@cnc-tools/storm 0.15.0 → 0.16.0

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.
Files changed (109) hide show
  1. package/dist/bin/storm.js +1 -1
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-QUHY6FGN.js → chunk-2MAD5NKK.js} +1 -1
  4. package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-3L52KNQA.js} +1 -1
  5. package/dist/chunks/{chunk-E4PJNZVG.js → chunk-7EENF73W.js} +12 -13
  6. package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-CK2GZEPK.js} +1 -1
  7. package/dist/chunks/{chunk-L36GBUBB.js → chunk-DC2CDHNK.js} +398 -158
  8. package/dist/chunks/{chunk-PN5ULTTH.js → chunk-DWEAHX4T.js} +1 -1
  9. package/dist/chunks/{chunk-5GBMR4HM.js → chunk-FCQUJDA4.js} +4 -7
  10. package/dist/chunks/{chunk-YV7GE6EV.js → chunk-FOZWA52V.js} +1 -1
  11. package/dist/chunks/{chunk-OX7X4B2L.js → chunk-G3PHMXH5.js} +1 -1
  12. package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-HVNK3I45.js} +1 -1
  13. package/dist/chunks/{chunk-QVS7HRU7.js → chunk-OIY3DMF2.js} +2 -2
  14. package/dist/chunks/{chunk-SZEURWRS.js → chunk-P357TZAY.js} +2 -2
  15. package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-V4IKA3WI.js} +153 -139
  16. package/dist/chunks/{chunk-RAQEXKL6.js → chunk-Z5PBVG3Y.js} +26 -18
  17. package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-WECQOQ4C.js} +4 -4
  18. package/dist/commands/exec/across-sandboxes-outcomes.js +2 -1
  19. package/dist/commands/exec/command.d.ts +8 -2
  20. package/dist/commands/exec/command.js +11 -11
  21. package/dist/commands/exec/metadata.js +1 -1
  22. package/dist/commands/exec/outcomes.d.ts +4 -1
  23. package/dist/commands/exec/outcomes.js +2 -2
  24. package/dist/commands/exec/plan-only.js +1 -2
  25. package/dist/commands/exec/planned-outcome.js +8 -1
  26. package/dist/commands/exec/run-command.d.ts +6 -7
  27. package/dist/commands/exec/run-command.js +8 -9
  28. package/dist/commands/exec/run-metadata.js +1 -1
  29. package/dist/commands/runs/facts.d.ts +2 -1
  30. package/dist/commands/runs/facts.js +11 -3
  31. package/dist/commands/runs/list/command.d.ts +2 -0
  32. package/dist/commands/runs/list/command.js +6 -6
  33. package/dist/commands/runs/list/outcomes.d.ts +1 -0
  34. package/dist/commands/runs/logs/command.d.ts +6 -2
  35. package/dist/commands/runs/logs/command.js +6 -6
  36. package/dist/commands/runs/logs/outcomes.d.ts +3 -1
  37. package/dist/commands/runs/past-run.d.ts +14 -5
  38. package/dist/commands/runs/past-run.js +16 -5
  39. package/dist/commands/runs/show/command.d.ts +6 -2
  40. package/dist/commands/runs/show/command.js +9 -9
  41. package/dist/commands/runs/show/outcomes.d.ts +3 -1
  42. package/dist/commands/snapshots/build/command.js +11 -11
  43. package/dist/commands/snapshots/list/command.d.ts +3 -3
  44. package/dist/commands/snapshots/list/command.js +6 -6
  45. package/dist/commands/snapshots/list/metadata.js +1 -1
  46. package/dist/commands/suites/list/command.js +7 -6
  47. package/dist/commands/suites/list/outcomes.js +2 -2
  48. package/dist/commands/test/command.d.ts +8 -2
  49. package/dist/commands/test/command.js +38 -40
  50. package/dist/commands/test/metadata.js +1 -1
  51. package/dist/commands/test/outcomes.d.ts +4 -1
  52. package/dist/commands/test/outcomes.js +2 -2
  53. package/dist/commands/test/plan.d.ts +2 -2
  54. package/dist/commands/test/plan.js +2 -5
  55. package/dist/config/check-runner.d.ts +4 -2
  56. package/dist/config/check-runner.js +27 -2
  57. package/dist/config/check-suites.js +1 -0
  58. package/dist/config/gateways.d.ts +7 -3
  59. package/dist/config/index.d.ts +2 -3
  60. package/dist/config/index.js +2 -3
  61. package/dist/config/live/config-gateway.js +5 -2
  62. package/dist/config/load.d.ts +21 -4
  63. package/dist/config/load.js +129 -15
  64. package/dist/config/runner.d.ts +5 -6
  65. package/dist/config/runner.js +1 -1
  66. package/dist/config/schema.d.ts +15 -3
  67. package/dist/config/schema.js +10 -2
  68. package/dist/config/typed-options.d.ts +1 -6
  69. package/dist/config/typed-options.js +2 -10
  70. package/dist/config-file/define.d.ts +1 -11
  71. package/dist/config-file/define.js +3 -3
  72. package/dist/config-file/runner.d.ts +2 -3
  73. package/dist/config-file/toolchain.d.ts +13 -7
  74. package/dist/config-file/toolchain.js +51 -35
  75. package/dist/extensions/github/resource.d.ts +1 -1
  76. package/dist/extensions/github/resource.js +1 -1
  77. package/dist/extensions/testserver/commands/pool/create/command.js +1 -1
  78. package/dist/extensions/testserver/resource.d.ts +2 -2
  79. package/dist/extensions/testserver/resource.js +2 -2
  80. package/dist/planning/plan-only.d.ts +4 -1
  81. package/dist/planning/plan-only.js +5 -2
  82. package/dist/planning/run-plan.d.ts +1 -2
  83. package/dist/planning/test-plan.js +1 -2
  84. package/dist/runner/base.d.ts +0 -6
  85. package/dist/runner/base.js +0 -15
  86. package/dist/runner/build-snapshots.js +7 -8
  87. package/dist/runner/gateways.d.ts +5 -0
  88. package/dist/runner/index.d.ts +1 -1
  89. package/dist/runner/live/sandbox-gateway.js +12 -0
  90. package/dist/runner/prepare.d.ts +16 -15
  91. package/dist/runner/prepare.js +11 -12
  92. package/dist/runner/recipe.d.ts +66 -67
  93. package/dist/runner/recipe.js +204 -120
  94. package/dist/runner/snapshot-build.d.ts +1 -1
  95. package/dist/runner/snapshot-build.js +10 -3
  96. package/dist/runner/snapshot-inspect.d.ts +4 -4
  97. package/dist/runner/snapshot-inspect.js +7 -7
  98. package/dist/runner/snapshot-key.d.ts +23 -15
  99. package/dist/runner/snapshot-key.js +46 -27
  100. package/dist/sdk/extension/resource-definition.d.ts +3 -2
  101. package/dist/sdk/extension/resource-definition.js +3 -2
  102. package/dist/sdk/extension/resource-factory.js +3 -4
  103. package/dist/sdk/run/present.d.ts +3 -3
  104. package/dist/sdk/run/present.js +1 -3
  105. package/package.json +1 -1
  106. package/skills/overview.md +2 -0
  107. package/skills/plan-runs.md +1 -1
  108. package/dist/config/recipe-run.d.ts +0 -33
  109. package/dist/config/recipe-run.js +0 -28
