@swmansion/argent 0.35.1-next.6 → 0.35.1-next.7

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.
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -38585,7 +38585,7 @@ function isCi(env = process.env) {
38585
38585
  var SESSION_ID2 = randomUUID5();
38586
38586
  function readCliVersion() {
38587
38587
  if (true) {
38588
- return "0.35.1-next.6";
38588
+ return "0.35.1-next.7";
38589
38589
  }
38590
38590
  return "0.0.0";
38591
38591
  }
@@ -39602,7 +39602,12 @@ function parseCommandArgs(argv, specs) {
39602
39602
  if (spec.choices && !spec.choices.includes(value)) {
39603
39603
  throw new UsageError(`${display} must be ${listChoices(spec.choices)}, got "${value}"`);
39604
39604
  }
39605
- options[name] = value;
39605
+ if (spec.repeatable) {
39606
+ const seen = options[name];
39607
+ options[name] = Array.isArray(seen) ? [...seen, value] : [value];
39608
+ } else {
39609
+ options[name] = value;
39610
+ }
39606
39611
  }
39607
39612
  return { positionals, options };
39608
39613
  }
@@ -39875,6 +39880,8 @@ Options (run):
39875
39880
  --update-baselines Write/refresh screenshot baselines instead of diffing,
39876
39881
  also those of tests that tool: e2e-execute steps run,
39877
39882
  unless such a step sets updateBaselines
39883
+ --env NAME=value Override a script environment value for this run.
39884
+ Repeatable. Values may contain {{secret:NAME}}
39878
39885
  --output <dir> Also write failed snapshot images (baseline/current/diff)
39879
39886
  and failed-step screenshots (step-<n>-screen.png)
39880
39887
  under <dir>/<test>/ \u2014 a stable path for CI artifact
@@ -39897,6 +39904,7 @@ Examples:
39897
39904
  argent e2e run .argent/e2e/checkout.yaml --output e2e-artifacts --json
39898
39905
  argent e2e run ~/shared-e2e/checkout.yaml --device <UDID> --update-baselines
39899
39906
  argent e2e run .argent/e2e --recursive
