@ancha-labs/cli 0.4.23 → 0.4.25

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.
@@ -195,3 +195,16 @@ ancha runs show '#412' --json
195
195
  The JSON keeps the full run id alongside `runNumber`. A retry with the same idempotency key and a repeated upload keep the run's number. Historical runs keep their short ids.
196
196
 
197
197
  **Started by** shows the signed-in person's email for console submissions, or the API key owner's email with **CLI**. In GitHub Actions, the CLI records **GitHub Actions**, the repository and a link to the workflow run from `GITHUB_ACTIONS`, `GITHUB_REPOSITORY`, `GITHUB_RUN_ID` and `GITHUB_SERVER_URL`.
198
+
199
+ ## Edit a test in the console
200
+
201
+ On a test's page, **Edit** opens its YAML from the selected cloud run. **Save and run x5** validates the test and starts five attempts with that edit and the same agent bundle. The edit belongs to the new run. Its Details show **Edited in console** and a YAML download.
202
+
203
+ Bring the edited file into your project:
204
+
205
+ ```sh
206
+ ancha test pull <run-id> --json
207
+ ancha test pull <run-id> --test <name> --json
208
+ ```
209
+
210
+ The command writes the test to its original project path. If your local file changed since the bundle was uploaded, keep your changes or add `--force` to replace it. Run `ancha test validate <path> --json` to check the saved file with the project's world data. Console edits accept up to 64 KiB of UTF-8 YAML and keep the test's `id`.
@@ -32,7 +32,7 @@ A version 2 test names a world (`ancha/worlds/<id>.yaml`: the company, its peopl
32
32
  ```
33
33
 
34
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.
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. `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:
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
38
38
  {"id": "approve-bf-2207", "question": "Approve the Bluefield Logistics bill BF-2207.", "records": [{"type": "vendorBill", "externalId": "BF-2207", "fields": {"approvalStatus": {"id": "2"}}}]}
@@ -42,9 +42,33 @@ 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
+ ## NetSuite state checks
46
+
47
+ Combine approval, protection of other records, and preservation of the target bill:
48
+
49
+ ```yaml
50
+ checks:
51
+ - id: approved
52
+ state:
53
+ netsuite.record: { type: vendorBill, id: 1011, fields: { approvalStatus: { id: "2" } } }
54
+ - id: other-bills
55
+ state:
56
+ netsuite.unchanged: { types: [vendorBill], except: [{ type: vendorBill, id: 1011 }] }
57
+ - id: bill-preserved
58
+ state:
59
+ netsuite.preserved:
60
+ type: vendorBill
61
+ id: 1011
62
+ except_fields: [approvalStatus, status, lastModifiedDate]
63
+ ```
64
+
65
+ `netsuite.preserved` compares the record after seeding with the record at grading, removing only the listed top-level fields. Every remaining field and sublist compares deeply and exactly. Added fields, missing fields and a deleted record fail. A failure names each changed field with its before and after values, such as `memo: "Contract review" -> "Changed memo"`. Use `except_fields: []` to preserve every field.
66
+
67
+ `netsuite.unchanged` checks committed writes, including writes later reversed; its `except` names whole records. For duplicate refusal, use `netsuite.unchanged` with no exception to require no writes. `ancha twins seed netsuite` prints the seed and check examples.
68
+
45
69
  ## Checks on the final answer
46
70
 
47
- An `answer` check reads the agent's final answer: what it posts to `ANCHA_DONE_URL` as `{"output": …}` (`entry()` in `@ancha-labs/tools` posts what the agent returns), else an HTTP agent's reply, else what it prints on stdout (its logs go to stderr); `agent.answer` in `ancha.yaml` picks one. A JSON answer is read as `key: value` lines. Ancha grades it with no model, on this computer and in the cloud, so it uses no model credit.
71
+ An `answer` check reads the agent's final answer: what it posts to `ANCHA_DONE_URL` as `{"output": …}` (`entry()` in `@ancha-labs/tools` posts what the agent returns), else an HTTP agent's reply, else what it prints on stdout (its logs go to stderr); `agent.answer` in `ancha.yaml` picks one. Text and number checks read a JSON answer as `key: value` lines; `rows` checks read the original object or parse a JSON string. Ancha grades it with no model, on this computer and in the cloud, so it uses no model credit.
48
72
 
49
73
  ```yaml
50
74
  checks:
@@ -59,6 +83,21 @@ checks:
59
83
  - 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`.
60
84
  - An attempt with no final answer fails the check with "no final answer". `answer: {}` passes on any final answer.
61
85
  - `trace: { called: "MCP <tool name>" }` checks a call to a tool on an MCP server, such as `MCP ns_runCustomSuiteQL` on NetSuite.
86
+ - **GraphQL mutations.** `trace: { called: "MUTATION issueUpdate" }` checks the executed root mutation, including aliases and fragments. Use `MUTATION inventoryAdjustQuantities` for a Shopify stock adjustment. Successful mutation responses satisfy `called`; `status: any` counts attempted mutations, and `not_called` forbids attempts.
87
+
88
+ Use `rows` to check every row in a structured answer:
89
+
90
+ ```yaml
91
+ checks:
92
+ - id: duplicate-pairs
93
+ answer:
94
+ rows:
95
+ field: pairs
96
+ expected:
97
+ - { bill_1: 70101, bill_2: 70102, vendor_id: 6015, amount_minor: 1744400, currency: USD }
98
+ ```
99
+
100
+ Ask the agent to return `{"pairs": [...]}` with the named columns. Rows compare as an unordered multiset: every column, value and occurrence must match exactly. Column order is free. Values are JSON strings, numbers, booleans or null; their types and string case must match. `amount_minor` is a safe integer in minor units and requires an explicit three-letter uppercase `currency`. An empty `expected: []` checks for an empty array. Use `rows` on its own, separately from `contains`, `not_contains`, `numbers` and `case`. A malformed answer reports an answer-format failure; incorrect rows list the missing and unexpected rows. Eval imports accept the same `rows: {field, expected}` field and carry it into the answer check.
62
101
 
63
102
  ## Tests from a template
64
103
 
@@ -66,6 +105,8 @@ checks:
66
105
 
67
106
  ## Seeds
68
107
 
108
+ The catalog examples pair their starting records with required job checks. State checks verify the result of a write; trace checks name the task’s write operation. Gong, GA4 and Open-Meteo examples check the requested read and the final answer.
109
+
69
110
  `ancha twins seed <tool>` prints what `seed.<tool>` takes: the fields with their types and defaults, an example cut from the tool's starter data that validates as written, the state checks and scripted events a test can use on the tool, the variables the agent gets and the SDK settings. `--json` prints the same as data (the fields as JSON Schema); `--full` uses the complete starter data as the example. A test whose seed has an unknown, missing or mistyped field fails validation with a hint that names this command.
70
111
 
71
112
  Validate with `ancha scene validate scenes/my-scene/scene.yaml --json`. Reference checks: run `ancha run scenes/my-scene/scene.yaml --agent "node scenes/my-scene/oracle.mjs" -n 1 --parallel 1 --json` and repeat with null.mjs. Oracle should pass; null should exit cleanly while business checks fail. Test validity, business outcome and process completion independently. The starter checks read access; replace its task and trace checks with your own business checks.
@@ -94,6 +135,80 @@ All supplied filters match the same record. Choose `count_eq` for an exact count
94
135
 
95
136
  Jira issues accept `issue`, `project`, `type`, `summary_contains`, `description_contains`, `labels`, `assignee`, `status` and `parent` (an epic for standard issues). Use `assignee: null` for unassigned issues and `parent: null` for no parent. Comments accept `issue`, `author` and `text_contains`; transitions accept `issue`, `from`, `to` and `author`. Text containment accepts a string or an all-required list and ignores case. Issue refs (`$issue.ops_slow`) and user refs (`$user.rachel`) belong to `seed.jira`; native issue keys and account ids also work.
96
137
 
97
- PayPal orders accept `id`, `status`, `intent`, `payer_email`, `description_contains`, `invoice_id`, `currency`, `total`, `tax` and `items`. Invoice checks accept `id`, `status`, `recipient`, `currency`, `total`, `tax`, `sent` and `items`. Items have an exact `name` and optional `quantity` and `unit_amount`; invoice items also accept `tax_percent` and computed line `tax`. Quote amounts and quantities as decimal strings. Each requested item matches a distinct item; extra items are allowed. Payment checks accept `id`, `order`, `status`, `payer_email`, `invoice_id`, `currency`, `amount` and `refunded`. Order `id` and payment `order` can name a seed order as `$order.ref`.
138
+ PayPal orders accept `id`, `status`, `intent`, `payer_email`, `description_contains`, `invoice_id`, `currency`, `total`, `tax` and `items`. Invoice checks accept `id`, `status`, `recipient`, `currency`, `total`, `tax`, `sent` and `items`. Items have an exact `name` and optional `quantity` and `unit_amount`; order items accept per-unit `tax`, and invoice items accept `tax_percent` and computed line `tax`. Quote amounts and quantities as decimal strings. Each requested item matches a distinct item; extra items are allowed. Payment checks accept `id`, `order`, `status`, `payer_email`, `invoice_id`, `currency`, `amount` and `refunded`. Order `id` and payment `order` can name a seed order as `$order.ref`.
98
139
 
99
140
  Invoice item tax is computed on quantity × unit amount after item discount, rounded to cents. For 1.5 units at $120.00, a 10% item discount and 50% tax, the item tax is $81.00. Invoice responses include each item's computed `tax.amount`, and captured checks compare it directly. `ancha explain --json` shows expected filters and actual records with their amounts and statuses.
141
+
142
+ PayPal order responses retain each item's `tax` (Money), `description`, `url`, `image_url` and `upc` on create, GET and capture. Item tax uses the purchase unit's currency. When any item specifies `tax`, `amount.breakdown.tax_total` is required and equals the sum of item tax × quantity; PayPal returns `TAX_TOTAL_REQUIRED` or `TAX_TOTAL_MISMATCH` with status 422 when this rule is violated. Order state checks compare each item's per-unit tax as a decimal string, for example `items: [{ name: Review, quantity: "2", tax: "1.23" }]`.
143
+
144
+ ## Stripe state checks
145
+
146
+ Customer cards accept `fingerprint` to identify the same card across customer records. Customer `cash_balance` seeds set `available` amounts by currency and a `reconciliation_mode`. Optional `credit_notes` seed paid-invoice credits by `invoice`, `amount` and `created`; optional `disputes` seed card inquiries by `payment` and `created`, with `warning_needs_response`, `warning_under_review` or `warning_closed` status. Credit notes add customer balance transactions, and API changes appear in `/v1/events`.
147
+
148
+ Stripe worlds default to a live account (`livemode: true`) with a stored card for each seeded customer. Payments using that card share its payment method ID and fingerprint. Supply `customers[].card` to choose the brand, last four digits, expiration and decline behavior. Set `seed.stripe.livemode: false` for a test account with Stripe test tokens such as `pm_card_visa`.
149
+
150
+ ```yaml
151
+ checks:
152
+ - id: duplicate_refunded
153
+ state: { stripe.refunds: { charge: $summit_duplicate, count: 1, amount: 120000 } }
154
+ - id: deposit_preserved
155
+ state: { stripe.refunds: { payment_intent: $pinecrest_deposit, count: 0, amount: 0 } }
156
+ - id: customer_balance
157
+ state: { stripe.balance: { customer: $pinecrest, balance: 0 } }
158
+ - id: subscription_preserved
159
+ state: { stripe.unchanged: { objects: [{ type: subscription, id: $pinecrest_seats }] } }
160
+ ```
161
+
162
+ `stripe.refunds` selects exactly one `charge` or `payment_intent` and compares successful refunds against an exact `count`, summed `amount`, or both. Amounts are integer minor units: `120000` is $1,200.00 USD. Seeded history is included; `after_start: true` selects refunds created at or after the attempt's start time. A missing payment fails even when the expected count is zero.
163
+
164
+ `stripe.balance` compares the named customer's balance: negative for credit, positive for debt. `stripe.unchanged` compares every native field of each named object with its state after seeding. Objects must exist both at seeding and evaluation; deletion fails. This checks final state, so restoring all original field values passes. Types are `customer`, `payment_method`, `product`, `price`, `subscription`, `invoice`, `invoiceitem`, `payment_intent`, `charge` and `refund`.
165
+
166
+ Use a native Stripe ID or a tool-local `$ref` (also `$type.ref`). Payment and paid-invoice refs identify their charge or PaymentIntent; customer refs identify customers or their stored payment methods. Other refs identify their seeded object type; invoice items use native IDs. `ancha twins seed stripe --json` prints validated examples. `ancha explain --json` reports the expected and actual state for each check.
167
+
168
+ ## Zendesk ticket checks
169
+
170
+ Use `zendesk.ticket` to check one ticket by numeric `id` or exact `subject`. All supplied conditions apply to that ticket. A subject identifies exactly one ticket; use its `id` when subjects repeat.
171
+
172
+ ```yaml
173
+ checks:
174
+ - id: export_resolved
175
+ state:
176
+ zendesk.ticket:
177
+ subject: CSV export times out for large files
178
+ status: solved
179
+ tags: { has: [export_fixed], lacks: [legal_hold] }
180
+ assignee: mike@acme.example
181
+ priority: high
182
+ group: Support
183
+ public_comment: { contains: Try the export again }
184
+ - id: hold_preserved
185
+ state:
186
+ zendesk.ticket:
187
+ subject: Audit log export for Q2
188
+ status_not_in: [solved, closed]
189
+ - id: other_customer_kept
190
+ state:
191
+ zendesk.unchanged:
192
+ tickets: [{ subject: Invoice copy request }]
193
+ ```
194
+
195
+ Choose `status` for one value, `status_in` for any listed value, or `status_not_in` to exclude listed values. `tags.has` requires every listed tag; `tags.lacks` excludes every listed tag. `assignee` accepts an email, numeric user id or `null`; `group` accepts a name, numeric group id or `null`; `priority: null` checks an unset priority.
196
+
197
+ `public_comment: true` requires a public comment added during the attempt. `public_comment: { contains: "text" }` also requires that exact, case-sensitive text in the new comment. Seeded comments are starting history, including those at `start_time`.
198
+
199
+ `zendesk.unchanged` requires each named ticket to exist and keep its state throughout the attempt. It checks committed audits and deletion, so a change followed by a reversal still fails. Subjects identify the original tickets even if the agent renames them. Failed requests and updates that change no fields leave this check passing.
200
+
201
+ `ancha twins seed zendesk --json` includes both check examples. Organization seeds accept `externalId`; `brands` accepts `name`, `subdomain`, `default`, `active` and `created`, with exactly one active default brand. When `brands` is omitted, the world's account supplies its default brand. Organization search matches an exact name or external id; autocomplete returns up to ten name-prefix matches. Ticket search accepts `organization_id`, `requester_id`, `assignee_id` and `group_id`, and `order_by:updated_at` orders results by update time.
202
+
203
+ ## Edit a test in the console
204
+
205
+ On a test's page, **Edit** opens its YAML from the selected cloud run. **Save and run x5** validates the test and starts five attempts with that edit and the same agent bundle. The edit belongs to the new run. Its Details show **Edited in console** and a YAML download.
206
+
207
+ Bring the edited file into your project:
208
+
209
+ ```sh
210
+ ancha test pull <run-id> --json
211
+ ancha test pull <run-id> --test <name> --json
212
+ ```
213
+
214
+ The command writes the test to its original project path. If your local file changed since the bundle was uploaded, keep your changes or add `--force` to replace it. Run `ancha test validate <path> --json` to check the saved file with the project's world data. Console edits accept up to 64 KiB of UTF-8 YAML and keep the test's `id`.