@@ -89,18 +89,6 @@ async function resolveBase(checkout, request2) {
89
89
  }
90
90
  return best === void 0 ? { kind: "no-base-ref", refs: refused2 } : { kind: "resolved", ...best };
91
91
  }
92
- function baseStepContext(checkout, request2) {
93
- const { repoRoot, base } = request2;
94
- return {
95
- base,
96
- readBaseFile: async (path) => {
97
- const file = await checkout.readFileAt({ repoRoot, commit: base, path });
98
- if (file.kind === "found") return file.text;
99
- if (file.kind === "missing") throw new Error(`${path} doesn't exist at ${base.slice(0, 12)}`);
100
- throw new Error(`can't read ${path} at ${base.slice(0, 12)}: ${file.failure.message}`);
101
- }
102
- };
103
- }
104
92
 
105
93
  // src/runner/time-limit.ts
106
94
  function callWithin(timer, ms, call) {
@@ -968,9 +956,12 @@ var RECIPE_KEYS = /* @__PURE__ */ new Set([
968
956
  "sandboxes"
969
957
  ]);
970
958
  var SANDBOXES_KEYS = /* @__PURE__ */ new Set(["max", "default"]);
959
+ var SANDBOXES_DEFAULT_RULE_KEYS = /* @__PURE__ */ new Set(["filesPerSandbox", "max"]);
960
+ var VCPUS_RULE_KEYS = /* @__PURE__ */ new Set(["resource", "option", "per", "min", "max"]);
971
961
  var SNAPSHOT_KEYS = /* @__PURE__ */ new Set(["vcpus", "summary", "toolchains", "prebuild"]);
972
962
  var RUN_KEYS = /* @__PURE__ */ new Set(["install", "build"]);
973
963
  var STEP_KEYS = /* @__PURE__ */ new Set(["label", "script"]);
964
+ var TOOLCHAIN_STEP_KEYS = /* @__PURE__ */ new Set(["label", "script", "baseFiles"]);
974
965
  var NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
975
966
  var ALLOWED_DOMAIN_PATTERN = /^(?:\*\.)?(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
976
967
  function checkRecipe(value) {
@@ -992,9 +983,7 @@ function checkRecipe(value) {
992
983
  const cwd = orDefault(value["cwd"], RECIPE_DEFAULTS.cwd);
993
984
  if (!isRelativePath(cwd))
994
985
  report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeRecipeValue(cwd)}`);
995
- const vcpus = value["vcpus"];
996
- if (typeof vcpus !== "function" && !isPositiveInteger(vcpus))
997
- report(["vcpus"], `must be a positive whole number, or a function of the run, not ${describeRecipeValue(vcpus)}`);
986
+ const vcpus = checkVcpus(value["vcpus"], report);
998
987
  const env = checkEnv(value["env"], report);
999
988
  const credentials2 = checkCredentials(value["credentials"], report);
1000
989
  const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials2, report);
@@ -1025,7 +1014,7 @@ function checkRecipe(value) {
1025
1014
  if (!isNonEmptyString(runtime))
1026
1015
  report(["runtime"], `must be a non-empty string, not ${describeRecipeValue(runtime)}`);
1027
1016
  const sandboxes = checkSandboxes(value["sandboxes"], report);
1028
- if (problems.length > 0 || snapshot === void 0 || run === void 0 || env === void 0 || credentials2 === void 0 || unsafeSecretEnvVars === void 0 || allowedDomains === null || baseRefs === void 0 || timeoutMinutes === void 0 || sandboxes === false)
1017
+ if (problems.length > 0 || snapshot === void 0 || run === void 0 || vcpus === void 0 || env === void 0 || credentials2 === void 0 || unsafeSecretEnvVars === void 0 || allowedDomains === null || baseRefs === void 0 || timeoutMinutes === void 0 || sandboxes === false)
1029
1018
  return { ok: false, problems };
1030
1019
  return {
1031
1020
  ok: true,
@@ -1049,6 +1038,56 @@ function checkRecipe(value) {
1049
1038
  }
1050
1039
  };
1051
1040
  }
1041
+ function checkVcpus(value, report) {
1042
+ if (isPositiveInteger(value)) return value;
1043
+ if (typeof value === "function") {
1044
+ report(["vcpus"], "can't be a function: use a positive whole number, or { resource, option, per, min, max }");
1045
+ return void 0;
1046
+ }
1047
+ if (!isRecord(value)) {
1048
+ report(
1049
+ ["vcpus"],
1050
+ `must be a positive whole number, or { resource, option, per, min, max }, not ${describeRecipeValue(value)}`
1051
+ );
1052
+ return void 0;
1053
+ }
1054
+ let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a runner recipe vcpus rule key", report);
1055
+ const resource = value["resource"];
1056
+ if (!isNonEmptyString(resource)) {
1057
+ report(["vcpus", "resource"], `must be a non-empty string, not ${describeRecipeValue(resource)}`);
1058
+ ok = false;
1059
+ }
1060
+ const option = value["option"];
1061
+ if (!isNonEmptyString(option)) {
1062
+ report(["vcpus", "option"], `must be a non-empty string, not ${describeRecipeValue(option)}`);
1063
+ ok = false;
1064
+ }
1065
+ const per = value["per"];
1066
+ if (!isPositiveInteger(per)) {
1067
+ report(["vcpus", "per"], `must be a positive whole number, not ${describeRecipeValue(per)}`);
1068
+ ok = false;
1069
+ }
1070
+ const min = value["min"];
1071
+ if (!isPositiveInteger(min)) {
1072
+ report(["vcpus", "min"], `must be a positive whole number, not ${describeRecipeValue(min)}`);
1073
+ ok = false;
1074
+ }
1075
+ const max = value["max"];
1076
+ if (!isPositiveInteger(max)) {
1077
+ report(["vcpus", "max"], `must be a positive whole number, not ${describeRecipeValue(max)}`);
1078
+ ok = false;
1079
+ } else if (isPositiveInteger(min) && max < min) {
1080
+ report(["vcpus", "max"], `must be at least vcpus.min (${min}), not ${max}`);
1081
+ ok = false;
1082
+ }
1083
+ return ok ? {
1084
+ resource,
1085
+ option,
1086
+ per,
1087
+ min,
1088
+ max
1089
+ } : void 0;
1090
+ }
1052
1091
  function checkSandboxes(value, report) {
1053
1092
  if (value === void 0) return void 0;
1054
1093
  if (!isRecord(value)) {
@@ -1064,18 +1103,62 @@ function checkSandboxes(value, report) {
1064
1103
  );
1065
1104
  ok = false;
1066
1105
  }
1067
- const sandboxesDefault = value["default"];
1068
- if (sandboxesDefault !== void 0 && typeof sandboxesDefault !== "function" && !(isPositiveInteger(sandboxesDefault) && sandboxesDefault <= MAX_RUNNER_SANDBOXES)) {
1106
+ const rawDefault = value["default"];
1107
+ let sandboxesDefault;
1108
+ if (rawDefault !== void 0) {
1109
+ const checkedDefault = checkSandboxesDefault(rawDefault, report);
1110
+ if (checkedDefault === void 0) ok = false;
1111
+ else sandboxesDefault = checkedDefault;
1112
+ }
1113
+ if (!ok) return false;
1114
+ return {
1115
+ max,
1116
+ ...sandboxesDefault === void 0 ? {} : { default: sandboxesDefault }
1117
+ };
1118
+ }
1119
+ function checkSandboxesDefault(value, report) {
1120
+ if (isPositiveInteger(value) && value <= MAX_RUNNER_SANDBOXES) return value;
1121
+ if (typeof value === "function") {
1122
+ report(
1123
+ ["sandboxes", "default"],
1124
+ `can't be a function: use a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }`
1125
+ );
1126
+ return void 0;
1127
+ }
1128
+ if (!isRecord(value)) {
1069
1129
  report(
1070
1130
  ["sandboxes", "default"],
1071
- `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or a function of the run's test plan, not ${describeRecipeValue(sandboxesDefault)}`
1131
+ `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${describeRecipeValue(value)}`
1132
+ );
1133
+ return void 0;
1134
+ }
1135
+ let ok = reportUnknownKeys(
1136
+ value,
1137
+ SANDBOXES_DEFAULT_RULE_KEYS,
1138
+ ["sandboxes", "default"],
1139
+ "a runner recipe sandboxes default rule key",
1140
+ report
1141
+ );
1142
+ const filesPerSandbox = value["filesPerSandbox"];
1143
+ if (!isPositiveInteger(filesPerSandbox)) {
1144
+ report(
1145
+ ["sandboxes", "default", "filesPerSandbox"],
1146
+ `must be a positive whole number, not ${describeRecipeValue(filesPerSandbox)}`
1072
1147
  );
1073
1148
  ok = false;
1074
1149
  }
1075
- if (!ok) return false;
1150
+ const max = value["max"];
1151
+ if (max !== void 0 && (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES)) {
1152
+ report(
1153
+ ["sandboxes", "default", "max"],
1154
+ `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeRecipeValue(max)}`
1155
+ );
1156
+ ok = false;
1157
+ }
1158
+ if (!ok) return void 0;
1076
1159
  return {
1077
- max,
1078
- ...sandboxesDefault === void 0 ? {} : { default: sandboxesDefault }
1160
+ filesPerSandbox,
1161
+ ...max === void 0 ? {} : { max }
1079
1162
  };
1080
1163
  }
