@ancha-labs/cli 0.4.10 → 0.4.12
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/README.md +10 -10
- package/lib/ancha.mjs +8991 -5469
- package/lib/assets/SKILL.md +30 -27
- package/lib/assets/agents-section.md +21 -19
- package/lib/assets/docs/apps.md +8 -8
- package/lib/assets/docs/cloud.md +35 -32
- package/lib/assets/docs/compare.md +3 -3
- package/lib/assets/docs/explain.md +8 -6
- package/lib/assets/docs/run.md +13 -13
- package/lib/assets/docs/scenes.md +4 -4
- package/lib/assets/docs/setup.md +26 -24
- package/lib/assets/docs/traces.md +8 -7
- package/lib/assets/harbor/companion.mjs +19 -19
- package/lib/assets/llms.txt +6 -6
- package/lib/assets/ui/app.js +110 -35
- package/lib/assets/ui/style.css +5 -2
- package/lib/mcp-entry.mjs +15 -15
- package/lib/worker.mjs +704 -331
- package/lib/world-server.mjs +19 -19
- package/package.json +1 -1
package/lib/worker.mjs
CHANGED
|
@@ -5058,7 +5058,7 @@ function isRef(value4) {
|
|
|
5058
5058
|
function cloneIssues(issues) {
|
|
5059
5059
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
5060
5060
|
}
|
|
5061
|
-
function isRecursive(inst, stack,
|
|
5061
|
+
function isRecursive(inst, stack, resolve13) {
|
|
5062
5062
|
const cached3 = recursive.get(inst);
|
|
5063
5063
|
if (cached3 !== void 0)
|
|
5064
5064
|
return cached3 ? PROVEN : NONE;
|
|
@@ -5068,7 +5068,7 @@ function isRecursive(inst, stack, resolve12) {
|
|
|
5068
5068
|
let result = NONE;
|
|
5069
5069
|
const check3 = (child2) => {
|
|
5070
5070
|
if (result !== PROVEN && child2?._zod) {
|
|
5071
|
-
const answer = isRecursive(child2, stack,
|
|
5071
|
+
const answer = isRecursive(child2, stack, resolve13);
|
|
5072
5072
|
if (answer > result)
|
|
5073
5073
|
result = answer;
|
|
5074
5074
|
}
|
|
@@ -5079,7 +5079,7 @@ function isRecursive(inst, stack, resolve12) {
|
|
|
5079
5079
|
const desc = Object.getOwnPropertyDescriptor(sh, key4);
|
|
5080
5080
|
if (spread && !desc.enumerable)
|
|
5081
5081
|
continue;
|
|
5082
|
-
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
5082
|
+
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve13) : NONE;
|
|
5083
5083
|
if (child2 > answer)
|
|
5084
5084
|
answer = child2;
|
|
5085
5085
|
}
|
|
@@ -5143,7 +5143,7 @@ function isRecursive(inst, stack, resolve12) {
|
|
|
5143
5143
|
break;
|
|
5144
5144
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
5145
5145
|
case "lazy": {
|
|
5146
|
-
const inner = def._cachedInner ?? (
|
|
5146
|
+
const inner = def._cachedInner ?? (resolve13 ? inst._zod.innerType : void 0);
|
|
5147
5147
|
merge3(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
5148
5148
|
break;
|
|
5149
5149
|
}
|
|
@@ -22747,7 +22747,7 @@ var init_gmail = __esm({
|
|
|
22747
22747
|
} catch {
|
|
22748
22748
|
return false;
|
|
22749
22749
|
}
|
|
22750
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
22750
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -35m");
|
|
22751
22751
|
ref7 = external_exports.string().regex(/^[A-Za-z0-9_-]{1,80}$/);
|
|
22752
22752
|
attachment = external_exports.strictObject({
|
|
22753
22753
|
filename: external_exports.string().min(1).max(255),
|
|
@@ -23134,7 +23134,7 @@ var init_linear = __esm({
|
|
|
23134
23134
|
} catch {
|
|
23135
23135
|
return false;
|
|
23136
23136
|
}
|
|
23137
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
23137
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -2h");
|
|
23138
23138
|
zone3 = external_exports.string().max(100).refine((value4) => {
|
|
23139
23139
|
try {
|
|
23140
23140
|
new Intl.DateTimeFormat("en", { timeZone: value4 });
|
|
@@ -23683,11 +23683,11 @@ var init_stripe = __esm({
|
|
|
23683
23683
|
};
|
|
23684
23684
|
past = external_exports.string().refine(
|
|
23685
23685
|
(value4) => external_exports.iso.datetime({ offset: true }).safeParse(value4).success ? Number.isFinite(Date.parse(value4)) : isDuration(value4) && parseDuration(value4) <= 0,
|
|
23686
|
-
"expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
23686
|
+
"expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -720h"
|
|
23687
23687
|
);
|
|
23688
23688
|
moment = external_exports.string().refine(
|
|
23689
23689
|
(value4) => external_exports.iso.datetime({ offset: true }).safeParse(value4).success ? Number.isFinite(Date.parse(value4)) : isDuration(value4),
|
|
23690
|
-
"expected an ISO 8601 time with a timezone, or an offset from the
|
|
23690
|
+
"expected an ISO 8601 time with a timezone, or an offset from the start of the test such as 72h or -24h"
|
|
23691
23691
|
);
|
|
23692
23692
|
StripeSeedSchema = external_exports.strictObject({
|
|
23693
23693
|
account: external_exports.strictObject({ name: text8, currency: external_exports.enum(["usd", "eur", "gbp", "cad", "aud"]).default("usd"), statement_descriptor: external_exports.string().regex(/^[A-Za-z0-9 .-]{5,22}$/).optional() }),
|
|
@@ -24240,7 +24240,7 @@ var init_notion = __esm({
|
|
|
24240
24240
|
} catch {
|
|
24241
24241
|
return false;
|
|
24242
24242
|
}
|
|
24243
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
24243
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -8h");
|
|
24244
24244
|
day2 = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
24245
24245
|
block = external_exports.lazy(() => external_exports.strictObject({
|
|
24246
24246
|
type: external_exports.enum(NOTION_BLOCK_TYPES),
|
|
@@ -24549,7 +24549,7 @@ var init_attio = __esm({
|
|
|
24549
24549
|
} catch {
|
|
24550
24550
|
return false;
|
|
24551
24551
|
}
|
|
24552
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
24552
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -30h");
|
|
24553
24553
|
attribute = external_exports.strictObject({
|
|
24554
24554
|
api_slug: slug,
|
|
24555
24555
|
title: external_exports.string().min(1).max(100),
|
|
@@ -24831,7 +24831,7 @@ var init_resend = __esm({
|
|
|
24831
24831
|
};
|
|
24832
24832
|
past2 = external_exports.string().refine(
|
|
24833
24833
|
(v) => external_exports.iso.datetime({ offset: true }).safeParse(v).success ? Number.isFinite(Date.parse(v)) : isDuration2(v) && parseDuration(v) <= 0,
|
|
24834
|
-
"expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
24834
|
+
"expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -26h"
|
|
24835
24835
|
);
|
|
24836
24836
|
moment2 = external_exports.string().refine((v) => external_exports.iso.datetime({ offset: true }).safeParse(v).success ? Number.isFinite(Date.parse(v)) : isDuration2(v), "expected an ISO 8601 time or an offset such as 24h");
|
|
24837
24837
|
ResendSeedSchema = external_exports.strictObject({
|
|
@@ -25210,7 +25210,7 @@ var init_shopify = __esm({
|
|
|
25210
25210
|
} catch {
|
|
25211
25211
|
return false;
|
|
25212
25212
|
}
|
|
25213
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
25213
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -30h");
|
|
25214
25214
|
address3 = external_exports.strictObject({
|
|
25215
25215
|
first_name: external_exports.string().max(100).optional(),
|
|
25216
25216
|
last_name: external_exports.string().max(100).optional(),
|
|
@@ -25972,7 +25972,7 @@ var init_paypal = __esm({
|
|
|
25972
25972
|
} catch {
|
|
25973
25973
|
return false;
|
|
25974
25974
|
}
|
|
25975
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
25975
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -30h");
|
|
25976
25976
|
person = external_exports.strictObject({ first_name: external_exports.string().min(1).max(140), last_name: external_exports.string().min(1).max(140), email: external_exports.string().regex(EMAIL8) });
|
|
25977
25977
|
PayPalSeedSchema = external_exports.strictObject({
|
|
25978
25978
|
account: external_exports.strictObject({
|
|
@@ -26185,7 +26185,7 @@ var init_jira = __esm({
|
|
|
26185
26185
|
} catch {
|
|
26186
26186
|
return false;
|
|
26187
26187
|
}
|
|
26188
|
-
}, future ? "expected an ISO 8601 time with a timezone, or an offset from the
|
|
26188
|
+
}, future ? "expected an ISO 8601 time with a timezone, or an offset from the start of the test such as 7d" : "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -30h");
|
|
26189
26189
|
past5 = time3();
|
|
26190
26190
|
moment3 = time3(true);
|
|
26191
26191
|
JiraSeedSchema = external_exports.strictObject({
|
|
@@ -26746,7 +26746,7 @@ var init_intercom = __esm({
|
|
|
26746
26746
|
} catch {
|
|
26747
26747
|
return false;
|
|
26748
26748
|
}
|
|
26749
|
-
}, future ? "expected an ISO 8601 time with a timezone, or an offset from the
|
|
26749
|
+
}, future ? "expected an ISO 8601 time with a timezone, or an offset from the start of the test such as 1d" : "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -30h");
|
|
26750
26750
|
past6 = time4();
|
|
26751
26751
|
moment4 = time4(true);
|
|
26752
26752
|
IntercomSeedSchema = external_exports.strictObject({
|
|
@@ -27288,7 +27288,7 @@ var init_google_calendar = __esm({
|
|
|
27288
27288
|
};
|
|
27289
27289
|
time5 = (future) => external_exports.string().refine(
|
|
27290
27290
|
(v) => external_exports.iso.datetime({ offset: true }).safeParse(v).success ? Number.isFinite(Date.parse(v)) : offsetOk(v, future),
|
|
27291
|
-
future ? "expected an ISO 8601 time with an offset, or an offset from the
|
|
27291
|
+
future ? "expected an ISO 8601 time with an offset, or an offset from the start of the test such as 26h" : "expected an ISO 8601 time with an offset, or a nonpositive offset such as -30h"
|
|
27292
27292
|
);
|
|
27293
27293
|
past7 = time5(false);
|
|
27294
27294
|
moment5 = time5(true);
|
|
@@ -28056,7 +28056,7 @@ var init_sentry = __esm({
|
|
|
28056
28056
|
} catch {
|
|
28057
28057
|
return false;
|
|
28058
28058
|
}
|
|
28059
|
-
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the
|
|
28059
|
+
}, "expected an ISO 8601 time with a timezone, or a nonpositive offset from the start of the test such as -30h");
|
|
28060
28060
|
spacing = external_exports.string().refine((value4) => {
|
|
28061
28061
|
try {
|
|
28062
28062
|
return parseDuration(value4) > 0;
|
|
@@ -30395,7 +30395,7 @@ var init_netsuite = __esm({
|
|
|
30395
30395
|
positive = money6.refine((value4) => value4 > 0, "must be more than 0");
|
|
30396
30396
|
day5 = external_exports.string().refine(
|
|
30397
30397
|
(value4) => /^-?\d+d$/.test(value4) || /^\d{4}-\d{2}-\d{2}$/.test(value4) && (/* @__PURE__ */ new Date(`${value4}T00:00:00Z`)).toISOString().slice(0, 10) === value4,
|
|
30398
|
-
"expected YYYY-MM-DD or an offset in days from the
|
|
30398
|
+
"expected YYYY-MM-DD or an offset in days from the start of the test, e.g. -30d"
|
|
30399
30399
|
);
|
|
30400
30400
|
external = text11.optional();
|
|
30401
30401
|
custom2 = external_exports.record(external_exports.string().regex(/^cust(?:entity|body|col|item)[a-z0-9_]+$/), external_exports.union([external_exports.string().max(4e3), external_exports.number(), external_exports.boolean(), external_exports.null()])).optional();
|
|
@@ -31069,7 +31069,7 @@ var init_schema2 = __esm({
|
|
|
31069
31069
|
});
|
|
31070
31070
|
SceneToolSchema = external_exports.strictObject({
|
|
31071
31071
|
/** A JSON lines file next to the scene, one recorded call per line (`ancha run` reads it into `recorded`). */
|
|
31072
|
-
observations: external_exports.string().regex(/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\0]+$/, "a path relative to the
|
|
31072
|
+
observations: external_exports.string().regex(/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\0]+$/, "a path relative to the test file (scene.yaml), without ..").optional(),
|
|
31073
31073
|
recorded: external_exports.array(ToolObservationSchema).optional(),
|
|
31074
31074
|
/** Calls from other traces of this agent, so a simulated answer can follow how the tool behaved there. */
|
|
31075
31075
|
examples: external_exports.array(ToolExampleSchema).optional(),
|
|
@@ -39635,7 +39635,7 @@ function toolIssues(scene2) {
|
|
|
39635
39635
|
if (tool.unrecorded === "twin" && tool.twin === void 0) issues.push({ path: `${path6}.unrecorded`, message: "unrecorded: twin needs the twin that answers", hint: `set ${path6}.twin, e.g. twin: slack` });
|
|
39636
39636
|
if (tool.pure && tool.write) issues.push({ path: `${path6}.pure`, message: "a tool that changes something is not pure", hint: `remove ${path6}.pure, or ${path6}.write if it only computes from its arguments` });
|
|
39637
39637
|
if (tool.observations !== void 0 && tool.recorded === void 0) {
|
|
39638
|
-
issues.push({ path: `${path6}.observations`, message: `${tool.observations} was not read`, hint: "load the
|
|
39638
|
+
issues.push({ path: `${path6}.observations`, message: `${tool.observations} was not read`, hint: "load the test from its file (ancha run, ancha scene validate), which reads the recorded calls next to it" });
|
|
39639
39639
|
}
|
|
39640
39640
|
tool.recorded?.forEach((o, i) => {
|
|
39641
39641
|
if (o.tool !== name5) issues.push({ path: `${path6}.recorded[${i}].tool`, message: `a call to ${o.tool} recorded under ${name5}` });
|
|
@@ -39648,7 +39648,7 @@ function toolIssues(scene2) {
|
|
|
39648
39648
|
const patterns = check3.trace[key4] === void 0 ? [] : [].concat(check3.trace[key4]);
|
|
39649
39649
|
patterns.forEach((pattern) => {
|
|
39650
39650
|
const bare = /^([A-Za-z_][\w.-]{0,127})(?:\s+\{.*\})?$/s.exec(pattern.trim());
|
|
39651
|
-
if (bare && !scene2.tools[bare[1]]) issues.push({ path: `checks[${i}].trace.${key4}`, message: `${bare[1]} is not one of this
|
|
39651
|
+
if (bare && !scene2.tools[bare[1]]) issues.push({ path: `checks[${i}].trace.${key4}`, message: `${bare[1]} is not one of this test's tools`, hint: `the tools are ${Object.keys(scene2.tools).join(", ")}; an API call is "<METHOD> <PATH>"` });
|
|
39652
39652
|
});
|
|
39653
39653
|
}
|
|
39654
39654
|
});
|
|
@@ -39972,7 +39972,7 @@ function ruleIssues(scene2) {
|
|
|
39972
39972
|
if (scene2.world === "static" && scene2.world_rules !== void 0) {
|
|
39973
39973
|
issues.push({
|
|
39974
39974
|
path: "world_rules",
|
|
39975
|
-
message: "static
|
|
39975
|
+
message: "static tests cannot declare world rules",
|
|
39976
39976
|
hint: "set world: living, or remove world_rules"
|
|
39977
39977
|
});
|
|
39978
39978
|
}
|
|
@@ -40109,7 +40109,7 @@ function parseSceneYaml(text24) {
|
|
|
40109
40109
|
return { path: `line ${line2}, column ${col2}`, message: e.message };
|
|
40110
40110
|
});
|
|
40111
40111
|
const atError = doc.errors.findIndex((e) => text24[e.pos[0]] === "@");
|
|
40112
|
-
if (atError >= 0) issues[atError].hint = "
|
|
40112
|
+
if (atError >= 0) issues[atError].hint = "refs in a test use $, e.g. $alice \u2014 YAML reserves @";
|
|
40113
40113
|
throw sceneError(issues, doc.errors[0]);
|
|
40114
40114
|
}
|
|
40115
40115
|
const cut = cutProseIssues(doc, text24, lineCounter);
|
|
@@ -45198,14 +45198,14 @@ function inputRequiredRoundsExceededMessage(method2, maxRounds) {
|
|
|
45198
45198
|
return `Multi-round-trip request '${method2}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
45199
45199
|
}
|
|
45200
45200
|
function sleep(ms, signal) {
|
|
45201
|
-
return new Promise((
|
|
45201
|
+
return new Promise((resolve13, reject3) => {
|
|
45202
45202
|
if (signal?.aborted) {
|
|
45203
45203
|
reject3(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
45204
45204
|
return;
|
|
45205
45205
|
}
|
|
45206
45206
|
const timer = setTimeout(() => {
|
|
45207
45207
|
signal?.removeEventListener("abort", onAbort);
|
|
45208
|
-
|
|
45208
|
+
resolve13();
|
|
45209
45209
|
}, ms);
|
|
45210
45210
|
const onAbort = () => {
|
|
45211
45211
|
clearTimeout(timer);
|
|
@@ -47069,7 +47069,7 @@ var init_src_DdvbAHrR = __esm({
|
|
|
47069
47069
|
const flowStartedAt = Date.now();
|
|
47070
47070
|
let onAbort;
|
|
47071
47071
|
let cleanupMessageId;
|
|
47072
|
-
return new Promise((
|
|
47072
|
+
return new Promise((resolve13, reject3) => {
|
|
47073
47073
|
const earlyReject = (error64) => {
|
|
47074
47074
|
reject3(error64);
|
|
47075
47075
|
};
|
|
@@ -47138,7 +47138,7 @@ var init_src_DdvbAHrR = __esm({
|
|
|
47138
47138
|
}
|
|
47139
47139
|
if (decoded.kind === "invalid") return reject3(decoded.error);
|
|
47140
47140
|
if (decoded.kind === "input_required") {
|
|
47141
|
-
if (options4?.allowInputRequired === true) return
|
|
47141
|
+
if (options4?.allowInputRequired === true) return resolve13(manualInputRequiredValue(decoded));
|
|
47142
47142
|
const flow = {
|
|
47143
47143
|
codec: codec2,
|
|
47144
47144
|
request: request2,
|
|
@@ -47150,11 +47150,11 @@ var init_src_DdvbAHrR = __esm({
|
|
|
47150
47150
|
params: params10
|
|
47151
47151
|
}, resultSchema, legOptions)
|
|
47152
47152
|
};
|
|
47153
|
-
return
|
|
47153
|
+
return resolve13(this._resolveNonCompleteResult(decoded, flow));
|
|
47154
47154
|
}
|
|
47155
47155
|
const result = decoded.result;
|
|
47156
47156
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
47157
|
-
if (parseResult.success)
|
|
47157
|
+
if (parseResult.success) resolve13(parseResult.data);
|
|
47158
47158
|
else reject3(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
47159
47159
|
}, reject3);
|
|
47160
47160
|
});
|
|
@@ -49941,7 +49941,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
49941
49941
|
ref22 = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref22);
|
|
49942
49942
|
const schOrFunc = root3.refs[ref22];
|
|
49943
49943
|
if (schOrFunc) return schOrFunc;
|
|
49944
|
-
let _sch =
|
|
49944
|
+
let _sch = resolve13.call(this, root3, ref22);
|
|
49945
49945
|
if (_sch === void 0) {
|
|
49946
49946
|
const schema = (_a7 = root3.localRefs) === null || _a7 === void 0 ? void 0 : _a7[ref22];
|
|
49947
49947
|
const { schemaId } = this.opts;
|
|
@@ -49967,7 +49967,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
49967
49967
|
function sameSchemaEnv(s1, s2) {
|
|
49968
49968
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
49969
49969
|
}
|
|
49970
|
-
function
|
|
49970
|
+
function resolve13(root3, ref22) {
|
|
49971
49971
|
let sch;
|
|
49972
49972
|
while (typeof (sch = this.refs[ref22]) == "string") ref22 = sch;
|
|
49973
49973
|
return sch || this.schemas[ref22] || resolveSchema.call(this, root3, ref22);
|
|
@@ -50662,7 +50662,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
50662
50662
|
else if (typeof uri === "object") uri = parse14(serialize2(uri, options4), options4);
|
|
50663
50663
|
return uri;
|
|
50664
50664
|
}
|
|
50665
|
-
function
|
|
50665
|
+
function resolve13(baseURI, relativeURI, options4) {
|
|
50666
50666
|
const schemelessOptions = options4 ? Object.assign({ scheme: "null" }, options4) : { scheme: "null" };
|
|
50667
50667
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
|
|
50668
50668
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -50677,41 +50677,41 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
50677
50677
|
schemelessOptions.skipEscape = true;
|
|
50678
50678
|
return serialize2(resolved, schemelessOptions);
|
|
50679
50679
|
}
|
|
50680
|
-
function resolveComponent(base3,
|
|
50680
|
+
function resolveComponent(base3, relative7, options4, skipNormalization) {
|
|
50681
50681
|
const target4 = {};
|
|
50682
50682
|
if (!skipNormalization) {
|
|
50683
50683
|
base3 = parse14(serialize2(base3, options4), options4);
|
|
50684
|
-
|
|
50684
|
+
relative7 = parse14(serialize2(relative7, options4), options4);
|
|
50685
50685
|
}
|
|
50686
50686
|
options4 = options4 || {};
|
|
50687
|
-
if (!options4.tolerant &&
|
|
50688
|
-
target4.scheme =
|
|
50689
|
-
target4.userinfo =
|
|
50690
|
-
target4.host =
|
|
50691
|
-
target4.port =
|
|
50692
|
-
target4.path = removeDotSegments(
|
|
50693
|
-
target4.query =
|
|
50687
|
+
if (!options4.tolerant && relative7.scheme) {
|
|
50688
|
+
target4.scheme = relative7.scheme;
|
|
50689
|
+
target4.userinfo = relative7.userinfo;
|
|
50690
|
+
target4.host = relative7.host;
|
|
50691
|
+
target4.port = relative7.port;
|
|
50692
|
+
target4.path = removeDotSegments(relative7.path || "");
|
|
50693
|
+
target4.query = relative7.query;
|
|
50694
50694
|
} else {
|
|
50695
|
-
if (
|
|
50696
|
-
target4.userinfo =
|
|
50697
|
-
target4.host =
|
|
50698
|
-
target4.port =
|
|
50699
|
-
target4.path = removeDotSegments(
|
|
50700
|
-
target4.query =
|
|
50695
|
+
if (relative7.userinfo !== void 0 || relative7.host !== void 0 || relative7.port !== void 0) {
|
|
50696
|
+
target4.userinfo = relative7.userinfo;
|
|
50697
|
+
target4.host = relative7.host;
|
|
50698
|
+
target4.port = relative7.port;
|
|
50699
|
+
target4.path = removeDotSegments(relative7.path || "");
|
|
50700
|
+
target4.query = relative7.query;
|
|
50701
50701
|
} else {
|
|
50702
|
-
if (!
|
|
50702
|
+
if (!relative7.path) {
|
|
50703
50703
|
target4.path = base3.path;
|
|
50704
|
-
if (
|
|
50704
|
+
if (relative7.query !== void 0) target4.query = relative7.query;
|
|
50705
50705
|
else target4.query = base3.query;
|
|
50706
50706
|
} else {
|
|
50707
|
-
if (
|
|
50707
|
+
if (relative7.path[0] === "/") target4.path = removeDotSegments(relative7.path);
|
|
50708
50708
|
else {
|
|
50709
|
-
if ((base3.userinfo !== void 0 || base3.host !== void 0 || base3.port !== void 0) && !base3.path) target4.path = "/" +
|
|
50710
|
-
else if (!base3.path) target4.path =
|
|
50711
|
-
else target4.path = base3.path.slice(0, base3.path.lastIndexOf("/") + 1) +
|
|
50709
|
+
if ((base3.userinfo !== void 0 || base3.host !== void 0 || base3.port !== void 0) && !base3.path) target4.path = "/" + relative7.path;
|
|
50710
|
+
else if (!base3.path) target4.path = relative7.path;
|
|
50711
|
+
else target4.path = base3.path.slice(0, base3.path.lastIndexOf("/") + 1) + relative7.path;
|
|
50712
50712
|
target4.path = removeDotSegments(target4.path);
|
|
50713
50713
|
}
|
|
50714
|
-
target4.query =
|
|
50714
|
+
target4.query = relative7.query;
|
|
50715
50715
|
}
|
|
50716
50716
|
target4.userinfo = base3.userinfo;
|
|
50717
50717
|
target4.host = base3.host;
|
|
@@ -50719,7 +50719,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
50719
50719
|
}
|
|
50720
50720
|
target4.scheme = base3.scheme;
|
|
50721
50721
|
}
|
|
50722
|
-
target4.fragment =
|
|
50722
|
+
target4.fragment = relative7.fragment;
|
|
50723
50723
|
return target4;
|
|
50724
50724
|
}
|
|
50725
50725
|
function equal3(uriA, uriB, options4) {
|
|
@@ -50944,7 +50944,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
50944
50944
|
const fastUri = {
|
|
50945
50945
|
SCHEMES,
|
|
50946
50946
|
normalize: normalize2,
|
|
50947
|
-
resolve:
|
|
50947
|
+
resolve: resolve13,
|
|
50948
50948
|
resolveComponent,
|
|
50949
50949
|
equal: equal3,
|
|
50950
50950
|
serialize: serialize2,
|
|
@@ -54808,9 +54808,9 @@ function validateScopeChallenge(challenge) {
|
|
|
54808
54808
|
if (challenge.errorDescription !== void 0 && !/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(challenge.errorDescription)) throw new TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");
|
|
54809
54809
|
return challenge;
|
|
54810
54810
|
}
|
|
54811
|
-
async function findScopeChallenge(requests, authInfo,
|
|
54811
|
+
async function findScopeChallenge(requests, authInfo, resolve13) {
|
|
54812
54812
|
for (const request2 of requests) {
|
|
54813
|
-
const challenge = await
|
|
54813
|
+
const challenge = await resolve13({
|
|
54814
54814
|
request: request2,
|
|
54815
54815
|
...authInfo !== void 0 && { authInfo }
|
|
54816
54816
|
});
|
|
@@ -55029,15 +55029,15 @@ var init_mcp_oHn3ureC = __esm({
|
|
|
55029
55029
|
};
|
|
55030
55030
|
if (isJSONRPCRequest(message7)) {
|
|
55031
55031
|
this._requestId = message7.id;
|
|
55032
|
-
let
|
|
55032
|
+
let resolve13;
|
|
55033
55033
|
let reject3;
|
|
55034
55034
|
const promise2 = new Promise((promiseResolve, promiseReject) => {
|
|
55035
|
-
|
|
55035
|
+
resolve13 = promiseResolve;
|
|
55036
55036
|
reject3 = promiseReject;
|
|
55037
55037
|
});
|
|
55038
55038
|
this._deferredResponse = {
|
|
55039
55039
|
promise: promise2,
|
|
55040
|
-
resolve:
|
|
55040
|
+
resolve: resolve13,
|
|
55041
55041
|
reject: reject3,
|
|
55042
55042
|
settled: false
|
|
55043
55043
|
};
|
|
@@ -57559,9 +57559,9 @@ data:
|
|
|
57559
57559
|
const streamId = crypto.randomUUID();
|
|
57560
57560
|
const initRequest = messages2.find((m) => isInitializeRequest(m));
|
|
57561
57561
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
57562
|
-
if (this._enableJsonResponse) return new Promise((
|
|
57562
|
+
if (this._enableJsonResponse) return new Promise((resolve13) => {
|
|
57563
57563
|
this._streamMapping.set(streamId, {
|
|
57564
|
-
resolveJson:
|
|
57564
|
+
resolveJson: resolve13,
|
|
57565
57565
|
cleanup: () => {
|
|
57566
57566
|
this._streamMapping.delete(streamId);
|
|
57567
57567
|
}
|
|
@@ -61448,13 +61448,13 @@ function reviewCommentShape(ctx, repo4, row) {
|
|
|
61448
61448
|
const url4 = apiUrl(ctx, `${repoPath(repo4)}/pulls/comments/${row.id}`), pull2 = apiUrl(ctx, `${repoPath(repo4)}/pulls/${row.pull_number}`), html2 = `https://github.com/${repo4.full_name}/pull/${row.pull_number}#discussion_r${row.id}`;
|
|
61449
61449
|
return { id: row.id, node_id: nodeId("PullRequestReviewComment", row.id), pull_request_review_id: row.review_id, url: url4, html_url: html2, pull_request_url: pull2, user: userShape(ctx, getUser(ctx, row.user_id)), body: row.body, diff_hunk: row.diff_hunk, path: row.path, commit_id: row.commit_sha, original_commit_id: row.commit_sha, line: row.line, original_line: row.line, side: row.side, start_line: null, original_start_line: null, start_side: null, ...row.in_reply_to_id !== null && { in_reply_to_id: row.in_reply_to_id }, created_at: row.created_at, updated_at: row.updated_at, author_association: "NONE", _links: { self: { href: url4 }, html: { href: html2 }, pull_request: { href: pull2 } } };
|
|
61450
61450
|
}
|
|
61451
|
-
function resourceUserShape(ctx, user8,
|
|
61452
|
-
const result = userShape(
|
|
61453
|
-
if (
|
|
61451
|
+
function resourceUserShape(ctx, user8, relative7 = false) {
|
|
61452
|
+
const result = userShape(relative7 ? { ...ctx, serviceUrl: "https://ancha.invalid" } : ctx, user8);
|
|
61453
|
+
if (relative7) for (const key4 of ["url", "followers_url", "following_url", "gists_url", "starred_url", "subscriptions_url", "organizations_url", "repos_url", "events_url", "received_events_url"]) result[key4] = result[key4].slice("https://ancha.invalid".length);
|
|
61454
61454
|
return result;
|
|
61455
61455
|
}
|
|
61456
|
-
function resourceUrl(ctx, path6,
|
|
61457
|
-
return
|
|
61456
|
+
function resourceUrl(ctx, path6, relative7 = false) {
|
|
61457
|
+
return relative7 ? path6 : apiUrl(ctx, path6);
|
|
61458
61458
|
}
|
|
61459
61459
|
var segment, repoPath, nodeId;
|
|
61460
61460
|
var init_shapes = __esm({
|
|
@@ -61939,13 +61939,13 @@ function requireDeployment(ctx, repoId, id14) {
|
|
|
61939
61939
|
if (!row) throw new GitHubError(404, "Not Found");
|
|
61940
61940
|
return row;
|
|
61941
61941
|
}
|
|
61942
|
-
function deploymentShape(ctx, repo4, row,
|
|
61942
|
+
function deploymentShape(ctx, repo4, row, relative7 = false) {
|
|
61943
61943
|
const path6 = `${repoPath(repo4)}/deployments/${row.id}`, data5 = JSON.parse(row.json);
|
|
61944
|
-
return { ...data5, id: row.id, node_id: Buffer.from(`Deployment:${row.id}`).toString("base64"), sha: row.sha, ref: row.ref, environment: row.environment, creator: resourceUserShape(ctx, getUser(ctx, row.user_id),
|
|
61944
|
+
return { ...data5, id: row.id, node_id: Buffer.from(`Deployment:${row.id}`).toString("base64"), sha: row.sha, ref: row.ref, environment: row.environment, creator: resourceUserShape(ctx, getUser(ctx, row.user_id), relative7), created_at: row.created_at, updated_at: row.created_at, url: resourceUrl(ctx, path6, relative7), statuses_url: resourceUrl(ctx, `${path6}/statuses`, relative7), repository_url: resourceUrl(ctx, repoPath(repo4), relative7) };
|
|
61945
61945
|
}
|
|
61946
|
-
function deploymentStatusShape(ctx, repo4, deployment, row,
|
|
61946
|
+
function deploymentStatusShape(ctx, repo4, deployment, row, relative7 = false) {
|
|
61947
61947
|
const path6 = `${repoPath(repo4)}/deployments/${deployment.id}`;
|
|
61948
|
-
return { ...JSON.parse(row.json), id: row.id, node_id: Buffer.from(`DeploymentStatus:${row.id}`).toString("base64"), state: row.state, creator: resourceUserShape(ctx, botUser(ctx),
|
|
61948
|
+
return { ...JSON.parse(row.json), id: row.id, node_id: Buffer.from(`DeploymentStatus:${row.id}`).toString("base64"), state: row.state, creator: resourceUserShape(ctx, botUser(ctx), relative7), created_at: row.created_at, updated_at: row.created_at, environment: deployment.environment, url: resourceUrl(ctx, `${path6}/statuses/${row.id}`, relative7), deployment_url: resourceUrl(ctx, path6, relative7), repository_url: resourceUrl(ctx, repoPath(repo4), relative7) };
|
|
61949
61949
|
}
|
|
61950
61950
|
function insertDeployment(ctx, repo4, sha2, ref22, environment2, data5 = {}) {
|
|
61951
61951
|
return withMutation(ctx, () => {
|
|
@@ -62055,11 +62055,11 @@ function requireRun(ctx, repoId, runId) {
|
|
|
62055
62055
|
if (!row) throw new GitHubError(404, "Not Found");
|
|
62056
62056
|
return row;
|
|
62057
62057
|
}
|
|
62058
|
-
function workflowRunShape(ctx, repo4, row,
|
|
62058
|
+
function workflowRunShape(ctx, repo4, row, relative7 = false) {
|
|
62059
62059
|
const workflow = ctx.store.db.prepare("SELECT * FROM github_workflows WHERE repo_id = ? AND id = ?").get(repo4.id, row.workflow_id);
|
|
62060
|
-
const path6 = `${repoPath(repo4)}/actions/runs/${row.id}`, commit = getCommit(ctx, repo4.id, row.head_sha), actor2 = resourceUserShape(ctx, botUser(ctx),
|
|
62061
|
-
const link6 = (suffix) => resourceUrl(ctx, `${path6}/${suffix}`,
|
|
62062
|
-
const repository2 = repositoryShape(
|
|
62060
|
+
const path6 = `${repoPath(repo4)}/actions/runs/${row.id}`, commit = getCommit(ctx, repo4.id, row.head_sha), actor2 = resourceUserShape(ctx, botUser(ctx), relative7);
|
|
62061
|
+
const link6 = (suffix) => resourceUrl(ctx, `${path6}/${suffix}`, relative7);
|
|
62062
|
+
const repository2 = repositoryShape(relative7 ? githubEventContext(ctx) : ctx, repo4);
|
|
62063
62063
|
return {
|
|
62064
62064
|
id: row.id,
|
|
62065
62065
|
node_id: Buffer.from(`WorkflowRun:${row.id}`).toString("base64"),
|
|
@@ -62079,16 +62079,16 @@ function workflowRunShape(ctx, repo4, row, relative6 = false) {
|
|
|
62079
62079
|
actor: actor2,
|
|
62080
62080
|
triggering_actor: actor2,
|
|
62081
62081
|
display_title: commit.message.split("\n")[0],
|
|
62082
|
-
url: resourceUrl(ctx, path6,
|
|
62082
|
+
url: resourceUrl(ctx, path6, relative7),
|
|
62083
62083
|
html_url: `https://github.com/${repo4.full_name}/actions/runs/${row.id}`,
|
|
62084
62084
|
pull_requests: [],
|
|
62085
62085
|
jobs_url: link6("jobs"),
|
|
62086
62086
|
logs_url: link6("logs"),
|
|
62087
|
-
check_suite_url: resourceUrl(ctx, `${repoPath(repo4)}/check-suites/${row.id}`,
|
|
62087
|
+
check_suite_url: resourceUrl(ctx, `${repoPath(repo4)}/check-suites/${row.id}`, relative7),
|
|
62088
62088
|
artifacts_url: link6("artifacts"),
|
|
62089
62089
|
cancel_url: link6("cancel"),
|
|
62090
62090
|
rerun_url: link6("rerun"),
|
|
62091
|
-
workflow_url: resourceUrl(ctx, `${repoPath(repo4)}/actions/workflows/${workflow.id}`,
|
|
62091
|
+
workflow_url: resourceUrl(ctx, `${repoPath(repo4)}/actions/workflows/${workflow.id}`, relative7),
|
|
62092
62092
|
repository: repository2,
|
|
62093
62093
|
head_repository: repository2,
|
|
62094
62094
|
head_commit: { id: row.head_sha, tree_id: commit.tree, message: commit.message, timestamp: commit.at, author: commit.author, committer: commit.author }
|
|
@@ -67170,7 +67170,7 @@ function matches(integration2, event3) {
|
|
|
67170
67170
|
return on.includes(type) || event3.action !== void 0 && on.includes(`${type}.${event3.action}`);
|
|
67171
67171
|
}
|
|
67172
67172
|
function renderContext(env) {
|
|
67173
|
-
const
|
|
67173
|
+
const resolve13 = (ref22, kind) => {
|
|
67174
67174
|
try {
|
|
67175
67175
|
return env.refs.tryResolve(ref22, kind);
|
|
67176
67176
|
} catch {
|
|
@@ -67178,9 +67178,9 @@ function renderContext(env) {
|
|
|
67178
67178
|
}
|
|
67179
67179
|
};
|
|
67180
67180
|
return {
|
|
67181
|
-
resolve:
|
|
67181
|
+
resolve: resolve13,
|
|
67182
67182
|
openIssueByTitle: (repoRef, title2) => {
|
|
67183
|
-
const repo4 =
|
|
67183
|
+
const repo4 = resolve13(repoRef, "repo");
|
|
67184
67184
|
if (repo4 === void 0) return void 0;
|
|
67185
67185
|
return env.store.db.prepare("SELECT number FROM github_issues WHERE repo_id = ? AND title = ? AND state = 'open' AND is_pull = 0 ORDER BY number LIMIT 1").get(Number(repo4), title2)?.number;
|
|
67186
67186
|
},
|
|
@@ -67387,13 +67387,13 @@ function aggregateValues(values2, aggregation) {
|
|
|
67387
67387
|
}
|
|
67388
67388
|
function resolveQueryRange(from, to, nowMs) {
|
|
67389
67389
|
if (!Number.isFinite(nowMs)) invalid3("invalid captured query time");
|
|
67390
|
-
const
|
|
67390
|
+
const resolve13 = (text24) => {
|
|
67391
67391
|
if (text24 === "now") return Math.floor(nowMs);
|
|
67392
|
-
const
|
|
67393
|
-
if (
|
|
67392
|
+
const relative7 = /^now-(.+)$/.exec(text24);
|
|
67393
|
+
if (relative7) {
|
|
67394
67394
|
let duration9;
|
|
67395
67395
|
try {
|
|
67396
|
-
duration9 = /^[1-9]\d*d$/.test(
|
|
67396
|
+
duration9 = /^[1-9]\d*d$/.test(relative7[1]) ? Number(relative7[1].slice(0, -1)) * MAX_QUERY_WINDOW_MS : parseDuration(relative7[1]);
|
|
67397
67397
|
} catch {
|
|
67398
67398
|
return invalid3("invalid relative query duration");
|
|
67399
67399
|
}
|
|
@@ -67407,7 +67407,7 @@ function resolveQueryRange(from, to, nowMs) {
|
|
|
67407
67407
|
if (date10.toISOString().slice(0, 10) !== absolute2[1]) return invalid3("invalid ISO calendar date");
|
|
67408
67408
|
return value4;
|
|
67409
67409
|
};
|
|
67410
|
-
const fromMs =
|
|
67410
|
+
const fromMs = resolve13(from), toMs = resolve13(to);
|
|
67411
67411
|
checkRange(fromMs, toMs);
|
|
67412
67412
|
return { fromMs, toMs };
|
|
67413
67413
|
}
|
|
@@ -68933,7 +68933,7 @@ async function fetchPost(url4, body6, headers, signal) {
|
|
|
68933
68933
|
return { status: response5.status, headers: Object.fromEntries(response5.headers), text: Buffer.concat(chunks).toString("utf8") };
|
|
68934
68934
|
}
|
|
68935
68935
|
function socketPost(socketPath) {
|
|
68936
|
-
return (url4, body6, headers, signal) => new Promise((
|
|
68936
|
+
return (url4, body6, headers, signal) => new Promise((resolve13, reject3) => {
|
|
68937
68937
|
const req = httpRequest({ socketPath, path: new URL(url4).pathname, method: "POST", headers: { ...headers, host: "relay", "content-length": Buffer.byteLength(body6) }, signal }, (res) => {
|
|
68938
68938
|
let text24 = "", bytes2 = 0;
|
|
68939
68939
|
res.setEncoding("utf8");
|
|
@@ -68948,7 +68948,7 @@ function socketPost(socketPath) {
|
|
|
68948
68948
|
}
|
|
68949
68949
|
text24 += chunk;
|
|
68950
68950
|
});
|
|
68951
|
-
res.on("end", () =>
|
|
68951
|
+
res.on("end", () => resolve13({ status: res.statusCode ?? 0, headers: Object.fromEntries(Object.entries(res.headers).map(([k, v]) => [k, String(v)])), text: text24 }));
|
|
68952
68952
|
res.on("error", reject3);
|
|
68953
68953
|
});
|
|
68954
68954
|
req.on("error", reject3);
|
|
@@ -69110,8 +69110,8 @@ var init_model = __esm({
|
|
|
69110
69110
|
if (code2 !== void 0) this.code = code2;
|
|
69111
69111
|
}
|
|
69112
69112
|
};
|
|
69113
|
-
defaultSleep = (ms, signal) => new Promise((
|
|
69114
|
-
const timer = setTimeout(
|
|
69113
|
+
defaultSleep = (ms, signal) => new Promise((resolve13, reject3) => {
|
|
69114
|
+
const timer = setTimeout(resolve13, ms);
|
|
69115
69115
|
signal.addEventListener("abort", () => {
|
|
69116
69116
|
clearTimeout(timer);
|
|
69117
69117
|
reject3(signal.reason);
|
|
@@ -71458,8 +71458,8 @@ var init_env = __esm({
|
|
|
71458
71458
|
this.world.freeze();
|
|
71459
71459
|
this.#draining = true;
|
|
71460
71460
|
const disposals = this.#stop();
|
|
71461
|
-
const drain = this.#active === 0 ? Promise.resolve() : new Promise((
|
|
71462
|
-
this.#freeze = new Promise((
|
|
71461
|
+
const drain = this.#active === 0 ? Promise.resolve() : new Promise((resolve13) => this.#drained.add(resolve13));
|
|
71462
|
+
this.#freeze = new Promise((resolve13, reject3) => {
|
|
71463
71463
|
const timer = setTimeout(() => fail6(new AnchaError("INTERNAL", "environment request drain exceeded 5000ms")), 5e3);
|
|
71464
71464
|
timer.unref();
|
|
71465
71465
|
const fail6 = (error64) => {
|
|
@@ -71474,7 +71474,7 @@ var init_env = __esm({
|
|
|
71474
71474
|
Promise.all([drain, ...disposals]).then(() => {
|
|
71475
71475
|
clearTimeout(timer);
|
|
71476
71476
|
this.#draining = false;
|
|
71477
|
-
|
|
71477
|
+
resolve13();
|
|
71478
71478
|
}, fail6);
|
|
71479
71479
|
});
|
|
71480
71480
|
return this.#freeze;
|
|
@@ -72845,7 +72845,7 @@ var require_aspromise = __commonJS({
|
|
|
72845
72845
|
var params10 = new Array(arguments.length - 1), offset17 = 0, index = 2, pending = true;
|
|
72846
72846
|
while (index < arguments.length)
|
|
72847
72847
|
params10[offset17++] = arguments[index++];
|
|
72848
|
-
return new Promise(function executor(
|
|
72848
|
+
return new Promise(function executor(resolve13, reject3) {
|
|
72849
72849
|
params10[offset17] = function callback(err2) {
|
|
72850
72850
|
if (pending) {
|
|
72851
72851
|
pending = false;
|
|
@@ -72855,7 +72855,7 @@ var require_aspromise = __commonJS({
|
|
|
72855
72855
|
var params11 = new Array(arguments.length - 1), offset18 = 0;
|
|
72856
72856
|
while (offset18 < params11.length)
|
|
72857
72857
|
params11[offset18++] = arguments[offset18];
|
|
72858
|
-
|
|
72858
|
+
resolve13.apply(null, params11);
|
|
72859
72859
|
}
|
|
72860
72860
|
}
|
|
72861
72861
|
};
|
|
@@ -75415,7 +75415,7 @@ var require_path = __commonJS({
|
|
|
75415
75415
|
return prefix2 + parts3.join("/");
|
|
75416
75416
|
}
|
|
75417
75417
|
);
|
|
75418
|
-
path6.resolve = function
|
|
75418
|
+
path6.resolve = function resolve13(originPath, includePath, alreadyNormalized) {
|
|
75419
75419
|
if (!alreadyNormalized)
|
|
75420
75420
|
includePath = normalize2(includePath);
|
|
75421
75421
|
if (isAbsolute4(includePath))
|
|
@@ -75772,7 +75772,7 @@ var require_mapfield = __commonJS({
|
|
|
75772
75772
|
keepComments ? this.comment : void 0
|
|
75773
75773
|
]);
|
|
75774
75774
|
};
|
|
75775
|
-
MapField.prototype.resolve = function
|
|
75775
|
+
MapField.prototype.resolve = function resolve13() {
|
|
75776
75776
|
if (this.resolved)
|
|
75777
75777
|
return this;
|
|
75778
75778
|
if (types.mapKey[this.keyType] === void 0)
|
|
@@ -75849,7 +75849,7 @@ var require_method = __commonJS({
|
|
|
75849
75849
|
this.parsedOptions
|
|
75850
75850
|
]);
|
|
75851
75851
|
};
|
|
75852
|
-
Method.prototype.resolve = function
|
|
75852
|
+
Method.prototype.resolve = function resolve13() {
|
|
75853
75853
|
if (this.resolved)
|
|
75854
75854
|
return this;
|
|
75855
75855
|
this.resolvedRequestType = this.parent.lookupType(this.requestType);
|
|
@@ -77467,7 +77467,7 @@ var require_field = __commonJS({
|
|
|
77467
77467
|
keepComments ? this.comment : void 0
|
|
77468
77468
|
]);
|
|
77469
77469
|
};
|
|
77470
|
-
Field.prototype.resolve = function
|
|
77470
|
+
Field.prototype.resolve = function resolve13() {
|
|
77471
77471
|
if (this.resolved)
|
|
77472
77472
|
return this;
|
|
77473
77473
|
if ((this.typeDefault = types.defaults[this.type]) === void 0) {
|
|
@@ -77740,7 +77740,7 @@ var require_object = __commonJS({
|
|
|
77740
77740
|
this.parent = null;
|
|
77741
77741
|
this.resolved = false;
|
|
77742
77742
|
};
|
|
77743
|
-
ReflectionObject.prototype.resolve = function
|
|
77743
|
+
ReflectionObject.prototype.resolve = function resolve13() {
|
|
77744
77744
|
if (this.resolved)
|
|
77745
77745
|
return this;
|
|
77746
77746
|
if (this.root instanceof Root)
|
|
@@ -82622,7 +82622,7 @@ var require_call_credentials = __commonJS({
|
|
|
82622
82622
|
if (isCurrentOauth2Client(googleCredentials)) {
|
|
82623
82623
|
getHeaders = googleCredentials.getRequestHeaders(options4.service_url);
|
|
82624
82624
|
} else {
|
|
82625
|
-
getHeaders = new Promise((
|
|
82625
|
+
getHeaders = new Promise((resolve13, reject3) => {
|
|
82626
82626
|
googleCredentials.getRequestMetadata(options4.service_url, (err2, headers) => {
|
|
82627
82627
|
if (err2) {
|
|
82628
82628
|
reject3(err2);
|
|
@@ -82632,7 +82632,7 @@ var require_call_credentials = __commonJS({
|
|
|
82632
82632
|
reject3(new Error("Headers not set by metadata plugin"));
|
|
82633
82633
|
return;
|
|
82634
82634
|
}
|
|
82635
|
-
|
|
82635
|
+
resolve13(headers);
|
|
82636
82636
|
});
|
|
82637
82637
|
});
|
|
82638
82638
|
}
|
|
@@ -82688,10 +82688,10 @@ var require_call_credentials = __commonJS({
|
|
|
82688
82688
|
this.metadataGenerator = metadataGenerator;
|
|
82689
82689
|
}
|
|
82690
82690
|
generateMetadata(options4) {
|
|
82691
|
-
return new Promise((
|
|
82691
|
+
return new Promise((resolve13, reject3) => {
|
|
82692
82692
|
this.metadataGenerator(options4, (err2, metadata7) => {
|
|
82693
82693
|
if (metadata7 !== void 0) {
|
|
82694
|
-
|
|
82694
|
+
resolve13(metadata7);
|
|
82695
82695
|
} else {
|
|
82696
82696
|
reject3(err2);
|
|
82697
82697
|
}
|
|
@@ -83076,14 +83076,14 @@ var require_channel_credentials = __commonJS({
|
|
|
83076
83076
|
}
|
|
83077
83077
|
connect(socket) {
|
|
83078
83078
|
const tlsConnectOptions = Object.assign({ socket }, this.connectionOptions);
|
|
83079
|
-
return new Promise((
|
|
83079
|
+
return new Promise((resolve13, reject3) => {
|
|
83080
83080
|
const tlsSocket = (0, tls_1.connect)(tlsConnectOptions, () => {
|
|
83081
83081
|
var _a7;
|
|
83082
83082
|
if (((_a7 = this.connectionOptions.rejectUnauthorized) !== null && _a7 !== void 0 ? _a7 : true) && !tlsSocket.authorized) {
|
|
83083
83083
|
reject3(tlsSocket.authorizationError);
|
|
83084
83084
|
return;
|
|
83085
83085
|
}
|
|
83086
|
-
|
|
83086
|
+
resolve13({
|
|
83087
83087
|
socket: tlsSocket,
|
|
83088
83088
|
secure: true
|
|
83089
83089
|
});
|
|
@@ -83202,8 +83202,8 @@ var require_channel_credentials = __commonJS({
|
|
|
83202
83202
|
if (this.hasReceivedUpdates()) {
|
|
83203
83203
|
return Promise.resolve(this.getLatestSecureContext());
|
|
83204
83204
|
} else {
|
|
83205
|
-
return new Promise((
|
|
83206
|
-
this.secureContextWatchers.push(
|
|
83205
|
+
return new Promise((resolve13) => {
|
|
83206
|
+
this.secureContextWatchers.push(resolve13);
|
|
83207
83207
|
});
|
|
83208
83208
|
}
|
|
83209
83209
|
}
|
|
@@ -83236,7 +83236,7 @@ var require_channel_credentials = __commonJS({
|
|
|
83236
83236
|
this.callCredentials = callCredentials;
|
|
83237
83237
|
}
|
|
83238
83238
|
connect(socket) {
|
|
83239
|
-
return new Promise((
|
|
83239
|
+
return new Promise((resolve13, reject3) => {
|
|
83240
83240
|
const secureContext = this.parent.getLatestSecureContext();
|
|
83241
83241
|
if (!secureContext) {
|
|
83242
83242
|
reject3(new Error("Failed to load credentials"));
|
|
@@ -83261,7 +83261,7 @@ var require_channel_credentials = __commonJS({
|
|
|
83261
83261
|
reject3(tlsSocket.authorizationError);
|
|
83262
83262
|
return;
|
|
83263
83263
|
}
|
|
83264
|
-
|
|
83264
|
+
resolve13({
|
|
83265
83265
|
socket: tlsSocket,
|
|
83266
83266
|
secure: true
|
|
83267
83267
|
});
|
|
@@ -87176,18 +87176,18 @@ var require_compression_filter = __commonJS({
|
|
|
87176
87176
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
87177
87177
|
}
|
|
87178
87178
|
compressMessage(message7) {
|
|
87179
|
-
return new Promise((
|
|
87179
|
+
return new Promise((resolve13, reject3) => {
|
|
87180
87180
|
zlib.deflate(message7, (err2, output2) => {
|
|
87181
87181
|
if (err2) {
|
|
87182
87182
|
reject3(err2);
|
|
87183
87183
|
} else {
|
|
87184
|
-
|
|
87184
|
+
resolve13(output2);
|
|
87185
87185
|
}
|
|
87186
87186
|
});
|
|
87187
87187
|
});
|
|
87188
87188
|
}
|
|
87189
87189
|
decompressMessage(message7) {
|
|
87190
|
-
return new Promise((
|
|
87190
|
+
return new Promise((resolve13, reject3) => {
|
|
87191
87191
|
let totalLength = 0;
|
|
87192
87192
|
const messageParts = [];
|
|
87193
87193
|
const decompresser = zlib.createInflate();
|
|
@@ -87209,7 +87209,7 @@ var require_compression_filter = __commonJS({
|
|
|
87209
87209
|
}
|
|
87210
87210
|
});
|
|
87211
87211
|
decompresser.on("end", () => {
|
|
87212
|
-
|
|
87212
|
+
resolve13(Buffer.concat(messageParts));
|
|
87213
87213
|
});
|
|
87214
87214
|
decompresser.write(message7);
|
|
87215
87215
|
decompresser.end();
|
|
@@ -87222,18 +87222,18 @@ var require_compression_filter = __commonJS({
|
|
|
87222
87222
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
87223
87223
|
}
|
|
87224
87224
|
compressMessage(message7) {
|
|
87225
|
-
return new Promise((
|
|
87225
|
+
return new Promise((resolve13, reject3) => {
|
|
87226
87226
|
zlib.gzip(message7, (err2, output2) => {
|
|
87227
87227
|
if (err2) {
|
|
87228
87228
|
reject3(err2);
|
|
87229
87229
|
} else {
|
|
87230
|
-
|
|
87230
|
+
resolve13(output2);
|
|
87231
87231
|
}
|
|
87232
87232
|
});
|
|
87233
87233
|
});
|
|
87234
87234
|
}
|
|
87235
87235
|
decompressMessage(message7) {
|
|
87236
|
-
return new Promise((
|
|
87236
|
+
return new Promise((resolve13, reject3) => {
|
|
87237
87237
|
let totalLength = 0;
|
|
87238
87238
|
const messageParts = [];
|
|
87239
87239
|
const decompresser = zlib.createGunzip();
|
|
@@ -87255,7 +87255,7 @@ var require_compression_filter = __commonJS({
|
|
|
87255
87255
|
}
|
|
87256
87256
|
});
|
|
87257
87257
|
decompresser.on("end", () => {
|
|
87258
|
-
|
|
87258
|
+
resolve13(Buffer.concat(messageParts));
|
|
87259
87259
|
});
|
|
87260
87260
|
decompresser.write(message7);
|
|
87261
87261
|
decompresser.end();
|
|
@@ -88605,7 +88605,7 @@ var require_http_proxy = __commonJS({
|
|
|
88605
88605
|
options4.headers = headers;
|
|
88606
88606
|
const proxyAddressString = (0, subchannel_address_1.subchannelAddressToString)(address8);
|
|
88607
88607
|
trace("Using proxy " + proxyAddressString + " to connect to " + options4.path);
|
|
88608
|
-
return new Promise((
|
|
88608
|
+
return new Promise((resolve13, reject3) => {
|
|
88609
88609
|
const request2 = http.request(options4);
|
|
88610
88610
|
request2.once("connect", (res, socket, head) => {
|
|
88611
88611
|
request2.removeAllListeners();
|
|
@@ -88616,7 +88616,7 @@ var require_http_proxy = __commonJS({
|
|
|
88616
88616
|
socket.unshift(head);
|
|
88617
88617
|
}
|
|
88618
88618
|
trace("Successfully established a plaintext connection to " + options4.path + " through proxy " + proxyAddressString);
|
|
88619
|
-
|
|
88619
|
+
resolve13(socket);
|
|
88620
88620
|
} else {
|
|
88621
88621
|
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, "Failed to connect to " + options4.path + " through proxy " + proxyAddressString + " with status " + res.statusCode);
|
|
88622
88622
|
reject3();
|
|
@@ -89599,7 +89599,7 @@ var require_transport = __commonJS({
|
|
|
89599
89599
|
if (secureConnectResult.socket.closed) {
|
|
89600
89600
|
return Promise.reject("Connection closed before starting HTTP/2 handshake");
|
|
89601
89601
|
}
|
|
89602
|
-
return new Promise((
|
|
89602
|
+
return new Promise((resolve13, reject3) => {
|
|
89603
89603
|
var _a7, _b, _c, _d, _e, _f, _g, _h;
|
|
89604
89604
|
let remoteName = null;
|
|
89605
89605
|
let realTarget = this.channelTarget;
|
|
@@ -89670,7 +89670,7 @@ var require_transport = __commonJS({
|
|
|
89670
89670
|
session2.removeAllListeners();
|
|
89671
89671
|
secureConnectResult.socket.removeListener("close", closeHandler);
|
|
89672
89672
|
secureConnectResult.socket.removeListener("error", errorHandler2);
|
|
89673
|
-
|
|
89673
|
+
resolve13(new Http2Transport(session2, address8, options4, remoteName));
|
|
89674
89674
|
this.session = null;
|
|
89675
89675
|
});
|
|
89676
89676
|
session2.once("close", closeHandler);
|
|
@@ -89684,7 +89684,7 @@ var require_transport = __commonJS({
|
|
|
89684
89684
|
if (proxiedSocket) {
|
|
89685
89685
|
return proxiedSocket;
|
|
89686
89686
|
} else {
|
|
89687
|
-
return new Promise((
|
|
89687
|
+
return new Promise((resolve13, reject3) => {
|
|
89688
89688
|
const closeCallback = () => {
|
|
89689
89689
|
reject3(new Error("Socket closed"));
|
|
89690
89690
|
};
|
|
@@ -89694,7 +89694,7 @@ var require_transport = __commonJS({
|
|
|
89694
89694
|
const socket = net.connect(address8, () => {
|
|
89695
89695
|
socket.removeListener("close", closeCallback);
|
|
89696
89696
|
socket.removeListener("error", errorCallback);
|
|
89697
|
-
|
|
89697
|
+
resolve13(socket);
|
|
89698
89698
|
});
|
|
89699
89699
|
socket.once("close", closeCallback);
|
|
89700
89700
|
socket.once("error", errorCallback);
|
|
@@ -93135,7 +93135,7 @@ var require_server_interceptors = __commonJS({
|
|
|
93135
93135
|
} else {
|
|
93136
93136
|
decompresser = zlib.createGunzip();
|
|
93137
93137
|
}
|
|
93138
|
-
return new Promise((
|
|
93138
|
+
return new Promise((resolve13, reject3) => {
|
|
93139
93139
|
let totalLength = 0;
|
|
93140
93140
|
const messageParts = [];
|
|
93141
93141
|
decompresser.on("error", (error64) => {
|
|
@@ -93156,7 +93156,7 @@ var require_server_interceptors = __commonJS({
|
|
|
93156
93156
|
}
|
|
93157
93157
|
});
|
|
93158
93158
|
decompresser.on("end", () => {
|
|
93159
|
-
|
|
93159
|
+
resolve13(Buffer.concat(messageParts));
|
|
93160
93160
|
});
|
|
93161
93161
|
decompresser.write(messageContents);
|
|
93162
93162
|
decompresser.end();
|
|
@@ -93767,10 +93767,10 @@ var require_server = __commonJS({
|
|
|
93767
93767
|
bindOneAddress(address8, boundPortObject) {
|
|
93768
93768
|
this.trace("Attempting to bind " + (0, subchannel_address_1.subchannelAddressToString)(address8));
|
|
93769
93769
|
const http2Server = this.createHttp2Server(boundPortObject.credentials);
|
|
93770
|
-
return new Promise((
|
|
93770
|
+
return new Promise((resolve13, reject3) => {
|
|
93771
93771
|
const onError = (err2) => {
|
|
93772
93772
|
this.trace("Failed to bind " + (0, subchannel_address_1.subchannelAddressToString)(address8) + " with error " + err2.message);
|
|
93773
|
-
|
|
93773
|
+
resolve13({
|
|
93774
93774
|
port: "port" in address8 ? address8.port : 1,
|
|
93775
93775
|
error: err2.message
|
|
93776
93776
|
});
|
|
@@ -93798,7 +93798,7 @@ var require_server = __commonJS({
|
|
|
93798
93798
|
});
|
|
93799
93799
|
boundPortObject.listeningServers.add(http2Server);
|
|
93800
93800
|
this.trace("Successfully bound " + (0, subchannel_address_1.subchannelAddressToString)(boundSubchannelAddress));
|
|
93801
|
-
|
|
93801
|
+
resolve13({
|
|
93802
93802
|
port: "port" in boundSubchannelAddress ? boundSubchannelAddress.port : 1
|
|
93803
93803
|
});
|
|
93804
93804
|
http2Server.removeListener("error", onError);
|
|
@@ -93851,7 +93851,7 @@ var require_server = __commonJS({
|
|
|
93851
93851
|
}
|
|
93852
93852
|
}
|
|
93853
93853
|
resolvePort(port) {
|
|
93854
|
-
return new Promise((
|
|
93854
|
+
return new Promise((resolve13, reject3) => {
|
|
93855
93855
|
let seenResolution = false;
|
|
93856
93856
|
const resolverListener = (endpointList, attributes2, serviceConfig, resolutionNote) => {
|
|
93857
93857
|
if (seenResolution) {
|
|
@@ -93867,7 +93867,7 @@ var require_server = __commonJS({
|
|
|
93867
93867
|
reject3(new Error(`No addresses resolved for port ${port}`));
|
|
93868
93868
|
return true;
|
|
93869
93869
|
}
|
|
93870
|
-
|
|
93870
|
+
resolve13(addressList);
|
|
93871
93871
|
return true;
|
|
93872
93872
|
};
|
|
93873
93873
|
const resolver = (0, resolver_1.createResolver)(port, resolverListener, this.options);
|
|
@@ -97144,7 +97144,7 @@ async function startGoogleAdsGrpc(env) {
|
|
|
97144
97144
|
}
|
|
97145
97145
|
native2.addService(serviceDefinition(service), handlers);
|
|
97146
97146
|
}
|
|
97147
|
-
const innerPort = await new Promise((
|
|
97147
|
+
const innerPort = await new Promise((resolve13, reject3) => native2.bindAsync("127.0.0.1:0", grpc.ServerCredentials.createInsecure(), (err2, port2) => err2 ? reject3(err2) : resolve13(port2)));
|
|
97148
97148
|
const proxy = connect(`http://127.0.0.1:${innerPort}`);
|
|
97149
97149
|
proxy.on("error", () => {
|
|
97150
97150
|
});
|
|
@@ -97256,11 +97256,11 @@ async function startGoogleAdsGrpc(env) {
|
|
|
97256
97256
|
stream.pipe(upstream);
|
|
97257
97257
|
upstream.pipe(stream);
|
|
97258
97258
|
});
|
|
97259
|
-
await new Promise((
|
|
97259
|
+
await new Promise((resolve13, reject3) => {
|
|
97260
97260
|
front.once("error", reject3);
|
|
97261
97261
|
front.listen(0, "127.0.0.1", () => {
|
|
97262
97262
|
front.off("error", reject3);
|
|
97263
|
-
|
|
97263
|
+
resolve13();
|
|
97264
97264
|
});
|
|
97265
97265
|
}).catch((e) => {
|
|
97266
97266
|
proxy.destroy();
|
|
@@ -97279,7 +97279,7 @@ async function startGoogleAdsGrpc(env) {
|
|
|
97279
97279
|
s2.destroy();
|
|
97280
97280
|
proxy.destroy();
|
|
97281
97281
|
native2.forceShutdown();
|
|
97282
|
-
await new Promise((
|
|
97282
|
+
await new Promise((resolve13) => front.close(() => resolve13()));
|
|
97283
97283
|
})();
|
|
97284
97284
|
return closing;
|
|
97285
97285
|
} };
|
|
@@ -109374,9 +109374,9 @@ var require_lexer2 = __commonJS({
|
|
|
109374
109374
|
}
|
|
109375
109375
|
if (code2 === 92) {
|
|
109376
109376
|
value4 += body6.slice(chunkStart, position);
|
|
109377
|
-
const
|
|
109378
|
-
value4 +=
|
|
109379
|
-
position +=
|
|
109377
|
+
const escape11 = body6.charCodeAt(position + 1) === 117 ? body6.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
|
|
109378
|
+
value4 += escape11.value;
|
|
109379
|
+
position += escape11.size;
|
|
109380
109380
|
chunkStart = position;
|
|
109381
109381
|
continue;
|
|
109382
109382
|
}
|
|
@@ -122791,7 +122791,7 @@ var require_graphql = __commonJS({
|
|
|
122791
122791
|
var _validate2 = require_validate3();
|
|
122792
122792
|
var _execute = require_execute();
|
|
122793
122793
|
function graphql(args) {
|
|
122794
|
-
return new Promise((
|
|
122794
|
+
return new Promise((resolve13) => resolve13(graphqlImpl(args)));
|
|
122795
122795
|
}
|
|
122796
122796
|
function graphqlSync(args) {
|
|
122797
122797
|
const result = graphqlImpl(args);
|
|
@@ -137782,9 +137782,9 @@ function scheduleTime(r2, value4) {
|
|
|
137782
137782
|
if (value4 === void 0 || value4 === null) invalid16("Missing `scheduled_at` field.", "missing_required_field");
|
|
137783
137783
|
if (typeof value4 !== "string") invalid16("The `scheduled_at` field must be a string.");
|
|
137784
137784
|
const now11 = r2.ctx.clock.nowMs(), text24 = value4.trim();
|
|
137785
|
-
const
|
|
137785
|
+
const relative7 = /^in\s+(\d{1,6})\s+(min|minute|hr|hour|day|week)s?$/i.exec(text24);
|
|
137786
137786
|
const iso22 = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/i.exec(text24);
|
|
137787
|
-
const ms =
|
|
137787
|
+
const ms = relative7 ? now11 + Number(relative7[1]) * UNIT_MS[relative7[2].toLowerCase()] : iso22 ? Date.parse(iso22[1] && !iso22[2] ? `${text24}Z` : text24) : unsupported20(`scheduled_at in natural language ("${text24}")`);
|
|
137788
137788
|
if (!Number.isFinite(ms)) invalid16("The `scheduled_at` field must be a valid date.");
|
|
137789
137789
|
if (ms <= now11) invalid16("The `scheduled_at` field must be a date in the future.");
|
|
137790
137790
|
if (ms > now11 + 30 * 864e5) invalid16("The `scheduled_at` field must be within the next 30 days.");
|
|
@@ -138854,9 +138854,9 @@ function freeName(ctx, parentId, name5) {
|
|
|
138854
138854
|
if (!childNamed(ctx, parentId, candidate)) return candidate;
|
|
138855
138855
|
}
|
|
138856
138856
|
}
|
|
138857
|
-
function walk(call2, from,
|
|
138857
|
+
function walk(call2, from, relative7) {
|
|
138858
138858
|
let node5 = from;
|
|
138859
|
-
for (const part of
|
|
138859
|
+
for (const part of relative7.split("/").filter(Boolean)) node5 = node5 && childNamed(call2.ctx, node5.id, part);
|
|
138860
138860
|
return node5;
|
|
138861
138861
|
}
|
|
138862
138862
|
function ensureFolder(call2, from, parts3) {
|
|
@@ -140169,14 +140169,14 @@ async function handle17(c) {
|
|
|
140169
140169
|
if (!item2) throw new GraphError(404, "itemNotFound", "The resource could not be found.");
|
|
140170
140170
|
remaining = remaining.slice(byId2[0].length);
|
|
140171
140171
|
}
|
|
140172
|
-
let
|
|
140172
|
+
let relative7;
|
|
140173
140173
|
if (remaining.startsWith(":/")) {
|
|
140174
140174
|
const end = remaining.indexOf(":", 2);
|
|
140175
|
-
|
|
140175
|
+
relative7 = decodeURIComponent(end === -1 ? remaining.slice(2) : remaining.slice(2, end));
|
|
140176
140176
|
remaining = end === -1 ? "" : remaining.slice(end + 1);
|
|
140177
140177
|
} else if (remaining === ":") remaining = "";
|
|
140178
140178
|
const action = remaining.replace(/^\//, "");
|
|
140179
|
-
return itemRoute({ ctx, method: method2, url: url4, item: item2, relative:
|
|
140179
|
+
return itemRoute({ ctx, method: method2, url: url4, item: item2, relative: relative7, action, body: raw3, json: body6, headers: c.req.raw.headers });
|
|
140180
140180
|
});
|
|
140181
140181
|
} catch (error64) {
|
|
140182
140182
|
if (ctx.signal?.aborted) return new Response(null, { status: 409 });
|
|
@@ -145850,9 +145850,9 @@ function evaluate2(q, w2) {
|
|
|
145850
145850
|
if (!found2) throw new JqlError(/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(text24) ? `An issue with key '${text24.toUpperCase()}' does not exist for field '${field6}'.` : `The issue key '${text24}' for field '${field6}' is invalid.`);
|
|
145851
145851
|
return found2.id;
|
|
145852
145852
|
};
|
|
145853
|
-
const one7 = (
|
|
145853
|
+
const one7 = (resolve13) => (v) => {
|
|
145854
145854
|
const t = literal2(v, "");
|
|
145855
|
-
return t === null ? [] : [
|
|
145855
|
+
return t === null ? [] : [resolve13(t)];
|
|
145856
145856
|
};
|
|
145857
145857
|
const users5 = (field6, get5) => ({ kind: "set", get: (i) => get5(i).filter((x) => x !== null), resolve: (v) => {
|
|
145858
145858
|
if (v.kind === "func") {
|
|
@@ -150249,9 +150249,9 @@ function parseQuery2(query10) {
|
|
|
150249
150249
|
return terms;
|
|
150250
150250
|
}
|
|
150251
150251
|
function dateMatches(ms, term2, now11) {
|
|
150252
|
-
const
|
|
150253
|
-
if (
|
|
150254
|
-
const edge = now11 - Number(
|
|
150252
|
+
const relative7 = /^(\d+)(minute|hour|day|week|month|year)s?$/i.exec(term2.value);
|
|
150253
|
+
if (relative7) {
|
|
150254
|
+
const edge = now11 - Number(relative7[1]) * UNITS3[relative7[2].toLowerCase()];
|
|
150255
150255
|
return term2.op === ">" || term2.op === ">=" || term2.op === ":" ? ms >= edge : ms < edge;
|
|
150256
150256
|
}
|
|
150257
150257
|
const date10 = /^\d{4}-\d{2}-\d{2}$/.test(term2.value) ? Date.parse(`${term2.value}T00:00:00Z`) : Date.parse(term2.value);
|
|
@@ -155954,9 +155954,9 @@ function matches6(f2, value4, now11) {
|
|
|
155954
155954
|
if (f2.key === "message" || f2.key === "title") return f2.values.some((v) => v.includes("*") ? glob2(v, value4, true) : value4.toLowerCase().includes(v.toLowerCase()));
|
|
155955
155955
|
return f2.values.some((v) => glob2(v, value4, caseless));
|
|
155956
155956
|
}
|
|
155957
|
-
function eventTest(filters, text24, lookup6, now11,
|
|
155957
|
+
function eventTest(filters, text24, lookup6, now11, resolve13 = (f2) => f2) {
|
|
155958
155958
|
return (e) => filters.every((raw3) => {
|
|
155959
|
-
const f2 =
|
|
155959
|
+
const f2 = resolve13(raw3, e);
|
|
155960
155960
|
if (f2.key === "has") return f2.values.every((k) => {
|
|
155961
155961
|
const v = eventValue(e, k, lookup6);
|
|
155962
155962
|
return v !== null && v !== "" && !(Array.isArray(v) && !v.length);
|
|
@@ -163136,9 +163136,9 @@ function formatNumber(value4, model) {
|
|
|
163136
163136
|
}
|
|
163137
163137
|
return (number7 < 0 ? "-" : " ") + result.padStart(spec.integer.length + (spec.decimals ? spec.decimals.length + 1 : 0), " ");
|
|
163138
163138
|
}
|
|
163139
|
-
function like(value4, pattern, ...
|
|
163140
|
-
if (value4 == null || pattern == null ||
|
|
163141
|
-
const esc2 =
|
|
163139
|
+
function like(value4, pattern, ...escape11) {
|
|
163140
|
+
if (value4 == null || pattern == null || escape11.length > 0 && escape11[0] == null) return null;
|
|
163141
|
+
const esc2 = escape11.length ? Array.from(String(escape11[0])) : void 0;
|
|
163142
163142
|
if (esc2 && esc2.length !== 1) invalid24("The LIKE escape character must be one character.");
|
|
163143
163143
|
const mask2 = [], chars = Array.from(String(pattern));
|
|
163144
163144
|
for (let k = 0; k < chars.length; k++) {
|
|
@@ -163834,8 +163834,8 @@ var init_suiteql = __esm({
|
|
|
163834
163834
|
this.need(")");
|
|
163835
163835
|
left = this.node({ kind: "in", arg: left, query: query10, values: query10 ? void 0 : values2, not: negated });
|
|
163836
163836
|
} else if (actual === "like") {
|
|
163837
|
-
const pattern = this.expr(prec + 1),
|
|
163838
|
-
left = this.node({ kind: "like", arg: left, pattern, escape:
|
|
163837
|
+
const pattern = this.expr(prec + 1), escape11 = this.eat("escape") ? this.expr(prec + 1) : void 0;
|
|
163838
|
+
left = this.node({ kind: "like", arg: left, pattern, escape: escape11, not: negated });
|
|
163839
163839
|
} else left = this.node({ kind: "binary", op: actual, left, right: this.expr(prec + 1) });
|
|
163840
163840
|
}
|
|
163841
163841
|
this.depth--;
|
|
@@ -164774,8 +164774,8 @@ var init_suiteql_executor = __esm({
|
|
|
164774
164774
|
const free = this.#slots.size < this.#options.workers || [...this.#slots].some((s2) => !s2.job && !s2.terminating);
|
|
164775
164775
|
const active2 = [...this.#slots].some((s2) => s2.job?.ctx.store === ctx.store);
|
|
164776
164776
|
if ((!free || active2) && this.#queue.length >= this.#options.queue) return Promise.reject(new NetsuiteError(429, "CONCURRENCY_LIMIT_EXCEEDED", "Query execution queue is full."));
|
|
164777
|
-
return new Promise((
|
|
164778
|
-
const job = { ctx, query: query10, page: page18, mapped, params: params10, prepare: prepare2, resolve:
|
|
164777
|
+
return new Promise((resolve13, reject3) => {
|
|
164778
|
+
const job = { ctx, query: query10, page: page18, mapped, params: params10, prepare: prepare2, resolve: resolve13, reject: reject3, settled: false, timer: void 0, abort: () => this.#cancel(job, ctx.signal?.reason ?? new DOMException("Aborted", "AbortError")) };
|
|
164779
164779
|
job.timer = setTimeout(() => this.#cancel(job, new NetsuiteError(400, "INVALID_REQUEST", "Query execution deadline exceeded.")), this.#options.deadlineMs);
|
|
164780
164780
|
ctx.signal?.addEventListener("abort", job.abort, { once: true });
|
|
164781
164781
|
this.#queue.push(job);
|
|
@@ -172505,12 +172505,12 @@ function grantsFor(manager) {
|
|
|
172505
172505
|
}
|
|
172506
172506
|
function closeSocket(socket) {
|
|
172507
172507
|
if (!socket || socket.readyState === import_websocket.default.CLOSED) return Promise.resolve();
|
|
172508
|
-
return new Promise((
|
|
172508
|
+
return new Promise((resolve13) => {
|
|
172509
172509
|
const timer = setTimeout(() => socket.terminate(), 1e3);
|
|
172510
172510
|
timer.unref();
|
|
172511
172511
|
socket.once("close", () => {
|
|
172512
172512
|
clearTimeout(timer);
|
|
172513
|
-
|
|
172513
|
+
resolve13();
|
|
172514
172514
|
});
|
|
172515
172515
|
socket.close(1e3, "session ended");
|
|
172516
172516
|
});
|
|
@@ -172558,7 +172558,7 @@ Content-Length: 0\r
|
|
|
172558
172558
|
return { close: () => closing ??= (async () => {
|
|
172559
172559
|
server.off("upgrade", upgrade);
|
|
172560
172560
|
await Promise.all([...wss.clients].map(closeSocket));
|
|
172561
|
-
await new Promise((
|
|
172561
|
+
await new Promise((resolve13) => wss.close(() => resolve13()));
|
|
172562
172562
|
})() };
|
|
172563
172563
|
}
|
|
172564
172564
|
var SOCKET_GRANT_TTL_MS, SOCKET_ACK_MS, SOCKET_PING_MS, SOCKET_PONG_MS, registries, SocketDelivery;
|
|
@@ -172873,7 +172873,7 @@ async function readFeed(env, options4) {
|
|
|
172873
172873
|
if (!Number.isSafeInteger(waitMs) || waitMs < 0 || waitMs > 25e3) throw new AnchaError("USAGE", "wait_ms must be an integer from 0 to 25000");
|
|
172874
172874
|
let events3 = env.events.list(after);
|
|
172875
172875
|
if (events3.length === 0 && waitMs > 0) {
|
|
172876
|
-
events3 = await new Promise((
|
|
172876
|
+
events3 = await new Promise((resolve13, reject3) => {
|
|
172877
172877
|
let settled = false;
|
|
172878
172878
|
let unsubscribe = () => {
|
|
172879
172879
|
};
|
|
@@ -172888,7 +172888,7 @@ async function readFeed(env, options4) {
|
|
|
172888
172888
|
if (settled) return;
|
|
172889
172889
|
settled = true;
|
|
172890
172890
|
cleanup();
|
|
172891
|
-
|
|
172891
|
+
resolve13(batch4);
|
|
172892
172892
|
};
|
|
172893
172893
|
const abort = () => {
|
|
172894
172894
|
if (settled) return;
|
|
@@ -174635,7 +174635,7 @@ var init_dist3 = __esm({
|
|
|
174635
174635
|
});
|
|
174636
174636
|
if (!chunk) {
|
|
174637
174637
|
if (i === 1) {
|
|
174638
|
-
await new Promise((
|
|
174638
|
+
await new Promise((resolve13) => setTimeout(resolve13));
|
|
174639
174639
|
maxReadCount = 3;
|
|
174640
174640
|
continue;
|
|
174641
174641
|
}
|
|
@@ -174832,11 +174832,11 @@ async function startServer(opts = {}) {
|
|
|
174832
174832
|
let stopAfterError;
|
|
174833
174833
|
let onError;
|
|
174834
174834
|
try {
|
|
174835
|
-
await new Promise((
|
|
174835
|
+
await new Promise((resolve13, reject3) => {
|
|
174836
174836
|
let listening = false;
|
|
174837
174837
|
const onListening = () => {
|
|
174838
174838
|
listening = true;
|
|
174839
|
-
|
|
174839
|
+
resolve13();
|
|
174840
174840
|
};
|
|
174841
174841
|
onError = (cause) => {
|
|
174842
174842
|
if (!listening) {
|
|
@@ -174861,8 +174861,8 @@ async function startServer(opts = {}) {
|
|
|
174861
174861
|
const sweep = setInterval(() => manager.reapExpired(), 1e3);
|
|
174862
174862
|
sweep.unref();
|
|
174863
174863
|
let resolveClosed;
|
|
174864
|
-
const closed = new Promise((
|
|
174865
|
-
resolveClosed =
|
|
174864
|
+
const closed = new Promise((resolve13) => {
|
|
174865
|
+
resolveClosed = resolve13;
|
|
174866
174866
|
});
|
|
174867
174867
|
let closing;
|
|
174868
174868
|
const close = () => closing ??= (async () => {
|
|
@@ -174874,12 +174874,12 @@ async function startServer(opts = {}) {
|
|
|
174874
174874
|
await manager.drainResources().catch((error64) => {
|
|
174875
174875
|
runtimeError ??= error64 instanceof AnchaError ? error64 : new AnchaError("INTERNAL", "native transport shutdown failed", { cause: error64 });
|
|
174876
174876
|
});
|
|
174877
|
-
await new Promise((
|
|
174877
|
+
await new Promise((resolve13, reject3) => {
|
|
174878
174878
|
const force = setTimeout(() => server.closeAllConnections(), 1e3);
|
|
174879
174879
|
server.close((e) => {
|
|
174880
174880
|
clearTimeout(force);
|
|
174881
174881
|
if (e) reject3(runtimeError ?? startError(e));
|
|
174882
|
-
else
|
|
174882
|
+
else resolve13();
|
|
174883
174883
|
});
|
|
174884
174884
|
server.closeIdleConnections();
|
|
174885
174885
|
});
|
|
@@ -176035,11 +176035,11 @@ async function startIsolationGateway(options4) {
|
|
|
176035
176035
|
server.on("clientError", (_error, socket) => socket.destroy());
|
|
176036
176036
|
server.on("upgrade", (_req, socket) => socket.end("HTTP/1.1 501 Not Implemented\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"));
|
|
176037
176037
|
server.on("connect", (_req, client2) => client2.end("HTTP/1.1 403 Rejected\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"));
|
|
176038
|
-
await new Promise((
|
|
176038
|
+
await new Promise((resolve13, rejectListen) => {
|
|
176039
176039
|
server.once("error", rejectListen);
|
|
176040
176040
|
server.listen(options4.port ?? 0, "127.0.0.1", () => {
|
|
176041
176041
|
server.removeListener("error", rejectListen);
|
|
176042
|
-
|
|
176042
|
+
resolve13();
|
|
176043
176043
|
});
|
|
176044
176044
|
});
|
|
176045
176045
|
const address8 = server.address();
|
|
@@ -176052,7 +176052,7 @@ async function startIsolationGateway(options4) {
|
|
|
176052
176052
|
options4.signal?.removeEventListener("abort", abort);
|
|
176053
176053
|
for (const target4 of upstreamRequests) target4.destroy();
|
|
176054
176054
|
for (const socket of sockets) socket.destroy();
|
|
176055
|
-
await new Promise((
|
|
176055
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
176056
176056
|
})();
|
|
176057
176057
|
const abort = () => {
|
|
176058
176058
|
void close();
|
|
@@ -176187,8 +176187,12 @@ var init_runtime3 = __esm({
|
|
|
176187
176187
|
});
|
|
176188
176188
|
|
|
176189
176189
|
// backend/src/runner/agent-env.ts
|
|
176190
|
+
function agentTask(scene2, runtime2) {
|
|
176191
|
+
return runtime2?.task ?? scene2.trigger?.task ?? scene2.task ?? "";
|
|
176192
|
+
}
|
|
176190
176193
|
function agentTemplateVars(envId, services2, task2, trial, session2, runtime2, mcp) {
|
|
176191
176194
|
const vars = { task: task2, "env.id": envId, trial: String(trial) };
|
|
176195
|
+
if (runtime2?.taskFile !== void 0) vars.task_file = runtime2.taskFile;
|
|
176192
176196
|
for (const [tool, connection3] of Object.entries(mcp ?? {})) Object.assign(vars, { [`${tool}.mcp_url`]: connection3.url, [`${tool}.mcp_token`]: connection3.token });
|
|
176193
176197
|
for (const [twin, s2] of Object.entries(services2)) {
|
|
176194
176198
|
vars[`${twin}.url`] = s2.url;
|
|
@@ -176234,12 +176238,13 @@ function describeAgentEnvironment(agent, parent2, crash) {
|
|
|
176234
176238
|
return { target: "host", inherited, withheld, ...(agent.inheritEnv || agent.passEnv === void 0) && { inheritAll: true }, ...named3.length > 0 && { withheldInLogs: named3 } };
|
|
176235
176239
|
}
|
|
176236
176240
|
function agentEnv(env, scene2, agent, trial, inheritedEnv, session2, runtime2) {
|
|
176237
|
-
const task2 =
|
|
176241
|
+
const task2 = agentTask(scene2, runtime2);
|
|
176238
176242
|
const defaults3 = {
|
|
176239
176243
|
ANCHA_ENV_ID: env.id,
|
|
176240
176244
|
ANCHA_TRIAL: String(trial),
|
|
176241
176245
|
ANCHA_SCENE_ID: scene2.id,
|
|
176242
176246
|
ANCHA_TASK: task2,
|
|
176247
|
+
...runtime2?.taskFile !== void 0 && { ANCHA_TASK_FILE: runtime2.taskFile },
|
|
176243
176248
|
...runtime2?.event !== void 0 && { ANCHA_EVENT_JSON: runtime2.event },
|
|
176244
176249
|
// A test made from a trace hands the agent the invocation's own input: the conversation so far and the user (TRACE_PLAN_V2 §3).
|
|
176245
176250
|
...scene2.trigger?.input !== void 0 && { ANCHA_INPUT_JSON: JSON.stringify(scene2.trigger.input) }
|
|
@@ -176276,7 +176281,12 @@ function validateAgentEnv(scene2, agent) {
|
|
|
176276
176281
|
if (Object.keys(scene2.tools ?? {}).length) services2.tools = { url: "http://localhost", hostUrl: "http://localhost", token: "" };
|
|
176277
176282
|
for (const twin of scene2.twins) services2[twin] = { url: "http://localhost", hostUrl: "http://localhost", token: "", signingSecret: "", ...twin === "slack" ? { appToken: "" } : {}, ...twin === "gmail" ? { address: "" } : {}, ...twin === "datadog" ? { apiKey: "", appKey: "", webhookToken: "" } : {}, ...twin === "pagerduty" ? { fromEmail: "", routingKey: "", routingKeys: {} } : {}, ...twin === "gong" ? { accessKey: "", accessKeySecret: "" } : {}, ...twin === "google-ads" ? { grpcEndpoint: "localhost:1", tlsRootCertificate: "" } : {} };
|
|
176278
176283
|
const session2 = { id: "", token: "", envId: "", eventsUrl: "http://localhost/events", doneUrl: "http://localhost/done", contextUrl: "http://localhost/context", state: "prepared" };
|
|
176279
|
-
const
|
|
176284
|
+
const launched = agent.mode !== "endpoint";
|
|
176285
|
+
const runtime2 = {
|
|
176286
|
+
...(agent.mode === "endpoint" && agent.start !== void 0 || agent.taskInput?.kind === "http") && { port: 34567 },
|
|
176287
|
+
attempt: { id: "validation", caseId: scene2.id, stateDir: "/ancha/validation/agent-state", seed: "validation" },
|
|
176288
|
+
...launched && { taskFile: "/ancha/validation/task.txt" }
|
|
176289
|
+
};
|
|
176280
176290
|
const vars = agentTemplateVars("", services2, "", 0, session2, runtime2, Object.keys(scene2.tools ?? {}).length ? { tools: { url: "http://localhost/mcp", token: "" } } : void 0);
|
|
176281
176291
|
renderEnvMapping(agent.env, vars);
|
|
176282
176292
|
if (agent.mode === "endpoint") {
|
|
@@ -176441,7 +176451,7 @@ var init_run_bundle = __esm({
|
|
|
176441
176451
|
entriesFor = (source) => source === "cloud" ? BUNDLE_LIMITS2.cloudEntries : BUNDLE_LIMITS2.entries;
|
|
176442
176452
|
allowedFor = (source, path6) => BUNDLE_PATH.test(path6) && (source === "cloud" || !CLOUD_ONLY_PATH.test(path6));
|
|
176443
176453
|
sha2563 = (data5) => createHash53("sha256").update(data5).digest("hex");
|
|
176444
|
-
tooBig = (message7) => new AnchaError("USAGE", message7, { hint: "upload a run with fewer trials, or run fewer trials per
|
|
176454
|
+
tooBig = (message7) => new AnchaError("USAGE", message7, { hint: "upload a run with fewer trials, or run fewer trials per test" });
|
|
176445
176455
|
}
|
|
176446
176456
|
});
|
|
176447
176457
|
|
|
@@ -176514,10 +176524,155 @@ var init_actions7 = __esm({
|
|
|
176514
176524
|
}
|
|
176515
176525
|
});
|
|
176516
176526
|
|
|
176527
|
+
// cloud/rebuild/readers/suiteql.mjs
|
|
176528
|
+
var init_suiteql2 = __esm({
|
|
176529
|
+
"cloud/rebuild/readers/suiteql.mjs"() {
|
|
176530
|
+
"use strict";
|
|
176531
|
+
}
|
|
176532
|
+
});
|
|
176533
|
+
|
|
176534
|
+
// cloud/rebuild/netsuite-mcp.mjs
|
|
176535
|
+
var NETSUITE_MCP_TOOLS, TOOLS;
|
|
176536
|
+
var init_netsuite_mcp = __esm({
|
|
176537
|
+
"cloud/rebuild/netsuite-mcp.mjs"() {
|
|
176538
|
+
"use strict";
|
|
176539
|
+
NETSUITE_MCP_TOOLS = Object.freeze([
|
|
176540
|
+
"ns_createRecord",
|
|
176541
|
+
"ns_getRecord",
|
|
176542
|
+
"ns_getRecordTransformMetadata",
|
|
176543
|
+
"ns_getRecordTypeMetadata",
|
|
176544
|
+
"ns_transformRecord",
|
|
176545
|
+
"ns_updateRecord",
|
|
176546
|
+
"ns_getRecordActionMetadata",
|
|
176547
|
+
"ns_executeRecordAction",
|
|
176548
|
+
"ns_getAccountingBooks",
|
|
176549
|
+
"ns_getAccountingContexts",
|
|
176550
|
+
"ns_getNexusIds",
|
|
176551
|
+
"ns_getSubsidiaries",
|
|
176552
|
+
"ns_listAllReports",
|
|
176553
|
+
"ns_runReport",
|
|
176554
|
+
"ns_getSessionInfo",
|
|
176555
|
+
"ns_listSavedSearches",
|
|
176556
|
+
"ns_runSavedSearch",
|
|
176557
|
+
"ns_getSuiteQLMetadata",
|
|
176558
|
+
"ns_runCustomSuiteQL",
|
|
176559
|
+
"ns_attachFile",
|
|
176560
|
+
"ns_detachFile",
|
|
176561
|
+
"ns_getFolderByPath",
|
|
176562
|
+
"ns_getIdFromPath",
|
|
176563
|
+
"ns_getPathFromId",
|
|
176564
|
+
"ns_searchFiles"
|
|
176565
|
+
]);
|
|
176566
|
+
TOOLS = new Set(NETSUITE_MCP_TOOLS);
|
|
176567
|
+
}
|
|
176568
|
+
});
|
|
176569
|
+
|
|
176570
|
+
// cloud/rebuild/readers/netsuite.mjs
|
|
176571
|
+
var RECORD_TYPES, TYPE_BY_LOWER, TX2, TX_TYPES, LABEL, TYPE_OF_LABEL, TYPE_OF_CODE, ITEM_TYPES, CODE_OF, ITEM_USE2;
|
|
176572
|
+
var init_netsuite4 = __esm({
|
|
176573
|
+
"cloud/rebuild/readers/netsuite.mjs"() {
|
|
176574
|
+
"use strict";
|
|
176575
|
+
init_suiteql2();
|
|
176576
|
+
init_netsuite_mcp();
|
|
176577
|
+
RECORD_TYPES = Object.freeze([
|
|
176578
|
+
"customer",
|
|
176579
|
+
"vendor",
|
|
176580
|
+
"contact",
|
|
176581
|
+
"employee",
|
|
176582
|
+
"serviceSaleItem",
|
|
176583
|
+
"servicePurchaseItem",
|
|
176584
|
+
"serviceResaleItem",
|
|
176585
|
+
"nonInventorySaleItem",
|
|
176586
|
+
"nonInventoryPurchaseItem",
|
|
176587
|
+
"nonInventoryResaleItem",
|
|
176588
|
+
"otherChargeSaleItem",
|
|
176589
|
+
"otherChargePurchaseItem",
|
|
176590
|
+
"otherChargeResaleItem",
|
|
176591
|
+
"inventoryItem",
|
|
176592
|
+
"account",
|
|
176593
|
+
"subsidiary",
|
|
176594
|
+
"currency",
|
|
176595
|
+
"term",
|
|
176596
|
+
"department",
|
|
176597
|
+
"location",
|
|
176598
|
+
"classification",
|
|
176599
|
+
"accountingPeriod",
|
|
176600
|
+
"accountingBook",
|
|
176601
|
+
"currencyRate",
|
|
176602
|
+
"expenseCategory",
|
|
176603
|
+
"bankingTransaction",
|
|
176604
|
+
"bankRecSuggestion",
|
|
176605
|
+
"transactionMatch",
|
|
176606
|
+
"estimate",
|
|
176607
|
+
"salesOrder",
|
|
176608
|
+
"itemFulfillment",
|
|
176609
|
+
"invoice",
|
|
176610
|
+
"cashSale",
|
|
176611
|
+
"cashRefund",
|
|
176612
|
+
"creditMemo",
|
|
176613
|
+
"customerPayment",
|
|
176614
|
+
"customerDeposit",
|
|
176615
|
+
"depositApplication",
|
|
176616
|
+
"customerRefund",
|
|
176617
|
+
"returnAuthorization",
|
|
176618
|
+
"purchaseOrder",
|
|
176619
|
+
"itemReceipt",
|
|
176620
|
+
"vendorBill",
|
|
176621
|
+
"vendorCredit",
|
|
176622
|
+
"vendorPayment",
|
|
176623
|
+
"vendorReturnAuthorization",
|
|
176624
|
+
"journalEntry",
|
|
176625
|
+
"expenseReport"
|
|
176626
|
+
]);
|
|
176627
|
+
TYPE_BY_LOWER = new Map(RECORD_TYPES.map((t) => [t.toLowerCase(), t]));
|
|
176628
|
+
TX2 = {
|
|
176629
|
+
CustInvc: ["invoice", "Invoice"],
|
|
176630
|
+
VendBill: ["vendorBill", "Bill"],
|
|
176631
|
+
PurchOrd: ["purchaseOrder", "Purchase Order"],
|
|
176632
|
+
ItemRcpt: ["itemReceipt", "Item Receipt"],
|
|
176633
|
+
CustPymt: ["customerPayment", "Payment"],
|
|
176634
|
+
VendPymt: ["vendorPayment", "Bill Payment"],
|
|
176635
|
+
Journal: ["journalEntry", "Journal"],
|
|
176636
|
+
CustCred: ["creditMemo", "Credit Memo"],
|
|
176637
|
+
SalesOrd: ["salesOrder", "Sales Order"],
|
|
176638
|
+
ItemShip: ["itemFulfillment", "Item Fulfillment"],
|
|
176639
|
+
VendCred: ["vendorCredit", "Bill Credit"],
|
|
176640
|
+
CustDep: ["customerDeposit", "Customer Deposit"],
|
|
176641
|
+
CustRfnd: ["customerRefund", "Customer Refund"],
|
|
176642
|
+
CashSale: ["cashSale", "Cash Sale"],
|
|
176643
|
+
CashRfnd: ["cashRefund", "Cash Refund"],
|
|
176644
|
+
Estimate: ["estimate", "Quote"],
|
|
176645
|
+
ExpRept: ["expenseReport", "Expense Report"],
|
|
176646
|
+
RtnAuth: ["returnAuthorization", "Return Authorization"],
|
|
176647
|
+
VendAuth: ["vendorReturnAuthorization", "Vendor Return Authorization"],
|
|
176648
|
+
DepAppl: ["depositApplication", "Deposit Application"]
|
|
176649
|
+
};
|
|
176650
|
+
TX_TYPES = new Set(Object.values(TX2).map(([type]) => type));
|
|
176651
|
+
LABEL = Object.fromEntries(Object.values(TX2).map(([type, label5]) => [type, label5]));
|
|
176652
|
+
TYPE_OF_LABEL = new Map(Object.values(TX2).map(([type, label5]) => [label5.toLowerCase(), type]));
|
|
176653
|
+
TYPE_OF_CODE = new Map(Object.entries(TX2).map(([code2, [type]]) => [code2.toLowerCase(), type]));
|
|
176654
|
+
ITEM_TYPES = new Set(RECORD_TYPES.filter((t) => /Item$/.test(t)));
|
|
176655
|
+
CODE_OF = Object.fromEntries(Object.entries(TX2).map(([code2, [type]]) => [type, code2]));
|
|
176656
|
+
ITEM_USE2 = Object.fromEntries([...ITEM_TYPES].map((t) => [t, { sale: !/Purchase/.test(t), purchase: !/Sale/.test(t), inventory: t === "inventoryItem" }]));
|
|
176657
|
+
}
|
|
176658
|
+
});
|
|
176659
|
+
|
|
176660
|
+
// cloud/rebuild/netsuite-checks.mjs
|
|
176661
|
+
var COUNTED, BOOKS;
|
|
176662
|
+
var init_netsuite_checks = __esm({
|
|
176663
|
+
"cloud/rebuild/netsuite-checks.mjs"() {
|
|
176664
|
+
"use strict";
|
|
176665
|
+
init_netsuite4();
|
|
176666
|
+
COUNTED = new Set(RECORD_TYPES.filter((t) => !["account", "accountingPeriod", "accountingBook", "currencyRate", "expenseCategory", "bankingTransaction", "bankRecSuggestion", "transactionMatch"].includes(t)));
|
|
176667
|
+
BOOKS = RECORD_TYPES.filter((t) => !["bankingTransaction", "bankRecSuggestion", "transactionMatch"].includes(t));
|
|
176668
|
+
}
|
|
176669
|
+
});
|
|
176670
|
+
|
|
176517
176671
|
// cloud/rebuild/production-state.mjs
|
|
176518
176672
|
var init_production_state = __esm({
|
|
176519
176673
|
"cloud/rebuild/production-state.mjs"() {
|
|
176520
176674
|
"use strict";
|
|
176675
|
+
init_netsuite_checks();
|
|
176521
176676
|
}
|
|
176522
176677
|
});
|
|
176523
176678
|
|
|
@@ -176790,7 +176945,7 @@ var init_values2 = __esm({
|
|
|
176790
176945
|
var sleep2;
|
|
176791
176946
|
var init_sleep = __esm({
|
|
176792
176947
|
"node_modules/.pnpm/openai@7.43.0_@aws-sdk+credential-provider-node@3.972.91_@smithy+signature-v4@5.7.5_undici@8.12.3_ws@8.22.0_zod@4.6.7/node_modules/openai/internal/utils/sleep.mjs"() {
|
|
176793
|
-
sleep2 = (ms, ...signals) => new Promise((
|
|
176948
|
+
sleep2 = (ms, ...signals) => new Promise((resolve13, reject3) => {
|
|
176794
176949
|
const activeSignals = [...new Set(signals.filter((signal) => signal != null))];
|
|
176795
176950
|
let timeout;
|
|
176796
176951
|
let settled = false;
|
|
@@ -176822,7 +176977,7 @@ var init_sleep = __esm({
|
|
|
176822
176977
|
return;
|
|
176823
176978
|
}
|
|
176824
176979
|
timeout = setTimeout(() => {
|
|
176825
|
-
settle3(
|
|
176980
|
+
settle3(resolve13);
|
|
176826
176981
|
}, ms);
|
|
176827
176982
|
for (const signal of activeSignals) {
|
|
176828
176983
|
if (settled) {
|
|
@@ -177368,8 +177523,8 @@ function createAbortableSSESource(body6, signal) {
|
|
|
177368
177523
|
let interrupt;
|
|
177369
177524
|
const waitForAbort = () => (
|
|
177370
177525
|
// oxlint-disable-next-line promise/avoid-new -- AbortSignal callbacks need a portable Promise bridge.
|
|
177371
|
-
new Promise((
|
|
177372
|
-
interrupt =
|
|
177526
|
+
new Promise((resolve13) => {
|
|
177527
|
+
interrupt = resolve13;
|
|
177373
177528
|
})
|
|
177374
177529
|
);
|
|
177375
177530
|
const cancel3 = () => {
|
|
@@ -178642,8 +178797,8 @@ var init_api_promise = __esm({
|
|
|
178642
178797
|
init_parse3();
|
|
178643
178798
|
APIPromise = class _APIPromise extends Promise {
|
|
178644
178799
|
constructor(client2, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
178645
|
-
super((
|
|
178646
|
-
|
|
178800
|
+
super((resolve13) => {
|
|
178801
|
+
resolve13(null);
|
|
178647
178802
|
});
|
|
178648
178803
|
this.responsePromise = responsePromise;
|
|
178649
178804
|
this.parseResponse = parseResponse2;
|
|
@@ -181814,12 +181969,12 @@ var init_EventStream = __esm({
|
|
|
181814
181969
|
_EventStream_aborted.set(this, false);
|
|
181815
181970
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
181816
181971
|
_EventStream_terminalFailure.set(this, void 0);
|
|
181817
|
-
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((
|
|
181818
|
-
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise,
|
|
181972
|
+
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve13, reject3) => {
|
|
181973
|
+
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve13, "f");
|
|
181819
181974
|
__classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject3, "f");
|
|
181820
181975
|
}), "f");
|
|
181821
|
-
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((
|
|
181822
|
-
__classPrivateFieldSet(this, _EventStream_resolveEndPromise,
|
|
181976
|
+
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve13, reject3) => {
|
|
181977
|
+
__classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve13, "f");
|
|
181823
181978
|
__classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject3, "f");
|
|
181824
181979
|
}), "f");
|
|
181825
181980
|
__classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => void 0);
|
|
@@ -181957,7 +182112,7 @@ var init_EventStream = __esm({
|
|
|
181957
182112
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
181958
182113
|
*/
|
|
181959
182114
|
emitted(event3) {
|
|
181960
|
-
return new Promise((
|
|
182115
|
+
return new Promise((resolve13, reject3) => {
|
|
181961
182116
|
__classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
181962
182117
|
const onError = (error64) => {
|
|
181963
182118
|
this.off(event3, onEvent);
|
|
@@ -181967,7 +182122,7 @@ var init_EventStream = __esm({
|
|
|
181967
182122
|
if (event3 !== "error") {
|
|
181968
182123
|
this.off("error", onError);
|
|
181969
182124
|
}
|
|
181970
|
-
|
|
182125
|
+
resolve13(values2.length > 1 ? values2 : values2[0]);
|
|
181971
182126
|
};
|
|
181972
182127
|
if (event3 !== "error") {
|
|
181973
182128
|
__classPrivateFieldGet(this, _EventStream_instances, "m", _EventStream_onceForEmitted).call(this, "error", onError);
|
|
@@ -182183,8 +182338,8 @@ var init_EventStream = __esm({
|
|
|
182183
182338
|
if (ended) {
|
|
182184
182339
|
return Promise.resolve(doneResult());
|
|
182185
182340
|
}
|
|
182186
|
-
return new Promise((
|
|
182187
|
-
readQueue.enqueue({ resolve:
|
|
182341
|
+
return new Promise((resolve13, reject3) => {
|
|
182342
|
+
readQueue.enqueue({ resolve: resolve13, reject: reject3 });
|
|
182188
182343
|
});
|
|
182189
182344
|
},
|
|
182190
182345
|
return: () => {
|
|
@@ -182953,21 +183108,21 @@ var init_parser2 = __esm({
|
|
|
182953
183108
|
};
|
|
182954
183109
|
const parseStr = () => {
|
|
182955
183110
|
const start = index;
|
|
182956
|
-
let
|
|
183111
|
+
let escape11 = false;
|
|
182957
183112
|
index++;
|
|
182958
|
-
while (index < length && (jsonString[index] !== '"' ||
|
|
182959
|
-
|
|
183113
|
+
while (index < length && (jsonString[index] !== '"' || escape11 && jsonString[index - 1] === "\\")) {
|
|
183114
|
+
escape11 = jsonString[index] === "\\" ? !escape11 : false;
|
|
182960
183115
|
index++;
|
|
182961
183116
|
}
|
|
182962
183117
|
if (jsonString.charAt(index) === '"') {
|
|
182963
183118
|
try {
|
|
182964
|
-
return JSON.parse(jsonString.substring(start, ++index - Number(
|
|
183119
|
+
return JSON.parse(jsonString.substring(start, ++index - Number(escape11)));
|
|
182965
183120
|
} catch (e) {
|
|
182966
183121
|
throwMalformedError(String(e));
|
|
182967
183122
|
}
|
|
182968
183123
|
} else if (Allow.STR & allow) {
|
|
182969
183124
|
try {
|
|
182970
|
-
return JSON.parse(jsonString.substring(start, index - Number(
|
|
183125
|
+
return JSON.parse(jsonString.substring(start, index - Number(escape11)) + '"');
|
|
182971
183126
|
} catch {
|
|
182972
183127
|
return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + '"');
|
|
182973
183128
|
}
|
|
@@ -190770,8 +190925,8 @@ var init_tool_dispatcher = __esm({
|
|
|
190770
190925
|
try {
|
|
190771
190926
|
await __classPrivateFieldGet(this, _AgentToolDispatcher_instances, "m", _AgentToolDispatcher_wait).call(this, () => (
|
|
190772
190927
|
// oxlint-disable-next-line promise/avoid-new -- Own the registration timer so cancellation clears it promptly.
|
|
190773
|
-
new Promise((
|
|
190774
|
-
timer = setTimeout(
|
|
190928
|
+
new Promise((resolve13) => {
|
|
190929
|
+
timer = setTimeout(resolve13, delay);
|
|
190775
190930
|
})
|
|
190776
190931
|
));
|
|
190777
190932
|
} finally {
|
|
@@ -192704,7 +192859,7 @@ var init_steps2 = __esm({
|
|
|
192704
192859
|
|
|
192705
192860
|
// node_modules/.pnpm/openai@7.43.0_@aws-sdk+credential-provider-node@3.972.91_@smithy+signature-v4@5.7.5_undici@8.12.3_ws@8.22.0_zod@4.6.7/node_modules/openai/lib/polling.mjs
|
|
192706
192861
|
function sleepUntilAborted(milliseconds, signal) {
|
|
192707
|
-
return new Promise((
|
|
192862
|
+
return new Promise((resolve13, reject3) => {
|
|
192708
192863
|
let timer;
|
|
192709
192864
|
let registered;
|
|
192710
192865
|
let settled = false;
|
|
@@ -192753,7 +192908,7 @@ function sleepUntilAborted(milliseconds, signal) {
|
|
|
192753
192908
|
}
|
|
192754
192909
|
settled = true;
|
|
192755
192910
|
cleanup();
|
|
192756
|
-
|
|
192911
|
+
resolve13();
|
|
192757
192912
|
}, milliseconds);
|
|
192758
192913
|
registered = abort;
|
|
192759
192914
|
try {
|
|
@@ -201895,6 +202050,17 @@ async function evaluateJudges(scene2, capture3, options4) {
|
|
|
201895
202050
|
});
|
|
201896
202051
|
} catch (failure5) {
|
|
201897
202052
|
const error64 = options4.signal?.aborted ? "Judge evaluation cancelled." : options4.relay && failure5 instanceof AnchaError ? `Judge evaluation failed: ${failure5.message.replace(/\.+$/, "")}.` : "Judge evaluation failed: provider request or structured grade was invalid.";
|
|
202053
|
+
if (!base3.required && !options4.signal?.aborted) {
|
|
202054
|
+
evaluated.set(check3.id, {
|
|
202055
|
+
...base3,
|
|
202056
|
+
status: "skipped",
|
|
202057
|
+
actual: "judge skipped",
|
|
202058
|
+
explanation: error64,
|
|
202059
|
+
warning: `Optional judge skipped: ${error64.replace(/^Judge evaluation failed: /, "")}`,
|
|
202060
|
+
judge: { model, ...cut }
|
|
202061
|
+
});
|
|
202062
|
+
continue;
|
|
202063
|
+
}
|
|
201898
202064
|
evaluated.set(check3.id, {
|
|
201899
202065
|
...base3,
|
|
201900
202066
|
...options4.relay ? {} : { status: "failed" },
|
|
@@ -201960,6 +202126,55 @@ var init_production = __esm({
|
|
|
201960
202126
|
}
|
|
201961
202127
|
});
|
|
201962
202128
|
|
|
202129
|
+
// backend/src/reproduction-text.ts
|
|
202130
|
+
function renderWrites(writes2) {
|
|
202131
|
+
const of = `${writes2.of} ${writes2.of === 1 ? "trial" : "trials"}`;
|
|
202132
|
+
if (!writes2.tools.length) return [` writes compared with production: none in production, none in this run's ${of}`];
|
|
202133
|
+
const called = (n2) => n2 === 0 ? "not called" : n2 === 1 ? "called" : `called ${n2} times`;
|
|
202134
|
+
const width = Math.max(...writes2.tools.map((w2) => w2.tool.length)), said = Math.max(...writes2.tools.map((w2) => called(w2.production).length));
|
|
202135
|
+
return [" writes compared with production:", ...writes2.tools.map((w2) => ` ${w2.tool.padEnd(width)} production: ${called(w2.production).padEnd(said)} this run: ${w2.trials} of ${of}`)];
|
|
202136
|
+
}
|
|
202137
|
+
function renderReproduction(reproductions, opts = {}) {
|
|
202138
|
+
if (opts.neverRan) return reproductions.map((r2) => `compared with production${r2.trace === void 0 ? "" : ` (trace ${r2.trace.slice(0, 12)})`}: ${r2.sceneId}
|
|
202139
|
+
=> not compared: the agent never ran`).join("\n\n");
|
|
202140
|
+
return reproductions.map((r2) => {
|
|
202141
|
+
const width = Math.max(...r2.checks.map((c) => c.check.length));
|
|
202142
|
+
const rows7 = r2.checks.map((c) => ` ${c.check.padEnd(width)} ${c.production} in production \xB7 ${c.total === 0 ? "not run" : c.failed === 0 ? `passed ${c.total}/${c.total} here` : `failed ${c.failed}/${c.total} here`}`);
|
|
202143
|
+
const also = r2.verdict !== "differs" ? r2.checks.filter((c) => c.production === "passed" && c.failed > 0).map((c) => c.check) : [];
|
|
202144
|
+
const verdict = r2.error !== void 0 && r2.checks.length === 0 ? [] : [`=> ${SAY[r2.verdict]}`];
|
|
202145
|
+
return [
|
|
202146
|
+
`compared with production${r2.trace === void 0 ? "" : ` (trace ${r2.trace.slice(0, 12)})`}: ${r2.sceneId}`,
|
|
202147
|
+
...rows7,
|
|
202148
|
+
...verdict,
|
|
202149
|
+
...r2.error !== void 0 ? [` grading production's record failed: ${r2.error}`] : [],
|
|
202150
|
+
...also.length > 0 ? [` also failing here, though production passed: ${also.join(", ")}`] : [],
|
|
202151
|
+
// A failure here on a check production is not graded on yet is neither a match nor a regression: say how to grade both.
|
|
202152
|
+
...r2.verdict !== "unknown" && r2.checks.some((c) => c.production === "unknown" && c.failed > 0) ? [` set OPENROUTER_API_KEY to grade ${r2.checks.filter((c) => c.production === "unknown" && c.failed > 0).map((c) => c.check).join(", ")} on production's record and here`] : [],
|
|
202153
|
+
...r2.added.length > 0 ? [` checks added after saving, with no production result: ${r2.added.join(", ")}`] : [],
|
|
202154
|
+
// How much of the run stood on production's own answers (TRACE_PLAN_V2 §8.6).
|
|
202155
|
+
...r2.answers ? [` answers to the agent's tools: ${["replayed", "replayed-elsewhere", "twin", "ran", "simulated", "validated", "failed"].filter((s2) => r2.answers[s2]).map((s2) => `${r2.answers[s2]} ${s2}`).join(", ")}${r2.answers.simulated ? "; simulated answers took the agent where production never went (ancha explain lists them)" : ""}`] : [],
|
|
202156
|
+
// What the agent changed, next to what production changed: an answer that needs no model (SPEC-020 R1).
|
|
202157
|
+
...r2.writes !== void 0 && r2.writes.of > 0 ? renderWrites(r2.writes) : []
|
|
202158
|
+
].join("\n");
|
|
202159
|
+
}).join("\n\n");
|
|
202160
|
+
}
|
|
202161
|
+
var SAY;
|
|
202162
|
+
var init_reproduction_text = __esm({
|
|
202163
|
+
"backend/src/reproduction-text.ts"() {
|
|
202164
|
+
"use strict";
|
|
202165
|
+
SAY = {
|
|
202166
|
+
crashed: "the agent exited with an error in every trial, so this run says nothing about production's failure: fix the agent first",
|
|
202167
|
+
reproduced: "production's failure happens here too",
|
|
202168
|
+
partly: "production's failure happens here in part",
|
|
202169
|
+
"not-reproduced": "production's failure did not happen here",
|
|
202170
|
+
matches: "this run matches production, which passed these checks",
|
|
202171
|
+
differs: "checks production passed failed here",
|
|
202172
|
+
unknown: "set OPENROUTER_API_KEY and run again: a model grades these checks on production's record and on this run",
|
|
202173
|
+
ungraded: "the checks that compare with production could not be graded in this run, so it says nothing about production yet"
|
|
202174
|
+
};
|
|
202175
|
+
}
|
|
202176
|
+
});
|
|
202177
|
+
|
|
201963
202178
|
// backend/src/production-comparison.ts
|
|
201964
202179
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
201965
202180
|
import { dirname as dirname3, join as join7, resolve as resolve6 } from "node:path";
|
|
@@ -201978,9 +202193,11 @@ async function reproductionOf(summary, scenePaths, cwd, runDir, scenes = [], pro
|
|
|
201978
202193
|
});
|
|
201979
202194
|
const failedInProduction = checks2.filter((c) => c.production === "failed"), failedThere = failedInProduction.filter((c) => c.total > 0);
|
|
201980
202195
|
const ungraded = failedInProduction.length > 0 && failedThere.length === 0;
|
|
202196
|
+
const passedThere = checks2.filter((c) => c.production === "passed" && c.total > 0);
|
|
202197
|
+
const invalid30 = Object.values(scene2.checks).some((c) => c.invalid);
|
|
201981
202198
|
const detail3 = scene2.trialsDetail ?? [];
|
|
201982
|
-
const crashed = detail3.length > 0 && detail3.every((t) => t.exit === "exited" && t.exitCode !== 0);
|
|
201983
|
-
const verdict = crashed ? "crashed" : ungraded ?
|
|
202199
|
+
const crashed = detail3.length > 0 && detail3.every((t) => t.exit === "exited" && t.exitCode !== 0 || t.exit === "spawn_failed" || t.exit === "invalid" && t.originalExit === "spawn_failed");
|
|
202200
|
+
const verdict = crashed ? "crashed" : ungraded ? invalid30 ? "ungraded" : "unknown" : failedThere.length > 0 ? failedThere.every((c) => c.failed * 2 > c.total) ? "reproduced" : failedThere.some((c) => c.failed > 0) ? "partly" : "not-reproduced" : passedThere.some((c) => c.failed > 0) ? "differs" : passedThere.length > 0 ? "matches" : checks2.some((c) => c.production === "passed") && invalid30 ? "ungraded" : "unknown";
|
|
201984
202201
|
const added = Object.keys(scene2.checks).filter((check3) => !(check3 in production2.checks));
|
|
201985
202202
|
const counts = runDir === void 0 ? {} : await answerSources(runDir, scene2);
|
|
201986
202203
|
const defined = scenes.find((s2) => s2.id === scene2.sceneId);
|
|
@@ -202014,51 +202231,12 @@ async function writesOf(scene2, dir, runDir, ran) {
|
|
|
202014
202231
|
const tools = [...made.keys(), ...[...here.keys()].filter((tool) => !made.has(tool)).sort()];
|
|
202015
202232
|
return { of: trials.length, tools: tools.map((tool) => ({ tool, production: made.get(tool) ?? 0, trials: here.get(tool) ?? 0 })) };
|
|
202016
202233
|
}
|
|
202017
|
-
function renderWrites(writes2) {
|
|
202018
|
-
const of = `${writes2.of} ${writes2.of === 1 ? "trial" : "trials"}`;
|
|
202019
|
-
if (!writes2.tools.length) return [` writes compared with production: none in production, none in this run's ${of}`];
|
|
202020
|
-
const called = (n2) => n2 === 0 ? "not called" : n2 === 1 ? "called" : `called ${n2} times`;
|
|
202021
|
-
const width = Math.max(...writes2.tools.map((w2) => w2.tool.length)), said = Math.max(...writes2.tools.map((w2) => called(w2.production).length));
|
|
202022
|
-
return [" writes compared with production:", ...writes2.tools.map((w2) => ` ${w2.tool.padEnd(width)} production: ${called(w2.production).padEnd(said)} this run: ${w2.trials} of ${of}`)];
|
|
202023
|
-
}
|
|
202024
|
-
function renderReproduction(reproductions) {
|
|
202025
|
-
return reproductions.map((r2) => {
|
|
202026
|
-
const width = Math.max(...r2.checks.map((c) => c.check.length));
|
|
202027
|
-
const rows7 = r2.checks.map((c) => ` ${c.check.padEnd(width)} ${c.production} in production \xB7 ${c.total === 0 ? "not run" : c.failed === 0 ? `passed ${c.total}/${c.total} here` : `failed ${c.failed}/${c.total} here`}`);
|
|
202028
|
-
const also = r2.verdict !== "differs" ? r2.checks.filter((c) => c.production === "passed" && c.failed > 0).map((c) => c.check) : [];
|
|
202029
|
-
const verdict = r2.error !== void 0 && r2.checks.length === 0 ? [] : [`=> ${SAY[r2.verdict]}`];
|
|
202030
|
-
return [
|
|
202031
|
-
`compared with production${r2.trace === void 0 ? "" : ` (trace ${r2.trace.slice(0, 12)})`}: ${r2.sceneId}`,
|
|
202032
|
-
...rows7,
|
|
202033
|
-
...verdict,
|
|
202034
|
-
...r2.error !== void 0 ? [` grading production's record failed: ${r2.error}`] : [],
|
|
202035
|
-
...also.length > 0 ? [` also failing here, though production passed: ${also.join(", ")}`] : [],
|
|
202036
|
-
// A failure here on a check production is not graded on yet is neither a match nor a regression: say how to grade both.
|
|
202037
|
-
...r2.verdict !== "unknown" && r2.checks.some((c) => c.production === "unknown" && c.failed > 0) ? [` set OPENROUTER_API_KEY to grade ${r2.checks.filter((c) => c.production === "unknown" && c.failed > 0).map((c) => c.check).join(", ")} on production's record and here`] : [],
|
|
202038
|
-
...r2.added.length > 0 ? [` checks added after saving, with no production result: ${r2.added.join(", ")}`] : [],
|
|
202039
|
-
// How much of the run stood on production's own answers (TRACE_PLAN_V2 §8.6).
|
|
202040
|
-
...r2.answers ? [` answers to the agent's tools: ${["replayed", "replayed-elsewhere", "twin", "ran", "simulated", "validated", "failed"].filter((s2) => r2.answers[s2]).map((s2) => `${r2.answers[s2]} ${s2}`).join(", ")}${r2.answers.simulated ? "; simulated answers took the agent where production never went (ancha explain lists them)" : ""}`] : [],
|
|
202041
|
-
// What the agent changed, next to what production changed: an answer that needs no model (SPEC-020 R1).
|
|
202042
|
-
...r2.writes !== void 0 && r2.writes.of > 0 ? renderWrites(r2.writes) : []
|
|
202043
|
-
].join("\n");
|
|
202044
|
-
}).join("\n\n");
|
|
202045
|
-
}
|
|
202046
|
-
var SAY;
|
|
202047
202234
|
var init_production_comparison = __esm({
|
|
202048
202235
|
"backend/src/production-comparison.ts"() {
|
|
202049
202236
|
"use strict";
|
|
202050
202237
|
init_actions7();
|
|
202051
202238
|
init_production();
|
|
202052
|
-
|
|
202053
|
-
crashed: "the agent exited with an error in every trial, so this run says nothing about production's failure: fix the agent first",
|
|
202054
|
-
reproduced: "production's failure happens here too",
|
|
202055
|
-
partly: "production's failure happens here in part",
|
|
202056
|
-
"not-reproduced": "production's failure did not happen here",
|
|
202057
|
-
matches: "this run matches production, which passed these checks",
|
|
202058
|
-
differs: "checks production passed failed here",
|
|
202059
|
-
unknown: "set OPENROUTER_API_KEY and run again: a model grades these checks on production's record and on this run",
|
|
202060
|
-
ungraded: "no check production failed could be graded in this run, so it says nothing about production's failure yet"
|
|
202061
|
-
};
|
|
202239
|
+
init_reproduction_text();
|
|
202062
202240
|
}
|
|
202063
202241
|
});
|
|
202064
202242
|
|
|
@@ -202083,9 +202261,97 @@ var init_scenes = __esm({
|
|
|
202083
202261
|
}
|
|
202084
202262
|
});
|
|
202085
202263
|
|
|
202264
|
+
// backend/src/agent-fix.ts
|
|
202265
|
+
function givenByTwins(name5) {
|
|
202266
|
+
twinVariables ??= new Set(Object.keys(toolConnectionEnvironment(Object.fromEntries(SUPPORTED_TWINS.map((twin) => [twin, ANY_SERVICE2])))));
|
|
202267
|
+
return twinVariables.has(name5);
|
|
202268
|
+
}
|
|
202269
|
+
function taskVariables(text24) {
|
|
202270
|
+
const found = [];
|
|
202271
|
+
for (const match3 of text24.matchAll(TASK_NAME)) {
|
|
202272
|
+
const name5 = match3[1], before = text24.slice(0, match3.index);
|
|
202273
|
+
if (name5.startsWith("ANCHA_") || /--?[A-Za-z][\w-]*[ =]$/.test(before)) continue;
|
|
202274
|
+
const bare = !name5.includes("_");
|
|
202275
|
+
const named3 = escape10(name5);
|
|
202276
|
+
if (bare && !new RegExp(`(?:\\$\\{?|process\\.env\\.|process\\.env\\[['"]|environ(?:\\.get)?\\(?\\[?['"]|getenv\\(['"]|\\bset\\s+|\\bexport\\s+)${named3}\\b|\\b${named3}\\s+(?:is\\s+)?(?:not\\s+set|unset|empty|missing|required|undefined)|\\b${named3}\\s+(?:env(?:ironment)?\\s+)?variable|variable\\s+${named3}\\b|KeyError:\\s*['"]${named3}['"]`).test(text24)) continue;
|
|
202277
|
+
if (!found.includes(name5)) found.push(name5);
|
|
202278
|
+
}
|
|
202279
|
+
return found;
|
|
202280
|
+
}
|
|
202281
|
+
function taskFlags(text24) {
|
|
202282
|
+
return [...new Set([...text24.matchAll(TASK_FLAG)].map((match3) => match3[1]))];
|
|
202283
|
+
}
|
|
202284
|
+
function taskFix(text24, command) {
|
|
202285
|
+
const names5 = taskVariables(text24);
|
|
202286
|
+
const plain3 = names5.find((name5) => !/_(?:FILE|PATH)$/.test(name5)), file3 = names5.find((name5) => /_(?:FILE|PATH)$/.test(name5));
|
|
202287
|
+
if (plain3 !== void 0) return `it looks for its task in ${plain3}; Ancha gives the task in ANCHA_TASK. Add under agent: in ancha.yaml: env: { ${plain3}: "{{task}}" }`;
|
|
202288
|
+
const flags = taskFlags(text24), flag5 = flags.find((f2) => !f2.endsWith("-file")), fileFlag = flags.find((f2) => f2.endsWith("-file"));
|
|
202289
|
+
const shellCommand = command !== void 0 && !/^https?:\/\//.test(command) ? command : void 0;
|
|
202290
|
+
if (flag5 !== void 0 && !shellCommand?.includes(flag5)) {
|
|
202291
|
+
return `it takes its task with ${flag5}; Ancha gives the task in ANCHA_TASK. In ancha.yaml, set agent.command to: ${shellCommand === void 0 ? "<its command>" : shellCommand} ${flag5} "$ANCHA_TASK"`;
|
|
202292
|
+
}
|
|
202293
|
+
if (file3 !== void 0) return `it looks for a file with its task in ${file3}; Ancha writes the task to a file at {{task_file}}. Add under agent: in ancha.yaml: env: { ${file3}: "{{task_file}}" }`;
|
|
202294
|
+
if (fileFlag !== void 0 && !shellCommand?.includes(fileFlag)) {
|
|
202295
|
+
return `it reads its task from the file given with ${fileFlag}; Ancha writes the task to a file at {{task_file}}. Add under agent: in ancha.yaml: env: { TASK_FILE: "{{task_file}}" }, and add ${fileFlag} "$TASK_FILE" to agent.command`;
|
|
202296
|
+
}
|
|
202297
|
+
return void 0;
|
|
202298
|
+
}
|
|
202299
|
+
function keyFix(lines, context3) {
|
|
202300
|
+
for (const line2 of [...lines].reverse()) {
|
|
202301
|
+
if (!MISSING.test(line2)) continue;
|
|
202302
|
+
const name5 = [...line2.matchAll(CREDENTIAL)].map((match3) => match3[1]).find((found) => !found.startsWith("ANCHA_") && !givenByTwins(found));
|
|
202303
|
+
if (name5 === void 0) continue;
|
|
202304
|
+
return context3.target === "cloud" ? `it needs ${name5}: run ancha secrets set ${name5} in the project, which stores it in your workspace and lists it under agent.pass_env in ancha.yaml` : `it needs ${name5}: set it in this shell and list it under agent.pass_env in ancha.yaml (or pass --pass-env ${name5})`;
|
|
202305
|
+
}
|
|
202306
|
+
return void 0;
|
|
202307
|
+
}
|
|
202308
|
+
function missingFix(text24, context3) {
|
|
202309
|
+
const cloud = context3.target === "cloud";
|
|
202310
|
+
const notFoundCommand = /(?:^|\n|: )([\w./@+-]+): (?:command )?not found\b/.exec(text24) ?? /(?:^|\n)(?:sh|bash|zsh|\/bin\/sh)(?:: line \d+|: \d+)?: ([\w./@+-]+): not found/.exec(text24);
|
|
202311
|
+
const packageName = /Cannot find package '([^']+)'/.exec(text24)?.[1];
|
|
202312
|
+
const required4 = /Cannot find module '([^']+)'/.exec(text24)?.[1];
|
|
202313
|
+
const requiredFile = required4 !== void 0 && /^(?:\.{1,2}[/\\]|[/\\]|[A-Za-z]:\\)|\.(?:[cm]?[jt]s|py|sh)$/.test(required4);
|
|
202314
|
+
const missingFile = (requiredFile ? required4 : void 0) ?? /can't open file '([^']+)'/.exec(text24)?.[1] ?? /No such file or directory: '([^']+)'/.exec(text24)?.[1];
|
|
202315
|
+
const module = packageName ?? (requiredFile ? void 0 : required4);
|
|
202316
|
+
const pythonModule = /No module named '([^']+)'/.exec(text24)?.[1];
|
|
202317
|
+
const install = cloud ? "the cloud machine installs what the project's manifests list (agent.install in ancha.yaml sets the command)" : "install the project's dependencies";
|
|
202318
|
+
if (module === void 0 && missingFile !== void 0) {
|
|
202319
|
+
const file3 = missingFile.replace(/^.*[/\\](?=[^/\\]+$)/, "");
|
|
202320
|
+
return cloud ? `it could not find ${file3}: check the path in agent.command in ancha.yaml; the cloud machine has the project's files, so a built or gitignored file is built by agent.install or added with --bundle-file` : `it could not find ${file3}: check the path in agent.command in ancha.yaml (it runs in the project folder)`;
|
|
202321
|
+
}
|
|
202322
|
+
if (module !== void 0) return `its dependency ${module} is not installed: add it to package.json; ${install}`;
|
|
202323
|
+
if (pythonModule !== void 0) return `its dependency ${pythonModule} is not installed: add it to requirements.txt or pyproject.toml; ${install}`;
|
|
202324
|
+
if (notFoundCommand !== null) return `its command ${notFoundCommand[1]} was not found: check agent.command in ancha.yaml, or make it a dependency of the project; ${install}`;
|
|
202325
|
+
return void 0;
|
|
202326
|
+
}
|
|
202327
|
+
function likelyFix(logTail3, context3 = {}) {
|
|
202328
|
+
const task2 = taskFix(logTail3.join("\n"), context3.command);
|
|
202329
|
+
if (task2 !== void 0 || context3.withheld !== void 0) return task2 ?? context3.withheld;
|
|
202330
|
+
const errors2 = logTail3.filter((line2) => /error|exception|fatal|panic|missing|required|usage|not set|not found|cannot|can't/i.test(line2));
|
|
202331
|
+
for (const lines of [errors2, logTail3]) {
|
|
202332
|
+
const fix = lines.length === 0 ? void 0 : keyFix(lines, context3) ?? missingFix(lines.join("\n"), context3);
|
|
202333
|
+
if (fix !== void 0) return fix;
|
|
202334
|
+
}
|
|
202335
|
+
return void 0;
|
|
202336
|
+
}
|
|
202337
|
+
var TASK_WORD, TASK_NAME, TASK_FLAG, CREDENTIAL, MISSING, twinVariables, ANY_SERVICE2, escape10;
|
|
202338
|
+
var init_agent_fix = __esm({
|
|
202339
|
+
"backend/src/agent-fix.ts"() {
|
|
202340
|
+
"use strict";
|
|
202341
|
+
init_src();
|
|
202342
|
+
TASK_WORD = "(?:TASKS?|PROMPTS?|QUERY|QUERIES|INSTRUCTIONS?|MESSAGES?|REQUESTS?|INPUTS?)";
|
|
202343
|
+
TASK_NAME = new RegExp(`(?<![A-Za-z0-9_])((?:[A-Z][A-Z0-9]*_)*${TASK_WORD}(?:_[A-Z0-9]+)*)(?![A-Za-z0-9_])`, "g");
|
|
202344
|
+
TASK_FLAG = /(?<![\w-])(--(?:task|prompt|message|input|query|instructions?|request)(?:-file)?)(?![\w-])/g;
|
|
202345
|
+
CREDENTIAL = /(?<![A-Za-z0-9_])([A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*_(?:KEY|TOKEN|SECRET|PASSWORD))(?![A-Za-z0-9_])/g;
|
|
202346
|
+
MISSING = /missing|not set|unset|undefined|required|must be set|no .*(?:key|token)|KeyError|not found|empty|expected/i;
|
|
202347
|
+
ANY_SERVICE2 = { url: "x", hostUrl: "x", token: "x", signingSecret: "x", appToken: "x", apiKey: "x", appKey: "x", webhookToken: "x", fromEmail: "x", address: "x", routingKey: "x", routingKeys: {}, accessKey: "x", accessKeySecret: "x", clientSecret: "x", grpcEndpoint: "x", tlsRootCertificate: "x" };
|
|
202348
|
+
escape10 = (text24) => text24.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
202349
|
+
}
|
|
202350
|
+
});
|
|
202351
|
+
|
|
202086
202352
|
// backend/src/report.ts
|
|
202087
202353
|
import { readFile as readFile7, writeFile as writeFile5 } from "node:fs/promises";
|
|
202088
|
-
import { basename as basename3, dirname as dirname4, join as join8, resolve as resolve7 } from "node:path";
|
|
202354
|
+
import { basename as basename3, dirname as dirname4, join as join8, relative as relative3, resolve as resolve7 } from "node:path";
|
|
202089
202355
|
function okFalseError(response5) {
|
|
202090
202356
|
if (typeof response5 !== "object" || response5 === null || response5.ok !== false) return void 0;
|
|
202091
202357
|
const error64 = response5.error;
|
|
@@ -202131,8 +202397,9 @@ function summarizeScene(sceneId, trials, requestedTrials = trials.length) {
|
|
|
202131
202397
|
for (const issue6 of trialIssues(t)) {
|
|
202132
202398
|
if (harnessIssues.length < MAX_FAILURES_PER_SCENE) harnessIssues.push({ ...issue6, sceneId, trial: t.trial });
|
|
202133
202399
|
}
|
|
202134
|
-
|
|
202135
|
-
|
|
202400
|
+
const exit = t.exit === "invalid" && t.originalExit === "spawn_failed" ? "spawn_failed" : t.exit;
|
|
202401
|
+
if (!t.passed && exit !== "invalid" && !exitedCleanly({ exit, exitCode: t.exitCode }) && agentIssues.length < MAX_FAILURES_PER_SCENE) {
|
|
202402
|
+
agentIssues.push({ sceneId, trial: t.trial, exit, exitCode: t.exitCode, realMs: t.realMs, log: join8(t.dir, "agent.log"), logTail: t.logTail, ...t.invocations !== void 0 && { invocations: t.invocations } });
|
|
202136
202403
|
}
|
|
202137
202404
|
const valid = trialValid(t);
|
|
202138
202405
|
for (const c of t.checks) {
|
|
@@ -202233,6 +202500,70 @@ function crashLines(logTail3) {
|
|
|
202233
202500
|
while (start > 0 && start > last - 2 && ERROR_LINE.test(lines[start - 1])) start--;
|
|
202234
202501
|
return (start >= 0 ? lines.slice(start, start + 3) : lines.slice(-3)).map((line2) => line2.length > CRASH_LINE_MAX ? `${line2.slice(0, CRASH_LINE_MAX)}\u2026` : line2);
|
|
202235
202502
|
}
|
|
202503
|
+
function agentNeverRan(s2) {
|
|
202504
|
+
if (s2.pytest) return void 0;
|
|
202505
|
+
const ended = [];
|
|
202506
|
+
for (const scene2 of s2.scenes) {
|
|
202507
|
+
if ((scene2.agentCalls ?? 0) > 0) return void 0;
|
|
202508
|
+
for (const t of scene2.trialsDetail ?? []) {
|
|
202509
|
+
const issue6 = (scene2.agentIssues ?? []).find((i) => i.trial === t.trial);
|
|
202510
|
+
const spawn4 = t.exit === "spawn_failed" || t.exit === "invalid" && (t.originalExit === "spawn_failed" || (scene2.harnessIssues ?? []).some((i) => i.trial === t.trial && i.message.startsWith("AGENT_SPAWN_FAILED")));
|
|
202511
|
+
if (spawn4) {
|
|
202512
|
+
ended.push({ exit: "spawn_failed", exitCode: t.exitCode, realMs: t.realMs, perEvent: false, issue: issue6 });
|
|
202513
|
+
continue;
|
|
202514
|
+
}
|
|
202515
|
+
if (t.exit !== "exited" || t.exitCode === 0 || t.passed) return void 0;
|
|
202516
|
+
const invocations = issue6?.invocations;
|
|
202517
|
+
if (invocations !== void 0 ? invocations.total === 0 || invocations.failed < invocations.total : t.realMs > NEVER_RAN_MS) return void 0;
|
|
202518
|
+
ended.push({ exit: "exited", exitCode: t.exitCode, realMs: t.realMs, perEvent: invocations !== void 0, issue: issue6 });
|
|
202519
|
+
}
|
|
202520
|
+
}
|
|
202521
|
+
if (ended.length === 0) return void 0;
|
|
202522
|
+
const exits = new Set(ended.map((e) => e.exit)), codes = new Set(ended.map((e) => e.exitCode));
|
|
202523
|
+
const first = ended.find((e) => e.issue !== void 0)?.issue;
|
|
202524
|
+
const cloud = s2.target === "cloud";
|
|
202525
|
+
const withheld = first === void 0 || cloud ? void 0 : withheldHint(first, s2.agentEnvironment);
|
|
202526
|
+
const fix = first === void 0 ? void 0 : likelyFix(first.logTail, { target: s2.target, command: s2.agent, ...withheld !== void 0 && { withheld } });
|
|
202527
|
+
const checksFailed = s2.scenes.reduce((n2, scene2) => n2 + Object.values(scene2.checks).filter((c) => c.required && c.total - c.passed - (c.skipped ?? 0) - (c.invalid ?? 0) > 0).length, 0);
|
|
202528
|
+
const exit = exits.size > 1 ? "mixed" : [...exits][0];
|
|
202529
|
+
return {
|
|
202530
|
+
attempts: ended.length,
|
|
202531
|
+
tests: s2.scenes.filter((scene2) => (scene2.trialsDetail ?? []).length > 0).length,
|
|
202532
|
+
exit,
|
|
202533
|
+
exitCode: codes.size === 1 ? ended[0].exitCode : null,
|
|
202534
|
+
...exit === "exited" && codes.size === 1 && ended[0].exitCode === null && { signal: true },
|
|
202535
|
+
...exit === "exited" && ended.every((e) => e.perEvent) && { perEvent: true },
|
|
202536
|
+
ms: Math.max(...ended.map((e) => e.realMs)),
|
|
202537
|
+
logTail: (first?.logTail ?? []).filter((line2) => !CRASH_NOISE.test(line2)).slice(-10).map((line2) => line2.length > CRASH_LINE_MAX ? `${line2.slice(0, CRASH_LINE_MAX)}\u2026` : line2),
|
|
202538
|
+
...first !== void 0 && !cloud && { log: first.log },
|
|
202539
|
+
...fix !== void 0 && { fix },
|
|
202540
|
+
checksFailed
|
|
202541
|
+
};
|
|
202542
|
+
}
|
|
202543
|
+
function neverRanHeadline(n2) {
|
|
202544
|
+
const time7 = `${n2.attempts === 1 ? "after" : "within"} ${spaced(n2.ms)}`;
|
|
202545
|
+
const how = n2.exit === "spawn_failed" ? n2.exitCode === 127 ? "its command was not found" : "its command could not be started" : n2.exit === "mixed" ? "it stopped before doing anything" : n2.perEvent ? n2.signal ? "it was killed by a signal each time it was started" : n2.exitCode === null ? "it exited with an error each time it was started" : `it exited with code ${n2.exitCode} each time it was started` : n2.signal ? `it was killed by a signal ${time7}` : n2.exitCode === null ? `it exited with an error ${time7}` : `it exited with code ${n2.exitCode} ${time7}`;
|
|
202546
|
+
const where2 = n2.attempts === 1 ? "" : n2.tests > 1 ? ` in all ${n2.attempts} attempts of ${n2.tests} tests` : n2.attempts === 2 ? " in both attempts" : ` in all ${n2.attempts} attempts`;
|
|
202547
|
+
return `Your agent didn't run: ${how}${where2}`;
|
|
202548
|
+
}
|
|
202549
|
+
function neverRanLines(n2, cwd) {
|
|
202550
|
+
const path6 = n2.log === void 0 || cwd === void 0 || relative3(cwd, n2.log).startsWith("..") ? n2.log : relative3(cwd, n2.log);
|
|
202551
|
+
const log2 = path6 === void 0 ? "log (from the cloud machine)" : `log (${path6})`;
|
|
202552
|
+
return [neverRanHeadline(n2), n2.logTail.length === 0 ? ` ${log2}: empty` : ` ${log2}:`, ...n2.logTail.map((line2) => ` ${line2}`), ...n2.fix === void 0 ? [] : [` likely fix: ${n2.fix}`]];
|
|
202553
|
+
}
|
|
202554
|
+
function neverRanChecksLine(n2, runId, out) {
|
|
202555
|
+
if (n2.checksFailed === 0) return void 0;
|
|
202556
|
+
return `${n2.checksFailed} ${n2.checksFailed === 1 ? "check" : "checks"} failed because the agent never ran; ancha explain ${runId}${out === void 0 ? "" : ` --out ${shellWord(out)}`} --all shows them`;
|
|
202557
|
+
}
|
|
202558
|
+
function retryCommands(s2, opts = {}) {
|
|
202559
|
+
const tests = opts.tests !== void 0 && opts.tests.length > 0 && opts.tests.length <= 3 ? ` ${opts.tests.map(shellWord).join(" ")}` : "";
|
|
202560
|
+
if (s2.target === "cloud") return ["ancha agent upload", `ancha run --on cloud${tests}`];
|
|
202561
|
+
const on = s2.target === "docker" ? " --on docker" : s2.target === "local" ? " --on local" : "";
|
|
202562
|
+
return [`ancha run${on}${tests}${opts.out === void 0 ? "" : ` --out ${shellWord(opts.out)}`}`];
|
|
202563
|
+
}
|
|
202564
|
+
function neverRanNextLine(n2, retry) {
|
|
202565
|
+
return `next: ${n2.fix === void 0 ? "fix what its log says" : "make the fix above"}, then ${retry.join(", then ")}`;
|
|
202566
|
+
}
|
|
202236
202567
|
async function writeSummary(run4, summary) {
|
|
202237
202568
|
await writeFile5(join8(run4.dir, "summary.json"), `${JSON.stringify(summary, null, 2)}
|
|
202238
202569
|
`);
|
|
@@ -202262,12 +202593,15 @@ function nonDefaultOut(cwd, out) {
|
|
|
202262
202593
|
function renderSummaryText(s2, opts = {}) {
|
|
202263
202594
|
const lines = s2.replayOf === void 0 ? [] : [`replay of ${s2.replayOf}`];
|
|
202264
202595
|
if (s2.pytest) lines.push(`pytest ${s2.pytest.nodeId}: ${s2.pytest.outcome}${s2.pytest.invalid ? " [invalid]" : !s2.pytest.graded ? " (ungraded)" : ""}`);
|
|
202596
|
+
const never2 = agentNeverRan(s2);
|
|
202597
|
+
if (never2 !== void 0) lines.push(...neverRanLines(never2, opts.cwd));
|
|
202265
202598
|
for (const scene2 of s2.scenes) {
|
|
202266
202599
|
const invalid30 = scene2.invalidTrials ?? 0;
|
|
202267
202600
|
const ok = invalid30 === 0 && !!scene2.counts && meetsPassRate(scene2.counts, s2.minPassRate);
|
|
202268
202601
|
const excluded2 = scene2.trialsDetail.filter((trial) => trial.outcome === "skipped" || trial.outcome === "xfailed").length;
|
|
202269
202602
|
if (s2.pytest && !s2.pytest.graded) lines.push(`\u2014 ${scene2.sceneId} ungraded${excluded2 ? ` (${excluded2} excluded)` : ""}${invalid30 ? " [invalid]" : ""}`);
|
|
202270
202603
|
else lines.push(`${ok ? "\u2713" : "\u2717"} ${scene2.sceneId} ${scene2.passed}/${scene2.counts?.requested ?? scene2.trials} (${pct(scene2.passRate)}%)${invalid30 > 0 ? " [invalid]" : ""}${excluded2 ? ` (${excluded2} excluded)` : ""}`);
|
|
202604
|
+
if (never2 !== void 0) continue;
|
|
202271
202605
|
if (invalid30 > 0) lines.push(` \u2717 harness failure: ${invalid30}/${scene2.trials} trials invalid`);
|
|
202272
202606
|
if ((scene2.skippedJudges ?? 0) > 0) lines.push(` judge grading skipped: ${scene2.skippedJudges} check(s)`);
|
|
202273
202607
|
for (const warning of scene2.warnings ?? []) lines.push(` warning: trial ${warning.trial} ${warning.check}: ${warning.message.replaceAll("\n", "\n ")}`);
|
|
@@ -202309,13 +202643,17 @@ function renderSummaryText(s2, opts = {}) {
|
|
|
202309
202643
|
if (made.length > SUMMARY_ACTIONS_SHOWN) lines.push(` \u2026 ${made.length - SUMMARY_ACTIONS_SHOWN} more`);
|
|
202310
202644
|
}
|
|
202311
202645
|
}
|
|
202646
|
+
const folded = never2 === void 0 ? void 0 : neverRanChecksLine(never2, s2.runId, opts.out);
|
|
202647
|
+
if (folded !== void 0) lines.push(folded);
|
|
202312
202648
|
lines.push("");
|
|
202313
202649
|
lines.push(...strictSummaryLines(s2));
|
|
202314
202650
|
if (s2.comparison !== void 0) lines.push(...comparisonLines(s2.comparison));
|
|
202651
|
+
if ((opts.reproduction ?? []).length > 0) lines.push(renderReproduction(opts.reproduction, { neverRan: never2 !== void 0 }), "");
|
|
202315
202652
|
const noneGraded = s2.scenes.length > 0 && s2.scenes.every((scene2) => scene2.trials > 0 && (scene2.invalidTrials ?? 0) >= scene2.trials);
|
|
202316
202653
|
lines.push(`${s2.pytest && !s2.pytest.graded && !s2.pytest.invalid ? s2.pytest.outcome + " (ungraded)" : noneGraded ? "invalid (no trials graded)" : s2.verdict} (minimum pass rate ${pct(s2.minPassRate)}%) run ${s2.runId}`);
|
|
202317
202654
|
const next2 = nextAfterRun(s2, opts);
|
|
202318
|
-
if (
|
|
202655
|
+
if (never2 !== void 0) lines.push(neverRanNextLine(never2, next2));
|
|
202656
|
+
else if (next2.length > 0) lines.push(`next: ${next2.join(", then ")}`);
|
|
202319
202657
|
return lines.join("\n").replaceAll(PATTERN_NOTE, "") + (lines.some((line2) => line2.includes(PATTERN_NOTE)) ? `
|
|
202320
202658
|
${PATTERN_NOTE.trim()}` : "");
|
|
202321
202659
|
}
|
|
@@ -202332,6 +202670,7 @@ function comparisonLines(comparison2) {
|
|
|
202332
202670
|
return lines;
|
|
202333
202671
|
}
|
|
202334
202672
|
function nextAfterRun(s2, opts = {}) {
|
|
202673
|
+
if (agentNeverRan(s2) !== void 0) return retryCommands(s2, opts);
|
|
202335
202674
|
const out = opts.out === void 0 ? "" : ` --out ${shellWord(opts.out)}`;
|
|
202336
202675
|
const failed = s2.verdict === "fail" || s2.scenes.some((scene2) => scene2.failures.length > 0 || (scene2.agentIssues ?? []).length > 0 || (scene2.harnessIssues ?? []).length > 0 || (scene2.invalidTrials ?? 0) > 0);
|
|
202337
202676
|
if (failed) return [`ancha explain ${s2.runId}${out}`];
|
|
@@ -202340,7 +202679,7 @@ function nextAfterRun(s2, opts = {}) {
|
|
|
202340
202679
|
function uploadHintLine(runId, workspace3, opts = {}) {
|
|
202341
202680
|
return `ancha runs upload ${runId}${opts.out === void 0 ? "" : ` --out ${shellWord(opts.out)}`} sends this run to ${workspace3}`;
|
|
202342
202681
|
}
|
|
202343
|
-
var MAX_FAILURES_PER_SCENE, DEFAULT_RUNS_DIR, exitedCleanly, FALLBACK_EXCERPT_CALLS, round4, trialIssues, trialValid, outcomeOf2, CRASH_NOISE, ERROR_LINE, CRASH_LINE_MAX, pct, SUMMARY_GAPS_SHOWN, SUMMARY_ACTIONS_SHOWN, ANSWER_SOURCES, duration8, shellWord, PATTERN_NOTE;
|
|
202682
|
+
var MAX_FAILURES_PER_SCENE, DEFAULT_RUNS_DIR, exitedCleanly, FALLBACK_EXCERPT_CALLS, round4, trialIssues, trialValid, outcomeOf2, CRASH_NOISE, ERROR_LINE, CRASH_LINE_MAX, NEVER_RAN_MS, spaced, pct, SUMMARY_GAPS_SHOWN, SUMMARY_ACTIONS_SHOWN, ANSWER_SOURCES, duration8, shellWord, PATTERN_NOTE;
|
|
202344
202683
|
var init_report2 = __esm({
|
|
202345
202684
|
"backend/src/report.ts"() {
|
|
202346
202685
|
"use strict";
|
|
@@ -202348,6 +202687,8 @@ var init_report2 = __esm({
|
|
|
202348
202687
|
init_harness_issues2();
|
|
202349
202688
|
init_scenes();
|
|
202350
202689
|
init_actions7();
|
|
202690
|
+
init_reproduction_text();
|
|
202691
|
+
init_agent_fix();
|
|
202351
202692
|
init_src();
|
|
202352
202693
|
MAX_FAILURES_PER_SCENE = 20;
|
|
202353
202694
|
DEFAULT_RUNS_DIR = ".ancha/runs";
|
|
@@ -202360,6 +202701,8 @@ var init_report2 = __esm({
|
|
|
202360
202701
|
CRASH_NOISE = /^\s*$|^\s+at\s|^\s*… \d+ more frames$|^\s*[~^]+\s*$|^\s*[{}]\s*$|^Node\.js v\d/;
|
|
202361
202702
|
ERROR_LINE = /error|exception|fatal|panic/i;
|
|
202362
202703
|
CRASH_LINE_MAX = 200;
|
|
202704
|
+
NEVER_RAN_MS = 5e3;
|
|
202705
|
+
spaced = (ms) => ms < 1e3 ? `${ms} ms` : `${(ms / 1e3).toFixed(1)} s`;
|
|
202363
202706
|
pct = (rate) => String(Math.round(rate * 1e3) / 10);
|
|
202364
202707
|
SUMMARY_GAPS_SHOWN = 10;
|
|
202365
202708
|
SUMMARY_ACTIONS_SHOWN = 8;
|
|
@@ -202411,9 +202754,9 @@ function startAgentProcess(command, opts) {
|
|
|
202411
202754
|
graceEnds = performance.now() + KILL_GRACE_MS;
|
|
202412
202755
|
killTimer = setTimeout(() => signalGroup(pid, "SIGKILL"), KILL_GRACE_MS);
|
|
202413
202756
|
};
|
|
202414
|
-
const outcome3 = new Promise((
|
|
202415
|
-
child2.once("error", (error64) =>
|
|
202416
|
-
child2.once("exit", (code2) =>
|
|
202757
|
+
const outcome3 = new Promise((resolve13) => {
|
|
202758
|
+
child2.once("error", (error64) => resolve13({ kind: "error", error: error64 }));
|
|
202759
|
+
child2.once("exit", (code2) => resolve13({ kind: "exit", code: code2 }));
|
|
202417
202760
|
});
|
|
202418
202761
|
const exited = outcome3.then(async (result) => {
|
|
202419
202762
|
try {
|
|
@@ -202496,7 +202839,7 @@ var init_contained_env = __esm({
|
|
|
202496
202839
|
// backend/src/execution/source.ts
|
|
202497
202840
|
import { constants as constants5 } from "node:fs";
|
|
202498
202841
|
import { chmod as chmod2, lstat, mkdir as mkdir3, open as open2, readdir as readdir2, realpath } from "node:fs/promises";
|
|
202499
|
-
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute3, join as join9, relative as
|
|
202842
|
+
import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute3, join as join9, relative as relative4, resolve as resolve8, sep, win32 } from "node:path";
|
|
202500
202843
|
function invalid29(message7) {
|
|
202501
202844
|
return new AnchaError("CONFIG_INVALID", `Cannot stage agent source: ${message7}`, {
|
|
202502
202845
|
hint: "Select only source files or directories. Put Linux dependencies in the runtime image and pass credentials explicitly."
|
|
@@ -202507,7 +202850,7 @@ function excluded(name5) {
|
|
|
202507
202850
|
return lower4.startsWith(".") || EXCLUDED_DIRECTORIES.has(lower4) || EXCLUDED_NAMES.has(lower4) || /\.(?:env|pem|key|p12|pfx|jks|keystore|pyc|pyo)$/.test(lower4);
|
|
202508
202851
|
}
|
|
202509
202852
|
function within(root3, candidate) {
|
|
202510
|
-
const path6 =
|
|
202853
|
+
const path6 = relative4(root3, candidate);
|
|
202511
202854
|
return path6 === "" || path6 !== ".." && !path6.startsWith(`..${sep}`) && !isAbsolute3(path6);
|
|
202512
202855
|
}
|
|
202513
202856
|
function sameFile(a, b) {
|
|
@@ -202539,10 +202882,10 @@ async function stageProject(sourceRoot, selections2, destination, options4 = {})
|
|
|
202539
202882
|
const rootNow = await lstat(source);
|
|
202540
202883
|
if (!sameFile(sourceIdentity, rootNow) || rootNow.isSymbolicLink()) throw invalid29("project directory changed while staging");
|
|
202541
202884
|
const stat2 = await lstat(path6).catch(() => {
|
|
202542
|
-
throw invalid29(`selected source is missing or changed: ${
|
|
202885
|
+
throw invalid29(`selected source is missing or changed: ${relative4(source, path6) || "."}`);
|
|
202543
202886
|
});
|
|
202544
202887
|
if (stat2.isSymbolicLink() || await realpath(path6) !== path6 || !within(source, path6)) {
|
|
202545
|
-
throw invalid29(`symlinks are not allowed: ${
|
|
202888
|
+
throw invalid29(`symlinks are not allowed: ${relative4(source, path6) || "."}`);
|
|
202546
202889
|
}
|
|
202547
202890
|
return stat2;
|
|
202548
202891
|
}
|
|
@@ -202566,7 +202909,7 @@ async function stageProject(sourceRoot, selections2, destination, options4 = {})
|
|
|
202566
202909
|
async function destinationDirectory(path6) {
|
|
202567
202910
|
if (!within(target4, path6)) throw invalid29("staging destination escaped its root");
|
|
202568
202911
|
if (!sameFile(targetIdentity, await lstat(target4)) || await realpath(target4) !== target4) throw invalid29("staging destination changed");
|
|
202569
|
-
const parts3 =
|
|
202912
|
+
const parts3 = relative4(target4, path6).split(sep).filter(Boolean);
|
|
202570
202913
|
let current = target4;
|
|
202571
202914
|
for (const part of parts3) {
|
|
202572
202915
|
current = join9(current, part);
|
|
@@ -202597,7 +202940,7 @@ async function stageProject(sourceRoot, selections2, destination, options4 = {})
|
|
|
202597
202940
|
return;
|
|
202598
202941
|
}
|
|
202599
202942
|
if (excludedPaths.has(path6)) return;
|
|
202600
|
-
const name5 =
|
|
202943
|
+
const name5 = relative4(source, path6);
|
|
202601
202944
|
if (!stat2.isFile()) throw invalid29(`only regular files are supported: ${name5}`);
|
|
202602
202945
|
if (stat2.nlink !== 1) throw invalid29(`hard-linked source files are not allowed: ${name5}`);
|
|
202603
202946
|
if (files2 + 1 > MAX_FILES) throw invalid29(`source exceeds ${MAX_FILES} files`);
|
|
@@ -202705,14 +203048,14 @@ function attachIsolationRelay(options4) {
|
|
|
202705
203048
|
const channels = /* @__PURE__ */ new Map();
|
|
202706
203049
|
let ended = false, readySeen = false, buffer = "", counter = 0;
|
|
202707
203050
|
let resolveReady, rejectReady, resolveClosed;
|
|
202708
|
-
const peerReady = new Promise((
|
|
202709
|
-
resolveReady =
|
|
203051
|
+
const peerReady = new Promise((resolve13, reject3) => {
|
|
203052
|
+
resolveReady = resolve13;
|
|
202710
203053
|
rejectReady = reject3;
|
|
202711
203054
|
});
|
|
202712
203055
|
void peerReady.catch(() => {
|
|
202713
203056
|
});
|
|
202714
|
-
const closed = new Promise((
|
|
202715
|
-
resolveClosed =
|
|
203057
|
+
const closed = new Promise((resolve13) => {
|
|
203058
|
+
resolveClosed = resolve13;
|
|
202716
203059
|
});
|
|
202717
203060
|
const forward = options4.forwardPort === void 0 ? void 0 : createServer2({ allowHalfOpen: true });
|
|
202718
203061
|
let closing;
|
|
@@ -202729,9 +203072,9 @@ function attachIsolationRelay(options4) {
|
|
|
202729
203072
|
}
|
|
202730
203073
|
channels.clear();
|
|
202731
203074
|
options4.output.end();
|
|
202732
|
-
closing = new Promise((
|
|
202733
|
-
if (forward?.listening) forward.close(() =>
|
|
202734
|
-
else
|
|
203075
|
+
closing = new Promise((resolve13) => {
|
|
203076
|
+
if (forward?.listening) forward.close(() => resolve13());
|
|
203077
|
+
else resolve13();
|
|
202735
203078
|
}).finally(resolveClosed);
|
|
202736
203079
|
}
|
|
202737
203080
|
function send2(frame2) {
|
|
@@ -202859,9 +203202,9 @@ function attachIsolationRelay(options4) {
|
|
|
202859
203202
|
options4.output.once("close", () => fail6());
|
|
202860
203203
|
options4.signal?.addEventListener("abort", abort, { once: true });
|
|
202861
203204
|
if (options4.signal?.aborted) abort();
|
|
202862
|
-
const forwardReady = new Promise((
|
|
203205
|
+
const forwardReady = new Promise((resolve13, reject3) => {
|
|
202863
203206
|
if (!forward || ended) {
|
|
202864
|
-
|
|
203207
|
+
resolve13();
|
|
202865
203208
|
return;
|
|
202866
203209
|
}
|
|
202867
203210
|
forward.on("connection", (socket) => {
|
|
@@ -202880,7 +203223,7 @@ function attachIsolationRelay(options4) {
|
|
|
202880
203223
|
});
|
|
202881
203224
|
forward.listen(options4.forwardPort, "127.0.0.1", () => {
|
|
202882
203225
|
if (ended) forward.close();
|
|
202883
|
-
|
|
203226
|
+
resolve13();
|
|
202884
203227
|
});
|
|
202885
203228
|
});
|
|
202886
203229
|
const ready3 = Promise.all([peerReady, forwardReady]).then(() => {
|
|
@@ -203063,7 +203406,7 @@ async function preflightExecution(agent, scenes = [], signal) {
|
|
|
203063
203406
|
if (agent.slackTransport === "socket") throw new AnchaError("CONFIG_INVALID", "Contained Slack Socket Mode is not qualified yet; use the event feed or managed HTTP delivery");
|
|
203064
203407
|
if (scenes.some((scene2) => scene2.twins.includes("google-ads"))) throw new AnchaError("CONFIG_INVALID", "Contained Google Ads gRPC is not qualified yet; this run cannot use a host-process fallback");
|
|
203065
203408
|
const status4 = await executionRuntimeStatus();
|
|
203066
|
-
if (!status4.available) throw new AnchaError("AGENT_UNREACHABLE", status4.message, { hint: "Run ancha execution doctor
|
|
203409
|
+
if (!status4.available) throw new AnchaError("AGENT_UNREACHABLE", status4.message, { hint: "Run ancha execution doctor. Container execution never falls back to a host process." });
|
|
203067
203410
|
await inspectImage(policy.image, status4.context, signal);
|
|
203068
203411
|
await inspectImage(RELAY_IMAGE, status4.context, signal);
|
|
203069
203412
|
}
|
|
@@ -203140,7 +203483,7 @@ async function startContainedAgent(command, opts) {
|
|
|
203140
203483
|
failures.push("gateway");
|
|
203141
203484
|
}
|
|
203142
203485
|
await rm(temporary, { force: true, recursive: true });
|
|
203143
|
-
if (failures.length) throw new AnchaError("INTERNAL", `Container cleanup incomplete: ${failures.join(", ")}`, { hint: "Inspect ancha execution list
|
|
203486
|
+
if (failures.length) throw new AnchaError("INTERNAL", `Container cleanup incomplete: ${failures.join(", ")}`, { hint: "Inspect ancha execution list before starting another run." });
|
|
203144
203487
|
})();
|
|
203145
203488
|
const abort = () => {
|
|
203146
203489
|
void cleanup().catch(() => {
|
|
@@ -203153,11 +203496,16 @@ async function startContainedAgent(command, opts) {
|
|
|
203153
203496
|
await mkdir4(join10(temporary, "project", ".ancha-records"), { recursive: true });
|
|
203154
203497
|
await copyFile2(records3, join10(temporary, "project", CONTAINER_RECORDS));
|
|
203155
203498
|
}
|
|
203499
|
+
const withTask = opts.agent.mode !== "endpoint";
|
|
203500
|
+
if (withTask) {
|
|
203501
|
+
await mkdir4(join10(temporary, "project", ".ancha-task"), { recursive: true });
|
|
203502
|
+
await writeFile6(join10(temporary, "project", CONTAINER_TASK), agentTask(opts.scene, opts.runtime));
|
|
203503
|
+
}
|
|
203156
203504
|
startup2.throwIfAborted();
|
|
203157
203505
|
createdVolume = true;
|
|
203158
|
-
await run4(["volume", "create", "--label", `${
|
|
203506
|
+
await run4(["volume", "create", "--label", `${LABEL2}=true`, volume]);
|
|
203159
203507
|
containers.add(helperName);
|
|
203160
|
-
await run4(["create", "--name", helperName, "--label", `${
|
|
203508
|
+
await run4(["create", "--name", helperName, "--label", `${LABEL2}=true`, "--network", "none", "--cap-drop", "ALL", "--security-opt", "no-new-privileges=true", "--mount", `type=volume,source=${volume},target=/workspace`, "--entrypoint", "/bin/sh", relayImage.id, "-c", "find /workspace -type d -exec chmod 755 {} +; find /workspace -type f -exec chmod a+r {} +; ln -s /opt/ancha/node_modules /workspace/node_modules"]);
|
|
203161
203509
|
await run4(["cp", join10(temporary, "project") + "/.", `${helperName}:/workspace`]);
|
|
203162
203510
|
await run4(["start", "-a", helperName]);
|
|
203163
203511
|
await run4(["rm", helperName]);
|
|
@@ -203170,7 +203518,7 @@ async function startContainedAgent(command, opts) {
|
|
|
203170
203518
|
"--name",
|
|
203171
203519
|
agentName,
|
|
203172
203520
|
"--label",
|
|
203173
|
-
`${
|
|
203521
|
+
`${LABEL2}=true`,
|
|
203174
203522
|
"--network",
|
|
203175
203523
|
"none",
|
|
203176
203524
|
...hardening,
|
|
@@ -203197,7 +203545,7 @@ async function startContainedAgent(command, opts) {
|
|
|
203197
203545
|
"--name",
|
|
203198
203546
|
relayName,
|
|
203199
203547
|
"--label",
|
|
203200
|
-
`${
|
|
203548
|
+
`${LABEL2}=true`,
|
|
203201
203549
|
"--network",
|
|
203202
203550
|
`container:${agentName}`,
|
|
203203
203551
|
"--cap-drop",
|
|
@@ -203239,7 +203587,7 @@ async function startContainedAgent(command, opts) {
|
|
|
203239
203587
|
startup2.throwIfAborted();
|
|
203240
203588
|
const mapped = gateway.rewrite(`http://127.0.0.1:${RELAY_PORT}`);
|
|
203241
203589
|
const allowed2 = explicitEnvironment(policy.env, opts.inheritedEnv);
|
|
203242
|
-
const runtime2 = { ...opts.runtime, ...opts.runtime?.attempt && { attempt: { ...opts.runtime.attempt, stateDir: "/state", records: records3 === void 0 ? void 0 : `/workspace/${CONTAINER_RECORDS}` } } };
|
|
203590
|
+
const runtime2 = { ...opts.runtime, ...withTask && { taskFile: `/workspace/${CONTAINER_TASK}` }, ...opts.runtime?.attempt && { attempt: { ...opts.runtime.attempt, stateDir: "/state", records: records3 === void 0 ? void 0 : `/workspace/${CONTAINER_RECORDS}` } } };
|
|
203243
203591
|
const values2 = containedEnvironment({ ...opts, secretValues: opts.inheritedEnv, policy, mapped, runtime: runtime2, paths: { path: image2.path, home: "/home/ancha", tmp: "/tmp", state: "/state" } });
|
|
203244
203592
|
const names5 = Object.keys(values2);
|
|
203245
203593
|
if (names5.some((name5) => !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name5))) throw new AnchaError("CONFIG_INVALID", "Invalid agent environment variable name");
|
|
@@ -203291,9 +203639,9 @@ async function startContainedAgent(command, opts) {
|
|
|
203291
203639
|
});
|
|
203292
203640
|
}
|
|
203293
203641
|
});
|
|
203294
|
-
const outcome3 = new Promise((
|
|
203295
|
-
child2.once("error", (error64) =>
|
|
203296
|
-
child2.once("close", (code2) =>
|
|
203642
|
+
const outcome3 = new Promise((resolve13) => {
|
|
203643
|
+
child2.once("error", (error64) => resolve13({ kind: "error", error: error64 }));
|
|
203644
|
+
child2.once("close", (code2) => resolve13(bridgeFailed ? { kind: "error", error: new Error("Container bridge failed or agent output exceeded 8 MiB") } : { kind: "exit", code: code2 }));
|
|
203297
203645
|
});
|
|
203298
203646
|
const exited = outcome3.then(async (result) => {
|
|
203299
203647
|
try {
|
|
@@ -203316,11 +203664,12 @@ async function startContainedAgent(command, opts) {
|
|
|
203316
203664
|
throw error64;
|
|
203317
203665
|
}
|
|
203318
203666
|
}
|
|
203319
|
-
var exec, RELAY_IMAGE, RELAY_PORT, LOG_LIMIT,
|
|
203667
|
+
var exec, RELAY_IMAGE, RELAY_PORT, LOG_LIMIT, LABEL2, CONTAINER_RECORDS, CONTAINER_TASK;
|
|
203320
203668
|
var init_docker = __esm({
|
|
203321
203669
|
"backend/src/execution/docker.ts"() {
|
|
203322
203670
|
"use strict";
|
|
203323
203671
|
init_src();
|
|
203672
|
+
init_agent_env();
|
|
203324
203673
|
init_contained_env();
|
|
203325
203674
|
init_runtime3();
|
|
203326
203675
|
init_policy();
|
|
@@ -203332,8 +203681,9 @@ var init_docker = __esm({
|
|
|
203332
203681
|
RELAY_IMAGE = "node:24-slim";
|
|
203333
203682
|
RELAY_PORT = 18991;
|
|
203334
203683
|
LOG_LIMIT = 8 * 1024 * 1024;
|
|
203335
|
-
|
|
203684
|
+
LABEL2 = "dev.ancha.execution";
|
|
203336
203685
|
CONTAINER_RECORDS = ".ancha-records/records.jsonl";
|
|
203686
|
+
CONTAINER_TASK = ".ancha-task/task.txt";
|
|
203337
203687
|
}
|
|
203338
203688
|
});
|
|
203339
203689
|
|
|
@@ -203478,9 +203828,17 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
203478
203828
|
await chmod3(records3, 292);
|
|
203479
203829
|
await chmod3(directory, 457);
|
|
203480
203830
|
}
|
|
203831
|
+
let taskFile;
|
|
203832
|
+
if (opts.agent.mode !== "endpoint") {
|
|
203833
|
+
const directory = await mkdtemp2(join11(paths2.root, "task-"));
|
|
203834
|
+
taskFile = join11(directory, "task.txt");
|
|
203835
|
+
await writeFile7(taskFile, agentTask(opts.scene, opts.runtime), { mode: 292 });
|
|
203836
|
+
await chmod3(taskFile, 292);
|
|
203837
|
+
await chmod3(directory, 457);
|
|
203838
|
+
}
|
|
203481
203839
|
gateway = await (deps.gateway ?? startIsolationGateway)({ env: opts.env, ...opts.session && { session: opts.session }, modelHosts, port: unsafe ? 0 : 18991 });
|
|
203482
203840
|
const mapped = gateway.rewrite(unsafe ? gateway.url : VM_GATEWAY_ORIGIN);
|
|
203483
|
-
const agentRuntime = { ...opts.runtime, ...opts.runtime?.attempt && { attempt: { ...opts.runtime.attempt, stateDir: paths2.state, records: records3 } } };
|
|
203841
|
+
const agentRuntime = { ...opts.runtime, ...taskFile !== void 0 && { taskFile }, ...opts.runtime?.attempt && { attempt: { ...opts.runtime.attempt, stateDir: paths2.state, records: records3 } } };
|
|
203484
203842
|
const values2 = containedEnvironment({
|
|
203485
203843
|
...opts,
|
|
203486
203844
|
secretValues: descriptor2.secretValues,
|
|
@@ -203530,10 +203888,10 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
203530
203888
|
};
|
|
203531
203889
|
child2.stdout?.on("data", log2);
|
|
203532
203890
|
child2.stderr?.on("data", log2);
|
|
203533
|
-
const closed = new Promise((
|
|
203534
|
-
const outcome3 = new Promise((
|
|
203535
|
-
child2.once("error", () =>
|
|
203536
|
-
child2.once("exit", (code2) =>
|
|
203891
|
+
const closed = new Promise((resolve13) => child2.once("close", () => resolve13()));
|
|
203892
|
+
const outcome3 = new Promise((resolve13) => {
|
|
203893
|
+
child2.once("error", () => resolve13({ kind: "error", error: new AnchaError("AGENT_UNREACHABLE", "The agent process could not be started.") }));
|
|
203894
|
+
child2.once("exit", (code2) => resolve13({ kind: "exit", code: code2 }));
|
|
203537
203895
|
});
|
|
203538
203896
|
const exited = outcome3.then(async (result) => {
|
|
203539
203897
|
try {
|
|
@@ -203548,7 +203906,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
203548
203906
|
void exited.catch(() => {
|
|
203549
203907
|
});
|
|
203550
203908
|
const startup2 = AbortSignal.any([AbortSignal.timeout(1e4), ...opts.signal ? [opts.signal] : [], ...opts.startupSignal ? [opts.startupSignal] : []]);
|
|
203551
|
-
await new Promise((
|
|
203909
|
+
await new Promise((resolve13, reject3) => {
|
|
203552
203910
|
const pipe2 = unsafe ? void 0 : child2.stdio[3];
|
|
203553
203911
|
let received = "";
|
|
203554
203912
|
const remove5 = () => {
|
|
@@ -203560,7 +203918,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
203560
203918
|
};
|
|
203561
203919
|
const ready3 = () => {
|
|
203562
203920
|
remove5();
|
|
203563
|
-
|
|
203921
|
+
resolve13();
|
|
203564
203922
|
};
|
|
203565
203923
|
const failed = () => {
|
|
203566
203924
|
remove5();
|
|
@@ -203604,6 +203962,7 @@ var init_vm = __esm({
|
|
|
203604
203962
|
"backend/src/execution/vm.ts"() {
|
|
203605
203963
|
"use strict";
|
|
203606
203964
|
init_src();
|
|
203965
|
+
init_agent_env();
|
|
203607
203966
|
init_contained_env();
|
|
203608
203967
|
init_gateway();
|
|
203609
203968
|
init_runtime3();
|
|
@@ -203616,17 +203975,26 @@ var init_vm = __esm({
|
|
|
203616
203975
|
});
|
|
203617
203976
|
|
|
203618
203977
|
// backend/src/execution/launch.ts
|
|
203978
|
+
import { writeFile as writeFile8 } from "node:fs/promises";
|
|
203979
|
+
import { resolve as resolve9 } from "node:path";
|
|
203619
203980
|
async function launchAgent(command, opts) {
|
|
203620
203981
|
const runtime2 = trustedRuntime();
|
|
203621
203982
|
if (runtime2 === "fly-vm" || runtime2 === "unsafe-local") return startVmAgent(command, opts);
|
|
203622
203983
|
if (opts.agent.execution?.mode === "container") return startContainedAgent(command, opts);
|
|
203984
|
+
let agentRuntime = opts.runtime;
|
|
203985
|
+
if (opts.agent.mode !== "endpoint") {
|
|
203986
|
+
const taskFile = resolve9(opts.dir, TASK_FILE);
|
|
203987
|
+
await writeFile8(taskFile, agentTask(opts.scene, opts.runtime), { mode: 384 });
|
|
203988
|
+
agentRuntime = { ...opts.runtime, taskFile };
|
|
203989
|
+
}
|
|
203623
203990
|
return startAgentProcess(command, {
|
|
203624
203991
|
cwd: opts.agent.cwd,
|
|
203625
|
-
env: agentEnv(opts.env, opts.scene, opts.agent, opts.trial, hostEnvironment(opts.inheritedEnv, opts.agent).env, opts.session,
|
|
203992
|
+
env: agentEnv(opts.env, opts.scene, opts.agent, opts.trial, hostEnvironment(opts.inheritedEnv, opts.agent).env, opts.session, agentRuntime),
|
|
203626
203993
|
logFd: opts.logFd,
|
|
203627
203994
|
signal: opts.signal
|
|
203628
203995
|
});
|
|
203629
203996
|
}
|
|
203997
|
+
var TASK_FILE;
|
|
203630
203998
|
var init_launch = __esm({
|
|
203631
203999
|
"backend/src/execution/launch.ts"() {
|
|
203632
204000
|
"use strict";
|
|
@@ -203635,11 +204003,12 @@ var init_launch = __esm({
|
|
|
203635
204003
|
init_docker();
|
|
203636
204004
|
init_runtime3();
|
|
203637
204005
|
init_vm();
|
|
204006
|
+
TASK_FILE = "task.txt";
|
|
203638
204007
|
}
|
|
203639
204008
|
});
|
|
203640
204009
|
|
|
203641
204010
|
// backend/src/runner/artifacts.ts
|
|
203642
|
-
import { open as open3, writeFile as
|
|
204011
|
+
import { open as open3, writeFile as writeFile9 } from "node:fs/promises";
|
|
203643
204012
|
import { join as join12 } from "node:path";
|
|
203644
204013
|
async function logTail2(path6) {
|
|
203645
204014
|
const file3 = await open3(path6, "r");
|
|
@@ -203677,23 +204046,23 @@ async function captureTrial(backend, envId, sessionId, dir, scene2, judge = {},
|
|
|
203677
204046
|
const capture3 = await evaluateJudges(scene2, frozen, judge);
|
|
203678
204047
|
onCaptured?.(capture3);
|
|
203679
204048
|
await Promise.all([
|
|
203680
|
-
|
|
204049
|
+
writeFile9(join12(dir, "trace.jsonl"), capture3.trace.map((e) => `${JSON.stringify(e)}
|
|
203681
204050
|
`).join("")),
|
|
203682
|
-
|
|
204051
|
+
writeFile9(join12(dir, "state.json"), `${JSON.stringify(capture3.state, null, 2)}
|
|
203683
204052
|
`),
|
|
203684
|
-
|
|
204053
|
+
writeFile9(join12(dir, "checks.json"), `${JSON.stringify(capture3.checks, null, 2)}
|
|
203685
204054
|
`),
|
|
203686
204055
|
// Every people-model call, in order: who, what kind, which model, hashes, tokens, cost and the answer. No credentials.
|
|
203687
|
-
...capture3.people?.length ? [
|
|
204056
|
+
...capture3.people?.length ? [writeFile9(join12(dir, "people.jsonl"), capture3.people.map((record11) => `${JSON.stringify(record11)}
|
|
203688
204057
|
`).join(""))] : [],
|
|
203689
204058
|
// A replay: how many answers came from the recording, how many live, and where it first diverged.
|
|
203690
|
-
...capture3.peopleReplay ? [
|
|
204059
|
+
...capture3.peopleReplay ? [writeFile9(join12(dir, "people-replay.json"), `${JSON.stringify(capture3.peopleReplay, null, 2)}
|
|
203691
204060
|
`)] : [],
|
|
203692
204061
|
// What passed between the agent and people, for the console; fact ids only, never values.
|
|
203693
|
-
...capture3.peopleTimeline ? [
|
|
204062
|
+
...capture3.peopleTimeline ? [writeFile9(join12(dir, "people-timeline.json"), `${JSON.stringify(capture3.peopleTimeline, null, 2)}
|
|
203694
204063
|
`)] : [],
|
|
203695
204064
|
// Why each failed check failed, from the world's records (explain v2).
|
|
203696
|
-
...capture3.explanations?.length ? [
|
|
204065
|
+
...capture3.explanations?.length ? [writeFile9(join12(dir, "explain.json"), `${JSON.stringify(capture3.explanations, null, 2)}
|
|
203697
204066
|
`)] : []
|
|
203698
204067
|
]);
|
|
203699
204068
|
return capture3;
|
|
@@ -203737,7 +204106,7 @@ var init_budget = __esm({
|
|
|
203737
204106
|
import { closeSync as closeSync2, openSync as openSync2, writeSync as writeSync3 } from "node:fs";
|
|
203738
204107
|
import { mkdir as mkdir6 } from "node:fs/promises";
|
|
203739
204108
|
import { createServer as createServer3 } from "node:net";
|
|
203740
|
-
import { join as join13, resolve as
|
|
204109
|
+
import { join as join13, resolve as resolve10 } from "node:path";
|
|
203741
204110
|
import { setTimeout as sleep6 } from "node:timers/promises";
|
|
203742
204111
|
function deadline2(ms) {
|
|
203743
204112
|
const controller = new AbortController();
|
|
@@ -203766,13 +204135,13 @@ async function abortable(promise2, signal) {
|
|
|
203766
204135
|
}
|
|
203767
204136
|
async function reservePort(used) {
|
|
203768
204137
|
const rejected = [];
|
|
203769
|
-
const close = (server) => new Promise((
|
|
204138
|
+
const close = (server) => new Promise((resolve13, reject3) => server.close((error64) => error64 ? reject3(error64) : resolve13()));
|
|
203770
204139
|
try {
|
|
203771
204140
|
for (; ; ) {
|
|
203772
204141
|
const socket = createServer3();
|
|
203773
|
-
await new Promise((
|
|
204142
|
+
await new Promise((resolve13, reject3) => {
|
|
203774
204143
|
socket.once("error", reject3);
|
|
203775
|
-
socket.listen(0, "127.0.0.1",
|
|
204144
|
+
socket.listen(0, "127.0.0.1", resolve13);
|
|
203776
204145
|
});
|
|
203777
204146
|
const address8 = socket.address();
|
|
203778
204147
|
if (address8 === null || typeof address8 === "string") {
|
|
@@ -203850,7 +204219,7 @@ async function runEndpointTrial(spec) {
|
|
|
203850
204219
|
const port = agent.start !== void 0 ? await reservePort(spec.reservedPorts ?? /* @__PURE__ */ new Set()) : void 0;
|
|
203851
204220
|
let released = false;
|
|
203852
204221
|
try {
|
|
203853
|
-
const clockFile = agent.clock === "node" ?
|
|
204222
|
+
const clockFile = agent.clock === "node" ? resolve10(dir, "clock.json") : void 0;
|
|
203854
204223
|
const session2 = await backend.prepareTrial(env.id, { mode: "endpoint", idleMs: agent.idleMs, slackTransport: agent.slackTransport ?? "http", ...agent.setupCalls && { setupCalls: true }, ...clockFile && { clockFile }, ...agent.execution?.mode === "container" && { clientOrigin: "http://127.0.0.1:18991" } });
|
|
203855
204224
|
const runtime2 = { ...port && { port: port.port }, ...spec.attempt && { attempt: spec.attempt } };
|
|
203856
204225
|
const vars = agentTemplateVars(env.id, env.services, scene2.task ?? "", trial, session2, runtime2, env.mcp);
|
|
@@ -203993,16 +204362,16 @@ async function reserve(used) {
|
|
|
203993
204362
|
for (let n2 = 0; n2 < 100; n2++) {
|
|
203994
204363
|
const server = createServer4();
|
|
203995
204364
|
held.push(server);
|
|
203996
|
-
await new Promise((
|
|
204365
|
+
await new Promise((resolve13, reject3) => {
|
|
203997
204366
|
server.once("error", reject3);
|
|
203998
|
-
server.listen(0, "127.0.0.1",
|
|
204367
|
+
server.listen(0, "127.0.0.1", resolve13);
|
|
203999
204368
|
});
|
|
204000
204369
|
const address8 = server.address();
|
|
204001
204370
|
if (!address8 || typeof address8 === "string") throw new Error("local agent port unavailable");
|
|
204002
204371
|
if (used.has(address8.port)) continue;
|
|
204003
204372
|
used.add(address8.port);
|
|
204004
204373
|
chosen = true;
|
|
204005
|
-
return { port: address8.port, release: () => new Promise((
|
|
204374
|
+
return { port: address8.port, release: () => new Promise((resolve13, reject3) => server.close((error64) => error64 ? reject3(error64) : resolve13())) };
|
|
204006
204375
|
}
|
|
204007
204376
|
throw new Error("fresh local agent port unavailable");
|
|
204008
204377
|
} finally {
|
|
@@ -204522,8 +204891,8 @@ var init_invalid_trial = __esm({
|
|
|
204522
204891
|
|
|
204523
204892
|
// backend/src/runner/run.ts
|
|
204524
204893
|
import { createHash as createHash55, randomInt } from "node:crypto";
|
|
204525
|
-
import { access as access3, mkdir as mkdir11, readFile as readFile8, writeFile as
|
|
204526
|
-
import { dirname as dirname7, join as join18, relative as
|
|
204894
|
+
import { access as access3, mkdir as mkdir11, readFile as readFile8, writeFile as writeFile10 } from "node:fs/promises";
|
|
204895
|
+
import { dirname as dirname7, join as join18, relative as relative5, resolve as resolve11 } from "node:path";
|
|
204527
204896
|
function interrupted(dir) {
|
|
204528
204897
|
return new AnchaError("USAGE", "run interrupted", dir === void 0 ? {} : { hint: `partial results in ${dir}` });
|
|
204529
204898
|
}
|
|
@@ -204535,11 +204904,11 @@ function newRunId(now11) {
|
|
|
204535
204904
|
}
|
|
204536
204905
|
async function recordsFor(scenePath, root3 = process.cwd()) {
|
|
204537
204906
|
if (scenePath === void 0) return void 0;
|
|
204538
|
-
const top =
|
|
204539
|
-
for (let dir = dirname7(
|
|
204907
|
+
const top = resolve11(root3);
|
|
204908
|
+
for (let dir = dirname7(resolve11(top, scenePath)); ; dir = dirname7(dir)) {
|
|
204540
204909
|
const file3 = join18(dir, "records.jsonl");
|
|
204541
204910
|
if (await access3(file3).then(() => true, () => false)) return file3;
|
|
204542
|
-
if (dir === top ||
|
|
204911
|
+
if (dir === top || relative5(top, dir).startsWith("..") || dirname7(dir) === dir) return void 0;
|
|
204543
204912
|
}
|
|
204544
204913
|
}
|
|
204545
204914
|
async function createEnvFor(backend, scene2, seed43, path6, people3) {
|
|
@@ -204547,7 +204916,7 @@ async function createEnvFor(backend, scene2, seed43, path6, people3) {
|
|
|
204547
204916
|
return await backend.createEnv(scene2, seed43, { paused: true, ...people3 !== void 0 && { people: people3 } });
|
|
204548
204917
|
} catch (e) {
|
|
204549
204918
|
if (!(e instanceof AnchaError)) throw e;
|
|
204550
|
-
const where2 = path6 === void 0 ? `
|
|
204919
|
+
const where2 = path6 === void 0 ? `test ${scene2.id}` : `test ${scene2.id} (${path6})`;
|
|
204551
204920
|
throw new AnchaError(e.code, `${where2}: ${e.message}`, {
|
|
204552
204921
|
...e.hint !== void 0 && { hint: e.hint },
|
|
204553
204922
|
...e.docs !== void 0 && { docs: e.docs },
|
|
@@ -204584,7 +204953,7 @@ async function executeRun(opts) {
|
|
|
204584
204953
|
for (const scene2 of scenes) validateAgentEnv(scene2, agent);
|
|
204585
204954
|
} else {
|
|
204586
204955
|
const calling = scenes.find((scene2) => scene2.world_rules?.app_calls?.length);
|
|
204587
|
-
if (calling) throw new AnchaError("CONFIG_INVALID", `
|
|
204956
|
+
if (calling) throw new AnchaError("CONFIG_INVALID", `test ${calling.id} has app_calls, which need an app Ancha can call: set agent.url (and agent.start for an app Ancha starts)`);
|
|
204588
204957
|
}
|
|
204589
204958
|
const ids2 = cases.map((item2) => item2.id);
|
|
204590
204959
|
const duplicate2 = ids2.find((id14, i) => ids2.indexOf(id14) !== i);
|
|
@@ -204686,7 +205055,7 @@ async function executeRun(opts) {
|
|
|
204686
205055
|
try {
|
|
204687
205056
|
await mkdir11(outDir, { recursive: true });
|
|
204688
205057
|
await mkdir11(dir);
|
|
204689
|
-
await
|
|
205058
|
+
await writeFile10(join18(dir, "inputs.json"), `${JSON.stringify({
|
|
204690
205059
|
schemaVersion: 1,
|
|
204691
205060
|
cases: frozen.map((value4, index) => ({ ...value4, scene: cases[index].scene })),
|
|
204692
205061
|
// Names only, never values: what a later `ancha runs upload` redacts (hosting spec §3.1).
|
|
@@ -204700,7 +205069,7 @@ async function executeRun(opts) {
|
|
|
204700
205069
|
if (source === void 0) continue;
|
|
204701
205070
|
const text24 = await readFile8(source), copy = join18(dir, "records", `${index}.jsonl`);
|
|
204702
205071
|
await mkdir11(dirname7(copy), { recursive: true });
|
|
204703
|
-
await
|
|
205072
|
+
await writeFile10(copy, text24, { flag: "wx", mode: 384 });
|
|
204704
205073
|
kept.set(item2.id, copy);
|
|
204705
205074
|
results.get(item2.id).records = createHash55("sha256").update(text24).digest("hex");
|
|
204706
205075
|
}
|
|
@@ -204712,7 +205081,7 @@ async function executeRun(opts) {
|
|
|
204712
205081
|
const trial = Math.floor(index / cases.length) + 1 + trialOffset;
|
|
204713
205082
|
const trialDir = join18(dir, `trial-${item2.id}-${trial}`);
|
|
204714
205083
|
const records3 = kept.get(item2.id);
|
|
204715
|
-
const attempt = { id: `${runId}/${item2.id}/${trial}`, caseId: item2.id, stateDir:
|
|
205084
|
+
const attempt = { id: `${runId}/${item2.id}/${trial}`, caseId: item2.id, stateDir: resolve11(trialDir, "agent-state"), seed: seedOf(item2), ...records3 !== void 0 && { records: records3 }, ...opts.recordsDiagnostic && { recordsDiagnostic: { ...opts.recordsDiagnostic, attempt: trial } } };
|
|
204716
205085
|
const startedAt2 = performance.now();
|
|
204717
205086
|
const attemptCancellation = new AbortController();
|
|
204718
205087
|
const attemptSignal = AbortSignal.any([runningSignal, attemptCancellation.signal]);
|
|
@@ -204788,7 +205157,7 @@ async function executeRun(opts) {
|
|
|
204788
205157
|
}
|
|
204789
205158
|
finished++;
|
|
204790
205159
|
results.get(item2.id).trials.push(result);
|
|
204791
|
-
await
|
|
205160
|
+
await writeFile10(join18(trialDir, "result.json"), `${JSON.stringify({ ...result, trace: void 0 }, null, 2)}
|
|
204792
205161
|
`, { flag: "wx", mode: 384 });
|
|
204793
205162
|
onEvent?.({
|
|
204794
205163
|
event: "trial_finished",
|
|
@@ -204855,9 +205224,9 @@ var init_run_store = __esm({
|
|
|
204855
205224
|
// backend/src/baselines.ts
|
|
204856
205225
|
function validateTrialCounts(scene2) {
|
|
204857
205226
|
if (!Number.isSafeInteger(scene2.passed) || !Number.isSafeInteger(scene2.trials) || scene2.trials <= 0 || scene2.passed < 0 || scene2.passed > scene2.trials) {
|
|
204858
|
-
throw new AnchaError("USAGE", `invalid passed/trial counts for
|
|
205227
|
+
throw new AnchaError("USAGE", `invalid passed/trial counts for test ${scene2.sceneId}`);
|
|
204859
205228
|
}
|
|
204860
|
-
if (!Number.isFinite(scene2.passRate) || scene2.passRate < 0 || scene2.passRate > 1) throw new AnchaError("USAGE", `invalid pass rate for
|
|
205229
|
+
if (!Number.isFinite(scene2.passRate) || scene2.passRate < 0 || scene2.passRate > 1) throw new AnchaError("USAGE", `invalid pass rate for test ${scene2.sceneId}`);
|
|
204861
205230
|
}
|
|
204862
205231
|
function assertComparableSummaries(current, baseline) {
|
|
204863
205232
|
try {
|
|
@@ -204872,12 +205241,12 @@ function assertComparableSummaries(current, baseline) {
|
|
|
204872
205241
|
const ids2 = (s2) => s2.scenes.map((scene2) => scene2.sceneId).sort();
|
|
204873
205242
|
const currentIds = ids2(current), baselineIds = ids2(baseline);
|
|
204874
205243
|
if (new Set(currentIds).size !== currentIds.length || JSON.stringify(currentIds) !== JSON.stringify(baselineIds) || currentIds.length === 0) {
|
|
204875
|
-
throw new AnchaError("USAGE", "comparison requires the same complete
|
|
205244
|
+
throw new AnchaError("USAGE", "comparison requires the same complete set of tests", { hint: "save a fresh baseline after intentional test changes" });
|
|
204876
205245
|
}
|
|
204877
205246
|
for (const id14 of currentIds) {
|
|
204878
205247
|
const before = baseline.sceneFingerprints?.[id14], after = current.sceneFingerprints?.[id14];
|
|
204879
|
-
if (!before || !after || !/^[a-f0-9]{64}$/.test(before) || !/^[a-f0-9]{64}$/.test(after)) throw new AnchaError("USAGE", `unverified
|
|
204880
|
-
if (before !== after) throw new AnchaError("USAGE", `
|
|
205248
|
+
if (!before || !after || !/^[a-f0-9]{64}$/.test(before) || !/^[a-f0-9]{64}$/.test(after)) throw new AnchaError("USAGE", `unverified test fingerprint for ${id14}`, { hint: "legacy summaries can be displayed but need a new run before comparison" });
|
|
205249
|
+
if (before !== after) throw new AnchaError("USAGE", `test fingerprint changed for ${id14} (test, criteria or records differ)`, { hint: "save a fresh baseline after intentional test changes" });
|
|
204881
205250
|
}
|
|
204882
205251
|
for (const id14 of currentIds) {
|
|
204883
205252
|
const before = baseline.caseFingerprints?.[id14], after = current.caseFingerprints?.[id14];
|
|
@@ -204943,7 +205312,7 @@ init_src();
|
|
|
204943
205312
|
|
|
204944
205313
|
// packages/cli/src/commands/run.ts
|
|
204945
205314
|
import { appendFileSync } from "node:fs";
|
|
204946
|
-
import { dirname as dirname8, join as join19, relative as
|
|
205315
|
+
import { dirname as dirname8, join as join19, relative as relative6, resolve as resolve12 } from "node:path";
|
|
204947
205316
|
init_src();
|
|
204948
205317
|
init_run_state();
|
|
204949
205318
|
|
|
@@ -205105,7 +205474,7 @@ function progressLine(e, scenes) {
|
|
|
205105
205474
|
if (e.event === "trace_skipped" && typeof e.trace === "string" && typeof e.reason === "string") return `skipped trace ${e.trace.slice(0, 8)}: ${e.reason}`;
|
|
205106
205475
|
if (e.event === "run_started" && typeof e.runId === "string" && Array.isArray(e.scenes) && typeof e.trials === "number" && typeof e.parallel === "number") {
|
|
205107
205476
|
if (typeof e.replayOf === "string") return `${e.runId}: replay of ${e.replayOf}`;
|
|
205108
|
-
const what = e.scenes.length === 1 ? `${plural4(e.trials, "trial")} of ${String(e.scenes[0])}` : `${plural4(e.trials, "trial")} each of ${e.scenes.length}
|
|
205477
|
+
const what = e.scenes.length === 1 ? `${plural4(e.trials, "trial")} of ${String(e.scenes[0])}` : `${plural4(e.trials, "trial")} each of ${e.scenes.length} tests`;
|
|
205109
205478
|
const total2 = e.trials * e.scenes.length;
|
|
205110
205479
|
return `${e.runId}: ${what}${total2 > 1 ? `, ${Math.min(e.parallel, total2)} at a time` : ""}`;
|
|
205111
205480
|
}
|
|
@@ -205193,6 +205562,10 @@ var Output = class {
|
|
|
205193
205562
|
}
|
|
205194
205563
|
};
|
|
205195
205564
|
|
|
205565
|
+
// packages/cli/src/onboarding.ts
|
|
205566
|
+
init_src();
|
|
205567
|
+
init_credentials();
|
|
205568
|
+
|
|
205196
205569
|
// packages/cli/src/commands/internal-cloud.ts
|
|
205197
205570
|
init_src();
|
|
205198
205571
|
init_config();
|
|
@@ -205219,14 +205592,14 @@ async function interruptible(ctx, fn) {
|
|
|
205219
205592
|
external2?.removeEventListener("abort", stop);
|
|
205220
205593
|
}
|
|
205221
205594
|
}
|
|
205222
|
-
function emitFinished(ctx, summary, out, upload4, uploadHint, reproduction = summary.reproduction ?? []) {
|
|
205223
|
-
|
|
205595
|
+
function emitFinished(ctx, summary, out, upload4, uploadHint, reproduction = summary.reproduction ?? [], tests) {
|
|
205596
|
+
const opts = { out: nonDefaultOut(ctx.io.cwd, out), ...tests !== void 0 && { tests }, cwd: ctx.io.cwd };
|
|
205597
|
+
const never2 = agentNeverRan(summary);
|
|
205598
|
+
if (ctx.out.json) ctx.out.event({ event: "run_finished", summary, next: nextAfterRun(summary, opts), ...upload4 !== void 0 && { upload: upload4 }, ...reproduction.length > 0 && { reproduction }, ...never2 !== void 0 && { agentNeverRan: never2 } });
|
|
205224
205599
|
else ctx.out.result(summary, () => `
|
|
205225
|
-
${renderSummaryText(summary, {
|
|
205226
|
-
${renderReproduction(reproduction)}
|
|
205227
|
-
` : ""}${upload4 !== void 0 && "url" in upload4 ? `
|
|
205600
|
+
${renderSummaryText(summary, { ...opts, reproduction })}${upload4 !== void 0 && "url" in upload4 ? `
|
|
205228
205601
|
uploaded: ${upload4.url}` : ""}${upload4 === void 0 && uploadHint !== void 0 ? `
|
|
205229
|
-
${uploadHintLine(summary.runId, uploadHint, { out:
|
|
205602
|
+
${uploadHintLine(summary.runId, uploadHint, { out: opts.out })}` : ""}`);
|
|
205230
205603
|
}
|
|
205231
205604
|
async function uploadFinished(ctx, input4, runId) {
|
|
205232
205605
|
if (input4.upload === void 0) return void 0;
|
|
@@ -205290,7 +205663,7 @@ async function executePreparedRun(ctx, input4, initial, ready3) {
|
|
|
205290
205663
|
const upload4 = await uploadFinished(ctx, input4, summary.runId);
|
|
205291
205664
|
await writer.finish({ state: "finished", exitCode: ctx.exitCode, ...upload4 !== void 0 && { upload: keptUpload(upload4, summary.runId) } });
|
|
205292
205665
|
if (input4.strict && summary.scenes.some((scene2) => scene2.coverageGaps.length > 0)) ctx.out.info("--strict: endpoint coverage errors are recorded in the summary");
|
|
205293
|
-
emitFinished(ctx, summary, input4.out, upload4, input4.uploadHint);
|
|
205666
|
+
emitFinished(ctx, summary, input4.out, upload4, input4.uploadHint, summary.reproduction ?? [], Object.values(input4.scenePaths));
|
|
205294
205667
|
} catch (error64) {
|
|
205295
205668
|
const code2 = toErrorJson(error64).code;
|
|
205296
205669
|
const interrupted2 = error64 instanceof AnchaError && error64.code === "USAGE" && error64.message === "run interrupted";
|
|
@@ -205324,7 +205697,7 @@ process.once("message", async (message7) => {
|
|
|
205324
205697
|
throw new Error("worker inputs must be prepared");
|
|
205325
205698
|
}, exitCode: 0 };
|
|
205326
205699
|
try {
|
|
205327
|
-
await executePreparedRun(ctx, input4, state3, () => new Promise((
|
|
205700
|
+
await executePreparedRun(ctx, input4, state3, () => new Promise((resolve13, reject3) => {
|
|
205328
205701
|
const timer = setTimeout(() => finish2(new Error("startup acceptance timed out")), 1e4);
|
|
205329
205702
|
const disconnected = () => finish2(new Error("startup parent disconnected before acceptance"));
|
|
205330
205703
|
const accepted = (value4) => {
|
|
@@ -205335,7 +205708,7 @@ process.once("message", async (message7) => {
|
|
|
205335
205708
|
process.off("disconnect", disconnected);
|
|
205336
205709
|
process.off("message", accepted);
|
|
205337
205710
|
if (error64) reject3(error64);
|
|
205338
|
-
else
|
|
205711
|
+
else resolve13();
|
|
205339
205712
|
}
|
|
205340
205713
|
process.once("disconnect", disconnected);
|
|
205341
205714
|
process.on("message", accepted);
|