@walkeros/cli 4.0.0 → 4.1.0-next-1778155282668

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -422,11 +422,11 @@ import path5 from "path";
422
422
  import fs3 from "fs-extra";
423
423
  async function resolveLocalPackage(packageName, localPath, configDir, logger) {
424
424
  const absolutePath = path5.isAbsolute(localPath) ? localPath : path5.resolve(configDir, localPath);
425
- const stat = await fs3.stat(absolutePath).catch(() => null);
426
- if (stat?.isFile()) {
425
+ const stat2 = await fs3.stat(absolutePath).catch(() => null);
426
+ if (stat2?.isFile()) {
427
427
  return { name: packageName, absolutePath, type: "file" };
428
428
  }
429
- if (!stat) {
429
+ if (!stat2) {
430
430
  for (const ext of [".ts", ".mjs", ".js", ".json"]) {
431
431
  const withExt = absolutePath + ext;
432
432
  if (await fs3.pathExists(withExt)) {
@@ -437,7 +437,7 @@ async function resolveLocalPackage(packageName, localPath, configDir, logger) {
437
437
  `Local package path not found: ${localPath} (resolved to ${absolutePath})`
438
438
  );
439
439
  }
440
- if (stat.isDirectory()) {
440
+ if (stat2.isDirectory()) {
441
441
  const hasPkgJson = await fs3.pathExists(
442
442
  path5.join(absolutePath, "package.json")
443
443
  );
@@ -745,6 +745,49 @@ var init_package_path = __esm({
745
745
  }
746
746
  });
747
747
 
748
+ // src/core/import-specifier.ts
749
+ var toFileImportSpecifier;
750
+ var init_import_specifier = __esm({
751
+ "src/core/import-specifier.ts"() {
752
+ "use strict";
753
+ toFileImportSpecifier = (absPath) => absPath.replace(/\\/g, "/");
754
+ }
755
+ });
756
+
757
+ // src/core/parse-component-ref.ts
758
+ function isAllowedPrefix(value, allowed) {
759
+ return allowed.includes(value);
760
+ }
761
+ function parseComponentRef(input, options) {
762
+ const { allowed, messages = {} } = options;
763
+ const allowedList = allowed.join(" | ");
764
+ const parts = input.split(".");
765
+ if (parts.length < 2) {
766
+ const msg = messages.invalidFormat ? messages.invalidFormat(input) : `Invalid target "${input}". Expected <kind>.<name> where kind is ${allowedList}.`;
767
+ throw new Error(msg);
768
+ }
769
+ const prefix = parts[0];
770
+ const name = parts[1];
771
+ if (!name) {
772
+ const msg = messages.missingName ? messages.missingName(input, prefix) : `Invalid target "${input}". Missing name after "${prefix}."`;
773
+ throw new Error(msg);
774
+ }
775
+ if (!isAllowedPrefix(prefix, allowed)) {
776
+ const msg = messages.invalidPrefix ? messages.invalidPrefix(prefix) : `Invalid kind "${prefix}". Expected ${allowedList}.`;
777
+ throw new Error(msg);
778
+ }
779
+ return {
780
+ prefix,
781
+ name,
782
+ rest: parts.slice(2)
783
+ };
784
+ }
785
+ var init_parse_component_ref = __esm({
786
+ "src/core/parse-component-ref.ts"() {
787
+ "use strict";
788
+ }
789
+ });
790
+
748
791
  // src/core/index.ts
749
792
  var init_core = __esm({
750
793
  "src/core/index.ts"() {
@@ -763,6 +806,8 @@ var init_core = __esm({
763
806
  init_sse();
764
807
  init_event_validation();
765
808
  init_package_path();
809
+ init_import_specifier();
810
+ init_parse_component_ref();
766
811
  }
767
812
  });
768
813
 
@@ -828,7 +873,7 @@ var init_build_defaults = __esm({
828
873
  };
829
874
  DEFAULT_OUTPUT_PATHS = {
830
875
  web: "./dist/walker.js",
831
- server: "./dist/bundle.mjs"
876
+ server: "./dist/flow.mjs"
832
877
  };
833
878
  }
834
879
  });
@@ -838,7 +883,8 @@ import path7 from "path";
838
883
  import fs6 from "fs-extra";
839
884
  import { getFlowSettings, getPlatform } from "@walkeros/core";
840
885
  function loadBundleConfig(rawConfig, options) {
841
- const config = validateFlowConfig(rawConfig);
886
+ const sanitized = stripLegacyBundleExternal(rawConfig, options.logger);
887
+ const config = validateFlowConfig(sanitized);
842
888
  const availableFlows = getAvailableFlows(config);
843
889
  const flowName = resolveFlow(config, options.flowName, availableFlows);
844
890
  let flowSettings = getFlowSettings(config, flowName, { deferred: true });
@@ -852,8 +898,10 @@ function loadBundleConfig(rawConfig, options) {
852
898
  flowSettings = getFlowSettings(config, flowName);
853
899
  }
854
900
  const buildDefaults = getBuildDefaults(platform);
855
- const packages = flowSettings.config?.bundle?.packages || {};
856
- const overrides = flowSettings.config?.bundle?.overrides || {};
901
+ const bundle2 = flowSettings.config?.bundle;
902
+ const packages = bundle2?.packages ?? {};
903
+ const overrides = bundle2?.overrides ?? {};
904
+ const traceInclude = bundle2?.traceInclude;
857
905
  const output = options.buildOverrides?.output || getDefaultOutput(platform);
858
906
  const configDir = isUrl(options.configPath) ? process.cwd() : path7.dirname(options.configPath);
859
907
  let includes = config.include;
@@ -867,6 +915,7 @@ function loadBundleConfig(rawConfig, options) {
867
915
  ...buildDefaults,
868
916
  packages,
869
917
  overrides,
918
+ traceInclude,
870
919
  output,
871
920
  include: includes,
872
921
  configDir,
@@ -923,6 +972,38 @@ async function loadFlowConfig(configPath, options) {
923
972
  const rawConfig = await loadJsonConfig(configPath);
924
973
  return loadBundleConfig(rawConfig, { configPath, ...options });
925
974
  }
975
+ function stripLegacyBundleExternal(rawConfig, logger) {
976
+ if (!isPlainObject(rawConfig)) return rawConfig;
977
+ const flows = rawConfig.flows;
978
+ if (!isPlainObject(flows)) return rawConfig;
979
+ let mutated = null;
980
+ for (const [flowName, flowValue] of Object.entries(flows)) {
981
+ if (!isPlainObject(flowValue)) continue;
982
+ const flowConfig = flowValue.config;
983
+ if (!isPlainObject(flowConfig)) continue;
984
+ const bundle2 = flowConfig.bundle;
985
+ if (!isPlainObject(bundle2)) continue;
986
+ if (!("external" in bundle2)) continue;
987
+ logger?.warn(
988
+ `flow.config.bundle.external is no longer supported; @walkeros/cli@4.x traces server bundles automatically. Remove it from flows.${flowName}.config.bundle.`
989
+ );
990
+ if (!mutated) {
991
+ mutated = {
992
+ ...rawConfig,
993
+ flows: { ...flows }
994
+ };
995
+ }
996
+ const mutatedFlows = mutated.flows;
997
+ const newBundle = { ...bundle2 };
998
+ delete newBundle.external;
999
+ const newConfig = { ...flowConfig, bundle: newBundle };
1000
+ mutatedFlows[flowName] = { ...flowValue, config: newConfig };
1001
+ }
1002
+ return mutated ?? rawConfig;
1003
+ }
1004
+ function isPlainObject(value) {
1005
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1006
+ }
926
1007
  var DEFAULT_INCLUDE_FOLDER;
927
1008
  var init_loader = __esm({
928
1009
  "src/config/loader.ts"() {
@@ -1024,7 +1105,49 @@ var init_cache_utils = __esm({
1024
1105
  import pacote from "pacote";
1025
1106
  import path8 from "path";
1026
1107
  import fs7 from "fs-extra";
1108
+ import { readFile } from "fs/promises";
1109
+ import os2 from "os";
1027
1110
  import semver2 from "semver";
1111
+ async function loadNpmConfigForPacote(projectDir = process.cwd(), homeDir = os2.homedir()) {
1112
+ const merged = {};
1113
+ const sources = [
1114
+ path8.join(homeDir, ".npmrc"),
1115
+ path8.join(projectDir, ".npmrc")
1116
+ ];
1117
+ for (const file of sources) {
1118
+ let content;
1119
+ try {
1120
+ content = await readFile(file, "utf-8");
1121
+ } catch {
1122
+ continue;
1123
+ }
1124
+ for (const rawLine of content.split("\n")) {
1125
+ const line = rawLine.trim();
1126
+ if (!line || line.startsWith("#") || line.startsWith(";")) continue;
1127
+ const eq = line.indexOf("=");
1128
+ if (eq < 0) continue;
1129
+ const key = line.slice(0, eq).trim();
1130
+ let value = line.slice(eq + 1).trim();
1131
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
1132
+ value = value.slice(1, -1);
1133
+ }
1134
+ value = value.replace(
1135
+ /\$\{([^}]+)\}/g,
1136
+ (match, v) => process.env[v] ?? match
1137
+ );
1138
+ merged[key] = value;
1139
+ }
1140
+ }
1141
+ let registry = merged["registry"] ?? "https://registry.npmjs.org/";
1142
+ if (!registry.endsWith("/")) registry = `${registry}/`;
1143
+ for (const key of Object.keys(merged)) {
1144
+ if (key.endsWith(":registry") && key.startsWith("@")) {
1145
+ const v = merged[key];
1146
+ if (!v.endsWith("/")) merged[key] = `${v}/`;
1147
+ }
1148
+ }
1149
+ return { ...merged, registry, preferOnline: true };
1150
+ }
1028
1151
  async function withTimeout(promise, ms, errorMessage) {
1029
1152
  let timer;
1030
1153
  const timeout = new Promise((_, reject) => {
@@ -1048,7 +1171,7 @@ function getNestedPackageDirectory(baseDir, consumerName, nestedPackageName) {
1048
1171
  nestedPackageName
1049
1172
  );
1050
1173
  }
1051
- async function collectAllSpecs(packages, logger, configDir, overrides = {}) {
1174
+ async function collectAllSpecs(packages, logger, configDir, overrides = {}, npmConfig = PACOTE_OPTS) {
1052
1175
  const allSpecs = /* @__PURE__ */ new Map();
1053
1176
  const visited = /* @__PURE__ */ new Set();
1054
1177
  const directLocalNames = new Set(
@@ -1137,7 +1260,7 @@ async function collectAllSpecs(packages, logger, configDir, overrides = {}) {
1137
1260
  let manifest;
1138
1261
  try {
1139
1262
  manifest = await withTimeout(
1140
- pacote.manifest(`${item.name}@${item.spec}`, PACOTE_OPTS),
1263
+ pacote.manifest(`${item.name}@${item.spec}`, npmConfig),
1141
1264
  PACKAGE_DOWNLOAD_TIMEOUT_MS,
1142
1265
  `Manifest fetch timed out: ${item.name}@${item.spec}`
1143
1266
  );
@@ -1274,7 +1397,19 @@ function resolveVersionConflicts(allSpecs, logger) {
1274
1397
  }
1275
1398
  return { topLevel, nested: [...consolidatedMap.values()] };
1276
1399
  }
1277
- async function downloadPackages(packages, targetDir, logger, useCache = true, configDir, tmpDir, overrides = {}) {
1400
+ async function downloadPackagesWithResolution(packages, targetDir, logger, useCache = true, configDir, tmpDir, overrides = {}, npmConfig = PACOTE_OPTS) {
1401
+ return downloadPackagesImpl(
1402
+ packages,
1403
+ targetDir,
1404
+ logger,
1405
+ useCache,
1406
+ configDir,
1407
+ tmpDir,
1408
+ overrides,
1409
+ npmConfig
1410
+ );
1411
+ }
1412
+ async function downloadPackagesImpl(packages, targetDir, logger, useCache, configDir, tmpDir, overrides, npmConfig) {
1278
1413
  const packagePaths = /* @__PURE__ */ new Map();
1279
1414
  const userSpecifiedPackages = new Set(packages.map((p) => p.name));
1280
1415
  validateNoDuplicatePackages(packages);
@@ -1283,9 +1418,11 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
1283
1418
  packages,
1284
1419
  logger,
1285
1420
  configDir,
1286
- overrides
1421
+ overrides,
1422
+ npmConfig
1287
1423
  );
1288
- const { topLevel, nested } = resolveVersionConflicts(allSpecs, logger);
1424
+ const resolution = resolveVersionConflicts(allSpecs, logger);
1425
+ const { topLevel, nested } = resolution;
1289
1426
  await fs7.ensureDir(targetDir);
1290
1427
  const localPackageMap = /* @__PURE__ */ new Map();
1291
1428
  for (const pkg of packages) {
@@ -1328,7 +1465,7 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
1328
1465
  const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(tmpDir, "cache", "npm");
1329
1466
  await withTimeout(
1330
1467
  pacote.extract(packageSpec, packageDir, {
1331
- ...PACOTE_OPTS,
1468
+ ...npmConfig,
1332
1469
  cache: cacheDir
1333
1470
  }),
1334
1471
  PACKAGE_DOWNLOAD_TIMEOUT_MS,
@@ -1354,7 +1491,7 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
1354
1491
  if (!semver2.valid(nestedPkg.version)) {
1355
1492
  try {
1356
1493
  const manifest = await withTimeout(
1357
- pacote.manifest(resolvedSpec, PACOTE_OPTS),
1494
+ pacote.manifest(resolvedSpec, npmConfig),
1358
1495
  PACKAGE_DOWNLOAD_TIMEOUT_MS,
1359
1496
  `Manifest fetch timed out: ${resolvedSpec}`
1360
1497
  );
@@ -1376,7 +1513,7 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
1376
1513
  const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(tmpDir, "cache", "npm");
1377
1514
  await withTimeout(
1378
1515
  pacote.extract(resolvedSpec, nestedDir, {
1379
- ...PACOTE_OPTS,
1516
+ ...npmConfig,
1380
1517
  cache: cacheDir
1381
1518
  }),
1382
1519
  PACKAGE_DOWNLOAD_TIMEOUT_MS,
@@ -1390,7 +1527,7 @@ async function downloadPackages(packages, targetDir, logger, useCache = true, co
1390
1527
  }
1391
1528
  }
1392
1529
  }
1393
- return packagePaths;
1530
+ return { packagePaths, resolution };
1394
1531
  }
1395
1532
  async function getCachedPackagePath(pkg, tmpDir) {
1396
1533
  const cacheDir = getTmpPath(tmpDir, "cache", "packages");
@@ -1432,7 +1569,7 @@ var init_package_manager = __esm({
1432
1569
  init_tmp();
1433
1570
  PACKAGE_DOWNLOAD_TIMEOUT_MS = 6e4;
1434
1571
  PACOTE_OPTS = {
1435
- registry: "https://registry.npmjs.org",
1572
+ registry: "https://registry.npmjs.org/",
1436
1573
  preferOnline: true,
1437
1574
  where: void 0
1438
1575
  };
@@ -1445,55 +1582,174 @@ var init_package_manager = __esm({
1445
1582
  }
1446
1583
  });
1447
1584
 
1585
+ // src/commands/bundle/nft-trace.ts
1586
+ import { nodeFileTrace } from "@vercel/nft";
1587
+ import * as path9 from "path";
1588
+ import * as fs8 from "fs/promises";
1589
+ import picomatch from "picomatch";
1590
+ async function traceAndCopy(opts) {
1591
+ try {
1592
+ await fs8.stat(opts.entry);
1593
+ } catch {
1594
+ throw new Error(
1595
+ `nft-trace: entry file not found at '${opts.entry}'. Check the path or run 'walkeros bundle' from the directory containing your flow.json.`
1596
+ );
1597
+ }
1598
+ const realBase = await fs8.realpath(opts.base);
1599
+ const expandedExtras = await expandTraceIncludes(
1600
+ opts.extraIncludes ?? [],
1601
+ realBase
1602
+ );
1603
+ const entries = [opts.entry, ...expandedExtras];
1604
+ const { fileList, reasons } = await nodeFileTrace(entries, {
1605
+ base: realBase
1606
+ });
1607
+ const outDirReal = path9.resolve(opts.outDir);
1608
+ let copied = 0;
1609
+ for (const file of fileList) {
1610
+ const reason = reasons.get(file);
1611
+ if (reason?.ignored) continue;
1612
+ const dst = path9.resolve(outDirReal, file);
1613
+ if (!dst.startsWith(outDirReal + path9.sep) && dst !== outDirReal) {
1614
+ throw new Error(
1615
+ `nft-trace: traced file '${file}' resolves outside outDir. This usually means base is too narrow for a hoisted monorepo. Move base up to the workspace root or set traceInclude explicitly.`
1616
+ );
1617
+ }
1618
+ const src = path9.join(realBase, file);
1619
+ await fs8.mkdir(path9.dirname(dst), { recursive: true });
1620
+ await fs8.copyFile(src, dst);
1621
+ const s = await fs8.stat(src);
1622
+ if (s.mode & 73) await fs8.chmod(dst, s.mode);
1623
+ copied++;
1624
+ }
1625
+ return { fileList: Array.from(fileList), copied, reasons };
1626
+ }
1627
+ function assertDepsTraced(opts) {
1628
+ const missing = opts.expectedPackages.filter((dep) => {
1629
+ const expected = `node_modules/${dep}/package.json`;
1630
+ return !opts.fileList.some((f) => f.endsWith(expected));
1631
+ });
1632
+ if (missing.length > 0) {
1633
+ throw new Error(
1634
+ `nft-trace: resolved packages missing from trace: ${missing.join(", ")}. Possible causes: hoisted monorepo symlinks outside base; nft per-release regression; dynamic require not statically traceable. Add specific paths to flow.<name>.config.bundle.traceInclude as a workaround.`
1635
+ );
1636
+ }
1637
+ }
1638
+ async function expandTraceIncludes(patterns, base) {
1639
+ if (patterns.length === 0) return [];
1640
+ const literals = [];
1641
+ const globs = [];
1642
+ for (const entry of patterns) {
1643
+ if (GLOB_CHARS.test(entry)) globs.push(entry);
1644
+ else literals.push(entry);
1645
+ }
1646
+ const resolvedLiterals = literals.map(
1647
+ (p) => path9.isAbsolute(p) ? p : path9.resolve(base, p)
1648
+ );
1649
+ if (globs.length === 0) return resolvedLiterals;
1650
+ const matchers = globs.map((g) => picomatch(g));
1651
+ const matchedFiles = [];
1652
+ await walkFiles(base, base, async (absFile, relFile) => {
1653
+ const relPosix = relFile.split(path9.sep).join("/");
1654
+ if (matchers.some((m) => m(relPosix))) {
1655
+ matchedFiles.push(absFile);
1656
+ }
1657
+ });
1658
+ return [...resolvedLiterals, ...matchedFiles];
1659
+ }
1660
+ async function walkFiles(root, dir, visit) {
1661
+ let entries;
1662
+ try {
1663
+ entries = await fs8.readdir(dir, { withFileTypes: true });
1664
+ } catch {
1665
+ return;
1666
+ }
1667
+ for (const entry of entries) {
1668
+ const abs = path9.join(dir, entry.name);
1669
+ if (entry.isDirectory()) {
1670
+ await walkFiles(root, abs, visit);
1671
+ } else if (entry.isFile()) {
1672
+ await visit(abs, path9.relative(root, abs));
1673
+ }
1674
+ }
1675
+ }
1676
+ var GLOB_CHARS;
1677
+ var init_nft_trace = __esm({
1678
+ "src/commands/bundle/nft-trace.ts"() {
1679
+ "use strict";
1680
+ GLOB_CHARS = /[*?[\]{}]/;
1681
+ }
1682
+ });
1683
+
1448
1684
  // src/core/build-cache.ts
1449
- import fs8 from "fs-extra";
1450
- import path9 from "path";
1685
+ import fs9 from "fs-extra";
1686
+ import path10 from "path";
1451
1687
  import { getHashServer as getHashServer2 } from "@walkeros/server-core";
1688
+ function serializeKeyInputs(inputs) {
1689
+ return JSON.stringify({
1690
+ externals: [...inputs.externals].sort(),
1691
+ platform: inputs.platform,
1692
+ target: inputs.target,
1693
+ nodeMajor: inputs.nodeMajor,
1694
+ format: inputs.format,
1695
+ minify: inputs.minify ?? false,
1696
+ minifyOptions: inputs.minifyOptions ?? null,
1697
+ windowCollector: inputs.windowCollector ?? null,
1698
+ windowElb: inputs.windowElb ?? null,
1699
+ versionsHash: inputs.versionsHash
1700
+ });
1701
+ }
1702
+ async function computeCodeCacheKey(codeContent, inputs) {
1703
+ const keyMaterial = `${codeContent}
1704
+ ###
1705
+ ${serializeKeyInputs(inputs)}`;
1706
+ return getHashServer2(keyMaterial, 12);
1707
+ }
1452
1708
  async function getBuildCachePath(configContent, tmpDir) {
1453
1709
  const cacheDir = getTmpPath(tmpDir, "cache", "builds");
1454
1710
  const cacheKey = await getFlowSettingsCacheKey(configContent);
1455
- return path9.join(cacheDir, `${cacheKey}.js`);
1711
+ return path10.join(cacheDir, `${cacheKey}.js`);
1456
1712
  }
1457
1713
  async function isBuildCached(configContent, tmpDir) {
1458
1714
  const cachePath = await getBuildCachePath(configContent, tmpDir);
1459
- return fs8.pathExists(cachePath);
1715
+ return fs9.pathExists(cachePath);
1460
1716
  }
1461
1717
  async function cacheBuild(configContent, buildOutput, tmpDir) {
1462
1718
  const cachePath = await getBuildCachePath(configContent, tmpDir);
1463
- await fs8.ensureDir(path9.dirname(cachePath));
1464
- await fs8.writeFile(cachePath, buildOutput, "utf-8");
1719
+ await fs9.ensureDir(path10.dirname(cachePath));
1720
+ await fs9.writeFile(cachePath, buildOutput, "utf-8");
1465
1721
  }
1466
1722
  async function getCachedBuild(configContent, tmpDir) {
1467
1723
  const cachePath = await getBuildCachePath(configContent, tmpDir);
1468
- if (await fs8.pathExists(cachePath)) {
1469
- return await fs8.readFile(cachePath, "utf-8");
1724
+ if (await fs9.pathExists(cachePath)) {
1725
+ return await fs9.readFile(cachePath, "utf-8");
1470
1726
  }
1471
1727
  return null;
1472
1728
  }
1473
- async function getCodeCachePath(codeContent, tmpDir) {
1729
+ async function getCodeCachePath(codeContent, tmpDir, inputs) {
1474
1730
  const cacheDir = getTmpPath(tmpDir, "cache", "code");
1475
- const cacheKey = await getHashServer2(codeContent, 12);
1476
- return path9.join(cacheDir, `${cacheKey}.js`);
1731
+ const cacheKey = await computeCodeCacheKey(codeContent, inputs);
1732
+ return path10.join(cacheDir, `${cacheKey}.js`);
1477
1733
  }
1478
- async function cacheCode(codeContent, codeOutput, tmpDir) {
1479
- const cachePath = await getCodeCachePath(codeContent, tmpDir);
1480
- await fs8.ensureDir(path9.dirname(cachePath));
1481
- await fs8.writeFile(cachePath, codeOutput, "utf-8");
1734
+ async function cacheCode(codeContent, codeOutput, tmpDir, inputs) {
1735
+ const cachePath = await getCodeCachePath(codeContent, tmpDir, inputs);
1736
+ await fs9.ensureDir(path10.dirname(cachePath));
1737
+ await fs9.writeFile(cachePath, codeOutput, "utf-8");
1482
1738
  }
1483
- async function getCachedCode(codeContent, tmpDir) {
1484
- const cachePath = await getCodeCachePath(codeContent, tmpDir);
1485
- if (await fs8.pathExists(cachePath)) {
1486
- return fs8.readFile(cachePath, "utf-8");
1739
+ async function getCachedCode(codeContent, tmpDir, inputs) {
1740
+ const cachePath = await getCodeCachePath(codeContent, tmpDir, inputs);
1741
+ if (await fs9.pathExists(cachePath)) {
1742
+ return fs9.readFile(cachePath, "utf-8");
1487
1743
  }
1488
1744
  return null;
1489
1745
  }
1490
- async function ensureCodeOnDisk(codeContent, compiledCode, tmpDir) {
1746
+ async function ensureCodeOnDisk(codeContent, compiledCode, tmpDir, inputs) {
1491
1747
  const cacheDir = getTmpPath(tmpDir, "cache", "code");
1492
- const cacheKey = await getHashServer2(codeContent, 12);
1493
- const cachePath = path9.join(cacheDir, `${cacheKey}.mjs`);
1494
- if (!await fs8.pathExists(cachePath)) {
1495
- await fs8.ensureDir(path9.dirname(cachePath));
1496
- await fs8.writeFile(cachePath, compiledCode, "utf-8");
1748
+ const cacheKey = await computeCodeCacheKey(codeContent, inputs);
1749
+ const cachePath = path10.join(cacheDir, `${cacheKey}.mjs`);
1750
+ if (!await fs9.pathExists(cachePath)) {
1751
+ await fs9.ensureDir(path10.dirname(cachePath));
1752
+ await fs9.writeFile(cachePath, compiledCode, "utf-8");
1497
1753
  }
1498
1754
  return cachePath;
1499
1755
  }
@@ -1509,9 +1765,10 @@ var init_build_cache = __esm({
1509
1765
  import crypto from "crypto";
1510
1766
  import esbuild from "esbuild";
1511
1767
  import { builtinModules } from "module";
1512
- import path10 from "path";
1513
- import fs9 from "fs-extra";
1768
+ import path11 from "path";
1769
+ import fs10 from "fs-extra";
1514
1770
  import { packageNameToVariable, ENV_MARKER_PREFIX } from "@walkeros/core";
1771
+ import { getHashServer as getHashServer3 } from "@walkeros/server-core";
1515
1772
  function isInlineCode(code) {
1516
1773
  return code !== null && typeof code === "object" && !Array.isArray(code) && "push" in code;
1517
1774
  }
@@ -1575,25 +1832,25 @@ function generateInlineCode(inline, config, env, chain, chainPropertyName, isDes
1575
1832
  }
1576
1833
  async function copyIncludes(includes, sourceDir, outputDir, logger) {
1577
1834
  for (const include of includes) {
1578
- const sourcePath = path10.resolve(sourceDir, include);
1579
- const folderName = path10.basename(include);
1580
- const destPath = path10.join(outputDir, folderName);
1581
- const resolvedOutput = path10.resolve(outputDir);
1582
- const resolvedSource = path10.resolve(sourcePath);
1583
- if (resolvedSource === resolvedOutput || resolvedOutput.startsWith(resolvedSource + path10.sep) || resolvedSource.startsWith(resolvedOutput + path10.sep)) {
1835
+ const sourcePath = path11.resolve(sourceDir, include);
1836
+ const folderName = path11.basename(include);
1837
+ const destPath = path11.join(outputDir, folderName);
1838
+ const resolvedOutput = path11.resolve(outputDir);
1839
+ const resolvedSource = path11.resolve(sourcePath);
1840
+ if (resolvedSource === resolvedOutput || resolvedOutput.startsWith(resolvedSource + path11.sep) || resolvedSource.startsWith(resolvedOutput + path11.sep)) {
1584
1841
  throw new Error(
1585
1842
  `Circular include detected: "${include}" resolves to "${resolvedSource}" which overlaps with output directory "${resolvedOutput}"`
1586
1843
  );
1587
1844
  }
1588
- if (await fs9.pathExists(sourcePath)) {
1589
- await fs9.copy(sourcePath, destPath);
1845
+ if (await fs10.pathExists(sourcePath)) {
1846
+ await fs10.copy(sourcePath, destPath);
1590
1847
  logger.debug(`Copied ${include} to output`);
1591
1848
  } else {
1592
1849
  logger.warn(`Include folder not found: ${include}`);
1593
1850
  }
1594
1851
  }
1595
1852
  }
1596
- function generateCacheKeyContent(flowSettings, buildOptions) {
1853
+ function generateCacheKeyContent(flowSettings, buildOptions, versionsHash) {
1597
1854
  const configForCache = {
1598
1855
  flow: flowSettings,
1599
1856
  build: {
@@ -1601,7 +1858,8 @@ function generateCacheKeyContent(flowSettings, buildOptions) {
1601
1858
  // Exclude non-deterministic fields from cache key
1602
1859
  tempDir: void 0,
1603
1860
  output: void 0
1604
- }
1861
+ },
1862
+ versionsHash
1605
1863
  };
1606
1864
  return JSON.stringify(configForCache);
1607
1865
  }
@@ -1610,44 +1868,16 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
1610
1868
  const buildId = crypto.randomUUID();
1611
1869
  const TEMP_DIR = buildOptions.tempDir || getTmpPath(void 0, `walkeros-build-${buildId}`);
1612
1870
  const CACHE_DIR = buildOptions.tempDir || getTmpPath();
1613
- if (buildOptions.cache !== false) {
1614
- const configContent = generateCacheKeyContent(flowSettings, buildOptions);
1615
- const cached = await isBuildCached(configContent, CACHE_DIR);
1616
- if (cached) {
1617
- const cachedBuild = await getCachedBuild(configContent, CACHE_DIR);
1618
- if (cachedBuild) {
1619
- logger.debug("Using cached build");
1620
- const outputPath = path10.resolve(buildOptions.output);
1621
- await fs9.ensureDir(path10.dirname(outputPath));
1622
- await fs9.writeFile(outputPath, cachedBuild);
1623
- const stats = await fs9.stat(outputPath);
1624
- const sizeKB = (stats.size / 1024).toFixed(1);
1625
- logger.info(`Output: ${outputPath} (${sizeKB} KB, cached)`);
1626
- if (showStats) {
1627
- const stats2 = await fs9.stat(outputPath);
1628
- const packageStats = Object.entries(buildOptions.packages).map(
1629
- ([name, pkg]) => ({
1630
- name: `${name}@${pkg.version || "latest"}`,
1631
- size: 0
1632
- // Size estimation not available for cached builds
1633
- })
1634
- );
1635
- const hasWildcardImports = /import\s+\*\s+as\s+\w+\s+from/.test(
1636
- buildOptions.code || ""
1637
- );
1638
- return {
1639
- totalSize: stats2.size,
1640
- packages: packageStats,
1641
- buildTime: Date.now() - bundleStartTime,
1642
- treeshakingEffective: !hasWildcardImports
1643
- };
1644
- }
1645
- return;
1646
- }
1647
- }
1648
- }
1871
+ const npmConfig = await loadNpmConfigForPacote(
1872
+ buildOptions.configDir ?? process.cwd()
1873
+ );
1874
+ const outputPath = path11.resolve(buildOptions.output);
1875
+ const outputDirAbs = path11.dirname(outputPath);
1876
+ await fs10.remove(path11.join(outputDirAbs, "node_modules"));
1877
+ await fs10.remove(path11.join(outputDirAbs, "package.json"));
1878
+ await fs10.remove(path11.join(outputDirAbs, "package-lock.json"));
1649
1879
  try {
1650
- await fs9.ensureDir(TEMP_DIR);
1880
+ await fs10.ensureDir(TEMP_DIR);
1651
1881
  const hasSourcesOrDests = Object.keys(flowSettings.sources || {}).length > 0 || Object.keys(flowSettings.destinations || {}).length > 0;
1652
1882
  if (hasSourcesOrDests && !buildOptions.packages["@walkeros/collector"]) {
1653
1883
  buildOptions.packages["@walkeros/collector"] = {};
@@ -1691,7 +1921,7 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
1691
1921
  // Pass local path if defined
1692
1922
  })
1693
1923
  );
1694
- const packagePaths = await downloadPackages(
1924
+ const { packagePaths, resolution: resolutionResult } = await downloadPackagesWithResolution(
1695
1925
  packagesArray,
1696
1926
  TEMP_DIR,
1697
1927
  logger,
@@ -1699,25 +1929,98 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
1699
1929
  buildOptions.configDir,
1700
1930
  // For resolving relative local paths
1701
1931
  CACHE_DIR,
1702
- buildOptions.overrides
1932
+ buildOptions.overrides,
1933
+ npmConfig
1703
1934
  );
1935
+ const warnedBundleFieldPackages = /* @__PURE__ */ new Set();
1704
1936
  for (const [pkgName, pkgPath] of packagePaths.entries()) {
1937
+ const pkgJsonPath = path11.join(pkgPath, "package.json");
1938
+ let pkgJson;
1939
+ try {
1940
+ pkgJson = await fs10.readJSON(pkgJsonPath);
1941
+ } catch {
1942
+ continue;
1943
+ }
1944
+ const walkerOSBlock = pkgJson.walkerOS;
1945
+ if (walkerOSBlock && typeof walkerOSBlock === "object" && !Array.isArray(walkerOSBlock)) {
1946
+ const bundleField = walkerOSBlock.bundle;
1947
+ if (bundleField && typeof bundleField === "object" && !Array.isArray(bundleField) && !warnedBundleFieldPackages.has(pkgName)) {
1948
+ warnedBundleFieldPackages.add(pkgName);
1949
+ const keys = Object.keys(bundleField).sort().join(", ");
1950
+ logger.warn(
1951
+ `walkeros: package ${pkgName} still declares walkerOS.bundle.${keys}; this is ignored in @walkeros/cli@4.x. Tell the package author to remove it.`
1952
+ );
1953
+ }
1954
+ }
1705
1955
  if (pkgName.startsWith("@walkeros/")) {
1706
- const pkgJsonPath = path10.join(pkgPath, "package.json");
1707
- const pkgJson = await fs9.readJSON(pkgJsonPath);
1708
- if (!pkgJson.exports && pkgJson.module) {
1956
+ const exportsField = pkgJson.exports;
1957
+ const moduleField = pkgJson.module;
1958
+ if (!exportsField && typeof moduleField === "string") {
1709
1959
  pkgJson.exports = {
1710
1960
  ".": {
1711
- import: pkgJson.module,
1961
+ import: moduleField,
1712
1962
  require: pkgJson.main
1713
1963
  }
1714
1964
  };
1715
- await fs9.writeJSON(pkgJsonPath, pkgJson, { spaces: 2 });
1965
+ await fs10.writeJSON(pkgJsonPath, pkgJson, { spaces: 2 });
1966
+ }
1967
+ }
1968
+ }
1969
+ const sortedVersions = [...resolutionResult.topLevel.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([name, p]) => `${name}@${p.version}`);
1970
+ const versionsHash = await getHashServer3(sortedVersions.join("\n"), 12);
1971
+ const expectedTopLevelPackages = Object.keys(buildOptions.packages).filter(
1972
+ (name) => !name.startsWith(".") && !name.startsWith("/")
1973
+ );
1974
+ if (buildOptions.cache !== false) {
1975
+ const configContent = generateCacheKeyContent(
1976
+ flowSettings,
1977
+ buildOptions,
1978
+ versionsHash
1979
+ );
1980
+ const cached = await isBuildCached(configContent, CACHE_DIR);
1981
+ if (cached) {
1982
+ const cachedBuild = await getCachedBuild(configContent, CACHE_DIR);
1983
+ if (cachedBuild) {
1984
+ logger.debug("Using cached build");
1985
+ await fs10.ensureDir(path11.dirname(outputPath));
1986
+ await fs10.writeFile(outputPath, cachedBuild);
1987
+ if (buildOptions.platform === "node") {
1988
+ await runNftServerPath(
1989
+ outputPath,
1990
+ flowSettings,
1991
+ buildOptions,
1992
+ TEMP_DIR,
1993
+ expectedTopLevelPackages,
1994
+ logger
1995
+ );
1996
+ }
1997
+ const stats2 = await fs10.stat(outputPath);
1998
+ const sizeKB2 = (stats2.size / 1024).toFixed(1);
1999
+ logger.info(`Output: ${outputPath} (${sizeKB2} KB, cached)`);
2000
+ if (showStats) {
2001
+ const packageStats = Object.entries(buildOptions.packages).map(
2002
+ ([name, pkg]) => ({
2003
+ name: `${name}@${pkg.version || "latest"}`,
2004
+ size: 0
2005
+ // Size estimation not available for cached builds
2006
+ })
2007
+ );
2008
+ const hasWildcardImports = /import\s+\*\s+as\s+\w+\s+from/.test(
2009
+ buildOptions.code || ""
2010
+ );
2011
+ return {
2012
+ totalSize: stats2.size,
2013
+ packages: packageStats,
2014
+ buildTime: Date.now() - bundleStartTime,
2015
+ treeshakingEffective: !hasWildcardImports
2016
+ };
2017
+ }
2018
+ return;
1716
2019
  }
1717
2020
  }
1718
2021
  }
1719
- const packageJsonPath = path10.join(TEMP_DIR, "package.json");
1720
- await fs9.writeFile(
2022
+ const packageJsonPath = path11.join(TEMP_DIR, "package.json");
2023
+ await fs10.writeFile(
1721
2024
  packageJsonPath,
1722
2025
  JSON.stringify({ type: "module" }, null, 2)
1723
2026
  );
@@ -1727,11 +2030,22 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
1727
2030
  buildOptions,
1728
2031
  packagePaths
1729
2032
  );
1730
- const outputPath = path10.resolve(buildOptions.output);
1731
- await fs9.ensureDir(path10.dirname(outputPath));
2033
+ await fs10.ensureDir(path11.dirname(outputPath));
2034
+ const codeKeyInputs = {
2035
+ externals: /* @__PURE__ */ new Set(),
2036
+ platform: buildOptions.platform === "node" ? "node" : "browser",
2037
+ target: resolveTarget(buildOptions),
2038
+ nodeMajor: parseInt(process.versions.node.split(".")[0], 10),
2039
+ format: buildOptions.format,
2040
+ minify: buildOptions.minify,
2041
+ minifyOptions: buildOptions.minifyOptions,
2042
+ windowCollector: buildOptions.windowCollector,
2043
+ windowElb: buildOptions.windowElb,
2044
+ versionsHash
2045
+ };
1732
2046
  let compiledCode = null;
1733
2047
  if (buildOptions.cache !== false) {
1734
- compiledCode = await getCachedCode(codeEntry, CACHE_DIR);
2048
+ compiledCode = await getCachedCode(codeEntry, CACHE_DIR, codeKeyInputs);
1735
2049
  }
1736
2050
  if (compiledCode) {
1737
2051
  logger.debug("Using cached compiled code (config-only change)");
@@ -1739,15 +2053,16 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
1739
2053
  logger.debug(
1740
2054
  `Running esbuild (target: ${buildOptions.target || "es2018"}, format: ${buildOptions.format})`
1741
2055
  );
1742
- const entryPath = path10.join(TEMP_DIR, "entry.js");
1743
- await fs9.writeFile(entryPath, codeEntry);
2056
+ const entryPath = path11.join(TEMP_DIR, "entry.js");
2057
+ await fs10.writeFile(entryPath, codeEntry);
1744
2058
  const esbuildOptions = createEsbuildOptions(
1745
2059
  { ...buildOptions, minify: false },
1746
2060
  entryPath,
1747
2061
  outputPath,
1748
2062
  TEMP_DIR,
1749
2063
  packagePaths,
1750
- logger
2064
+ logger,
2065
+ expectedTopLevelPackages
1751
2066
  );
1752
2067
  try {
1753
2068
  await esbuild.build(esbuildOptions);
@@ -1759,15 +2074,16 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
1759
2074
  } finally {
1760
2075
  await esbuild.stop();
1761
2076
  }
1762
- compiledCode = await fs9.readFile(outputPath, "utf-8");
2077
+ compiledCode = await fs10.readFile(outputPath, "utf-8");
1763
2078
  if (buildOptions.cache !== false) {
1764
- await cacheCode(codeEntry, compiledCode, CACHE_DIR);
2079
+ await cacheCode(codeEntry, compiledCode, CACHE_DIR, codeKeyInputs);
1765
2080
  }
1766
2081
  }
1767
2082
  const stage1Path = await ensureCodeOnDisk(
1768
2083
  codeEntry,
1769
2084
  compiledCode,
1770
- CACHE_DIR
2085
+ CACHE_DIR,
2086
+ codeKeyInputs
1771
2087
  );
1772
2088
  if (buildOptions.skipWrapper || !hasFlow) {
1773
2089
  const dataDeclaration = `const __configData = ${dataPayload};
@@ -1776,15 +2092,15 @@ export { __configData };`;
1776
2092
  ` : "";
1777
2093
  const esmOutput = `${banner}${compiledCode}
1778
2094
  ${dataDeclaration}`;
1779
- await fs9.writeFile(outputPath, esmOutput);
2095
+ await fs10.writeFile(outputPath, esmOutput);
1780
2096
  } else {
1781
2097
  const stage2Entry = (buildOptions.platform || "node") === "browser" ? generateWebEntry(stage1Path, dataPayload, {
1782
2098
  windowCollector: buildOptions.windowCollector,
1783
2099
  windowElb: buildOptions.windowElb,
1784
2100
  platform: buildOptions.platform
1785
2101
  }) : generateServerEntry(stage1Path, dataPayload);
1786
- const stage2EntryPath = path10.join(TEMP_DIR, "stage2.mjs");
1787
- await fs9.writeFile(stage2EntryPath, stage2Entry);
2102
+ const stage2EntryPath = path11.join(TEMP_DIR, "stage2.mjs");
2103
+ await fs10.writeFile(stage2EntryPath, stage2Entry);
1788
2104
  const stage2Options = {
1789
2105
  entryPoints: [stage2EntryPath],
1790
2106
  bundle: true,
@@ -1807,13 +2123,16 @@ ${dataDeclaration}`;
1807
2123
  "process.env.NODE_ENV": '"production"',
1808
2124
  global: "globalThis"
1809
2125
  };
1810
- stage2Options.target = buildOptions.target || "es2018";
2126
+ stage2Options.target = resolveTarget(buildOptions);
1811
2127
  } else {
1812
- stage2Options.external = getNodeExternals();
2128
+ stage2Options.external = [
2129
+ ...getNodeExternals(),
2130
+ ...expectedTopLevelPackages
2131
+ ];
1813
2132
  stage2Options.banner = {
1814
2133
  js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
1815
2134
  };
1816
- stage2Options.target = buildOptions.target || "node18";
2135
+ stage2Options.target = resolveTarget(buildOptions);
1817
2136
  }
1818
2137
  try {
1819
2138
  await esbuild.build(stage2Options);
@@ -1821,16 +2140,30 @@ ${dataDeclaration}`;
1821
2140
  await esbuild.stop();
1822
2141
  }
1823
2142
  }
1824
- const outputStats = await fs9.stat(outputPath);
2143
+ const outputStats = await fs10.stat(outputPath);
1825
2144
  const sizeKB = (outputStats.size / 1024).toFixed(1);
1826
2145
  const buildTime = ((Date.now() - bundleStartTime) / 1e3).toFixed(1);
1827
2146
  logger.info(`Output: ${outputPath} (${sizeKB} KB, ${buildTime}s)`);
1828
2147
  if (buildOptions.cache !== false) {
1829
- const configContent = generateCacheKeyContent(flowSettings, buildOptions);
1830
- const buildOutput = await fs9.readFile(outputPath, "utf-8");
2148
+ const configContent = generateCacheKeyContent(
2149
+ flowSettings,
2150
+ buildOptions,
2151
+ versionsHash
2152
+ );
2153
+ const buildOutput = await fs10.readFile(outputPath, "utf-8");
1831
2154
  await cacheBuild(configContent, buildOutput, CACHE_DIR);
1832
2155
  logger.debug("Build cached for future use");
1833
2156
  }
2157
+ if (buildOptions.platform === "node") {
2158
+ await runNftServerPath(
2159
+ outputPath,
2160
+ flowSettings,
2161
+ buildOptions,
2162
+ TEMP_DIR,
2163
+ expectedTopLevelPackages,
2164
+ logger
2165
+ );
2166
+ }
1834
2167
  let stats;
1835
2168
  if (showStats) {
1836
2169
  stats = await collectBundleStats(
@@ -1841,7 +2174,7 @@ ${dataDeclaration}`;
1841
2174
  );
1842
2175
  }
1843
2176
  if (buildOptions.include && buildOptions.include.length > 0) {
1844
- const outputDir = path10.dirname(outputPath);
2177
+ const outputDir = path11.dirname(outputPath);
1845
2178
  await copyIncludes(
1846
2179
  buildOptions.include,
1847
2180
  buildOptions.configDir || process.cwd(),
@@ -1854,13 +2187,13 @@ ${dataDeclaration}`;
1854
2187
  throw error;
1855
2188
  } finally {
1856
2189
  if (!buildOptions.tempDir) {
1857
- fs9.remove(TEMP_DIR).catch(() => {
2190
+ fs10.remove(TEMP_DIR).catch(() => {
1858
2191
  });
1859
2192
  }
1860
2193
  }
1861
2194
  }
1862
2195
  async function collectBundleStats(outputPath, packages, startTime, entryContent) {
1863
- const stats = await fs9.stat(outputPath);
2196
+ const stats = await fs10.stat(outputPath);
1864
2197
  const totalSize = stats.size;
1865
2198
  const buildTime = Date.now() - startTime;
1866
2199
  const packageStats = Object.entries(packages).map(([name, pkg]) => {
@@ -1886,7 +2219,10 @@ async function collectBundleStats(outputPath, packages, startTime, entryContent)
1886
2219
  treeshakingEffective
1887
2220
  };
1888
2221
  }
1889
- function createEsbuildOptions(buildOptions, entryPath, outputPath, tempDir, packagePaths, logger) {
2222
+ function resolveTarget(buildOptions) {
2223
+ return buildOptions.target ?? (buildOptions.platform === "node" ? "node18" : "es2018");
2224
+ }
2225
+ function createEsbuildOptions(buildOptions, entryPath, outputPath, tempDir, packagePaths, logger, stepPackageExternals = []) {
1890
2226
  const alias = {};
1891
2227
  const baseOptions = {
1892
2228
  entryPoints: [entryPath],
@@ -1924,15 +2260,11 @@ function createEsbuildOptions(buildOptions, entryPath, outputPath, tempDir, pack
1924
2260
  baseOptions.external = buildOptions.external || [];
1925
2261
  } else if (buildOptions.platform === "node") {
1926
2262
  const nodeExternals = getNodeExternals();
1927
- baseOptions.external = buildOptions.external ? [...nodeExternals, ...buildOptions.external] : nodeExternals;
1928
- }
1929
- if (buildOptions.target) {
1930
- baseOptions.target = buildOptions.target;
1931
- } else if (buildOptions.platform === "node") {
1932
- baseOptions.target = "node18";
1933
- } else {
1934
- baseOptions.target = "es2018";
2263
+ const externalsParts = [nodeExternals, stepPackageExternals];
2264
+ if (buildOptions.external) externalsParts.push(buildOptions.external);
2265
+ baseOptions.external = externalsParts.flat();
1935
2266
  }
2267
+ baseOptions.target = resolveTarget(buildOptions);
1936
2268
  return baseOptions;
1937
2269
  }
1938
2270
  function detectStepPackages(flowSettings, section) {
@@ -1956,6 +2288,57 @@ function getNodeExternals() {
1956
2288
  }
1957
2289
  return externals;
1958
2290
  }
2291
+ async function runNftServerPath(outputPath, flowSettings, buildOptions, tempDir, expectedPackages, logger) {
2292
+ const outDir = path11.dirname(outputPath);
2293
+ const flowExtraIncludes = [
2294
+ ...flowSettings.config?.bundle?.traceInclude ?? [],
2295
+ ...buildOptions.traceInclude ?? []
2296
+ ];
2297
+ const stagedEntry = path11.join(tempDir, "__nft-flow.mjs");
2298
+ await fs10.copyFile(outputPath, stagedEntry);
2299
+ let result;
2300
+ try {
2301
+ result = await traceAndCopy({
2302
+ entry: stagedEntry,
2303
+ base: tempDir,
2304
+ outDir,
2305
+ extraIncludes: flowExtraIncludes
2306
+ });
2307
+ } finally {
2308
+ await fs10.remove(stagedEntry).catch(() => {
2309
+ });
2310
+ }
2311
+ const stagedRel = path11.relative(await fs10.realpath(tempDir), stagedEntry);
2312
+ const trimmedFileList = result.fileList.filter((f) => f !== stagedRel);
2313
+ await fs10.remove(path11.join(outDir, stagedRel)).catch(() => {
2314
+ });
2315
+ if (expectedPackages.length > 0) {
2316
+ assertDepsTraced({
2317
+ fileList: trimmedFileList,
2318
+ expectedPackages
2319
+ });
2320
+ }
2321
+ const stepPackages = collectAllStepPackages(flowSettings);
2322
+ const dependencies = {};
2323
+ for (const name of [...stepPackages].sort()) {
2324
+ if (name.startsWith(".") || name.startsWith("/")) continue;
2325
+ dependencies[name] = "*";
2326
+ }
2327
+ const sidecarPath = path11.join(outDir, "package.json");
2328
+ await fs10.writeJson(
2329
+ sidecarPath,
2330
+ {
2331
+ name: "walkeros-bundle",
2332
+ private: true,
2333
+ type: "module",
2334
+ dependencies
2335
+ },
2336
+ { spaces: 2 }
2337
+ );
2338
+ logger.debug(
2339
+ `nft-trace: copied ${result.copied} file(s); wrote ${sidecarPath}`
2340
+ );
2341
+ }
1959
2342
  function collectAllStepPackages(flowSettings) {
1960
2343
  const allPackages = /* @__PURE__ */ new Set();
1961
2344
  const sections = [
@@ -2082,8 +2465,8 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
2082
2465
  const localPath = packagePaths.get(packageName);
2083
2466
  if (!localPath) continue;
2084
2467
  try {
2085
- const pkgJsonPath = path10.join(localPath, "package.json");
2086
- const pkgJson = await fs9.readJSON(pkgJsonPath);
2468
+ const pkgJsonPath = path11.join(localPath, "package.json");
2469
+ const pkgJson = await fs10.readJSON(pkgJsonPath);
2087
2470
  const exports = pkgJson.exports;
2088
2471
  if (exports && typeof exports === "object" && "./dev" in exports) {
2089
2472
  const varName = `__dev_${packageNameToVariable(packageName)}`;
@@ -2369,7 +2752,8 @@ ${userCode}
2369
2752
  export { startFlow };`;
2370
2753
  }
2371
2754
  function generateServerEntry(stage1Path, dataPayload) {
2372
- return `import { startFlow, wireConfig } from '${stage1Path}';
2755
+ const stage1Specifier = toFileImportSpecifier(stage1Path);
2756
+ return `import { startFlow, wireConfig } from '${stage1Specifier}';
2373
2757
 
2374
2758
  const __configData = ${dataPayload};
2375
2759
 
@@ -2418,7 +2802,8 @@ function generateWebEntry(stage1Path, dataPayload, options = {}) {
2418
2802
  env.document = env.document ?? (typeof document !== 'undefined' ? document : undefined);
2419
2803
  }
2420
2804
  }` : "";
2421
- return `import { startFlow, wireConfig } from '${stage1Path}';
2805
+ const stage1Specifier = toFileImportSpecifier(stage1Path);
2806
+ return `import { startFlow, wireConfig } from '${stage1Specifier}';
2422
2807
 
2423
2808
  const __configData = ${dataPayload};
2424
2809
 
@@ -2505,7 +2890,8 @@ function generateWrapEntry(stage1Path, options = {}) {
2505
2890
  env.document = env.document ?? (typeof document !== 'undefined' ? document : undefined);
2506
2891
  }
2507
2892
  }` : "";
2508
- return `import { startFlow, wireConfig, __configData } from '${stage1Path}';
2893
+ const stage1Specifier = toFileImportSpecifier(stage1Path);
2894
+ return `import { startFlow, wireConfig, __configData } from '${stage1Specifier}';
2509
2895
 
2510
2896
  (async () => {${preflightBlock}
2511
2897
  const config = wireConfig(__configData);${envBlock}
@@ -2513,7 +2899,8 @@ function generateWrapEntry(stage1Path, options = {}) {
2513
2899
  })();`;
2514
2900
  }
2515
2901
  function generateWrapEntryServer(stage1Path) {
2516
- return `import { startFlow, wireConfig, __configData } from '${stage1Path}';
2902
+ const stage1Specifier = toFileImportSpecifier(stage1Path);
2903
+ return `import { startFlow, wireConfig, __configData } from '${stage1Specifier}';
2517
2904
 
2518
2905
  export default async function(context = {}) {
2519
2906
  const config = wireConfig(__configData);
@@ -2609,14 +2996,16 @@ var init_bundler = __esm({
2609
2996
  "use strict";
2610
2997
  init_config_classifier();
2611
2998
  init_package_manager();
2999
+ init_nft_trace();
2612
3000
  init_tmp();
3001
+ init_import_specifier();
2613
3002
  init_build_cache();
2614
3003
  VALID_JS_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
2615
3004
  }
2616
3005
  });
2617
3006
 
2618
3007
  // src/commands/bundle/targets.ts
2619
- function resolveTarget(target) {
3008
+ function resolveTarget2(target) {
2620
3009
  const preset = BUNDLE_TARGETS[target];
2621
3010
  if (!preset) {
2622
3011
  throw new Error(
@@ -2665,12 +3054,12 @@ var init_targets = __esm({
2665
3054
  });
2666
3055
 
2667
3056
  // src/commands/bundle/upload.ts
2668
- import fs10 from "fs-extra";
3057
+ import fs11 from "fs-extra";
2669
3058
  function sanitizeUrl(url) {
2670
3059
  return url.split("?")[0];
2671
3060
  }
2672
3061
  async function uploadBundleToUrl(filePath, url, timeoutMs = 3e4) {
2673
- const bundleContent = await fs10.readFile(filePath);
3062
+ const bundleContent = await fs11.readFile(filePath);
2674
3063
  const doUpload = async (attempt) => {
2675
3064
  const response = await fetch(url, {
2676
3065
  method: "PUT",
@@ -2727,50 +3116,17 @@ var init_stats = __esm({
2727
3116
  }
2728
3117
  });
2729
3118
 
2730
- // src/commands/bundle/dockerfile.ts
2731
- import path11 from "path";
2732
- import fs11 from "fs-extra";
2733
- function buildDockerfileContent(platform, includedFolders) {
2734
- const bundleFile = platform === "web" ? "walker.js" : "bundle.mjs";
2735
- const lines = [
2736
- "# Generated by walkeros CLI",
2737
- "FROM walkeros/flow:latest",
2738
- "",
2739
- `COPY ${bundleFile} /app/flow/${bundleFile}`
2740
- ];
2741
- for (const folder of includedFolders) {
2742
- const name = path11.basename(folder);
2743
- lines.push(`COPY ${name}/ /app/flow/${name}/`);
2744
- }
2745
- lines.push("", `ENV BUNDLE=/app/flow/${bundleFile}`, "", "EXPOSE 8080", "");
2746
- return lines.join("\n");
2747
- }
2748
- async function generateDockerfile(outputDir, platform, logger, customFile, includedFolders) {
2749
- const destPath = path11.join(outputDir, "Dockerfile");
2750
- if (customFile && await fs11.pathExists(customFile)) {
2751
- await fs11.copy(customFile, destPath);
2752
- logger.info(`Dockerfile: ${destPath} (copied from ${customFile})`);
2753
- return;
2754
- }
2755
- const dockerfile = buildDockerfileContent(platform, includedFolders || []);
2756
- await fs11.writeFile(destPath, dockerfile);
2757
- logger.info(`Dockerfile: ${destPath}`);
2758
- }
2759
- var init_dockerfile = __esm({
2760
- "src/commands/bundle/dockerfile.ts"() {
2761
- "use strict";
2762
- }
2763
- });
2764
-
2765
3119
  // src/commands/bundle/index.ts
2766
3120
  import path12 from "path";
2767
3121
  import fs12 from "fs-extra";
2768
- import { getPlatform as getPlatform2 } from "@walkeros/core";
2769
- function resolveOutputPath(output, buildOptions) {
3122
+ function resolveOutputPath(output, buildOptions, flowSubdir) {
2770
3123
  const resolved = path12.resolve(output);
3124
+ const filename = buildOptions.platform === "browser" ? "walker.js" : "flow.mjs";
3125
+ if (flowSubdir) {
3126
+ return path12.join(resolved, flowSubdir, filename);
3127
+ }
2771
3128
  const ext = path12.extname(resolved);
2772
3129
  if (output.endsWith("/") || output.endsWith(path12.sep) || !ext) {
2773
- const filename = buildOptions.platform === "browser" ? "walker.js" : "bundle.mjs";
2774
3130
  return path12.join(resolved, filename);
2775
3131
  }
2776
3132
  return resolved;
@@ -2834,7 +3190,11 @@ async function bundleCommand(options) {
2834
3190
  `url-bundle-${Date.now()}${ext}`
2835
3191
  );
2836
3192
  } else if (options.output) {
2837
- buildOptions.output = resolveOutputPath(options.output, buildOptions);
3193
+ buildOptions.output = resolveOutputPath(
3194
+ options.output,
3195
+ buildOptions,
3196
+ options.all ? flowName : void 0
3197
+ );
2838
3198
  } else {
2839
3199
  const ext = buildOptions.platform === "browser" ? ".js" : ".mjs";
2840
3200
  buildOptions.output = getTmpPath(void 0, "stdout-bundle" + ext);
@@ -2864,26 +3224,12 @@ async function bundleCommand(options) {
2864
3224
  const bundleContent = await fs12.readFile(buildOptions.output);
2865
3225
  await writeResult(bundleContent, {});
2866
3226
  if (process.stdout.isTTY) {
2867
- const defaultPath = buildOptions.platform === "browser" ? "./dist/walker.js" : "./dist/bundle.mjs";
3227
+ const defaultPath = buildOptions.platform === "browser" ? "./dist/walker.js" : "./dist/flow.mjs";
2868
3228
  logger.info(
2869
3229
  `Bundle written to stdout. Use -o ${defaultPath} to write to file.`
2870
3230
  );
2871
3231
  }
2872
3232
  }
2873
- if (options.dockerfile && options.output) {
2874
- const platform = getPlatform2(flowSettings);
2875
- if (platform) {
2876
- const outputDir = path12.dirname(buildOptions.output);
2877
- const customFile = typeof options.dockerfile === "string" ? options.dockerfile : void 0;
2878
- await generateDockerfile(
2879
- outputDir,
2880
- platform,
2881
- logger,
2882
- customFile,
2883
- buildOptions.include
2884
- );
2885
- }
2886
- }
2887
3233
  } catch (error) {
2888
3234
  const errorMessage = getErrorMessage(error);
2889
3235
  results.push({ flowName, success: false, error: errorMessage });
@@ -2951,7 +3297,7 @@ async function bundle(configOrPath, options = {}) {
2951
3297
  } else {
2952
3298
  effectiveTarget = "cdn";
2953
3299
  }
2954
- const preset = resolveTarget(effectiveTarget);
3300
+ const preset = resolveTarget2(effectiveTarget);
2955
3301
  if (options.buildOverrides?.skipWrapper !== void 0 && !options.target && process.env.WALKEROS_SUPPRESS_DEPRECATIONS !== "1") {
2956
3302
  console.warn(
2957
3303
  "[@walkeros/cli] buildOverrides.skipWrapper is deprecated. Pass `target: 'cdn' | 'cdn-skeleton' | 'runner' | 'simulate' | 'push'` instead. Set WALKEROS_SUPPRESS_DEPRECATIONS=1 to silence this warning."
@@ -2997,7 +3343,6 @@ var init_bundle = __esm({
2997
3343
  init_targets();
2998
3344
  init_upload();
2999
3345
  init_stats();
3000
- init_dockerfile();
3001
3346
  }
3002
3347
  });
3003
3348
 
@@ -3015,18 +3360,18 @@ import {
3015
3360
  writeFileSync as writeFileSync3,
3016
3361
  readFileSync as readFileSync2
3017
3362
  } from "fs";
3018
- import { join as join2 } from "path";
3363
+ import { join as join3 } from "path";
3019
3364
  function writeCache(cacheDir, bundlePath, configContent, version) {
3020
3365
  mkdirSync3(cacheDir, { recursive: true });
3021
- copyFileSync(bundlePath, join2(cacheDir, "bundle.mjs"));
3022
- writeFileSync3(join2(cacheDir, "config.json"), configContent, "utf-8");
3366
+ copyFileSync(bundlePath, join3(cacheDir, "flow.mjs"));
3367
+ writeFileSync3(join3(cacheDir, "config.json"), configContent, "utf-8");
3023
3368
  const meta = { version, timestamp: Date.now() };
3024
- writeFileSync3(join2(cacheDir, "meta.json"), JSON.stringify(meta), "utf-8");
3369
+ writeFileSync3(join3(cacheDir, "meta.json"), JSON.stringify(meta), "utf-8");
3025
3370
  }
3026
3371
  function readCache(cacheDir) {
3027
3372
  try {
3028
- const metaPath = join2(cacheDir, "meta.json");
3029
- const bundlePath = join2(cacheDir, "bundle.mjs");
3373
+ const metaPath = join3(cacheDir, "meta.json");
3374
+ const bundlePath = join3(cacheDir, "flow.mjs");
3030
3375
  if (!existsSync3(metaPath) || !existsSync3(bundlePath)) return null;
3031
3376
  const meta = JSON.parse(readFileSync2(metaPath, "utf-8"));
3032
3377
  return { bundlePath, version: meta.version };
@@ -3036,7 +3381,7 @@ function readCache(cacheDir) {
3036
3381
  }
3037
3382
  function readCacheConfig(cacheDir) {
3038
3383
  try {
3039
- const configPath = join2(cacheDir, "config.json");
3384
+ const configPath = join3(cacheDir, "config.json");
3040
3385
  if (!existsSync3(configPath)) return null;
3041
3386
  return readFileSync2(configPath, "utf-8");
3042
3387
  } catch {
@@ -3063,7 +3408,7 @@ async function prepareBundleForRun(configPath, options) {
3063
3408
  `run-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
3064
3409
  );
3065
3410
  await fs15.ensureDir(tempDir);
3066
- const tempPath = path16.join(tempDir, "bundle.mjs");
3411
+ const tempPath = path16.join(tempDir, "flow.mjs");
3067
3412
  await bundle(configPath, {
3068
3413
  cache: true,
3069
3414
  verbose: options.verbose,
@@ -3107,7 +3452,7 @@ import path15 from "path";
3107
3452
  import fs14 from "fs-extra";
3108
3453
  import {
3109
3454
  createIngest,
3110
- getPlatform as getPlatform4,
3455
+ getPlatform as getPlatform3,
3111
3456
  compileNext,
3112
3457
  resolveNext,
3113
3458
  isRouteArray,
@@ -3123,6 +3468,8 @@ import {
3123
3468
  } from "@walkeros/collector";
3124
3469
 
3125
3470
  // src/commands/push/overrides.ts
3471
+ init_parse_component_ref();
3472
+ var STEP_KINDS = ["source", "destination", "transformer"];
3126
3473
  function buildOverrides(flags, flowConfig) {
3127
3474
  const simulateFlags = flags.simulate ?? [];
3128
3475
  const mockFlags = flags.mock ?? [];
@@ -3217,32 +3564,22 @@ function buildOverrides(flags, flowConfig) {
3217
3564
  return overrides;
3218
3565
  }
3219
3566
  function parseStep(step) {
3220
- const parts = step.split(".");
3221
- if (parts.length < 2) {
3222
- throw new Error(
3223
- `Invalid step format: "${step}". Expected "source.NAME" or "destination.NAME"`
3224
- );
3225
- }
3226
- const prefix = parts[0];
3227
- if (prefix !== "source" && prefix !== "destination" && prefix !== "transformer") {
3228
- throw new Error(
3229
- `Unsupported step type: "${prefix}". Use "source", "destination", or "transformer"`
3230
- );
3231
- }
3232
- const name = parts[1];
3233
- if (!name) {
3234
- throw new Error(
3235
- `Invalid step format: "${step}". Missing name after "${prefix}."`
3236
- );
3237
- }
3238
- if (parts.length >= 4) {
3239
- const chainType = parts[2];
3567
+ const { prefix, name, rest } = parseComponentRef(step, {
3568
+ allowed: STEP_KINDS,
3569
+ messages: {
3570
+ invalidFormat: (input) => `Invalid step format: "${input}". Expected "source.NAME" or "destination.NAME"`,
3571
+ invalidPrefix: (p) => `Unsupported step type: "${p}". Use "source", "destination", or "transformer"`,
3572
+ missingName: (input, p) => `Invalid step format: "${input}". Missing name after "${p}."`
3573
+ }
3574
+ });
3575
+ if (rest.length >= 2) {
3576
+ const chainType = rest[0];
3240
3577
  if (chainType !== "before" && chainType !== "next") {
3241
3578
  throw new Error(
3242
3579
  `Invalid chain type: "${chainType}". Use "before" or "next"`
3243
3580
  );
3244
3581
  }
3245
- const transformerId = parts[3];
3582
+ const transformerId = rest[1];
3246
3583
  if (!transformerId) {
3247
3584
  throw new Error(
3248
3585
  `Invalid step format: "${step}". Missing transformer name after "${chainType}."`
@@ -3250,7 +3587,7 @@ function parseStep(step) {
3250
3587
  }
3251
3588
  return { type: prefix, name, chainType, transformerId };
3252
3589
  }
3253
- if (parts.length === 3) {
3590
+ if (rest.length === 1) {
3254
3591
  throw new Error(
3255
3592
  `Invalid step format: "${step}". Specify a transformer: "${step}.TRANSFORMER_NAME"`
3256
3593
  );
@@ -3358,7 +3695,7 @@ function installTimerInterception(options = {}) {
3358
3695
  if (options.domWindow && options.domWindow !== globalThis) {
3359
3696
  patchTarget(options.domWindow);
3360
3697
  }
3361
- const drainMicrotasks = () => new Promise((resolve4) => realSetTimeout(resolve4, 0));
3698
+ const drainMicrotasks = () => new Promise((resolve5) => realSetTimeout(resolve5, 0));
3362
3699
  async function flush(wallTimeout = 5e3) {
3363
3700
  const deadline = Date.now() + wallTimeout;
3364
3701
  const maxIterations = 100;
@@ -3614,7 +3951,7 @@ init_config();
3614
3951
  init_bundler();
3615
3952
  import path14 from "path";
3616
3953
  import fs13 from "fs-extra";
3617
- import { getPlatform as getPlatform3 } from "@walkeros/core";
3954
+ import { getPlatform as getPlatform2 } from "@walkeros/core";
3618
3955
  async function prepareFlow(input) {
3619
3956
  const logger = createCLILogger({
3620
3957
  silent: input.silent,
@@ -3625,7 +3962,7 @@ async function prepareFlow(input) {
3625
3962
  configPath: process.cwd(),
3626
3963
  flowName: input.flow
3627
3964
  });
3628
- const platform = getPlatform3(flowSettings);
3965
+ const platform = getPlatform2(flowSettings);
3629
3966
  const overrides = buildOverrides(
3630
3967
  { simulate: input.simulate, mock: input.mock },
3631
3968
  flowSettings
@@ -3646,7 +3983,7 @@ async function prepareFlow(input) {
3646
3983
  `push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
3647
3984
  );
3648
3985
  await fs13.ensureDir(tempDir);
3649
- const bundlePath = path14.join(tempDir, "bundle.mjs");
3986
+ const bundlePath = path14.join(tempDir, "flow.mjs");
3650
3987
  const pushBuildOptions = {
3651
3988
  ...buildOptions,
3652
3989
  output: bundlePath,
@@ -3945,7 +4282,7 @@ async function executeConfigPush(options, validatedEvent, logger, setTempDir, sn
3945
4282
  flowName: options.flow,
3946
4283
  logger
3947
4284
  });
3948
- const platform = getPlatform4(flowSettings);
4285
+ const platform = getPlatform3(flowSettings);
3949
4286
  const overrides = buildOverrides({ mock: options.mock }, flowSettings);
3950
4287
  logger.debug("Bundling flow configuration");
3951
4288
  const tempDir = getTmpPath(
@@ -3954,7 +4291,7 @@ async function executeConfigPush(options, validatedEvent, logger, setTempDir, sn
3954
4291
  );
3955
4292
  setTempDir(tempDir);
3956
4293
  await fs14.ensureDir(tempDir);
3957
- const tempPath = path15.join(tempDir, "bundle.mjs");
4294
+ const tempPath = path15.join(tempDir, "flow.mjs");
3958
4295
  const pushBuildOptions = {
3959
4296
  ...buildOptions,
3960
4297
  output: tempPath,
@@ -3985,7 +4322,7 @@ async function executeBundlePush(bundleContent, platform, validatedEvent, logger
3985
4322
  );
3986
4323
  setTempDir(tempDir);
3987
4324
  await fs14.ensureDir(tempDir);
3988
- const tempPath = path15.join(tempDir, "bundle.mjs");
4325
+ const tempPath = path15.join(tempDir, "flow.mjs");
3989
4326
  await fs14.writeFile(tempPath, bundleContent, "utf8");
3990
4327
  logger.debug(`Bundle written to: ${tempPath}`);
3991
4328
  logger.debug(
@@ -4417,21 +4754,21 @@ init_auth();
4417
4754
  import path17 from "path";
4418
4755
  import { writeFileSync as writeFileSync5 } from "fs";
4419
4756
  import { homedir as homedir2 } from "os";
4420
- import { join as join4 } from "path";
4757
+ import { join as join5 } from "path";
4421
4758
 
4422
4759
  // src/runtime/resolve-bundle.ts
4423
4760
  init_stdin();
4424
4761
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
4425
- import { dirname } from "path";
4762
+ import { dirname as dirname2 } from "path";
4426
4763
  function getDefaultWritePath() {
4427
- if (existsSync2("/app/flow")) return "/app/flow/bundle.mjs";
4428
- return "/tmp/walkeros-bundle.mjs";
4764
+ if (existsSync2("/app/flow")) return "/app/flow/flow.mjs";
4765
+ return "/tmp/walkeros-flow.mjs";
4429
4766
  }
4430
4767
  function isUrl2(value) {
4431
4768
  return value.startsWith("http://") || value.startsWith("https://");
4432
4769
  }
4433
4770
  function writeBundleToDisk(writePath, content) {
4434
- const dir = dirname(writePath);
4771
+ const dir = dirname2(writePath);
4435
4772
  if (!existsSync2(dir)) {
4436
4773
  mkdirSync2(dir, { recursive: true });
4437
4774
  }
@@ -4665,7 +5002,7 @@ import fs16 from "fs-extra";
4665
5002
  // src/runtime/health-server.ts
4666
5003
  import http from "http";
4667
5004
  function createHealthServer(port, logger) {
4668
- return new Promise((resolve4, reject) => {
5005
+ return new Promise((resolve5, reject) => {
4669
5006
  let flowHandler = null;
4670
5007
  const server = http.createServer((req, res) => {
4671
5008
  if (req.url === "/health" && req.method === "GET") {
@@ -4692,7 +5029,7 @@ function createHealthServer(port, logger) {
4692
5029
  server.headersTimeout = 1e4;
4693
5030
  server.listen(port, "0.0.0.0", () => {
4694
5031
  logger.info(`Health server listening on port ${port}`);
4695
- resolve4({
5032
+ resolve5({
4696
5033
  server,
4697
5034
  setFlowHandler(handler) {
4698
5035
  flowHandler = handler;
@@ -4707,13 +5044,13 @@ function createHealthServer(port, logger) {
4707
5044
  }
4708
5045
 
4709
5046
  // src/runtime/runner.ts
4710
- import { resolve as resolve2, dirname as dirname2 } from "path";
5047
+ import { resolve as resolve3, dirname as dirname3 } from "path";
4711
5048
 
4712
5049
  // src/runtime/load-bundle.ts
4713
- import { resolve } from "path";
5050
+ import { resolve as resolve2 } from "path";
4714
5051
  import { pathToFileURL as pathToFileURL2 } from "url";
4715
5052
  async function loadBundle(file, context2, logger) {
4716
- const absolutePath = resolve(file);
5053
+ const absolutePath = resolve2(file);
4717
5054
  const fileUrl = pathToFileURL2(absolutePath).href;
4718
5055
  logger?.debug?.(`Importing bundle: ${absolutePath}`);
4719
5056
  const module = await import(`${fileUrl}?t=${Date.now()}`);
@@ -4737,8 +5074,8 @@ async function loadBundle(file, context2, logger) {
4737
5074
 
4738
5075
  // src/runtime/runner.ts
4739
5076
  async function loadFlow(file, config, logger, loggerConfig, healthServer) {
4740
- const absolutePath = resolve2(file);
4741
- const flowDir = dirname2(absolutePath);
5077
+ const absolutePath = resolve3(file);
5078
+ const flowDir = dirname3(absolutePath);
4742
5079
  process.chdir(flowDir);
4743
5080
  const flowContext = {
4744
5081
  ...config,
@@ -4787,14 +5124,14 @@ import { randomBytes } from "crypto";
4787
5124
  // src/version.ts
4788
5125
  import { readFileSync as readFileSync3 } from "fs";
4789
5126
  import { fileURLToPath } from "url";
4790
- import { dirname as dirname3, join as join3 } from "path";
5127
+ import { dirname as dirname4, join as join4 } from "path";
4791
5128
  var versionFilename = fileURLToPath(import.meta.url);
4792
- var versionDirname = dirname3(versionFilename);
5129
+ var versionDirname = dirname4(versionFilename);
4793
5130
  function findPackageJson() {
4794
5131
  const paths = [
4795
- join3(versionDirname, "../package.json"),
5132
+ join4(versionDirname, "../package.json"),
4796
5133
  // dist/ or src/
4797
- join3(versionDirname, "../../package.json")
5134
+ join4(versionDirname, "../../package.json")
4798
5135
  // src/core/ (not used, but safe)
4799
5136
  ];
4800
5137
  for (const p of paths) {
@@ -5156,8 +5493,8 @@ async function injectSecrets(api, logger) {
5156
5493
  // src/commands/run/index.ts
5157
5494
  function defaultCacheDir() {
5158
5495
  const xdgCache = process.env.XDG_CACHE_HOME;
5159
- const base = xdgCache || join4(homedir2(), ".cache");
5160
- return join4(base, "walkeros");
5496
+ const base = xdgCache || join5(homedir2(), ".cache");
5497
+ return join5(base, "walkeros");
5161
5498
  }
5162
5499
  async function lazyPrepareBundleForRun(configPath, options) {
5163
5500
  const { prepareBundleForRun: prepareBundleForRun2 } = await Promise.resolve().then(() => (init_utils3(), utils_exports));
@@ -5871,7 +6208,7 @@ function validateMapping(input) {
5871
6208
  // src/commands/validate/validators/entry.ts
5872
6209
  import Ajv from "ajv";
5873
6210
  import { fetchPackageSchema } from "@walkeros/core";
5874
- var CLIENT_HEADER = "walkeros-cli/4.0.0";
6211
+ var CLIENT_HEADER = "walkeros-cli/4.1.0-next-1778155282668";
5875
6212
  var SECTIONS = ["destinations", "sources", "transformers"];
5876
6213
  function resolveEntry(path19, flowConfig) {
5877
6214
  const flows = flowConfig.flows;
@@ -7018,7 +7355,7 @@ async function getDeploymentCommand(flowId, options) {
7018
7355
  // src/commands/deployments/index.ts
7019
7356
  init_auth();
7020
7357
  init_http();
7021
- import { getPlatform as getPlatform5 } from "@walkeros/core";
7358
+ import { getPlatform as getPlatform4 } from "@walkeros/core";
7022
7359
  init_cli_logger();
7023
7360
  init_output();
7024
7361
  init_loader();
@@ -7187,7 +7524,7 @@ async function createDeployCommand(config, options) {
7187
7524
  const result2 = await loadFlowConfig(config, {
7188
7525
  flowName: options.flow
7189
7526
  });
7190
- type = getPlatform5(result2.flowSettings);
7527
+ type = getPlatform4(result2.flowSettings);
7191
7528
  }
7192
7529
  const deployment = await createDeployment({
7193
7530
  type,
@@ -7284,14 +7621,14 @@ async function feedbackCommand(text) {
7284
7621
  }
7285
7622
  }
7286
7623
  function promptUser(question) {
7287
- return new Promise((resolve4) => {
7624
+ return new Promise((resolve5) => {
7288
7625
  const rl = createInterface({
7289
7626
  input: process.stdin,
7290
7627
  output: process.stderr
7291
7628
  });
7292
7629
  rl.question(question, (answer) => {
7293
7630
  rl.close();
7294
- resolve4(answer);
7631
+ resolve5(answer);
7295
7632
  });
7296
7633
  });
7297
7634
  }
@@ -7373,7 +7710,7 @@ init_bundle();
7373
7710
  // src/commands/bundle/wrap.ts
7374
7711
  init_bundler();
7375
7712
  import * as path18 from "path";
7376
- import * as os2 from "os";
7713
+ import * as os3 from "os";
7377
7714
  import fs17 from "fs-extra";
7378
7715
  import * as esbuild2 from "esbuild";
7379
7716
  async function wrapSkeleton(options) {
@@ -7408,8 +7745,8 @@ async function wrapSkeleton(options) {
7408
7745
  ...options.previewScope ? { previewScope: options.previewScope } : {},
7409
7746
  platform
7410
7747
  }) : generateWrapEntryServer(absoluteSkeletonPath);
7411
- const entryDir = await fs17.mkdtemp(path18.join(os2.tmpdir(), "walkeros-wrap-"));
7412
- const entryPath = path18.join(entryDir, "entry.mjs");
7748
+ const entryDir = await fs17.mkdtemp(path18.join(os3.tmpdir(), "walkeros-wrap-"));
7749
+ const entryPath = path18.join(entryDir, "flow.mjs");
7413
7750
  try {
7414
7751
  await fs17.writeFile(entryPath, entryText);
7415
7752
  await fs17.ensureDir(path18.dirname(outputPath));
@@ -7671,12 +8008,12 @@ function buildInitConfig(input) {
7671
8008
  }
7672
8009
 
7673
8010
  // src/telemetry/environment.ts
7674
- import * as os3 from "os";
8011
+ import * as os4 from "os";
7675
8012
  function getEnvironment() {
7676
8013
  const locale = Intl.DateTimeFormat().resolvedOptions();
7677
8014
  return {
7678
8015
  os: process.platform,
7679
- osVersion: os3.release(),
8016
+ osVersion: os4.release(),
7680
8017
  node: process.version,
7681
8018
  language: locale.locale,
7682
8019
  timezone: locale.timeZone