1081
1164
  function checkSnapshot(value, report) {
@@ -1097,8 +1180,8 @@ function checkSnapshot(value, report) {
1097
1180
  report(["snapshot", "summary"], `must be a non-empty string, not ${describeRecipeValue(summary)}`);
1098
1181
  ok = false;
1099
1182
  }
1100
- const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], report);
1101
- const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], report);
1183
+ const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], true, report);
1184
+ const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], false, report);
1102
1185
  if (!ok || toolchains === void 0 || prebuild === void 0) return void 0;
1103
1186
  return {
1104
1187
  vcpus,
@@ -1113,30 +1196,40 @@ function checkRun(value, report) {
1113
1196
  return void 0;
1114
1197
  }
1115
1198
  const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a runner recipe run key", report);
1116
- const install = checkStep(value["install"], ["run", "install"], report);
1117
- const build = checkStep(value["build"], ["run", "build"], report);
1199
+ const install = checkStep(value["install"], ["run", "install"], false, report);
1200
+ const build = checkStep(value["build"], ["run", "build"], false, report);
1118
1201
  return ok && install !== void 0 && build !== void 0 ? { install, build } : void 0;
1119
1202
  }
1120
- function checkSteps(value, path, report) {
1121
- if (typeof value === "function") return value;
1203
+ function checkSteps(value, path, allowBaseFiles, report) {
1204
+ if (typeof value === "function") {
1205
+ report(
1206
+ path,
1207
+ allowBaseFiles ? "can't be a function: use a list of { label, script, baseFiles? } steps and declare the base files each step reads" : "can't be a function: use a list of { label, script } steps (prebuild steps already see the base's files)"
1208
+ );
1209
+ return void 0;
1210
+ }
1122
1211
  if (!Array.isArray(value)) {
1123
- report(path, `must be a list of steps, or a function that returns one, not ${describeRecipeValue(value)}`);
1212
+ report(path, `must be a list of steps, not ${describeRecipeValue(value)}`);
1124
1213
  return void 0;
1125
1214
  }
1126
- const steps = value.map((step, index) => checkStep(step, [...path, String(index)], report));
1215
+ const steps = value.map(
1216
+ (step, index) => allowBaseFiles ? checkStep(step, [...path, String(index)], true, report) : checkStep(step, [...path, String(index)], false, report)
1217
+ );
1127
1218
  return steps.every((step) => step !== void 0) ? steps : void 0;
1128
1219
  }
1129
- function checkStep(value, path, report) {
1220
+ function checkStep(value, path, allowBaseFiles, report) {
1130
1221
  if (!isRecord(value)) {
1131
- report(path, `must be a step, { label, script }, not ${describeRecipeValue(value)}`);
1222
+ const shape = allowBaseFiles ? "{ label, script, baseFiles? }" : "{ label, script }";
1223
+ report(path, `must be a step, ${shape}, not ${describeRecipeValue(value)}`);
1132
1224
  return void 0;
1133
1225
  }
1226
+ const allowedKeys = allowBaseFiles ? TOOLCHAIN_STEP_KEYS : STEP_KEYS;
1134
1227
  let ok = true;
1135
1228
  for (const key of Object.keys(value)) {
1136
- if (STEP_KEYS.has(key)) continue;
1229
+ if (allowedKeys.has(key)) continue;
1137
1230
  report(
1138
1231
  [...path, key],
1139
- key === "secrets" ? "is not a step key: every recipe step gets every credential runner.credentials declares" : "is not a step key"
1232
+ key === "secrets" ? "is not a step key: every recipe step gets every credential runner.credentials declares" : key === "baseFiles" ? "is only allowed on snapshot.toolchains steps: this step already sees the base's files" : "is not a step key"
1140
1233
  );
1141
1234
  ok = false;
1142
1235
  }
@@ -1150,7 +1243,42 @@ function checkStep(value, path, report) {
1150
1243
  report([...path, "script"], `must be a non-empty string, not ${describeRecipeValue(script)}`);
1151
1244
  ok = false;
1152
1245
  }
1153
- return ok ? { label, script } : void 0;
1246
+ if (!allowBaseFiles) return ok ? { label, script } : void 0;
1247
+ const baseFiles = checkBaseFiles(value["baseFiles"], [...path, "baseFiles"], report);
1248
+ if (baseFiles === null) ok = false;
1249
+ if (!ok || baseFiles === null) return void 0;
1250
+ return {
1251
+ label,
1252
+ script,
1253
+ ...baseFiles === void 0 || baseFiles.length === 0 ? {} : { baseFiles }
1254
+ };
1255
+ }
1256
+ function checkBaseFiles(value, path, report) {
1257
+ if (value === void 0) return void 0;
1258
+ if (!Array.isArray(value)) {
1259
+ report(path, `must be a list of relative file paths, not ${describeRecipeValue(value)}`);
1260
+ return null;
1261
+ }
1262
+ let ok = true;
1263
+ const seen = /* @__PURE__ */ new Set();
1264
+ const checked = [];
1265
+ value.forEach((entry, index) => {
1266
+ const at = [...path, String(index)];
1267
+ if (!isRelativeFilePath(entry)) {
1268
+ report(
1269
+ at,
1270
+ `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${describeRecipeValue(entry)}`
1271
+ );
1272
+ ok = false;
1273
+ } else if (seen.has(entry)) {
1274
+ report(at, `lists ${entry} again`);
1275
+ ok = false;
1276
+ } else {
1277
+ seen.add(entry);
1278
+ checked.push(entry);
1279
+ }
1280
+ });
1281
+ return ok ? checked : null;
1154
1282
  }
1155
1283
  function checkEnv(value, report) {
1156
1284
  if (value === void 0) return {};
@@ -1220,66 +1348,34 @@ function checkBaseRefs(value, report) {
1220
1348
  });
1221
1349
  return ok ? [...value] : void 0;
1222
1350
  }
1223
- async function resolveSteps(steps, context) {
1224
- if (typeof steps !== "function") return { ok: true, steps: steps.map(({ label, script }) => ({ label, script })) };
1225
- let returned;
1226
- try {
1227
- returned = await steps(context);
1228
- } catch (error) {
1229
- return { ok: false, problem: `threw at base ${context.base.slice(0, 12)}: ${errorMessage(error)}` };
1351
+ function declaredBaseFilePaths(toolchains) {
1352
+ const paths = /* @__PURE__ */ new Set();
1353
+ for (const step of toolchains) {
1354
+ if (step.baseFiles === void 0) continue;
1355
+ for (const file of step.baseFiles) paths.add(file);
1230
1356
  }
1231
- if (!Array.isArray(returned))
1232
- return { ok: false, problem: `must return a list of steps, not ${describeRecipeValue(returned)}` };
1233
- const problems = [];
1234
- const checked = returned.map(
1235
- (step, index) => checkStep(step, [String(index)], (path, problem) => problems.push({ path, problem }))
1236
- );
1237
- const first = problems[0];
1238
- if (first !== void 0)
1357
+ return [...paths].toSorted((a, b) => a < b ? -1 : a > b ? 1 : 0);
1358
+ }
1359
+ function resolveVcpus(recipe, run) {
1360
+ if (typeof recipe.vcpus === "number") return { ok: true, vcpus: recipe.vcpus };
1361
+ const { resource, option, per, min, max } = recipe.vcpus;
1362
+ const options = Object.hasOwn(run.resources, resource) ? run.resources[resource] : void 0;
1363
+ if (options === void 0) return { ok: true, vcpus: min };
1364
+ const raw = Object.hasOwn(options, option) ? options[option] : void 0;
1365
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) {
1239
1366
  return {
1240
1367
  ok: false,
1241
- problem: `must return a list of { label, script } steps, but item ${first.path.join(".")} ${first.problem}`
1368
+ problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${describeRecipeValue(raw)}`
1242
1369
  };
1243
- return { ok: true, steps: checked };
1244
- }
1245
- function resolveVcpus(recipe, { run, resourceKeys }) {
1246
- if (typeof recipe.vcpus !== "function") return { ok: true, vcpus: recipe.vcpus };
1247
- let returned;
1248
- try {
1249
- returned = recipe.vcpus(run);
1250
- } catch (error) {
1251
- return { ok: false, problem: `threw for ${describeResourceKeys(resourceKeys)}: ${errorMessage(error)}` };
1252
1370
  }
1253
- return isPositiveInteger(returned) ? { ok: true, vcpus: returned } : {
1254
- ok: false,
1255
- problem: `must return a positive whole number, not ${describeRecipeValue(returned)} for ${describeResourceKeys(resourceKeys)}`
1256
- };
1371
+ const perSandbox = Math.ceil(raw / Math.max(1, run.sandboxes));
1372
+ return { ok: true, vcpus: Math.min(max, Math.max(min, per * perSandbox)) };
1257
1373
  }
1258
1374
  function resolveSandboxCountDefault(sandboxesDefault, testPlan) {
1259
- if (typeof sandboxesDefault !== "function") return { ok: true, sandboxes: sandboxesDefault };
1260
- let returned;
1261
- try {
1262
- returned = sandboxesDefault(Object.freeze({ testPlan }));
1263
- } catch (error) {
1264
- return { ok: false, problem: `threw for ${describeTestPlan(testPlan)}: ${errorMessage(error)}` };
1265
- }
1266
- return isPositiveInteger(returned) ? { ok: true, sandboxes: returned } : {
1267
- ok: false,
1268
- problem: `must return a whole number from 1, not ${describeRecipeValue(returned)} for ${describeTestPlan(testPlan)}`
1269
- };
1270
- }
1271
- function describeTestPlan(testPlan) {
1272
- if (testPlan.kind !== "counted") return "a test plan that counted nothing";
1273
- const files = `${testPlan.files} test ${testPlan.files === 1 ? "file" : "files"}`;
1274
- return testPlan.tests === void 0 ? `a test plan of ${files}` : `a test plan of ${testPlan.tests} ${testPlan.tests === 1 ? "test" : "tests"} in ${files}`;
1275
- }
1276
- function describeResourceKeys(names) {
1277
- const last = names.at(-1);
1278
- if (last === void 0) return "a run with no resource";
1279
- return `a run with ${names.length === 1 ? last : `${names.slice(0, -1).join(", ")} and ${last}`}`;
1280
- }
1281
- function errorMessage(error) {
1282
- return error instanceof Error ? error.message : String(error);
1375
+ if (typeof sandboxesDefault === "number") return sandboxesDefault;
1376
+ if (testPlan.kind !== "counted") return 1;
1377
+ const limit = sandboxesDefault.max ?? MAX_RUNNER_SANDBOXES;
1378
+ return Math.max(1, Math.min(limit, Math.ceil(testPlan.files / sandboxesDefault.filesPerSandbox)));
1283
1379
  }
1284
1380
  function orDefault(value, fallback) {
1285
1381
  return value === void 0 ? fallback : value;
@@ -1296,9 +1392,15 @@ function isPositiveInteger(value) {
1296
1392
  function isRelativePath(value) {
1297
1393
  return typeof value === "string" && value.length > 0 && !value.startsWith("/") && !value.split(/[/\\]/).includes("..");
1298
1394
  }
1395
+ function isRelativeFilePath(value) {
1396
+ if (typeof value !== "string" || value.length === 0) return false;
1397
+ if (value.startsWith("/") || value.endsWith("/") || value.includes("\\") || value.includes("\0")) return false;
1398
+ const segments = value.split("/");
1399
+ return segments.every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
1400
+ }
1299
1401
 
1300
1402
  // src/runner/snapshot-key.ts
1301
- var SNAPSHOT_FORMAT = 4;
1403
+ var SNAPSHOT_FORMAT = 5;
1302
1404
  var SANDBOX_ROOT = "/vercel/sandbox";
1303
1405
  var STAGED_FILES = {
1304
1406
  baseTarball: "base.tgz",
@@ -1347,31 +1449,49 @@ function applyScript(staging, root = SANDBOX_ROOT) {
1347
1449
  }
1348
1450
  function snapshotKey(steps) {
1349
1451
  const text = (list) => list.flatMap(({ label, script }) => [label, script]);
1452
+ const baseFiles = [...steps.baseFiles].toSorted((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
1350
1453
  return createHash2("sha256").update(
1351
1454
  [
1352
1455
  `format=${SNAPSHOT_FORMAT}`,
1353
1456
  `credentials=${[...new Set(steps.credentials)].toSorted().join(",")}`,
1457
+ `baseFiles=${baseFiles.length}`,
1458
+ ...baseFiles.flatMap(({ path, text: content }) => [path, content]),
1354
1459
  ...text(steps.toolchains),
1355
1460
  baseIndexScript("<base>", "<staging>"),
1356
1461
  ...text(steps.prebuild)
1357
1462
  ].join("\0")
1358
1463
  ).digest("hex");
1359
1464
  }
1360
- async function snapshotStepsAt(checkout, request2) {
1361
- const context = baseStepContext(checkout, request2);
1362
- const { snapshot } = request2.recipe;
1363
- const toolchains = await resolveSteps(snapshot.toolchains, context);
1364
- if (!toolchains.ok) return { ok: false, path: ["snapshot", "toolchains"], problem: toolchains.problem };
1365
- const prebuild = await resolveSteps(snapshot.prebuild, context);
1366
- if (!prebuild.ok) return { ok: false, path: ["snapshot", "prebuild"], problem: prebuild.problem };
1465
+ async function snapshotInputsAt(checkout, request2) {
1466
+ const { repoRoot, base, recipe } = request2;
1467
+ const { snapshot } = recipe;
1468
+ const baseFiles = [];
1469
+ for (const path of declaredBaseFilePaths(snapshot.toolchains)) {
1470
+ const file = await checkout.readFileAt({ repoRoot, commit: base, path });
1471
+ if (file.kind === "missing") {
1472
+ return {
1473
+ ok: false,
1474
+ path: ["snapshot", "toolchains"],
1475
+ problem: `declared base file "${path}" doesn't exist at base ${base.slice(0, 12)}`
1476
+ };
1477
+ }
1478
+ if (file.kind === "failed") {
1479
+ return {
1480
+ ok: false,
1481
+ path: ["snapshot", "toolchains"],
1482
+ problem: `can't read declared base file "${path}" at base ${base.slice(0, 12)}: ${file.failure.message}`
1483
+ };
1484
+ }
1485
+ baseFiles.push({ path, text: file.text });
1486
+ }
1367
1487
  return {
1368
1488
  ok: true,
1369
- toolchains: toolchains.steps,
1370
- prebuild: prebuild.steps,
1489
+ baseFiles,
1371
1490
  key: snapshotKey({
1372
- credentials: credentialSourceIds(request2.recipe),
1373
- toolchains: toolchains.steps,
1374
- prebuild: prebuild.steps
1491
+ credentials: credentialSourceIds(recipe),
1492
+ baseFiles,
1493
+ toolchains: snapshot.toolchains,
1494
+ prebuild: snapshot.prebuild
1375
1495
  })
1376
1496
  };
1377
1497
  }
@@ -1509,7 +1629,7 @@ async function buildSnapshot(context, request2, control, progress) {
1509
1629
  kind: "snapshot-build-started",
1510
1630
  base,
1511
1631
  why: request2.why,
1512
- summary: recipe.snapshot.summary ?? [...prepared.toolchains, ...prepared.prebuild].map(({ label }) => label).join(", ")
1632
+ summary: recipe.snapshot.summary ?? [...recipe.snapshot.toolchains, ...recipe.snapshot.prebuild].map(({ label }) => label).join(", ")
1513
1633
  });
