@ancha-labs/cli 0.1.2 → 0.1.3
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/THIRD_PARTY_NOTICES.md +4 -0
- package/lib/ancha.mjs +76680 -62255
- package/lib/assets/SKILL.md +1 -1
- package/lib/assets/docs/cloud.md +27 -8
- package/lib/assets/docs/explain.md +8 -2
- package/lib/assets/docs/run.md +6 -0
- package/lib/assets/docs/tools.md +2 -0
- package/lib/assets/examples/incident-agent/agent.ts +1 -1
- package/lib/assets/harbor/companion.mjs +28950 -16413
- package/lib/assets/llms.txt +1 -1
- package/lib/assets/ui/app.js +542 -203
- package/lib/assets/ui/style.css +28 -0
- package/lib/mcp-entry.mjs +28853 -16354
- package/lib/worker.mjs +27939 -15155
- package/lib/world-server.mjs +28545 -16045
- package/package.json +1 -1
package/lib/assets/SKILL.md
CHANGED
|
@@ -47,7 +47,7 @@ Each trial gives the agent its tools as environment variables, with fake credent
|
|
|
47
47
|
|
|
48
48
|
## Hosted workspace
|
|
49
49
|
|
|
50
|
-
If the user has an Ancha workspace, `ancha login` asks them to approve this computer once in the browser; ask them to do it. After that, `ancha run`
|
|
50
|
+
If the user has an Ancha workspace, `ancha login` asks them to approve this computer once in the browser; ask them to do it. After that, `ancha run` still runs its worlds on this computer; `ancha run --upload --json` sends the finished run to their workspace, where the console shows it (`upload.url` in the JSON). `ancha whoami --json` shows the workspace and where runs put their worlds. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login: `ancha run --local --upload --json`. `ancha secrets set NAME` copies a provider key from this shell into the workspace for agents that run there.
|
|
51
51
|
|
|
52
52
|
Running the agent itself in the cloud is a console flow at https://app.ancha.io: Bring your agent, Connect, tasks with checks, Run. Send the user there for it.
|
|
53
53
|
|
package/lib/assets/docs/cloud.md
CHANGED
|
@@ -4,19 +4,38 @@ A hosted workspace at https://app.ancha.io runs your worlds on a machine of your
|
|
|
4
4
|
|
|
5
5
|
## Sign in once
|
|
6
6
|
|
|
7
|
-
`ancha login` prints a link and a code and opens the browser; the engineer approves this computer once (`--no-browser` only prints the link). The CLI saves an API key for the workspace
|
|
7
|
+
`ancha login` prints a link and a code and opens the browser; the engineer approves this computer once (`--no-browser` only prints the link). With `--json` the first line is `{"event": "login_pending", "verificationUrl", "userCode", "expiresIn"}`, for a coding agent to show its user, and the last is the saved login. The CLI saves an API key for the workspace in `~/.config/ancha/credentials.json` (mode 0600; `ANCHA_CREDENTIALS_FILE` moves it). A process started without `HOME` (or `XDG_CONFIG_HOME`) has no saved login.
|
|
8
8
|
|
|
9
|
-
`ancha whoami --json` shows the workspace
|
|
9
|
+
`ancha whoami --json` shows the workspace and where that choice came from (`--server-url`, `server.url` in `ancha.yaml`, `ANCHA_SERVER_URL`, or the saved login), and in `worlds` where `ancha run` puts its worlds. `ancha whoami --verify` also asks the server whether it accepts the key. `ancha logout` forgets the saved login. `--local` keeps a command's worlds on this computer.
|
|
10
10
|
|
|
11
|
-
The first line of every `ancha run` says where its worlds run
|
|
11
|
+
The first line of every `ancha run` says where its worlds run: `running locally (worlds in a server this command starts; logged in to https://app.ancha.io/t/<workspace>: --upload sends the results there)` after a login, or `running on hosted https://app.ancha.io/t/<workspace> (from ANCHA_SERVER_URL; --local to run here)` when a server was asked for. Its JSON events and summary carry `workspace` (that URL, or `local:<project path>`) and `target` (`local` for a process on this computer, `docker` for a container).
|
|
12
12
|
|
|
13
13
|
## What runs where
|
|
14
14
|
|
|
15
|
-
- `ancha run`, `ancha doctor`, `ancha env` and `ancha
|
|
16
|
-
- `ancha agent
|
|
17
|
-
-
|
|
15
|
+
- `ancha run`, `ancha doctor`, `ancha world up`, `ancha env`, `ancha sandbox` and `ancha replay` create their worlds on this computer, also when you're logged in. `--server-url`, `server.url` in `ancha.yaml` or `ANCHA_SERVER_URL` put them on that server instead, for example the hosted world server `https://app.ancha.io/t/<workspace>` (your agent still runs here; its tool URLs point at `…/t/<workspace>/e/<environment>/<tool>/…`). `--on cloud` runs the agent in the workspace too (below).
|
|
16
|
+
- `ancha agent` (except `agent detect`), `ancha world list|show|create|update|archive`, `ancha test`, `ancha runs`, `ancha attempt` and `ancha explain <play_…>` run in the hosted workspace: they list and change the same agents, worlds, tests and runs as the console, and every JSON object they print names its `workspace`. `--local` keeps them on this project's `.ancha/`. `ancha playground` stays on this computer.
|
|
17
|
+
- `ancha agent add|update --cwd <dir>` uploads the folder first: the files git tracks or would add, without `.anchaignore` patterns, hidden files, dependencies or credential-like files, at most 200 MB.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Run the agent in the workspace
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
ancha run --on cloud --json # every test or scene ancha.yaml names; or pass files
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This uploads the project, registers its agent under the project folder's name (updating it the next time), connects it (the workspace builds its image once per code version), and runs each test there as its own run, streaming `run_started`, each attempt and `run_finished` with the grade. The exit code is the worst of the runs: 0 every attempt passed, 1 an attempt failed, 2 stopped, 3 error. The workspace's console owns each run, so a dropped connection doesn't stop it: `ancha runs show <id>` and `ancha explain <id> --json` pick it up. A test for the workspace gives the agent a task (`start.task` in a version 2 test, or `task` in a scene). `ancha runs start --agent <id> --test <file>` runs one test with an agent that is already there.
|
|
26
|
+
|
|
27
|
+
## Results in the workspace
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
ancha run --upload --json # or ANCHA_UPLOAD=1; the console shows the run at https://app.ancha.io/runs/<run id>
|
|
31
|
+
ancha runs upload latest # a run that already finished (also a run id)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`--upload` sends the finished run to the workspace: its summary and inputs, and for each attempt the agent's log (the last 4 MB), the calls, the final state, the checks and their explanations. Before it leaves, the values of variables the agent got through `--pass-env` or `--inherit-env`, and of `.ancha/openrouter.env`, become `[redacted]`. The JSON `run_finished` event carries `upload: { url, bytes, files }`. Uploading a run again replaces its copy in the workspace (`replaced: true`). A failed upload is a warning and the run keeps its own exit code; `--upload-required` makes it fail the command. A run started with `--detach` uploads when it finishes, and `ancha wait <run id>` says where the results went. A run's files stay in `.ancha/runs/` either way.
|
|
35
|
+
|
|
36
|
+
## People and world generation
|
|
37
|
+
|
|
38
|
+
The people in a world and `ancha world gen` call a language model. With `OPENROUTER_API_KEY` set they use your key. Logged in to a workspace without one, they use the workspace's model credit through its relay (`https://app.ancha.io/t/<workspace>/_relay/v1`, authorized by the workspace's API key; your own key never goes there). Those calls go through the hosted workspace and wake its machine, which can take up to a minute after it sleeps. The relay serves its own model list, takes requests up to 256 KB and about 120 a minute per workspace, and says when the workspace is out of credit or has model calls turned off; the error names the next step, and setting `OPENROUTER_API_KEY` always works.
|
|
20
39
|
|
|
21
40
|
## CI
|
|
22
41
|
|
|
@@ -25,7 +44,7 @@ Set two variables; no login or browser is needed:
|
|
|
25
44
|
```sh
|
|
26
45
|
export ANCHA_SERVER_URL=https://app.ancha.io/t/<workspace> # shown on https://app.ancha.io/account
|
|
27
46
|
export ANCHA_API_KEY=… # create one on the same page; store it as a CI secret
|
|
28
|
-
npx -y @ancha-labs/cli run --json
|
|
47
|
+
npx -y @ancha-labs/cli run --local --upload --json # worlds on the CI runner; the results go to the workspace
|
|
29
48
|
```
|
|
30
49
|
|
|
31
50
|
`ANCHA_API_KEY` wins over a saved login. Never commit it or put it in `ancha.yaml`.
|
|
@@ -6,12 +6,18 @@ It reports, in order:
|
|
|
6
6
|
|
|
7
7
|
- harness issues: a part of Ancha that failed, which makes the trial invalid rather than a failure of the agent;
|
|
8
8
|
- agents that crashed or timed out, with the end of `agent.log`;
|
|
9
|
-
- each failed check: what was expected, what happened, and the agent's calls and world events behind it;
|
|
9
|
+
- 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;
|
|
10
10
|
- 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;
|
|
11
11
|
- when the agent ran on this computer, 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`.
|
|
12
12
|
|
|
13
|
-
JSON keys: `runId`, `agentIssues`, `harnessIssues`, `failures` (each with `check`, `expected`, `actual`, `explanation`, `traceExcerpt`), `coverageGaps` (each with `service`, `method`, `path`, `count`, the twin's `status` and `error`, and a `hint`), `agentEnvironment` (`target`, and for this computer `inherited` and `withheld`), and `gradingWarnings` when a check produced one.
|
|
13
|
+
JSON keys: `runId`, `agentIssues`, `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` and `withheld`), and `gradingWarnings` when a check produced one.
|
|
14
14
|
|
|
15
15
|
A clean process exit doesn't mean the task passed, and an invalid trial isn't an agent failure. The reference companions (`oracle.mjs`, `null.mjs`) prove the scene and harness behave; they aren't evidence that an AI agent solved the task.
|
|
16
16
|
|
|
17
17
|
Fix the agent after reading the evidence, then prove the fix with `ancha run --compare before --json` against a saved reference: `ancha docs compare`.
|
|
18
|
+
|
|
19
|
+
## Replay an attempt
|
|
20
|
+
|
|
21
|
+
`ancha replay latest/trial-<scene>-1 --json` runs one attempt again: its world with the same seed, its people answering from what they said in it, and the agent as it is now (or `--agent "<command>"`). Name the attempt as `<run id or latest>/<trial directory>`, as it appears under the runs directory. The replay is saved as a new run, so `ancha explain` and `ancha report` read it.
|
|
22
|
+
|
|
23
|
+
It reports whether the agent acted differently and where: the first of its writes that differs from the attempt (`diverged`, with the recorded and the new call), then every check against the attempt's outcome (`was`). With the same agent, nothing diverges and no model is called. Once the agent acts differently, people answer live with `--people live` (your `OPENROUTER_API_KEY`, or the workspace's model credit after `ancha login`), or the replay stops there with `--people strict`, the default when there is no model. A replay stopped that way is invalid (exit 3, `invalidReason: "diverged"`): its checks say nothing about the agent. `ancha schema replay_finished` describes the JSON.
|
package/lib/assets/docs/run.md
CHANGED
|
@@ -22,6 +22,12 @@ agent:
|
|
|
22
22
|
|
|
23
23
|
By default the agent runs once per attempt with the task in `ANCHA_TASK`. When the world has people who reply later, set `agent.input: per_event`: Ancha runs the command once per event addressed to the agent (a DM, a mention, a thread it is in), with the event in `ANCHA_EVENT_JSON` and a one-line summary in `ANCHA_TASK`, one conversation at a time. Simulated time skips ahead while nobody is working, and the attempt ends when the world is quiet with nothing scheduled before the deadline.
|
|
24
24
|
|
|
25
|
+
## Where the agent runs
|
|
26
|
+
|
|
27
|
+
`--on local` starts it as a process on this computer, `--on docker` in the sealed container below (never a process instead), and `--on cloud` in your hosted workspace (`ancha docs cloud`). Without `--on`, `ancha.yaml` decides.
|
|
28
|
+
|
|
29
|
+
`--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.
|
|
30
|
+
|
|
25
31
|
## Run the agent in a container
|
|
26
32
|
|
|
27
33
|
```yaml
|
package/lib/assets/docs/tools.md
CHANGED
|
@@ -44,6 +44,8 @@ Run `ancha connect <tool> --lang ts` for the selected native HTTP setup. Google
|
|
|
44
44
|
|
|
45
45
|
The new tools are LinkedIn Ads (202610), Salesforce (REST v67.0), Gong (v2), Google Ads (v26), ChatGPT Ads (Advertiser API v1), HubSpot (CRM v3), and Google Analytics (Data API v1beta REST). `ancha twins coverage <tool> --json` lists each one's supported operations and known gaps. Slack, GitHub, Datadog, PagerDuty and Open-Meteo are available too.
|
|
46
46
|
|
|
47
|
+
Some replicas are measured against their vendor's own OpenAPI description: the official SDK calls every endpoint the replica claims and each response is checked. `ancha twins list --json` gives those replicas a `conformance` object (`claimed`, `exercised`, `sdkCalls`, `sdkFailures`, `mismatches`, `accepted`, and the pinned `source` descriptions); a difference is `accepted` only with a written reason. `ancha twins coverage <tool>` prints the same numbers under its table.
|
|
48
|
+
|
|
47
49
|
One coherent synthetic dataset per tool is the starting point. Reporting data is historical; changing a budget does not manufacture new impressions, leads or revenue. Delayed transcripts, review decisions, search visibility and reporting rows follow explicit deterministic mock rules. **+2 min** advances that simulated availability; it does not purchase or deliver advertising. A successful local client test does not establish live-vendor parity.
|
|
48
50
|
|
|
49
51
|
## MCP and fresh attempts
|
|
@@ -2,7 +2,7 @@ import OpenAI from 'openai';
|
|
|
2
2
|
import type { ResponseCreateParamsNonStreaming, ResponseInputItem, Response, Tool } from 'openai/resources/responses/responses';
|
|
3
3
|
import { PROMPT } from './prompt.ts';
|
|
4
4
|
|
|
5
|
-
export const DEFAULT_MODEL = '
|
|
5
|
+
export const DEFAULT_MODEL = 'anthropic/claude-haiku-5.5';
|
|
6
6
|
export const LIMITS = { turns: 24, outputTokens: 8192, requestMs: 45000, wallMs: 540000, callsPerTurn: 32, queuedEvents: 128 } as const;
|
|
7
7
|
export type Log = (value: Record<string, unknown>) => void;
|
|
8
8
|
export interface Tools { definitions: Tool[]; execute(name: string, args: unknown, signal: AbortSignal): Promise<unknown> }
|