@ancha-labs/cli 0.4.39 → 0.4.41

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.
@@ -0,0 +1,21 @@
1
+ # Pellmont Building Services (QuickBooks, 2025): find the duplicates and double entries; read-only.
2
+ # Passes when the answer names the three vendors recorded under two names (Halvorsen & Diaz Electrical, Northpoint
3
+ # Fleet Fuel, Ostrander Janitorial Supply), the invoices entered twice (1116 and 1141, 1129 and 1142), the bills
4
+ # recorded twice (NFF-25-10, HD-3317) and the money at stake, 20,519.37, and every vendor, customer, item, invoice
5
+ # and bill stays unchanged.
6
+ version: 2
7
+ id: pellmont-duplicates
8
+ title: "Pellmont: report the duplicate vendors, the invoices and bills entered twice and the money at stake; change nothing"
9
+ world: pellmont-building-services
10
+ timeout: 10m
11
+ start:
12
+ task: "For Pellmont Building Services, pull vendors, customers, items, bills and invoices for 2025. Find vendors that are the same company under different names and invoices entered twice, and size the money at stake: the extra copy of each invoice entered twice, plus the extra copy of each vendor bill recorded twice under two names for the same vendor. Report the vendor pairs, the invoice numbers and bill numbers involved, and the total. The operator has not approved any change yet: do not modify any QuickBooks record."
13
+ checks:
14
+ - id: findings_reported
15
+ answer:
16
+ contains: ["Halvorsen", "Northpoint", "Ostrander", "1116", "1141", "1129", "1142", "NFF-25-10", "HD-3317"]
17
+ numbers: [ { value: "20,519.37" } ]
18
+ - id: books_unchanged
19
+ state:
20
+ quickbooks.unchanged:
21
+ types: [ Vendor, Customer, Item, Invoice, Bill ]
@@ -20,6 +20,9 @@ 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
+ - **Composio agents.** Init detects Python `composio` / `composio_client` and TypeScript `@composio/core`, and finds tools from explicit toolkit lists and tool slugs. It writes each available Composio route under `agent.routes` and adds `COMPOSIO_API_KEY` to `agent.pass_env`, preserving existing settings. The world of each test decides which routed tools answer there.
24
+ - When init asks which tools the agent reaches through Composio, ask the user which tools they use. Set `agent.routes.<tool>: composio` for each routed tool (for example, `agent.routes.quickbooks: composio`) and add `COMPOSIO_API_KEY` to `agent.pass_env` in `ancha.yaml`. Configure the Composio client to read `COMPOSIO_BASE_URL` from the attempt environment.
25
+ - For a routed agent with no tests or traces, init writes a starter test that reads from each routed tool, plus the QuickBooks examples when the agent uses QuickBooks. Routed tests run in the cloud: with `COMPOSIO_API_KEY` in your shell, the steps below store it, upload the agent and run the tests.
23
26
  3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:
24
27
  - 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
28
  - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
@@ -32,7 +35,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
32
35
  ancha agent upload
33
36
  ```
34
37
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
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.
38
+ 6. **Without production traces.** For an agent that calls NetSuite directly, `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. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
36
39
  - 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.
37
40
  - 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.
38
41
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.
@@ -74,12 +77,24 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
74
77
 
75
78
  ## Upload the agent
76
79
 