1514
1634
  const [started, archive] = await Promise.all([
1515
1635
  scope.startBuildSandbox(access, {
@@ -1541,10 +1661,19 @@ async function buildSnapshot(context, request2, control, progress) {
1541
1661
  signal
1542
1662
  );
1543
1663
  if (!staged.ok) return sandboxStop("upload", staged.failure);
1664
+ if (prepared.baseFiles.length > 0) {
1665
+ const encoder = new TextEncoder();
1666
+ const placed = await context.runnerSandboxes.placeBaseFiles(
1667
+ sandbox,
1668
+ prepared.baseFiles.map(({ path, text }) => ({ name: path, content: encoder.encode(text) })),
1669
+ signal
1670
+ );
1671
+ if (!placed.ok) return sandboxStop("upload", placed.failure);
1672
+ }
1544
1673
  const steps = [
1545
- ...prepared.toolchains,
1674
+ ...recipe.snapshot.toolchains,
1546
1675
  { label: BASE_INDEX_LABEL, script: baseIndexScript(base, staged.value.directory) },
1547
- ...prepared.prebuild
1676
+ ...recipe.snapshot.prebuild
1548
1677
  ];
1549
1678
  await progress.emit({ kind: "output-started", section: "snapshot", sandbox: sandbox.name, region: recipe.region });
1550
1679
  let stop;
@@ -1638,12 +1767,12 @@ async function prepareSnapshotBuild(context, request2) {
1638
1767
  if (commit.value === null) return { kind: "ref-not-found", ref };
1639
1768
  base = commit.value;
1640
1769
  }
1641
- const steps = await snapshotStepsAt(checkout, { repoRoot, base, recipe });
1642
- if (!steps.ok) return { kind: "invalid-recipe", path: steps.path, problem: steps.problem };
1770
+ const inputs = await snapshotInputsAt(checkout, { repoRoot, base, recipe });
1771
+ if (!inputs.ok) return { kind: "invalid-recipe", path: inputs.path, problem: inputs.problem };
1643
1772
  const listed = await context.runnerSnapshots.listEntries();
1644
1773
  const now = context.clock.now();
1645
1774
  const cached = (listed.ok ? listed.value.entries : []).filter(
1646
- (entry) => entry.base === base && entry.recipeName === recipe.name && entry.region === recipe.region && entry.runtime === recipe.runtime && entry.snapshotKey === steps.key && hasTimeLeft(entry, now)
1775
+ (entry) => entry.base === base && entry.recipeName === recipe.name && entry.region === recipe.region && entry.runtime === recipe.runtime && entry.snapshotKey === inputs.key && hasTimeLeft(entry, now)
1647
1776
  );
1648
1777
  const atMergeBase = base === mergeBase?.commit;
1649
1778
  let commitsAfterBase = null;
@@ -1659,9 +1788,8 @@ async function prepareSnapshotBuild(context, request2) {
1659
1788
  recipe,
1660
1789
  repoRoot,
1661
1790
  base,
1662
- toolchains: steps.toolchains,
1663
- prebuild: steps.prebuild,
1664
- snapshotKey: steps.key,
1791
+ baseFiles: inputs.baseFiles,
1792
+ snapshotKey: inputs.key,
1665
1793
  commitsAfterBase
1666
1794
  },
1667
1795
  head: head2.value,
@@ -1809,15 +1937,15 @@ async function inspectSnapshotCache(context, request2) {
1809
1937
  };
1810
1938
  }
1811
1939
  const mergeBase = resolved.base;
1812
- const steps = await snapshotStepsAt(checkout, { repoRoot, base: mergeBase, recipe });
1813
- if (!steps.ok) return { kind: "invalid-recipe", path: steps.path, problem: steps.problem };
1940
+ const inputs = await snapshotInputsAt(checkout, { repoRoot, base: mergeBase, recipe });
1941
+ if (!inputs.ok) return { kind: "invalid-recipe", path: inputs.path, problem: inputs.problem };
1814
1942
  const afterBase = await checkout.commitCount({ repoRoot, from: mergeBase, to: "HEAD" });
1815
1943
  if (!afterBase.ok) return { kind: "checkout-failed", failure: afterBase.failure };
1816
1944
  const read = classifySnapshotEntries(context, {
1817
1945
  entries,
1818
1946
  recipe,
1819
1947
  base: mergeBase,
1820
- snapshotKey: steps.key,
1948
+ snapshotKey: inputs.key,
1821
1949
  commitsAfterBase: afterBase.value
1822
1950
  });
1823
1951
  const owners = new Map(read.candidates.map(({ entry }) => [`${entry.teamId}\0${entry.projectId}`, entry]));
@@ -2194,6 +2322,16 @@ function liveRunnerSandboxGateway() {
2194
2322
  return { ok: false, failure: sandboxFailure(error, signal) };
2195
2323
  }
2196
2324
  },
2325
+ async placeBaseFiles(sandbox, files, signal) {
2326
+ if (files.length === 0) return { ok: true };
2327
+ const holder = holding(sandbox);
2328
+ try {
2329
+ await holder.sandbox.writeFiles(writes(SANDBOX_ROOT, files), signal === void 0 ? void 0 : { signal });
2330
+ return { ok: true };
2331
+ } catch (error) {
2332
+ return { ok: false, failure: sandboxFailure(error, signal) };
2333
+ }
2334
+ },
2197
2335
  async runScript(sandbox, request2, onOutput, signal) {
2198
2336
  const holder = holding(sandbox);
2199
2337
  try {
@@ -2776,9 +2914,9 @@ async function prepareRunner(context, request2) {
2776
2914
  const submodules2 = await checkout.submodules({ repoRoot });
2777
2915
  if (!submodules2.ok) return { kind: "checkout-failed", failure: submodules2.failure };
2778
2916
  if (submodules2.value.length > 0) return { kind: "submodules", paths: [...submodules2.value] };
2779
- const steps = await snapshotStepsAt(checkout, { repoRoot, base, recipe });
2780
- if (!steps.ok) return { kind: "invalid-recipe", path: steps.path, problem: steps.problem };
2781
- const vcpus = resolveVcpus(recipe, request2.vcpusRun);
2917
+ const inputs = await snapshotInputsAt(checkout, { repoRoot, base, recipe });
2918
+ if (!inputs.ok) return { kind: "invalid-recipe", path: inputs.path, problem: inputs.problem };
2919
+ const vcpus = resolveVcpus(recipe, request2.vcpuRun);
2782
2920
  if (!vcpus.ok) return { kind: "invalid-recipe", path: ["vcpus"], problem: vcpus.problem };
2783
2921
  const upload = await checkout.assembleUpload({ repoRoot, base });
2784
2922
  if (!upload.ok) return { kind: "checkout-failed", failure: upload.failure };
@@ -2789,7 +2927,7 @@ async function prepareRunner(context, request2) {
2789
2927
  entries: listing.entries,
2790
2928
  recipe,
2791
2929
  base,
2792
- snapshotKey: steps.key,
2930
+ snapshotKey: inputs.key,
2793
2931
  commitsAfterBase: afterBase.value
2794
2932
  });
2795
2933
  return {
@@ -2799,9 +2937,8 @@ async function prepareRunner(context, request2) {
2799
2937
  repoRoot,
2800
2938
  base,
2801
2939
  baseRef: resolved.ref,
2802
- toolchains: steps.toolchains,
2803
- prebuild: steps.prebuild,
2804
- snapshotKey: steps.key,
2940
+ baseFiles: inputs.baseFiles,
2941
+ snapshotKey: inputs.key,
2805
2942
  vcpus: vcpus.vcpus,
2806
2943
  upload: upload.value,
2807
2944
  candidates: cache.candidates,
@@ -3203,11 +3340,11 @@ function openRunnerSession(context, request2, control, progress) {
3203
3340
  }
3204
3341
 
3205
3342
  // src/config/load.ts
3206
- import { dirname, join as join2 } from "node:path";
3343
+ import { basename, dirname, join as join2 } from "node:path";
3207
3344
 
3208
3345
  // src/config/check-runner.ts
3209
3346
  var FACTORY_HINT = "must be made by vercelSandbox({ \u2026 }) or launchMachine()";
3210
- function checkRunner(value, inherited) {
3347
+ function checkRunner(value, inherited, definitions = []) {
3211
3348
  if (!isRecord2(value)) {
3212
3349
  return { ok: false, problems: [{ path: [], problem: `${FACTORY_HINT}, not ${describeValue(value)}` }] };
3213
3350
  }
@@ -3231,10 +3368,31 @@ function checkRunner(value, inherited) {
3231
3368
  };
3232
3369
  const checked = checkRecipe(rawOptions);
3233
3370
  if (!checked.ok) return checked;
3371
+ const vcpusProblems = checkVcpusRuleDefinitions(checked.value.vcpus, definitions);
3372
+ if (vcpusProblems.length > 0) return { ok: false, problems: vcpusProblems };
3234
3373
  return { ok: true, value: { kind: "vercel-sandbox", recipe: checked.value } };
3235
3374
  }
3236
3375
  return { ok: false, problems: [{ path: [], problem: `${FACTORY_HINT}, not ${describeValue(value)}` }] };
3237
3376
  }
3377
+ function checkVcpusRuleDefinitions(vcpus, definitions) {
3378
+ if (typeof vcpus === "number") return [];
3379
+ const definition = definitions.find((each) => each.name === vcpus.resource);
3380
+ if (definition === void 0) {
3381
+ const known = definitions.length === 0 ? "none" : definitions.map((each) => each.name).join(", ");
3382
+ return [{ path: ["vcpus", "resource"], problem: `is not a resource; storm has ${known}` }];
3383
+ }
3384
+ if (!Object.hasOwn(definition.options, vcpus.option)) {
3385
+ const optionNames = Object.keys(definition.options);
3386
+ const available = optionNames.length === 0 ? "none" : optionNames.join(", ");
3387
+ return [
3388
+ {
3389
+ path: ["vcpus", "option"],
3390
+ problem: `is not a ${definition.name} option; ${definition.name} has ${available}`
3391
+ }
3392
+ ];
3393
+ }
3394
+ return [];
3395
+ }
3238
3396
  function rawVercelSandboxOptions(value) {
3239
3397
  if (!isRecord2(value) || value["kind"] !== "vercel-sandbox") return void 0;
3240
3398
  const options = value["options"];
@@ -3246,6 +3404,8 @@ function isRecord2(value) {
3246
3404
 
3247
3405
  // src/config/schema.ts
3248
3406
  var CONFIG_FILE_NAME = "storm.config.ts";
3407
+ var CONFIG_FILE_NAMES = [CONFIG_FILE_NAME, "storm.config.mts"];
3408
+ var CONFIG_FILE_NAMES_TEXT = CONFIG_FILE_NAMES.join(" or ");
3249
3409
  function checkWith(schema, value) {
3250
3410
  const parsed = schema.safeParse(value);
3251
3411
  if (parsed.success) return { ok: true, value: parsed.data };
@@ -3280,7 +3440,7 @@ var SETTING_CHECKS = {
3280
3440
  project: (value) => checkWith(nonEmptyString, value),
3281
3441
  driver: (value, { drivers }) => checkDriver(value, drivers),
3282
3442
  args: checkStringList,
3283
- runner: (value, { topLevelRunnerOptions }) => checkRunner(value, topLevelRunnerOptions),
3443
+ runner: (value, { topLevelRunnerOptions, definitions }) => checkRunner(value, topLevelRunnerOptions, definitions),
3284
3444
  testPlan: (value) => checkWith(booleanOption, value)
3285
3445
  };
3286
3446
  function isConfigSettingKey(key) {
@@ -3376,6 +3536,7 @@ function checkSuites(value, options, problems) {
3376
3536
  return {};
3377
3537
  }
3378
3538
  const settingContext = {
3539
+ definitions: options.definitions,
3379
3540
  drivers: options.drivers,
3380
3541
  topLevelRunnerOptions: options.topLevelRunnerOptions
3381
3542
  };
@@ -3449,14 +3610,22 @@ function isRecord4(value) {
3449
3610
 
3450
3611
  // src/config/load.ts
3451
3612
  async function findConfigFile(gateway, startDirectory) {
3452
- if (await gateway.hasConfigFile(startDirectory)) return join2(startDirectory, CONFIG_FILE_NAME);
3613
+ const here = await lookIn(gateway, startDirectory);
3614
+ if (here !== void 0) return here;
3453
3615
  const root = await worktreeRoot(gateway, startDirectory);
3454
- if (root === void 0) return void 0;
3616
+ if (root === void 0) return { kind: "none" };
3455
3617
  for (let directory = startDirectory; directory !== root; ) {
3456
3618
  directory = dirname(directory);
3457
- if (await gateway.hasConfigFile(directory)) return join2(directory, CONFIG_FILE_NAME);
3619
+ const found = await lookIn(gateway, directory);
3620
+ if (found !== void 0) return found;
3458
3621
  }
3459
- return void 0;
3622
+ return { kind: "none" };
3623
+ }
3624
+ async function lookIn(gateway, directory) {
3625
+ const [first, second, ...rest] = (await gateway.configFileNames(directory)).map((name) => join2(directory, name));
3626
+ if (first === void 0) return void 0;
3627
+ if (second === void 0) return { kind: "found", path: first };
3628
+ return { kind: "conflict", paths: [first, second, ...rest] };
3460
3629
  }
3461
3630
  async function worktreeRoot(gateway, directory) {
3462
3631
  for (let current = directory; ; current = dirname(current)) {
@@ -3465,8 +3634,22 @@ async function worktreeRoot(gateway, directory) {
3465
3634
  }
3466
3635
  }
3467
3636
  async function loadConfig(gateway, startDirectory, definitions, drivers) {
3468
- const path = await findConfigFile(gateway, startDirectory);
3469
- if (path === void 0) return { kind: "none" };
3637
+ const found = await findConfigFile(gateway, startDirectory);
3638
+ if (found.kind === "none") return { kind: "none" };
3639
+ if (found.kind === "conflict") {
3640
+ const [path2, ...others] = found.paths;
3641
+ const names = others.map((other) => basename(other)).join(" and ");
3642
+ return {
3643
+ kind: "invalid",
3644
+ path: path2,
3645
+ problems: [
3646
+ fileProblem(
3647
+ `is in the same directory as ${names}, so storm can't tell which config file applies; keep one of them`
3648
+ )
3649
+ ]
3650
+ };
3651
+ }
3652
+ const { path } = found;
3470
3653
  const imported = await gateway.importConfig(path);
3471
3654
  switch (imported.kind) {
3472
3655
  case "import-failed":
@@ -3497,7 +3680,7 @@ function checkFile(path, value, definitions, drivers) {
3497
3680
  let resources = {};
3498
3681
  let rawSuites;
3499
3682
  let hasSuitesKey = false;
3500
- const settingContext = { drivers };
3683
+ const settingContext = { definitions, drivers };
3501
3684
  const hasTopLevelDriver = value["driver"] !== void 0;
3502
3685
  for (const [key, keyValue] of Object.entries(value)) {
3503
3686
  if (key === "resources") resources = checkResources(keyValue, definitions, problems, "resources");
@@ -3506,7 +3689,7 @@ function checkFile(path, value, definitions, drivers) {
3506
3689
  rawSuites = keyValue;
3507
3690
  } else if (isConfigSettingKey(key)) {
3508
3691
  if (keyValue !== void 0) checkSetting(key, keyValue, settings, settingContext, problems);
3509
- } else problems.push({ key, location: null, problem: `is not a ${CONFIG_FILE_NAME} key` });
3692
+ } else problems.push({ key, location: null, problem: `is not a ${basename(path)} key` });
3510
3693
  }
3511
3694
  if (settings.args !== void 0 && !hasTopLevelDriver) {
3512
3695
  problems.push({ key: "args", location: null, problem: "requires a top-level driver" });
@@ -3521,9 +3704,84 @@ function checkFile(path, value, definitions, drivers) {
3521
3704
  },
3522
3705
  problems
3523
3706
  ) : {};
3707
+ checkPlainData(value, problems);
3524
3708
  if (problems.length > 0) return { kind: "invalid", path, problems };
3525
3709
  return { kind: "loaded", path, values: { settings, resources, suites } };
3526
3710
  }
3711
+ function checkPlainData(root, problems) {
3712
+ const reported = new Set(problems.map(({ key }) => key).filter((key) => key !== null));
3713
+ const visiting = /* @__PURE__ */ new Set();
3714
+ const addProblem = (path, problem) => {
3715
+ const key = path.join(".");
3716
+ if (reported.has(key)) return;
3717
+ reported.add(key);
3718
+ problems.push({ key: key.length === 0 ? null : key, location: null, problem });
3719
+ };
3720
+ const visit = (current, path) => {
3721
+ if (current === null || typeof current === "string" || typeof current === "boolean") return;
3722
+ if (current === void 0) {
3723
+ addProblem(path, "must be plain data (JSON cannot hold undefined in an array)");
3724
+ return;
3725
+ }
3726
+ if (typeof current === "number") {
3727
+ if (!Number.isFinite(current)) addProblem(path, `must be plain data (JSON cannot hold ${String(current)})`);
3728
+ return;
3729
+ }
3730
+ if (typeof current === "function") {
3731
+ addProblem(path, "must be plain data (JSON cannot hold a function)");
3732
+ return;
3733
+ }
3734
+ if (typeof current === "symbol") {
3735
+ addProblem(path, "must be plain data (JSON cannot hold a symbol)");
3736
+ return;
3737
+ }
3738
+ if (typeof current === "bigint") {
3739
+ addProblem(path, "must be plain data (JSON cannot hold a bigint)");
3740
+ return;
3741
+ }
3742
+ if (typeof current !== "object") return;
3743
+ if (visiting.has(current)) {
3744
+ addProblem(path, "must be plain data (circular reference)");
3745
+ return;
3746
+ }
3747
+ if (Array.isArray(current)) {
3748
+ visiting.add(current);
3749
+ for (let index = 0; index < current.length; index += 1) visit(current[index], [...path, String(index)]);
3750
+ visiting.delete(current);
3751
+ return;
3752
+ }
3753
+ const proto = Object.getPrototypeOf(current);
3754
+ if (proto !== Object.prototype && proto !== null) {
3755
+ addProblem(path, `must be plain data (expected a plain object, not ${describeNonPlainObject(proto)})`);
3756
+ return;
3757
+ }
3758
+ visiting.add(current);
3759
+ const isRunnerWrapper = path.length === 1 && path[0] === "runner" || path.length === 3 && path[0] === "suites" && path[2] === "runner";
3760
+ const unwrapRunnerOptions = isRunnerWrapper && current["kind"] === "vercel-sandbox";
3761
+ const isResourceWrapper = path.length === 2 && path[0] === "resources" || path.length === 4 && path[0] === "suites" && path[2] === "resources";
3762
+ const unwrapResourceOptions = isResourceWrapper && typeof current["name"] === "string";
3763
+ for (const [key, entry] of Object.entries(current)) {
3764
+ if (entry === void 0) continue;
3765
+ if ((unwrapRunnerOptions || unwrapResourceOptions) && key === "options" && isPlainObject2(entry)) {
3766
+ visit(entry, path);
3767
+ continue;
3768
+ }
3769
+ visit(entry, [...path, key]);
3770
+ }
3771
+ visiting.delete(current);
3772
+ };
3773
+ visit(root, []);
3774
+ }
3775
+ function isPlainObject2(value) {
3776
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
3777
+ const proto = Object.getPrototypeOf(value);
3778
+ return proto === Object.prototype || proto === null;
3779
+ }
3780
+ function describeNonPlainObject(proto) {
3781
+ const ctor = typeof proto === "object" && proto !== null ? proto.constructor : void 0;
3782
+ if (typeof ctor === "function" && ctor.name.length > 0 && ctor.name !== "Object") return ctor.name;
3783
+ return "a non-plain object";
3784
+ }
3527
3785
  function checkSetting(key, value, settings, context, problems) {
3528
3786
  const checked = checkSettingValue(key, value, context);
3529
3787
  if (checked.ok) Object.assign(settings, { [key]: checked.value });
@@ -3635,9 +3893,6 @@ function givenOptionsOf(_definition, values) {
3635
3893
  function settingsOf(_definition, settings) {
3636
3894
  return settings;
3637
3895
  }
3638
- function resourceOptionsOf(_definition, value) {
3639
- return value;
3640
- }
3641
3896
 
3642
3897
  // src/config/resolve.ts
3643
3898
  function resolveSettings(flags, file) {
@@ -3929,10 +4184,10 @@ async function request(env, timeoutMs) {
3929
4184
  return classifyTokenResponse({ status: response.status, body: await response.text() }, token);
3930
4185
  } catch (error) {
3931
4186
  if (signal.aborted) return { ok: false, failure: { kind: "timeout", seconds } };
3932
- return { ok: false, failure: { kind: "unreachable", said: said(errorMessage2(error), token) } };
4187
+ return { ok: false, failure: { kind: "unreachable", said: said(errorMessage(error), token) } };
3933
4188
  }
3934
4189
  }
3935
- function errorMessage2(error) {
4190
+ function errorMessage(error) {
3936
4191
  if (!(error instanceof Error)) return String(error);
3937
4192
  const cause = error.cause;
3938
4193
  return cause instanceof Error && cause.message !== "" ? `${error.message}: ${cause.message}` : error.message;
@@ -4216,11 +4471,14 @@ function credentialResolver(gateways) {
4216
4471
 
4217
4472
  // src/config/live/config-gateway.ts
4218
4473
  import { stat } from "node:fs/promises";
4219
- import { basename, join as join3 } from "node:path";
4474
+ import { basename as basename2, join as join3 } from "node:path";
4220
4475
  import { pathToFileURL } from "node:url";
4221
4476
  function liveConfigGateway() {
4222
4477
  return {
4223
- hasConfigFile: async (directory) => await kind(join3(directory, CONFIG_FILE_NAME)) === "file",
4478
+ configFileNames: async (directory) => {
4479
+ const kinds = await Promise.all(CONFIG_FILE_NAMES.map((name) => kind(join3(directory, name))));
4480
+ return CONFIG_FILE_NAMES.filter((_, index) => kinds[index] === "file");
4481
+ },
4224
4482
  isWorktreeRoot: async (directory) => await kind(join3(directory, ".git")) !== void 0,
4225
4483
  importConfig: async (path) => {
4226
4484
  try {
@@ -4241,7 +4499,7 @@ async function kind(path) {
4241
4499
  }
4242
4500
  function importFailure(error, path) {
4243
4501
  if (!(error instanceof Error)) return { kind: "import-failed", message: String(error) };
4244
- const location = errorLocation(error, basename(path));
4502
+ const location = errorLocation(error, basename2(path));
4245
4503
  return { kind: "import-failed", message: error.message, ...location === void 0 ? {} : { location } };
4246
4504
  }
4247
4505
  function errorLocation(error, name) {
@@ -4286,24 +4544,6 @@ function liveFileListsFileGateway(stdin = process.stdin) {
4286
4544
  };
4287
4545
  }
4288
4546
 
4289
- // src/config/recipe-run.ts
4290
- var NOT_PRESENT = Object.freeze({ present: false });
4291
- function recipeRun(resources, sandboxes = 1) {
4292
- const run = {
4293
- sandboxes,
4294
- get: ({ definition }) => {
4295
- const key = defaultResourceKey(definition);
4296
- const resource = Object.hasOwn(resources, key) ? resources[key] : void 0;
4297
- if (resource === void 0 || resource.definition !== definition.name) return NOT_PRESENT;
4298
- return Object.freeze({
4299
- present: true,
4300
- value: resourceOptionsOf(definition, Object.freeze({ ...resource.options }))
4301
- });
4302
- }
4303
- };
4304
- return { run: Object.freeze(run), resourceKeys: Object.keys(resources) };
4305
- }
4306
-
4307
4547
  // src/config/resolver.ts
4308
4548
  function configResolver(launcher) {
4309
4549
  const loadFile = () => loadSettingsFile(launcher.gateway, launcher.cwd, launcher.definitions, launcher.drivers);
@@ -4365,10 +4605,10 @@ export {
4365
4605
  openRunnerSession,
4366
4606
  inspectSnapshotCache,
4367
4607
  CONFIG_FILE_NAME,
4608
+ CONFIG_FILE_NAMES_TEXT,
4368
4609
  liveConfigGateway,
4369
4610
  liveFileListsFileGateway,
4370
4611
  findConfigFile,
4371
- recipeRun,
4372
4612
  effectiveConfig,
4373
4613
  fileSettings,
4374
4614
  settleRunResources,