@ancha-labs/cli 0.2.0 → 0.3.0
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/lib/ancha.mjs +4947 -3534
- package/lib/assets/SKILL.md +1 -1
- package/lib/assets/docs/apps.md +7 -5
- package/lib/assets/docs/integrations.md +1 -1
- package/lib/assets/docs/run.md +2 -0
- package/lib/assets/harbor/companion.mjs +722 -277
- package/lib/assets/ui/app.js +1 -1
- package/lib/mcp-entry.mjs +51 -1
- package/lib/worker.mjs +87968 -85498
- package/lib/world-server.mjs +719 -278
- package/package.json +1 -1
package/lib/assets/SKILL.md
CHANGED
|
@@ -35,7 +35,7 @@ A production run that went wrong becomes a test here. With a trace file (an expo
|
|
|
35
35
|
|
|
36
36
|
1. `ancha import --offline <trace file> --json` makes the test on this computer and uploads nothing. It writes `scenes/from-traces/<name>/scene.yaml` and lists the questions one trace cannot settle, each with the default the test uses.
|
|
37
37
|
2. Ask the user for the answers; don't guess them. Pass them with `--answer <question>=<value>` and import again with `--force` (`ancha docs apps`).
|
|
38
|
-
3. `ancha run` on the `scene.yaml` against the version that failed in production should fail the same way. That is where the loop above starts.
|
|
38
|
+
3. `ancha run` on the `scene.yaml` against the version that failed in production should fail the same way. That is where the loop above starts. If it doesn't, `ancha traces diff <trace file> latest` shows the calls production made and the trial didn't; the import also lists the app's own setup calls, which the start script or an `app_call` has to make.
|
|
39
39
|
|
|
40
40
|
If the user's workspace takes traces (their agents send them to it), `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` saves it, 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. A workspace that doesn't take traces says so; use the file.
|
|
41
41
|
|
package/lib/assets/docs/apps.md
CHANGED
|
@@ -19,12 +19,14 @@ scenes: [ancha/scenes/*.yaml]
|
|
|
19
19
|
trials: 3
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
`ancha run --dry-run` checks this file and every scene and starts nothing.
|
|
23
|
+
|
|
22
24
|
- `{{agent.port}}` is reserved for the trial, so the health route and the event routes need nothing Ancha-specific.
|
|
23
25
|
- `clock: node` needs `start`. Apps in other runtimes keep real time: give them short thresholds in their seeded settings instead.
|
|
24
26
|
|
|
25
27
|
## The start script
|
|
26
28
|
|
|
27
|
-
-
|
|
29
|
+
- From your shell it gets only a base set (`PATH`, `HOME`, the locale and the like). It also gets Ancha's variables (`ANCHA_AGENT_PORT`, `ANCHA_TRIAL` …), the variables of every tool in the scene (`ancha connect <tool> --json` lists them) and `agent.env`. Set database and cache URLs and the app's test secrets in the script. A real key, such as the app's model key, goes in `agent.pass_env` by name (or `ancha run --pass-env NAME`): its value stays in your shell, not in a script you commit.
|
|
28
30
|
- Every trial is a new world with new URLs and tokens, so every trial starts the app clean:
|
|
29
31
|
1. restore the database from a template copy (`CREATE DATABASE app_trial TEMPLATE app_base`, with `app_base` migrated once);
|
|
30
32
|
2. flush caches and queues the tests own;
|
|
@@ -39,7 +41,7 @@ trials: 3
|
|
|
39
41
|
|
|
40
42
|
- Use the app's base-URL setting if it has one; `ancha connect <tool> --lang ts|py` prints the SDK settings. If the SDK has none, add a development-only initializer that reads the tool's variable and does nothing when it is unset. Keep app changes that small and say why in a comment.
|
|
41
43
|
- Google clients keep only the host of a `rootUrl` set on the client; Ancha routes those calls by their token.
|
|
42
|
-
- Gmail reaches an app the way it does in production: the app calls `users.watch`, and the world then pushes Pub/Sub notifications to `agent.url`. If the app registers its watch on a schedule, call that route with an `app_call` early in the scene. The world gives `GMAIL_API_URL` and `
|
|
44
|
+
- Gmail reaches an app the way it does in production: the app calls `users.watch`, and the world then pushes Pub/Sub notifications to `agent.url`. If the app registers its watch on a schedule, call that route with an `app_call` early in the scene. The world gives `GMAIL_API_URL`, `GMAIL_ACCESS_TOKEN` and `GMAIL_ADDRESS`, the mailbox's address (`{{gmail.url}}`, `{{gmail.token}}`, `{{gmail.address}}`); `GET /gmail/v1/users/me/profile` answers the same address, as in Gmail. `ancha connect gmail --lang ts` prints the client settings.
|
|
43
45
|
- Identifiers a scene relies on (an inbox token, a cron secret, an API key the world sends) should be fixed values your seed creates, because a scene is static.
|
|
44
46
|
|
|
45
47
|
## Scenes for an app
|
|
@@ -75,7 +77,7 @@ checks:
|
|
|
75
77
|
|
|
76
78
|
- `app_calls` take `at`, `method` (default GET), `path`, `headers` and `body`; they go to the origin of `ready_url`.
|
|
77
79
|
- `gmail.send` takes `from`, `to`, `cc`, `subject`, `body`, `in_reply_to` and `ref`. The `gmail.thread` check takes `of` (a message ref), `label` with `present`, `drafts_gte`, `drafts_lte` and `messages_gte`.
|
|
78
|
-
- People who answer like a person
|
|
80
|
+
- People who answer like a person go in the scene's `people:` (`ancha schema scene` lists every field). One with a Gmail account reads the mail delivered to that mailbox, which must be in `seed.gmail.mailboxes`, and replies in the thread: `{ ref: tom, name: Tom, role: a client who answers email himself within a day or two, accounts: { gmail: tom@client.example }, replies_after: 1d..2d }`. People call a model with your `OPENROUTER_API_KEY`, or `ANCHA_PEOPLE_BASE_URL` and `ANCHA_PEOPLE_API_KEY` (`ancha docs cloud`). `ancha twins seed <tool> --json` prints each tool's seed fields and checks.
|
|
79
81
|
- Make every check able to fail. Run a scene once against a build with the feature broken, or also check the state in between (the label the app should have removed). A check can pass for the wrong reason: a reminder that never comes because the scheduled call ran too early proves nothing.
|
|
80
82
|
|
|
81
83
|
## From a production trace, on this computer
|
|
@@ -84,5 +86,5 @@ checks:
|
|
|
84
86
|
2. It lists the questions one trace cannot settle, each with the default the test uses. Examples: should a label the app added still be on the thread at the end, and what header do the app's scheduled calls carry? Ask the user, then import again with `--answer <id>=<value>` for each and `--force`.
|
|
85
87
|
3. Run the scene against the build that failed in production. It should fail the way production did. Then fix the app and run again.
|
|
86
88
|
|
|
87
|
-
- A trace holds the app's calls, not what started each one.
|
|
88
|
-
- When a test does not fail the way production did,
|
|
89
|
+
- A trace holds the app's calls, not what started each one. The import lists the calls production made before the first event the test replays: the app's own setup, such as a watch or its labels. The test has them only if the app makes them when it starts, or the start script or an `app_call` does.
|
|
90
|
+
- When a test does not fail the way production did, `ancha traces diff <trace file> <run>/<trial>` lists the calls only production made, the ones only the trial made, and the first call where their orders part. A call production made and the trial didn't (labels created at setup, a settings read) usually points at what the seed lacks.
|
|
@@ -8,6 +8,6 @@ Slack WebClient uses slackApiUrl. With Bolt Socket Mode configure both App clien
|
|
|
8
8
|
|
|
9
9
|
PagerDuty PDJS requires a full local url for every REST request; its server option assumes production HTTPS. Use response.data and next(); resource/all and Events convenience helpers have production-host assumptions. Use fetch to the local /v2/enqueue with a native Events v2 payload and a service routing key. REST tokens, routing keys, From identity and webhook signing secrets have separate roles.
|
|
10
10
|
|
|
11
|
-
Gmail: Ancha supplies GMAIL_API_URL/GMAIL_ACCESS_TOKEN (`ancha connect gmail --lang ts`). Google clients take the URL as each call's `rootUrl` (`GMAIL_API_URL + '/'`) or the app's own base-URL setting; push to the app follows its `users.watch` call (`ancha docs apps`).
|
|
11
|
+
Gmail: Ancha supplies GMAIL_API_URL/GMAIL_ACCESS_TOKEN and GMAIL_ADDRESS, the mailbox's address (`ancha connect gmail --lang ts`). Google clients take the URL as each call's `rootUrl` (`GMAIL_API_URL + '/'`) or the app's own base-URL setting; push to the app follows its `users.watch` call (`ancha docs apps`).
|
|
12
12
|
|
|
13
13
|
Verify webhook signatures against exact raw request bytes before JSON parsing. Slack uses its signing secret, GitHub its webhook secret, PagerDuty its signing secret; Datadog's declared custom webhook profile uses a bearer token. Native route support and delivery/retry policies are a bounded subset, not full vendor parity.
|
package/lib/assets/docs/run.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
`ancha run --json` loads `ancha.yaml` and runs the configured agent against every scene its `scenes:` globs match, `trials` times each, in fresh worlds. Pass scene files to run only those. `--agent "<command>"` overrides `agent.command`; `-n 1 --parallel 1` runs one diagnostic trial; `--out <dir>` chooses where results go (use the same `--out` for `explain`, `report` and `compare`). Paths are relative to the directory you run `ancha` from.
|
|
4
4
|
|
|
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
|
+
|
|
5
7
|
The first line says where the worlds run: locally, or on the hosted workspace you signed in to (`--local` keeps them on this computer). NDJSON starts with `run_started`, which carries `workspace` and `target`, and ends with `run_finished` after a completed run. 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 unimplemented endpoint under `--strict`. A harness failure takes precedence over thresholds and strict gaps.
|
|
6
8
|
|
|
7
9
|
## What the agent gets
|