@ancha-labs/cli 0.4.47 → 0.4.49
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 +192 -64
- 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 +2 -2
- package/lib/assets/harbor/companion.mjs +10 -3
- package/lib/assets/ui/app.js +1 -1
- package/lib/assets/ui/style.css +1 -0
- package/lib/worker.mjs +10 -3
- package/lib/world-server.mjs +10 -3
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -181022,10 +181022,10 @@ function commentJson2(model2, row2) {
|
|
|
181022
181022
|
...Object.keys(mentioned).length && { mentioned }
|
|
181023
181023
|
};
|
|
181024
181024
|
}
|
|
181025
|
-
function commentsOf3(call4,
|
|
181026
|
-
need(call4.ctx,
|
|
181025
|
+
function commentsOf3(call4, writing2) {
|
|
181026
|
+
need(call4.ctx, writing2 ? "data.recordComments:write" : "data.recordComments:read");
|
|
181027
181027
|
const model2 = AirtableBase.find(call4.ctx, call4.ids[0]), table6 = model2.table(call4.ids[1]);
|
|
181028
|
-
if (
|
|
181028
|
+
if (writing2) atLeast(model2, "comment");
|
|
181029
181029
|
return { model: model2, record: recordIn(model2, table6, call4.ids[2]) };
|
|
181030
181030
|
}
|
|
181031
181031
|
function listComments3(call4) {
|
|
@@ -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, value6) => {
|
|
193697
|
+
if (typeof value6 !== "string") return value6;
|
|
193698
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
193699
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value6)) return Number(value6);
|
|
193700
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value6)) return value6.toLowerCase() === "true";
|
|
193701
|
+
return value6;
|
|
193702
|
+
};
|
|
193696
193703
|
projection2 = projection2?.map((p2) => property4(p2));
|
|
193697
193704
|
const conditions = [];
|
|
193698
193705
|
let explicitActive = false;
|
|
@@ -193712,10 +193719,10 @@ function queryRecords(ctx, sql6) {
|
|
|
193712
193719
|
const op2 = ts3[i++]?.text.toUpperCase();
|
|
193713
193720
|
if (op2 === "IN") {
|
|
193714
193721
|
take2("(");
|
|
193715
|
-
const values3 = [literal4()];
|
|
193722
|
+
const values3 = [typed(key5, literal4())];
|
|
193716
193723
|
while (peek(",")) {
|
|
193717
193724
|
i++;
|
|
193718
|
-
values3.push(literal4());
|
|
193725
|
+
values3.push(typed(key5, literal4()));
|
|
193719
193726
|
}
|
|
193720
193727
|
take2(")");
|
|
193721
193728
|
conditions.push((row2) => {
|
|
@@ -193735,7 +193742,7 @@ function queryRecords(ctx, sql6) {
|
|
|
193735
193742
|
});
|
|
193736
193743
|
} else {
|
|
193737
193744
|
if (!["=", "<", ">", "<=", ">="].includes(op2 ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
193738
|
-
const expected = literal4();
|
|
193745
|
+
const expected = typed(key5, literal4());
|
|
193739
193746
|
conditions.push((row2) => {
|
|
193740
193747
|
const value6 = scalar2(row2, key5);
|
|
193741
193748
|
return (Array.isArray(value6) ? value6 : [value6]).some((item2) => {
|
|
@@ -249932,7 +249939,6 @@ Additional required criterion: ${savedGoal.judge}`;
|
|
|
249932
249939
|
const required6 = new Set(scene2.pass ?? scene2.checks.map((c) => c.id));
|
|
249933
249940
|
const catchesInaction = scene2.checks.some((check4) => {
|
|
249934
249941
|
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
249942
|
if (!check4.state || check4.state.exists === false) return false;
|
|
249937
249943
|
try {
|
|
249938
249944
|
return startingState(check4.state, scene2) === "failed";
|
|
@@ -251675,7 +251681,7 @@ function withOwnNext(onboarding) {
|
|
|
251675
251681
|
const testsAdded = onboarding.checks.testsAdded ?? { done: traces?.done === true, traceId: traces?.traceId ?? null, runId: null, at: traces?.at ?? null };
|
|
251676
251682
|
const checks2 = { ...onboarding.checks, testsAdded };
|
|
251677
251683
|
const open17 = CHECKS.find(([key5]) => !checks2[key5].done)?.[0];
|
|
251678
|
-
return { ...onboarding, checks: checks2, nextCommand: NEXT_COMMANDS[open17 ?? "done"] };
|
|
251684
|
+
return { ...onboarding, checks: checks2, nextCommand: open17 === "testsAdded" && traces?.done && traces.traceId ? `ancha pull ${traces.traceId}` : NEXT_COMMANDS[open17 ?? "done"] };
|
|
251679
251685
|
}
|
|
251680
251686
|
var checkLine = (done, [, doneLabel, title2]) => `${done ? "\u2713" : "\u25CB"} ${done ? doneLabel : title2}`;
|
|
251681
251687
|
async function listsTests(ctx) {
|
|
@@ -251964,7 +251970,7 @@ function eventLine(event3, all9) {
|
|
|
251964
251970
|
case "phase":
|
|
251965
251971
|
return all9 ? `${attemptOf(event3)}: ${text27(data7.phase)}` : void 0;
|
|
251966
251972
|
case "log":
|
|
251967
|
-
return all9 ? `${event3.attemptId === null ? "" : `${attemptOf(event3)}: `}${text27(data7.line ?? data7.text ?? data7.message)}` : void 0;
|
|
251973
|
+
return data7.source === "machine_wait" ? `waiting for a machine: ${text27(data7.reason)}; retrying` : all9 ? `${event3.attemptId === null ? "" : `${attemptOf(event3)}: `}${text27(data7.line ?? data7.text ?? data7.message)}` : void 0;
|
|
251968
251974
|
default:
|
|
251969
251975
|
return all9 ? `${event3.type.replace(/_/g, " ")}${data7.state ? `: ${text27(data7.state)}` : ""}` : void 0;
|
|
251970
251976
|
}
|
|
@@ -252020,7 +252026,7 @@ function projectTestDirectoryReader(cwd, cloud) {
|
|
|
252020
252026
|
function finishedText(ws, detail3, includeNext = true) {
|
|
252021
252027
|
const { job, summary } = detail3;
|
|
252022
252028
|
const counts2 = summary?.counts ?? job.counts;
|
|
252023
|
-
const never2 = cloudNeverRan(detail3);
|
|
252029
|
+
const never2 = ["install", "create", "start"].includes(job.error?.step ?? "") ? void 0 : cloudNeverRan(detail3);
|
|
252024
252030
|
if (never2 !== void 0 && summary !== null) {
|
|
252025
252031
|
const head2 = summary.graded !== true && counts2.completedAttempts === 0 ? "INVALID (no attempts graded)" : job.state === "completed" ? summary.verdict.toUpperCase() : job.state.toUpperCase();
|
|
252026
252032
|
const folded = neverRanChecksLine(never2, job.id);
|
|
@@ -252062,7 +252068,11 @@ function finishedText(ws, detail3, includeNext = true) {
|
|
|
252062
252068
|
const counts3 = job.counts;
|
|
252063
252069
|
if (counts3 !== void 0) lines2.push(`Cases: ${counts3.cases} \xB7 attempts: ${counts3.requestedAttempts} requested, ${counts3.completedAttempts} completed, ${counts3.invalidAttempts} invalid${counts3.skippedAttempts ? `, ${counts3.skippedAttempts} skipped` : ""}${counts3.cancelledAttempts ? `, ${counts3.cancelledAttempts} cancelled` : ""}`);
|
|
252064
252070
|
}
|
|
252065
|
-
if (job.error !== null && job.error !== void 0) lines2.push(
|
|
252071
|
+
if (job.error !== null && job.error !== void 0) lines2.push(
|
|
252072
|
+
`${job.error.step ? `${job.error.step}: ` : ""}${job.error.message}`,
|
|
252073
|
+
...job.error.step === "install" && job.error.stderr ? job.error.stderr.trim().split("\n").slice(-10).map((line2) => ` ${line2}`) : [],
|
|
252074
|
+
errorAction(toErrorJson(serverError(400, { error: job.error }, { message: "The job failed." })))
|
|
252075
|
+
);
|
|
252066
252076
|
lines2.push(`Result: ${resultUrl(ws, detail3)}`);
|
|
252067
252077
|
if (includeNext && job.kind === "run") {
|
|
252068
252078
|
const ungraded = summary?.verdict === "ungraded";
|
|
@@ -256050,8 +256060,10 @@ next: ancha wait ${job.id}`);
|
|
|
256050
256060
|
return followToEnd(ctx, ws, job.id, signal);
|
|
256051
256061
|
}
|
|
256052
256062
|
async function connectOnCloud(ctx, ws, check4, signal) {
|
|
256063
|
+
const key5 = submissionKey(check4.idempotencyKey);
|
|
256053
256064
|
const { bundle } = await cloudBundle(ctx, { kind: "connect", tests: [], options: { attempts: 1, concurrency: 1, seed: null, strict: false, minPassRate: check4.minPassRate, allowUnwrapped: [], agentCommand: check4.agentCommand } });
|
|
256054
|
-
const submitted = await submit2(ws, bundle,
|
|
256065
|
+
const submitted = await submit2(ws, bundle, key5, signal, {});
|
|
256066
|
+
if (submitted.replayed && check4.idempotencyKey !== void 0) ctx.out.info(`${submitted.job.id}: already submitted with this --idempotency-key`);
|
|
256055
256067
|
const logTail3 = [];
|
|
256056
256068
|
const agentLogTail = [];
|
|
256057
256069
|
await followJob(ws, submitted.job.id, { signal, onEvent: (event3) => {
|
|
@@ -256301,7 +256313,12 @@ function registerRun(program2, ctx) {
|
|
|
256301
256313
|
} catch (error65) {
|
|
256302
256314
|
if (!defaulted) throw error65;
|
|
256303
256315
|
const failure6 = toErrorJson(error65);
|
|
256304
|
-
|
|
256316
|
+
let next2 = "to run on this computer: ancha run --on local";
|
|
256317
|
+
if (Object.keys(config12.agent?.routes ?? {}).length > 0) {
|
|
256318
|
+
const test3 = (await glob3(sceneArgs.length > 0 ? sceneArgs : config12.scenes, { cwd, onlyFiles: true })).sort()[0] ?? sceneArgs[0];
|
|
256319
|
+
next2 = `to try one test: ancha run --on cloud -n 1 ${test3 === void 0 ? "<test>" : shellWord(test3)}`;
|
|
256320
|
+
}
|
|
256321
|
+
throw new AnchaError(failure6.code, failure6.message, { ...failure6.docs !== void 0 && { docs: failure6.docs }, hint: `${failure6.hint ? `${failure6.hint}; ` : ""}${next2}`, cause: error65 });
|
|
256305
256322
|
}
|
|
256306
256323
|
return;
|
|
256307
256324
|
}
|
|
@@ -257039,7 +257056,7 @@ async function uploadAgent(ctx, opts, command = "ancha agent upload") {
|
|
|
257039
257056
|
const configured = config12.agent?.mode === "endpoint" ? void 0 : config12.agent;
|
|
257040
257057
|
const task2 = await taskCheck(ctx, typeof opts.agent === "string" ? { command: opts.agent, ...configured?.env && { env: configured.env } } : configured);
|
|
257041
257058
|
if (task2?.status === "warning") ctx.out.info(`${task2.message}: ${task2.fix} (${task2.hint})`);
|
|
257042
|
-
const { detail: detail3, agent, agentAction: agentAction2, bundle, logTail: logTail3, url: url4 } = await interruptible(ctx, (signal) => connectOnCloud(ctx, ws, { agentCommand: typeof opts.agent === "string" ? opts.agent : null, minPassRate: config12.min_pass_rate }, signal));
|
|
257059
|
+
const { detail: detail3, agent, agentAction: agentAction2, bundle, logTail: logTail3, url: url4 } = await interruptible(ctx, (signal) => connectOnCloud(ctx, ws, { agentCommand: typeof opts.agent === "string" ? opts.agent : null, minPassRate: config12.min_pass_rate, ...opts.idempotencyKey !== void 0 && { idempotencyKey: opts.idempotencyKey } }, signal));
|
|
257043
257060
|
const checks2 = [
|
|
257044
257061
|
{ name: "workspace", status: "pass", message: `running in the workspace ${ws.server}` },
|
|
257045
257062
|
{ name: "bundle", status: "pass", message: `${bundle.files} files, ${(bundle.bytes / 1024 / 1024).toFixed(1)} MiB; project ${bundle.projectHash.slice(0, 12)}` },
|
|
@@ -257444,7 +257461,7 @@ function loginRunLine(ctx) {
|
|
|
257444
257461
|
const apiKey = Boolean(ctx.io.env.ANCHA_API_KEY);
|
|
257445
257462
|
return apiKey || inCi(ctx.io.env) ? `${apiKey ? "With ANCHA_API_KEY set" : "In CI"}, ancha run runs where ancha.yaml says; ancha run --on cloud runs in this workspace.` : "ancha run runs your tests in this workspace; ancha run --on local runs them on this computer.";
|
|
257446
257463
|
}
|
|
257447
|
-
async function json38(url4, init = {}, fetchImpl = fetch) {
|
|
257464
|
+
async function json38(url4, init = {}, fetchImpl = fetch, transient = false) {
|
|
257448
257465
|
let res;
|
|
257449
257466
|
let text31;
|
|
257450
257467
|
try {
|
|
@@ -257454,10 +257471,16 @@ async function json38(url4, init = {}, fetchImpl = fetch) {
|
|
|
257454
257471
|
});
|
|
257455
257472
|
throw authError(new URL(url4).origin, { status: 401, keySent: Boolean(new Headers(init.headers).get("authorization")) });
|
|
257456
257473
|
}
|
|
257474
|
+
if (transient && [429, 502, 503, 504].includes(res.status)) {
|
|
257475
|
+
void res.body?.cancel().catch(() => {
|
|
257476
|
+
});
|
|
257477
|
+
throw Object.assign(new AnchaError("SERVER_UNREACHABLE", `cannot reach ${new URL(url4).origin}`, { hint: "run ancha login again" }), { retryAfter: res.headers.get("retry-after") });
|
|
257478
|
+
}
|
|
257457
257479
|
text31 = await res.text();
|
|
257458
257480
|
} catch (e) {
|
|
257459
257481
|
if (e instanceof AnchaError) throw e;
|
|
257460
|
-
|
|
257482
|
+
const error65 = new AnchaError("SERVER_UNREACHABLE", `cannot reach ${new URL(url4).origin}`, { hint: "check the address and your network, then run ancha login again", cause: e });
|
|
257483
|
+
throw transient ? Object.assign(error65, { retryAfter: null }) : error65;
|
|
257461
257484
|
}
|
|
257462
257485
|
let body8;
|
|
257463
257486
|
try {
|
|
@@ -257467,7 +257490,14 @@ async function json38(url4, init = {}, fetchImpl = fetch) {
|
|
|
257467
257490
|
}
|
|
257468
257491
|
if (!res.ok) {
|
|
257469
257492
|
const message8 = body8 && typeof body8 === "object" && typeof body8.error === "string" ? body8.error : `HTTP ${res.status}`;
|
|
257470
|
-
throw new AnchaError("INTERNAL", `${new URL(url4).origin}: ${message8}`);
|
|
257493
|
+
if (!transient || res.status === 403) throw new AnchaError("INTERNAL", `${new URL(url4).origin}: ${message8}`);
|
|
257494
|
+
const contract = body8 && typeof body8 === "object" && typeof body8.error === "object" ? body8 : void 0;
|
|
257495
|
+
const error65 = serverError(res.status, contract, { message: `${new URL(url4).origin}: ${message8}`, code: "INTERNAL" });
|
|
257496
|
+
if (res.status === 500) {
|
|
257497
|
+
error65.code = "INTERNAL";
|
|
257498
|
+
error65.kind = "ours";
|
|
257499
|
+
}
|
|
257500
|
+
throw error65;
|
|
257471
257501
|
}
|
|
257472
257502
|
if (body8 === void 0) throw new AnchaError("INTERNAL", `${new URL(url4).origin} sent a malformed response`);
|
|
257473
257503
|
return body8;
|
|
@@ -257485,12 +257515,34 @@ function openBrowser(url4) {
|
|
|
257485
257515
|
}
|
|
257486
257516
|
}
|
|
257487
257517
|
var sleep12 = (ms2, signal) => new Promise((resolve63) => {
|
|
257488
|
-
const
|
|
257489
|
-
signal?.addEventListener("abort", () => {
|
|
257518
|
+
const done = () => {
|
|
257490
257519
|
clearTimeout(timer);
|
|
257520
|
+
signal?.removeEventListener("abort", done);
|
|
257491
257521
|
resolve63();
|
|
257492
|
-
}
|
|
257522
|
+
};
|
|
257523
|
+
const timer = setTimeout(done, ms2);
|
|
257524
|
+
if (signal?.aborted) done();
|
|
257525
|
+
else signal?.addEventListener("abort", done, { once: true });
|
|
257493
257526
|
});
|
|
257527
|
+
async function loginJson(url4, init, fetchImpl, signal, deadline3 = Infinity) {
|
|
257528
|
+
for (let failures = 0; ; failures++) {
|
|
257529
|
+
if (signal?.aborted) throw new AnchaError("USAGE", "login interrupted");
|
|
257530
|
+
try {
|
|
257531
|
+
const timeout = AbortSignal.timeout(Math.max(1, Math.min(2e4, deadline3 > Date.now() ? deadline3 - Date.now() : 2e4)));
|
|
257532
|
+
return await json38(url4, { ...init, signal: signal ? AbortSignal.any([signal, timeout]) : timeout }, fetchImpl, true);
|
|
257533
|
+
} catch (error65) {
|
|
257534
|
+
if (signal?.aborted) throw new AnchaError("USAGE", "login interrupted");
|
|
257535
|
+
if (!(error65 instanceof AnchaError) || !("retryAfter" in error65)) throw error65;
|
|
257536
|
+
const unavailable3 = () => new AnchaError("SERVER_UNREACHABLE", error65.message, { kind: "retry", hint: "run ancha login again", cause: error65 });
|
|
257537
|
+
if (failures >= 5 || Date.now() >= deadline3) throw unavailable3();
|
|
257538
|
+
const after = error65.retryAfter;
|
|
257539
|
+
const delay = after && /^\d+(?:\.\d+)?$/.test(after.trim()) ? Number(after) * 1e3 : after ? Date.parse(after) - Date.now() : NaN;
|
|
257540
|
+
await sleep12(Math.min(deadline3 - Date.now(), Number.isFinite(delay) ? Math.max(0, Math.min(3e4, delay)) : 4e3 + Math.random() * 2e3), signal);
|
|
257541
|
+
if (Date.now() >= deadline3) throw unavailable3();
|
|
257542
|
+
}
|
|
257543
|
+
}
|
|
257544
|
+
}
|
|
257545
|
+
var SAVE_REASONS = { EACCES: "permission denied", EPERM: "operation not permitted", EROFS: "read-only file system", ENOSPC: "no space left on device", EISDIR: "is a directory", ENOTDIR: "not a directory" };
|
|
257494
257546
|
var RESUME_HINT = "If this command stops before you approve, run ancha login again: it finishes this sign-in.";
|
|
257495
257547
|
var pendingPath = (env2) => {
|
|
257496
257548
|
const path9 = credentialsPath(env2);
|
|
@@ -257538,10 +257590,10 @@ function registerLogin(program2, ctx, deps = {}) {
|
|
|
257538
257590
|
}
|
|
257539
257591
|
const env2 = ctx.io.env, signal = ctx.io.abort;
|
|
257540
257592
|
if (!credentialsPath(env2)) throw new AnchaError("USAGE", "set HOME or ANCHA_CREDENTIALS_FILE to save a sign-in");
|
|
257541
|
-
const poll = (deviceCode) =>
|
|
257593
|
+
const poll = (deviceCode, deadline4) => loginJson(`${base6}/cli/poll?device_code=${encodeURIComponent(deviceCode)}`, {}, deps.fetch, signal, deadline4);
|
|
257542
257594
|
let pending = await readPending(env2, base6), resumed = false;
|
|
257543
257595
|
if (pending) {
|
|
257544
|
-
const first2 = await poll(pending.deviceCode);
|
|
257596
|
+
const first2 = await poll(pending.deviceCode, Date.parse(pending.expiresAt));
|
|
257545
257597
|
if (first2.status === "approved") return finish2(first2, pending.deviceCode);
|
|
257546
257598
|
if (first2.status === "pending" && Date.parse(pending.expiresAt) - Date.now() > 15e3) resumed = true;
|
|
257547
257599
|
else {
|
|
@@ -257551,7 +257603,7 @@ function registerLogin(program2, ctx, deps = {}) {
|
|
|
257551
257603
|
}
|
|
257552
257604
|
let saved = resumed;
|
|
257553
257605
|
if (!pending) {
|
|
257554
|
-
const start2 = await
|
|
257606
|
+
const start2 = await loginJson(`${base6}/cli/device`, { method: "POST", body: JSON.stringify({ name: hostname4() }) }, deps.fetch, signal);
|
|
257555
257607
|
pending = { version: 1, server: base6, deviceCode: start2.device_code, userCode: start2.user_code, verificationUrl: start2.verification_url, interval: start2.interval, window: start2.expires_in, expiresAt: new Date(Date.now() + start2.expires_in * 1e3).toISOString() };
|
|
257556
257608
|
saved = await writePending(env2, pending);
|
|
257557
257609
|
}
|
|
@@ -257565,9 +257617,9 @@ function registerLogin(program2, ctx, deps = {}) {
|
|
|
257565
257617
|
const deadline3 = Date.parse(pending.expiresAt);
|
|
257566
257618
|
const interval = Math.max(2, Math.min(15, pending.interval || 3)) * 1e3;
|
|
257567
257619
|
while (Date.now() < deadline3 && !signal?.aborted) {
|
|
257568
|
-
await sleep12(interval, signal);
|
|
257569
|
-
if (signal?.aborted) break;
|
|
257570
|
-
const result = await poll(pending.deviceCode);
|
|
257620
|
+
await sleep12(Math.min(interval, deadline3 - Date.now()), signal);
|
|
257621
|
+
if (signal?.aborted || Date.now() >= deadline3) break;
|
|
257622
|
+
const result = await poll(pending.deviceCode, Date.parse(pending.expiresAt));
|
|
257571
257623
|
if (result.status === "pending") continue;
|
|
257572
257624
|
if (result.status === "denied") {
|
|
257573
257625
|
await dropPending(env2, pending.deviceCode);
|
|
@@ -257586,10 +257638,17 @@ function registerLogin(program2, ctx, deps = {}) {
|
|
|
257586
257638
|
throw new AnchaError("INTERNAL", `${base6} approved the sign-in without a key`);
|
|
257587
257639
|
}
|
|
257588
257640
|
const serverUrl3 = normalizeServerUrl(approved.serverUrl);
|
|
257589
|
-
|
|
257590
|
-
|
|
257591
|
-
|
|
257592
|
-
|
|
257641
|
+
let path9;
|
|
257642
|
+
try {
|
|
257643
|
+
const file3 = await readCredentials(env2);
|
|
257644
|
+
file3.servers[serverUrl3] = { apiKey: approved.apiKey, ...approved.email && { email: approved.email }, savedAt: (/* @__PURE__ */ new Date()).toISOString(), minted: "device" };
|
|
257645
|
+
file3.default = serverUrl3;
|
|
257646
|
+
path9 = await writeCredentials(file3, env2);
|
|
257647
|
+
} catch (error65) {
|
|
257648
|
+
const reason2 = SAVE_REASONS[error65.code ?? ""];
|
|
257649
|
+
if (!reason2) throw error65;
|
|
257650
|
+
throw new AnchaError("CONFIG_INVALID", `cannot save the sign-in to ${credentialsPath(env2)}: ${reason2}`, { kind: "fix", hint: "make the folder writable, or set ANCHA_CREDENTIALS_FILE to a file you can write", cause: error65 });
|
|
257651
|
+
}
|
|
257593
257652
|
await dropPending(env2, deviceCode);
|
|
257594
257653
|
let onboarding = null, unread2;
|
|
257595
257654
|
try {
|
|
@@ -258581,7 +258640,7 @@ init_scenes();
|
|
|
258581
258640
|
|
|
258582
258641
|
// packages/cli/src/kit/init.ts
|
|
258583
258642
|
import { constants as constants12 } from "node:fs";
|
|
258584
|
-
import { lstat as lstat10, mkdir as mkdir26, open as
|
|
258643
|
+
import { lstat as lstat10, mkdir as mkdir26, open as fsOpen, readFile as readFile43, rm as rm13, writeFile as fsWriteFile } from "node:fs/promises";
|
|
258585
258644
|
import { join as join58 } from "node:path";
|
|
258586
258645
|
import { Writable } from "node:stream";
|
|
258587
258646
|
var import_yaml18 = __toESM(require_dist(), 1);
|
|
@@ -260579,6 +260638,30 @@ ${doc.markdown}` : doc.markdown);
|
|
|
260579
260638
|
|
|
260580
260639
|
// packages/cli/src/kit/init.ts
|
|
260581
260640
|
var toolName = (twin) => TOOL_DESCRIPTORS.find((tool) => tool.name === twin)?.title ?? twin;
|
|
260641
|
+
var WRITE_REFUSALS = {
|
|
260642
|
+
EACCES: "permission denied",
|
|
260643
|
+
EPERM: "not permitted",
|
|
260644
|
+
EROFS: "the file system is read-only",
|
|
260645
|
+
ENOSPC: "the disk is full",
|
|
260646
|
+
EDQUOT: "the disk quota is used up",
|
|
260647
|
+
ENOTDIR: "part of the path is a file, not a folder",
|
|
260648
|
+
EISDIR: "it is a folder"
|
|
260649
|
+
};
|
|
260650
|
+
function initWriteError(error65, cwd) {
|
|
260651
|
+
const cause = error65;
|
|
260652
|
+
if (error65 instanceof AnchaError || !cause?.code || !Object.hasOwn(WRITE_REFUSALS, cause.code) || !/^(open|mkdir|write|writev|ftruncate|rename|unlink|rmdir|copyfile)$/.test(cause.syscall ?? "")) return error65;
|
|
260653
|
+
return new AnchaError("CONFIG_INVALID", `cannot write ${cause.path ?? cwd}: ${WRITE_REFUSALS[cause.code]}`, { kind: "fix", hint: "run ancha init in a folder you can write", cause });
|
|
260654
|
+
}
|
|
260655
|
+
async function writing(path9, fn) {
|
|
260656
|
+
try {
|
|
260657
|
+
return await fn();
|
|
260658
|
+
} catch (error65) {
|
|
260659
|
+
throw initWriteError(error65, path9);
|
|
260660
|
+
}
|
|
260661
|
+
}
|
|
260662
|
+
var applyScaffold2 = (cwd, files2) => writing(cwd, () => applyScaffold(cwd, files2));
|
|
260663
|
+
var open11 = (path9, flags) => writing(path9, () => fsOpen(path9, flags));
|
|
260664
|
+
var writeFile27 = (path9, content2) => writing(path9, () => fsWriteFile(path9, content2));
|
|
260582
260665
|
function step2(ctx) {
|
|
260583
260666
|
const io = { ...ctx.io, stdout: new Writable({ write(_chunk, _encoding, done) {
|
|
260584
260667
|
done();
|
|
@@ -260603,7 +260686,7 @@ Read \`ancha docs tools\` for function checks and registration.
|
|
|
260603
260686
|
original2 = await readFile43(target6, "utf8");
|
|
260604
260687
|
} catch (error65) {
|
|
260605
260688
|
if (error65.code !== "ENOENT") throw error65;
|
|
260606
|
-
const result = await
|
|
260689
|
+
const result = await applyScaffold2(cwd, [{ relativePath: "AGENTS.md", content: managed }]);
|
|
260607
260690
|
return result.created.length ? "created" : "preserved";
|
|
260608
260691
|
}
|
|
260609
260692
|
if (original2.includes(BEGIN) || original2.includes(END)) {
|
|
@@ -260616,7 +260699,7 @@ Read \`ancha docs tools\` for function checks and registration.
|
|
|
260616
260699
|
await preflightFiles(cwd, [{ relativePath: "AGENTS.md", content: "" }]);
|
|
260617
260700
|
const handle31 = await open11(target6, constants12.O_WRONLY | constants12.O_APPEND | constants12.O_NOFOLLOW);
|
|
260618
260701
|
try {
|
|
260619
|
-
await handle31.writeFile(`${original2.endsWith("\n") ? "\n" : "\n\n"}${managed}`);
|
|
260702
|
+
await writing(target6, () => handle31.writeFile(`${original2.endsWith("\n") ? "\n" : "\n\n"}${managed}`));
|
|
260620
260703
|
} finally {
|
|
260621
260704
|
await handle31.close();
|
|
260622
260705
|
}
|
|
@@ -260632,15 +260715,15 @@ async function ignoreAnchaDirectory(cwd) {
|
|
|
260632
260715
|
original2 = await readFile43(target6, "utf8");
|
|
260633
260716
|
} catch (error65) {
|
|
260634
260717
|
if (error65.code !== "ENOENT") throw error65;
|
|
260635
|
-
const result = await
|
|
260718
|
+
const result = await applyScaffold2(cwd, [{ relativePath: ".gitignore", content: ".ancha/\n" }]);
|
|
260636
260719
|
return result.created.length ? "created" : "preserved";
|
|
260637
260720
|
}
|
|
260638
260721
|
if (ignoresAncha(original2)) return "preserved";
|
|
260639
260722
|
await preflightFiles(cwd, [{ relativePath: ".gitignore", content: "" }]);
|
|
260640
260723
|
const handle31 = await open11(target6, constants12.O_WRONLY | constants12.O_APPEND | constants12.O_NOFOLLOW);
|
|
260641
260724
|
try {
|
|
260642
|
-
await handle31.writeFile(`${original2 === "" || original2.endsWith("\n") ? "" : "\n"}.ancha/
|
|
260643
|
-
`);
|
|
260725
|
+
await writing(target6, () => handle31.writeFile(`${original2 === "" || original2.endsWith("\n") ? "" : "\n"}.ancha/
|
|
260726
|
+
`));
|
|
260644
260727
|
} finally {
|
|
260645
260728
|
await handle31.close();
|
|
260646
260729
|
}
|
|
@@ -260788,7 +260871,7 @@ async function rewrite(cwd, relativePath, content2) {
|
|
|
260788
260871
|
await preflightFiles(cwd, [{ relativePath, content: "" }]);
|
|
260789
260872
|
const handle31 = await open11(join58(cwd, relativePath), constants12.O_WRONLY | constants12.O_TRUNC | constants12.O_NOFOLLOW);
|
|
260790
260873
|
try {
|
|
260791
|
-
await handle31.writeFile(content2);
|
|
260874
|
+
await writing(join58(cwd, relativePath), () => handle31.writeFile(content2));
|
|
260792
260875
|
} finally {
|
|
260793
260876
|
await handle31.close();
|
|
260794
260877
|
}
|
|
@@ -260923,7 +261006,7 @@ async function wireExistingConfig(cwd, fillMissing) {
|
|
|
260923
261006
|
await preflightFiles(cwd, [{ relativePath: "ancha.yaml", content: "" }]);
|
|
260924
261007
|
const handle31 = await open11(target6, constants12.O_WRONLY | constants12.O_TRUNC | constants12.O_NOFOLLOW);
|
|
260925
261008
|
try {
|
|
260926
|
-
await handle31.writeFile(next2);
|
|
261009
|
+
await writing(target6, () => handle31.writeFile(next2));
|
|
260927
261010
|
} finally {
|
|
260928
261011
|
await handle31.close();
|
|
260929
261012
|
}
|
|
@@ -260960,7 +261043,7 @@ function registerKit(program2, ctx) {
|
|
|
260960
261043
|
const own2 = opts.template === "starter" ? await ownStarter(ctx.io.cwd) : void 0;
|
|
260961
261044
|
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") : [];
|
|
260962
261045
|
const cloud = opts.on === "local" ? false : await cloudWorkspace(ctx, { code: "USAGE", message: "no workspace", hint: "" }).then(() => true, () => false);
|
|
260963
|
-
const traces = await
|
|
261046
|
+
const traces = (await glob3(["traces/**/*.json", "traces/**/*.jsonl"], { cwd: ctx.io.cwd, onlyFiles: true, dot: false, ignore: ["**/node_modules/**"] })).length > 0;
|
|
260964
261047
|
const noStarter = defaultTemplate && (existing3.length > 0 || cloud && !(routeTools.length > 0 && !traces));
|
|
260965
261048
|
const starter = opts.template === "starter" && (!noStarter || own2 !== void 0);
|
|
260966
261049
|
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");
|
|
@@ -261001,7 +261084,7 @@ min_pass_rate: 1
|
|
|
261001
261084
|
await rewrite(ctx.io.cwd, file3.relativePath, file3.content);
|
|
261002
261085
|
updated.push(file3.relativePath);
|
|
261003
261086
|
}
|
|
261004
|
-
const result = await
|
|
261087
|
+
const result = await applyScaffold2(ctx.io.cwd, files2.filter((file3) => !rewritten.includes(file3)));
|
|
261005
261088
|
const agents = await installAgents(ctx.io.cwd, detection.functionTools);
|
|
261006
261089
|
let savedCommand;
|
|
261007
261090
|
if (configured) {
|
|
@@ -261031,9 +261114,9 @@ min_pass_rate: 1
|
|
|
261031
261114
|
const isGenerated = (twin) => gen_exports.GENERATED_TOOLS.includes(twin);
|
|
261032
261115
|
const tools2 = twins.filter(isGenerated);
|
|
261033
261116
|
const keyed2 = (suffix) => opts.idempotencyKey === void 0 ? {} : { idempotencyKey: `${opts.idempotencyKey}-${suffix}` };
|
|
261034
|
-
const world5 = await worldGen(step2(ctx), opts.intent, { ...used.length > 0 && tools2.length > 0 && { tools: tools2.join(",") }, ...keyed2("world") });
|
|
261117
|
+
const world5 = await writing(ctx.io.cwd, () => worldGen(step2(ctx), opts.intent, { ...used.length > 0 && tools2.length > 0 && { tools: tools2.join(",") }, ...keyed2("world") }));
|
|
261035
261118
|
notGenerated = await addExampleSeeds(join58(ctx.io.cwd, world5.world), used.filter((twin) => !isGenerated(twin)));
|
|
261036
|
-
const test3 = await testNew(step2(ctx), opts.intent, { world: world5.id, ...keyed2("test") });
|
|
261119
|
+
const test3 = await writing(ctx.io.cwd, () => testNew(step2(ctx), opts.intent, { world: world5.id, ...keyed2("test") }));
|
|
261037
261120
|
generated = { world: { id: world5.id, file: world5.world, people: world5.people, ...notGenerated.added.length > 0 && { exampleData: notGenerated.added } }, test: { id: test3.id, file: test3.file, checks: test3.checks }, ...(world5.modelCredit ?? test3.modelCredit) && { modelCredit: "workspace" } };
|
|
261038
261121
|
result.created.push(...world5.files, test3.file, test3.record);
|
|
261039
261122
|
}
|
|
@@ -261121,7 +261204,7 @@ function registerSceneNew(scene2, ctx) {
|
|
|
261121
261204
|
throw new AnchaError("USAGE", `cannot create scene destination: ${prefix2}`, { hint: "choose another id and remove unsafe symlinks", cause });
|
|
261122
261205
|
}
|
|
261123
261206
|
try {
|
|
261124
|
-
const result = await
|
|
261207
|
+
const result = await applyScaffold2(ctx.io.cwd, planned);
|
|
261125
261208
|
ctx.out.result({ id: id15, twins, ...result }, () => `Created ${prefix2}/scene.yaml and oracle/null companions. Validate: ancha scene validate ${prefix2}/scene.yaml`);
|
|
261126
261209
|
} catch (error65) {
|
|
261127
261210
|
await rm13(target6, { recursive: true, force: true });
|
|
@@ -264360,10 +264443,14 @@ function traceRef(source, ref23) {
|
|
|
264360
264443
|
async function call3(f2, url4, init, tool, keys7) {
|
|
264361
264444
|
for (let attempt2 = 0; ; attempt2++) {
|
|
264362
264445
|
let res;
|
|
264446
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), 3e4);
|
|
264363
264447
|
try {
|
|
264364
|
-
|
|
264448
|
+
const response6 = await f2(url4, { ...init, signal: controller.signal });
|
|
264449
|
+
res = new Response([204, 205, 304].includes(response6.status) ? null : await response6.arrayBuffer(), { status: response6.status, headers: response6.headers });
|
|
264365
264450
|
} catch (error65) {
|
|
264366
|
-
throw new AnchaError("SERVER_UNREACHABLE", `cannot reach ${tool} at ${new URL(url4).origin}`, { cause: error65, hint: "check the host in your environment and the network" });
|
|
264451
|
+
throw new AnchaError("SERVER_UNREACHABLE", `cannot reach ${tool} at ${new URL(url4).origin}`, { cause: error65, kind: "retry", hint: "check the host in your environment and the network; no workspace uploads have been confirmed by this command. Running the same command again is safe." });
|
|
264452
|
+
} finally {
|
|
264453
|
+
clearTimeout(timer);
|
|
264367
264454
|
}
|
|
264368
264455
|
if (res.status === 429 && attempt2 < 8) {
|
|
264369
264456
|
await sleep14((Number(res.headers.get("retry-after")) || 2 ** attempt2) * 1e3);
|
|
@@ -264422,7 +264509,10 @@ async function fromLangsmith(traceId, env2, f2) {
|
|
|
264422
264509
|
if (!runs.length) throw new AnchaError("USAGE", `LangSmith has no trace ${traceId} that this key can read`);
|
|
264423
264510
|
const root3 = runs.find((r2) => !r2.parent_run_id) ?? runs[0];
|
|
264424
264511
|
const thread4 = root3.thread_id ?? root3.extra?.metadata?.thread_id;
|
|
264425
|
-
const turns = thread4 && root3.session_id ? await query12({ session: [root3.session_id], is_root: true, filter: `and(eq(metadata_key, "thread_id"), eq(metadata_value, ${JSON.stringify(String(thread4))}))` }).catch(() =>
|
|
264512
|
+
const turns = thread4 && root3.session_id ? await query12({ session: [root3.session_id], is_root: true, filter: `and(eq(metadata_key, "thread_id"), eq(metadata_value, ${JSON.stringify(String(thread4))}))` }).catch((error65) => {
|
|
264513
|
+
if (error65 instanceof AnchaError && error65.code === "SERVER_UNREACHABLE") throw error65;
|
|
264514
|
+
return [root3];
|
|
264515
|
+
}) : [root3];
|
|
264426
264516
|
const ids3 = [.../* @__PURE__ */ new Set([root3.id, ...turns.map((r2) => r2.id)])];
|
|
264427
264517
|
const feedback = [];
|
|
264428
264518
|
for (const id15 of ids3) feedback.push(...await call3(f2, `${api4}/feedback?${new URLSearchParams({ run: id15 })}`, { headers }, "LangSmith", "LANGSMITH_API_KEY"));
|
|
@@ -264828,24 +264918,51 @@ var WorkspaceError = class extends AnchaError {
|
|
|
264828
264918
|
};
|
|
264829
264919
|
function workspaceError(status6, body8, path9) {
|
|
264830
264920
|
if (status6 === 404 && body8.error === void 0) return new WorkspaceError(404, "this workspace does not take traces", "ancha import --offline <trace file> makes the test on this computer; nothing is uploaded", true);
|
|
264831
|
-
const
|
|
264921
|
+
const contract = typeof body8.error === "string" ? { error: { message: body8.error, code: body8.code, kind: body8.kind, hint: body8.hint, reference: body8.reference } } : body8;
|
|
264922
|
+
const error65 = serverError(status6, contract, { message: `${path9}: HTTP ${status6}`, code: "USAGE" });
|
|
264923
|
+
if (status6 === 409 && error65.message === "this trace is still arriving; try again in a minute") error65.kind = "retry";
|
|
264832
264924
|
return Object.assign(new WorkspaceError(status6, error65.message, error65.hint), { code: error65.code, kind: error65.kind, ...error65.reference && { reference: error65.reference } });
|
|
264833
264925
|
}
|
|
264834
264926
|
function notInWorkspace(error65) {
|
|
264835
264927
|
return error65 instanceof WorkspaceError && error65.status === 404 && !error65.noTraces;
|
|
264836
264928
|
}
|
|
264929
|
+
var traceRequestMs = (bytes4 = 0) => Math.min(3e5, 3e4 + Math.ceil(bytes4 / 65536) * 1e3);
|
|
264930
|
+
async function traceRequest(url4, init, receipt2 = () => "No workspace uploads have been confirmed by this command.") {
|
|
264931
|
+
const controller = new AbortController(), ms2 = traceRequestMs(new URL(url4).pathname === "/v1/imports" && typeof init.body === "string" ? Buffer.byteLength(init.body) : 0);
|
|
264932
|
+
const timer = setTimeout(() => controller.abort(), ms2);
|
|
264933
|
+
try {
|
|
264934
|
+
const res = await fetch(url4, { ...init, signal: controller.signal });
|
|
264935
|
+
const text31 = await res.text();
|
|
264936
|
+
let body8 = {};
|
|
264937
|
+
try {
|
|
264938
|
+
const parsed5 = JSON.parse(text31);
|
|
264939
|
+
if (parsed5 && typeof parsed5 === "object" && !Array.isArray(parsed5)) body8 = parsed5;
|
|
264940
|
+
} catch {
|
|
264941
|
+
}
|
|
264942
|
+
return { res, body: body8 };
|
|
264943
|
+
} catch (cause) {
|
|
264944
|
+
throw new AnchaError(
|
|
264945
|
+
"SERVER_UNREACHABLE",
|
|
264946
|
+
`The workspace did not answer. ${receipt2()} The interrupted request may have been saved. Running the same command again is safe.`,
|
|
264947
|
+
{ kind: "retry", hint: "run the same command again; traces already in the workspace are reported as already imported", cause }
|
|
264948
|
+
);
|
|
264949
|
+
} finally {
|
|
264950
|
+
clearTimeout(timer);
|
|
264951
|
+
}
|
|
264952
|
+
}
|
|
264837
264953
|
async function workspaceApi(ctx, hint = "run ancha login, or set ANCHA_SERVER_URL and ANCHA_API_KEY") {
|
|
264838
264954
|
const workspace4 = await uploadWorkspace(ctx, { message: "not logged in to a workspace", hint });
|
|
264839
264955
|
const key5 = await apiKeyFor(workspace4, ctx.io.env);
|
|
264840
264956
|
if (key5 === void 0) throw authError(workspace4, { keySent: false });
|
|
264841
264957
|
const origin = new URL(workspace4).origin;
|
|
264958
|
+
const traces = /* @__PURE__ */ new Set(), tests = /* @__PURE__ */ new Set();
|
|
264959
|
+
const receipt2 = () => `Workspace receipts from this command: traces ${[...traces].join(", ") || "none confirmed"}; saved tests ${[...tests].join(", ") || "none confirmed"}.`;
|
|
264842
264960
|
return async (path9, init = {}) => {
|
|
264843
|
-
const res = await
|
|
264844
|
-
throw new AnchaError("SERVER_UNREACHABLE", "The workspace did not answer.", { cause });
|
|
264845
|
-
});
|
|
264846
|
-
const body8 = await res.json().catch(() => ({}));
|
|
264961
|
+
const { res, body: body8 } = await traceRequest(`${origin}${path9}`, { ...init, headers: { authorization: `Bearer ${key5}`, "x-ancha-trace-import": "1", ...init.headers } }, receipt2);
|
|
264847
264962
|
if (res.status === 401) throw serverError(res.status, body8, authError(workspace4, { keySent: true }));
|
|
264848
264963
|
if (!res.ok) throw workspaceError(res.status, body8, path9);
|
|
264964
|
+
if (path9.startsWith("/v1/imports")) for (const trace2 of body8.traces ?? []) traces.add(trace2.id);
|
|
264965
|
+
if (init.method === "POST" && body8.world?.id) tests.add(body8.world.id);
|
|
264849
264966
|
return body8;
|
|
264850
264967
|
};
|
|
264851
264968
|
}
|
|
@@ -265101,6 +265218,7 @@ async function nextLines(ctx, paths3, dest, connection4) {
|
|
|
265101
265218
|
var testName = (id15) => /^trace-([0-9a-f]{8,})$/i.exec(id15.trim())?.[1];
|
|
265102
265219
|
var AT_ONCE = 4;
|
|
265103
265220
|
var MB4 = 1024 * 1024;
|
|
265221
|
+
var classifiedSkip = (skip, error65) => ({ code: error65?.code ?? "USAGE", kind: error65?.kind ?? "fix", ...skip });
|
|
265104
265222
|
async function atOnce(items2, n2, fn) {
|
|
265105
265223
|
const out = new Array(items2.length);
|
|
265106
265224
|
let next2 = 0;
|
|
@@ -265130,14 +265248,15 @@ async function projectAgent(ctx) {
|
|
|
265130
265248
|
return configured ? agentName(ctx.io.cwd) : void 0;
|
|
265131
265249
|
}
|
|
265132
265250
|
async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
265133
|
-
const packed = packUploads(units, name5, maxBytes), skipped =
|
|
265251
|
+
const packed = packUploads(units, name5, maxBytes), skipped = packed.skipped.map((s3) => classifiedSkip(s3)), uploads = [];
|
|
265134
265252
|
const sent2 = [], fileOf = (unit) => units.find((u) => u.id === unit)?.files[0];
|
|
265135
265253
|
const queue = [...packed.uploads];
|
|
265136
|
-
|
|
265254
|
+
const alreadyImported = [];
|
|
265255
|
+
let stop, stopError, first2;
|
|
265137
265256
|
for (let i = 0; i < queue.length; i++) {
|
|
265138
265257
|
const upload6 = queue[i];
|
|
265139
265258
|
if (stop) {
|
|
265140
|
-
skipped.push(...upload6.ids.map((id15) => ({ trace: id15, file: fileOf(id15), reason: stop })));
|
|
265259
|
+
skipped.push(...upload6.ids.map((id15) => classifiedSkip({ trace: id15, file: fileOf(id15), reason: stop }, stopError)));
|
|
265141
265260
|
continue;
|
|
265142
265261
|
}
|
|
265143
265262
|
const size2 = upload6.bytes >= MB4 / 10 ? `${(upload6.bytes / MB4).toFixed(1)} MB` : `${Math.max(1, Math.round(upload6.bytes / 1024))} KB`;
|
|
@@ -265154,17 +265273,21 @@ async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
|
265154
265273
|
}
|
|
265155
265274
|
if (![400, 413, 429].includes(error65.status)) throw error65;
|
|
265156
265275
|
first2 ??= error65;
|
|
265157
|
-
if (error65.status === 429)
|
|
265158
|
-
|
|
265276
|
+
if (error65.status === 429) {
|
|
265277
|
+
stop = `${error65.message} (the workspace takes 600 uploads an hour)`;
|
|
265278
|
+
stopError = error65;
|
|
265279
|
+
}
|
|
265280
|
+
skipped.push(...upload6.ids.map((id15) => classifiedSkip({ trace: id15, file: fileOf(id15), reason: stop ?? error65.message }, error65)));
|
|
265159
265281
|
continue;
|
|
265160
265282
|
}
|
|
265161
265283
|
uploads.push(upload6);
|
|
265284
|
+
alreadyImported.push(...answer.traces.filter((t) => t.alreadyImported).map((t) => t.id));
|
|
265162
265285
|
answer.traces.forEach((t, n2) => sent2.push({ id: t.id, file: fileOf(answer.traces.length === upload6.ids.length ? upload6.ids[n2] : upload6.ids.find((id15) => t.trace?.endsWith(`:${id15}`))) }));
|
|
265163
265286
|
}
|
|
265164
265287
|
if (sent2.length > 1) ctx.out.info(`making ${plural6(sent2.length, "test")}, ${AT_ONCE} at a time`);
|
|
265165
265288
|
const answered = options5.expect !== void 0 || options5.answer.length > 0 || Boolean(options5.resetAnswers);
|
|
265166
265289
|
const results = await atOnce(sent2, AT_ONCE, async ({ id: id15, file: file3 }) => {
|
|
265167
|
-
const skip = (error65) => ({ skip: { trace: id15, ...file3 && { file: file3 }, reason: error65.message }, error: error65 });
|
|
265290
|
+
const skip = (error65) => ({ skip: classifiedSkip({ trace: id15, ...file3 && { file: file3 }, reason: error65.message }, error65), error: error65 });
|
|
265168
265291
|
let changes;
|
|
265169
265292
|
try {
|
|
265170
265293
|
changes = await guard(ctx, resolve50(ctx.io.cwd, options5.dest, `trace-${id15.slice(0, 8)}`), options5.force);
|
|
@@ -265190,7 +265313,7 @@ async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
|
265190
265313
|
skipped.push(r2.skip);
|
|
265191
265314
|
first2 ??= r2.error;
|
|
265192
265315
|
}
|
|
265193
|
-
return { made: results.flatMap((r2) => r2.made ? [r2.made] : []), skipped, uploads, sent: sent2.length, files: options5.files, first: first2 };
|
|
265316
|
+
return { alreadyImported, made: results.flatMap((r2) => r2.made ? [r2.made] : []), skipped, uploads, sent: sent2.length, files: options5.files, first: first2 };
|
|
265194
265317
|
}
|
|
265195
265318
|
function outcomeOf3(world5) {
|
|
265196
265319
|
const production3 = world5.summary?.production ?? {}, values3 = checksOf2(world5.scene).map((c) => production3[c.id] ?? "unknown");
|
|
@@ -265228,6 +265351,7 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
265228
265351
|
...m.written.kept.length && { kept: m.written.kept }
|
|
265229
265352
|
})),
|
|
265230
265353
|
skipped: done.skipped,
|
|
265354
|
+
alreadyImported: done.alreadyImported,
|
|
265231
265355
|
questions: asking.length,
|
|
265232
265356
|
uploads: done.uploads.map((u) => ({ format: u.format, traces: u.ids.length, files: u.files, bytes: u.bytes })),
|
|
265233
265357
|
...connection4 && { connection: connection4 },
|
|
@@ -265251,7 +265375,8 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
265251
265375
|
});
|
|
265252
265376
|
const short = (m) => m.world.name;
|
|
265253
265377
|
return [
|
|
265254
|
-
`Uploaded ${plural6(done.sent, "trace")} from ${from}: ${made}${done.skipped.length ? `; ${done.skipped.length} skipped` : ""}`,
|
|
265378
|
+
`Uploaded ${plural6(done.sent, "trace")} from ${from}: ${made}${done.skipped.length ? `; ${done.skipped.length} skipped (${ERROR_KINDS.map((kind2) => [kind2, done.skipped.filter((s3) => s3.kind === kind2).length]).filter(([, n2]) => n2).map(([kind2, n2]) => `${n2} ${kind2}`).join(", ")})` : ""}`,
|
|
265379
|
+
...done.alreadyImported.map((id15) => ` already imported: trace ${id15}`),
|
|
265255
265380
|
...rows35.length ? formatTable(rows35).split("\n").map((line2) => ` ${line2}`) : [],
|
|
265256
265381
|
// Each test's evidence under its name when there are several.
|
|
265257
265382
|
...tests.flatMap((m) => {
|
|
@@ -265269,10 +265394,12 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
265269
265394
|
});
|
|
265270
265395
|
}
|
|
265271
265396
|
async function importJson(ctx, done) {
|
|
265272
|
-
for (const s3 of done.skipped) if (s3.trace) ctx.out.event({ event: "trace_skipped", trace: s3.trace, reason: s3.reason });
|
|
265397
|
+
for (const s3 of done.skipped) if (s3.trace) ctx.out.event({ event: "trace_skipped", trace: s3.trace, reason: s3.reason, code: s3.code, kind: s3.kind });
|
|
265273
265398
|
for (const { world: world5, written } of done.made) {
|
|
265274
265399
|
const where3 = relative25(ctx.io.cwd, written.scene) || written.scene, connection4 = await connectionFor(ctx, [written.scene], where3);
|
|
265275
265400
|
ctx.out.result({
|
|
265401
|
+
alreadyImported: done.alreadyImported,
|
|
265402
|
+
skipped: done.skipped,
|
|
265276
265403
|
connection: connection4,
|
|
265277
265404
|
world: world5.id,
|
|
265278
265405
|
name: world5.name,
|
|
@@ -265475,10 +265602,10 @@ function registerTraces(program2, ctx) {
|
|
|
265475
265602
|
}
|
|
265476
265603
|
expectOne(options5.expect, units.length);
|
|
265477
265604
|
const done = await sendTraces(ctx, api4, units, name5, { dest: options5.dest, ...options5.force && { force: true }, ...options5.expect !== void 0 && { expect: options5.expect }, answer: [], files: read7.length, agent: await projectAgent(ctx) });
|
|
265478
|
-
done.skipped.unshift(...fetchSkipped, ...skipped);
|
|
265605
|
+
done.skipped.unshift(...[...fetchSkipped, ...skipped].map((s3) => classifiedSkip(s3)));
|
|
265479
265606
|
if (!done.made.length) {
|
|
265480
265607
|
if (done.skipped.length === 1 && done.first instanceof AnchaError) throw done.first;
|
|
265481
|
-
throw new AnchaError("USAGE", `none of the ${plural6(done.sent || units.length, "trace")} made a test`, { hint: done.skipped.slice(0, 5).map((s3) => `${s3.trace ? `trace ${s3.trace.slice(0, 8)}` : s3.file}: ${s3.reason}`).join("; ") });
|
|
265608
|
+
throw new AnchaError("USAGE", `none of the ${plural6(done.sent || units.length, "trace")} made a test`, { kind: done.skipped.some((s3) => s3.kind === "ours") ? "ours" : done.skipped.every((s3) => s3.kind === "retry") ? "retry" : "fix", hint: done.skipped.slice(0, 5).map((s3) => `${s3.trace ? `trace ${s3.trace.slice(0, 8)}` : s3.file}: ${s3.reason}`).join("; ") });
|
|
265482
265609
|
}
|
|
265483
265610
|
await uploadReport(ctx, done, options5.from !== void 0 ? options5.from === "langfuse" ? "Langfuse" : "LangSmith" : read7.length === 1 ? read7[0] : plural6(read7.length, "file"), options5.dest);
|
|
265484
265611
|
});
|
|
@@ -265497,6 +265624,7 @@ function registerTraces(program2, ctx) {
|
|
|
265497
265624
|
if (!units.length) throw new AnchaError("USAGE", `${source.label}: ${skipped[0]?.reason ?? "it holds no traces"}`, { hint: "use Ancha Trace IR JSONL, OTLP JSON, or a Langfuse or LangSmith export; ancha docs traces" });
|
|
265498
265625
|
expectOne(options5.expect, units.length);
|
|
265499
265626
|
const done = await sendTraces(ctx, api4, units, source.name, { ...options5, files: 1, agent: await projectAgent(ctx) });
|
|
265627
|
+
done.skipped.unshift(...skipped.map((s3) => classifiedSkip(s3)));
|
|
265500
265628
|
if (!done.made.length) throw done.first ?? new AnchaError("USAGE", `${source.label}: ${done.skipped[0]?.reason ?? "no trace made a test"}`);
|
|
265501
265629
|
if (ctx.out.json) await importJson(ctx, done);
|
|
265502
265630
|
else await uploadReport(ctx, done, source.label, options5.dest);
|
|
@@ -266077,8 +266205,8 @@ ${result.verification?.message ?? "Use ancha report or ancha explain to inspect
|
|
|
266077
266205
|
function registerAgent(program2, ctx) {
|
|
266078
266206
|
const registry2 = () => new AgentRegistry(ctx.io.cwd);
|
|
266079
266207
|
const command = program2.command("agent").description("upload this project's agent to the cloud (agent upload), or save and test a local agent against automatically prepared tool worlds");
|
|
266080
|
-
command.command("upload").description("install this project's agent in a cloud machine, as a cloud run does, and start it once with a task (also: ancha doctor --on cloud)").option("--agent <command>", "override the configured agent command").action(async (opts) => {
|
|
266081
|
-
const result = await uploadAgent(ctx, { ...opts.agent !== void 0 && { agent: opts.agent }, timeout: "10s", on: "cloud" });
|
|
266208
|
+
command.command("upload").description("install this project's agent in a cloud machine, as a cloud run does, and start it once with a task (also: ancha doctor --on cloud)").option("--agent <command>", "override the configured agent command").option("--idempotency-key <key>", "retry safely: the same key and the same project return the upload the workspace accepted instead of starting another").action(async (opts) => {
|
|
266209
|
+
const result = await uploadAgent(ctx, { ...opts.agent !== void 0 && { agent: opts.agent }, ...opts.idempotencyKey !== void 0 && { idempotencyKey: opts.idempotencyKey }, timeout: "10s", on: "cloud" });
|
|
266082
266210
|
ctx.exitCode = result.exitCode;
|
|
266083
266211
|
ctx.out.result(result.report, () => renderUpload(result.report));
|
|
266084
266212
|
});
|
package/lib/assets/SKILL.md
CHANGED
|
@@ -18,7 +18,7 @@ Add `--json` to every command. Runs print NDJSON events that end with `run_finis
|
|
|
18
18
|
<!-- ancha:first-steps -->
|
|
19
19
|
1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.
|
|
20
20
|
```sh
|
|
21
|
-
|
|
21
|
+
npm install -g @ancha-labs/cli
|
|
22
22
|
ancha login
|
|
23
23
|
```
|
|
24
24
|
2. **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.
|
|
@@ -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
|
```
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.
|
|
5
5
|
```sh
|
|
6
|
-
|
|
6
|
+
npm install -g @ancha-labs/cli
|
|
7
7
|
ancha login
|
|
8
8
|
```
|
|
9
9
|
2. **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.
|
|
@@ -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
|
@@ -11,7 +11,7 @@ Without `--on`, a project with `ancha.yaml` (or `--config`) runs in the workspac
|
|
|
11
11
|
<!-- ancha:first-steps -->
|
|
12
12
|
1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.
|
|
13
13
|
```sh
|
|
14
|
-
|
|
14
|
+
npm install -g @ancha-labs/cli
|
|
15
15
|
ancha login
|
|
16
16
|
```
|
|
17
17
|
2. **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.
|
|
@@ -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
|
@@ -9,7 +9,7 @@ Requirements: Node 24 or newer. Install once with `npm install -g @ancha-labs/cl
|
|
|
9
9
|
<!-- ancha:first-steps -->
|
|
10
10
|
1. **Install the CLI and sign in.** It needs Node 24 or newer. Approve this computer in the browser, once.
|
|
11
11
|
```sh
|
|
12
|
-
|
|
12
|
+
npm install -g @ancha-labs/cli
|
|
13
13
|
ancha login
|
|
14
14
|
```
|
|
15
15
|
2. **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.
|
|
@@ -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
|
```
|
|
@@ -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, value5) => {
|
|
166356
|
+
if (typeof value5 !== "string") return value5;
|
|
166357
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
166358
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value5)) return Number(value5);
|
|
166359
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value5)) return value5.toLowerCase() === "true";
|
|
166360
|
+
return value5;
|
|
166361
|
+
};
|
|
166355
166362
|
projection = projection?.map((p2) => property4(p2));
|
|
166356
166363
|
const conditions = [];
|
|
166357
166364
|
let explicitActive = false;
|
|
@@ -166371,10 +166378,10 @@ function queryRecords(ctx, sql5) {
|
|
|
166371
166378
|
const op = ts2[i++]?.text.toUpperCase();
|
|
166372
166379
|
if (op === "IN") {
|
|
166373
166380
|
take2("(");
|
|
166374
|
-
const values3 = [literal2()];
|
|
166381
|
+
const values3 = [typed(key5, literal2())];
|
|
166375
166382
|
while (peek(",")) {
|
|
166376
166383
|
i++;
|
|
166377
|
-
values3.push(literal2());
|
|
166384
|
+
values3.push(typed(key5, literal2()));
|
|
166378
166385
|
}
|
|
166379
166386
|
take2(")");
|
|
166380
166387
|
conditions.push((row2) => {
|
|
@@ -166394,7 +166401,7 @@ function queryRecords(ctx, sql5) {
|
|
|
166394
166401
|
});
|
|
166395
166402
|
} else {
|
|
166396
166403
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
166397
|
-
const expected = literal2();
|
|
166404
|
+
const expected = typed(key5, literal2());
|
|
166398
166405
|
conditions.push((row2) => {
|
|
166399
166406
|
const value5 = scalar2(row2, key5);
|
|
166400
166407
|
return (Array.isArray(value5) ? value5 : [value5]).some((item2) => {
|
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 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`.\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. 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, value5) => {
|
|
214463
|
+
if (typeof value5 !== "string") return value5;
|
|
214464
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
214465
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value5)) return Number(value5);
|
|
214466
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value5)) return value5.toLowerCase() === "true";
|
|
214467
|
+
return value5;
|
|
214468
|
+
};
|
|
214462
214469
|
projection = projection?.map((p2) => property4(p2));
|
|
214463
214470
|
const conditions = [];
|
|
214464
214471
|
let explicitActive = false;
|
|
@@ -214478,10 +214485,10 @@ function queryRecords(ctx, sql5) {
|
|
|
214478
214485
|
const op = ts3[i++]?.text.toUpperCase();
|
|
214479
214486
|
if (op === "IN") {
|
|
214480
214487
|
take2("(");
|
|
214481
|
-
const values3 = [literal2()];
|
|
214488
|
+
const values3 = [typed(key5, literal2())];
|
|
214482
214489
|
while (peek(",")) {
|
|
214483
214490
|
i++;
|
|
214484
|
-
values3.push(literal2());
|
|
214491
|
+
values3.push(typed(key5, literal2()));
|
|
214485
214492
|
}
|
|
214486
214493
|
take2(")");
|
|
214487
214494
|
conditions.push((row2) => {
|
|
@@ -214501,7 +214508,7 @@ function queryRecords(ctx, sql5) {
|
|
|
214501
214508
|
});
|
|
214502
214509
|
} else {
|
|
214503
214510
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
214504
|
-
const expected = literal2();
|
|
214511
|
+
const expected = typed(key5, literal2());
|
|
214505
214512
|
conditions.push((row2) => {
|
|
214506
214513
|
const value5 = scalar2(row2, key5);
|
|
214507
214514
|
return (Array.isArray(value5) ? value5 : [value5]).some((item2) => {
|
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, value5) => {
|
|
182579
|
+
if (typeof value5 !== "string") return value5;
|
|
182580
|
+
const declared = fields13.find((f2) => f2[0] === key5)?.[1];
|
|
182581
|
+
if (["decimal", "int", "long", "positiveInteger"].includes(declared ?? "") && /^-?\d+(?:\.\d+)?$/.test(value5)) return Number(value5);
|
|
182582
|
+
if (declared === "boolean" && /^(true|false)$/i.test(value5)) return value5.toLowerCase() === "true";
|
|
182583
|
+
return value5;
|
|
182584
|
+
};
|
|
182578
182585
|
projection = projection?.map((p2) => property4(p2));
|
|
182579
182586
|
const conditions = [];
|
|
182580
182587
|
let explicitActive = false;
|
|
@@ -182594,10 +182601,10 @@ function queryRecords(ctx, sql5) {
|
|
|
182594
182601
|
const op = ts2[i++]?.text.toUpperCase();
|
|
182595
182602
|
if (op === "IN") {
|
|
182596
182603
|
take2("(");
|
|
182597
|
-
const values3 = [literal2()];
|
|
182604
|
+
const values3 = [typed(key5, literal2())];
|
|
182598
182605
|
while (peek(",")) {
|
|
182599
182606
|
i++;
|
|
182600
|
-
values3.push(literal2());
|
|
182607
|
+
values3.push(typed(key5, literal2()));
|
|
182601
182608
|
}
|
|
182602
182609
|
take2(")");
|
|
182603
182610
|
conditions.push((row2) => {
|
|
@@ -182617,7 +182624,7 @@ function queryRecords(ctx, sql5) {
|
|
|
182617
182624
|
});
|
|
182618
182625
|
} else {
|
|
182619
182626
|
if (!["=", "<", ">", "<=", ">="].includes(op ?? "")) parseError2("Expected a comparison, IN or LIKE.");
|
|
182620
|
-
const expected = literal2();
|
|
182627
|
+
const expected = typed(key5, literal2());
|
|
182621
182628
|
conditions.push((row2) => {
|
|
182622
182629
|
const value5 = scalar2(row2, key5);
|
|
182623
182630
|
return (Array.isArray(value5) ? value5 : [value5]).some((item2) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancha-labs/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.49",
|
|
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": {
|