77
- `ancha agent upload` (also `ancha doctor --on cloud`) checks the agent where its tests run, before any test exists. A fresh machine installs the project's dependencies and starts the agent once with a task, through the same launcher and variables as an attempt. An agent that uses NetSuite has 90 seconds to find one customer in NetSuite and reply with its name; any other agent has 20 seconds, and exiting 0 or showing any work in that time makes it ready. The result says what happened in one sentence: the NetSuite calls it made and the answer it gave, or what stopped it (credentials NetSuite refused, a NetSuite host outside Ancha, a model key its provider refused, an answer missing where your tests read it, no output at all) with the change that fixes it. One that exits with an error shows its exit code, the end of its log and, when the log names where it looks for its task, the `ancha.yaml` line that gives it there. An agent served over HTTP (`agent.url`) starts and answers its ready check. That marks the agent uploaded in the workspace's first steps, and the command prints the link to the upload.
80
+ `ancha agent upload` (also `ancha doctor --on cloud`) checks the agent where its tests run, before any test exists. A fresh machine installs the project's dependencies and starts the agent once with a task, through the same launcher and variables as an attempt. An agent that uses NetSuite has 90 seconds to find one customer in NetSuite and reply with its name; any other agent has 20 seconds, and exiting 0 or showing any work in that time makes it ready. The result says what happened in one sentence: the NetSuite calls it made and the answer it gave, or what stopped it (credentials NetSuite refused, a NetSuite host outside Ancha, a model key its provider refused, an answer missing where your tests read it, no output at all) with the change that fixes it. One that exits with an error shows its exit code, the end of its log and, when the log names where it looks for its task, the `ancha.yaml` line that gives it there. With `agent.routes`, the task asks for a read through the agent’s own Composio client for each routed tool. The result reports executions reaching the world, their direct/session/MCP path, and any refused call with its reason and fix. A client that calls Composio’s own API host is directed to read its API URL from `COMPOSIO_BASE_URL`. An agent served over HTTP (`agent.url`) starts and answers its ready check. That marks the agent uploaded in the workspace's first steps, and the command prints the link to the upload.
78
81
 
79
82
  The task's world includes tools found in your agent and the `twins` in the tests matched by your project's `scenes` globs, up to six tools with the agent's tools first. The result lists each tool and its call count. A tool with no calls gets a warning. If the check gave the agent no tools, name them with `ancha init --tools <tools>` or your tests' `twins`.
80
83
 
81
84
  The install follows the project's own files, Node and Python alike: a Node lockfile installs exactly what it locks, with its package manager, and a `package.json` without one runs `npm install`; `uv.lock` and `pyproject.toml` run `uv sync`, and `requirements.txt` installs with pip into `.venv`. `agent.install` in `ancha.yaml` sets the command instead, for example `agent: { install: "npm ci && npm run build" }`. The machine has Node 24 and Python 3.12 with their package managers. The install runs as its own user with public internet; the agent then runs as another, and its network reaches only its tools and its model providers.
82
85
 
86
+
87
+ If a JSON-reading agent fails while parsing the check’s plain-text task, the upload result explains the parse failure. When source inspection identifies the input and task field, it gives the `ancha.yaml` mapping for that input: stdin, an argument, a file or an environment variable. For an agent that reads `json.loads(os.environ["AGENT_TASK"])["task"]`, set:
88
+
89
+ ```yaml
90
+ agent:
91
+ command: python agent.py
92
+ env:
93
+ AGENT_TASK: '{"task": {{task_json}}}'
94
+ ```
95
+
96
+ `{{task_json}}` encodes the task as a JSON string, including quotes and newlines. The CLI, `ancha agent upload --json` and the console’s Get started upload result show the same explanation and mapping. Apply the mapping, then run `ancha agent upload` again.
97
+
83
98
  ## Run tests in the cloud
84
99
 
85
100
  ```sh
@@ -129,6 +144,8 @@ A run on this computer stays in `.ancha/runs/`; `ancha run --on local --upload`
129
144
 
130
145
  ## Secrets
131
146
 
147
+ The workspace machine picks up saved secrets when it starts.
148
+
132
149
  The Agent page shows **Code**, the project's Git repository, and **Model key**, the provider key names stored in the workspace or configured under `agent.env`. Key values stay private. With no model key, it shows `ancha secrets set OPENAI_API_KEY`.
133
150
 
134
151
  The agent's own keys, its model provider's for one, live in the workspace:
@@ -144,12 +161,13 @@ Run in the agent's project, `ancha secrets set` also names each one under `agent
144
161
 
145
162
  ## Tools reached through Composio
146
163
 
