@ancha-labs/cli 0.4.48 → 0.4.50
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 +36 -16
- package/lib/assets/SKILL.md +2 -2
- package/lib/assets/agents-section.md +2 -2
- package/lib/assets/docs/cloud.md +2 -2
- package/lib/assets/docs/setup.md +3 -3
- package/lib/assets/harbor/companion.mjs +19 -7
- package/lib/assets/ui/app.js +1 -1
- package/lib/assets/ui/style.css +1 -0
- package/lib/worker.mjs +19 -7
- package/lib/world-server.mjs +19 -7
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -193693,6 +193693,13 @@ function queryRecords(ctx, sql6) {
|
|
|
193693
193693
|
if (!confirmed.has(key5) && !["TimeActivity", "Attachable", "TaxAgency", "ExchangeRate"].includes(type)) hasGap = true;
|
|
193694
193694
|
return key5;
|
|
193695
193695
|
}
|
|
193696
|
+
const typed = (key5, value7) => {
|
|
193697
|
+
if (typeof value7 !== "string") return value7;
|
|
193698
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
193699
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value7)) return Number(value7);
|
|
193700
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value7)) return value7.toLowerCase() === "true";
|
|
193701
|
+
return value7;
|
|
193702
|
+
};
|
|
193696
193703
|
projection2 = projection2?.map((p2) => property4(p2));
|
|
193697
193704
|
const conditions = [];
|
|
193698
193705
|
let explicitActive = false;
|
|
@@ -193704,6 +193711,11 @@ function queryRecords(ctx, sql6) {
|
|
|
193704
193711
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
193705
193712
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
193706
193713
|
};
|
|
193714
|
+
const value6 = (key5) => {
|
|
193715
|
+
const token5 = ts3[i], read7 = typed(key5, literal4());
|
|
193716
|
+
if (token5?.kind === "number" && fields13.find((f2) => f2[0] === key5)?.[1] === "string") parseError2(`${key5} is text: give its value in single quotes.`);
|
|
193717
|
+
return read7;
|
|
193718
|
+
};
|
|
193707
193719
|
if (peek("WHERE")) {
|
|
193708
193720
|
i++;
|
|
193709
193721
|
do {
|
|
@@ -193712,10 +193724,10 @@ function queryRecords(ctx, sql6) {
|
|
|
193712
193724
|
const op2 = ts3[i++]?.text.toUpperCase();
|
|
193713
193725
|
if (op2 === "IN") {
|
|
193714
193726
|
take2("(");
|
|
193715
|
-
const values3 = [
|
|
193727
|
+
const values3 = [value6(key5)];
|
|
193716
193728
|
while (peek(",")) {
|
|
193717
193729
|
i++;
|
|
193718
|
-
values3.push(
|
|
193730
|
+
values3.push(value6(key5));
|
|
193719
193731
|
}
|
|
193720
193732
|
take2(")");
|
|
193721
193733
|
conditions.push((row2) => {
|
|
@@ -193728,17 +193740,17 @@ function queryRecords(ctx, sql6) {
|
|
|
193728
193740
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
193729
193741
|
conditions.push((row2) => {
|
|
193730
193742
|
const actual = scalar2(row2, key5);
|
|
193731
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
193732
|
-
const v = String(
|
|
193743
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value7) => {
|
|
193744
|
+
const v = String(value7 ?? "").toLowerCase();
|
|
193733
193745
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
193734
193746
|
});
|
|
193735
193747
|
});
|
|
193736
193748
|
} else {
|
|
193737
193749
|
if (!["=", "<", ">", "<=", ">="].includes(op2 ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
193738
|
-
const expected =
|
|
193750
|
+
const expected = value6(key5);
|
|
193739
193751
|
conditions.push((row2) => {
|
|
193740
|
-
const
|
|
193741
|
-
return (Array.isArray(
|
|
193752
|
+
const value7 = scalar2(row2, key5);
|
|
193753
|
+
return (Array.isArray(value7) ? value7 : [value7]).some((item2) => {
|
|
193742
193754
|
let actual = item2, target6 = expected;
|
|
193743
193755
|
if (actual === void 0) return false;
|
|
193744
193756
|
if (key5.startsWith("MetaData.")) {
|
|
@@ -249932,7 +249944,6 @@ Additional required criterion: ${savedGoal.judge}`;
|
|
|
249932
249944
|
const required6 = new Set(scene2.pass ?? scene2.checks.map((c) => c.id));
|
|
249933
249945
|
const catchesInaction = scene2.checks.some((check4) => {
|
|
249934
249946
|
if (!required6.has(check4.id) || check4.judge) return false;
|
|
249935
|
-
if (check4.trace?.called) return !Array.isArray(check4.trace.called) || check4.trace.called.length > 0;
|
|
249936
249947
|
if (!check4.state || check4.state.exists === false) return false;
|
|
249937
249948
|
try {
|
|
249938
249949
|
return startingState(check4.state, scene2) === "failed";
|
|
@@ -256307,7 +256318,12 @@ function registerRun(program2, ctx) {
|
|
|
256307
256318
|
} catch (error65) {
|
|
256308
256319
|
if (!defaulted) throw error65;
|
|
256309
256320
|
const failure6 = toErrorJson(error65);
|
|
256310
|
-
|
|
256321
|
+
let next2 = "to run on this computer: ancha run --on local";
|
|
256322
|
+
if (Object.keys(config12.agent?.routes ?? {}).length > 0) {
|
|
256323
|
+
const test3 = (await glob3(sceneArgs.length > 0 ? sceneArgs : config12.scenes, { cwd, onlyFiles: true })).sort()[0] ?? sceneArgs[0];
|
|
256324
|
+
next2 = `to try one test: ancha run --on cloud -n 1 ${test3 === void 0 ? "<test>" : shellWord(test3)}`;
|
|
256325
|
+
}
|
|
256326
|
+
throw new AnchaError(failure6.code, failure6.message, { ...failure6.docs !== void 0 && { docs: failure6.docs }, hint: `${failure6.hint ? `${failure6.hint}; ` : ""}${next2}`, cause: error65 });
|
|
256311
256327
|
}
|
|
256312
256328
|
return;
|
|
256313
256329
|
}
|
|
@@ -259896,14 +259912,18 @@ function readEvalItems(name5, raw3) {
|
|
|
259896
259912
|
|
|
259897
259913
|
// backend/src/kit/netsuite-data.ts
|
|
259898
259914
|
function netsuiteData(size2, options5 = {}) {
|
|
259899
|
-
const { world: world5, evals, counts: counts2 } = generateNetsuitePe({ size: size2, id: options5.id ?? `netsuite-pe-${size2}`, startTime: NETSUITE_PE_START_TIME, vocab: options5.vocab });
|
|
259915
|
+
const { world: world5, evals: all9, counts: counts2 } = generateNetsuitePe({ size: size2, id: options5.id ?? `netsuite-pe-${size2}`, startTime: NETSUITE_PE_START_TIME, vocab: options5.vocab });
|
|
259916
|
+
const evals = options5.readOnly ? all9.filter((e) => e.read_only) : all9;
|
|
259900
259917
|
const evalsFile = `${world5.id}.jsonl`;
|
|
259901
259918
|
const { tests, skipped } = importEvals(evals, { id: world5.id, tools: world5.tools }, { out: options5.testDirectory ?? "ancha/tests", source: evalsFile, judge: "never" });
|
|
259902
259919
|
if (skipped.length) throw new Error("NetSuite eval compilation failed");
|
|
259920
|
+
const reads2 = evals.filter((e) => e.read_only).length;
|
|
259903
259921
|
return {
|
|
259904
259922
|
id: world5.id,
|
|
259905
259923
|
size: size2,
|
|
259906
259924
|
counts: counts2,
|
|
259925
|
+
reads: reads2,
|
|
259926
|
+
writes: evals.length - reads2,
|
|
259907
259927
|
world: `ancha/worlds/${world5.id}.yaml`,
|
|
259908
259928
|
evals: `ancha/evals/${evalsFile}`,
|
|
259909
259929
|
tests: tests.map((test3) => test3.path),
|
|
@@ -261002,7 +261022,7 @@ async function wireExistingConfig(cwd, fillMissing) {
|
|
|
261002
261022
|
return task2;
|
|
261003
261023
|
}
|
|
261004
261024
|
function registerKit(program2, ctx) {
|
|
261005
|
-
program2.command("init").description("set up agent tests in this project: ancha.yaml, a starter test for the tools it uses, coding-agent instructions; installs and runs nothing").option("--on <target>", "use local setup and starter tests: local").option("--agent <command>", "the command that starts your agent (default: project scripts, README usage, Procfile, Dockerfile, langgraph.json or a single entry file)").option("--template <template>", "starter or incidents", "starter").option("--tools <tools>", "the tools your agent uses, comma-separated (e.g. netsuite,slack), in place of the ones init finds in its dependencies and source").option("--data <data>", "for an agent that uses NetSuite, in a project with no tests: netsuite-pe:s, netsuite-pe:m (the default) or netsuite-pe:l, the NetSuite world init writes with its 25 tests; none leaves them out, and the QuickBooks examples too").option("--intent <description>", "also generate a world (company, people, tool history) from this description and draft a first test with people for it (uses a model)").option("--idempotency-key <key>", "with --intent: return the first world and test for a repeated request instead of generating again").action(async (opts, command) => {
|
|
261025
|
+
program2.command("init").description("set up agent tests in this project: ancha.yaml, a starter test for the tools it uses, coding-agent instructions; installs and runs nothing").option("--on <target>", "use local setup and starter tests: local").option("--agent <command>", "the command that starts your agent (default: project scripts, README usage, Procfile, Dockerfile, langgraph.json or a single entry file)").option("--template <template>", "starter or incidents", "starter").option("--tools <tools>", "the tools your agent uses, comma-separated (e.g. netsuite,slack), in place of the ones init finds in its dependencies and source").option("--data <data>", "for an agent that uses NetSuite, in a project with no tests: netsuite-pe:s, netsuite-pe:m (the default) or netsuite-pe:l, the NetSuite world init writes with its 25 tests (its 10 read tasks for an agent on Composio); none leaves them out, and the QuickBooks examples too").option("--intent <description>", "also generate a world (company, people, tool history) from this description and draft a first test with people for it (uses a model)").option("--idempotency-key <key>", "with --intent: return the first world and test for a repeated request instead of generating again").action(async (opts, command) => {
|
|
261006
261026
|
if (opts.on !== void 0 && opts.on !== "local") throw new AnchaError("USAGE", "init --on expects local", { hint: "run ancha init --on local for local setup, or ancha init for your linked workspace" });
|
|
261007
261027
|
if (opts.template !== "starter" && opts.template !== "incidents") throw new AnchaError("USAGE", `unknown template: ${opts.template}`, { hint: "available templates: starter, incidents" });
|
|
261008
261028
|
const given2 = opts.tools === void 0 ? void 0 : parseTools(opts.tools);
|
|
@@ -261032,12 +261052,12 @@ function registerKit(program2, ctx) {
|
|
|
261032
261052
|
const own2 = opts.template === "starter" ? await ownStarter(ctx.io.cwd) : void 0;
|
|
261033
261053
|
const existing3 = defaultTemplate ? (await glob3(["scenes/**/scene.yaml", "ancha/tests/**/*.{yaml,yml}", ...existingConfig?.scenes ?? []], { cwd: ctx.io.cwd, onlyFiles: true, followSymbolicLinks: false })).sort().filter((path9) => own2 === void 0 || path9 !== "scenes/starter/scene.yaml") : [];
|
|
261034
261054
|
const cloud = opts.on === "local" ? false : await cloudWorkspace(ctx, { code: "USAGE", message: "no workspace", hint: "" }).then(() => true, () => false);
|
|
261035
|
-
const traces = await
|
|
261055
|
+
const traces = (await glob3(["traces/**/*.json", "traces/**/*.jsonl"], { cwd: ctx.io.cwd, onlyFiles: true, dot: false, ignore: ["**/node_modules/**"] })).length > 0;
|
|
261036
261056
|
const noStarter = defaultTemplate && (existing3.length > 0 || cloud && !(routeTools.length > 0 && !traces));
|
|
261037
261057
|
const starter = opts.template === "starter" && (!noStarter || own2 !== void 0);
|
|
261038
261058
|
const tests = (await glob3(["scenes/**/scene.yaml", "ancha/tests/**/*.yaml", ...existingConfig?.scenes ?? []], { cwd: ctx.io.cwd, onlyFiles: true, followSymbolicLinks: false })).filter((path9) => own2 === void 0 || path9 !== "scenes/starter/scene.yaml");
|
|
261039
|
-
const dataSize = data7 === "none" ? void 0 : data7 !== void 0 ? data7.size : used.includes("netsuite") &&
|
|
261040
|
-
const pe = dataSize === void 0 ? void 0 : netsuiteData(dataSize);
|
|
261059
|
+
const dataSize = data7 === "none" ? void 0 : data7 !== void 0 ? data7.size : used.includes("netsuite") && opts.intent === void 0 && tests.length === 0 && !traces ? "m" : void 0;
|
|
261060
|
+
const pe = dataSize === void 0 ? void 0 : netsuiteData(dataSize, { readOnly: routeTools.includes("netsuite") });
|
|
261041
261061
|
const examples2 = data7 !== "none" && used.includes("quickbooks") && opts.intent === void 0 && tests.length === 0 && !traces ? await quickbooksExamples() : void 0;
|
|
261042
261062
|
const existingTwins = await Promise.all(existing3.map((path9) => loadSceneFile(join58(ctx.io.cwd, path9)).then((scene2) => scene2.twins, () => [])));
|
|
261043
261063
|
const mapsNetsuite = task2 !== void 0 && task2.netsuite.length > 0 && opts.template === "starter" && existingTwins.every((list19) => list19.includes("netsuite")) && (!starter || twins.includes("netsuite"));
|
|
@@ -261124,7 +261144,7 @@ min_pass_rate: 1
|
|
|
261124
261144
|
const composio = detection.composio ? { tools: detection.composio.tools, routes: routes2, ...routeWiring, ...question && { question } } : void 0;
|
|
261125
261145
|
const savedLaunch = savedAgent?.mode === "endpoint" ? savedAgent.start : savedAgent?.command;
|
|
261126
261146
|
const runs = savedLaunch ? { command: savedLaunch, source: "ancha.yaml" } : void 0;
|
|
261127
|
-
const next2 = runs === void 0 ? ["set agent.command in ancha.yaml", cloud ? "ancha agent upload" : "ancha run"] : Object.keys(routes2).length > 0 && starter && !traces && existing3.length === 0 ? composioStarterNext(cloud, examples2 !== void 0) : generated ? cloud ? ["ancha agent upload", `ancha run ${generated.test.file}`] : [`ancha run ${generated.test.file}`] : cloud ? ["ancha agent upload", starter || existing3.length > 0 || pe || examples2 ? "ancha run" : "ancha traces upload ./traces"] : ["ancha run"];
|
|
261147
|
+
const next2 = runs === void 0 ? ["set agent.command in ancha.yaml", cloud ? "ancha agent upload" : "ancha run"] : Object.keys(routes2).length > 0 && starter && !traces && existing3.length === 0 ? composioStarterNext(cloud, examples2 !== void 0 || pe !== void 0) : generated ? cloud ? ["ancha agent upload", `ancha run ${generated.test.file}`] : [`ancha run ${generated.test.file}`] : cloud ? ["ancha agent upload", starter || existing3.length > 0 || pe || examples2 ? "ancha run" : "ancha traces upload ./traces"] : ["ancha run"];
|
|
261128
261148
|
next2.unshift(...functionToolWiring(detection.functionTools));
|
|
261129
261149
|
const taskInput = task2 === void 0 ? void 0 : {
|
|
261130
261150
|
native: task2.scan.native,
|
|
@@ -261157,7 +261177,7 @@ min_pass_rate: 1
|
|
|
261157
261177
|
...existing3.length > 0 ? [`scenes: ${existing3.length} already in this project (${existing3.slice(0, 2).join(", ")}${existing3.length > 2 ? ", \u2026" : ""}); ancha init --template starter adds the starter test`] : [],
|
|
261158
261178
|
...starter && unchecked.length > 0 ? [` ${names8(unchecked)}: seeded; no access check, since ${unchecked.length === 1 ? "its" : "their"} requests need signing or a token exchange; add checks of your own`] : [],
|
|
261159
261179
|
...examples2 ? [`examples: QuickBooks world ${examples2.id} (Pellmont Building Services' 2025 books) and ${examples2.tests.length} tests:`, ...examples2.tests.map((test3) => ` ${test3.file}: ${test3.title}`)] : [],
|
|
261160
|
-
...dataOutput ? [`data: NetSuite world ${pe.id} (${dataOutput.subsidiaries} subsidiaries, ${dataOutput.transactions.toLocaleString("en-US")} transactions) and ${dataOutput.tests} tests (
|
|
261180
|
+
...dataOutput ? [`data: NetSuite world ${pe.id} (${dataOutput.subsidiaries} subsidiaries, ${dataOutput.transactions.toLocaleString("en-US")} transactions) and ${dataOutput.tests} tests (${pe.reads} read tasks${pe.writes ? `, ${pe.writes} write workflows` : ""})`] : [],
|
|
261161
261181
|
...generated ? [`world: ${generated.world.file} (people: ${generated.world.people.join(", ") || "none"})`] : [],
|
|
261162
261182
|
...notGenerated?.added.length ? [` world gen populates ${gen_exports.GENERATED_TOOLS.join(", ")}; ${names8(notGenerated.added)} got ${notGenerated.added.length === 1 ? "its" : "their"} example data instead (ancha twins seed <tool> shows the fields)`] : [],
|
|
261163
261183
|
...notGenerated?.skipped.length ? [` ${names8(notGenerated.skipped)}: not in the world (the example data clashes with it); add a seed by hand (ancha twins seed <tool>)`] : [],
|
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.
|
|
@@ -70,7 +70,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
|
|
|
70
70
|
ancha run --compare before
|
|
71
71
|
```
|
|
72
72
|
- Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.
|
|
73
|
-
10. **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.
|
|
73
|
+
10. **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.
|
|
74
74
|
```sh
|
|
75
75
|
ancha run --on local --attempts 1
|
|
76
76
|
```
|
|
@@ -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.
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
ancha run --compare before
|
|
56
56
|
```
|
|
57
57
|
- Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.
|
|
58
|
-
10. **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.
|
|
58
|
+
10. **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.
|
|
59
59
|
```sh
|
|
60
60
|
ancha run --on local --attempts 1
|
|
61
61
|
```
|
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.
|
|
@@ -63,7 +63,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
|
|
|
63
63
|
ancha run --compare before
|
|
64
64
|
```
|
|
65
65
|
- Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.
|
|
66
|
-
10. **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.
|
|
66
|
+
10. **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.
|
|
67
67
|
```sh
|
|
68
68
|
ancha run --on local --attempts 1
|
|
69
69
|
```
|
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.
|
|
@@ -61,7 +61,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
61
61
|
ancha run --compare before
|
|
62
62
|
```
|
|
63
63
|
- Commit `scenes/from-traces/` so every run, in CI too, keeps it fixed.
|
|
64
|
-
10. **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.
|
|
64
|
+
10. **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.
|
|
65
65
|
```sh
|
|
66
66
|
ancha run --on local --attempts 1
|
|
67
67
|
```
|
|
@@ -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,6 +166352,13 @@ 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, value6) => {
|
|
166356
|
+
if (typeof value6 !== "string") return value6;
|
|
166357
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
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
|
+
};
|
|
166355
166362
|
projection = projection?.map((p2) => property4(p2));
|
|
166356
166363
|
const conditions = [];
|
|
166357
166364
|
let explicitActive = false;
|
|
@@ -166363,6 +166370,11 @@ function queryRecords(ctx, sql5) {
|
|
|
166363
166370
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
166364
166371
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
166365
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
|
+
};
|
|
166366
166378
|
if (peek("WHERE")) {
|
|
166367
166379
|
i++;
|
|
166368
166380
|
do {
|
|
@@ -166371,10 +166383,10 @@ function queryRecords(ctx, sql5) {
|
|
|
166371
166383
|
const op = ts2[i++]?.text.toUpperCase();
|
|
166372
166384
|
if (op === "IN") {
|
|
166373
166385
|
take2("(");
|
|
166374
|
-
const values3 = [
|
|
166386
|
+
const values3 = [value5(key5)];
|
|
166375
166387
|
while (peek(",")) {
|
|
166376
166388
|
i++;
|
|
166377
|
-
values3.push(
|
|
166389
|
+
values3.push(value5(key5));
|
|
166378
166390
|
}
|
|
166379
166391
|
take2(")");
|
|
166380
166392
|
conditions.push((row2) => {
|
|
@@ -166387,17 +166399,17 @@ function queryRecords(ctx, sql5) {
|
|
|
166387
166399
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
166388
166400
|
conditions.push((row2) => {
|
|
166389
166401
|
const actual = scalar2(row2, key5);
|
|
166390
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
166391
|
-
const v = String(
|
|
166402
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value6) => {
|
|
166403
|
+
const v = String(value6 ?? "").toLowerCase();
|
|
166392
166404
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
166393
166405
|
});
|
|
166394
166406
|
});
|
|
166395
166407
|
} else {
|
|
166396
166408
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
166397
|
-
const expected =
|
|
166409
|
+
const expected = value5(key5);
|
|
166398
166410
|
conditions.push((row2) => {
|
|
166399
|
-
const
|
|
166400
|
-
return (Array.isArray(
|
|
166411
|
+
const value6 = scalar2(row2, key5);
|
|
166412
|
+
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
166401
166413
|
let actual = item2, target5 = expected;
|
|
166402
166414
|
if (actual === void 0) return false;
|
|
166403
166415
|
if (key5.startsWith("MetaData.")) {
|
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.\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/assets/ui/style.css
CHANGED
|
@@ -1090,6 +1090,7 @@ select.k-filter:hover{border-color:#B9B7B0}
|
|
|
1090
1090
|
@media (prefers-reduced-motion:reduce){.k-sq.run{animation:none}.k-switch::after{transition:none}}
|
|
1091
1091
|
@media (max-width:650px){
|
|
1092
1092
|
.k-title h1{font-size:23px}
|
|
1093
|
+
.call-value dl.call-fields{grid-template-columns:minmax(0,1fr)}
|
|
1093
1094
|
.k-step{grid-template-columns:22px minmax(0,1fr) auto;gap:4px 10px;padding:8px 12px}
|
|
1094
1095
|
.k-step>.tool{grid-column:2}.k-step>.what{grid-column:2}.k-step>.t{grid-column:3;grid-row:1}
|
|
1095
1096
|
.k-step-check{padding:4px 12px 14px}
|
package/lib/worker.mjs
CHANGED
|
@@ -214459,6 +214459,13 @@ function queryRecords(ctx, sql5) {
|
|
|
214459
214459
|
if (!confirmed.has(key5) && !["TimeActivity", "Attachable", "TaxAgency", "ExchangeRate"].includes(type)) hasGap = true;
|
|
214460
214460
|
return key5;
|
|
214461
214461
|
}
|
|
214462
|
+
const typed = (key5, value6) => {
|
|
214463
|
+
if (typeof value6 !== "string") return value6;
|
|
214464
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
214465
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value6)) return Number(value6);
|
|
214466
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value6)) return value6.toLowerCase() === "true";
|
|
214467
|
+
return value6;
|
|
214468
|
+
};
|
|
214462
214469
|
projection = projection?.map((p2) => property4(p2));
|
|
214463
214470
|
const conditions = [];
|
|
214464
214471
|
let explicitActive = false;
|
|
@@ -214470,6 +214477,11 @@ function queryRecords(ctx, sql5) {
|
|
|
214470
214477
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
214471
214478
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
214472
214479
|
};
|
|
214480
|
+
const value5 = (key5) => {
|
|
214481
|
+
const token5 = ts3[i], read6 = typed(key5, literal2());
|
|
214482
|
+
if (token5?.kind === "number" && fields13.find((f2) => f2[0] === key5)?.[1] === "string") parseError2(`${key5} is text: give its value in single quotes.`);
|
|
214483
|
+
return read6;
|
|
214484
|
+
};
|
|
214473
214485
|
if (peek("WHERE")) {
|
|
214474
214486
|
i++;
|
|
214475
214487
|
do {
|
|
@@ -214478,10 +214490,10 @@ function queryRecords(ctx, sql5) {
|
|
|
214478
214490
|
const op = ts3[i++]?.text.toUpperCase();
|
|
214479
214491
|
if (op === "IN") {
|
|
214480
214492
|
take2("(");
|
|
214481
|
-
const values3 = [
|
|
214493
|
+
const values3 = [value5(key5)];
|
|
214482
214494
|
while (peek(",")) {
|
|
214483
214495
|
i++;
|
|
214484
|
-
values3.push(
|
|
214496
|
+
values3.push(value5(key5));
|
|
214485
214497
|
}
|
|
214486
214498
|
take2(")");
|
|
214487
214499
|
conditions.push((row2) => {
|
|
@@ -214494,17 +214506,17 @@ function queryRecords(ctx, sql5) {
|
|
|
214494
214506
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
214495
214507
|
conditions.push((row2) => {
|
|
214496
214508
|
const actual = scalar2(row2, key5);
|
|
214497
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
214498
|
-
const v = String(
|
|
214509
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value6) => {
|
|
214510
|
+
const v = String(value6 ?? "").toLowerCase();
|
|
214499
214511
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
214500
214512
|
});
|
|
214501
214513
|
});
|
|
214502
214514
|
} else {
|
|
214503
214515
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
214504
|
-
const expected =
|
|
214516
|
+
const expected = value5(key5);
|
|
214505
214517
|
conditions.push((row2) => {
|
|
214506
|
-
const
|
|
214507
|
-
return (Array.isArray(
|
|
214518
|
+
const value6 = scalar2(row2, key5);
|
|
214519
|
+
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
214508
214520
|
let actual = item2, target5 = expected;
|
|
214509
214521
|
if (actual === void 0) return false;
|
|
214510
214522
|
if (key5.startsWith("MetaData.")) {
|
package/lib/world-server.mjs
CHANGED
|
@@ -182575,6 +182575,13 @@ 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, value6) => {
|
|
182579
|
+
if (typeof value6 !== "string") return value6;
|
|
182580
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
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
|
+
};
|
|
182578
182585
|
projection = projection?.map((p2) => property4(p2));
|
|
182579
182586
|
const conditions = [];
|
|
182580
182587
|
let explicitActive = false;
|
|
@@ -182586,6 +182593,11 @@ function queryRecords(ctx, sql5) {
|
|
|
182586
182593
|
if (/^(true|false)$/i.test(t.text)) return t.text.toLowerCase() === "true";
|
|
182587
182594
|
return parseError2("Expected a quoted string, number or boolean.");
|
|
182588
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
|
+
};
|
|
182589
182601
|
if (peek("WHERE")) {
|
|
182590
182602
|
i++;
|
|
182591
182603
|
do {
|
|
@@ -182594,10 +182606,10 @@ function queryRecords(ctx, sql5) {
|
|
|
182594
182606
|
const op = ts2[i++]?.text.toUpperCase();
|
|
182595
182607
|
if (op === "IN") {
|
|
182596
182608
|
take2("(");
|
|
182597
|
-
const values3 = [
|
|
182609
|
+
const values3 = [value5(key5)];
|
|
182598
182610
|
while (peek(",")) {
|
|
182599
182611
|
i++;
|
|
182600
|
-
values3.push(
|
|
182612
|
+
values3.push(value5(key5));
|
|
182601
182613
|
}
|
|
182602
182614
|
take2(")");
|
|
182603
182615
|
conditions.push((row2) => {
|
|
@@ -182610,17 +182622,17 @@ function queryRecords(ctx, sql5) {
|
|
|
182610
182622
|
const needle = pattern.replace(/^%/, "").replace(/%$/, "").toLowerCase();
|
|
182611
182623
|
conditions.push((row2) => {
|
|
182612
182624
|
const actual = scalar2(row2, key5);
|
|
182613
|
-
return (Array.isArray(actual) ? actual : [actual]).some((
|
|
182614
|
-
const v = String(
|
|
182625
|
+
return (Array.isArray(actual) ? actual : [actual]).some((value6) => {
|
|
182626
|
+
const v = String(value6 ?? "").toLowerCase();
|
|
182615
182627
|
return pattern.startsWith("%") && pattern.endsWith("%") ? v.includes(needle) : pattern.startsWith("%") ? v.endsWith(needle) : pattern.endsWith("%") ? v.startsWith(needle) : v === needle;
|
|
182616
182628
|
});
|
|
182617
182629
|
});
|
|
182618
182630
|
} else {
|
|
182619
182631
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
182620
|
-
const expected =
|
|
182632
|
+
const expected = value5(key5);
|
|
182621
182633
|
conditions.push((row2) => {
|
|
182622
|
-
const
|
|
182623
|
-
return (Array.isArray(
|
|
182634
|
+
const value6 = scalar2(row2, key5);
|
|
182635
|
+
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
182624
182636
|
let actual = item2, target5 = expected;
|
|
182625
182637
|
if (actual === void 0) return false;
|
|
182626
182638
|
if (key5.startsWith("MetaData.")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancha-labs/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
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": {
|