@ancha-labs/cli 0.4.49 → 0.4.51
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 +358 -313
- package/lib/assets/SKILL.md +1 -1
- package/lib/assets/agents-section.md +1 -1
- package/lib/assets/docs/cloud.md +1 -1
- package/lib/assets/docs/run.md +1 -1
- package/lib/assets/docs/scenes.md +1 -1
- package/lib/assets/docs/setup.md +2 -2
- package/lib/assets/harbor/companion.mjs +29 -15
- package/lib/assets/ui/app.js +1 -1
- package/lib/worker.mjs +49 -22
- package/lib/world-server.mjs +18 -12
- package/package.json +1 -1
package/lib/assets/SKILL.md
CHANGED
|
@@ -42,7 +42,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
|
|
|
42
42
|
ancha agent upload
|
|
43
43
|
```
|
|
44
44
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
45
|
-
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
45
|
+
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows; an agent that reaches NetSuite through Composio gets the same books and the 10 read tasks. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
46
46
|
- Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
|
|
47
47
|
- Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
|
|
48
48
|
- Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
ancha agent upload
|
|
28
28
|
```
|
|
29
29
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
30
|
-
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
30
|
+
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows; an agent that reaches NetSuite through Composio gets the same books and the 10 read tasks. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
31
31
|
- Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
|
|
32
32
|
- Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
|
|
33
33
|
- Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
|
package/lib/assets/docs/cloud.md
CHANGED
|
@@ -35,7 +35,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
|
|
|
35
35
|
ancha agent upload
|
|
36
36
|
```
|
|
37
37
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
38
|
-
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
38
|
+
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows; an agent that reaches NetSuite through Composio gets the same books and the 10 read tasks. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
39
39
|
- Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
|
|
40
40
|
- Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
|
|
41
41
|
- Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
|
package/lib/assets/docs/run.md
CHANGED
|
@@ -12,7 +12,7 @@ When `CI=true` or `CI=1` (case-insensitive), a verdict using simulated tool answ
|
|
|
12
12
|
|
|
13
13
|
New run summaries use `verdictVersion: 3`. Each test (an entry of `scenes`) has `counts.requested`, `completed`, `valid`, `passed`, `invalid` and `skipped`. The pass-rate denominator is the requested count, including invalid, skipped and unfinished trials. “Pass all k” requires all k requested trials to complete validly and pass. A test with no check evaluated is ungraded (`graded: false`); the run's verdict is `ungraded` when any test is ungraded and none failed. HTML and the console show invalid attempts separately. Older reports stay readable; comparison with an old baseline lacking these counts exits 2 and asks you to rerun the reference and save a fresh baseline.
|
|
14
14
|
|
|
15
|
-
Each trial gets the tools' URLs and fake credentials (`ancha docs integrations`), `ANCHA_TASK` and `ANCHA_TASK_FILE` (a file holding the 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. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: "{{task}}" }` (`{{task_file}}` for the file's path, `{{task_json}}` for the task encoded as a JSON string); `ancha init` writes that line when it finds the name in the agent's code or usage text.
|
|
15
|
+
Each trial gets the tools' URLs and fake credentials (`ancha docs integrations`), `ANCHA_TASK` and `ANCHA_TASK_FILE` (a file holding the 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 (each request with `Authorization: Bearer $ANCHA_TRIAL_TOKEN`), and `ANCHA_AGENT_PORT` for HTTP agents. No SDK is installed and no paid AI call is made for you. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: "{{task}}" }` (`{{task_file}}` for the file's path, `{{task_json}}` for the task encoded as a JSON string); `ancha init` writes that line when it finds the name in the agent's code or usage text.
|
|
16
16
|
|
|
17
17
|
Map your agent's tool settings with `agent.env`: `{{<tool>.url}}`, `{{<tool>.host_url}}` and `{{<tool>.token}}` use that tool's connection. Jira also offers `{{jira.email}}` (the login email, also `{{jira.access_key}}`) and `{{jira.access_key_secret}}` (the API token). For example, `env: { JIRA_USERNAME: "{{jira.email}}", JIRA_INSTANCE_URL: "{{jira.url}}"` gives an agent its own names for Jira's email and URL; `JIRA_API_TOKEN` is supplied automatically. An unknown template produces `CONFIG_INVALID` with the available template names before a run or upload check starts the agent.
|
|
18
18
|
|
|
@@ -118,7 +118,7 @@ Include the check ID in `pass` to require it (by default, every check is require
|
|
|
118
118
|
|
|
119
119
|
## Checks on the final answer
|
|
120
120
|
|
|
121
|
-
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.
|
|
121
|
+
An `answer` check reads the agent's final answer: what it posts to `ANCHA_DONE_URL` as `{"output": …}` with `Authorization: Bearer $ANCHA_TRIAL_TOKEN` (`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.
|
|
122
122
|
|
|
123
123
|
```yaml
|
|
124
124
|
checks:
|
package/lib/assets/docs/setup.md
CHANGED
|
@@ -33,7 +33,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
33
33
|
ancha agent upload
|
|
34
34
|
```
|
|
35
35
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
36
|
-
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
36
|
+
6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows; an agent that reaches NetSuite through Composio gets the same books and the 10 read tasks. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.
|
|
37
37
|
- Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.
|
|
38
38
|
- Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.
|
|
39
39
|
- Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.
|
|
@@ -73,7 +73,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
73
73
|
`ancha init --agent "node agent.mjs"`, with your own start command, writes:
|
|
74
74
|
- `ancha.yaml`: how to start the agent, how many trials, which tests;
|
|
75
75
|
- `scenes/starter/`: a starter test that checks the agent reaches each tool, with a 60-second timeout for startup and model calls, and two reference companions (`oracle.mjs` passes, `null.mjs` makes no calls);
|
|
76
|
-
- for an agent that uses NetSuite, in a project with no tests and no `traces
|
|
76
|
+
- for an agent that uses NetSuite, in a project with no tests and no trace files in `traces/`: `ancha/worlds/netsuite-pe-m.yaml`, the NetSuite books of a private-equity portfolio company, and 25 tests in `ancha/tests/`: 10 read tasks and 15 write workflows (their evals in `ancha/evals/`); the 10 read tasks alone for an agent that reaches NetSuite through Composio. `--data netsuite-pe:s` or `--data netsuite-pe:l` writes another size, `--data none` leaves them out;
|
|
77
77
|
- `.claude/skills/ancha/SKILL.md` and an Ancha section in `AGENTS.md`, for coding agents;
|
|
78
78
|
- `.ancha/` in `.gitignore`: run history, traces and fake tokens never belong in git.
|
|
79
79
|
|
|
@@ -166352,12 +166352,12 @@ function queryRecords(ctx, sql5) {
|
|
|
166352
166352
|
if (!confirmed.has(key5) && !["TimeActivity", "Attachable", "TaxAgency", "ExchangeRate"].includes(type)) hasGap = true;
|
|
166353
166353
|
return key5;
|
|
166354
166354
|
}
|
|
166355
|
-
const typed = (key5,
|
|
166356
|
-
if (typeof
|
|
166355
|
+
const typed = (key5, value6) => {
|
|
166356
|
+
if (typeof value6 !== "string") return value6;
|
|
166357
166357
|
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
166358
|
-
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(
|
|
166359
|
-
if (declared === "boolean" && /^(true|false)$/i.test(
|
|
166360
|
-
return
|
|
166358
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value6)) return Number(value6);
|
|
166359
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value6)) return value6.toLowerCase() === "true";
|
|
166360
|
+
return value6;
|
|
166361
166361
|
};
|
|
166362
166362
|
projection = projection?.map((p2) => property4(p2));
|
|
166363
166363
|
const conditions = [];
|
|
@@ -166370,6 +166370,11 @@ function queryRecords(ctx, sql5) {
|
|
|
166370
166370
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
166371
166371
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
166372
166372
|
};
|
|
166373
|
+
const value5 = (key5) => {
|
|
166374
|
+
const token5 = ts2[i], read6 = typed(key5, literal2());
|
|
166375
|
+
if (token5?.kind === "number" && fields13.find((f2) => f2[0] === key5)?.[1] === "string") parseError2(`${key5} is text: give its value in single quotes.`);
|
|
166376
|
+
return read6;
|
|
166377
|
+
};
|
|
166373
166378
|
if (peek("WHERE")) {
|
|
166374
166379
|
i++;
|
|
166375
166380
|
do {
|
|
@@ -166378,10 +166383,10 @@ function queryRecords(ctx, sql5) {
|
|
|
166378
166383
|
const op = ts2[i++]?.text.toUpperCase();
|
|
166379
166384
|
if (op === "IN") {
|
|
166380
166385
|
take2("(");
|
|
166381
|
-
const values3 = [
|
|
166386
|
+
const values3 = [value5(key5)];
|
|
166382
166387
|
while (peek(",")) {
|
|
166383
166388
|
i++;
|
|
166384
|
-
values3.push(
|
|
166389
|
+
values3.push(value5(key5));
|
|
166385
166390
|
}
|
|
166386
166391
|
take2(")");
|
|
166387
166392
|
conditions.push((row2) => {
|
|
@@ -166394,17 +166399,17 @@ function queryRecords(ctx, sql5) {
|
|
|
166394
166399
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
166395
166400
|
conditions.push((row2) => {
|
|
166396
166401
|
const actual = scalar2(row2, key5);
|
|
166397
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
166398
|
-
const v = String(
|
|
166402
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value6) => {
|
|
166403
|
+
const v = String(value6 ?? "").toLowerCase();
|
|
166399
166404
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
166400
166405
|
});
|
|
166401
166406
|
});
|
|
166402
166407
|
} else {
|
|
166403
166408
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
166404
|
-
const expected =
|
|
166409
|
+
const expected = value5(key5);
|
|
166405
166410
|
conditions.push((row2) => {
|
|
166406
|
-
const
|
|
166407
|
-
return (Array.isArray(
|
|
166411
|
+
const value6 = scalar2(row2, key5);
|
|
166412
|
+
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
166408
166413
|
let actual = item2, target5 = expected;
|
|
166409
166414
|
if (actual === void 0) return false;
|
|
166410
166415
|
if (key5.startsWith("MetaData.")) {
|
|
@@ -168258,6 +168263,7 @@ var TrialSessions = class {
|
|
|
168258
168263
|
});
|
|
168259
168264
|
}
|
|
168260
168265
|
authenticate(token5, allowFinished = false) {
|
|
168266
|
+
if (!token5) throw new AnchaError("SESSION_UNAUTHORIZED", "invalid session capability", { hint: "send Authorization: Bearer $ANCHA_TRIAL_TOKEN" });
|
|
168261
168267
|
const env = token5 ? this.#manager.list().find((env2) => this.#records.get(env2)?.session.token === token5) : void 0;
|
|
168262
168268
|
const record11 = env ? this.#records.get(env) : void 0;
|
|
168263
168269
|
if (!env || !record11 || record11.signal !== env.signal) throw new AnchaError("SESSION_UNAUTHORIZED", "invalid session capability");
|
|
@@ -187482,10 +187488,10 @@ async function startIsolationGateway(options4) {
|
|
|
187482
187488
|
roots.set(root3, upstream);
|
|
187483
187489
|
}
|
|
187484
187490
|
const sessionRoutes2 = /* @__PURE__ */ new Map();
|
|
187485
|
-
if (session2) for (const [field5, path6, method2] of [["eventsUrl", "/_ancha/events", "GET"], ["contextUrl", "/_ancha/context", "GET"], ["doneUrl", "/_ancha/done", "POST"]]) {
|
|
187491
|
+
if (session2) for (const [field5, path6, method2, name5] of [["eventsUrl", "/_ancha/events", "GET", "ANCHA_EVENTS_URL"], ["contextUrl", "/_ancha/context", "GET", "ANCHA_CONTEXT_URL"], ["doneUrl", "/_ancha/done", "POST", "ANCHA_DONE_URL"]]) {
|
|
187486
187492
|
const upstream = loopbackOrigin(session2[field5]);
|
|
187487
187493
|
if (upstream.pathname !== path6 || upstream.search || upstream.hash) throw new Error("Invalid trial session route");
|
|
187488
|
-
sessionRoutes2.set(path6, { method: method2, upstream });
|
|
187494
|
+
sessionRoutes2.set(path6, { name: name5, method: method2, upstream });
|
|
187489
187495
|
}
|
|
187490
187496
|
const socketGrants = /* @__PURE__ */ new Map();
|
|
187491
187497
|
const modelHosts = new Set((options4.modelHosts ?? []).map(normalizeModelHost));
|
|
@@ -187649,7 +187655,15 @@ async function startIsolationGateway(options4) {
|
|
|
187649
187655
|
}
|
|
187650
187656
|
if (!upstream) {
|
|
187651
187657
|
const route16 = sessionRoutes2.get(path6);
|
|
187652
|
-
if (!route16
|
|
187658
|
+
if (!route16) return reject2(res);
|
|
187659
|
+
const status4 = req.method !== route16.method ? 405 : req.headers.authorization !== `Bearer ${session2.token}` ? 401 : void 0;
|
|
187660
|
+
if (status4 !== void 0) {
|
|
187661
|
+
try {
|
|
187662
|
+
options4.onSessionRefused?.(route16.name, status4);
|
|
187663
|
+
} catch {
|
|
187664
|
+
}
|
|
187665
|
+
return reject2(res, status4, status4 === 405 ? `${route16.name} takes ${route16.method}.` : `${route16.name} takes Authorization: Bearer $ANCHA_TRIAL_TOKEN.`);
|
|
187666
|
+
}
|
|
187653
187667
|
upstream = route16.upstream;
|
|
187654
187668
|
if (path6 === "/_ancha/context") transform3 = "context";
|
|
187655
187669
|
}
|
package/lib/assets/ui/app.js
CHANGED
|
@@ -22222,7 +22222,7 @@ function starterCount(tool, key, state) {
|
|
|
22222
22222
|
}
|
|
22223
22223
|
|
|
22224
22224
|
// frontend/src/generated/coding-agent-skill.ts
|
|
22225
|
-
var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, built from its production traces, and prove a fix with graded runs in the cloud. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company or rebuilt from a production trace, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself. `ancha run --on cloud` runs each attempt on a fresh machine of its own in Ancha's cloud.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; `ancha traces upload` prints the tests it made. `env list` and `sandbox list` return arrays; trace commands use the fields described in `ancha docs traces`. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, test files (`scene.yaml`) and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## First steps\n\n<!-- ancha:first-steps -->\n1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.\n ```sh\n npm install -g @ancha-labs/cli\n ancha login\n ```\n2. **Set up the project.** Run it in the agent's project: it finds the command that starts the agent and how the agent takes its task, and writes both to `ancha.yaml`. It installs and runs nothing.\n ```sh\n ancha init\n ```\n - To name the command yourself: `ancha init --agent \"<the command that starts your agent>\"`.\n - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.\n - **Composio agents.** Init detects Python `composio` / `composio_client` and TypeScript `@composio/core`, and finds tools from explicit toolkit lists and tool slugs. It writes each available Composio route under `agent.routes` and adds `COMPOSIO_API_KEY` to `agent.pass_env`, preserving existing settings. The world of each test decides which routed tools answer there.\n - When init asks which tools the agent reaches through Composio, ask the user which tools they use. Set `agent.routes.<tool>: composio` for each routed tool (for example, `agent.routes.quickbooks: composio`) and add `COMPOSIO_API_KEY` to `agent.pass_env` in `ancha.yaml`. Configure the Composio client to read `COMPOSIO_BASE_URL` from the attempt environment.\n - For a routed agent with no tests or traces, init writes a starter test that reads from each routed tool, plus the QuickBooks examples when the agent uses QuickBooks. Routed tests run in the cloud: with `COMPOSIO_API_KEY` in your shell, the steps below store it, upload the agent and run the tests.\n3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:\n - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.\n - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.\n4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.\n ```sh\n ancha secrets set ANTHROPIC_API_KEY\n ```\n5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.\n ```sh\n ancha agent upload\n ```\n - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.\n6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.\n - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.\n - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.\n - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.\n ```sh\n ancha traces upload ./traces\n ```\n - From Langfuse or LangSmith, with your keys on this computer: `ancha traces upload --from langfuse --limit 50`, or `--from langsmith`.\n - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect \"<what went wrong>\"`, or for a test already made, `ancha pull <test id> --expect \"<what went wrong>\"`.\n - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.\n - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.\n - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success=\"<end state>\"` makes completing the request decide it too.\n8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.\n ```sh\n ancha run\n ```\n - Your agent and its worlds run in the cloud, each attempt on a fresh machine of its own; a run keeps going when your laptop closes, and its results land in Runs.\n - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.\n - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.\n - `ancha status` shows which of these steps your workspace has done.\n9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.\n ```sh\n ancha baseline save before --from <run id>\n ancha run --compare before\n ```\n - Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.\n10. **Run it on this computer.** While you develop, `ancha run --on local` runs the agent and its worlds on this computer, with the same checks; an agent whose tools go through Composio runs in the cloud.\n ```sh\n ancha run --on local --attempts 1\n ```\n - Here the agent gets the keys in `agent.pass_env` from your shell, and model-graded checks need `OPENROUTER_API_KEY`.\n<!-- /ancha:first-steps -->\n\n## Cloud runs\n\n- `ancha run --on cloud` sends the project as one bundle: the agent's files, without hidden directories, dependencies or credential-like files, and its tests with their worlds and checks, which stay with the grader and never reach the agent. Each attempt's machine installs the dependencies, runs the agent and grades it with the same engine as a run on this computer. `--attempts <n>` sets the attempts per test, `--concurrency <n>` how many run at once.\n- The agent gets the workspace's secrets for the names in `agent.pass_env`, and its network reaches its tools and its model providers. Model-graded checks and the people in a world run on the workspace's model credit.\n- The `run_finished` event carries `url` (the result in the workspace) and `summary`, with `counts` of the attempts: requested, completed, invalid, skipped and cancelled. Interrupting the command stops the following, never the run: `ancha wait <run id>` follows it again, and `--detach` returns once the run is accepted.\n- `ancha explain <run id> --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n- When every attempt ended before the agent did anything (it exited within seconds without a call, or its command could not start), the run, `ancha wait` and `ancha explain` say that first: \"Your agent didn't run\", the end of its log once, and the likely fix read from it, such as the `agent.env` line that gives the agent its task under the name it reads. `agentNeverRan` in the JSON carries the same. Make that fix first: the failed checks follow from it, and `ancha explain <run id> --all` lists them.\n- `ancha status --json` shows the workspace's three steps (agent uploaded, tests added, tests run in the cloud) and the next command. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login. More: `ancha docs cloud`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per attempt with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every attempt: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## More from production traces\n\n`ancha traces upload <file or folder> --json` sends the traces to the workspace, which rebuilds each one's world and checks, and writes each test to `scenes/from-traces/<name>/scene.yaml`: runs that went fine and runs that failed. `--from langfuse` or `--from langsmith` takes the newest traces there instead (`--limit`, `--since`), with the keys in this shell. For one trace of a failure, `--expect \"<what went wrong>\"` adds a check for it. A test lists the questions one trace cannot settle, each with the default it uses. Ask the user for the answers; don't guess them. Pass them with `ancha pull <test id> --answer <question>=<value>`. `ancha import --offline <trace file> --json` makes the tests on this computer instead, one per conversation, and uploads nothing; there, `--answer` and `--force` go on the import.\n\nA test from a run that failed should fail the same way production did. If it doesn't, run it on this computer: `ancha traces diff <trace file> latest` shows the calls production made and the attempt didn't, and the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\n\nIf the user's workspace takes traces (their agents send them to it), each trace becomes a test there: `ancha pull --all --json` writes every test that is turned on (`--agent <name>` for one agent's), `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` writes one, 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. More: `ancha docs traces`.\n\n## Other tests\n\nThe starter test `ancha init` writes when `scenes/` holds no tests only proves that the agent reaches each tool. For the agent's real job beyond its traces, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a test can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not the tests or their checks. `ancha.yaml` says how to start the agent and give it its task and keys: change it for that, never to make a check pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the tests, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach attempt gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task, and `ANCHA_TASK_FILE` names a file holding it. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: \"{{task}}\" }` (`{{task_file}}` for the file); `ancha init` writes that line when it finds the name.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\nThe agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as `agent.pass_env: [OPENAI_API_KEY]`, and `agent.env` sets fixed values, such as the path of a key file. In the cloud each name comes from the workspace's secrets (`ancha secrets set NAME`). `ancha run --on local` starts the agent on this computer instead, with this computer's network and those names from this shell (or `--pass-env NAME`); `--on docker` seals it in a container (`agent.execution: { mode: container, image: node:24-slim }`, which needs Docker). An agent without its model key stops at its first model call.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.\n- Exit 2: usage, config, test file 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`.\n- 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 agent upload --json` if it repeats.\n- 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.\n\nRead 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.\n\nTell the user what you ran, where it ran, the pass rate, the evidence and the result link. Never claim a fix until `ancha run --compare` exits 0.\n";
|
|
22225
|
+
var codingAgentSkill = "---\nname: ancha\ndescription: Test, debug and fix an AI agent (a Slack bot, a support or on-call agent) against stateful replicas of the tools it uses, built from its production traces, and prove a fix with graded runs in the cloud. Use when asked to test an agent with Ancha, or in a repository that has ancha.yaml.\n---\n\n# Ancha\n\nAncha gives an AI agent the other side of its job: stateful replicas of the tools it uses (Slack, GitHub, Datadog, PagerDuty and more), seeded with one fictional company or rebuilt from a production trace, and checks that grade every attempt from the agent's calls and the world's end state. The verdict comes from the world, not from mocks you wrote yourself. `ancha run --on cloud` runs each attempt on a fresh machine of its own in Ancha's cloud.\n\n## Run the CLI\n\nBefore the CLI is installed, run every command as `npx -y @ancha-labs/cli <command>`. After `npm install -g @ancha-labs/cli` (Node 24 or newer), run `ancha <command>`. Never run `npx` with the bare name `ancha`: that npm name is not this package.\n\nAdd `--json` to every command. Runs print NDJSON events that end with `run_finished`; `ancha traces upload` prints the tests it made. `env list` and `sandbox list` return arrays; trace commands use the fields described in `ancha docs traces`. `ancha schema <kind> --json` prints the JSON Schema of `ancha.yaml`, test files (`scene.yaml`) and these outputs. If your command can time out, give `ancha run` an `--idempotency-key <key>`: running it again with the same key returns the same run instead of starting another.\n\n## First steps\n\n<!-- ancha:first-steps -->\n1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.\n ```sh\n npm install -g @ancha-labs/cli\n ancha login\n ```\n2. **Set up the project.** Run it in the agent's project: it finds the command that starts the agent and how the agent takes its task, and writes both to `ancha.yaml`. It installs and runs nothing.\n ```sh\n ancha init\n ```\n - To name the command yourself: `ancha init --agent \"<the command that starts your agent>\"`.\n - To name its tools yourself (NetSuite, Slack, ...): `ancha init --tools netsuite,slack`.\n - **Composio agents.** Init detects Python `composio` / `composio_client` and TypeScript `@composio/core`, and finds tools from explicit toolkit lists and tool slugs. It writes each available Composio route under `agent.routes` and adds `COMPOSIO_API_KEY` to `agent.pass_env`, preserving existing settings. The world of each test decides which routed tools answer there.\n - When init asks which tools the agent reaches through Composio, ask the user which tools they use. Set `agent.routes.<tool>: composio` for each routed tool (for example, `agent.routes.quickbooks: composio`) and add `COMPOSIO_API_KEY` to `agent.pass_env` in `ancha.yaml`. Configure the Composio client to read `COMPOSIO_BASE_URL` from the attempt environment.\n - For a routed agent with no tests or traces, init writes a starter test that reads from each routed tool, plus the QuickBooks examples when the agent uses QuickBooks. Routed tests run in the cloud: with `COMPOSIO_API_KEY` in your shell, the steps below store it, upload the agent and run the tests.\n3. **Point the agent at Ancha's tools.** In a test, the agent calls Ancha instead of production:\n - Its clients for Slack, GitHub and the other tools Ancha replicates take the URLs and credentials Ancha supplies: `ancha connect <tool>` prints the settings.\n - Its own functions: wrap them with `wrapTools` from `@ancha-labs/tools` (`ancha.wrap_tools` in Python), or serve them over MCP.\n4. **Store the key it needs.** The agent's own model key, read from your shell, never from an argument: it is stored in your workspace and named under `agent.pass_env` in `ancha.yaml`, so the agent gets it in every cloud attempt.\n ```sh\n ancha secrets set ANTHROPIC_API_KEY\n ```\n5. **Upload your agent.** A fresh machine in the cloud installs the project's dependencies and starts the agent once with a task. It says the agent is ready, or shows the end of its log.\n ```sh\n ancha agent upload\n ```\n - The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.\n6. **Without production traces.** For an agent that calls NetSuite directly, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests: 10 read tasks and 15 write workflows; an agent that reaches NetSuite through Composio gets the same books and the 10 read tasks. For an agent that uses QuickBooks, it writes Pellmont Building Services' 2025 books and two tests: `pellmont-duplicates` reports the duplicate vendors, the invoices and bills entered twice and the money at stake without changing the books, and `pellmont-approved-merge` merges the three duplicate vendor pairs as approved and changes nothing else.\n - Variants: once `pellmont-duplicates` passes, `ancha test vary ancha/tests/pellmont-duplicates.yaml` writes ten variants of it, each changing one thing in the books with the expected findings recalculated; run them with the command it prints.\n - Your data: `ancha world import netsuite <your exports> --id <id>` reads REST record JSON, SuiteQL results and saved search CSV into `ancha/worlds/<id>.yaml`; check it with `ancha world validate`. To write the seed yourself, `ancha twins seed netsuite` lists its fields.\n - Your evals: `ancha test import <file>` (JSONL, JSON, CSV or YAML with a question and an expected answer) writes tests for the only world in `ancha/worlds/`, or the one `--world <id>` names; with none, `ancha init --on local --template starter` adds one.\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n7. **Upload traces.** A file or a folder of traces, runs that went fine and runs that failed: each trace becomes a test, in `scenes/from-traces/` and in your workspace.\n ```sh\n ancha traces upload ./traces\n ```\n - From Langfuse or LangSmith, with your keys on this computer: `ancha traces upload --from langfuse --limit 50`, or `--from langsmith`.\n - A trace of a run that went wrong can say what went wrong: `ancha traces upload <trace file> --expect \"<what went wrong>\"`, or for a test already made, `ancha pull <test id> --expect \"<what went wrong>\"`.\n - Traces your agent already sent to your workspace: `ancha traces`, then `ancha pull <trace id>`.\n - A test lists what one trace cannot settle: answer with `ancha pull <test id> --answer <question>=<answer>`.\n - A check marked `(optional)` is graded and shown, and the required checks decide the test; `ancha pull <test id> --answer checks.success=\"<end state>\"` makes completing the request decide it too.\n8. **Run your tests.** Every test, each attempt on a fresh machine. The run grades each attempt check by check and ends with the link to its result.\n ```sh\n ancha run\n ```\n - Your agent and its worlds run in the cloud, each attempt on a fresh machine of its own; a run keeps going when your laptop closes, and its results land in Runs.\n - `--attempts <n>` sets how many attempts each test gets, `--concurrency <n>` how many run at once.\n - `ancha wait <run id>` follows a run again from any terminal; `ancha explain <run id>` shows why a check failed.\n - `ancha status` shows which of these steps your workspace has done.\n9. **Fix the agent and keep the test.** Keep the failing run as the reference, fix the agent, and run again: exit 0 means every required check passes and nothing regressed.\n ```sh\n ancha baseline save before --from <run id>\n ancha run --compare before\n ```\n - Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.\n10. **Run it on this computer.** While you develop, `ancha run --on local` runs the agent and its worlds on this computer, with the same checks; an agent whose tools go through Composio runs in the cloud.\n ```sh\n ancha run --on local --attempts 1\n ```\n - Here the agent gets the keys in `agent.pass_env` from your shell, and model-graded checks need `OPENROUTER_API_KEY`.\n<!-- /ancha:first-steps -->\n\n## Cloud runs\n\n- `ancha run --on cloud` sends the project as one bundle: the agent's files, without hidden directories, dependencies or credential-like files, and its tests with their worlds and checks, which stay with the grader and never reach the agent. Each attempt's machine installs the dependencies, runs the agent and grades it with the same engine as a run on this computer. `--attempts <n>` sets the attempts per test, `--concurrency <n>` how many run at once.\n- The agent gets the workspace's secrets for the names in `agent.pass_env`, and its network reaches its tools and its model providers. Model-graded checks and the people in a world run on the workspace's model credit.\n- The `run_finished` event carries `url` (the result in the workspace) and `summary`, with `counts` of the attempts: requested, completed, invalid, skipped and cancelled. Interrupting the command stops the following, never the run: `ancha wait <run id>` follows it again, and `--detach` returns once the run is accepted.\n- `ancha explain <run id> --json` shows each failed check: what was expected, what happened, and the calls and world events behind it. Read it before guessing from the code; many bugs only show up with the world's data and timing.\n- When every attempt ended before the agent did anything (it exited within seconds without a call, or its command could not start), the run, `ancha wait` and `ancha explain` say that first: \"Your agent didn't run\", the end of its log once, and the likely fix read from it, such as the `agent.env` line that gives the agent its task under the name it reads. `agentNeverRan` in the JSON carries the same. Make that fix first: the failed checks follow from it, and `ancha explain <run id> --all` lists them.\n- `ancha status --json` shows the workspace's three steps (agent uploaded, tests added, tests run in the cloud) and the next command. In CI, `ANCHA_SERVER_URL` and `ANCHA_API_KEY` replace the login. More: `ancha docs cloud`.\n\n## An app, not a command\n\nIf the AI feature lives inside an app (a web app or API server with its database, workers and scheduled jobs), don't wrap it in `agent.command`. Ancha starts the app once per attempt with `agent.start`, waits for `agent.ready_url`, delivers the tools' events to `agent.url`, and a scene's `world_rules.app_calls` call the app's own routes, such as its cron jobs, at a time. Read `ancha docs apps` before writing `ancha.yaml`. The start script gives the app a clean database, cache and seed every attempt: a new world has new URLs and tokens, and stale rows or sync cursors make an app silently do nothing.\n\n## More from production traces\n\n`ancha traces upload <file or folder> --json` sends the traces to the workspace, which rebuilds each one's world and checks, and writes each test to `scenes/from-traces/<name>/scene.yaml`: runs that went fine and runs that failed. `--from langfuse` or `--from langsmith` takes the newest traces there instead (`--limit`, `--since`), with the keys in this shell. For one trace of a failure, `--expect \"<what went wrong>\"` adds a check for it. A test lists the questions one trace cannot settle, each with the default it uses. Ask the user for the answers; don't guess them. Pass them with `ancha pull <test id> --answer <question>=<value>`. `ancha import --offline <trace file> --json` makes the tests on this computer instead, one per conversation, and uploads nothing; there, `--answer` and `--force` go on the import.\n\nA test from a run that failed should fail the same way production did. If it doesn't, run it on this computer: `ancha traces diff <trace file> latest` shows the calls production made and the attempt didn't, and the import also lists the app's own setup calls, which the start script or an `app_call` has to make.\n\nIf the user's workspace takes traces (their agents send them to it), each trace becomes a test there: `ancha pull --all --json` writes every test that is turned on (`--agent <name>` for one agent's), `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` writes one, 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. More: `ancha docs traces`.\n\n## Other tests\n\nThe starter test `ancha init` writes when `scenes/` holds no tests only proves that the agent reaches each tool. For the agent's real job beyond its traces, `ancha test new \"<the test in one sentence>\" --json` drafts a test with people for the project's world (`ancha init --intent \"<company and scenario>\"` makes the world and a first test). Review its checks before you run it. To write a seed yourself, `ancha twins seed <tool> --json` prints the tool's fields, an example that validates as written, and the checks a test can make on it. More: `ancha docs scenes`.\n\n## The rule\n\nFix the agent, not the tests or their checks. `ancha.yaml` says how to start the agent and give it its task and keys: change it for that, never to make a check pass. The exception is a check that is wrong for the real API, such as a method the official SDK never sends. Then don't quietly edit it: tell the user, show the evidence (the call from `ancha explain`, the vendor's documentation), and change it only with their agreement.\n\nNever give the agent under test the tests, checks, seeds or reference companions (`oracle.mjs`, `null.mjs`), and never point it at a real SaaS API.\n\n## What the agent gets\n\nEach attempt gives the agent its tools as environment variables, with fake credentials that only work against the replicas:\n\n- Slack: `SLACK_API_URL` (ends in `/api/`), `SLACK_BOT_TOKEN`\n- GitHub: `GITHUB_API_URL`, `GITHUB_TOKEN`\n- Datadog: `DATADOG_API_URL`, `DD_API_KEY`, `DD_APP_KEY`\n- PagerDuty: `PAGERDUTY_API_URL`, `PAGERDUTY_API_TOKEN`, `PAGERDUTY_FROM_EMAIL`, `PAGERDUTY_ROUTING_KEY`\n- the same pattern for the other tools in the world; `ANCHA_TASK` carries a command-line task, and `ANCHA_TASK_FILE` names a file holding it. An agent that reads its task under another name gets it with `agent.env: { MY_TASK: \"{{task}}\" }` (`{{task_file}}` for the file); `ancha init` writes that line when it finds the name.\n\n`ancha connect <tool> --lang ts|py` prints the SDK settings. `ancha twins coverage <tool>` lists the endpoints each replica implements.\n\nGoogle clients (`googleapis`, `@googleapis/*`) take the replica's URL in each call's options: `drive.files.list(params, { rootUrl: process.env.GOOGLE_DRIVE_API_URL + '/' })`. A `rootUrl` set on the client keeps only the host; Ancha still routes those calls by their token, but the client sends file uploads to www.googleapis.com.\n\nThe agent's own keys are the names in `agent.pass_env` in `ancha.yaml`, such as `agent.pass_env: [OPENAI_API_KEY]`, and `agent.env` sets fixed values, such as the path of a key file. In the cloud each name comes from the workspace's secrets (`ancha secrets set NAME`). `ancha run --on local` starts the agent on this computer instead, with this computer's network and those names from this shell (or `--pass-env NAME`); `--on docker` seals it in a container (`agent.execution: { mode: container, image: node:24-slim }`, which needs Docker). An agent without its model key stops at its first model call.\n\n## When something fails\n\n- Exit 1: a check failed or the comparison regressed (a single check's drop counts, see `comparison.droppedChecks`). Run `ancha explain <run id> --json`.\n- Exit 2: usage, config, test file 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`.\n- 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 agent upload --json` if it repeats.\n- 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.\n\nRead 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.\n\nTell the user what you ran, where it ran, the pass rate, the evidence and the result link. Never claim a fix until `ancha run --compare` exits 0.\n";
|
|
22226
22226
|
|
|
22227
22227
|
// frontend/src/workspace-pages.ts
|
|
22228
22228
|
var startSentence = "Set up Ancha for this agent: read https://app.ancha.io/llms.txt and follow its first steps.";
|
package/lib/worker.mjs
CHANGED
|
@@ -71574,10 +71574,10 @@ async function startIsolationGateway(options5) {
|
|
|
71574
71574
|
roots.set(root3, upstream);
|
|
71575
71575
|
}
|
|
71576
71576
|
const sessionRoutes2 = /* @__PURE__ */ new Map();
|
|
71577
|
-
if (session2) for (const [field6, path8, method2] of [["eventsUrl", "/_ancha/events", "GET"], ["contextUrl", "/_ancha/context", "GET"], ["doneUrl", "/_ancha/done", "POST"]]) {
|
|
71577
|
+
if (session2) for (const [field6, path8, method2, name5] of [["eventsUrl", "/_ancha/events", "GET", "ANCHA_EVENTS_URL"], ["contextUrl", "/_ancha/context", "GET", "ANCHA_CONTEXT_URL"], ["doneUrl", "/_ancha/done", "POST", "ANCHA_DONE_URL"]]) {
|
|
71578
71578
|
const upstream = loopbackOrigin(session2[field6]);
|
|
71579
71579
|
if (upstream.pathname !== path8 || upstream.search || upstream.hash) throw new Error("Invalid trial session route");
|
|
71580
|
-
sessionRoutes2.set(path8, { method: method2, upstream });
|
|
71580
|
+
sessionRoutes2.set(path8, { name: name5, method: method2, upstream });
|
|
71581
71581
|
}
|
|
71582
71582
|
const socketGrants = /* @__PURE__ */ new Map();
|
|
71583
71583
|
const modelHosts = new Set((options5.modelHosts ?? []).map(normalizeModelHost));
|
|
@@ -71741,7 +71741,15 @@ async function startIsolationGateway(options5) {
|
|
|
71741
71741
|
}
|
|
71742
71742
|
if (!upstream) {
|
|
71743
71743
|
const route16 = sessionRoutes2.get(path8);
|
|
71744
|
-
if (!route16
|
|
71744
|
+
if (!route16) return reject2(res);
|
|
71745
|
+
const status5 = req.method !== route16.method ? 405 : req.headers.authorization !== `Bearer ${session2.token}` ? 401 : void 0;
|
|
71746
|
+
if (status5 !== void 0) {
|
|
71747
|
+
try {
|
|
71748
|
+
options5.onSessionRefused?.(route16.name, status5);
|
|
71749
|
+
} catch {
|
|
71750
|
+
}
|
|
71751
|
+
return reject2(res, status5, status5 === 405 ? `${route16.name} takes ${route16.method}.` : `${route16.name} takes Authorization: Bearer $ANCHA_TRIAL_TOKEN.`);
|
|
71752
|
+
}
|
|
71745
71753
|
upstream = route16.upstream;
|
|
71746
71754
|
if (path8 === "/_ancha/context") transform3 = "context";
|
|
71747
71755
|
}
|
|
@@ -214459,12 +214467,12 @@ function queryRecords(ctx, sql5) {
|
|
|
214459
214467
|
if (!confirmed.has(key5) && !["TimeActivity", "Attachable", "TaxAgency", "ExchangeRate"].includes(type)) hasGap = true;
|
|
214460
214468
|
return key5;
|
|
214461
214469
|
}
|
|
214462
|
-
const typed = (key5,
|
|
214463
|
-
if (typeof
|
|
214470
|
+
const typed = (key5, value6) => {
|
|
214471
|
+
if (typeof value6 !== "string") return value6;
|
|
214464
214472
|
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
214465
|
-
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(
|
|
214466
|
-
if (declared === "boolean" && /^(true|false)$/i.test(
|
|
214467
|
-
return
|
|
214473
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value6)) return Number(value6);
|
|
214474
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value6)) return value6.toLowerCase() === "true";
|
|
214475
|
+
return value6;
|
|
214468
214476
|
};
|
|
214469
214477
|
projection = projection?.map((p2) => property4(p2));
|
|
214470
214478
|
const conditions = [];
|
|
@@ -214477,6 +214485,11 @@ function queryRecords(ctx, sql5) {
|
|
|
214477
214485
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
214478
214486
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
214479
214487
|
};
|
|
214488
|
+
const value5 = (key5) => {
|
|
214489
|
+
const token5 = ts3[i], read6 = typed(key5, literal2());
|
|
214490
|
+
if (token5?.kind === "number" && fields13.find((f2) => f2[0] === key5)?.[1] === "string") parseError2(`${key5} is text: give its value in single quotes.`);
|
|
214491
|
+
return read6;
|
|
214492
|
+
};
|
|
214480
214493
|
if (peek("WHERE")) {
|
|
214481
214494
|
i++;
|
|
214482
214495
|
do {
|
|
@@ -214485,10 +214498,10 @@ function queryRecords(ctx, sql5) {
|
|
|
214485
214498
|
const op = ts3[i++]?.text.toUpperCase();
|
|
214486
214499
|
if (op === "IN") {
|
|
214487
214500
|
take2("(");
|
|
214488
|
-
const values3 = [
|
|
214501
|
+
const values3 = [value5(key5)];
|
|
214489
214502
|
while (peek(",")) {
|
|
214490
214503
|
i++;
|
|
214491
|
-
values3.push(
|
|
214504
|
+
values3.push(value5(key5));
|
|
214492
214505
|
}
|
|
214493
214506
|
take2(")");
|
|
214494
214507
|
conditions.push((row2) => {
|
|
@@ -214501,17 +214514,17 @@ function queryRecords(ctx, sql5) {
|
|
|
214501
214514
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
214502
214515
|
conditions.push((row2) => {
|
|
214503
214516
|
const actual = scalar2(row2, key5);
|
|
214504
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
214505
|
-
const v = String(
|
|
214517
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value6) => {
|
|
214518
|
+
const v = String(value6 ?? "").toLowerCase();
|
|
214506
214519
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
214507
214520
|
});
|
|
214508
214521
|
});
|
|
214509
214522
|
} else {
|
|
214510
214523
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
214511
|
-
const expected =
|
|
214524
|
+
const expected = value5(key5);
|
|
214512
214525
|
conditions.push((row2) => {
|
|
214513
|
-
const
|
|
214514
|
-
return (Array.isArray(
|
|
214526
|
+
const value6 = scalar2(row2, key5);
|
|
214527
|
+
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
214515
214528
|
let actual = item2, target5 = expected;
|
|
214516
214529
|
if (actual === void 0) return false;
|
|
214517
214530
|
if (key5.startsWith("MetaData.")) {
|
|
@@ -220324,6 +220337,7 @@ var init_sessions5 = __esm({
|
|
|
220324
220337
|
});
|
|
220325
220338
|
}
|
|
220326
220339
|
authenticate(token5, allowFinished = false) {
|
|
220340
|
+
if (!token5) throw new AnchaError("SESSION_UNAUTHORIZED", "invalid session capability", { hint: "send Authorization: Bearer $ANCHA_TRIAL_TOKEN" });
|
|
220327
220341
|
const env = token5 ? this.#manager.list().find((env2) => this.#records.get(env2)?.session.token === token5) : void 0;
|
|
220328
220342
|
const record15 = env ? this.#records.get(env) : void 0;
|
|
220329
220343
|
if (!env || !record15 || record15.signal !== env.signal) throw new AnchaError("SESSION_UNAUTHORIZED", "invalid session capability");
|
|
@@ -223720,7 +223734,7 @@ function withoutScriptBanners(lines) {
|
|
|
223720
223734
|
function stdoutAnswer(stdout) {
|
|
223721
223735
|
return withoutScriptBanners(stdout.replace(ANSI, "").replace(/\r\n?/g, "\n").trimEnd().split("\n")).join("\n").trimEnd();
|
|
223722
223736
|
}
|
|
223723
|
-
var ANSWER_MAX_CHARS, STDOUT_MAX_CHARS, OutputTail, ModelReplies, ANSI, NPM_SCRIPT, NPM_COMMAND, YARN_RUN, YARN_COMMAND, YARN_DONE;
|
|
223737
|
+
var ANSWER_MAX_CHARS, STDOUT_MAX_CHARS, OutputTail, ModelReplies, SessionRefusals, ANSI, NPM_SCRIPT, NPM_COMMAND, YARN_RUN, YARN_COMMAND, YARN_DONE;
|
|
223724
223738
|
var init_agent_output = __esm({
|
|
223725
223739
|
"backend/src/runner/agent-output.ts"() {
|
|
223726
223740
|
"use strict";
|
|
@@ -223775,6 +223789,17 @@ var init_agent_output = __esm({
|
|
|
223775
223789
|
return this.#last !== void 0 && MODEL_REFUSALS.has(this.#last.status) ? { ...this.#last } : void 0;
|
|
223776
223790
|
}
|
|
223777
223791
|
};
|
|
223792
|
+
SessionRefusals = class {
|
|
223793
|
+
#counts = /* @__PURE__ */ new Map();
|
|
223794
|
+
add(name5, status5) {
|
|
223795
|
+
const key5 = `${name5} ${status5}`, refusal = this.#counts.get(key5);
|
|
223796
|
+
if (refusal) refusal.count++;
|
|
223797
|
+
else this.#counts.set(key5, { name: name5, status: status5, count: 1 });
|
|
223798
|
+
}
|
|
223799
|
+
list() {
|
|
223800
|
+
return [...this.#counts.values()].map((refusal) => ({ ...refusal }));
|
|
223801
|
+
}
|
|
223802
|
+
};
|
|
223778
223803
|
ANSI = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
223779
223804
|
NPM_SCRIPT = /^> (?:\S+@\S* )?[\w:.-]+(?: \/\S*)?$/;
|
|
223780
223805
|
NPM_COMMAND = /^> \S/;
|
|
@@ -224714,8 +224739,8 @@ async function startContainedAgent(command, opts) {
|
|
|
224714
224739
|
"exec sleep 86400"
|
|
224715
224740
|
]);
|
|
224716
224741
|
await run5(["start", relayName]);
|
|
224717
|
-
const replies = new ModelReplies();
|
|
224718
|
-
gateway2 = await startIsolationGateway({ env: opts.env, session: opts.session, modelHosts: policy.modelHosts, ...opts.onModelActivity && { onModelActivity: opts.onModelActivity }, onModelReply: (host, status6, message8) => replies.add(host, status6, message8) });
|
|
224742
|
+
const replies = new ModelReplies(), refusals = new SessionRefusals();
|
|
224743
|
+
gateway2 = await startIsolationGateway({ env: opts.env, session: opts.session, modelHosts: policy.modelHosts, ...opts.onModelActivity && { onModelActivity: opts.onModelActivity }, onModelReply: (host, status6, message8) => replies.add(host, status6, message8), onSessionRefused: (name5, status6) => refusals.add(name5, status6) });
|
|
224719
224744
|
const script2 = isolationRelayScript({ port: RELAY_PORT, ...opts.runtime?.port && { agentPort: opts.runtime.port } });
|
|
224720
224745
|
relayChild = spawn2("docker", ["--context", context3, "exec", "-i", relayName, "node", "-e", script2], { env: dockerEnvironment(), stdio: ["pipe", "pipe", "pipe"] });
|
|
224721
224746
|
relayChild.stderr.on("data", () => {
|
|
@@ -224807,7 +224832,7 @@ async function startContainedAgent(command, opts) {
|
|
|
224807
224832
|
return { pid: child3.pid, exited, async stop() {
|
|
224808
224833
|
await cleanup();
|
|
224809
224834
|
await exited;
|
|
224810
|
-
}, output: () => ({ stdout: tail.text(), printed: tail.length(), modelReplies: replies.list(), modelRefusal: replies.refusal() }) };
|
|
224835
|
+
}, output: () => ({ stdout: tail.text(), printed: tail.length(), modelReplies: replies.list(), sessionRefusals: refusals.list(), modelRefusal: replies.refusal() }) };
|
|
224811
224836
|
} catch (error64) {
|
|
224812
224837
|
opts.signal?.removeEventListener("abort", abort);
|
|
224813
224838
|
await cleanup();
|
|
@@ -225026,7 +225051,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
225026
225051
|
await chmod3(taskFile, 292);
|
|
225027
225052
|
await chmod3(directory, 457);
|
|
225028
225053
|
}
|
|
225029
|
-
const replies = new ModelReplies();
|
|
225054
|
+
const replies = new ModelReplies(), refusals = new SessionRefusals();
|
|
225030
225055
|
gateway2 = await (deps.gateway ?? startIsolationGateway)({
|
|
225031
225056
|
...composio && { composio },
|
|
225032
225057
|
env: opts.env,
|
|
@@ -225035,7 +225060,8 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
225035
225060
|
port: unsafe ? 0 : 18991,
|
|
225036
225061
|
slackSocket: opts.agent.slackTransport === "socket",
|
|
225037
225062
|
...opts.onModelActivity && { onModelActivity: opts.onModelActivity },
|
|
225038
|
-
onModelReply: (host, status5, message8) => replies.add(host, status5, message8)
|
|
225063
|
+
onModelReply: (host, status5, message8) => replies.add(host, status5, message8),
|
|
225064
|
+
onSessionRefused: (name5, status5) => refusals.add(name5, status5)
|
|
225039
225065
|
});
|
|
225040
225066
|
const mapped = gateway2.rewrite(unsafe ? gateway2.url : VM_GATEWAY_ORIGIN);
|
|
225041
225067
|
const agentRuntime = { ...opts.runtime, ...taskFile !== void 0 && { taskFile }, ...opts.runtime?.attempt && { attempt: { ...opts.runtime.attempt, stateDir: paths3.state, records: records5 } } };
|
|
@@ -225163,7 +225189,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
225163
225189
|
return { pid: child3.pid, exited, async stop() {
|
|
225164
225190
|
await cleanup();
|
|
225165
225191
|
await exited;
|
|
225166
|
-
}, output: () => ({ stdout: tail.text(), printed: tail.length(), modelReplies: replies.list(), modelRefusal: replies.refusal() }) };
|
|
225192
|
+
}, output: () => ({ stdout: tail.text(), printed: tail.length(), modelReplies: replies.list(), sessionRefusals: refusals.list(), modelRefusal: replies.refusal() }) };
|
|
225167
225193
|
} catch (error64) {
|
|
225168
225194
|
await cleanup();
|
|
225169
225195
|
throw error64;
|
|
@@ -226065,6 +226091,7 @@ async function runTrialInner(spec) {
|
|
|
226065
226091
|
...playOut !== void 0 && playOut.toMs > playOut.fromMs && { playOut },
|
|
226066
226092
|
checks: checks2,
|
|
226067
226093
|
...output2?.modelReplies?.length && { modelReplies: output2.modelReplies },
|
|
226094
|
+
...output2?.sessionRefusals?.length && { sessionRefusals: output2.sessionRefusals },
|
|
226068
226095
|
logTail: exit === "idle" || exit === "done" || exit === "exited" && exitCode === 0 ? [] : await logTail(join21(dir, "agent.log")),
|
|
226069
226096
|
// An agent that exits non-zero or dies by a signal on its own fails its trial whatever the checks say, as a per_event
|
|
226070
226097
|
// invocation does: an agent that crashed before its first call would otherwise pass every not_called check.
|
package/lib/world-server.mjs
CHANGED
|
@@ -182575,12 +182575,12 @@ function queryRecords(ctx, sql5) {
|
|
|
182575
182575
|
if (!confirmed.has(key5) && !["TimeActivity", "Attachable", "TaxAgency", "ExchangeRate"].includes(type)) hasGap = true;
|
|
182576
182576
|
return key5;
|
|
182577
182577
|
}
|
|
182578
|
-
const typed = (key5,
|
|
182579
|
-
if (typeof
|
|
182578
|
+
const typed = (key5, value6) => {
|
|
182579
|
+
if (typeof value6 !== "string") return value6;
|
|
182580
182580
|
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
182581
|
-
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(
|
|
182582
|
-
if (declared === "boolean" && /^(true|false)$/i.test(
|
|
182583
|
-
return
|
|
182581
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value6)) return Number(value6);
|
|
182582
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value6)) return value6.toLowerCase() === "true";
|
|
182583
|
+
return value6;
|
|
182584
182584
|
};
|
|
182585
182585
|
projection = projection?.map((p2) => property4(p2));
|
|
182586
182586
|
const conditions = [];
|
|
@@ -182593,6 +182593,11 @@ function queryRecords(ctx, sql5) {
|
|
|
182593
182593
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
182594
182594
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
182595
182595
|
};
|
|
182596
|
+
const value5 = (key5) => {
|
|
182597
|
+
const token5 = ts2[i], read6 = typed(key5, literal2());
|
|
182598
|
+
if (token5?.kind === "number" && fields13.find((f2) => f2[0] === key5)?.[1] === "string") parseError2(`${key5} is text: give its value in single quotes.`);
|
|
182599
|
+
return read6;
|
|
182600
|
+
};
|
|
182596
182601
|
if (peek("WHERE")) {
|
|
182597
182602
|
i++;
|
|
182598
182603
|
do {
|
|
@@ -182601,10 +182606,10 @@ function queryRecords(ctx, sql5) {
|
|
|
182601
182606
|
const op = ts2[i++]?.text.toUpperCase();
|
|
182602
182607
|
if (op === "IN") {
|
|
182603
182608
|
take2("(");
|
|
182604
|
-
const values3 = [
|
|
182609
|
+
const values3 = [value5(key5)];
|
|
182605
182610
|
while (peek(",")) {
|
|
182606
182611
|
i++;
|
|
182607
|
-
values3.push(
|
|
182612
|
+
values3.push(value5(key5));
|
|
182608
182613
|
}
|
|
182609
182614
|
take2(")");
|
|
182610
182615
|
conditions.push((row2) => {
|
|
@@ -182617,17 +182622,17 @@ function queryRecords(ctx, sql5) {
|
|
|
182617
182622
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
182618
182623
|
conditions.push((row2) => {
|
|
182619
182624
|
const actual = scalar2(row2, key5);
|
|
182620
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
182621
|
-
const v = String(
|
|
182625
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value6) => {
|
|
182626
|
+
const v = String(value6 ?? "").toLowerCase();
|
|
182622
182627
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
182623
182628
|
});
|
|
182624
182629
|
});
|
|
182625
182630
|
} else {
|
|
182626
182631
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
182627
|
-
const expected =
|
|
182632
|
+
const expected = value5(key5);
|
|
182628
182633
|
conditions.push((row2) => {
|
|
182629
|
-
const
|
|
182630
|
-
return (Array.isArray(
|
|
182634
|
+
const value6 = scalar2(row2, key5);
|
|
182635
|
+
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
182631
182636
|
let actual = item2, target5 = expected;
|
|
182632
182637
|
if (actual === void 0) return false;
|
|
182633
182638
|
if (key5.startsWith("MetaData.")) {
|
|
@@ -184481,6 +184486,7 @@ var TrialSessions = class {
|
|
|
184481
184486
|
});
|
|
184482
184487
|
}
|
|
184483
184488
|
authenticate(token5, allowFinished = false) {
|
|
184489
|
+
if (!token5) throw new AnchaError("SESSION_UNAUTHORIZED", "invalid session capability", { hint: "send Authorization: Bearer $ANCHA_TRIAL_TOKEN" });
|
|
184484
184490
|
const env = token5 ? this.#manager.list().find((env2) => this.#records.get(env2)?.session.token === token5) : void 0;
|
|
184485
184491
|
const record10 = env ? this.#records.get(env) : void 0;
|
|
184486
184492
|
if (!env || !record10 || record10.signal !== env.signal) throw new AnchaError("SESSION_UNAUTHORIZED", "invalid session capability");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancha-labs/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.51",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Simulation playgrounds for agents: run your agent against stateful replicas of Slack, GitHub, Datadog and more, each attempt on a fresh cloud machine in your app.ancha.io workspace, or on your computer.",
|
|
6
6
|
"bugs": {
|