@swmansion/argent 0.35.1-next.43 → 0.35.1-next.45

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/dist/cli-cmds.mjs CHANGED
@@ -38596,7 +38596,7 @@ function isCi(env = process.env) {
38596
38596
  var SESSION_ID2 = randomUUID5();
38597
38597
  function readCliVersion() {
38598
38598
  if (true) {
38599
- return "0.35.1-next.43";
38599
+ return "0.35.1-next.44";
38600
38600
  }
38601
38601
  return "0.0.0";
38602
38602
  }
@@ -39908,8 +39908,8 @@ Options (run):
39908
39908
  --update-baselines Write/refresh screenshot baselines instead of diffing,
39909
39909
  also those of tests that tool: e2e-execute steps run,
39910
39910
  unless such a step sets updateBaselines
39911
- --env NAME=value Override a script environment value for this run.
39912
- Repeatable. Values may contain {{secret:NAME}}
39911
+ --var NAME=value Set a test input for this run. Repeat for more names.
39912
+ Use {{secret:NAME}} for credentials.
39913
39913
  --output <dir> Also write failed snapshot images (baseline/current/diff)
39914
39914
  and failed-step screenshots (step-<n>-screen.png)
39915
39915
  under <dir>/<test>/ \u2014 a stable path for CI artifact
@@ -39932,7 +39932,8 @@ Examples:
39932
39932
  argent e2e run .argent/e2e/checkout.yaml --output e2e-artifacts --json
39933
39933
  argent e2e run ~/shared-e2e/checkout.yaml --device <UDID> --update-baselines
39934
39934
  argent e2e run .argent/e2e --recursive
39935
- argent e2e run checkout --env API_URL=https://staging.example.com
39935
+ argent e2e run checkout --var API_URL=https://staging.example.com
39936
+ argent e2e run login --var PASSWORD='{{secret:ALICE_PASSWORD}}'
39936
39937
  argent e2e check checkout
39937
39938
  `);
39938
39939
  }
@@ -39946,7 +39947,7 @@ var RUN_OPTIONS = {
39946
39947
  // run it would stop the whole batch.
39947
39948
  "platform": { kind: "value", choices: SELECTABLE_PLATFORMS },
39948
39949
  "output": { kind: "value" },
39949
- "env": { kind: "value", repeatable: true }
39950
+ "var": { kind: "value", repeatable: true }
39950
39951
  };
39951
39952
  var LIST_OPTIONS = {
39952
39953
  json: { kind: "boolean" },
@@ -39982,27 +39983,33 @@ function parseRunArgs(argv) {
39982
39983
  if (options.device !== void 0) out.device = options.device;
39983
39984
  if (options.platform !== void 0) out.platform = options.platform;
39984
39985
  if (options.output !== void 0) out.output = options.output;
39985
- if (options.env !== void 0) out.env = parseEnvFlags(options.env);
39986
+ if (options.var !== void 0) out.vars = parseVarFlags(options.var);
39986
39987
  if (out.json && out.jsonStream) {
39987
39988
  throw new FlagParseException("--json and --json-stream cannot be combined");
39988
39989
  }
39989
39990
  return out;
39990
39991
  }
39991
- var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
39992
- function parseEnvFlags(values) {
39993
- const env = {};
39992
+ var VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
39993
+ function parseVarFlags(values) {
39994
+ const vars = {};
39994
39995
  for (const entry of values) {
39995
39996
  const eq = entry.indexOf("=");
39996
39997
  const name = eq === -1 ? entry : entry.slice(0, eq);
39997
- if (eq === -1 || !ENV_NAME_RE.test(name) || name === "__proto__") {
39998
+ if (eq === -1 || !VAR_NAME_RE.test(name) || name === "__proto__") {
39998
39999
  throw new FlagParseException(
39999
- `--env takes NAME=value with a name of letters, digits and _, not starting with a digit; got ${JSON.stringify(entry)}`
40000
+ `--var takes NAME=value with a name of letters, digits and _, not starting with a digit; got ${JSON.stringify(entry)}`
40000
40001
  );
40001
40002
  }
40002
- delete env[name];
40003
- env[name] = entry.slice(eq + 1);
40003
+ const value = entry.slice(eq + 1);
40004
+ if (value.replace(SECRET_PLACEHOLDER_RE, "").includes("{{")) {
40005
+ throw new FlagParseException(
40006
+ `--var ${name} takes only literal text and {{secret:NAME}} placeholders, not another reference; got ${JSON.stringify(value)}`
40007
+ );
40008
+ }
40009
+ delete vars[name];
40010
+ vars[name] = value;
40004
40011
  }
40005
- return env;
40012
+ return vars;
40006
40013
  }
40007
40014
  var SHUTDOWN_HEADER = " shutdown:";
40008
40015
  function renderEchoLine(s) {
@@ -40161,8 +40168,8 @@ function rerunCommand(flowPath, rel, projectRoot, args) {
40161
40168
  if (args.platform) parts.push("--platform", shellQuoteArg(args.platform));
40162
40169
  if (args.updateBaselines) parts.push("--update-baselines");
40163
40170
  if (args.output) parts.push("--output", pathArg(path20.join(args.output, path20.dirname(rel))));
40164
- for (const [name, value] of Object.entries(args.env ?? {})) {
40165
- parts.push("--env", shellQuoteArg(`${name}=${value}`));
40171
+ for (const [name, value] of Object.entries(args.vars ?? {})) {
40172
+ parts.push("--var", shellQuoteArg(`${name}=${value}`));
40166
40173
  }
40167
40174
  return parts.join(" ");
40168
40175
  }
@@ -40550,7 +40557,7 @@ function buildRunPayload(flowPath, projectRoot, args) {
40550
40557
  if (args.device) payload.device = args.device;
40551
40558
  if (args.platform) payload.platform = args.platform;
40552
40559
  if (args.updateBaselines) payload.updateBaselines = true;
40553
- if (args.env) payload.env = args.env;
40560
+ if (args.vars) payload.vars = args.vars;
40554
40561
  return payload;
40555
40562
  }
40556
40563
  function writeJsonStreamRecord(record2) {
@@ -17118,7 +17118,7 @@ function isCi(env = process.env) {
17118
17118
  var SESSION_ID = randomUUID4();
17119
17119
  function readCliVersion() {
17120
17120
  if (true) {
17121
- return "0.35.1-next.43";
17121
+ return "0.35.1-next.44";
17122
17122
  }
17123
17123
  return "0.0.0";
17124
17124
  }
@@ -38155,7 +38155,7 @@ async function startMcpServer(options) {
38155
38155
  const autoDescribeOn = autoDescribeEnabled();
38156
38156
  const whatsNewOn = whatsNewEnabled();
38157
38157
  const installedVersion = getInstalledVersion();
38158
- const highlightsVersion = true ? "0.35.1-next.43" : installedVersion;
38158
+ const highlightsVersion = true ? "0.35.1-next.44" : installedVersion;
38159
38159
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38160
38160
  const trees = createTreeMemory();
38161
38161
  const screenshots = createScreenshotMemory();
@@ -308,7 +308,7 @@ export interface ArgentToolArgs {
308
308
  path: string;
309
309
  /** Timeout in ms (default 30000, min 100). */
310
310
  timeout?: number;
311
- /** Env overrides (supports `{{secret:NAME}}` and `{{output:PATH}}`). */
311
+ /** Environment values for this script. Override same-name vars. Supports `{{secret:NAME}}`, `{{var:NAME}}`, and `{{output:PATH}}`. */
312
312
  env?: {
313
313
  [key: string]: string;
314
314
  };
@@ -358,8 +358,8 @@ export interface ArgentToolArgs {
358
358
  updateBaselines?: boolean;
359
359
  /** Set true to confirm a fragment's `executionPrerequisite` is met; otherwise returns the prerequisite text without running. Not a dry run: a test with no prerequisite runs in full (read `executionPrerequisite` in the YAML to inspect without running). */
360
360
  prerequisiteAcknowledged?: boolean;
361
- /** Script env overrides (also for `run:` fragments). Supports `{{secret:NAME}}`. */
362
- env?: {
361
+ /** Overrides for the test's `vars:` defaults, including `run:` fragments. Values can contain `{{secret:NAME}}` placeholders. */
362
+ vars?: {
363
363
  [key: string]: string;
364
364
  };
365
365
  /** @deprecated Renamed to `e2e_test_path`. */
@@ -387,13 +387,13 @@ export interface ArgentToolArgs {
387
387
  /** @deprecated Renamed to `e2e_test_file`. */
388
388
  flow_file?: string;
389
389
  };
390
- "e2e-set-env": {
390
+ "e2e-set-vars": {
391
391
  /** Test name passed to e2e-start-recording. */
392
392
  name: string;
393
393
  /** Absolute project root passed to e2e-start-recording. */
394
394
  project_root: string;
395
- /** Variable names to update. A null value removes that name. Omitted names keep their values. Use {{secret:NAME}} for credentials. */
396
- env: {
395
+ /** Set values by name. Use null to remove a name and `{{secret:NAME}}` for credentials. */
396
+ vars: {
397
397
  [key: string]: string | null;
398
398
  };
399
399
  };
@@ -409,8 +409,8 @@ export interface ArgentToolArgs {
409
409
  platform?: "ios" | "android" | "chromium" | "vega" | "macos" | Array<"ios" | "android" | "chromium" | "vega" | "macos">;
410
410
  runtimeKind?: "mobile" | "tv";
411
411
  };
412
- /** Top-level script env defaults. Supports `{{secret:NAME}}`. */
413
- env?: {
412
+ /** Test inputs to save under `vars:` and read with `{{var:NAME}}`. Use `{{secret:NAME}}` for credentials. */
413
+ vars?: {
414
414
  [key: string]: string;
415
415
  };
416
416
  };
@@ -72982,7 +72982,7 @@ function isCi(env = process.env) {
72982
72982
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
72983
72983
  function readCliVersion() {
72984
72984
  if (true) {
72985
- return "0.35.1-next.43";
72985
+ return "0.35.1-next.44";
72986
72986
  }
72987
72987
  return "0.0.0";
72988
72988
  }
@@ -75949,8 +75949,14 @@ var SEGMENT = String.raw`(?:[A-Za-z_][A-Za-z0-9_-]*|0|[1-9]\d*)`;
75949
75949
  var PATH_RE = new RegExp(`^${SEGMENT}(?:\\.${SEGMENT})*$`);
75950
75950
  var NUMBER_RE = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
75951
75951
  var MAX_LISTED_KEYS = 20;
75952
- 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}}`";
75953
- var OutputReferenceError = class extends Error {
75952
+ var OUTPUT_SYNTAX = {
75953
+ marker: OUTPUT_REFERENCE_MARKER,
75954
+ name: PATH_RE,
75955
+ 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}}`"
75956
+ };
75957
+ var StepReferenceError = class extends Error {
75958
+ };
75959
+ var OutputReferenceError = class extends StepReferenceError {
75954
75960
  };
75955
75961
  function outputReferenceProblem(text) {
75956
75962
  try {
@@ -75964,19 +75970,23 @@ function holdsOutputMarker(text) {
75964
75970
  return text.includes(OUTPUT_REFERENCE_MARKER);
75965
75971
  }
75966
75972
  function scan(text) {
75973
+ return scanReferences(text, OUTPUT_SYNTAX);
75974
+ }
75975
+ function scanReferences(text, syntax) {
75976
+ const { marker, grammar } = syntax;
75967
75977
  const refs = [];
75968
- let at = text.indexOf(OUTPUT_REFERENCE_MARKER);
75978
+ let at = text.indexOf(marker);
75969
75979
  while (at !== -1) {
75970
- const close = text.indexOf("}}", at + OUTPUT_REFERENCE_MARKER.length);
75980
+ const close = text.indexOf("}}", at + marker.length);
75971
75981
  if (close === -1) {
75972
- throw new Error(`has a reference with no closing \`}}\`: ${GRAMMAR}`);
75982
+ throw new Error(`has a reference with no closing \`}}\`: ${grammar}`);
75973
75983
  }
