@ancha-labs/cli 0.4.25 → 0.4.27

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.
@@ -20,6 +20,8 @@ agent:
20
20
 
21
21
  Point both the Bolt Web API client and its Socket Mode client's API URL at `SLACK_API_URL`; `ancha connect slack` prints SDK settings. The connection check passes when the app opens its WebSocket. Each test's Slack trigger arrives as a native Slack event, including its Socket Mode envelope and acknowledgement.
22
22
 
23
+ A Socket Mode attempt ends with `idle` when the app goes quiet after its events are acknowledged and scheduled world work is complete. `agent.idle` sets the quiet window in real time, independent of `time_scale`: `30s` by default for cloud attempts through the model gateway, `2m` for local processes. Model requests through the attempt's gateway keep it active through the entire response stream; the quiet window starts again when they finish. Set `agent.idle` longer than the longest quiet stretch of work in your app, including model calls made directly from a local process.
24
+
23
25
  For the HTTP Events API:
24
26
 
25
27
  ```yaml
@@ -9,7 +9,7 @@ Otherwise it reports, in order:
9
9
  - harness issues: a part of Ancha that failed, which makes the trial invalid rather than a failure of the agent;
10
10
  - agents that crashed or timed out, with the end of `agent.log`, and, when it names a variable this shell has but the agent didn't get (`missing OPENROUTER_API_KEY`), the `--pass-env` that passes it;
11
11
  - each failed check: what was expected, what happened, and the agent's calls and world events behind it. For message and people checks it also shows what the world recorded: the messages that came closest, decisions and what people learned (each at its simulated time, such as `+3m`), the conversation around them, and what each person the check names knew and decided;
12
- - coverage gaps, with or without `--strict`: "the agent called POST /api/chat.scheduleMessage, which the slack twin doesn't implement; it answered unknown_method". The agent's call may be right; check `ancha twins coverage <tool>` before changing it;
12
+ - coverage gaps, with or without `--strict`: "the agent called POST /api/reminders.add, which the slack twin doesn't implement; it answered unknown_method". The agent's call may be right; check `ancha twins coverage <tool>` before changing it;
13
13
  - when the agent ran on this computer and no crash named a variable, how many of this shell's variables were withheld from it. If it needs one, such as a provider key, pass it with `--pass-env NAME` or `agent.pass_env`.
14
14
 
15
15
  JSON keys: `runId`, `agentNeverRan` when the agent never ran (`attempts`, `tests`, `exit`, `exitCode`, `ms`, `logTail`, `log` on this computer, `fix`, `checksFailed`), `agentIssues` (each with `exit`, `exitCode`, `log`, `logTail`, and a `hint` when its log names a withheld variable), `harnessIssues`, `failures` (each with `check`, `expected`, `actual`, `explanation`, `traceExcerpt`, and when the world recorded them `kind`, `evidence` (each with `type`, `simAt`, `at`, `from`, `to`, `where`, `excerpt`), `conversation` and `people`), `coverageGaps` (each with `service`, `method`, `path`, `count`, the twin's `status` and `error`, and a `hint`), `agentEnvironment` (`target`, and for this computer `inherited`, `withheld` and `withheldInLogs`, the withheld variables a crashed agent's log names), and `gradingWarnings` when a check produced one.
@@ -112,3 +112,5 @@ ancha runs show '#412' --json
112
112
  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.
113
113
 
114
114
  **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`.
115
+
116
+ Function tool evidence in the summary JSON and `ancha explain --json` lists each logical call's arguments, outcome, error type, answer source and evidence seqs. Explain text shows function tool evidence that needs attention after the trial diagnosis and failed checks. `ancha doctor` reports registration independently from call counts. `ancha attempt show --json` includes the same `functionTools` projection; the console expands each call's detailed payload from its summary.
@@ -66,6 +66,26 @@ checks:
66
66
 
67
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
68
 
