@swmansion/argent 0.35.1-next.8 → 0.35.1-next.9
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.
|
@@ -257,7 +257,7 @@ export interface ArgentToolArgs {
|
|
|
257
257
|
path: string;
|
|
258
258
|
/** Time limit in milliseconds. The default is 30000 and the minimum is 100. */
|
|
259
259
|
timeout?: number;
|
|
260
|
-
/** Environment overrides for this script. Argent uses them immediately and saves them on the step. Values can include {{secret:NAME}}. */
|
|
260
|
+
/** Environment overrides for this script. Argent uses them immediately and saves them on the step. Values can include {{secret:NAME}} or {{output:PATH}}. */
|
|
261
261
|
env?: {
|
|
262
262
|
[key: string]: string;
|
|
263
263
|
};
|
package/dist/tool-server.cjs
CHANGED
|
@@ -48465,8 +48465,8 @@ var init_android_binary = __esm({
|
|
|
48465
48465
|
function formatSubprocessFailure(label, args, err) {
|
|
48466
48466
|
const e = err;
|
|
48467
48467
|
const argv = args.join(" ");
|
|
48468
|
-
const
|
|
48469
|
-
const ioDetail =
|
|
48468
|
+
const asText2 = (v) => v == null ? "" : v.toString();
|
|
48469
|
+
const ioDetail = asText2(e.stderr).trim() || asText2(e.stdout).trim();
|
|
48470
48470
|
if (ioDetail) return `${label} ${argv} failed: ${ioDetail}`;
|
|
48471
48471
|
const meta3 = [];
|
|
48472
48472
|
if (e.killed) meta3.push("killed=true");
|
|
@@ -75830,6 +75830,211 @@ function selectRotateCandidate(candidates) {
|
|
|
75830
75830
|
})[0];
|
|
75831
75831
|
}
|
|
75832
75832
|
|
|
75833
|
+
// ../tool-server/src/tools/flows/flow-output.ts
|
|
75834
|
+
init_src();
|
|
75835
|
+
var OUTPUT_REFERENCE_MARKER = "{{output:";
|
|
75836
|
+
var SEGMENT = String.raw`(?:[A-Za-z_][A-Za-z0-9_-]*|0|[1-9]\d*)`;
|
|
75837
|
+
var PATH_RE = new RegExp(`^${SEGMENT}(?:\\.${SEGMENT})*$`);
|
|
75838
|
+
var NUMBER_RE = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
75839
|
+
var MAX_LISTED_KEYS = 20;
|
|
75840
|
+
var GRAMMAR = "write `{{output:PATH}}` or `{{output:PATH ?? FALLBACK}}`, where PATH is keys and array indexes joined by dots, e.g. `{{output:user.id}}` or `{{output:items.0.name ?? none}}`";
|
|
75841
|
+
var OutputReferenceError = class extends Error {
|
|
75842
|
+
};
|
|
75843
|
+
function outputReferenceProblem(text) {
|
|
75844
|
+
try {
|
|
75845
|
+
scan(text);
|
|
75846
|
+
return void 0;
|
|
75847
|
+
} catch (err) {
|
|
75848
|
+
return err.message;
|
|
75849
|
+
}
|
|
75850
|
+
}
|
|
75851
|
+
function holdsOutputMarker(text) {
|
|
75852
|
+
return text.includes(OUTPUT_REFERENCE_MARKER);
|
|
75853
|
+
}
|
|
75854
|
+
function scan(text) {
|
|
75855
|
+
const refs = [];
|
|
75856
|
+
let at = text.indexOf(OUTPUT_REFERENCE_MARKER);
|
|
75857
|
+
while (at !== -1) {
|
|
75858
|
+
const close = text.indexOf("}}", at + OUTPUT_REFERENCE_MARKER.length);
|
|
75859
|
+
if (close === -1) {
|
|
75860
|
+
throw new Error(`has a reference with no closing \`}}\`: ${GRAMMAR}`);
|
|
75861
|
+
}
|
|
75862
|
+
const source = text.slice(at, close + 2);
|
|
75863
|
+
const body = text.slice(at + OUTPUT_REFERENCE_MARKER.length, close);
|
|
75864
|
+
const split = body.indexOf("??");
|
|
75865
|
+
const path74 = (split === -1 ? body : body.slice(0, split)).trim();
|
|
75866
|
+
if (!PATH_RE.test(path74)) {
|
|
75867
|
+
throw new Error(`has an invalid reference ${JSON.stringify(source)}: ${GRAMMAR}`);
|
|
75868
|
+
}
|
|
75869
|
+
const ref = { start: at, end: close + 2, source, path: path74 };
|
|
75870
|
+
if (split !== -1) {
|
|
75871
|
+
const literal2 = body.slice(split + 2).trim();
|
|
75872
|
+
if (!literal2.startsWith('"') && literal2.includes("??")) {
|
|
75873
|
+
throw new Error(
|
|
75874
|
+
`has an invalid reference ${JSON.stringify(source)}: a reference takes one \`??\` fallback`
|
|
75875
|
+
);
|
|
75876
|
+
}
|
|
75877
|
+
if (literal2.includes("{{")) {
|
|
75878
|
+
throw new Error(
|
|
75879
|
+
`has an invalid reference ${JSON.stringify(source)}: a fallback is a literal value, not another reference`
|
|
75880
|
+
);
|
|
75881
|
+
}
|
|
75882
|
+
const value = parseFallback(literal2, source);
|
|
75883
|
+
ref.fallback = { value, text: typeof value === "string" ? value : literal2 };
|
|
75884
|
+
}
|
|
75885
|
+
refs.push(ref);
|
|
75886
|
+
at = text.indexOf(OUTPUT_REFERENCE_MARKER, close + 2);
|
|
75887
|
+
}
|
|
75888
|
+
return refs;
|
|
75889
|
+
}
|
|
75890
|
+
function parseFallback(literal2, source) {
|
|
75891
|
+
if (literal2 === "true") return true;
|
|
75892
|
+
if (literal2 === "false") return false;
|
|
75893
|
+
if (literal2 === "null") return null;
|
|
75894
|
+
if (NUMBER_RE.test(literal2)) {
|
|
75895
|
+
const value = Number(literal2);
|
|
75896
|
+
if (!Number.isFinite(value)) {
|
|
75897
|
+
throw new Error(
|
|
75898
|
+
`has an invalid reference ${JSON.stringify(source)}: the fallback number is too large`
|
|
75899
|
+
);
|
|
75900
|
+
}
|
|
75901
|
+
return value;
|
|
75902
|
+
}
|
|
75903
|
+
if (literal2.startsWith('"')) {
|
|
75904
|
+
let parsed2;
|
|
75905
|
+
try {
|
|
75906
|
+
parsed2 = JSON.parse(literal2);
|
|
75907
|
+
} catch {
|
|
75908
|
+
parsed2 = void 0;
|
|
75909
|
+
}
|
|
75910
|
+
if (typeof parsed2 !== "string") {
|
|
75911
|
+
throw new Error(
|
|
75912
|
+
`has an invalid reference ${JSON.stringify(source)}: a quoted fallback must be one JSON string, e.g. "3"`
|
|
75913
|
+
);
|
|
75914
|
+
}
|
|
75915
|
+
return parsed2;
|
|
75916
|
+
}
|
|
75917
|
+
return literal2;
|
|
75918
|
+
}
|
|
75919
|
+
function isRecord(value) {
|
|
75920
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
75921
|
+
}
|
|
75922
|
+
function lookupOutput(output2, path74) {
|
|
75923
|
+
let node2 = output2;
|
|
75924
|
+
let walked = "output";
|
|
75925
|
+
for (const segment of path74.split(".")) {
|
|
75926
|
+
if (Array.isArray(node2)) {
|
|
75927
|
+
const index = /^\d+$/.test(segment) ? Number(segment) : -1;
|
|
75928
|
+
if (index < 0 || index >= node2.length) {
|
|
75929
|
+
return {
|
|
75930
|
+
found: false,
|
|
75931
|
+
why: `${walked} is a list of ${node2.length} item${node2.length === 1 ? "" : "s"}, with no index ${segment}`
|
|
75932
|
+
};
|
|
75933
|
+
}
|
|
75934
|
+
node2 = node2[index];
|
|
75935
|
+
} else if (isRecord(node2)) {
|
|
75936
|
+
if (!Object.hasOwn(node2, segment)) {
|
|
75937
|
+
const keys = Object.keys(node2);
|
|
75938
|
+
const listed = keys.slice(0, MAX_LISTED_KEYS).join(", ");
|
|
75939
|
+
const more = keys.length > MAX_LISTED_KEYS ? `, and ${keys.length - MAX_LISTED_KEYS} more` : "";
|
|
75940
|
+
return {
|
|
75941
|
+
found: false,
|
|
75942
|
+
why: keys.length === 0 ? `${walked} has no keys` : `${walked} has no key "${segment}" (keys: ${listed}${more})`
|
|
75943
|
+
};
|
|
75944
|
+
}
|
|
75945
|
+
node2 = node2[segment];
|
|
75946
|
+
} else {
|
|
75947
|
+
return { found: false, why: `${walked} is ${describe3(node2)}, not an object or a list` };
|
|
75948
|
+
}
|
|
75949
|
+
walked += `.${segment}`;
|
|
75950
|
+
}
|
|
75951
|
+
if (node2 === null) return { found: false, why: `${walked} is null` };
|
|
75952
|
+
return { found: true, value: node2 };
|
|
75953
|
+
}
|
|
75954
|
+
function describe3(value) {
|
|
75955
|
+
if (value === null) return "null";
|
|
75956
|
+
if (typeof value === "string") return "a string";
|
|
75957
|
+
return `a ${typeof value}`;
|
|
75958
|
+
}
|
|
75959
|
+
function resolveRef2(ref, output2) {
|
|
75960
|
+
const hit = lookupOutput(output2, ref.path);
|
|
75961
|
+
if (hit.found) return hit;
|
|
75962
|
+
if (ref.fallback) return { found: false, fallback: ref.fallback };
|
|
75963
|
+
throw new OutputReferenceError(`${ref.source} has no value: ${hit.why}`);
|
|
75964
|
+
}
|
|
75965
|
+
function asText(value, ref) {
|
|
75966
|
+
if (typeof value === "string") return value;
|
|
75967
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
75968
|
+
throw new OutputReferenceError(
|
|
75969
|
+
`${ref.source} is ${Array.isArray(value) ? "a list" : "an object"}, which cannot be part of text: reference one of its values`
|
|
75970
|
+
);
|
|
75971
|
+
}
|
|
75972
|
+
function secretRefusal(ref) {
|
|
75973
|
+
return new OutputReferenceError(
|
|
75974
|
+
`${ref.source} would put a {{secret:...}} placeholder in the step. A value from a script's output never resolves a secret: write the placeholder in the e2e test file instead`
|
|
75975
|
+
);
|
|
75976
|
+
}
|
|
75977
|
+
function resolveOutputText(text, output2) {
|
|
75978
|
+
const refs = scan(text);
|
|
75979
|
+
if (refs.length === 0) return text;
|
|
75980
|
+
let resolved = "";
|
|
75981
|
+
let copied = 0;
|
|
75982
|
+
const spans = [];
|
|
75983
|
+
for (const ref of refs) {
|
|
75984
|
+
resolved += text.slice(copied, ref.start);
|
|
75985
|
+
const hit = resolveRef2(ref, output2);
|
|
75986
|
+
const value = hit.found ? asText(hit.value, ref) : hit.fallback.text;
|
|
75987
|
+
spans.push({ from: resolved.length, to: resolved.length + value.length, ref });
|
|
75988
|
+
resolved += value;
|
|
75989
|
+
copied = ref.end;
|
|
75990
|
+
}
|
|
75991
|
+
resolved += text.slice(copied);
|
|
75992
|
+
for (const match of resolved.matchAll(SECRET_PLACEHOLDER_RE)) {
|
|
75993
|
+
const from2 = match.index;
|
|
75994
|
+
const to = from2 + match[0].length;
|
|
75995
|
+
const span = spans.find((s) => s.from < to && s.to > from2);
|
|
75996
|
+
if (span) throw secretRefusal(span.ref);
|
|
75997
|
+
}
|
|
75998
|
+
return resolved;
|
|
75999
|
+
}
|
|
76000
|
+
function resolveOutputValue(text, output2) {
|
|
76001
|
+
const refs = scan(text);
|
|
76002
|
+
const only = refs.length === 1 ? refs[0] : void 0;
|
|
76003
|
+
if (!only || only.start !== 0 || only.end !== text.length) return resolveOutputText(text, output2);
|
|
76004
|
+
const hit = resolveRef2(only, output2);
|
|
76005
|
+
const value = hit.found ? hit.value : hit.fallback.value;
|
|
76006
|
+
if (new RegExp(SECRET_PLACEHOLDER_RE.source).test(JSON.stringify(value))) {
|
|
76007
|
+
throw secretRefusal(only);
|
|
76008
|
+
}
|
|
76009
|
+
return structuredClone(value);
|
|
76010
|
+
}
|
|
76011
|
+
var OUTPUT_CHECK_TESTS = ["exists", "equals", "contains", "matches"];
|
|
76012
|
+
function outputPathProblem(path74) {
|
|
76013
|
+
if (typeof path74 === "string" && PATH_RE.test(path74)) return void 0;
|
|
76014
|
+
return "output needs a path of keys and array indexes joined by dots, without braces, e.g. `output: user.id`";
|
|
76015
|
+
}
|
|
76016
|
+
function evaluateOutputCheck(check3, output2) {
|
|
76017
|
+
const expected = check3.expected;
|
|
76018
|
+
const hit = lookupOutput(output2, check3.path);
|
|
76019
|
+
const at = `output.${check3.path}`;
|
|
76020
|
+
if (check3.test === "exists") {
|
|
76021
|
+
const ok2 = hit.found === expected;
|
|
76022
|
+
return { ok: ok2, reason: hit.found ? `${at} is set` : hit.why };
|
|
76023
|
+
}
|
|
76024
|
+
if (!hit.found) return { ok: false, reason: hit.why };
|
|
76025
|
+
const value = hit.value;
|
|
76026
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
76027
|
+
return {
|
|
76028
|
+
ok: false,
|
|
76029
|
+
reason: `${at} is ${Array.isArray(value) ? "a list" : "an object"}: check one of its values`
|
|
76030
|
+
};
|
|
76031
|
+
}
|
|
76032
|
+
const actual = String(value);
|
|
76033
|
+
const want = String(expected);
|
|
76034
|
+
const ok = check3.test === "equals" ? actual === want : check3.test === "contains" ? actual.includes(want) : new RegExp(want).test(actual);
|
|
76035
|
+
return { ok, reason: `${at} is ${JSON.stringify(actual)}` };
|
|
76036
|
+
}
|
|
76037
|
+
|
|
75833
76038
|
// ../tool-server/src/tools/flows/flow-utils.ts
|
|
75834
76039
|
function windowsPathRefusal(label, value) {
|
|
75835
76040
|
if (process.platform === "win32" || path14.isAbsolute(value) || !path14.win32.isAbsolute(value)) {
|
|
@@ -76052,6 +76257,7 @@ function precedesLeadingLaunch(step) {
|
|
|
76052
76257
|
switch (step.kind) {
|
|
76053
76258
|
case "echo":
|
|
76054
76259
|
case "script":
|
|
76260
|
+
case "output-check":
|
|
76055
76261
|
return true;
|
|
76056
76262
|
case "launch":
|
|
76057
76263
|
case "run":
|
|
@@ -76364,7 +76570,7 @@ function toYamlStep(step) {
|
|
|
76364
76570
|
case "run":
|
|
76365
76571
|
return { run: step.flow };
|
|
76366
76572
|
case "when": {
|
|
76367
|
-
const when = step.condition.kind === "platform" ? { platform: step.condition.platform } : waitToYaml(
|
|
76573
|
+
const when = step.condition.kind === "platform" ? { platform: step.condition.platform } : step.condition.kind === "output" ? outputCheckToYaml(step.condition.check) : waitToYaml(
|
|
76368
76574
|
step.condition.condition,
|
|
76369
76575
|
step.condition.selector,
|
|
76370
76576
|
step.condition.expectedText,
|
|
@@ -76443,6 +76649,8 @@ function toYamlStep(step) {
|
|
|
76443
76649
|
void 0
|
|
76444
76650
|
)
|
|
76445
76651
|
};
|
|
76652
|
+
case "output-check":
|
|
76653
|
+
return { assert: outputCheckToYaml(step.check) };
|
|
76446
76654
|
case "wait":
|
|
76447
76655
|
return { wait: step.ms };
|
|
76448
76656
|
case "scroll-to": {
|
|
@@ -76722,7 +76930,7 @@ var TEXT_MATCH_MODES = Object.keys({
|
|
|
76722
76930
|
});
|
|
76723
76931
|
var SCROLL_DIRECTIONS = ["up", "down", "left", "right"];
|
|
76724
76932
|
function parseWaitFields(raw, kind) {
|
|
76725
|
-
const legalKeys = kind === "await" ? [...WAIT_CONDITIONS, IDLE_CONDITION] : WAIT_CONDITIONS;
|
|
76933
|
+
const legalKeys = kind === "await" ? [...WAIT_CONDITIONS, IDLE_CONDITION] : kind === "assert" ? [...WAIT_CONDITIONS, "output"] : WAIT_CONDITIONS;
|
|
76726
76934
|
if (raw === null || typeof raw !== "object") {
|
|
76727
76935
|
badEntry({ [kind]: raw }, `${kind} needs a condition (${legalKeys.join(", ")})`);
|
|
76728
76936
|
}
|
|
@@ -77216,8 +77424,44 @@ function foldStepFromArgs(args) {
|
|
|
77216
77424
|
return void 0;
|
|
77217
77425
|
}
|
|
77218
77426
|
}
|
|
77427
|
+
function parseOutputCheck(b, kind) {
|
|
77428
|
+
const entry = { [kind]: b };
|
|
77429
|
+
const pathProblem = outputPathProblem(b.output);
|
|
77430
|
+
if (pathProblem) badEntry(entry, `${kind} ${pathProblem}`);
|
|
77431
|
+
rejectUnknownKeys(entry, b, ["output", ...OUTPUT_CHECK_TESTS], `${kind}.output`);
|
|
77432
|
+
const tests = OUTPUT_CHECK_TESTS.filter((test2) => test2 in b);
|
|
77433
|
+
if (tests.length !== 1) {
|
|
77434
|
+
badEntry(
|
|
77435
|
+
entry,
|
|
77436
|
+
`${kind} output needs exactly one of \`exists\`, \`equals\`, \`contains\` or \`matches\`, e.g. \`${kind}: { output: user.role, equals: admin }\``
|
|
77437
|
+
);
|
|
77438
|
+
}
|
|
77439
|
+
const test = tests[0];
|
|
77440
|
+
const path74 = b.output;
|
|
77441
|
+
const value = b[test];
|
|
77442
|
+
if (test === "exists") {
|
|
77443
|
+
if (typeof value !== "boolean")
|
|
77444
|
+
badEntry(entry, `${kind} output \`exists\` takes true or false`);
|
|
77445
|
+
return { path: path74, test, expected: value };
|
|
77446
|
+
}
|
|
77447
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
77448
|
+
badEntry(
|
|
77449
|
+
entry,
|
|
77450
|
+
`${kind} output \`${test}\` compares text: quote the value, e.g. \`${test}: "${value}"\``
|
|
77451
|
+
);
|
|
77452
|
+
}
|
|
77453
|
+
const expected = value;
|
|
77454
|
+
if (typeof expected !== "string" || expected === "" && test !== "equals") {
|
|
77455
|
+
badEntry(entry, `${kind} output \`${test}\` needs a non-empty string`);
|
|
77456
|
+
}
|
|
77457
|
+
if (test === "matches") validatePattern(entry, expected, `${kind} output`);
|
|
77458
|
+
return { path: path74, test, expected };
|
|
77459
|
+
}
|
|
77460
|
+
function outputCheckToYaml(check3) {
|
|
77461
|
+
return { output: check3.path, [check3.test]: check3.expected };
|
|
77462
|
+
}
|
|
77219
77463
|
function parseWhenCondition(raw) {
|
|
77220
|
-
const conditionKeys = `${WAIT_CONDITIONS.join(", ")}, platform`;
|
|
77464
|
+
const conditionKeys = `${WAIT_CONDITIONS.join(", ")}, platform, output`;
|
|
77221
77465
|
if (raw === null || typeof raw !== "object") {
|
|
77222
77466
|
badEntry({ when: raw }, `when needs exactly one condition key (${conditionKeys})`);
|
|
77223
77467
|
}
|
|
@@ -77228,6 +77472,7 @@ function parseWhenCondition(raw) {
|
|
|
77228
77472
|
"when has no idle form \u2014 stillness is a wait, and a guard asks what is on the screen now. Put `await: { idle: true }` before the block instead"
|
|
77229
77473
|
);
|
|
77230
77474
|
}
|
|
77475
|
+
if ("output" in b) return { kind: "output", check: parseOutputCheck(b, "when") };
|
|
77231
77476
|
const present = [...WAIT_CONDITIONS, "platform"].filter((c) => c in b);
|
|
77232
77477
|
if (present.length !== 1) {
|
|
77233
77478
|
badEntry({ when: raw }, `when needs exactly one condition key (${conditionKeys})`);
|
|
@@ -77349,14 +77594,14 @@ function parseScriptStep(raw, body) {
|
|
|
77349
77594
|
};
|
|
77350
77595
|
if (b.timeout !== void 0) step.timeout = parseScriptTimeout(raw, b.timeout);
|
|
77351
77596
|
if (b.env !== void 0) {
|
|
77352
|
-
const problem = flowEnvProblem(b.env);
|
|
77597
|
+
const problem = flowEnvProblem(b.env, { references: true });
|
|
77353
77598
|
if (problem) badEntry(raw, `script.env ${problem}`);
|
|
77354
77599
|
step.env = b.env;
|
|
77355
77600
|
}
|
|
77356
77601
|
return step;
|
|
77357
77602
|
}
|
|
77358
77603
|
var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
77359
|
-
function flowEnvProblem(value) {
|
|
77604
|
+
function flowEnvProblem(value, { references = false } = {}) {
|
|
77360
77605
|
if (value === null || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
|
|
77361
77606
|
return "must be a map of variable names to string values, e.g. `env: { API_URL: https://example.com }`";
|
|
77362
77607
|
}
|
|
@@ -77370,9 +77615,11 @@ function flowEnvProblem(value) {
|
|
|
77370
77615
|
}
|
|
77371
77616
|
if (typeof entry !== "string") return `has a non-string value for ${name}`;
|
|
77372
77617
|
if (entry.includes("\0")) return `has a NUL character in the value of ${name}`;
|
|
77373
|
-
if (entry
|
|
77374
|
-
return `
|
|
77618
|
+
if (!references && holdsOutputMarker(entry)) {
|
|
77619
|
+
return `has an {{output:...}} reference in the value of ${name}: only the env: of the script step that reads it takes one`;
|
|
77375
77620
|
}
|
|
77621
|
+
const problem = outputReferenceProblem(entry);
|
|
77622
|
+
if (problem) return `${name} ${problem}`;
|
|
77376
77623
|
}
|
|
77377
77624
|
return void 0;
|
|
77378
77625
|
}
|
|
@@ -77440,76 +77687,153 @@ function parseScriptTimeout(raw, value) {
|
|
|
77440
77687
|
}
|
|
77441
77688
|
return value;
|
|
77442
77689
|
}
|
|
77443
|
-
|
|
77444
|
-
|
|
77445
|
-
|
|
77446
|
-
|
|
77690
|
+
function* selectorFields(sel, where) {
|
|
77691
|
+
if (sel.text !== void 0) {
|
|
77692
|
+
yield {
|
|
77693
|
+
where: `${where}.text`,
|
|
77694
|
+
value: sel.text,
|
|
77695
|
+
set: (v) => sel.text = v,
|
|
77696
|
+
required: "visible"
|
|
77697
|
+
};
|
|
77698
|
+
}
|
|
77699
|
+
if (sel.textMatches !== void 0)
|
|
77447
77700
|
yield { where: `${where}.text.matches`, value: sel.textMatches };
|
|
77701
|
+
if (sel.identifier !== void 0) {
|
|
77702
|
+
yield {
|
|
77703
|
+
where: `${where}.id`,
|
|
77704
|
+
value: sel.identifier,
|
|
77705
|
+
set: (v) => sel.identifier = v,
|
|
77706
|
+
required: "visible"
|
|
77707
|
+
};
|
|
77708
|
+
}
|
|
77709
|
+
if (sel.role !== void 0) {
|
|
77710
|
+
yield {
|
|
77711
|
+
where: `${where}.role`,
|
|
77712
|
+
value: sel.role,
|
|
77713
|
+
set: (v) => sel.role = v,
|
|
77714
|
+
required: "visible"
|
|
77715
|
+
};
|
|
77448
77716
|
}
|
|
77449
|
-
if (sel.identifier !== void 0) yield { where: `${where}.id`, value: sel.identifier };
|
|
77450
|
-
if (sel.role !== void 0) yield { where: `${where}.role`, value: sel.role };
|
|
77451
77717
|
for (const relation of SELECTOR_RELATIONS) {
|
|
77452
77718
|
const nested = sel[relation];
|
|
77453
|
-
if (nested !== void 0) yield* selectorFields(nested, `${where}.${relation}
|
|
77719
|
+
if (nested !== void 0) yield* selectorFields(nested, `${where}.${relation}`);
|
|
77454
77720
|
}
|
|
77455
77721
|
}
|
|
77456
|
-
function* argFields(value, where, seen = /* @__PURE__ */ new Set()) {
|
|
77722
|
+
function* argFields(value, where, set2, typed = true, seen = /* @__PURE__ */ new Set()) {
|
|
77457
77723
|
if (typeof value === "string") {
|
|
77458
|
-
yield { where, value };
|
|
77724
|
+
yield { where, value, ...set2 ? { set: set2, typed } : {} };
|
|
77459
77725
|
return;
|
|
77460
77726
|
}
|
|
77461
77727
|
if (value === null || typeof value !== "object") return;
|
|
77462
77728
|
if (seen.has(value)) return;
|
|
77463
77729
|
seen.add(value);
|
|
77730
|
+
const settable = set2 !== void 0;
|
|
77464
77731
|
if (Array.isArray(value)) {
|
|
77465
|
-
for (const [i, item] of value.entries())
|
|
77732
|
+
for (const [i, item] of value.entries()) {
|
|
77733
|
+
yield* argFields(
|
|
77734
|
+
item,
|
|
77735
|
+
`${where}[${i}]`,
|
|
77736
|
+
settable ? (v) => value[i] = v : void 0,
|
|
77737
|
+
typed,
|
|
77738
|
+
seen
|
|
77739
|
+
);
|
|
77740
|
+
}
|
|
77466
77741
|
} else if (value instanceof Map) {
|
|
77467
|
-
for (const [key2, item] of value)
|
|
77742
|
+
for (const [key2, item] of value) {
|
|
77743
|
+
yield* argFields(
|
|
77744
|
+
item,
|
|
77745
|
+
`${where}.${String(key2)}`,
|
|
77746
|
+
settable ? (v) => value.set(key2, v) : void 0,
|
|
77747
|
+
typed,
|
|
77748
|
+
seen
|
|
77749
|
+
);
|
|
77750
|
+
}
|
|
77468
77751
|
} else if (value instanceof Set) {
|
|
77469
|
-
for (const item of value) yield* argFields(item, where, seen);
|
|
77752
|
+
for (const item of value) yield* argFields(item, where, void 0, typed, seen);
|
|
77470
77753
|
} else {
|
|
77471
|
-
|
|
77472
|
-
|
|
77754
|
+
const record2 = value;
|
|
77755
|
+
for (const [key2, item] of Object.entries(record2)) {
|
|
77756
|
+
if (holdsOutputMarker(key2)) yield { where: `${where}.${key2}`, value: key2 };
|
|
77757
|
+
yield* argFields(
|
|
77758
|
+
item,
|
|
77759
|
+
`${where}.${key2}`,
|
|
77760
|
+
settable ? (v) => record2[key2] = v : void 0,
|
|
77761
|
+
typed,
|
|
77762
|
+
seen
|
|
77763
|
+
);
|
|
77764
|
+
}
|
|
77473
77765
|
}
|
|
77474
77766
|
seen.delete(value);
|
|
77475
77767
|
}
|
|
77768
|
+
function* toolArgFields(step) {
|
|
77769
|
+
if (canonicalToolId(step.name) !== "e2e-execute") {
|
|
77770
|
+
yield* argFields(step.args, "args", () => {
|
|
77771
|
+
});
|
|
77772
|
+
return;
|
|
77773
|
+
}
|
|
77774
|
+
for (const [key2, item] of Object.entries(step.args)) {
|
|
77775
|
+
if (holdsOutputMarker(key2)) yield { where: `args.${key2}`, value: key2 };
|
|
77776
|
+
const settable = key2 === "env" ? (v) => step.args[key2] = v : void 0;
|
|
77777
|
+
yield* argFields(item, `args.${key2}`, settable, typeof item === "string");
|
|
77778
|
+
}
|
|
77779
|
+
}
|
|
77476
77780
|
function gestureTargetPath(step) {
|
|
77477
77781
|
if (step.kind === "pinch" || step.kind === "rotate") return { path: `${step.kind}.on` };
|
|
77478
77782
|
const option = step.kind === "tap" ? step.times ?? step.button ?? step.modifiers : step.duration;
|
|
77479
77783
|
if (option !== void 0) return { path: `${step.kind}.on` };
|
|
77480
77784
|
return { path: step.kind, alt: `${step.kind}.on` };
|
|
77481
77785
|
}
|
|
77482
|
-
function* conditionFields(kind, cond
|
|
77786
|
+
function* conditionFields(kind, cond) {
|
|
77483
77787
|
yield* selectorFields(
|
|
77484
77788
|
cond.selector,
|
|
77485
|
-
cond.condition === "text" ? `${kind}.text.in` : `${kind}.${cond.condition}
|
|
77486
|
-
patterns
|
|
77789
|
+
cond.condition === "text" ? `${kind}.text.in` : `${kind}.${cond.condition}`
|
|
77487
77790
|
);
|
|
77488
|
-
if (cond.expectedText !== void 0
|
|
77791
|
+
if (cond.expectedText !== void 0) {
|
|
77489
77792
|
yield {
|
|
77490
77793
|
where: cond.textMatch ? `${kind}.text.${cond.textMatch}` : `${kind}.text`,
|
|
77491
|
-
value: cond.expectedText
|
|
77794
|
+
value: cond.expectedText,
|
|
77795
|
+
...cond.textMatch === "matches" ? {} : { set: (v) => cond.expectedText = v, required: "nonEmpty" }
|
|
77492
77796
|
};
|
|
77493
77797
|
}
|
|
77494
77798
|
}
|
|
77799
|
+
function* outputCheckFields(kind, check3) {
|
|
77800
|
+
if (typeof check3.expected !== "string") return;
|
|
77801
|
+
yield {
|
|
77802
|
+
where: `${kind}.${check3.test}`,
|
|
77803
|
+
value: check3.expected,
|
|
77804
|
+
...check3.test === "matches" ? {} : { set: (v) => check3.expected = v },
|
|
77805
|
+
...check3.test === "contains" ? { required: "nonEmpty" } : {}
|
|
77806
|
+
};
|
|
77807
|
+
}
|
|
77495
77808
|
function* outputReferenceFields(step) {
|
|
77496
77809
|
switch (step.kind) {
|
|
77810
|
+
// Narration: a run's verdict never counts an echo, so one that could not
|
|
77811
|
+
// resolve a reference would stop the run and still read as a pass.
|
|
77497
77812
|
case "echo":
|
|
77498
77813
|
yield { where: "echo", value: step.message };
|
|
77499
77814
|
return;
|
|
77500
77815
|
case "tool":
|
|
77501
|
-
yield*
|
|
77816
|
+
yield* toolArgFields(step);
|
|
77502
77817
|
return;
|
|
77503
77818
|
case "type":
|
|
77504
77819
|
yield* selectorFields(step.into, "type.into");
|
|
77505
|
-
yield {
|
|
77820
|
+
yield {
|
|
77821
|
+
where: "type.text",
|
|
77822
|
+
value: step.text,
|
|
77823
|
+
set: (v) => step.text = v,
|
|
77824
|
+
required: "nonEmpty"
|
|
77825
|
+
};
|
|
77506
77826
|
return;
|
|
77507
77827
|
case "await":
|
|
77508
77828
|
case "assert":
|
|
77509
77829
|
yield* conditionFields(step.kind, step);
|
|
77510
77830
|
return;
|
|
77831
|
+
case "output-check":
|
|
77832
|
+
yield* outputCheckFields("assert", step.check);
|
|
77833
|
+
return;
|
|
77511
77834
|
case "when":
|
|
77512
|
-
if (step.condition.kind === "ui") yield* conditionFields("when", step.condition
|
|
77835
|
+
if (step.condition.kind === "ui") yield* conditionFields("when", step.condition);
|
|
77836
|
+
if (step.condition.kind === "output") yield* outputCheckFields("when", step.condition.check);
|
|
77513
77837
|
return;
|
|
77514
77838
|
case "tap":
|
|
77515
77839
|
case "long-press":
|
|
@@ -77538,12 +77862,22 @@ function* outputReferenceFields(step) {
|
|
|
77538
77862
|
if (step.within) yield* selectorFields(step.within, "scroll-to.within");
|
|
77539
77863
|
return;
|
|
77540
77864
|
case "snapshot":
|
|
77541
|
-
if (step.cropOn)
|
|
77542
|
-
|
|
77543
|
-
|
|
77865
|
+
if (step.cropOn) {
|
|
77866
|
+
for (const field2 of selectorFields(step.cropOn, "snapshot.cropOn")) {
|
|
77867
|
+
yield { where: field2.where, value: field2.value };
|
|
77868
|
+
}
|
|
77869
|
+
}
|
|
77544
77870
|
return;
|
|
77871
|
+
// Which app and which test a step starts are spelled in the file.
|
|
77545
77872
|
case "launch":
|
|
77873
|
+
yield* argFields(step.app, "launch", void 0);
|
|
77874
|
+
return;
|
|
77546
77875
|
case "run":
|
|
77876
|
+
yield { where: "run", value: step.flow };
|
|
77877
|
+
return;
|
|
77878
|
+
// A script's env values resolve when the step runs, merged across the
|
|
77879
|
+
// layers (`runFlowScriptStep`), and parse through `flowEnvProblem`.
|
|
77880
|
+
case "script":
|
|
77547
77881
|
case "idle":
|
|
77548
77882
|
case "wait":
|
|
77549
77883
|
case "fold":
|
|
@@ -77557,29 +77891,62 @@ function* outputReferenceFields(step) {
|
|
|
77557
77891
|
}
|
|
77558
77892
|
function holdsOutputReference(step) {
|
|
77559
77893
|
for (const field2 of outputReferenceFields(step)) {
|
|
77560
|
-
if (field2.value
|
|
77894
|
+
if (holdsOutputMarker(field2.value)) return true;
|
|
77895
|
+
}
|
|
77896
|
+
if (step.kind === "script" && step.env) {
|
|
77897
|
+
if (Object.values(step.env).some(holdsOutputMarker)) return true;
|
|
77561
77898
|
}
|
|
77562
77899
|
return blockSteps(step)?.some(holdsOutputReference) ?? false;
|
|
77563
77900
|
}
|
|
77564
|
-
function
|
|
77901
|
+
function resolveStepOutputs(step, output2) {
|
|
77902
|
+
if (![...outputReferenceFields(step)].some((field2) => holdsOutputMarker(field2.value))) {
|
|
77903
|
+
return step;
|
|
77904
|
+
}
|
|
77905
|
+
const copy = structuredClone(step);
|
|
77906
|
+
const fields = [...outputReferenceFields(copy)];
|
|
77907
|
+
for (const field2 of fields) {
|
|
77908
|
+
if (!field2.set || !holdsOutputMarker(field2.value)) continue;
|
|
77909
|
+
const value = field2.typed ? resolveOutputValue(field2.value, output2) : resolveOutputText(field2.value, output2);
|
|
77910
|
+
if (field2.required === "visible" && !hasVisibleText(value)) {
|
|
77911
|
+
throw new OutputReferenceError(
|
|
77912
|
+
`\`${field2.where}\` resolved to ${JSON.stringify(value)}, which has no visible text and would match any element`
|
|
77913
|
+
);
|
|
77914
|
+
}
|
|
77915
|
+
if (field2.required === "nonEmpty" && value === "") {
|
|
77916
|
+
throw new OutputReferenceError(`\`${field2.where}\` resolved to an empty value`);
|
|
77917
|
+
}
|
|
77918
|
+
field2.set(value);
|
|
77919
|
+
}
|
|
77920
|
+
return copy;
|
|
77921
|
+
}
|
|
77922
|
+
function stepOutputReferenceProblem(step) {
|
|
77923
|
+
for (const field2 of outputReferenceFields(step)) {
|
|
77924
|
+
if (!holdsOutputMarker(field2.value)) continue;
|
|
77925
|
+
const locator = field2.altWhere ? `\`${field2.where}\` (spelled \`${field2.altWhere}\` if the target sits under \`on:\`)` : `\`${field2.where}\``;
|
|
77926
|
+
if (field2.set) {
|
|
77927
|
+
const problem = outputReferenceProblem(field2.value);
|
|
77928
|
+
if (problem) return `${locator} ${problem}`;
|
|
77929
|
+
continue;
|
|
77930
|
+
}
|
|
77931
|
+
const rendered = field2.value.length > MAX_ENTRY_RENDER_CHARS ? `${field2.value.slice(0, MAX_ENTRY_RENDER_CHARS)}\u2026` : field2.value;
|
|
77932
|
+
return `${locator} takes no {{output:...}} reference. Replace it with the literal value the step needs: ${JSON.stringify(rendered)}`;
|
|
77933
|
+
}
|
|
77934
|
+
return void 0;
|
|
77935
|
+
}
|
|
77936
|
+
function assertOutputReferences(steps, trail = []) {
|
|
77565
77937
|
steps.forEach((step, i) => {
|
|
77566
77938
|
const at = [...trail, i + 1];
|
|
77567
|
-
|
|
77568
|
-
|
|
77569
|
-
|
|
77570
|
-
|
|
77571
|
-
|
|
77572
|
-
|
|
77573
|
-
|
|
77574
|
-
|
|
77575
|
-
failure_stage: "flow_output_reference",
|
|
77576
|
-
failure_area: "tool_server",
|
|
77577
|
-
error_kind: "validation"
|
|
77578
|
-
}
|
|
77579
|
-
);
|
|
77939
|
+
const problem = stepOutputReferenceProblem(step);
|
|
77940
|
+
if (problem) {
|
|
77941
|
+
throw new FailureError(`Step ${at.join(".")} (\`${step.kind}\`): ${problem}`, {
|
|
77942
|
+
error_code: FAILURE_CODES.FLOW_ENTRY_UNRECOGNIZED,
|
|
77943
|
+
failure_stage: "flow_output_reference",
|
|
77944
|
+
failure_area: "tool_server",
|
|
77945
|
+
error_kind: "validation"
|
|
77946
|
+
});
|
|
77580
77947
|
}
|
|
77581
77948
|
const inner = blockSteps(step);
|
|
77582
|
-
if (inner)
|
|
77949
|
+
if (inner) assertOutputReferences(inner, at);
|
|
77583
77950
|
});
|
|
77584
77951
|
}
|
|
77585
77952
|
var SWIPE_DIRECTIONS = ["up", "down", "left", "right"];
|
|
@@ -77754,6 +78121,12 @@ function fromYamlStep(raw, blockDepth = 0) {
|
|
|
77754
78121
|
}
|
|
77755
78122
|
if ("await" in raw) {
|
|
77756
78123
|
const body = raw.await;
|
|
78124
|
+
if (body !== null && typeof body === "object" && "output" in body) {
|
|
78125
|
+
badEntry(
|
|
78126
|
+
raw,
|
|
78127
|
+
"await has no output form \u2014 a script's output does not change while the step waits; use `assert: { output: \u2026 }`"
|
|
78128
|
+
);
|
|
78129
|
+
}
|
|
77757
78130
|
if (isIdleCondition(body, "await")) {
|
|
77758
78131
|
return parseIdleFields(body, "await");
|
|
77759
78132
|
}
|
|
@@ -77761,6 +78134,12 @@ function fromYamlStep(raw, blockDepth = 0) {
|
|
|
77761
78134
|
}
|
|
77762
78135
|
if ("assert" in raw) {
|
|
77763
78136
|
const body = raw.assert;
|
|
78137
|
+
if (body !== null && typeof body === "object" && "output" in body) {
|
|
78138
|
+
return {
|
|
78139
|
+
kind: "output-check",
|
|
78140
|
+
check: parseOutputCheck(body, "assert")
|
|
78141
|
+
};
|
|
78142
|
+
}
|
|
77764
78143
|
if (isIdleCondition(body, "assert")) {
|
|
77765
78144
|
return parseIdleFields(body, "assert");
|
|
77766
78145
|
}
|
|
@@ -77883,7 +78262,7 @@ function serializeFlow(flow) {
|
|
|
77883
78262
|
return (0, import_yaml.stringify)(doc, { blockQuote: false, doubleQuotedMinMultiLineLength: Infinity });
|
|
77884
78263
|
}
|
|
77885
78264
|
function validateFlow(flow) {
|
|
77886
|
-
|
|
78265
|
+
assertOutputReferences(flow.steps);
|
|
77887
78266
|
if (isE2eFlow(flow) && flow.executionPrerequisite) {
|
|
77888
78267
|
throw new FailureError(
|
|
77889
78268
|
"An e2e test whose first step other than `echo:`/`script:` is a `launch` must not declare executionPrerequisite \u2014 it launches its own app and controls its start state. Drop that launch to make it a fragment, or drop executionPrerequisite.",
|
|
@@ -122895,7 +123274,7 @@ function appIdentifier(v) {
|
|
|
122895
123274
|
const id = str2(v);
|
|
122896
123275
|
return id && !APPKIT_IDENTIFIER.test(id) ? id : void 0;
|
|
122897
123276
|
}
|
|
122898
|
-
function
|
|
123277
|
+
function isRecord2(v) {
|
|
122899
123278
|
return typeof v === "object" && v !== null;
|
|
122900
123279
|
}
|
|
122901
123280
|
function str2(v) {
|
|
@@ -122905,7 +123284,7 @@ function finite(v) {
|
|
|
122905
123284
|
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
122906
123285
|
}
|
|
122907
123286
|
function asRect(v) {
|
|
122908
|
-
if (!
|
|
123287
|
+
if (!isRecord2(v)) return void 0;
|
|
122909
123288
|
const [x, y, width, height] = [v.x, v.y, v.width, v.height].map(finite);
|
|
122910
123289
|
if (x === void 0 || y === void 0 || width === void 0 || height === void 0) {
|
|
122911
123290
|
return void 0;
|
|
@@ -122913,7 +123292,7 @@ function asRect(v) {
|
|
|
122913
123292
|
return width < 0 || height < 0 ? void 0 : { x, y, width, height };
|
|
122914
123293
|
}
|
|
122915
123294
|
function asWebItem(v) {
|
|
122916
|
-
if (!
|
|
123295
|
+
if (!isRecord2(v)) return null;
|
|
122917
123296
|
const s = (k) => typeof v[k] === "string" ? v[k] : "";
|
|
122918
123297
|
return {
|
|
122919
123298
|
tag: s("tag").toLowerCase(),
|
|
@@ -123128,7 +123507,7 @@ function axNode(r, build2, layer, inScrollBar = false) {
|
|
|
123128
123507
|
return node2;
|
|
123129
123508
|
}
|
|
123130
123509
|
for (const child of Array.isArray(r.children) ? r.children : []) {
|
|
123131
|
-
if (!
|
|
123510
|
+
if (!isRecord2(child)) continue;
|
|
123132
123511
|
const childRole = str2(child.role) ?? "";
|
|
123133
123512
|
const comboList = role === "AXComboBox" && childRole === "AXScrollArea";
|
|
123134
123513
|
const converted = axNode(
|
|
@@ -123204,7 +123583,7 @@ async function getTree(api, limits) {
|
|
|
123204
123583
|
{ maxNodes: limits.maxNodes },
|
|
123205
123584
|
{ timeoutMs: TREE_CALL_TIMEOUT_MS }
|
|
123206
123585
|
);
|
|
123207
|
-
if (!
|
|
123586
|
+
if (!isRecord2(raw) || !Array.isArray(raw.windows)) {
|
|
123208
123587
|
throw new Error("Accessibility.getTree returned no windows");
|
|
123209
123588
|
}
|
|
123210
123589
|
return raw;
|
|
@@ -123218,7 +123597,7 @@ async function readMacosTree(api, limits = MACOS_DESCRIBE_LIMITS) {
|
|
|
123218
123597
|
const build2 = { webViews: /* @__PURE__ */ new Map(), menus: [] };
|
|
123219
123598
|
const nodes = [];
|
|
123220
123599
|
for (const entry of raw.windows) {
|
|
123221
|
-
if (!
|
|
123600
|
+
if (!isRecord2(entry) || !isRecord2(entry.root)) continue;
|
|
123222
123601
|
const root = axNode(entry.root, build2, KIND_LAYERS.get(str2(entry.kind) ?? "") ?? 0);
|
|
123223
123602
|
if (!root) continue;
|
|
123224
123603
|
if (entry.kind === "menu" || root.d.role === "AXMenu") {
|
|
@@ -123231,7 +123610,7 @@ async function readMacosTree(api, limits = MACOS_DESCRIBE_LIMITS) {
|
|
|
123231
123610
|
}
|
|
123232
123611
|
nodes.push(...build2.menus);
|
|
123233
123612
|
for (const v of Array.isArray(raw.extraViews) ? raw.extraViews : []) {
|
|
123234
|
-
const node2 =
|
|
123613
|
+
const node2 = isRecord2(v) ? extraViewNode(v) : null;
|
|
123235
123614
|
if (node2) nodes.push(node2);
|
|
123236
123615
|
}
|
|
123237
123616
|
const webErrors = [];
|
|
@@ -124418,7 +124797,7 @@ function isDebuggerNotConnectedResult(toolId, result) {
|
|
|
124418
124797
|
init_src2();
|
|
124419
124798
|
var FLOW_EXECUTE_TOOL_ID = "e2e-execute";
|
|
124420
124799
|
var RUN_SEQUENCE_TOOL_ID = "run-sequence";
|
|
124421
|
-
function
|
|
124800
|
+
function isRecord3(value) {
|
|
124422
124801
|
return typeof value === "object" && value !== null;
|
|
124423
124802
|
}
|
|
124424
124803
|
function reasonText(value) {
|
|
@@ -124428,7 +124807,7 @@ function reasonText(value) {
|
|
|
124428
124807
|
function firstFailingStep(steps) {
|
|
124429
124808
|
if (!Array.isArray(steps)) return void 0;
|
|
124430
124809
|
for (const entry of steps) {
|
|
124431
|
-
if (!
|
|
124810
|
+
if (!isRecord3(entry)) continue;
|
|
124432
124811
|
if (entry.status !== "fail" && entry.status !== "error") continue;
|
|
124433
124812
|
const what = typeof entry.tool === "string" ? entry.tool : typeof entry.kind === "string" ? entry.kind : "step";
|
|
124434
124813
|
return `${what}: ${reasonText(entry.reason)}`;
|
|
@@ -124463,8 +124842,8 @@ function flowExecuteOutcome(result) {
|
|
|
124463
124842
|
function runSequenceOutcome(result) {
|
|
124464
124843
|
const steps = result.steps;
|
|
124465
124844
|
if (!Array.isArray(steps)) return void 0;
|
|
124466
|
-
const failed3 = steps.find((s) =>
|
|
124467
|
-
if (failed3 &&
|
|
124845
|
+
const failed3 = steps.find((s) => isRecord3(s) && typeof s.error === "string");
|
|
124846
|
+
if (failed3 && isRecord3(failed3)) {
|
|
124468
124847
|
const tool = typeof failed3.tool === "string" ? failed3.tool : "step";
|
|
124469
124848
|
return {
|
|
124470
124849
|
status: "fail",
|
|
@@ -124488,7 +124867,7 @@ function isNestedOrchestratorTool(tool) {
|
|
|
124488
124867
|
return NESTED_ORCHESTRATORS.has(canonicalToolId(tool));
|
|
124489
124868
|
}
|
|
124490
124869
|
function nestedOrchestratorOutcome(tool, result) {
|
|
124491
|
-
if (!
|
|
124870
|
+
if (!isRecord3(result)) return void 0;
|
|
124492
124871
|
return NESTED_ORCHESTRATORS.get(canonicalToolId(tool))?.(result);
|
|
124493
124872
|
}
|
|
124494
124873
|
|
|
@@ -124519,9 +124898,9 @@ function toolResultVerdict(tool, result) {
|
|
|
124519
124898
|
if (isNativeDevtoolsBlockResult(tool, result)) {
|
|
124520
124899
|
return { status: "fail", reason: `${tool} did not run (${result.status}): ${result.message}` };
|
|
124521
124900
|
}
|
|
124522
|
-
return
|
|
124901
|
+
return isRecord4(result) ? unrecordedStepVerdict(canonicalToolId(tool), result) : void 0;
|
|
124523
124902
|
}
|
|
124524
|
-
function
|
|
124903
|
+
function isRecord4(value) {
|
|
124525
124904
|
return typeof value === "object" && value !== null;
|
|
124526
124905
|
}
|
|
124527
124906
|
function unrecordedStepVerdict(tool, result) {
|
|
@@ -124538,15 +124917,15 @@ function unrecordedStepVerdict(tool, result) {
|
|
|
124538
124917
|
var STATUS_TOOLS = /* @__PURE__ */ new Set(["debugger-status", "native-devtools-status"]);
|
|
124539
124918
|
function directCallFailure(tool, result) {
|
|
124540
124919
|
if (STATUS_TOOLS.has(tool)) return void 0;
|
|
124541
|
-
if (tool === "debugger-inspect-element" &&
|
|
124920
|
+
if (tool === "debugger-inspect-element" && isRecord4(result) && typeof result.error === "string") {
|
|
124542
124921
|
return `debugger-inspect-element failed: ${result.error}`;
|
|
124543
124922
|
}
|
|
124544
124923
|
if (tool === "debugger-component-tree" && typeof result === "string") {
|
|
124545
124924
|
return result.startsWith("Error: ") ? `debugger-component-tree failed: ${result.slice("Error: ".length)}` : void 0;
|
|
124546
124925
|
}
|
|
124547
|
-
if (tool === "native-profiler-analyze" &&
|
|
124926
|
+
if (tool === "native-profiler-analyze" && isRecord4(result)) {
|
|
124548
124927
|
if (result.status !== "analysis_failed") return void 0;
|
|
124549
|
-
const errors =
|
|
124928
|
+
const errors = isRecord4(result.exportErrors) ? Object.entries(result.exportErrors) : [];
|
|
124550
124929
|
const detail = errors.map(([name, error63]) => `${name}: ${String(error63)}`).join("; ");
|
|
124551
124930
|
return `native-profiler-analyze could not analyze the whole trace${detail ? ` (${detail})` : ""}`;
|
|
124552
124931
|
}
|
|
@@ -132389,7 +132768,7 @@ var ownRecords = /* @__PURE__ */ new Map();
|
|
|
132389
132768
|
function recordsFilePath() {
|
|
132390
132769
|
return process.env.ARGENT_ANDROID_READ_ONLY_BOOTS_FILE ?? import_node_path17.default.join(import_node_os13.default.homedir(), ".argent", "android-read-only-boots.json");
|
|
132391
132770
|
}
|
|
132392
|
-
function
|
|
132771
|
+
function isRecord5(value) {
|
|
132393
132772
|
const v = value;
|
|
132394
132773
|
return typeof v === "object" && v !== null && typeof v.avdName === "string" && typeof v.pid === "number" && typeof v.pinned === "boolean";
|
|
132395
132774
|
}
|
|
@@ -132398,7 +132777,7 @@ function loadPersisted() {
|
|
|
132398
132777
|
const raw = JSON.parse(import_node_fs16.default.readFileSync(recordsFilePath(), "utf8"));
|
|
132399
132778
|
if (typeof raw !== "object" || raw === null) return /* @__PURE__ */ new Map();
|
|
132400
132779
|
return new Map(
|
|
132401
|
-
Object.entries(raw).filter((e) =>
|
|
132780
|
+
Object.entries(raw).filter((e) => isRecord5(e[1]))
|
|
132402
132781
|
);
|
|
132403
132782
|
} catch {
|
|
132404
132783
|
return /* @__PURE__ */ new Map();
|
|
@@ -133421,9 +133800,9 @@ async function bootIos(udid, registry2, force, headless, prepareOnly) {
|
|
|
133421
133800
|
);
|
|
133422
133801
|
}
|
|
133423
133802
|
await ensureDep("xcrun");
|
|
133424
|
-
const
|
|
133425
|
-
const simMatch =
|
|
133426
|
-
if (!simMatch &&
|
|
133803
|
+
const scan2 = await scanIosSimulators().catch(() => void 0);
|
|
133804
|
+
const simMatch = scan2?.simulators.find((s) => s.udid === udid);
|
|
133805
|
+
if (!simMatch && scan2?.timedOut) {
|
|
133427
133806
|
throw new FailureError(
|
|
133428
133807
|
`Could not read the state of iOS simulator ${udid}: ${simctlListTimeoutAdvice("boot-device")}`,
|
|
133429
133808
|
{
|
|
@@ -133851,9 +134230,9 @@ function writableConflictAdvice(params, writable, shutDown) {
|
|
|
133851
134230
|
return `${reach}, or close it, then retry.`;
|
|
133852
134231
|
}
|
|
133853
134232
|
function readOnlyConflictError(params, blocking, shutDown = false) {
|
|
133854
|
-
const
|
|
134233
|
+
const describe4 = (p) => `pid ${p.pid}${p.port !== null ? ` on emulator-${p.port}` : ""}`;
|
|
133855
134234
|
const writable = blocking.filter((p) => !p.readOnly);
|
|
133856
|
-
const message = params.readOnly ? `AVD "${params.avdName}" is running writable (${writable.map(
|
|
134235
|
+
const message = params.readOnly ? `AVD "${params.avdName}" is running writable (${writable.map(describe4).join(", ")}), and the emulator starts a read-only instance only next to other read-only ones. Close that emulator, or start it with \`-read-only\` too, then retry.` : writable.length > 0 ? `AVD "${params.avdName}" is already running writable (${writable.map(describe4).join(", ")}), and the emulator runs one writable instance of an AVD at a time. ` + writableConflictAdvice(params, writable, shutDown) : `AVD "${params.avdName}" is running read-only (${blocking.map(describe4).join(", ")}), and the emulator cannot start a writable instance next to it. Pass \`readOnly: true\`, or close the read-only emulators, then retry.`;
|
|
133857
134236
|
return new FailureError(message, {
|
|
133858
134237
|
error_code: FAILURE_CODES.BOOT_ANDROID_READ_ONLY_CONFLICT,
|
|
133859
134238
|
failure_stage: "boot_android_read_only",
|
|
@@ -141509,6 +141888,7 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
|
|
|
141509
141888
|
...extra?.fileInputs ? { fileInputs: extra.fileInputs } : {},
|
|
141510
141889
|
...flowStack ? { flowStack } : {},
|
|
141511
141890
|
...flowSecret ? { flowSecret } : {},
|
|
141891
|
+
...extra?.flowOutput ? { flowOutput: extra.flowOutput } : {},
|
|
141512
141892
|
...ctx?.clientSecrets ? { clientSecrets: ctx.clientSecrets } : {}
|
|
141513
141893
|
};
|
|
141514
141894
|
if (!recordChildInvocation) {
|
|
@@ -163769,6 +164149,20 @@ function resolveScriptEnv(env, projectRoot, clientSecrets) {
|
|
|
163769
164149
|
}
|
|
163770
164150
|
return { env: resolved, secrets };
|
|
163771
164151
|
}
|
|
164152
|
+
function outputsInEnv(env, output2) {
|
|
164153
|
+
const resolved = {};
|
|
164154
|
+
for (const [name, value] of Object.entries(env)) {
|
|
164155
|
+
try {
|
|
164156
|
+
resolved[name] = resolveOutputText(value, output2);
|
|
164157
|
+
} catch (err) {
|
|
164158
|
+
if (err instanceof OutputReferenceError) {
|
|
164159
|
+
throw new InvalidToolInputError(`The value of ${name}: ${err.message}.`);
|
|
164160
|
+
}
|
|
164161
|
+
throw err;
|
|
164162
|
+
}
|
|
164163
|
+
}
|
|
164164
|
+
return resolved;
|
|
164165
|
+
}
|
|
163772
164166
|
async function runFlowScriptStep(request4) {
|
|
163773
164167
|
const { flowDir, step } = request4;
|
|
163774
164168
|
const target = step.path;
|
|
@@ -163805,7 +164199,8 @@ async function runFlowScriptStep(request4) {
|
|
|
163805
164199
|
let resolved;
|
|
163806
164200
|
try {
|
|
163807
164201
|
if (request4.env) {
|
|
163808
|
-
|
|
164202
|
+
const env = outputsInEnv(request4.env, request4.output ?? {});
|
|
164203
|
+
resolved = resolveScriptEnv(env, request4.projectRoot, request4.clientSecrets);
|
|
163809
164204
|
}
|
|
163810
164205
|
} catch (err) {
|
|
163811
164206
|
return {
|
|
@@ -163815,7 +164210,7 @@ async function runFlowScriptStep(request4) {
|
|
|
163815
164210
|
}
|
|
163816
164211
|
const result = await flowScriptExecutor().execute({
|
|
163817
164212
|
scriptPath: canonical,
|
|
163818
|
-
output: {},
|
|
164213
|
+
output: request4.output ?? {},
|
|
163819
164214
|
...step.timeout !== void 0 ? { timeoutMs: step.timeout } : {},
|
|
163820
164215
|
projectRoot: request4.projectRoot,
|
|
163821
164216
|
flowDir,
|
|
@@ -164352,10 +164747,12 @@ function stepRequiresDevice(registry2, step) {
|
|
|
164352
164747
|
case "echo":
|
|
164353
164748
|
case "wait":
|
|
164354
164749
|
case "script":
|
|
164750
|
+
case "output-check":
|
|
164355
164751
|
return false;
|
|
164356
164752
|
case "tool":
|
|
164357
164753
|
return toolRequiresDevice(registry2, step.name);
|
|
164358
164754
|
case "when":
|
|
164755
|
+
return step.condition.kind !== "output";
|
|
164359
164756
|
case "run":
|
|
164360
164757
|
case "launch":
|
|
164361
164758
|
case "tap":
|
|
@@ -166689,7 +167086,12 @@ function swipeLabel(step, renderSelector) {
|
|
|
166689
167086
|
return `${travel}${step.from ? ` from ${gestureTargetLabel(step.from, renderSelector)}` : ""}`;
|
|
166690
167087
|
}
|
|
166691
167088
|
function whenLabel(cond, renderUi) {
|
|
166692
|
-
|
|
167089
|
+
if (cond.kind === "platform") return `platform ${cond.platform}`;
|
|
167090
|
+
if (cond.kind === "output") return outputCheckLabel(cond.check);
|
|
167091
|
+
return renderUi(cond);
|
|
167092
|
+
}
|
|
167093
|
+
function outputCheckLabel(check3) {
|
|
167094
|
+
return `output ${escapeInline(check3.path)} ${check3.test} ${escapeInline(JSON.stringify(check3.expected))}`;
|
|
166693
167095
|
}
|
|
166694
167096
|
function describeWhenCondition(cond) {
|
|
166695
167097
|
return whenLabel(cond, (ui) => conditionLabel(ui, describeSelector));
|
|
@@ -166847,6 +167249,11 @@ var FLOW_STEP_DEFINITIONS = {
|
|
|
166847
167249
|
summary: (step) => `${escapeInline(step.path)}${step.timeout !== void 0 ? ` (timeout ${step.timeout}ms)` : ""}`,
|
|
166848
167250
|
target: (step) => escapeInline(step.path)
|
|
166849
167251
|
},
|
|
167252
|
+
"output-check": {
|
|
167253
|
+
summaryKind: "assert",
|
|
167254
|
+
summary: (step) => outputCheckLabel(step.check),
|
|
167255
|
+
target: (step) => outputCheckLabel(step.check)
|
|
167256
|
+
},
|
|
166850
167257
|
"snapshot": {
|
|
166851
167258
|
// `name` interpolates raw on both surfaces. It becomes a baseline filename,
|
|
166852
167259
|
// so `parseFlow` gates it on FLOW_NAME_PATTERN (letters, digits, `_`, `-`)
|
|
@@ -166876,6 +167283,7 @@ function stepAnchor(step) {
|
|
|
166876
167283
|
// ../tool-server/src/tools/flows/flow-add-step.ts
|
|
166877
167284
|
init_device_info();
|
|
166878
167285
|
init_capability();
|
|
167286
|
+
init_capability();
|
|
166879
167287
|
var REPLAY_TREE_SOURCES = {
|
|
166880
167288
|
ios: "native-devtools",
|
|
166881
167289
|
android: "android-devtools",
|
|
@@ -167394,8 +167802,8 @@ function replayRefusal(issue2, args) {
|
|
|
167394
167802
|
}
|
|
167395
167803
|
);
|
|
167396
167804
|
}
|
|
167397
|
-
function withRecordedPanelKind(command, args, toolResult) {
|
|
167398
|
-
if (command !== "file-panel" ||
|
|
167805
|
+
function withRecordedPanelKind(command, args, toolResult, ranAction = args.action) {
|
|
167806
|
+
if (command !== "file-panel" || ranAction !== "stub" || args.panelKind !== void 0) {
|
|
167399
167807
|
return args;
|
|
167400
167808
|
}
|
|
167401
167809
|
const panelKind = toolResult?.panelKind;
|
|
@@ -167421,7 +167829,7 @@ function createFlowAddStepTool(registry2) {
|
|
|
167421
167829
|
return {
|
|
167422
167830
|
id: "e2e-add-step",
|
|
167423
167831
|
description: `Execute one MCP tool and record its step in the e2e test named by \`name\` + \`project_root\`. Use when recording and you want each action run and captured; the recording must already be open.
|
|
167424
|
-
A coordinate \`gesture-tap\` records as a portable \`tap\` selector step; \`restart-app\` as a \`launch\`.
|
|
167832
|
+
A coordinate \`gesture-tap\` records as a portable \`tap\` selector step; \`restart-app\` as a \`launch\`. Use \`{{output:PATH}}\` in arguments to read prior script output. The tool resolves the values for the live call and saves the references in a \`tool:\` step.
|
|
167425
167833
|
Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status, says whether a step was appended. Fails with an error, recording nothing. Call recording tools, including \`e2e-add-script\`, directly.`,
|
|
167426
167834
|
zodSchema: zodSchema71,
|
|
167427
167835
|
aliases: ["flow-add-step"],
|
|
@@ -167466,6 +167874,19 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167466
167874
|
if (command === RUN_TARGET_COMMAND) {
|
|
167467
167875
|
await rewriteSiblingFlowPath(session, args, project, linked);
|
|
167468
167876
|
}
|
|
167877
|
+
const authored = { kind: "tool", name: command, args };
|
|
167878
|
+
const referencedArgs = holdsOutputReference(authored) ? args : void 0;
|
|
167879
|
+
if (referencedArgs) {
|
|
167880
|
+
const problem = stepOutputReferenceProblem(authored);
|
|
167881
|
+
if (problem)
|
|
167882
|
+
throw new InvalidToolInputError(`Nothing ran and no step was recorded: ${problem}`);
|
|
167883
|
+
try {
|
|
167884
|
+
args = resolveStepOutputs(authored, session.output ?? {}).args;
|
|
167885
|
+
} catch (err) {
|
|
167886
|
+
if (!(err instanceof OutputReferenceError)) throw err;
|
|
167887
|
+
throw new InvalidToolInputError(`Nothing ran and no step was recorded: ${err.message}`);
|
|
167888
|
+
}
|
|
167889
|
+
}
|
|
167469
167890
|
if (linked) {
|
|
167470
167891
|
const issue2 = toolStepUploadIssue(
|
|
167471
167892
|
registry2,
|
|
@@ -167475,7 +167896,7 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167475
167896
|
);
|
|
167476
167897
|
if (issue2) throw replayRefusal(issue2, args);
|
|
167477
167898
|
}
|
|
167478
|
-
const isTap = command === "gesture-tap" && params.delayMs === void 0 && typeof args.udid === "string" && typeof args.x === "number" && typeof args.y === "number";
|
|
167899
|
+
const isTap = !referencedArgs && command === "gesture-tap" && params.delayMs === void 0 && typeof args.udid === "string" && typeof args.x === "number" && typeof args.y === "number";
|
|
167479
167900
|
let captured;
|
|
167480
167901
|
if (isTap) {
|
|
167481
167902
|
captured = await captureTapSelector(registry2, session, args.udid, {
|
|
@@ -167483,6 +167904,8 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167483
167904
|
y: args.y
|
|
167484
167905
|
});
|
|
167485
167906
|
}
|
|
167907
|
+
const runTarget = command === RUN_TARGET_COMMAND && params.delayMs === void 0 && !referencedArgs ? await captureRunTarget(session, args, project) : void 0;
|
|
167908
|
+
const sharedOutput = runTarget?.flow ? { doc: structuredClone(session.output ?? {}) } : void 0;
|
|
167486
167909
|
let prepared;
|
|
167487
167910
|
let toolResult;
|
|
167488
167911
|
try {
|
|
@@ -167498,7 +167921,8 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167498
167921
|
// A nested run whose flow came from the client gets a run stack even
|
|
167499
167922
|
// with no enclosing run, which marks it as nested: its refusals name
|
|
167500
167923
|
// the flow it runs, and this call returns the baselines it writes.
|
|
167501
|
-
...nestedFromClient ? { flowStack: ctx?.flowStack ?? [] } : {}
|
|
167924
|
+
...nestedFromClient ? { flowStack: ctx?.flowStack ?? [] } : {},
|
|
167925
|
+
...sharedOutput ? { flowOutput: sharedOutput } : {}
|
|
167502
167926
|
});
|
|
167503
167927
|
} catch (err) {
|
|
167504
167928
|
const hint = isToolNotFound(err, params.command) ? directiveCommandHint(params.command) : void 0;
|
|
@@ -167572,7 +167996,6 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167572
167996
|
const probed = (await probeAgainstRunnerTree(registry2, ctx, args)).warning;
|
|
167573
167997
|
if (probed) waitWarning = { warning: probed, kind: "conversion" };
|
|
167574
167998
|
}
|
|
167575
|
-
const runTarget = command === RUN_TARGET_COMMAND && params.delayMs === void 0 ? await captureRunTarget(session, args, project) : void 0;
|
|
167576
167999
|
const strippedArgs = stripDeviceKeys(args);
|
|
167577
168000
|
const { bundleId: _bundleId, launchArgs, ...extraLaunchArgs } = strippedArgs;
|
|
167578
168001
|
const noLaunchArgs = launchArgs === void 0 || Array.isArray(launchArgs) && launchArgs.length === 0;
|
|
@@ -167588,7 +168011,20 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167588
168011
|
const tapModifiers = isTap && heldKeys.length > 0 ? { modifiers: heldKeys } : {};
|
|
167589
168012
|
let step;
|
|
167590
168013
|
let warning;
|
|
167591
|
-
if (
|
|
168014
|
+
if (referencedArgs) {
|
|
168015
|
+
step = {
|
|
168016
|
+
kind: "tool",
|
|
168017
|
+
name: command,
|
|
168018
|
+
args: withRecordedPanelKind(
|
|
168019
|
+
command,
|
|
168020
|
+
stripDeviceKeys(referencedArgs),
|
|
168021
|
+
toolResult,
|
|
168022
|
+
args.action
|
|
168023
|
+
),
|
|
168024
|
+
delayMs: params.delayMs
|
|
168025
|
+
};
|
|
168026
|
+
warning = waitWarning?.warning;
|
|
168027
|
+
} else if (captured?.selector) {
|
|
167592
168028
|
step = {
|
|
167593
168029
|
kind: "tap",
|
|
167594
168030
|
selector: captured.selector,
|
|
@@ -167641,9 +168077,10 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167641
168077
|
failure_area: "tool_server",
|
|
167642
168078
|
error_kind: "validation"
|
|
167643
168079
|
},
|
|
167644
|
-
|
|
168080
|
+
`The \`${params.command}\` call ran, but an existing e2e test step failed validation. Fix the step named below. Check the call's changes before you retry. ${refused}`
|
|
167645
168081
|
);
|
|
167646
168082
|
}
|
|
168083
|
+
if (step.kind === "run" && sharedOutput) session.output = sharedOutput.doc;
|
|
167647
168084
|
if (waitWarning) {
|
|
167648
168085
|
(session.stepWarnings ??= /* @__PURE__ */ new Map()).set(stepCount, {
|
|
167649
168086
|
...waitWarning,
|
|
@@ -167806,12 +168243,12 @@ var zodSchema74 = external_exports.object({
|
|
|
167806
168243
|
),
|
|
167807
168244
|
timeout: external_exports.number().optional().describe("Time limit in milliseconds. The default is 30000 and the minimum is 100."),
|
|
167808
168245
|
env: envRecordSchema(external_exports.string()).optional().describe(
|
|
167809
|
-
"Environment overrides for this script. Argent uses them immediately and saves them on the step. Values can include {{secret:NAME}}."
|
|
168246
|
+
"Environment overrides for this script. Argent uses them immediately and saves them on the step. Values can include {{secret:NAME}} or {{output:PATH}}."
|
|
167810
168247
|
)
|
|
167811
168248
|
});
|
|
167812
168249
|
var flowAddScriptTool = {
|
|
167813
168250
|
id: "e2e-add-script",
|
|
167814
|
-
description: `Run a local JavaScript (.mjs, .js) or TypeScript (.mts, .ts) file and record it as a
|
|
168251
|
+
description: `Run a local JavaScript (.mjs, .js) or TypeScript (.mts, .ts) file and record it as a script step. Use when the user requests a local script in an active recording. Call it where the script must run. A successful script updates the shared output and returns it as \`outputJson\`. Later steps can read it with \`{{output:PATH}}\`. Returns \`status\`, \`reason\` and \`stepCount\`. A failed script is not recorded. Check \`reason\` and the affected state before retrying. Record without a link (argent link or ARGENT_TOOLS_URL).`,
|
|
167815
168252
|
zodSchema: zodSchema74,
|
|
167816
168253
|
fileInputs: PROJECT_ROOT_INPUT,
|
|
167817
168254
|
aliases: ["flow-add-script"],
|
|
@@ -167850,7 +168287,7 @@ var flowAddScriptTool = {
|
|
|
167850
168287
|
...params.env !== void 0 ? { env: params.env } : {}
|
|
167851
168288
|
}
|
|
167852
168289
|
};
|
|
167853
|
-
const envProblem = params.env === void 0 ? void 0 : flowEnvProblem(params.env);
|
|
168290
|
+
const envProblem = params.env === void 0 ? void 0 : flowEnvProblem(params.env, { references: true });
|
|
167854
168291
|
if (envProblem) throw new InvalidToolInputError(`env ${envProblem}`);
|
|
167855
168292
|
const step = {
|
|
167856
168293
|
kind: "script",
|
|
@@ -167865,6 +168302,7 @@ var flowAddScriptTool = {
|
|
|
167865
168302
|
step,
|
|
167866
168303
|
projectRoot: params.project_root,
|
|
167867
168304
|
env,
|
|
168305
|
+
output: session.output ?? {},
|
|
167868
168306
|
...ctx?.clientSecrets ? { clientSecrets: ctx.clientSecrets } : {},
|
|
167869
168307
|
...ctx?.signal ? { signal: ctx.signal } : {}
|
|
167870
168308
|
});
|
|
@@ -167910,6 +168348,7 @@ var flowAddScriptTool = {
|
|
|
167910
168348
|
`Script "${step.path}" passed, but the step was not recorded. ` + (refusedAnEarlierStep ? `Fix the existing step named below in ${session.filePath}. ` : "Check the script's changes before you retry. ") + `${err instanceof Error ? err.message : String(err)}`
|
|
167911
168349
|
);
|
|
167912
168350
|
}
|
|
168351
|
+
if (result?.output) session.output = result.output;
|
|
167913
168352
|
const rendered = result?.output ? renderOutput(result.output) : void 0;
|
|
167914
168353
|
return {
|
|
167915
168354
|
...common,
|
|
@@ -171289,6 +171728,7 @@ Without a link, every step kind runs.`,
|
|
|
171289
171728
|
secret: ctx?.flowSecret ?? {},
|
|
171290
171729
|
projectRoot: params.project_root,
|
|
171291
171730
|
runEnv,
|
|
171731
|
+
output: ctx?.flowOutput ?? { doc: {} },
|
|
171292
171732
|
scriptLogBudget: createScriptLogBudget(),
|
|
171293
171733
|
networkCaptureNoted: /* @__PURE__ */ new Map(),
|
|
171294
171734
|
...!resolved.booted && device?.platform === "chromium" ? { attachedDeviceId: device.id } : {},
|
|
@@ -171648,9 +172088,26 @@ async function execSteps(state3, steps, scope) {
|
|
|
171648
172088
|
if (step.kind !== "script" && JSON.stringify(step).includes(SECRET_PLACEHOLDER_MARKER)) {
|
|
171649
172089
|
state3.secret.typed = true;
|
|
171650
172090
|
}
|
|
172091
|
+
let leaf;
|
|
172092
|
+
try {
|
|
172093
|
+
leaf = resolveStepOutputs(step, state3.output.doc);
|
|
172094
|
+
} catch (err) {
|
|
172095
|
+
if (!(err instanceof OutputReferenceError)) throw err;
|
|
172096
|
+
pushReport(state3, {
|
|
172097
|
+
index,
|
|
172098
|
+
kind: step.kind,
|
|
172099
|
+
status: "error",
|
|
172100
|
+
e2eTest: scopeFlow(scope),
|
|
172101
|
+
target: stepTarget(step),
|
|
172102
|
+
...depthOf(scope),
|
|
172103
|
+
reason: escapeInline(err.message)
|
|
172104
|
+
});
|
|
172105
|
+
state3.stopped = true;
|
|
172106
|
+
continue;
|
|
172107
|
+
}
|
|
171651
172108
|
const report = await inCoordinateSpace(
|
|
171652
172109
|
scope.legacyPoints && step.kind === "tool" ? "native" : "upright",
|
|
171653
|
-
() => execLeafStep(state3,
|
|
172110
|
+
() => execLeafStep(state3, leaf, index, scope)
|
|
171654
172111
|
);
|
|
171655
172112
|
if (report.status !== "skip" && !SCREEN_READING_STEPS.has(step.kind)) {
|
|
171656
172113
|
state3.lastActionAt = Date.now();
|
|
@@ -171702,21 +172159,35 @@ async function execBlockStep(state3, step, scope) {
|
|
|
171702
172159
|
}
|
|
171703
172160
|
}
|
|
171704
172161
|
}
|
|
171705
|
-
async function execWhenStep(state3,
|
|
172162
|
+
async function execWhenStep(state3, authored, scope) {
|
|
171706
172163
|
const index = state3.reports.length;
|
|
171707
|
-
const
|
|
171708
|
-
const target = stepTarget(step);
|
|
171709
|
-
const marker = {
|
|
172164
|
+
const unresolved = {
|
|
171710
172165
|
index,
|
|
171711
172166
|
kind: "when",
|
|
171712
172167
|
e2eTest: scopeFlow(scope),
|
|
171713
|
-
target,
|
|
172168
|
+
target: stepTarget(authored),
|
|
171714
172169
|
...depthOf(scope)
|
|
171715
172170
|
};
|
|
171716
172171
|
const inner = childScope(scope);
|
|
172172
|
+
let step;
|
|
172173
|
+
try {
|
|
172174
|
+
step = resolveStepOutputs(authored, state3.output.doc);
|
|
172175
|
+
} catch (err) {
|
|
172176
|
+
if (!(err instanceof OutputReferenceError)) throw err;
|
|
172177
|
+
pushReport(state3, { ...unresolved, status: "error", reason: escapeInline(err.message) });
|
|
172178
|
+
state3.stopped = true;
|
|
172179
|
+
reportBlockSkipped(state3, authored.steps, inner, "when guard errored");
|
|
172180
|
+
return;
|
|
172181
|
+
}
|
|
172182
|
+
const marker = { ...unresolved, target: stepTarget(step) };
|
|
172183
|
+
let label = describeWhenCondition(step.condition);
|
|
171717
172184
|
const guardStartedAt = Date.now();
|
|
171718
172185
|
let met;
|
|
171719
|
-
if (step.condition.kind === "
|
|
172186
|
+
if (step.condition.kind === "output") {
|
|
172187
|
+
const check3 = evaluateOutputCheck(step.condition.check, state3.output.doc);
|
|
172188
|
+
label += `: ${escapeInline(check3.reason)}`;
|
|
172189
|
+
met = check3.ok;
|
|
172190
|
+
} else if (step.condition.kind === "platform") {
|
|
171720
172191
|
const guardEnv = deviceEnv(state3);
|
|
171721
172192
|
const platform = authoringPlatform(guardEnv.device.platform);
|
|
171722
172193
|
met = platform === step.condition.platform;
|
|
@@ -171850,15 +172321,17 @@ function oneLineReason(text) {
|
|
|
171850
172321
|
}
|
|
171851
172322
|
async function runScriptStep(state3, step, scope) {
|
|
171852
172323
|
const env = mergeScriptEnv(scope.fileEnv, step.env, state3.runEnv);
|
|
171853
|
-
const { outcome } = await runFlowScriptStep({
|
|
172324
|
+
const { outcome, result } = await runFlowScriptStep({
|
|
171854
172325
|
flowDir: scopeFlowDir(scope),
|
|
171855
172326
|
step,
|
|
171856
172327
|
projectRoot: state3.projectRoot,
|
|
171857
172328
|
env,
|
|
172329
|
+
output: state3.output.doc,
|
|
171858
172330
|
...state3.ctx?.clientSecrets ? { clientSecrets: state3.ctx.clientSecrets } : {},
|
|
171859
172331
|
logBudget: state3.scriptLogBudget,
|
|
171860
172332
|
...state3.signal ? { signal: state3.signal } : {}
|
|
171861
172333
|
});
|
|
172334
|
+
if (outcome.status === "pass" && result?.output) state3.output.doc = result.output;
|
|
171862
172335
|
return outcome.reason === void 0 ? outcome : { ...outcome, reason: oneLineReason(outcome.reason) };
|
|
171863
172336
|
}
|
|
171864
172337
|
async function runFold(state3, step) {
|
|
@@ -172083,6 +172556,10 @@ async function execLeafStep(state3, step, index, scope) {
|
|
|
172083
172556
|
const outcome = await runScriptStep(state3, step, scope);
|
|
172084
172557
|
return { ...base, ...outcome };
|
|
172085
172558
|
}
|
|
172559
|
+
case "output-check": {
|
|
172560
|
+
const check3 = evaluateOutputCheck(step.check, state3.output.doc);
|
|
172561
|
+
return { ...base, status: check3.ok ? "pass" : "fail", reason: escapeInline(check3.reason) };
|
|
172562
|
+
}
|
|
172086
172563
|
default: {
|
|
172087
172564
|
const unexecuted = step;
|
|
172088
172565
|
void unexecuted;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.35.1-next.
|
|
3
|
+
"version": "0.35.1-next.9",
|
|
4
4
|
"mcpName": "io.github.software-mansion/argent",
|
|
5
5
|
"description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"vitest": "^5.0.5",
|
|
99
99
|
"yaml": "^2.9.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "aa8a0c6bf0326f7fff85d0cab3a2ea0613e5d6e8"
|
|
102
102
|
}
|
|
@@ -231,7 +231,7 @@ Use `when:` only for optional setup or an interstitial that reconverges:
|
|
|
231
231
|
- tap: { text: Got it }
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
Use a UI condition (`exists`, `visible`, `hidden`, or `text`), an [output check](#pass-values-between-steps), or a platform guard (`{ platform: ios|android|chromium|vega|macos }`). A run on a remote simulator matches `ios`. UI guards use the short assert grace and reject `timeout`. There is no `else` or per-step `optional`. Put separate behavioral paths in separate tests. Never place a required acceptance check inside `when:`.
|
|
235
235
|
|
|
236
236
|
## Composition and platform limits
|
|
237
237
|
|
|
@@ -272,6 +272,14 @@ If the reason says that the Node.js of the tool-server cannot run TypeScript, us
|
|
|
272
272
|
|
|
273
273
|
Over a link (`argent link` or `ARGENT_TOOLS_URL`, also to 127.0.0.1), `e2e-add-script` refuses the call, and a replay rejects a test with a `script:` step. Record and replay a test with a script without a link.
|
|
274
274
|
|
|
275
|
+
### Pass values between steps
|
|
276
|
+
|
|
277
|
+
Save JSON data to the global `output`, for example `output.user = { id: "user-7" }`. Record scripts one at a time so each starts with the previous output. Inspect `e2e-add-script.outputJson` before writing a reference. A `run:` fragment shares output. For a separate `tool: e2e-execute` run, pass inputs through `env`.
|
|
278
|
+
|
|
279
|
+
Quote references in YAML, such as `"{{output:user.id}}"`. Use dotted keys and indexes (`items.0.id`). If a script may be skipped, guard the use with an output check or provide a literal fallback, such as `"{{output:user.id ?? guest}}"`. For a required check, use `assert: { output: user.id, exists: true }`.
|
|
280
|
+
|
|
281
|
+
Use references in selectors, typed text, equality or contains checks, tool arguments, and script-step environment values. A whole-value tool argument keeps its JSON type. Return a string when the tool expects text. Keep secret placeholders in the YAML. See [Script output](https://docs.swmansion.com/argent/docs/reference/e2e-yaml#script-output) for supported fields and fallback syntax.
|
|
282
|
+
|
|
275
283
|
## Snapshots and CLI runs
|
|
276
284
|
|
|
277
285
|
`argent e2e run <name> [--device <id>] [--platform ios|android|chromium|vega|macos|ios-remote] [--update-baselines] [--env NAME=value] [--output <dir>] [--json]` runs without an LLM and exits non-zero on failure.
|