75974
75984
  const source = text.slice(at, close + 2);
75975
- const body = text.slice(at + OUTPUT_REFERENCE_MARKER.length, close);
75985
+ const body = text.slice(at + marker.length, close);
75976
75986
  const split = body.indexOf("??");
75977
75987
  const path77 = (split === -1 ? body : body.slice(0, split)).trim();
75978
- if (!PATH_RE.test(path77)) {
75979
- throw new Error(`has an invalid reference ${JSON.stringify(source)}: ${GRAMMAR}`);
75988
+ if (!syntax.name.test(path77)) {
75989
+ throw new Error(`has an invalid reference ${JSON.stringify(source)}: ${grammar}`);
75980
75990
  }
75981
75991
  const ref = { start: at, end: close + 2, source, path: path77 };
75982
75992
  if (split !== -1) {
@@ -75995,7 +76005,7 @@ function scan(text) {
75995
76005
  ref.fallback = { value, text: typeof value === "string" ? value : literal2 };
75996
76006
  }
75997
76007
  refs.push(ref);
75998
- at = text.indexOf(OUTPUT_REFERENCE_MARKER, close + 2);
76008
+ at = text.indexOf(marker, close + 2);
75999
76009
  }
76000
76010
  return refs;
76001
76011
  }
@@ -76158,6 +76168,115 @@ function evaluateValueCheck(test, expected, hit, at) {
76158
76168
  return { ok, reason: `${at} is ${JSON.stringify(actual)}` };
76159
76169
  }
76160
76170
 
76171
+ // ../tool-server/src/tools/flows/flow-vars.ts
76172
+ init_src();
76173
+ var VAR_REFERENCE_MARKER = "{{var:";
76174
+ var VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
76175
+ var MAX_LISTED_NAMES = 20;
76176
+ var VAR_SYNTAX = {
76177
+ marker: VAR_REFERENCE_MARKER,
76178
+ name: VAR_NAME_RE,
76179
+ grammar: "write `{{var:NAME}}` or `{{var:NAME ?? FALLBACK}}`, where NAME is a var of the e2e test, e.g. `{{var:USER_NAME}}` or `{{var:USER_NAME ?? guest}}`"
76180
+ };
76181
+ var VarReferenceError = class extends StepReferenceError {
76182
+ };
76183
+ function holdsVarMarker(text) {
76184
+ return text.includes(VAR_REFERENCE_MARKER);
76185
+ }
76186
+ function varReferenceProblem(text) {
76187
+ try {
76188
+ scanReferences(text, VAR_SYNTAX);
76189
+ return void 0;
76190
+ } catch (err) {
76191
+ return err.message;
76192
+ }
76193
+ }
76194
+ function requiredVarNames(text) {
76195
+ if (!holdsVarMarker(text)) return [];
76196
+ return scanReferences(text, VAR_SYNTAX).filter((ref) => ref.fallback === void 0).map((ref) => ref.path);
76197
+ }
76198
+ function varValueProblem(value) {
76199
+ if (!value.replace(new RegExp(SECRET_PLACEHOLDER_RE.source, "g"), "").includes("{{")) {
76200
+ return void 0;
76201
+ }
76202
+ return "takes only literal text and {{secret:NAME}} placeholders, not another reference";
76203
+ }
76204
+ function lookupVar(vars, name) {
76205
+ if (Object.hasOwn(vars, name)) return vars[name];
76206
+ if (process.platform !== "win32") return void 0;
76207
+ const lower = name.toLowerCase();
76208
+ const match = Object.keys(vars).find((key2) => key2.toLowerCase() === lower);
76209
+ return match === void 0 ? void 0 : vars[match];
76210
+ }
76211
+ function namesOfVar(vars, name) {
76212
+ if (process.platform !== "win32") return Object.hasOwn(vars, name) ? [name] : [];
76213
+ const lower = name.toLowerCase();
76214
+ return Object.keys(vars).filter((key2) => key2.toLowerCase() === lower);
76215
+ }
76216
+ function varIsSet(vars, name) {
76217
+ return lookupVar(vars, name) !== void 0;
76218
+ }
76219
+ function secretVarNames(text, vars) {
76220
+ if (!holdsVarMarker(text)) return [];
76221
+ return scanReferences(text, VAR_SYNTAX).map((ref) => ref.path).filter((name) => new RegExp(SECRET_PLACEHOLDER_RE.source).test(lookupVar(vars, name) ?? ""));
76222
+ }
76223
+ function missingVarReason(name, vars) {
76224
+ const names = Object.keys(vars).sort();
76225
+ if (names.length === 0) return `the run sets no vars, and ${name} is not one of them`;
76226
+ const listed = names.slice(0, MAX_LISTED_NAMES).join(", ");
76227
+ const more = names.length > MAX_LISTED_NAMES ? `, and ${names.length - MAX_LISTED_NAMES} more` : "";
76228
+ return `the run sets no var ${name} (vars: ${listed}${more})`;
76229
+ }
76230
+ function resolveRef3(ref, vars) {
76231
+ const value = lookupVar(vars, ref.path);
76232
+ if (value !== void 0) return { value, text: value };
76233
+ if (ref.fallback) return ref.fallback;
76234
+ throw new VarReferenceError(`${ref.source} has no value: ${missingVarReason(ref.path, vars)}`);
76235
+ }
76236
+ function resolveVarText(text, vars) {
76237
+ if (!holdsVarMarker(text)) return text;
76238
+ const refs = scanReferences(text, VAR_SYNTAX);
76239
+ let resolved = "";
76240
+ let copied = 0;
76241
+ const spans = [];
76242
+ for (const ref of refs) {
76243
+ resolved += text.slice(copied, ref.start);
76244
+ const value = resolveRef3(ref, vars).text;
76245
+ spans.push({ from: resolved.length, to: resolved.length + value.length, ref });
76246
+ resolved += value;
76247
+ copied = ref.end;
76248
+ }
76249
+ resolved += text.slice(copied);
76250
+ for (const match of resolved.matchAll(SECRET_PLACEHOLDER_RE)) {
76251
+ const from2 = match.index;
76252
+ const to = from2 + match[0].length;
76253
+ const touching = spans.filter((s) => s.from < to && s.to > from2);
76254
+ if (touching.length === 0) continue;
76255
+ if (touching.length === 1 && touching[0].from <= from2 && touching[0].to >= to) continue;
76256
+ throw new VarReferenceError(
76257
+ `${touching[0].ref.source} would form a {{secret:...}} placeholder with the text or the var next to it. Write the whole placeholder in one var's value or in the e2e test file`
76258
+ );
76259
+ }
76260
+ for (let at = resolved.indexOf(OUTPUT_REFERENCE_MARKER); at !== -1; at = resolved.indexOf(OUTPUT_REFERENCE_MARKER, at + 1)) {
76261
+ const close = resolved.indexOf("}}", at + OUTPUT_REFERENCE_MARKER.length);
76262
+ const end = close === -1 ? resolved.length : close + 2;
76263
+ const touching = spans.find((s) => s.from < end && s.to > at);
76264
+ if (touching) {
76265
+ throw new VarReferenceError(
76266
+ `${touching.ref.source} would form an {{output:...}} reference with the text or the var next to it. A var's value is inserted as text, never read for a reference`
76267
+ );
76268
+ }
76269
+ }
76270
+ return resolved;
76271
+ }
76272
+ function resolveVarValue(text, vars) {
76273
+ if (!holdsVarMarker(text)) return text;
76274
+ const refs = scanReferences(text, VAR_SYNTAX);
76275
+ const only = refs.length === 1 ? refs[0] : void 0;
76276
+ if (!only || only.start !== 0 || only.end !== text.length) return resolveVarText(text, vars);
76277
+ return resolveRef3(only, vars).value;
76278
+ }
76279
+
76161
76280
  // ../tool-server/src/tools/flows/flow-utils.ts
