@ancha-labs/cli 0.4.42 → 0.4.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ancha.mjs +728 -621
- package/lib/assets/SKILL.md +1 -0
- package/lib/assets/agents-section.md +1 -0
- package/lib/assets/docs/cloud.md +3 -2
- package/lib/assets/docs/explain.md +2 -0
- package/lib/assets/docs/scenes.md +2 -0
- package/lib/assets/docs/setup.md +1 -0
- package/lib/assets/harbor/companion.mjs +7 -2
- package/lib/assets/ui/app.js +1 -1
- package/lib/worker.mjs +52 -5
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -8010,7 +8010,7 @@ function isRef(value6) {
|
|
|
8010
8010
|
function cloneIssues(issues) {
|
|
8011
8011
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
8012
8012
|
}
|
|
8013
|
-
function isRecursive(inst, stack,
|
|
8013
|
+
function isRecursive(inst, stack, resolve63) {
|
|
8014
8014
|
const cached3 = recursive.get(inst);
|
|
8015
8015
|
if (cached3 !== void 0)
|
|
8016
8016
|
return cached3 ? PROVEN : NONE;
|
|
@@ -8020,7 +8020,7 @@ function isRecursive(inst, stack, resolve62) {
|
|
|
8020
8020
|
let result = NONE;
|
|
8021
8021
|
const check4 = (child3) => {
|
|
8022
8022
|
if (result !== PROVEN && child3?._zod) {
|
|
8023
|
-
const answer = isRecursive(child3, stack,
|
|
8023
|
+
const answer = isRecursive(child3, stack, resolve63);
|
|
8024
8024
|
if (answer > result)
|
|
8025
8025
|
result = answer;
|
|
8026
8026
|
}
|
|
@@ -8031,7 +8031,7 @@ function isRecursive(inst, stack, resolve62) {
|
|
|
8031
8031
|
const desc = Object.getOwnPropertyDescriptor(sh, key5);
|
|
8032
8032
|
if (spread && !desc.enumerable)
|
|
8033
8033
|
continue;
|
|
8034
|
-
const child3 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
8034
|
+
const child3 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve63) : NONE;
|
|
8035
8035
|
if (child3 > answer)
|
|
8036
8036
|
answer = child3;
|
|
8037
8037
|
}
|
|
@@ -8095,7 +8095,7 @@ function isRecursive(inst, stack, resolve62) {
|
|
|
8095
8095
|
break;
|
|
8096
8096
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
8097
8097
|
case "lazy": {
|
|
8098
|
-
const inner2 = def._cachedInner ?? (
|
|
8098
|
+
const inner2 = def._cachedInner ?? (resolve63 ? inst._zod.innerType : void 0);
|
|
8099
8099
|
merge5(inner2 ? isRecursive(inner2, stack, false) : ASSUMED);
|
|
8100
8100
|
break;
|
|
8101
8101
|
}
|
|
@@ -43426,10 +43426,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
43426
43426
|
let offset20 = bm.offset;
|
|
43427
43427
|
let commentEnd = null;
|
|
43428
43428
|
for (const collItem of bm.items) {
|
|
43429
|
-
const { start: start2, key: key5, sep:
|
|
43429
|
+
const { start: start2, key: key5, sep: sep10, value: value6 } = collItem;
|
|
43430
43430
|
const keyProps = resolveProps.resolveProps(start2, {
|
|
43431
43431
|
indicator: "explicit-key-ind",
|
|
43432
|
-
next: key5 ??
|
|
43432
|
+
next: key5 ?? sep10?.[0],
|
|
43433
43433
|
offset: offset20,
|
|
43434
43434
|
onError,
|
|
43435
43435
|
parentIndent: bm.indent,
|
|
@@ -43443,7 +43443,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
43443
43443
|
else if ("indent" in key5 && key5.indent !== bm.indent)
|
|
43444
43444
|
onError(offset20, "BAD_INDENT", startColMsg);
|
|
43445
43445
|
}
|
|
43446
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
43446
|
+
if (!keyProps.anchor && !keyProps.tag && !sep10) {
|
|
43447
43447
|
commentEnd = keyProps.end;
|
|
43448
43448
|
if (keyProps.comment) {
|
|
43449
43449
|
if (map2.comment)
|
|
@@ -43467,7 +43467,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
43467
43467
|
ctx.atKey = false;
|
|
43468
43468
|
if (utilMapIncludes.mapIncludes(ctx, map2.items, keyNode))
|
|
43469
43469
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
43470
|
-
const valueProps = resolveProps.resolveProps(
|
|
43470
|
+
const valueProps = resolveProps.resolveProps(sep10 ?? [], {
|
|
43471
43471
|
indicator: "map-value-ind",
|
|
43472
43472
|
next: value6,
|
|
43473
43473
|
offset: keyNode.range[2],
|
|
@@ -43483,7 +43483,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
43483
43483
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
43484
43484
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
43485
43485
|
}
|
|
43486
|
-
const valueNode = value6 ? composeNode(ctx, value6, valueProps, onError) : composeEmptyNode(ctx, offset20,
|
|
43486
|
+
const valueNode = value6 ? composeNode(ctx, value6, valueProps, onError) : composeEmptyNode(ctx, offset20, sep10, null, valueProps, onError);
|
|
43487
43487
|
if (ctx.schema.compat)
|
|
43488
43488
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value6, onError);
|
|
43489
43489
|
offset20 = valueNode.range[2];
|
|
@@ -43574,7 +43574,7 @@ var require_resolve_end = __commonJS({
|
|
|
43574
43574
|
let comment10 = "";
|
|
43575
43575
|
if (end) {
|
|
43576
43576
|
let hasSpace = false;
|
|
43577
|
-
let
|
|
43577
|
+
let sep10 = "";
|
|
43578
43578
|
for (const token5 of end) {
|
|
43579
43579
|
const { source, type } = token5;
|
|
43580
43580
|
switch (type) {
|
|
@@ -43588,13 +43588,13 @@ var require_resolve_end = __commonJS({
|
|
|
43588
43588
|
if (!comment10)
|
|
43589
43589
|
comment10 = cb;
|
|
43590
43590
|
else
|
|
43591
|
-
comment10 +=
|
|
43592
|
-
|
|
43591
|
+
comment10 += sep10 + cb;
|
|
43592
|
+
sep10 = "";
|
|
43593
43593
|
break;
|
|
43594
43594
|
}
|
|
43595
43595
|
case "newline":
|
|
43596
43596
|
if (comment10)
|
|
43597
|
-
|
|
43597
|
+
sep10 += source;
|
|
43598
43598
|
hasSpace = true;
|
|
43599
43599
|
break;
|
|
43600
43600
|
default:
|
|
@@ -43637,18 +43637,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
43637
43637
|
let offset20 = fc.offset + fc.start.source.length;
|
|
43638
43638
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
43639
43639
|
const collItem = fc.items[i];
|
|
43640
|
-
const { start: start2, key: key5, sep:
|
|
43640
|
+
const { start: start2, key: key5, sep: sep10, value: value6 } = collItem;
|
|
43641
43641
|
const props = resolveProps.resolveProps(start2, {
|
|
43642
43642
|
flow: fcName,
|
|
43643
43643
|
indicator: "explicit-key-ind",
|
|
43644
|
-
next: key5 ??
|
|
43644
|
+
next: key5 ?? sep10?.[0],
|
|
43645
43645
|
offset: offset20,
|
|
43646
43646
|
onError,
|
|
43647
43647
|
parentIndent: fc.indent,
|
|
43648
43648
|
startOnNewline: false
|
|
43649
43649
|
});
|
|
43650
43650
|
if (!props.found) {
|
|
43651
|
-
if (!props.anchor && !props.tag && !
|
|
43651
|
+
if (!props.anchor && !props.tag && !sep10 && !value6) {
|
|
43652
43652
|
if (i === 0 && props.comma)
|
|
43653
43653
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
43654
43654
|
else if (i < fc.items.length - 1)
|
|
@@ -43702,8 +43702,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
43702
43702
|
}
|
|
43703
43703
|
}
|
|
43704
43704
|
}
|
|
43705
|
-
if (!isMap3 && !
|
|
43706
|
-
const valueNode = value6 ? composeNode(ctx, value6, props, onError) : composeEmptyNode(ctx, props.end,
|
|
43705
|
+
if (!isMap3 && !sep10 && !props.found) {
|
|
43706
|
+
const valueNode = value6 ? composeNode(ctx, value6, props, onError) : composeEmptyNode(ctx, props.end, sep10, null, props, onError);
|
|
43707
43707
|
coll.items.push(valueNode);
|
|
43708
43708
|
offset20 = valueNode.range[2];
|
|
43709
43709
|
if (isBlock(value6))
|
|
@@ -43715,7 +43715,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
43715
43715
|
if (isBlock(key5))
|
|
43716
43716
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
43717
43717
|
ctx.atKey = false;
|
|
43718
|
-
const valueProps = resolveProps.resolveProps(
|
|
43718
|
+
const valueProps = resolveProps.resolveProps(sep10 ?? [], {
|
|
43719
43719
|
flow: fcName,
|
|
43720
43720
|
indicator: "map-value-ind",
|
|
43721
43721
|
next: value6,
|
|
@@ -43726,8 +43726,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
43726
43726
|
});
|
|
43727
43727
|
if (valueProps.found) {
|
|
43728
43728
|
if (!isMap3 && !props.found && ctx.options.strict) {
|
|
43729
|
-
if (
|
|
43730
|
-
for (const st of
|
|
43729
|
+
if (sep10)
|
|
43730
|
+
for (const st of sep10) {
|
|
43731
43731
|
if (st === valueProps.found)
|
|
43732
43732
|
break;
|
|
43733
43733
|
if (st.type === "newline") {
|
|
@@ -43744,7 +43744,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
43744
43744
|
else
|
|
43745
43745
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
43746
43746
|
}
|
|
43747
|
-
const valueNode = value6 ? composeNode(ctx, value6, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
43747
|
+
const valueNode = value6 ? composeNode(ctx, value6, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep10, null, valueProps, onError) : null;
|
|
43748
43748
|
if (valueNode) {
|
|
43749
43749
|
if (isBlock(value6))
|
|
43750
43750
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -43924,7 +43924,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
43924
43924
|
chompStart = i + 1;
|
|
43925
43925
|
}
|
|
43926
43926
|
let value6 = "";
|
|
43927
|
-
let
|
|
43927
|
+
let sep10 = "";
|
|
43928
43928
|
let prevMoreIndented = false;
|
|
43929
43929
|
for (let i = 0; i < contentStart; ++i)
|
|
43930
43930
|
value6 += lines2[i][0].slice(trimIndent) + "\n";
|
|
@@ -43941,24 +43941,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
43941
43941
|
indent2 = "";
|
|
43942
43942
|
}
|
|
43943
43943
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
43944
|
-
value6 +=
|
|
43945
|
-
|
|
43944
|
+
value6 += sep10 + indent2.slice(trimIndent) + content2;
|
|
43945
|
+
sep10 = "\n";
|
|
43946
43946
|
} else if (indent2.length > trimIndent || content2[0] === " ") {
|
|
43947
|
-
if (
|
|
43948
|
-
|
|
43949
|
-
else if (!prevMoreIndented &&
|
|
43950
|
-
|
|
43951
|
-
value6 +=
|
|
43952
|
-
|
|
43947
|
+
if (sep10 === " ")
|
|
43948
|
+
sep10 = "\n";
|
|
43949
|
+
else if (!prevMoreIndented && sep10 === "\n")
|
|
43950
|
+
sep10 = "\n\n";
|
|
43951
|
+
value6 += sep10 + indent2.slice(trimIndent) + content2;
|
|
43952
|
+
sep10 = "\n";
|
|
43953
43953
|
prevMoreIndented = true;
|
|
43954
43954
|
} else if (content2 === "") {
|
|
43955
|
-
if (
|
|
43955
|
+
if (sep10 === "\n")
|
|
43956
43956
|
value6 += "\n";
|
|
43957
43957
|
else
|
|
43958
|
-
|
|
43958
|
+
sep10 = "\n";
|
|
43959
43959
|
} else {
|
|
43960
|
-
value6 +=
|
|
43961
|
-
|
|
43960
|
+
value6 += sep10 + content2;
|
|
43961
|
+
sep10 = " ";
|
|
43962
43962
|
prevMoreIndented = false;
|
|
43963
43963
|
}
|
|
43964
43964
|
}
|
|
@@ -44141,25 +44141,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
44141
44141
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
44142
44142
|
}
|
|
44143
44143
|
let res = match3[1].replace(trimEnd, "");
|
|
44144
|
-
let
|
|
44144
|
+
let sep10 = " ";
|
|
44145
44145
|
let pos = line2.lastIndex;
|
|
44146
44146
|
while (match3 = line2.exec(source)) {
|
|
44147
44147
|
const lm = match3[1].replace(trimBoth, "");
|
|
44148
44148
|
if (lm === "") {
|
|
44149
|
-
if (
|
|
44150
|
-
res +=
|
|
44149
|
+
if (sep10 === "\n")
|
|
44150
|
+
res += sep10;
|
|
44151
44151
|
else
|
|
44152
|
-
|
|
44152
|
+
sep10 = "\n";
|
|
44153
44153
|
} else {
|
|
44154
|
-
res +=
|
|
44155
|
-
|
|
44154
|
+
res += sep10 + lm;
|
|
44155
|
+
sep10 = " ";
|
|
44156
44156
|
}
|
|
44157
44157
|
pos = line2.lastIndex;
|
|
44158
44158
|
}
|
|
44159
44159
|
const last = /[ \t]*(.*)/sy;
|
|
44160
44160
|
last.lastIndex = pos;
|
|
44161
44161
|
match3 = last.exec(source);
|
|
44162
|
-
return res +
|
|
44162
|
+
return res + sep10 + (match3?.[1] ?? "");
|
|
44163
44163
|
}
|
|
44164
44164
|
function doubleQuotedValue(source, onError) {
|
|
44165
44165
|
let res = "";
|
|
@@ -44969,14 +44969,14 @@ var require_cst_stringify = __commonJS({
|
|
|
44969
44969
|
}
|
|
44970
44970
|
}
|
|
44971
44971
|
}
|
|
44972
|
-
function stringifyItem({ start: start2, key: key5, sep:
|
|
44972
|
+
function stringifyItem({ start: start2, key: key5, sep: sep10, value: value6 }) {
|
|
44973
44973
|
let res = "";
|
|
44974
44974
|
for (const st of start2)
|
|
44975
44975
|
res += st.source;
|
|
44976
44976
|
if (key5)
|
|
44977
44977
|
res += stringifyToken(key5);
|
|
44978
|
-
if (
|
|
44979
|
-
for (const st of
|
|
44978
|
+
if (sep10)
|
|
44979
|
+
for (const st of sep10)
|
|
44980
44980
|
res += st.source;
|
|
44981
44981
|
if (value6)
|
|
44982
44982
|
res += stringifyToken(value6);
|
|
@@ -46143,18 +46143,18 @@ var require_parser = __commonJS({
|
|
|
46143
46143
|
if (this.type === "map-value-ind") {
|
|
46144
46144
|
const prev = getPrevProps(this.peek(2));
|
|
46145
46145
|
const start2 = getFirstKeyStartProps(prev);
|
|
46146
|
-
let
|
|
46146
|
+
let sep10;
|
|
46147
46147
|
if (scalar4.end) {
|
|
46148
|
-
|
|
46149
|
-
|
|
46148
|
+
sep10 = scalar4.end;
|
|
46149
|
+
sep10.push(this.sourceToken);
|
|
46150
46150
|
delete scalar4.end;
|
|
46151
46151
|
} else
|
|
46152
|
-
|
|
46152
|
+
sep10 = [this.sourceToken];
|
|
46153
46153
|
const map2 = {
|
|
46154
46154
|
type: "block-map",
|
|
46155
46155
|
offset: scalar4.offset,
|
|
46156
46156
|
indent: scalar4.indent,
|
|
46157
|
-
items: [{ start: start2, key: scalar4, sep:
|
|
46157
|
+
items: [{ start: start2, key: scalar4, sep: sep10 }]
|
|
46158
46158
|
};
|
|
46159
46159
|
this.onKeyLine = true;
|
|
46160
46160
|
this.stack[this.stack.length - 1] = map2;
|
|
@@ -46307,15 +46307,15 @@ var require_parser = __commonJS({
|
|
|
46307
46307
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
46308
46308
|
const start3 = getFirstKeyStartProps(it.start);
|
|
46309
46309
|
const key5 = it.key;
|
|
46310
|
-
const
|
|
46311
|
-
|
|
46310
|
+
const sep10 = it.sep;
|
|
46311
|
+
sep10.push(this.sourceToken);
|
|
46312
46312
|
delete it.key;
|
|
46313
46313
|
delete it.sep;
|
|
46314
46314
|
this.stack.push({
|
|
46315
46315
|
type: "block-map",
|
|
46316
46316
|
offset: this.offset,
|
|
46317
46317
|
indent: this.indent,
|
|
46318
|
-
items: [{ start: start3, key: key5, sep:
|
|
46318
|
+
items: [{ start: start3, key: key5, sep: sep10 }]
|
|
46319
46319
|
});
|
|
46320
46320
|
} else if (start2.length > 0) {
|
|
46321
46321
|
it.sep = it.sep.concat(start2, this.sourceToken);
|
|
@@ -46509,13 +46509,13 @@ var require_parser = __commonJS({
|
|
|
46509
46509
|
const prev = getPrevProps(parent3);
|
|
46510
46510
|
const start2 = getFirstKeyStartProps(prev);
|
|
46511
46511
|
fixFlowSeqItems(fc);
|
|
46512
|
-
const
|
|
46513
|
-
|
|
46512
|
+
const sep10 = fc.end.splice(1, fc.end.length);
|
|
46513
|
+
sep10.push(this.sourceToken);
|
|
46514
46514
|
const map2 = {
|
|
46515
46515
|
type: "block-map",
|
|
46516
46516
|
offset: fc.offset,
|
|
46517
46517
|
indent: fc.indent,
|
|
46518
|
-
items: [{ start: start2, key: fc, sep:
|
|
46518
|
+
items: [{ start: start2, key: fc, sep: sep10 }]
|
|
46519
46519
|
};
|
|
46520
46520
|
this.onKeyLine = true;
|
|
46521
46521
|
this.stack[this.stack.length - 1] = map2;
|
|
@@ -57160,14 +57160,14 @@ function inputRequiredRoundsExceededMessage(method2, maxRounds) {
|
|
|
57160
57160
|
return `Multi-round-trip request '${method2}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
57161
57161
|
}
|
|
57162
57162
|
function sleep(ms2, signal) {
|
|
57163
|
-
return new Promise((
|
|
57163
|
+
return new Promise((resolve63, reject4) => {
|
|
57164
57164
|
if (signal?.aborted) {
|
|
57165
57165
|
reject4(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
57166
57166
|
return;
|
|
57167
57167
|
}
|
|
57168
57168
|
const timer = setTimeout(() => {
|
|
57169
57169
|
signal?.removeEventListener("abort", onAbort);
|
|
57170
|
-
|
|
57170
|
+
resolve63();
|
|
57171
57171
|
}, ms2);
|
|
57172
57172
|
const onAbort = () => {
|
|
57173
57173
|
clearTimeout(timer);
|
|
@@ -59037,7 +59037,7 @@ var init_src_DdvbAHrR = __esm({
|
|
|
59037
59037
|
const flowStartedAt = Date.now();
|
|
59038
59038
|
let onAbort;
|
|
59039
59039
|
let cleanupMessageId;
|
|
59040
|
-
return new Promise((
|
|
59040
|
+
return new Promise((resolve63, reject4) => {
|
|
59041
59041
|
const earlyReject = (error65) => {
|
|
59042
59042
|
reject4(error65);
|
|
59043
59043
|
};
|
|
@@ -59106,7 +59106,7 @@ var init_src_DdvbAHrR = __esm({
|
|
|
59106
59106
|
}
|
|
59107
59107
|
if (decoded.kind === "invalid") return reject4(decoded.error);
|
|
59108
59108
|
if (decoded.kind === "input_required") {
|
|
59109
|
-
if (options5?.allowInputRequired === true) return
|
|
59109
|
+
if (options5?.allowInputRequired === true) return resolve63(manualInputRequiredValue(decoded));
|
|
59110
59110
|
const flow = {
|
|
59111
59111
|
codec: codec2,
|
|
59112
59112
|
request: request2,
|
|
@@ -59118,11 +59118,11 @@ var init_src_DdvbAHrR = __esm({
|
|
|
59118
59118
|
params: params10
|
|
59119
59119
|
}, resultSchema, legOptions)
|
|
59120
59120
|
};
|
|
59121
|
-
return
|
|
59121
|
+
return resolve63(this._resolveNonCompleteResult(decoded, flow));
|
|
59122
59122
|
}
|
|
59123
59123
|
const result = decoded.result;
|
|
59124
59124
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
59125
|
-
if (parseResult.success)
|
|
59125
|
+
if (parseResult.success) resolve63(parseResult.data);
|
|
59126
59126
|
else reject4(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
59127
59127
|
}, reject4);
|
|
59128
59128
|
});
|
|
@@ -61941,7 +61941,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
61941
61941
|
ref23 = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref23);
|
|
61942
61942
|
const schOrFunc = root3.refs[ref23];
|
|
61943
61943
|
if (schOrFunc) return schOrFunc;
|
|
61944
|
-
let _sch =
|
|
61944
|
+
let _sch = resolve63.call(this, root3, ref23);
|
|
61945
61945
|
if (_sch === void 0) {
|
|
61946
61946
|
const schema4 = (_a7 = root3.localRefs) === null || _a7 === void 0 ? void 0 : _a7[ref23];
|
|
61947
61947
|
const { schemaId } = this.opts;
|
|
@@ -61967,7 +61967,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
61967
61967
|
function sameSchemaEnv(s1, s22) {
|
|
61968
61968
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
61969
61969
|
}
|
|
61970
|
-
function
|
|
61970
|
+
function resolve63(root3, ref23) {
|
|
61971
61971
|
let sch;
|
|
61972
61972
|
while (typeof (sch = this.refs[ref23]) == "string") ref23 = sch;
|
|
61973
61973
|
return sch || this.schemas[ref23] || resolveSchema.call(this, root3, ref23);
|
|
@@ -62662,7 +62662,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62662
62662
|
else if (typeof uri === "object") uri = parse28(serialize2(uri, options5), options5);
|
|
62663
62663
|
return uri;
|
|
62664
62664
|
}
|
|
62665
|
-
function
|
|
62665
|
+
function resolve63(baseURI, relativeURI, options5) {
|
|
62666
62666
|
const schemelessOptions = options5 ? Object.assign({ scheme: "null" }, options5) : { scheme: "null" };
|
|
62667
62667
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
|
|
62668
62668
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -62677,41 +62677,41 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62677
62677
|
schemelessOptions.skipEscape = true;
|
|
62678
62678
|
return serialize2(resolved, schemelessOptions);
|
|
62679
62679
|
}
|
|
62680
|
-
function resolveComponent(base6,
|
|
62680
|
+
function resolveComponent(base6, relative31, options5, skipNormalization) {
|
|
62681
62681
|
const target6 = {};
|
|
62682
62682
|
if (!skipNormalization) {
|
|
62683
62683
|
base6 = parse28(serialize2(base6, options5), options5);
|
|
62684
|
-
|
|
62684
|
+
relative31 = parse28(serialize2(relative31, options5), options5);
|
|
62685
62685
|
}
|
|
62686
62686
|
options5 = options5 || {};
|
|
62687
|
-
if (!options5.tolerant &&
|
|
62688
|
-
target6.scheme =
|
|
62689
|
-
target6.userinfo =
|
|
62690
|
-
target6.host =
|
|
62691
|
-
target6.port =
|
|
62692
|
-
target6.path = removeDotSegments(
|
|
62693
|
-
target6.query =
|
|
62687
|
+
if (!options5.tolerant && relative31.scheme) {
|
|
62688
|
+
target6.scheme = relative31.scheme;
|
|
62689
|
+
target6.userinfo = relative31.userinfo;
|
|
62690
|
+
target6.host = relative31.host;
|
|
62691
|
+
target6.port = relative31.port;
|
|
62692
|
+
target6.path = removeDotSegments(relative31.path || "");
|
|
62693
|
+
target6.query = relative31.query;
|
|
62694
62694
|
} else {
|
|
62695
|
-
if (
|
|
62696
|
-
target6.userinfo =
|
|
62697
|
-
target6.host =
|
|
62698
|
-
target6.port =
|
|
62699
|
-
target6.path = removeDotSegments(
|
|
62700
|
-
target6.query =
|
|
62695
|
+
if (relative31.userinfo !== void 0 || relative31.host !== void 0 || relative31.port !== void 0) {
|
|
62696
|
+
target6.userinfo = relative31.userinfo;
|
|
62697
|
+
target6.host = relative31.host;
|
|
62698
|
+
target6.port = relative31.port;
|
|
62699
|
+
target6.path = removeDotSegments(relative31.path || "");
|
|
62700
|
+
target6.query = relative31.query;
|
|
62701
62701
|
} else {
|
|
62702
|
-
if (!
|
|
62702
|
+
if (!relative31.path) {
|
|
62703
62703
|
target6.path = base6.path;
|
|
62704
|
-
if (
|
|
62704
|
+
if (relative31.query !== void 0) target6.query = relative31.query;
|
|
62705
62705
|
else target6.query = base6.query;
|
|
62706
62706
|
} else {
|
|
62707
|
-
if (
|
|
62707
|
+
if (relative31.path[0] === "/") target6.path = removeDotSegments(relative31.path);
|
|
62708
62708
|
else {
|
|
62709
|
-
if ((base6.userinfo !== void 0 || base6.host !== void 0 || base6.port !== void 0) && !base6.path) target6.path = "/" +
|
|
62710
|
-
else if (!base6.path) target6.path =
|
|
62711
|
-
else target6.path = base6.path.slice(0, base6.path.lastIndexOf("/") + 1) +
|
|
62709
|
+
if ((base6.userinfo !== void 0 || base6.host !== void 0 || base6.port !== void 0) && !base6.path) target6.path = "/" + relative31.path;
|
|
62710
|
+
else if (!base6.path) target6.path = relative31.path;
|
|
62711
|
+
else target6.path = base6.path.slice(0, base6.path.lastIndexOf("/") + 1) + relative31.path;
|
|
62712
62712
|
target6.path = removeDotSegments(target6.path);
|
|
62713
62713
|
}
|
|
62714
|
-
target6.query =
|
|
62714
|
+
target6.query = relative31.query;
|
|
62715
62715
|
}
|
|
62716
62716
|
target6.userinfo = base6.userinfo;
|
|
62717
62717
|
target6.host = base6.host;
|
|
@@ -62719,7 +62719,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62719
62719
|
}
|
|
62720
62720
|
target6.scheme = base6.scheme;
|
|
62721
62721
|
}
|
|
62722
|
-
target6.fragment =
|
|
62722
|
+
target6.fragment = relative31.fragment;
|
|
62723
62723
|
return target6;
|
|
62724
62724
|
}
|
|
62725
62725
|
function equal4(uriA, uriB, options5) {
|
|
@@ -62944,7 +62944,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62944
62944
|
const fastUri = {
|
|
62945
62945
|
SCHEMES,
|
|
62946
62946
|
normalize: normalize4,
|
|
62947
|
-
resolve:
|
|
62947
|
+
resolve: resolve63,
|
|
62948
62948
|
resolveComponent,
|
|
62949
62949
|
equal: equal4,
|
|
62950
62950
|
serialize: serialize2,
|
|
@@ -66809,9 +66809,9 @@ function validateScopeChallenge(challenge) {
|
|
|
66809
66809
|
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");
|
|
66810
66810
|
return challenge;
|
|
66811
66811
|
}
|
|
66812
|
-
async function findScopeChallenge(requests2, authInfo,
|
|
66812
|
+
async function findScopeChallenge(requests2, authInfo, resolve63) {
|
|
66813
66813
|
for (const request2 of requests2) {
|
|
66814
|
-
const challenge = await
|
|
66814
|
+
const challenge = await resolve63({
|
|
66815
66815
|
request: request2,
|
|
66816
66816
|
...authInfo !== void 0 && { authInfo }
|
|
66817
66817
|
});
|
|
@@ -67030,15 +67030,15 @@ var init_mcp_oHn3ureC = __esm({
|
|
|
67030
67030
|
};
|
|
67031
67031
|
if (isJSONRPCRequest(message8)) {
|
|
67032
67032
|
this._requestId = message8.id;
|
|
67033
|
-
let
|
|
67033
|
+
let resolve63;
|
|
67034
67034
|
let reject4;
|
|
67035
67035
|
const promise3 = new Promise((promiseResolve, promiseReject) => {
|
|
67036
|
-
|
|
67036
|
+
resolve63 = promiseResolve;
|
|
67037
67037
|
reject4 = promiseReject;
|
|
67038
67038
|
});
|
|
67039
67039
|
this._deferredResponse = {
|
|
67040
67040
|
promise: promise3,
|
|
67041
|
-
resolve:
|
|
67041
|
+
resolve: resolve63,
|
|
67042
67042
|
reject: reject4,
|
|
67043
67043
|
settled: false
|
|
67044
67044
|
};
|
|
@@ -69560,9 +69560,9 @@ data:
|
|
|
69560
69560
|
const streamId = crypto.randomUUID();
|
|
69561
69561
|
const initRequest = messages7.find((m) => isInitializeRequest(m));
|
|
69562
69562
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
69563
|
-
if (this._enableJsonResponse) return new Promise((
|
|
69563
|
+
if (this._enableJsonResponse) return new Promise((resolve63) => {
|
|
69564
69564
|
this._streamMapping.set(streamId, {
|
|
69565
|
-
resolveJson:
|
|
69565
|
+
resolveJson: resolve63,
|
|
69566
69566
|
cleanup: () => {
|
|
69567
69567
|
this._streamMapping.delete(streamId);
|
|
69568
69568
|
}
|
|
@@ -85815,7 +85815,7 @@ var require_graphql = __commonJS({
|
|
|
85815
85815
|
var _validate2 = require_validate3();
|
|
85816
85816
|
var _execute = require_execute();
|
|
85817
85817
|
function graphql(args) {
|
|
85818
|
-
return new Promise((
|
|
85818
|
+
return new Promise((resolve63) => resolve63(graphqlImpl(args)));
|
|
85819
85819
|
}
|
|
85820
85820
|
function graphqlSync(args) {
|
|
85821
85821
|
const result = graphqlImpl(args);
|
|
@@ -93352,7 +93352,7 @@ async function fetchPost(url4, body8, headers, signal) {
|
|
|
93352
93352
|
return { status: response6.status, headers: Object.fromEntries(response6.headers), text: Buffer.concat(chunks).toString("utf8") };
|
|
93353
93353
|
}
|
|
93354
93354
|
function socketPost(socketPath) {
|
|
93355
|
-
return (url4, body8, headers, signal) => new Promise((
|
|
93355
|
+
return (url4, body8, headers, signal) => new Promise((resolve63, reject4) => {
|
|
93356
93356
|
const req = httpRequest({ socketPath, path: new URL(url4).pathname, method: "POST", headers: { ...headers, host: "relay", "content-length": Buffer.byteLength(body8) }, signal }, (res) => {
|
|
93357
93357
|
let text31 = "", bytes4 = 0;
|
|
93358
93358
|
res.setEncoding("utf8");
|
|
@@ -93367,7 +93367,7 @@ function socketPost(socketPath) {
|
|
|
93367
93367
|
}
|
|
93368
93368
|
text31 += chunk;
|
|
93369
93369
|
});
|
|
93370
|
-
res.on("end", () =>
|
|
93370
|
+
res.on("end", () => resolve63({ status: res.statusCode ?? 0, headers: Object.fromEntries(Object.entries(res.headers).map(([k, v]) => [k, String(v)])), text: text31 }));
|
|
93371
93371
|
res.on("error", reject4);
|
|
93372
93372
|
});
|
|
93373
93373
|
req.on("error", reject4);
|
|
@@ -93529,8 +93529,8 @@ var init_model = __esm({
|
|
|
93529
93529
|
if (code5 !== void 0) this.code = code5;
|
|
93530
93530
|
}
|
|
93531
93531
|
};
|
|
93532
|
-
defaultSleep = (ms2, signal) => new Promise((
|
|
93533
|
-
const timer = setTimeout(
|
|
93532
|
+
defaultSleep = (ms2, signal) => new Promise((resolve63, reject4) => {
|
|
93533
|
+
const timer = setTimeout(resolve63, ms2);
|
|
93534
93534
|
signal.addEventListener("abort", () => {
|
|
93535
93535
|
clearTimeout(timer);
|
|
93536
93536
|
reject4(signal.reason);
|
|
@@ -95202,9 +95202,9 @@ function scheduleTime(r2, value6) {
|
|
|
95202
95202
|
if (value6 === void 0 || value6 === null) invalid6("Missing `scheduled_at` field.", "missing_required_field");
|
|
95203
95203
|
if (typeof value6 !== "string") invalid6("The `scheduled_at` field must be a string.");
|
|
95204
95204
|
const now11 = r2.ctx.clock.nowMs(), text31 = value6.trim();
|
|
95205
|
-
const
|
|
95205
|
+
const relative31 = /^in\s+(\d{1,6})\s+(min|minute|hr|hour|day|week)s?$/i.exec(text31);
|
|
95206
95206
|
const iso27 = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/i.exec(text31);
|
|
95207
|
-
const ms2 =
|
|
95207
|
+
const ms2 = relative31 ? now11 + Number(relative31[1]) * UNIT_MS[relative31[2].toLowerCase()] : iso27 ? Date.parse(iso27[1] && !iso27[2] ? `${text31}Z` : text31) : unsupported(`scheduled_at in natural language ("${text31}")`);
|
|
95208
95208
|
if (!Number.isFinite(ms2)) invalid6("The `scheduled_at` field must be a valid date.");
|
|
95209
95209
|
if (ms2 <= now11) invalid6("The `scheduled_at` field must be a date in the future.");
|
|
95210
95210
|
if (ms2 > now11 + 30 * 864e5) invalid6("The `scheduled_at` field must be within the next 30 days.");
|
|
@@ -99438,13 +99438,13 @@ function reviewCommentShape(ctx, repo4, row2) {
|
|
|
99438
99438
|
const url4 = apiUrl(ctx, `${repoPath(repo4)}/pulls/comments/${row2.id}`), pull2 = apiUrl(ctx, `${repoPath(repo4)}/pulls/${row2.pull_number}`), html4 = `https://github.com/${repo4.full_name}/pull/${row2.pull_number}#discussion_r${row2.id}`;
|
|
99439
99439
|
return { id: row2.id, node_id: nodeId("PullRequestReviewComment", row2.id), pull_request_review_id: row2.review_id, url: url4, html_url: html4, pull_request_url: pull2, user: userShape(ctx, getUser(ctx, row2.user_id)), body: row2.body, diff_hunk: row2.diff_hunk, path: row2.path, commit_id: row2.commit_sha, original_commit_id: row2.commit_sha, line: row2.line, original_line: row2.line, side: row2.side, start_line: null, original_start_line: null, start_side: null, ...row2.in_reply_to_id !== null && { in_reply_to_id: row2.in_reply_to_id }, created_at: row2.created_at, updated_at: row2.updated_at, author_association: "NONE", _links: { self: { href: url4 }, html: { href: html4 }, pull_request: { href: pull2 } } };
|
|
99440
99440
|
}
|
|
99441
|
-
function resourceUserShape(ctx, user9,
|
|
99442
|
-
const result = userShape(
|
|
99443
|
-
if (
|
|
99441
|
+
function resourceUserShape(ctx, user9, relative31 = false) {
|
|
99442
|
+
const result = userShape(relative31 ? { ...ctx, serviceUrl: "https://ancha.invalid" } : ctx, user9);
|
|
99443
|
+
if (relative31) for (const key5 of ["url", "followers_url", "following_url", "gists_url", "starred_url", "subscriptions_url", "organizations_url", "repos_url", "events_url", "received_events_url"]) result[key5] = result[key5].slice("https://ancha.invalid".length);
|
|
99444
99444
|
return result;
|
|
99445
99445
|
}
|
|
99446
|
-
function resourceUrl(ctx, path9,
|
|
99447
|
-
return
|
|
99446
|
+
function resourceUrl(ctx, path9, relative31 = false) {
|
|
99447
|
+
return relative31 ? path9 : apiUrl(ctx, path9);
|
|
99448
99448
|
}
|
|
99449
99449
|
var segment, repoPath, nodeId;
|
|
99450
99450
|
var init_shapes = __esm({
|
|
@@ -100038,13 +100038,13 @@ function requireDeployment(ctx, repoId, id15) {
|
|
|
100038
100038
|
if (!row2) throw new GitHubError(404, "Not Found");
|
|
100039
100039
|
return row2;
|
|
100040
100040
|
}
|
|
100041
|
-
function deploymentShape(ctx, repo4, row2,
|
|
100041
|
+
function deploymentShape(ctx, repo4, row2, relative31 = false) {
|
|
100042
100042
|
const path9 = `${repoPath(repo4)}/deployments/${row2.id}`, data7 = JSON.parse(row2.json);
|
|
100043
|
-
return { ...data7, id: row2.id, node_id: Buffer.from(`Deployment:${row2.id}`).toString("base64"), sha: row2.sha, ref: row2.ref, environment: row2.environment, creator: resourceUserShape(ctx, getUser(ctx, row2.user_id),
|
|
100043
|
+
return { ...data7, id: row2.id, node_id: Buffer.from(`Deployment:${row2.id}`).toString("base64"), sha: row2.sha, ref: row2.ref, environment: row2.environment, creator: resourceUserShape(ctx, getUser(ctx, row2.user_id), relative31), created_at: row2.created_at, updated_at: row2.created_at, url: resourceUrl(ctx, path9, relative31), statuses_url: resourceUrl(ctx, `${path9}/statuses`, relative31), repository_url: resourceUrl(ctx, repoPath(repo4), relative31) };
|
|
100044
100044
|
}
|
|
100045
|
-
function deploymentStatusShape(ctx, repo4, deployment, row2,
|
|
100045
|
+
function deploymentStatusShape(ctx, repo4, deployment, row2, relative31 = false) {
|
|
100046
100046
|
const path9 = `${repoPath(repo4)}/deployments/${deployment.id}`;
|
|
100047
|
-
return { ...JSON.parse(row2.json), id: row2.id, node_id: Buffer.from(`DeploymentStatus:${row2.id}`).toString("base64"), state: row2.state, creator: resourceUserShape(ctx, botUser(ctx),
|
|
100047
|
+
return { ...JSON.parse(row2.json), id: row2.id, node_id: Buffer.from(`DeploymentStatus:${row2.id}`).toString("base64"), state: row2.state, creator: resourceUserShape(ctx, botUser(ctx), relative31), created_at: row2.created_at, updated_at: row2.created_at, environment: deployment.environment, url: resourceUrl(ctx, `${path9}/statuses/${row2.id}`, relative31), deployment_url: resourceUrl(ctx, path9, relative31), repository_url: resourceUrl(ctx, repoPath(repo4), relative31) };
|
|
100048
100048
|
}
|
|
100049
100049
|
function insertDeployment(ctx, repo4, sha2, ref23, environment3, data7 = {}) {
|
|
100050
100050
|
return withMutation(ctx, () => {
|
|
@@ -100154,11 +100154,11 @@ function requireRun(ctx, repoId, runId2) {
|
|
|
100154
100154
|
if (!row2) throw new GitHubError(404, "Not Found");
|
|
100155
100155
|
return row2;
|
|
100156
100156
|
}
|
|
100157
|
-
function workflowRunShape(ctx, repo4, row2,
|
|
100157
|
+
function workflowRunShape(ctx, repo4, row2, relative31 = false) {
|
|
100158
100158
|
const workflow = ctx.store.db.prepare("SELECT * FROM github_workflows WHERE repo_id = ? AND id = ?").get(repo4.id, row2.workflow_id);
|
|
100159
|
-
const path9 = `${repoPath(repo4)}/actions/runs/${row2.id}`, commit = getCommit(ctx, repo4.id, row2.head_sha), actor3 = resourceUserShape(ctx, botUser(ctx),
|
|
100160
|
-
const link9 = (suffix) => resourceUrl(ctx, `${path9}/${suffix}`,
|
|
100161
|
-
const repository3 = repositoryShape(
|
|
100159
|
+
const path9 = `${repoPath(repo4)}/actions/runs/${row2.id}`, commit = getCommit(ctx, repo4.id, row2.head_sha), actor3 = resourceUserShape(ctx, botUser(ctx), relative31);
|
|
100160
|
+
const link9 = (suffix) => resourceUrl(ctx, `${path9}/${suffix}`, relative31);
|
|
100161
|
+
const repository3 = repositoryShape(relative31 ? githubEventContext(ctx) : ctx, repo4);
|
|
100162
100162
|
return {
|
|
100163
100163
|
id: row2.id,
|
|
100164
100164
|
node_id: Buffer.from(`WorkflowRun:${row2.id}`).toString("base64"),
|
|
@@ -100178,16 +100178,16 @@ function workflowRunShape(ctx, repo4, row2, relative30 = false) {
|
|
|
100178
100178
|
actor: actor3,
|
|
100179
100179
|
triggering_actor: actor3,
|
|
100180
100180
|
display_title: commit.message.split("\n")[0],
|
|
100181
|
-
url: resourceUrl(ctx, path9,
|
|
100181
|
+
url: resourceUrl(ctx, path9, relative31),
|
|
100182
100182
|
html_url: `https://github.com/${repo4.full_name}/actions/runs/${row2.id}`,
|
|
100183
100183
|
pull_requests: [],
|
|
100184
100184
|
jobs_url: link9("jobs"),
|
|
100185
100185
|
logs_url: link9("logs"),
|
|
100186
|
-
check_suite_url: resourceUrl(ctx, `${repoPath(repo4)}/check-suites/${row2.id}`,
|
|
100186
|
+
check_suite_url: resourceUrl(ctx, `${repoPath(repo4)}/check-suites/${row2.id}`, relative31),
|
|
100187
100187
|
artifacts_url: link9("artifacts"),
|
|
100188
100188
|
cancel_url: link9("cancel"),
|
|
100189
100189
|
rerun_url: link9("rerun"),
|
|
100190
|
-
workflow_url: resourceUrl(ctx, `${repoPath(repo4)}/actions/workflows/${workflow.id}`,
|
|
100190
|
+
workflow_url: resourceUrl(ctx, `${repoPath(repo4)}/actions/workflows/${workflow.id}`, relative31),
|
|
100191
100191
|
repository: repository3,
|
|
100192
100192
|
head_repository: repository3,
|
|
100193
100193
|
head_commit: { id: row2.head_sha, tree_id: commit.tree, message: commit.message, timestamp: commit.at, author: commit.author, committer: commit.author }
|
|
@@ -103479,7 +103479,7 @@ function matches(integration2, event3) {
|
|
|
103479
103479
|
return on.includes(type) || event3.action !== void 0 && on.includes(`${type}.${event3.action}`);
|
|
103480
103480
|
}
|
|
103481
103481
|
function renderContext(env2) {
|
|
103482
|
-
const
|
|
103482
|
+
const resolve63 = (ref23, kind2) => {
|
|
103483
103483
|
try {
|
|
103484
103484
|
return env2.refs.tryResolve(ref23, kind2);
|
|
103485
103485
|
} catch {
|
|
@@ -103487,9 +103487,9 @@ function renderContext(env2) {
|
|
|
103487
103487
|
}
|
|
103488
103488
|
};
|
|
103489
103489
|
return {
|
|
103490
|
-
resolve:
|
|
103490
|
+
resolve: resolve63,
|
|
103491
103491
|
openIssueByTitle: (repoRef, title2) => {
|
|
103492
|
-
const repo4 =
|
|
103492
|
+
const repo4 = resolve63(repoRef, "repo");
|
|
103493
103493
|
if (repo4 === void 0) return void 0;
|
|
103494
103494
|
return env2.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;
|
|
103495
103495
|
},
|
|
@@ -103696,13 +103696,13 @@ function aggregateValues(values3, aggregation) {
|
|
|
103696
103696
|
}
|
|
103697
103697
|
function resolveQueryRange(from, to, nowMs) {
|
|
103698
103698
|
if (!Number.isFinite(nowMs)) invalid8("invalid captured query time");
|
|
103699
|
-
const
|
|
103699
|
+
const resolve63 = (text31) => {
|
|
103700
103700
|
if (text31 === "now") return Math.floor(nowMs);
|
|
103701
|
-
const
|
|
103702
|
-
if (
|
|
103701
|
+
const relative31 = /^now-(.+)$/.exec(text31);
|
|
103702
|
+
if (relative31) {
|
|
103703
103703
|
let duration13;
|
|
103704
103704
|
try {
|
|
103705
|
-
duration13 = /^[1-9]\d*d$/.test(
|
|
103705
|
+
duration13 = /^[1-9]\d*d$/.test(relative31[1]) ? Number(relative31[1].slice(0, -1)) * MAX_QUERY_WINDOW_MS : parseDuration(relative31[1]);
|
|
103706
103706
|
} catch {
|
|
103707
103707
|
return invalid8("invalid relative query duration");
|
|
103708
103708
|
}
|
|
@@ -103716,7 +103716,7 @@ function resolveQueryRange(from, to, nowMs) {
|
|
|
103716
103716
|
if (date11.toISOString().slice(0, 10) !== absolute2[1]) return invalid8("invalid ISO calendar date");
|
|
103717
103717
|
return value6;
|
|
103718
103718
|
};
|
|
103719
|
-
const fromMs =
|
|
103719
|
+
const fromMs = resolve63(from), toMs = resolve63(to);
|
|
103720
103720
|
checkRange(fromMs, toMs);
|
|
103721
103721
|
return { fromMs, toMs };
|
|
103722
103722
|
}
|
|
@@ -111543,8 +111543,8 @@ var init_env = __esm({
|
|
|
111543
111543
|
this.world.freeze();
|
|
111544
111544
|
this.#draining = true;
|
|
111545
111545
|
const disposals = this.#stop();
|
|
111546
|
-
const drain2 = this.#active === 0 ? Promise.resolve() : new Promise((
|
|
111547
|
-
this.#freeze = new Promise((
|
|
111546
|
+
const drain2 = this.#active === 0 ? Promise.resolve() : new Promise((resolve63) => this.#drained.add(resolve63));
|
|
111547
|
+
this.#freeze = new Promise((resolve63, reject4) => {
|
|
111548
111548
|
const timer = setTimeout(() => fail9(new AnchaError("INTERNAL", "environment request drain exceeded 5000ms")), 5e3);
|
|
111549
111549
|
timer.unref();
|
|
111550
111550
|
const fail9 = (error65) => {
|
|
@@ -111559,7 +111559,7 @@ var init_env = __esm({
|
|
|
111559
111559
|
Promise.all([drain2, ...disposals]).then(() => {
|
|
111560
111560
|
clearTimeout(timer);
|
|
111561
111561
|
this.#draining = false;
|
|
111562
|
-
|
|
111562
|
+
resolve63();
|
|
111563
111563
|
}, fail9);
|
|
111564
111564
|
});
|
|
111565
111565
|
return this.#freeze;
|
|
@@ -112949,7 +112949,7 @@ var require_aspromise = __commonJS({
|
|
|
112949
112949
|
var params10 = new Array(arguments.length - 1), offset20 = 0, index = 2, pending = true;
|
|
112950
112950
|
while (index < arguments.length)
|
|
112951
112951
|
params10[offset20++] = arguments[index++];
|
|
112952
|
-
return new Promise(function executor(
|
|
112952
|
+
return new Promise(function executor(resolve63, reject4) {
|
|
112953
112953
|
params10[offset20] = function callback2(err2) {
|
|
112954
112954
|
if (pending) {
|
|
112955
112955
|
pending = false;
|
|
@@ -112959,7 +112959,7 @@ var require_aspromise = __commonJS({
|
|
|
112959
112959
|
var params11 = new Array(arguments.length - 1), offset21 = 0;
|
|
112960
112960
|
while (offset21 < params11.length)
|
|
112961
112961
|
params11[offset21++] = arguments[offset21];
|
|
112962
|
-
|
|
112962
|
+
resolve63.apply(null, params11);
|
|
112963
112963
|
}
|
|
112964
112964
|
}
|
|
112965
112965
|
};
|
|
@@ -115482,13 +115482,13 @@ var require_path = __commonJS({
|
|
|
115482
115482
|
"node_modules/.pnpm/@protobufjs+path@1.1.2/node_modules/@protobufjs/path/index.js"(exports) {
|
|
115483
115483
|
"use strict";
|
|
115484
115484
|
var path9 = exports;
|
|
115485
|
-
var
|
|
115485
|
+
var isAbsolute14 = (
|
|
115486
115486
|
/**
|
|
115487
115487
|
* Tests if the specified path is absolute.
|
|
115488
115488
|
* @param {string} path Path to test
|
|
115489
115489
|
* @returns {boolean} `true` if path is absolute
|
|
115490
115490
|
*/
|
|
115491
|
-
path9.isAbsolute = function
|
|
115491
|
+
path9.isAbsolute = function isAbsolute15(path10) {
|
|
115492
115492
|
return /^(?:\/|\w+:)/.test(path10);
|
|
115493
115493
|
}
|
|
115494
115494
|
);
|
|
@@ -115500,7 +115500,7 @@ var require_path = __commonJS({
|
|
|
115500
115500
|
*/
|
|
115501
115501
|
path9.normalize = function normalize5(path10) {
|
|
115502
115502
|
path10 = path10.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
115503
|
-
var parts3 = path10.split("/"), absolute2 =
|
|
115503
|
+
var parts3 = path10.split("/"), absolute2 = isAbsolute14(path10), prefix2 = "";
|
|
115504
115504
|
if (absolute2)
|
|
115505
115505
|
prefix2 = parts3.shift() + "/";
|
|
115506
115506
|
for (var i = 0; i < parts3.length; ) {
|
|
@@ -115519,10 +115519,10 @@ var require_path = __commonJS({
|
|
|
115519
115519
|
return prefix2 + parts3.join("/");
|
|
115520
115520
|
}
|
|
115521
115521
|
);
|
|
115522
|
-
path9.resolve = function
|
|
115522
|
+
path9.resolve = function resolve63(originPath, includePath, alreadyNormalized) {
|
|
115523
115523
|
if (!alreadyNormalized)
|
|
115524
115524
|
includePath = normalize4(includePath);
|
|
115525
|
-
if (
|
|
115525
|
+
if (isAbsolute14(includePath))
|
|
115526
115526
|
return includePath;
|
|
115527
115527
|
if (!alreadyNormalized)
|
|
115528
115528
|
originPath = normalize4(originPath);
|
|
@@ -115876,7 +115876,7 @@ var require_mapfield = __commonJS({
|
|
|
115876
115876
|
keepComments ? this.comment : void 0
|
|
115877
115877
|
]);
|
|
115878
115878
|
};
|
|
115879
|
-
MapField.prototype.resolve = function
|
|
115879
|
+
MapField.prototype.resolve = function resolve63() {
|
|
115880
115880
|
if (this.resolved)
|
|
115881
115881
|
return this;
|
|
115882
115882
|
if (types.mapKey[this.keyType] === void 0)
|
|
@@ -115953,7 +115953,7 @@ var require_method = __commonJS({
|
|
|
115953
115953
|
this.parsedOptions
|
|
115954
115954
|
]);
|
|
115955
115955
|
};
|
|
115956
|
-
Method.prototype.resolve = function
|
|
115956
|
+
Method.prototype.resolve = function resolve63() {
|
|
115957
115957
|
if (this.resolved)
|
|
115958
115958
|
return this;
|
|
115959
115959
|
this.resolvedRequestType = this.parent.lookupType(this.requestType);
|
|
@@ -117571,7 +117571,7 @@ var require_field = __commonJS({
|
|
|
117571
117571
|
keepComments ? this.comment : void 0
|
|
117572
117572
|
]);
|
|
117573
117573
|
};
|
|
117574
|
-
Field.prototype.resolve = function
|
|
117574
|
+
Field.prototype.resolve = function resolve63() {
|
|
117575
117575
|
if (this.resolved)
|
|
117576
117576
|
return this;
|
|
117577
117577
|
if ((this.typeDefault = types.defaults[this.type]) === void 0) {
|
|
@@ -117844,7 +117844,7 @@ var require_object = __commonJS({
|
|
|
117844
117844
|
this.parent = null;
|
|
117845
117845
|
this.resolved = false;
|
|
117846
117846
|
};
|
|
117847
|
-
ReflectionObject.prototype.resolve = function
|
|
117847
|
+
ReflectionObject.prototype.resolve = function resolve63() {
|
|
117848
117848
|
if (this.resolved)
|
|
117849
117849
|
return this;
|
|
117850
117850
|
if (this.root instanceof Root)
|
|
@@ -122726,7 +122726,7 @@ var require_call_credentials = __commonJS({
|
|
|
122726
122726
|
if (isCurrentOauth2Client(googleCredentials)) {
|
|
122727
122727
|
getHeaders = googleCredentials.getRequestHeaders(options5.service_url);
|
|
122728
122728
|
} else {
|
|
122729
|
-
getHeaders = new Promise((
|
|
122729
|
+
getHeaders = new Promise((resolve63, reject4) => {
|
|
122730
122730
|
googleCredentials.getRequestMetadata(options5.service_url, (err2, headers) => {
|
|
122731
122731
|
if (err2) {
|
|
122732
122732
|
reject4(err2);
|
|
@@ -122736,7 +122736,7 @@ var require_call_credentials = __commonJS({
|
|
|
122736
122736
|
reject4(new Error("Headers not set by metadata plugin"));
|
|
122737
122737
|
return;
|
|
122738
122738
|
}
|
|
122739
|
-
|
|
122739
|
+
resolve63(headers);
|
|
122740
122740
|
});
|
|
122741
122741
|
});
|
|
122742
122742
|
}
|
|
@@ -122792,10 +122792,10 @@ var require_call_credentials = __commonJS({
|
|
|
122792
122792
|
this.metadataGenerator = metadataGenerator;
|
|
122793
122793
|
}
|
|
122794
122794
|
generateMetadata(options5) {
|
|
122795
|
-
return new Promise((
|
|
122795
|
+
return new Promise((resolve63, reject4) => {
|
|
122796
122796
|
this.metadataGenerator(options5, (err2, metadata8) => {
|
|
122797
122797
|
if (metadata8 !== void 0) {
|
|
122798
|
-
|
|
122798
|
+
resolve63(metadata8);
|
|
122799
122799
|
} else {
|
|
122800
122800
|
reject4(err2);
|
|
122801
122801
|
}
|
|
@@ -123180,14 +123180,14 @@ var require_channel_credentials = __commonJS({
|
|
|
123180
123180
|
}
|
|
123181
123181
|
connect(socket) {
|
|
123182
123182
|
const tlsConnectOptions = Object.assign({ socket }, this.connectionOptions);
|
|
123183
|
-
return new Promise((
|
|
123183
|
+
return new Promise((resolve63, reject4) => {
|
|
123184
123184
|
const tlsSocket = (0, tls_1.connect)(tlsConnectOptions, () => {
|
|
123185
123185
|
var _a7;
|
|
123186
123186
|
if (((_a7 = this.connectionOptions.rejectUnauthorized) !== null && _a7 !== void 0 ? _a7 : true) && !tlsSocket.authorized) {
|
|
123187
123187
|
reject4(tlsSocket.authorizationError);
|
|
123188
123188
|
return;
|
|
123189
123189
|
}
|
|
123190
|
-
|
|
123190
|
+
resolve63({
|
|
123191
123191
|
socket: tlsSocket,
|
|
123192
123192
|
secure: true
|
|
123193
123193
|
});
|
|
@@ -123306,8 +123306,8 @@ var require_channel_credentials = __commonJS({
|
|
|
123306
123306
|
if (this.hasReceivedUpdates()) {
|
|
123307
123307
|
return Promise.resolve(this.getLatestSecureContext());
|
|
123308
123308
|
} else {
|
|
123309
|
-
return new Promise((
|
|
123310
|
-
this.secureContextWatchers.push(
|
|
123309
|
+
return new Promise((resolve63) => {
|
|
123310
|
+
this.secureContextWatchers.push(resolve63);
|
|
123311
123311
|
});
|
|
123312
123312
|
}
|
|
123313
123313
|
}
|
|
@@ -123340,7 +123340,7 @@ var require_channel_credentials = __commonJS({
|
|
|
123340
123340
|
this.callCredentials = callCredentials;
|
|
123341
123341
|
}
|
|
123342
123342
|
connect(socket) {
|
|
123343
|
-
return new Promise((
|
|
123343
|
+
return new Promise((resolve63, reject4) => {
|
|
123344
123344
|
const secureContext = this.parent.getLatestSecureContext();
|
|
123345
123345
|
if (!secureContext) {
|
|
123346
123346
|
reject4(new Error("Failed to load credentials"));
|
|
@@ -123365,7 +123365,7 @@ var require_channel_credentials = __commonJS({
|
|
|
123365
123365
|
reject4(tlsSocket.authorizationError);
|
|
123366
123366
|
return;
|
|
123367
123367
|
}
|
|
123368
|
-
|
|
123368
|
+
resolve63({
|
|
123369
123369
|
socket: tlsSocket,
|
|
123370
123370
|
secure: true
|
|
123371
123371
|
});
|
|
@@ -127280,18 +127280,18 @@ var require_compression_filter = __commonJS({
|
|
|
127280
127280
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
127281
127281
|
}
|
|
127282
127282
|
compressMessage(message8) {
|
|
127283
|
-
return new Promise((
|
|
127283
|
+
return new Promise((resolve63, reject4) => {
|
|
127284
127284
|
zlib.deflate(message8, (err2, output2) => {
|
|
127285
127285
|
if (err2) {
|
|
127286
127286
|
reject4(err2);
|
|
127287
127287
|
} else {
|
|
127288
|
-
|
|
127288
|
+
resolve63(output2);
|
|
127289
127289
|
}
|
|
127290
127290
|
});
|
|
127291
127291
|
});
|
|
127292
127292
|
}
|
|
127293
127293
|
decompressMessage(message8) {
|
|
127294
|
-
return new Promise((
|
|
127294
|
+
return new Promise((resolve63, reject4) => {
|
|
127295
127295
|
let totalLength = 0;
|
|
127296
127296
|
const messageParts = [];
|
|
127297
127297
|
const decompresser = zlib.createInflate();
|
|
@@ -127313,7 +127313,7 @@ var require_compression_filter = __commonJS({
|
|
|
127313
127313
|
}
|
|
127314
127314
|
});
|
|
127315
127315
|
decompresser.on("end", () => {
|
|
127316
|
-
|
|
127316
|
+
resolve63(Buffer.concat(messageParts));
|
|
127317
127317
|
});
|
|
127318
127318
|
decompresser.write(message8);
|
|
127319
127319
|
decompresser.end();
|
|
@@ -127326,18 +127326,18 @@ var require_compression_filter = __commonJS({
|
|
|
127326
127326
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
127327
127327
|
}
|
|
127328
127328
|
compressMessage(message8) {
|
|
127329
|
-
return new Promise((
|
|
127329
|
+
return new Promise((resolve63, reject4) => {
|
|
127330
127330
|
zlib.gzip(message8, (err2, output2) => {
|
|
127331
127331
|
if (err2) {
|
|
127332
127332
|
reject4(err2);
|
|
127333
127333
|
} else {
|
|
127334
|
-
|
|
127334
|
+
resolve63(output2);
|
|
127335
127335
|
}
|
|
127336
127336
|
});
|
|
127337
127337
|
});
|
|
127338
127338
|
}
|
|
127339
127339
|
decompressMessage(message8) {
|
|
127340
|
-
return new Promise((
|
|
127340
|
+
return new Promise((resolve63, reject4) => {
|
|
127341
127341
|
let totalLength = 0;
|
|
127342
127342
|
const messageParts = [];
|
|
127343
127343
|
const decompresser = zlib.createGunzip();
|
|
@@ -127359,7 +127359,7 @@ var require_compression_filter = __commonJS({
|
|
|
127359
127359
|
}
|
|
127360
127360
|
});
|
|
127361
127361
|
decompresser.on("end", () => {
|
|
127362
|
-
|
|
127362
|
+
resolve63(Buffer.concat(messageParts));
|
|
127363
127363
|
});
|
|
127364
127364
|
decompresser.write(message8);
|
|
127365
127365
|
decompresser.end();
|
|
@@ -128709,7 +128709,7 @@ var require_http_proxy = __commonJS({
|
|
|
128709
128709
|
options5.headers = headers;
|
|
128710
128710
|
const proxyAddressString = (0, subchannel_address_1.subchannelAddressToString)(address9);
|
|
128711
128711
|
trace2("Using proxy " + proxyAddressString + " to connect to " + options5.path);
|
|
128712
|
-
return new Promise((
|
|
128712
|
+
return new Promise((resolve63, reject4) => {
|
|
128713
128713
|
const request2 = http.request(options5);
|
|
128714
128714
|
request2.once("connect", (res, socket, head) => {
|
|
128715
128715
|
request2.removeAllListeners();
|
|
@@ -128720,7 +128720,7 @@ var require_http_proxy = __commonJS({
|
|
|
128720
128720
|
socket.unshift(head);
|
|
128721
128721
|
}
|
|
128722
128722
|
trace2("Successfully established a plaintext connection to " + options5.path + " through proxy " + proxyAddressString);
|
|
128723
|
-
|
|
128723
|
+
resolve63(socket);
|
|
128724
128724
|
} else {
|
|
128725
128725
|
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, "Failed to connect to " + options5.path + " through proxy " + proxyAddressString + " with status " + res.statusCode);
|
|
128726
128726
|
reject4();
|
|
@@ -129703,7 +129703,7 @@ var require_transport = __commonJS({
|
|
|
129703
129703
|
if (secureConnectResult.socket.closed) {
|
|
129704
129704
|
return Promise.reject("Connection closed before starting HTTP/2 handshake");
|
|
129705
129705
|
}
|
|
129706
|
-
return new Promise((
|
|
129706
|
+
return new Promise((resolve63, reject4) => {
|
|
129707
129707
|
var _a7, _b, _c, _d, _e, _f, _g, _h;
|
|
129708
129708
|
let remoteName = null;
|
|
129709
129709
|
let realTarget = this.channelTarget;
|
|
@@ -129774,7 +129774,7 @@ var require_transport = __commonJS({
|
|
|
129774
129774
|
session2.removeAllListeners();
|
|
129775
129775
|
secureConnectResult.socket.removeListener("close", closeHandler);
|
|
129776
129776
|
secureConnectResult.socket.removeListener("error", errorHandler2);
|
|
129777
|
-
|
|
129777
|
+
resolve63(new Http2Transport(session2, address9, options5, remoteName));
|
|
129778
129778
|
this.session = null;
|
|
129779
129779
|
});
|
|
129780
129780
|
session2.once("close", closeHandler);
|
|
@@ -129788,7 +129788,7 @@ var require_transport = __commonJS({
|
|
|
129788
129788
|
if (proxiedSocket) {
|
|
129789
129789
|
return proxiedSocket;
|
|
129790
129790
|
} else {
|
|
129791
|
-
return new Promise((
|
|
129791
|
+
return new Promise((resolve63, reject4) => {
|
|
129792
129792
|
const closeCallback = () => {
|
|
129793
129793
|
reject4(new Error("Socket closed"));
|
|
129794
129794
|
};
|
|
@@ -129798,7 +129798,7 @@ var require_transport = __commonJS({
|
|
|
129798
129798
|
const socket = net.connect(address9, () => {
|
|
129799
129799
|
socket.removeListener("close", closeCallback);
|
|
129800
129800
|
socket.removeListener("error", errorCallback);
|
|
129801
|
-
|
|
129801
|
+
resolve63(socket);
|
|
129802
129802
|
});
|
|
129803
129803
|
socket.once("close", closeCallback);
|
|
129804
129804
|
socket.once("error", errorCallback);
|
|
@@ -133239,7 +133239,7 @@ var require_server_interceptors = __commonJS({
|
|
|
133239
133239
|
} else {
|
|
133240
133240
|
decompresser = zlib.createGunzip();
|
|
133241
133241
|
}
|
|
133242
|
-
return new Promise((
|
|
133242
|
+
return new Promise((resolve63, reject4) => {
|
|
133243
133243
|
let totalLength = 0;
|
|
133244
133244
|
const messageParts = [];
|
|
133245
133245
|
decompresser.on("error", (error65) => {
|
|
@@ -133260,7 +133260,7 @@ var require_server_interceptors = __commonJS({
|
|
|
133260
133260
|
}
|
|
133261
133261
|
});
|
|
133262
133262
|
decompresser.on("end", () => {
|
|
133263
|
-
|
|
133263
|
+
resolve63(Buffer.concat(messageParts));
|
|
133264
133264
|
});
|
|
133265
133265
|
decompresser.write(messageContents);
|
|
133266
133266
|
decompresser.end();
|
|
@@ -133871,10 +133871,10 @@ var require_server = __commonJS({
|
|
|
133871
133871
|
bindOneAddress(address9, boundPortObject) {
|
|
133872
133872
|
this.trace("Attempting to bind " + (0, subchannel_address_1.subchannelAddressToString)(address9));
|
|
133873
133873
|
const http2Server = this.createHttp2Server(boundPortObject.credentials);
|
|
133874
|
-
return new Promise((
|
|
133874
|
+
return new Promise((resolve63, reject4) => {
|
|
133875
133875
|
const onError = (err2) => {
|
|
133876
133876
|
this.trace("Failed to bind " + (0, subchannel_address_1.subchannelAddressToString)(address9) + " with error " + err2.message);
|
|
133877
|
-
|
|
133877
|
+
resolve63({
|
|
133878
133878
|
port: "port" in address9 ? address9.port : 1,
|
|
133879
133879
|
error: err2.message
|
|
133880
133880
|
});
|
|
@@ -133902,7 +133902,7 @@ var require_server = __commonJS({
|
|
|
133902
133902
|
});
|
|
133903
133903
|
boundPortObject.listeningServers.add(http2Server);
|
|
133904
133904
|
this.trace("Successfully bound " + (0, subchannel_address_1.subchannelAddressToString)(boundSubchannelAddress));
|
|
133905
|
-
|
|
133905
|
+
resolve63({
|
|
133906
133906
|
port: "port" in boundSubchannelAddress ? boundSubchannelAddress.port : 1
|
|
133907
133907
|
});
|
|
133908
133908
|
http2Server.removeListener("error", onError);
|
|
@@ -133955,7 +133955,7 @@ var require_server = __commonJS({
|
|
|
133955
133955
|
}
|
|
133956
133956
|
}
|
|
133957
133957
|
resolvePort(port) {
|
|
133958
|
-
return new Promise((
|
|
133958
|
+
return new Promise((resolve63, reject4) => {
|
|
133959
133959
|
let seenResolution = false;
|
|
133960
133960
|
const resolverListener = (endpointList, attributes3, serviceConfig, resolutionNote) => {
|
|
133961
133961
|
if (seenResolution) {
|
|
@@ -133971,7 +133971,7 @@ var require_server = __commonJS({
|
|
|
133971
133971
|
reject4(new Error(`No addresses resolved for port ${port}`));
|
|
133972
133972
|
return true;
|
|
133973
133973
|
}
|
|
133974
|
-
|
|
133974
|
+
resolve63(addressList);
|
|
133975
133975
|
return true;
|
|
133976
133976
|
};
|
|
133977
133977
|
const resolver = (0, resolver_1.createResolver)(port, resolverListener, this.options);
|
|
@@ -137248,7 +137248,7 @@ async function startGoogleAdsGrpc(env2) {
|
|
|
137248
137248
|
}
|
|
137249
137249
|
native3.addService(serviceDefinition(service), handlers);
|
|
137250
137250
|
}
|
|
137251
|
-
const innerPort = await new Promise((
|
|
137251
|
+
const innerPort = await new Promise((resolve63, reject4) => native3.bindAsync("127.0.0.1:0", grpc.ServerCredentials.createInsecure(), (err2, port2) => err2 ? reject4(err2) : resolve63(port2)));
|
|
137252
137252
|
const proxy = connect(`http://127.0.0.1:${innerPort}`);
|
|
137253
137253
|
proxy.on("error", () => {
|
|
137254
137254
|
});
|
|
@@ -137360,11 +137360,11 @@ async function startGoogleAdsGrpc(env2) {
|
|
|
137360
137360
|
stream2.pipe(upstream);
|
|
137361
137361
|
upstream.pipe(stream2);
|
|
137362
137362
|
});
|
|
137363
|
-
await new Promise((
|
|
137363
|
+
await new Promise((resolve63, reject4) => {
|
|
137364
137364
|
front.once("error", reject4);
|
|
137365
137365
|
front.listen(0, "127.0.0.1", () => {
|
|
137366
137366
|
front.off("error", reject4);
|
|
137367
|
-
|
|
137367
|
+
resolve63();
|
|
137368
137368
|
});
|
|
137369
137369
|
}).catch((e) => {
|
|
137370
137370
|
proxy.destroy();
|
|
@@ -137383,7 +137383,7 @@ async function startGoogleAdsGrpc(env2) {
|
|
|
137383
137383
|
s3.destroy();
|
|
137384
137384
|
proxy.destroy();
|
|
137385
137385
|
native3.forceShutdown();
|
|
137386
|
-
await new Promise((
|
|
137386
|
+
await new Promise((resolve63) => front.close(() => resolve63()));
|
|
137387
137387
|
})();
|
|
137388
137388
|
return closing;
|
|
137389
137389
|
} };
|
|
@@ -156218,8 +156218,8 @@ function list13(call4) {
|
|
|
156218
156218
|
const found = rows31(call4, `select row_to_json(o) from storage.objects o where bucket_id = $1 and ${body8.exactMatch ? "name = $2" : "starts_with(name, $2)"}`, [bucket4, body8.exactMatch ? prefix2 : folder2]);
|
|
156219
156219
|
const entries4 = /* @__PURE__ */ new Map();
|
|
156220
156220
|
for (const obj of found) {
|
|
156221
|
-
const
|
|
156222
|
-
const name5 = slash < 0 ?
|
|
156221
|
+
const relative31 = body8.exactMatch ? obj.name : obj.name.slice(folder2.length), slash = relative31.indexOf("/");
|
|
156222
|
+
const name5 = slash < 0 ? relative31 : relative31.slice(0, slash);
|
|
156223
156223
|
if (body8.search && !name5.toLowerCase().startsWith(String(body8.search).toLowerCase())) continue;
|
|
156224
156224
|
if (slash >= 0) {
|
|
156225
156225
|
if (!entries4.has(`folder:${name5}`)) entries4.set(`folder:${name5}`, { name: name5, id: null, created_at: null, updated_at: null, last_accessed_at: null, metadata: null });
|
|
@@ -161081,9 +161081,9 @@ function freeName(ctx, parentId, name5) {
|
|
|
161081
161081
|
if (!childNamed(ctx, parentId, candidate)) return candidate;
|
|
161082
161082
|
}
|
|
161083
161083
|
}
|
|
161084
|
-
function walk(call4, from,
|
|
161084
|
+
function walk(call4, from, relative31) {
|
|
161085
161085
|
let node5 = from;
|
|
161086
|
-
for (const part of
|
|
161086
|
+
for (const part of relative31.split("/").filter(Boolean)) node5 = node5 && childNamed(call4.ctx, node5.id, part);
|
|
161087
161087
|
return node5;
|
|
161088
161088
|
}
|
|
161089
161089
|
function ensureFolder(call4, from, parts3) {
|
|
@@ -162404,14 +162404,14 @@ async function handle18(c) {
|
|
|
162404
162404
|
if (!item2) throw new GraphError(404, "itemNotFound", "The resource could not be found.");
|
|
162405
162405
|
remaining = remaining.slice(byId3[0].length);
|
|
162406
162406
|
}
|
|
162407
|
-
let
|
|
162407
|
+
let relative31;
|
|
162408
162408
|
if (remaining.startsWith(":/")) {
|
|
162409
162409
|
const end = remaining.indexOf(":", 2);
|
|
162410
|
-
|
|
162410
|
+
relative31 = decodeURIComponent(end === -1 ? remaining.slice(2) : remaining.slice(2, end));
|
|
162411
162411
|
remaining = end === -1 ? "" : remaining.slice(end + 1);
|
|
162412
162412
|
} else if (remaining === ":") remaining = "";
|
|
162413
162413
|
const action = remaining.replace(/^\//, "");
|
|
162414
|
-
return itemRoute({ ctx, method: method2, url: url4, item: item2, relative:
|
|
162414
|
+
return itemRoute({ ctx, method: method2, url: url4, item: item2, relative: relative31, action, body: raw3, json: body8, headers: c.req.raw.headers });
|
|
162415
162415
|
});
|
|
162416
162416
|
} catch (error65) {
|
|
162417
162417
|
if (ctx.signal?.aborted) return new Response(null, { status: 409 });
|
|
@@ -169231,9 +169231,9 @@ function evaluate2(q2, w2) {
|
|
|
169231
169231
|
if (!found2) throw new JqlError(/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(text31) ? `An issue with key '${text31.toUpperCase()}' does not exist for field '${field6}'.` : `The issue key '${text31}' for field '${field6}' is invalid.`);
|
|
169232
169232
|
return found2.id;
|
|
169233
169233
|
};
|
|
169234
|
-
const one7 = (
|
|
169234
|
+
const one7 = (resolve63) => (v) => {
|
|
169235
169235
|
const t = literal4(v, "");
|
|
169236
|
-
return t === null ? [] : [
|
|
169236
|
+
return t === null ? [] : [resolve63(t)];
|
|
169237
169237
|
};
|
|
169238
169238
|
const users5 = (field6, get8) => ({ kind: "set", get: (i) => get8(i).filter((x) => x !== null), resolve: (v) => {
|
|
169239
169239
|
if (v.kind === "func") {
|
|
@@ -173759,9 +173759,9 @@ function parseQuery2(query12) {
|
|
|
173759
173759
|
return terms2;
|
|
173760
173760
|
}
|
|
173761
173761
|
function dateMatches(ms2, term2, now11) {
|
|
173762
|
-
const
|
|
173763
|
-
if (
|
|
173764
|
-
const edge = now11 - Number(
|
|
173762
|
+
const relative31 = /^(\d+)(minute|hour|day|week|month|year)s?$/i.exec(term2.value);
|
|
173763
|
+
if (relative31) {
|
|
173764
|
+
const edge = now11 - Number(relative31[1]) * UNITS3[relative31[2].toLowerCase()];
|
|
173765
173765
|
return term2.op === ">" || term2.op === ">=" || term2.op === ":" ? ms2 >= edge : ms2 < edge;
|
|
173766
173766
|
}
|
|
173767
173767
|
const date11 = /^\d{4}-\d{2}-\d{2}$/.test(term2.value) ? Date.parse(`${term2.value}T00:00:00Z`) : Date.parse(term2.value);
|
|
@@ -179403,9 +179403,9 @@ function matches7(f2, value6, now11) {
|
|
|
179403
179403
|
if (f2.key === "message" || f2.key === "title") return f2.values.some((v) => v.includes("*") ? glob2(v, value6, true) : value6.toLowerCase().includes(v.toLowerCase()));
|
|
179404
179404
|
return f2.values.some((v) => glob2(v, value6, caseless));
|
|
179405
179405
|
}
|
|
179406
|
-
function eventTest(filters2, text31, lookup7, now11,
|
|
179406
|
+
function eventTest(filters2, text31, lookup7, now11, resolve63 = (f2) => f2) {
|
|
179407
179407
|
return (e) => filters2.every((raw3) => {
|
|
179408
|
-
const f2 =
|
|
179408
|
+
const f2 = resolve63(raw3, e);
|
|
179409
179409
|
if (f2.key === "has") return f2.values.every((k) => {
|
|
179410
179410
|
const v = eventValue(e, k, lookup7);
|
|
179411
179411
|
return v !== null && v !== "" && !(Array.isArray(v) && !v.length);
|
|
@@ -186838,8 +186838,8 @@ function hasWindow(e) {
|
|
|
186838
186838
|
function sql3(...parts3) {
|
|
186839
186839
|
return { sql: parts3.map((p2) => typeof p2 === "string" ? p2 : p2.sql).join(""), params: parts3.flatMap((p2) => typeof p2 === "string" ? [] : p2.params) };
|
|
186840
186840
|
}
|
|
186841
|
-
function separated(parts3,
|
|
186842
|
-
return sql3(...parts3.flatMap((p2, i) => i ? [
|
|
186841
|
+
function separated(parts3, sep10 = ", ") {
|
|
186842
|
+
return sql3(...parts3.flatMap((p2, i) => i ? [sep10, p2] : [p2]));
|
|
186843
186843
|
}
|
|
186844
186844
|
function bound2(value6, type, kids = [], aggregateRoot = false) {
|
|
186845
186845
|
return { ...value6, type, children: kids, aggregateRoot, aggregate: aggregateRoot || kids.some((k) => k.aggregate) };
|
|
@@ -188667,8 +188667,8 @@ var init_suiteql_executor = __esm({
|
|
|
188667
188667
|
const free = this.#slots.size < this.#options.workers || [...this.#slots].some((s3) => !s3.job && !s3.terminating);
|
|
188668
188668
|
const active4 = [...this.#slots].some((s3) => s3.job?.ctx.store === ctx.store);
|
|
188669
188669
|
if ((!free || active4) && this.#queue.length >= this.#options.queue) return Promise.reject(new NetsuiteError(429, "CONCURRENCY_LIMIT_EXCEEDED", "Query execution queue is full."));
|
|
188670
|
-
return new Promise((
|
|
188671
|
-
const job = { ctx, query: query12, page: page20, mapped, params: params10, prepare: prepare4, resolve:
|
|
188670
|
+
return new Promise((resolve63, reject4) => {
|
|
188671
|
+
const job = { ctx, query: query12, page: page20, mapped, params: params10, prepare: prepare4, resolve: resolve63, reject: reject4, settled: false, timer: void 0, abort: () => this.#cancel(job, ctx.signal?.reason ?? new DOMException("Aborted", "AbortError")) };
|
|
188672
188672
|
job.timer = setTimeout(() => this.#cancel(job, new NetsuiteError(400, "INVALID_REQUEST", "Query execution deadline exceeded.")), this.#options.deadlineMs);
|
|
188673
188673
|
ctx.signal?.addEventListener("abort", job.abort, { once: true });
|
|
188674
188674
|
this.#queue.push(job);
|
|
@@ -198810,12 +198810,12 @@ function grantsFor(manager) {
|
|
|
198810
198810
|
}
|
|
198811
198811
|
function closeSocket(socket) {
|
|
198812
198812
|
if (!socket || socket.readyState === import_websocket.default.CLOSED) return Promise.resolve();
|
|
198813
|
-
return new Promise((
|
|
198813
|
+
return new Promise((resolve63) => {
|
|
198814
198814
|
const timer = setTimeout(() => socket.terminate(), 1e3);
|
|
198815
198815
|
timer.unref();
|
|
198816
198816
|
socket.once("close", () => {
|
|
198817
198817
|
clearTimeout(timer);
|
|
198818
|
-
|
|
198818
|
+
resolve63();
|
|
198819
198819
|
});
|
|
198820
198820
|
socket.close(1e3, "session ended");
|
|
198821
198821
|
});
|
|
@@ -198863,7 +198863,7 @@ Content-Length: 0\r
|
|
|
198863
198863
|
return { close: () => closing ??= (async () => {
|
|
198864
198864
|
server.off("upgrade", upgrade);
|
|
198865
198865
|
await Promise.all([...wss.clients].map(closeSocket));
|
|
198866
|
-
await new Promise((
|
|
198866
|
+
await new Promise((resolve63) => wss.close(() => resolve63()));
|
|
198867
198867
|
})() };
|
|
198868
198868
|
}
|
|
198869
198869
|
var SOCKET_GRANT_TTL_MS, SOCKET_ACK_MS, SOCKET_PING_MS, SOCKET_PONG_MS, registries, SocketDelivery;
|
|
@@ -199181,7 +199181,7 @@ async function readFeed(env2, options5) {
|
|
|
199181
199181
|
if (!Number.isSafeInteger(waitMs) || waitMs < 0 || waitMs > 25e3) throw new AnchaError("USAGE", "wait_ms must be an integer from 0 to 25000");
|
|
199182
199182
|
let events3 = env2.events.list(after);
|
|
199183
199183
|
if (events3.length === 0 && waitMs > 0) {
|
|
199184
|
-
events3 = await new Promise((
|
|
199184
|
+
events3 = await new Promise((resolve63, reject4) => {
|
|
199185
199185
|
let settled = false;
|
|
199186
199186
|
let unsubscribe = () => {
|
|
199187
199187
|
};
|
|
@@ -199196,7 +199196,7 @@ async function readFeed(env2, options5) {
|
|
|
199196
199196
|
if (settled) return;
|
|
199197
199197
|
settled = true;
|
|
199198
199198
|
cleanup();
|
|
199199
|
-
|
|
199199
|
+
resolve63(batch4);
|
|
199200
199200
|
};
|
|
199201
199201
|
const abort = () => {
|
|
199202
199202
|
if (settled) return;
|
|
@@ -199676,7 +199676,7 @@ async function advanceLive(env2, by2, budgets = { segmentMs: 1e4, totalMs: 6e4,
|
|
|
199676
199676
|
reason2 = env2.deliveriesDueAt(next2) ? "delivery_timeout" : "request_timeout";
|
|
199677
199677
|
break;
|
|
199678
199678
|
}
|
|
199679
|
-
await new Promise((
|
|
199679
|
+
await new Promise((resolve63) => setTimeout(resolve63, 5));
|
|
199680
199680
|
}
|
|
199681
199681
|
if (!live2()) {
|
|
199682
199682
|
reason2 = "stopped";
|
|
@@ -201299,7 +201299,7 @@ var init_dist3 = __esm({
|
|
|
201299
201299
|
});
|
|
201300
201300
|
if (!chunk) {
|
|
201301
201301
|
if (i === 1) {
|
|
201302
|
-
await new Promise((
|
|
201302
|
+
await new Promise((resolve63) => setTimeout(resolve63));
|
|
201303
201303
|
maxReadCount = 3;
|
|
201304
201304
|
continue;
|
|
201305
201305
|
}
|
|
@@ -201512,11 +201512,11 @@ async function startServer(opts = {}) {
|
|
|
201512
201512
|
let stopAfterError;
|
|
201513
201513
|
let onError;
|
|
201514
201514
|
try {
|
|
201515
|
-
await new Promise((
|
|
201515
|
+
await new Promise((resolve63, reject4) => {
|
|
201516
201516
|
let listening = false;
|
|
201517
201517
|
const onListening = () => {
|
|
201518
201518
|
listening = true;
|
|
201519
|
-
|
|
201519
|
+
resolve63();
|
|
201520
201520
|
};
|
|
201521
201521
|
onError = (cause) => {
|
|
201522
201522
|
if (!listening) {
|
|
@@ -201542,8 +201542,8 @@ async function startServer(opts = {}) {
|
|
|
201542
201542
|
const sweep = setInterval(() => manager.reapExpired(), 1e3);
|
|
201543
201543
|
sweep.unref();
|
|
201544
201544
|
let resolveClosed;
|
|
201545
|
-
const closed = new Promise((
|
|
201546
|
-
resolveClosed =
|
|
201545
|
+
const closed = new Promise((resolve63) => {
|
|
201546
|
+
resolveClosed = resolve63;
|
|
201547
201547
|
});
|
|
201548
201548
|
let closing;
|
|
201549
201549
|
const close2 = () => closing ??= (async () => {
|
|
@@ -201555,12 +201555,12 @@ async function startServer(opts = {}) {
|
|
|
201555
201555
|
await manager.drainResources().catch((error65) => {
|
|
201556
201556
|
runtimeError ??= error65 instanceof AnchaError ? error65 : new AnchaError("INTERNAL", "native transport shutdown failed", { cause: error65 });
|
|
201557
201557
|
});
|
|
201558
|
-
await new Promise((
|
|
201558
|
+
await new Promise((resolve63, reject4) => {
|
|
201559
201559
|
const force = setTimeout(() => server.closeAllConnections(), 1e3);
|
|
201560
201560
|
server.close((e) => {
|
|
201561
201561
|
clearTimeout(force);
|
|
201562
201562
|
if (e) reject4(runtimeError ?? startError(e));
|
|
201563
|
-
else
|
|
201563
|
+
else resolve63();
|
|
201564
201564
|
});
|
|
201565
201565
|
server.closeIdleConnections();
|
|
201566
201566
|
});
|
|
@@ -205352,7 +205352,7 @@ var init_values2 = __esm({
|
|
|
205352
205352
|
var sleep2;
|
|
205353
205353
|
var init_sleep = __esm({
|
|
205354
205354
|
"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"() {
|
|
205355
|
-
sleep2 = (ms2, ...signals) => new Promise((
|
|
205355
|
+
sleep2 = (ms2, ...signals) => new Promise((resolve63, reject4) => {
|
|
205356
205356
|
const activeSignals = [...new Set(signals.filter((signal) => signal != null))];
|
|
205357
205357
|
let timeout;
|
|
205358
205358
|
let settled = false;
|
|
@@ -205384,7 +205384,7 @@ var init_sleep = __esm({
|
|
|
205384
205384
|
return;
|
|
205385
205385
|
}
|
|
205386
205386
|
timeout = setTimeout(() => {
|
|
205387
|
-
settle4(
|
|
205387
|
+
settle4(resolve63);
|
|
205388
205388
|
}, ms2);
|
|
205389
205389
|
for (const signal of activeSignals) {
|
|
205390
205390
|
if (settled) {
|
|
@@ -205930,8 +205930,8 @@ function createAbortableSSESource(body8, signal) {
|
|
|
205930
205930
|
let interrupt;
|
|
205931
205931
|
const waitForAbort = () => (
|
|
205932
205932
|
// oxlint-disable-next-line promise/avoid-new -- AbortSignal callbacks need a portable Promise bridge.
|
|
205933
|
-
new Promise((
|
|
205934
|
-
interrupt =
|
|
205933
|
+
new Promise((resolve63) => {
|
|
205934
|
+
interrupt = resolve63;
|
|
205935
205935
|
})
|
|
205936
205936
|
);
|
|
205937
205937
|
const cancel4 = () => {
|
|
@@ -207204,8 +207204,8 @@ var init_api_promise = __esm({
|
|
|
207204
207204
|
init_parse3();
|
|
207205
207205
|
APIPromise = class _APIPromise extends Promise {
|
|
207206
207206
|
constructor(client2, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
207207
|
-
super((
|
|
207208
|
-
|
|
207207
|
+
super((resolve63) => {
|
|
207208
|
+
resolve63(null);
|
|
207209
207209
|
});
|
|
207210
207210
|
this.responsePromise = responsePromise;
|
|
207211
207211
|
this.parseResponse = parseResponse2;
|
|
@@ -210376,12 +210376,12 @@ var init_EventStream = __esm({
|
|
|
210376
210376
|
_EventStream_aborted.set(this, false);
|
|
210377
210377
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
210378
210378
|
_EventStream_terminalFailure.set(this, void 0);
|
|
210379
|
-
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((
|
|
210380
|
-
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise,
|
|
210379
|
+
__classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve63, reject4) => {
|
|
210380
|
+
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve63, "f");
|
|
210381
210381
|
__classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject4, "f");
|
|
210382
210382
|
}), "f");
|
|
210383
|
-
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((
|
|
210384
|
-
__classPrivateFieldSet(this, _EventStream_resolveEndPromise,
|
|
210383
|
+
__classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve63, reject4) => {
|
|
210384
|
+
__classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve63, "f");
|
|
210385
210385
|
__classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject4, "f");
|
|
210386
210386
|
}), "f");
|
|
210387
210387
|
__classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => void 0);
|
|
@@ -210519,7 +210519,7 @@ var init_EventStream = __esm({
|
|
|
210519
210519
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
210520
210520
|
*/
|
|
210521
210521
|
emitted(event3) {
|
|
210522
|
-
return new Promise((
|
|
210522
|
+
return new Promise((resolve63, reject4) => {
|
|
210523
210523
|
__classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
210524
210524
|
const onError = (error65) => {
|
|
210525
210525
|
this.off(event3, onEvent);
|
|
@@ -210529,7 +210529,7 @@ var init_EventStream = __esm({
|
|
|
210529
210529
|
if (event3 !== "error") {
|
|
210530
210530
|
this.off("error", onError);
|
|
210531
210531
|
}
|
|
210532
|
-
|
|
210532
|
+
resolve63(values3.length > 1 ? values3 : values3[0]);
|
|
210533
210533
|
};
|
|
210534
210534
|
if (event3 !== "error") {
|
|
210535
210535
|
__classPrivateFieldGet(this, _EventStream_instances, "m", _EventStream_onceForEmitted).call(this, "error", onError);
|
|
@@ -210745,8 +210745,8 @@ var init_EventStream = __esm({
|
|
|
210745
210745
|
if (ended) {
|
|
210746
210746
|
return Promise.resolve(doneResult());
|
|
210747
210747
|
}
|
|
210748
|
-
return new Promise((
|
|
210749
|
-
readQueue.enqueue({ resolve:
|
|
210748
|
+
return new Promise((resolve63, reject4) => {
|
|
210749
|
+
readQueue.enqueue({ resolve: resolve63, reject: reject4 });
|
|
210750
210750
|
});
|
|
210751
210751
|
},
|
|
210752
210752
|
return: () => {
|
|
@@ -219332,8 +219332,8 @@ var init_tool_dispatcher = __esm({
|
|
|
219332
219332
|
try {
|
|
219333
219333
|
await __classPrivateFieldGet(this, _AgentToolDispatcher_instances, "m", _AgentToolDispatcher_wait).call(this, () => (
|
|
219334
219334
|
// oxlint-disable-next-line promise/avoid-new -- Own the registration timer so cancellation clears it promptly.
|
|
219335
|
-
new Promise((
|
|
219336
|
-
timer = setTimeout(
|
|
219335
|
+
new Promise((resolve63) => {
|
|
219336
|
+
timer = setTimeout(resolve63, delay);
|
|
219337
219337
|
})
|
|
219338
219338
|
));
|
|
219339
219339
|
} finally {
|
|
@@ -221266,7 +221266,7 @@ var init_steps2 = __esm({
|
|
|
221266
221266
|
|
|
221267
221267
|
// 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
|
|
221268
221268
|
function sleepUntilAborted(milliseconds, signal) {
|
|
221269
|
-
return new Promise((
|
|
221269
|
+
return new Promise((resolve63, reject4) => {
|
|
221270
221270
|
let timer;
|
|
221271
221271
|
let registered;
|
|
221272
221272
|
let settled = false;
|
|
@@ -221315,7 +221315,7 @@ function sleepUntilAborted(milliseconds, signal) {
|
|
|
221315
221315
|
}
|
|
221316
221316
|
settled = true;
|
|
221317
221317
|
cleanup();
|
|
221318
|
-
|
|
221318
|
+
resolve63();
|
|
221319
221319
|
}, milliseconds);
|
|
221320
221320
|
registered = abort;
|
|
221321
221321
|
try {
|
|
@@ -231360,9 +231360,14 @@ function noWorldMessage(toolkit) {
|
|
|
231360
231360
|
const name5 = toolkit === "quickbooks" ? "QuickBooks" : "NetSuite";
|
|
231361
231361
|
return `This test's world has no ${name5}. Add ${name5} to the test's world or run this call in a test whose world has it.`;
|
|
231362
231362
|
}
|
|
231363
|
+
function notRoutedMessage(toolkit) {
|
|
231364
|
+
return `${toolkit === "quickbooks" ? "QuickBooks" : "NetSuite"} is not routed for this agent. Add ${toolkit}: composio under agent.routes in ancha.yaml.`;
|
|
231365
|
+
}
|
|
231363
231366
|
function requireWorld(name5, route15) {
|
|
231364
231367
|
const toolkit = name5.startsWith("QUICKBOOKS_") ? "quickbooks" : name5.startsWith("NETSUITE_") ? "netsuite" : void 0;
|
|
231365
|
-
if (
|
|
231368
|
+
if (!toolkit) return;
|
|
231369
|
+
if (!(route15.toolkits ?? { quickbooks: "composio" })[toolkit]) throw new RouteRefusal("NOT_ROUTED", toolkit);
|
|
231370
|
+
if (!activeComposioToolkits(route15)[toolkit]) throw new RouteRefusal("NO_WORLD", toolkit);
|
|
231366
231371
|
}
|
|
231367
231372
|
function parsed3(schema4, value6) {
|
|
231368
231373
|
const result = schema4.safeParse(value6);
|
|
@@ -231709,7 +231714,7 @@ var init_composio = __esm({
|
|
|
231709
231714
|
reason;
|
|
231710
231715
|
toolkit;
|
|
231711
231716
|
constructor(reason2, toolkit) {
|
|
231712
|
-
super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
|
|
231717
|
+
super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NOT_ROUTED" && toolkit ? notRoutedMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
|
|
231713
231718
|
this.reason = reason2;
|
|
231714
231719
|
this.toolkit = toolkit;
|
|
231715
231720
|
}
|
|
@@ -231970,9 +231975,9 @@ async function startIsolationGateway(options5) {
|
|
|
231970
231975
|
res.once("close", record32);
|
|
231971
231976
|
}
|
|
231972
231977
|
if (activityCallback) {
|
|
231973
|
-
const ended = new Promise((
|
|
231974
|
-
res.once("finish",
|
|
231975
|
-
res.once("close",
|
|
231978
|
+
const ended = new Promise((resolve63) => {
|
|
231979
|
+
res.once("finish", resolve63);
|
|
231980
|
+
res.once("close", resolve63);
|
|
231976
231981
|
});
|
|
231977
231982
|
const started = activityCallback(true);
|
|
231978
231983
|
const activity3 = (async () => {
|
|
@@ -232239,11 +232244,11 @@ ${Object.entries(reply6.headers).map(([name5, value6]) => `${name5}: ${value6}`)
|
|
|
232239
232244
|
target6.end();
|
|
232240
232245
|
});
|
|
232241
232246
|
server.on("connect", (_req, client2) => client2.end("HTTP/1.1 403 Rejected\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"));
|
|
232242
|
-
await new Promise((
|
|
232247
|
+
await new Promise((resolve63, rejectListen) => {
|
|
232243
232248
|
server.once("error", rejectListen);
|
|
232244
232249
|
server.listen(options5.port ?? 0, "127.0.0.1", () => {
|
|
232245
232250
|
server.removeListener("error", rejectListen);
|
|
232246
|
-
|
|
232251
|
+
resolve63();
|
|
232247
232252
|
});
|
|
232248
232253
|
});
|
|
232249
232254
|
const address9 = server.address();
|
|
@@ -232258,7 +232263,7 @@ ${Object.entries(reply6.headers).map(([name5, value6]) => `${name5}: ${value6}`)
|
|
|
232258
232263
|
for (const controller of localRequests) controller.abort();
|
|
232259
232264
|
for (const target6 of upstreamRequests) target6.destroy();
|
|
232260
232265
|
for (const socket of sockets) socket.destroy();
|
|
232261
|
-
await new Promise((
|
|
232266
|
+
await new Promise((resolve63) => server.close(() => resolve63()));
|
|
232262
232267
|
await Promise.all(modelActivity);
|
|
232263
232268
|
})();
|
|
232264
232269
|
const abort = () => {
|
|
@@ -232928,6 +232933,7 @@ var init_ingress_client = __esm({
|
|
|
232928
232933
|
hash6 = (value6) => createHash61("sha256").update(value6).digest("hex").slice(0, 16);
|
|
232929
232934
|
REFUSAL_FIX = {
|
|
232930
232935
|
NO_WORLD: noWorldMessage,
|
|
232936
|
+
NOT_ROUTED: notRoutedMessage,
|
|
232931
232937
|
NETSUITE_TOOL: "use session.execute or tools.execute with NETSUITE_RUN_SUITEQL_QUERY",
|
|
232932
232938
|
ROUTE_UNAVAILABLE: "the route had closed; run again",
|
|
232933
232939
|
PATH: "use QuickBooks tools, sessions and session MCP through COMPOSIO_BASE_URL",
|
|
@@ -233620,9 +233626,9 @@ function startAgentProcess(command, opts) {
|
|
|
233620
233626
|
graceEnds = performance.now() + KILL_GRACE_MS;
|
|
233621
233627
|
killTimer = setTimeout(() => signalGroup(pid, "SIGKILL"), KILL_GRACE_MS);
|
|
233622
233628
|
};
|
|
233623
|
-
const outcome4 = new Promise((
|
|
233624
|
-
child3.once("error", (error65) =>
|
|
233625
|
-
child3.once("exit", (code5) =>
|
|
233629
|
+
const outcome4 = new Promise((resolve63) => {
|
|
233630
|
+
child3.once("error", (error65) => resolve63({ kind: "error", error: error65 }));
|
|
233631
|
+
child3.once("exit", (code5) => resolve63({ kind: "exit", code: code5 }));
|
|
233626
233632
|
});
|
|
233627
233633
|
const exited = outcome4.then(async (result) => {
|
|
233628
233634
|
try {
|
|
@@ -233763,14 +233769,14 @@ function attachIsolationRelay(options5) {
|
|
|
233763
233769
|
const channels = /* @__PURE__ */ new Map();
|
|
233764
233770
|
let ended = false, readySeen = false, buffer = "", counter = 0;
|
|
233765
233771
|
let resolveReady, rejectReady, resolveClosed;
|
|
233766
|
-
const peerReady = new Promise((
|
|
233767
|
-
resolveReady =
|
|
233772
|
+
const peerReady = new Promise((resolve63, reject4) => {
|
|
233773
|
+
resolveReady = resolve63;
|
|
233768
233774
|
rejectReady = reject4;
|
|
233769
233775
|
});
|
|
233770
233776
|
void peerReady.catch(() => {
|
|
233771
233777
|
});
|
|
233772
|
-
const closed = new Promise((
|
|
233773
|
-
resolveClosed =
|
|
233778
|
+
const closed = new Promise((resolve63) => {
|
|
233779
|
+
resolveClosed = resolve63;
|
|
233774
233780
|
});
|
|
233775
233781
|
const forward2 = options5.forwardPort === void 0 ? void 0 : createServer2({ allowHalfOpen: true });
|
|
233776
233782
|
let closing;
|
|
@@ -233787,9 +233793,9 @@ function attachIsolationRelay(options5) {
|
|
|
233787
233793
|
}
|
|
233788
233794
|
channels.clear();
|
|
233789
233795
|
options5.output.end();
|
|
233790
|
-
closing = new Promise((
|
|
233791
|
-
if (forward2?.listening) forward2.close(() =>
|
|
233792
|
-
else
|
|
233796
|
+
closing = new Promise((resolve63) => {
|
|
233797
|
+
if (forward2?.listening) forward2.close(() => resolve63());
|
|
233798
|
+
else resolve63();
|
|
233793
233799
|
}).finally(resolveClosed);
|
|
233794
233800
|
}
|
|
233795
233801
|
function send3(frame2) {
|
|
@@ -233917,9 +233923,9 @@ function attachIsolationRelay(options5) {
|
|
|
233917
233923
|
options5.output.once("close", () => fail9());
|
|
233918
233924
|
options5.signal?.addEventListener("abort", abort, { once: true });
|
|
233919
233925
|
if (options5.signal?.aborted) abort();
|
|
233920
|
-
const forwardReady = new Promise((
|
|
233926
|
+
const forwardReady = new Promise((resolve63, reject4) => {
|
|
233921
233927
|
if (!forward2 || ended) {
|
|
233922
|
-
|
|
233928
|
+
resolve63();
|
|
233923
233929
|
return;
|
|
233924
233930
|
}
|
|
233925
233931
|
forward2.on("connection", (socket) => {
|
|
@@ -233938,7 +233944,7 @@ function attachIsolationRelay(options5) {
|
|
|
233938
233944
|
});
|
|
233939
233945
|
forward2.listen(options5.forwardPort, "127.0.0.1", () => {
|
|
233940
233946
|
if (ended) forward2.close();
|
|
233941
|
-
|
|
233947
|
+
resolve63();
|
|
233942
233948
|
});
|
|
233943
233949
|
});
|
|
233944
233950
|
const ready3 = Promise.all([peerReady, forwardReady]).then(() => {
|
|
@@ -234366,9 +234372,9 @@ async function startContainedAgent(command, opts) {
|
|
|
234366
234372
|
});
|
|
234367
234373
|
}
|
|
234368
234374
|
});
|
|
234369
|
-
const outcome4 = new Promise((
|
|
234370
|
-
child3.once("error", (error65) =>
|
|
234371
|
-
child3.once("close", (code5) =>
|
|
234375
|
+
const outcome4 = new Promise((resolve63) => {
|
|
234376
|
+
child3.once("error", (error65) => resolve63({ kind: "error", error: error65 }));
|
|
234377
|
+
child3.once("close", (code5) => resolve63(bridgeFailed ? { kind: "error", error: new Error("Container bridge failed or agent output exceeded 8 MiB") } : { kind: "exit", code: code5 }));
|
|
234372
234378
|
});
|
|
234373
234379
|
const exited = outcome4.then(async (result) => {
|
|
234374
234380
|
try {
|
|
@@ -234687,10 +234693,10 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
234687
234693
|
if (!truncated) stdoutTail.push(chunk);
|
|
234688
234694
|
});
|
|
234689
234695
|
child3.stderr?.on("data", log3);
|
|
234690
|
-
const closed = new Promise((
|
|
234691
|
-
const outcome4 = new Promise((
|
|
234692
|
-
child3.once("error", () =>
|
|
234693
|
-
child3.once("exit", (code5) =>
|
|
234696
|
+
const closed = new Promise((resolve63) => child3.once("close", () => resolve63()));
|
|
234697
|
+
const outcome4 = new Promise((resolve63) => {
|
|
234698
|
+
child3.once("error", () => resolve63({ kind: "error", error: new AnchaError("AGENT_UNREACHABLE", "The agent process could not be started.") }));
|
|
234699
|
+
child3.once("exit", (code5) => resolve63({ kind: "exit", code: code5 }));
|
|
234694
234700
|
});
|
|
234695
234701
|
const exited = outcome4.then(async (result) => {
|
|
234696
234702
|
try {
|
|
@@ -234706,7 +234712,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
234706
234712
|
void exited.catch(() => {
|
|
234707
234713
|
});
|
|
234708
234714
|
const startup = AbortSignal.any([AbortSignal.timeout(1e4), ...opts.signal ? [opts.signal] : [], ...opts.startupSignal ? [opts.startupSignal] : []]);
|
|
234709
|
-
await new Promise((
|
|
234715
|
+
await new Promise((resolve63, reject4) => {
|
|
234710
234716
|
const pipe2 = unsafe ? void 0 : child3.stdio[3];
|
|
234711
234717
|
let received = "";
|
|
234712
234718
|
const remove5 = () => {
|
|
@@ -234718,7 +234724,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
234718
234724
|
};
|
|
234719
234725
|
const ready3 = () => {
|
|
234720
234726
|
remove5();
|
|
234721
|
-
|
|
234727
|
+
resolve63();
|
|
234722
234728
|
};
|
|
234723
234729
|
const failed2 = () => {
|
|
234724
234730
|
remove5();
|
|
@@ -234866,13 +234872,13 @@ async function abortable(promise3, signal) {
|
|
|
234866
234872
|
}
|
|
234867
234873
|
async function reservePort(used) {
|
|
234868
234874
|
const rejected = [];
|
|
234869
|
-
const close2 = (server) => new Promise((
|
|
234875
|
+
const close2 = (server) => new Promise((resolve63, reject4) => server.close((error65) => error65 ? reject4(error65) : resolve63()));
|
|
234870
234876
|
try {
|
|
234871
234877
|
for (; ; ) {
|
|
234872
234878
|
const socket = createServer3();
|
|
234873
|
-
await new Promise((
|
|
234879
|
+
await new Promise((resolve63, reject4) => {
|
|
234874
234880
|
socket.once("error", reject4);
|
|
234875
|
-
socket.listen(0, "127.0.0.1",
|
|
234881
|
+
socket.listen(0, "127.0.0.1", resolve63);
|
|
234876
234882
|
});
|
|
234877
234883
|
const address9 = socket.address();
|
|
234878
234884
|
if (address9 === null || typeof address9 === "string") {
|
|
@@ -235097,16 +235103,16 @@ async function reserve(used) {
|
|
|
235097
235103
|
for (let n2 = 0; n2 < 100; n2++) {
|
|
235098
235104
|
const server = createServer4();
|
|
235099
235105
|
held.push(server);
|
|
235100
|
-
await new Promise((
|
|
235106
|
+
await new Promise((resolve63, reject4) => {
|
|
235101
235107
|
server.once("error", reject4);
|
|
235102
|
-
server.listen(0, "127.0.0.1",
|
|
235108
|
+
server.listen(0, "127.0.0.1", resolve63);
|
|
235103
235109
|
});
|
|
235104
235110
|
const address9 = server.address();
|
|
235105
235111
|
if (!address9 || typeof address9 === "string") throw new Error("local agent port unavailable");
|
|
235106
235112
|
if (used.has(address9.port)) continue;
|
|
235107
235113
|
used.add(address9.port);
|
|
235108
235114
|
chosen = true;
|
|
235109
|
-
return { port: address9.port, release: () => new Promise((
|
|
235115
|
+
return { port: address9.port, release: () => new Promise((resolve63, reject4) => server.close((error65) => error65 ? reject4(error65) : resolve63())) };
|
|
235110
235116
|
}
|
|
235111
235117
|
throw new Error("fresh local agent port unavailable");
|
|
235112
235118
|
} finally {
|
|
@@ -236486,7 +236492,7 @@ function variantFamilies(summary) {
|
|
|
236486
236492
|
for (const name5 of ["requested", "passed", "failed", "invalid"]) family2.attempts[name5] += counts2[name5];
|
|
236487
236493
|
family2.attempts.ungraded += counts2.ungraded + counts2.skipped;
|
|
236488
236494
|
family2.attempts.notRun += counts2.pending;
|
|
236489
|
-
family2.rows.push({ sceneId: scene2.sceneId, ordinal: v.ordinal, kind: v.kind, change: v.change, passed: counts2.passed, requested: counts2.requested });
|
|
236495
|
+
family2.rows.push({ sceneId: scene2.sceneId, ordinal: v.ordinal, kind: v.kind, change: v.change, passed: counts2.passed, requested: counts2.requested, notRun: counts2.pending });
|
|
236490
236496
|
}
|
|
236491
236497
|
return [...families.values()].map((family2) => ({
|
|
236492
236498
|
...family2,
|
|
@@ -236498,10 +236504,15 @@ function variantFamilyLine(family2) {
|
|
|
236498
236504
|
const a = family2.attempts;
|
|
236499
236505
|
return `${family2.parentId}: ${family2.variantsMet} of ${family2.variants} variants passed \xB7 ${a.passed}/${a.requested} attempts (${family2.passRate === null ? "\u2014" : `${(family2.passRate * 100).toFixed(1)}%`}) \xB7 ${a.failed} failed \xB7 ${a.invalid} invalid \xB7 ${a.ungraded} ungraded \xB7 ${a.notRun} not run`;
|
|
236500
236506
|
}
|
|
236507
|
+
function variantRowCount(row2) {
|
|
236508
|
+
const notRun = row2.notRun ?? 0;
|
|
236509
|
+
if (row2.requested > 0 && notRun === row2.requested) return "not run";
|
|
236510
|
+
return `${row2.passed}/${row2.requested}${notRun > 0 && notRun < row2.requested ? ` \xB7 ${notRun} not run` : ""}`;
|
|
236511
|
+
}
|
|
236501
236512
|
function variantFamilyLines(families) {
|
|
236502
236513
|
return families.flatMap((family2) => ["", variantFamilyLine(family2), ...family2.rows.map((row2) => {
|
|
236503
236514
|
const change4 = row2.change.replace(/\s+/g, " ");
|
|
236504
|
-
return ` ${change4.length > 96 ? `${change4.slice(0, 95)}\u2026` : change4} ${row2
|
|
236515
|
+
return ` ${change4.length > 96 ? `${change4.slice(0, 95)}\u2026` : change4} ${variantRowCount(row2)}`;
|
|
236505
236516
|
})]);
|
|
236506
236517
|
}
|
|
236507
236518
|
function selectVariantParent(summary, parent3) {
|
|
@@ -236672,8 +236683,44 @@ function neverRanChecksLine(n2, runId2, out) {
|
|
|
236672
236683
|
if (n2.checksFailed === 0) return void 0;
|
|
236673
236684
|
return `${n2.checksFailed} ${n2.checksFailed === 1 ? "check" : "checks"} failed because the agent never ran; ancha explain ${runId2}${out === void 0 ? "" : ` --out ${shellWord(out)}`} --all shows them`;
|
|
236674
236685
|
}
|
|
236686
|
+
function rerunTestWords(summary, tests, readDirectory, quote6 = shellWord) {
|
|
236687
|
+
if (!readDirectory) return tests.map(quote6);
|
|
236688
|
+
const replacements = /* @__PURE__ */ new Map(), omitted = /* @__PURE__ */ new Set();
|
|
236689
|
+
const parents = new Set((summary.scenes ?? []).flatMap((scene2) => scene2.variant ? [scene2.variant.parentId] : []));
|
|
236690
|
+
for (const parent3 of parents) {
|
|
236691
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(parent3)) continue;
|
|
236692
|
+
const matches11 = (name5) => name5.startsWith(`${parent3}-v-`) && name5.endsWith(".yaml");
|
|
236693
|
+
const groups = /* @__PURE__ */ new Map();
|
|
236694
|
+
for (const path9 of tests) {
|
|
236695
|
+
if (replacements.has(path9) || omitted.has(path9) || !matches11(basename5(path9)) || /[*?\[\]{}()!\\]/.test(path9)) continue;
|
|
236696
|
+
const ids3 = summary.provenance?.tests.filter((test3) => test3.path === path9).map((test3) => test3.caseId);
|
|
236697
|
+
const variant = (summary.scenes ?? []).some((scene2) => scene2.variant?.parentId === parent3 && (ids3 ? ids3.includes(scene2.sceneId) : `${scene2.scenarioId ?? scene2.sceneId}.yaml` === basename5(path9)));
|
|
236698
|
+
if (!variant) continue;
|
|
236699
|
+
const directory = dirname7(path9), group5 = groups.get(directory) ?? [];
|
|
236700
|
+
group5.push(path9);
|
|
236701
|
+
groups.set(directory, group5);
|
|
236702
|
+
}
|
|
236703
|
+
for (const [directory, paths3] of groups) {
|
|
236704
|
+
let entries4;
|
|
236705
|
+
try {
|
|
236706
|
+
entries4 = readDirectory(directory);
|
|
236707
|
+
} catch {
|
|
236708
|
+
continue;
|
|
236709
|
+
}
|
|
236710
|
+
if (!entries4) continue;
|
|
236711
|
+
if (tests.some((path9) => dirname7(path9) === directory && !entries4.includes(basename5(path9)))) continue;
|
|
236712
|
+
const selected3 = new Set(paths3.map((path9) => basename5(path9))), present3 = new Set(entries4.filter(matches11));
|
|
236713
|
+
if (selected3.size !== present3.size || [...selected3].some((name5) => !present3.has(name5))) continue;
|
|
236714
|
+
const first2 = paths3[0];
|
|
236715
|
+
replacements.set(first2, `${directory === "." ? "" : quote6(`${directory}/`)}${parent3}-v-*.yaml`);
|
|
236716
|
+
for (const path9 of paths3) if (path9 !== first2) omitted.add(path9);
|
|
236717
|
+
}
|
|
236718
|
+
}
|
|
236719
|
+
return tests.filter((path9) => !omitted.has(path9)).map((path9) => replacements.get(path9) ?? quote6(path9));
|
|
236720
|
+
}
|
|
236675
236721
|
function retryCommands(s3, opts = {}) {
|
|
236676
|
-
const
|
|
236722
|
+
const words9 = rerunTestWords(s3, opts.tests ?? s3.testPaths ?? [], opts.readDirectory);
|
|
236723
|
+
const tests = words9.length ? ` ${words9.join(" ")}` : "";
|
|
236677
236724
|
if (s3.target === "cloud") return ["ancha agent upload", `ancha run --on cloud${tests}`];
|
|
236678
236725
|
const on = s3.target === "docker" ? " --on docker" : s3.target === "local" ? " --on local" : "";
|
|
236679
236726
|
return [`ancha run${on}${tests}${opts.out === void 0 ? "" : ` --out ${shellWord(opts.out)}`}`];
|
|
@@ -239135,7 +239182,7 @@ var init_run_bundle = __esm({
|
|
|
239135
239182
|
// backend/src/kit/assets.ts
|
|
239136
239183
|
import { constants as constants10 } from "node:fs";
|
|
239137
239184
|
import { lstat as lstat5, mkdir as mkdir14, open as open9, readFile as readFile15, realpath as realpath6, rm as rm4 } from "node:fs/promises";
|
|
239138
|
-
import { dirname as dirname12, isAbsolute as
|
|
239185
|
+
import { dirname as dirname12, isAbsolute as isAbsolute9, join as join31, relative as relative12, resolve as resolve23, sep as sep7 } from "node:path";
|
|
239139
239186
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
239140
239187
|
function assetRoot() {
|
|
239141
239188
|
return new URL("./assets/", import.meta.url);
|
|
@@ -239144,7 +239191,7 @@ function invalid37(message8) {
|
|
|
239144
239191
|
return new AnchaError("CONFIG_INVALID", message8, { hint: "use a complete packaged template; remove unsafe symlinks or choose another project directory", docs: "ancha docs setup" });
|
|
239145
239192
|
}
|
|
239146
239193
|
function safePath3(path9) {
|
|
239147
|
-
if (!path9 ||
|
|
239194
|
+
if (!path9 || isAbsolute9(path9) || path9.includes("\\") || path9.split("/").some((part) => part === ".." || part === "." || part === "") || path9.includes("\0")) throw invalid37(`unsafe scaffold path: ${path9}`);
|
|
239148
239195
|
}
|
|
239149
239196
|
async function preflightFiles(cwd, files2) {
|
|
239150
239197
|
const root3 = await realpath6(cwd);
|
|
@@ -239153,14 +239200,14 @@ async function preflightFiles(cwd, files2) {
|
|
|
239153
239200
|
safePath3(file3.relativePath);
|
|
239154
239201
|
if (seen.has(file3.relativePath)) throw invalid37(`duplicate scaffold target: ${file3.relativePath}`);
|
|
239155
239202
|
seen.add(file3.relativePath);
|
|
239156
|
-
const target6 =
|
|
239157
|
-
if (
|
|
239203
|
+
const target6 = resolve23(root3, file3.relativePath);
|
|
239204
|
+
if (relative12(root3, target6).startsWith(`..${sep7}`)) throw invalid37(`path escapes project: ${file3.relativePath}`);
|
|
239158
239205
|
const parts3 = file3.relativePath.split("/");
|
|
239159
239206
|
for (let i = 1; i <= parts3.length; i++) {
|
|
239160
239207
|
const part = join31(root3, ...parts3.slice(0, i));
|
|
239161
239208
|
try {
|
|
239162
239209
|
const stat22 = await lstat5(part);
|
|
239163
|
-
if (stat22.isSymbolicLink() || (i < parts3.length ? !stat22.isDirectory() : !stat22.isFile())) throw invalid37(`unsafe scaffold target: ${
|
|
239210
|
+
if (stat22.isSymbolicLink() || (i < parts3.length ? !stat22.isDirectory() : !stat22.isFile())) throw invalid37(`unsafe scaffold target: ${relative12(root3, part)}`);
|
|
239164
239211
|
} catch (error65) {
|
|
239165
239212
|
if (error65.code !== "ENOENT") throw error65;
|
|
239166
239213
|
}
|
|
@@ -239598,7 +239645,7 @@ async function cleanupHarborBatch(workspaceDir, batchId) {
|
|
|
239598
239645
|
} catch {
|
|
239599
239646
|
}
|
|
239600
239647
|
const until = Date.now() + 45e3;
|
|
239601
|
-
while (Date.now() < until && await same4()) await new Promise((
|
|
239648
|
+
while (Date.now() < until && await same4()) await new Promise((resolve63) => setTimeout(resolve63, 200));
|
|
239602
239649
|
if (await same4()) throw new AnchaError("INTERNAL", "The previous execution controller is still stopping. Try again shortly.");
|
|
239603
239650
|
}
|
|
239604
239651
|
const privateDir = dirname14(marker.inputFile);
|
|
@@ -239767,9 +239814,9 @@ network_mode = "public"
|
|
|
239767
239814
|
if (peopleController?.signal.aborted) return await peopleSetupFailed();
|
|
239768
239815
|
const child3 = spawn4(paths3.python, [driver, inputFile], { cwd: privateDir, env: { PATH: controlledEnv().PATH ?? "/usr/bin:/bin", HOME: join36(privateDir, "home"), PYTHONPATH: dirname14(driver), HARBOR_TELEMETRY: "0", DOCKER_CONFIG: paths3.dockerConfig, DOCKER_HOST: endpoint2 }, stdio: ["ignore", "pipe", "pipe", "pipe"] });
|
|
239769
239816
|
ownedChild = child3;
|
|
239770
|
-
const completion = new Promise((
|
|
239817
|
+
const completion = new Promise((resolve63, reject4) => {
|
|
239771
239818
|
child3.once("error", reject4);
|
|
239772
|
-
child3.once("close",
|
|
239819
|
+
child3.once("close", resolve63);
|
|
239773
239820
|
});
|
|
239774
239821
|
ownedCompletion = completion;
|
|
239775
239822
|
void completion.catch(() => {
|
|
@@ -240339,7 +240386,7 @@ function lineage2(sql6) {
|
|
|
240339
240386
|
if (alias === void 0) continue;
|
|
240340
240387
|
columns.push({ key: item2.key ?? (item2.display ? void 0 : item2.column), alias, column: item2.column, ...item2.display && { display: true }, ...item2.format && { format: item2.format }, ...item2.abs && { abs: true } });
|
|
240341
240388
|
}
|
|
240342
|
-
const
|
|
240389
|
+
const resolve63 = ([alias, column3]) => {
|
|
240343
240390
|
const placed2 = place2(alias, column3);
|
|
240344
240391
|
return placed2 === void 0 ? void 0 : [placed2, column3];
|
|
240345
240392
|
};
|
|
@@ -240347,8 +240394,8 @@ function lineage2(sql6) {
|
|
|
240347
240394
|
tables,
|
|
240348
240395
|
columns: columns.filter((c) => c.key !== void 0),
|
|
240349
240396
|
stars,
|
|
240350
|
-
constants: into.constants.map(([ref23, value6]) => [
|
|
240351
|
-
equal: into.equal.map((pair) => pair.map(
|
|
240397
|
+
constants: into.constants.map(([ref23, value6]) => [resolve63(ref23), value6]).filter(([ref23]) => ref23),
|
|
240398
|
+
equal: into.equal.map((pair) => pair.map(resolve63)).filter(([a, b]) => a && b),
|
|
240352
240399
|
grouped: top.some(([v]) => v === "group")
|
|
240353
240400
|
};
|
|
240354
240401
|
}
|
|
@@ -242696,9 +242743,9 @@ function productionState(check4, scene2, trace2, refs = {}) {
|
|
|
242696
242743
|
}
|
|
242697
242744
|
function slackState(check4, trace2, refs, complete = false) {
|
|
242698
242745
|
const args = check4["slack.message"];
|
|
242699
|
-
const
|
|
242700
|
-
const channel3 =
|
|
242701
|
-
const parent3 = args.in_thread_of === void 0 ? void 0 :
|
|
242746
|
+
const resolve63 = (ref23) => refs[refName7(ref23)];
|
|
242747
|
+
const channel3 = resolve63(args.channel), author = args.from === void 0 ? void 0 : resolve63(args.from);
|
|
242748
|
+
const parent3 = args.in_thread_of === void 0 ? void 0 : resolve63(args.in_thread_of);
|
|
242702
242749
|
if (typeof channel3 !== "string" || args.from !== void 0 && typeof author !== "string" || args.in_thread_of !== void 0 && (typeof parent3 !== "object" || parent3.channel !== channel3)) return "unknown";
|
|
242703
242750
|
const messages7 = /* @__PURE__ */ new Map();
|
|
242704
242751
|
const add = (m) => {
|
|
@@ -242766,20 +242813,20 @@ function startingState(check4, scene2) {
|
|
|
242766
242813
|
if ("slack.message" in check4 && seed44.slack) {
|
|
242767
242814
|
const slack2 = seed44.slack, args = check4["slack.message"];
|
|
242768
242815
|
for (const row2 of [...slack2.users ?? [], ...slack2.channels ?? []]) refs[row2.ref] = row2.id ?? row2.ref;
|
|
242769
|
-
const
|
|
242816
|
+
const resolve63 = (value6) => refs[refName7(value6)];
|
|
242770
242817
|
const messages7 = slack2.messages ?? [];
|
|
242771
|
-
for (const [i, m] of messages7.entries()) refs[m.ref] = { channel:
|
|
242818
|
+
for (const [i, m] of messages7.entries()) refs[m.ref] = { channel: resolve63(m.channel), ts: m.ts ?? String(i + 1) };
|
|
242772
242819
|
for (const actor3 of scene2.world_rules?.actors ?? []) {
|
|
242773
242820
|
const m = actor3["slack.post"];
|
|
242774
|
-
if (m?.ref && !refs[m.ref]) refs[m.ref] = { channel:
|
|
242821
|
+
if (m?.ref && !refs[m.ref]) refs[m.ref] = { channel: resolve63(m.channel), ts: `actor:${m.ref}` };
|
|
242775
242822
|
}
|
|
242776
|
-
const channel3 =
|
|
242823
|
+
const channel3 = resolve63(args.channel), parent3 = args.in_thread_of && resolve63(args.in_thread_of);
|
|
242777
242824
|
const observed = messages7.map((m) => ({
|
|
242778
|
-
channel:
|
|
242825
|
+
channel: resolve63(m.channel),
|
|
242779
242826
|
ts: refs[m.ref].ts,
|
|
242780
|
-
user:
|
|
242827
|
+
user: resolve63(m.user),
|
|
242781
242828
|
text: m.text,
|
|
242782
|
-
...m.thread_of && { thread_ts:
|
|
242829
|
+
...m.thread_of && { thread_ts: resolve63(m.thread_of)?.ts }
|
|
242783
242830
|
})).filter((m) => m.channel === channel3);
|
|
242784
242831
|
return slackState(check4, [read7(
|
|
242785
242832
|
"slack",
|
|
@@ -243030,13 +243077,13 @@ var init_production = __esm({
|
|
|
243030
243077
|
|
|
243031
243078
|
// backend/src/production-comparison.ts
|
|
243032
243079
|
import { readFile as readFile23 } from "node:fs/promises";
|
|
243033
|
-
import { dirname as dirname16, join as join40, resolve as
|
|
243080
|
+
import { dirname as dirname16, join as join40, resolve as resolve28 } from "node:path";
|
|
243034
243081
|
async function reproductionOf(summary, scenePaths, cwd, runDir, scenes = [], productionFiles = {}) {
|
|
243035
243082
|
const out = [];
|
|
243036
243083
|
for (const scene2 of summary.scenes) {
|
|
243037
243084
|
const path9 = scenePaths[scene2.sceneId];
|
|
243038
243085
|
if (path9 === void 0) continue;
|
|
243039
|
-
const file3 = Object.hasOwn(productionFiles, scene2.sceneId) ? productionFiles[scene2.sceneId] : join40(dirname16(
|
|
243086
|
+
const file3 = Object.hasOwn(productionFiles, scene2.sceneId) ? productionFiles[scene2.sceneId] : join40(dirname16(resolve28(cwd, path9)), "production.json");
|
|
243040
243087
|
const production3 = await readFile23(file3, "utf8").then((text31) => JSON.parse(text31), () => void 0);
|
|
243041
243088
|
if (production3?.checks === void 0) continue;
|
|
243042
243089
|
const checks2 = Object.entries(production3.checks).flatMap(([check4, result]) => {
|
|
@@ -243054,7 +243101,7 @@ async function reproductionOf(summary, scenePaths, cwd, runDir, scenes = [], pro
|
|
|
243054
243101
|
const added = Object.keys(scene2.checks).filter((check4) => !(check4 in production3.checks));
|
|
243055
243102
|
const counts2 = runDir === void 0 ? {} : await answerSources(runDir, scene2);
|
|
243056
243103
|
const defined = scenes.find((s3) => s3.id === scene2.sceneId);
|
|
243057
|
-
const writes3 = defined === void 0 || runDir === void 0 || !writeTools(defined).size ? void 0 : await writesOf(defined, dirname16(
|
|
243104
|
+
const writes3 = defined === void 0 || runDir === void 0 || !writeTools(defined).size ? void 0 : await writesOf(defined, dirname16(resolve28(cwd, path9)), runDir, scene2);
|
|
243058
243105
|
const required6 = new Set(Object.keys(scene2.checks).filter((check4) => scene2.checks[check4].required));
|
|
243059
243106
|
for (const [check4, result] of Object.entries(production3.checks)) if (result === "failed" && scene2.checks[check4] === void 0) required6.add(check4);
|
|
243060
243107
|
const repairEvidence = scene2.counts === void 0 ? void 0 : {
|
|
@@ -243125,7 +243172,7 @@ var init_production_comparison = __esm({
|
|
|
243125
243172
|
// backend/src/baselines.ts
|
|
243126
243173
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
243127
243174
|
import { link as link7, mkdir as mkdir18, readFile as readFile24, rename as rename6, unlink, writeFile as writeFile17 } from "node:fs/promises";
|
|
243128
|
-
import { dirname as dirname17, join as join41, resolve as
|
|
243175
|
+
import { dirname as dirname17, join as join41, resolve as resolve30 } from "node:path";
|
|
243129
243176
|
function validateTrialCounts(scene2) {
|
|
243130
243177
|
if (!Number.isSafeInteger(scene2.passed) || !Number.isSafeInteger(scene2.trials) || scene2.trials <= 0 || scene2.passed < 0 || scene2.passed > scene2.trials) {
|
|
243131
243178
|
throw new AnchaError("USAGE", `invalid passed/trial counts for test ${scene2.sceneId}`);
|
|
@@ -243268,7 +243315,7 @@ var init_baselines = __esm({
|
|
|
243268
243315
|
init_actions8();
|
|
243269
243316
|
init_scenes();
|
|
243270
243317
|
BASELINE_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
243271
|
-
baselineDir = (cwd, out) => join41(dirname17(
|
|
243318
|
+
baselineDir = (cwd, out) => join41(dirname17(resolve30(cwd, out ?? DEFAULT_RUNS_DIR)), "baselines");
|
|
243272
243319
|
}
|
|
243273
243320
|
});
|
|
243274
243321
|
|
|
@@ -243279,7 +243326,7 @@ __export(dependency_plan_exports, {
|
|
|
243279
243326
|
});
|
|
243280
243327
|
import { constants as constants11 } from "node:fs";
|
|
243281
243328
|
import { open as open10 } from "node:fs/promises";
|
|
243282
|
-
import { join as join43, resolve as
|
|
243329
|
+
import { join as join43, resolve as resolve33 } from "node:path";
|
|
243283
243330
|
async function manifest(root3, name5) {
|
|
243284
243331
|
let file3;
|
|
243285
243332
|
try {
|
|
@@ -243295,7 +243342,7 @@ async function manifest(root3, name5) {
|
|
|
243295
243342
|
}
|
|
243296
243343
|
}
|
|
243297
243344
|
async function dependencyPlan(root3, options5 = {}) {
|
|
243298
|
-
const pathPrepend = [join43(
|
|
243345
|
+
const pathPrepend = [join43(resolve33(root3), ".venv/bin"), join43(resolve33(root3), "node_modules/.bin")];
|
|
243299
243346
|
if (options5.install !== void 0) {
|
|
243300
243347
|
if (typeof options5.install !== "string" || !options5.install.trim() || options5.install.length > 2e3 || /[\0\r\n]/.test(options5.install)) {
|
|
243301
243348
|
throw new AnchaError("CONFIG_INVALID", "agent.install must be a non-empty single-line command of at most 2000 characters.");
|
|
@@ -243445,15 +243492,15 @@ function executable(command) {
|
|
|
243445
243492
|
async function freePort() {
|
|
243446
243493
|
const server = createServer5();
|
|
243447
243494
|
try {
|
|
243448
|
-
await new Promise((
|
|
243495
|
+
await new Promise((resolve63, reject4) => {
|
|
243449
243496
|
server.once("error", reject4);
|
|
243450
|
-
server.listen(0, "127.0.0.1",
|
|
243497
|
+
server.listen(0, "127.0.0.1", resolve63);
|
|
243451
243498
|
});
|
|
243452
243499
|
const address9 = server.address();
|
|
243453
243500
|
if (!address9 || typeof address9 === "string") throw new Error("No local port");
|
|
243454
243501
|
return address9.port;
|
|
243455
243502
|
} finally {
|
|
243456
|
-
if (server.listening) await new Promise((
|
|
243503
|
+
if (server.listening) await new Promise((resolve63) => server.close(() => resolve63()));
|
|
243457
243504
|
}
|
|
243458
243505
|
}
|
|
243459
243506
|
function taskFixFromLog(lines2, agent) {
|
|
@@ -243769,7 +243816,7 @@ __export(assemble_exports, {
|
|
|
243769
243816
|
import { createHash as createHash72 } from "node:crypto";
|
|
243770
243817
|
import { copyFile as copyFile4, lstat as lstat9, mkdir as mkdir21, mkdtemp as mkdtemp7, readdir as readdir8, readFile as readFile26, rm as rm9, writeFile as writeFile19 } from "node:fs/promises";
|
|
243771
243818
|
import { tmpdir as tmpdir6 } from "node:os";
|
|
243772
|
-
import { dirname as dirname18, join as join45, resolve as
|
|
243819
|
+
import { dirname as dirname18, join as join45, resolve as resolve34, sep as sep9 } from "node:path";
|
|
243773
243820
|
function finalizeInput(value6) {
|
|
243774
243821
|
const wrong = (what) => {
|
|
243775
243822
|
throw new AnchaError("INTERNAL", `the finalize input ${what}`);
|
|
@@ -243861,8 +243908,8 @@ async function checkFolders(artifactsDir, input5) {
|
|
|
243861
243908
|
if (missing10) throw new AnchaError("INTERNAL", `the evidence of attempt ${missing10.id} is not in the artifacts folder`);
|
|
243862
243909
|
}
|
|
243863
243910
|
function inside2(root3, path9, what) {
|
|
243864
|
-
const full2 =
|
|
243865
|
-
if (!full2.startsWith(`${
|
|
243911
|
+
const full2 = resolve34(root3, path9);
|
|
243912
|
+
if (!full2.startsWith(`${resolve34(root3)}${sep9}`)) throw new AnchaError("INTERNAL", `${what} ${JSON.stringify(path9)} is not inside the project`);
|
|
243866
243913
|
return full2;
|
|
243867
243914
|
}
|
|
243868
243915
|
async function bundleManifest(bundleDir) {
|
|
@@ -243989,7 +244036,7 @@ async function productionComparison(summary, cases, projectDir, runDir, judge) {
|
|
|
243989
244036
|
try {
|
|
243990
244037
|
const files2 = {}, errors3 = /* @__PURE__ */ new Map();
|
|
243991
244038
|
for (const [index, item2] of cases.entries()) {
|
|
243992
|
-
const scenePath =
|
|
244039
|
+
const scenePath = resolve34(projectDir, item2.path), file3 = join45(copies, `${index}.json`);
|
|
243993
244040
|
files2[item2.caseId] = file3;
|
|
243994
244041
|
await copyFile4(join45(dirname18(scenePath), "production.json"), file3).catch((error65) => {
|
|
243995
244042
|
if (error65.code !== "ENOENT") throw error65;
|
|
@@ -248820,7 +248867,7 @@ var init_person = __esm({
|
|
|
248820
248867
|
norm2 = (text31) => String(text31 ?? "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
248821
248868
|
exactLike = (fact2) => fact2.exact === true || fact2.match === "exact" || /[\d$€£¥]/.test(String(fact2.value ?? ""));
|
|
248822
248869
|
tokens6 = (text31) => ` ${String(text31 ?? "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim()} `;
|
|
248823
|
-
slug15 = (text31,
|
|
248870
|
+
slug15 = (text31, sep10) => String(text31 ?? "").toLowerCase().replace(/[^a-z0-9]+/g, sep10).replace(new RegExp(`^\\${sep10}+|\\${sep10}+$`, "g"), "");
|
|
248824
248871
|
}
|
|
248825
248872
|
});
|
|
248826
248873
|
|
|
@@ -250050,7 +250097,7 @@ init_credentials();
|
|
|
250050
250097
|
import { execFile as execFile4 } from "node:child_process";
|
|
250051
250098
|
import { mkdtemp as mkdtemp4, readFile as readFile13, rm as rm3, stat as stat7, writeFile as writeFile12 } from "node:fs/promises";
|
|
250052
250099
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
250053
|
-
import { basename as basename8, join as join29, resolve as
|
|
250100
|
+
import { basename as basename8, join as join29, resolve as resolve22 } from "node:path";
|
|
250054
250101
|
import { promisify as promisify4 } from "node:util";
|
|
250055
250102
|
|
|
250056
250103
|
// backend/src/cloud/dependencies.ts
|
|
@@ -250830,8 +250877,8 @@ function getCrawler(globInput, inputOptions2 = {}) {
|
|
|
250830
250877
|
return patterns.length > 0 ? buildCrawler(options5, patterns) : [];
|
|
250831
250878
|
}
|
|
250832
250879
|
async function glob3(globInput, options5) {
|
|
250833
|
-
const [crawler,
|
|
250834
|
-
return crawler ? formatPaths(await crawler.withPromise(),
|
|
250880
|
+
const [crawler, relative31] = getCrawler(globInput, options5);
|
|
250881
|
+
return crawler ? formatPaths(await crawler.withPromise(), relative31) : [];
|
|
250835
250882
|
}
|
|
250836
250883
|
|
|
250837
250884
|
// backend/src/cloud/dependencies.ts
|
|
@@ -251210,7 +251257,8 @@ init_run_metadata();
|
|
|
251210
251257
|
init_src();
|
|
251211
251258
|
init_credentials();
|
|
251212
251259
|
import { access as access8, mkdir as mkdir13, mkdtemp as mkdtemp3, rename as rename3, rm as rm2, writeFile as writeFile11 } from "node:fs/promises";
|
|
251213
|
-
import {
|
|
251260
|
+
import { readFileSync as readFileSync4, readdirSync as readdirSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
251261
|
+
import { dirname as dirname11, isAbsolute as isAbsolute8, join as join28, relative as relative11, resolve as resolve21, sep as sep6 } from "node:path";
|
|
251214
251262
|
import { setTimeout as sleep10 } from "node:timers/promises";
|
|
251215
251263
|
|
|
251216
251264
|
// backend/src/cloud/bundle.ts
|
|
@@ -251797,7 +251845,29 @@ var capsText = (caps2) => [
|
|
|
251797
251845
|
function cloudNeverRan(detail3) {
|
|
251798
251846
|
return detail3.job.kind === "run" && detail3.summary !== null ? agentNeverRan(detail3.summary) : void 0;
|
|
251799
251847
|
}
|
|
251800
|
-
var cloudRetry = (summary) => retryCommands({ target: "cloud" }, { tests: [...new Set((summary?.provenance?.tests ?? []).map((test3) => test3.path))] });
|
|
251848
|
+
var cloudRetry = (summary, readDirectory) => retryCommands({ ...summary, target: "cloud" }, { tests: [...new Set((summary?.provenance?.tests ?? []).map((test3) => test3.path))], readDirectory });
|
|
251849
|
+
function projectTestDirectoryReader(cwd, cloud) {
|
|
251850
|
+
try {
|
|
251851
|
+
const root3 = realpathSync2(cwd);
|
|
251852
|
+
if (cloud) {
|
|
251853
|
+
const receipt2 = JSON.parse(readFileSync4(join28(root3, ".ancha/runs/latest-cloud"), "utf8"));
|
|
251854
|
+
if (receipt2.runId !== cloud.runId || receipt2.server?.replace(/\/$/, "") !== cloud.server.replace(/\/$/, "")) return void 0;
|
|
251855
|
+
}
|
|
251856
|
+
return (directory) => {
|
|
251857
|
+
try {
|
|
251858
|
+
const path9 = realpathSync2(resolve21(root3, directory)), rel = relative11(root3, path9);
|
|
251859
|
+
if (isAbsolute8(rel) || rel === ".." || rel.startsWith(`..${sep6}`)) return void 0;
|
|
251860
|
+
const entries4 = readdirSync2(path9, { withFileTypes: true });
|
|
251861
|
+
if (entries4.some((entry3) => entry3.name.endsWith(".yaml") && !entry3.isFile())) return void 0;
|
|
251862
|
+
return entries4.filter((entry3) => entry3.isFile()).map((entry3) => entry3.name);
|
|
251863
|
+
} catch {
|
|
251864
|
+
return void 0;
|
|
251865
|
+
}
|
|
251866
|
+
};
|
|
251867
|
+
} catch {
|
|
251868
|
+
return void 0;
|
|
251869
|
+
}
|
|
251870
|
+
}
|
|
251801
251871
|
function finishedText(ws, detail3, includeNext = true) {
|
|
251802
251872
|
const { job, summary } = detail3;
|
|
251803
251873
|
const counts2 = summary?.counts ?? job.counts;
|
|
@@ -251968,7 +252038,7 @@ async function forward(ctx, serverUrl3, words9, raw3) {
|
|
|
251968
252038
|
argv.push(arg);
|
|
251969
252039
|
continue;
|
|
251970
252040
|
}
|
|
251971
|
-
const path9 =
|
|
252041
|
+
const path9 = resolve22(ctx.io.cwd, value6), name5 = basename8(path9).replace(/[^A-Za-z0-9._-]/g, "-").replace(/^[^A-Za-z0-9]+/, "").slice(0, 100) || "file";
|
|
251972
252042
|
const content2 = await readFile13(path9).catch(() => void 0);
|
|
251973
252043
|
if (content2 === void 0) {
|
|
251974
252044
|
if (flag5 === "--test") {
|
|
@@ -251986,9 +252056,9 @@ async function forward(ctx, serverUrl3, words9, raw3) {
|
|
|
251986
252056
|
argv.push(arg);
|
|
251987
252057
|
continue;
|
|
251988
252058
|
}
|
|
251989
|
-
const name5 = slug12(optionValue(args, "--name") ?? (words9[1] === "update" ? args[0] : basename8(
|
|
252059
|
+
const name5 = slug12(optionValue(args, "--name") ?? (words9[1] === "update" ? args[0] : basename8(resolve22(ctx.io.cwd, value6))));
|
|
251990
252060
|
await refuseWhileConnecting(server, key5, words9[1] === "update" ? args[0] : void 0, optionValue(args, "--name"));
|
|
251991
|
-
const uploaded = await uploadProject(server, key5, name5,
|
|
252061
|
+
const uploaded = await uploadProject(server, key5, name5, resolve22(ctx.io.cwd, value6));
|
|
251992
252062
|
argv.push("--cwd", uploaded.project_path);
|
|
251993
252063
|
} else argv.push(arg);
|
|
251994
252064
|
}
|
|
@@ -252097,7 +252167,7 @@ function withWorkspace(line2, workspace4) {
|
|
|
252097
252167
|
}
|
|
252098
252168
|
}
|
|
252099
252169
|
async function packProject(dir2) {
|
|
252100
|
-
const root3 =
|
|
252170
|
+
const root3 = resolve22(dir2);
|
|
252101
252171
|
if (!(await stat7(root3).catch(() => void 0))?.isDirectory()) throw new AnchaError("USAGE", `${dir2} is not a folder`, { hint: "pass the agent project folder to --cwd" });
|
|
252102
252172
|
const files2 = await projectFiles(root3);
|
|
252103
252173
|
if (files2.length === 0) throw new AnchaError("USAGE", `${dir2} has no files to upload`, { hint: "check .gitignore and .anchaignore" });
|
|
@@ -252212,7 +252282,7 @@ function registerEnv(program2, ctx) {
|
|
|
252212
252282
|
init_src();
|
|
252213
252283
|
init_src();
|
|
252214
252284
|
import { readFile as readFile34, writeFile as writeFile23 } from "node:fs/promises";
|
|
252215
|
-
import { join as join50, relative as
|
|
252285
|
+
import { join as join50, relative as relative19, resolve as resolve39 } from "node:path";
|
|
252216
252286
|
|
|
252217
252287
|
// packages/cli/src/numbers.ts
|
|
252218
252288
|
init_src();
|
|
@@ -252778,7 +252848,7 @@ function familySection(d) {
|
|
|
252778
252848
|
if (!d.families?.length) return "";
|
|
252779
252849
|
return `<section id="families" aria-labelledby="families-h"><h2 id="families-h">Variant families</h2>${d.families.map((family2) => `<p class="sub" data-q>${esc2(variantFamilyLine(family2))}</p><div class="scroll"><table class="fams"><thead><tr><th scope="col">Variant</th><th scope="col" class="num">Passed</th></tr></thead><tbody>${family2.rows.map((row2) => {
|
|
252780
252850
|
const test3 = d.tests.find((test4) => test4.id === row2.sceneId);
|
|
252781
|
-
return `<tr><td>${test3 ? `<a href="#${test3.anchor}">${q(row2.change)}</a>` : q(row2.change)}</td><td class="num" data-q>${row2
|
|
252851
|
+
return `<tr><td>${test3 ? `<a href="#${test3.anchor}">${q(row2.change)}</a>` : q(row2.change)}</td><td class="num" data-q>${esc2(variantRowCount(row2))}</td></tr>`;
|
|
252782
252852
|
}).join("")}</tbody></table></div>`).join("")}</section>`;
|
|
252783
252853
|
}
|
|
252784
252854
|
function renderHtmlReport(input5) {
|
|
@@ -253079,7 +253149,7 @@ async function consoleApi(base6) {
|
|
|
253079
253149
|
var import_yaml8 = __toESM(require_dist(), 1);
|
|
253080
253150
|
init_src();
|
|
253081
253151
|
import { readFile as readFile30, stat as stat11 } from "node:fs/promises";
|
|
253082
|
-
import { resolve as
|
|
253152
|
+
import { resolve as resolve37 } from "node:path";
|
|
253083
253153
|
|
|
253084
253154
|
// backend/src/playgrounds/service.ts
|
|
253085
253155
|
import { randomUUID as randomUUID13, createHash as createHash69 } from "node:crypto";
|
|
@@ -253206,11 +253276,11 @@ var AdmissionStore = class {
|
|
|
253206
253276
|
this.workspace = workspace4;
|
|
253207
253277
|
}
|
|
253208
253278
|
async withDb(fn) {
|
|
253209
|
-
const
|
|
253210
|
-
await preflightFiles(this.workspace, [
|
|
253279
|
+
const relative31 = `${BASE3}/ownership.sqlite`;
|
|
253280
|
+
await preflightFiles(this.workspace, [relative31, `${relative31}-journal`, `${relative31}-wal`, `${relative31}-shm`].map((relativePath) => ({ relativePath, content: "" })));
|
|
253211
253281
|
await mkdir15(join32(this.workspace, BASE3), { recursive: true, mode: 448 });
|
|
253212
253282
|
await chmod4(join32(this.workspace, BASE3), 448);
|
|
253213
|
-
const db3 = new Database3(join32(this.workspace,
|
|
253283
|
+
const db3 = new Database3(join32(this.workspace, relative31));
|
|
253214
253284
|
try {
|
|
253215
253285
|
db3.pragma("busy_timeout = 5000");
|
|
253216
253286
|
db3.exec(`CREATE TABLE IF NOT EXISTS lease (singleton INTEGER PRIMARY KEY CHECK(singleton = 1), token TEXT NOT NULL, runId TEXT NOT NULL, pid INTEGER NOT NULL, birth TEXT NOT NULL);
|
|
@@ -253218,7 +253288,7 @@ var AdmissionStore = class {
|
|
|
253218
253288
|
CREATE TABLE IF NOT EXISTS submissions (key TEXT PRIMARY KEY, signature TEXT NOT NULL, runId TEXT NOT NULL);
|
|
253219
253289
|
CREATE TABLE IF NOT EXISTS orphans (runId TEXT PRIMARY KEY);`);
|
|
253220
253290
|
ensureAdmissionSchema(db3);
|
|
253221
|
-
await chmod4(join32(this.workspace,
|
|
253291
|
+
await chmod4(join32(this.workspace, relative31), 384);
|
|
253222
253292
|
return fn(db3);
|
|
253223
253293
|
} finally {
|
|
253224
253294
|
db3.close();
|
|
@@ -253399,13 +253469,13 @@ import { createHash as createHash66, randomUUID as randomUUID9 } from "node:cryp
|
|
|
253399
253469
|
import { execFile as execFile6 } from "node:child_process";
|
|
253400
253470
|
import { promisify as promisify6 } from "node:util";
|
|
253401
253471
|
import { readFile as readFile18, readdir as readdir6, realpath as realpath9, rename as rename4, rm as rm5, stat as stat9, lstat as lstat7, writeFile as writeFile13 } from "node:fs/promises";
|
|
253402
|
-
import { join as join34, resolve as
|
|
253472
|
+
import { join as join34, resolve as resolve26 } from "node:path";
|
|
253403
253473
|
init_config();
|
|
253404
253474
|
init_assets();
|
|
253405
253475
|
|
|
253406
253476
|
// backend/src/console/catalog.ts
|
|
253407
253477
|
import { readFile as readFile16, realpath as realpath7, stat as stat8 } from "node:fs/promises";
|
|
253408
|
-
import { basename as basename9, join as join33, resolve as
|
|
253478
|
+
import { basename as basename9, join as join33, resolve as resolve24 } from "node:path";
|
|
253409
253479
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
253410
253480
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
253411
253481
|
init_src();
|
|
@@ -253525,7 +253595,7 @@ var ScenarioCatalog = class {
|
|
|
253525
253595
|
const path9 = `${item2.scene.id}/${kind2}.${ext}`;
|
|
253526
253596
|
try {
|
|
253527
253597
|
await safeRead(root3, path9);
|
|
253528
|
-
return
|
|
253598
|
+
return resolve24(root3, path9);
|
|
253529
253599
|
} catch (error65) {
|
|
253530
253600
|
if (error65.code !== "ENOENT") throw error65;
|
|
253531
253601
|
}
|
|
@@ -253541,7 +253611,7 @@ init_policy();
|
|
|
253541
253611
|
// backend/src/execution/provider.ts
|
|
253542
253612
|
init_src();
|
|
253543
253613
|
import { lstat as lstat6, readFile as readFile17, realpath as realpath8 } from "node:fs/promises";
|
|
253544
|
-
import { isAbsolute as
|
|
253614
|
+
import { isAbsolute as isAbsolute10, relative as relative13, resolve as resolve25 } from "node:path";
|
|
253545
253615
|
var providerDetails = {
|
|
253546
253616
|
openrouter: { key: "OPENROUTER_API_KEY", modelVariable: "OPENROUTER_MODEL", host: "openrouter.ai", baseVariable: "OPENROUTER_BASE_URL", baseUrl: "https://openrouter.ai/api/v1" },
|
|
253547
253617
|
openai: { key: "OPENAI_API_KEY", modelVariable: "OPENAI_MODEL", host: "api.openai.com", baseVariable: "OPENAI_BASE_URL", baseUrl: "https://api.openai.com/v1" },
|
|
@@ -253577,15 +253647,15 @@ async function readApprovedOpenRouterKey(workspace4) {
|
|
|
253577
253647
|
} catch {
|
|
253578
253648
|
return void 0;
|
|
253579
253649
|
}
|
|
253580
|
-
const directory =
|
|
253581
|
-
const path9 =
|
|
253582
|
-
if (
|
|
253650
|
+
const directory = resolve25(root3, ".ancha");
|
|
253651
|
+
const path9 = resolve25(root3, ".ancha/openrouter.env");
|
|
253652
|
+
if (isAbsolute10(relative13(root3, path9)) || relative13(root3, path9).startsWith("..")) return void 0;
|
|
253583
253653
|
try {
|
|
253584
253654
|
const dirStat = await lstat6(directory);
|
|
253585
253655
|
const fileStat = await lstat6(path9);
|
|
253586
253656
|
if (!dirStat.isDirectory() || dirStat.isSymbolicLink() || !fileStat.isFile() || fileStat.isSymbolicLink()) return void 0;
|
|
253587
253657
|
const actual = await realpath8(path9);
|
|
253588
|
-
if (actual !== path9 || actual !==
|
|
253658
|
+
if (actual !== path9 || actual !== resolve25(root3, ".ancha/openrouter.env")) return void 0;
|
|
253589
253659
|
if (fileStat.size > 16384) return void 0;
|
|
253590
253660
|
const contents2 = await readFile17(path9, "utf8");
|
|
253591
253661
|
const keys7 = contents2.split(/\r?\n/).flatMap((line2) => {
|
|
@@ -253701,7 +253771,7 @@ var AgentRegistry = class {
|
|
|
253701
253771
|
}
|
|
253702
253772
|
async add(input5, options5 = {}) {
|
|
253703
253773
|
const parsed5 = parseAgentRegistration(input5);
|
|
253704
|
-
const cwd = await realpath9(
|
|
253774
|
+
const cwd = await realpath9(resolve26(this.workspace, parsed5.cwd)).catch(() => {
|
|
253705
253775
|
throw new AnchaError("USAGE", "agent project folder does not exist");
|
|
253706
253776
|
});
|
|
253707
253777
|
if (!(await stat9(cwd)).isDirectory()) throw new AnchaError("USAGE", "agent project must be a folder");
|
|
@@ -253755,7 +253825,7 @@ var AgentRegistry = class {
|
|
|
253755
253825
|
if (changes.taskInput === null) delete merged.taskInput;
|
|
253756
253826
|
if (changes.provider === null) delete merged.provider;
|
|
253757
253827
|
const parsed5 = parseAgentRegistration(merged);
|
|
253758
|
-
const cwd = await realpath9(
|
|
253828
|
+
const cwd = await realpath9(resolve26(this.workspace, parsed5.cwd)).catch(() => {
|
|
253759
253829
|
throw new AnchaError("USAGE", "agent project folder does not exist");
|
|
253760
253830
|
});
|
|
253761
253831
|
const saved = { ...parsed5, cwd, id: old.id, createdAt: old.createdAt };
|
|
@@ -253982,10 +254052,10 @@ var PlaygroundStore = class {
|
|
|
253982
254052
|
this.#db.exec("CREATE TABLE IF NOT EXISTS legacy_worlds (agentId TEXT PRIMARY KEY, worldId TEXT NOT NULL, sourceFingerprint TEXT NOT NULL)");
|
|
253983
254053
|
await chmod5(join35(this.workspace, BASE4, "ownership.sqlite"), 384);
|
|
253984
254054
|
}
|
|
253985
|
-
async write(
|
|
254055
|
+
async write(relative31, value6) {
|
|
253986
254056
|
const content2 = JSON.stringify(value6) + "\n";
|
|
253987
254057
|
if (Buffer.byteLength(content2) > 25e6) throw new AnchaError("CONFIG_INVALID", "playground artifact exceeds the 25 MB storage limit");
|
|
253988
|
-
const target6 = `${BASE4}/${
|
|
254058
|
+
const target6 = `${BASE4}/${relative31}`, temporary = `${target6}.${randomUUID11()}.tmp`;
|
|
253989
254059
|
await preflightFiles(this.workspace, [{ relativePath: target6, content: "" }, { relativePath: temporary, content: "" }]);
|
|
253990
254060
|
await mkdir16(dirname13(join35(this.workspace, target6)), { recursive: true, mode: 448 });
|
|
253991
254061
|
await chmod5(dirname13(join35(this.workspace, target6)), 448);
|
|
@@ -253997,9 +254067,9 @@ var PlaygroundStore = class {
|
|
|
253997
254067
|
await rm6(join35(this.workspace, temporary), { force: true });
|
|
253998
254068
|
}
|
|
253999
254069
|
}
|
|
254000
|
-
async read(
|
|
254070
|
+
async read(relative31) {
|
|
254001
254071
|
try {
|
|
254002
|
-
return JSON.parse(await safeRead(this.workspace, `${BASE4}/${
|
|
254072
|
+
return JSON.parse(await safeRead(this.workspace, `${BASE4}/${relative31}`, 25e6));
|
|
254003
254073
|
} catch (error65) {
|
|
254004
254074
|
if (missing8(error65)) return null;
|
|
254005
254075
|
throw error65;
|
|
@@ -254813,12 +254883,12 @@ var PlaygroundService = class {
|
|
|
254813
254883
|
for (const wake2 of [...this.#waiters]) wake2();
|
|
254814
254884
|
}
|
|
254815
254885
|
waitForCapacity(signal, observedVersion) {
|
|
254816
|
-
return new Promise((
|
|
254886
|
+
return new Promise((resolve63) => {
|
|
254817
254887
|
const finish2 = () => {
|
|
254818
254888
|
clearTimeout(timer);
|
|
254819
254889
|
this.#waiters.delete(finish2);
|
|
254820
254890
|
signal.removeEventListener("abort", finish2);
|
|
254821
|
-
|
|
254891
|
+
resolve63();
|
|
254822
254892
|
};
|
|
254823
254893
|
const timer = setTimeout(finish2, 1e3);
|
|
254824
254894
|
this.#waiters.add(finish2);
|
|
@@ -255128,7 +255198,7 @@ init_routed_trial();
|
|
|
255128
255198
|
import { createHash as createHash73 } from "node:crypto";
|
|
255129
255199
|
import { appendFileSync } from "node:fs";
|
|
255130
255200
|
import { access as access11, mkdir as mkdir22, readFile as readFile29, writeFile as writeFile21 } from "node:fs/promises";
|
|
255131
|
-
import { dirname as dirname20, join as join47, relative as
|
|
255201
|
+
import { dirname as dirname20, join as join47, relative as relative15, resolve as resolve36 } from "node:path";
|
|
255132
255202
|
init_src();
|
|
255133
255203
|
init_run_state();
|
|
255134
255204
|
|
|
@@ -255148,7 +255218,7 @@ async function startDetached(request2) {
|
|
|
255148
255218
|
serialization: "advanced"
|
|
255149
255219
|
});
|
|
255150
255220
|
try {
|
|
255151
|
-
await new Promise((
|
|
255221
|
+
await new Promise((resolve63, reject4) => {
|
|
255152
255222
|
const timeout = setTimeout(() => done(new AnchaError("INTERNAL", "detached worker did not acknowledge startup within 10 seconds")), 1e4);
|
|
255153
255223
|
const onError = (error65) => done(error65);
|
|
255154
255224
|
const onExit = () => done(new AnchaError("INTERNAL", "detached worker exited before acknowledging startup"));
|
|
@@ -255163,7 +255233,7 @@ async function startDetached(request2) {
|
|
|
255163
255233
|
child3.off("exit", onExit);
|
|
255164
255234
|
child3.off("message", onMessage);
|
|
255165
255235
|
if (error65) reject4(error65);
|
|
255166
|
-
else
|
|
255236
|
+
else resolve63();
|
|
255167
255237
|
}
|
|
255168
255238
|
child3.once("error", onError);
|
|
255169
255239
|
child3.once("exit", onExit);
|
|
@@ -255178,18 +255248,18 @@ async function startDetached(request2) {
|
|
|
255178
255248
|
child3.unref();
|
|
255179
255249
|
} catch (error65) {
|
|
255180
255250
|
child3.kill("SIGTERM");
|
|
255181
|
-
await new Promise((
|
|
255251
|
+
await new Promise((resolve63) => {
|
|
255182
255252
|
if (child3.exitCode !== null || child3.signalCode !== null) {
|
|
255183
|
-
|
|
255253
|
+
resolve63();
|
|
255184
255254
|
return;
|
|
255185
255255
|
}
|
|
255186
255256
|
const kill = setTimeout(() => {
|
|
255187
255257
|
child3.kill("SIGKILL");
|
|
255188
|
-
|
|
255258
|
+
resolve63();
|
|
255189
255259
|
}, 2e3);
|
|
255190
255260
|
child3.once("exit", () => {
|
|
255191
255261
|
clearTimeout(kill);
|
|
255192
|
-
|
|
255262
|
+
resolve63();
|
|
255193
255263
|
});
|
|
255194
255264
|
});
|
|
255195
255265
|
if (child3.connected) child3.disconnect();
|
|
@@ -255342,13 +255412,13 @@ init_src();
|
|
|
255342
255412
|
init_report2();
|
|
255343
255413
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
255344
255414
|
import { mkdir as mkdir19, writeFile as writeFile18 } from "node:fs/promises";
|
|
255345
|
-
import { join as join42, resolve as
|
|
255415
|
+
import { join as join42, resolve as resolve32 } from "node:path";
|
|
255346
255416
|
|
|
255347
255417
|
// packages/cli/src/project-identity.ts
|
|
255348
255418
|
import { createHash as createHash71 } from "node:crypto";
|
|
255349
255419
|
import { realpath as realpath11 } from "node:fs/promises";
|
|
255350
255420
|
import { hostname as hostname3 } from "node:os";
|
|
255351
|
-
import { isAbsolute as
|
|
255421
|
+
import { isAbsolute as isAbsolute11, relative as relative14, resolve as resolve29, sep as sep8 } from "node:path";
|
|
255352
255422
|
init_jobs_contract();
|
|
255353
255423
|
function normalizeRemote(remote) {
|
|
255354
255424
|
const value6 = remote.trim();
|
|
@@ -255362,7 +255432,7 @@ function normalizeRemote(remote) {
|
|
|
255362
255432
|
return value6.replace(/\/+$/, "").replace(/\.git$/, "");
|
|
255363
255433
|
}
|
|
255364
255434
|
async function projectIdentity(cwd) {
|
|
255365
|
-
const folder2 = await realpath11(
|
|
255435
|
+
const folder2 = await realpath11(resolve29(cwd));
|
|
255366
255436
|
let identity7 = `${hostname3()}
|
|
255367
255437
|
${folder2}`;
|
|
255368
255438
|
let repository3;
|
|
@@ -255370,13 +255440,13 @@ ${folder2}`;
|
|
|
255370
255440
|
const root3 = await realpath11(await gitOutput(folder2, ["rev-parse", "--show-toplevel"]));
|
|
255371
255441
|
const remotes = (await gitOutput(folder2, ["remote"])).split("\n").filter(Boolean).sort();
|
|
255372
255442
|
const remote = remotes.includes("origin") ? "origin" : remotes[0];
|
|
255373
|
-
const path9 =
|
|
255374
|
-
if (remote && path9 !== ".." && !path9.startsWith(`..${
|
|
255443
|
+
const path9 = relative14(root3, folder2);
|
|
255444
|
+
if (remote && path9 !== ".." && !path9.startsWith(`..${sep8}`) && !isAbsolute11(path9)) {
|
|
255375
255445
|
const url4 = await gitOutput(folder2, ["remote", "get-url", remote]);
|
|
255376
255446
|
if (url4) {
|
|
255377
255447
|
const normalized3 = normalizeRemote(url4);
|
|
255378
255448
|
identity7 = `${normalized3}
|
|
255379
|
-
${path9.split(
|
|
255449
|
+
${path9.split(sep8).join("/")}`;
|
|
255380
255450
|
const network = url4.includes("://") ? ["https:", "http:", "ssh:", "git:"].includes(new URL(url4).protocol) : /^(?:[^/@:]+@)?[^/:]+:.+$/.test(url4);
|
|
255381
255451
|
if (network && validRepository(normalized3)) repository3 = normalized3;
|
|
255382
255452
|
}
|
|
@@ -255390,14 +255460,14 @@ ${path9.split(sep7).join("/")}`;
|
|
|
255390
255460
|
init_src();
|
|
255391
255461
|
init_connection_tools();
|
|
255392
255462
|
import { access as access10 } from "node:fs/promises";
|
|
255393
|
-
import { basename as basename12, resolve as
|
|
255463
|
+
import { basename as basename12, resolve as resolve31 } from "node:path";
|
|
255394
255464
|
init_baselines();
|
|
255395
255465
|
init_run_store();
|
|
255396
255466
|
init_config();
|
|
255397
255467
|
init_report2();
|
|
255398
255468
|
init_agent_env();
|
|
255399
255469
|
init_run();
|
|
255400
|
-
var agentName = (cwd) => basename12(
|
|
255470
|
+
var agentName = (cwd) => basename12(resolve31(cwd)).slice(0, 100) || "agent";
|
|
255401
255471
|
async function pinnedBaseline(ctx, ref23, tests, options5, cloudSummary2) {
|
|
255402
255472
|
const { cwd } = ctx.io;
|
|
255403
255473
|
if (ref23 === "latest") ref23 = await latestRunId(cwd);
|
|
@@ -255418,7 +255488,7 @@ async function pinnedBaseline(ctx, ref23, tests, options5, cloudSummary2) {
|
|
|
255418
255488
|
}
|
|
255419
255489
|
async function cloudBundle(ctx, input5) {
|
|
255420
255490
|
const { cwd } = ctx.io;
|
|
255421
|
-
const configFile =
|
|
255491
|
+
const configFile = resolve31(cwd, ctx.globals().config ?? "ancha.yaml");
|
|
255422
255492
|
if (!await access10(configFile).then(() => true, () => false)) throw new AnchaError("USAGE", `no ${ctx.globals().config ?? "ancha.yaml"} here: a cloud run reads its agent from the project's config`, { hint: "run `ancha init` in your agent's project" });
|
|
255423
255493
|
const configPath = projectPath(cwd, configFile, "the config file");
|
|
255424
255494
|
const config12 = await ctx.loadConfig();
|
|
@@ -255810,7 +255880,7 @@ async function runOnCloud(ctx, ws, run7, signal) {
|
|
|
255810
255880
|
const submitted = await submit2(ws, bundle, key5, signal, runContextHeader(ctx.io.env));
|
|
255811
255881
|
const { job } = submitted, url4 = resultUrl(ws, submitted);
|
|
255812
255882
|
try {
|
|
255813
|
-
const dir2 =
|
|
255883
|
+
const dir2 = resolve32(ctx.io.cwd, DEFAULT_RUNS_DIR);
|
|
255814
255884
|
await mkdir19(dir2, { recursive: true });
|
|
255815
255885
|
await writeFile18(join42(dir2, "latest-cloud"), `${JSON.stringify({ runId: job.id, server: ws.server, submittedAt: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
255816
255886
|
`);
|
|
@@ -255854,7 +255924,7 @@ async function connectOnCloud(ctx, ws, check4, signal) {
|
|
|
255854
255924
|
|
|
255855
255925
|
// packages/cli/src/commands/internal-cloud.ts
|
|
255856
255926
|
import { readFile as readFile28, stat as stat10, writeFile as writeFile20 } from "node:fs/promises";
|
|
255857
|
-
import { basename as basename13, join as join46, resolve as
|
|
255927
|
+
import { basename as basename13, join as join46, resolve as resolve35 } from "node:path";
|
|
255858
255928
|
init_src();
|
|
255859
255929
|
init_config();
|
|
255860
255930
|
var cloudModules = {
|
|
@@ -255944,7 +256014,7 @@ async function missingCommandEntry(command, cwd) {
|
|
|
255944
256014
|
const entry3 = words9[0];
|
|
255945
256015
|
if (!entry3 || entry3.startsWith("-") || /^[a-z][a-z\d+.-]*:/i.test(entry3)) return void 0;
|
|
255946
256016
|
if (program2 === "bun" && !/[/.]/.test(entry3)) return void 0;
|
|
255947
|
-
paths3 = [
|
|
256017
|
+
paths3 = [resolve35(cwd, entry3)];
|
|
255948
256018
|
}
|
|
255949
256019
|
for (const path9 of paths3) if ((await stat10(path9).catch(() => void 0))?.isFile()) return void 0;
|
|
255950
256020
|
return `The agent entry file is missing: ${paths3.join(" or ")}.`;
|
|
@@ -255952,12 +256022,12 @@ async function missingCommandEntry(command, cwd) {
|
|
|
255952
256022
|
function registerInternalCloud(program2, ctx) {
|
|
255953
256023
|
program2.command("_cloud-view", { hidden: true }).description("read a world starting state inside a view machine").requiredOption("--input <file>", "the world input from the gateway").requiredOption("--out <file>", "where the starting data JSON goes").action(async (opts) => {
|
|
255954
256024
|
const { renderCloudView: renderCloudView2 } = await Promise.resolve().then(() => (init_view2(), view_exports));
|
|
255955
|
-
const result = await renderCloudView2(
|
|
255956
|
-
await writeFile20(
|
|
256025
|
+
const result = await renderCloudView2(resolve35(ctx.io.cwd, opts.input));
|
|
256026
|
+
await writeFile20(resolve35(ctx.io.cwd, opts.out), JSON.stringify(result), { mode: 384 });
|
|
255957
256027
|
ctx.out.result({ written: true }, () => "World data saved.");
|
|
255958
256028
|
});
|
|
255959
256029
|
program2.command("_cloud-plan", { hidden: true }).description("print the dependency install of a project in an attempt machine").requiredOption("--project <dir>", "the agent's project folder; --config is relative to it").action(async (opts) => {
|
|
255960
|
-
const project14 =
|
|
256030
|
+
const project14 = resolve35(ctx.io.cwd, opts.project);
|
|
255961
256031
|
const config12 = await loadConfig(project14, ctx.globals().config);
|
|
255962
256032
|
const cwd = await cloudAgentCwd(project14, ctx.globals().config ?? "ancha.yaml", config12);
|
|
255963
256033
|
const install = config12.agent?.install;
|
|
@@ -255985,7 +256055,7 @@ function registerInternalCloud(program2, ctx) {
|
|
|
255985
256055
|
program2.command("_cloud-assemble", { hidden: true }).description("assemble a cloud run from its attempts' artifacts in the finalize machine").requiredOption("--input <file>", "the finalize input (FinalizeInput JSON)").requiredOption("--bundle <dir>", "the unpacked input bundle").requiredOption("--artifacts <dir>", "one folder per source attempt id with its unpacked artifact").requiredOption("--out <dir>", "where the run and its archive go").option("--relay <file>", "the workspace relay for model-graded checks ({ baseUrl, token, bootId }, written root-only by the runner)").action(async (opts) => {
|
|
255986
256056
|
let input5;
|
|
255987
256057
|
try {
|
|
255988
|
-
input5 = JSON.parse(await readFile28(
|
|
256058
|
+
input5 = JSON.parse(await readFile28(resolve35(ctx.io.cwd, opts.input), "utf8"));
|
|
255989
256059
|
} catch (error65) {
|
|
255990
256060
|
throw new AnchaError("USAGE", `cannot read the finalize input ${opts.input}`, { hint: "pass the FinalizeInput JSON the runner wrote", cause: error65 });
|
|
255991
256061
|
}
|
|
@@ -255993,7 +256063,7 @@ function registerInternalCloud(program2, ctx) {
|
|
|
255993
256063
|
if (opts.relay !== void 0) {
|
|
255994
256064
|
let relay;
|
|
255995
256065
|
try {
|
|
255996
|
-
relay = JSON.parse(await readFile28(
|
|
256066
|
+
relay = JSON.parse(await readFile28(resolve35(ctx.io.cwd, opts.relay), "utf8"));
|
|
255997
256067
|
} catch (error65) {
|
|
255998
256068
|
throw new AnchaError("USAGE", `cannot read the relay file ${opts.relay}`, { hint: "pass the relay JSON the runner wrote", cause: error65 });
|
|
255999
256069
|
}
|
|
@@ -256003,7 +256073,7 @@ function registerInternalCloud(program2, ctx) {
|
|
|
256003
256073
|
judge = cloudModelAccess2({ baseUrl, token: token5, bootId }).judge;
|
|
256004
256074
|
}
|
|
256005
256075
|
const { assembleCloudRun: assembleCloudRun2 } = await cloudModules.assemble();
|
|
256006
|
-
const result = await assembleCloudRun2({ input: input5, bundleDir:
|
|
256076
|
+
const result = await assembleCloudRun2({ input: input5, bundleDir: resolve35(ctx.io.cwd, opts.bundle), artifactsDir: resolve35(ctx.io.cwd, opts.artifacts), outDir: resolve35(ctx.io.cwd, opts.out), ...judge !== void 0 && { judge }, cli: CLI_VERSION });
|
|
256007
256077
|
ctx.out.result(result, () => `${result.runId} ${result.verdict} (exit ${result.exitCode}): ${result.archivePath}`);
|
|
256008
256078
|
});
|
|
256009
256079
|
}
|
|
@@ -256063,7 +256133,7 @@ function registerRun(program2, ctx) {
|
|
|
256063
256133
|
program2.command("run").description("run the agent against its tests N times each and summarize how often it passes (starts its own server unless one is configured)").argument("[tests...]", "test files (scene.yaml; default: every test the scenes: globs of ancha.yaml match)").option("--agent <cmd>", "shell command that runs the agent (default: agent.command in ancha.yaml)").option("--agent-url <url>", "endpoint URL (overrides agent.url; requires endpoint setup/start configuration)").option("-n, --trials <n>", "trials per test (default: trials in ancha.yaml, else 5)").option("--attempts <n>", "another name for --trials").option("--parallel <n>", "trials running at once (default: parallel in ancha.yaml, else command 2 / endpoint 1)").option("--concurrency <n>", "another name for --parallel").option("--min-pass-rate <r>", "fraction of trials that must pass, 0 to 1 (default: min_pass_rate in ancha.yaml, else 1)").option("--seed <seed>", "seed for ids and randomness").option("--out <dir>", "where run directories go (default: .ancha/runs)").option("--strict", "exit 4 for endpoint coverage errors or verdicts using simulated tool answers").option("--allow-simulated", "allow verdicts using simulated tool answers, including in CI and with --strict").option("--detach", "return once the run has started (a private worker here, the workspace with --on cloud); observe with status/wait").option("--compare <reference>", "compare against a completed run id or saved baseline; any per-test decrease fails").option("--pass-env <name>", "give the agent this variable from this shell (repeatable); it otherwise gets only a base set (PATH, HOME, locale\u2026) plus Ancha's and the tools' variables", (name5, names8) => [...names8, name5], []).option("--inherit-env", "give the agent this shell's whole environment, including any real credentials (the behavior before 0.1.2)").option("--on <target>", "where the agent runs: local (a process on this computer), docker (a sealed container; needs agent.execution with an image in ancha.yaml) or cloud (each attempt in its own machine in your workspace, which keeps the run). Default: cloud with a saved ancha login and a project config outside CI; ANCHA_API_KEY, server overrides and local settings keep what ancha.yaml says").option("--idempotency-key <key>", "retry safely: the same key and the same run definition return the original run instead of starting another").option("--upload", "send the finished run to your workspace, where the console shows it (also ANCHA_UPLOAD=1); a failed upload is a warning").option("--upload-required", "like --upload, but a failed upload fails the command").option("--dry-run", "check ancha.yaml and every test, print what would run, and stop: no server, no agent, no trial").option("--allow-unwrapped <tools>", "in a test made from a trace, let the agent call these tools for real instead of stopping because it does not wrap them (comma-separated, repeatable)", (value6, all9 = []) => [...all9, ...value6.split(",").map((s3) => s3.trim()).filter(Boolean)]).option("--bundle-file <path>", "with --on cloud: a file or folder the agent reads that the project's files leave out, e.g. a gitignored fixture (repeatable)", (path9, paths3) => [...paths3, path9], []).action(async (sceneArgs, opts, command) => {
|
|
256064
256134
|
const { cwd } = ctx.io;
|
|
256065
256135
|
const descriptor3 = await vmDescriptor(ctx.io.env);
|
|
256066
|
-
if (descriptor3 === void 0 && opts.agent === void 0 && opts.agentUrl === void 0 && ctx.globals().config === void 0 && !await access11(
|
|
256136
|
+
if (descriptor3 === void 0 && opts.agent === void 0 && opts.agentUrl === void 0 && ctx.globals().config === void 0 && !await access11(resolve36(cwd, "ancha.yaml")).then(() => true, () => false)) {
|
|
256067
256137
|
throw new AnchaError("USAGE", "no ancha.yaml here", { hint: 'run `ancha init` in your agent\'s project, or pass --agent "<command>"' });
|
|
256068
256138
|
}
|
|
256069
256139
|
const config12 = descriptor3 !== void 0 && ctx.globals().config === void 0 ? await loadConfig(cwd, descriptor3.configPath) : await ctx.loadConfig();
|
|
@@ -256074,7 +256144,7 @@ function registerRun(program2, ctx) {
|
|
|
256074
256144
|
if (opts.dryRun && opts.on === "cloud") throw new AnchaError("USAGE", "--dry-run checks a run on this computer", { hint: "leave out --on cloud" });
|
|
256075
256145
|
const trialsOption = sameSetting(opts.trials, opts.attempts, "--trials", "--attempts");
|
|
256076
256146
|
const parallelOption = sameSetting(opts.parallel, opts.concurrency, "--parallel", "--concurrency");
|
|
256077
|
-
const defaulted = opts.on === void 0 && !opts.dryRun && !ctx.io.env.ANCHA_API_KEY && !inCi(ctx.io.env) && (ctx.globals().config !== void 0 || await access11(
|
|
256147
|
+
const defaulted = opts.on === void 0 && !opts.dryRun && !ctx.io.env.ANCHA_API_KEY && !inCi(ctx.io.env) && (ctx.globals().config !== void 0 || await access11(resolve36(cwd, "ancha.yaml")).then(() => true, () => false)) && cloudRunRefusal(ctx, opts, command, config12) === void 0 && (await serverChoice(ctx)).source === "login";
|
|
256078
256148
|
if (opts.on === "cloud" || defaulted) {
|
|
256079
256149
|
try {
|
|
256080
256150
|
ctx.exitCode = await cloudRun(ctx, sceneArgs, opts, command, config12, trialsOption, parallelOption, defaulted);
|
|
@@ -256104,7 +256174,7 @@ function registerRun(program2, ctx) {
|
|
|
256104
256174
|
}
|
|
256105
256175
|
const minPassRate = passRate(opts.minPassRate, config12.min_pass_rate);
|
|
256106
256176
|
const configured = (await glob3(config12.scenes, { cwd, absolute: true, onlyFiles: true })).sort();
|
|
256107
|
-
const scenePaths = sceneArgs.length > 0 ? sceneArgs : configured.map((p2) =>
|
|
256177
|
+
const scenePaths = sceneArgs.length > 0 ? sceneArgs : configured.map((p2) => relative15(cwd, p2));
|
|
256108
256178
|
if (scenePaths.length === 0) {
|
|
256109
256179
|
throw new AnchaError("USAGE", "no tests to run", { hint: "make tests with ancha traces upload ./traces, or pass a test file (scene.yaml), or set scenes: in ancha.yaml" });
|
|
256110
256180
|
}
|
|
@@ -256120,7 +256190,7 @@ function registerRun(program2, ctx) {
|
|
|
256120
256190
|
}
|
|
256121
256191
|
const limits = loaded.flatMap((s3) => s3.realTimeoutMs !== void 0 ? [[s3.scene.id, s3.realTimeoutMs]] : []);
|
|
256122
256192
|
const realTimeouts = limits.length > 0 ? Object.fromEntries(limits) : void 0;
|
|
256123
|
-
agent.privatePaths = [.../* @__PURE__ */ new Set([...loaded.flatMap((s3) => [
|
|
256193
|
+
agent.privatePaths = [.../* @__PURE__ */ new Set([...loaded.flatMap((s3) => [resolve36(cwd, s3.path), ...s3.world !== void 0 ? [s3.world] : []]), ...configured, resolve36(cwd, ctx.globals().config ?? "ancha.yaml")])];
|
|
256124
256194
|
for (const scene2 of scenes) validateAgentEnv(scene2, agent);
|
|
256125
256195
|
const digests = new Map(await Promise.all(loaded.map(async (s3) => [s3.scene.id, await recordsDigest(s3.path, cwd)])));
|
|
256126
256196
|
if (opts.compare === "latest") opts.compare = await latestRunId(cwd, opts.out);
|
|
@@ -256178,13 +256248,13 @@ function registerRun(program2, ctx) {
|
|
|
256178
256248
|
...uploadTo !== void 0 && { upload: { workspace: uploadTo, required: opts.uploadRequired === true } },
|
|
256179
256249
|
...uploadTo === void 0 && choice5.login !== void 0 && { uploadHint: choice5.login },
|
|
256180
256250
|
workspace: workspace4,
|
|
256181
|
-
outDir:
|
|
256251
|
+
outDir: resolve36(cwd, opts.out ?? DEFAULT_RUNS_DIR),
|
|
256182
256252
|
scenePaths: Object.fromEntries(loaded.map((s3) => [s3.scene.id, s3.path])),
|
|
256183
256253
|
...realTimeouts !== void 0 && { realTimeouts }
|
|
256184
256254
|
};
|
|
256185
256255
|
for (const s3 of loaded) {
|
|
256186
|
-
const added = await completeProduction(
|
|
256187
|
-
if (added.length) ctx.out.info(`computed production's result for ${added.join(", ")} from ${
|
|
256256
|
+
const added = await completeProduction(resolve36(cwd, s3.path), s3.scene, input5.judge);
|
|
256257
|
+
if (added.length) ctx.out.info(`computed production's result for ${added.join(", ")} from ${relative15(cwd, join47(dirname20(resolve36(cwd, s3.path)), "production.jsonl"))}`);
|
|
256188
256258
|
}
|
|
256189
256259
|
const definition3 = createHash73("sha256").update(JSON.stringify({ scenes: scenes.map((scene2) => sceneFingerprint(scene2)).sort(), agent: agent.mode === "endpoint" ? agent.url : agent.command, trials, seed: opts.seed ?? null, minPassRate, strict: opts.strict ?? false, compare: opts.compare ?? null, detach: opts.detach ?? false, ...simulatedPolicy(opts, ctx.io.env), ...realTimeouts !== void 0 && { realTimeouts }, ...[...digests.values()].some((d) => d !== void 0) && { records: Object.fromEntries([...digests].filter(([, d]) => d !== void 0)) } })).digest("hex");
|
|
256190
256260
|
if (opts.idempotencyKey !== void 0) {
|
|
@@ -256237,7 +256307,7 @@ async function cloudRun(ctx, sceneArgs, opts, command, config12, trials, paralle
|
|
|
256237
256307
|
const ws = await cloudWorkspace(ctx, { code: "USAGE", message: "--on cloud needs a workspace", hint: "run ancha login, or set ANCHA_SERVER_URL and ANCHA_API_KEY" });
|
|
256238
256308
|
const agent = resolveRunAgent(config12, cwd, { ...opts.agent !== void 0 && { agent: opts.agent }, parallel: 1 }).agent;
|
|
256239
256309
|
const concurrency = parallel ?? (config12.parallelExplicit ? config12.parallel : agent.mode === "endpoint" ? 1 : 2);
|
|
256240
|
-
const tests = sceneArgs.length > 0 ? sceneArgs : (await glob3(config12.scenes, { cwd, absolute: true, onlyFiles: true })).sort().map((path9) =>
|
|
256310
|
+
const tests = sceneArgs.length > 0 ? sceneArgs : (await glob3(config12.scenes, { cwd, absolute: true, onlyFiles: true })).sort().map((path9) => relative15(cwd, path9));
|
|
256241
256311
|
if (tests.length === 0) throw new AnchaError("USAGE", "no test to run", { hint: "pass a test file, or name tests in ancha.yaml" });
|
|
256242
256312
|
const resolvedOptions = { ...simulatedPolicy(opts, ctx.io.env), attempts: trials ?? config12.trials, concurrency, seed: opts.seed ?? null, strict: opts.strict === true, minPassRate: passRate(opts.minPassRate, config12.min_pass_rate), allowUnwrapped: opts.allowUnwrapped ?? [], agentCommand: opts.agent ?? null };
|
|
256243
256313
|
return interruptible(ctx, (signal) => runOnCloud(ctx, ws, {
|
|
@@ -256254,7 +256324,7 @@ async function runAttempt(ctx, descriptor3, config12, sceneArgs) {
|
|
|
256254
256324
|
const { cwd } = ctx.io;
|
|
256255
256325
|
const item2 = descriptor3.case;
|
|
256256
256326
|
if (descriptor3.role !== "attempt" || item2 === null) throw new AnchaError("USAGE", "this machine checks a connection and runs no test", { hint: "ancha _cloud-connect --json" });
|
|
256257
|
-
if (sceneArgs.some((path9) =>
|
|
256327
|
+
if (sceneArgs.some((path9) => resolve36(cwd, path9) !== resolve36(cwd, item2.path))) throw new AnchaError("USAGE", `this attempt runs ${item2.path}`, { hint: `ancha run ${item2.path} --json` });
|
|
256258
256328
|
const { options: options5 } = descriptor3;
|
|
256259
256329
|
const agent = withLocalEnvironment(resolveRunAgent(config12, cwd, { ...options5.agentCommand !== null && { agent: options5.agentCommand }, parallel: 1 }).agent, config12);
|
|
256260
256330
|
const loaded = await loadScenes(cwd, [item2.path]);
|
|
@@ -256262,7 +256332,7 @@ async function runAttempt(ctx, descriptor3, config12, sceneArgs) {
|
|
|
256262
256332
|
for (const name5 of options5.allowUnwrapped) for (const scene2 of scenes) if (scene2.tools?.[name5] !== void 0) scene2.tools[name5].allow_unwrapped = true;
|
|
256263
256333
|
const limits = loaded.flatMap((test3) => test3.realTimeoutMs !== void 0 ? [[test3.scene.id, test3.realTimeoutMs]] : []);
|
|
256264
256334
|
const configured = (await glob3(config12.scenes, { cwd, absolute: true, onlyFiles: true })).sort();
|
|
256265
|
-
agent.privatePaths = [.../* @__PURE__ */ new Set([...loaded.flatMap((test3) => [
|
|
256335
|
+
agent.privatePaths = [.../* @__PURE__ */ new Set([...loaded.flatMap((test3) => [resolve36(cwd, test3.path), ...test3.world !== void 0 ? [test3.world] : []]), ...configured, resolve36(cwd, ctx.globals().config ?? descriptor3.configPath)])];
|
|
256266
256336
|
for (const scene2 of scenes) validateAgentEnv(scene2, agent);
|
|
256267
256337
|
const access16 = (await cloudModules.relay()).cloudModelAccess(descriptor3.relay);
|
|
256268
256338
|
const now11 = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -256430,7 +256500,7 @@ async function executePreparedRun(ctx, input5, initial, ready3) {
|
|
|
256430
256500
|
|
|
256431
256501
|
// packages/cli/src/commands/playground.ts
|
|
256432
256502
|
async function definition2(ctx, path9) {
|
|
256433
|
-
const absolute2 =
|
|
256503
|
+
const absolute2 = resolve37(ctx.io.cwd, path9);
|
|
256434
256504
|
let body8;
|
|
256435
256505
|
try {
|
|
256436
256506
|
const info2 = await stat11(absolute2);
|
|
@@ -256610,7 +256680,7 @@ ${attempt2.response ?? attempt2.error ?? "No response"}`).join("\n\n"));
|
|
|
256610
256680
|
// packages/cli/src/kit/doctor.ts
|
|
256611
256681
|
import { mkdtemp as mkdtemp9, readFile as readFile32, rm as rm11 } from "node:fs/promises";
|
|
256612
256682
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
256613
|
-
import { join as join49, relative as
|
|
256683
|
+
import { join as join49, relative as relative17, resolve as resolve38 } from "node:path";
|
|
256614
256684
|
var import_yaml9 = __toESM(require_dist(), 1);
|
|
256615
256685
|
init_src();
|
|
256616
256686
|
init_backend();
|
|
@@ -256625,7 +256695,7 @@ init_run();
|
|
|
256625
256695
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
256626
256696
|
import { access as access12, mkdtemp as mkdtemp8, readFile as readFile31, rm as rm10, writeFile as writeFile22 } from "node:fs/promises";
|
|
256627
256697
|
import { tmpdir as tmpdir7 } from "node:os";
|
|
256628
|
-
import { join as join48, relative as
|
|
256698
|
+
import { join as join48, relative as relative16 } from "node:path";
|
|
256629
256699
|
var messages3 = {
|
|
256630
256700
|
RECORDS_ADAPTER_UNBOUND: "Bind the store in ancha_records.py and call open_store() before creating tools.",
|
|
256631
256701
|
RECORDS_ADAPTER_LEAK: "Attempt 2 observed attempt 1's diagnostic write.",
|
|
@@ -256725,7 +256795,7 @@ async function doctorRecords(opts) {
|
|
|
256725
256795
|
check4.message = `Bind the store in ${adapter} and call ${adapter.endsWith(".py") ? "open_store()" : "openStore()"} before creating tools.`;
|
|
256726
256796
|
check4.hint = `edit ${adapter}, open the bound store before creating tools, then run ancha doctor`;
|
|
256727
256797
|
}
|
|
256728
|
-
for (const group5 of check4.evidence.groups) evidence3.groups.push({ scene:
|
|
256798
|
+
for (const group5 of check4.evidence.groups) evidence3.groups.push({ scene: relative16(opts.cwd, item2.path), adapter, ...group5 });
|
|
256729
256799
|
if (!result || check4.status === "fail" || check4.status === "warning" && result.status === "pass") result = check4;
|
|
256730
256800
|
}
|
|
256731
256801
|
return { ...result, evidence: evidence3 };
|
|
@@ -256770,7 +256840,7 @@ var fixLine = (fix) => fix.via === "env" ? `add to ancha.yaml under agent: ${fix
|
|
|
256770
256840
|
async function taskCheck(ctx, agent) {
|
|
256771
256841
|
if (!agent?.command) return void 0;
|
|
256772
256842
|
const mapped = mappedTaskInput(agent);
|
|
256773
|
-
const scan2 = await scanTaskInput(
|
|
256843
|
+
const scan2 = await scanTaskInput(resolve38(ctx.io.cwd, agent.cwd ?? "."), agent.command).catch(() => void 0);
|
|
256774
256844
|
if (scan2?.native) return { name: "task", status: "pass", message: scan2.native.name === "entry" ? "your agent uses entry() from @ancha-labs/tools, which hands it each test's task" : `your agent reads ${scan2.native.name}, which holds each test's task` };
|
|
256775
256845
|
if (mapped !== null) return { name: "task", status: "pass", message: `ancha.yaml hands each test's task to ${mapped === "ANCHA_TASK" ? "your agent's command" : mapped}` };
|
|
256776
256846
|
if (agent.input === "stdin") return { name: "task", status: "pass", message: "ancha.yaml writes each test's task to your agent's stdin (agent.input: stdin)" };
|
|
@@ -257011,7 +257081,7 @@ async function doctor(ctx, opts) {
|
|
|
257011
257081
|
outDir: directory,
|
|
257012
257082
|
root: ctx.io.cwd,
|
|
257013
257083
|
inheritedEnv: ctx.io.env,
|
|
257014
|
-
scenePaths: { [scene2.id]:
|
|
257084
|
+
scenePaths: { [scene2.id]: relative17(ctx.io.cwd, first2.path) },
|
|
257015
257085
|
signal: AbortSignal.any([externalSignal, timer.signal])
|
|
257016
257086
|
});
|
|
257017
257087
|
} finally {
|
|
@@ -257200,14 +257270,21 @@ function loginRunLine(ctx) {
|
|
|
257200
257270
|
const apiKey = Boolean(ctx.io.env.ANCHA_API_KEY);
|
|
257201
257271
|
return apiKey || inCi(ctx.io.env) ? `${apiKey ? "With ANCHA_API_KEY set" : "In CI"}, ancha run runs where ancha.yaml says; ancha run --on cloud runs in this workspace.` : "ancha run runs your tests in this workspace; ancha run --on local runs them on this computer.";
|
|
257202
257272
|
}
|
|
257203
|
-
async function json38(url4, init = {}) {
|
|
257273
|
+
async function json38(url4, init = {}, fetchImpl = fetch) {
|
|
257204
257274
|
let res;
|
|
257275
|
+
let text31;
|
|
257205
257276
|
try {
|
|
257206
|
-
res = await
|
|
257277
|
+
res = await fetchImpl(url4, { ...init, headers: { accept: "application/json", ...init.body ? { "content-type": "application/json" } : {}, ...init.headers ?? {} }, signal: init.signal ?? AbortSignal.timeout(2e4) });
|
|
257278
|
+
if (res.status === 401) {
|
|
257279
|
+
void res.body?.cancel().catch(() => {
|
|
257280
|
+
});
|
|
257281
|
+
throw authError(new URL(url4).origin, { status: 401, keySent: Boolean(new Headers(init.headers).get("authorization")) });
|
|
257282
|
+
}
|
|
257283
|
+
text31 = await res.text();
|
|
257207
257284
|
} catch (e) {
|
|
257285
|
+
if (e instanceof AnchaError) throw e;
|
|
257208
257286
|
throw new AnchaError("SERVER_UNREACHABLE", `cannot reach ${new URL(url4).origin}`, { hint: "check the address and your network, then run ancha login again", cause: e });
|
|
257209
257287
|
}
|
|
257210
|
-
const text31 = await res.text();
|
|
257211
257288
|
let body8;
|
|
257212
257289
|
try {
|
|
257213
257290
|
body8 = JSON.parse(text31);
|
|
@@ -257233,14 +257310,14 @@ function openBrowser(url4) {
|
|
|
257233
257310
|
return false;
|
|
257234
257311
|
}
|
|
257235
257312
|
}
|
|
257236
|
-
var sleep12 = (ms2, signal) => new Promise((
|
|
257237
|
-
const timer = setTimeout(
|
|
257313
|
+
var sleep12 = (ms2, signal) => new Promise((resolve63) => {
|
|
257314
|
+
const timer = setTimeout(resolve63, ms2);
|
|
257238
257315
|
signal?.addEventListener("abort", () => {
|
|
257239
257316
|
clearTimeout(timer);
|
|
257240
|
-
|
|
257317
|
+
resolve63();
|
|
257241
257318
|
}, { once: true });
|
|
257242
257319
|
});
|
|
257243
|
-
function registerLogin(program2, ctx) {
|
|
257320
|
+
function registerLogin(program2, ctx, deps = {}) {
|
|
257244
257321
|
program2.command("login").description("sign in to your hosted workspace from this computer: ancha run runs your tests there, and import, pull and traces use it").option("--url <url>", "hosted Ancha address", DEFAULT_CLOUD_URL).option("--no-browser", "print the approval link instead of opening a browser").action(async (opts) => {
|
|
257245
257322
|
let base6;
|
|
257246
257323
|
try {
|
|
@@ -257248,7 +257325,7 @@ function registerLogin(program2, ctx) {
|
|
|
257248
257325
|
} catch {
|
|
257249
257326
|
throw new AnchaError("USAGE", "invalid --url", { hint: `use an https address such as ${DEFAULT_CLOUD_URL}` });
|
|
257250
257327
|
}
|
|
257251
|
-
const start2 = await json38(`${base6}/cli/device`, { method: "POST", body: JSON.stringify({ name: hostname4() }) });
|
|
257328
|
+
const start2 = await json38(`${base6}/cli/device`, { method: "POST", body: JSON.stringify({ name: hostname4() }) }, deps.fetch);
|
|
257252
257329
|
ctx.out.info(`Confirm this computer in your browser: ${start2.verification_url}`);
|
|
257253
257330
|
ctx.out.info(`Code: ${start2.user_code}`);
|
|
257254
257331
|
if (ctx.out.json) ctx.out.event({ event: "login_pending", verificationUrl: start2.verification_url, userCode: start2.user_code, expiresIn: start2.expires_in });
|
|
@@ -257259,14 +257336,14 @@ function registerLogin(program2, ctx) {
|
|
|
257259
257336
|
while (Date.now() < deadline3 && !signal?.aborted) {
|
|
257260
257337
|
await sleep12(interval, signal);
|
|
257261
257338
|
if (signal?.aborted) break;
|
|
257262
|
-
const poll = await json38(`${base6}/cli/poll?device_code=${encodeURIComponent(start2.device_code)}
|
|
257339
|
+
const poll = await json38(`${base6}/cli/poll?device_code=${encodeURIComponent(start2.device_code)}`, {}, deps.fetch);
|
|
257263
257340
|
if (poll.status === "pending") continue;
|
|
257264
257341
|
if (poll.status === "denied") throw new AnchaError("USAGE", "sign-in was denied in the browser");
|
|
257265
257342
|
if (poll.status === "expired") break;
|
|
257266
257343
|
if (!poll.apiKey || !poll.serverUrl) throw new AnchaError("INTERNAL", `${base6} approved the sign-in without a key`);
|
|
257267
257344
|
const serverUrl3 = normalizeServerUrl(poll.serverUrl);
|
|
257268
257345
|
const file3 = await readCredentials(ctx.io.env);
|
|
257269
|
-
file3.servers[serverUrl3] = { apiKey: poll.apiKey, ...poll.email && { email: poll.email }, savedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
257346
|
+
file3.servers[serverUrl3] = { apiKey: poll.apiKey, ...poll.email && { email: poll.email }, savedAt: (/* @__PURE__ */ new Date()).toISOString(), minted: "device" };
|
|
257270
257347
|
file3.default = serverUrl3;
|
|
257271
257348
|
const path9 = await writeCredentials(file3, ctx.io.env);
|
|
257272
257349
|
let onboarding = null, unread2;
|
|
@@ -257294,19 +257371,39 @@ ${renderOnboarding(onboarding, next2 ?? void 0)}` : `The onboarding checks could
|
|
|
257294
257371
|
const minutes = Math.max(1, Math.round(start2.expires_in / 60));
|
|
257295
257372
|
throw new AnchaError("USAGE", "the approval link expired", { hint: `run ancha login again and approve within ${minutes} minute${minutes === 1 ? "" : "s"}` });
|
|
257296
257373
|
});
|
|
257297
|
-
program2.command("logout").description("
|
|
257374
|
+
program2.command("logout").description("sign out of a hosted Ancha and revoke the key that sign-in created").option("--url <url>", "hosted world server to forget (default: the saved default)").action(async (opts) => {
|
|
257298
257375
|
const file3 = await readCredentials(ctx.io.env);
|
|
257299
257376
|
const target6 = opts.url ? normalizeServerUrl(opts.url) : file3.default;
|
|
257300
257377
|
if (!target6 || !file3.servers[target6]) {
|
|
257301
|
-
ctx.out.result({ removed: null }, () => "Nothing saved; you were not signed in.");
|
|
257378
|
+
ctx.out.result({ removed: null, revoked: false }, () => "Nothing saved; you were not signed in.");
|
|
257302
257379
|
return;
|
|
257303
257380
|
}
|
|
257381
|
+
const entry3 = file3.servers[target6];
|
|
257382
|
+
let revoked = false, revokeError;
|
|
257383
|
+
if (entry3.minted === "device" && !isLoopbackUrl(target6)) {
|
|
257384
|
+
try {
|
|
257385
|
+
const result = await json38(new URL("/cli/logout", target6).href, {
|
|
257386
|
+
method: "POST",
|
|
257387
|
+
headers: { authorization: `Bearer ${entry3.apiKey}` },
|
|
257388
|
+
signal: AbortSignal.timeout(5e3),
|
|
257389
|
+
redirect: "error"
|
|
257390
|
+
}, deps.fetch);
|
|
257391
|
+
if (result?.revoked !== true) throw new AnchaError("INTERNAL", "invalid revocation response");
|
|
257392
|
+
revoked = true;
|
|
257393
|
+
} catch (e) {
|
|
257394
|
+
revokeError = toErrorJson(e).code;
|
|
257395
|
+
}
|
|
257396
|
+
}
|
|
257304
257397
|
delete file3.servers[target6];
|
|
257305
257398
|
if (file3.default === target6) delete file3.default;
|
|
257306
257399
|
const remaining = Object.keys(file3.servers);
|
|
257307
257400
|
if (file3.default === void 0 && remaining.length === 1) file3.default = remaining[0];
|
|
257308
257401
|
await writeCredentials(file3, ctx.io.env);
|
|
257309
|
-
|
|
257402
|
+
const signedOut = revoked ? `Signed out of ${target6}; its key was revoked.` : revokeError === "AUTH_INVALID" ? `Signed out of ${target6}; its key was already revoked or is not valid.` : `Signed out of ${target6}. Its key still works until you revoke it in Settings: ${new URL(target6).origin}/account.`;
|
|
257403
|
+
ctx.out.result(
|
|
257404
|
+
{ removed: target6, credentials: credentialsPath(ctx.io.env), revoked, ...revokeError && { revokeError } },
|
|
257405
|
+
() => `${signedOut} Commands run a local server again unless --server-url is set.`
|
|
257406
|
+
);
|
|
257310
257407
|
});
|
|
257311
257408
|
program2.command("whoami").description("show the workspace, where that choice came from, and how runs choose their target; never prints a key").option("--verify", "also ask the server whether it accepts the key (AUTH_INVALID, exit 2, when it does not)").action(async (opts) => {
|
|
257312
257409
|
const { url: serverUrl3, source } = await serverChoice(ctx);
|
|
@@ -257341,10 +257438,10 @@ ${worlds2 === "local" ? loginRunLine(ctx) : "This server override keeps the agen
|
|
|
257341
257438
|
var import_yaml10 = __toESM(require_dist(), 1);
|
|
257342
257439
|
init_src();
|
|
257343
257440
|
import { readFile as readFile33 } from "node:fs/promises";
|
|
257344
|
-
import { relative as
|
|
257441
|
+
import { relative as relative18 } from "node:path";
|
|
257345
257442
|
init_detect();
|
|
257346
257443
|
async function traceConnection(cwd, paths3, configured, target6, recordsAdapter, cloud = false) {
|
|
257347
|
-
const scenes = await Promise.all(paths3.map(async (path9) => ({ path:
|
|
257444
|
+
const scenes = await Promise.all(paths3.map(async (path9) => ({ path: relative18(cwd, path9), scene: (0, import_yaml10.parse)(await readFile33(path9, "utf8")) })));
|
|
257348
257445
|
const tools2 = [...new Set(scenes.flatMap(({ scene: scene2 }) => (scene2.twins ?? []).filter((name5) => !(name5 === "slack" && scene2.agent_input === "per_event" && scene2.people?.length))))].map((name5) => ({
|
|
257349
257446
|
name: name5,
|
|
257350
257447
|
env: connectionGuide(name5, "ts").env,
|
|
@@ -257441,14 +257538,19 @@ async function toolAnswers(runDir, summary, filter4) {
|
|
|
257441
257538
|
return out;
|
|
257442
257539
|
}
|
|
257443
257540
|
var NAMED2 = /* @__PURE__ */ new Set(["model_key", "refused", "outside_host", "unserved", "idle", "no_answer"]);
|
|
257444
|
-
function invalidSetupNext(summary, out) {
|
|
257541
|
+
function invalidSetupNext(summary, out, readDirectory) {
|
|
257445
257542
|
const invalid42 = summary.scenes.filter((scene2) => (scene2.counts?.invalid ?? scene2.invalidTrials ?? 0) > 0 || scene2.trialsDetail.some((trial) => trial.valid === false));
|
|
257446
257543
|
if (!invalid42.length || summary.source === "pytest") return void 0;
|
|
257447
257544
|
const reasons = invalid42.flatMap((scene2) => {
|
|
257448
257545
|
const issues = scene2.harnessIssues.filter((issue9) => issue9.owner === "harness");
|
|
257449
257546
|
return issues.length ? issues.map((issue9) => `${scene2.sceneId} trial ${issue9.trial}: ${issue9.message}`) : [`${scene2.sceneId}: invalid harness trial; inspect its setup and capture`];
|
|
257450
257547
|
});
|
|
257451
|
-
|
|
257548
|
+
const cloud = summary;
|
|
257549
|
+
return [`fix the test setup: ${reasons.join("; ")}`, ...retryCommands(summary, {
|
|
257550
|
+
out,
|
|
257551
|
+
readDirectory,
|
|
257552
|
+
...cloud.provenance && { tests: [...new Set(cloud.provenance.tests.map((test3) => test3.path))] }
|
|
257553
|
+
})];
|
|
257452
257554
|
}
|
|
257453
257555
|
async function trialOutcomes(runDir, summary, filter4) {
|
|
257454
257556
|
const inputs2 = await readFile34(join50(runDir, "inputs.json"), "utf8").then((text31) => JSON.parse(text31), () => ({ cases: [] }));
|
|
@@ -257588,9 +257690,10 @@ next: ancha wait ${id15}`
|
|
|
257588
257690
|
const reproduction = (view3.reproduction ?? []).filter((item2) => filter4.parent === void 0 ? filter4.scene === void 0 || item2.sceneId === filter4.scene : scenes.some((scene2) => scene2.sceneId === item2.sceneId));
|
|
257589
257691
|
const graded = summary.checkCounts?.evaluated !== 0;
|
|
257590
257692
|
const never2 = agentNeverRan(summary);
|
|
257591
|
-
const
|
|
257592
|
-
const
|
|
257593
|
-
const
|
|
257693
|
+
const readDirectory = projectTestDirectoryReader(ctx.io.cwd, { runId: id15, server: ws.server });
|
|
257694
|
+
const retry = never2 === void 0 ? [] : cloudRetry(summary, readDirectory);
|
|
257695
|
+
const setupNext = invalidSetupNext(summary, void 0, readDirectory);
|
|
257696
|
+
const next2 = setupNext ?? (never2 !== void 0 ? retry : summary.verdict === "pass" || summary.verdict === "ungraded" ? [] : graded ? ["fix the agent", compareCommand(summary, id15, readDirectory)] : [`ancha logs ${id15}`]);
|
|
257594
257697
|
ctx.out.result(
|
|
257595
257698
|
{
|
|
257596
257699
|
runId: id15,
|
|
@@ -257623,11 +257726,13 @@ async function endedEvidence(ws, id15, attempts) {
|
|
|
257623
257726
|
}
|
|
257624
257727
|
return found;
|
|
257625
257728
|
}
|
|
257626
|
-
function compareCommand(summary, id15) {
|
|
257729
|
+
function compareCommand(summary, id15, readDirectory) {
|
|
257627
257730
|
const cloud = summary, tests = [...new Set((cloud.provenance?.tests ?? []).map((test3) => test3.path))];
|
|
257628
257731
|
const attempts = cloud.counts && cloud.counts.cases > 0 ? cloud.counts.requestedAttempts / cloud.counts.cases : NaN;
|
|
257629
|
-
|
|
257630
|
-
|
|
257732
|
+
const words9 = rerunTestWords(summary, tests, readDirectory, shellArgument);
|
|
257733
|
+
const selection2 = words9.length ? ` ${words9.join(" ")}` : "";
|
|
257734
|
+
const options5 = Number.isSafeInteger(attempts) && Number.isSafeInteger(cloud.requestedConcurrency) ? ` --attempts ${attempts} --concurrency ${cloud.requestedConcurrency}` : "";
|
|
257735
|
+
return `ancha run --on cloud${selection2}${options5} --compare ${id15}`;
|
|
257631
257736
|
}
|
|
257632
257737
|
function sameBaselineTests(run7, baseline) {
|
|
257633
257738
|
try {
|
|
@@ -257639,9 +257744,10 @@ function sameBaselineTests(run7, baseline) {
|
|
|
257639
257744
|
if (JSON.stringify(ids3) !== JSON.stringify(baseline.scenes.map((scene2) => scene2.sceneId).sort())) return false;
|
|
257640
257745
|
return ids3.every((id15) => run7.sceneFingerprints?.[id15] !== void 0 && run7.sceneFingerprints[id15] === baseline.sceneFingerprints?.[id15] && run7.caseFingerprints?.[id15] === baseline.caseFingerprints?.[id15]);
|
|
257641
257746
|
}
|
|
257642
|
-
function nextComparisonRun(summary, out) {
|
|
257747
|
+
function nextComparisonRun(summary, out, readDirectory) {
|
|
257643
257748
|
const target6 = summary.target === "docker" ? "docker" : summary.target === "cloud" ? "cloud" : "local";
|
|
257644
|
-
const
|
|
257749
|
+
const words9 = rerunTestWords(summary, summary.testPaths ?? [], readDirectory, shellArgument);
|
|
257750
|
+
const tests = words9.length ? ` ${words9.join(" ")}` : "";
|
|
257645
257751
|
return `ancha run --on ${target6}${tests} --compare before${out === void 0 ? "" : ` --out ${shellArgument(out)}`}`;
|
|
257646
257752
|
}
|
|
257647
257753
|
function registerExplain(program2, ctx) {
|
|
@@ -257654,7 +257760,7 @@ function registerExplain(program2, ctx) {
|
|
|
257654
257760
|
return explainPlayground(ctx, ref23, trial);
|
|
257655
257761
|
}
|
|
257656
257762
|
const saved = await loadRunSummary(ctx.io.cwd, ref23, opts.out);
|
|
257657
|
-
const summary = selectVariantParent(await withAttemptToolDiagnostics(saved, join50(
|
|
257763
|
+
const summary = selectVariantParent(await withAttemptToolDiagnostics(saved, join50(resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), saved.runId)), opts.parent);
|
|
257658
257764
|
const scenes = summary.scenes.filter((s3) => opts.scene === void 0 || s3.sceneId === opts.scene);
|
|
257659
257765
|
if (opts.scene !== void 0 && scenes.length === 0) {
|
|
257660
257766
|
throw new AnchaError("USAGE", `no test ${JSON.stringify(opts.scene)} in run ${summary.runId}`, { hint: `tests in this run: ${summary.scenes.map((s3) => s3.sceneId).join(", ")}` });
|
|
@@ -257666,15 +257772,15 @@ function registerExplain(program2, ctx) {
|
|
|
257666
257772
|
const filter4 = { ...opts.scene !== void 0 && { scene: opts.scene }, ...trial !== void 0 && { trial } };
|
|
257667
257773
|
const gradingWarnings = explainGradingWarnings(summary, filter4);
|
|
257668
257774
|
const playOuts = explainPlayOuts(summary, filter4);
|
|
257669
|
-
const failures = await withWorldEvidence(summary, join50(
|
|
257670
|
-
const tools2 = await toolAnswers(join50(
|
|
257775
|
+
const failures = await withWorldEvidence(summary, join50(resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), summary.runId), explainFailures(summary, filter4));
|
|
257776
|
+
const tools2 = await toolAnswers(join50(resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), summary.runId), summary, filter4);
|
|
257671
257777
|
const textSummary = { ...summary, scenes: summary.scenes.map((scene2) => ({ ...scene2, trialsDetail: scene2.trialsDetail.map((t) => {
|
|
257672
257778
|
const view3 = tools2.find((a) => a.scene === scene2.sceneId && a.trial === t.trial)?.functionTools;
|
|
257673
257779
|
return view3 ? { ...t, functionTools: view3 } : t;
|
|
257674
257780
|
}) })) };
|
|
257675
|
-
const outcomes = await trialOutcomes(join50(
|
|
257781
|
+
const outcomes = await trialOutcomes(join50(resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), summary.runId), summary, filter4);
|
|
257676
257782
|
const out = opts.out === void 0 ? "" : ` --out ${shellArgument(opts.out)}`;
|
|
257677
|
-
const baselinePath = join50(
|
|
257783
|
+
const baselinePath = join50(resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), "..", "baselines", "before.json");
|
|
257678
257784
|
const baselineText = await readFile34(baselinePath, "utf8").catch(() => void 0);
|
|
257679
257785
|
const baseline = baselineText === void 0 ? void 0 : (() => {
|
|
257680
257786
|
try {
|
|
@@ -257685,9 +257791,10 @@ function registerExplain(program2, ctx) {
|
|
|
257685
257791
|
})();
|
|
257686
257792
|
const hasBaseline = baseline !== void 0 && sameBaselineTests(summary, baseline);
|
|
257687
257793
|
const never2 = agentNeverRan(summary), folded = never2 !== void 0 && !opts.all && opts.scene === void 0 && trial === void 0;
|
|
257688
|
-
const
|
|
257794
|
+
const readDirectory = projectTestDirectoryReader(ctx.io.cwd);
|
|
257795
|
+
const setupNext = invalidSetupNext(summary, nonDefaultOut(ctx.io.cwd, opts.out), readDirectory);
|
|
257689
257796
|
const hasToolDiagnosis = scenes.some((s3) => s3.trialsDetail.some((t) => (trial === void 0 || t.trial === trial) && t.diagnosis));
|
|
257690
|
-
const next2 = setupNext ?? (never2 !== void 0 ? retryCommands(summary, { out: nonDefaultOut(ctx.io.cwd, opts.out) }) : summary.source === "pytest" ? [] : summary.verdict === "pass" || summary.verdict === "ungraded" ? [] : hasBaseline ? ["fix the agent", nextComparisonRun(summary, opts.out)] : [`ancha baseline save before --from ${summary.runId}${out}${baselineText === void 0 ? "" : " --force"}`, "fix the agent", nextComparisonRun(summary, opts.out)]);
|
|
257797
|
+
const next2 = setupNext ?? (never2 !== void 0 ? retryCommands(summary, { out: nonDefaultOut(ctx.io.cwd, opts.out), readDirectory }) : summary.source === "pytest" ? [] : summary.verdict === "pass" || summary.verdict === "ungraded" ? [] : hasBaseline ? ["fix the agent", nextComparisonRun(summary, opts.out, readDirectory)] : [`ancha baseline save before --from ${summary.runId}${out}${baselineText === void 0 ? "" : " --force"}`, "fix the agent", nextComparisonRun(summary, opts.out, readDirectory)]);
|
|
257691
257798
|
ctx.out.result(
|
|
257692
257799
|
{
|
|
257693
257800
|
runId: summary.runId,
|
|
@@ -257720,13 +257827,13 @@ next: ${next2.join(", then ")}` : ""}`
|
|
|
257720
257827
|
});
|
|
257721
257828
|
program2.command("report").description("show the summary of a finished run again, or write its report page").argument("<run>", 'run id (run_\u2026 or run_cloud_\u2026) or "latest"').option("--out <dir>", "where run directories are (default: .ancha/runs)").option("--html", "write a self-contained offline report.html in the run directory").option("--open", "write report.html (as --html) and open it").action(async (ref23, opts) => {
|
|
257722
257829
|
if (ref23 === "latest") ref23 = await latestRunId(ctx.io.cwd, opts.out);
|
|
257723
|
-
const runsDir =
|
|
257830
|
+
const runsDir = resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR);
|
|
257724
257831
|
if (isCloudId(ref23)) await cachedCloudRun(ctx, ref23, runsDir);
|
|
257725
257832
|
const saved = await loadRunSummary(ctx.io.cwd, ref23, opts.out);
|
|
257726
|
-
const summary = await withAttemptToolDiagnostics(saved, join50(
|
|
257833
|
+
const summary = await withAttemptToolDiagnostics(saved, join50(resolve39(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), saved.runId));
|
|
257727
257834
|
if (opts.html || opts.open) {
|
|
257728
257835
|
const runDir = join50(runsDir, summary.runId), path9 = join50(runDir, "report.html");
|
|
257729
|
-
const folder2 =
|
|
257836
|
+
const folder2 = relative19(ctx.io.cwd, runDir) || ".";
|
|
257730
257837
|
const records6 = await readRunRecords(runDir, summary, { folder: folder2, secrets: await bundleSecrets({ cwd: ctx.io.cwd, env: ctx.io.env }) });
|
|
257731
257838
|
await writeFile23(path9, renderHtmlReport(reportData(summary, records6)));
|
|
257732
257839
|
const opened = opts.open === true && openBrowser(path9);
|
|
@@ -257740,7 +257847,7 @@ next: ${next2.join(", then ")}` : ""}`
|
|
|
257740
257847
|
// packages/cli/src/commands/replay.ts
|
|
257741
257848
|
init_src();
|
|
257742
257849
|
import { appendFileSync as appendFileSync2 } from "node:fs";
|
|
257743
|
-
import { join as join52, resolve as
|
|
257850
|
+
import { join as join52, resolve as resolve41 } from "node:path";
|
|
257744
257851
|
init_backend();
|
|
257745
257852
|
init_config();
|
|
257746
257853
|
|
|
@@ -257750,7 +257857,7 @@ init_report2();
|
|
|
257750
257857
|
init_run();
|
|
257751
257858
|
init_run_inputs();
|
|
257752
257859
|
import { readdir as readdir9, readFile as readFile35 } from "node:fs/promises";
|
|
257753
|
-
import { join as join51, resolve as
|
|
257860
|
+
import { join as join51, resolve as resolve40 } from "node:path";
|
|
257754
257861
|
var RUN_ID2 = /^[A-Za-z0-9_][\w.-]*$/;
|
|
257755
257862
|
var TRIAL_DIR = /^trial-[a-z0-9][a-z0-9_-]*-[1-9]\d*$/;
|
|
257756
257863
|
var HINT = "name an attempt as <run id or latest>/<trial directory>, as it appears under the runs directory, e.g. latest/trial-relay-1";
|
|
@@ -257768,7 +257875,7 @@ function firstDifference(recorded2, now11) {
|
|
|
257768
257875
|
return null;
|
|
257769
257876
|
}
|
|
257770
257877
|
async function loadReplayAttempt(cwd, ref23, out) {
|
|
257771
|
-
const runs =
|
|
257878
|
+
const runs = resolve40(cwd, out ?? DEFAULT_RUNS_DIR);
|
|
257772
257879
|
const slash = ref23.indexOf("/");
|
|
257773
257880
|
if (slash < 0) throw new AnchaError("USAGE", `${JSON.stringify(ref23)} is not an attempt`, { hint: HINT });
|
|
257774
257881
|
let runId2 = ref23.slice(0, slash);
|
|
@@ -257896,14 +258003,14 @@ function registerReplay(program2, ctx) {
|
|
|
257896
258003
|
throw new AnchaError("USAGE", `--people takes live or strict, not ${opts.people}`, { hint: "ancha replay latest/trial-<test>-1 --people strict" });
|
|
257897
258004
|
}
|
|
257898
258005
|
const runId2 = ref23.split("/")[0];
|
|
257899
|
-
if (/^run_cloud_/.test(runId2)) await cachedCloudRun(ctx, runId2,
|
|
258006
|
+
if (/^run_cloud_/.test(runId2)) await cachedCloudRun(ctx, runId2, resolve41(cwd, opts.out ?? DEFAULT_RUNS_DIR));
|
|
257900
258007
|
const attempt2 = await loadReplayAttempt(cwd, ref23, opts.out);
|
|
257901
258008
|
const config12 = await ctx.loadConfig();
|
|
257902
258009
|
const resolved = resolveRunAgent(config12, cwd, { ...opts.agent !== void 0 && { agent: opts.agent } });
|
|
257903
258010
|
const agent = withLocalEnvironment(resolved.agent, config12, { ...opts.passEnv !== void 0 && { passEnv: opts.passEnv }, ...opts.inheritEnv && { inheritEnv: true } });
|
|
257904
258011
|
if (opts.inheritEnv && agent.execution?.mode !== "container") ctx.out.info("warning: --inherit-env gives the agent this shell's whole environment, including any real credentials it holds");
|
|
257905
|
-
const outDir =
|
|
257906
|
-
agent.privatePaths = [
|
|
258012
|
+
const outDir = resolve41(cwd, opts.out ?? DEFAULT_RUNS_DIR);
|
|
258013
|
+
agent.privatePaths = [resolve41(cwd, ctx.globals().config ?? "ancha.yaml"), outDir];
|
|
257907
258014
|
validateAgentEnv(attempt2.scene, agent);
|
|
257908
258015
|
const choice5 = await worldServerChoice(ctx);
|
|
257909
258016
|
const hasPeople = (attempt2.scene.people?.length ?? 0) > 0;
|
|
@@ -257987,7 +258094,7 @@ init_report2();
|
|
|
257987
258094
|
init_run_store();
|
|
257988
258095
|
init_run_state();
|
|
257989
258096
|
import { readFile as readFile36 } from "node:fs/promises";
|
|
257990
|
-
import { join as join53, resolve as
|
|
258097
|
+
import { join as join53, resolve as resolve42 } from "node:path";
|
|
257991
258098
|
import { setTimeout as sleep13 } from "node:timers/promises";
|
|
257992
258099
|
function registerStatus(program2, ctx) {
|
|
257993
258100
|
program2.command("status").description("show a run's lifecycle: a foreground, detached or cloud run; without an id, the workspace's first steps and the next command").argument("[id]", 'run id (run_\u2026, run_cloud_\u2026) or "latest"').option("--out <dir>", "run directory (default: .ancha/runs)").option("--on <target>", "cloud: the workspace's first steps (the same as no id)").action(async (ref23, opts) => {
|
|
@@ -258007,7 +258114,7 @@ function registerStatus(program2, ctx) {
|
|
|
258007
258114
|
return;
|
|
258008
258115
|
}
|
|
258009
258116
|
const id15 = await resolveRunId(ctx.io.cwd, ref23, opts.out);
|
|
258010
|
-
const state3 = await readRunState(
|
|
258117
|
+
const state3 = await readRunState(resolve42(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), id15);
|
|
258011
258118
|
ctx.out.result(state3, () => `${state3.runId} ${state3.state} ${state3.completedTrials}/${state3.totalTrials}${state3.error ? `
|
|
258012
258119
|
${state3.error.message}` : ""}`);
|
|
258013
258120
|
if (terminal(state3) && state3.exitCode === void 0) ctx.exitCode = 3;
|
|
@@ -258024,7 +258131,7 @@ ${state3.error.message}` : ""}`);
|
|
|
258024
258131
|
let previous = "";
|
|
258025
258132
|
for (; ; ) {
|
|
258026
258133
|
if (signal.aborted) throw new AnchaError("USAGE", "wait interrupted; the run continues");
|
|
258027
|
-
const state3 = await readRunState(
|
|
258134
|
+
const state3 = await readRunState(resolve42(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR), id15);
|
|
258028
258135
|
if (terminal(state3)) {
|
|
258029
258136
|
if (state3.state === "finished") {
|
|
258030
258137
|
if (state3.error) ctx.out.error(new AnchaError(state3.error.code, state3.error.message));
|
|
@@ -258059,7 +258166,7 @@ hint: ${state3.upload.error.hint}` : ""}`);
|
|
|
258059
258166
|
ctx.exitCode = jobExitCode(await getJob(ws, ref23));
|
|
258060
258167
|
return;
|
|
258061
258168
|
}
|
|
258062
|
-
const outDir =
|
|
258169
|
+
const outDir = resolve42(ctx.io.cwd, opts.out ?? DEFAULT_RUNS_DIR);
|
|
258063
258170
|
const id15 = await resolveRunId(ctx.io.cwd, ref23, opts.out);
|
|
258064
258171
|
await readRunState(outDir, id15);
|
|
258065
258172
|
const log3 = join53(outDir, id15, "events.ndjson");
|
|
@@ -258094,7 +258201,7 @@ init_src();
|
|
|
258094
258201
|
init_src();
|
|
258095
258202
|
init_backend();
|
|
258096
258203
|
import { readFile as readFile37 } from "node:fs/promises";
|
|
258097
|
-
import { dirname as dirname21, join as join55, resolve as
|
|
258204
|
+
import { dirname as dirname21, join as join55, resolve as resolve43 } from "node:path";
|
|
258098
258205
|
init_config();
|
|
258099
258206
|
init_report2();
|
|
258100
258207
|
init_run();
|
|
@@ -258158,7 +258265,7 @@ function registerSimulate(sceneCommand, ctx) {
|
|
|
258158
258265
|
const config12 = await ctx.loadConfig();
|
|
258159
258266
|
let agent;
|
|
258160
258267
|
if (mode !== "world") {
|
|
258161
|
-
agent = withLocalEnvironment(resolveRunAgent(config12, ctx.io.cwd, { agent: await companionCommand(dirname21(
|
|
258268
|
+
agent = withLocalEnvironment(resolveRunAgent(config12, ctx.io.cwd, { agent: await companionCommand(dirname21(resolve43(ctx.io.cwd, loaded.path)), mode), parallel: 1 }).agent, config12);
|
|
258162
258269
|
}
|
|
258163
258270
|
const serverUrl3 = await configuredWorldServerUrl(ctx);
|
|
258164
258271
|
const backend = await openBackend({ ...serverUrl3 !== void 0 && { serverUrl: serverUrl3 } });
|
|
@@ -258193,7 +258300,7 @@ function registerSimulate(sceneCommand, ctx) {
|
|
|
258193
258300
|
...config12.judge?.model !== void 0 && { model: config12.judge.model },
|
|
258194
258301
|
...ctx.io.env.ANCHA_JUDGE_BASE_URL !== void 0 && { baseUrl: ctx.io.env.ANCHA_JUDGE_BASE_URL }
|
|
258195
258302
|
},
|
|
258196
|
-
outDir:
|
|
258303
|
+
outDir: resolve43(ctx.io.cwd, DEFAULT_RUNS_DIR),
|
|
258197
258304
|
inheritedEnv: ctx.io.env,
|
|
258198
258305
|
signal,
|
|
258199
258306
|
scenePaths: { [scene2.id]: loaded.path }
|
|
@@ -258465,7 +258572,7 @@ function valid(twin, seed44) {
|
|
|
258465
258572
|
return false;
|
|
258466
258573
|
}
|
|
258467
258574
|
}
|
|
258468
|
-
var
|
|
258575
|
+
var resolve44 = (node5, root3) => {
|
|
258469
258576
|
const ref23 = node5?.$ref;
|
|
258470
258577
|
if (typeof ref23 !== "string") return node5 ?? {};
|
|
258471
258578
|
if (ref23 === "#") return root3;
|
|
@@ -258473,14 +258580,14 @@ var resolve43 = (node5, root3) => {
|
|
|
258473
258580
|
return name5 === void 0 ? {} : root3.$defs?.[name5] ?? {};
|
|
258474
258581
|
};
|
|
258475
258582
|
function withoutDefaults(value6, node5, root3) {
|
|
258476
|
-
const schema4 =
|
|
258583
|
+
const schema4 = resolve44(node5, root3);
|
|
258477
258584
|
if (Array.isArray(value6)) return schema4.items === void 0 ? value6 : value6.map((item2) => withoutDefaults(item2, schema4.items, root3));
|
|
258478
258585
|
if (value6 === null || typeof value6 !== "object") return value6;
|
|
258479
258586
|
const properties3 = schema4.properties;
|
|
258480
258587
|
if (properties3 === void 0) return value6;
|
|
258481
258588
|
const out = {};
|
|
258482
258589
|
for (const [key5, item2] of Object.entries(value6)) {
|
|
258483
|
-
const property4 = properties3[key5] === void 0 ? void 0 :
|
|
258590
|
+
const property4 = properties3[key5] === void 0 ? void 0 : resolve44(properties3[key5], root3);
|
|
258484
258591
|
if (property4 !== void 0 && "default" in property4 && isDeepStrictEqual6(property4.default, item2)) continue;
|
|
258485
258592
|
out[key5] = property4 === void 0 ? item2 : withoutDefaults(item2, property4, root3);
|
|
258486
258593
|
}
|
|
@@ -258612,7 +258719,7 @@ var MAX_DEPTH3 = 4;
|
|
|
258612
258719
|
var clip2 = (text31, length) => text31.length > length ? `${text31.slice(0, length - 1)}\u2026` : text31;
|
|
258613
258720
|
var REF_USE = /^\^\\\$/;
|
|
258614
258721
|
function typeName(node5, root3, depth = 0) {
|
|
258615
|
-
const s3 =
|
|
258722
|
+
const s3 = resolve44(node5, root3);
|
|
258616
258723
|
if (depth > 4) return "object";
|
|
258617
258724
|
const variants = s3.anyOf ?? s3.oneOf;
|
|
258618
258725
|
if (variants) {
|
|
@@ -258649,13 +258756,13 @@ function typeName(node5, root3, depth = 0) {
|
|
|
258649
258756
|
}
|
|
258650
258757
|
}
|
|
258651
258758
|
function fieldLines(node5, root3, depth = 1) {
|
|
258652
|
-
const s3 =
|
|
258759
|
+
const s3 = resolve44(node5, root3);
|
|
258653
258760
|
const properties3 = s3.properties;
|
|
258654
258761
|
if (properties3 === void 0) return [];
|
|
258655
258762
|
const required6 = new Set(s3.required ?? []);
|
|
258656
258763
|
const rows35 = Object.entries(properties3).map(([name5, raw3]) => {
|
|
258657
|
-
const field6 =
|
|
258658
|
-
const items2 = field6.type === "array" && field6.items !== void 0 ?
|
|
258764
|
+
const field6 = resolve44(raw3, root3);
|
|
258765
|
+
const items2 = field6.type === "array" && field6.items !== void 0 ? resolve44(field6.items, root3) : void 0;
|
|
258659
258766
|
const nested = items2?.properties !== void 0 ? items2 : field6.properties !== void 0 ? field6 : void 0;
|
|
258660
258767
|
const description2 = typeof field6.description === "string" && !/^(Declares a ref|Globally unique declaration name|Reference to a declared ref)/.test(field6.description) ? field6.description : void 0;
|
|
258661
258768
|
const detail3 = [
|
|
@@ -259117,7 +259224,7 @@ function promptfooTest(test3, defaults4, used) {
|
|
|
259117
259224
|
};
|
|
259118
259225
|
}
|
|
259119
259226
|
function readCsv(raw3) {
|
|
259120
|
-
const
|
|
259227
|
+
const sep10 = /^sep=.\r?\n/i.exec(raw3), rows35 = csvRows2(sep10 ? raw3.slice(sep10[0].length) : raw3), notes7 = [];
|
|
259121
259228
|
const at6 = rows35.findIndex((row2) => row2.filter((cell18) => cell18.trim()).length >= 2);
|
|
259122
259229
|
if (at6 < 0) return void 0;
|
|
259123
259230
|
if (at6 > 0) notes7.push(`the header is row ${at6 + 1}; the ${at6 === 1 ? "row above it is a title" : `${at6} rows above it are titles`}`);
|
|
@@ -259553,7 +259660,7 @@ init_src();
|
|
|
259553
259660
|
import { createHash as createHash75 } from "node:crypto";
|
|
259554
259661
|
import { existsSync as existsSync2 } from "node:fs";
|
|
259555
259662
|
import { mkdir as mkdir23, readFile as readFile39, writeFile as writeFile24 } from "node:fs/promises";
|
|
259556
|
-
import { dirname as dirname22, join as join56, relative as
|
|
259663
|
+
import { dirname as dirname22, join as join56, relative as relative20, resolve as resolve45 } from "node:path";
|
|
259557
259664
|
async function model(ctx) {
|
|
259558
259665
|
const env2 = ctx.io.env;
|
|
259559
259666
|
if (env2.ANCHA_PEOPLE_BASE_URL && env2.ANCHA_PEOPLE_API_KEY) return { client: gen_exports.openRouterClient({ apiKey: env2.ANCHA_PEOPLE_API_KEY, baseUrl: env2.ANCHA_PEOPLE_BASE_URL, relay: true }), credit: "own" };
|
|
@@ -259583,7 +259690,7 @@ async function worldGenDataset(ctx, options5, description2) {
|
|
|
259583
259690
|
if (!["s", "m", "l"].includes(size2)) throw new AnchaError("USAGE", `--size must be s, m or l, got ${JSON.stringify(options5.size)}`, { hint: "e.g. --size s" });
|
|
259584
259691
|
const id15 = options5.id ?? `netsuite-pe-${size2}`;
|
|
259585
259692
|
if (!/^[a-z0-9-]+$/.test(id15)) throw new AnchaError("USAGE", "--id must match [a-z0-9-]+", { hint: "e.g. --id portfolio-books" });
|
|
259586
|
-
const outDir =
|
|
259693
|
+
const outDir = resolve45(ctx.io.cwd, options5.out ?? "ancha/worlds"), worldPath = join56(outDir, `${id15}.yaml`), evalsPath = join56(dirname22(outDir), "evals", `${id15}.jsonl`);
|
|
259587
259694
|
const taken2 = [worldPath, evalsPath].find((path9) => existsSync2(path9));
|
|
259588
259695
|
if (taken2 && !options5.force) throw exists4(taken2, ctx);
|
|
259589
259696
|
const { world: world5, evals, counts: counts2 } = generateNetsuitePe({ size: size2, id: id15, startTime: NETSUITE_PE_START_TIME });
|
|
@@ -259591,7 +259698,7 @@ async function worldGenDataset(ctx, options5, description2) {
|
|
|
259591
259698
|
await mkdir23(dirname22(evalsPath), { recursive: true });
|
|
259592
259699
|
await writeFile24(worldPath, worldFileYaml(world5));
|
|
259593
259700
|
await writeFile24(evalsPath, netsuitePeJsonl(evals));
|
|
259594
|
-
const rel = (path9) =>
|
|
259701
|
+
const rel = (path9) => relative20(ctx.io.cwd, path9) || ".";
|
|
259595
259702
|
const result = {
|
|
259596
259703
|
workspace: `local:${ctx.io.cwd}`,
|
|
259597
259704
|
dataset: `netsuite-pe@${NETSUITE_PE_VERSION}`,
|
|
@@ -259618,15 +259725,15 @@ async function worldGen(ctx, description2, options5) {
|
|
|
259618
259725
|
const tools2 = options5.tools?.split(",").map((tool) => tool.trim()).filter(Boolean);
|
|
259619
259726
|
if (tools2) gen_exports.assertGeneratedTools(tools2);
|
|
259620
259727
|
if (options5.id !== void 0 && !/^[a-z0-9-]+$/.test(options5.id)) throw new AnchaError("USAGE", "--id must match [a-z0-9-]+", { hint: "e.g. --id acme-support" });
|
|
259621
|
-
const outDir =
|
|
259728
|
+
const outDir = resolve45(ctx.io.cwd, options5.out ?? "ancha/worlds");
|
|
259622
259729
|
const request2 = { description: description2, id: options5.id ?? null, tools: tools2 ?? null, size: size2, variants, from: options5.from ?? null };
|
|
259623
259730
|
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join56(ctx.io.cwd, ".ancha", "world-gen", `${createHash75("sha256").update(options5.idempotencyKey).digest("hex").slice(0, 32)}.json`);
|
|
259624
259731
|
if (keyFile && existsSync2(keyFile)) {
|
|
259625
259732
|
const saved = JSON.parse(await readFile39(keyFile, "utf8"));
|
|
259626
259733
|
if (JSON.stringify(saved.request) !== JSON.stringify(request2)) throw new AnchaError("USAGE", "this --idempotency-key was used with different arguments", { hint: "use a new key for a new request" });
|
|
259627
|
-
if (saved.result.files.every((file3) => existsSync2(
|
|
259734
|
+
if (saved.result.files.every((file3) => existsSync2(resolve45(ctx.io.cwd, file3)))) return report5(ctx, { ...saved.result, reused: true });
|
|
259628
259735
|
}
|
|
259629
|
-
const from = options5.from === void 0 ? void 0 : parseWorldFile((0, import_yaml15.parse)(await readFile39(
|
|
259736
|
+
const from = options5.from === void 0 ? void 0 : parseWorldFile((0, import_yaml15.parse)(await readFile39(resolve45(ctx.io.cwd, options5.from), "utf8")));
|
|
259630
259737
|
if (options5.id && !options5.force && existsSync2(join56(outDir, `${options5.id}.yaml`))) throw exists4(join56(outDir, `${options5.id}.yaml`), ctx);
|
|
259631
259738
|
const { client: client2, credit } = await model(ctx);
|
|
259632
259739
|
ctx.out.info(`generating a world from the description (size ${size2}${variants ? `, ${variants} variant${variants === 1 ? "" : "s"}` : ""})`);
|
|
@@ -259645,7 +259752,7 @@ async function worldGen(ctx, description2, options5) {
|
|
|
259645
259752
|
if (taken2 && !options5.force) throw exists4(taken2, ctx);
|
|
259646
259753
|
await mkdir23(outDir, { recursive: true });
|
|
259647
259754
|
for (const [name5, text31] of Object.entries(generated.files)) await writeFile24(join56(outDir, name5), text31);
|
|
259648
|
-
const rel = (path9) =>
|
|
259755
|
+
const rel = (path9) => relative20(ctx.io.cwd, path9) || ".";
|
|
259649
259756
|
const worldPath = rel(join56(outDir, `${generated.world.id}.yaml`));
|
|
259650
259757
|
const result = {
|
|
259651
259758
|
workspace: `local:${ctx.io.cwd}`,
|
|
@@ -259671,7 +259778,7 @@ async function worldGen(ctx, description2, options5) {
|
|
|
259671
259778
|
return report5(ctx, result);
|
|
259672
259779
|
}
|
|
259673
259780
|
function exists4(path9, ctx) {
|
|
259674
|
-
return new AnchaError("USAGE", `${
|
|
259781
|
+
return new AnchaError("USAGE", `${relative20(ctx.io.cwd, path9)} already exists`, { hint: "pass --force to overwrite it, or --id <another id>" });
|
|
259675
259782
|
}
|
|
259676
259783
|
function report5(ctx, result) {
|
|
259677
259784
|
ctx.out.result(result, () => [
|
|
@@ -259687,7 +259794,7 @@ var import_yaml17 = __toESM(require_dist(), 1);
|
|
|
259687
259794
|
import { createHash as createHash77 } from "node:crypto";
|
|
259688
259795
|
import { existsSync as existsSync3 } from "node:fs";
|
|
259689
259796
|
import { mkdir as mkdir24, readFile as readFile40, readdir as readdir10, writeFile as writeFile25 } from "node:fs/promises";
|
|
259690
|
-
import { join as join57, relative as
|
|
259797
|
+
import { join as join57, relative as relative21, resolve as resolve46 } from "node:path";
|
|
259691
259798
|
init_src();
|
|
259692
259799
|
|
|
259693
259800
|
// backend/src/kit/test-draft.ts
|
|
@@ -260083,7 +260190,7 @@ async function draftingModel(ctx) {
|
|
|
260083
260190
|
throw new AnchaError("CONFIG_INVALID", "test new needs a model key", { hint: "set OPENROUTER_API_KEY, or log in to your workspace with ancha login, then run the same command again" });
|
|
260084
260191
|
}
|
|
260085
260192
|
async function chooseWorld(ctx, id15, command = 'ancha test new "<sentence>"') {
|
|
260086
|
-
const dir2 =
|
|
260193
|
+
const dir2 = resolve46(ctx.io.cwd, "ancha/worlds");
|
|
260087
260194
|
const ids3 = (await readdir10(dir2).catch(() => [])).filter((name5) => /^[a-z0-9][a-z0-9-]*\.yaml$/.test(name5)).map((name5) => name5.slice(0, -5)).sort();
|
|
260088
260195
|
const chosen = id15 ?? (ids3.length === 1 ? ids3[0] : void 0);
|
|
260089
260196
|
const scene2 = ids3.length === 0 ? (await glob3(["scenes/**/scene.yaml", "scene.yaml"], { cwd: ctx.io.cwd, onlyFiles: true, followSymbolicLinks: false })).sort()[0] : void 0;
|
|
@@ -260127,13 +260234,13 @@ async function testNew(ctx, intent, options5) {
|
|
|
260127
260234
|
if (!intent.trim()) throw new AnchaError("USAGE", "describe the test in one sentence", { hint: `ancha test new "Laura reports empty exports; the agent gets Ben's workaround to her"` });
|
|
260128
260235
|
if (options5.id !== void 0 && !/^[a-z0-9-]+$/.test(options5.id)) throw new AnchaError("USAGE", "--id must match [a-z0-9-]+", { hint: "e.g. --id export-bug" });
|
|
260129
260236
|
const world5 = await chooseWorld(ctx, options5.world);
|
|
260130
|
-
const outDir =
|
|
260131
|
-
const request2 = { intent, world: world5.id, id: options5.id ?? null, out:
|
|
260237
|
+
const outDir = resolve46(ctx.io.cwd, options5.out ?? "ancha/tests");
|
|
260238
|
+
const request2 = { intent, world: world5.id, id: options5.id ?? null, out: relative21(ctx.io.cwd, outDir) };
|
|
260132
260239
|
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join57(ctx.io.cwd, ".ancha", "test-new", `${createHash77("sha256").update(options5.idempotencyKey).digest("hex").slice(0, 32)}.json`);
|
|
260133
260240
|
if (keyFile && existsSync3(keyFile)) {
|
|
260134
260241
|
const saved = JSON.parse(await readFile40(keyFile, "utf8"));
|
|
260135
260242
|
if (JSON.stringify(saved.request) !== JSON.stringify(request2)) throw new AnchaError("USAGE", "this --idempotency-key was used with different arguments", { hint: "use a new key for a new request" });
|
|
260136
|
-
if ([saved.result.file, saved.result.record].every((file4) => existsSync3(
|
|
260243
|
+
if ([saved.result.file, saved.result.record].every((file4) => existsSync3(resolve46(ctx.io.cwd, file4)))) return report6(ctx, { ...saved.result, reused: true });
|
|
260137
260244
|
}
|
|
260138
260245
|
if (options5.id && !options5.force && existsSync3(join57(outDir, `${options5.id}.yaml`))) throw exists5(ctx, join57(outDir, `${options5.id}.yaml`));
|
|
260139
260246
|
const { client: client2, credit } = await draftingModel(ctx);
|
|
@@ -260149,12 +260256,12 @@ async function testNew(ctx, intent, options5) {
|
|
|
260149
260256
|
await writeFile25(path9, yaml);
|
|
260150
260257
|
await writeFile25(recordPath, `${JSON.stringify({ generated: { by: "ancha test new", at: at6 }, request: { intent, world: world5.id }, prompt: draft2.prompt, calls: draft2.calls, cost_usd: cost }, null, 2)}
|
|
260151
260258
|
`);
|
|
260152
|
-
const file3 =
|
|
260259
|
+
const file3 = relative21(ctx.io.cwd, path9);
|
|
260153
260260
|
const people4 = [...new Set((draft2.test.checks ?? []).flatMap((check4) => JSON.stringify(check4).match(/"(?:to|from)":"([a-z][a-z0-9_-]*)"|\[\s*"([a-z][a-z0-9_-]*)"/g) ?? []).map((match3) => match3.replace(/^.*"([a-z][a-z0-9_-]*)"$/, "$1")))].filter((ref23) => (world5.people ?? []).some((person5) => person5.ref === ref23));
|
|
260154
260261
|
const result = {
|
|
260155
260262
|
id: draft2.test.id,
|
|
260156
260263
|
file: file3,
|
|
260157
|
-
record:
|
|
260264
|
+
record: relative21(ctx.io.cwd, recordPath),
|
|
260158
260265
|
world: world5.id,
|
|
260159
260266
|
checks: (draft2.test.checks ?? []).map((check4) => String(check4.id)),
|
|
260160
260267
|
people: people4,
|
|
@@ -260173,7 +260280,7 @@ async function testNew(ctx, intent, options5) {
|
|
|
260173
260280
|
return report6(ctx, result);
|
|
260174
260281
|
}
|
|
260175
260282
|
function exists5(ctx, path9) {
|
|
260176
|
-
return new AnchaError("USAGE", `${
|
|
260283
|
+
return new AnchaError("USAGE", `${relative21(ctx.io.cwd, path9)} already exists`, { hint: "pass --force to replace it, or --id <another-id>" });
|
|
260177
260284
|
}
|
|
260178
260285
|
function report6(ctx, result) {
|
|
260179
260286
|
ctx.out.result(result, () => [
|
|
@@ -260831,7 +260938,7 @@ function registerServe(program2, ctx) {
|
|
|
260831
260938
|
program2.command("serve").description("start the Ancha server and run until SIGINT/SIGTERM").addOption(new Option("--port <n>", "port to listen on, 0 for any free port").default(DEFAULT_PORT).argParser(parsePort)).option("--host <host>", "address to bind", DEFAULT_HOST).option("--public-url <url>", "advertised HTTP loopback origin (match the Docker host port)").action(async (opts) => {
|
|
260832
260939
|
const server = await startServer({ mcp: mcpTwins, port: opts.port, host: opts.host, ...opts.publicUrl === void 0 ? {} : { publicUrl: opts.publicUrl } });
|
|
260833
260940
|
let stop;
|
|
260834
|
-
const stopped = new Promise((
|
|
260941
|
+
const stopped = new Promise((resolve63) => stop = resolve63);
|
|
260835
260942
|
const abort = ctx.io.abort;
|
|
260836
260943
|
process.once("SIGINT", stop);
|
|
260837
260944
|
process.once("SIGTERM", stop);
|
|
@@ -260889,7 +260996,7 @@ ${conformanceLine(conformance)}` : "")
|
|
|
260889
260996
|
|
|
260890
260997
|
// packages/cli/src/commands/ui.ts
|
|
260891
260998
|
init_backend();
|
|
260892
|
-
import { resolve as
|
|
260999
|
+
import { resolve as resolve47 } from "node:path";
|
|
260893
261000
|
|
|
260894
261001
|
// backend/src/console/run-list.ts
|
|
260895
261002
|
var pick5 = (value6, keys7) => Object.fromEntries(keys7.filter((key5) => value6[key5] !== void 0).map((key5) => [key5, value6[key5]]));
|
|
@@ -260972,7 +261079,7 @@ async function suggestAgentProject(path9) {
|
|
|
260972
261079
|
}
|
|
260973
261080
|
|
|
260974
261081
|
// backend/src/execution/connection.ts
|
|
260975
|
-
import { realpathSync as
|
|
261082
|
+
import { realpathSync as realpathSync3 } from "node:fs";
|
|
260976
261083
|
init_src();
|
|
260977
261084
|
import { randomUUID as randomUUID20 } from "node:crypto";
|
|
260978
261085
|
import { mkdir as mkdir28, rm as rm16, writeFile as writeFile29 } from "node:fs/promises";
|
|
@@ -261001,9 +261108,9 @@ async function runtimeCacheKey(source, project14, command, context3) {
|
|
|
261001
261108
|
const hash10 = createHash78("sha256").update(JSON.stringify(["verified-runtime-v1", await realpath13(project14), command, context3]));
|
|
261002
261109
|
async function visit4(path9, prefix2 = "") {
|
|
261003
261110
|
for (const entry3 of (await readdir11(path9, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
261004
|
-
const
|
|
261005
|
-
if (entry3.isDirectory()) await visit4(join59(path9, entry3.name),
|
|
261006
|
-
else hash10.update(
|
|
261111
|
+
const relative31 = prefix2 + entry3.name;
|
|
261112
|
+
if (entry3.isDirectory()) await visit4(join59(path9, entry3.name), relative31 + "/");
|
|
261113
|
+
else hash10.update(relative31).update("\0").update(await readFile43(join59(path9, entry3.name))).update("\0");
|
|
261007
261114
|
}
|
|
261008
261115
|
}
|
|
261009
261116
|
await visit4(source);
|
|
@@ -261086,8 +261193,8 @@ WORKDIR /workspace
|
|
|
261086
261193
|
async function docker2(args, context3, signal, progress2) {
|
|
261087
261194
|
const env2 = { ...Object.fromEntries(["PATH", "HOME", "TMPDIR"].flatMap((key5) => process.env[key5] ? [[key5, process.env[key5]]] : [])), BUILDKIT_PROGRESS: "plain" };
|
|
261088
261195
|
try {
|
|
261089
|
-
return await new Promise((
|
|
261090
|
-
const child3 = execFile9("docker", ["--context", context3, ...args], { env: env2, timeout: args[0] === "build" ? 6e5 : 15e3, maxBuffer: 8e6, ...signal && { signal } }, (error65, stdout) => error65 ? reject4(error65) :
|
|
261196
|
+
return await new Promise((resolve63, reject4) => {
|
|
261197
|
+
const child3 = execFile9("docker", ["--context", context3, ...args], { env: env2, timeout: args[0] === "build" ? 6e5 : 15e3, maxBuffer: 8e6, ...signal && { signal } }, (error65, stdout) => error65 ? reject4(error65) : resolve63(stdout));
|
|
261091
261198
|
let pending = "", last = "";
|
|
261092
261199
|
child3.stderr?.on("data", (chunk) => {
|
|
261093
261200
|
pending = (pending + String(chunk)).slice(-8192);
|
|
@@ -261169,9 +261276,9 @@ async function prepareAgent(workspace4, agentId2, options5 = {}) {
|
|
|
261169
261276
|
const digest5 = createHash79("sha256").update("ancha-image-v2").update(runtime2.context).update(plan4.dockerfile);
|
|
261170
261277
|
async function hashTree(path9, prefix2 = "") {
|
|
261171
261278
|
for (const entry3 of (await readdir12(path9, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
261172
|
-
const
|
|
261173
|
-
if (entry3.isDirectory()) await hashTree(join60(path9, entry3.name),
|
|
261174
|
-
else digest5.update(
|
|
261279
|
+
const relative31 = prefix2 + entry3.name;
|
|
261280
|
+
if (entry3.isDirectory()) await hashTree(join60(path9, entry3.name), relative31 + "/");
|
|
261281
|
+
else digest5.update(relative31).update("\0").update(await readFile44(join60(path9, entry3.name))).update("\0");
|
|
261175
261282
|
}
|
|
261176
261283
|
}
|
|
261177
261284
|
await hashTree(source);
|
|
@@ -261261,7 +261368,7 @@ async function probeAgentConnection(agent, signal, progress2, inheritedEnv = pro
|
|
|
261261
261368
|
const containers = [];
|
|
261262
261369
|
const children3 = /* @__PURE__ */ new Set();
|
|
261263
261370
|
function docker3(args, body8, cleanup = false, timeout = 3e4) {
|
|
261264
|
-
return new Promise((
|
|
261371
|
+
return new Promise((resolve63, reject4) => {
|
|
261265
261372
|
const child3 = spawn6("docker", ["--context", runtime2.context, ...args], { env: env2, stdio: ["pipe", "pipe", "pipe"], ...cleanup ? {} : { signal } });
|
|
261266
261373
|
children3.add(child3);
|
|
261267
261374
|
let output2 = "", settled = false;
|
|
@@ -261281,7 +261388,7 @@ async function probeAgentConnection(agent, signal, progress2, inheritedEnv = pro
|
|
|
261281
261388
|
clearTimeout(timer);
|
|
261282
261389
|
children3.delete(child3);
|
|
261283
261390
|
if (error65 || code5 !== 0) reject4(new AnchaError("AGENT_UNREACHABLE", "The agent could not start in its playground. Check the launch command, dependencies and required environment variables.", { cause: new Error(`Connection controller step: ${args[0]}`) }));
|
|
261284
|
-
else
|
|
261391
|
+
else resolve63(output2.trim());
|
|
261285
261392
|
};
|
|
261286
261393
|
child3.on("error", (error65) => finish2(error65));
|
|
261287
261394
|
child3.on("close", (code5) => finish2(void 0, code5));
|
|
@@ -261304,11 +261411,11 @@ async function probeAgentConnection(agent, signal, progress2, inheritedEnv = pro
|
|
|
261304
261411
|
children3.add(archive);
|
|
261305
261412
|
archive.stderr.on("data", () => {
|
|
261306
261413
|
});
|
|
261307
|
-
const archived = new Promise((
|
|
261414
|
+
const archived = new Promise((resolve63, reject4) => {
|
|
261308
261415
|
archive.once("error", reject4);
|
|
261309
261416
|
archive.once("close", (code5) => {
|
|
261310
261417
|
children3.delete(archive);
|
|
261311
|
-
code5 === 0 ?
|
|
261418
|
+
code5 === 0 ? resolve63() : reject4(new AnchaError("AGENT_UNREACHABLE", "Agent files could not be copied into the playground."));
|
|
261312
261419
|
});
|
|
261313
261420
|
});
|
|
261314
261421
|
await Promise.all([docker3(["exec", "-i", "--user", "root", id15, "tar", "--no-same-owner", "--no-same-permissions", "-xf", "-", "-C", "/workspace"], archive.stdout), archived]);
|
|
@@ -261387,7 +261494,7 @@ var AgentConnectionService = class {
|
|
|
261387
261494
|
store;
|
|
261388
261495
|
owned = /* @__PURE__ */ new Set();
|
|
261389
261496
|
constructor(workspace4, dependencies = {}) {
|
|
261390
|
-
this.workspace =
|
|
261497
|
+
this.workspace = realpathSync3(workspace4);
|
|
261391
261498
|
this.dependencies = dependencies;
|
|
261392
261499
|
this.store = new PlaygroundStore(this.workspace);
|
|
261393
261500
|
}
|
|
@@ -261516,7 +261623,7 @@ var AgentConnectionService = class {
|
|
|
261516
261623
|
async whenRunnerFree(value6, controller, provider) {
|
|
261517
261624
|
const request2 = `${this.path(value6.agentId)}.cancel`;
|
|
261518
261625
|
while (!controller.signal.aborted) {
|
|
261519
|
-
await new Promise((
|
|
261626
|
+
await new Promise((resolve63) => setTimeout(resolve63, this.dependencies.queuePollMs ?? 1e3));
|
|
261520
261627
|
if (await safeRead(this.workspace, request2, 200).catch(() => void 0) === value6.id) {
|
|
261521
261628
|
controller.abort();
|
|
261522
261629
|
break;
|
|
@@ -261647,7 +261754,7 @@ init_assets();
|
|
|
261647
261754
|
import { createServer as createServer6 } from "node:http";
|
|
261648
261755
|
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
261649
261756
|
import { readFile as readFile45, realpath as realpath14, stat as stat15 } from "node:fs/promises";
|
|
261650
|
-
import { isAbsolute as
|
|
261757
|
+
import { isAbsolute as isAbsolute12 } from "node:path";
|
|
261651
261758
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
261652
261759
|
|
|
261653
261760
|
// backend/src/console/jobs.ts
|
|
@@ -262254,11 +262361,11 @@ var FsRunFiles = class {
|
|
|
262254
262361
|
}
|
|
262255
262362
|
}
|
|
262256
262363
|
async tail(runId2, path9, bytes4) {
|
|
262257
|
-
const
|
|
262258
|
-
await preflightFiles(this.workspace, [{ relativePath:
|
|
262364
|
+
const relative31 = `.ancha/runs/${runId2}/${path9}`;
|
|
262365
|
+
await preflightFiles(this.workspace, [{ relativePath: relative31, content: "" }]);
|
|
262259
262366
|
let handle31;
|
|
262260
262367
|
try {
|
|
262261
|
-
handle31 = await open12(join64(this.workspace,
|
|
262368
|
+
handle31 = await open12(join64(this.workspace, relative31), "r");
|
|
262262
262369
|
} catch (error65) {
|
|
262263
262370
|
if (error65.code === "ENOENT") return void 0;
|
|
262264
262371
|
throw error65;
|
|
@@ -263132,7 +263239,7 @@ async function startConsole(opts) {
|
|
|
263132
263239
|
const selected3 = await (opts.pickFolder ?? pickMacFolder)(selection2.signal);
|
|
263133
263240
|
let path9 = null;
|
|
263134
263241
|
if (selected3 !== null && !selection2.signal.aborted) {
|
|
263135
|
-
if (!
|
|
263242
|
+
if (!isAbsolute12(selected3)) throw new AnchaError("USAGE", "Select an absolute folder path.");
|
|
263136
263243
|
path9 = await realpath14(selected3).catch(() => {
|
|
263137
263244
|
throw new AnchaError("USAGE", "The selected folder is no longer available.");
|
|
263138
263245
|
});
|
|
@@ -263444,9 +263551,9 @@ async function startConsole(opts) {
|
|
|
263444
263551
|
}
|
|
263445
263552
|
});
|
|
263446
263553
|
try {
|
|
263447
|
-
await new Promise((
|
|
263554
|
+
await new Promise((resolve63, reject4) => {
|
|
263448
263555
|
server.once("error", reject4);
|
|
263449
|
-
server.listen(opts.port ?? 4401, "127.0.0.1",
|
|
263556
|
+
server.listen(opts.port ?? 4401, "127.0.0.1", resolve63);
|
|
263450
263557
|
});
|
|
263451
263558
|
} catch (error65) {
|
|
263452
263559
|
await connections4.close();
|
|
@@ -263467,7 +263574,7 @@ async function startConsole(opts) {
|
|
|
263467
263574
|
await playgrounds.close();
|
|
263468
263575
|
await jobs.close();
|
|
263469
263576
|
await sandboxes.close();
|
|
263470
|
-
await new Promise((
|
|
263577
|
+
await new Promise((resolve63, reject4) => server.close((e) => e ? reject4(e) : resolve63()));
|
|
263471
263578
|
if (!opts.backend) await backend.close();
|
|
263472
263579
|
} };
|
|
263473
263580
|
}
|
|
@@ -263483,13 +263590,13 @@ function registerUI(program2, ctx) {
|
|
|
263483
263590
|
return n2;
|
|
263484
263591
|
}, 4401).option("--workspace <path>", "workspace containing scenarios and results", ".").action(async (opts) => {
|
|
263485
263592
|
const backend = ctx.globals().serverUrl ? await openBackend({ serverUrl: ctx.globals().serverUrl }) : void 0;
|
|
263486
|
-
const console2 = await startConsole({ workspace:
|
|
263593
|
+
const console2 = await startConsole({ workspace: resolve47(ctx.io.cwd, opts.workspace), port: opts.port, configPath: ctx.globals().config, backend, version: CLI_VERSION }).catch(async (error65) => {
|
|
263487
263594
|
await backend?.close();
|
|
263488
263595
|
throw error65;
|
|
263489
263596
|
});
|
|
263490
263597
|
let stop;
|
|
263491
|
-
const stopped = new Promise((
|
|
263492
|
-
stop =
|
|
263598
|
+
const stopped = new Promise((resolve63) => {
|
|
263599
|
+
stop = resolve63;
|
|
263493
263600
|
});
|
|
263494
263601
|
process.once("SIGINT", stop);
|
|
263495
263602
|
process.once("SIGTERM", stop);
|
|
@@ -263634,7 +263741,7 @@ init_scenes();
|
|
|
263634
263741
|
import { createHash as createHash84 } from "node:crypto";
|
|
263635
263742
|
import { constants as constants13 } from "node:fs";
|
|
263636
263743
|
import { link as link8, lstat as lstat12, mkdir as mkdir30, mkdtemp as mkdtemp12, open as open13, readFile as readFile47, readdir as readdir16, rename as rename11, rm as rm20, rmdir, unlink as unlink2, writeFile as writeFile32 } from "node:fs/promises";
|
|
263637
|
-
import { dirname as dirname24, join as join67, relative as
|
|
263744
|
+
import { dirname as dirname24, join as join67, relative as relative22, resolve as resolve48 } from "node:path";
|
|
263638
263745
|
var sha2567 = (bytes4) => createHash84("sha256").update(bytes4).digest("hex");
|
|
263639
263746
|
var KEY_ORDER = ["version", "id", "title", "variant", "start", "attempts", "deadline", "timeout", "until", "checks", "pass", "world"];
|
|
263640
263747
|
var ordered4 = (test3) => Object.fromEntries([...KEY_ORDER.filter((key5) => key5 in test3), ...Object.keys(test3).filter((key5) => !KEY_ORDER.includes(key5)).sort()].map((key5) => [key5, test3[key5]]));
|
|
@@ -263793,7 +263900,7 @@ async function mergeManifest(path9, next2) {
|
|
|
263793
263900
|
}
|
|
263794
263901
|
async function varyTestFiles(cwd, path9, options5 = {}, dependencies = {}) {
|
|
263795
263902
|
const resolved = resolveVaryOptions(options5);
|
|
263796
|
-
const source =
|
|
263903
|
+
const source = resolve48(cwd, path9);
|
|
263797
263904
|
let test3;
|
|
263798
263905
|
try {
|
|
263799
263906
|
test3 = parseSceneYaml(await readFile47(source, "utf8"));
|
|
@@ -263804,13 +263911,13 @@ async function varyTestFiles(cwd, path9, options5 = {}, dependencies = {}) {
|
|
|
263804
263911
|
if (!isTestFile(test3)) throw new AnchaError("CONFIG_INVALID", `${path9}: test vary needs a version 2 test`, { hint: "write a version: 2 test with start, world and checks; see `ancha docs tests` and `ancha schema test`" });
|
|
263805
263912
|
const loaded = await loadSceneOrTest(cwd, source);
|
|
263806
263913
|
const parent3 = {
|
|
263807
|
-
path:
|
|
263914
|
+
path: relative22(cwd, source),
|
|
263808
263915
|
test: test3,
|
|
263809
263916
|
fingerprint: sceneFingerprint(loaded.scene),
|
|
263810
263917
|
...loaded.world ? { world: parseSceneYaml(await readFile47(loaded.world, "utf8")) } : {}
|
|
263811
263918
|
};
|
|
263812
|
-
const out = options5.out === void 0 ? dirname24(source) :
|
|
263813
|
-
const keyPath = options5.idempotencyKey === void 0 ? void 0 : join67(
|
|
263919
|
+
const out = options5.out === void 0 ? dirname24(source) : resolve48(cwd, options5.out);
|
|
263920
|
+
const keyPath = options5.idempotencyKey === void 0 ? void 0 : join67(resolve48(cwd), ".ancha", "test-variation", `${sha2567(options5.idempotencyKey)}.json`);
|
|
263814
263921
|
const inputHash = sceneFingerprint({ parent: parent3, options: resolved, out });
|
|
263815
263922
|
const keyConflict = () => new AnchaError("USAGE", "this idempotency key is already bound to different inputs or options", { hint: "repeat the original request, or choose another --idempotency-key" });
|
|
263816
263923
|
if (keyPath) {
|
|
@@ -263844,20 +263951,20 @@ async function varyTestFiles(cwd, path9, options5 = {}, dependencies = {}) {
|
|
|
263844
263951
|
for (const item2 of prepared) {
|
|
263845
263952
|
const file3 = join67(out, item2.variant.file);
|
|
263846
263953
|
const status6 = options5.dryRun ? "planned" : await createExclusive(file3, item2.bytes);
|
|
263847
|
-
if (!options5.dryRun && sceneFingerprint((await loadSceneOrTest(cwd, file3)).scene) !== item2.fingerprint) throw invalid40(`${
|
|
263954
|
+
if (!options5.dryRun && sceneFingerprint((await loadSceneOrTest(cwd, file3)).scene) !== item2.fingerprint) throw invalid40(`${relative22(cwd, file3)}: loading the written test changed its fingerprint`);
|
|
263848
263955
|
const { ordinal: ordinal2, kind: kind2, change: change4 } = item2.variant.block;
|
|
263849
|
-
variants.push({ ordinal: ordinal2, kind: kind2, change: change4, file:
|
|
263956
|
+
variants.push({ ordinal: ordinal2, kind: kind2, change: change4, file: relative22(cwd, file3), status: status6 });
|
|
263850
263957
|
}
|
|
263851
263958
|
if (!options5.dryRun) await atomicRecord(manifestPath, JSON.stringify(await mergeManifest(manifestPath, manifest2), null, 2) + "\n");
|
|
263852
263959
|
const quote6 = (value6) => `'${value6.replaceAll("'", "'\\''")}'`;
|
|
263853
263960
|
const prefix2 = `${plan4.parent.id}-v-`, mine = new Set(prepared.map((item2) => item2.variant.file));
|
|
263854
263961
|
const siblings = options5.dryRun ? [] : (await readdir16(out)).filter((name5) => name5.startsWith(prefix2) && name5.endsWith(".yaml"));
|
|
263855
263962
|
const onlyMine = !options5.dryRun && siblings.length === mine.size && siblings.every((name5) => mine.has(name5));
|
|
263856
|
-
const selection2 = variants.length === 1 ? quote6(variants[0].file) : onlyMine ? `${
|
|
263963
|
+
const selection2 = variants.length === 1 ? quote6(variants[0].file) : onlyMine ? `${relative22(cwd, out) || "."}/${prefix2}*.yaml` : `${quote6((relative22(cwd, out) || ".") + "/")}{${prepared.map((item2) => item2.variant.file).join(",")}}`;
|
|
263857
263964
|
const next2 = [`ancha run ${selection2}`];
|
|
263858
263965
|
return {
|
|
263859
263966
|
version: 1,
|
|
263860
|
-
workspace: `local:${
|
|
263967
|
+
workspace: `local:${resolve48(cwd)}`,
|
|
263861
263968
|
parent: plan4.parent,
|
|
263862
263969
|
suite: plan4.suite,
|
|
263863
263970
|
seed: plan4.seed,
|
|
@@ -263867,7 +263974,7 @@ async function varyTestFiles(cwd, path9, options5 = {}, dependencies = {}) {
|
|
|
263867
263974
|
dryRun: options5.dryRun ?? false,
|
|
263868
263975
|
modelCalls: 0,
|
|
263869
263976
|
costUsd: 0,
|
|
263870
|
-
manifest:
|
|
263977
|
+
manifest: relative22(cwd, manifestPath),
|
|
263871
263978
|
variants,
|
|
263872
263979
|
next: next2
|
|
263873
263980
|
};
|
|
@@ -263895,7 +264002,7 @@ function registerTestVary(tests, ctx, dependencies = {}) {
|
|
|
263895
264002
|
}
|
|
263896
264003
|
|
|
263897
264004
|
// packages/cli/src/commands/agent.ts
|
|
263898
|
-
import { resolve as
|
|
264005
|
+
import { resolve as resolve53 } from "node:path";
|
|
263899
264006
|
init_src();
|
|
263900
264007
|
init_credentials();
|
|
263901
264008
|
init_backend();
|
|
@@ -263907,7 +264014,7 @@ init_trace_import();
|
|
|
263907
264014
|
init_trace_import();
|
|
263908
264015
|
import { createHash as createHash85 } from "node:crypto";
|
|
263909
264016
|
import { access as access13, readFile as readFile50, mkdir as mkdir31, stat as stat17, writeFile as writeFile33 } from "node:fs/promises";
|
|
263910
|
-
import { basename as basename15, dirname as dirname25, join as join69, relative as
|
|
264017
|
+
import { basename as basename15, dirname as dirname25, join as join69, relative as relative25, resolve as resolve50 } from "node:path";
|
|
263911
264018
|
import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
|
|
263912
264019
|
var import_yaml21 = __toESM(require_dist(), 1);
|
|
263913
264020
|
init_src();
|
|
@@ -264113,7 +264220,7 @@ async function listTraces(source, { limit: limit2, since, name: name5 }, env2, f
|
|
|
264113
264220
|
|
|
264114
264221
|
// packages/cli/src/trace-files.ts
|
|
264115
264222
|
import { readFile as readFile49, stat as stat16 } from "node:fs/promises";
|
|
264116
|
-
import { basename as basename14, relative as
|
|
264223
|
+
import { basename as basename14, relative as relative23, resolve as resolve49 } from "node:path";
|
|
264117
264224
|
init_src();
|
|
264118
264225
|
var MB3 = 1024 * 1024;
|
|
264119
264226
|
var UPLOAD_BYTES = 20 * MB3;
|
|
@@ -264122,7 +264229,7 @@ var UPLOAD_TRACES = 50;
|
|
|
264122
264229
|
async function findTraceFiles(cwd, args) {
|
|
264123
264230
|
const found = /* @__PURE__ */ new Set();
|
|
264124
264231
|
for (const arg of args) {
|
|
264125
|
-
const path9 =
|
|
264232
|
+
const path9 = resolve49(cwd, arg);
|
|
264126
264233
|
const kind2 = await stat16(path9).then((s3) => s3.isDirectory() ? "dir" : s3.isFile() ? "file" : void 0, () => void 0);
|
|
264127
264234
|
if (kind2 === "file") {
|
|
264128
264235
|
found.add(path9);
|
|
@@ -264141,7 +264248,7 @@ async function findTraceFiles(cwd, args) {
|
|
|
264141
264248
|
return [...found].sort();
|
|
264142
264249
|
}
|
|
264143
264250
|
async function readTraceTexts(cwd, paths3) {
|
|
264144
|
-
return Promise.all(paths3.map(async (path9) => ({ file:
|
|
264251
|
+
return Promise.all(paths3.map(async (path9) => ({ file: relative23(cwd, path9) || basename14(path9), name: basename14(path9), text: await readFile49(path9, "utf8").catch(() => void 0) })));
|
|
264145
264252
|
}
|
|
264146
264253
|
function readTraceUnits(texts4, { fileToIr: fileToIr2, sourceOf: sourceOf2 }) {
|
|
264147
264254
|
const drafts = /* @__PURE__ */ new Map(), skipped = [], read7 = [];
|
|
@@ -264312,7 +264419,7 @@ init_production();
|
|
|
264312
264419
|
init_src();
|
|
264313
264420
|
init_assets();
|
|
264314
264421
|
init_detect();
|
|
264315
|
-
import { relative as
|
|
264422
|
+
import { relative as relative24 } from "node:path";
|
|
264316
264423
|
function recordsAdapterText(language) {
|
|
264317
264424
|
return language === "ts" ? `import { mappingStore, openRecordsStore } from '@ancha-labs/tools/records';
|
|
264318
264425
|
import type { Records, StoreBinding, StoreContext } from '@ancha-labs/tools/records';
|
|
@@ -264363,7 +264470,7 @@ async function generateRecordsAdapter(project14, agentDirectory, language) {
|
|
|
264363
264470
|
const selected3 = language ?? (await detectProject(agentDirectory)).language;
|
|
264364
264471
|
if (selected3 === "unknown") return { generation: "language-required", binding: "bindStore", verify: "ancha doctor" };
|
|
264365
264472
|
const name5 = `ancha_records.${selected3}`, result = await applyScaffold(agentDirectory, [{ relativePath: name5, content: recordsAdapterText(selected3) }]);
|
|
264366
|
-
return { path:
|
|
264473
|
+
return { path: relative24(project14, `${agentDirectory}/${name5}`), language: selected3, generation: result.created.length ? "created" : "preserved", binding: selected3 === "ts" ? "bindStore" : "bind_store", verify: "ancha doctor" };
|
|
264367
264474
|
}
|
|
264368
264475
|
|
|
264369
264476
|
// packages/cli/src/import-people.ts
|
|
@@ -264628,7 +264735,7 @@ async function guard(ctx, dir2, force) {
|
|
|
264628
264735
|
if (changes?.other) {
|
|
264629
264736
|
throw new AnchaError(
|
|
264630
264737
|
"USAGE",
|
|
264631
|
-
`${
|
|
264738
|
+
`${relative25(ctx.io.cwd, join69(dir2, "scene.yaml"))} has changes besides checks you added; pulling would overwrite them`,
|
|
264632
264739
|
{ hint: "move those changes into checks of your own, or pass --force to overwrite the file" }
|
|
264633
264740
|
);
|
|
264634
264741
|
}
|
|
@@ -264652,7 +264759,7 @@ function sceneToWrite(next2, changes) {
|
|
|
264652
264759
|
return { scene: { ...next2, checks: [...checksOf2(next2), ...kept], ...!implicit && { pass } }, kept: kept.map((c) => c.id) };
|
|
264653
264760
|
}
|
|
264654
264761
|
async function writeWorld(ctx, world5, dest, changes) {
|
|
264655
|
-
const dir2 =
|
|
264762
|
+
const dir2 = resolve50(ctx.io.cwd, dest, world5.name);
|
|
264656
264763
|
await mkdir31(dir2, { recursive: true });
|
|
264657
264764
|
const { scene: content2, kept } = sceneToWrite(world5.scene, changes);
|
|
264658
264765
|
const scene2 = join69(dir2, "scene.yaml");
|
|
@@ -264674,7 +264781,7 @@ ${(0, import_yaml21.stringify)(files2.scene)}`);
|
|
|
264674
264781
|
return { dir: dir2, scene: scene2, kept };
|
|
264675
264782
|
}
|
|
264676
264783
|
async function report7(ctx, world5, written) {
|
|
264677
|
-
const where3 =
|
|
264784
|
+
const where3 = relative25(ctx.io.cwd, written.scene) || written.scene;
|
|
264678
264785
|
const globs = await ctx.loadConfig().then((config12) => config12.scenes, () => void 0);
|
|
264679
264786
|
const seen = globs === void 0 || (await glob3(globs, { cwd: ctx.io.cwd, absolute: true, onlyFiles: true })).includes(written.scene);
|
|
264680
264787
|
const questions = world5.questions ?? [], open17 = questions.filter((q2) => q2.form && q2.answer === void 0);
|
|
@@ -264690,7 +264797,7 @@ async function report7(ctx, world5, written) {
|
|
|
264690
264797
|
...open17.length ? [` answer: ancha pull ${world5.id.slice(0, 8)} --answer <question>=<value>; ancha traces show ${world5.id.slice(0, 8)} says how for each`] : [],
|
|
264691
264798
|
...traceConnectionLines(connection4),
|
|
264692
264799
|
`next: ${connection4.commands.init ? `${connection4.commands.init}, then ` : ""}${connection4.commands.run}`,
|
|
264693
|
-
...seen ? [] : [`note: scenes: in ancha.yaml does not include ${where3}; add ${
|
|
264800
|
+
...seen ? [] : [`note: scenes: in ancha.yaml does not include ${where3}; add ${relative25(ctx.io.cwd, dirname25(written.dir)) || "."}/**/scene.yaml to run it with the rest`]
|
|
264694
264801
|
].join("\n")
|
|
264695
264802
|
);
|
|
264696
264803
|
}
|
|
@@ -264707,7 +264814,7 @@ async function pullAll(ctx, options5) {
|
|
|
264707
264814
|
}
|
|
264708
264815
|
let changes;
|
|
264709
264816
|
try {
|
|
264710
|
-
changes = await guard(ctx,
|
|
264817
|
+
changes = await guard(ctx, resolve50(ctx.io.cwd, options5.dest, test3.name), options5.force);
|
|
264711
264818
|
} catch (error65) {
|
|
264712
264819
|
if (!(error65 instanceof AnchaError)) throw error65;
|
|
264713
264820
|
skipped.push({ id: test3.id, name: test3.name, reason: error65.message });
|
|
@@ -264722,26 +264829,26 @@ async function pullAll(ctx, options5) {
|
|
|
264722
264829
|
skipped.push({ id: test3.id, name: test3.name, reason: error65.message });
|
|
264723
264830
|
continue;
|
|
264724
264831
|
}
|
|
264725
|
-
written.push({ id: world5.id, name: world5.name, version: world5.version ?? test3.version, scene:
|
|
264832
|
+
written.push({ id: world5.id, name: world5.name, version: world5.version ?? test3.version, scene: relative25(ctx.io.cwd, done.scene) || done.scene });
|
|
264726
264833
|
paths3.push(done.scene);
|
|
264727
264834
|
}
|
|
264728
264835
|
const connection4 = paths3.length ? await connectionFor(ctx, paths3, `${options5.dest}/*/scene.yaml`) : void 0;
|
|
264729
264836
|
const next2 = paths3.length ? [...traceConnectionLines(connection4), ...await nextLines(ctx, paths3, options5.dest, connection4)] : [];
|
|
264730
264837
|
const from = options5.agent === void 0 ? "" : ` from ${options5.agent}`;
|
|
264731
264838
|
ctx.out.result({ written, skipped, next: paths3.length ? [...connection4?.commands.init ? [connection4.commands.init] : [], connection4?.cloud ? connection4.commands.run : `ancha run ${options5.dest}/*/scene.yaml`] : ["ancha traces"], ...connection4 && { connection: connection4 }, ...options5.agent !== void 0 && { agent: options5.agent } }, () => [
|
|
264732
|
-
written.length ? `wrote ${plural6(written.length, "test")}${from} to ${
|
|
264839
|
+
written.length ? `wrote ${plural6(written.length, "test")}${from} to ${relative25(ctx.io.cwd, resolve50(ctx.io.cwd, options5.dest)) || "."}/` : tests.length ? `wrote no tests${from}` : `the workspace has no tests${from}; ancha traces lists what it received`,
|
|
264733
264840
|
...skipped.map((s3) => ` skipped ${s3.name}: ${s3.reason}`),
|
|
264734
264841
|
...skipped.some((s3) => s3.reason !== OFF) ? [" move those changes into checks of your own, or pass --force to overwrite the files"] : [],
|
|
264735
264842
|
...next2
|
|
264736
264843
|
].join("\n"));
|
|
264737
264844
|
}
|
|
264738
264845
|
async function connectionFor(ctx, paths3, target6, recordsAdapter) {
|
|
264739
|
-
const configured = ctx.globals().config !== void 0 || await access13(
|
|
264846
|
+
const configured = ctx.globals().config !== void 0 || await access13(resolve50(ctx.io.cwd, "ancha.yaml")).then(() => true, () => false);
|
|
264740
264847
|
const cloud = await cloudWorkspace(ctx, { code: "USAGE", message: "no workspace", hint: "" }).then(() => true, () => false);
|
|
264741
264848
|
return traceConnection(ctx.io.cwd, paths3, configured, target6, recordsAdapter, cloud);
|
|
264742
264849
|
}
|
|
264743
264850
|
async function nextLines(ctx, paths3, dest, connection4) {
|
|
264744
|
-
const folder2 =
|
|
264851
|
+
const folder2 = relative25(ctx.io.cwd, resolve50(ctx.io.cwd, dest)) || ".", where3 = paths3.length === 1 ? relative25(ctx.io.cwd, paths3[0]) : `${folder2}/*/scene.yaml`;
|
|
264745
264852
|
if (connection4.commands.init) return [`next: ${connection4.commands.init}, then ${connection4.commands.run}`];
|
|
264746
264853
|
const globs = await ctx.loadConfig().then((config12) => config12.scenes, () => void 0);
|
|
264747
264854
|
const found = globs === void 0 ? void 0 : new Set(await glob3(globs, { cwd: ctx.io.cwd, absolute: true, onlyFiles: true }));
|
|
@@ -264775,7 +264882,7 @@ async function saveWithAnswers(api4, id15, options5) {
|
|
|
264775
264882
|
return api4(`/v1/traces/${id15}/tests`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ answers, ...options5.resetAnswers && { resetAnswers: true } }) });
|
|
264776
264883
|
}
|
|
264777
264884
|
async function projectAgent(ctx) {
|
|
264778
|
-
const configured = ctx.globals().config !== void 0 || await access13(
|
|
264885
|
+
const configured = ctx.globals().config !== void 0 || await access13(resolve50(ctx.io.cwd, "ancha.yaml")).then(() => true, () => false);
|
|
264779
264886
|
return configured ? agentName(ctx.io.cwd) : void 0;
|
|
264780
264887
|
}
|
|
264781
264888
|
async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
@@ -264816,7 +264923,7 @@ async function sendTraces(ctx, api4, units, name5, options5, maxBytes) {
|
|
|
264816
264923
|
const skip = (error65) => ({ skip: { trace: id15, ...file3 && { file: file3 }, reason: error65.message }, error: error65 });
|
|
264817
264924
|
let changes;
|
|
264818
264925
|
try {
|
|
264819
|
-
changes = await guard(ctx,
|
|
264926
|
+
changes = await guard(ctx, resolve50(ctx.io.cwd, options5.dest, `trace-${id15.slice(0, 8)}`), options5.force);
|
|
264820
264927
|
} catch (error65) {
|
|
264821
264928
|
if (!(error65 instanceof AnchaError)) throw error65;
|
|
264822
264929
|
return skip(error65);
|
|
@@ -264850,7 +264957,7 @@ var openQuestions = (world5) => (world5.questions ?? []).filter((q2) => q2.form
|
|
|
264850
264957
|
async function runNext(ctx, paths3, dest, init) {
|
|
264851
264958
|
const globs = await ctx.loadConfig().then((config12) => config12.scenes, () => void 0);
|
|
264852
264959
|
const found = globs === void 0 ? void 0 : new Set(await glob3(globs, { cwd: ctx.io.cwd, absolute: true, onlyFiles: true }));
|
|
264853
|
-
const folder2 =
|
|
264960
|
+
const folder2 = relative25(ctx.io.cwd, resolve50(ctx.io.cwd, dest)) || ".", seen = !found || paths3.every((path9) => found.has(path9));
|
|
264854
264961
|
return {
|
|
264855
264962
|
next: [...init ? [init] : [], seen ? "ancha run" : `ancha run ${folder2}/*/scene.yaml`],
|
|
264856
264963
|
...!seen && { note: `note: scenes: in ancha.yaml does not include ${folder2}; add ${folder2}/**/scene.yaml to run these tests with the rest` }
|
|
@@ -264861,7 +264968,7 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
264861
264968
|
const connection4 = paths3.length ? await connectionFor(ctx, paths3, `${dest}/*/scene.yaml`) : void 0;
|
|
264862
264969
|
const { next: next2, note: note2 } = await runNext(ctx, paths3, dest, connection4?.commands.init);
|
|
264863
264970
|
const asking = tests.filter((m) => openQuestions(m.world).length);
|
|
264864
|
-
const where3 = (path9) =>
|
|
264971
|
+
const where3 = (path9) => relative25(ctx.io.cwd, path9) || path9;
|
|
264865
264972
|
const result = {
|
|
264866
264973
|
tests: tests.map((m) => ({
|
|
264867
264974
|
id: m.world.id,
|
|
@@ -264920,7 +265027,7 @@ async function uploadReport(ctx, done, from, dest) {
|
|
|
264920
265027
|
async function importJson(ctx, done) {
|
|
264921
265028
|
for (const s3 of done.skipped) if (s3.trace) ctx.out.event({ event: "trace_skipped", trace: s3.trace, reason: s3.reason });
|
|
264922
265029
|
for (const { world: world5, written } of done.made) {
|
|
264923
|
-
const where3 =
|
|
265030
|
+
const where3 = relative25(ctx.io.cwd, written.scene) || written.scene, connection4 = await connectionFor(ctx, [written.scene], where3);
|
|
264924
265031
|
ctx.out.result({
|
|
264925
265032
|
connection: connection4,
|
|
264926
265033
|
world: world5.id,
|
|
@@ -265058,7 +265165,7 @@ function registerTraces(program2, ctx) {
|
|
|
265058
265165
|
}
|
|
265059
265166
|
};
|
|
265060
265167
|
const summary = await loadRunSummary(ctx.io.cwd, runId2, options5.out);
|
|
265061
|
-
const dirs = summary.scenes.flatMap((scene2) => scene2.trialsDetail.map((detail3) =>
|
|
265168
|
+
const dirs = summary.scenes.flatMap((scene2) => scene2.trialsDetail.map((detail3) => resolve50(ctx.io.cwd, detail3.dir)));
|
|
265062
265169
|
const dir2 = trial === void 0 ? dirs[0] : dirs.find((path9) => basename15(path9) === trial);
|
|
265063
265170
|
if (dir2 === void 0) throw new AnchaError("USAGE", trial === void 0 ? `run ${summary.runId} has no attempts` : `no attempt ${trial} in run ${summary.runId}`, { hint: `its attempts: ${dirs.map((path9) => basename15(path9)).join(", ") || "none"}` });
|
|
265064
265171
|
const attemptLines2 = safe(attemptToIr(await readAttemptTrace(dir2), basename15(dir2)));
|
|
@@ -265110,7 +265217,7 @@ function registerTraces(program2, ctx) {
|
|
|
265110
265217
|
name5 = from;
|
|
265111
265218
|
} else {
|
|
265112
265219
|
texts4 = await readTraceTexts(ctx.io.cwd, await findTraceFiles(ctx.io.cwd, paths3));
|
|
265113
|
-
const one7 = paths3.length === 1 ?
|
|
265220
|
+
const one7 = paths3.length === 1 ? resolve50(ctx.io.cwd, paths3[0]) : void 0;
|
|
265114
265221
|
name5 = one7 && await stat17(one7).then(() => true, () => false) ? basename15(one7).slice(0, 80) : "traces";
|
|
265115
265222
|
}
|
|
265116
265223
|
const { units, skipped, read: read7 } = await traceUnits(texts4);
|
|
@@ -265173,7 +265280,7 @@ function registerTraces(program2, ctx) {
|
|
|
265173
265280
|
if (trace2.world_id) world5 = (await api4(`/v1/worlds/${trace2.world_id}`)).world;
|
|
265174
265281
|
}
|
|
265175
265282
|
const traceId = trace2?.id ?? world5?.trace_id;
|
|
265176
|
-
const changes = await guard(ctx,
|
|
265283
|
+
const changes = await guard(ctx, resolve50(ctx.io.cwd, options5.dest, world5?.name ?? `trace-${String(traceId).slice(0, 8)}`), options5.force);
|
|
265177
265284
|
if (options5.answer.length || options5.expect || options5.resetAnswers) {
|
|
265178
265285
|
if (!traceId) throw new AnchaError("USAGE", `the trace ${id15} was made from is deleted, so it cannot be rebuilt with answers`, { hint: "edit its scene.yaml instead" });
|
|
265179
265286
|
const { preview } = await api4(`/v1/traces/${traceId}/preview`);
|
|
@@ -265184,7 +265291,7 @@ function registerTraces(program2, ctx) {
|
|
|
265184
265291
|
});
|
|
265185
265292
|
}
|
|
265186
265293
|
async function traceSource(ctx, trace2, from) {
|
|
265187
|
-
if (!from) return { text: await readFile50(
|
|
265294
|
+
if (!from) return { text: await readFile50(resolve50(ctx.io.cwd, trace2), "utf8").catch(() => {
|
|
265188
265295
|
throw new AnchaError("USAGE", `cannot read ${trace2}`, { hint: "pass the path of a trace file: ancha import --offline <trace.jsonl>" });
|
|
265189
265296
|
}), name: basename15(trace2), label: basename15(trace2) };
|
|
265190
265297
|
const doc = await fetchTrace(from, trace2, ctx.io.env);
|
|
@@ -265192,7 +265299,7 @@ async function traceSource(ctx, trace2, from) {
|
|
|
265192
265299
|
return { text: JSON.stringify(doc), name: `${from}-${id15}`.slice(0, 80), label: `${from === "langfuse" ? "Langfuse" : "LangSmith"} trace ${id15}` };
|
|
265193
265300
|
}
|
|
265194
265301
|
async function traceFileLines(ctx, file3) {
|
|
265195
|
-
const text31 = await readFile50(
|
|
265302
|
+
const text31 = await readFile50(resolve50(ctx.io.cwd, file3), "utf8").catch(() => {
|
|
265196
265303
|
throw new AnchaError("USAGE", `cannot read ${file3}`, { hint: "pass the path of a trace file: ancha traces diff <trace.jsonl> latest" });
|
|
265197
265304
|
});
|
|
265198
265305
|
return { text: text31, lines: await traceTextLines(text31, basename15(file3)) };
|
|
@@ -265264,12 +265371,12 @@ async function writeRecords(ctx, conversations, dest) {
|
|
|
265264
265371
|
const { recordsOf: recordsOf2, mergeRecords: mergeRecords2, readRecordLines: readRecordLines2, recordLines: recordLines2 } = await Promise.resolve().then(() => (init_rebuild(), rebuild_exports));
|
|
265265
265372
|
const seen = conversations.flatMap((c) => recordsOf2(toolCallsOf(c.lines), { conversation: c.id }));
|
|
265266
265373
|
if (!seen.length) return void 0;
|
|
265267
|
-
const path9 =
|
|
265374
|
+
const path9 = resolve50(ctx.io.cwd, dest, "records.jsonl");
|
|
265268
265375
|
const merged = mergeRecords2(readRecordLines2(await readFile50(path9, "utf8").catch(() => "")), seen);
|
|
265269
265376
|
await mkdir31(dirname25(path9), { recursive: true });
|
|
265270
265377
|
await writeFile33(path9, recordLines2(merged));
|
|
265271
265378
|
const types = merged.reduce((all9, r2) => all9.set(r2.type, (all9.get(r2.type) ?? 0) + 1), /* @__PURE__ */ new Map());
|
|
265272
|
-
return { path:
|
|
265379
|
+
return { path: relative25(ctx.io.cwd, path9), count: merged.length, types: Object.fromEntries(types) };
|
|
265273
265380
|
}
|
|
265274
265381
|
var recordsLines = (records6) => !records6 ? [] : [
|
|
265275
265382
|
` records: ${records6.path}, ${plural6(records6.count, "record")} (${Object.entries(records6.types).map(([type, n2]) => `${type} ${n2}`).join(", ")}), what the tools answered before anything changed; a test hands them to your agent as ANCHA_RECORDS`
|
|
@@ -265279,7 +265386,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
265279
265386
|
const { text: text31 } = source, all9 = await traceConversations(text31, source.name);
|
|
265280
265387
|
const { sceneFiles: sceneFiles2 } = await Promise.resolve().then(() => (init_trace_import(), trace_import_exports));
|
|
265281
265388
|
const rebuild3 = rebuildTraceImport;
|
|
265282
|
-
const checks2 = options5.checks ? readImportChecks(await readFile50(
|
|
265389
|
+
const checks2 = options5.checks ? readImportChecks(await readFile50(resolve50(ctx.io.cwd, options5.checks), "utf8").catch(() => {
|
|
265283
265390
|
throw new AnchaError("USAGE", `cannot read checks file ${options5.checks}`);
|
|
265284
265391
|
})) : void 0;
|
|
265285
265392
|
const picked = options5.conversation === void 0 ? all9 : all9.filter((c) => c.id === options5.conversation || c.traces.includes(options5.conversation));
|
|
@@ -265298,7 +265405,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
265298
265405
|
const made = [], skipped = [];
|
|
265299
265406
|
for (const [i, conversation3] of picked.entries()) {
|
|
265300
265407
|
const examples2 = [...all9.filter((c) => c !== conversation3).map((c) => c.lines), ...files2], customer3 = customers3.people[i];
|
|
265301
|
-
const earlier2 = options5.resetAnswers ? {} : await readFile50(
|
|
265408
|
+
const earlier2 = options5.resetAnswers ? {} : await readFile50(resolve50(ctx.io.cwd, options5.dest, named5.get(conversation3), "answers.json"), "utf8").then((text32) => JSON.parse(text32), () => ({}));
|
|
265302
265409
|
try {
|
|
265303
265410
|
const preview = rebuild3(conversation3.lines, { id: named5.get(conversation3), withRecords: true, examples: examples2, useReportedResults: options5.useReportedResults });
|
|
265304
265411
|
const answers = { ...answersFor(preview.questions, earlier2, options5.answer), ...options5.expect && { "checks.expect": options5.expect } };
|
|
@@ -265309,9 +265416,9 @@ async function importLocally(ctx, source, options5) {
|
|
|
265309
265416
|
skipped.push(conversation3.id);
|
|
265310
265417
|
}
|
|
265311
265418
|
}
|
|
265312
|
-
const paths3 = made.map((m) => join69(
|
|
265419
|
+
const paths3 = made.map((m) => join69(resolve50(ctx.io.cwd, options5.dest, m.id), "scene.yaml"));
|
|
265313
265420
|
if (!options5.force) {
|
|
265314
|
-
for (const path9 of paths3) if (await readFile50(path9, "utf8").then(() => true, () => false)) throw new AnchaError("USAGE", `${
|
|
265421
|
+
for (const path9 of paths3) if (await readFile50(path9, "utf8").then(() => true, () => false)) throw new AnchaError("USAGE", `${relative25(ctx.io.cwd, path9)} exists; --force replaces it`);
|
|
265315
265422
|
}
|
|
265316
265423
|
for (const [i, m] of made.entries()) {
|
|
265317
265424
|
const path9 = paths3[i], dir2 = dirname25(path9);
|
|
@@ -265333,7 +265440,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
265333
265440
|
const records6 = await writeRecords(ctx, all9, options5.dest);
|
|
265334
265441
|
const needsAdapter = made.some((m) => Object.values(m.made.scene.tools ?? {}).some((tool) => tool.unrecorded === "run"));
|
|
265335
265442
|
const config12 = needsAdapter ? await ctx.loadConfig() : void 0;
|
|
265336
|
-
const recordsAdapter = needsAdapter ? await generateRecordsAdapter(ctx.io.cwd,
|
|
265443
|
+
const recordsAdapter = needsAdapter ? await generateRecordsAdapter(ctx.io.cwd, resolve50(ctx.io.cwd, config12?.agent?.cwd ?? "."), options5.adapterLang) : void 0;
|
|
265337
265444
|
const setupOf = (m) => [...m.made.setup.reduce((all10, call4) => all10.set(call4, (all10.get(call4) ?? 0) + 1), /* @__PURE__ */ new Map())].map(([call4, count13]) => ({ call: call4, count: count13 }));
|
|
265338
265445
|
const questionLines = (questions2) => questions2.length ? [
|
|
265339
265446
|
" questions (answer with --answer <id>=<value>, then import again with --force):",
|
|
@@ -265348,7 +265455,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
265348
265455
|
if (all9.length === 1) {
|
|
265349
265456
|
const [m] = made, setup2 = setupOf(m), path9 = paths3[0];
|
|
265350
265457
|
const lines3 = [
|
|
265351
|
-
`wrote ${
|
|
265458
|
+
`wrote ${relative25(ctx.io.cwd, path9)} from ${source.label}, on this computer (nothing was uploaded)`,
|
|
265352
265459
|
` ${m.made.summary.observed} observed, ${m.made.summary.inferred} inferred, ${m.made.summary.missing} missing; provenance in provenance.json`,
|
|
265353
265460
|
...evidenceLines2(m.made),
|
|
265354
265461
|
...toolLines(m.made.scene),
|
|
@@ -265363,16 +265470,16 @@ async function importLocally(ctx, source, options5) {
|
|
|
265363
265470
|
" the test has them only if the app makes them when it starts, or the start script or an app_calls entry does (ancha docs apps)"
|
|
265364
265471
|
);
|
|
265365
265472
|
}
|
|
265366
|
-
const connection5 = await connectionFor(ctx, [path9],
|
|
265473
|
+
const connection5 = await connectionFor(ctx, [path9], relative25(ctx.io.cwd, path9), recordsAdapter);
|
|
265367
265474
|
lines3.push(...traceConnectionLines(connection5), ...await nextLines(ctx, [path9], options5.dest, connection5));
|
|
265368
|
-
return { result: { workspace: `local:${ctx.io.cwd}`, format: importFormat(text31, "trace").format, connection: connection5, scene:
|
|
265475
|
+
return { result: { workspace: `local:${ctx.io.cwd}`, format: importFormat(text31, "trace").format, connection: connection5, scene: relative25(ctx.io.cwd, path9), evidence: m.made.evidence, candidates: m.made.candidates, required_checks: m.made.scene.pass, checks: importedChecks(m.made.scene, m.made.production), summary: m.made.summary, questions: m.made.questions, setup: setup2, next: [...connection5.commands.init ? [connection5.commands.init] : [], connection5.cloud ? connection5.commands.run : `ancha run ${relative25(ctx.io.cwd, path9)}`], ...records6 && { records: records6 } }, text: lines3.join("\n") };
|
|
265369
265476
|
}
|
|
265370
265477
|
const questions = [...new Map(made.flatMap((m) => m.made.questions).reverse().map((q2) => [q2.id, q2])).values()].reverse();
|
|
265371
265478
|
const recorded2 = (m) => Object.values(m.made.scene.tools ?? {}).reduce((n2, t) => n2 + (t.recorded?.length ?? 0), 0);
|
|
265372
265479
|
const lines2 = [
|
|
265373
265480
|
`wrote ${plural6(made.length, "test")} from ${source.label}, one per conversation, on this computer (nothing was uploaded)`,
|
|
265374
265481
|
...made.flatMap((m, i) => [
|
|
265375
|
-
` ${
|
|
265482
|
+
` ${relative25(ctx.io.cwd, paths3[i])} ${plural6(m.conversation.traces.length, "turn")}, ${plural6(recorded2(m), "recorded call")} (conversation ${m.conversation.id})`,
|
|
265376
265483
|
...evidenceLines2(m.made),
|
|
265377
265484
|
...importedCheckLines(m.made.scene, m.made.production)
|
|
265378
265485
|
]),
|
|
@@ -265386,7 +265493,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
265386
265493
|
if (setups) lines2.push(` warning: in ${plural6(setups, "test")}, calls came before the first event the test replays, the app's own setup (provenance.json lists them; ancha docs apps)`);
|
|
265387
265494
|
const connection4 = await connectionFor(ctx, paths3, `${options5.dest}/*/scene.yaml`, recordsAdapter);
|
|
265388
265495
|
lines2.push(...traceConnectionLines(connection4), ...await nextLines(ctx, paths3, options5.dest, connection4));
|
|
265389
|
-
return { result: { workspace: `local:${ctx.io.cwd}`, format: importFormat(text31, "trace").format, connection: connection4, scenes: made.map((m, i) => ({ scene:
|
|
265496
|
+
return { result: { workspace: `local:${ctx.io.cwd}`, format: importFormat(text31, "trace").format, connection: connection4, scenes: made.map((m, i) => ({ scene: relative25(ctx.io.cwd, paths3[i]), conversation: m.conversation.id, traces: m.conversation.traces, evidence: m.made.evidence, candidates: m.made.candidates, required_checks: m.made.scene.pass, checks: importedChecks(m.made.scene, m.made.production), summary: m.made.summary, setup: setupOf(m) })), questions, skipped, next: [...connection4.commands.init ? [connection4.commands.init] : [], connection4.cloud ? connection4.commands.run : `ancha run ${options5.dest}/*/scene.yaml`], ...records6 && { records: records6 } }, text: lines2.join("\n") };
|
|
265390
265497
|
}
|
|
265391
265498
|
function evidenceLines2(made) {
|
|
265392
265499
|
return [
|
|
@@ -265402,7 +265509,7 @@ function evidenceLines2(made) {
|
|
|
265402
265509
|
// packages/cli/src/commands/test-import.ts
|
|
265403
265510
|
import { existsSync as existsSync4 } from "node:fs";
|
|
265404
265511
|
import { access as access14, mkdir as mkdir32, readFile as readFile51, writeFile as writeFile34 } from "node:fs/promises";
|
|
265405
|
-
import { basename as basename16, dirname as dirname26, extname as extname2, isAbsolute as
|
|
265512
|
+
import { basename as basename16, dirname as dirname26, extname as extname2, isAbsolute as isAbsolute13, relative as relative26, resolve as resolve51 } from "node:path";
|
|
265406
265513
|
init_src();
|
|
265407
265514
|
init_detect();
|
|
265408
265515
|
init_function_tools();
|
|
@@ -265429,7 +265536,7 @@ async function testImport(ctx, file3, options5) {
|
|
|
265429
265536
|
if (options5.on !== void 0 && options5.on !== "local") throw new AnchaError("USAGE", "test import writes local files; use --on local");
|
|
265430
265537
|
if (!JUDGE_MODES.includes(options5.judge)) throw new AnchaError("USAGE", `--judge must be one of ${JUDGE_MODES.join(", ")}`, { hint: "e.g. --judge never: answer checks only, no model" });
|
|
265431
265538
|
if (options5.prefix !== void 0 && !/[a-z0-9]/i.test(options5.prefix)) throw new AnchaError("USAGE", "--prefix needs letters or digits", { hint: "e.g. --prefix ops" });
|
|
265432
|
-
const path9 =
|
|
265539
|
+
const path9 = resolve51(ctx.io.cwd, file3);
|
|
265433
265540
|
if ([".xlsx", ".xlsm", ".xls", ".ods", ".numbers"].includes(extname2(path9).toLowerCase())) {
|
|
265434
265541
|
throw new AnchaError("USAGE", `${file3} is a spreadsheet: import it as CSV`, { hint: "in Excel, File > Save As > CSV UTF-8; in Google Sheets, File > Download > Comma-separated values; then ancha test import <file>.csv" });
|
|
265435
265542
|
}
|
|
@@ -265457,7 +265564,7 @@ ${made.text}`);
|
|
|
265457
265564
|
}
|
|
265458
265565
|
if (read7.items.length === 0) throw new AnchaError("USAGE", `no evals in ${file3}`, { hint: 'each eval is a question with its expected answer, e.g. {"question": "\u2026", "expected": "\u2026"}' });
|
|
265459
265566
|
const world5 = await chooseWorld(ctx, options5.world, `ancha test import ${file3}`);
|
|
265460
|
-
const outDir =
|
|
265567
|
+
const outDir = resolve51(ctx.io.cwd, options5.out), out = relative26(ctx.io.cwd, outDir) || ".";
|
|
265461
265568
|
const detection = await detectProject(ctx.io.cwd);
|
|
265462
265569
|
const imported2 = importEvals(read7.items, { id: world5.id, tools: world5.tools }, { functionTools: detection.functionTools.map((t) => t.name), judge: options5.judge, ...options5.prefix !== void 0 && { prefix: options5.prefix }, out, source: basename16(path9) });
|
|
265463
265570
|
const reasons = new Map([...imported2.skipped.map((s3) => [s3.index, s3.reason]), ...read7.unreadable.map((u) => [u.index, u.reason])]);
|
|
@@ -265468,23 +265575,23 @@ ${skipped.slice(0, 10).map((s3) => `item ${s3.item}: ${s3.reason}`).join("\n")}`
|
|
|
265468
265575
|
}
|
|
265469
265576
|
const tests = [];
|
|
265470
265577
|
for (const test3 of imported2.tests) {
|
|
265471
|
-
const target6 =
|
|
265578
|
+
const target6 = resolve51(ctx.io.cwd, test3.path);
|
|
265472
265579
|
const before = existsSync4(target6) ? await readFile51(target6, "utf8") : void 0;
|
|
265473
265580
|
const status6 = before === void 0 ? "written" : before === test3.yaml ? "unchanged" : !editedSinceImport(before) ? "updated" : options5.force ? "written" : "kept";
|
|
265474
265581
|
if (status6 === "written" || status6 === "updated") {
|
|
265475
265582
|
await mkdir32(dirname26(target6), { recursive: true });
|
|
265476
265583
|
await writeFile34(target6, test3.yaml);
|
|
265477
265584
|
}
|
|
265478
|
-
tests.push({ id: String(test3.scene.id), file:
|
|
265585
|
+
tests.push({ id: String(test3.scene.id), file: relative26(ctx.io.cwd, target6), checks: test3.scene.checks.map(kind), status: status6 });
|
|
265479
265586
|
}
|
|
265480
265587
|
const checks2 = {};
|
|
265481
265588
|
for (const test3 of tests) for (const name5 of test3.checks) checks2[name5] = (checks2[name5] ?? 0) + 1;
|
|
265482
|
-
const configured = ctx.globals().config !== void 0 || await access14(
|
|
265589
|
+
const configured = ctx.globals().config !== void 0 || await access14(resolve51(ctx.io.cwd, "ancha.yaml")).then(() => true, () => false);
|
|
265483
265590
|
const globs = configured ? await ctx.loadConfig().then((config12) => config12.scenes, () => void 0) : void 0;
|
|
265484
265591
|
const found = globs === void 0 ? void 0 : new Set(await glob3(globs, { cwd: ctx.io.cwd, absolute: true, onlyFiles: true }));
|
|
265485
|
-
const seen = found !== void 0 && imported2.tests.every((test3) => found.has(
|
|
265486
|
-
const inProject2 =
|
|
265487
|
-
const withAgent = inProject2[0] !== ".." && !
|
|
265592
|
+
const seen = found !== void 0 && imported2.tests.every((test3) => found.has(resolve51(ctx.io.cwd, test3.path)));
|
|
265593
|
+
const inProject2 = relative26(ctx.io.cwd, path9).split(/[\\/]/);
|
|
265594
|
+
const withAgent = inProject2[0] !== ".." && !isAbsolute13(inProject2.join("/")) && inProject2[0] !== "ancha" && !inProject2.some((part) => part.startsWith(".") || part === "node_modules");
|
|
265488
265595
|
const notes7 = [
|
|
265489
265596
|
...imported2.warnings,
|
|
265490
265597
|
...withAgent ? [`${file3} goes to the agent with its files in a cloud run, expected answers and all: move it under ancha/ (e.g. ancha/evals/${basename16(path9)}), which stays with the grader`] : [],
|
|
@@ -265496,7 +265603,7 @@ ${skipped.slice(0, 10).map((s3) => `item ${s3.item}: ${s3.reason}`).join("\n")}`
|
|
|
265496
265603
|
const next2 = configured ? [seen ? "ancha run" : `ancha run ${out}/*.yaml`] : ["ancha init", `ancha run ${out}/*.yaml`];
|
|
265497
265604
|
next2.unshift(...functionToolWiring(detection.functionTools));
|
|
265498
265605
|
const format2 = read7.format ?? { jsonl: "JSON lines", json: "JSON", csv: "CSV", yaml: "YAML" }[evalFormat(basename16(path9), text31)];
|
|
265499
|
-
const result = { file:
|
|
265606
|
+
const result = { file: relative26(ctx.io.cwd, path9), world: world5.id, out, format: format2, ...read7.fields && { fields: read7.fields }, tests, checks: checks2, skipped, next: next2, notes: notes7 };
|
|
265500
265607
|
ctx.out.result(result, () => report8(result));
|
|
265501
265608
|
return result;
|
|
265502
265609
|
}
|
|
@@ -265522,7 +265629,7 @@ function registerTestImport(tests, ctx) {
|
|
|
265522
265629
|
|
|
265523
265630
|
// packages/cli/src/commands/test-files.ts
|
|
265524
265631
|
import { readFile as readFile52, stat as stat18 } from "node:fs/promises";
|
|
265525
|
-
import { basename as basename17, relative as
|
|
265632
|
+
import { basename as basename17, relative as relative27, resolve as resolve52 } from "node:path";
|
|
265526
265633
|
init_src();
|
|
265527
265634
|
init_scenes();
|
|
265528
265635
|
async function projectTestFiles(ctx) {
|
|
@@ -265538,12 +265645,12 @@ async function projectTestFiles(ctx) {
|
|
|
265538
265645
|
}
|
|
265539
265646
|
async function showTestFile(ctx, ref23) {
|
|
265540
265647
|
let path9 = ref23;
|
|
265541
|
-
const directFile = await stat18(
|
|
265648
|
+
const directFile = await stat18(resolve52(ctx.io.cwd, ref23)).then((info2) => info2.isFile(), () => false);
|
|
265542
265649
|
if (!directFile && !/[\\/]|\.(?:ya?ml|json)$/i.test(ref23)) {
|
|
265543
265650
|
const matches11 = [];
|
|
265544
265651
|
for (const file3 of await projectTestFiles(ctx)) {
|
|
265545
265652
|
try {
|
|
265546
|
-
const doc2 = parseSceneYaml(await readFile52(
|
|
265653
|
+
const doc2 = parseSceneYaml(await readFile52(resolve52(ctx.io.cwd, file3), "utf8"));
|
|
265547
265654
|
if (doc2 && typeof doc2 === "object" && "id" in doc2 && doc2.id === ref23) matches11.push(file3);
|
|
265548
265655
|
} catch {
|
|
265549
265656
|
}
|
|
@@ -265554,14 +265661,14 @@ async function showTestFile(ctx, ref23) {
|
|
|
265554
265661
|
path9 = matches11[0];
|
|
265555
265662
|
}
|
|
265556
265663
|
const [{ scene: scene2, world: worldPath }] = await loadScenes(ctx.io.cwd, [path9]);
|
|
265557
|
-
const doc = parseSceneYaml(await readFile52(
|
|
265664
|
+
const doc = parseSceneYaml(await readFile52(resolve52(ctx.io.cwd, path9), "utf8"));
|
|
265558
265665
|
const world5 = {
|
|
265559
|
-
...worldPath !== void 0 && { id: basename17(worldPath, ".yaml"), path:
|
|
265666
|
+
...worldPath !== void 0 && { id: basename17(worldPath, ".yaml"), path: relative27(ctx.io.cwd, worldPath) },
|
|
265560
265667
|
tools: scene2.twins
|
|
265561
265668
|
};
|
|
265562
265669
|
const value6 = {
|
|
265563
265670
|
kind: "file",
|
|
265564
|
-
path:
|
|
265671
|
+
path: relative27(ctx.io.cwd, resolve52(ctx.io.cwd, path9)),
|
|
265565
265672
|
id: scene2.id,
|
|
265566
265673
|
title: scene2.title,
|
|
265567
265674
|
world: world5,
|
|
@@ -265732,7 +265839,7 @@ function registerAgent(program2, ctx) {
|
|
|
265732
265839
|
ctx.out.result(result.report, () => renderUpload(result.report));
|
|
265733
265840
|
});
|
|
265734
265841
|
command.command("detect").option("--cwd <folder>", "project folder to inspect without running code", ".").description("suggest explicit project settings from known manifests").action(async (options5) => {
|
|
265735
|
-
const value6 = await suggestAgentProject(
|
|
265842
|
+
const value6 = await suggestAgentProject(resolve53(ctx.io.cwd, options5.cwd));
|
|
265736
265843
|
ctx.out.result(value6, () => [value6.suggestions.configPath ? `Configuration: ${value6.suggestions.configPath}` : value6.suggestions.command ? `Suggested command: ${value6.suggestions.command}` : "No explicit starting command found. Enter your agent command.", ...value6.warnings].join("\n"));
|
|
265737
265844
|
});
|
|
265738
265845
|
command.command("prepare").argument("<id>", "registered agent").description("prepare the agent code and dependencies for isolated playground runs").action(async (id15) => {
|
|
@@ -265838,7 +265945,7 @@ Run again with ancha test run ${saved.id}`);
|
|
|
265838
265945
|
var import_yaml22 = __toESM(require_dist(), 1);
|
|
265839
265946
|
init_src();
|
|
265840
265947
|
import { readFile as readFile53 } from "node:fs/promises";
|
|
265841
|
-
import { resolve as
|
|
265948
|
+
import { resolve as resolve54 } from "node:path";
|
|
265842
265949
|
init_backend();
|
|
265843
265950
|
function tools(value6) {
|
|
265844
265951
|
if (!value6) throw new AnchaError("USAGE", "select tools with --tools, or supply --definition");
|
|
@@ -265884,7 +265991,7 @@ Use --json to export this configuration.`);
|
|
|
265884
265991
|
if ([opts.tools, opts.preset, opts.definition].filter(Boolean).length > 1) throw new AnchaError("USAGE", "choose --tools, --preset or --definition");
|
|
265885
265992
|
let input5;
|
|
265886
265993
|
if (opts.definition) {
|
|
265887
|
-
const doc = (0, import_yaml22.parseDocument)(await readFile53(
|
|
265994
|
+
const doc = (0, import_yaml22.parseDocument)(await readFile53(resolve54(ctx.io.cwd, opts.definition), "utf8"));
|
|
265888
265995
|
if (doc.errors.length) throw new AnchaError("CONFIG_INVALID", doc.errors.map((error65) => error65.message).join("; "));
|
|
265889
265996
|
input5 = doc.toJS({ maxAliasCount: 100 });
|
|
265890
265997
|
if (opts.name && input5 && typeof input5 === "object" && !Array.isArray(input5)) input5 = { ...input5, name: opts.name };
|
|
@@ -269482,14 +269589,14 @@ function inputRequiredRoundsExceededMessage2(method2, maxRounds) {
|
|
|
269482
269589
|
return `Multi-round-trip request '${method2}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
269483
269590
|
}
|
|
269484
269591
|
function sleep15(ms2, signal) {
|
|
269485
|
-
return new Promise((
|
|
269592
|
+
return new Promise((resolve63, reject4) => {
|
|
269486
269593
|
if (signal?.aborted) {
|
|
269487
269594
|
reject4(signal.reason instanceof SdkError2 ? signal.reason : new SdkError2(SdkErrorCode2.RequestTimeout, String(signal.reason)));
|
|
269488
269595
|
return;
|
|
269489
269596
|
}
|
|
269490
269597
|
const timer = setTimeout(() => {
|
|
269491
269598
|
signal?.removeEventListener("abort", onAbort);
|
|
269492
|
-
|
|
269599
|
+
resolve63();
|
|
269493
269600
|
}, ms2);
|
|
269494
269601
|
const onAbort = () => {
|
|
269495
269602
|
clearTimeout(timer);
|
|
@@ -270333,7 +270440,7 @@ var Protocol2 = class {
|
|
|
270333
270440
|
const flowStartedAt = Date.now();
|
|
270334
270441
|
let onAbort;
|
|
270335
270442
|
let cleanupMessageId;
|
|
270336
|
-
return new Promise((
|
|
270443
|
+
return new Promise((resolve63, reject4) => {
|
|
270337
270444
|
const earlyReject = (error65) => {
|
|
270338
270445
|
reject4(error65);
|
|
270339
270446
|
};
|
|
@@ -270402,7 +270509,7 @@ var Protocol2 = class {
|
|
|
270402
270509
|
}
|
|
270403
270510
|
if (decoded.kind === "invalid") return reject4(decoded.error);
|
|
270404
270511
|
if (decoded.kind === "input_required") {
|
|
270405
|
-
if (options5?.allowInputRequired === true) return
|
|
270512
|
+
if (options5?.allowInputRequired === true) return resolve63(manualInputRequiredValue2(decoded));
|
|
270406
270513
|
const flow = {
|
|
270407
270514
|
codec: codec2,
|
|
270408
270515
|
request: request2,
|
|
@@ -270414,11 +270521,11 @@ var Protocol2 = class {
|
|
|
270414
270521
|
params: params10
|
|
270415
270522
|
}, resultSchema, legOptions)
|
|
270416
270523
|
};
|
|
270417
|
-
return
|
|
270524
|
+
return resolve63(this._resolveNonCompleteResult(decoded, flow));
|
|
270418
270525
|
}
|
|
270419
270526
|
const result = decoded.result;
|
|
270420
270527
|
validateStandardSchema2(resultSchema, result).then((parseResult) => {
|
|
270421
|
-
if (parseResult.success)
|
|
270528
|
+
if (parseResult.success) resolve63(parseResult.data);
|
|
270422
270529
|
else reject4(new SdkError2(SdkErrorCode2.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
270423
270530
|
}, reject4);
|
|
270424
270531
|
});
|
|
@@ -273397,7 +273504,7 @@ var require_compile2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
273397
273504
|
ref23 = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref23);
|
|
273398
273505
|
const schOrFunc = root3.refs[ref23];
|
|
273399
273506
|
if (schOrFunc) return schOrFunc;
|
|
273400
|
-
let _sch =
|
|
273507
|
+
let _sch = resolve63.call(this, root3, ref23);
|
|
273401
273508
|
if (_sch === void 0) {
|
|
273402
273509
|
const schema4 = (_a7 = root3.localRefs) === null || _a7 === void 0 ? void 0 : _a7[ref23];
|
|
273403
273510
|
const { schemaId } = this.opts;
|
|
@@ -273423,7 +273530,7 @@ var require_compile2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
273423
273530
|
function sameSchemaEnv(s1, s22) {
|
|
273424
273531
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
273425
273532
|
}
|
|
273426
|
-
function
|
|
273533
|
+
function resolve63(root3, ref23) {
|
|
273427
273534
|
let sch;
|
|
273428
273535
|
while (typeof (sch = this.refs[ref23]) == "string") ref23 = sch;
|
|
273429
273536
|
return sch || this.schemas[ref23] || resolveSchema.call(this, root3, ref23);
|
|
@@ -274118,7 +274225,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
274118
274225
|
else if (typeof uri === "object") uri = parse28(serialize2(uri, options5), options5);
|
|
274119
274226
|
return uri;
|
|
274120
274227
|
}
|
|
274121
|
-
function
|
|
274228
|
+
function resolve63(baseURI, relativeURI, options5) {
|
|
274122
274229
|
const schemelessOptions = options5 ? Object.assign({ scheme: "null" }, options5) : { scheme: "null" };
|
|
274123
274230
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
|
|
274124
274231
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -274133,41 +274240,41 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
274133
274240
|
schemelessOptions.skipEscape = true;
|
|
274134
274241
|
return serialize2(resolved, schemelessOptions);
|
|
274135
274242
|
}
|
|
274136
|
-
function resolveComponent(base6,
|
|
274243
|
+
function resolveComponent(base6, relative31, options5, skipNormalization) {
|
|
274137
274244
|
const target6 = {};
|
|
274138
274245
|
if (!skipNormalization) {
|
|
274139
274246
|
base6 = parse28(serialize2(base6, options5), options5);
|
|
274140
|
-
|
|
274247
|
+
relative31 = parse28(serialize2(relative31, options5), options5);
|
|
274141
274248
|
}
|
|
274142
274249
|
options5 = options5 || {};
|
|
274143
|
-
if (!options5.tolerant &&
|
|
274144
|
-
target6.scheme =
|
|
274145
|
-
target6.userinfo =
|
|
274146
|
-
target6.host =
|
|
274147
|
-
target6.port =
|
|
274148
|
-
target6.path = removeDotSegments(
|
|
274149
|
-
target6.query =
|
|
274250
|
+
if (!options5.tolerant && relative31.scheme) {
|
|
274251
|
+
target6.scheme = relative31.scheme;
|
|
274252
|
+
target6.userinfo = relative31.userinfo;
|
|
274253
|
+
target6.host = relative31.host;
|
|
274254
|
+
target6.port = relative31.port;
|
|
274255
|
+
target6.path = removeDotSegments(relative31.path || "");
|
|
274256
|
+
target6.query = relative31.query;
|
|
274150
274257
|
} else {
|
|
274151
|
-
if (
|
|
274152
|
-
target6.userinfo =
|
|
274153
|
-
target6.host =
|
|
274154
|
-
target6.port =
|
|
274155
|
-
target6.path = removeDotSegments(
|
|
274156
|
-
target6.query =
|
|
274258
|
+
if (relative31.userinfo !== void 0 || relative31.host !== void 0 || relative31.port !== void 0) {
|
|
274259
|
+
target6.userinfo = relative31.userinfo;
|
|
274260
|
+
target6.host = relative31.host;
|
|
274261
|
+
target6.port = relative31.port;
|
|
274262
|
+
target6.path = removeDotSegments(relative31.path || "");
|
|
274263
|
+
target6.query = relative31.query;
|
|
274157
274264
|
} else {
|
|
274158
|
-
if (!
|
|
274265
|
+
if (!relative31.path) {
|
|
274159
274266
|
target6.path = base6.path;
|
|
274160
|
-
if (
|
|
274267
|
+
if (relative31.query !== void 0) target6.query = relative31.query;
|
|
274161
274268
|
else target6.query = base6.query;
|
|
274162
274269
|
} else {
|
|
274163
|
-
if (
|
|
274270
|
+
if (relative31.path[0] === "/") target6.path = removeDotSegments(relative31.path);
|
|
274164
274271
|
else {
|
|
274165
|
-
if ((base6.userinfo !== void 0 || base6.host !== void 0 || base6.port !== void 0) && !base6.path) target6.path = "/" +
|
|
274166
|
-
else if (!base6.path) target6.path =
|
|
274167
|
-
else target6.path = base6.path.slice(0, base6.path.lastIndexOf("/") + 1) +
|
|
274272
|
+
if ((base6.userinfo !== void 0 || base6.host !== void 0 || base6.port !== void 0) && !base6.path) target6.path = "/" + relative31.path;
|
|
274273
|
+
else if (!base6.path) target6.path = relative31.path;
|
|
274274
|
+
else target6.path = base6.path.slice(0, base6.path.lastIndexOf("/") + 1) + relative31.path;
|
|
274168
274275
|
target6.path = removeDotSegments(target6.path);
|
|
274169
274276
|
}
|
|
274170
|
-
target6.query =
|
|
274277
|
+
target6.query = relative31.query;
|
|
274171
274278
|
}
|
|
274172
274279
|
target6.userinfo = base6.userinfo;
|
|
274173
274280
|
target6.host = base6.host;
|
|
@@ -274175,7 +274282,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
274175
274282
|
}
|
|
274176
274283
|
target6.scheme = base6.scheme;
|
|
274177
274284
|
}
|
|
274178
|
-
target6.fragment =
|
|
274285
|
+
target6.fragment = relative31.fragment;
|
|
274179
274286
|
return target6;
|
|
274180
274287
|
}
|
|
274181
274288
|
function equal4(uriA, uriB, options5) {
|
|
@@ -274400,7 +274507,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
274400
274507
|
const fastUri = {
|
|
274401
274508
|
SCHEMES,
|
|
274402
274509
|
normalize: normalize4,
|
|
274403
|
-
resolve:
|
|
274510
|
+
resolve: resolve63,
|
|
274404
274511
|
resolveComponent,
|
|
274405
274512
|
equal: equal4,
|
|
274406
274513
|
serialize: serialize2,
|
|
@@ -279773,14 +279880,14 @@ var ProbeWindow = class ProbeWindow2 {
|
|
|
279773
279880
|
*/
|
|
279774
279881
|
async exchange(buildRequest, timeoutMs) {
|
|
279775
279882
|
const id15 = `server-discover-probe-${++this._probeCounter}`;
|
|
279776
|
-
return new Promise((
|
|
279883
|
+
return new Promise((resolve63) => {
|
|
279777
279884
|
let settled = false;
|
|
279778
279885
|
const settle4 = (reply6) => {
|
|
279779
279886
|
if (settled) return;
|
|
279780
279887
|
settled = true;
|
|
279781
279888
|
clearTimeout(timer);
|
|
279782
279889
|
if (this._pending?.id === id15) this._pending = void 0;
|
|
279783
|
-
|
|
279890
|
+
resolve63(reply6);
|
|
279784
279891
|
};
|
|
279785
279892
|
const timer = setTimeout(() => settle4({ kind: "timeout" }), timeoutMs);
|
|
279786
279893
|
this._pending = {
|
|
@@ -281015,13 +281122,13 @@ var Client = class extends Protocol2 {
|
|
|
281015
281122
|
let onCallerAbort;
|
|
281016
281123
|
let resolveOpening;
|
|
281017
281124
|
let rejectOpening;
|
|
281018
|
-
const opening3 = new Promise((
|
|
281019
|
-
resolveOpening =
|
|
281125
|
+
const opening3 = new Promise((resolve63, reject4) => {
|
|
281126
|
+
resolveOpening = resolve63;
|
|
281020
281127
|
rejectOpening = reject4;
|
|
281021
281128
|
});
|
|
281022
281129
|
let resolveClosed;
|
|
281023
|
-
const closed = new Promise((
|
|
281024
|
-
resolveClosed =
|
|
281130
|
+
const closed = new Promise((resolve63) => {
|
|
281131
|
+
resolveClosed = resolve63;
|
|
281025
281132
|
});
|
|
281026
281133
|
const settle4 = (outcome4) => {
|
|
281027
281134
|
if (state3 === "closed") return;
|
|
@@ -282378,7 +282485,7 @@ var StdioServerTransport = class {
|
|
|
282378
282485
|
}
|
|
282379
282486
|
send(message8) {
|
|
282380
282487
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
282381
|
-
return new Promise((
|
|
282488
|
+
return new Promise((resolve63, reject4) => {
|
|
282382
282489
|
const json40 = serializeMessage(message8);
|
|
282383
282490
|
let settled = false;
|
|
282384
282491
|
const onError = (error65) => {
|
|
@@ -282393,14 +282500,14 @@ var StdioServerTransport = class {
|
|
|
282393
282500
|
settled = true;
|
|
282394
282501
|
this._stdout.off("error", onError);
|
|
282395
282502
|
this._stdout.off("drain", onDrain);
|
|
282396
|
-
|
|
282503
|
+
resolve63();
|
|
282397
282504
|
};
|
|
282398
282505
|
this._stdout.once("error", onError);
|
|
282399
282506
|
if (this._stdout.write(json40)) {
|
|
282400
282507
|
if (settled) return;
|
|
282401
282508
|
settled = true;
|
|
282402
282509
|
this._stdout.off("error", onError);
|
|
282403
|
-
|
|
282510
|
+
resolve63();
|
|
282404
282511
|
} else if (!settled) this._stdout.once("drain", onDrain);
|
|
282405
282512
|
});
|
|
282406
282513
|
}
|
|
@@ -282436,7 +282543,7 @@ async function serveMcpStdio(connection4, options5) {
|
|
|
282436
282543
|
}
|
|
282437
282544
|
});
|
|
282438
282545
|
const stdio = new StdioServerTransport(options5.stdin, options5.stdout, { maxBufferSize: 1e6 });
|
|
282439
|
-
await new Promise((
|
|
282546
|
+
await new Promise((resolve63, reject4) => {
|
|
282440
282547
|
let closed = false;
|
|
282441
282548
|
const close2 = () => {
|
|
282442
282549
|
if (closed) return;
|
|
@@ -282444,7 +282551,7 @@ async function serveMcpStdio(connection4, options5) {
|
|
|
282444
282551
|
process.off("SIGINT", close2);
|
|
282445
282552
|
process.off("SIGTERM", close2);
|
|
282446
282553
|
options5.signal?.removeEventListener("abort", close2);
|
|
282447
|
-
void Promise.allSettled([http.close(), stdio.close()]).then(() =>
|
|
282554
|
+
void Promise.allSettled([http.close(), stdio.close()]).then(() => resolve63());
|
|
282448
282555
|
};
|
|
282449
282556
|
stdio.onclose = close2;
|
|
282450
282557
|
http.onclose = close2;
|
|
@@ -282475,7 +282582,7 @@ async function serveMcpStdio(connection4, options5) {
|
|
|
282475
282582
|
}
|
|
282476
282583
|
|
|
282477
282584
|
// packages/cli/src/commands/lifecycle.ts
|
|
282478
|
-
import { relative as
|
|
282585
|
+
import { relative as relative28, resolve as resolve55 } from "node:path";
|
|
282479
282586
|
init_src();
|
|
282480
282587
|
init_backend();
|
|
282481
282588
|
init_credentials();
|
|
@@ -282535,7 +282642,7 @@ async function withLock(cwd, work) {
|
|
|
282535
282642
|
continue;
|
|
282536
282643
|
}
|
|
282537
282644
|
if (attempt2 > 150) throw new AnchaError("SESSION_CONFLICT", "another ancha world up is starting the local world server", { hint: "retry in a few seconds" });
|
|
282538
|
-
await new Promise((
|
|
282645
|
+
await new Promise((resolve63) => setTimeout(resolve63, 200));
|
|
282539
282646
|
}
|
|
282540
282647
|
}
|
|
282541
282648
|
try {
|
|
@@ -282572,7 +282679,7 @@ function startWorldServer(cwd, controlToken) {
|
|
|
282572
282679
|
execArgv: source ? ["--import", createRequire6(import.meta.url).resolve("tsx")] : [],
|
|
282573
282680
|
stdio: ["ignore", "ignore", "ignore", "ipc"]
|
|
282574
282681
|
});
|
|
282575
|
-
return new Promise((
|
|
282682
|
+
return new Promise((resolve63, reject4) => {
|
|
282576
282683
|
const timeout = setTimeout(() => done(new AnchaError("INTERNAL", "the local world server did not start within 15 seconds")), 15e3);
|
|
282577
282684
|
const onError = (error65) => done(error65);
|
|
282578
282685
|
const onExit = () => done(new AnchaError("INTERNAL", "the local world server exited while starting"));
|
|
@@ -282592,7 +282699,7 @@ function startWorldServer(cwd, controlToken) {
|
|
|
282592
282699
|
if (error65 !== void 0) {
|
|
282593
282700
|
child3.kill("SIGTERM");
|
|
282594
282701
|
reject4(new AnchaError("INTERNAL", "could not start the local world server", { hint: "run ancha doctor", cause: error65 }));
|
|
282595
|
-
} else
|
|
282702
|
+
} else resolve63(value6);
|
|
282596
282703
|
}
|
|
282597
282704
|
child3.once("error", onError);
|
|
282598
282705
|
child3.once("exit", onExit);
|
|
@@ -282636,7 +282743,7 @@ function ttl(value6) {
|
|
|
282636
282743
|
}
|
|
282637
282744
|
async function onlyConfiguredScene(ctx) {
|
|
282638
282745
|
const config12 = await ctx.loadConfig();
|
|
282639
|
-
const paths3 = (await glob3(config12.scenes, { cwd: ctx.io.cwd, absolute: true, onlyFiles: true })).sort().map((path9) =>
|
|
282746
|
+
const paths3 = (await glob3(config12.scenes, { cwd: ctx.io.cwd, absolute: true, onlyFiles: true })).sort().map((path9) => relative28(ctx.io.cwd, path9));
|
|
282640
282747
|
if (paths3.length === 1) return paths3[0];
|
|
282641
282748
|
throw new AnchaError("USAGE", paths3.length === 0 ? "no test to start a world from" : `ancha.yaml names ${paths3.length} tests; choose one`, {
|
|
282642
282749
|
hint: paths3.length === 0 ? "ancha world up --scene <scene.yaml>" : `ancha world up --scene ${paths3[0]}`
|
|
@@ -282721,7 +282828,7 @@ function registerWorldLifecycle(world5, ctx) {
|
|
|
282721
282828
|
definition3 = { configuration: compiled2.configuration, ...saved.people !== void 0 && { people: saved.people } };
|
|
282722
282829
|
if (saved.people?.length) scene2 = compiled2.scene;
|
|
282723
282830
|
} else {
|
|
282724
|
-
scenePath =
|
|
282831
|
+
scenePath = resolve55(ctx.io.cwd, opts.scene ?? opts.test ?? await onlyConfiguredScene(ctx));
|
|
282725
282832
|
scene2 = (await loadSceneOrTest(ctx.io.cwd, scenePath)).scene;
|
|
282726
282833
|
definition3 = { scene: scene2 };
|
|
282727
282834
|
}
|
|
@@ -282959,7 +283066,7 @@ function environment2() {
|
|
|
282959
283066
|
return Object.fromEntries(["PATH", "HOME", "TMPDIR", "LANG", "SYSTEMROOT"].flatMap((key5) => process.env[key5] ? [[key5, process.env[key5]]] : []));
|
|
282960
283067
|
}
|
|
282961
283068
|
async function run6(file3, args, timeout = 6e5) {
|
|
282962
|
-
return new Promise((
|
|
283069
|
+
return new Promise((resolve63, reject4) => {
|
|
282963
283070
|
const child3 = spawn7(file3, args, { env: environment2(), stdio: ["ignore", "pipe", "pipe"] });
|
|
282964
283071
|
let tail = "";
|
|
282965
283072
|
const collect4 = (chunk) => {
|
|
@@ -282974,7 +283081,7 @@ async function run6(file3, args, timeout = 6e5) {
|
|
|
282974
283081
|
});
|
|
282975
283082
|
child3.once("exit", (code5) => {
|
|
282976
283083
|
clearTimeout(timer);
|
|
282977
|
-
code5 === 0 ?
|
|
283084
|
+
code5 === 0 ? resolve63() : reject4(new AnchaError("AGENT_UNREACHABLE", `Runtime setup failed: ${tail.trim() || file3 + " exited " + code5}`));
|
|
282978
283085
|
});
|
|
282979
283086
|
});
|
|
282980
283087
|
}
|
|
@@ -283084,7 +283191,7 @@ init_src();
|
|
|
283084
283191
|
init_src();
|
|
283085
283192
|
import { constants as constants14 } from "node:fs";
|
|
283086
283193
|
import { lstat as lstat13, mkdir as mkdir35, open as open15, readFile as readFile55, rm as rm22 } from "node:fs/promises";
|
|
283087
|
-
import { dirname as dirname27, join as join72, resolve as
|
|
283194
|
+
import { dirname as dirname27, join as join72, resolve as resolve56 } from "node:path";
|
|
283088
283195
|
|
|
283089
283196
|
// backend/src/company/fetch.ts
|
|
283090
283197
|
init_src();
|
|
@@ -283117,7 +283224,7 @@ function companyUrl(input5) {
|
|
|
283117
283224
|
var networkDeps = {
|
|
283118
283225
|
now: () => performance.now(),
|
|
283119
283226
|
resolve: async (host) => isIP4(host) ? [host] : (await lookup6(host, { all: true, verbatim: true })).map((row2) => row2.address),
|
|
283120
|
-
request: (url4, { address: address9, signal }) => new Promise((
|
|
283227
|
+
request: (url4, { address: address9, signal }) => new Promise((resolve63, reject4) => {
|
|
283121
283228
|
const req = httpsRequest(url4, {
|
|
283122
283229
|
signal,
|
|
283123
283230
|
agent: false,
|
|
@@ -283140,7 +283247,7 @@ var networkDeps = {
|
|
|
283140
283247
|
res.on("error", (error65) => decoder.destroy(error65));
|
|
283141
283248
|
signal.addEventListener("abort", () => decoder.destroy(signal.reason), { once: true });
|
|
283142
283249
|
}
|
|
283143
|
-
|
|
283250
|
+
resolve63({ status: res.statusCode ?? 0, headers, body: decoder ? res.pipe(decoder) : res });
|
|
283144
283251
|
});
|
|
283145
283252
|
req.on("error", reject4);
|
|
283146
283253
|
req.end();
|
|
@@ -283399,7 +283506,7 @@ async function worldCompany(ctx, url4, options5, deps = {}) {
|
|
|
283399
283506
|
let source = null, fetched = [], modelCredit = null;
|
|
283400
283507
|
if (options5.profile) {
|
|
283401
283508
|
try {
|
|
283402
|
-
profile2 = parseCompanyProfile(JSON.parse(await readFile55(
|
|
283509
|
+
profile2 = parseCompanyProfile(JSON.parse(await readFile55(resolve56(ctx.io.cwd, options5.profile), "utf8")));
|
|
283403
283510
|
} catch {
|
|
283404
283511
|
throw new AnchaError("CONFIG_INVALID", "company profile file must contain a valid version 1 profile", { hint: "see ancha docs company" });
|
|
283405
283512
|
}
|
|
@@ -283466,10 +283573,10 @@ async function worldCompany(ctx, url4, options5, deps = {}) {
|
|
|
283466
283573
|
// packages/cli/src/commands/world-from.ts
|
|
283467
283574
|
init_src();
|
|
283468
283575
|
init_assets();
|
|
283469
|
-
import { resolve as
|
|
283576
|
+
import { resolve as resolve57 } from "node:path";
|
|
283470
283577
|
function registerWorldFrom(command, ctx) {
|
|
283471
283578
|
command.command("from").description("save a reusable world from an existing scene, using its tools and starting data (no model)").argument("<scene>", "path to a scene YAML file").option("--id <id>", "world id (default: the scene id)").action(async (file3, options5) => {
|
|
283472
|
-
const scene2 = await loadSceneFile(
|
|
283579
|
+
const scene2 = await loadSceneFile(resolve57(ctx.io.cwd, file3));
|
|
283473
283580
|
const id15 = options5.id ?? scene2.id;
|
|
283474
283581
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(id15)) throw new AnchaError("USAGE", "world id must match [a-z0-9][a-z0-9-]*", { hint: "pass --id <lowercase-world-id>" });
|
|
283475
283582
|
const world5 = sceneWorld(scene2, id15), path9 = `ancha/worlds/${id15}.yaml`;
|
|
@@ -283484,7 +283591,7 @@ function registerWorldFrom(command, ctx) {
|
|
|
283484
283591
|
init_src();
|
|
283485
283592
|
import { existsSync as existsSync5 } from "node:fs";
|
|
283486
283593
|
import { mkdir as mkdir36, readdir as readdir17, readFile as readFile57, stat as stat20, writeFile as writeFile37 } from "node:fs/promises";
|
|
283487
|
-
import { extname as extname3, join as join73, relative as
|
|
283594
|
+
import { extname as extname3, join as join73, relative as relative29, resolve as resolve58 } from "node:path";
|
|
283488
283595
|
|
|
283489
283596
|
// backend/src/kit/netsuite-import.ts
|
|
283490
283597
|
init_src();
|
|
@@ -284017,7 +284124,7 @@ function readFile56(file3, type, notes7) {
|
|
|
284017
284124
|
});
|
|
284018
284125
|
}
|
|
284019
284126
|
function readCsv2(path9, text31, type, notes7) {
|
|
284020
|
-
const
|
|
284127
|
+
const sep10 = /^sep=.\r?\n/i.exec(text31), rows35 = csvRows2(sep10 ? text31.slice(sep10[0].length) : text31);
|
|
284021
284128
|
const at6 = rows35.findIndex((row2) => row2.filter((value6) => value6.trim()).length >= 2);
|
|
284022
284129
|
if (at6 < 0) {
|
|
284023
284130
|
notes7.push(`${path9}: no header row; nothing read from it`);
|
|
@@ -285340,7 +285447,7 @@ function registerWorldImport(world5, ctx) {
|
|
|
285340
285447
|
});
|
|
285341
285448
|
}
|
|
285342
285449
|
async function exportFiles(cwd, path9) {
|
|
285343
|
-
const full2 =
|
|
285450
|
+
const full2 = resolve58(cwd, path9);
|
|
285344
285451
|
let info2;
|
|
285345
285452
|
try {
|
|
285346
285453
|
info2 = await stat20(full2);
|
|
@@ -285368,7 +285475,7 @@ async function worldImportNetsuite(ctx, paths3, options5) {
|
|
|
285368
285475
|
if (options5.start !== void 0 && !(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/.test(options5.start) && !Number.isNaN(Date.parse(options5.start)))) {
|
|
285369
285476
|
throw new AnchaError("USAGE", `--start must be an ISO 8601 time with a timezone, got ${JSON.stringify(options5.start)}`, { hint: "e.g. --start 2026-11-02T14:00:00Z" });
|
|
285370
285477
|
}
|
|
285371
|
-
const outDir =
|
|
285478
|
+
const outDir = resolve58(ctx.io.cwd, options5.out), worldPath = join73(outDir, `${options5.id}.yaml`), rel = (path9) => relative29(ctx.io.cwd, path9) || ".";
|
|
285372
285479
|
if (existsSync5(worldPath) && !options5.force) throw new AnchaError("USAGE", `${rel(worldPath)} already exists`, { hint: "pass --force to overwrite it, or choose another --id" });
|
|
285373
285480
|
const names8 = [...new Set((await Promise.all(paths3.map((path9) => exportFiles(ctx.io.cwd, path9)))).flat())];
|
|
285374
285481
|
if (!names8.length) throw new AnchaError("USAGE", `no export files in ${paths3.join(", ")}`, { hint: "NetSuite exports are .json (REST records, SuiteQL results) and .csv (saved searches)" });
|
|
@@ -285454,7 +285561,7 @@ function registerWorldValidate(world5, ctx) {
|
|
|
285454
285561
|
init_src();
|
|
285455
285562
|
import { constants as constants15 } from "node:fs";
|
|
285456
285563
|
import { open as open16 } from "node:fs/promises";
|
|
285457
|
-
import { resolve as
|
|
285564
|
+
import { resolve as resolve60 } from "node:path";
|
|
285458
285565
|
|
|
285459
285566
|
// backend/src/pytest-record.ts
|
|
285460
285567
|
init_zod();
|
|
@@ -285464,7 +285571,7 @@ init_assets();
|
|
|
285464
285571
|
init_report2();
|
|
285465
285572
|
import { createHash as createHash87, randomBytes as randomBytes12 } from "node:crypto";
|
|
285466
285573
|
import { lstat as lstat14, mkdir as mkdir37, mkdtemp as mkdtemp13, readFile as readFile58, rename as rename13, rm as rm23, writeFile as writeFile38 } from "node:fs/promises";
|
|
285467
|
-
import { dirname as dirname28, join as join74, resolve as
|
|
285574
|
+
import { dirname as dirname28, join as join74, resolve as resolve59 } from "node:path";
|
|
285468
285575
|
var object27 = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
285469
285576
|
var instant = external_exports.string().max(80).refine((value6) => /^\d{4}-\d\d-\d\dT.+(?:Z|[+-]\d\d:\d\d)$/.test(value6) && Number.isFinite(Date.parse(value6)));
|
|
285470
285577
|
var code3 = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_.:-]{0,127}$/);
|
|
@@ -285626,10 +285733,10 @@ async function recordPytestRun(cwd, input5, env2 = {}) {
|
|
|
285626
285733
|
attempts: record32.attempts.map((attempt2) => ({ ...attempt2, errors: cleanErrors(attempt2.errors), worlds: attempt2.worlds.map((world5) => redact3(world5, env2)) }))
|
|
285627
285734
|
};
|
|
285628
285735
|
const fingerprint = hash9(JSON.stringify(cleaned));
|
|
285629
|
-
const outDir =
|
|
285736
|
+
const outDir = resolve59(cwd, DEFAULT_RUNS_DIR), runDir = join74(outDir, record32.runId), relative31 = `${DEFAULT_RUNS_DIR}/${record32.runId}`;
|
|
285630
285737
|
const result = { runId: record32.runId, runDir, source: "pytest", target: "local", next: [`ancha --local runs show ${record32.runId}`, `ancha --local explain ${record32.runId}`] };
|
|
285631
285738
|
const exists7 = async () => {
|
|
285632
|
-
await preflightFiles(cwd, [{ relativePath: `${
|
|
285739
|
+
await preflightFiles(cwd, [{ relativePath: `${relative31}/record.json`, content: "" }]);
|
|
285633
285740
|
const completed = async () => {
|
|
285634
285741
|
const text31 = await readFile58(join74(runDir, "record.json"), "utf8");
|
|
285635
285742
|
let previous;
|
|
@@ -285659,19 +285766,19 @@ async function recordPytestRun(cwd, input5, env2 = {}) {
|
|
|
285659
285766
|
return false;
|
|
285660
285767
|
}
|
|
285661
285768
|
};
|
|
285662
|
-
await preflightFiles(cwd, [{ relativePath: `${
|
|
285769
|
+
await preflightFiles(cwd, [{ relativePath: `${relative31}/summary.json`, content: "" }, { relativePath: `${DEFAULT_RUNS_DIR}/latest`, content: "" }]);
|
|
285663
285770
|
if (await exists7()) return result;
|
|
285664
285771
|
const files2 = artifacts(cleaned, runDir);
|
|
285665
285772
|
files2.set("record.json", json39({ version: 1, fingerprint }));
|
|
285666
285773
|
await mkdir37(outDir, { recursive: true, mode: 448 });
|
|
285667
|
-
await preflightFiles(cwd, [{ relativePath: `${
|
|
285774
|
+
await preflightFiles(cwd, [{ relativePath: `${relative31}/summary.json`, content: "" }]);
|
|
285668
285775
|
const staging = await mkdtemp13(join74(outDir, ".pytest-"));
|
|
285669
285776
|
try {
|
|
285670
285777
|
for (const [path9, content2] of files2) {
|
|
285671
285778
|
await mkdir37(dirname28(join74(staging, path9)), { recursive: true, mode: 448 });
|
|
285672
285779
|
await writeFile38(join74(staging, path9), content2, { flag: "wx", mode: 384 });
|
|
285673
285780
|
}
|
|
285674
|
-
await preflightFiles(cwd, [{ relativePath: `${
|
|
285781
|
+
await preflightFiles(cwd, [{ relativePath: `${relative31}/summary.json`, content: "" }]);
|
|
285675
285782
|
try {
|
|
285676
285783
|
await rename13(staging, runDir);
|
|
285677
285784
|
} catch (error65) {
|
|
@@ -285698,7 +285805,7 @@ function registerWorldRecord(command, ctx) {
|
|
|
285698
285805
|
command.command("record").description("record one completed pytest test and its captured attempts locally").requiredOption("--file <file>", "private JSON record from pytest-ancha").action(async (options5) => {
|
|
285699
285806
|
let handle31;
|
|
285700
285807
|
try {
|
|
285701
|
-
handle31 = await open16(
|
|
285808
|
+
handle31 = await open16(resolve60(ctx.io.cwd, options5.file), constants15.O_RDONLY | constants15.O_NOFOLLOW);
|
|
285702
285809
|
} catch {
|
|
285703
285810
|
throw new AnchaError("USAGE", "pytest record must be a readable regular JSON file");
|
|
285704
285811
|
}
|
|
@@ -285768,12 +285875,12 @@ ${formatTable(value6.configuration.preset.datasets.map((data7) => [data7.tool, d
|
|
|
285768
285875
|
var import_yaml23 = __toESM(require_dist(), 1);
|
|
285769
285876
|
init_src();
|
|
285770
285877
|
import { readFile as readFile59, writeFile as writeFile39 } from "node:fs/promises";
|
|
285771
|
-
import { resolve as
|
|
285878
|
+
import { resolve as resolve61 } from "node:path";
|
|
285772
285879
|
init_credentials();
|
|
285773
285880
|
var NAME_RE2 = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
285774
285881
|
var DEFERRED_SYNC = "Saved in the workspace; the workspace machine picks it up when it starts.";
|
|
285775
285882
|
async function nameInConfig(ctx, names8) {
|
|
285776
|
-
const label7 = ctx.globals().config ?? "ancha.yaml", file3 =
|
|
285883
|
+
const label7 = ctx.globals().config ?? "ancha.yaml", file3 = resolve61(ctx.io.cwd, label7);
|
|
285777
285884
|
const them = names8.length === 1 ? "it" : "them", list19 = names8.join(", ");
|
|
285778
285885
|
const text31 = await readFile59(file3, "utf8").catch(() => void 0);
|
|
285779
285886
|
if (text31 === void 0) return { passEnvHint: `no ${label7} here: list ${list19} under agent.pass_env in the agent's ${label7} so its cloud runs get ${them}` };
|
|
@@ -286200,7 +286307,7 @@ init_run_metadata();
|
|
|
286200
286307
|
var import_yaml24 = __toESM(require_dist(), 1);
|
|
286201
286308
|
init_src();
|
|
286202
286309
|
import { mkdir as mkdir38, readFile as readFile60, stat as stat21, writeFile as writeFile40 } from "node:fs/promises";
|
|
286203
|
-
import { basename as basename18, join as join75, relative as
|
|
286310
|
+
import { basename as basename18, join as join75, relative as relative30, resolve as resolve62 } from "node:path";
|
|
286204
286311
|
init_report2();
|
|
286205
286312
|
init_run_store();
|
|
286206
286313
|
init_credentials();
|
|
@@ -286227,7 +286334,7 @@ var grade = (run7) => {
|
|
|
286227
286334
|
};
|
|
286228
286335
|
var ManagedTaskFields = TestFileSchema.pick({ id: true, title: true, start: true, checks: true, attempts: true, timeout: true }).extend({ id: TestFileSchema.shape.id.max(80) }).partial();
|
|
286229
286336
|
async function testTask(ctx, file3, worldOverride) {
|
|
286230
|
-
const path9 =
|
|
286337
|
+
const path9 = resolve62(ctx.io.cwd, file3);
|
|
286231
286338
|
let doc;
|
|
286232
286339
|
try {
|
|
286233
286340
|
doc = (0, import_yaml24.parse)(await readFile60(path9, "utf8"));
|
|
@@ -286333,7 +286440,7 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
286333
286440
|
if (isCloudId(ref23)) throw new AnchaError("USAGE", `${ref23} ran in the cloud and is in the workspace already`, { hint: `ancha runs show ${ref23}` });
|
|
286334
286441
|
const workspace4 = await uploadWorkspace(ctx);
|
|
286335
286442
|
const summary = await loadRunSummary(ctx.io.cwd, ref23, options5.out);
|
|
286336
|
-
const runDir = join75(
|
|
286443
|
+
const runDir = join75(resolve62(ctx.io.cwd, options5.out ?? DEFAULT_RUNS_DIR), summary.runId);
|
|
286337
286444
|
const inputs2 = JSON.parse(await readFile60(join75(runDir, "inputs.json"), "utf8").catch(() => "{}"));
|
|
286338
286445
|
const passEnv = inputs2.agentEnvironment?.passEnv ?? (await ctx.loadConfig().catch(() => void 0))?.agent?.passEnv ?? [];
|
|
286339
286446
|
const inheritEnv = inputs2.agentEnvironment?.inheritEnv ?? summary.agentEnvironment?.inheritAll === true;
|
|
@@ -286344,9 +286451,9 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
286344
286451
|
if (ref23 === "latest") ref23 = await latestRunId(ctx.io.cwd, options5.out);
|
|
286345
286452
|
onThisComputer(ref23);
|
|
286346
286453
|
const summary = await loadRunSummary(ctx.io.cwd, ref23, options5.out);
|
|
286347
|
-
const dest =
|
|
286454
|
+
const dest = resolve62(ctx.io.cwd, options5.dest ?? join75(".ancha", "exports", summary.runId));
|
|
286348
286455
|
for (const scene2 of summary.scenes) for (const trial of scene2.trialsDetail) {
|
|
286349
|
-
const trace2 = join75(
|
|
286456
|
+
const trace2 = join75(resolve62(ctx.io.cwd, trial.dir), "trace.jsonl");
|
|
286350
286457
|
const recorded2 = await stat21(trace2).then((file3) => file3.isFile(), (error65) => {
|
|
286351
286458
|
if (error65.code === "ENOENT") return false;
|
|
286352
286459
|
throw error65;
|
|
@@ -286356,10 +286463,10 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
286356
286463
|
});
|
|
286357
286464
|
}
|
|
286358
286465
|
await mkdir38(dest, { recursive: true });
|
|
286359
|
-
const inputs2 = await readFile60(join75(
|
|
286466
|
+
const inputs2 = await readFile60(join75(resolve62(ctx.io.cwd, options5.out ?? DEFAULT_RUNS_DIR), summary.runId, "inputs.json"), "utf8").then((text31) => JSON.parse(text31), () => ({}));
|
|
286360
286467
|
const files2 = [], cases = withSeeds(inputs2.cases ?? []);
|
|
286361
286468
|
for (const scene2 of summary.scenes) for (const trial of scene2.trialsDetail) {
|
|
286362
|
-
const dir2 =
|
|
286469
|
+
const dir2 = resolve62(ctx.io.cwd, trial.dir), name5 = basename18(dir2), file3 = join75(dest, `${name5}.ir.jsonl`);
|
|
286363
286470
|
await writeFile40(file3, attemptToIr(await readAttemptTrace(dir2), `${summary.runId}/${name5}`, summary.agent, {
|
|
286364
286471
|
scene: cases.find((c) => c.id === scene2.sceneId)?.scene,
|
|
286365
286472
|
checks: await readFile60(join75(dir2, "checks.json"), "utf8").then((text31) => JSON.parse(text31), () => void 0),
|
|
@@ -286369,7 +286476,7 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
286369
286476
|
}).map((line2) => JSON.stringify(line2)).join("\n") + "\n");
|
|
286370
286477
|
files2.push(file3);
|
|
286371
286478
|
}
|
|
286372
|
-
const upload6 = `ancha traces upload ${shellWord(
|
|
286479
|
+
const upload6 = `ancha traces upload ${shellWord(relative30(ctx.io.cwd, dest) || ".")}`;
|
|
286373
286480
|
ctx.out.result({ runId: summary.runId, files: files2, next: [upload6] }, () => [...files2, `next: ${upload6}`].join("\n"));
|
|
286374
286481
|
});
|
|
286375
286482
|
runs.command("show").argument("<id>", 'a run: run_cloud_\u2026 (a cloud run), play_\u2026 (a playground run), run_\u2026 (a run on this computer), or "latest" (the most recent run from this project, on this computer or in the workspace)').description("show one run with its attempts and grade").action(async (id15) => {
|
|
@@ -286636,7 +286743,7 @@ function nativeModuleError(e) {
|
|
|
286636
286743
|
}
|
|
286637
286744
|
|
|
286638
286745
|
// packages/cli/src/bin.ts
|
|
286639
|
-
var drain = (stream2) => new Promise((
|
|
286746
|
+
var drain = (stream2) => new Promise((resolve63) => stream2.write("", () => resolve63()));
|
|
286640
286747
|
for (const stream2 of [process.stdout, process.stderr]) {
|
|
286641
286748
|
stream2.on("error", (error65) => {
|
|
286642
286749
|
if (error65.code !== "EPIPE" && error65.code !== "ERR_STREAM_DESTROYED") throw error65;
|