@ancha-labs/cli 0.4.31 → 0.4.32
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 +193 -49
- package/lib/assets/SKILL.md +10 -9
- package/lib/assets/agents-section.md +10 -9
- package/lib/assets/docs/cloud.md +10 -9
- package/lib/assets/docs/scenes.md +13 -1
- package/lib/assets/docs/setup.md +10 -9
- package/lib/assets/harbor/companion.mjs +108 -6
- package/lib/assets/ui/app.js +6 -2
- package/lib/mcp-entry.mjs +8 -1
- package/lib/worker.mjs +110 -8
- package/lib/world-server.mjs +108 -6
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -24167,6 +24167,9 @@ var init_zod = __esm({
|
|
|
24167
24167
|
|
|
24168
24168
|
// packages/core/src/answer.ts
|
|
24169
24169
|
function readNumbers(text31) {
|
|
24170
|
+
return readNumberSpans(text31).map(({ start: _start, end: _end, ...number7 }) => number7);
|
|
24171
|
+
}
|
|
24172
|
+
function readNumberSpans(text31) {
|
|
24170
24173
|
const numbers2 = [];
|
|
24171
24174
|
for (const match3 of text31.normalize("NFKC").matchAll(NUMBER)) {
|
|
24172
24175
|
const { open: open15, sign: sign3, before, minus, inner: inner2, digits, after, close } = match3.groups;
|
|
@@ -24175,6 +24178,8 @@ function readNumbers(text31) {
|
|
|
24175
24178
|
const negative = sign3 !== void 0 && sign3 !== "+" || minus !== void 0 || parenthesized && amount5;
|
|
24176
24179
|
const value5 = Number(digits.replaceAll(",", ""));
|
|
24177
24180
|
numbers2.push({
|
|
24181
|
+
start: match3.index,
|
|
24182
|
+
end: match3.index + match3[0].length,
|
|
24178
24183
|
value: negative && value5 !== 0 ? -value5 : value5,
|
|
24179
24184
|
decimals: digits.split(".")[1]?.length ?? 0,
|
|
24180
24185
|
text: match3[0].trim(),
|
|
@@ -24206,6 +24211,113 @@ function expectedNumber(number7) {
|
|
|
24206
24211
|
const read7 = typeof number7.value === "number" ? { value: number7.value, decimals: decimalsOf(number7.value) } : readNumbers(number7.value)[0];
|
|
24207
24212
|
return { value: read7.value, tolerance: number7.tolerance ?? 0.5 * 10 ** -read7.decimals };
|
|
24208
24213
|
}
|
|
24214
|
+
function answerTokens(text31) {
|
|
24215
|
+
const tokens6 = [];
|
|
24216
|
+
let cursor4 = 0;
|
|
24217
|
+
const quotes = [];
|
|
24218
|
+
const gap8 = (end) => {
|
|
24219
|
+
for (const match3 of text31.slice(cursor4, end).matchAll(/[\p{L}\p{M}]+|[^\s]/gu)) {
|
|
24220
|
+
const start2 = cursor4 + match3.index, word2 = match3[0];
|
|
24221
|
+
const apostrophe = (word2 === "'" || word2 === "\u2019") && (WORD_CHAR.test(text31[start2 - 1] ?? "") && (WORD_CHAR.test(text31[start2 + 1] ?? "") || quotes.at(-1) !== word2) || text31[start2 - 1] === "." && /^s\b/i.test(text31.slice(start2 + 1)));
|
|
24222
|
+
const quote6 = !apostrophe && ['"', "'", "\u201C", "\u201D", "\u2018", "\u2019"].includes(word2);
|
|
24223
|
+
tokens6.push({ text: word2.toLowerCase(), start: start2, end: start2 + word2.length, quoted: quotes.length > 0 || quote6 });
|
|
24224
|
+
if (quote6) {
|
|
24225
|
+
if (quotes.at(-1) === word2) quotes.pop();
|
|
24226
|
+
else if (word2 !== "\u201D" && word2 !== "\u2019") quotes.push(word2 === "\u201C" ? "\u201D" : word2 === "\u2018" ? "\u2019" : word2);
|
|
24227
|
+
}
|
|
24228
|
+
}
|
|
24229
|
+
};
|
|
24230
|
+
for (const number7 of readNumberSpans(text31)) {
|
|
24231
|
+
gap8(number7.start);
|
|
24232
|
+
tokens6.push({ text: number7.text, start: number7.start, end: number7.end, number: number7, quoted: quotes.length > 0 });
|
|
24233
|
+
cursor4 = number7.end;
|
|
24234
|
+
}
|
|
24235
|
+
gap8(text31.length);
|
|
24236
|
+
return tokens6;
|
|
24237
|
+
}
|
|
24238
|
+
function distinctLabels(labels2) {
|
|
24239
|
+
return labels2.every((label7, i) => labels2.every((other, j) => i === j || !labelPattern(label7).test(other)));
|
|
24240
|
+
}
|
|
24241
|
+
function inferNumberLabels(text31, numbers2 = readNumberSpans(text31)) {
|
|
24242
|
+
const tokens6 = answerTokens(text31.normalize("NFKC"));
|
|
24243
|
+
const labels2 = numbers2.map((number7) => {
|
|
24244
|
+
let i = tokens6.findIndex((token4) => token4.start === number7.start) - 1;
|
|
24245
|
+
while (i >= 0) {
|
|
24246
|
+
const word2 = tokens6[i].text, before = tokens6[i - 1]?.text;
|
|
24247
|
+
if (word2 === "at" && before === "stands" || word2 === "to" && (before === "comes" || before === "came")) i -= 2;
|
|
24248
|
+
else if (LINK_WORDS.has(word2) || CURRENCY_TOKEN.test(word2) || word2 === ":" || word2 === "=") i--;
|
|
24249
|
+
else break;
|
|
24250
|
+
}
|
|
24251
|
+
const words9 = [];
|
|
24252
|
+
while (i >= 0 && words9.length < 2) {
|
|
24253
|
+
const token4 = tokens6[i--];
|
|
24254
|
+
if (token4.number || !WORD.test(token4.text) || ARTICLES.has(token4.text) || LINK_WORDS.has(token4.text) || CLAUSE_WORDS.has(token4.text)) break;
|
|
24255
|
+
words9.unshift(token4.text);
|
|
24256
|
+
}
|
|
24257
|
+
return words9.join(" ");
|
|
24258
|
+
});
|
|
24259
|
+
return numbers2.length >= 2 && labels2.every((label7) => label7.length > 0 && label7.length <= 40) && distinctLabels(labels2) ? labels2 : numbers2.map(() => void 0);
|
|
24260
|
+
}
|
|
24261
|
+
function fieldRows(text31) {
|
|
24262
|
+
return text31.split("\n").map((line2) => {
|
|
24263
|
+
const lead = /^\s*\|?/.exec(line2)[0].length, end = line2.length - /\|?\s*$/.exec(line2)[0].length;
|
|
24264
|
+
const inner2 = line2.slice(lead, end), at6 = inner2.indexOf("|");
|
|
24265
|
+
if (at6 < 0 || inner2.includes("|", at6 + 1) || !inner2.slice(0, at6).trim() || !inner2.slice(at6 + 1).trim() || /^[\s:-]+$/.test(inner2.replace("|", ""))) return line2;
|
|
24266
|
+
return `${line2.slice(0, lead + at6)}:${line2.slice(lead + at6 + 1)}`;
|
|
24267
|
+
}).join("\n");
|
|
24268
|
+
}
|
|
24269
|
+
function readLabelEvidence(text31, labels2) {
|
|
24270
|
+
text31 = fieldRows(text31.normalize("NFKC"));
|
|
24271
|
+
const tokens6 = answerTokens(text31);
|
|
24272
|
+
const occurrences2 = labels2.flatMap((label7) => [...text31.matchAll(labelPattern(normalizedLabel(label7)))].map((match3) => ({ label: label7, start: match3.index, end: match3.index + match3[0].length }))).sort((a, b) => a.start - b.start);
|
|
24273
|
+
const evidence3 = [];
|
|
24274
|
+
occurrences2.forEach((occurrence, index) => {
|
|
24275
|
+
const next2 = occurrences2[index + 1]?.start ?? text31.length;
|
|
24276
|
+
const after = tokens6.filter((token4) => token4.start >= occurrence.end && token4.start < next2);
|
|
24277
|
+
const clause2 = [];
|
|
24278
|
+
let previous = occurrence.end;
|
|
24279
|
+
for (const token4 of after) {
|
|
24280
|
+
if (/[\r\n]/.test(text31.slice(previous, token4.start)) || !token4.number && (/^[.!?;,|]$/.test(token4.text) || CLAUSE_WORDS.has(token4.text))) break;
|
|
24281
|
+
clause2.push(token4);
|
|
24282
|
+
previous = token4.end;
|
|
24283
|
+
}
|
|
24284
|
+
let links3 = 0;
|
|
24285
|
+
for (let i = 0; i < clause2.length; i++) {
|
|
24286
|
+
const token4 = clause2[i];
|
|
24287
|
+
if (token4.number) {
|
|
24288
|
+
evidence3.push({
|
|
24289
|
+
label: occurrence.label,
|
|
24290
|
+
number: token4.number,
|
|
24291
|
+
clauseNumbers: clause2.flatMap((t) => t.number ? [t.number] : []),
|
|
24292
|
+
quoted: token4.quoted || tokens6.some((t) => t.start >= occurrence.start && t.start < occurrence.end && t.quoted)
|
|
24293
|
+
});
|
|
24294
|
+
break;
|
|
24295
|
+
}
|
|
24296
|
+
if (CURRENCY_TOKEN.test(token4.text) || /^[*_]$/.test(token4.text)) continue;
|
|
24297
|
+
if (token4.text === "stands" && clause2[i + 1]?.text === "at" || ["comes", "came"].includes(token4.text) && clause2[i + 1]?.text === "to") i++;
|
|
24298
|
+
else if (!LINK_WORDS.has(token4.text) && token4.text !== ":" && token4.text !== "=") break;
|
|
24299
|
+
if (++links3 > 3) break;
|
|
24300
|
+
}
|
|
24301
|
+
});
|
|
24302
|
+
return evidence3;
|
|
24303
|
+
}
|
|
24304
|
+
function swappedAnswerNumbers(text31, numbers2) {
|
|
24305
|
+
const labelled = numbers2.filter((n2) => n2.label !== void 0);
|
|
24306
|
+
if (labelled.length < 2 || !distinctLabels(labelled.map((n2) => normalizedLabel(n2.label)))) return [];
|
|
24307
|
+
const evidence3 = readLabelEvidence(text31, labelled.map((n2) => n2.label));
|
|
24308
|
+
const matches11 = (actual, expected) => {
|
|
24309
|
+
const { value: value5, tolerance } = expectedNumber(expected);
|
|
24310
|
+
return numberMatches(actual, value5, tolerance);
|
|
24311
|
+
};
|
|
24312
|
+
return labelled.flatMap((expected) => {
|
|
24313
|
+
if (evidence3.some((e) => e.label === expected.label && matches11(e.number, expected))) return [];
|
|
24314
|
+
return labelled.flatMap((under2) => {
|
|
24315
|
+
if (under2 === expected || matches11({ value: expectedNumber(under2).value, decimals: 0, text: "" }, expected) || matches11({ value: expectedNumber(expected).value, decimals: 0, text: "" }, under2)) return [];
|
|
24316
|
+
const wrong = evidence3.find((e) => e.label === under2.label && !e.quoted && matches11(e.number, expected) && !matches11(e.number, under2) && !e.clauseNumbers.some((n2) => n2.start !== e.number.start && numbers2.some((want) => matches11(n2, want))));
|
|
24317
|
+
return wrong ? [{ expected, under: under2, stated: wrong.number }] : [];
|
|
24318
|
+
});
|
|
24319
|
+
});
|
|
24320
|
+
}
|
|
24209
24321
|
function decimalsOf(value5) {
|
|
24210
24322
|
const [mantissa, exponent] = String(Math.abs(value5)).split("e");
|
|
24211
24323
|
return Math.max(0, (mantissa.split(".")[1]?.length ?? 0) - Number(exponent ?? 0));
|
|
@@ -24214,7 +24326,7 @@ function comparableText(text31, sensitive = false) {
|
|
|
24214
24326
|
const plain8 = text31.normalize("NFKC").replace(/[‘’‛′]/g, "'").replace(/[“”„″]/g, '"').replace(/[‐‑‒–—−]/g, "-").replace(/\s+/g, " ").trim();
|
|
24215
24327
|
return sensitive ? plain8 : plain8.toLowerCase();
|
|
24216
24328
|
}
|
|
24217
|
-
var SYMBOLS, CODES, CURRENCY, NUMBER, AnswerNumberSchema, texts, AnswerRowSchema, AnswerRowsSchema, AnswerCheckSchema;
|
|
24329
|
+
var SYMBOLS, CODES, CURRENCY, NUMBER, AnswerNumberSchema, texts, AnswerRowSchema, AnswerRowsSchema, AnswerCheckSchema, LINK_WORDS, ARTICLES, CLAUSE_WORDS, CURRENCY_TOKEN, WORD, WORD_CHAR, escapeRegex2, labelPattern, normalizedLabel;
|
|
24218
24330
|
var init_answer = __esm({
|
|
24219
24331
|
"packages/core/src/answer.ts"() {
|
|
24220
24332
|
"use strict";
|
|
@@ -24282,7 +24394,8 @@ var init_answer = __esm({
|
|
|
24282
24394
|
);
|
|
24283
24395
|
AnswerNumberSchema = external_exports.strictObject({
|
|
24284
24396
|
value: external_exports.union([external_exports.number(), external_exports.string().refine((text31) => readNumbers(text31).length === 1, 'a number, or one number written as text, e.g. "1,240.00" or "(300.00)"')]).describe('The number the answer must state: a number, or one number as text ("1,240.00") to keep its decimal places'),
|
|
24285
|
-
tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)")
|
|
24397
|
+
tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)"),
|
|
24398
|
+
label: external_exports.string().trim().min(1).max(40).optional().describe("The name of this number, such as balance or credit limit; detects expected values stated under another label")
|
|
24286
24399
|
});
|
|
24287
24400
|
texts = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]);
|
|
24288
24401
|
AnswerRowSchema = external_exports.record(external_exports.string().min(1), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()])).superRefine((row2, ctx) => {
|
|
@@ -24312,6 +24425,15 @@ var init_answer = __esm({
|
|
|
24312
24425
|
if (check4[key4] !== void 0) ctx.addIssue({ code: "custom", path: [key4], message: `rows is mutually exclusive with ${key4}` });
|
|
24313
24426
|
}
|
|
24314
24427
|
}).describe("Checks the agent's final answer (what it posts to ANCHA_DONE_URL, its HTTP reply, or what it prints on stdout): text and numbers, or exact structured rows");
|
|
24428
|
+
LINK_WORDS = /* @__PURE__ */ new Set(["is", "was", "are", "were", "of", "at", "to", "totals"]);
|
|
24429
|
+
ARTICLES = /* @__PURE__ */ new Set(["a", "an", "the"]);
|
|
24430
|
+
CLAUSE_WORDS = /* @__PURE__ */ new Set(["and", "but", "while", "whereas", "with"]);
|
|
24431
|
+
CURRENCY_TOKEN = new RegExp(`^(?:${CURRENCY})$`, "iu");
|
|
24432
|
+
WORD = /^[\p{L}\p{M}]+$/u;
|
|
24433
|
+
WORD_CHAR = /[\p{L}\p{N}_]/u;
|
|
24434
|
+
escapeRegex2 = (text31) => text31.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
24435
|
+
labelPattern = (label7) => new RegExp(`(?<![\\p{L}\\p{N}_])${escapeRegex2(label7)}(?![\\p{L}\\p{N}_])`, "giu");
|
|
24436
|
+
normalizedLabel = (label7) => label7.normalize("NFKC").toLowerCase();
|
|
24315
24437
|
}
|
|
24316
24438
|
});
|
|
24317
24439
|
|
|
@@ -93198,10 +93320,10 @@ function evaluateAnswerRows(check4, answer) {
|
|
|
93198
93320
|
function evaluateAnswer(check4, trace) {
|
|
93199
93321
|
if (check4.rows !== void 0) return evaluateAnswerRows(check4.rows, finalAnswer(trace));
|
|
93200
93322
|
const contains3 = asList(check4.contains), absent = asList(check4.not_contains), sensitive = check4.case === "sensitive";
|
|
93201
|
-
const numbers2 = (check4.numbers ?? []).map((number7) => ({ ...expectedNumber(number7), written: typeof number7.value === "string" ? number7.value : plainNumber(number7.value) }));
|
|
93323
|
+
const numbers2 = (check4.numbers ?? []).map((number7) => ({ ...expectedNumber(number7), label: number7.label, written: typeof number7.value === "string" ? number7.value : plainNumber(number7.value) }));
|
|
93202
93324
|
const parts3 = [
|
|
93203
93325
|
...contains3.length ? [`contains ${quoted2(contains3)}`] : [],
|
|
93204
|
-
...numbers2.length ? [`states ${numbers2.map((n2) => `${n2.written} (\xB1${plainNumber(n2.tolerance)})`).join(", ")}`] : [],
|
|
93326
|
+
...numbers2.length ? [`states ${numbers2.map((n2) => `${n2.written} (${n2.label ? `${n2.label}, ` : ""}\xB1${plainNumber(n2.tolerance)})`).join(", ")}`] : [],
|
|
93205
93327
|
...absent.length ? [`does not contain ${quoted2(absent)}`] : []
|
|
93206
93328
|
];
|
|
93207
93329
|
const expected = parts3.length ? `the final answer ${parts3.join("; ")}` : "a final answer";
|
|
@@ -93229,9 +93351,10 @@ function evaluateAnswer(check4, trace) {
|
|
|
93229
93351
|
const missing9 = contains3.filter((piece2) => !text31.includes(comparableText(piece2, sensitive)));
|
|
93230
93352
|
const unstated = numbers2.filter((n2) => !stated.some((number7) => numberMatches(number7, n2.value, n2.tolerance)));
|
|
93231
93353
|
const present3 = absent.filter((piece2) => text31.includes(comparableText(piece2, sensitive)));
|
|
93354
|
+
const swaps = swappedAnswerNumbers(answer.text, check4.numbers ?? []);
|
|
93232
93355
|
const line2 = answer.text.replace(/\s+/g, " ").trim();
|
|
93233
93356
|
const actual = `"${line2.length > ANSWER_QUOTE ? `${line2.slice(0, ANSWER_QUOTE - 1)}\u2026` : line2}"`;
|
|
93234
|
-
if (!missing9.length && !unstated.length && !present3.length) {
|
|
93357
|
+
if (!missing9.length && !unstated.length && !present3.length && !swaps.length) {
|
|
93235
93358
|
return { passed: true, expected, actual, explanation: parts3.length ? "The final answer states everything the check asks for." : "The agent gave a final answer.", evidence: [answer.seq] };
|
|
93236
93359
|
}
|
|
93237
93360
|
const said = stated.length ? `the numbers it states are ${list4(stated.map((number7) => number7.text))}` : "it states no numbers";
|
|
@@ -93239,6 +93362,7 @@ function evaluateAnswer(check4, trace) {
|
|
|
93239
93362
|
...missing9.length ? [`The final answer does not contain ${quoted2(missing9)}.`] : [],
|
|
93240
93363
|
...unstated.length ? [`It states no number within ${unstated.map((n2) => `${plainNumber(n2.tolerance)} of ${n2.written}`).join(", nor within ")}: ${said}.`] : [],
|
|
93241
93364
|
...present3.length ? [`It contains ${quoted2(present3)}, which it must not.`] : [],
|
|
93365
|
+
...swaps.map((swap) => `It states ${swap.stated.text} after \u201C${swap.under.label}\u201D, but the expected \u201C${swap.under.label}\u201D is ${typeof swap.under.value === "string" ? swap.under.value : plainNumber(swap.under.value)} and ${typeof swap.expected.value === "string" ? swap.expected.value : plainNumber(swap.expected.value)} is the expected \u201C${swap.expected.label}\u201D.`),
|
|
93242
93366
|
...answer.source === "stdout" ? ["Its answer is everything it printed on stdout."] : answer.source === "reply" ? ["Its answer is its HTTP reply."] : []
|
|
93243
93367
|
].join(" ");
|
|
93244
93368
|
return { passed: false, expected, actual, explanation, evidence: [answer.seq] };
|
|
@@ -137466,13 +137590,13 @@ function compileSearch(q2, env2) {
|
|
|
137466
137590
|
const root3 = parse8(tokenize5(q2 ?? ""));
|
|
137467
137591
|
return { matches: (m) => evaluate(root3, m, env2), includesTrash: mentions(root3, "mentionsTrash"), includesSpam: mentions(root3, "mentionsSpam") };
|
|
137468
137592
|
}
|
|
137469
|
-
var
|
|
137593
|
+
var WORD2, words3, addressText, SYSTEM_IN, CATEGORIES2;
|
|
137470
137594
|
var init_search5 = __esm({
|
|
137471
137595
|
"packages/server/src/twins/gmail/search.ts"() {
|
|
137472
137596
|
"use strict";
|
|
137473
137597
|
init_request6();
|
|
137474
|
-
|
|
137475
|
-
words3 = (text31) => text31.toLowerCase().match(
|
|
137598
|
+
WORD2 = /[\p{L}\p{N}]+/gu;
|
|
137599
|
+
words3 = (text31) => text31.toLowerCase().match(WORD2) ?? [];
|
|
137476
137600
|
addressText = (list18) => list18.map((a) => `${a.name} ${a.email}`).join(" ");
|
|
137477
137601
|
SYSTEM_IN = { inbox: "INBOX", sent: "SENT", draft: "DRAFT", drafts: "DRAFT", spam: "SPAM", trash: "TRASH", starred: "STARRED", important: "IMPORTANT", unread: "UNREAD", chats: "CHAT", chat: "CHAT" };
|
|
137478
137602
|
CATEGORIES2 = { primary: "CATEGORY_PERSONAL", personal: "CATEGORY_PERSONAL", social: "CATEGORY_SOCIAL", promotions: "CATEGORY_PROMOTIONS", updates: "CATEGORY_UPDATES", forums: "CATEGORY_FORUMS" };
|
|
@@ -176523,7 +176647,7 @@ function dateModel(model2) {
|
|
|
176523
176647
|
function parseDate2(value5, model2) {
|
|
176524
176648
|
const parts3 = dateModel(model2), tokens6 = [];
|
|
176525
176649
|
const pattern = parts3.map((p2) => {
|
|
176526
|
-
if (!p2.token) return
|
|
176650
|
+
if (!p2.token) return escapeRegex3(p2.literal);
|
|
176527
176651
|
if (p2.token === "FM") return "";
|
|
176528
176652
|
tokens6.push(p2.token);
|
|
176529
176653
|
return p2.token === "YYYY" ? "(\\d{4})" : ["MON", "MONTH"].includes(p2.token) ? "([A-Za-z]+)" : ["AM", "PM"].includes(p2.token) ? "(AM|PM)" : "(\\d{1,2})";
|
|
@@ -177094,7 +177218,7 @@ function scan(db3, query11, page18, opts) {
|
|
|
177094
177218
|
throw error65;
|
|
177095
177219
|
}
|
|
177096
177220
|
}
|
|
177097
|
-
var SuiteqlError, SuiteqlResultSizeError, MAX_TOKENS, MAX_NODES, MAX_DEPTH2, MAX_JOINS, MAX_RESULTS, RESERVED, Parser, subqueryOf, isRownum, quote, param3, key3, numeric3, dated2, textLiteral, family, commonType, direction, JOINS, SET_OPERATORS, AGGREGATES2, RANKING, MATH, ARITIES, OTHER_FUNCTIONS, Compiler, pad2, MONTHS3,
|
|
177221
|
+
var SuiteqlError, SuiteqlResultSizeError, MAX_TOKENS, MAX_NODES, MAX_DEPTH2, MAX_JOINS, MAX_RESULTS, RESERVED, Parser, subqueryOf, isRownum, quote, param3, key3, numeric3, dated2, textLiteral, family, commonType, direction, JOINS, SET_OPERATORS, AGGREGATES2, RANKING, MATH, ARITIES, OTHER_FUNCTIONS, Compiler, pad2, MONTHS3, escapeRegex3, str3, num3, textOrNull, finite2, outOfRange, timestamp3, sameShape2, DAYS2, POSIX, nth;
|
|
177098
177222
|
var init_suiteql = __esm({
|
|
177099
177223
|
"packages/server/src/twins/netsuite/suiteql.ts"() {
|
|
177100
177224
|
"use strict";
|
|
@@ -178130,7 +178254,7 @@ var init_suiteql = __esm({
|
|
|
178130
178254
|
};
|
|
178131
178255
|
pad2 = (n2, width = 2) => String(n2).padStart(width, "0");
|
|
178132
178256
|
MONTHS3 = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
178133
|
-
|
|
178257
|
+
escapeRegex3 = (s3) => s3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
178134
178258
|
str3 = (v) => typeof v === "number" ? cleanNumber(v) : String(v);
|
|
178135
178259
|
num3 = (v) => numericValue(v);
|
|
178136
178260
|
textOrNull = (s3) => s3 === "" ? null : s3;
|
|
@@ -226837,7 +226961,7 @@ __export(harbor_exports, {
|
|
|
226837
226961
|
import { execFile as execFile7, spawn as spawn4 } from "node:child_process";
|
|
226838
226962
|
import { access as access9, chmod as chmod6, mkdir as mkdir16, mkdtemp as mkdtemp5, readFile as readFile20, rm as rm7, writeFile as writeFile14, lstat as lstat8, realpath as realpath10 } from "node:fs/promises";
|
|
226839
226963
|
import { tmpdir as tmpdir4, homedir } from "node:os";
|
|
226840
|
-
import { dirname as dirname14, join as join35, basename as
|
|
226964
|
+
import { dirname as dirname14, join as join35, basename as basename10 } from "node:path";
|
|
226841
226965
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
226842
226966
|
import { promisify as promisify7 } from "node:util";
|
|
226843
226967
|
async function exists3(path7) {
|
|
@@ -226926,7 +227050,7 @@ async function cleanupHarborBatch(workspaceDir, batchId) {
|
|
|
226926
227050
|
if (await same3()) throw new AnchaError("INTERNAL", "The previous execution controller is still stopping. Try again shortly.");
|
|
226927
227051
|
}
|
|
226928
227052
|
const privateDir = dirname14(marker.inputFile);
|
|
226929
|
-
if (/^ancha-harbor-[A-Za-z0-9]+$/.test(
|
|
227053
|
+
if (/^ancha-harbor-[A-Za-z0-9]+$/.test(basename10(privateDir)) && await exists3(privateDir)) {
|
|
226930
227054
|
const entry3 = await lstat8(privateDir);
|
|
226931
227055
|
if (entry3.isDirectory() && !entry3.isSymbolicLink() && await realpath10(dirname14(privateDir)) === await realpath10(tmpdir4())) await rm7(privateDir, { recursive: true, force: true });
|
|
226932
227056
|
else throw new AnchaError("INTERNAL", "The previous execution directory could not be safely removed.");
|
|
@@ -240447,7 +240571,7 @@ init_assets();
|
|
|
240447
240571
|
|
|
240448
240572
|
// backend/src/console/catalog.ts
|
|
240449
240573
|
import { readFile as readFile16, realpath as realpath7, stat as stat8 } from "node:fs/promises";
|
|
240450
|
-
import { join as join32, resolve as resolve23 } from "node:path";
|
|
240574
|
+
import { basename as basename9, join as join32, resolve as resolve23 } from "node:path";
|
|
240451
240575
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
240452
240576
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
240453
240577
|
init_src();
|
|
@@ -240477,6 +240601,21 @@ var ScenarioCatalog = class {
|
|
|
240477
240601
|
this.workspace = workspace4;
|
|
240478
240602
|
this.configPath = configPath;
|
|
240479
240603
|
}
|
|
240604
|
+
async worlds() {
|
|
240605
|
+
const worlds2 = [];
|
|
240606
|
+
for (const path7 of (await glob3("ancha/worlds/*.yaml", { cwd: this.workspace, followSymbolicLinks: false })).sort()) {
|
|
240607
|
+
const id14 = basename9(path7, ".yaml");
|
|
240608
|
+
try {
|
|
240609
|
+
const doc = (0, import_yaml6.parseDocument)(await safeRead(this.workspace, path7));
|
|
240610
|
+
if (doc.errors.length) throw new AnchaError("SCENE_INVALID", doc.errors.map((e) => e.message).join("\n"));
|
|
240611
|
+
const world5 = parseWorldFile(doc.toJS({ maxAliasCount: 100 }));
|
|
240612
|
+
worlds2.push({ id: id14, path: path7, tools: world5.tools, ...world5.people !== void 0 && { people: world5.people.length } });
|
|
240613
|
+
} catch (error65) {
|
|
240614
|
+
worlds2.push({ id: id14, path: path7, tools: [], error: error65 instanceof Error ? error65.message : String(error65) });
|
|
240615
|
+
}
|
|
240616
|
+
}
|
|
240617
|
+
return worlds2;
|
|
240618
|
+
}
|
|
240480
240619
|
/** `workspaceOnly`: this folder's scene files alone (the configured globs and drafts), without the bundled library. */
|
|
240481
240620
|
async list(options4 = {}) {
|
|
240482
240621
|
const scenes = [], errors3 = [];
|
|
@@ -242239,7 +242378,7 @@ init_run_metadata();
|
|
|
242239
242378
|
init_src();
|
|
242240
242379
|
init_credentials();
|
|
242241
242380
|
import { readFile as readFile21 } from "node:fs/promises";
|
|
242242
|
-
import { basename as
|
|
242381
|
+
import { basename as basename11, join as join37 } from "node:path";
|
|
242243
242382
|
|
|
242244
242383
|
// packages/cli/src/git-state.ts
|
|
242245
242384
|
import { execFile as execFile8 } from "node:child_process";
|
|
@@ -242282,7 +242421,7 @@ async function uploadRun(ctx, workspace4, run6) {
|
|
|
242282
242421
|
createdAt: summary.startedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
242283
242422
|
source: bundleSource(ctx.io.env),
|
|
242284
242423
|
cli: CLI_VERSION,
|
|
242285
|
-
project: { name:
|
|
242424
|
+
project: { name: basename11(ctx.io.cwd), git: git.commit === void 0 ? null : { commit: git.commit, branch: git.branch ?? null, dirty: git.dirty ?? false } },
|
|
242286
242425
|
secrets: await bundleSecrets({ cwd: ctx.io.cwd, env: ctx.io.env, ...run6.passEnv !== void 0 && { passEnv: run6.passEnv }, ...run6.inheritEnv && { inheritEnv: true } })
|
|
242287
242426
|
});
|
|
242288
242427
|
let response6;
|
|
@@ -242416,14 +242555,14 @@ ${path7.split(sep7).join("/")}`;
|
|
|
242416
242555
|
init_src();
|
|
242417
242556
|
init_connection_tools();
|
|
242418
242557
|
import { access as access10 } from "node:fs/promises";
|
|
242419
|
-
import { basename as
|
|
242558
|
+
import { basename as basename12, resolve as resolve30 } from "node:path";
|
|
242420
242559
|
init_baselines();
|
|
242421
242560
|
init_run_store();
|
|
242422
242561
|
init_config();
|
|
242423
242562
|
init_report2();
|
|
242424
242563
|
init_agent_env();
|
|
242425
242564
|
init_run();
|
|
242426
|
-
var agentName = (cwd) =>
|
|
242565
|
+
var agentName = (cwd) => basename12(resolve30(cwd)).slice(0, 100) || "agent";
|
|
242427
242566
|
async function pinnedBaseline(ctx, ref23, tests, options4, cloudSummary2) {
|
|
242428
242567
|
const { cwd } = ctx.io;
|
|
242429
242568
|
if (ref23 === "latest") ref23 = await latestRunId(cwd);
|
|
@@ -242865,7 +243004,7 @@ async function connectOnCloud(ctx, ws, check4, signal) {
|
|
|
242865
243004
|
|
|
242866
243005
|
// packages/cli/src/commands/internal-cloud.ts
|
|
242867
243006
|
import { readFile as readFile28, stat as stat10, writeFile as writeFile19 } from "node:fs/promises";
|
|
242868
|
-
import { basename as
|
|
243007
|
+
import { basename as basename13, join as join45, resolve as resolve34 } from "node:path";
|
|
242869
243008
|
init_src();
|
|
242870
243009
|
init_config();
|
|
242871
243010
|
var cloudModules = {
|
|
@@ -242925,7 +243064,7 @@ function commandWords(command) {
|
|
|
242925
243064
|
async function missingCommandEntry(command, cwd) {
|
|
242926
243065
|
const words9 = commandWords(command);
|
|
242927
243066
|
if (!words9?.length) return void 0;
|
|
242928
|
-
const program2 =
|
|
243067
|
+
const program2 = basename13(words9.shift());
|
|
242929
243068
|
const python = /^python(?:\d+(?:\.\d+)*)?$/.test(program2);
|
|
242930
243069
|
if (!python && !["node", "nodejs", "tsx", "bun", "deno"].includes(program2)) return void 0;
|
|
242931
243070
|
if ((program2 === "bun" || program2 === "deno") && words9[0] === "run") words9.shift();
|
|
@@ -246193,7 +246332,9 @@ function givenNumbers(value5) {
|
|
|
246193
246332
|
if (typeof entry3.value === "string" && readNumbers(entry3.value).length !== 1) return `numbers: ${JSON.stringify(entry3.value)} is not one number`;
|
|
246194
246333
|
if (typeof entry3.value !== "number" && typeof entry3.value !== "string") return `numbers: each is a number, or { value, tolerance }`;
|
|
246195
246334
|
if (entry3.tolerance !== void 0 && (typeof entry3.tolerance !== "number" || entry3.tolerance < 0)) return `numbers: the tolerance of ${entry3.value} is not a number of 0 or more`;
|
|
246196
|
-
|
|
246335
|
+
const parsed4 = AnswerCheckSchema.safeParse({ numbers: [{ value: entry3.value, ...entry3.tolerance !== void 0 && { tolerance: entry3.tolerance }, ...entry3.label !== void 0 && { label: entry3.label } }] });
|
|
246336
|
+
if (!parsed4.success) return `numbers: ${parsed4.error.issues.map((issue9) => `${issue9.path.slice(2).join(".")}: ${issue9.message}`).join("; ")}`;
|
|
246337
|
+
numbers2.push(parsed4.data.numbers[0]);
|
|
246197
246338
|
}
|
|
246198
246339
|
return numbers2;
|
|
246199
246340
|
}
|
|
@@ -246202,7 +246343,10 @@ function extractExpected(expected, question = "") {
|
|
|
246202
246343
|
const rest2 = expected.replace(QUOTED, " ");
|
|
246203
246344
|
const documents = [...rest2.matchAll(DOCUMENT)].map((m) => m[0]);
|
|
246204
246345
|
const asked2 = new Set(readNumbers(question.replace(DATE4, " ")).map((n2) => Math.abs(n2.value)));
|
|
246205
|
-
const
|
|
246346
|
+
const labelText = expected.replace(QUOTED, "|").replace(DOCUMENT, "|").replace(DATE4, "|").normalize("NFKC");
|
|
246347
|
+
const spans = readNumberSpans(labelText).filter((n2) => !asked2.has(Math.abs(n2.value)));
|
|
246348
|
+
const labels2 = inferNumberLabels(labelText, spans);
|
|
246349
|
+
const numbers2 = spans.map((n2, i) => ({ value: n2.value, tolerance: 0.5 * 10 ** -n2.decimals, ...labels2[i] !== void 0 && { label: labels2[i] } }));
|
|
246206
246350
|
return { contains: unique3([...quoted4, ...documents]), numbers: numbers2.filter((n2, i) => numbers2.findIndex((o) => o.value === n2.value) === i) };
|
|
246207
246351
|
}
|
|
246208
246352
|
function callPattern(value5, functions) {
|
|
@@ -250201,7 +250345,7 @@ async function startConsole(opts) {
|
|
|
250201
250345
|
if (parts3[1] === "scenarios") {
|
|
250202
250346
|
if (method2 === "GET" && parts3.length === 3 && parts3[2] === "folder") {
|
|
250203
250347
|
const { scenes, errors: errors3 } = await catalog2.list({ workspaceOnly: true });
|
|
250204
|
-
return send3(res, { scenes: scenes.filter((s3) => s3.origin === "workspace").map((s3) => ({ key: s3.key, path: s3.path, id: s3.scene.id, title: s3.scene.title, tools: s3.scene.twins })), errors: errors3 });
|
|
250348
|
+
return send3(res, { scenes: scenes.filter((s3) => s3.origin === "workspace").map((s3) => ({ key: s3.key, path: s3.path, id: s3.scene.id, title: s3.scene.title, tools: s3.scene.twins })), worlds: await catalog2.worlds(), errors: errors3 });
|
|
250205
250349
|
}
|
|
250206
250350
|
if (method2 === "GET" && parts3.length === 3 && parts3[2] === "data") {
|
|
250207
250351
|
const found = await catalog2.get(query10(url4, ["key"]).key ?? "");
|
|
@@ -250529,7 +250673,7 @@ init_trace_import();
|
|
|
250529
250673
|
init_trace_import();
|
|
250530
250674
|
import { createHash as createHash78 } from "node:crypto";
|
|
250531
250675
|
import { access as access13, readFile as readFile48, mkdir as mkdir29, stat as stat17, writeFile as writeFile31 } from "node:fs/promises";
|
|
250532
|
-
import { basename as
|
|
250676
|
+
import { basename as basename15, dirname as dirname24, join as join67, relative as relative23, resolve as resolve48 } from "node:path";
|
|
250533
250677
|
import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
|
|
250534
250678
|
var import_yaml19 = __toESM(require_dist(), 1);
|
|
250535
250679
|
init_src();
|
|
@@ -250735,7 +250879,7 @@ async function listTraces(source, { limit: limit2, since, name: name5 }, env2, f
|
|
|
250735
250879
|
|
|
250736
250880
|
// packages/cli/src/trace-files.ts
|
|
250737
250881
|
import { readFile as readFile47, stat as stat16 } from "node:fs/promises";
|
|
250738
|
-
import { basename as
|
|
250882
|
+
import { basename as basename14, relative as relative21, resolve as resolve47 } from "node:path";
|
|
250739
250883
|
init_src();
|
|
250740
250884
|
var MB3 = 1024 * 1024;
|
|
250741
250885
|
var UPLOAD_BYTES = 20 * MB3;
|
|
@@ -250763,7 +250907,7 @@ async function findTraceFiles(cwd, args) {
|
|
|
250763
250907
|
return [...found].sort();
|
|
250764
250908
|
}
|
|
250765
250909
|
async function readTraceTexts(cwd, paths3) {
|
|
250766
|
-
return Promise.all(paths3.map(async (path7) => ({ file: relative21(cwd, path7) ||
|
|
250910
|
+
return Promise.all(paths3.map(async (path7) => ({ file: relative21(cwd, path7) || basename14(path7), name: basename14(path7), text: await readFile47(path7, "utf8").catch(() => void 0) })));
|
|
250767
250911
|
}
|
|
250768
250912
|
function readTraceUnits(texts4, { fileToIr: fileToIr2, sourceOf: sourceOf2 }) {
|
|
250769
250913
|
const drafts = /* @__PURE__ */ new Map(), skipped = [], read7 = [];
|
|
@@ -251681,14 +251825,14 @@ function registerTraces(program2, ctx) {
|
|
|
251681
251825
|
};
|
|
251682
251826
|
const summary = await loadRunSummary(ctx.io.cwd, runId2, options4.out);
|
|
251683
251827
|
const dirs = summary.scenes.flatMap((scene2) => scene2.trialsDetail.map((detail3) => resolve48(ctx.io.cwd, detail3.dir)));
|
|
251684
|
-
const dir2 = trial === void 0 ? dirs[0] : dirs.find((path7) =>
|
|
251685
|
-
if (dir2 === void 0) throw new AnchaError("USAGE", trial === void 0 ? `run ${summary.runId} has no attempts` : `no attempt ${trial} in run ${summary.runId}`, { hint: `its attempts: ${dirs.map((path7) =>
|
|
251686
|
-
const attemptLines2 = safe(attemptToIr(await readAttemptTrace(dir2),
|
|
251828
|
+
const dir2 = trial === void 0 ? dirs[0] : dirs.find((path7) => basename15(path7) === trial);
|
|
251829
|
+
if (dir2 === void 0) throw new AnchaError("USAGE", trial === void 0 ? `run ${summary.runId} has no attempts` : `no attempt ${trial} in run ${summary.runId}`, { hint: `its attempts: ${dirs.map((path7) => basename15(path7)).join(", ") || "none"}` });
|
|
251830
|
+
const attemptLines2 = safe(attemptToIr(await readAttemptTrace(dir2), basename15(dir2)));
|
|
251687
251831
|
const production3 = calls2(productionLinesSafe), attemptCalls = calls2(attemptLines2);
|
|
251688
251832
|
const ids2 = comparisonIds2(observedRefs(productionLinesSafe), observedRefs(attemptLines2));
|
|
251689
251833
|
const result = {
|
|
251690
251834
|
production: { file: file3, calls: production3.length },
|
|
251691
|
-
attempt: { id: `${summary.runId}/${
|
|
251835
|
+
attempt: { id: `${summary.runId}/${basename15(dir2)}`, calls: attemptCalls.length },
|
|
251692
251836
|
scope: ["service", "method", "path", "query", "arguments", "body"],
|
|
251693
251837
|
next: [`ancha explain ${summary.runId}`],
|
|
251694
251838
|
...diffCalls(production3.map((item2) => callFingerprint2(item2, ids2.production[item2.service])), attemptCalls.map((item2) => callFingerprint2(item2, ids2.attempt[item2.service])))
|
|
@@ -251697,7 +251841,7 @@ function registerTraces(program2, ctx) {
|
|
|
251697
251841
|
const list18 = (calls3) => calls3.length ? calls3.map((c) => ` ${c.call}${c.count > 1 ? ` \xD7${c.count}` : ""}`) : [" none"];
|
|
251698
251842
|
const first2 = result.firstDifference;
|
|
251699
251843
|
return [
|
|
251700
|
-
`production ${
|
|
251844
|
+
`production ${basename15(file3)}: ${plural6(production3.length, "call")}; attempt ${result.attempt.id}: ${plural6(attemptCalls.length, "call")}`,
|
|
251701
251845
|
"only in production:",
|
|
251702
251846
|
...list18(result.onlyInProduction),
|
|
251703
251847
|
"only in the attempt:",
|
|
@@ -251733,7 +251877,7 @@ function registerTraces(program2, ctx) {
|
|
|
251733
251877
|
} else {
|
|
251734
251878
|
texts4 = await readTraceTexts(ctx.io.cwd, await findTraceFiles(ctx.io.cwd, paths3));
|
|
251735
251879
|
const one7 = paths3.length === 1 ? resolve48(ctx.io.cwd, paths3[0]) : void 0;
|
|
251736
|
-
name5 = one7 && await stat17(one7).then(() => true, () => false) ?
|
|
251880
|
+
name5 = one7 && await stat17(one7).then(() => true, () => false) ? basename15(one7).slice(0, 80) : "traces";
|
|
251737
251881
|
}
|
|
251738
251882
|
const { units, skipped, read: read7 } = await traceUnits(texts4);
|
|
251739
251883
|
if (!units.length) {
|
|
@@ -251808,7 +251952,7 @@ function registerTraces(program2, ctx) {
|
|
|
251808
251952
|
async function traceSource(ctx, trace, from) {
|
|
251809
251953
|
if (!from) return { text: await readFile48(resolve48(ctx.io.cwd, trace), "utf8").catch(() => {
|
|
251810
251954
|
throw new AnchaError("USAGE", `cannot read ${trace}`, { hint: "pass the path of a trace file: ancha import --offline <trace.jsonl>" });
|
|
251811
|
-
}), name:
|
|
251955
|
+
}), name: basename15(trace), label: basename15(trace) };
|
|
251812
251956
|
const doc = await fetchTrace(from, trace, ctx.io.env);
|
|
251813
251957
|
const id14 = traceRef(from, trace);
|
|
251814
251958
|
return { text: JSON.stringify(doc), name: `${from}-${id14}`.slice(0, 80), label: `${from === "langfuse" ? "Langfuse" : "LangSmith"} trace ${id14}` };
|
|
@@ -251817,7 +251961,7 @@ async function traceFileLines(ctx, file3) {
|
|
|
251817
251961
|
const text31 = await readFile48(resolve48(ctx.io.cwd, file3), "utf8").catch(() => {
|
|
251818
251962
|
throw new AnchaError("USAGE", `cannot read ${file3}`, { hint: "pass the path of a trace file: ancha traces diff <trace.jsonl> latest" });
|
|
251819
251963
|
});
|
|
251820
|
-
return { text: text31, lines: await traceTextLines(text31,
|
|
251964
|
+
return { text: text31, lines: await traceTextLines(text31, basename15(file3)) };
|
|
251821
251965
|
}
|
|
251822
251966
|
async function traceTextLines(text31, name5) {
|
|
251823
251967
|
const { fileToIr: fileToIr2, mergeIr: mergeIr2 } = await Promise.resolve().then(() => (init_rebuild(), rebuild_exports));
|
|
@@ -252024,14 +252168,14 @@ function evidenceLines2(made) {
|
|
|
252024
252168
|
// packages/cli/src/commands/test-import.ts
|
|
252025
252169
|
import { existsSync as existsSync4 } from "node:fs";
|
|
252026
252170
|
import { access as access14, mkdir as mkdir30, readFile as readFile49, writeFile as writeFile32 } from "node:fs/promises";
|
|
252027
|
-
import { basename as
|
|
252171
|
+
import { basename as basename16, dirname as dirname25, extname as extname2, isAbsolute as isAbsolute12, relative as relative24, resolve as resolve49 } from "node:path";
|
|
252028
252172
|
init_src();
|
|
252029
252173
|
init_detect();
|
|
252030
252174
|
init_function_tools();
|
|
252031
252175
|
var EXAMPLE = `
|
|
252032
252176
|
Each eval is a question with its expected answer. Fields: question (or input, prompt, query, task); expected (or answer,
|
|
252033
252177
|
ideal, output, reference, expected_output); optional: id, read_only (default true; false with records), must_call and must_not_call
|
|
252034
|
-
("METHOD /path", a detected function tool name or an MCP tool name), numbers ([{ value, tolerance }]), contains (text the answer must hold), judge (a
|
|
252178
|
+
("METHOD /path", a detected function tool name or an MCP tool name), numbers ([{ value, tolerance, label? }]), contains (text the answer must hold), judge (a
|
|
252035
252179
|
rubric), tags, records (the NetSuite state a write leaves: [{ type, id or externalId, fields }]). Other fields are kept
|
|
252036
252180
|
in the test's header. It also reads eval tools' files as they are: OpenAI evals, promptfoo configs and tests,
|
|
252037
252181
|
LangSmith and Braintrust dataset exports, DeepEval and Ragas datasets, and CSV with any column names (it prints the
|
|
@@ -252064,7 +252208,7 @@ async function testImport(ctx, file3, options4) {
|
|
|
252064
252208
|
const detected = importFormat(text31, options4.format);
|
|
252065
252209
|
if (detected.route === "trace") {
|
|
252066
252210
|
if (options4.world) throw new AnchaError("USAGE", "--world selects an eval world; trace import rebuilds its world from the trace", { hint: "omit --world for --format trace, or choose --format eval" });
|
|
252067
|
-
const made = await importLocally(ctx, { text: text31, name:
|
|
252211
|
+
const made = await importLocally(ctx, { text: text31, name: basename16(path7), label: file3 }, { dest: options4.out, force: options4.force, answer: options4.answer ?? [], expect: options4.expect, checks: options4.checks, useReportedResults: options4.useReportedResults });
|
|
252068
252212
|
const result2 = { ...made.result, format: detected.format };
|
|
252069
252213
|
ctx.out.result(result2, () => `format: ${detected.format}
|
|
252070
252214
|
${made.text}`);
|
|
@@ -252073,7 +252217,7 @@ ${made.text}`);
|
|
|
252073
252217
|
if (options4.checks || options4.expect || options4.answer?.length || options4.useReportedResults) throw new AnchaError("USAGE", "--checks, --expect, --answer and --use-reported-results select trace import options", { hint: "use --format trace for trace records" });
|
|
252074
252218
|
let read7;
|
|
252075
252219
|
try {
|
|
252076
|
-
read7 = readEvalItems(
|
|
252220
|
+
read7 = readEvalItems(basename16(path7), text31);
|
|
252077
252221
|
} catch (error65) {
|
|
252078
252222
|
throw new AnchaError("USAGE", error65 instanceof Error ? error65.message : String(error65), { hint: "write JSON lines (one eval per line), a JSON array, CSV with a header row, or a YAML list" });
|
|
252079
252223
|
}
|
|
@@ -252081,7 +252225,7 @@ ${made.text}`);
|
|
|
252081
252225
|
const world5 = await chooseWorld(ctx, options4.world, `ancha test import ${file3}`);
|
|
252082
252226
|
const outDir = resolve49(ctx.io.cwd, options4.out), out = relative24(ctx.io.cwd, outDir) || ".";
|
|
252083
252227
|
const detection = await detectProject(ctx.io.cwd);
|
|
252084
|
-
const imported2 = importEvals(read7.items, { id: world5.id, tools: world5.tools }, { functionTools: detection.functionTools.map((t) => t.name), judge: options4.judge, ...options4.prefix !== void 0 && { prefix: options4.prefix }, out, source:
|
|
252228
|
+
const imported2 = importEvals(read7.items, { id: world5.id, tools: world5.tools }, { functionTools: detection.functionTools.map((t) => t.name), judge: options4.judge, ...options4.prefix !== void 0 && { prefix: options4.prefix }, out, source: basename16(path7) });
|
|
252085
252229
|
const reasons = new Map([...imported2.skipped.map((s3) => [s3.index, s3.reason]), ...read7.unreadable.map((u) => [u.index, u.reason])]);
|
|
252086
252230
|
const skipped = [...reasons].sort(([a], [b]) => a - b).map(([index, reason2]) => ({ item: index + 1, reason: reason2 }));
|
|
252087
252231
|
if (imported2.tests.length === 0) {
|
|
@@ -252109,7 +252253,7 @@ ${skipped.slice(0, 10).map((s3) => `item ${s3.item}: ${s3.reason}`).join("\n")}`
|
|
|
252109
252253
|
const withAgent = inProject2[0] !== ".." && !isAbsolute12(inProject2.join("/")) && inProject2[0] !== "ancha" && !inProject2.some((part) => part.startsWith(".") || part === "node_modules");
|
|
252110
252254
|
const notes6 = [
|
|
252111
252255
|
...imported2.warnings,
|
|
252112
|
-
...withAgent ? [`${file3} goes to the agent with its files in a cloud run, expected answers and all: move it under ancha/ (e.g. ancha/evals/${
|
|
252256
|
+
...withAgent ? [`${file3} goes to the agent with its files in a cloud run, expected answers and all: move it under ancha/ (e.g. ancha/evals/${basename16(path7)}), which stays with the grader`] : [],
|
|
252113
252257
|
...encoding ? [`read as ${encoding} text`] : [],
|
|
252114
252258
|
...read7.notes ?? [],
|
|
252115
252259
|
...configured && !seen ? [`scenes: in ancha.yaml does not include ${out}; add ${out}/*.yaml to run these tests with the rest`] : [],
|
|
@@ -252117,7 +252261,7 @@ ${skipped.slice(0, 10).map((s3) => `item ${s3.item}: ${s3.reason}`).join("\n")}`
|
|
|
252117
252261
|
];
|
|
252118
252262
|
const next2 = configured ? [seen ? "ancha run" : `ancha run ${out}/*.yaml`] : ["ancha init", `ancha run ${out}/*.yaml`];
|
|
252119
252263
|
next2.unshift(...functionToolWiring(detection.functionTools));
|
|
252120
|
-
const format2 = read7.format ?? { jsonl: "JSON lines", json: "JSON", csv: "CSV", yaml: "YAML" }[evalFormat(
|
|
252264
|
+
const format2 = read7.format ?? { jsonl: "JSON lines", json: "JSON", csv: "CSV", yaml: "YAML" }[evalFormat(basename16(path7), text31)];
|
|
252121
252265
|
const result = { file: relative24(ctx.io.cwd, path7), world: world5.id, out, format: format2, ...read7.fields && { fields: read7.fields }, tests, checks: checks2, skipped, next: next2, notes: notes6 };
|
|
252122
252266
|
ctx.out.result(result, () => report8(result));
|
|
252123
252267
|
return result;
|
|
@@ -252144,7 +252288,7 @@ function registerTestImport(tests, ctx) {
|
|
|
252144
252288
|
|
|
252145
252289
|
// packages/cli/src/commands/test-files.ts
|
|
252146
252290
|
import { readFile as readFile50, stat as stat18 } from "node:fs/promises";
|
|
252147
|
-
import { basename as
|
|
252291
|
+
import { basename as basename17, relative as relative25, resolve as resolve50 } from "node:path";
|
|
252148
252292
|
init_src();
|
|
252149
252293
|
init_scenes();
|
|
252150
252294
|
async function projectTestFiles(ctx) {
|
|
@@ -252178,7 +252322,7 @@ async function showTestFile(ctx, ref23) {
|
|
|
252178
252322
|
const [{ scene: scene2, world: worldPath }] = await loadScenes(ctx.io.cwd, [path7]);
|
|
252179
252323
|
const doc = parseSceneYaml(await readFile50(resolve50(ctx.io.cwd, path7), "utf8"));
|
|
252180
252324
|
const world5 = {
|
|
252181
|
-
...worldPath !== void 0 && { id:
|
|
252325
|
+
...worldPath !== void 0 && { id: basename17(worldPath, ".yaml"), path: relative25(ctx.io.cwd, worldPath) },
|
|
252182
252326
|
tools: scene2.twins
|
|
252183
252327
|
};
|
|
252184
252328
|
const value5 = {
|
|
@@ -272735,7 +272879,7 @@ init_run_metadata();
|
|
|
272735
272879
|
var import_yaml22 = __toESM(require_dist(), 1);
|
|
272736
272880
|
init_src();
|
|
272737
272881
|
import { mkdir as mkdir36, readFile as readFile58, stat as stat21, writeFile as writeFile38 } from "node:fs/promises";
|
|
272738
|
-
import { basename as
|
|
272882
|
+
import { basename as basename18, join as join73, relative as relative28, resolve as resolve60 } from "node:path";
|
|
272739
272883
|
init_report2();
|
|
272740
272884
|
init_run_store();
|
|
272741
272885
|
init_credentials();
|
|
@@ -272780,7 +272924,7 @@ async function testTask(ctx, file3, worldOverride) {
|
|
|
272780
272924
|
if (typeof prompt !== "string" || !prompt.trim()) {
|
|
272781
272925
|
throw new AnchaError("USAGE", `${file3} gives the agent no task`, { hint: v22 && start2.message !== void 0 ? "a test that starts with a message runs with ancha run; give it start.task to run it here" : "add start.task (version 2) or task" });
|
|
272782
272926
|
}
|
|
272783
|
-
const id14 = String(typeof doc.id === "string" ? doc.id :
|
|
272927
|
+
const id14 = String(typeof doc.id === "string" ? doc.id : basename18(path7).replace(/\.ya?ml$/, "")).replace(/[^A-Za-z0-9_-]/g, "-").replace(/^[^A-Za-z0-9]+/, "").slice(0, 80) || "test";
|
|
272784
272928
|
const pass = Array.isArray(doc.pass) ? new Set(doc.pass.map(String)) : void 0;
|
|
272785
272929
|
const checks2 = Array.isArray(doc.checks) ? doc.checks.filter((check4) => pass === void 0 || pass.has(String(check4.id))) : [];
|
|
272786
272930
|
const timeoutMs = v22 && typeof doc.timeout === "string" ? parseDuration(doc.timeout) : void 0;
|
|
@@ -272894,7 +273038,7 @@ next page: ancha runs list --cursor ${page18.nextCursor}`}`);
|
|
|
272894
273038
|
const inputs2 = await readFile58(join73(resolve60(ctx.io.cwd, options4.out ?? DEFAULT_RUNS_DIR), summary.runId, "inputs.json"), "utf8").then((text31) => JSON.parse(text31), () => ({}));
|
|
272895
273039
|
const files2 = [], cases = withSeeds(inputs2.cases ?? []);
|
|
272896
273040
|
for (const scene2 of summary.scenes) for (const trial of scene2.trialsDetail) {
|
|
272897
|
-
const dir2 = resolve60(ctx.io.cwd, trial.dir), name5 =
|
|
273041
|
+
const dir2 = resolve60(ctx.io.cwd, trial.dir), name5 = basename18(dir2), file3 = join73(dest, `${name5}.ir.jsonl`);
|
|
272898
273042
|
await writeFile38(file3, attemptToIr(await readAttemptTrace(dir2), `${summary.runId}/${name5}`, summary.agent, {
|
|
272899
273043
|
scene: cases.find((c) => c.id === scene2.sceneId)?.scene,
|
|
272900
273044
|
checks: await readFile58(join73(dir2, "checks.json"), "utf8").then((text31) => JSON.parse(text31), () => void 0),
|
|
@@ -273021,12 +273165,12 @@ function processIO() {
|
|
|
273021
273165
|
return { stdout: process.stdout, stderr: process.stderr, cwd: process.cwd(), env: process.env };
|
|
273022
273166
|
}
|
|
273023
273167
|
var HELP_GROUPS = {
|
|
273024
|
-
"Start:": ["login", "init", "secrets", "agent", "traces", "run", "explain"],
|
|
273168
|
+
"Start:": ["login", "init", "secrets", "agent", "traces", "run", "explain", "report"],
|
|
273025
273169
|
"Cloud:": ["status", "wait", "whoami"],
|
|
273026
|
-
"Inspect:": ["world", "test", "twins", "connect", "doctor"],
|
|
273170
|
+
"Inspect:": ["world", "test", "pull", "twins", "connect", "doctor"],
|
|
273027
273171
|
"More:": ["import", "baseline", "docs", "completion"]
|
|
273028
273172
|
};
|
|
273029
|
-
var ADVANCED = /* @__PURE__ */ new Set(["serve", "ui", "scene", "env", "sandbox", "mcp", "execution", "playground", "logs", "
|
|
273173
|
+
var ADVANCED = /* @__PURE__ */ new Set(["serve", "ui", "scene", "env", "sandbox", "mcp", "execution", "playground", "logs", "check", "runs", "attempt", "replay", "schema", "logout"]);
|
|
273030
273174
|
var START = [
|
|
273031
273175
|
"Ancha: simulation playgrounds for agents. Start here:",
|
|
273032
273176
|
" ancha login sign in to your workspace at app.ancha.io (one browser approval)",
|