69
+ ## Checks on tool calls
70
+
71
+ `tool_call` checks named function tools, MCP tools and `tools.run` calls by their exact tool name. It matches arguments, completion status and results, then counts matching logical calls. A completion updates its original call.
72
+
73
+ ```yaml
74
+ - id: calendar_is_busy
75
+ tool_call:
76
+ name: check_calendar_availability
77
+ args: {contains: {start: "2026-11-18T10:00:00Z"}}
78
+ status: succeeded
79
+ result: {contains: {available: false}}
80
+ count: {eq: 1}
81
+ ```
82
+
83
+ `args` and `result` each take exactly one of `equals` or `contains`. Scalars compare by JSON type: `"1"` differs from `1`. `contains` matches object fields recursively; arrays compare in full, including order and object fields. `equals` compares the complete value, with object key order ignored.
84
+
85
+ `status` is `attempted`, `succeeded` (the default), or `failed`. A failed call can match `error: {type: RangeError}`. `count` takes `eq`, or `gte` and/or `lte`; the default is `gte: 1`. For example, `count: {eq: 0}` verifies that no calls match the other predicates.
86
+
87
+ Include the check ID in `pass` to require it (by default, every check is required). Connect required function tools with `ancha.wrap_tools` and `ancha.entry`, or JavaScript `wrapTools` and `entry`. Registration and completion evidence establish whether the attempt can be graded. `ancha explain` and the console show expected values, actual differences and links to the closest call's evidence.
88
+
69
89
  ## Checks on the final answer
70
90
 
71
91
  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.
@@ -2,6 +2,33 @@
2
2
 
3
3
  A run of the agent in production becomes a test: the conversation it had, the calls it made with their answers, and how it ended. Runs that went fine and runs that failed both make tests, one per conversation.
4
4
 
5
+ ## Import traces or evals
6
+
7
+ `ancha test import <file> --format auto|trace|eval --on local` writes tests under `ancha/tests/` (`--out <dir>` chooses the root). `auto` routes OTLP JSON, Ancha Trace IR, LangSmith runs and Langfuse observations to trace import. Eval datasets, including LangSmith `inputs`/`outputs` examples, use the eval importer and its `--world` selection. When a file has both readings, the command returns `USAGE` and asks for `--format trace` or `--format eval`. Use `--world` with eval imports; trace imports rebuild their world from the recorded calls.
8
+
9
+ For each function, import reports executed spans, model-requested calls and model-reported results, scoped by trace and call ID. The report lists duplicate, missing-ID, conflicting and out-of-order evidence. Executed evidence determines the recorded fixture when both executed and reported evidence exist. `--use-reported-results` selects paired reported results as fixtures with `origin: reported`.
10
+
11
+ `observations.jsonl` includes `format_version: 1`, origin, trace and original span/call IDs, and separate argument/result capture states: `complete`, `not_captured`, `truncated` and `unserializable`. JSON `null` is a complete value. Credentials are redacted before files are written. Replay requires complete, unambiguous captured arguments and outcomes.
12
+
13
+ Import writes reviewable observed-call candidates to `candidates.json` and `provenance.json`. Each candidate includes its trace, arguments and a proposed check. Put the checks you choose in a YAML or JSON list and pass `--checks <file>` to add them to the test's `checks` and `pass`. Candidates remain optional until selected. Object arguments appear in the proposed trace pattern; other JSON argument values remain in the candidate's `args` for review. For example:
14
+
15
+ ```yaml
16
+ - id: draft-for-ben
17
+ trace:
18
+ called: 'write_email {to: ben@example.com}'
19
+ ```
20
+
21
+ ```sh
22
+ ancha test import email-trace.json --format trace --checks checks.yaml --on local --json
23
+ ancha import email-trace.json --offline --checks checks.yaml --on local
24
+ ```
25
+
26
+ `--expect` adds the stated production failure as a judge check. `--answer checks.success="<required end state>"` defines the successful outcome. Both stay alongside selected checks.
27
+
28
+ New imports set `tools.<name>.exhausted: repeat_last` for reads: repeated calls reuse the last matching fixture. Writes use `exhausted: fail`: a call beyond its matching fixtures returns a tool error. Scenes that omit `exhausted` retain their existing behavior. Reads with no matching fixture can reuse an exact-argument answer from another trace; the example names its source trace. Borrowed examples have complete argument and result capture and are replayable. Reported examples require `--use-reported-results`. A function-only test uses `twins: []`, `seed: {}`, `tools`, `trigger` and `checks` together with its scene identity and clock.
29
+
30
+ With `--json`, local trace import includes `workspace`, detected `format`, `evidence`, `candidates`, `required_checks` and connection commands. Multi-conversation imports place evidence and checks on each entry in `scenes`.
31
+
5
32
  ## Make the tests