76162
76281
  function windowsPathRefusal(label, value) {
76163
76282
  if (process.platform === "win32" || path15.isAbsolute(value) || !path15.win32.isAbsolute(value)) {
@@ -77778,20 +77897,19 @@ function parseScriptStep(raw, body) {
77778
77897
  };
77779
77898
  if (b.timeout !== void 0) step.timeout = parseScriptTimeout(raw, b.timeout);
77780
77899
  if (b.env !== void 0) {
77781
- const problem = flowEnvProblem(b.env, { references: true });
77900
+ const problem = scriptEnvProblem(b.env);
77782
77901
  if (problem) badEntry(raw, `script.env ${problem}`);
77783
77902
  step.env = b.env;
77784
77903
  }
77785
77904
  return step;
77786
77905
  }
77787
- var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
77788
- function flowEnvProblem(value, { references = false } = {}) {
77906
+ function nameMapProblem(value, example) {
77789
77907
  if (value === null || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
77790
- return "must be a map of variable names to string values, e.g. `env: { API_URL: https://example.com }`";
77908
+ return `must be a map of names to string values, e.g. ${example}`;
77791
77909
  }
77792
77910
  for (const [name, entry] of Object.entries(value)) {
77793
- if (!ENV_NAME_RE.test(name)) {
77794
- return `has an invalid variable name ${JSON.stringify(name)}: use letters, digits and _, not starting with a digit`;
77911
+ if (!VAR_NAME_RE.test(name)) {
77912
+ return `has an invalid name ${JSON.stringify(name)}: use letters, digits and _, not starting with a digit`;
77795
77913
  }
77796
77914
  if (name === "__proto__") return "cannot set __proto__";
77797
77915
  if (typeof entry === "number" || typeof entry === "boolean") {
@@ -77799,19 +77917,32 @@ function flowEnvProblem(value, { references = false } = {}) {
77799
77917
  }
77800
77918
  if (typeof entry !== "string") return `has a non-string value for ${name}`;
77801
77919
  if (entry.includes("\0")) return `has a NUL character in the value of ${name}`;
77802
- if (!references && holdsOutputMarker(entry)) {
77803
- return `has an {{output:...}} reference in the value of ${name}: only the env: of the script step that reads it takes one`;
77804
- }
77805
- const problem = outputReferenceProblem(entry);
77806
- if (problem) return `${name} ${problem}`;
77807
77920
  }
77808
77921
  return void 0;
77809
77922
  }
77810
- function envRecordSchema(value) {
77923
+ function flowVarsProblem(value) {
77924
+ const problem = nameMapProblem(value, "`vars: { USER_NAME: alice }`");
77925
+ if (problem) return problem;
77926
+ for (const [name, entry] of Object.entries(value)) {
77927
+ const valueProblem = varValueProblem(entry);
77928
+ if (valueProblem) return `${name} ${valueProblem}`;
77929
+ }
77930
+ return void 0;
77931
+ }
77932
+ function scriptEnvProblem(value) {
77933
+ const problem = nameMapProblem(value, '`env: { PORT: "8080" }`');
77934
+ if (problem) return problem;
77935
+ for (const [name, entry] of Object.entries(value)) {
77936
+ const referenceProblem = outputReferenceProblem(entry) ?? varReferenceProblem(entry);
77937
+ if (referenceProblem) return `${name} ${referenceProblem}`;
77938
+ }
77939
+ return void 0;
77940
+ }
77941
+ function nameRecordSchema(value, label) {
77811
77942
  return external_exports.preprocess(
77812
77943
  (input2, ctx) => {
77813
77944
  if (input2 !== null && typeof input2 === "object" && Object.hasOwn(input2, "__proto__")) {
77814
- ctx.addIssue({ code: "custom", message: "env cannot set __proto__" });
77945
+ ctx.addIssue({ code: "custom", message: `${label} cannot set __proto__` });
77815
77946
  }
77816
77947
  return input2;
77817
77948
  },
@@ -77905,7 +78036,7 @@ function* selectorFields(sel, where) {
77905
78036
  }
77906
78037
  function* argFields(value, where, set2, typed = true, seen = /* @__PURE__ */ new Set()) {
77907
78038
  if (typeof value === "string") {
77908
- yield { where, value, ...set2 ? { set: set2, typed } : {} };
78039
+ yield { where, value, ...set2 ? { set: set2, typed, secretOk: true } : {} };
77909
78040
  return;
77910
78041
  }
77911
78042
  if (value === null || typeof value !== "object") return;
@@ -77937,7 +78068,7 @@ function* argFields(value, where, set2, typed = true, seen = /* @__PURE__ */ new
77937
78068
  } else {
77938
78069
  const record2 = value;
77939
78070
  for (const [key2, item] of Object.entries(record2)) {
77940
- if (holdsOutputMarker(key2)) yield { where: `${where}.${key2}`, value: key2 };
78071
+ if (holdsReferenceMarker(key2)) yield { where: `${where}.${key2}`, value: key2 };
77941
78072
  yield* argFields(
77942
78073
  item,
77943
78074
  `${where}.${key2}`,
@@ -77956,8 +78087,8 @@ function* toolArgFields(step) {
77956
78087
  return;
77957
78088
  }
77958
78089
  for (const [key2, item] of Object.entries(step.args)) {
77959
- if (holdsOutputMarker(key2)) yield { where: `args.${key2}`, value: key2 };
77960
- const settable = key2 === "env" ? (v) => step.args[key2] = v : void 0;
78090
+ if (holdsReferenceMarker(key2)) yield { where: `args.${key2}`, value: key2 };
78091
+ const settable = key2 === "vars" ? (v) => step.args[key2] = v : void 0;
77961
78092
  yield* argFields(item, `args.${key2}`, settable, typeof item === "string");
77962
78093
  }
77963
78094
  }
@@ -78005,7 +78136,8 @@ function* outputReferenceFields(step) {
78005
78136
  where: "type.text",
78006
78137
  value: step.text,
78007
78138
  set: (v) => step.text = v,
78008
- required: "nonEmpty"
78139
+ required: "nonEmpty",
78140
+ secretOk: true
78009
78141
  };
78010
78142
  return;
78011
78143
  case "await":
@@ -78059,8 +78191,8 @@ function* outputReferenceFields(step) {
78059
78191
  case "run":
78060
78192
  yield { where: "run", value: step.flow };
78061
78193
  return;
78062
- // A script's env values resolve when the step runs, merged across the
78063
- // layers (`runFlowScriptStep`), and parse through `flowEnvProblem`.
78194
+ // A script's env values resolve when the step runs, over the run's vars
78195
+ // (`runFlowScriptStep`), and parse through `scriptEnvProblem`.
78064
78196
  case "script":
78065
78197
  case "idle":
78066
78198
  case "wait":
@@ -78073,54 +78205,91 @@ function* outputReferenceFields(step) {
78073
78205
  }
78074
78206
  }
78075
78207
  }
78076
- function holdsOutputReference(step) {
78208
+ function holdsReferenceMarker(text) {
78209
+ return holdsOutputMarker(text) || holdsVarMarker(text);
78210
+ }
78211
+ function holdsReference(step) {
78077
78212
  for (const field2 of outputReferenceFields(step)) {
78078
- if (holdsOutputMarker(field2.value)) return true;
78213
+ if (holdsReferenceMarker(field2.value)) return true;
78079
78214
  }
78080
78215
  if (step.kind === "script" && step.env) {
78081
- if (Object.values(step.env).some(holdsOutputMarker)) return true;
78216
+ if (Object.values(step.env).some(holdsReferenceMarker)) return true;
78082
78217
  }
78083
- return blockSteps(step)?.some(holdsOutputReference) ?? false;
78218
+ return blockSteps(step)?.some(holdsReference) ?? false;
78084
78219
  }
78085
- function resolveStepOutputs(step, output2) {
78086
- if (![...outputReferenceFields(step)].some((field2) => holdsOutputMarker(field2.value))) {
78220
+ function resolveStepReferences(step, output2, vars) {
78221
+ if (![...outputReferenceFields(step)].some((field2) => holdsReferenceMarker(field2.value))) {
78087
78222
  return step;
78088
78223
  }
78089
78224
  const copy = structuredClone(step);
78090
78225
  const fields = [...outputReferenceFields(copy)];
78091
78226
  for (const field2 of fields) {
78092
- if (!field2.set || !holdsOutputMarker(field2.value)) continue;
78093
- const value = field2.typed ? resolveOutputValue(field2.value, output2) : resolveOutputText(field2.value, output2);
78227
+ if (!field2.set || !holdsReferenceMarker(field2.value)) continue;
78228
+ let value = field2.value;
78229
+ if (holdsVarMarker(field2.value)) {
78230
+ const secret = field2.secretOk ? void 0 : secretVarNames(field2.value, vars)[0];
78231
+ if (secret !== void 0) {
78232
+ throw new VarReferenceError(
78233
+ `\`${field2.where}\` takes {{var:${secret}}}, whose value is a {{secret:...}} placeholder. A secret resolves only in text a step types, a tool's arguments and a script's env; here it would be compared as literal text that is never on screen`
78234
+ );
78235
+ }
78236
+ value = field2.typed ? resolveVarValue(field2.value, vars) : resolveVarText(field2.value, vars);
78237
+ }
78238
+ if (typeof value === "string" && holdsOutputMarker(value)) {
78239
+ value = field2.typed ? resolveOutputValue(value, output2) : resolveOutputText(value, output2);
78240
+ }
78094
78241
  if (field2.required === "visible" && !hasVisibleText(value)) {
78095
- throw new OutputReferenceError(
78242
+ throw new StepReferenceError(
78096
78243
  `\`${field2.where}\` resolved to ${JSON.stringify(value)}, which has no visible text and would match any element`
78097
78244
  );
78098
78245
  }
78099
78246
  if (field2.required === "nonEmpty" && value === "") {
78100
- throw new OutputReferenceError(`\`${field2.where}\` resolved to an empty value`);
78247
+ throw new StepReferenceError(`\`${field2.where}\` resolved to an empty value`);
78101
78248
  }
78102
78249
  field2.set(value);
78103
78250
  }
78104
78251
  return copy;
78105
78252
  }
78106
- function stepOutputReferenceProblem(step) {
78253
+ function stepReferenceProblem(step) {
78107
78254
  for (const field2 of outputReferenceFields(step)) {
78108
- if (!holdsOutputMarker(field2.value)) continue;
78255
+ if (!holdsReferenceMarker(field2.value)) continue;
78109
78256
  const locator = field2.altWhere ? `\`${field2.where}\` (spelled \`${field2.altWhere}\` if the target sits under \`on:\`)` : `\`${field2.where}\``;
78110
78257
  if (field2.set) {
78111
- const problem = outputReferenceProblem(field2.value);
78258
+ const problem = outputReferenceProblem(field2.value) ?? varReferenceProblem(field2.value);
78112
78259
  if (problem) return `${locator} ${problem}`;
78113
78260
  continue;
78114
78261
  }
78115
78262
  const rendered = field2.value.length > MAX_ENTRY_RENDER_CHARS ? `${field2.value.slice(0, MAX_ENTRY_RENDER_CHARS)}\u2026` : field2.value;
78116
- return `${locator} takes no {{output:...}} reference. Replace it with the literal value the step needs: ${JSON.stringify(rendered)}`;
78263
+ return `${locator} takes no {{output:...}} or {{var:...}} reference. Replace it with the literal value the step needs: ${JSON.stringify(rendered)}`;
78264
+ }
78265
+ return void 0;
78266
+ }
78267
+ function unsetVarProblem(steps, vars, label = "Step", trail = []) {
78268
+ for (const [i, step] of steps.entries()) {
78269
+ const at = [...trail, i + 1];
78270
+ const fields = [...outputReferenceFields(step)];
78271
+ if (step.kind === "script" && step.env) {
78272
+ for (const [name, value] of Object.entries(step.env)) {
78273
+ fields.push({ where: `script.env.${name}`, value });
78274
+ }
78275
+ }
78276
+ for (const field2 of fields) {
78277
+ for (const name of requiredVarNames(field2.value)) {
78278
+ if (!varIsSet(vars, name)) {
78279
+ return `${label} ${at.join(".")} (\`${step.kind}\`): \`${field2.where}\` takes {{var:${name}}}, but ${missingVarReason(name, vars)}. Set it in the e2e test's \`vars:\` or with \`--var ${name}=...\`, or give the reference a fallback: \`{{var:${name} ?? ...}}\``;
78280
+ }
78281
+ }
78282
+ }
78283
+ const inner = blockSteps(step);
78284
+ const problem = inner ? unsetVarProblem(inner, vars, label, at) : void 0;
78285
+ if (problem) return problem;
78117
78286
  }
78118
78287
  return void 0;
78119
78288
  }
78120
78289
  function assertOutputReferences(steps, trail = [], label = "Step") {
78121
78290
  steps.forEach((step, i) => {
78122
78291
  const at = [...trail, i + 1];
78123
- const problem = stepOutputReferenceProblem(step);
78292
+ const problem = stepReferenceProblem(step);
78124
78293
  if (problem) {
78125
78294
  throw new FailureError(`${label} ${at.join(".")} (\`${step.kind}\`): ${problem}`, {
78126
78295
  error_code: FAILURE_CODES.FLOW_ENTRY_UNRECOGNIZED,
@@ -78439,7 +78608,7 @@ function serializeFlow(flow) {
78439
78608
  const doc = {
78440
78609
  version: FLOW_FILE_VERSION,
78441
78610
  ...flow.requires ? { requires: requiresToYaml(flow.requires) } : {},
78442
- ...flow.env ? { env: flow.env } : {},
78611
+ ...flow.vars ? { vars: flow.vars } : {},
78443
78612
  steps: flow.steps.map(toYamlStep),
78444
78613
  ...flow.shutdown?.length ? { shutdown: flow.shutdown.map(toYamlStep) } : {}
78445
78614
  };
@@ -78524,7 +78693,7 @@ function parseFlowContent(content, stepErrors) {
78524
78693
  "version",
78525
78694
  "executionPrerequisite",
78526
78695
  "requires",
78527
- "env",
78696
+ "vars",
78528
78697
  "steps",
78529
78698
  "shutdown"
78530
78699
  ];
@@ -78552,10 +78721,10 @@ function parseFlowContent(content, stepErrors) {
78552
78721
  const steps = parseStepList(parsed2.steps, 0, sink);
78553
78722
  const shutdown2 = parseStepList(parsed2.shutdown ?? [], 0, sink, true);
78554
78723
  if (stepErrors?.length) return null;
78555
- if (parsed2.env !== void 0) {
78556
- const problem = flowEnvProblem(parsed2.env);
78724
+ if (parsed2.vars !== void 0) {
78725
+ const problem = flowVarsProblem(parsed2.vars);
78557
78726
  if (problem) {
78558
- throw new FailureError(`Invalid e2e test file: env ${problem}`, {
78727
+ throw new FailureError(`Invalid e2e test file: vars ${problem}`, {
78559
78728
  error_code: FAILURE_CODES.FLOW_FILE_INVALID,
78560
78729
  failure_stage: "flow_file_parse",
78561
78730
  failure_area: "tool_server",
@@ -78566,7 +78735,7 @@ function parseFlowContent(content, stepErrors) {
78566
78735
  const flow = {
78567
78736
  executionPrerequisite: parsed2.executionPrerequisite ?? "",
78568
78737
  ...parsed2.requires === void 0 ? {} : { requires: parseRequires(parsed2.requires) },
78569
- ...parsed2.env === void 0 ? {} : { env: parsed2.env },
78738
+ ...parsed2.vars === void 0 ? {} : { vars: parsed2.vars },
78570
78739
  steps,
78571
78740
  ...shutdown2.length > 0 ? { shutdown: shutdown2 } : {}
78572
78741
  };
@@ -78717,24 +78886,24 @@ async function countStepsOnDisk(filePath, block = "steps") {
78717
78886
  return void 0;
78718
78887
  }
78719
78888
  }
78720
- async function setRecordingEnv(session, changes) {
78889
+ async function setRecordingVars(session, changes) {
78721
78890
  const apply = (flow) => {
78722
- const env = { ...flow.env };
78891
+ const vars = { ...flow.vars };
78723
78892
  for (const [name, value] of Object.entries(changes)) {
78724
- if (value === null) delete env[name];
78725
- else env[name] = value;
78893
+ for (const existing of namesOfVar(vars, name)) delete vars[existing];
78894
+ if (value !== null) vars[name] = value;
78726
78895
  }
78727
- const next = { ...flow, env };
78728
- if (Object.keys(env).length === 0) delete next.env;
78896
+ const next = { ...flow, vars };
78897
+ if (Object.keys(vars).length === 0) delete next.vars;
78729
78898
  return next;
78730
78899
  };
78731
78900
  return withFlowLock(session.key, async () => {
78732
78901
  if (recordingSessionState(session) !== "live") {
78733
78902
  throw new FailureError(
78734
- `The recording of e2e test "${session.name}" ended while env was being set; nothing was changed.`,
78903
+ `The recording of e2e test "${session.name}" ended while vars were being set; nothing was changed.`,
78735
78904
  {
78736
78905
  error_code: FAILURE_CODES.FLOW_NO_ACTIVE_RECORDING,
78737
- failure_stage: "flow_set_env",
78906
+ failure_stage: "flow_set_vars",
78738
78907
  failure_area: "tool_server",
78739
78908
  error_kind: "validation"
78740
78909
  }
@@ -78747,13 +78916,13 @@ async function setRecordingEnv(session, changes) {
78747
78916
  const updated = serializeFlow(flow2);
78748
78917
  await writeFlowFile(session.filePath, updated);
78749
78918
  adoptRecordedFile(session, parseFlow(updated));
78750
- return { env: session.flow.env ?? {}, savedTo: session.filePath };
78919
+ return { vars: session.flow.vars ?? {}, savedTo: session.filePath };
78751
78920
  }
78752
78921
  const flow = apply(session.flow);
78753
78922
  validateFlow(flow);
78754
78923
  const savedTo = clientFileDirective(session.filePath, serializeFlow(flow));
78755
78924
  session.flow = flow;
78756
- return { env: flow.env ?? {}, savedTo };
78925
+ return { vars: flow.vars ?? {}, savedTo };
78757
78926
  });
78758
78927
  }
78759
78928
  async function appendStep(filePath, step, block) {
@@ -165273,6 +165442,12 @@ function setEnvName(env, name, value) {
165273
165442
  }
165274
165443
  env[name] = value;
165275
165444
  }
165445
+ function isHostEnvName(name) {
165446
+ const caseInsensitive = process.platform === "win32";
165447
+ const key2 = caseInsensitive ? name.toLowerCase() : name;
165448
+ const matches2 = (candidate) => (caseInsensitive ? candidate.toLowerCase() : candidate) === key2;
165449
+ return ALLOWED_ENV_NAMES.some(matches2) || ALLOWED_ENV_PREFIXES.some((prefix) => key2.startsWith(prefix)) || RESERVED_ENV_NAMES.some(matches2) || reservedNpmConfigName(name) !== void 0;
165450
+ }
165276
165451
  function buildChildEnv(overrides) {
165277
165452
  const caseInsensitive = process.platform === "win32";
165278
165453
  const allowed = new Set(
@@ -165605,6 +165780,7 @@ function describeDuration(ms3) {
165605
165780
  }
165606
165781
 
165607
165782
  // ../tool-server/src/tools/flows/flow-script-step.ts
165783
+ init_src();
165608
165784
  init_capability();
165609
165785
  var vegaKindBySerial = /* @__PURE__ */ new Map();
165610
165786
  async function scriptDeviceKind(device) {
@@ -165644,13 +165820,19 @@ function resolveScriptEnv(env, projectRoot, clientSecrets) {
165644
165820
  }
165645
165821
  return { env: resolved, secrets };
165646
165822
  }
165647
- function outputsInEnv(env, output2) {
165823
+ function exportedVars(vars) {
165824
+ const placeholder = new RegExp(SECRET_PLACEHOLDER_RE.source);
165825
+ return Object.fromEntries(
165826
+ Object.entries(vars).filter(([name, value]) => !placeholder.test(value) && !isHostEnvName(name))
165827
+ );
165828
+ }
165829
+ function referencesInEnv(env, vars, output2) {
165648
165830
  const resolved = {};
165649
165831
  for (const [name, value] of Object.entries(env)) {
165650
165832
  try {
165651
- resolved[name] = resolveOutputText(value, output2);
165833
+ resolved[name] = resolveOutputText(resolveVarText(value, vars), output2);
165652
165834
  } catch (err) {
165653
- if (err instanceof OutputReferenceError) {
165835
+ if (err instanceof StepReferenceError) {
165654
165836
  throw new InvalidToolInputError(`The value of ${name}: ${err.message}.`);
165655
165837
  }
165656
165838
  throw err;
@@ -165697,8 +165879,10 @@ async function runFlowScriptStep(request4) {
165697
165879
  }
165698
165880
  let resolved;
165699
165881
  try {
165700
- if (request4.env) {
165701
- const env2 = outputsInEnv(request4.env, request4.output ?? {});
165882
+ const vars = request4.vars ?? {};
165883
+ const stepEnv = step.env ? referencesInEnv(step.env, vars, request4.output ?? {}) : void 0;
165884
+ const env2 = mergeScriptEnv(exportedVars(vars), stepEnv);
165885
+ if (Object.keys(env2).length > 0) {
165702
165886
  resolved = resolveScriptEnv(env2, request4.projectRoot, request4.clientSecrets);
165703
165887
  }
165704
165888
  } catch (err) {
@@ -165916,11 +166100,13 @@ var zodSchema70 = external_exports.object({
165916
166100
  ]).optional(),
165917
166101
  runtimeKind: external_exports.enum(RUNTIME_KINDS).optional()
165918
166102
  }).optional().describe("Supported target filter (`platform` and/or `runtimeKind`, ANDed). Omit for any."),
165919
- env: envRecordSchema(external_exports.string()).optional().describe("Top-level script env defaults. Supports `{{secret:NAME}}`.")
166103
+ vars: nameRecordSchema(external_exports.string(), "vars").optional().describe(
166104
+ "Test inputs to save under `vars:` and read with `{{var:NAME}}`. Use `{{secret:NAME}}` for credentials."
166105
+ )
165920
166106
  });
165921
166107
  var flowStartRecordingTool = {
165922
166108
  id: "e2e-start-recording",
165923
- description: `Start recording a new e2e test, resetting \`.argent/e2e/<name>.yaml\`. Starting over an existing test replaces the whole file, including its \`requires:\` and \`env:\` blocks (pass \`requires\` and \`env\` to keep them), and runs pending fragment cleanup on restart.
166109
+ description: `Start recording an e2e test in \`.argent/e2e/<name>.yaml\`. Starting over replaces the entire file. Pass \`requires\` and \`vars\` again to retain them. Restart runs any pending fragment cleanup.
165924
166110
  Use when capturing a reusable sequence of device actions for replay; load the \`argent-create-e2e\` skill first. Not for Apple TV or Android TV.
165925
166111
  Record live steps with \`e2e-add-step\` (start standalone tests with \`restart-app\`; use \`executionPrerequisite\` for fragments), \`e2e-add-echo\`, and \`e2e-add-script\`, then call \`e2e-finish-recording\`. Edit the YAML only after finishing.
165926
166112
  Returns \`{ message, e2eTestFile, savedTo, restarted?, discardedSteps?, fragmentShutdown? }\`. Fails if the target file or directory cannot be written.`,
@@ -165942,14 +166128,14 @@ Returns \`{ message, e2eTestFile, savedTo, restarted?, discardedSteps?, fragment
165942
166128
  longRunning: true,
165943
166129
  services: () => ({}),
165944
166130
  async execute(_services, params, ctx) {
165945
- if (params.env) {
165946
- const problem = flowEnvProblem(params.env);
165947
- if (problem) throw new InvalidToolInputError(`env ${problem}`);
166131
+ if (params.vars) {
166132
+ const problem = flowVarsProblem(params.vars);
166133
+ if (problem) throw new InvalidToolInputError(`vars ${problem}`);
165948
166134
  }
165949
166135
  const flow = {
165950
166136
  executionPrerequisite: params.executionPrerequisite ?? "",
165951
166137
  ...params.requires ? { requires: parseRequires(params.requires) } : {},
165952
- ...params.env && Object.keys(params.env).length > 0 ? { env: params.env } : {},
166138
+ ...params.vars && Object.keys(params.vars).length > 0 ? { vars: params.vars } : {},
165953
166139
  steps: []
165954
166140
  };
165955
166141
  validateFlow(flow);
@@ -165957,7 +166143,7 @@ Returns \`{ message, e2eTestFile, savedTo, restarted?, discardedSteps?, fragment
165957
166143
  const probe4 = ctx?.fileInputs?.project_root;
165958
166144
  const persist2 = ctx?.linked || probe4 && !probe4.presentOnHost ? "client" : "host";
165959
166145
  const filePath = persist2 === "client" && ctx?.legacyE2eDir ? getLegacyFlowPath(params.project_root, params.name) : getFlowPath(params.project_root, params.name);
165960
- if (params.env) resolveScriptEnv(params.env, params.project_root, ctx?.clientSecrets);
166146
+ if (params.vars) resolveScriptEnv(params.vars, params.project_root, ctx?.clientSecrets);
165961
166147
  const { savedTo, replaced, discardedSteps } = await withFlowFileLock(
165962
166148
  params.project_root,
165963
166149
  params.name,
@@ -169088,7 +169274,7 @@ var DIRECTIVE_COMMAND_HINTS = {
169088
169274
  var NESTED_RECORDER_TOOLS = {
169089
169275
  "e2e-add-echo": "`e2e-add-echo` records a step itself, so it must be called DIRECTLY, not through e2e-add-step \u2014 nesting it would write the echo AND a `tool: e2e-add-echo` step that fails on every replay.",
169090
169276
  "e2e-add-script": "`e2e-add-script` records its own step. Call it directly, not through e2e-add-step.",
169091
- "e2e-set-env": "`e2e-set-env` edits the e2e test's top-level env:, so it is not a step. Call it directly.",
169277
+ "e2e-set-vars": "`e2e-set-vars` edits the e2e test's top-level vars:, so it is not a step. Call it directly.",
169092
169278
  "e2e-add-step": "e2e-add-step cannot record itself. Pass the MCP tool you want to execute as `command`.",
169093
169279
  "e2e-start-recording": "`e2e-start-recording` truncates the e2e test it names. Recording it as a step would erase this e2e test at replay; call it directly when you want to start a recording.",
169094
169280
  "e2e-finish-recording": "`e2e-finish-recording` ends the recording, so it cannot also be a step in it. Call it directly when the walkthrough is complete."
@@ -169219,6 +169405,11 @@ async function captureRunTarget(session, args, project) {
169219
169405
  if (name === void 0) {
169220
169406
  return { warning: "e2e-execute call had no e2e test name; kept the raw step" };
169221
169407
  }
169408
+ if (args.vars !== void 0) {
169409
+ return {
169410
+ warning: "kept the raw e2e-execute step \u2014 a `run:` step gets the vars of the e2e test that runs it, so the call's own `vars` would be lost at replay"
169411
+ };
169412
+ }
169222
169413
  try {
169223
169414
  assertSafeFlowName(name);
169224
169415
  const projectRoot = args.project_root;
@@ -169364,15 +169555,19 @@ Returns \`{ message, toolResult, stepCount, recorded?, savedTo }\`. Fails if no
169364
169555
  await rewriteSiblingFlowPath(session, args, project, linked);
169365
169556
  }
169366
169557
  const authored = { kind: "tool", name: command, args };
169367
- const referencedArgs = holdsOutputReference(authored) ? args : void 0;
169558
+ const referencedArgs = holdsReference(authored) ? args : void 0;
169368
169559
  if (referencedArgs) {
169369
- const problem = stepOutputReferenceProblem(authored);
169560
+ const problem = stepReferenceProblem(authored);
169370
169561
  if (problem)
169371
169562
  throw new InvalidToolInputError(`Nothing ran and no step was recorded: ${problem}`);
169372
169563
  try {
169373
- args = resolveStepOutputs(authored, recordingOutput(session, block)).args;
169564
+ args = resolveStepReferences(
169565
+ authored,
169566
+ recordingOutput(session, block),
169567
+ session.flow.vars ?? {}
169568
+ ).args;
169374
169569
  } catch (err) {
169375
- if (!(err instanceof OutputReferenceError)) throw err;
169570
+ if (!(err instanceof StepReferenceError)) throw err;
169376
169571
  throw new InvalidToolInputError(`Nothing ran and no step was recorded: ${err.message}`);
169377
169572
  }
169378
169573
  }
@@ -169424,7 +169619,8 @@ Returns \`{ message, toolResult, stepCount, recorded?, savedTo }\`. Fails if no
169424
169619
  }
169425
169620
  prepared = await prepareToolStepInputs(registry2, project, params.command, args);
169426
169621
  const nestedFromClient = command === RUN_TARGET_COMMAND && prepared.fileInputs !== void 0;
169427
- toolResult = await invokeSubTool(registry2, ctx, params.command, prepared.args, {
169622
+ const invokeArgs = runTarget?.flow && session.flow.vars ? { ...prepared.args, vars: session.flow.vars } : prepared.args;
169623
+ toolResult = await invokeSubTool(registry2, ctx, params.command, invokeArgs, {
169428
169624
  ...prepared.fileInputs ? { fileInputs: prepared.fileInputs } : {},
169429
169625
  // A nested run whose flow came from the client gets a run stack even
169430
169626
  // with no enclosing run, which marks it as nested: its refusals name
@@ -169664,43 +169860,42 @@ Returns { message, stepCount, savedTo }. Fails if that e2e test has no recording
169664
169860
  }
169665
169861
  };
169666
169862
 
169667
- // ../tool-server/src/tools/flows/flow-set-env.ts
169863
+ // ../tool-server/src/tools/flows/flow-set-vars.ts
169668
169864
  init_zod();
169669
169865
  init_capability();
169670
169866
  var zodSchema73 = external_exports.object({
169671
169867
  name: external_exports.string().describe("Test name passed to e2e-start-recording."),
169672
169868
  project_root: external_exports.string().describe("Absolute project root passed to e2e-start-recording."),
169673
- env: envRecordSchema(external_exports.string().nullable()).describe(
169674
- "Variable names to update. A null value removes that name. Omitted names keep their values. Use {{secret:NAME}} for credentials."
169869
+ vars: nameRecordSchema(external_exports.string().nullable(), "vars").describe(
169870
+ "Set values by name. Use null to remove a name and `{{secret:NAME}}` for credentials."
169675
169871
  )
169676
169872
  });
169677
- var flowSetEnvTool = {
169678
- id: "e2e-set-env",
169679
- description: `Set or remove script environment defaults in an active e2e recording. Use when several script steps need a shared value. Call this tool directly before e2e-add-script.
169680
- Returns the updated env map with secret placeholders intact, plus savedTo. If the tool rejects an invalid value or missing secret, correct the input or define the secret and retry.`,
169873
+ var flowSetVarsTool = {
169874
+ id: "e2e-set-vars",
169875
+ description: `Update the test inputs in an active e2e recording. Call directly before recording steps that use \`{{var:NAME}}\`. Saves the defaults under \`vars:\` and returns them with secret placeholders intact.`,
169681
169876
  zodSchema: zodSchema73,
169682
169877
  fileInputs: PROJECT_ROOT_INPUT,
169683
169878
  interaction: {
169684
- startedMsg: ({ params }) => `Setting env for e2e test ${params.name}`,
169685
- completedMsg: ({ params }) => `Set env for e2e test ${params.name}`,
169686
- failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to set env for e2e test ${params.name}: ${failureSignal2.error_code}`
169879
+ startedMsg: ({ params }) => `Setting vars for e2e test ${params.name}`,
169880
+ completedMsg: ({ params }) => `Set vars for e2e test ${params.name}`,
169881
+ failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to set vars for e2e test ${params.name}: ${failureSignal2.error_code}`
169687
169882
  },
169688
169883
  services: () => ({}),
169689
169884
  async execute(_services, params, ctx) {
169690
169885
  const session = await requireRecordingSession(params.project_root, params.name);
169691
169886
  const set2 = {};
169692
- for (const [name, value] of Object.entries(params.env)) {
169887
+ for (const [name, value] of Object.entries(params.vars)) {
169693
169888
  if (value !== null) set2[name] = value;
169694
169889
  }
169695
- const problem = flowEnvProblem(
169696
- Object.fromEntries(Object.entries(params.env).map(([name, value]) => [name, value ?? ""]))
169890
+ const problem = flowVarsProblem(
169891
+ Object.fromEntries(Object.entries(params.vars).map(([name, value]) => [name, value ?? ""]))
169697
169892
  );
169698
- if (problem) throw new InvalidToolInputError(`env ${problem}`);
169893
+ if (problem) throw new InvalidToolInputError(`vars ${problem}`);
169699
169894
  resolveScriptEnv(set2, params.project_root, ctx?.clientSecrets);
169700
- const { env, savedTo } = await setRecordingEnv(session, params.env);
169895
+ const { vars, savedTo } = await setRecordingVars(session, params.vars);
169701
169896
  return {
169702
- message: `Updated env of "${params.name}" e2e test.`,
169703
- env,
169897
+ message: `Updated vars of "${params.name}" e2e test.`,
169898
+ vars,
169704
169899
  savedTo
169705
169900
  };
169706
169901
  }
@@ -169722,9 +169917,9 @@ async function recordedStepCount(session, block) {
169722
169917
  note: `Could not verify stepCount from ${session.filePath}.`
169723
169918
  };
169724
169919
  }
169725
- async function recordedFileEnv(session) {
169920
+ async function recordedFileVars(session) {
169726
169921
  try {
169727
- return parseFlow(await fs83.readFile(session.filePath, "utf8")).env;
169922
+ return parseFlow(await fs83.readFile(session.filePath, "utf8")).vars;
169728
169923
  } catch (err) {
169729
169924
  throw wrapFailure(
169730
169925
  err,
@@ -169767,7 +169962,9 @@ var zodSchema74 = external_exports.object({
169767
169962
  project_root: external_exports.string().describe("Project root from `e2e-start-recording`."),
169768
169963
  path: external_exports.string().describe("Script path (.mjs/.mts/.js/.ts) relative to the test YAML."),
169769
169964
  timeout: external_exports.number().optional().describe("Timeout in ms (default 30000, min 100)."),
169770
- env: envRecordSchema(external_exports.string()).optional().describe("Env overrides (supports `{{secret:NAME}}` and `{{output:PATH}}`)."),
169965
+ env: nameRecordSchema(external_exports.string(), "env").optional().describe(
169966
+ "Environment values for this script. Override same-name vars. Supports `{{secret:NAME}}`, `{{var:NAME}}`, and `{{output:PATH}}`."
169967
+ ),
169771
169968
  shutdown: external_exports.boolean().optional().describe(
169772
169969
  "Save the script in the shutdown list. Pending fragment cleanup runs before the script. The script's output reaches only later shutdown steps. stepCount counts shutdown entries."
169773
169970
  ),
@@ -169819,7 +170016,7 @@ Returns \`{ status, reason?, outputJson?, stepCount, recorded? }\`. A failed scr
169819
170016
  ...params.env !== void 0 ? { env: params.env } : {}
169820
170017
  }
169821
170018
  };
169822
- const envProblem = params.env === void 0 ? void 0 : flowEnvProblem(params.env, { references: true });
170019
+ const envProblem = params.env === void 0 ? void 0 : scriptEnvProblem(params.env);
169823
170020
  if (envProblem) throw new InvalidToolInputError(`env ${envProblem}`);
169824
170021
  const step = {
169825
170022
  kind: "script",
@@ -169828,14 +170025,14 @@ Returns \`{ status, reason?, outputJson?, stepCount, recorded? }\`. A failed scr
169828
170025
  ...params.env && Object.keys(params.env).length > 0 ? { env: params.env } : {}
169829
170026
  };
169830
170027
  const flowDir = nodePath.dirname(await canonicalFlowPath(session.filePath));
169831
- const env = mergeScriptEnv(await recordedFileEnv(session), step.env);
170028
+ const vars = await recordedFileVars(session);
169832
170029
  const ranAgainst = recordingOutput(session, block);
169833
170030
  const { outcome, result, ran } = await runFlowScriptStep({
169834
170031
  flowDir,
169835
170032
  step,
169836
170033
  projectRoot: params.project_root,
169837
170034
  ...params.udid !== void 0 ? { device: resolveDevice(params.udid) } : {},
169838
- env,
170035
+ ...vars ? { vars } : {},
169839
170036
  output: ranAgainst,
169840
170037
  ...ctx?.clientSecrets ? { clientSecrets: ctx.clientSecrets } : {},
169841
170038
  ...ctx?.signal ? { signal: ctx.signal } : {}
@@ -170293,7 +170490,12 @@ function toolArgsRefusal(tool, def, stepArgs) {
170293
170490
  args = bindDeviceArgsTo(def.inputSchema, CHECK_DEVICE_ID, args);
170294
170491
  const parsed2 = def.zodSchema?.safeParse(args);
170295
170492
  if (!parsed2 || parsed2.success) return void 0;
170296
- const issues = parsed2.error.issues.filter((issue2) => !BOUND_KEYS.includes(String(issue2.path[0])));
170493
+ const issues = parsed2.error.issues.filter((issue2) => {
170494
+ const key2 = String(issue2.path[0]);
170495
+ if (BOUND_KEYS.includes(key2)) return false;
170496
+ const value = args[key2];
170497
+ return !holdsReferenceMarker(typeof value === "string" ? value : JSON.stringify(value) ?? "");
170498
+ });
170297
170499
  if (issues.length === 0) return void 0;
170298
170500
  return `Invalid params for tool "${toolId}": ${describeParamIssues({ issues }, args)}`;
170299
170501
  }
@@ -173488,11 +173690,13 @@ var zodSchema76 = external_exports.object({
173488
173690
  prerequisiteAcknowledged: external_exports.boolean().optional().describe(
173489
173691
  "Set true to confirm a fragment's `executionPrerequisite` is met; otherwise returns the prerequisite text without running. Not a dry run: a test with no prerequisite runs in full (read `executionPrerequisite` in the YAML to inspect without running)."
173490
173692
  ),
173491
- env: external_exports.record(external_exports.string(), external_exports.string()).optional().describe("Script env overrides (also for `run:` fragments). Supports `{{secret:NAME}}`.")
173693
+ vars: external_exports.record(external_exports.string(), external_exports.string()).optional().describe(
173694
+ "Overrides for the test's `vars:` defaults, including `run:` fragments. Values can contain `{{secret:NAME}}` placeholders."
173695
+ )
173492
173696
  }).superRefine((params, ctx) => {
173493
- const envProblem = params.env === void 0 ? void 0 : flowEnvProblem(params.env);
173494
- if (envProblem) {
173495
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: envProblem, path: ["env"] });
173697
+ const varsProblem = params.vars === void 0 ? void 0 : flowVarsProblem(params.vars);
173698
+ if (varsProblem) {
173699
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: varsProblem, path: ["vars"] });
173496
173700
  }
173497
173701
  if (params.name === void 0 === (params.e2e_test_path === void 0)) {
173498
173702
  ctx.addIssue({
@@ -173548,8 +173752,20 @@ Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the tes
173548
173752
  if (retiredArg) throw preflightFailure(retiredArg);
173549
173753
  const unrunnableScript = await unrunnableScriptRefusal(flow, flowName);
173550
173754
  if (unrunnableScript) throw preflightFailure(unrunnableScript);
173551
- const runEnv = mergeScriptEnv(params.env);
173552
- resolveScriptEnv(runEnv, params.project_root, ctx?.clientSecrets);
173755
+ const runVars = mergeScriptEnv(params.vars);
173756
+ resolveScriptEnv(runVars, params.project_root, ctx?.clientSecrets);
173757
+ const unsetVar = unsetVarProblem(
173758
+ [...flow.steps, ...flow.shutdown ?? []],
173759
+ mergeScriptEnv(flow.vars, runVars)
173760
+ );
173761
+ if (unsetVar) {
173762
+ throw new FailureError(`E2E test "${flowName}" was not run. ${unsetVar}`, {
173763
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
173764
+ failure_stage: "flow_run_validate",
173765
+ failure_area: "tool_server",
173766
+ error_kind: "validation"
173767
+ });
173768
+ }
173553
173769
  const enclosing = ctx?.flowStack ?? [];
173554
173770
  const nesting = nestedRunRefusal(enclosing, rootEntry);
173555
173771
  if (nesting !== void 0) throw nestingFailure(nesting.refusal);
@@ -173638,7 +173854,7 @@ Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the tes
173638
173854
  snapshotApps: /* @__PURE__ */ new Map(),
173639
173855
  secret: ctx?.flowSecret ?? {},
173640
173856
  projectRoot: params.project_root,
173641
- runEnv,
173857
+ runVars,
173642
173858
  output: ctx?.flowOutput ?? { doc: {} },
173643
173859
  scriptLogBudget: createScriptLogBudget(),
173644
173860
  networkCaptureNoted: /* @__PURE__ */ new Map(),
@@ -173651,7 +173867,7 @@ Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the tes
173651
173867
  try {
173652
173868
  const rootScope = {
173653
173869
  runStack: seed,
173654
- fileEnv: flow.env ?? {},
173870
+ fileVars: flow.vars ?? {},
173655
173871
  rootDisplay: rootEntry.display,
173656
173872
  depth: 0,
173657
173873
  legacyPoints: flowFormatVersion(flow) < 2
@@ -173915,6 +174131,9 @@ function pushReport(state3, report2) {
173915
174131
  state3.reports.push(report2);
173916
174132
  state3.onStepReport?.(report2);
173917
174133
  }
174134
+ function scopeVars(state3, scope) {
174135
+ return mergeScriptEnv(scope.fileVars, state3.runVars);
174136
+ }
173918
174137
  function scopeFlow(scope) {
173919
174138
  return scope.runStack[scope.runStack.length - 1].display;
173920
174139
  }
@@ -174011,14 +174230,14 @@ async function execSteps(state3, steps, scope) {
174011
174230
  startedAt -= state3.hoistedBootMs;
174012
174231
  state3.hoistedBootMs = void 0;
174013
174232
  }
174014
- if (step.kind !== "script" && JSON.stringify(step).includes(SECRET_PLACEHOLDER_MARKER)) {
174015
- state3.secret.typed = true;
174016
- }
174233
+ const typesSecret = (s) => s.kind !== "script" && JSON.stringify(s).includes(SECRET_PLACEHOLDER_MARKER);
174234
+ if (typesSecret(step)) state3.secret.typed = true;
174017
174235
  let leaf;
174018
174236
  try {
174019
- leaf = resolveStepOutputs(step, state3.output.doc);
174237
+ leaf = resolveStepReferences(step, state3.output.doc, scopeVars(state3, scope));
174238
+ if (typesSecret(leaf)) state3.secret.typed = true;
174020
174239
  } catch (err) {
174021
- if (!(err instanceof OutputReferenceError)) throw err;
174240
+ if (!(err instanceof StepReferenceError)) throw err;
174022
174241
  pushReport(state3, {
174023
174242
  index,
174024
174243
  kind: step.kind,
@@ -174148,9 +174367,9 @@ async function execWhenStep(state3, authored, scope) {
174148
174367
  const inner = childScope(scope);
174149
174368
  let step;
174150
174369
  try {
174151
- step = resolveStepOutputs(authored, state3.output.doc);
174370
+ step = resolveStepReferences(authored, state3.output.doc, scopeVars(state3, scope));
174152
174371
  } catch (err) {
174153
- if (!(err instanceof OutputReferenceError)) throw err;
174372
+ if (!(err instanceof StepReferenceError)) throw err;
174154
174373
  pushReport(state3, { ...unresolved, status: "error", reason: escapeInline(err.message) });
174155
174374
  state3.stopped = true;
174156
174375
  reportBlockSkipped(state3, authored.steps, inner, "when guard errored");
@@ -174241,6 +174460,13 @@ async function execRunStep(state3, step, scope) {
174241
174460
  return fail(errMsg6(err));
174242
174461
  }
174243
174462
  }
174463
+ const fileVars = mergeScriptEnv(fragment.vars, scope.fileVars);
174464
+ const unsetVar = unsetVarProblem(
174465
+ [...fragment.steps, ...fragment.shutdown ?? []],
174466
+ mergeScriptEnv(fileVars, state3.runVars),
174467
+ `Fragment "${shown}" step`
174468
+ );
174469
+ if (unsetVar) return fail(unsetVar);
174244
174470
  pushReport(state3, {
174245
174471
  index,
174246
174472
  kind: "run",
@@ -174252,7 +174478,7 @@ async function execRunStep(state3, step, scope) {
174252
174478
  });
174253
174479
  const fragmentScope = childScope(scope, {
174254
174480
  runStack: [...scope.runStack, { canonical, display }],
174255
- fileEnv: mergeScriptEnv(fragment.env, scope.fileEnv),
174481
+ fileVars,
174256
174482
  legacyPoints: flowFormatVersion(fragment) < 2
174257
174483
  });
174258
174484
  if (fragment.shutdown) {
@@ -174264,13 +174490,12 @@ function oneLineReason(text) {
174264
174490
  return text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
174265
174491
  }
174266
174492
  async function runScriptStep(state3, step, scope) {
174267
- const env = mergeScriptEnv(scope.fileEnv, step.env, state3.runEnv);
174268
174493
  const { outcome, result } = await runFlowScriptStep({
174269
174494
  flowDir: scopeFlowDir(scope),
174270
174495
  step,
174271
174496
  projectRoot: state3.projectRoot,
174272
174497
  device: state3.device,
174273
- env,
174498
+ vars: scopeVars(state3, scope),
174274
174499
  output: state3.output.doc,
174275
174500
  ...state3.ctx?.clientSecrets ? { clientSecrets: state3.ctx.clientSecrets } : {},
174276
174501
  logBudget: state3.scriptLogBudget,
@@ -176514,7 +176739,7 @@ function createRegistry() {
176514
176739
  registry2.registerTool(flowStartRecordingTool);
176515
176740
  registry2.registerTool(createFlowAddStepTool(registry2));
176516
176741
  registry2.registerTool(flowInsertEchoTool);
176517
- registry2.registerTool(flowSetEnvTool);
176742
+ registry2.registerTool(flowSetVarsTool);
176518
176743
  registry2.registerTool(flowAddScriptTool);
176519
176744
  registry2.registerTool(flowFinishRecordingTool);
176520
176745
  registry2.registerTool(flowReadPrerequisiteTool);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.35.1-next.43",
3
+ "version": "0.35.1-next.45",
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": "62ec07e8a69c9465d2e9ca80decce1af295dbf2f"
101
+ "gitHead": "6b6f0509a40b30bb6d70096e186d8e1e76990cb5"
102
102
  }
@@ -257,16 +257,16 @@ A `run:` target is a YAML path resolved against the directory of the test file c
257
257
  ```yaml
258
258
  - script: { path: ../../scripts/seed-order.mjs }
259
259
  - script: { path: ../../scripts/seed-order.mjs, timeout: 60000 }
260
- - script: { path: ../../scripts/seed-order.mjs, env: { API_TOKEN: "{{secret:API_TOKEN}}" } }
260
+ - script: { path: ../../scripts/seed-order.mjs, env: { API_TOKEN: "{{var:API_TOKEN}}" } }
261
261
  ```
262
262
 
263
263
  Use the map form shown above. A bare `script: scripts/seed.mjs` is invalid.
264
264
 
265
265
  `path` is relative to the test file that contains the step. Use an `.mjs` or `.js` file, or an `.mts` or `.ts` file for TypeScript, and match the file name's letter case. `timeout` is in milliseconds, as in `e2e-add-script`.
266
266
 
267
- Use top-level `env` for script defaults, step `env` for one script, and `--env NAME=value` or `e2e-execute.env` for run overrides. The last layer to set a name wins. A `run:` fragment fills missing defaults. Pass overrides explicitly to a separate `tool: e2e-execute` run.
267
+ Scripts get ordinary [vars](#vars) through `process.env`. Use step `env` to pass a secret var explicitly or override a value for one script. To let `--var` override an `env` entry, use `"{{var:NAME}}"` as its value.
268
268
 
269
- Quote non-string YAML scalars, such as `PORT: "8080"`. Use `{{secret:NAME}}` for credentials and keep credentials out of logs. If a secret is missing, check the secret sources for the run's project root. See [Environment values](https://docs.swmansion.com/argent/docs/reference/e2e-yaml#environment-values) for the value rules and redaction limits.
269
+ Quote numbers and booleans in `env`, for example `PORT: "8080"`. If a secret is missing, check the secret sources for the run's project root. See [Script environment](https://docs.swmansion.com/argent/docs/reference/e2e-yaml#script-environment) for excluded host names and redaction limits.
270
270
 
271
271
  `.mjs` and `.mts` are always ES modules. `.js` and `.ts` take their module type from the project's `package.json` `type` field; with no `type`, Node reads a file with `import`, `export` or top-level `await` as an ES module, and each other file as CommonJS. So prefer `.mjs` or `.mts` for a new script and use `.js` or `.ts` for a script the project already has. `.cjs` and `.cts` are invalid: under `"type": "module"`, use `import` in the script, not `require`.
272
272
 
@@ -282,9 +282,26 @@ A script reads the run's device from three environment variables: `ARGENT_DEVICE
282
282
 
283
283
  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.
284
284
 
285
+ ### Vars
286
+
287
+ Define test inputs under `vars:`. Override defaults with `--var NAME=value` or `e2e-execute.vars`. Use `run:` to inherit the caller's vars. For a separate `tool: e2e-execute` run, pass any overrides explicitly.
288
+
289
+ ```yaml
290
+ vars:
291
+ USER_NAME: alice
292
+ PASSWORD: "{{secret:ALICE_PASSWORD}}"
293
+ steps:
294
+ - type: { into: { id: user }, text: "{{var:USER_NAME}}" }
295
+ - type: { into: { id: password }, text: "{{var:PASSWORD}}" }
296
+ ```
297
+
298
+ Use quoted var references in the same fields as output references. For an unset var, supply a value or add a fallback such as `"{{var:USER_NAME ?? guest}}"`.
299
+
300
+ Use secret placeholders for credentials, including values passed with `--var`. Pass secret vars in typed text, tool arguments, or explicit script `env` entries. Use ordinary vars in selectors and checks. See [Vars in the YAML reference](https://docs.swmansion.com/argent/docs/reference/e2e-yaml#vars) for validation and precedence rules.
301
+
285
302
  ### Pass values between steps
286
303
 
287
- 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`.
304
+ 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 `vars`.
288
305
 
289
306
  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 }`.
290
307
 
@@ -292,7 +309,7 @@ Use references in selectors, typed text, equality or contains checks, tool argum
292
309
 
293
310
  ## Snapshots and CLI runs
294
311
 
295
- `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.
312
+ `argent e2e run <name> [--device <id>] [--platform ios|android|chromium|vega|macos|ios-remote] [--update-baselines] [--var NAME=value] [--output <dir>] [--json]` runs without an LLM and exits non-zero on failure.
296
313
 
297
314
  A screenshot is human evidence. A `snapshot:` is executable visual verification. A missing baseline or excessive mismatch fails. A `cropOn` size change also fails. Use snapshots for color, layout, size, spacing, typography, clipping, overflow, images, icons, or stable component appearance. Use full screen for global changes and `cropOn` for one component.
298
315
 
@@ -35,7 +35,7 @@ Obey these lifecycle rules:
35
35
  3. If a call says the recording is inactive, do not restart under that name. The completed take can still be on disk. Copy it aside or record under a fresh name.
36
36
  4. Read `recorded` after each call. The recorder does not always store the tool call you made, and that line is where a rewrite shows up. The recorder still appends `await-ui-element` and `await-network-request` steps that return `success: false`. Check the warning before continuing. To see the whole file mid-recording, read it at `savedTo`. A `null` `savedTo` means only the write on your side failed: the step is still in the recording, the next step rewrites the whole file, and `e2e-finish-recording` returns `e2eTestFile` regardless.
37
37
  5. Edit or reorder the YAML only after `e2e-finish-recording`.
38
- 6. Set script defaults with `e2e-start-recording.env` or call `e2e-set-env` directly before recording the script. Use `e2e-add-script.env` for values specific to one step. The tool runs the script immediately. If a secret is missing, check the project’s secret sources before retrying.
38
+ 6. Set vars with `e2e-start-recording.vars` or call `e2e-set-vars` directly before recording steps that use them. For a fragment that expects a caller's var, set a recording default or add a fallback. See [Vars](e2e-yaml.md#vars) before adding references to the YAML.
39
39
 
40
40
  ## Record cleanup after the main steps
41
41