@ancha-labs/cli 0.4.15 → 0.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ancha.mjs +1890 -1297
- package/lib/assets/SKILL.md +1 -1
- package/lib/assets/agents-section.md +1 -1
- package/lib/assets/docs/cloud.md +3 -1
- package/lib/assets/docs/datasets.md +2 -2
- package/lib/assets/docs/scenes.md +2 -2
- package/lib/assets/docs/setup.md +2 -2
- package/lib/assets/docs/traces.md +1 -1
- package/lib/assets/harbor/companion.mjs +114 -38
- package/lib/assets/harbor/driver.py +17 -3
- package/lib/assets/ui/app.js +1 -1
- package/lib/mcp-entry.mjs +10 -6
- package/lib/worker.mjs +220 -73
- package/lib/world-server.mjs +71 -36
- package/package.json +1 -1
package/lib/world-server.mjs
CHANGED
|
@@ -92098,7 +92098,7 @@ var AnswerCheckSchema = external_exports.strictObject({
|
|
|
92098
92098
|
not_contains: texts.optional().describe("Text the final answer must not contain"),
|
|
92099
92099
|
numbers: external_exports.array(AnswerNumberSchema).min(1).optional().describe("Numbers the final answer must state, each within its tolerance; thousands separators, currency codes and symbols, minus signs and parentheses for negatives are read"),
|
|
92100
92100
|
case: external_exports.enum(["insensitive", "sensitive"]).optional().describe("How contains and not_contains compare letters; default insensitive")
|
|
92101
|
-
}).describe("Checks the agent's final answer (what it posts to ANCHA_DONE_URL, its HTTP reply, or
|
|
92101
|
+
}).describe("Checks the agent's final answer (what it posts to ANCHA_DONE_URL, its HTTP reply, or what it prints on stdout): the text and numbers it states");
|
|
92102
92102
|
function expectedNumber(number7) {
|
|
92103
92103
|
const read6 = typeof number7.value === "number" ? { value: number7.value, decimals: decimalsOf(number7.value) } : readNumbers(number7.value)[0];
|
|
92104
92104
|
return { value: read6.value, tolerance: number7.tolerance ?? 0.5 * 10 ** -read6.decimals };
|
|
@@ -95327,10 +95327,10 @@ var BetterStackSeedSchema = external_exports.strictObject({
|
|
|
95327
95327
|
open2.add(entry2.source);
|
|
95328
95328
|
}
|
|
95329
95329
|
});
|
|
95330
|
-
seed43.onCall.forEach((
|
|
95330
|
+
seed43.onCall.forEach((calendar4, i) => calendar4.users.forEach((user8, j) => {
|
|
95331
95331
|
if (!people3.has(user8)) issue6(["onCall", i, "users", j], `${user8} is not a user`);
|
|
95332
95332
|
}));
|
|
95333
|
-
if (seed43.onCall.filter((
|
|
95333
|
+
if (seed43.onCall.filter((calendar4) => calendar4.default).length > 1) issue6(["onCall"], "only one default calendar");
|
|
95334
95334
|
seed43.statusPages.forEach((page18, i) => {
|
|
95335
95335
|
const names5 = new Set(page18.resources.map((resource2) => resource2.publicName));
|
|
95336
95336
|
page18.resources.forEach((resource2, j) => {
|
|
@@ -102019,10 +102019,14 @@ var NetsuiteRecordCheckSchema = external_exports.strictObject({
|
|
|
102019
102019
|
id: id8.optional(),
|
|
102020
102020
|
externalId: text11.optional(),
|
|
102021
102021
|
fields: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
102022
|
-
apply: external_exports.array(application).optional()
|
|
102022
|
+
apply: external_exports.array(application).optional(),
|
|
102023
|
+
credit: external_exports.array(application).optional()
|
|
102023
102024
|
}).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both", path: ["id"] });
|
|
102024
|
-
var NetsuiteUnchangedCheckSchema = external_exports.strictObject({
|
|
102025
|
-
|
|
102025
|
+
var NetsuiteUnchangedCheckSchema = external_exports.strictObject({
|
|
102026
|
+
types: external_exports.array(external_exports.enum(netsuiteRecordTypes)).min(1),
|
|
102027
|
+
except: external_exports.array(external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), id: id8.optional(), externalId: text11.optional() }).refine((check3) => check3.id === void 0 !== (check3.externalId === void 0), { message: "name the record with id or with externalId, not both" })).optional()
|
|
102028
|
+
});
|
|
102029
|
+
var NetsuiteCountCheckSchema = external_exports.strictObject({ type: external_exports.enum(netsuiteRecordTypes), count: external_exports.number().int().min(0), includeSettlement: external_exports.boolean().optional() });
|
|
102026
102030
|
|
|
102027
102031
|
// packages/core/src/scene/schema.ts
|
|
102028
102032
|
var SUPPORTED_TWINS = ["slack", "github", "datadog", "pagerduty", "linkedin-ads", "salesforce", "gong", "hubspot", "ga4", "google-ads", "chatgpt-ads", "open-meteo", "google-drive", "gmail", "amazon-s3", "linear", "okta", "stripe", "clerk", "better-stack", "notion", "attio", "dropbox", "resend", "microsoft-word", "outlook", "shopify", "lob", "paypal", "jira", "kalshi", "intercom", "zendesk", "google-calendar", "twilio", "asana", "discord", "sentry", "airtable", "netsuite", "carrier-portal"];
|
|
@@ -107361,8 +107365,10 @@ var ANSWER_QUOTE = 300;
|
|
|
107361
107365
|
function finalAnswer(trace) {
|
|
107362
107366
|
const entry2 = trace.findLast((e) => e.source === "agent" && e.service === "agent" && e.path === "/done");
|
|
107363
107367
|
if (!entry2) return void 0;
|
|
107364
|
-
const
|
|
107365
|
-
|
|
107368
|
+
const request = typeof entry2.request === "object" && entry2.request !== null ? entry2.request : void 0;
|
|
107369
|
+
const output2 = typeof entry2.request === "string" ? entry2.request : request?.output;
|
|
107370
|
+
const source = request?.source === "reply" || request?.source === "stdout" ? request.source : "done";
|
|
107371
|
+
return { text: answerText(output2), seq: entry2.seq, source, ...typeof request?.printed === "number" && { printed: request.printed } };
|
|
107366
107372
|
}
|
|
107367
107373
|
function evaluateAnswer(check3, trace) {
|
|
107368
107374
|
const contains3 = asList(check3.contains), absent = asList(check3.not_contains), sensitive = check3.case === "sensitive";
|
|
@@ -107374,13 +107380,22 @@ function evaluateAnswer(check3, trace) {
|
|
|
107374
107380
|
];
|
|
107375
107381
|
const expected = parts3.length ? `the final answer ${parts3.join("; ")}` : "a final answer";
|
|
107376
107382
|
const answer = finalAnswer(trace);
|
|
107383
|
+
if (answer?.printed !== void 0) {
|
|
107384
|
+
return {
|
|
107385
|
+
passed: false,
|
|
107386
|
+
expected,
|
|
107387
|
+
actual: `${answer.printed.toLocaleString("en-US")} characters on stdout`,
|
|
107388
|
+
evidence: [answer.seq],
|
|
107389
|
+
explanation: `The agent printed ${answer.printed.toLocaleString("en-US")} characters on stdout, more than an answer can be, so it gave no final answer. An agent prints its logs on stderr, or posts its answer to ANCHA_DONE_URL, body {"output": <its answer>}.`
|
|
107390
|
+
};
|
|
107391
|
+
}
|
|
107377
107392
|
if (!answer || answer.text.trim() === "") {
|
|
107378
107393
|
return {
|
|
107379
107394
|
passed: false,
|
|
107380
107395
|
expected,
|
|
107381
107396
|
actual: answer ? "an empty final answer" : "no final answer",
|
|
107382
107397
|
evidence: answer ? [answer.seq] : [],
|
|
107383
|
-
explanation: `The agent gave ${answer ? "an empty" : "no"} final answer. An agent answers with a POST to ANCHA_DONE_URL, body {"output": <its answer>}, or by printing it
|
|
107398
|
+
explanation: `The agent gave ${answer ? "an empty" : "no"} final answer. An agent answers with a POST to ANCHA_DONE_URL, body {"output": <its answer>}, or by printing it on stdout.`
|
|
107384
107399
|
};
|
|
107385
107400
|
}
|
|
107386
107401
|
const text23 = comparableText(answer.text, sensitive);
|
|
@@ -107397,7 +107412,8 @@ function evaluateAnswer(check3, trace) {
|
|
|
107397
107412
|
const explanation = [
|
|
107398
107413
|
...missing6.length ? [`The final answer does not contain ${quoted2(missing6)}.`] : [],
|
|
107399
107414
|
...unstated.length ? [`It states no number within ${unstated.map((n2) => `${plainNumber(n2.tolerance)} of ${n2.written}`).join(", nor within ")}: ${said}.`] : [],
|
|
107400
|
-
...present2.length ? [`It contains ${quoted2(present2)}, which it must not.`] : []
|
|
107415
|
+
...present2.length ? [`It contains ${quoted2(present2)}, which it must not.`] : [],
|
|
107416
|
+
...answer.source === "stdout" ? ["Its answer is everything it printed on stdout."] : answer.source === "reply" ? ["Its answer is its HTTP reply."] : []
|
|
107401
107417
|
].join(" ");
|
|
107402
107418
|
return { passed: false, expected, actual, explanation, evidence: [answer.seq] };
|
|
107403
107419
|
}
|
|
@@ -123643,7 +123659,7 @@ var catalogRoutes3 = [
|
|
|
123643
123659
|
return json8({ elements: entities.filter((e) => e.facet === q.get("facet")).map((e) => ({ urn: e.urn, facetUrn: e.facet, name: e.name })) });
|
|
123644
123660
|
} }
|
|
123645
123661
|
];
|
|
123646
|
-
function
|
|
123662
|
+
function calendar2(raw3) {
|
|
123647
123663
|
const match3 = /^\((?:year:(\d{4}),month:(\d{1,2}),day:(\d{1,2})|day:(\d{1,2}),month:(\d{1,2}),year:(\d{4}))\)$/.exec(raw3);
|
|
123648
123664
|
if (!match3) invalid8("Date must be (year:YYYY,month:M,day:D) or (day:D,month:M,year:YYYY)");
|
|
123649
123665
|
const y = match3[1] ?? match3[6], m = match3[2] ?? match3[5], d = match3[3] ?? match3[4], date10 = `${y}-${m.padStart(2, "0")}-${d.padStart(2, "0")}`;
|
|
@@ -123665,7 +123681,7 @@ var analyticsRoutes = [{ method: "GET", path: "/rest/adAnalytics", notes: "analy
|
|
|
123665
123681
|
if (!["DAILY", "ALL"].includes(q.get("timeGranularity") ?? "")) gap2(`timeGranularity ${q.get("timeGranularity")}`);
|
|
123666
123682
|
const range2 = /^\(start:(\([^()]+\))(?:,end:(\([^()]+\)))?\)$/.exec(q.get("dateRange") ?? "");
|
|
123667
123683
|
if (!range2) invalid8("dateRange requires start and optional end tuples");
|
|
123668
|
-
const start =
|
|
123684
|
+
const start = calendar2(range2[1]), end = range2[2] ? calendar2(range2[2]) : c.env.ctx.clock.now().toISOString().slice(0, 10);
|
|
123669
123685
|
if (end < start) invalid8("dateRange.end precedes start");
|
|
123670
123686
|
const selectedFields2 = q.get("fields")?.split(",") ?? ["impressions", "clicks"];
|
|
123671
123687
|
const allowed2 = ["pivotValues", "dateRange", "impressions", "clicks", "oneClickLeads", "costInLocalCurrency"];
|
|
@@ -133843,9 +133859,9 @@ function seed21(ctx) {
|
|
|
133843
133859
|
entry2.resolved?.by ?? null
|
|
133844
133860
|
);
|
|
133845
133861
|
}
|
|
133846
|
-
for (const
|
|
133847
|
-
const users5 =
|
|
133848
|
-
db3.prepare("INSERT INTO bs_calendars (id, name, is_default, users) VALUES (?, ?, ?, ?)").run(nextId3(ctx, "calendar"),
|
|
133862
|
+
for (const calendar4 of input4.onCall) {
|
|
133863
|
+
const users5 = calendar4.users.map((email11) => db3.prepare("SELECT id FROM bs_users WHERE email = ?").get(email11).id);
|
|
133864
|
+
db3.prepare("INSERT INTO bs_calendars (id, name, is_default, users) VALUES (?, ?, ?, ?)").run(nextId3(ctx, "calendar"), calendar4.name, calendar4.default ? 1 : 0, JSON.stringify(users5));
|
|
133849
133865
|
}
|
|
133850
133866
|
for (const page18 of input4.statusPages) {
|
|
133851
133867
|
const id14 = nextId3(ctx, "page");
|
|
@@ -133901,9 +133917,9 @@ function dumpState20(ctx) {
|
|
|
133901
133917
|
resolvedBy: row2.resolved_by,
|
|
133902
133918
|
...row2.summary && { summary: row2.summary }
|
|
133903
133919
|
})),
|
|
133904
|
-
onCall: db3.prepare("SELECT * FROM bs_calendars ORDER BY rowid").all().map((
|
|
133905
|
-
name:
|
|
133906
|
-
users: JSON.parse(
|
|
133920
|
+
onCall: db3.prepare("SELECT * FROM bs_calendars ORDER BY rowid").all().map((calendar4) => ({
|
|
133921
|
+
name: calendar4.name,
|
|
133922
|
+
users: JSON.parse(calendar4.users).map((id14) => db3.prepare("SELECT email FROM bs_users WHERE id = ?").get(id14)?.email ?? id14)
|
|
133907
133923
|
})),
|
|
133908
133924
|
statusPages: db3.prepare("SELECT * FROM bs_pages ORDER BY rowid").all().map((page18) => ({
|
|
133909
133925
|
id: page18.id,
|
|
@@ -147324,7 +147340,7 @@ function feeFor(series2, count4, price3, taker) {
|
|
|
147324
147340
|
const exact = rate * series2.fee_multiplier * (count4 / 100) * (price3 / ONE) * (1 - price3 / ONE);
|
|
147325
147341
|
return Math.ceil(exact * 100 - 1e-9) * 1e4;
|
|
147326
147342
|
}
|
|
147327
|
-
function
|
|
147343
|
+
function ledger2(ctx, now11) {
|
|
147328
147344
|
const db3 = ctx.store.db, positions2 = /* @__PURE__ */ new Map();
|
|
147329
147345
|
let cash = db3.prepare("SELECT COALESCE(SUM(amount), 0) AS total FROM kx_deposits WHERE at_ms <= ?").get(now11).total;
|
|
147330
147346
|
for (const fill of db3.prepare("SELECT * FROM kx_fills WHERE created_ms <= ? ORDER BY created_ms, rowid").all(now11)) {
|
|
@@ -147363,7 +147379,7 @@ function ledger(ctx, now11) {
|
|
|
147363
147379
|
}
|
|
147364
147380
|
var collateral = (order5) => (order5.initial - order5.filled) * (order5.book_side === "bid" ? order5.price : ONE - order5.price);
|
|
147365
147381
|
function balances(ctx, now11) {
|
|
147366
|
-
const { cash, positions: positions2 } =
|
|
147382
|
+
const { cash, positions: positions2 } = ledger2(ctx, now11);
|
|
147367
147383
|
const held = restingOrders(ctx, now11).reduce((total2, order5) => total2 + collateral(order5), 0);
|
|
147368
147384
|
let value4 = 0;
|
|
147369
147385
|
for (const entry2 of positions2.values()) if (entry2.position) value4 += Math.abs(entry2.position) * (entry2.position > 0 ? getMarket(ctx, entry2.ticker).last_price : ONE - getMarket(ctx, entry2.ticker).last_price);
|
|
@@ -147408,7 +147424,7 @@ function seed32(ctx) {
|
|
|
147408
147424
|
});
|
|
147409
147425
|
});
|
|
147410
147426
|
input4.orders.forEach((entry2, i) => {
|
|
147411
|
-
const id14 = seededUuid(`order:${i}`), created3 = at3(entry2.created), series2 = seriesOfMarket(ctx, getMarket(ctx, entry2.market)), positionBefore =
|
|
147427
|
+
const id14 = seededUuid(`order:${i}`), created3 = at3(entry2.created), series2 = seriesOfMarket(ctx, getMarket(ctx, entry2.market)), positionBefore = ledger2(ctx, created3).positions.get(entry2.market)?.position ?? 0;
|
|
147412
147428
|
const legacy2 = legacySide(entry2.side, positionBefore);
|
|
147413
147429
|
db3.prepare(`INSERT INTO kx_orders (id, client_order_id, ticker, book_side, side, action, outcome_side, price, initial, filled, time_in_force, post_only, stp, cancel_on_pause, expiration_ms, created_ms, updated_ms, canceled_ms,
|
|
147414
147430
|
taker_cost, maker_cost, taker_fees, maker_fees) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, 0, 'taker_at_cross', 0, NULL, ?, ?, ?, 0, 0, 0, 0)`).run(id14, entry2.clientOrderId ?? null, entry2.market, entry2.side, legacy2.side, legacy2.action, legacy2.outcome, price3(entry2.price), count4(entry2.count), entry2.timeInForce, created3, created3, entry2.canceled === void 0 ? null : at3(entry2.canceled));
|
|
@@ -147889,7 +147905,7 @@ function positions(call2) {
|
|
|
147889
147905
|
choice2(settlement, "settlement_status", ["all", "settled", "unsettled"]);
|
|
147890
147906
|
for (const name5 of counts) choice2(name5, "count_filter", ["position", "total_traded"]);
|
|
147891
147907
|
const ticker2 = params10.get("ticker"), eventTicker = params10.get("event_ticker");
|
|
147892
|
-
const entries3 = [...
|
|
147908
|
+
const entries3 = [...ledger2(ctx, now11).positions.values()].filter((entry2) => {
|
|
147893
147909
|
const market2 = getMarket(ctx, entry2.ticker);
|
|
147894
147910
|
return (settlement === "all" || settlement === "settled" === (entry2.settlement !== void 0)) && (!ticker2 || entry2.ticker === ticker2) && (!eventTicker || market2.event === eventTicker) && (!counts.length || counts.some((name5) => name5 === "position" ? entry2.position !== 0 : entry2.traded !== 0));
|
|
147895
147911
|
});
|
|
@@ -147951,7 +147967,7 @@ function settlements(call2) {
|
|
|
147951
147967
|
const ctx = call2.ctx, now11 = ctx.clock.nowMs(), params10 = query9(call2, ["limit", "cursor", "ticker", "event_ticker", "min_ts", "max_ts", "subaccount"]), ticker2 = params10.get("ticker"), eventTicker = params10.get("event_ticker");
|
|
147952
147968
|
primary2(params10.get("subaccount"));
|
|
147953
147969
|
const within = timeRange2(params10, "min_ts", "max_ts");
|
|
147954
|
-
const rows7 = [...
|
|
147970
|
+
const rows7 = [...ledger2(ctx, now11).positions.values()].filter((entry2) => entry2.settlement && (!ticker2 || entry2.ticker === ticker2) && (!eventTicker || getMarket(ctx, entry2.ticker).event === eventTicker) && within(entry2.settlement.at)).sort((a, b) => b.settlement.at - a.settlement.at);
|
|
147955
147971
|
const result = page14(call2, rows7, 200, 100);
|
|
147956
147972
|
return json22({
|
|
147957
147973
|
settlements: result.items.map((entry2) => ({
|
|
@@ -163405,7 +163421,7 @@ function bindValue(value4) {
|
|
|
163405
163421
|
}
|
|
163406
163422
|
var pad2 = (n2, width = 2) => String(n2).padStart(width, "0");
|
|
163407
163423
|
var MONTHS2 = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
163408
|
-
function
|
|
163424
|
+
function calendar3(y, m, d) {
|
|
163409
163425
|
const date10 = /* @__PURE__ */ new Date(0);
|
|
163410
163426
|
date10.setUTCFullYear(y, m - 1, d);
|
|
163411
163427
|
date10.setUTCHours(0, 0, 0, 0);
|
|
@@ -163415,7 +163431,7 @@ function calendar2(y, m, d) {
|
|
|
163415
163431
|
function isoDate(text23) {
|
|
163416
163432
|
const match3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text23);
|
|
163417
163433
|
if (!match3) invalid24("Expected a YYYY-MM-DD world date.");
|
|
163418
|
-
|
|
163434
|
+
calendar3(+match3[1], +match3[2], +match3[3]);
|
|
163419
163435
|
return text23;
|
|
163420
163436
|
}
|
|
163421
163437
|
function dateModel(model) {
|
|
@@ -163455,7 +163471,7 @@ function parseDate2(value4, model) {
|
|
|
163455
163471
|
const values2 = new Map(tokens3.map((t, i) => [t, match3[i + 1]]));
|
|
163456
163472
|
if (!values2.has("YYYY") || !values2.has("DD") || !["MM", "MON", "MONTH"].some((t) => values2.has(t))) invalid24("TO_DATE requires year, month and day.", true);
|
|
163457
163473
|
const month = values2.has("MM") ? Number(values2.get("MM")) : MONTHS2.findIndex((m) => values2.has("MON") ? m.slice(0, 3).toLowerCase() === values2.get("MON").toLowerCase() : m.toLowerCase() === values2.get("MONTH").toLowerCase()) + 1;
|
|
163458
|
-
const date10 =
|
|
163474
|
+
const date10 = calendar3(Number(values2.get("YYYY")), month, Number(values2.get("DD")));
|
|
163459
163475
|
let hour2 = Number(values2.get("HH24") ?? values2.get("HH12") ?? values2.get("HH") ?? 0);
|
|
163460
163476
|
const minute2 = Number(values2.get("MI") ?? 0), second = Number(values2.get("SS") ?? 0);
|
|
163461
163477
|
if (values2.has("HH12") || values2.has("HH")) {
|
|
@@ -167296,14 +167312,29 @@ function record8(ctx, args) {
|
|
|
167296
167312
|
}
|
|
167297
167313
|
const applied = composite2 ? [...byLine.values()].sort((a, b) => a.doc - b.doc || a.line - b.line) : applications(ctx, id14).map((a) => ({ doc: a.doc, amount: a.amount })).sort((a, b) => a.doc - b.doc);
|
|
167298
167314
|
const wanted = args.apply?.map((a) => composite2 ? { ...a, line: a.line ?? 0 } : { ...a }).sort((a, b) => a.doc - b.doc || (a.line ?? 0) - (b.line ?? 0));
|
|
167299
|
-
|
|
167315
|
+
const creditLines = args.credit?.some((a) => a.line !== void 0);
|
|
167316
|
+
const credits = /* @__PURE__ */ new Map();
|
|
167317
|
+
for (const a of edges(ctx, id14).filter((a2) => a2.source !== id14)) {
|
|
167318
|
+
const key4 = creditLines ? `${a.source}:${a.sourceline}` : String(a.source);
|
|
167319
|
+
const item2 = credits.get(key4) ?? { doc: a.source, ...creditLines && { line: a.sourceline }, amount: 0 };
|
|
167320
|
+
item2.amount = Math.round((item2.amount + a.amount) * 100) / 100;
|
|
167321
|
+
credits.set(key4, item2);
|
|
167322
|
+
}
|
|
167323
|
+
const sort = (a, b) => a.doc - b.doc || (a.line ?? 0) - (b.line ?? 0);
|
|
167324
|
+
const credited = [...credits.values()].sort(sort);
|
|
167325
|
+
const wantedCredits = args.credit?.map((a) => creditLines ? { ...a, line: a.line ?? 0 } : { ...a }).sort(sort);
|
|
167326
|
+
const creditExpected = args.credit === void 0 ? "" : ` and credits ${JSON.stringify(args.credit)}`;
|
|
167327
|
+
return checkOutcome(matches8(actual, args.fields ?? {}) && (wanted === void 0 || isDeepStrictEqual(applied, wanted)) && (wantedCredits === void 0 || isDeepStrictEqual(credited, wantedCredits)), expected + creditExpected, JSON.stringify({ record: actual, apply: applied, credit: credited }));
|
|
167300
167328
|
}
|
|
167301
167329
|
function unchanged(ctx, args) {
|
|
167302
|
-
const
|
|
167303
|
-
|
|
167330
|
+
const allowed2 = (args.except ?? []).map((r2) => ({ type: r2.type, id: r2.id ?? byExternalId(ctx, r2.type, r2.externalId) }));
|
|
167331
|
+
const changes = sql(ctx).prepare("SELECT recordtype, id, operation FROM ns_history ORDER BY ordinal").all().filter((row2) => args.types.includes(row2.recordtype) && !allowed2.some((r2) => r2.type === row2.recordtype && r2.id === row2.id));
|
|
167332
|
+
const types = args.types.length >= netsuiteRecordTypes.length && netsuiteRecordTypes.every((type) => args.types.includes(type)) ? "NetSuite records" : args.types.length > 4 ? `${args.types.slice(0, 3).join(", ")} and ${args.types.length - 3} more record types` : args.types.join(", ");
|
|
167333
|
+
const except = args.except?.length ? ` except ${args.except.map((r2) => `${r2.type} ${r2.id ?? `eid:${r2.externalId}`}`).join(", ")}` : "";
|
|
167334
|
+
return checkOutcome(changes.length === 0, `no writes to ${types}${except}`, changes.length ? JSON.stringify(changes) : except ? "no other committed writes" : "no committed writes");
|
|
167304
167335
|
}
|
|
167305
167336
|
function count3(ctx, args) {
|
|
167306
|
-
const actual = recordIds(ctx, args.type).length;
|
|
167337
|
+
const actual = args.includeSettlement && isTx(args.type) ? sql(ctx).prepare("SELECT COUNT(*) AS count FROM ns_transactions WHERE recordtype = ?").get(args.type).count : recordIds(ctx, args.type).length;
|
|
167307
167338
|
return checkOutcome(actual === args.count, `${args.count} ${args.type} records`, `${actual} records`);
|
|
167308
167339
|
}
|
|
167309
167340
|
|
|
@@ -168807,8 +168838,9 @@ var TrialSessions = class {
|
|
|
168807
168838
|
});
|
|
168808
168839
|
}
|
|
168809
168840
|
/**
|
|
168810
|
-
* The runner records the agent's answer for it when the agent posted none (SPEC-053 F2): an HTTP agent's reply, or
|
|
168811
|
-
*
|
|
168841
|
+
* The runner records the agent's answer for it when the agent posted none (SPEC-053 F2): an HTTP agent's reply, or its
|
|
168842
|
+
* stdout (SPEC-056 A), or how much it printed when that is too long to be an answer. The same `POST /done` entry, with
|
|
168843
|
+
* that source; never a second answer.
|
|
168812
168844
|
*/
|
|
168813
168845
|
answer(env, id14, answer) {
|
|
168814
168846
|
return env.serialize(() => {
|
|
@@ -168816,7 +168848,7 @@ var TrialSessions = class {
|
|
|
168816
168848
|
if (state2 === "prepared") throw new AnchaError("SESSION_CONFLICT", "session has not started");
|
|
168817
168849
|
if (state2 === "finished") throw new AnchaError("SESSION_CONFLICT", "session has finished");
|
|
168818
168850
|
if (env.trace.list().some((entry2) => entry2.service === "agent" && entry2.path === "/done")) return { recorded: false };
|
|
168819
|
-
env.trace.record({ source: "agent", service: "agent", method: "POST", path: "/done", status: 200, request: { output: answer.output, source: answer.source } });
|
|
168851
|
+
env.trace.record({ source: "agent", service: "agent", method: "POST", path: "/done", status: 200, request: { output: answer.output, source: answer.source, ...answer.printed !== void 0 && { printed: answer.printed } } });
|
|
168820
168852
|
return { recorded: true };
|
|
168821
168853
|
});
|
|
168822
168854
|
}
|
|
@@ -169131,7 +169163,7 @@ function parseStartOptions(value4) {
|
|
|
169131
169163
|
if (input4.delivery !== void 0) parseOptions({ mode: "endpoint", delivery: input4.delivery });
|
|
169132
169164
|
return input4;
|
|
169133
169165
|
}
|
|
169134
|
-
var MAX_ANSWER_CHARS =
|
|
169166
|
+
var MAX_ANSWER_CHARS = 64 * 1024;
|
|
169135
169167
|
function sessionRoutes(opts, sessions) {
|
|
169136
169168
|
const app2 = new Hono3();
|
|
169137
169169
|
const token4 = (header3) => /^Bearer\s+(\S+)\s*$/i.exec(header3 ?? "")?.[1];
|
|
@@ -169165,10 +169197,13 @@ function sessionRoutes(opts, sessions) {
|
|
|
169165
169197
|
} catch {
|
|
169166
169198
|
throw new AnchaError("USAGE", "request must be a JSON object");
|
|
169167
169199
|
}
|
|
169168
|
-
fields10(input4, ["output", "source"]);
|
|
169200
|
+
fields10(input4, ["output", "source", "printed"]);
|
|
169169
169201
|
if (typeof input4.output !== "string" || input4.output.length > MAX_ANSWER_CHARS) throw new AnchaError("USAGE", `output must be a string of at most ${MAX_ANSWER_CHARS} characters`);
|
|
169170
169202
|
if (input4.source !== "reply" && input4.source !== "stdout") throw new AnchaError("USAGE", "source must be reply or stdout");
|
|
169171
|
-
|
|
169203
|
+
if (input4.printed !== void 0 && (input4.source !== "stdout" || input4.output !== "" || typeof input4.printed !== "number" || !Number.isSafeInteger(input4.printed) || input4.printed <= 0)) {
|
|
169204
|
+
throw new AnchaError("USAGE", "printed is how many characters stdout held, with source stdout and an empty output");
|
|
169205
|
+
}
|
|
169206
|
+
return c.json(await sessions.answer(opts.manager.get(c.req.param("id")), c.req.param("sid"), { output: input4.output, source: input4.source, ...input4.printed !== void 0 && { printed: input4.printed } }));
|
|
169172
169207
|
});
|
|
169173
169208
|
app2.post("/envs/:id/trials/:sid/agent", async (c) => {
|
|
169174
169209
|
let input4;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancha-labs/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.17",
|
|
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": {
|