39907
+ argent e2e run checkout --env API_URL=https://staging.example.com
39900
39908
  `);
39901
39909
  }
39902
39910
  var RUN_OPTIONS = {
@@ -39908,7 +39916,8 @@ var RUN_OPTIONS = {
39908
39916
  // The tool-server's schema rejection carries no error_kind, so in a directory
39909
39917
  // run it would stop the whole batch.
39910
39918
  "platform": { kind: "value", choices: SELECTABLE_PLATFORMS },
39911
- "output": { kind: "value" }
39919
+ "output": { kind: "value" },
39920
+ "env": { kind: "value", repeatable: true }
39912
39921
  };
39913
39922
  var LIST_OPTIONS = {
39914
39923
  json: { kind: "boolean" },
@@ -39941,11 +39950,28 @@ function parseRunArgs(argv) {
39941
39950
  if (options.device !== void 0) out.device = options.device;
39942
39951
  if (options.platform !== void 0) out.platform = options.platform;
39943
39952
  if (options.output !== void 0) out.output = options.output;
39953
+ if (options.env !== void 0) out.env = parseEnvFlags(options.env);
39944
39954
  if (out.json && out.jsonStream) {
39945
39955
  throw new FlagParseException("--json and --json-stream cannot be combined");
39946
39956
  }
39947
39957
  return out;
39948
39958
  }
39959
+ var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
39960
+ function parseEnvFlags(values) {
39961
+ const env = {};
39962
+ for (const entry of values) {
39963
+ const eq = entry.indexOf("=");
39964
+ const name = eq === -1 ? entry : entry.slice(0, eq);
39965
+ if (eq === -1 || !ENV_NAME_RE.test(name) || name === "__proto__") {
39966
+ throw new FlagParseException(
39967
+ `--env takes NAME=value with a name of letters, digits and _, not starting with a digit; got ${JSON.stringify(entry)}`
39968
+ );
39969
+ }
39970
+ delete env[name];
39971
+ env[name] = entry.slice(eq + 1);
39972
+ }
39973
+ return env;
39974
+ }
39949
39975
  function renderEchoLine(s) {
39950
39976
  if (!s.message) return void 0;
39951
39977
  const indent = stepIndent(s.depth);
@@ -40087,6 +40113,9 @@ function rerunCommand(flowPath, rel, projectRoot, args) {
40087
40113
  if (args.platform) parts.push("--platform", shellQuoteArg(args.platform));
40088
40114
  if (args.updateBaselines) parts.push("--update-baselines");
40089
40115
  if (args.output) parts.push("--output", pathArg(path19.join(args.output, path19.dirname(rel))));
40116
+ for (const [name, value] of Object.entries(args.env ?? {})) {
40117
+ parts.push("--env", shellQuoteArg(`${name}=${value}`));
40118
+ }
40090
40119
  return parts.join(" ");
40091
40120
  }
40092
40121
  var EXPORT_SOURCE_MARKER = ".argent-e2e-source";
@@ -40371,6 +40400,7 @@ function buildRunPayload(flowPath, projectRoot, args) {
40371
40400
  if (args.device) payload.device = args.device;
40372
40401
  if (args.platform) payload.platform = args.platform;
40373
40402
  if (args.updateBaselines) payload.updateBaselines = true;
40403
+ if (args.env) payload.env = args.env;
40374
40404
  return payload;
40375
40405
  }
40376
40406
  function writeJsonStreamRecord(record2) {
@@ -17103,7 +17103,7 @@ function isCi(env = process.env) {
17103
17103
  var SESSION_ID = randomUUID4();
17104
17104
  function readCliVersion() {
17105
17105
  if (true) {
17106
- return "0.35.1-next.6";
17106
+ return "0.35.1-next.7";
17107
17107
  }
17108
17108
  return "0.0.0";
17109
17109
  }
@@ -38044,7 +38044,7 @@ async function startMcpServer(options) {
38044
38044
  const autoDescribeOn = autoDescribeEnabled();
38045
38045
  const whatsNewOn = whatsNewEnabled();
38046
38046
  const installedVersion = getInstalledVersion();
38047
- const highlightsVersion = true ? "0.35.1-next.6" : installedVersion;
38047
+ const highlightsVersion = true ? "0.35.1-next.7" : installedVersion;
38048
38048
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38049
38049
  const trees = createTreeMemory();
38050
38050
  const screenshots = createScreenshotMemory();
@@ -287,6 +287,10 @@ export interface ArgentToolArgs {
287
287
  updateBaselines?: boolean;
288
288
  /** Set to true to confirm the execution prerequisite has been met. Required when a fragment defines an executionPrerequisite: without it, the call runs no step and returns the prerequisite text. Not a dry run: an e2e test with no prerequisite runs in full. To read a prerequisite without running, read executionPrerequisite in the YAML file. */
289
289
  prerequisiteAcknowledged?: boolean;
290
+ /** Script environment overrides for this run, including run: fragments. Names match [A-Za-z_][A-Za-z0-9_]*, except __proto__. Values can include {{secret:NAME}}. A missing secret rejects the run before any step. */
291
+ env?: {
292
+ [key: string]: string;
293
+ };
290
294
  /** @deprecated Renamed to `e2e_test_path`. */
291
295
  flow_path?: string;
292
296
  /** @deprecated Renamed to `e2e_test_file`. */
@@ -72957,7 +72957,7 @@ function isCi(env = process.env) {
72957
72957
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
72958
72958
  function readCliVersion() {
72959
72959
  if (true) {
72960
- return "0.35.1-next.6";
72960
+ return "0.35.1-next.7";
72961
72961
  }
72962
72962
  return "0.0.0";
72963
72963
  }
@@ -75590,67 +75590,102 @@ ${describeSecretSources(sources)}
75590
75590
  });
75591
75591
  return { text: resolved, secrets };
75592
75592
  }
75593
- function scrubSecretValues(text, secrets) {
75594
- return scrubSecretChunk(text, secrets, true).emit;
75593
+ var MIN_FRAGMENT = 6;
75594
+ function redactSecrets(text, secrets) {
75595
+ return secretRedactor(secrets)(text);
75595
75596
  }
75596
- function scrubSecretChunk(text, secrets, final) {
75597
- const ordered = orderedSecrets(secrets);
75598
- if (ordered.length === 0) return { emit: text, held: 0 };
75599
- const longestValue = ordered[0].value.length;
75600
- const names = new Set(ordered.map((secret) => secret.name));
75601
- const longestName = Math.max(...ordered.map((secret) => secret.name.length));
75602
- let out = "";
75603
- let copied = 0;
75604
- let at = 0;
75605
- while (at < text.length) {
75606
- const marker = markerLengthAt(text, at, names, longestName);
75607
- if (marker > 0 && !valueLeavesMarker(text, at, at + marker, ordered)) {
75608
- at += marker;
75609
- continue;
75597
+ function secretRedactor(secrets) {
75598
+ const ordered = secrets.filter(({ value }) => value.length > 0).sort((a, b) => b.value.length - a.value.length || (a.name < b.name ? -1 : +(a.name > b.name)));
75599
+ const none = ordered.length;
75600
+ const spellings = ordered.map(({ value }) => [...spellingsOf(value)]);
75601
+ const windows = /* @__PURE__ */ new Map();
75602
+ spellings.forEach((forms, id) => {
75603
+ for (const spelling of forms) {
75604
+ for (let i = 0; i + MIN_FRAGMENT <= spelling.length; i++) {
75605
+ const window2 = spelling.slice(i, i + MIN_FRAGMENT);
75606
+ if (!windows.has(window2)) windows.set(window2, id);
75607
+ }
75610
75608
  }
75611
- if (!final && text.length - at < longestValue && beginsAValue(text, at, ordered)) break;
75612
- const hit = ordered.find((secret) => text.startsWith(secret.value, at));
75613
- if (hit) {
75614
- out += `${text.slice(copied, at)}${SECRET_PLACEHOLDER_MARKER}${hit.name}}}`;
75615
- at += hit.value.length;
75616
- copied = at;
75617
- continue;
75609
+ });
75610
+ const claims = (text, opts = {}) => {
75611
+ const owner = new Int32Array(text.length).fill(none);
75612
+ if (none === 0) return owner;
75613
+ const claim2 = (from2, to, id) => {
75614
+ for (let i = from2; i < to; i++) owner[i] = Math.min(owner[i], id);
75615
+ };
75616
+ spellings.forEach((forms, id) => {
75617
+ for (const spelling of forms) {
75618
+ if (spelling.length >= MIN_FRAGMENT) continue;
75619
+ for (let at = text.indexOf(spelling); at !== -1; at = text.indexOf(spelling, at + 1)) {
75620
+ claim2(at, at + spelling.length, id);
75621
+ }
75622
+ }
75623
+ });
75624
+ if (windows.size > 0) {
75625
+ for (let p = 0; p + MIN_FRAGMENT <= text.length; p++) {
75626
+ const id = windows.get(text.slice(p, p + MIN_FRAGMENT));
75627
+ if (id !== void 0) claim2(p, p + MIN_FRAGMENT, id);
75628
+ }
75618
75629
  }
75619
- at += 1;
75620
- }
75621
- return {
75622
- emit: copied === 0 ? text.slice(0, at) : out + text.slice(copied, at),
75623
- held: text.length - at
75630
+ if (opts.cut) {
75631
+ spellings.forEach((forms, id) => {
75632
+ for (const spelling of forms) {
75633
+ const longest = Math.min(MIN_FRAGMENT - 1, spelling.length - 1, text.length);
75634
+ for (let n = longest; n > 0; n--) {
75635
+ if (text.endsWith(spelling.slice(0, n))) {
75636
+ claim2(text.length - n, text.length, id);
75637
+ break;
75638
+ }
75639
+ }
75640
+ }
75641
+ });
75642
+ }
75643
+ for (let i = 0; i + 1 < text.length; i++) {
75644
+ const high = text.charCodeAt(i);
75645
+ const low = text.charCodeAt(i + 1);
75646
+ if (high < 55296 || high > 56319 || low < 56320 || low > 57343) continue;
75647
+ const id = Math.min(owner[i], owner[i + 1]);
75648
+ owner[i] = id;
75649
+ owner[i + 1] = id;
75650
+ i++;
75651
+ }
75652
+ return owner;
75624
75653
  };
75625
- }
75626
- function valueLeavesMarker(text, from2, end, ordered) {
75627
- for (let at = from2; at < end; at++) {
75628
- for (const { value } of ordered) {
75629
- if (at + value.length >= end && text.startsWith(value, at)) return true;
75654
+ const render2 = (text, owner) => {
75655
+ let out = "";
75656
+ let copied = 0;
75657
+ for (let at = 0; at < text.length; at++) {
75658
+ if (owner[at] === none) continue;
75659
+ const { name } = ordered[owner[at]];
75660
+ let end = at + 1;
75661
+ while (end < text.length && ordered[owner[end]]?.name === name) end++;
75662
+ out += `${text.slice(copied, at)}${SECRET_PLACEHOLDER_MARKER}${name}}}`;
75663
+ copied = end;
75664
+ at = end - 1;
75630
75665
  }
75631
- }
75632
- return false;
75633
- }
75634
- function beginsAValue(text, at, ordered) {
75635
- const rest = text.slice(at);
75636
- return ordered.some(({ value }) => value.length > rest.length && value.startsWith(rest));
75637
- }
75638
- function orderedSecrets(secrets) {
75639
- return secrets.filter(({ value }) => value.length > 0).sort((a, b) => b.value.length - a.value.length);
75666
+ return copied === 0 ? text : out + text.slice(copied);
75667
+ };
75668
+ const redact2 = ((text, opts) => none === 0 || text.length === 0 ? text : render2(text, claims(text, opts)));
75669
+ return Object.assign(redact2, {
75670
+ claims,
75671
+ render: render2,
75672
+ names: new Set(ordered.map(({ name }) => name))
75673
+ });
75640
75674
  }
75641
- function markerLengthAt(text, at, names, longestName) {
75642
- if (!text.startsWith(SECRET_PLACEHOLDER_MARKER, at)) return 0;
75643
- const from2 = at + SECRET_PLACEHOLDER_MARKER.length;
75644
- const window2 = text.slice(from2, from2 + longestName + 2);
75645
- const end = window2.indexOf("}}");
75646
- return end >= 0 && names.has(window2.slice(0, end)) ? SECRET_PLACEHOLDER_MARKER.length + end + 2 : 0;
75675
+ function spellingsOf(value) {
75676
+ const spellings = /* @__PURE__ */ new Set([value, JSON.stringify(value).slice(1, -1)]);
75677
+ try {
75678
+ spellings.add(encodeURIComponent(value));
75679
+ } catch {
75680
+ }
75681
+ return spellings;
75647
75682
  }
75648
75683
  function redactSecretsFromError(err, secrets) {
75649
75684
  const forms = secrets.flatMap((secret) => {
75650
75685
  const quoted = secret.value.replaceAll("'", "'\\''");
75651
75686
  return quoted === secret.value ? [secret] : [secret, { name: secret.name, value: quoted }];
75652
75687
  });
75653
- const scrub = (s) => scrubSecretValues(s, forms);
75688
+ const scrub = (s) => redactSecrets(s, forms);
75654
75689
  if (err instanceof Error) {
75655
75690
  err.message = scrub(err.message);
75656
75691
  if (err.stack) err.stack = scrub(err.stack);
@@ -76452,6 +76487,7 @@ function toYamlStep(step) {
76452
76487
  case "script": {
76453
76488
  const body = { path: step.path };
76454
76489
  if (step.timeout !== void 0) body.timeout = step.timeout;
76490
+ if (step.env) body.env = step.env;
76455
76491
  return { script: body };
76456
76492
  }
76457
76493
  case "tool": {
@@ -77299,17 +77335,46 @@ function parseScriptStep(raw, body) {
77299
77335
  );
77300
77336
  }
77301
77337
  if (body === null || typeof body !== "object" || Array.isArray(body)) {
77302
- badEntry(raw, "script needs { path, timeout? }, e.g. `script: { path: scripts/seed.mjs }`");
77338
+ badEntry(
77339
+ raw,
77340
+ "script needs { path, timeout?, env? }, e.g. `script: { path: scripts/seed.mjs }`"
77341
+ );
77303
77342
  }
77304
77343
  const b = body;
77305
- rejectUnknownKeys(raw, b, ["path", "timeout"], "script");
77344
+ rejectUnknownKeys(raw, b, ["path", "timeout", "env"], "script");
77306
77345
  const step = {
77307
77346
  kind: "script",
77308
77347
  path: parseScriptPath(raw, b.path)
77309
77348
  };
77310
77349
  if (b.timeout !== void 0) step.timeout = parseScriptTimeout(raw, b.timeout);
77350
+ if (b.env !== void 0) {
77351
+ const problem = flowEnvProblem(b.env);
77352
+ if (problem) badEntry(raw, `script.env ${problem}`);
77353
+ step.env = b.env;
77354
+ }
77311
77355
  return step;
77312
77356
  }
77357
+ var ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
77358
+ function flowEnvProblem(value) {
77359
+ if (value === null || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
77360
+ return "must be a map of variable names to string values, e.g. `env: { API_URL: https://example.com }`";
77361
+ }
77362
+ for (const [name, entry] of Object.entries(value)) {
77363
+ if (!ENV_NAME_RE.test(name)) {
77364
+ return `has an invalid variable name ${JSON.stringify(name)}: use letters, digits and _, not starting with a digit`;
77365
+ }
77366
+ if (name === "__proto__") return "cannot set __proto__";
77367
+ if (typeof entry === "number" || typeof entry === "boolean") {
77368
+ return `has a non-string value for ${name}: quote it, e.g. \`${name}: "${entry}"\``;
77369
+ }
77370
+ if (typeof entry !== "string") return `has a non-string value for ${name}`;
77371
+ if (entry.includes("\0")) return `has a NUL character in the value of ${name}`;
77372
+ if (entry.includes(OUTPUT_REFERENCE_MARKER)) {
77373
+ return `uses unsupported template syntax in ${name}: only {{secret:NAME}} placeholders are resolved`;
77374
+ }
77375
+ }
77376
+ return void 0;
77377
+ }
77313
77378
  function parseScriptPath(raw, value) {
77314
77379
  if (typeof value !== "string" || value.length === 0) {
77315
77380
  badEntry(
@@ -77799,6 +77864,7 @@ function serializeFlow(flow) {
77799
77864
  const doc = {
77800
77865
  version: FLOW_FILE_VERSION,
77801
77866
  ...flow.requires ? { requires: requiresToYaml(flow.requires) } : {},
77867
+ ...flow.env ? { env: flow.env } : {},
77802
77868
  steps: flow.steps.map(toYamlStep)
77803
77869
  };
77804
77870
  if (flow.executionPrerequisite) doc.executionPrerequisite = flow.executionPrerequisite;
@@ -77869,7 +77935,13 @@ function parseFlow(content) {
77869
77935
  );
77870
77936
  }
77871
77937
  if (!("steps" in parsed2) || !Array.isArray(parsed2.steps)) throw notAFlow();
77872
- const topKeys2 = ["version", "executionPrerequisite", "requires", "steps"];
77938
+ const topKeys2 = [
77939
+ "version",
77940
+ "executionPrerequisite",
77941
+ "requires",
77942
+ "env",
77943
+ "steps"
77944
+ ];
77873
77945
  const unknownTop = Object.keys(parsed2).filter((k) => !topKeys2.includes(k));
77874
77946
  if (unknownTop.length > 0) {
77875
77947
  throw new FailureError(
@@ -77886,9 +77958,21 @@ function parseFlow(content) {
77886
77958
  if (raw !== null && typeof raw === "object") return fromYamlStep(raw);
77887
77959
  return badEntry(raw, "step must be an object");
77888
77960
  });
77961
+ if (parsed2.env !== void 0) {
77962
+ const problem = flowEnvProblem(parsed2.env);
77963
+ if (problem) {
77964
+ throw new FailureError(`Invalid e2e test file: env ${problem}`, {
77965
+ error_code: FAILURE_CODES.FLOW_FILE_INVALID,
77966
+ failure_stage: "flow_file_parse",
77967
+ failure_area: "tool_server",
77968
+ error_kind: "validation"
77969
+ });
77970
+ }
77971
+ }
77889
77972
  const flow = {
77890
77973
  executionPrerequisite: parsed2.executionPrerequisite ?? "",
77891
77974
  ...parsed2.requires === void 0 ? {} : { requires: parseRequires(parsed2.requires) },
77975
+ ...parsed2.env === void 0 ? {} : { env: parsed2.env },
77892
77976
  steps
77893
77977
  };
77894
77978
  validateFlow(flow);
@@ -166484,11 +166568,7 @@ var FlowScriptExecutor = class {
166484
166568
  );
166485
166569
  }
166486
166570
  const timeoutMs = clampTimeout(request4.timeoutMs, bounds.maxTimeoutMs, notes);
166487
- const capture = new ScriptLogCapture(
166488
- () => request4.secrets ?? [],
166489
- SCRIPT_STEP_LOG_LIMIT_BYTES,
166490
- request4.logBudget
166491
- );
166571
+ const capture = new ScriptLogCapture(SCRIPT_STEP_LOG_LIMIT_BYTES, request4.logBudget);
166492
166572
  const scriptPath = realPathOrSelf(path65.resolve(cwd, request4.scriptPath));
166493
166573
  let child;
166494
166574
  try {
@@ -166538,8 +166618,9 @@ var FlowScriptExecutor = class {
166538
166618
  };
166539
166619
  child = (0, import_node_child_process54.fork)(scriptPath, [], forkOptions);
166540
166620
  } catch (err) {
166621
+ const reason2 = redactSecrets(errorMessage5(err), request4.secrets ?? []);
166541
166622
  return emptyResult(
166542
- { kind: "spawn", message: `Could not start the script process: ${errorMessage5(err)}` },
166623
+ { kind: "spawn", message: `Could not start the script process: ${reason2}` },
166543
166624
  { notes, durationMs: Date.now() - startedAt }
166544
166625
  );
166545
166626
  }
@@ -166620,8 +166701,10 @@ var FlowScriptExecutor = class {
166620
166701
  child.stderr?.destroy();
166621
166702
  lifeline?.destroy?.();
166622
166703
  if (child.connected) child.disconnect();
166623
- const log = capture.text;
166624
- const verdict = redactSecrets(
166704
+ const secrets = request4.secrets ?? [];
166705
+ const redact2 = secretRedactor(secrets);
166706
+ const { text: log, truncated: logTruncated } = redactedLog(capture, redact2);
166707
+ const verdict = redactVerdict(
166625
166708
  classifyOutcome({
166626
166709
  exit,
166627
166710
  spawnProblem,
@@ -166634,12 +166717,12 @@ var FlowScriptExecutor = class {
166634
166717
  heapFatalSeen: capture.heapFatalSeen,
166635
166718
  heapLimitMb: bounds.heapLimitMb
166636
166719
  }),
166637
- request4.secrets ?? []
166720
+ secrets.length > 0 ? redact2 : void 0
166638
166721
  );
166639
166722
  return {
166640
166723
  ...verdict,
166641
166724
  log,
166642
- logTruncated: capture.truncated,
166725
+ logTruncated,
166643
166726
  durationMs: Date.now() - startedAt,
166644
166727
  queuedMs: 0,
166645
166728
  notes
@@ -166690,54 +166773,82 @@ function classifyOutcome(input2) {
166690
166773
  `The script stopped its own process with exit code ${exit.code ?? 0} instead of returning; no output was captured.`
166691
166774
  );
166692
166775
  }
166693
- function redactSecrets(verdict, secrets) {
166694
- if (secrets.length === 0) return verdict;
166695
- if (verdict.output) {
166696
- const collision = scrubDocument(verdict.output, secrets);
166697
- if (collision) {
166698
- return failed2(
166699
- "output",
166700
- `Two keys in the script's output become "${collision}" once the secret in them is redacted, so one would silently replace the other. Rename one of them.`
166701
- );
166702
- }
166703
- }
166776
+ function redactVerdict(verdict, redact2) {
166777
+ if (!redact2) return verdict;
166778
+ if (verdict.output) redactDocument(verdict.output, redact2);
166704
166779
  const failure3 = verdict.failure;
166705
166780
  if (!failure3) return verdict;
166706
166781
  return {
166707
166782
  ...verdict,
166708
166783
  failure: {
166709
166784
  ...failure3,
166710
- message: redactTruncated(failure3.message, secrets),
166711
- ...failure3.stack ? { stack: redactTruncated(failure3.stack, secrets) } : {}
166785
+ message: redactClamped(failure3.message, redact2),
166786
+ ...failure3.stack ? { stack: redactClamped(failure3.stack, redact2) } : {}
166712
166787
  }
166713
166788
  };
166714
166789
  }
166715
- function scrubDocument(root, secrets) {
166790
+ function redactedLog(capture, redact2) {
166791
+ const { parts: parts2 } = capture;
166792
+ const joined = parts2.map((part) => part.text).join("");
166793
+ if (redact2.names.size === 0) return { text: joined, truncated: capture.truncated };
166794
+ const result = clampRedacted(capture, redact2, joined);
166795
+ capture.settle(Buffer.byteLength(result.text, "utf8"));
166796
+ return result;
166797
+ }
166798
+ function clampRedacted(capture, redact2, joined) {
166799
+ const { parts: parts2 } = capture;
166800
+ const owner = redact2.claims(joined, { cut: capture.truncated });
166801
+ for (const stream of ["stdout", "stderr"]) {
166802
+ const own2 = parts2.filter((part) => part.stream === stream);
166803
+ const claims = redact2.claims(own2.map((part) => part.text).join(""), {
166804
+ cut: capture.truncated
166805
+ });
166806
+ let from2 = 0;
166807
+ let at = 0;
166808
+ for (const part of parts2) {
166809
+ if (part.stream === stream) {
166810
+ for (let i = 0; i < part.text.length; i++) {
166811
+ owner[at + i] = Math.min(owner[at + i], claims[from2 + i]);
166812
+ }
166813
+ from2 += part.text.length;
166814
+ }
166815
+ at += part.text.length;
166816
+ }
166817
+ }
166818
+ const text = redact2.render(joined, owner);
166819
+ const buffer = Buffer.from(text, "utf8");
166820
+ const limit = capture.renderLimit;
166821
+ if (buffer.length <= limit) {
166822
+ return { text, truncated: capture.truncated };
166823
+ }
166824
+ const cut = buffer.subarray(0, utf8SafeCut(buffer, limit)).toString("utf8");
166825
+ const open5 = text.lastIndexOf(SECRET_PLACEHOLDER_MARKER, cut.length - 1);
166826
+ const name = open5 === -1 ? void 0 : MARKER_AT_RE.exec(text.slice(open5))?.[1];
166827
+ const end = name !== void 0 && redact2.names.has(name) ? open5 + SECRET_PLACEHOLDER_MARKER.length + name.length + 2 : -1;
166828
+ if (end > cut.length) {
166829
+ return { text: text.slice(0, end), truncated: capture.truncated || end < text.length };
166830
+ }
166831
+ return { text: cut, truncated: true };
166832
+ }
166833
+ var MARKER_AT_RE = /^\{\{secret:([A-Za-z_][A-Za-z0-9_]*)\}\}/;
166834
+ var OMISSION_RE = /… \[\d+ more characters omitted]$/;
166835
+ function redactClamped(text, redact2) {
166836
+ const omission = OMISSION_RE.exec(text);
166837
+ if (!omission) return redact2(text);
166838
+ return redact2(text.slice(0, omission.index), { cut: true }) + omission[0];
166839
+ }
166840
+ function redactDocument(root, redact2) {
166716
166841
  const pending = [root];
166717
166842
  while (pending.length > 0) {
166718
166843
  const node2 = pending.pop();
166719
- if (Array.isArray(node2)) {
166720
- for (let i = 0; i < node2.length; i++) {
166721
- const value = node2[i];
166722
- if (typeof value === "string") node2[i] = scrubSecretValues(value, secrets);
166723
- else if (value !== null && typeof value === "object") pending.push(value);
166724
- }
166725
- continue;
166726
- }
166727
166844
  if (node2 === null || typeof node2 !== "object") continue;
166728
166845
  const record2 = node2;
166729
166846
  for (const key2 of Object.keys(record2)) {
166730
166847
  const value = record2[key2];
166731
- if (typeof value === "string") record2[key2] = scrubSecretValues(value, secrets);
166848
+ if (typeof value === "string") record2[key2] = redact2(value);
166732
166849
  else if (value !== null && typeof value === "object") pending.push(value);
166733
- const scrubbedKey = scrubSecretValues(key2, secrets);
166734
- if (scrubbedKey === key2) continue;
166735
- if (Object.prototype.hasOwnProperty.call(record2, scrubbedKey)) return scrubbedKey;
166736
- record2[scrubbedKey] = record2[key2];
166737
- delete record2[key2];
166738
166850
  }
166739
166851
  }
166740
- return void 0;
166741
166852
  }
166742
166853
  function commitOutput(outputJson) {
166743
166854
  const bytes = Buffer.byteLength(outputJson, "utf8");
@@ -166794,17 +166905,6 @@ var IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
166794
166905
  function memberPath(key2) {
166795
166906
  return IDENTIFIER_RE.test(key2) ? `.${key2}` : `[${JSON.stringify(key2)}]`;
166796
166907
  }
166797
- function redactTruncated(text, secrets) {
166798
- const scrubbed = scrubSecretValues(text, secrets);
166799
- const omission = OMISSION_RE.exec(scrubbed);
166800
- if (!omission) return scrubbed;
166801
- const head = scrubbed.slice(0, omission.index);
166802
- const partial2 = partialSecretTail(head, secrets);
166803
- if (partial2 === 0) return scrubbed;
166804
- const omitted = Number(omission[1]) + partial2;
166805
- return `${head.slice(0, head.length - partial2)}${omissionMarker(omitted)}`;
166806
- }
166807
- var OMISSION_RE = /… \[(\d+) more characters omitted]$/;
166808
166908
  function omissionMarker(omitted) {
166809
166909
  return `\u2026 [${omitted} more characters omitted]`;
166810
166910
  }
@@ -166934,6 +167034,22 @@ function probeTypeStripping(nodeOptions) {
166934
167034
  }
166935
167035
  });
166936
167036
  }
167037
+ function mergeScriptEnv(...layers) {
167038
+ const env = {};
167039
+ for (const layer of layers) {
167040
+ for (const [name, value] of Object.entries(layer ?? {})) setEnvName(env, name, value);
167041
+ }
167042
+ return env;
167043
+ }
167044
+ function setEnvName(env, name, value) {
167045
+ if (process.platform === "win32") {
167046
+ const lower = name.toLowerCase();
167047
+ for (const existing of Object.keys(env)) {
167048
+ if (existing !== name && existing.toLowerCase() === lower) delete env[existing];
167049
+ }
167050
+ }
167051
+ env[name] = value;
167052
+ }
166937
167053
  function buildChildEnv(overrides) {
166938
167054
  const caseInsensitive = process.platform === "win32";
166939
167055
  const allowed = new Set(
@@ -166968,7 +167084,7 @@ function buildChildEnv(overrides) {
166968
167084
  `${name} cannot be set for a script: it steers the runner's own process (reserved names: ${reservedEnvNamesForMessage()}).`
166969
167085
  );
166970
167086
  }
166971
- env[name] = value;
167087
+ setEnvName(env, name, value);
166972
167088
  }
166973
167089
  env[RUNNER_ACTIVATION_ENV] = "1";
166974
167090
  return env;
@@ -167061,12 +167177,12 @@ function hasExited(child) {
167061
167177
  return child.exitCode !== null || child.signalCode !== null;
167062
167178
  }
167063
167179
  var ScriptLogCapture = class {
167064
- constructor(secrets, stepLimitBytes, runBudget) {
167065
- this.secrets = secrets;
167180
+ constructor(stepLimitBytes, runBudget) {
167181
+ this.stepLimitBytes = stepLimitBytes;
167066
167182
  this.runBudget = runBudget;
167067
167183
  this.stepRemaining = stepLimitBytes;
167068
167184
  }
167069
- secrets;
167185
+ stepLimitBytes;
167070
167186
  runBudget;
167071
167187
  parts = [];
167072
167188
  streams = /* @__PURE__ */ new Map();
@@ -167082,24 +167198,33 @@ var ScriptLogCapture = class {
167082
167198
  */
167083
167199
  push(stream, chunk) {
167084
167200
  const state3 = this.stateFor(stream);
167085
- this.consume(state3, state3.decoder.write(chunk), false);
167201
+ this.consume(stream, state3, state3.decoder.write(chunk));
167086
167202
  }
167087
167203
  end() {
167088
- for (const state3 of this.streams.values()) {
167089
- this.consume(state3, state3.decoder.end(), true);
167204
+ for (const [stream, state3] of this.streams) {
167205
+ this.consume(stream, state3, state3.decoder.end());
167090
167206
  if (state3.collapser) {
167091
- this.append(state3.collapser.end());
167207
+ this.append(stream, state3.collapser.end());
167092
167208
  if (state3.collapser.collapsed) this.truncatedFlag = true;
167093
167209
  }
167094
167210
  }
167095
167211
  this.streams.clear();
167096
167212
  }
167097
- get text() {
167098
- return scrubSecretValues(this.parts.join(""), this.secrets());
167099
- }
167100
167213
  get truncated() {
167101
167214
  return this.truncatedFlag;
167102
167215
  }
167216
+ /** What the redacted log may take: the step's limit, and what the run budget holds. */
167217
+ get renderLimit() {
167218
+ const charged = this.stepLimitBytes - this.stepRemaining;
167219
+ const runRemaining = this.runBudget ? Math.max(0, this.runBudget.remainingBytes) : Number.POSITIVE_INFINITY;
167220
+ return Math.min(this.stepLimitBytes, charged + runRemaining);
167221
+ }
167222
+ /** Charges the run budget for the log as returned, in place of the raw bytes captured. */
167223
+ settle(returnedBytes) {
167224
+ if (this.runBudget) {
167225
+ this.runBudget.remainingBytes += this.stepLimitBytes - this.stepRemaining - returnedBytes;
167226
+ }
167227
+ }
167103
167228
  get heapFatalSeen() {
167104
167229
  return this.heapFatalFlag;
167105
167230
  }
@@ -167118,40 +167243,19 @@ var ScriptLogCapture = class {
167118
167243
  if (!state3) {
167119
167244
  state3 = {
167120
167245
  decoder: new import_node_string_decoder.StringDecoder("utf8"),
167121
- holdback: "",
167122
167246
  ...stream === "stderr" ? { collapser: new V8FrameCollapser(), watchForHeapFatal: true } : {}
167123
167247
  };
167124
167248
  this.streams.set(stream, state3);
167125
167249
  }
167126
167250
  return state3;
167127
167251
  }
167128
- consume(state3, text, final) {
167129
- if (!text && !final) return;
167252
+ consume(stream, state3, text) {
167253
+ if (!text) return;
167130
167254
  if (state3.watchForHeapFatal) this.watchForHeapFatal(text);
167131
- const secrets = this.secrets();
167132
- const held = state3.holdback;
167133
- const pending = held + text;
167134
- const { emit, held: keep } = scrubSecretChunk(pending, secrets, final);
167135
- const split = pending.length - keep;
167136
- state3.holdback = pending.slice(split);
167137
- this.release(state3, held.slice(0, split), emit);
167255
+ this.append(stream, state3.collapser ? state3.collapser.write(text) : text);
167138
167256
  if (state3.collapser?.collapsed) this.truncatedFlag = true;
167139
- if (!state3.holdback) state3.holdbackAt = void 0;
167140
- else if (split >= held.length) state3.holdbackAt = this.parts.push("") - 1;
167141
167257
  }
167142
- release(state3, released, emit) {
167143
- const at = state3.holdbackAt;
167144
- if (at === void 0 || !emit) {
167145
- this.append(state3.collapser ? state3.collapser.write(emit) : emit);
167146
- return;
167147
- }
167148
- const head = scrubSecretValues(released, this.secrets());
167149
- const headText = emit.startsWith(head) ? head : "";
167150
- this.append(state3.collapser ? state3.collapser.write(headText) : headText, at);
167151
- const tailText = emit.slice(headText.length);
167152
- this.append(state3.collapser ? state3.collapser.write(tailText) : tailText);
167153
- }
167154
- append(text, at) {
167258
+ append(stream, text) {
167155
167259
  if (!text) return;
167156
167260
  const runRemaining = this.runBudget ? Math.max(0, this.runBudget.remainingBytes) : Number.POSITIVE_INFINITY;
167157
167261
  const allowed = Math.min(this.stepRemaining, runRemaining);
@@ -167160,45 +167264,19 @@ var ScriptLogCapture = class {
167160
167264
  return;
167161
167265
  }
167162
167266
  const buffer = Buffer.from(text, "utf8");
167163
- let taken = buffer.length <= allowed ? buffer.length : utf8SafeCut(buffer, allowed);
167267
+ const taken = buffer.length <= allowed ? buffer.length : utf8SafeCut(buffer, allowed);
167164
167268
  if (taken < buffer.length) {
167165
167269
  this.truncatedFlag = true;
167166
167270
  this.cut = true;
167167
- taken = withoutPartialMarker(buffer, taken);
167168
167271
  }
167169
167272
  if (taken > 0) {
167170
167273
  const kept = taken === buffer.length ? text : buffer.subarray(0, taken).toString("utf8");
167171
- if (at === void 0) this.parts.push(kept);
167172
- else this.parts[at] += kept;
167274
+ this.parts.push({ stream, text: kept });
167173
167275
  this.stepRemaining -= taken;
167174
167276
  if (this.runBudget) this.runBudget.remainingBytes -= taken;
167175
167277
  }
167176
167278
  }
167177
167279
  };
167178
- function withoutPartialMarker(buffer, taken) {
167179
- const text = buffer.subarray(0, taken).toString("utf8");
167180
- const open5 = text.lastIndexOf(SECRET_PLACEHOLDER_MARKER);
167181
- if (open5 >= 0 && !text.includes("}}", open5 + SECRET_PLACEHOLDER_MARKER.length)) {
167182
- return Buffer.byteLength(text.slice(0, open5), "utf8");
167183
- }
167184
- for (let n = Math.min(SECRET_PLACEHOLDER_MARKER.length - 1, text.length); n > 0; n--) {
167185
- if (text.endsWith(SECRET_PLACEHOLDER_MARKER.slice(0, n))) return taken - n;
167186
- }
167187
- return taken;
167188
- }
167189
- function partialSecretTail(text, secrets) {
167190
- let keep = 0;
167191
- for (const { value } of secrets) {
167192
- const longest = Math.min(value.length - 1, text.length);
167193
- for (let n = longest; n > keep; n--) {
167194
- if (text.endsWith(value.slice(0, n))) {
167195
- keep = n;
167196
- break;
167197
- }
167198
- }
167199
- }
167200
- return keep;
167201
- }
167202
167280
  function utf8SafeCut(buffer, max) {
167203
167281
  let cut = Math.min(max, buffer.length);
167204
167282
  while (cut > 0 && (buffer[cut] & 192) === 128) cut -= 1;
@@ -167304,6 +167382,27 @@ function describeDuration(ms3) {
167304
167382
  }
167305
167383
 
167306
167384
  // ../tool-server/src/tools/flows/flow-script-step.ts
167385
+ init_capability();
167386
+ function resolveScriptEnv(env, projectRoot, clientSecrets) {
167387
+ const resolved = {};
167388
+ const secrets = [];
167389
+ for (const [name, value] of Object.entries(env)) {
167390
+ const { text, secrets: found } = resolveSecretPlaceholders(value, {
167391
+ cwd: projectRoot,
167392
+ ...clientSecrets ? { clientSecrets } : {}
167393
+ });
167394
+ if (text.includes("\0")) {
167395
+ throw new InvalidToolInputError(
167396
+ `The value of ${name} holds a NUL character, which an environment value cannot carry.`
167397
+ );
167398
+ }
167399
+ resolved[name] = text;
167400
+ for (const secret of found) {
167401
+ if (!secrets.some((s) => s.name === secret.name)) secrets.push(secret);
167402
+ }
167403
+ }
167404
+ return { env: resolved, secrets };
167405
+ }
167307
167406
  async function runFlowScriptStep(request4) {
167308
167407
  const { flowDir, step } = request4;
167309
167408
  const target = step.path;
@@ -167337,14 +167436,24 @@ async function runFlowScriptStep(request4) {
167337
167436
  if (refusal !== void 0) {
167338
167437
  return { ran: "no", outcome: { status: "error", reason: refusal } };
167339
167438
  }
167439
+ let resolved;
167440
+ try {
167441
+ if (request4.env) {
167442
+ resolved = resolveScriptEnv(request4.env, request4.projectRoot, request4.clientSecrets);
167443
+ }
167444
+ } catch (err) {
167445
+ return {
167446
+ ran: "no",
167447
+ outcome: { status: "error", reason: err instanceof Error ? err.message : String(err) }
167448
+ };
167449
+ }
167340
167450
  const result = await flowScriptExecutor().execute({
167341
167451
  scriptPath: canonical,
167342
167452
  output: {},
167343
167453
  ...step.timeout !== void 0 ? { timeoutMs: step.timeout } : {},
167344
167454
  projectRoot: request4.projectRoot,
167345
167455
  flowDir,
167346
- // No `secrets`: nothing resolves one into a script step yet, so there is
167347
- // nothing for the executor to redact out of the captured log.
167456
+ ...resolved ? { env: resolved.env, secrets: resolved.secrets } : {},
167348
167457
  ...request4.logBudget ? { logBudget: request4.logBudget } : {},
167349
167458
  ...request4.signal ? { signal: request4.signal } : {}
167350
167459
  });
@@ -170844,8 +170953,15 @@ var zodSchema75 = external_exports.object({
170844
170953
  ),
170845
170954
  prerequisiteAcknowledged: external_exports.boolean().optional().describe(
170846
170955
  "Set to true to confirm the execution prerequisite has been met. Required when a fragment defines an executionPrerequisite: without it, the call runs no step and returns the prerequisite text. Not a dry run: an e2e test with no prerequisite runs in full. To read a prerequisite without running, read executionPrerequisite in the YAML file."
170956
+ ),
170957
+ env: external_exports.record(external_exports.string(), external_exports.string()).optional().describe(
170958
+ "Script environment overrides for this run, including run: fragments. Names match [A-Za-z_][A-Za-z0-9_]*, except __proto__. Values can include {{secret:NAME}}. A missing secret rejects the run before any step."
170847
170959
  )
170848
170960
  }).superRefine((params, ctx) => {
170961
+ const envProblem = params.env === void 0 ? void 0 : flowEnvProblem(params.env);
170962
+ if (envProblem) {
170963
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: envProblem, path: ["env"] });
170964
+ }
170849
170965
  if (params.name === void 0 === (params.e2e_test_path === void 0)) {
170850
170966
  ctx.addIssue({
170851
170967
  code: external_exports.ZodIssueCode.custom,
@@ -170930,6 +171046,8 @@ Without a link, every step kind runs.`,
170930
171046
  error_kind: "validation"
170931
171047
  });
170932
171048
  }
171049
+ const runEnv = mergeScriptEnv(params.env);
171050
+ resolveScriptEnv(runEnv, params.project_root, ctx?.clientSecrets);
170933
171051
  const rootEntry = {
170934
171052
  canonical: clientProject && rootInput ? clientRootCanonical(rootInput, params.name, flow) : canonicalPath2,
170935
171053
  display: flowName
@@ -171031,6 +171149,7 @@ Without a link, every step kind runs.`,
171031
171149
  snapshotApps: /* @__PURE__ */ new Map(),
171032
171150
  secret: ctx?.flowSecret ?? {},
171033
171151
  projectRoot: params.project_root,
171152
+ runEnv,
171034
171153
  scriptLogBudget: createScriptLogBudget(),
171035
171154
  networkCaptureNoted: /* @__PURE__ */ new Map(),
171036
171155
  ...!resolved.booted && device?.platform === "chromium" ? { attachedDeviceId: device.id } : {},
@@ -171040,6 +171159,7 @@ Without a link, every step kind runs.`,
171040
171159
  try {
171041
171160
  await execSteps(state3, flow.steps, {
171042
171161
  runStack: seed,
171162
+ fileEnv: flow.env ?? {},
171043
171163
  rootDisplay: rootEntry.display,
171044
171164
  depth: 0,
171045
171165
  legacyPoints: flowFormatVersion(flow) < 2
@@ -171386,7 +171506,9 @@ async function execSteps(state3, steps, scope) {
171386
171506
  startedAt -= state3.hoistedBootMs;
171387
171507
  state3.hoistedBootMs = void 0;
171388
171508
  }
171389
- if (JSON.stringify(step).includes(SECRET_PLACEHOLDER_MARKER)) state3.secret.typed = true;
171509
+ if (step.kind !== "script" && JSON.stringify(step).includes(SECRET_PLACEHOLDER_MARKER)) {
171510
+ state3.secret.typed = true;
171511
+ }
171390
171512
  const report = await inCoordinateSpace(
171391
171513
  scope.legacyPoints && step.kind === "tool" ? "native" : "upright",
171392
171514
  () => execLeafStep(state3, step, index, scope)
@@ -171579,6 +171701,7 @@ async function execRunStep(state3, step, scope) {
171579
171701
  fragment.steps,
171580
171702
  childScope(scope, {
171581
171703
  runStack: [...scope.runStack, { canonical, display }],
171704
+ fileEnv: mergeScriptEnv(fragment.env, scope.fileEnv),
171582
171705
  legacyPoints: flowFormatVersion(fragment) < 2
171583
171706
  })
171584
171707
  );
@@ -171587,10 +171710,13 @@ function oneLineReason(text) {
171587
171710
  return text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
171588
171711
  }
171589
171712
  async function runScriptStep(state3, step, scope) {
171713
+ const env = mergeScriptEnv(scope.fileEnv, step.env, state3.runEnv);
171590
171714
  const { outcome } = await runFlowScriptStep({
171591
171715
  flowDir: scopeFlowDir(scope),
171592
171716
  step,
171593
171717
  projectRoot: state3.projectRoot,
171718
+ env,
171719
+ ...state3.ctx?.clientSecrets ? { clientSecrets: state3.ctx.clientSecrets } : {},
171594
171720
  logBudget: state3.scriptLogBudget,
171595
171721
  ...state3.signal ? { signal: state3.signal } : {}
171596
171722
  });
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.35.1-next.6",
3
+ "version": "0.35.1-next.7",
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": "0e7a817c0dfcfd2c615d5247a62f58858764c3ad"
101
+ "gitHead": "f08fda01f14d7105db692d16edacac7cf588a706"
102
102
  }
@@ -249,12 +249,17 @@ A `run:` target is a YAML path resolved against the directory of the test file c
249
249
  ```yaml
250
250
  - script: { path: ../../scripts/seed-order.mjs }
251
251
  - script: { path: ../../scripts/seed-order.mjs, timeout: 60000 }
252
+ - script: { path: ../../scripts/seed-order.mjs, env: { API_TOKEN: "{{secret:API_TOKEN}}" } }
252
253
  ```
253
254
 
254
255
  Use the map form shown above. A bare `script: scripts/seed.mjs` is invalid.
255
256
 
256
257
  `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`.
257
258
 
259
+ Add `env` to the YAML after recording. 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.
260
+
261
+ 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.
262
+
258
263
  `.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`.
259
264
 
260
265
  Node runs `.mts` and `.ts` by removing the types, and it does not read `tsconfig.json`. In an `.mts` or `.ts` script:
@@ -269,7 +274,7 @@ Over a link (`argent link` or `ARGENT_TOOLS_URL`, also to 127.0.0.1), `e2e-add-s
269
274
 
270
275
  ## Snapshots and CLI runs
271
276
 
272
- `argent e2e run <name> [--device <id>] [--platform ios|android|chromium|vega|macos|ios-remote] [--update-baselines] [--output <dir>] [--json]` runs without an LLM and exits non-zero on failure.
277
+ `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.
273
278
 
274
279
  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.
275
280