6
33
 
7
34
  - After `ancha login`, `ancha traces upload <file|folder|glob>...` sends traces to the workspace, which makes a test from each and writes it here, under `scenes/from-traces/`. A file is OTLP JSON, a Langfuse or LangSmith export, or Ancha Trace IR; a folder is searched for `.json` and `.jsonl` files. A trace that makes no test is listed with the reason, and the upload goes on with the rest.
@@ -100,4 +127,14 @@ When a test doesn't fail the way production did, `ancha traces diff <trace file>
100
127
 
101
128
  `ancha runs export <run> --json` writes one IR trace per attempt, including the saved task, agent identity, test definition, outcome and check evidence. Reimporting uses those saved criteria and production verdicts.
102
129
 
103
- With `--json`, `traces` returns `{traces, next}`, `traces show` returns `{trace, test, preview, next}`, and `traces diff` returns `{production, attempt, scope, onlyInProduction, onlyInAttempt, firstDifference, next}`. Offline import returns `{scene, checks, summary, questions, setup, next}` for one conversation, or `{scenes, questions, skipped, next}` for several. Each imported scene's `checks` lists its check IDs, whether they are required, and their production verdicts. Hosted import emits one result object per saved test and a `trace_skipped` event for each skipped trace. Pull returns `{world, name, version, checks, summary, questions, scene, kept, next}`; `pull --all` returns `{written, skipped, next}`. Export returns `{runId, files, next}`. `--limit` takes a positive safe integer; for example, `ancha traces --limit 5 --json`.
130
+ With `--json`, `traces` returns `{traces, next}`, `traces show` returns `{trace, test, preview, next}`, and `traces diff` returns `{production, attempt, scope, onlyInProduction, onlyInAttempt, firstDifference, next}`. Offline import returns `{workspace, format, scene, evidence, candidates, required_checks, checks, summary, questions, setup, next}` for one conversation, or `{scenes, questions, skipped, next}` for several. Each imported scene's `checks` lists its check IDs, whether they are required, and their production verdicts. Hosted import emits one result object per saved test and a `trace_skipped` event for each skipped trace. Pull returns `{world, name, version, checks, summary, questions, scene, kept, next}`; `pull --all` returns `{written, skipped, next}`. Export returns `{runId, files, next}`. `--limit` takes a positive safe integer; for example, `ancha traces --limit 5 --json`.
131
+
132
+ ### Function tool evidence
133
+
134
+ `ancha doctor --json` includes `functionTools`: each tool's registration, protocol version, and pending and completed call counts. Registration is recorded independently of whether the task calls the tool.
135
+
136
+ The run summary JSON, `ancha explain --json`, `ancha attempt show`, and console attempt pages show one logical function call per `call_id`, with its arguments, outcome (`succeeded`, `failed`, `pending`, or `unknown`), error type, answer source and evidence sequence numbers. Recorded responses and real function execution have distinct source labels. Completion evidence joins the original call. JSON preserves these facts in `functionTools.tools` and `functionTools.calls`; each call includes `seq` and `evidence`, plus `completion` when captured. Historical evidence uses `unknown` for facts it did not record. Explain text places function tool evidence that needs attention after the trial diagnosis and failed checks. The console attempt page shows compact tool rows below Steps.
137
+
138
+ The console's Steps and Calls show summaries; expand a call to inspect its arguments and response. The attempt page lists each function tool below its Steps, one line per tool: registered or not, its calls, and any pending or unknown ones. Production trace pages use the same outcome and evidence presentation; source is `unknown` when the recording does not establish how the answer was produced.
139
+
140
+ Trace import prints Python `ancha.wrap_tools` / `ancha.entry` and JavaScript `wrapTools` / `entry` examples using the tests' required function names. Bind the named entries to your existing functions and pass the wrapped tools to your agent framework.