@ancha-labs/cli 0.4.16 → 0.4.17
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 +926 -473
- 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/datasets.md +2 -2
- package/lib/assets/docs/scenes.md +1 -1
- package/lib/assets/docs/setup.md +2 -2
- package/lib/assets/docs/traces.md +1 -1
- package/lib/assets/harbor/companion.mjs +43 -25
- package/lib/assets/harbor/driver.py +17 -3
- package/lib/assets/ui/app.js +1 -1
- package/lib/mcp-entry.mjs +9 -5
- package/lib/worker.mjs +53 -25
- package/lib/world-server.mjs +43 -25
- package/package.json +1 -1
package/lib/assets/SKILL.md
CHANGED
|
@@ -36,7 +36,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
|
|
|
36
36
|
ancha agent upload
|
|
37
37
|
```
|
|
38
38
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
39
|
-
5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests
|
|
39
|
+
5. **Without production traces.** For an agent that uses NetSuite, `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.
|
|
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> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
|
|
42
42
|
- One test from a sentence: `ancha test new "<sentence>" --world <id>`.
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
ancha agent upload
|
|
22
22
|
```
|
|
23
23
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
24
|
-
5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests
|
|
24
|
+
5. **Without production traces.** For an agent that uses NetSuite, `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.
|
|
25
25
|
- 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.
|
|
26
26
|
- Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
|
|
27
27
|
- One test from a sentence: `ancha test new "<sentence>" --world <id>`.
|
package/lib/assets/docs/cloud.md
CHANGED
|
@@ -29,7 +29,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
|
|
|
29
29
|
ancha agent upload
|
|
30
30
|
```
|
|
31
31
|
- The install follows the project's own manifests and lockfiles; `agent.install` in `ancha.yaml` sets the command instead.
|
|
32
|
-
5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests
|
|
32
|
+
5. **Without production traces.** For an agent that uses NetSuite, `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.
|
|
33
33
|
- 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.
|
|
34
34
|
- Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
|
|
35
35
|
- One test from a sentence: `ancha test new "<sentence>" --world <id>`.
|
|
@@ -8,7 +8,7 @@ A world file (`ancha/worlds/<id>.yaml`) holds the records your agent's tools sta
|
|
|
8
8
|
ancha world gen --dataset netsuite-pe --size m
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
This writes the books of a private-equity portfolio company, `ancha/worlds/netsuite-pe-m.yaml`, and
|
|
11
|
+
This writes the books of a private-equity portfolio company, `ancha/worlds/netsuite-pe-m.yaml`, and 10 read tasks and 15 write workflows with computed answers and final-state checks, `ancha/evals/netsuite-pe-m.jsonl`. It needs no model and no description: the same size always gives the same files. The company has four subsidiaries, US dollar and euro books, eighteen months of order to cash and procure to pay, and the problems an operator finds at close: duplicate bills, unapplied payments and credits, overdue receivables, three-way-match exceptions, journal entries waiting for approval. Sizes `s`, `m` and `l` hold about 1,500, 11,400 and 22,000 transactions. `ancha sandbox datasets` lists it with the starter datasets.
|
|
12
12
|
|
|
13
13
|
## Your NetSuite exports
|
|
14
14
|
|
|
@@ -54,7 +54,7 @@ Give your coding agent this recipe and an export of your records (a spreadsheet,
|
|
|
54
54
|
|
|
55
55
|
```text
|
|
56
56
|
invalid ancha/worlds/our-books.yaml (our-books)
|
|
57
|
-
netsuite: 4 subsidiaries, 2 currencies,
|
|
57
|
+
netsuite: 4 subsidiaries, 2 currencies, 40 accounts, 400 customers, 180 vendors, 150 items, 11,431 transactions
|
|
58
58
|
seed.netsuite.invoices[212]: INV12213 (id 40213, customer 1297 Jarvis Food Processing Co.): invoice is over-applied: applications total USD 11,641.54 against a total of USD 11,601.54 (over by USD 40.00)
|
|
59
59
|
```
|
|
60
60
|
|
|
@@ -17,7 +17,7 @@ A version 2 test names a world (`ancha/worlds/<id>.yaml`: the company, its peopl
|
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
- The question is `question`, `input`, `prompt`, `query` or `task`; the expected answer is `expected`, `answer`, `ideal`, `output`, `reference` or `expected_output`. Optional: `id`, `read_only` (default true; false for an eval with `records`), `must_call` (`"METHOD /path"` or an MCP tool name), `numbers` (`[{ value, tolerance }]`), `contains`, `judge` (a rubric), `tags`, and `records`: the NetSuite state a write leaves, `[{ type, id or externalId, fields }]`. Other fields go in the test's header as comments.
|
|
20
|
-
- Each eval becomes a test whose task is the question, with an `answer` check: the `numbers` and `contains` it gives, or the numbers, document numbers (`INV-1043`) and quoted text of its expected answer. Numbers the question states and dates are left out. A test also gets `netsuite.unchanged` over every record type when it only reads and the world has NetSuite, a `trace.called` check for each `must_call`, and a `netsuite.record` check for each of its `records`. A record named by `externalId` can be one the agent creates:
|
|
20
|
+
- Each eval becomes a test whose task is the question, with an `answer` check: the `numbers` and `contains` it gives, or the numbers, document numbers (`INV-1043`) and quoted text of its expected answer. Numbers the question states and dates are left out. A test also gets `netsuite.unchanged` over every record type when it only reads and the world has NetSuite, a `trace.called` check for each `must_call`, and a `netsuite.record` check for each of its `records`. Write evals can also give `counts: [{type, count}]` and `unchanged: {types, except: [{type, id | externalId}]}` to check record counts and protect other records. `includeSettlement: true` in a count includes zero-cash settlement records. A record check’s `apply` names the exact applied documents; `credit` names the exact credit sources, both as `[{doc, amount}]` (with `line` for line-level identities). A record named by `externalId` can be one the agent creates:
|
|
21
21
|
|
|
22
22
|
```json
|
|
23
23
|
{"id": "approve-bf-2207", "question": "Approve the Bluefield Logistics bill BF-2207.", "records": [{"type": "vendorBill", "externalId": "BF-2207", "fields": {"approvalStatus": {"id": "2"}}}]}
|
package/lib/assets/docs/setup.md
CHANGED
|
@@ -27,7 +27,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
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
|
-
5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests
|
|
30
|
+
5. **Without production traces.** For an agent that uses NetSuite, `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.
|
|
31
31
|
- 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.
|
|
32
32
|
- Your evals: `ancha test import <file> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).
|
|
33
33
|
- One test from a sentence: `ancha test new "<sentence>" --world <id>`.
|
|
@@ -68,7 +68,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
68
68
|
`ancha init --agent "node agent.mjs"`, with your own start command, writes:
|
|
69
69
|
- `ancha.yaml`: how to start the agent, how many trials, which tests;
|
|
70
70
|
- `scenes/starter/`: a starter test that checks the agent reaches each tool, with two reference companions (`oracle.mjs` passes, `null.mjs` makes no calls);
|
|
71
|
-
- for an agent that uses NetSuite, in a project with no tests and no `traces/` folder: `ancha/worlds/netsuite-pe-m.yaml`, the NetSuite books of a private-equity portfolio company, and 25 tests in `ancha/tests
|
|
71
|
+
- for an agent that uses NetSuite, in a project with no tests and no `traces/` folder: `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/`). `--data netsuite-pe:s` or `--data netsuite-pe:l` writes another size, `--data none` leaves them out;
|
|
72
72
|
- `.claude/skills/ancha/SKILL.md` and an Ancha section in `AGENTS.md`, for coding agents;
|
|
73
73
|
- `.ancha/` in `.gitignore`: run history, traces and fake tokens never belong in git.
|
|
74
74
|
|
|
@@ -24,7 +24,7 @@ The import lists the questions the trace leaves open, each with the default the
|
|
|
24
24
|
- `tools.simulate_writes`: the writes a test simulates when the agent makes one production never made; the others fail.
|
|
25
25
|
- `tools.pure`: tools that only compute from their arguments; a test runs them itself.
|
|
26
26
|
- `tools.run`: tools that can run their own code in a test, over a store the agent fills from `records.jsonl`. Production's answers are replayed until something changes; a call production never made, a write, and every call after a write run the tool itself. It also lists the tools the agent's model was given that production never called; a test does not require the agent to wrap those.
|
|
27
|
-
- `checks.success`: the required end state for the user's request,
|
|
27
|
+
- `checks.success`: the required end state for the user's request: what a correct run leaves changed, leaves unchanged and tells the user. For a run that went wrong it is the right action, and the import asks for it plainly; every check of the test judges against the answer, and it stays required. `success:` in the import's output says which end state the test uses.
|
|
28
28
|
- `github.members.<org>`: who was a member of the GitHub organization when the run started, as logins or `none`. The import asks when the agent removed someone's direct access to the organization's repositories; a member keeps read access to all of them.
|
|
29
29
|
|
|
30
30
|
Reimporting into the workspace keeps the latest saved answers, including `task` and `--expect`. Offline imports keep the answers saved in the destination test folder. `--answer task=default` restores one default; `--reset-answers` starts with the trace defaults. Pull preserves checks you add and their membership in `pass`; a conflicting check ID names the check to rename.
|
|
@@ -79642,10 +79642,10 @@ var BetterStackSeedSchema = external_exports.strictObject({
|
|
|
79642
79642
|
open2.add(entry2.source);
|
|
79643
79643
|
}
|
|
79644
79644
|
});
|
|
79645
|
-
seed43.onCall.forEach((
|
|
79645
|
+
seed43.onCall.forEach((calendar4, i) => calendar4.users.forEach((user8, j) => {
|
|
79646
79646
|
if (!people3.has(user8)) issue6(["onCall", i, "users", j], `${user8} is not a user`);
|
|
79647
79647
|
}));
|
|
79648
|
-
if (seed43.onCall.filter((
|
|
79648
|
+
if (seed43.onCall.filter((calendar4) => calendar4.default).length > 1) issue6(["onCall"], "only one default calendar");
|
|
79649
79649
|
seed43.statusPages.forEach((page18, i) => {
|
|
79650
79650
|
const names5 = new Set(page18.resources.map((resource2) => resource2.publicName));
|
|
79651
79651
|
page18.resources.forEach((resource2, j) => {
|
|
@@ -86334,10 +86334,14 @@ var NetsuiteRecordCheckSchema = external_exports.strictObject({
|
|
|
86334
86334
|
id: id8.optional(),
|
|
86335
86335
|
externalId: text11.optional(),
|
|
86336
86336
|
fields: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
86337
|
-
apply: external_exports.array(application).optional()
|
|
86337
|
+
apply: external_exports.array(application).optional(),
|
|
86338
|
+
credit: external_exports.array(application).optional()
|
|
86338
86339
|
}).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both", path: ["id"] });
|
|
86339
|
-
var NetsuiteUnchangedCheckSchema = external_exports.strictObject({
|
|
86340
|
-
|
|
86340
|
+
var NetsuiteUnchangedCheckSchema = external_exports.strictObject({
|
|
86341
|
+
types: external_exports.array(external_exports.enum(netsuiteRecordTypes)).min(1),
|
|
86342
|
+
except: external_exports.array(external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), id: id8.optional(), externalId: text11.optional() }).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both" })).optional()
|
|
86343
|
+
});
|
|
86344
|
+
var NetsuiteCountCheckSchema = external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), count: external_exports.number().int().min(0), includeSettlement: external_exports.boolean().optional() });
|
|
86341
86345
|
|
|
86342
86346
|
// packages/core/src/scene/schema.ts
|
|
86343
86347
|
var SUPPORTED_TWINS = ["slack", "github", "datadog", "pagerduty", "linkedin-ads", "salesforce", "gong", "hubspot", "ga4", "google-ads", "chatgpt-ads", "open-meteo", "google-drive", "gmail", "amazon-s3", "linear", "okta", "stripe", "clerk", "better-stack", "notion", "attio", "dropbox", "resend", "microsoft-word", "outlook", "shopify", "lob", "paypal", "jira", "kalshi", "intercom", "zendesk", "google-calendar", "twilio", "asana", "discord", "sentry", "airtable", "netsuite", "carrier-portal"];
|
|
@@ -107398,7 +107402,7 @@ var catalogRoutes3 = [
|
|
|
107398
107402
|
return json8({ elements: entities.filter((e) => e.facet === q.get("facet")).map((e) => ({ urn: e.urn, facetUrn: e.facet, name: e.name })) });
|
|
107399
107403
|
} }
|
|
107400
107404
|
];
|
|
107401
|
-
function
|
|
107405
|
+
function calendar2(raw3) {
|
|
107402
107406
|
const match3 = /^\((?:year:(\d{4}),month:(\d{1,2}),day:(\d{1,2})|day:(\d{1,2}),month:(\d{1,2}),year:(\d{4}))\)$/.exec(raw3);
|
|
107403
107407
|
if (!match3) invalid8("Date must be (year:YYYY,month:M,day:D) or (day:D,month:M,year:YYYY)");
|
|
107404
107408
|
const y = match3[1] ?? match3[6], m = match3[2] ?? match3[5], d = match3[3] ?? match3[4], date10 = `${y}-${m.padStart(2, "0")}-${d.padStart(2, "0")}`;
|
|
@@ -107420,7 +107424,7 @@ var analyticsRoutes = [{ method: "GET", path: "/rest/adAnalytics", notes: "analy
|
|
|
107420
107424
|
if (!["DAILY", "ALL"].includes(q.get("timeGranularity") ?? "")) gap2(`timeGranularity ${q.get("timeGranularity")}`);
|
|
107421
107425
|
const range2 = /^\(start:(\([^()]+\))(?:,end:(\([^()]+\)))?\)$/.exec(q.get("dateRange") ?? "");
|
|
107422
107426
|
if (!range2) invalid8("dateRange requires start and optional end tuples");
|
|
107423
|
-
const start =
|
|
107427
|
+
const start = calendar2(range2[1]), end = range2[2] ? calendar2(range2[2]) : c.env.ctx.clock.now().toISOString().slice(0, 10);
|
|
107424
107428
|
if (end < start) invalid8("dateRange.end precedes start");
|
|
107425
107429
|
const selectedFields2 = q.get("fields")?.split(",") ?? ["impressions", "clicks"];
|
|
107426
107430
|
const allowed2 = ["pivotValues", "dateRange", "impressions", "clicks", "oneClickLeads", "costInLocalCurrency"];
|
|
@@ -117598,9 +117602,9 @@ function seed21(ctx) {
|
|
|
117598
117602
|
entry2.resolved?.by ?? null
|
|
117599
117603
|
);
|
|
117600
117604
|
}
|
|
117601
|
-
for (const
|
|
117602
|
-
const users5 =
|
|
117603
|
-
db3.prepare("INSERT INTO bs_calendars (id, name, is_default, users) VALUES (?, ?, ?, ?)").run(nextId3(ctx, "calendar"),
|
|
117605
|
+
for (const calendar4 of input4.onCall) {
|
|
117606
|
+
const users5 = calendar4.users.map((email11) => db3.prepare("SELECT id FROM bs_users WHERE email = ?").get(email11).id);
|
|
117607
|
+
db3.prepare("INSERT INTO bs_calendars (id, name, is_default, users) VALUES (?, ?, ?, ?)").run(nextId3(ctx, "calendar"), calendar4.name, calendar4.default ? 1 : 0, JSON.stringify(users5));
|
|
117604
117608
|
}
|
|
117605
117609
|
for (const page18 of input4.statusPages) {
|
|
117606
117610
|
const id14 = nextId3(ctx, "page");
|
|
@@ -117656,9 +117660,9 @@ function dumpState20(ctx) {
|
|
|
117656
117660
|
resolvedBy: row2.resolved_by,
|
|
117657
117661
|
...row2.summary && { summary: row2.summary }
|
|
117658
117662
|
})),
|
|
117659
|
-
onCall: db3.prepare("SELECT * FROM bs_calendars ORDER BY rowid").all().map((
|
|
117660
|
-
name:
|
|
117661
|
-
users: JSON.parse(
|
|
117663
|
+
onCall: db3.prepare("SELECT * FROM bs_calendars ORDER BY rowid").all().map((calendar4) => ({
|
|
117664
|
+
name: calendar4.name,
|
|
117665
|
+
users: JSON.parse(calendar4.users).map((id14) => db3.prepare("SELECT email FROM bs_users WHERE id = ?").get(id14)?.email ?? id14)
|
|
117662
117666
|
})),
|
|
117663
117667
|
statusPages: db3.prepare("SELECT * FROM bs_pages ORDER BY rowid").all().map((page18) => ({
|
|
117664
117668
|
id: page18.id,
|
|
@@ -131079,7 +131083,7 @@ function feeFor(series2, count4, price3, taker) {
|
|
|
131079
131083
|
const exact = rate * series2.fee_multiplier * (count4 / 100) * (price3 / ONE) * (1 - price3 / ONE);
|
|
131080
131084
|
return Math.ceil(exact * 100 - 1e-9) * 1e4;
|
|
131081
131085
|
}
|
|
131082
|
-
function
|
|
131086
|
+
function ledger2(ctx, now11) {
|
|
131083
131087
|
const db3 = ctx.store.db, positions2 = /* @__PURE__ */ new Map();
|
|
131084
131088
|
let cash = db3.prepare("SELECT COALESCE(SUM(amount), 0) AS total FROM kx_deposits WHERE at_ms <= ?").get(now11).total;
|
|
131085
131089
|
for (const fill of db3.prepare("SELECT * FROM kx_fills WHERE created_ms <= ? ORDER BY created_ms, rowid").all(now11)) {
|
|
@@ -131118,7 +131122,7 @@ function ledger(ctx, now11) {
|
|
|
131118
131122
|
}
|
|
131119
131123
|
var collateral = (order5) => (order5.initial - order5.filled) * (order5.book_side === "bid" ? order5.price : ONE - order5.price);
|
|
131120
131124
|
function balances(ctx, now11) {
|
|
131121
|
-
const { cash, positions: positions2 } =
|
|
131125
|
+
const { cash, positions: positions2 } = ledger2(ctx, now11);
|
|
131122
131126
|
const held = restingOrders(ctx, now11).reduce((total2, order5) => total2 + collateral(order5), 0);
|
|
131123
131127
|
let value4 = 0;
|
|
131124
131128
|
for (const entry2 of positions2.values()) if (entry2.position) value4 += Math.abs(entry2.position) * (entry2.position > 0 ? getMarket(ctx, entry2.ticker).last_price : ONE - getMarket(ctx, entry2.ticker).last_price);
|
|
@@ -131163,7 +131167,7 @@ function seed32(ctx) {
|
|
|
131163
131167
|
});
|
|
131164
131168
|
});
|
|
131165
131169
|
input4.orders.forEach((entry2, i) => {
|
|
131166
|
-
const id14 = seededUuid(`order:${i}`), created3 = at3(entry2.created), series2 = seriesOfMarket(ctx, getMarket(ctx, entry2.market)), positionBefore =
|
|
131170
|
+
const id14 = seededUuid(`order:${i}`), created3 = at3(entry2.created), series2 = seriesOfMarket(ctx, getMarket(ctx, entry2.market)), positionBefore = ledger2(ctx, created3).positions.get(entry2.market)?.position ?? 0;
|
|
131167
131171
|
const legacy2 = legacySide(entry2.side, positionBefore);
|
|
131168
131172
|
db3.prepare(`INSERT INTO kx_orders (id, client_order_id, ticker, book_side, side, action, outcome_side, price, initial, filled, time_in_force, post_only, stp, cancel_on_pause, expiration_ms, created_ms, updated_ms, canceled_ms,
|
|
131169
131173
|
taker_cost, maker_cost, taker_fees, maker_fees) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, 0, 'taker_at_cross', 0, NULL, ?, ?, ?, 0, 0, 0, 0)`).run(id14, entry2.clientOrderId ?? null, entry2.market, entry2.side, legacy2.side, legacy2.action, legacy2.outcome, price3(entry2.price), count4(entry2.count), entry2.timeInForce, created3, created3, entry2.canceled === void 0 ? null : at3(entry2.canceled));
|
|
@@ -131644,7 +131648,7 @@ function positions(call2) {
|
|
|
131644
131648
|
choice2(settlement, "settlement_status", ["all", "settled", "unsettled"]);
|
|
131645
131649
|
for (const name5 of counts) choice2(name5, "count_filter", ["position", "total_traded"]);
|
|
131646
131650
|
const ticker2 = params10.get("ticker"), eventTicker = params10.get("event_ticker");
|
|
131647
|
-
const entries3 = [...
|
|
131651
|
+
const entries3 = [...ledger2(ctx, now11).positions.values()].filter((entry2) => {
|
|
131648
131652
|
const market2 = getMarket(ctx, entry2.ticker);
|
|
131649
131653
|
return (settlement === "all" || settlement === "settled" === (entry2.settlement !== void 0)) && (!ticker2 || entry2.ticker === ticker2) && (!eventTicker || market2.event === eventTicker) && (!counts.length || counts.some((name5) => name5 === "position" ? entry2.position !== 0 : entry2.traded !== 0));
|
|
131650
131654
|
});
|
|
@@ -131706,7 +131710,7 @@ function settlements(call2) {
|
|
|
131706
131710
|
const ctx = call2.ctx, now11 = ctx.clock.nowMs(), params10 = query8(call2, ["limit", "cursor", "ticker", "event_ticker", "min_ts", "max_ts", "subaccount"]), ticker2 = params10.get("ticker"), eventTicker = params10.get("event_ticker");
|
|
131707
131711
|
primary2(params10.get("subaccount"));
|
|
131708
131712
|
const within = timeRange2(params10, "min_ts", "max_ts");
|
|
131709
|
-
const rows7 = [...
|
|
131713
|
+
const rows7 = [...ledger2(ctx, now11).positions.values()].filter((entry2) => entry2.settlement && (!ticker2 || entry2.ticker === ticker2) && (!eventTicker || getMarket(ctx, entry2.ticker).event === eventTicker) && within(entry2.settlement.at)).sort((a, b) => b.settlement.at - a.settlement.at);
|
|
131710
131714
|
const result = page11(call2, rows7, 200, 100);
|
|
131711
131715
|
return json22({
|
|
131712
131716
|
settlements: result.items.map((entry2) => ({
|
|
@@ -147160,7 +147164,7 @@ function bindValue(value4) {
|
|
|
147160
147164
|
}
|
|
147161
147165
|
var pad2 = (n2, width = 2) => String(n2).padStart(width, "0");
|
|
147162
147166
|
var MONTHS2 = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
147163
|
-
function
|
|
147167
|
+
function calendar3(y, m, d) {
|
|
147164
147168
|
const date10 = /* @__PURE__ */ new Date(0);
|
|
147165
147169
|
date10.setUTCFullYear(y, m - 1, d);
|
|
147166
147170
|
date10.setUTCHours(0, 0, 0, 0);
|
|
@@ -147170,7 +147174,7 @@ function calendar2(y, m, d) {
|
|
|
147170
147174
|
function isoDate(text23) {
|
|
147171
147175
|
const match3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text23);
|
|
147172
147176
|
if (!match3) invalid24("Expected a YYYY-MM-DD world date.");
|
|
147173
|
-
|
|
147177
|
+
calendar3(+match3[1], +match3[2], +match3[3]);
|
|
147174
147178
|
return text23;
|
|
147175
147179
|
}
|
|
147176
147180
|
function dateModel(model) {
|
|
@@ -147210,7 +147214,7 @@ function parseDate2(value4, model) {
|
|
|
147210
147214
|
const values2 = new Map(tokens3.map((t, i) => [t, match3[i + 1]]));
|
|
147211
147215
|
if (!values2.has("YYYY") || !values2.has("DD") || !["MM", "MON", "MONTH"].some((t) => values2.has(t))) invalid24("TO_DATE requires year, month and day.", true);
|
|
147212
147216
|
const month = values2.has("MM") ? Number(values2.get("MM")) : MONTHS2.findIndex((m) => values2.has("MON") ? m.slice(0, 3).toLowerCase() === values2.get("MON").toLowerCase() : m.toLowerCase() === values2.get("MONTH").toLowerCase()) + 1;
|
|
147213
|
-
const date10 =
|
|
147217
|
+
const date10 = calendar3(Number(values2.get("YYYY")), month, Number(values2.get("DD")));
|
|
147214
147218
|
let hour2 = Number(values2.get("HH24") ?? values2.get("HH12") ?? values2.get("HH") ?? 0);
|
|
147215
147219
|
const minute2 = Number(values2.get("MI") ?? 0), second = Number(values2.get("SS") ?? 0);
|
|
147216
147220
|
if (values2.has("HH12") || values2.has("HH")) {
|
|
@@ -151051,15 +151055,29 @@ function record8(ctx, args) {
|
|
|
151051
151055
|
}
|
|
151052
151056
|
const applied = composite2 ? [...byLine.values()].sort((a, b) => a.doc - b.doc || a.line - b.line) : applications(ctx, id14).map((a) => ({ doc: a.doc, amount: a.amount })).sort((a, b) => a.doc - b.doc);
|
|
151053
151057
|
const wanted = args.apply?.map((a) => composite2 ? { ...a, line: a.line ?? 0 } : { ...a }).sort((a, b) => a.doc - b.doc || (a.line ?? 0) - (b.line ?? 0));
|
|
151054
|
-
|
|
151058
|
+
const creditLines = args.credit?.some((a) => a.line !== void 0);
|
|
151059
|
+
const credits = /* @__PURE__ */ new Map();
|
|
151060
|
+
for (const a of edges(ctx, id14).filter((a2) => a2.source !== id14)) {
|
|
151061
|
+
const key4 = creditLines ? `${a.source}:${a.sourceline}` : String(a.source);
|
|
151062
|
+
const item2 = credits.get(key4) ?? { doc: a.source, ...creditLines && { line: a.sourceline }, amount: 0 };
|
|
151063
|
+
item2.amount = Math.round((item2.amount + a.amount) * 100) / 100;
|
|
151064
|
+
credits.set(key4, item2);
|
|
151065
|
+
}
|
|
151066
|
+
const sort = (a, b) => a.doc - b.doc || (a.line ?? 0) - (b.line ?? 0);
|
|
151067
|
+
const credited = [...credits.values()].sort(sort);
|
|
151068
|
+
const wantedCredits = args.credit?.map((a) => creditLines ? { ...a, line: a.line ?? 0 } : { ...a }).sort(sort);
|
|
151069
|
+
const creditExpected = args.credit === void 0 ? "" : ` and credits ${JSON.stringify(args.credit)}`;
|
|
151070
|
+
return checkOutcome(matches8(actual, args.fields ?? {}) && (wanted === void 0 || isDeepStrictEqual(applied, wanted)) && (wantedCredits === void 0 || isDeepStrictEqual(credited, wantedCredits)), expected + creditExpected, JSON.stringify({ record: actual, apply: applied, credit: credited }));
|
|
151055
151071
|
}
|
|
151056
151072
|
function unchanged(ctx, args) {
|
|
151057
|
-
const
|
|
151073
|
+
const allowed2 = (args.except ?? []).map((r2) => ({ type: r2.type, id: r2.id ?? byExternalId(ctx, r2.type, r2.externalId) }));
|
|
151074
|
+
const changes = sql(ctx).prepare("SELECT recordtype, id, operation FROM ns_history ORDER BY ordinal").all().filter((row2) => args.types.includes(row2.recordtype) && !allowed2.some((r2) => r2.type === row2.recordtype && r2.id === row2.id));
|
|
151058
151075
|
const types = args.types.length >= netsuiteRecordTypes.length && netsuiteRecordTypes.every((type) => args.types.includes(type)) ? "NetSuite records" : args.types.length > 4 ? `${args.types.slice(0, 3).join(", ")} and ${args.types.length - 3} more record types` : args.types.join(", ");
|
|
151059
|
-
|
|
151076
|
+
const except = args.except?.length ? ` except ${args.except.map((r2) => `${r2.type} ${r2.id ?? `eid:${r2.externalId}`}`).join(", ")}` : "";
|
|
151077
|
+
return checkOutcome(changes.length === 0, `no writes to ${types}${except}`, changes.length ? JSON.stringify(changes) : except ? "no other committed writes" : "no committed writes");
|
|
151060
151078
|
}
|
|
151061
151079
|
function count3(ctx, args) {
|
|
151062
|
-
const actual = recordIds(ctx, args.type).length;
|
|
151080
|
+
const actual = args.includeSettlement && isTx(args.type) ? sql(ctx).prepare("SELECT COUNT(*) AS count FROM ns_transactions WHERE recordtype = ?").get(args.type).count : recordIds(ctx, args.type).length;
|
|
151063
151081
|
return checkOutcome(actual === args.count, `${args.count} ${args.type} records`, `${actual} records`);
|
|
151064
151082
|
}
|
|
151065
151083
|
|
|
@@ -193,7 +193,7 @@ class AnchaAgent(BaseInstalledAgent):
|
|
|
193
193
|
ran = time.monotonic() - getattr(self, 'ran_from', time.monotonic())
|
|
194
194
|
limit = max(1, min(max(60, math.ceil(2 * ran)), max(60, math.ceil(self.attempt['timeoutMs'] / 1000))))
|
|
195
195
|
for _ in range(2):
|
|
196
|
-
began = time.monotonic()
|
|
196
|
+
began = time.monotonic(); capture = None
|
|
197
197
|
try:
|
|
198
198
|
capture = await asyncio.shield(environment.service_exec('node /opt/ancha/companion.mjs capture',service='tools',timeout_sec=limit))
|
|
199
199
|
check(capture,'Could not collect final tool state')
|
|
@@ -201,10 +201,22 @@ class AnchaAgent(BaseInstalledAgent):
|
|
|
201
201
|
return
|
|
202
202
|
except BaseException as exc:
|
|
203
203
|
timed_out = isinstance(exc, (TimeoutError, asyncio.TimeoutError)) or time.monotonic() - began >= limit - 1
|
|
204
|
-
CAPTURES[self.aid] = {'captureError':'Final tool state could not be collected','invalidReason':'capture_timeout' if timed_out else 'capture_failed'
|
|
204
|
+
CAPTURES[self.aid] = {'captureError':'Final tool state could not be collected','invalidReason':'capture_timeout' if timed_out else 'capture_failed',
|
|
205
|
+
'detail':capture_detail(capture, exc, timed_out, limit)}
|
|
205
206
|
if CANCELLED or isinstance(exc, asyncio.CancelledError): return
|
|
206
207
|
|
|
207
208
|
|
|
209
|
+
def capture_detail(result, exc, timed_out, limit):
|
|
210
|
+
"""Why the final capture failed, in one line: the world's own error, the end of its output, or the exception."""
|
|
211
|
+
if timed_out: return f'no answer within {limit} s'
|
|
212
|
+
if result is not None and getattr(result, 'return_code', 0) != 0:
|
|
213
|
+
out = (getattr(result, 'stdout', None) or '').strip()
|
|
214
|
+
try: message = json.loads(out).get('error')
|
|
215
|
+
except (ValueError, TypeError, AttributeError): message = None
|
|
216
|
+
return safe(message or out or (getattr(result, 'stderr', None) or '').strip() or f'exit {result.return_code}')[-300:]
|
|
217
|
+
return safe(f'{type(exc).__name__}: {exc}')[:300]
|
|
218
|
+
|
|
219
|
+
|
|
208
220
|
def render(template, info, attempt):
|
|
209
221
|
import re
|
|
210
222
|
values={'task':attempt['prompt'],'env.id':info['id'],'trial':str(attempt['number']),
|
|
@@ -235,8 +247,10 @@ def final_event(aid, error):
|
|
|
235
247
|
status='completed';fields['outcome']='invalid'
|
|
236
248
|
fields['invalidReason']='people_model_failed' if any(issue.get('service')=='people' for issue in issues) else 'harness_failed'
|
|
237
249
|
elif capture and status=='completed':
|
|
238
|
-
# The agent finished; only the final capture failed. Complete, but invalid: not graded, not an error.
|
|
250
|
+
# The agent finished; only the final capture failed. Complete, but invalid: not graded, not an error. Why it
|
|
251
|
+
# failed stays with the attempt as a harness issue.
|
|
239
252
|
fields['outcome']='invalid';fields['invalidReason']=capture.get('invalidReason','capture_failed')
|
|
253
|
+
if capture.get('detail'): fields['harnessIssues']=[{'owner':'harness','service':'tools','kind':'capture','message':f"{capture['captureError']}: {capture['detail']}"}]
|
|
240
254
|
elif capture and status!='stopped':
|
|
241
255
|
status='error';fields['error']=capture['captureError']
|
|
242
256
|
if error and fields.get('outcome')!='invalid': fields['error']=safe(error.exception_message)[:2000]
|
package/lib/assets/ui/app.js
CHANGED
|
@@ -2152,7 +2152,7 @@ function starterCount(tool, key, state) {
|
|
|
2152
2152
|
}
|
|
2153
2153
|
|
|
2154
2154
|
// frontend/src/generated/coding-agent-skill.ts
|
|
2155
|
-
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 ancha --version || 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`.\n3. **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 ```\n4. **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.\n5. **Without production traces.** For an agent that uses NetSuite, `ancha init` writes a NetSuite world of a private-equity portfolio company (four subsidiaries, two currencies, thousands of transactions) and 25 tests from the questions an operator asks.\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> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n6. **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>`.\n7. **Point the agent at the test'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.\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 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.\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";
|
|
2155
|
+
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 ancha --version || 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`.\n3. **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 ```\n4. **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.\n5. **Without production traces.** For an agent that uses NetSuite, `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.\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> --world <id>` (JSONL, JSON, CSV or YAML with a question and an expected answer).\n - One test from a sentence: `ancha test new \"<sentence>\" --world <id>`.\n6. **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>`.\n7. **Point the agent at the test'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.\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 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.\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";
|
|
2156
2156
|
|
|
2157
2157
|
// frontend/src/workspace-pages.ts
|
|
2158
2158
|
var startSentence = "Set up Ancha for this agent: read https://app.ancha.io/llms.txt and follow its first steps.";
|
package/lib/mcp-entry.mjs
CHANGED
|
@@ -60364,10 +60364,10 @@ var BetterStackSeedSchema = external_exports.strictObject({
|
|
|
60364
60364
|
open2.add(entry2.source);
|
|
60365
60365
|
}
|
|
60366
60366
|
});
|
|
60367
|
-
seed2.onCall.forEach((
|
|
60367
|
+
seed2.onCall.forEach((calendar2, i) => calendar2.users.forEach((user5, j) => {
|
|
60368
60368
|
if (!people2.has(user5)) issue2(["onCall", i, "users", j], `${user5} is not a user`);
|
|
60369
60369
|
}));
|
|
60370
|
-
if (seed2.onCall.filter((
|
|
60370
|
+
if (seed2.onCall.filter((calendar2) => calendar2.default).length > 1) issue2(["onCall"], "only one default calendar");
|
|
60371
60371
|
seed2.statusPages.forEach((page2, i) => {
|
|
60372
60372
|
const names = new Set(page2.resources.map((resource2) => resource2.publicName));
|
|
60373
60373
|
page2.resources.forEach((resource2, j) => {
|
|
@@ -66737,10 +66737,14 @@ var NetsuiteRecordCheckSchema = external_exports.strictObject({
|
|
|
66737
66737
|
id: id8.optional(),
|
|
66738
66738
|
externalId: text11.optional(),
|
|
66739
66739
|
fields: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
66740
|
-
apply: external_exports.array(application).optional()
|
|
66740
|
+
apply: external_exports.array(application).optional(),
|
|
66741
|
+
credit: external_exports.array(application).optional()
|
|
66741
66742
|
}).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both", path: ["id"] });
|
|
66742
|
-
var NetsuiteUnchangedCheckSchema = external_exports.strictObject({
|
|
66743
|
-
|
|
66743
|
+
var NetsuiteUnchangedCheckSchema = external_exports.strictObject({
|
|
66744
|
+
types: external_exports.array(external_exports.enum(netsuiteRecordTypes)).min(1),
|
|
66745
|
+
except: external_exports.array(external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), id: id8.optional(), externalId: text11.optional() }).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both" })).optional()
|
|
66746
|
+
});
|
|
66747
|
+
var NetsuiteCountCheckSchema = external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), count: external_exports.number().int().min(0), includeSettlement: external_exports.boolean().optional() });
|
|
66744
66748
|
|
|
66745
66749
|
// packages/core/src/scene/schema.ts
|
|
66746
66750
|
var SUPPORTED_TWINS = ["slack", "github", "datadog", "pagerduty", "linkedin-ads", "salesforce", "gong", "hubspot", "ga4", "google-ads", "chatgpt-ads", "open-meteo", "google-drive", "gmail", "amazon-s3", "linear", "okta", "stripe", "clerk", "better-stack", "notion", "attio", "dropbox", "resend", "microsoft-word", "outlook", "shopify", "lob", "paypal", "jira", "kalshi", "intercom", "zendesk", "google-calendar", "twilio", "asana", "discord", "sentry", "airtable", "netsuite", "carrier-portal"];
|