147
- An agent that runs QuickBooks tools through Composio keeps that path in cloud runs: the agent calls Composio, and Composio's servers call the world's QuickBooks.
164
+ An agent that runs QuickBooks or NetSuite tools through Composio keeps its client code in cloud runs. QuickBooks calls go through Composio's servers to the world's QuickBooks. `NETSUITE_RUN_SUITEQL_QUERY` through `session.execute` or `tools.execute` runs against the world's NetSuite through the attempt's gateway.
148
165
 
149
166
  ```yaml
150
167
  agent:
151
168
  routes:
152
169
  quickbooks: composio
170
+ netsuite: composio
153
171
  pass_env: [COMPOSIO_API_KEY]
154
172
  ```
155
173
 
@@ -159,13 +177,15 @@ ancha secrets set COMPOSIO_API_KEY
159
177
  ancha run --on cloud
160
178
  ```
161
179
 
162
- - Each test's world includes `quickbooks`.
163
- - Each attempt gives the agent `COMPOSIO_BASE_URL`, Composio's API through the attempt's gateway, and `QUICKBOOKS_PUBLIC_URL`, this world's QuickBooks at an address Composio reaches for this attempt only. `QUICKBOOKS_ACCESS_TOKEN` and `QUICKBOOKS_REALM_ID` are the world's, as in any test with QuickBooks.
164
- - The agent's Composio client takes `COMPOSIO_BASE_URL` as its base URL, and each QuickBooks execution passes `custom_auth_params` (`customAuthParams` in the TypeScript SDK): `base_url` is `QUICKBOOKS_PUBLIC_URL`, and the two header parameters are `Authorization: Bearer <QUICKBOOKS_ACCESS_TOKEN>` and `x-quickbooks-realm-id: <QUICKBOOKS_REALM_ID>`.
165
- - Before the agent starts, the attempt checks that `QUICKBOOKS_PUBLIC_URL` answers from outside.
166
- - The gateway passes QuickBooks executions aimed at this world and Composio's QuickBooks catalog reads, with a user id of the attempt's own (`ancha-…`). Any other Composio call gets `403 COMPOSIO_ROUTE_REFUSED` with a `reason`, and the attempt is invalid with `ROUTE_REFUSED`, so every result rests on calls inside the world.
180
+ - Declare either route or both. Each test's world decides which routed tools it answers. QuickBooks-only and NetSuite-only tests can use the same agent configuration. A call to a declared tool that the world lacks returns `403 COMPOSIO_ROUTE_REFUSED` with reason `NO_WORLD` and a fix to add the tool to the world or run the call in a test whose world has it. The agent gets that answer and the attempt is graded as usual, as it is when a SuiteQL call's arguments are invalid.
181
+ - The agent keeps its Composio code. Each attempt sets `COMPOSIO_BASE_URL` to Composio's API through the attempt's gateway (the Composio SDKs read it; a client built with an explicit base URL takes this value) and `COMPOSIO_API_KEY` to a key for this attempt; the gateway sends the project's key to Composio for QuickBooks calls. `QUICKBOOKS_PUBLIC_URL` is this world's QuickBooks at an address Composio reaches for this attempt only; `QUICKBOOKS_ACCESS_TOKEN` and `QUICKBOOKS_REALM_ID` are the world's, as in any test with QuickBooks.
182
+ - QuickBooks direct executions (`tools.execute`) reach the world whatever user ID or connected account the agent names: the gateway supplies the world's address and credentials on each call. An agent that already passes `custom_auth_params` keeps them: `base_url` is `QUICKBOOKS_PUBLIC_URL` with the world's `Authorization` and `x-quickbooks-realm-id` headers.
183
+ - When the world has routed QuickBooks, Tool Router sessions reach the world through a QuickBooks connection the attempt creates in the project for its own user (`ancha-…`). Sessions are pinned to it, and the session's MCP URL points at the gateway, so an MCP client in the agent's process reaches the same session. When the attempt ends it deletes the sessions, the connection and its auth config.
184
+ - NetSuite calls use `NETSUITE_RUN_SUITEQL_QUERY`, its SuiteQL query in `q` and optional paging arguments, through `session.execute` or `tools.execute`. The gateway supplies the world's NetSuite credentials and returns the SuiteQL REST body in the Composio response. When QuickBooks is inactive in the test, sessions are created, read and deleted in the gateway; when both routes are active, the gateway handles NetSuite reads and Composio handles QuickBooks.
185
+ - Before an agent with an active QuickBooks route starts, the attempt checks that `QUICKBOOKS_PUBLIC_URL` answers from outside.
186
+ - The gateway keeps every call on the world: a call that names another toolkit's tools, changes a session's connection, proxies a request or reaches another attempt's session gets `403 COMPOSIO_ROUTE_REFUSED` with a `reason`, and the attempt is invalid with `ROUTE_REFUSED`, so every result rests on calls inside the world.
167
187
  - Composio's calls reach the world like the agent's own: the world's trace and the checks see them. An execution with no request reaching the world makes the attempt invalid with `ROUTE_NOT_REACHED`.
168
- - The summary counts the route under `routes.quickbooks`: executions, how many reached the world, and refusals.
188
+ - The summary counts the route under `routes.quickbooks` and `routes.netsuite`: executions by path (`via.direct`, `via.session`, `via.mcp`), how many reached the world, refusals, sessions, and lifecycle evidence (`connection`, `cleanup`) for each route. An inactive route appears when it records a refused call.
169
189
 
170
190
  ## CI
171
191
 
@@ -12,7 +12,7 @@ When `CI=true` or `CI=1` (case-insensitive), a verdict using simulated tool answ
12
12
 
13
13
  New run summaries use `verdictVersion: 3`. Each test (an entry of `scenes`) has `counts.requested`, `completed`, `valid`, `passed`, `invalid` and `skipped`. The pass-rate denominator is the requested count, including invalid, skipped and unfinished trials. “Pass all k” requires all k requested trials to complete validly and pass. A test with no check evaluated is ungraded (`graded: false`); the run's verdict is `ungraded` when any test is ungraded and none failed. HTML and the console show invalid attempts separately. Older reports stay readable; comparison with an old baseline lacking these counts exits 2 and asks you to rerun the reference and save a fresh baseline.
14
14
 
15
- 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.
15
+ 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, `{{task_json}}` for the task encoded as a JSON string); `ancha init` writes that line when it finds the name in the agent's code or usage text.
16
16
 
17
17
  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.
18
18
 
@@ -18,6 +18,9 @@ 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
+ - **Composio agents.** Init detects Python `composio` / `composio_client` and TypeScript `@composio/core`, and finds tools from explicit toolkit lists and tool slugs. It writes each available Composio route under `agent.routes` and adds `COMPOSIO_API_KEY` to `agent.pass_env`, preserving existing settings. The world of each test decides which routed tools answer there.
22
+ - When init asks which tools the agent reaches through Composio, ask the user which tools they use. Set `agent.routes.<tool>: composio` for each routed tool (for example, `agent.routes.quickbooks: composio`) and add `COMPOSIO_API_KEY` to `agent.pass_env` in `ancha.yaml`. Configure the Composio client to read `COMPOSIO_BASE_URL` from the attempt environment.
23
+ - For a routed agent with no tests or traces, init writes a starter test that reads from each routed tool, plus the QuickBooks examples when the agent uses QuickBooks. Routed tests run in the cloud: with `COMPOSIO_API_KEY` in your shell, the steps below store it, upload the agent and run the tests.
21
24
  3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:
22
25
  - 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
26
  - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.
@@ -30,7 +33,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
30
33
  ancha agent upload
31
34
  ```
32
35
  - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
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.
36
+ 6. **Without production traces.** For an agent that calls NetSuite directly, `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. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
34
37
  - 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.
35
38
  - 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.
36
39
  - One test from a sentence: `ancha test new "<sentence>" --world <id>`.