@ancha-labs/cli 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/ancha.mjs +1218 -936
- package/lib/assets/SKILL.md +1 -1
- package/lib/assets/docs/cloud.md +5 -1
- package/lib/assets/docs/compare.md +1 -1
- package/lib/assets/docs/explain.md +1 -1
- package/lib/assets/docs/run.md +8 -4
- package/lib/assets/docs/setup.md +1 -1
- package/lib/assets/harbor/companion.mjs +9 -5
- package/lib/assets/ui/app.js +802 -217
- package/lib/assets/ui/style.css +244 -1
- package/lib/worker.mjs +38 -17
- package/lib/world-server.mjs +9 -5
- package/package.json +1 -1
package/lib/assets/SKILL.md
CHANGED
|
@@ -116,7 +116,7 @@ The agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as
|
|
|
116
116
|
- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.
|
|
117
117
|
- Exit 2: usage, config, scene 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`.
|
|
118
118
|
- 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 doctor --on cloud --json` if it repeats.
|
|
119
|
-
- Exit 4, only with `--strict`:
|
|
119
|
+
- 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.
|
|
120
120
|
|
|
121
121
|
Read 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.
|
|
122
122
|
|
package/lib/assets/docs/cloud.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
`ancha run --on cloud` runs your tests in Ancha's cloud. Each attempt gets a fresh machine of its own: a fresh copy of your agent, fresh memory and fresh tool state, graded by the same engine as a run on your computer. The run lives in your workspace at https://app.ancha.io, so closing your laptop does not stop it, and the console and the CLI read the same result.
|
|
4
4
|
|
|
5
|
+
Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspace saved by `ancha login`, outside CI and with no `ANCHA_API_KEY` or server override. A run with local settings keeps the target in `ancha.yaml`: a process on this computer or its configured Docker container. Local settings include `--agent-url`, `--out`, `--pass-env`, `--inherit-env`, `--upload`, `--upload-required`, `ANCHA_UPLOAD=1`, container execution, Slack HTTP or Socket Mode transport, and an endpoint agent without `agent.start`. `--agent "<command>"` alone, without a config, runs on this computer. `--dry-run` checks here and starts nothing. Use `ancha run --on local` to choose this computer or `ancha run --on cloud` to choose the workspace explicitly.
|
|
6
|
+
|
|
7
|
+
`--local`, `--server-url`, `server.url` and `ANCHA_SERVER_URL` keep the configured agent target. CI uses `--on cloud` explicitly. Once cloud is chosen, a workspace error stops the command; its hint includes `ancha run --on local` to run on this computer.
|
|
8
|
+
|
|
5
9
|
## First steps
|
|
6
10
|
|
|
7
11
|
<!-- ancha:first-steps -->
|
|
@@ -80,7 +84,7 @@ ancha run --on cloud scenes/from-traces/<test>/scene.yaml --attempts 3 --concurr
|
|
|
80
84
|
- The agent gets Ancha's and the tools' variables, `agent.env`, and the workspace's secrets for the names in `agent.pass_env`, as they were when the run was accepted. Its model providers are `openrouter.ai`, `api.openai.com` and `api.anthropic.com`, or the ones `agent.execution.modelHosts` names.
|
|
81
85
|
- Model-graded checks and the people in a world run on the workspace's model credit, so a cloud run needs no `OPENROUTER_API_KEY`.
|
|
82
86
|
- `--agent`, `--seed`, `--strict`, `--min-pass-rate`, `--allow-unwrapped` and `--idempotency-key` mean what they mean on this computer. `--compare <baseline>` compares with a saved baseline: `ancha baseline save before --from <run id>`, fix the agent, then `--compare before`. A cloud run's keys come from the workspace, so `--pass-env` and `--inherit-env` belong to runs on this computer, and its results live in the workspace, so it takes no `--out` or `--upload`.
|
|
83
|
-
- With `--json` the run prints NDJSON events and ends with `run_finished`: `url` is the result, `summary` the verdict with the attempt and check counts, and `next` the command that explains it. The exit codes are `ancha run`'s: 0 when every check passes, 1 when a check failed, 3 when an attempt could not run or be graded, 4 with `--strict` for an endpoint a
|
|
87
|
+
- With `--json` the run announces acceptance with `run_submitted` (`run_detached` with `--detach`), carrying `target: "cloud"` and adding `defaulted: true` when the saved login chose cloud. A followed run prints NDJSON events and ends with `run_finished`: `url` is the result, `summary` the verdict with the attempt and check counts, and `next` the command that explains it. The exit codes are `ancha run`'s: 0 when every check passes, 1 when a check failed, 3 when an attempt could not run or be graded, 4 with `--strict` for an endpoint coverage error or a verdict using simulated tool answers, and 2 for a cancelled run.
|
|
84
88
|
|
|
85
89
|
## Follow a run from anywhere
|
|
86
90
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Run `ancha run --json`, then `ancha baseline save before` to freeze a completed reference. Inspect `ancha explain latest --json`, edit the agent and run `ancha run --compare before --json`. Use the same --out directory when you set one. Consult `ancha baseline --help --json` and `ancha run --help --json` for installed reference options.
|
|
4
4
|
|
|
5
|
-
`ancha baseline save <name> [--from <runId|latest>] [--force] [--out <runs-dir>]` defaults to the
|
|
5
|
+
`ancha baseline save <name> [--from <runId|latest>] [--force] [--out <runs-dir>]` defaults to the most recent run from this project, on this computer or in the workspace; `--from run_cloud_…` takes a cloud run's summary from the workspace. It copies the summary into `.ancha/baselines/<name>.json`, or a baselines directory next to a custom runs directory. Later changes to latest leave the snapshot intact. Saving an existing name requires --force. Names use 1–64 letters, digits, hyphens or underscores; latest and names beginning with run_ are reserved. `ancha run --compare <runId|baseline-name>` resolves its reference before starting agents or updating latest.
|
|
6
6
|
|
|
7
7
|
Comparison requires exactly matching scene sets and normalized scene fingerprints, including their success criteria. YAML formatting and object key order do not affect fingerprints. Scene content changes require a fresh reference. Trial counts may differ. References containing invalid harness trials must be rerun with a healthy harness; genuine agent failures remain valid references. Legacy summaries remain readable with report/explain, but summaries without scene fingerprints cannot establish a verified comparison.
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Inspect a saved run
|
|
2
2
|
|
|
3
|
-
`ancha explain latest --json` explains the most
|
|
3
|
+
`ancha explain latest --json` explains the most recent run from this project, on this computer or in the workspace; pass a run id for an earlier one, `--scene` and `--trial` to narrow it, and `--out <dir>` when the run used a custom output directory.
|
|
4
4
|
|
|
5
5
|
It reports, in order:
|
|
6
6
|
|
package/lib/assets/docs/run.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`ancha run --dry-run` checks `ancha.yaml` and every scene, prints the scenes, trials and parallelism, and starts nothing: no server, no agent, no trial.
|
|
6
6
|
|
|
7
|
-
The
|
|
7
|
+
The run says where it runs. A cloud run announces acceptance with `run_submitted` (`run_detached` with `--detach`); both carry `target: "cloud"` and add `defaulted: true` when the saved login chose cloud. A run on this computer starts its NDJSON with `run_started`, which carries `workspace` and `target`. A completed run ends with `run_finished`. Without `--json`, each finished trial prints one line, such as `trial 2 ✗ 3m02s · 3 checks failed`, before the summary. The agent's exit code and the checks are independent: a clean exit with failed checks is a failure. Exits: 0 success; 1 failed checks, threshold or regression; 2 usage, config, scene or authentication error; 3 infrastructure or a trial the harness couldn't complete; 4 an endpoint coverage error or a verdict using simulated tool answers under `--strict`. The summary names the tests, trials and evaluated checks using those answers. Exit-code precedence is 3, 2, 4, then 1.
|
|
8
8
|
|
|
9
9
|
## What the agent gets
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ New run summaries use `verdictVersion: 2`. Each scene has `counts.requested`, `c
|
|
|
12
12
|
|
|
13
13
|
Each trial gets the tools' URLs and fake credentials (`ancha docs integrations`), `ANCHA_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.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
With `--on local`, the agent runs as a process on this computer. It is not sealed: it can reach this computer's network. Its environment is limited to a base set from this shell (`PATH`, `HOME`, `USER`, `LOGNAME`, `SHELL`, `LANG`, `LC_*`, `TERM`, `TMPDIR`, `TZ`, `NODE_EXTRA_CA_CERTS`, `SSL_CERT_FILE`, `VIRTUAL_ENV`, `CONDA_PREFIX`, `PYTHONPATH`) plus Ancha's and the tools' variables. Real credentials in your shell, such as `GITHUB_TOKEN` or `DD_API_KEY`, never reach it unless you name them:
|
|
16
16
|
|
|
17
17
|
```yaml
|
|
18
18
|
agent:
|
|
@@ -30,7 +30,11 @@ By default the agent runs once per attempt with the task in `ANCHA_TASK`. Import
|
|
|
30
30
|
|
|
31
31
|
## Where the agent runs
|
|
32
32
|
|
|
33
|
-
`--on local` starts it as a process on this computer; `--on docker` uses the sealed container below (never a process instead).
|
|
33
|
+
`--on local` starts it as a process on this computer; `--on docker` uses the sealed container below (never a process instead). `--on cloud` runs every attempt in a machine of its own in your workspace, from one bundle of the project; `ancha docs cloud` says what goes up, what each attempt gets and how to follow the run. Explicit saved-world tasks use `ancha runs start`; that is a separate managed-task contract.
|
|
34
|
+
|
|
35
|
+
Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspace saved by `ancha login`, outside CI and with no `ANCHA_API_KEY` or server override. A run with local settings keeps the target in `ancha.yaml`: a process on this computer or its configured Docker container. Local settings include `--agent-url`, `--out`, `--pass-env`, `--inherit-env`, `--upload`, `--upload-required`, `ANCHA_UPLOAD=1`, container execution, Slack HTTP or Socket Mode transport, and an endpoint agent without `agent.start`. `--agent "<command>"` alone, without a config, runs on this computer. `--dry-run` checks here and starts nothing. Use `ancha run --on local` to choose this computer or `ancha run --on cloud` to choose the workspace explicitly.
|
|
36
|
+
|
|
37
|
+
`--local`, `--server-url`, `server.url` and `ANCHA_SERVER_URL` keep the configured agent target; the server options choose where its worlds run. A default cloud run stops on a workspace error and keeps the recovery command in its hint.
|
|
34
38
|
|
|
35
39
|
`--upload` (or `ANCHA_UPLOAD=1`) sends the finished run to your workspace, where the console shows it; `ancha runs upload <run id | latest>` does that later. A failed upload is a warning unless `--upload-required`. `ancha docs cloud` says what is sent and what is redacted.
|
|
36
40
|
|
|
@@ -68,7 +72,7 @@ A trial ends when the agent exits, finishes explicitly, goes idle (event and HTT
|
|
|
68
72
|
|
|
69
73
|
## Background runs
|
|
70
74
|
|
|
71
|
-
`ancha run --detach --json` returns `run_detached` with a run id once its worker has started. `ancha status <id> --json` shows the lifecycle and counters; `ancha wait <id> --json` streams progress, then the final summary, and exits with the run's own exit code. `ancha logs <id> --follow` prints the run's NDJSON events as they happen and exits with the run's exit code. Pass the original `--out` to all three. Interrupting `wait` or `logs` stops only the observer. Detached runs survive the launching CLI. A worker stopped with SIGTERM or SIGINT cleans up its agents and keeps partial artifacts; observers report a worker without a heartbeat for 15 seconds as an uncertain failure.
|
|
75
|
+
`ancha run --detach --json` returns `run_detached` with a run id once its worker has started. `ancha status <id> --json` shows the lifecycle and counters; `ancha wait <id> --json` streams progress, then the final summary, and exits with the run's own exit code. `ancha logs <id> --follow` prints the run's NDJSON events as they happen and exits with the run's exit code. Pass the original `--out` to all three. Interrupting `wait` or `logs` stops only the observer. Detached runs survive the launching CLI. A worker stopped with SIGTERM or SIGINT cleans up its agents and keeps partial artifacts; observers report a worker without a heartbeat for 15 seconds as an uncertain failure. `latest` selects the most recent run from this project, on this computer or in the workspace: a run on this computer updates it when completed, and a workspace run when submitted. `ancha status latest --json`, `ancha logs latest` and `ancha explain latest` select that same run.
|
|
72
76
|
|
|
73
77
|
## Your own harness
|
|
74
78
|
|
package/lib/assets/docs/setup.md
CHANGED
|
@@ -85,7 +85,7 @@ Fix the agent, not the scenes or checks. The exception is a check that is wrong
|
|
|
85
85
|
|
|
86
86
|
## Exit codes
|
|
87
87
|
|
|
88
|
-
0 pass; 1 a check failed, the pass rate is below `min_pass_rate`, a comparison regressed, or `ancha test` needs a subcommand; 2 usage, config, scene or authentication error; 3 infrastructure, or a trial the harness couldn't complete; 4
|
|
88
|
+
0 pass; 1 a check failed, the pass rate is below `min_pass_rate`, a comparison regressed, or `ancha test` needs a subcommand; 2 usage, config, scene or authentication error; 3 infrastructure, or a trial the harness couldn't complete; 4 an endpoint coverage error or a verdict using simulated tool answers, with `--strict`. A harness failure takes precedence over the others.
|
|
89
89
|
|
|
90
90
|
Add `--json` for machine-readable results. Runs and hosted imports emit NDJSON; `env list` and `sandbox list` return arrays. Read the command-specific result fields with `ancha schema` and `ancha docs traces`. Errors carry `code` and `message`; `hint` names the next action.
|
|
91
91
|
|
|
@@ -100605,6 +100605,10 @@ var Environment = class _Environment {
|
|
|
100605
100605
|
this.clock.onChange = path4 === void 0 ? void 0 : () => this.#writeClock();
|
|
100606
100606
|
this.#writeClock();
|
|
100607
100607
|
}
|
|
100608
|
+
/** Signed request freshness follows the receiving app's clock. */
|
|
100609
|
+
deliveryNowMs(realNow = Date.now) {
|
|
100610
|
+
return this.#clockFile === void 0 ? realNow() : Math.floor(this.clock.nowMs());
|
|
100611
|
+
}
|
|
100608
100612
|
#writeClock() {
|
|
100609
100613
|
const path4 = this.#clockFile;
|
|
100610
100614
|
if (path4 === void 0) return;
|
|
@@ -140598,7 +140602,7 @@ var checks = {
|
|
|
140598
140602
|
// packages/server/src/twins/carrier-portal/pdf.ts
|
|
140599
140603
|
var winAnsi = new Map([..."\u20AC\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u017D\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u017E\u0178"].map((c, i) => [c, [128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159][i]]));
|
|
140600
140604
|
function encodeText(text23) {
|
|
140601
|
-
return [...text23].map((c) => {
|
|
140605
|
+
return [...text23.normalize("NFC")].map((c) => {
|
|
140602
140606
|
const code2 = c.codePointAt(0);
|
|
140603
140607
|
if (code2 >= 32 && code2 <= 126 || code2 >= 160 && code2 <= 255) return c;
|
|
140604
140608
|
if (winAnsi.has(c)) return String.fromCharCode(winAnsi.get(c));
|
|
@@ -150683,7 +150687,7 @@ var EndpointDelivery = class {
|
|
|
150683
150687
|
try {
|
|
150684
150688
|
const target4 = this.#options.targets[service];
|
|
150685
150689
|
const call2 = service === "app" ? appCall(event3, target4) : void 0;
|
|
150686
|
-
const delivered = call2?.delivered ?? materializeEvent(event3, this.#info, (this.#options.realNow
|
|
150690
|
+
const delivered = call2?.delivered ?? materializeEvent(event3, this.#info, this.#env.deliveryNowMs(this.#options.realNow), target4);
|
|
150687
150691
|
delivered.headers["x-ancha-env-id"] = this.#env.id;
|
|
150688
150692
|
delivered.headers["x-ancha-session-id"] = this.#session.id;
|
|
150689
150693
|
response5 = await postEvent(call2?.url ?? target4, delivered, {
|
|
@@ -151217,7 +151221,7 @@ async function readFeed(env, options3) {
|
|
|
151217
151221
|
const excludedServices = options3.excludedServices?.();
|
|
151218
151222
|
const deliveredEvents = events3.filter((event3) => !excludedServices?.has(event3.service));
|
|
151219
151223
|
const batch3 = {
|
|
151220
|
-
events: deliveredEvents.map((event3) => materializeEvent(event3, options3.info, (options3.realNow
|
|
151224
|
+
events: deliveredEvents.map((event3) => materializeEvent(event3, options3.info, env.deliveryNowMs(options3.realNow))),
|
|
151221
151225
|
cursor: events3.at(-1)?.cursor ?? after
|
|
151222
151226
|
};
|
|
151223
151227
|
if (deliveredEvents.length > 0) {
|
|
@@ -151326,7 +151330,7 @@ var TrialSessions = class {
|
|
|
151326
151330
|
const socket = options3.slackTransport === "socket" && env.twins.some((t) => t.name === "slack") ? new SocketDelivery(env, session2, this.#manager, slackSocketCodec(env.ctxFor("slack"))) : void 0;
|
|
151327
151331
|
this.#records.set(env, { session: session2, options: structuredClone(options3), signal: env.signal, delivery, socket, busy: 0 });
|
|
151328
151332
|
env.openPreparedBootstrap({ setupCalls: options3.setupCalls === true });
|
|
151329
|
-
|
|
151333
|
+
env.setClockFile(options3.clockFile);
|
|
151330
151334
|
return { ...session2 };
|
|
151331
151335
|
});
|
|
151332
151336
|
}
|
|
@@ -151364,7 +151368,7 @@ var TrialSessions = class {
|
|
|
151364
151368
|
type: "url_verification",
|
|
151365
151369
|
tSim: env.clock.now().toISOString(),
|
|
151366
151370
|
body: body6,
|
|
151367
|
-
headers: { "content-type": "application/json", ...slackHeaders(secret, body6, Math.floor(
|
|
151371
|
+
headers: { "content-type": "application/json", ...slackHeaders(secret, body6, Math.floor(env.deliveryNowMs() / 1e3)), "x-ancha-env-id": env.id, "x-ancha-session-id": session2.id }
|
|
151368
151372
|
}, { signal });
|
|
151369
151373
|
let matches9 = response5.body === challenge;
|
|
151370
151374
|
if (!matches9) {
|