peachsim 0.1.2406 → 0.1.2409

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 (107) hide show
  1. package/cli/agent-note.ts +231 -0
  2. package/cli/cloud-client.ts +8 -3
  3. package/cli/cloud-dispatch.ts +1 -1
  4. package/cli/command-agent.ts +122 -0
  5. package/cli/commands/agent.ts +29 -26
  6. package/cli/commands/stream.ts +11 -7
  7. package/cli/main.ts +16 -2
  8. package/cli/outbound-endpoints.ts +15 -0
  9. package/cli/ws-bridge.ts +4 -1
  10. package/dist-lib/agent-daemon-client.cjs +23 -3
  11. package/dist-lib/agent-events.cjs +1 -1
  12. package/dist-lib/attached-projects.cjs +1 -1
  13. package/dist-lib/auth/shared-session.cjs +1 -1
  14. package/dist-lib/backend-origin.cjs +1 -1
  15. package/dist-lib/beta.cjs +1 -1
  16. package/dist-lib/beta.mjs +1 -1
  17. package/dist-lib/bridge-constants.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.mjs +1 -1
  20. package/dist-lib/bridge-contract.cjs +1 -1
  21. package/dist-lib/bridge-contract.mjs +1 -1
  22. package/dist-lib/bundle-channel.cjs +205 -62
  23. package/dist-lib/capture-contract.cjs +1 -1
  24. package/dist-lib/capture-contract.mjs +1 -1
  25. package/dist-lib/cloud-contract.cjs +20 -1
  26. package/dist-lib/cloud-contract.mjs +18 -1
  27. package/dist-lib/cloud-test-args.cjs +1 -1
  28. package/dist-lib/cloud-test-args.mjs +1 -1
  29. package/dist-lib/cloud.cjs +1 -1
  30. package/dist-lib/cloud.mjs +1 -1
  31. package/dist-lib/config.cjs +1 -1
  32. package/dist-lib/config.mjs +1 -1
  33. package/dist-lib/detox/index.cjs +1630 -1513
  34. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  35. package/dist-lib/expo-swift-bundle.cjs +203 -60
  36. package/dist-lib/expo-swift-metadata.cjs +1 -1
  37. package/dist-lib/expo-swift-metadata.mjs +1 -1
  38. package/dist-lib/home-paths.cjs +1 -1
  39. package/dist-lib/host/bridge-host.cjs +394 -102
  40. package/dist-lib/host/fetch-proxy-handler.cjs +5 -5
  41. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  42. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  43. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  44. package/dist-lib/host/websocket-proxy.cjs +1 -1
  45. package/dist-lib/index.cjs +392 -272
  46. package/dist-lib/jump-to-source-babel.cjs +1 -1
  47. package/dist-lib/jump-to-source-native.cjs +1 -1
  48. package/dist-lib/kotlin-host.cjs +1 -1
  49. package/dist-lib/menu.cjs +1 -1
  50. package/dist-lib/menu.mjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  53. package/dist-lib/metro-production-bundle.cjs +1 -1
  54. package/dist-lib/metro-production-bundle.mjs +1 -1
  55. package/dist-lib/metro.cjs +5 -5
  56. package/dist-lib/native-app-identity-project.cjs +3 -3
  57. package/dist-lib/native-app-identity-project.mjs +3 -3
  58. package/dist-lib/native-app-identity.cjs +1 -1
  59. package/dist-lib/native-app-identity.mjs +1 -1
  60. package/dist-lib/native-firebase-metadata.cjs +1 -1
  61. package/dist-lib/native-firebase-metadata.mjs +1 -1
  62. package/dist-lib/pdfium-raster.cjs +1 -1
  63. package/dist-lib/pdfium-raster.mjs +1 -1
  64. package/dist-lib/plist.cjs +1 -1
  65. package/dist-lib/plist.mjs +1 -1
  66. package/dist-lib/profiles.cjs +1 -1
  67. package/dist-lib/public-brand.cjs +1 -1
  68. package/dist-lib/public-origins-lib-esm.json +24 -24
  69. package/dist-lib/public-origins-lib.json +70 -60
  70. package/dist-lib/react-native-host-modules.cjs +1 -1
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/reap-browser.cjs +1 -1
  73. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  74. package/dist-lib/sdk.cjs +1 -1
  75. package/dist-lib/sdk.mjs +1 -1
  76. package/dist-lib/skills.cjs +1199 -821
  77. package/dist-lib/swift-compile.cjs +197 -55
  78. package/dist-lib/swift-compile.mjs +197 -55
  79. package/dist-lib/swift-package.cjs +1 -1
  80. package/dist-lib/swift-package.mjs +1 -1
  81. package/dist-lib/swift-submit.cjs +1 -1
  82. package/dist-lib/swift-submit.mjs +1 -1
  83. package/dist-lib/swift-toolchain.cjs +1 -1
  84. package/dist-lib/swift.cjs +1 -1
  85. package/dist-lib/vite-swift.cjs +213 -58
  86. package/dist-lib/vite.cjs +5 -5
  87. package/dist-lib/worklet-executable.cjs +1 -1
  88. package/dist-lib/worklet-executable.mjs +1 -1
  89. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
  90. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  91. package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +7 -0
  92. package/kotlin/sdk.tar.gz +0 -0
  93. package/package.json +1 -1
  94. package/runtime-companion.json +1 -1
  95. package/skills/peach-setup/SKILL.md +8 -3
  96. package/src/agent-daemon-client.ts +35 -2
  97. package/src/agent-prompt.ts +68 -0
  98. package/src/bridge-contract.ts +4 -0
  99. package/src/canvas-agent-note-delivery.ts +83 -0
  100. package/src/cloud-contract.ts +30 -0
  101. package/src/host/agent-host.ts +128 -18
  102. package/src/swift-compile.ts +124 -66
  103. package/src/swift-host.ts +2 -1
  104. package/src/swift-objc-import.ts +99 -0
  105. package/src/swift-packages.ts +1 -0
  106. package/src/swift-shared-sdk.ts +2 -1
  107. package/src/xcode-header-search.ts +33 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2406 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2409 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -30376,12 +30376,12 @@ function runtimeVersionHostname(version2) {
30376
30376
  if (!labels) throw new Error(`invalid Peach runtime version: ${version2}`);
30377
30377
  return `${labels.join(".")}${RUNTIME_VERSION_HOSTNAME_SUFFIX}`;
30378
30378
  }
30379
- function isRuntimeVersionHostname(hostname) {
30380
- return hostname.toLowerCase().endsWith(RUNTIME_VERSION_HOSTNAME_SUFFIX);
30379
+ function isRuntimeVersionHostname(hostname2) {
30380
+ return hostname2.toLowerCase().endsWith(RUNTIME_VERSION_HOSTNAME_SUFFIX);
30381
30381
  }
30382
- function runtimeVersionFromHostname(hostname) {
30383
- if (!isRuntimeVersionHostname(hostname)) return null;
30384
- const labels = hostname.slice(0, -RUNTIME_VERSION_HOSTNAME_SUFFIX.length).split(".");
30382
+ function runtimeVersionFromHostname(hostname2) {
30383
+ if (!isRuntimeVersionHostname(hostname2)) return null;
30384
+ const labels = hostname2.slice(0, -RUNTIME_VERSION_HOSTNAME_SUFFIX.length).split(".");
30385
30385
  if (labels.length === 0 || labels.some((label) => !/^[0-9a-f]{1,60}$/i.test(label))) {
30386
30386
  return null;
30387
30387
  }
@@ -30399,9 +30399,9 @@ function resolveInstalledRuntimeRoot(version2) {
30399
30399
  if (!import_fs.default.existsSync(import_path.default.join(dir, "index.html"))) return null;
30400
30400
  return dir;
30401
30401
  }
30402
- function resolveRuntimeRootForHostname(hostname) {
30403
- if (!isRuntimeVersionHostname(hostname)) return resolveActiveRuntimeRoot();
30404
- const version2 = runtimeVersionFromHostname(hostname);
30402
+ function resolveRuntimeRootForHostname(hostname2) {
30403
+ if (!isRuntimeVersionHostname(hostname2)) return resolveActiveRuntimeRoot();
30404
+ const version2 = runtimeVersionFromHostname(hostname2);
30405
30405
  return version2 ? resolveInstalledRuntimeRoot(version2) : null;
30406
30406
  }
30407
30407
  function sendFileWithRanges(req, res, filePath, total, headers) {
@@ -31115,8 +31115,8 @@ function swiftNativeTargetsRefusal(value) {
31115
31115
  const products = field2("productHeaders");
31116
31116
  const inputPath = (value2) => typeof value2 === "string" && value2.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) && isSwiftResourcePath(value2.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1));
31117
31117
  const deployment = field2("deploymentTarget");
31118
- const targetName = field2("name");
31119
- if (typeof targetName !== "string" || targetName.length === 0 || targetName.length > 4096 || targetName.includes("\0") || targetName.includes("/") || targetName.includes("\\") || targetName === "." || targetName === "..")
31118
+ const targetName2 = field2("name");
31119
+ if (typeof targetName2 !== "string" || targetName2.length === 0 || targetName2.length > 4096 || targetName2.includes("\0") || targetName2.includes("/") || targetName2.includes("\\") || targetName2 === "." || targetName2 === "..")
31120
31120
  return at("name");
31121
31121
  if (!(deployment === null || typeof deployment === "string" && /^\d+(?:\.\d+){0,2}$/.test(deployment)))
31122
31122
  return at("deploymentTarget");
@@ -33722,8 +33722,8 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33722
33722
  }
33723
33723
  return deps;
33724
33724
  };
33725
- const admitTextualIncludes = (root, targetName, targetObj, searchRoots) => {
33726
- const prefix = `${targetPath(targetName)}/upstream/`;
33725
+ const admitTextualIncludes = (root, targetName2, targetObj, searchRoots) => {
33726
+ const prefix = `${targetPath(targetName2)}/upstream/`;
33727
33727
  const queue2 = Object.keys(result.files).filter((key2) => key2.startsWith(prefix));
33728
33728
  const scanned = /* @__PURE__ */ new Set();
33729
33729
  const excludes = new Set(targetObj.exclude ?? []);
@@ -33782,22 +33782,22 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33782
33782
  for (const node of allModules) {
33783
33783
  const module2 = node.provider;
33784
33784
  const config = node.config;
33785
- const targetName = nitroProviderTarget(module2);
33786
- const targetObj = nodeTargets.get(targetName);
33785
+ const targetName2 = nitroProviderTarget(module2);
33786
+ const targetObj = nodeTargets.get(targetName2);
33787
33787
  const podName = node.podspec.podName ?? config.swiftModule ?? module2.name;
33788
33788
  const searchRoots = node.podspec.headerSearchPaths;
33789
33789
  for (const dir of searchRoots) searchRootDirs.add(dir);
33790
- const implementationHeaders = import_node_fs21.default.existsSync(import_node_path17.default.join(module2.root, "cpp")) ? collect(module2.root, "cpp", targetName, podName) : /* @__PURE__ */ new Map();
33790
+ const implementationHeaders = import_node_fs21.default.existsSync(import_node_path17.default.join(module2.root, "cpp")) ? collect(module2.root, "cpp", targetName2, podName) : /* @__PURE__ */ new Map();
33791
33791
  for (const dir of searchRoots.filter(
33792
33792
  (dir2) => dir2 !== "cpp" && !dir2.startsWith("cpp/") && dir2 !== "ios" && !dir2.startsWith("ios/") && !searchRoots.some((other) => other !== dir2 && dir2.startsWith(`${other}/`))
33793
33793
  )) {
33794
- collect(module2.root, dir, targetName, podName);
33794
+ collect(module2.root, dir, targetName2, podName);
33795
33795
  }
33796
33796
  if (import_node_fs21.default.existsSync(import_node_path17.default.join(module2.root, "ios"))) {
33797
33797
  const iosCollected = collect(
33798
33798
  module2.root,
33799
33799
  "ios",
33800
- targetName,
33800
+ targetName2,
33801
33801
  podName,
33802
33802
  /* @__PURE__ */ new Set(["Tests"]),
33803
33803
  () => true,
@@ -33805,24 +33805,24 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33805
33805
  );
33806
33806
  if (config.swiftModule) {
33807
33807
  const objcHeaders = [...iosCollected.entries()].filter(
33808
- ([name3, original]) => name3.endsWith(".h") && Object.hasOwn(result.files, `${targetPath(targetName)}/include/${name3}`) && /(?:@(?:interface|protocol)\b|\b(?:NS_(?:ENUM|OPTIONS)|FOUNDATION_EXPORT)\b)/.test(
33808
+ ([name3, original]) => name3.endsWith(".h") && Object.hasOwn(result.files, `${targetPath(targetName2)}/include/${name3}`) && /(?:@(?:interface|protocol)\b|\b(?:NS_(?:ENUM|OPTIONS)|FOUNDATION_EXPORT)\b)/.test(
33809
33809
  result.files[original] ?? ""
33810
33810
  )
33811
33811
  ).map(([name3]) => name3);
33812
- if (objcHeaders.length > 0) iosObjcHeadersByTarget.set(targetName, objcHeaders);
33812
+ if (objcHeaders.length > 0) iosObjcHeadersByTarget.set(targetName2, objcHeaders);
33813
33813
  }
33814
33814
  }
33815
- admitTextualIncludes(module2.root, targetName, targetObj, searchRoots);
33815
+ admitTextualIncludes(module2.root, targetName2, targetObj, searchRoots);
33816
33816
  const viewsDir = import_node_path17.default.join(module2.root, "nitrogen/generated/shared/c++/views");
33817
33817
  const viewHeaders = import_node_fs21.default.existsSync(viewsDir) ? import_node_fs21.default.readdirSync(viewsDir).filter((file) => /\.(?:h|hh|hpp|hxx)$/.test(file)) : [];
33818
- const upstreamPrefix = `${targetPath(targetName)}/upstream/`;
33818
+ const upstreamPrefix = `${targetPath(targetName2)}/upstream/`;
33819
33819
  const needsViews = viewHeaders.length > 0 && Object.entries(result.files).some(
33820
33820
  ([key2, text6]) => (key2.startsWith(`${upstreamPrefix}cpp/`) || key2.startsWith(`${upstreamPrefix}ios/`)) && viewHeaders.some((header) => text6.includes(header))
33821
33821
  );
33822
33822
  collect(
33823
33823
  module2.root,
33824
33824
  "nitrogen/generated/shared/c++",
33825
- targetName,
33825
+ targetName2,
33826
33826
  podName,
33827
33827
  needsViews ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set(["views"])
33828
33828
  );
@@ -33833,7 +33833,7 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33833
33833
  `${module2.root}: missing C++ implementation header ${entry.implementation}.hpp`
33834
33834
  );
33835
33835
  }
33836
- collect(module2.root, "nitrogen/generated/ios", targetName, podName);
33836
+ collect(module2.root, "nitrogen/generated/ios", targetName2, podName);
33837
33837
  if (config.swiftModule) {
33838
33838
  const companionDeps = collectCompanionPods(node);
33839
33839
  const peerModuleDeps = node.peerRoots.flatMap((peerRoot) => {
@@ -33844,7 +33844,7 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33844
33844
  ];
33845
33845
  });
33846
33846
  const packageSwift = target(config.swiftModule, [
33847
- targetName,
33847
+ targetName2,
33848
33848
  "NitroModules",
33849
33849
  .../* @__PURE__ */ new Set([...peerModuleDeps, ...companionDeps])
33850
33850
  ]);
@@ -33870,7 +33870,7 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33870
33870
  );
33871
33871
  add2(
33872
33872
  `${targetPath(config.swiftModule)}/PeachNitroExports.swift`,
33873
- `@_exported import ${targetName}
33873
+ `@_exported import ${targetName2}
33874
33874
  `
33875
33875
  );
33876
33876
  }
@@ -33878,21 +33878,21 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33878
33878
  const dependencyHeader = nitroDependencyReader(reactNative.version, reactNative.root);
33879
33879
  const admitted = /* @__PURE__ */ new Set();
33880
33880
  const dependencyTrees = /* @__PURE__ */ new Set();
33881
- const scan3 = (targetName, text6, includer) => {
33881
+ const scan3 = (targetName2, text6, includer) => {
33882
33882
  for (const [, quote, name3] of text6.matchAll(
33883
33883
  /^\s*#\s*include\s*([<"])([^>"\n]+)[>"]/gm
33884
33884
  )) {
33885
33885
  const relative6 = quote === '"' && includer ? [import_node_path17.default.posix.normalize(import_node_path17.default.posix.join(import_node_path17.default.posix.dirname(includer), name3))] : [];
33886
- for (const include of [...relative6, name3]) if (admit(targetName, include)) break;
33886
+ for (const include of [...relative6, name3]) if (admit(targetName2, include)) break;
33887
33887
  }
33888
33888
  };
33889
- const admit = (targetName, include) => {
33890
- const key2 = `${targetName}\0${include}`;
33889
+ const admit = (targetName2, include) => {
33890
+ const key2 = `${targetName2}\0${include}`;
33891
33891
  if (admitted.has(key2)) return true;
33892
33892
  const header = dependencyHeader(include);
33893
33893
  if (!header) return false;
33894
33894
  admitted.add(key2);
33895
- const original = `${targetPath(targetName)}/include/${include}`;
33895
+ const original = `${targetPath(targetName2)}/include/${include}`;
33896
33896
  add2(original, header.text);
33897
33897
  result.sources.push({
33898
33898
  file: original,
@@ -33900,8 +33900,8 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33900
33900
  sha256: header.sha256,
33901
33901
  ...header.derivation && { derivation: header.derivation }
33902
33902
  });
33903
- scan3(targetName, header.text, include);
33904
- const tree2 = `${targetName}\0${header.name}`;
33903
+ scan3(targetName2, header.text, include);
33904
+ const tree2 = `${targetName2}\0${header.name}`;
33905
33905
  if (!dependencyTrees.has(tree2)) {
33906
33906
  dependencyTrees.add(tree2);
33907
33907
  for (const name3 of nitroDependencyIncludes(
@@ -33909,15 +33909,15 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
33909
33909
  reactNative.root,
33910
33910
  header.name
33911
33911
  ))
33912
- admit(targetName, name3);
33912
+ admit(targetName2, name3);
33913
33913
  }
33914
33914
  return true;
33915
33915
  };
33916
33916
  for (const node of allModules) {
33917
- const targetName = nitroProviderTarget(node.provider);
33917
+ const targetName2 = nitroProviderTarget(node.provider);
33918
33918
  for (const [file, text6] of Object.entries(result.files))
33919
- if (file.startsWith(`${targetPath(targetName)}/upstream/`))
33920
- scan3(targetName, text6, null);
33919
+ if (file.startsWith(`${targetPath(targetName2)}/upstream/`))
33920
+ scan3(targetName2, text6, null);
33921
33921
  }
33922
33922
  add2(
33923
33923
  `${targetPath(jsiTarget)}/include/module.modulemap`,
@@ -34030,11 +34030,11 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
34030
34030
  for (const node of allModules) {
34031
34031
  const module2 = node.provider;
34032
34032
  const config = node.config;
34033
- const targetName = nitroProviderTarget(module2);
34034
- const iosObjcHeaders = iosObjcHeadersByTarget.get(targetName) ?? [];
34033
+ const targetName2 = nitroProviderTarget(module2);
34034
+ const iosObjcHeaders = iosObjcHeadersByTarget.get(targetName2) ?? [];
34035
34035
  if (iosObjcHeaders.length > 0) {
34036
34036
  add2(
34037
- `${targetPath(targetName)}/include/PeachPodObjCUmbrella.h`,
34037
+ `${targetPath(targetName2)}/include/PeachPodObjCUmbrella.h`,
34038
34038
  [
34039
34039
  "#pragma once",
34040
34040
  "#ifdef __OBJC__",
@@ -34052,8 +34052,8 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
34052
34052
  ...iosObjcHeaders.length > 0 ? ['header "PeachPodObjCUmbrella.h"'] : []
34053
34053
  ];
34054
34054
  add2(
34055
- `${targetPath(targetName)}/include/module.modulemap`,
34056
- `module ${targetName} { ${modulemapHeaders.length > 0 ? `${modulemapHeaders.join(" ")} ` : ""}export * }
34055
+ `${targetPath(targetName2)}/include/module.modulemap`,
34056
+ `module ${targetName2} { ${modulemapHeaders.length > 0 ? `${modulemapHeaders.join(" ")} ` : ""}export * }
34057
34057
  `
34058
34058
  );
34059
34059
  if (!node.registered) continue;
@@ -34066,7 +34066,7 @@ function collectNitroSources(options, nativeSourceKeys, sourceRoot) {
34066
34066
  extern "C" void ${registration.symbol}();
34067
34067
  `);
34068
34068
  add2(
34069
- `${targetPath(targetName)}/PeachNitroRegistration.cpp`,
34069
+ `${targetPath(targetName2)}/PeachNitroRegistration.cpp`,
34070
34070
  [
34071
34071
  '#include "PeachNitroRegistration.hpp"',
34072
34072
  "#include <NitroModules/HybridObjectRegistry.hpp>",
@@ -36464,24 +36464,24 @@ var init_app_config = __esm({
36464
36464
  });
36465
36465
 
36466
36466
  // src/backend-origin.ts
36467
- function normalizeHostname(hostname) {
36468
- return hostname.replace(/^\[|\]$/g, "").toLowerCase();
36467
+ function normalizeHostname(hostname2) {
36468
+ return hostname2.replace(/^\[|\]$/g, "").toLowerCase();
36469
36469
  }
36470
- function buildLoopbackProbeBaseUrl(protocol, hostname, port) {
36471
- const normalizedHostname = normalizeHostname(hostname);
36470
+ function buildLoopbackProbeBaseUrl(protocol, hostname2, port) {
36471
+ const normalizedHostname = normalizeHostname(hostname2);
36472
36472
  const urlHost = normalizedHostname.includes(":") ? `[${normalizedHostname}]` : normalizedHostname;
36473
36473
  return `${protocol}//${urlHost}:${port}`;
36474
36474
  }
36475
- function isLoopbackHost(hostname) {
36476
- const normalized = normalizeHostname(hostname);
36475
+ function isLoopbackHost(hostname2) {
36476
+ const normalized = normalizeHostname(hostname2);
36477
36477
  return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
36478
36478
  }
36479
36479
  function isTrustedBridgeRequest(headers) {
36480
36480
  const origin = headers.origin;
36481
36481
  if (origin === void 0) return true;
36482
36482
  try {
36483
- const { hostname, host: host2 } = new NativeURL(String(origin));
36484
- return isLoopbackHost(hostname) || [headers.host, headers[":authority"], headers["x-forwarded-host"]].some(
36483
+ const { hostname: hostname2, host: host2 } = new NativeURL(String(origin));
36484
+ return isLoopbackHost(hostname2) || [headers.host, headers[":authority"], headers["x-forwarded-host"]].some(
36485
36485
  (value) => typeof value === "string" && value.toLowerCase() === host2
36486
36486
  );
36487
36487
  } catch {
@@ -36500,8 +36500,8 @@ function buildBrowserAssetProxyUrl(targetUrl) {
36500
36500
  const proxyPath = isLoopbackHost(new NativeURL(targetUrl).hostname) ? "/__bundle-proxy" : "/__fetch-proxy";
36501
36501
  return `${proxyPath}?url=${encodeURIComponent(targetUrl)}`;
36502
36502
  }
36503
- function isContrastBackendHost(hostname) {
36504
- const normalized = normalizeHostname(hostname);
36503
+ function isContrastBackendHost(hostname2) {
36504
+ const normalized = normalizeHostname(hostname2);
36505
36505
  return isLoopbackHost(normalized) || normalized === "contrast.dev" || normalized.endsWith(".contrast.dev") || normalized === "peachsim.com" || normalized === "www.peachsim.com" || normalized === PEACHSIM_NATIVE_HOST;
36506
36506
  }
36507
36507
  function resolveContrastBackendOrigin(currentOrigin, search) {
@@ -37397,14 +37397,14 @@ function canonicalLabel(label, from) {
37397
37397
  const { repo, pkg } = splitLabel(from);
37398
37398
  return `${repo ? `@@${repo}` : ""}//${pkg}:${label.replace(/^:/, "")}`;
37399
37399
  }
37400
- function readBazelAppTarget(buildFile, targetName, configurationName, options = {}) {
37401
- if (!targetName)
37400
+ function readBazelAppTarget(buildFile, targetName2, configurationName, options = {}) {
37401
+ if (!targetName2)
37402
37402
  throw new Error(
37403
37403
  `${buildFile}: pass --target with the ios_application the bazel package builds`
37404
37404
  );
37405
37405
  const root = import_node_fs31.default.realpathSync.native(workspaceRoot(import_node_fs31.default.realpathSync.native(buildFile)));
37406
37406
  const pkg = import_node_path27.default.relative(root, import_node_path27.default.dirname(import_node_fs31.default.realpathSync.native(buildFile)));
37407
- const label = `//${pkg.split(import_node_path27.default.sep).join("/")}:${targetName}`;
37407
+ const label = `//${pkg.split(import_node_path27.default.sep).join("/")}:${targetName2}`;
37408
37408
  const configuration = configurationName ?? "Debug";
37409
37409
  const graph = bazelGraph(root, label, configuration);
37410
37410
  const files2 = new BazelFiles(graph, root);
@@ -37640,7 +37640,7 @@ ${published3.map(
37640
37640
  const appModule = {
37641
37641
  ...named,
37642
37642
  id: idOf(graph.app),
37643
- name: targetName,
37643
+ name: targetName2,
37644
37644
  targetIdentity: graph.app.label,
37645
37645
  targetDependencies: [
37646
37646
  ...new Set(appParts.flatMap(({ module: module2 }) => module2.targetDependencies))
@@ -37929,7 +37929,7 @@ ${published3.map(
37929
37929
  {
37930
37930
  id: appModule.id,
37931
37931
  sourceTarget: appModule.moduleName,
37932
- productName: `${targetName}.app`,
37932
+ productName: `${targetName2}.app`,
37933
37933
  productType: "com.apple.product-type.application",
37934
37934
  installName: null,
37935
37935
  buildVersion: { platform: "iphonesimulator", minimumOS, sdk: null },
@@ -37973,7 +37973,7 @@ ${published3.map(
37973
37973
  binaryFrameworks,
37974
37974
  sdkFrameworks,
37975
37975
  packageResolved: [],
37976
- appTargets: [targetName],
37976
+ appTargets: [targetName2],
37977
37977
  configuration,
37978
37978
  settings: (key2) => key2 === "PRODUCT_MODULE_NAME" ? appModule.moduleName : key2 === "IPHONEOS_DEPLOYMENT_TARGET" ? minimumOS : key2 === "PRODUCT_BUNDLE_IDENTIFIER" ? graph.app.attrs.get("bundle_id")?.value ?? "" : "",
37979
37979
  cocoapods: null
@@ -39240,7 +39240,7 @@ function parseBuildSettings(block2) {
39240
39240
  }
39241
39241
  return settings;
39242
39242
  }
39243
- function appTargetReleaseSettings(pbxproj, targetName, infoPlistRelativePath) {
39243
+ function appTargetReleaseSettings(pbxproj, targetName2, infoPlistRelativePath) {
39244
39244
  const configurationPattern = /\/\* (Release|Debug) \*\/ = \{/g;
39245
39245
  const candidates = [];
39246
39246
  let match;
@@ -39261,7 +39261,7 @@ function appTargetReleaseSettings(pbxproj, targetName, infoPlistRelativePath) {
39261
39261
  const normalized = plist6.replace(/^"|"$/g, "");
39262
39262
  return normalized === infoPlistRelativePath || infoPlistRelativePath.endsWith(`/${normalized}`) || normalized.endsWith(`/${infoPlistRelativePath}`);
39263
39263
  };
39264
- const named = (settings) => resolveBuildSetting(settings.PRODUCT_NAME ?? "", settings) === targetName;
39264
+ const named = (settings) => resolveBuildSetting(settings.PRODUCT_NAME ?? "", settings) === targetName2;
39265
39265
  return candidates.find(
39266
39266
  (candidate) => candidate.name === "Release" && plistMatch(candidate.settings)
39267
39267
  )?.settings ?? candidates.find(
@@ -39305,31 +39305,31 @@ function nativeAppIdentityFromIos(files2, parseInfoPlist, iosTarget, resourceUri
39305
39305
  applicationTargetNames.add(match[1]);
39306
39306
  }
39307
39307
  }
39308
- let targetName = null;
39308
+ let targetName2 = null;
39309
39309
  if (iosTarget) {
39310
39310
  if (applicationTargetNames.has(iosTarget)) {
39311
- targetName = iosTarget;
39311
+ targetName2 = iosTarget;
39312
39312
  } else {
39313
39313
  return null;
39314
39314
  }
39315
39315
  } else if (applicationTargetNames.size === 1) {
39316
- targetName = [...applicationTargetNames][0];
39316
+ targetName2 = [...applicationTargetNames][0];
39317
39317
  } else if (applicationTargetNames.size > 1) {
39318
39318
  const delegateTargets = Object.keys(files2).filter((path148) => !path148.includes("/Pods/")).map((path148) => path148.match(APP_DELEGATE_PATH_RE)?.[1]).filter(
39319
39319
  (name3) => typeof name3 === "string" && applicationTargetNames.has(name3)
39320
39320
  );
39321
39321
  if (delegateTargets.length === 1) {
39322
- targetName = delegateTargets[0];
39322
+ targetName2 = delegateTargets[0];
39323
39323
  } else {
39324
39324
  return null;
39325
39325
  }
39326
39326
  } else {
39327
39327
  return null;
39328
39328
  }
39329
- const selectedTarget = targets.find((t) => t.name === targetName);
39329
+ const selectedTarget = targets.find((t) => t.name === targetName2);
39330
39330
  const settings = {
39331
- TARGET_NAME: targetName,
39332
- PRODUCT_NAME: targetName
39331
+ TARGET_NAME: targetName2,
39332
+ PRODUCT_NAME: targetName2
39333
39333
  };
39334
39334
  for (const obj of Object.values(objects)) {
39335
39335
  if (isRecord(obj) && obj.isa === "PBXProject" && typeof obj.buildConfigurationList === "string") {
@@ -39365,8 +39365,8 @@ function nativeAppIdentityFromIos(files2, parseInfoPlist, iosTarget, resourceUri
39365
39365
  } else {
39366
39366
  const legacy2 = appTargetReleaseSettings(
39367
39367
  pbxproj,
39368
- targetName,
39369
- `${targetName}/Info.plist`
39368
+ targetName2,
39369
+ `${targetName2}/Info.plist`
39370
39370
  );
39371
39371
  if (legacy2) Object.assign(settings, legacy2);
39372
39372
  }
@@ -39377,7 +39377,7 @@ function nativeAppIdentityFromIos(files2, parseInfoPlist, iosTarget, resourceUri
39377
39377
  plist6 = files2[`ios/${normalized}`] ?? files2[normalized] ?? Object.entries(files2).find(([k]) => k.endsWith(`/${normalized}`))?.[1];
39378
39378
  }
39379
39379
  if (!plist6) {
39380
- plist6 = files2[`ios/${targetName}/Info.plist`] ?? files2[`${targetName}/Info.plist`] ?? Object.entries(files2).find(([k]) => k.endsWith(`/${targetName}/Info.plist`))?.[1];
39380
+ plist6 = files2[`ios/${targetName2}/Info.plist`] ?? files2[`${targetName2}/Info.plist`] ?? Object.entries(files2).find(([k]) => k.endsWith(`/${targetName2}/Info.plist`))?.[1];
39381
39381
  }
39382
39382
  if (!plist6) return null;
39383
39383
  const bundleIdentifier = identityFieldFrom(
@@ -39401,7 +39401,7 @@ function nativeAppIdentityFromIos(files2, parseInfoPlist, iosTarget, resourceUri
39401
39401
  settings,
39402
39402
  plistString(plist6, "CFBundleName"),
39403
39403
  settings.PRODUCT_NAME
39404
- ) ?? resolvedIdentityField(resolveBuildSetting(settings.PRODUCT_NAME ?? "", settings)) ?? resolvedIdentityField(targetName);
39404
+ ) ?? resolvedIdentityField(resolveBuildSetting(settings.PRODUCT_NAME ?? "", settings)) ?? resolvedIdentityField(targetName2);
39405
39405
  if (!bundleName) return null;
39406
39406
  const applicationName = identityFieldFrom(settings, plistString(plist6, "CFBundleDisplayName"), void 0) ?? bundleName;
39407
39407
  const dictionary2 = parseInfoPlist(plist6);
@@ -39567,7 +39567,7 @@ function nativeAppIdentityFromIos(files2, parseInfoPlist, iosTarget, resourceUri
39567
39567
  }
39568
39568
  const rootModuleName = readRootModuleName(
39569
39569
  Object.entries(files2).filter(
39570
- ([path148]) => !path148.includes("/Pods/") && (/(?:^|\/)(?:ios\/)?AppDelegate\.(?:swift|mm|m)$/.test(path148) || path148.match(APP_DELEGATE_PATH_RE)?.[1] === targetName)
39570
+ ([path148]) => !path148.includes("/Pods/") && (/(?:^|\/)(?:ios\/)?AppDelegate\.(?:swift|mm|m)$/.test(path148) || path148.match(APP_DELEGATE_PATH_RE)?.[1] === targetName2)
39571
39571
  ).map(([, source]) => source)
39572
39572
  );
39573
39573
  return {
@@ -40519,7 +40519,7 @@ var swiftCoverageProvenance;
40519
40519
  var init_provenance = __esm({
40520
40520
  "src/swift-coverage/provenance.ts"() {
40521
40521
  "use strict";
40522
- swiftCoverageProvenance = true ? JSON.parse('{"swift-coverage/indexdump.ts":"0d82d8eeb96bf377f409ea7e33274c341a710c0e071f6b6e17571a23d8d92412","swift-coverage/indexing.ts":"633ccf19eec1f382a8847d0ee1dca42a2792a3c60aafd43622ed5152b09b8272","swift-coverage/types.ts":"bd8fae54ea6c53e110cd8a5d7b57c1d532dd0166e09fdaea63c4f270c3780dd1","swift-coverage/source.ts":"c151758a9f67631bc61473c375df0dc017da6902a34533b2cf4fc4fd7d19b6ee","swift-coverage/package.ts":"1f0068be7461fa7c5a7a891faf318f305cbed2e94c19667ba76627f7e5be260b","swift-coverage/xcode.ts":"65a500b806ce1c3a496de27f2e0ad77287c0f6795c618342c08af647f92af1fa","swift-coverage/xcode-assets.ts":"d98d6294b359528f7733b26db6f80f554782354faa235605f9562be4ad98b8a3","swift-coverage/xcode-asset-symbols.ts":"1b2a67733bc9d139b351466270205452a6172140bc25080d72619e2952c44671","swift-coverage/xcode-bridging.ts":"33184be8c5daf6646aa5a1276a4e15531f1be27b7c26f56550e0fbb1fc678a11","swift-coverage/xcode-packages.ts":"5c83f56357d880243ab485b260d23abd0094583ffa2287dac6e9e7eb18c3673d","swift-coverage/xcode-strings.ts":"f2dd4c7cd8ef77035184b0132909c2fa09fd20ed06b7757c2f1f960bfdde031c","swift-coverage/reader.ts":"da559b67ecd1161dea70c980b5f98f2c55af3550f0714479100fa5e9e813625c","swift-coverage/provenance.ts":"f5039c16e63c6129e22b71203f58982c68cef6e282a4f236b93da28edd39c108","swift-package-manifest.ts":"a19fe4c5e2efe18bbc3ece544ff2c8be660170d63274cccb0ab58e53083050e4","swift-package.ts":"851417572ca9aff699ad368bdc3ff05309b0256e483d40812b9c0beb869d0a5b","swift-source-file.ts":"8becce5e73b76a61d9d202c1ecfb39b1238e9bbf0e77841f1c51c98fa9ac7bd3","swift-toolchain.ts":"dec93d0206df8efbd9f538d1f3e3f6173f6eb022cb9ad6b02271481db7578d77","home-paths.ts":"d1606390f0e8e50f0ff72544eadb3d49dfabf08e004c1218f2998c36fb8995dd","xcode-header-search.ts":"d61be5d97c018bef4cf2a423f3625bac9757ab2c8e8541a00a4f29ebf048640f","xcode-project.ts":"092e07d3f9154f5aaf9f7c668f16c933c3ac5d8c57e5c32df0222ae6f785eaf7","xcode-target-members.ts":"2f25aaf5a3aa34395983c75935491c06bd68554c47ff1cb06b49c79499c03db0","xcode-json-project.ts":"41990ebbe4b488eef34e74c4608b4b48e5a5b299ba98ca7fbcfdfa0e77be63b6","openstep-plist.ts":"74e6ce1dac80c9c318e0e9f5e3e8cd19a898a8820c36fc160609695bcb59dcd3"}') : swiftCoverageSourceDigests((0, import_node_path.join)(__sootsim_import_meta_dirname, ".."));
40522
+ swiftCoverageProvenance = true ? JSON.parse('{"swift-coverage/indexdump.ts":"0d82d8eeb96bf377f409ea7e33274c341a710c0e071f6b6e17571a23d8d92412","swift-coverage/indexing.ts":"633ccf19eec1f382a8847d0ee1dca42a2792a3c60aafd43622ed5152b09b8272","swift-coverage/types.ts":"bd8fae54ea6c53e110cd8a5d7b57c1d532dd0166e09fdaea63c4f270c3780dd1","swift-coverage/source.ts":"c151758a9f67631bc61473c375df0dc017da6902a34533b2cf4fc4fd7d19b6ee","swift-coverage/package.ts":"1f0068be7461fa7c5a7a891faf318f305cbed2e94c19667ba76627f7e5be260b","swift-coverage/xcode.ts":"65a500b806ce1c3a496de27f2e0ad77287c0f6795c618342c08af647f92af1fa","swift-coverage/xcode-assets.ts":"d98d6294b359528f7733b26db6f80f554782354faa235605f9562be4ad98b8a3","swift-coverage/xcode-asset-symbols.ts":"1b2a67733bc9d139b351466270205452a6172140bc25080d72619e2952c44671","swift-coverage/xcode-bridging.ts":"33184be8c5daf6646aa5a1276a4e15531f1be27b7c26f56550e0fbb1fc678a11","swift-coverage/xcode-packages.ts":"5c83f56357d880243ab485b260d23abd0094583ffa2287dac6e9e7eb18c3673d","swift-coverage/xcode-strings.ts":"f2dd4c7cd8ef77035184b0132909c2fa09fd20ed06b7757c2f1f960bfdde031c","swift-coverage/reader.ts":"da559b67ecd1161dea70c980b5f98f2c55af3550f0714479100fa5e9e813625c","swift-coverage/provenance.ts":"f5039c16e63c6129e22b71203f58982c68cef6e282a4f236b93da28edd39c108","swift-package-manifest.ts":"a19fe4c5e2efe18bbc3ece544ff2c8be660170d63274cccb0ab58e53083050e4","swift-package.ts":"851417572ca9aff699ad368bdc3ff05309b0256e483d40812b9c0beb869d0a5b","swift-source-file.ts":"8becce5e73b76a61d9d202c1ecfb39b1238e9bbf0e77841f1c51c98fa9ac7bd3","swift-toolchain.ts":"dec93d0206df8efbd9f538d1f3e3f6173f6eb022cb9ad6b02271481db7578d77","home-paths.ts":"d1606390f0e8e50f0ff72544eadb3d49dfabf08e004c1218f2998c36fb8995dd","xcode-header-search.ts":"4a775ba92c7b23ce71dd6bb08c188c4bccd6e1ed500cc9fc7850030b945fc8d4","xcode-project.ts":"092e07d3f9154f5aaf9f7c668f16c933c3ac5d8c57e5c32df0222ae6f785eaf7","xcode-target-members.ts":"2f25aaf5a3aa34395983c75935491c06bd68554c47ff1cb06b49c79499c03db0","xcode-json-project.ts":"41990ebbe4b488eef34e74c4608b4b48e5a5b299ba98ca7fbcfdfa0e77be63b6","openstep-plist.ts":"74e6ce1dac80c9c318e0e9f5e3e8cd19a898a8820c36fc160609695bcb59dcd3"}') : swiftCoverageSourceDigests((0, import_node_path.join)(__sootsim_import_meta_dirname, ".."));
40523
40523
  }
40524
40524
  });
40525
40525
 
@@ -49739,7 +49739,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk2)
49739
49739
  const overlayFiles = (0, import_node_fs44.readdirSync)(overlay, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => import_node_path41.default.join(entry.parentPath, entry.name)).sort();
49740
49740
  const key2 = JSON.stringify([
49741
49741
  // bump the recipe when the transformation changes; bundling changes function text.
49742
- "v24",
49742
+ "v25",
49743
49743
  [...WEAKEN_FOUNDATION_SYMS],
49744
49744
  toolchainBin,
49745
49745
  sdk2,
@@ -49799,6 +49799,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk2)
49799
49799
  "objc/NSObject.h",
49800
49800
  "ObjectiveC.apinotes",
49801
49801
  "net/if.h",
49802
+ "netinet/tcp.h",
49802
49803
  "notify.h",
49803
49804
  "notify.modulemap",
49804
49805
  "module.modulemap",
@@ -52280,9 +52281,9 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
52280
52281
  const sLive = liveSegs.get(obj);
52281
52282
  const dLive = liveDataSyms.get(obj);
52282
52283
  const tLive = liveTypes.get(obj);
52283
- const targetName = obj.symNames[r.rs] ?? "";
52284
+ const targetName2 = obj.symNames[r.rs] ?? "";
52284
52285
  if (segName === "swift5_type_metadata") {
52285
- const raw2 = targetName.startsWith(".Lgot.") ? targetName.slice(6) : targetName;
52286
+ const raw2 = targetName2.startsWith(".Lgot.") ? targetName2.slice(6) : targetName2;
52286
52287
  if (raw2.endsWith("Mn")) {
52287
52288
  const pref = raw2.slice(0, -2);
52288
52289
  if (obj.typePrefixesInObj.has(pref)) return tLive.has(pref);
@@ -57460,6 +57461,61 @@ function swiftClangImporterFlags(flags) {
57460
57461
  (flag) => flag !== "-fobjc-arc" && flag !== "-fno-objc-arc" && !/^-std=(?:c(?!\+\+)|gnu(?!\+\+)|iso9899:)/.test(flag)
57461
57462
  );
57462
57463
  }
57464
+ function compactSwiftClangDefines(flags) {
57465
+ const definitions = /* @__PURE__ */ new Map();
57466
+ const macros = [];
57467
+ for (let index = 0; index < flags.length; index++) {
57468
+ if (flags[index].startsWith("@")) return flags;
57469
+ if (flags[index] !== "-Xcc") continue;
57470
+ const flag = flags[++index];
57471
+ if (flag === void 0 || flags[index - 2] === "-Xfrontend" || flag === "-Xclang" || flag === "-Xpreprocessor" || flag.startsWith("-Wp,") || flag.startsWith("--config") || flag.startsWith("@"))
57472
+ return flags;
57473
+ if (CLANG_PATH_OPTIONS.has(flag) && flags[index + 1] === "-Xcc") {
57474
+ index += 2;
57475
+ continue;
57476
+ }
57477
+ if (!flag.startsWith("-D") && !flag.startsWith("-U")) continue;
57478
+ const name3 = /^-[DU]([A-Za-z_$][\w$]*)(?=[(=]|$)/.exec(flag)?.[1];
57479
+ if (!name3) return flags;
57480
+ const previous = definitions.get(name3);
57481
+ definitions.set(name3, previous === void 0 || previous === flag ? flag : null);
57482
+ macros.push({ index, name: name3, flag });
57483
+ }
57484
+ const seen = /* @__PURE__ */ new Set();
57485
+ const duplicates = /* @__PURE__ */ new Set();
57486
+ for (const { index, name: name3, flag } of macros) {
57487
+ if (definitions.get(name3) !== flag) continue;
57488
+ if (seen.has(name3)) {
57489
+ duplicates.add(index - 1);
57490
+ duplicates.add(index);
57491
+ }
57492
+ seen.add(name3);
57493
+ }
57494
+ return duplicates.size === 0 ? flags : flags.filter((_, index) => !duplicates.has(index));
57495
+ }
57496
+ function compactSwiftClangOverlays(flags, generated) {
57497
+ if (generated.size === 0) return flags;
57498
+ const overlays = /* @__PURE__ */ new Map();
57499
+ const duplicates = /* @__PURE__ */ new Set();
57500
+ for (let index = 0; index < flags.length; index++) {
57501
+ const flag = flags[index];
57502
+ if (flag.startsWith("@")) return flags;
57503
+ if (flag === "-Xcc" && flags[index - 1] === "-Xfrontend") return flags;
57504
+ if (flags[index - 1] === "-Xcc" && (flag.startsWith("--config") || flag === "-Xclang"))
57505
+ return flags;
57506
+ if (!flag.startsWith("-ivfsoverlay") && !flag.startsWith("-vfsoverlay")) continue;
57507
+ if (flag !== "-ivfsoverlay" || flags[index - 1] !== "-Xcc" || flags[index + 1] !== "-Xcc")
57508
+ return flags;
57509
+ const file = flags[index + 2];
57510
+ if (file === void 0 || !generated.has(file)) return flags;
57511
+ const previous = overlays.get(file);
57512
+ if (previous !== void 0)
57513
+ for (let offset = -1; offset < 3; offset++) duplicates.add(previous + offset);
57514
+ overlays.set(file, index);
57515
+ index += 2;
57516
+ }
57517
+ return duplicates.size === 0 ? flags : flags.filter((_, index) => !duplicates.has(index));
57518
+ }
57463
57519
  function swiftSubmoduleImports(sources) {
57464
57520
  const imports2 = /* @__PURE__ */ new Map();
57465
57521
  for (const source of sources)
@@ -57484,7 +57540,7 @@ function swiftObjCModuleMap(module2, headers, submodules = /* @__PURE__ */ new S
57484
57540
  ""
57485
57541
  ].join("\n");
57486
57542
  }
57487
- var SWIFT_OBJC_INTEROP_FLAGS, SWIFT_SUBMODULE_IMPORT;
57543
+ var SWIFT_OBJC_INTEROP_FLAGS, CLANG_PATH_OPTIONS, SWIFT_SUBMODULE_IMPORT;
57488
57544
  var init_swift_objc_import = __esm({
57489
57545
  "src/swift-objc-import.ts"() {
57490
57546
  "use strict";
@@ -57498,6 +57554,23 @@ var init_swift_objc_import = __esm({
57498
57554
  "-Xcc",
57499
57555
  "-fblocks"
57500
57556
  ];
57557
+ CLANG_PATH_OPTIONS = /* @__PURE__ */ new Set([
57558
+ "-I",
57559
+ "-F",
57560
+ "-idirafter",
57561
+ "-iframework",
57562
+ "-iframeworkwithsysroot",
57563
+ "-imacros",
57564
+ "-include",
57565
+ "-iprefix",
57566
+ "-iquote",
57567
+ "-isystem",
57568
+ "-isysroot",
57569
+ "-ivfsoverlay",
57570
+ "-iwithprefix",
57571
+ "-iwithprefixbefore",
57572
+ "--sysroot"
57573
+ ]);
57501
57574
  SWIFT_SUBMODULE_IMPORT = /^[ \t]*(?:@\w+(?:\([^)]*\))?[ \t]+)*import[ \t]+([A-Za-z_]\w*)\.([A-Za-z_]\w*)[ \t]*(?:\/\/.*)?$/gm;
57502
57575
  }
57503
57576
  });
@@ -57867,6 +57940,30 @@ var init_swift_uniform_type_constants = __esm({
57867
57940
  });
57868
57941
 
57869
57942
  // src/xcode-header-search.ts
57943
+ function coalescibleHeaderOverlays(files2) {
57944
+ const aliases = /* @__PURE__ */ new Map();
57945
+ const key2 = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
57946
+ const index = (directory2, entry) => {
57947
+ const name3 = import_node_path56.default.resolve(directory2, entry.name);
57948
+ if (entry.type === "directory")
57949
+ return entry.contents.every((child) => index(name3, child));
57950
+ const source = entry["external-contents"];
57951
+ const previous = aliases.get(key2(name3));
57952
+ if (previous !== void 0 && previous !== source) return false;
57953
+ aliases.set(key2(name3), source);
57954
+ return true;
57955
+ };
57956
+ for (const file of files2) {
57957
+ const overlay = JSON.parse(import_node_fs59.default.readFileSync(file, "utf8"));
57958
+ if (!overlay.roots.every((entry) => index(import_node_path56.default.dirname(file), entry)))
57959
+ return /* @__PURE__ */ new Set();
57960
+ }
57961
+ for (const file of [...files2, ...aliases.values()]) {
57962
+ const source = aliases.get(key2(import_node_path56.default.normalize(file)));
57963
+ if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
57964
+ }
57965
+ return files2;
57966
+ }
57870
57967
  function headerMap(entries) {
57871
57968
  const unique = /* @__PURE__ */ new Map();
57872
57969
  for (const entry of entries)
@@ -58791,6 +58888,15 @@ function swiftTargetDependencies(files2, targets, frameworks = OPTIONAL_FRAMEWOR
58791
58888
  )
58792
58889
  );
58793
58890
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
58891
+ const entriesByPrefix = new Map(
58892
+ targets.map(({ path: path148 }) => [path148 === "." ? "" : `${path148}/`, []])
58893
+ );
58894
+ for (const entry of Object.entries(files2)) {
58895
+ const [file] = entry;
58896
+ entriesByPrefix.get("")?.push(entry);
58897
+ for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1))
58898
+ entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
58899
+ }
58794
58900
  const siblings = /* @__PURE__ */ new Map();
58795
58901
  for (const target of targets) {
58796
58902
  const prefix = target.path === "." ? "" : `${target.path}/`;
@@ -58804,8 +58910,11 @@ function swiftTargetDependencies(files2, targets, frameworks = OPTIONAL_FRAMEWOR
58804
58910
  (dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) || dependency.kind === "product" && dependency.package === "sootsim-swift" && OPTIONAL_FRAMEWORKS.has(dependency.name) ? [dependency.name] : []
58805
58911
  )
58806
58912
  );
58807
- for (const [file, contents2] of Object.entries(files2)) {
58808
- if (file === "Package.swift" || !file.startsWith(prefix)) continue;
58913
+ const nested = target.sources === void 0 ? targets.flatMap(
58914
+ (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) ? [`${candidate.path}/`] : []
58915
+ ) : [];
58916
+ for (const [file, contents2] of entriesByPrefix.get(prefix) ?? []) {
58917
+ if (file === "Package.swift") continue;
58809
58918
  const relative6 = file.slice(prefix.length);
58810
58919
  if (target.sources !== void 0 && !target.sources.some(
58811
58920
  (source) => source === "." || relative6 === source || relative6.startsWith(`${source}/`)
@@ -58815,10 +58924,7 @@ function swiftTargetDependencies(files2, targets, frameworks = OPTIONAL_FRAMEWOR
58815
58924
  (excluded) => relative6 === excluded || relative6.startsWith(`${excluded}/`)
58816
58925
  ))
58817
58926
  continue;
58818
- if (target.sources === void 0 && targets.some(
58819
- (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
58820
- ))
58821
- continue;
58927
+ if (nested.some((path148) => file.startsWith(path148))) continue;
58822
58928
  const imports2 = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
58823
58929
  for (const name3 of imports2) {
58824
58930
  if (names.has(name3) && name3 !== target.name && !(target.dependencies !== void 0 && localNames.has(name3)))
@@ -59063,7 +59169,9 @@ function emitSwiftPackageManifest(args) {
59063
59169
  const flags = JSON.parse(literal6.replace(/,\s*]$/, "]")).filter(
59064
59170
  (flag, index, all) => !mapsPackageModule(flag) && !(flag === "-Xcc" && mapsPackageModule(all[index + 1] ?? ""))
59065
59171
  );
59066
- const content = flags.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
59172
+ const macros = compactSwiftClangDefines(flags);
59173
+ const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
59174
+ const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
59067
59175
  const digest3 = (0, import_node_crypto28.createHash)("sha256").update(content).digest("hex");
59068
59176
  const file = import_node_path57.default.join(args.root, ".peach-swift-arguments", `${digest3}.rsp`);
59069
59177
  args.files.set(file, content);
@@ -59154,7 +59262,7 @@ function emitSwiftPackageManifest(args) {
59154
59262
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
59155
59263
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
59156
59264
  (value) => value.late?.producers.includes(target.name)
59157
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path57.default.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
59265
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path57.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
59158
59266
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
59159
59267
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
59160
59268
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports2}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -61245,6 +61353,9 @@ module ${moduleName2}.Swift {
61245
61353
  nativeHeaderDeclarations[module2] = [...declared];
61246
61354
  }
61247
61355
  const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
61356
+ const generatedOverlays = new Set(
61357
+ headerSearch.files.filter((file) => file.endsWith(".yaml"))
61358
+ );
61248
61359
  if (nativeFlags) {
61249
61360
  const toolchainBin = nativeToolchain();
61250
61361
  const headers = import_node_path57.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
@@ -61265,8 +61376,11 @@ module ${moduleName2}.Swift {
61265
61376
  throw new Error(
61266
61377
  target.name + ": missing or unsupported declared iOS deployment target " + JSON.stringify(version2)
61267
61378
  );
61379
+ const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum);
61380
+ const sdkOverlay = sdkIntake.indexOf("-ivfsoverlay");
61381
+ if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]);
61268
61382
  const intake = [
61269
- ...objcSdkIntakeFlags(headers, toolchainBin, minimum),
61383
+ ...sdkIntake,
61270
61384
  "-ivfsoverlay",
61271
61385
  headerSearch.files[0],
61272
61386
  "-I",
@@ -61435,6 +61549,7 @@ module ${moduleName2}.Swift {
61435
61549
  sourceSwiftTargets: swiftTargets,
61436
61550
  nativeFlags,
61437
61551
  nativeImportFlags,
61552
+ coalescibleOverlays: nativeFlags ? coalescibleHeaderOverlays(generatedOverlays) : void 0,
61438
61553
  nativeHeaderFlags,
61439
61554
  nativeSwiftHeaderMaps,
61440
61555
  nativeHeaderDeclarations,
@@ -62733,6 +62848,7 @@ function compileSwiftProjectOnce(input, options) {
62733
62848
  report("compiling and linking Swift modules");
62734
62849
  const frameworkInterfaces = /* @__PURE__ */ new Map();
62735
62850
  const nativeDeclarations = /* @__PURE__ */ new Map();
62851
+ const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
62736
62852
  for (const [file, contents2] of Object.entries(input.files)) {
62737
62853
  if (!file.endsWith(".modulemap")) continue;
62738
62854
  const name3 = moduleMapName(contents2);
@@ -62820,54 +62936,83 @@ function compileSwiftProjectOnce(input, options) {
62820
62936
  );
62821
62937
  return value;
62822
62938
  };
62823
- try {
62824
- for (const build2 of preparation.headerBuilds) {
62825
- await runCompiler(
62826
- swift,
62827
- [...buildArgs, "--target", build2.target],
62828
- appOptions,
62829
- SWIFTPM_PROGRESS,
62830
- SWIFTPM_NOISE
62939
+ const compileApp = async () => {
62940
+ const stages = [
62941
+ ...preparation.headerBuilds,
62942
+ ...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
62943
+ ];
62944
+ const checkpoints = import_node_path57.default.join(root, ".build", "peach-product-checkpoints");
62945
+ const recipe2 = (0, import_node_crypto28.createHash)("sha256").update(hash).update((0, import_node_fs60.readFileSync)(import_node_path57.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
62946
+ for (const { target, producers } of stages) {
62947
+ const receipt = import_node_path57.default.join(
62948
+ checkpoints,
62949
+ (0, import_node_crypto28.createHash)("sha256").update(target).digest("hex")
62831
62950
  );
62832
- for (const producer of build2.producers) {
62833
- const emitted = import_node_path57.default.join(
62951
+ const headers = producers.map((producer) => {
62952
+ const stem = import_node_path57.default.join(
62834
62953
  root,
62835
62954
  ".build",
62836
62955
  "peach-cxx-headers",
62837
- `${producer}-Swift.h`
62956
+ `${producer}-Swift`
62838
62957
  );
62839
- const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
62840
- if ((0, import_node_fs60.existsSync)(original)) {
62841
- const generated = clangInterfaceHeader(
62842
- (0, import_node_fs60.readFileSync)(original, "utf8")
62843
- );
62844
- writeBuildFile(
62845
- emitted,
62846
- withoutSwiftDeclarations(
62847
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
62848
- /* @__PURE__ */ new Set([
62849
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
62850
- ...nativelyDeclaredFunctions(
62851
- generated,
62852
- Object.entries(input.files).filter(
62853
- ([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")
62854
- ).map(([, source]) => source)
62855
- )
62856
- ]),
62857
- `#import <${producer}/${producer}.h>`
62858
- )
62958
+ return {
62959
+ producer,
62960
+ original: `${stem}.original.h`,
62961
+ emitted: `${stem}.h`
62962
+ };
62963
+ });
62964
+ const fingerprint = () => {
62965
+ const digest3 = (0, import_node_crypto28.createHash)("sha256").update(recipe2);
62966
+ for (const { emitted } of headers) {
62967
+ if (!(0, import_node_fs60.existsSync)(emitted)) return;
62968
+ digest3.update(
62969
+ (0, import_node_crypto28.createHash)("sha256").update((0, import_node_fs60.readFileSync)(emitted)).digest()
62859
62970
  );
62860
62971
  }
62861
- }
62862
- }
62863
- if (preparation.nativeProductTarget) {
62972
+ return digest3.digest("hex");
62973
+ };
62974
+ if (!options.project && (0, import_node_fs60.existsSync)(receipt) && (0, import_node_fs60.readFileSync)(receipt, "utf8") === fingerprint())
62975
+ continue;
62976
+ if (!options.project) (0, import_node_fs60.rmSync)(receipt, { force: true });
62977
+ for (const { producer, original } of headers)
62978
+ if (!(0, import_node_fs60.existsSync)(original))
62979
+ (0, import_node_fs60.rmSync)(
62980
+ import_node_path57.default.join(
62981
+ root,
62982
+ ".build",
62983
+ WASM_TRIPLE,
62984
+ "release",
62985
+ "Modules",
62986
+ `${swiftTargetModuleName(producer)}.swiftmodule`
62987
+ ),
62988
+ { force: true }
62989
+ );
62864
62990
  await runCompiler(
62865
62991
  swift,
62866
- [...buildArgs, "--target", preparation.nativeProductTarget],
62992
+ [...buildArgs, "--target", target],
62867
62993
  appOptions,
62868
62994
  SWIFTPM_PROGRESS,
62869
62995
  SWIFTPM_NOISE
62870
62996
  );
62997
+ for (const { producer, original, emitted } of headers) {
62998
+ const generated = clangInterfaceHeader((0, import_node_fs60.readFileSync)(original, "utf8"));
62999
+ writeBuildFile(
63000
+ emitted,
63001
+ withoutSwiftDeclarations(
63002
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
63003
+ /* @__PURE__ */ new Set([
63004
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
63005
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
63006
+ ]),
63007
+ `#import <${producer}/${producer}.h>`
63008
+ )
63009
+ );
63010
+ }
63011
+ if (!options.project) {
63012
+ (0, import_node_fs60.mkdirSync)(checkpoints, { recursive: true });
63013
+ (0, import_node_fs60.writeFileSync)(`${receipt}.partial`, fingerprint());
63014
+ (0, import_node_fs60.renameSync)(`${receipt}.partial`, receipt);
63015
+ }
62871
63016
  }
62872
63017
  await runCompiler(
62873
63018
  swift,
@@ -62876,6 +63021,9 @@ function compileSwiftProjectOnce(input, options) {
62876
63021
  SWIFTPM_PROGRESS,
62877
63022
  SWIFTPM_NOISE
62878
63023
  );
63024
+ };
63025
+ try {
63026
+ await compileApp();
62879
63027
  } catch (error) {
62880
63028
  const output3 = outputOf(error);
62881
63029
  const moduleCache = import_node_path57.default.join(
@@ -62888,13 +63036,7 @@ function compileSwiftProjectOnce(input, options) {
62888
63036
  if (output3.includes("was compiled with module cache path") && (0, import_node_fs60.existsSync)(moduleCache)) {
62889
63037
  (0, import_node_fs60.rmSync)(moduleCache, { recursive: true, force: true });
62890
63038
  try {
62891
- await runCompiler(
62892
- swift,
62893
- buildArgs,
62894
- appOptions,
62895
- SWIFTPM_PROGRESS,
62896
- SWIFTPM_NOISE
62897
- );
63039
+ await compileApp();
62898
63040
  } catch (retryError) {
62899
63041
  throw new Error(
62900
63042
  [
@@ -63225,9 +63367,9 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
63225
63367
  `;
63226
63368
  darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
63227
63369
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
63228
- MULTI_MANIFEST_VERSION = 69;
63370
+ MULTI_MANIFEST_VERSION = 71;
63229
63371
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
63230
- compilerSourceDigest = true ? "5f7b13ec00e56a1f8e36b1e4f1688c4eb10836e9afffb80f5e63e4fbf23e9070" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
63372
+ compilerSourceDigest = true ? "d287f3ad479477c70004707c1336f37c9baeb81aef1880544a5ca236e088ca16" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
63231
63373
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
63232
63374
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
63233
63375
  cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
@@ -65183,10 +65325,10 @@ function readXcodeJsonProject(xcodeproj, source) {
65183
65325
  phases.set(`id:${phaseId}`, phaseId);
65184
65326
  }
65185
65327
  }
65186
- const phaseFiles = (reference, targetName) => {
65328
+ const phaseFiles = (reference, targetName2) => {
65187
65329
  const value = text5(reference);
65188
65330
  if (value === void 0) return null;
65189
- const key2 = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
65331
+ const key2 = value.startsWith("id:") || !targetName2 ? value : `${targetName2}/${value}`;
65190
65332
  const phase = objects[phases.get(key2) ?? ""];
65191
65333
  return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
65192
65334
  };
@@ -65851,7 +65993,7 @@ function fileListEntries(file, absolute) {
65851
65993
  }
65852
65994
  function targetMembers(ref, settings, options, settingKeys, projectInputs) {
65853
65995
  const { project: project2, target, id: targetId } = ref;
65854
- const targetName = str(target.name) ?? targetId;
65996
+ const targetName2 = str(target.name) ?? targetId;
65855
65997
  const sources = /* @__PURE__ */ new Set();
65856
65998
  const allSources = /* @__PURE__ */ new Set();
65857
65999
  const headers = /* @__PURE__ */ new Set();
@@ -65924,7 +66066,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
65924
66066
  for (const { file } of lists)
65925
66067
  if (!import_node_fs64.default.existsSync(file))
65926
66068
  throw new Error(
65927
- `${targetName}: Run Script "${script}" missing file list ${file}`
66069
+ `${targetName2}: Run Script "${script}" missing file list ${file}`
65928
66070
  );
65929
66071
  const env = {
65930
66072
  ...process.env,
@@ -66020,7 +66162,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
66020
66162
  const output2 = error instanceof Error ? `${error.message}
66021
66163
  ${"stdout" in error ? String(error.stdout) : ""}${"stderr" in error ? String(error.stderr) : ""}` : String(error);
66022
66164
  throw new Error(
66023
- `${targetName}: Run Script "${script}" failed preparing generated outputs:
66165
+ `${targetName2}: Run Script "${script}" failed preparing generated outputs:
66024
66166
  ${output2}`
66025
66167
  );
66026
66168
  }
@@ -66029,7 +66171,7 @@ ${output2}`
66029
66171
  );
66030
66172
  if (missing2.length > 0)
66031
66173
  throw new Error(
66032
- `${targetName}: Run Script "${script}" did not produce ${missing2.join(", ")}`
66174
+ `${targetName2}: Run Script "${script}" did not produce ${missing2.join(", ")}`
66033
66175
  );
66034
66176
  preparedSourcePhases.set(key2, stamp);
66035
66177
  preparedXcodePhase(
@@ -66061,7 +66203,7 @@ ${output2}`
66061
66203
  if (options.requireSources === false) return;
66062
66204
  const script = scriptForOutput.get(import_node_path62.default.normalize(file));
66063
66205
  throw new Error(
66064
- script ? `${targetName}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)` : `${targetName}: missing source ${file}`
66206
+ script ? `${targetName2}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)` : `${targetName2}: missing source ${file}`
66065
66207
  );
66066
66208
  }
66067
66209
  allSources.add(file);
@@ -66084,7 +66226,7 @@ ${output2}`
66084
66226
  );
66085
66227
  if (runtimeInterfaceFiles.length > 0)
66086
66228
  throw new Error(
66087
- `${targetName}: Interface Builder compilation requires macOS and Xcode`
66229
+ `${targetName2}: Interface Builder compilation requires macOS and Xcode`
66088
66230
  );
66089
66231
  for (const file of interfaceFiles) resources.delete(file);
66090
66232
  interfaceFiles.length = 0;
@@ -66100,7 +66242,7 @@ ${output2}`
66100
66242
  import_node_path62.default.basename(file, import_node_path62.default.extname(file)) + extension
66101
66243
  );
66102
66244
  if (interfaceOutputs.has(output2))
66103
- throw new Error(`${targetName}: duplicate Interface Builder output ${output2}`);
66245
+ throw new Error(`${targetName2}: duplicate Interface Builder output ${output2}`);
66104
66246
  interfaceOutputs.add(output2);
66105
66247
  const args = [
66106
66248
  "ibtool",
@@ -66142,7 +66284,7 @@ ${output2}`
66142
66284
  );
66143
66285
  if (definitions.length > 0 && process.platform !== "darwin")
66144
66286
  throw new Error(
66145
- `${targetName}: intent definition code generation requires macOS and Xcode`
66287
+ `${targetName2}: intent definition code generation requires macOS and Xcode`
66146
66288
  );
66147
66289
  for (const definition2 of definitions) {
66148
66290
  const configuredLanguage = settings("INTENTS_CODEGEN_LANGUAGE");
@@ -66427,8 +66569,8 @@ function readXcodeScheme(xcodeprojOrWorkspace, scheme) {
66427
66569
  if (!name3) {
66428
66570
  const declared = (project2 ? [project2] : projects2).flatMap(
66429
66571
  (candidate) => projectTargets(candidate).flatMap((ref) => {
66430
- const targetName = str(ref.target.name);
66431
- return targetName ? [targetName] : [];
66572
+ const targetName2 = str(ref.target.name);
66573
+ return targetName2 ? [targetName2] : [];
66432
66574
  })
66433
66575
  );
66434
66576
  throw new Error(
@@ -66530,9 +66672,9 @@ async function resolveXcodeSwiftPackages(input, signal, target, configuration) {
66530
66672
  );
66531
66673
  }
66532
66674
  }
66533
- function readXcodeAppTarget(input, targetName, configurationName, options = {}) {
66675
+ function readXcodeAppTarget(input, targetName2, configurationName, options = {}) {
66534
66676
  if (isBazelPackage(input))
66535
- return readBazelAppTarget(input, targetName, configurationName, options);
66677
+ return readBazelAppTarget(input, targetName2, configurationName, options);
66536
66678
  const xcodeprojOrWorkspace = import_node_fs64.default.realpathSync.native(input);
66537
66679
  const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
66538
66680
  const { listed, projects: projects2, projectAt, cocoapods } = workspaceProjects(
@@ -66541,18 +66683,18 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
66541
66683
  );
66542
66684
  const allTargets = projects2.flatMap(projectTargets);
66543
66685
  const appTargets = allTargets.filter(
66544
- (ref) => isIosAppTarget(ref, options) || targetName !== void 0 && ref.target.name === targetName && ref.target.productType === APP_EXTENSION
66686
+ (ref) => isIosAppTarget(ref, options) || targetName2 !== void 0 && ref.target.name === targetName2 && ref.target.productType === APP_EXTENSION
66545
66687
  );
66546
66688
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
66547
66689
  const container = import_node_path62.default.basename(xcodeprojOrWorkspace);
66548
- const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
66690
+ const named = targetName2 ? appTargets.filter((ref) => ref.target.name === targetName2) : appTargets;
66549
66691
  if (named.length !== 1) {
66550
66692
  if (appTargets.length === 0)
66551
66693
  throw new Error(
66552
66694
  `${container} has no application targets; open a project or workspace that contains one`
66553
66695
  );
66554
66696
  throw new Error(
66555
- targetName && named.length === 0 ? `${container} has no application target ${targetName}; it has ${appTargetNames.join(", ") || "none"}` : targetName ? `${container} has ${named.length} application targets named ${targetName}; open its .xcodeproj` : `${container} has ${appTargetNames.length} application targets (${appTargetNames.join(", ")}); pass --target`
66697
+ targetName2 && named.length === 0 ? `${container} has no application target ${targetName2}; it has ${appTargetNames.join(", ") || "none"}` : targetName2 ? `${container} has ${named.length} application targets named ${targetName2}; open its .xcodeproj` : `${container} has ${appTargetNames.length} application targets (${appTargetNames.join(", ")}); pass --target`
66556
66698
  );
66557
66699
  }
66558
66700
  const app = named[0];
@@ -69958,7 +70100,7 @@ var init_swift_standin_digest = __esm({
69958
70100
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
69959
70101
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
69960
70102
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
69961
- STANDIN_SOURCE_DIGEST = true ? "2e7f1f173feffee6e539b11d8cd6fa9540f7418a23e3563c8b2d9aa747495bd6" : standinSourceDigest();
70103
+ STANDIN_SOURCE_DIGEST = true ? "f2b2c9a5d56b4cc06d8934ce5600587dcf7893acdf17158203975d997dbd387e" : standinSourceDigest();
69962
70104
  }
69963
70105
  });
69964
70106
 
@@ -70453,7 +70595,7 @@ __export(expo_native_prebuilt_exports, {
70453
70595
  servedExpoSwift: () => servedExpoSwift
70454
70596
  });
70455
70597
  function expoNativeCompilerDigestValue() {
70456
- return true ? "a21e70334c74419c8ca0427886adcfb457911bc210711ce2210c3f98b2dabf6b" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
70598
+ return true ? "07e205f69ed280a405ff8ed7b8e6259e8752f107f8768d265a02d97d85bafdee" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
70457
70599
  }
70458
70600
  function readSources(value) {
70459
70601
  const sources = isRecord(value) ? value.sources : null;
@@ -71591,6 +71733,7 @@ async function fetchCheckout(checkouts, identity2, pin2, signal) {
71591
71733
  }
71592
71734
  function fetchedCheckout(checkouts, identity2, pin2) {
71593
71735
  const dir = import_node_path77.default.join(checkouts, identity2);
71736
+ if (preparedSwiftPin(checkouts, identity2, pin2.location, pin2.revision)) return dir;
71594
71737
  const head = import_node_path77.default.join(dir, ".git", "HEAD");
71595
71738
  if (!verified.has(checkoutKey(dir, pin2)) || !import_node_fs79.default.existsSync(head) || import_node_fs79.default.readFileSync(head, "utf8").trim() !== pin2.revision)
71596
71739
  throw new Error(
@@ -80808,7 +80951,7 @@ async function swiftPackages(entry, app) {
80808
80951
  ] : []
80809
80952
  );
80810
80953
  let reached = [...cached4.binaries.filter((binary2) => binary2.reached), ...vendored];
80811
- const standinArtifact = (binary2) => binary2.publicHeaders === void 0 || binary2.unloweredSources !== void 0;
80954
+ const standinArtifact = (binary2) => !binary2.rustCrate && (binary2.publicHeaders === void 0 || binary2.unloweredSources !== void 0);
80812
80955
  const artifacts = reached.filter(standinArtifact);
80813
80956
  if (entry.moduleRoot && entry.provided && artifacts.length > 0) {
80814
80957
  const { provided } = entry;
@@ -84635,12 +84778,12 @@ async function collectTurboSources(options) {
84635
84778
  )
84636
84779
  )
84637
84780
  );
84638
- const original = (targetName, label, root, relative6, compiled = true) => {
84781
+ const original = (targetName2, label, root, relative6, compiled = true) => {
84639
84782
  const staged = relative6.replace(
84640
84783
  /(^|\/)main(\.(?:c|cc|cpp|cxx|m|mm))$/,
84641
84784
  "$1main.library$2"
84642
84785
  );
84643
- const key2 = `${targetPath(targetName)}/upstream/${label}/${staged}`;
84786
+ const key2 = `${targetPath(targetName2)}/upstream/${label}/${staged}`;
84644
84787
  if (UNIT.test(relative6) || OBJC2.test(relative6))
84645
84788
  (compiled ? compiledSources : textualSources).add(key2);
84646
84789
  if (Object.hasOwn(result.files, key2)) return key2;
@@ -84649,24 +84792,24 @@ async function collectTurboSources(options) {
84649
84792
  if (installed2?.flags.length) {
84650
84793
  let prefixHeader = null;
84651
84794
  if (installed2.prefixHeader) {
84652
- prefixHeader = `${targetPath(targetName)}/${import_node_path93.default.basename(installed2.prefixHeader)}`;
84795
+ prefixHeader = `${targetPath(targetName2)}/${import_node_path93.default.basename(installed2.prefixHeader)}`;
84653
84796
  add2(prefixHeader, import_node_fs96.default.readFileSync(installed2.prefixHeader, "utf8"));
84654
84797
  }
84655
84798
  result.nativeTargets ??= [];
84656
- let native = result.nativeTargets.find(({ name: name3 }) => name3 === targetName);
84799
+ let native = result.nativeTargets.find(({ name: name3 }) => name3 === targetName2);
84657
84800
  if (!native) {
84658
84801
  native = {
84659
- name: targetName,
84802
+ name: targetName2,
84660
84803
  deploymentTarget: null,
84661
84804
  headers: [],
84662
- publicHeaders: targetName === TURBO_CORE_TARGET ? [
84663
- `${targetPath(targetName)}/${TURBO_CORE_PUBLIC_HEADERS}/${TURBO_ENTRY_HEADER}`
84805
+ publicHeaders: targetName2 === TURBO_CORE_TARGET ? [
84806
+ `${targetPath(targetName2)}/${TURBO_CORE_PUBLIC_HEADERS}/${TURBO_ENTRY_HEADER}`
84664
84807
  ] : [],
84665
84808
  flattensPublicHeaders: false,
84666
84809
  bridgingHeader: null,
84667
84810
  prefixHeader,
84668
84811
  headerSearchPaths: [
84669
- `${targetPath(targetName)}/${targetName === TURBO_CORE_TARGET ? TURBO_CORE_PUBLIC_HEADERS : "include"}`
84812
+ `${targetPath(targetName2)}/${targetName2 === TURBO_CORE_TARGET ? TURBO_CORE_PUBLIC_HEADERS : "include"}`
84670
84813
  ],
84671
84814
  userHeaderSearchPaths: [],
84672
84815
  frameworkSearchPaths: [],
@@ -84694,7 +84837,7 @@ async function collectTurboSources(options) {
84694
84837
  throw new Error(`TurboModule source is not UTF-8: ${disk}`);
84695
84838
  add2(key2, text6);
84696
84839
  result.sources.push({ file: key2, source: disk, sha256: sha2564(bytes) });
84697
- pending2.push({ key: key2, targetName, label, root, relative: relative6 });
84840
+ pending2.push({ key: key2, targetName: targetName2, label, root, relative: relative6 });
84698
84841
  return key2;
84699
84842
  };
84700
84843
  const pending2 = [];
@@ -85049,9 +85192,9 @@ async function collectTurboSources(options) {
85049
85192
  const unregisteredObjcClasses = /* @__PURE__ */ new Set();
85050
85193
  const deferredDepUnits = [];
85051
85194
  for (const provider of providers) {
85052
- const targetName = providerTarget(provider.info.name);
85195
+ const targetName2 = providerTarget(provider.info.name);
85053
85196
  const label = provider.info.name;
85054
- const providerTargetInput = target(targetName, [
85197
+ const providerTargetInput = target(targetName2, [
85055
85198
  TURBO_CORE_TARGET
85056
85199
  ]);
85057
85200
  result.targets.push(providerTargetInput);
@@ -85069,11 +85212,11 @@ async function collectTurboSources(options) {
85069
85212
  if (provider.providerFabric) {
85070
85213
  fabric = true;
85071
85214
  fabricPackages.add(provider.name);
85072
- fabricTarget ??= { targetName, label, root: provider.root };
85215
+ fabricTarget ??= { targetName: targetName2, label, root: provider.root };
85073
85216
  }
85074
85217
  if (pod.installed?.library) {
85075
85218
  result.libraries ??= {};
85076
- result.libraries[targetName] = import_node_fs96.default.readFileSync(pod.installed.library).toString("base64");
85219
+ result.libraries[targetName2] = import_node_fs96.default.readFileSync(pod.installed.library).toString("base64");
85077
85220
  }
85078
85221
  const files2 = podFiles(pod).filter((file) => {
85079
85222
  if (!provider.reactModulesOnly || HEADER5.test(file)) return true;
@@ -85086,10 +85229,10 @@ async function collectTurboSources(options) {
85086
85229
  if (paper.length > 0) {
85087
85230
  fabric = true;
85088
85231
  paperClasses.push(...paper);
85089
- paperTarget ??= { targetName, label, root: provider.root };
85232
+ paperTarget ??= { targetName: targetName2, label, root: provider.root };
85090
85233
  }
85091
85234
  const headers = /* @__PURE__ */ new Map();
85092
- podHeaders.set(targetName, {
85235
+ podHeaders.set(targetName2, {
85093
85236
  headers,
85094
85237
  label,
85095
85238
  root,
@@ -85402,33 +85545,33 @@ async function collectTurboSources(options) {
85402
85545
  );
85403
85546
  if (filtered !== source) {
85404
85547
  if (definedFacebookReactComponentNames(filtered).size === 0) continue;
85405
- const key2 = original(targetName, "ReactCodegen", generated, file);
85548
+ const key2 = original(targetName2, "ReactCodegen", generated, file);
85406
85549
  result.files[key2] = filtered;
85407
85550
  continue;
85408
85551
  }
85409
85552
  }
85410
85553
  }
85411
- original(targetName, "ReactCodegen", generated, file);
85554
+ original(targetName2, "ReactCodegen", generated, file);
85412
85555
  }
85413
85556
  }
85414
85557
  }
85415
- for (const file of sources) original(targetName, label, root, file);
85558
+ for (const file of sources) original(targetName2, label, root, file);
85416
85559
  for (const unit2 of depUnits) {
85417
85560
  if (!unit2.companionHeader) {
85418
85561
  result.externalPodSources.push({
85419
85562
  moduleName: unit2.moduleName,
85420
- file: original(targetName, unit2.label, unit2.root, unit2.relative)
85563
+ file: original(targetName2, unit2.label, unit2.root, unit2.relative)
85421
85564
  });
85422
85565
  } else {
85423
- deferredDepUnits.push({ targetName, ...unit2 });
85566
+ deferredDepUnits.push({ targetName: targetName2, ...unit2 });
85424
85567
  }
85425
85568
  }
85426
85569
  const declared = [];
85427
85570
  for (const [count, { file, load: load2 }] of loads.entries()) {
85428
- const symbol2 = `peach_turbo_load_${targetName}_${count}`;
85571
+ const symbol2 = `peach_turbo_load_${targetName2}_${count}`;
85429
85572
  declared.push(symbol2);
85430
- result.loads.push({ symbol: symbol2, target: targetName });
85431
- const unit2 = `${targetPath(targetName)}/PeachTurboLoad${count}.cpp`;
85573
+ result.loads.push({ symbol: symbol2, target: targetName2 });
85574
+ const unit2 = `${targetPath(targetName2)}/PeachTurboLoad${count}.cpp`;
85432
85575
  add2(
85433
85576
  unit2,
85434
85577
  [
@@ -85440,21 +85583,21 @@ async function collectTurboSources(options) {
85440
85583
  ].join("\n")
85441
85584
  );
85442
85585
  scanText(
85443
- { key: unit2, targetName, label, root, relative: file },
85586
+ { key: unit2, targetName: targetName2, label, root, relative: file },
85444
85587
  result.files[unit2]
85445
85588
  );
85446
85589
  }
85447
85590
  add2(
85448
- `${targetPath(targetName)}/include/PeachTurboLoad.hpp`,
85591
+ `${targetPath(targetName2)}/include/PeachTurboLoad.hpp`,
85449
85592
  `#pragma once
85450
85593
  ${declared.map((symbol2) => `extern "C" void ${symbol2}();
85451
85594
  `).join("")}`
85452
85595
  );
85453
85596
  add2(
85454
- `${targetPath(targetName)}/include/module.modulemap`,
85455
- `module ${targetName} { header "PeachTurboLoad.hpp"${swiftSources.length > 0 || depSwiftPods.length > 0 ? publicHeaders.map((file) => {
85456
- const source = original(targetName, label, root, file);
85457
- return ` header ${JSON.stringify(import_node_path93.default.posix.relative(`${targetPath(targetName)}/include`, source))}`;
85597
+ `${targetPath(targetName2)}/include/module.modulemap`,
85598
+ `module ${targetName2} { header "PeachTurboLoad.hpp"${swiftSources.length > 0 || depSwiftPods.length > 0 ? publicHeaders.map((file) => {
85599
+ const source = original(targetName2, label, root, file);
85600
+ return ` header ${JSON.stringify(import_node_path93.default.posix.relative(`${targetPath(targetName2)}/include`, source))}`;
85458
85601
  }).join("") : ""} export * }
85459
85602
  `
85460
85603
  );
@@ -93422,7 +93565,7 @@ var init_nitro_superset = __esm({
93422
93565
  init_nitroContract();
93423
93566
  init_swift_standin_digest();
93424
93567
  NITRO_SUPERSET_ENTRY_NAME = "superset";
93425
- NITRO_COMPILER_DIGEST = true ? "2e5b44e9dc857aa080b0fdbc25e3098d25f9ca1deb9250bdd5e7c10f2f96bffc" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
93568
+ NITRO_COMPILER_DIGEST = true ? "69eced6dbfe31f0e81808ff7cd7eb781e3ed61b284e528afaa6cf96ac2d2b871" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
93426
93569
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
93427
93570
  nitroSupersetKey = (inputs) => nativeEntryKey({ ...inputs, compiler: NITRO_COMPILER_DIGEST });
93428
93571
  published2 = /* @__PURE__ */ new Map();
@@ -94114,7 +94257,7 @@ var init_one_sdk_bundle = __esm({
94114
94257
  var runtime_companion_default;
94115
94258
  var init_runtime_companion = __esm({
94116
94259
  "runtime-companion.json"() {
94117
- runtime_companion_default = { abi: 1, sha256: "7e162f525497b8964ff8f7274ce8219416ec01ac8fc6986a80d2df90a54c71c4", file: "node/cli-7e162f525497b8964ff8f7274ce8219416ec01ac8fc6986a80d2df90a54c71c4.cjs" };
94260
+ runtime_companion_default = { abi: 1, sha256: "f0ebf18540275693f13d5f0638e9e6e2afd2b8a2fa10c6d5c1190341feaa430b", file: "node/cli-f0ebf18540275693f13d5f0638e9e6e2afd2b8a2fa10c6d5c1190341feaa430b.cjs" };
94118
94261
  }
94119
94262
  });
94120
94263
 
@@ -94970,9 +95113,9 @@ async function probePortBundle(port, pageOrigin, options = {}) {
94970
95113
  const unresolved = buildUnresolvedTargetError(`localhost:${port}`);
94971
95114
  try {
94972
95115
  return await Promise.any(
94973
- LOOPBACK_PROBE_HOSTNAMES.map(async (hostname) => {
95116
+ LOOPBACK_PROBE_HOSTNAMES.map(async (hostname2) => {
94974
95117
  const bundle = await probeBaseUrlBundleDirect(
94975
- buildLoopbackProbeBaseUrl("http:", hostname, port),
95118
+ buildLoopbackProbeBaseUrl("http:", hostname2, port),
94976
95119
  port,
94977
95120
  pageOrigin,
94978
95121
  options
@@ -95744,21 +95887,21 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
95744
95887
  try {
95745
95888
  return await Promise.any(
95746
95889
  LOOPBACK_PROBE_HOSTNAMES.map(
95747
- (hostname) => new Promise((resolve14, reject) => {
95890
+ (hostname2) => new Promise((resolve14, reject) => {
95748
95891
  const sock = new import_net.default.Socket();
95749
95892
  let settled = false;
95750
95893
  const done = (reachable) => {
95751
95894
  if (settled) return;
95752
95895
  settled = true;
95753
95896
  sock.destroy();
95754
- if (reachable) resolve14(hostname);
95755
- else reject(new Error(`unreachable loopback host ${hostname}`));
95897
+ if (reachable) resolve14(hostname2);
95898
+ else reject(new Error(`unreachable loopback host ${hostname2}`));
95756
95899
  };
95757
95900
  sock.setTimeout(timeout);
95758
95901
  sock.once("connect", () => done(true));
95759
95902
  sock.once("timeout", () => done(false));
95760
95903
  sock.once("error", () => done(false));
95761
- sock.connect(port, hostname);
95904
+ sock.connect(port, hostname2);
95762
95905
  })
95763
95906
  )
95764
95907
  );
@@ -95766,7 +95909,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
95766
95909
  return null;
95767
95910
  }
95768
95911
  }
95769
- function httpGet(hostname, port, path148, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
95912
+ function httpGet(hostname2, port, path148, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
95770
95913
  return new Promise((resolve14) => {
95771
95914
  let settled = false;
95772
95915
  let killing = false;
@@ -95775,7 +95918,7 @@ function httpGet(hostname, port, path148, method = "GET", timeout = TIMEOUT_MS,
95775
95918
  settled = true;
95776
95919
  resolve14(value);
95777
95920
  };
95778
- const req = import_http.default.request({ hostname, port, path: path148, method, headers }, (res) => {
95921
+ const req = import_http.default.request({ hostname: hostname2, port, path: path148, method, headers }, (res) => {
95779
95922
  let body = "";
95780
95923
  res.on("data", (c) => body += c.toString());
95781
95924
  const contentType2 = (() => {
@@ -95790,7 +95933,7 @@ function httpGet(hostname, port, path148, method = "GET", timeout = TIMEOUT_MS,
95790
95933
  statusCode: res.statusCode || 0,
95791
95934
  body,
95792
95935
  contentType: contentType2,
95793
- hostname
95936
+ hostname: hostname2
95794
95937
  })
95795
95938
  );
95796
95939
  });
@@ -95808,16 +95951,16 @@ function httpGet(hostname, port, path148, method = "GET", timeout = TIMEOUT_MS,
95808
95951
  });
95809
95952
  });
95810
95953
  }
95811
- async function probeManifest(hostname, port, timeout) {
95954
+ async function probeManifest(hostname2, port, timeout) {
95812
95955
  let deadline;
95813
95956
  try {
95814
95957
  return await Promise.race([
95815
- fetchDevManifest(buildLoopbackProbeBaseUrl("http:", hostname, port)).then(
95958
+ fetchDevManifest(buildLoopbackProbeBaseUrl("http:", hostname2, port)).then(
95816
95959
  async (res) => res ? {
95817
95960
  statusCode: res.status,
95818
95961
  body: await res.text(),
95819
95962
  contentType: res.headers.get("content-type") || "",
95820
- hostname
95963
+ hostname: hostname2
95821
95964
  } : null
95822
95965
  ),
95823
95966
  new Promise((resolve14) => {
@@ -96089,16 +96232,16 @@ function nativeBundleRoot(projectCwd) {
96089
96232
  }
96090
96233
  return "index";
96091
96234
  }
96092
- function makeResult(hostname, port, framework, owner) {
96235
+ function makeResult(hostname2, port, framework, owner) {
96093
96236
  return {
96094
96237
  port,
96095
96238
  framework,
96096
96239
  bundleUrl: withRuntimeConfig(
96097
96240
  port,
96098
- `${buildLoopbackProbeBaseUrl("http:", hostname, port)}/${nativeBundleRoot(owner.cwd)}.bundle?platform=ios&dev=true&hot=true&minify=false`,
96241
+ `${buildLoopbackProbeBaseUrl("http:", hostname2, port)}/${nativeBundleRoot(owner.cwd)}.bundle?platform=ios&dev=true&hot=true&minify=false`,
96099
96242
  owner.cwd
96100
96243
  ),
96101
- hmrUrl: `${buildLoopbackProbeBaseUrl("ws:", hostname, port)}/hot`,
96244
+ hmrUrl: `${buildLoopbackProbeBaseUrl("ws:", hostname2, port)}/hot`,
96102
96245
  lastSeen: Date.now(),
96103
96246
  ...owner
96104
96247
  };
@@ -96141,10 +96284,10 @@ function metroAssetPath(rawIcon) {
96141
96284
  function staticAssetPath(rawIcon) {
96142
96285
  return `/${rawIcon.replace(/^\.?\//, "")}`;
96143
96286
  }
96144
- async function resolveLocalIconPath(hostname, port, rawIcon) {
96287
+ async function resolveLocalIconPath(hostname2, port, rawIcon) {
96145
96288
  const candidates = [metroAssetPath(rawIcon), staticAssetPath(rawIcon)];
96146
96289
  for (const candidate of candidates) {
96147
- const res = await httpGet(hostname, port, candidate, "HEAD", ENRICH_TIMEOUT_MS);
96290
+ const res = await httpGet(hostname2, port, candidate, "HEAD", ENRICH_TIMEOUT_MS);
96148
96291
  if (res?.statusCode === 200) {
96149
96292
  localIconPathCache.set(port, candidate);
96150
96293
  invalidatePortCache(port);
@@ -96220,8 +96363,8 @@ function ensureLocalIconPathResolved(result) {
96220
96363
  if (localIconPathCache.has(result.port)) return;
96221
96364
  if (localIconProbeInFlight.has(result.port)) return;
96222
96365
  localIconProbeInFlight.add(result.port);
96223
- const hostname = normalizeHostname(new URL(result.bundleUrl).hostname);
96224
- void resolveLocalIconPath(hostname, result.port, rawIcon).finally(
96366
+ const hostname2 = normalizeHostname(new URL(result.bundleUrl).hostname);
96367
+ void resolveLocalIconPath(hostname2, result.port, rawIcon).finally(
96225
96368
  () => localIconProbeInFlight.delete(result.port)
96226
96369
  );
96227
96370
  }
@@ -96247,14 +96390,14 @@ function enrichWithManifest(result, buildIconProxyUrl) {
96247
96390
  return result;
96248
96391
  }
96249
96392
  async function fetchManifestEnrichment(result, buildIconProxyUrl) {
96250
- const hostname = normalizeHostname(new URL(result.bundleUrl).hostname);
96251
- const manifestRes = await probeManifest(hostname, result.port, ENRICH_TIMEOUT_MS);
96393
+ const hostname2 = normalizeHostname(new URL(result.bundleUrl).hostname);
96394
+ const manifestRes = await probeManifest(hostname2, result.port, ENRICH_TIMEOUT_MS);
96252
96395
  if (!manifestRes || manifestRes.statusCode !== 200) return;
96253
96396
  const parsed = applyManifest(
96254
96397
  {
96255
96398
  port: result.port,
96256
96399
  framework: "one",
96257
- bundleUrl: `${buildLoopbackProbeBaseUrl("http:", hostname, result.port)}/index.bundle`,
96400
+ bundleUrl: `${buildLoopbackProbeBaseUrl("http:", hostname2, result.port)}/index.bundle`,
96258
96401
  lastSeen: 0
96259
96402
  },
96260
96403
  manifestRes,
@@ -96715,29 +96858,31 @@ var init_dev_server_scanner = __esm({
96715
96858
  }
96716
96859
  });
96717
96860
 
96718
- // src/agent-events.ts
96719
- function isAgentEvent(value) {
96720
- if (!value || typeof value !== "object") return false;
96721
- const v7 = value;
96722
- return typeof v7.type === "string" && typeof v7.ts === "number";
96861
+ // src/agent-prompt.ts
96862
+ function readCanvasAgentId(value) {
96863
+ return typeof value === "string" && value.length <= CANVAS_AGENT_ID_MAX_CHARS ? value.trim() || void 0 : void 0;
96723
96864
  }
96724
- function parseAgentEventLine(line) {
96725
- const trimmed = line.trim();
96726
- if (!trimmed) return null;
96727
- try {
96728
- const parsed = JSON.parse(trimmed);
96729
- return isAgentEvent(parsed) ? parsed : null;
96730
- } catch {
96865
+ function readCanvasAgentNote(value) {
96866
+ if (!value || typeof value !== "object") return null;
96867
+ const agentId = readCanvasAgentId(Reflect.get(value, "agentId"));
96868
+ const text6 = Reflect.get(value, "text");
96869
+ const inspectSummary = Reflect.get(value, "inspectSummary");
96870
+ const inspectTrace = Reflect.get(value, "inspectTrace");
96871
+ const crop = Reflect.get(value, "crop");
96872
+ if (!agentId || typeof text6 !== "string" || !text6.trim() || text6.length > 8192 || typeof inspectSummary !== "string" || !inspectSummary.trim() || inspectSummary.length > 8192 || inspectTrace !== void 0 && (typeof inspectTrace !== "string" || inspectTrace.length > 32768) || typeof crop !== "string" || crop.length > MAX_NOTE_CROP_LENGTH || !/^data:image\/(?:webp|png);base64,[A-Za-z0-9+/]+={0,2}$/.test(crop))
96731
96873
  return null;
96732
- }
96874
+ return { agentId, text: text6.trim(), inspectSummary, inspectTrace, crop };
96875
+ }
96876
+ function createCanvasAgentInspectMessage(simId, { agentId, text: text6, inspectSummary, inspectTrace, crop }) {
96877
+ return {
96878
+ id: `inspect-${globalThis.crypto.randomUUID()}`,
96879
+ simId,
96880
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
96881
+ recipientId: agentId,
96882
+ prompt: { text: text6, inspectSummary, inspectTrace },
96883
+ crop
96884
+ };
96733
96885
  }
96734
- var init_agent_events = __esm({
96735
- "src/agent-events.ts"() {
96736
- "use strict";
96737
- }
96738
- });
96739
-
96740
- // src/agent-prompt.ts
96741
96886
  function cleanPromptText(value) {
96742
96887
  return typeof value === "string" ? value.trim() : "";
96743
96888
  }
@@ -96757,14 +96902,41 @@ function encodeAgentPromptEnvelope(input) {
96757
96902
  inspectTrace
96758
96903
  });
96759
96904
  }
96760
- var ENVELOPE_MARKER;
96905
+ var MAX_NOTE_CROP_LENGTH, CANVAS_AGENT_ID_MAX_CHARS, MAX_CANVAS_AGENT_NOTE_BODY_BYTES, AGENT_NOTE_TTL_MS, AGENT_NOTE_QUEUE_LIMIT, ENVELOPE_MARKER;
96761
96906
  var init_agent_prompt = __esm({
96762
96907
  "src/agent-prompt.ts"() {
96763
96908
  "use strict";
96909
+ MAX_NOTE_CROP_LENGTH = 2 * 1024 * 1024;
96910
+ CANVAS_AGENT_ID_MAX_CHARS = 200;
96911
+ MAX_CANVAS_AGENT_NOTE_BODY_BYTES = MAX_NOTE_CROP_LENGTH + 256 * 1024;
96912
+ AGENT_NOTE_TTL_MS = 24 * 60 * 60 * 1e3;
96913
+ AGENT_NOTE_QUEUE_LIMIT = 16;
96764
96914
  ENVELOPE_MARKER = "sootsim-agent-prompt-v1";
96765
96915
  }
96766
96916
  });
96767
96917
 
96918
+ // src/agent-events.ts
96919
+ function isAgentEvent(value) {
96920
+ if (!value || typeof value !== "object") return false;
96921
+ const v7 = value;
96922
+ return typeof v7.type === "string" && typeof v7.ts === "number";
96923
+ }
96924
+ function parseAgentEventLine(line) {
96925
+ const trimmed = line.trim();
96926
+ if (!trimmed) return null;
96927
+ try {
96928
+ const parsed = JSON.parse(trimmed);
96929
+ return isAgentEvent(parsed) ? parsed : null;
96930
+ } catch {
96931
+ return null;
96932
+ }
96933
+ }
96934
+ var init_agent_events = __esm({
96935
+ "src/agent-events.ts"() {
96936
+ "use strict";
96937
+ }
96938
+ });
96939
+
96768
96940
  // src/attached-projects.ts
96769
96941
  function userDataDir() {
96770
96942
  if (overrideDir) return overrideDir;
@@ -97507,6 +97679,7 @@ var init_agent_host = __esm({
97507
97679
  import_node_fs115 = __toESM(require("node:fs"), 1);
97508
97680
  import_node_path116 = __toESM(require("node:path"), 1);
97509
97681
  init_dev_server_scanner();
97682
+ init_agent_prompt();
97510
97683
  init_agent_sessions();
97511
97684
  init_attached_projects();
97512
97685
  WS_OPEN = 1;
@@ -97524,6 +97697,7 @@ var init_agent_host = __esm({
97524
97697
  allSockets = /* @__PURE__ */ new Set();
97525
97698
  inspectQueues = /* @__PURE__ */ new Map();
97526
97699
  inspectListeners = /* @__PURE__ */ new Map();
97700
+ takenNotes = /* @__PURE__ */ new Map();
97527
97701
  // agent wrappers also emit prompt-received from the FIFO reader, but the
97528
97702
  // shell/daemon already knows the user-facing display text when send-prompt
97529
97703
  // is accepted. emit the friendly prompt immediately and suppress the raw
@@ -97622,6 +97796,7 @@ var init_agent_host = __esm({
97622
97796
  }
97623
97797
  this.inspectListeners.clear();
97624
97798
  this.inspectQueues.clear();
97799
+ this.takenNotes.clear();
97625
97800
  this.allSockets.clear();
97626
97801
  }
97627
97802
  // --- dispatch ---
@@ -97641,7 +97816,49 @@ var init_agent_host = __esm({
97641
97816
  case "agent:start-session":
97642
97817
  return this.doStartSession(msg.input ?? {});
97643
97818
  case "agent:listen-inspect":
97644
- return this.listenForInspect(ws, this.requireSimId(msg, type));
97819
+ return this.listenForInspect(
97820
+ ws,
97821
+ this.requireSimId(msg, type),
97822
+ readCanvasAgentId(msg.recipientId)
97823
+ );
97824
+ case "agent:cancel-listen-inspect": {
97825
+ const simId = this.requireSimId(msg, type);
97826
+ const listeners = this.inspectListeners.get(simId) ?? [];
97827
+ const index = listeners.findIndex((listener2) => listener2.socket === ws);
97828
+ if (index < 0) return false;
97829
+ const [listener] = listeners.splice(index, 1);
97830
+ if (!listeners.length) this.inspectListeners.delete(simId);
97831
+ listener?.reject(new AgentSessionError("CANCELED", "inspect listener canceled"));
97832
+ return true;
97833
+ }
97834
+ case "agent:take-inspect-message": {
97835
+ const recipientId = readCanvasAgentId(msg.recipientId);
97836
+ return recipientId ? this.takeInspectMessage(this.requireSimId(msg, type), recipientId, true) : null;
97837
+ }
97838
+ case "agent:send-canvas-note": {
97839
+ const simId = this.requireSimId(msg, type);
97840
+ const note = readCanvasAgentNote(msg.note);
97841
+ if (!note) throw new AgentSessionError("INVALID_NOTE", "invalid canvas note");
97842
+ if (this.inspectQueue(simId).filter((message2) => message2.recipientId).length >= AGENT_NOTE_QUEUE_LIMIT) {
97843
+ throw new AgentSessionError(
97844
+ "INBOX_FULL",
97845
+ "the simulator has too many pending notes"
97846
+ );
97847
+ }
97848
+ const message = createCanvasAgentInspectMessage(simId, note);
97849
+ this.enqueueInspectMessage(message);
97850
+ return { id: message.id };
97851
+ }
97852
+ case "agent:canvas-note-status": {
97853
+ const simId = this.requireSimId(msg, type);
97854
+ this.pruneTakenNotes();
97855
+ const pending2 = this.inspectQueue(simId).some(
97856
+ (message) => message.id === msg.messageId
97857
+ );
97858
+ return {
97859
+ status: pending2 ? "pending" : this.takenNotes.get(msg.messageId)?.simId === simId ? "taken" : "missing"
97860
+ };
97861
+ }
97645
97862
  case "agent:get-inspect-listener-status": {
97646
97863
  const simId = this.requireSimId(msg, type);
97647
97864
  return { simId, listening: (this.inspectListeners.get(simId)?.length ?? 0) > 0 };
@@ -97687,19 +97904,52 @@ var init_agent_host = __esm({
97687
97904
  if (!simId) throw new AgentSessionError("NO_SIM", `${type} requires simId`);
97688
97905
  return simId;
97689
97906
  }
97690
- listenForInspect(socket, simId) {
97691
- const queue2 = this.inspectQueues.get(simId);
97692
- const queued = queue2?.shift();
97693
- if (queued && queue2) {
97694
- if (queue2.length === 0) this.inspectQueues.delete(simId);
97695
- return Promise.resolve(queued);
97696
- }
97907
+ listenForInspect(socket, simId, recipientId) {
97908
+ const queued = this.takeInspectMessage(simId, recipientId, false);
97909
+ if (queued) return Promise.resolve(queued);
97697
97910
  return new Promise((resolve14, reject) => {
97698
97911
  const listeners = this.inspectListeners.get(simId) ?? [];
97699
- listeners.push({ socket, resolve: resolve14, reject });
97912
+ listeners.push({ socket, recipientId, resolve: resolve14, reject });
97700
97913
  this.inspectListeners.set(simId, listeners);
97701
97914
  });
97702
97915
  }
97916
+ pruneTakenNotes() {
97917
+ const now = Date.now();
97918
+ for (const [id, receipt] of this.takenNotes) {
97919
+ if (receipt.expiresAt <= now) this.takenNotes.delete(id);
97920
+ }
97921
+ }
97922
+ markInspectMessageTaken(message) {
97923
+ if (!message.recipientId) return;
97924
+ this.pruneTakenNotes();
97925
+ this.takenNotes.set(message.id, {
97926
+ simId: message.simId,
97927
+ expiresAt: Date.now() + AGENT_NOTE_TTL_MS
97928
+ });
97929
+ }
97930
+ inspectQueue(simId) {
97931
+ const queue2 = this.inspectQueues.get(simId);
97932
+ if (!queue2) return [];
97933
+ const cutoff = Date.now() - AGENT_NOTE_TTL_MS;
97934
+ const pending2 = queue2.filter(
97935
+ (message) => !message.recipientId || Date.parse(message.createdAt) > cutoff
97936
+ );
97937
+ if (pending2.length) this.inspectQueues.set(simId, pending2);
97938
+ else this.inspectQueues.delete(simId);
97939
+ return pending2;
97940
+ }
97941
+ takeInspectMessage(simId, recipientId, notesOnly = false) {
97942
+ const queue2 = this.inspectQueue(simId);
97943
+ const index = queue2.findIndex(
97944
+ (message2) => message2.recipientId ? message2.recipientId === recipientId : !notesOnly
97945
+ );
97946
+ if (index < 0) return null;
97947
+ const [message] = queue2.splice(index, 1);
97948
+ if (!queue2.length) this.inspectQueues.delete(simId);
97949
+ if (!message) return null;
97950
+ this.markInspectMessageTaken(message);
97951
+ return message;
97952
+ }
97703
97953
  sendInspectMessage(simId, prompt) {
97704
97954
  if (!prompt.text.trim()) {
97705
97955
  throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
@@ -97710,17 +97960,26 @@ var init_agent_host = __esm({
97710
97960
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
97711
97961
  prompt
97712
97962
  };
97713
- const listeners = this.inspectListeners.get(simId);
97714
- const listener = listeners?.shift();
97715
- if (listener && listeners) {
97716
- if (listeners.length === 0) this.inspectListeners.delete(simId);
97717
- listener.resolve(message);
97718
- return { ok: true, queued: false, messageId: message.id };
97719
- }
97720
- const queue2 = this.inspectQueues.get(simId) ?? [];
97963
+ const queued = this.enqueueInspectMessage(message);
97964
+ return { ok: true, queued, messageId: message.id };
97965
+ }
97966
+ enqueueInspectMessage(message) {
97967
+ const { simId, recipientId } = message;
97968
+ const listeners = this.inspectListeners.get(simId) ?? [];
97969
+ const index = listeners.findIndex(
97970
+ (listener) => !recipientId || listener.recipientId === recipientId
97971
+ );
97972
+ if (index >= 0) {
97973
+ const [listener] = listeners.splice(index, 1);
97974
+ if (!listeners.length) this.inspectListeners.delete(simId);
97975
+ this.markInspectMessageTaken(message);
97976
+ listener?.resolve(message);
97977
+ return false;
97978
+ }
97979
+ const queue2 = this.inspectQueue(simId);
97721
97980
  queue2.push(message);
97722
97981
  this.inspectQueues.set(simId, queue2);
97723
- return { ok: true, queued: true, messageId: message.id };
97982
+ return true;
97724
97983
  }
97725
97984
  async doStartSession(input) {
97726
97985
  const project2 = findProjectById(input.projectId);
@@ -100616,8 +100875,8 @@ function resolveRedirectUrl(location, from) {
100616
100875
  if (!location.includes("#")) next.hash = from.hash;
100617
100876
  return next;
100618
100877
  }
100619
- function headerOverridesFor(hostname) {
100620
- const host2 = hostname.toLowerCase();
100878
+ function headerOverridesFor(hostname2) {
100879
+ const host2 = hostname2.toLowerCase();
100621
100880
  for (const override of HOST_HEADER_OVERRIDES) {
100622
100881
  if (host2 === override.hostSuffix || host2.endsWith(`.${override.hostSuffix}`)) {
100623
100882
  return override;
@@ -100946,8 +101205,8 @@ var init_hostname_resolver = __esm({
100946
101205
  });
100947
101206
 
100948
101207
  // src/host/loopback-ports.ts
100949
- function projectLoopbackPort(hostname, port) {
100950
- return isLoopbackHost(hostname) ? LOOPBACK_PORTS.get(port) ?? port : port;
101208
+ function projectLoopbackPort(hostname2, port) {
101209
+ return isLoopbackHost(hostname2) ? LOOPBACK_PORTS.get(port) ?? port : port;
100951
101210
  }
100952
101211
  function projectLoopbackUrl(value) {
100953
101212
  if (LOOPBACK_PORTS.size === 0) return value;
@@ -108796,10 +109055,11 @@ function rnxCloudScopesAllowCommand(scopes, type) {
108796
109055
  function isRnxCloudSimStatus(value) {
108797
109056
  return value === "creating" || value === "open" || value === "hibernated" || value === "deleting" || value === "deleted";
108798
109057
  }
108799
- var RNX_CLOUD_MAX_ARTIFACT_BYTES, RNX_CLOUD_DESIGN_MAX_STORAGE_BYTES, RNX_CLOUD_COMMAND_SCOPES, RNX_CLOUD_COMMAND_TYPES, RNX_CLOUD_COMMAND_TYPE_SET, RNX_CLOUD_TOKEN_SCOPES, RNX_CLOUD_ALL_COMMAND_SCOPES;
109058
+ var AGENT_IDENTITY_MAX_CHARS, RNX_CLOUD_MAX_ARTIFACT_BYTES, RNX_CLOUD_DESIGN_MAX_STORAGE_BYTES, RNX_CLOUD_COMMAND_SCOPES, RNX_CLOUD_COMMAND_TYPES, RNX_CLOUD_COMMAND_TYPE_SET, RNX_CLOUD_TOKEN_SCOPES, RNX_CLOUD_ALL_COMMAND_SCOPES;
108800
109059
  var init_cloud_contract = __esm({
108801
109060
  "src/cloud-contract.ts"() {
108802
109061
  "use strict";
109062
+ AGENT_IDENTITY_MAX_CHARS = 200;
108803
109063
  RNX_CLOUD_MAX_ARTIFACT_BYTES = 40761776;
108804
109064
  RNX_CLOUD_DESIGN_MAX_STORAGE_BYTES = 1024 * 1024;
108805
109065
  RNX_CLOUD_COMMAND_SCOPES = {
@@ -109026,6 +109286,560 @@ var init_cloud_session = __esm({
109026
109286
  }
109027
109287
  });
109028
109288
 
109289
+ // ../peach-kit/src/agent-identity.ts
109290
+ function formatLockOwner(owner) {
109291
+ const colon = owner.indexOf(":");
109292
+ if (colon <= 0) return owner.length > 24 ? `${owner.slice(0, 21)}\u2026` : owner;
109293
+ const source = owner.slice(0, colon);
109294
+ const value = owner.slice(colon + 1);
109295
+ if (source === "PEACH_CLI_IDENTITY" && value) return value;
109296
+ const short = value.length > 12 ? `${value.slice(0, 8)}\u2026` : value;
109297
+ if (source === "CLAUDE_CODE_SESSION_ID" || source === "CODEX_THREAD_ID") {
109298
+ return `agent ${short}`;
109299
+ }
109300
+ return `${source} ${short}`;
109301
+ }
109302
+ var init_agent_identity = __esm({
109303
+ "../peach-kit/src/agent-identity.ts"() {
109304
+ "use strict";
109305
+ }
109306
+ });
109307
+
109308
+ // cli/parent-pid.ts
109309
+ function getParentPid(pid) {
109310
+ if (!cached3) cached3 = build();
109311
+ try {
109312
+ return cached3(pid);
109313
+ } catch {
109314
+ return null;
109315
+ }
109316
+ }
109317
+ function getProcessComm(pid) {
109318
+ if (!cachedComm) cachedComm = buildComm();
109319
+ try {
109320
+ return cachedComm(pid);
109321
+ } catch {
109322
+ return null;
109323
+ }
109324
+ }
109325
+ function getProcessPgid(pid) {
109326
+ if (!cachedPgid) cachedPgid = buildPgid();
109327
+ try {
109328
+ return cachedPgid(pid);
109329
+ } catch {
109330
+ return null;
109331
+ }
109332
+ }
109333
+ function buildComm() {
109334
+ if (process.platform === "linux") {
109335
+ return (pid) => {
109336
+ try {
109337
+ return (0, import_fs4.readFileSync)(`/proc/${pid}/comm`, "utf8").trim() || null;
109338
+ } catch {
109339
+ return null;
109340
+ }
109341
+ };
109342
+ }
109343
+ if (process.platform === "darwin") {
109344
+ const ffi = tryBuildDarwinCommFfi();
109345
+ if (ffi) return ffi;
109346
+ return (pid) => readProcessTable2().get(pid)?.comm || null;
109347
+ }
109348
+ return () => null;
109349
+ }
109350
+ function build() {
109351
+ if (process.platform === "linux") return buildLinux();
109352
+ if (process.platform === "darwin") {
109353
+ const ffi = tryBuildDarwinFfi();
109354
+ if (ffi) return ffi;
109355
+ return (pid) => {
109356
+ const ppid = readProcessTable2().get(pid)?.ppid;
109357
+ return ppid !== void 0 && ppid > 0 ? ppid : null;
109358
+ };
109359
+ }
109360
+ return () => null;
109361
+ }
109362
+ function buildPgid() {
109363
+ if (process.platform === "linux") {
109364
+ return (pid) => {
109365
+ try {
109366
+ const raw2 = (0, import_fs4.readFileSync)(`/proc/${pid}/stat`, "utf8");
109367
+ const end = raw2.lastIndexOf(")");
109368
+ if (end < 0) return null;
109369
+ const rest = raw2.slice(end + 1).trim().split(/\s+/);
109370
+ const pgid = Number(rest[2]);
109371
+ return Number.isFinite(pgid) && pgid > 0 ? pgid : null;
109372
+ } catch {
109373
+ return null;
109374
+ }
109375
+ };
109376
+ }
109377
+ if (process.platform === "darwin") {
109378
+ const ffi = tryBuildDarwinPgidFfi();
109379
+ if (ffi) return ffi;
109380
+ return (pid) => {
109381
+ const pgid = readProcessTable2().get(pid)?.pgid;
109382
+ return pgid !== void 0 && pgid > 0 ? pgid : null;
109383
+ };
109384
+ }
109385
+ return () => null;
109386
+ }
109387
+ function readProcessTable2() {
109388
+ const now = Date.now();
109389
+ if (processTable2.readAt && now - processTable2.readAt < PROCESS_TABLE_TTL_MS) {
109390
+ return processTable2.rows;
109391
+ }
109392
+ const rows = /* @__PURE__ */ new Map();
109393
+ try {
109394
+ const out = (0, import_child_process3.execFileSync)("ps", ["-eo", "pid=,ppid=,pgid=,comm="], {
109395
+ encoding: "utf8",
109396
+ timeout: 5e3,
109397
+ maxBuffer: 8 * 1024 * 1024,
109398
+ stdio: ["ignore", "pipe", "ignore"]
109399
+ });
109400
+ for (const line of out.split("\n")) {
109401
+ const parsed = line.trim().match(/^(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/);
109402
+ if (!parsed) continue;
109403
+ rows.set(Number(parsed[1]), {
109404
+ ppid: Number(parsed[2]),
109405
+ pgid: Number(parsed[3]),
109406
+ comm: (parsed[4].split("/").at(-1) ?? "").slice(0, PBI_COMM_LEN)
109407
+ });
109408
+ }
109409
+ } catch {
109410
+ }
109411
+ processTable2 = { readAt: now, rows };
109412
+ return rows;
109413
+ }
109414
+ function buildLinux() {
109415
+ return (pid) => {
109416
+ try {
109417
+ const raw2 = (0, import_fs4.readFileSync)(`/proc/${pid}/stat`, "utf8");
109418
+ const end = raw2.lastIndexOf(")");
109419
+ if (end < 0) return null;
109420
+ const rest = raw2.slice(end + 1).trim().split(/\s+/);
109421
+ const ppid = Number(rest[1]);
109422
+ return Number.isFinite(ppid) && ppid > 0 ? ppid : null;
109423
+ } catch {
109424
+ return null;
109425
+ }
109426
+ };
109427
+ }
109428
+ function tryBuildDarwinFfi() {
109429
+ if (!process.versions?.bun) return null;
109430
+ try {
109431
+ const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
109432
+ const { dlopen, FFIType } = r("bun:ffi");
109433
+ const lib = dlopen("/usr/lib/libproc.dylib", {
109434
+ proc_pidinfo: {
109435
+ args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
109436
+ returns: FFIType.i32
109437
+ }
109438
+ });
109439
+ const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
109440
+ return (pid) => {
109441
+ const ret = Number(
109442
+ lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
109443
+ );
109444
+ if (ret <= 0) return null;
109445
+ const ppid = buf.readUInt32LE(PBI_PPID_OFFSET);
109446
+ return ppid > 0 ? ppid : null;
109447
+ };
109448
+ } catch {
109449
+ return null;
109450
+ }
109451
+ }
109452
+ function tryBuildDarwinCommFfi() {
109453
+ if (!process.versions?.bun) return null;
109454
+ try {
109455
+ const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
109456
+ const { dlopen, FFIType } = r("bun:ffi");
109457
+ const lib = dlopen("/usr/lib/libproc.dylib", {
109458
+ proc_pidinfo: {
109459
+ args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
109460
+ returns: FFIType.i32
109461
+ }
109462
+ });
109463
+ const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
109464
+ return (pid) => {
109465
+ const ret = Number(
109466
+ lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
109467
+ );
109468
+ if (ret <= 0) return null;
109469
+ const raw2 = buf.subarray(PBI_COMM_OFFSET, PBI_COMM_OFFSET + PBI_COMM_LEN);
109470
+ const end = raw2.indexOf(0);
109471
+ const comm = raw2.subarray(0, end < 0 ? raw2.length : end).toString("utf8");
109472
+ return comm || null;
109473
+ };
109474
+ } catch {
109475
+ return null;
109476
+ }
109477
+ }
109478
+ function tryBuildDarwinPgidFfi() {
109479
+ if (!process.versions?.bun) return null;
109480
+ try {
109481
+ const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
109482
+ const { dlopen, FFIType } = r("bun:ffi");
109483
+ const lib = dlopen("/usr/lib/libproc.dylib", {
109484
+ proc_pidinfo: {
109485
+ args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
109486
+ returns: FFIType.i32
109487
+ }
109488
+ });
109489
+ const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
109490
+ return (pid) => {
109491
+ const ret = Number(
109492
+ lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
109493
+ );
109494
+ if (ret <= 0) return null;
109495
+ const pgid = buf.readUInt32LE(PBI_PGID_OFFSET);
109496
+ return pgid > 0 ? pgid : null;
109497
+ };
109498
+ } catch {
109499
+ return null;
109500
+ }
109501
+ }
109502
+ var import_child_process3, import_fs4, import_module, cached3, cachedComm, cachedPgid, PROCESS_TABLE_TTL_MS, processTable2, PROC_PIDTBSDINFO, PROC_BSDINFO_SIZE, PBI_PPID_OFFSET, PBI_COMM_OFFSET, PBI_COMM_LEN, PBI_PGID_OFFSET;
109503
+ var init_parent_pid = __esm({
109504
+ "cli/parent-pid.ts"() {
109505
+ "use strict";
109506
+ import_child_process3 = require("child_process");
109507
+ import_fs4 = require("fs");
109508
+ import_module = require("module");
109509
+ cached3 = null;
109510
+ cachedComm = null;
109511
+ cachedPgid = null;
109512
+ PROCESS_TABLE_TTL_MS = 2e3;
109513
+ processTable2 = { readAt: 0, rows: /* @__PURE__ */ new Map() };
109514
+ PROC_PIDTBSDINFO = 3;
109515
+ PROC_BSDINFO_SIZE = 216;
109516
+ PBI_PPID_OFFSET = 16;
109517
+ PBI_COMM_OFFSET = 48;
109518
+ PBI_COMM_LEN = 16;
109519
+ PBI_PGID_OFFSET = 100;
109520
+ }
109521
+ });
109522
+
109523
+ // cli/current-sim.ts
109524
+ function findTopAncestor(start, maxDepth = 20) {
109525
+ let prev = start;
109526
+ let pid = getParentPid(start);
109527
+ if (!pid || pid <= 1) {
109528
+ const comm = getProcessComm(start);
109529
+ if (!comm || start < 1 || IMMORTAL_HOST_COMM_RE.test(comm)) return null;
109530
+ return start > 1 || !INIT_COMM_RE.test(comm) ? start : null;
109531
+ }
109532
+ for (let i = 0; i < maxDepth; i++) {
109533
+ const comm = getProcessComm(pid);
109534
+ if (comm && IMMORTAL_HOST_COMM_RE.test(comm)) return prev;
109535
+ const parent = getParentPid(pid);
109536
+ if (!parent || parent <= 1) {
109537
+ return comm ? pid : prev;
109538
+ }
109539
+ prev = pid;
109540
+ pid = parent;
109541
+ }
109542
+ return pid;
109543
+ }
109544
+ function getCliIdentity() {
109545
+ for (const name3 of IDENTITY_ENV_VARS) {
109546
+ const value = process.env[name3];
109547
+ if (value && value.trim()) {
109548
+ return { key: `${name3}:${value.trim()}`, source: name3, stable: true };
109549
+ }
109550
+ }
109551
+ const topPid = findTopAncestor(process.ppid);
109552
+ if (topPid) {
109553
+ return { key: `gppid-${topPid}`, source: "grand-ppid", stable: true };
109554
+ }
109555
+ return { key: `pid-${process.ppid}`, source: "ppid", stable: false };
109556
+ }
109557
+ function getCliIdentityKey() {
109558
+ return getCliIdentity().key;
109559
+ }
109560
+ function getStableOwnerPid() {
109561
+ return findTopAncestor(process.ppid);
109562
+ }
109563
+ function getOwnerProcessGroupId(owner = getStableOwnerPid()) {
109564
+ if (!owner || owner <= 1) return null;
109565
+ const pgid = getProcessPgid(owner);
109566
+ return pgid !== null && pgid > 1 ? pgid : null;
109567
+ }
109568
+ function getCurrentSimPath() {
109569
+ const envPath = process.env[CURRENT_SIM_PATH_ENV];
109570
+ if (envPath) {
109571
+ return (0, import_path4.resolve)(envPath);
109572
+ }
109573
+ const key2 = getCliIdentityKey();
109574
+ return (0, import_path4.join)((0, import_os.tmpdir)(), `peach-current-sim-${key2}.json`);
109575
+ }
109576
+ function legacyCloudCredentialDirectory(filepath) {
109577
+ return (0, import_path4.join)((0, import_path4.dirname)(filepath), `${(0, import_path4.basename)(filepath)}.credentials`);
109578
+ }
109579
+ function readCurrentTarget() {
109580
+ const filepath = getCurrentSimPath();
109581
+ (0, import_fs5.rmSync)(legacyCloudCredentialDirectory(filepath), { recursive: true, force: true });
109582
+ if (!(0, import_fs5.existsSync)(filepath)) return null;
109583
+ try {
109584
+ const parsed = JSON.parse((0, import_fs5.readFileSync)(filepath, "utf8"));
109585
+ if (parsed === null || typeof parsed !== "object") {
109586
+ (0, import_fs5.rmSync)(filepath, { force: true });
109587
+ return null;
109588
+ }
109589
+ if (Reflect.get(parsed, "pendingOpen") === true) return null;
109590
+ const version2 = Reflect.get(parsed, "version");
109591
+ const plane = Reflect.get(parsed, "plane");
109592
+ const simId = Reflect.get(parsed, "simId");
109593
+ const updatedAt = Reflect.get(parsed, "updatedAt");
109594
+ const rawPort = Reflect.get(parsed, "bridgePort");
109595
+ const bridgePort = typeof rawPort === "number" && Number.isInteger(rawPort) && rawPort > 0 ? rawPort : void 0;
109596
+ if (version2 !== 1 && version2 !== CURRENT_SIM_VERSION || version2 === CURRENT_SIM_VERSION && plane !== "local" || typeof simId !== "string" || !simId.trim() || typeof updatedAt !== "string") {
109597
+ (0, import_fs5.rmSync)(filepath, { force: true });
109598
+ return null;
109599
+ }
109600
+ const target = {
109601
+ version: CURRENT_SIM_VERSION,
109602
+ plane: "local",
109603
+ simId: simId.trim(),
109604
+ ...bridgePort === void 0 ? {} : { bridgePort },
109605
+ updatedAt
109606
+ };
109607
+ if (version2 === 1) writeSecureJsonAtomic(filepath, target, { durable: false });
109608
+ return target;
109609
+ } catch {
109610
+ (0, import_fs5.rmSync)(filepath, { force: true });
109611
+ return null;
109612
+ }
109613
+ }
109614
+ function readCurrentSimId() {
109615
+ return readCurrentTarget()?.simId ?? null;
109616
+ }
109617
+ function writeCurrentSim(simId, bridgePort) {
109618
+ const normalized = simId.trim();
109619
+ if (!normalized) return;
109620
+ writeSecureJsonAtomic(
109621
+ getCurrentSimPath(),
109622
+ {
109623
+ version: CURRENT_SIM_VERSION,
109624
+ plane: "local",
109625
+ simId: normalized,
109626
+ ...bridgePort === void 0 ? {} : { bridgePort },
109627
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
109628
+ },
109629
+ { durable: false }
109630
+ );
109631
+ }
109632
+ function saveCurrentSimId(simId, bridgePort) {
109633
+ writeCurrentSim(simId, bridgePort);
109634
+ }
109635
+ function replaceCurrentSimId(simId) {
109636
+ writeCurrentSim(simId, readCurrentTarget()?.bridgePort);
109637
+ }
109638
+ function getAgentIdPath() {
109639
+ return `${getCurrentSimPath()}.agent-id`;
109640
+ }
109641
+ function saveAgentId(agentId) {
109642
+ writeSecureJsonAtomic(getAgentIdPath(), { agentId }, { durable: false });
109643
+ }
109644
+ function readAgentId() {
109645
+ const filepath = getAgentIdPath();
109646
+ if (!(0, import_fs5.existsSync)(filepath)) return void 0;
109647
+ try {
109648
+ const parsed = JSON.parse((0, import_fs5.readFileSync)(filepath, "utf8"));
109649
+ const agentId = parsed !== null && typeof parsed === "object" ? Reflect.get(parsed, "agentId") : void 0;
109650
+ return typeof agentId === "string" && agentId.trim() ? agentId.trim() : void 0;
109651
+ } catch {
109652
+ (0, import_fs5.rmSync)(filepath, { force: true });
109653
+ return void 0;
109654
+ }
109655
+ }
109656
+ function clearCurrentSimId() {
109657
+ (0, import_fs5.rmSync)(getCurrentSimPath(), { force: true });
109658
+ }
109659
+ function markOpenPending() {
109660
+ writeSecureJsonAtomic(
109661
+ getCurrentSimPath(),
109662
+ {
109663
+ version: CURRENT_SIM_VERSION,
109664
+ plane: "local",
109665
+ pendingOpen: true,
109666
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
109667
+ },
109668
+ { durable: false }
109669
+ );
109670
+ }
109671
+ function assertNoPendingOpen() {
109672
+ if (!isOpenPending()) return;
109673
+ throw new PendingOpenError(
109674
+ "the last `peach open` did not pin a sim, so this command would land on whichever tab is connected. run `peach open` again, `peach use <sim>`, or pass --sim <id>"
109675
+ );
109676
+ }
109677
+ function isOpenPending() {
109678
+ const filepath = getCurrentSimPath();
109679
+ if (!(0, import_fs5.existsSync)(filepath)) return false;
109680
+ try {
109681
+ const parsed = JSON.parse((0, import_fs5.readFileSync)(filepath, "utf8"));
109682
+ return parsed !== null && typeof parsed === "object" && Reflect.get(parsed, "pendingOpen") === true;
109683
+ } catch {
109684
+ return false;
109685
+ }
109686
+ }
109687
+ var import_fs5, import_os, import_path4, CURRENT_SIM_VERSION, CURRENT_SIM_PATH_ENV, IDENTITY_ENV_VARS, IMMORTAL_HOST_COMM_RE, INIT_COMM_RE, readCurrentSim, PendingOpenError;
109688
+ var init_current_sim = __esm({
109689
+ "cli/current-sim.ts"() {
109690
+ "use strict";
109691
+ import_fs5 = require("fs");
109692
+ import_os = require("os");
109693
+ import_path4 = require("path");
109694
+ init_parent_pid();
109695
+ init_secure_file();
109696
+ CURRENT_SIM_VERSION = 2;
109697
+ CURRENT_SIM_PATH_ENV = "PEACH_CLI_CURRENT_SIM_PATH";
109698
+ IDENTITY_ENV_VARS = [
109699
+ "PEACH_CLI_IDENTITY",
109700
+ // explicit override — fastest path, skips all pid lookups
109701
+ "CLAUDE_CODE_SESSION_ID",
109702
+ // claude code, if ever set
109703
+ "CODEX_THREAD_ID",
109704
+ // codex / openai agent thread, stable across tool invocations
109705
+ // a Team Machine session, per agent run. its other runners set no session
109706
+ // variable of their own, and the terminal variables below are inherited from
109707
+ // whatever shell started the daemon, so every such agent would share one key.
109708
+ "TM_SESSION",
109709
+ "TERM_SESSION_ID",
109710
+ // macOS Terminal.app + iTerm2
109711
+ "ITERM_SESSION_ID",
109712
+ // iTerm2 (older variant)
109713
+ "TMUX_PANE",
109714
+ // tmux — stable per pane
109715
+ "STY",
109716
+ // GNU screen session
109717
+ "KITTY_WINDOW_ID",
109718
+ // kitty
109719
+ "WEZTERM_PANE",
109720
+ // wezterm
109721
+ "ALACRITTY_WINDOW_ID",
109722
+ // alacritty
109723
+ "WINDOWID",
109724
+ // X11 terminals
109725
+ "VSCODE_INJECTION"
109726
+ // vscode integrated terminal
109727
+ ];
109728
+ IMMORTAL_HOST_COMM_RE = /^(?:tmux|screen)|^tm$/i;
109729
+ INIT_COMM_RE = /^(?:init|systemd|launchd|tini|docker-init|dumb-init|catatonit|s6-svscan|runsvdir)$/i;
109730
+ readCurrentSim = readCurrentTarget;
109731
+ PendingOpenError = class extends Error {
109732
+ };
109733
+ }
109734
+ });
109735
+
109736
+ // cli/command-agent.ts
109737
+ function clip(text6) {
109738
+ return text6.length > AGENT_IDENTITY_MAX_CHARS ? `${text6.slice(0, AGENT_IDENTITY_MAX_CHARS - 1)}\u2026` : text6;
109739
+ }
109740
+ function targetName(target) {
109741
+ const name3 = target?.text?.trim() || target?.testID?.trim() || target?.id?.trim();
109742
+ return name3 ? name3.replace(/\s+/g, " ") : null;
109743
+ }
109744
+ function verb(action, target) {
109745
+ return target ? `${action} ${target}` : action;
109746
+ }
109747
+ function describeStep(step) {
109748
+ switch (step.type) {
109749
+ case "tap":
109750
+ return verb("Tapping", targetName(step.target));
109751
+ case "tapId":
109752
+ return verb("Tapping", step.id);
109753
+ case "doubleTap":
109754
+ return "Double tapping";
109755
+ case "longPress":
109756
+ return verb("Long pressing", targetName(step.target));
109757
+ case "drag":
109758
+ return "Dragging";
109759
+ case "pinch":
109760
+ return "Pinching";
109761
+ case "scroll":
109762
+ return verb("Scrolling", step.id);
109763
+ case "touchDown":
109764
+ case "touchMove":
109765
+ case "touchUp":
109766
+ case "touchCancel":
109767
+ return "Touching the screen";
109768
+ case "type":
109769
+ case "typeInto":
109770
+ case "setElementValue":
109771
+ return "Typing";
109772
+ case "key":
109773
+ case "keyDown":
109774
+ case "keyUp":
109775
+ return "Pressing a key";
109776
+ case "dismissKeyboard":
109777
+ case "toggleKeyboard":
109778
+ return "Using the keyboard";
109779
+ case "openUrl":
109780
+ return "Opening a link";
109781
+ case "setOrientation":
109782
+ return `Rotating to ${step.orientation}`;
109783
+ case "incrementElement":
109784
+ case "decrementElement":
109785
+ return verb("Adjusting", step.id);
109786
+ case "buttonDown":
109787
+ case "buttonUp":
109788
+ case "wait":
109789
+ case "waitFor":
109790
+ case "deviceInfo":
109791
+ case "discoverStoreKitConfig":
109792
+ case "clearStoreKitConfig":
109793
+ return null;
109794
+ }
109795
+ }
109796
+ function describeCommand(command) {
109797
+ switch (command.type) {
109798
+ case "tap":
109799
+ return verb("Tapping", targetName(command.target));
109800
+ case "longPress":
109801
+ return verb("Long pressing", targetName(command.target));
109802
+ case "keyboard":
109803
+ return command.action === "dismiss" ? "Dismissing the keyboard" : command.action === "press" || command.action === "dispatchKey" ? "Pressing a key" : "Typing";
109804
+ case "screenshot":
109805
+ return "Taking a screenshot";
109806
+ case "perform": {
109807
+ const labels = (command.steps ?? []).flatMap((step) => describeStep(step) ?? []);
109808
+ const [first] = labels;
109809
+ if (!first) return null;
109810
+ return labels.length === 1 ? first : `${first}, then ${labels.length - 1} more`;
109811
+ }
109812
+ default:
109813
+ return null;
109814
+ }
109815
+ }
109816
+ function commandAgent(command) {
109817
+ const step = describeCommand(command);
109818
+ if (!step) return void 0;
109819
+ const identity2 = getCliIdentity();
109820
+ if (!identity2.stable) return void 0;
109821
+ const machine = (0, import_os2.hostname)().split(".")[0];
109822
+ if (!machine) return void 0;
109823
+ return {
109824
+ id: clip(identity2.key),
109825
+ name: clip(
109826
+ readAgentId() ?? (process.env.PEACH_AGENT_ID?.trim() || formatLockOwner(identity2.key))
109827
+ ),
109828
+ machine: clip(machine),
109829
+ step: clip(step)
109830
+ };
109831
+ }
109832
+ var import_os2;
109833
+ var init_command_agent = __esm({
109834
+ "cli/command-agent.ts"() {
109835
+ "use strict";
109836
+ import_os2 = require("os");
109837
+ init_agent_identity();
109838
+ init_cloud_contract();
109839
+ init_current_sim();
109840
+ }
109841
+ });
109842
+
109029
109843
  // ../peach-globals/src/github-workflow-contract.ts
109030
109844
  var init_github_workflow_contract = __esm({
109031
109845
  "../peach-globals/src/github-workflow-contract.ts"() {
@@ -109044,7 +109858,7 @@ var init_github_workflow_identity = __esm({
109044
109858
  // cli/run-registry.ts
109045
109859
  function gitOutput(command, cwd) {
109046
109860
  try {
109047
- const out = (0, import_child_process3.execSync)(command, {
109861
+ const out = (0, import_child_process4.execSync)(command, {
109048
109862
  cwd,
109049
109863
  stdio: ["ignore", "pipe", "ignore"],
109050
109864
  timeout: 3e3,
@@ -109063,11 +109877,11 @@ function resolveCheckoutRepo(cwd) {
109063
109877
  );
109064
109878
  return match ? `${match[1]}/${match[2]}` : null;
109065
109879
  }
109066
- var import_child_process3;
109880
+ var import_child_process4;
109067
109881
  var init_run_registry = __esm({
109068
109882
  "cli/run-registry.ts"() {
109069
109883
  "use strict";
109070
- import_child_process3 = require("child_process");
109884
+ import_child_process4 = require("child_process");
109071
109885
  init_auth();
109072
109886
  init_github_workflow_identity();
109073
109887
  }
@@ -110243,6 +111057,7 @@ var init_cloud_client = __esm({
110243
111057
  init_public_brand();
110244
111058
  init_auth();
110245
111059
  init_cloud_session();
111060
+ init_command_agent();
110246
111061
  init_detect();
110247
111062
  init_run_registry();
110248
111063
  DEFAULT_RNX_CLOUD_ORIGIN = rnxPublicBrand.origin;
@@ -110287,10 +111102,11 @@ var init_cloud_client = __esm({
110287
111102
  plane = "cloud";
110288
111103
  async send(command, options) {
110289
111104
  const timeoutMs = options?.timeoutMs ?? this.explicitTimeoutMs ?? options?.defaultTimeoutMs;
111105
+ const agent = commandAgent(command);
110290
111106
  const body = {
110291
111107
  id: (0, import_node_crypto73.randomUUID)(),
110292
111108
  claimId: this.session.claimId,
110293
- command: cloudCommand(command)
111109
+ command: cloudCommand(agent ? { ...command, agent } : command)
110294
111110
  };
110295
111111
  let response;
110296
111112
  try {
@@ -110363,6 +111179,8 @@ var init_cloud_client = __esm({
110363
111179
  for (const [key2, value] of Object.entries(command)) {
110364
111180
  if (key2 !== "id" && key2 !== "simId") payload[key2] = value;
110365
111181
  }
111182
+ const agent = commandAgent(command);
111183
+ if (agent) payload.agent = agent;
110366
111184
  let response;
110367
111185
  try {
110368
111186
  response = await fetch(
@@ -110534,16 +111352,16 @@ function unrefTimer(timer) {
110534
111352
  timer.unref();
110535
111353
  }
110536
111354
  }
110537
- var import_child_process4, import_crypto2, import_fs4, import_http4, import_os, import_path4, import_ws2, SOOTSIM_CROSS_ORIGIN_EMBEDDER_POLICY, FORCE_CLOSE_GRACE_MS, FORCE_CLOSE_TERMINATE_MS, MAX_RETAINED_DISCONNECTS, DAEMON_HEARTBEAT_INTERVAL_MS, DEFAULT_RUNTIME_UPDATE_INTERVAL_MS, RUNTIME_UPDATE_INTERVAL_ENV, HTTP_MIME_TYPES, CAMERA_FIXTURE_ROUTE, CAMERA_FIXTURE_NAME_RE, SootSimBridgeHost;
111355
+ var import_child_process5, import_crypto2, import_fs6, import_http4, import_os3, import_path5, import_ws2, SOOTSIM_CROSS_ORIGIN_EMBEDDER_POLICY, FORCE_CLOSE_GRACE_MS, FORCE_CLOSE_TERMINATE_MS, MAX_RETAINED_DISCONNECTS, DAEMON_HEARTBEAT_INTERVAL_MS, DEFAULT_RUNTIME_UPDATE_INTERVAL_MS, RUNTIME_UPDATE_INTERVAL_ENV, HTTP_MIME_TYPES, CAMERA_FIXTURE_ROUTE, CAMERA_FIXTURE_NAME_RE, SootSimBridgeHost;
110538
111356
  var init_bridge_host = __esm({
110539
111357
  "src/host/bridge-host.ts"() {
110540
111358
  "use strict";
110541
- import_child_process4 = __toESM(require("child_process"), 1);
111359
+ import_child_process5 = __toESM(require("child_process"), 1);
110542
111360
  import_crypto2 = require("crypto");
110543
- import_fs4 = __toESM(require("fs"), 1);
111361
+ import_fs6 = __toESM(require("fs"), 1);
110544
111362
  import_http4 = require("http");
110545
- import_os = __toESM(require("os"), 1);
110546
- import_path4 = __toESM(require("path"), 1);
111363
+ import_os3 = __toESM(require("os"), 1);
111364
+ import_path5 = __toESM(require("path"), 1);
110547
111365
  import_ws2 = require("ws");
110548
111366
  init_automatic_update_policy();
110549
111367
  init_bridge_constants();
@@ -110711,7 +111529,7 @@ var init_bridge_host = __esm({
110711
111529
  async startAsync(options) {
110712
111530
  if (this.httpServer || this.wss) return this.effectivePort;
110713
111531
  const bootRuntimeDir = this.getActiveRuntime().runtimeDir;
110714
- this.bootstrapping = this.shouldWriteLockfile && (!bootRuntimeDir || !import_fs4.default.existsSync(import_path4.default.join(bootRuntimeDir, "index.html")));
111532
+ this.bootstrapping = this.shouldWriteLockfile && (!bootRuntimeDir || !import_fs6.default.existsSync(import_path5.default.join(bootRuntimeDir, "index.html")));
110715
111533
  for (let attempt = 0; attempt < this.portFallbackCount; attempt++) {
110716
111534
  const candidate = this.preferredPort === 0 ? 0 : this.preferredPort + attempt;
110717
111535
  try {
@@ -111400,10 +112218,10 @@ var init_bridge_host = __esm({
111400
112218
  return;
111401
112219
  }
111402
112220
  const root = cameraFixturesDir();
111403
- const filePath = import_path4.default.join(root, name3);
112221
+ const filePath = import_path5.default.join(root, name3);
111404
112222
  let stats;
111405
112223
  try {
111406
- stats = import_fs4.default.lstatSync(filePath);
112224
+ stats = import_fs6.default.lstatSync(filePath);
111407
112225
  } catch {
111408
112226
  res.writeHead(404, { ...cors, "Content-Type": "text/plain; charset=utf-8" });
111409
112227
  res.end("not found");
@@ -111414,7 +112232,7 @@ var init_bridge_host = __esm({
111414
112232
  res.end("forbidden");
111415
112233
  return;
111416
112234
  }
111417
- const contentType2 = HTTP_MIME_TYPES[import_path4.default.extname(filePath).toLowerCase()] || "application/octet-stream";
112235
+ const contentType2 = HTTP_MIME_TYPES[import_path5.default.extname(filePath).toLowerCase()] || "application/octet-stream";
111418
112236
  sendFileWithRanges(req, res, filePath, stats.size, {
111419
112237
  ...cors,
111420
112238
  "Content-Type": contentType2
@@ -111858,35 +112676,35 @@ var init_bridge_host = __esm({
111858
112676
  return;
111859
112677
  }
111860
112678
  }
111861
- const resolved = import_path4.default.resolve(baseDir, "." + rel);
111862
- const baseWithSep = baseDir.endsWith(import_path4.default.sep) ? baseDir : baseDir + import_path4.default.sep;
112679
+ const resolved = import_path5.default.resolve(baseDir, "." + rel);
112680
+ const baseWithSep = baseDir.endsWith(import_path5.default.sep) ? baseDir : baseDir + import_path5.default.sep;
111863
112681
  if (!resolved.startsWith(baseWithSep) && resolved !== baseDir) {
111864
112682
  res.writeHead(403);
111865
112683
  res.end("forbidden");
111866
112684
  return;
111867
112685
  }
111868
112686
  void ensureRuntimePackFor(baseDir, rel).then(
111869
- () => import_fs4.default.realpath(resolved, (realErr, realResolved) => {
112687
+ () => import_fs6.default.realpath(resolved, (realErr, realResolved) => {
111870
112688
  const servePath = realErr ? resolved : realResolved;
111871
- const servePathWithSep = servePath.endsWith(import_path4.default.sep) ? servePath : servePath + import_path4.default.sep;
112689
+ const servePathWithSep = servePath.endsWith(import_path5.default.sep) ? servePath : servePath + import_path5.default.sep;
111872
112690
  if (!realErr) {
111873
112691
  const realBaseWithSep = (() => {
111874
112692
  try {
111875
- const rb = import_fs4.default.realpathSync(baseDir);
111876
- return rb.endsWith(import_path4.default.sep) ? rb : rb + import_path4.default.sep;
112693
+ const rb = import_fs6.default.realpathSync(baseDir);
112694
+ return rb.endsWith(import_path5.default.sep) ? rb : rb + import_path5.default.sep;
111877
112695
  } catch {
111878
112696
  return baseWithSep;
111879
112697
  }
111880
112698
  })();
111881
- if (!servePathWithSep.startsWith(realBaseWithSep) && servePath + import_path4.default.sep !== realBaseWithSep) {
112699
+ if (!servePathWithSep.startsWith(realBaseWithSep) && servePath + import_path5.default.sep !== realBaseWithSep) {
111882
112700
  res.writeHead(403);
111883
112701
  res.end("forbidden");
111884
112702
  return;
111885
112703
  }
111886
112704
  }
111887
- import_fs4.default.stat(servePath, (err, stats) => {
112705
+ import_fs6.default.stat(servePath, (err, stats) => {
111888
112706
  if (err || !stats?.isFile()) {
111889
- const ext2 = import_path4.default.extname(rel).toLowerCase();
112707
+ const ext2 = import_path5.default.extname(rel).toLowerCase();
111890
112708
  if (ext2 && ext2 !== ".html") {
111891
112709
  res.writeHead(404);
111892
112710
  res.end("not found");
@@ -111897,8 +112715,8 @@ var init_bridge_host = __esm({
111897
112715
  res.end("not found");
111898
112716
  return;
111899
112717
  }
111900
- const indexPath = import_path4.default.join(baseDir, "index.html");
111901
- import_fs4.default.readFile(indexPath, (err2, data) => {
112718
+ const indexPath = import_path5.default.join(baseDir, "index.html");
112719
+ import_fs6.default.readFile(indexPath, (err2, data) => {
111902
112720
  if (err2) {
111903
112721
  res.writeHead(404);
111904
112722
  res.end("not found");
@@ -111918,7 +112736,7 @@ var init_bridge_host = __esm({
111918
112736
  });
111919
112737
  return;
111920
112738
  }
111921
- const ext = import_path4.default.extname(servePath).toLowerCase();
112739
+ const ext = import_path5.default.extname(servePath).toLowerCase();
111922
112740
  const contentType2 = HTTP_MIME_TYPES[ext] || "application/octet-stream";
111923
112741
  res.writeHead(200, {
111924
112742
  "Content-Type": contentType2,
@@ -111931,7 +112749,7 @@ var init_bridge_host = __esm({
111931
112749
  return;
111932
112750
  }
111933
112751
  if (ext === ".html") {
111934
- import_fs4.default.readFile(servePath, (readErr, data) => {
112752
+ import_fs6.default.readFile(servePath, (readErr, data) => {
111935
112753
  if (readErr) {
111936
112754
  try {
111937
112755
  res.end();
@@ -111945,7 +112763,7 @@ var init_bridge_host = __esm({
111945
112763
  });
111946
112764
  return;
111947
112765
  }
111948
- const stream = import_fs4.default.createReadStream(servePath);
112766
+ const stream = import_fs6.default.createReadStream(servePath);
111949
112767
  stream.pipe(res);
111950
112768
  stream.on("error", () => {
111951
112769
  try {
@@ -112033,7 +112851,7 @@ var init_bridge_host = __esm({
112033
112851
  chromiumQueueVerified = /* @__PURE__ */ new Map();
112034
112852
  chromiumLaunchWaiting() {
112035
112853
  const queue2 = readChromiumQueue(
112036
- { fs: import_fs4.default, os: import_os.default, path: import_path4.default, childProcess: import_child_process4.default },
112854
+ { fs: import_fs6.default, os: import_os3.default, path: import_path5.default, childProcess: import_child_process5.default },
112037
112855
  this.chromiumQueueVerified
112038
112856
  );
112039
112857
  const live = new Set(queue2.tickets);
@@ -112115,7 +112933,7 @@ var init_bridge_host = __esm({
112115
112933
  const target = `${filePath}${loc}`;
112116
112934
  const trySpawn = (cmd, args) => new Promise((resolve14) => {
112117
112935
  try {
112118
- const child = (0, import_child_process4.spawn)(cmd, args, { detached: true, stdio: "ignore" });
112936
+ const child = (0, import_child_process5.spawn)(cmd, args, { detached: true, stdio: "ignore" });
112119
112937
  let settled = false;
112120
112938
  child.on("error", () => {
112121
112939
  if (settled) return;
@@ -112670,434 +113488,6 @@ var init_cli_constants = __esm({
112670
113488
  }
112671
113489
  });
112672
113490
 
112673
- // cli/parent-pid.ts
112674
- function getParentPid(pid) {
112675
- if (!cached3) cached3 = build();
112676
- try {
112677
- return cached3(pid);
112678
- } catch {
112679
- return null;
112680
- }
112681
- }
112682
- function getProcessComm(pid) {
112683
- if (!cachedComm) cachedComm = buildComm();
112684
- try {
112685
- return cachedComm(pid);
112686
- } catch {
112687
- return null;
112688
- }
112689
- }
112690
- function getProcessPgid(pid) {
112691
- if (!cachedPgid) cachedPgid = buildPgid();
112692
- try {
112693
- return cachedPgid(pid);
112694
- } catch {
112695
- return null;
112696
- }
112697
- }
112698
- function buildComm() {
112699
- if (process.platform === "linux") {
112700
- return (pid) => {
112701
- try {
112702
- return (0, import_fs5.readFileSync)(`/proc/${pid}/comm`, "utf8").trim() || null;
112703
- } catch {
112704
- return null;
112705
- }
112706
- };
112707
- }
112708
- if (process.platform === "darwin") {
112709
- const ffi = tryBuildDarwinCommFfi();
112710
- if (ffi) return ffi;
112711
- return (pid) => readProcessTable2().get(pid)?.comm || null;
112712
- }
112713
- return () => null;
112714
- }
112715
- function build() {
112716
- if (process.platform === "linux") return buildLinux();
112717
- if (process.platform === "darwin") {
112718
- const ffi = tryBuildDarwinFfi();
112719
- if (ffi) return ffi;
112720
- return (pid) => {
112721
- const ppid = readProcessTable2().get(pid)?.ppid;
112722
- return ppid !== void 0 && ppid > 0 ? ppid : null;
112723
- };
112724
- }
112725
- return () => null;
112726
- }
112727
- function buildPgid() {
112728
- if (process.platform === "linux") {
112729
- return (pid) => {
112730
- try {
112731
- const raw2 = (0, import_fs5.readFileSync)(`/proc/${pid}/stat`, "utf8");
112732
- const end = raw2.lastIndexOf(")");
112733
- if (end < 0) return null;
112734
- const rest = raw2.slice(end + 1).trim().split(/\s+/);
112735
- const pgid = Number(rest[2]);
112736
- return Number.isFinite(pgid) && pgid > 0 ? pgid : null;
112737
- } catch {
112738
- return null;
112739
- }
112740
- };
112741
- }
112742
- if (process.platform === "darwin") {
112743
- const ffi = tryBuildDarwinPgidFfi();
112744
- if (ffi) return ffi;
112745
- return (pid) => {
112746
- const pgid = readProcessTable2().get(pid)?.pgid;
112747
- return pgid !== void 0 && pgid > 0 ? pgid : null;
112748
- };
112749
- }
112750
- return () => null;
112751
- }
112752
- function readProcessTable2() {
112753
- const now = Date.now();
112754
- if (processTable2.readAt && now - processTable2.readAt < PROCESS_TABLE_TTL_MS) {
112755
- return processTable2.rows;
112756
- }
112757
- const rows = /* @__PURE__ */ new Map();
112758
- try {
112759
- const out = (0, import_child_process5.execFileSync)("ps", ["-eo", "pid=,ppid=,pgid=,comm="], {
112760
- encoding: "utf8",
112761
- timeout: 5e3,
112762
- maxBuffer: 8 * 1024 * 1024,
112763
- stdio: ["ignore", "pipe", "ignore"]
112764
- });
112765
- for (const line of out.split("\n")) {
112766
- const parsed = line.trim().match(/^(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/);
112767
- if (!parsed) continue;
112768
- rows.set(Number(parsed[1]), {
112769
- ppid: Number(parsed[2]),
112770
- pgid: Number(parsed[3]),
112771
- comm: (parsed[4].split("/").at(-1) ?? "").slice(0, PBI_COMM_LEN)
112772
- });
112773
- }
112774
- } catch {
112775
- }
112776
- processTable2 = { readAt: now, rows };
112777
- return rows;
112778
- }
112779
- function buildLinux() {
112780
- return (pid) => {
112781
- try {
112782
- const raw2 = (0, import_fs5.readFileSync)(`/proc/${pid}/stat`, "utf8");
112783
- const end = raw2.lastIndexOf(")");
112784
- if (end < 0) return null;
112785
- const rest = raw2.slice(end + 1).trim().split(/\s+/);
112786
- const ppid = Number(rest[1]);
112787
- return Number.isFinite(ppid) && ppid > 0 ? ppid : null;
112788
- } catch {
112789
- return null;
112790
- }
112791
- };
112792
- }
112793
- function tryBuildDarwinFfi() {
112794
- if (!process.versions?.bun) return null;
112795
- try {
112796
- const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
112797
- const { dlopen, FFIType } = r("bun:ffi");
112798
- const lib = dlopen("/usr/lib/libproc.dylib", {
112799
- proc_pidinfo: {
112800
- args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
112801
- returns: FFIType.i32
112802
- }
112803
- });
112804
- const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
112805
- return (pid) => {
112806
- const ret = Number(
112807
- lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
112808
- );
112809
- if (ret <= 0) return null;
112810
- const ppid = buf.readUInt32LE(PBI_PPID_OFFSET);
112811
- return ppid > 0 ? ppid : null;
112812
- };
112813
- } catch {
112814
- return null;
112815
- }
112816
- }
112817
- function tryBuildDarwinCommFfi() {
112818
- if (!process.versions?.bun) return null;
112819
- try {
112820
- const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
112821
- const { dlopen, FFIType } = r("bun:ffi");
112822
- const lib = dlopen("/usr/lib/libproc.dylib", {
112823
- proc_pidinfo: {
112824
- args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
112825
- returns: FFIType.i32
112826
- }
112827
- });
112828
- const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
112829
- return (pid) => {
112830
- const ret = Number(
112831
- lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
112832
- );
112833
- if (ret <= 0) return null;
112834
- const raw2 = buf.subarray(PBI_COMM_OFFSET, PBI_COMM_OFFSET + PBI_COMM_LEN);
112835
- const end = raw2.indexOf(0);
112836
- const comm = raw2.subarray(0, end < 0 ? raw2.length : end).toString("utf8");
112837
- return comm || null;
112838
- };
112839
- } catch {
112840
- return null;
112841
- }
112842
- }
112843
- function tryBuildDarwinPgidFfi() {
112844
- if (!process.versions?.bun) return null;
112845
- try {
112846
- const r = (0, import_module.createRequire)(__sootsim_import_meta_url);
112847
- const { dlopen, FFIType } = r("bun:ffi");
112848
- const lib = dlopen("/usr/lib/libproc.dylib", {
112849
- proc_pidinfo: {
112850
- args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
112851
- returns: FFIType.i32
112852
- }
112853
- });
112854
- const buf = Buffer.alloc(PROC_BSDINFO_SIZE);
112855
- return (pid) => {
112856
- const ret = Number(
112857
- lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE)
112858
- );
112859
- if (ret <= 0) return null;
112860
- const pgid = buf.readUInt32LE(PBI_PGID_OFFSET);
112861
- return pgid > 0 ? pgid : null;
112862
- };
112863
- } catch {
112864
- return null;
112865
- }
112866
- }
112867
- var import_child_process5, import_fs5, import_module, cached3, cachedComm, cachedPgid, PROCESS_TABLE_TTL_MS, processTable2, PROC_PIDTBSDINFO, PROC_BSDINFO_SIZE, PBI_PPID_OFFSET, PBI_COMM_OFFSET, PBI_COMM_LEN, PBI_PGID_OFFSET;
112868
- var init_parent_pid = __esm({
112869
- "cli/parent-pid.ts"() {
112870
- "use strict";
112871
- import_child_process5 = require("child_process");
112872
- import_fs5 = require("fs");
112873
- import_module = require("module");
112874
- cached3 = null;
112875
- cachedComm = null;
112876
- cachedPgid = null;
112877
- PROCESS_TABLE_TTL_MS = 2e3;
112878
- processTable2 = { readAt: 0, rows: /* @__PURE__ */ new Map() };
112879
- PROC_PIDTBSDINFO = 3;
112880
- PROC_BSDINFO_SIZE = 216;
112881
- PBI_PPID_OFFSET = 16;
112882
- PBI_COMM_OFFSET = 48;
112883
- PBI_COMM_LEN = 16;
112884
- PBI_PGID_OFFSET = 100;
112885
- }
112886
- });
112887
-
112888
- // cli/current-sim.ts
112889
- function findTopAncestor(start, maxDepth = 20) {
112890
- let prev = start;
112891
- let pid = getParentPid(start);
112892
- if (!pid || pid <= 1) {
112893
- const comm = getProcessComm(start);
112894
- if (!comm || start < 1 || IMMORTAL_HOST_COMM_RE.test(comm)) return null;
112895
- return start > 1 || !INIT_COMM_RE.test(comm) ? start : null;
112896
- }
112897
- for (let i = 0; i < maxDepth; i++) {
112898
- const comm = getProcessComm(pid);
112899
- if (comm && IMMORTAL_HOST_COMM_RE.test(comm)) return prev;
112900
- const parent = getParentPid(pid);
112901
- if (!parent || parent <= 1) {
112902
- return comm ? pid : prev;
112903
- }
112904
- prev = pid;
112905
- pid = parent;
112906
- }
112907
- return pid;
112908
- }
112909
- function getCliIdentity() {
112910
- for (const name3 of IDENTITY_ENV_VARS) {
112911
- const value = process.env[name3];
112912
- if (value && value.trim()) {
112913
- return { key: `${name3}:${value.trim()}`, source: name3, stable: true };
112914
- }
112915
- }
112916
- const topPid = findTopAncestor(process.ppid);
112917
- if (topPid) {
112918
- return { key: `gppid-${topPid}`, source: "grand-ppid", stable: true };
112919
- }
112920
- return { key: `pid-${process.ppid}`, source: "ppid", stable: false };
112921
- }
112922
- function getCliIdentityKey() {
112923
- return getCliIdentity().key;
112924
- }
112925
- function getStableOwnerPid() {
112926
- return findTopAncestor(process.ppid);
112927
- }
112928
- function getOwnerProcessGroupId(owner = getStableOwnerPid()) {
112929
- if (!owner || owner <= 1) return null;
112930
- const pgid = getProcessPgid(owner);
112931
- return pgid !== null && pgid > 1 ? pgid : null;
112932
- }
112933
- function getCurrentSimPath() {
112934
- const envPath = process.env[CURRENT_SIM_PATH_ENV];
112935
- if (envPath) {
112936
- return (0, import_path5.resolve)(envPath);
112937
- }
112938
- const key2 = getCliIdentityKey();
112939
- return (0, import_path5.join)((0, import_os2.tmpdir)(), `peach-current-sim-${key2}.json`);
112940
- }
112941
- function legacyCloudCredentialDirectory(filepath) {
112942
- return (0, import_path5.join)((0, import_path5.dirname)(filepath), `${(0, import_path5.basename)(filepath)}.credentials`);
112943
- }
112944
- function readCurrentTarget() {
112945
- const filepath = getCurrentSimPath();
112946
- (0, import_fs6.rmSync)(legacyCloudCredentialDirectory(filepath), { recursive: true, force: true });
112947
- if (!(0, import_fs6.existsSync)(filepath)) return null;
112948
- try {
112949
- const parsed = JSON.parse((0, import_fs6.readFileSync)(filepath, "utf8"));
112950
- if (parsed === null || typeof parsed !== "object") {
112951
- (0, import_fs6.rmSync)(filepath, { force: true });
112952
- return null;
112953
- }
112954
- if (Reflect.get(parsed, "pendingOpen") === true) return null;
112955
- const version2 = Reflect.get(parsed, "version");
112956
- const plane = Reflect.get(parsed, "plane");
112957
- const simId = Reflect.get(parsed, "simId");
112958
- const updatedAt = Reflect.get(parsed, "updatedAt");
112959
- const rawPort = Reflect.get(parsed, "bridgePort");
112960
- const bridgePort = typeof rawPort === "number" && Number.isInteger(rawPort) && rawPort > 0 ? rawPort : void 0;
112961
- if (version2 !== 1 && version2 !== CURRENT_SIM_VERSION || version2 === CURRENT_SIM_VERSION && plane !== "local" || typeof simId !== "string" || !simId.trim() || typeof updatedAt !== "string") {
112962
- (0, import_fs6.rmSync)(filepath, { force: true });
112963
- return null;
112964
- }
112965
- const target = {
112966
- version: CURRENT_SIM_VERSION,
112967
- plane: "local",
112968
- simId: simId.trim(),
112969
- ...bridgePort === void 0 ? {} : { bridgePort },
112970
- updatedAt
112971
- };
112972
- if (version2 === 1) writeSecureJsonAtomic(filepath, target, { durable: false });
112973
- return target;
112974
- } catch {
112975
- (0, import_fs6.rmSync)(filepath, { force: true });
112976
- return null;
112977
- }
112978
- }
112979
- function readCurrentSimId() {
112980
- return readCurrentTarget()?.simId ?? null;
112981
- }
112982
- function writeCurrentSim(simId, bridgePort) {
112983
- const normalized = simId.trim();
112984
- if (!normalized) return;
112985
- writeSecureJsonAtomic(
112986
- getCurrentSimPath(),
112987
- {
112988
- version: CURRENT_SIM_VERSION,
112989
- plane: "local",
112990
- simId: normalized,
112991
- ...bridgePort === void 0 ? {} : { bridgePort },
112992
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
112993
- },
112994
- { durable: false }
112995
- );
112996
- }
112997
- function saveCurrentSimId(simId, bridgePort) {
112998
- writeCurrentSim(simId, bridgePort);
112999
- }
113000
- function replaceCurrentSimId(simId) {
113001
- writeCurrentSim(simId, readCurrentTarget()?.bridgePort);
113002
- }
113003
- function getAgentIdPath() {
113004
- return `${getCurrentSimPath()}.agent-id`;
113005
- }
113006
- function saveAgentId(agentId) {
113007
- writeSecureJsonAtomic(getAgentIdPath(), { agentId }, { durable: false });
113008
- }
113009
- function readAgentId() {
113010
- const filepath = getAgentIdPath();
113011
- if (!(0, import_fs6.existsSync)(filepath)) return void 0;
113012
- try {
113013
- const parsed = JSON.parse((0, import_fs6.readFileSync)(filepath, "utf8"));
113014
- const agentId = parsed !== null && typeof parsed === "object" ? Reflect.get(parsed, "agentId") : void 0;
113015
- return typeof agentId === "string" && agentId.trim() ? agentId.trim() : void 0;
113016
- } catch {
113017
- (0, import_fs6.rmSync)(filepath, { force: true });
113018
- return void 0;
113019
- }
113020
- }
113021
- function clearCurrentSimId() {
113022
- (0, import_fs6.rmSync)(getCurrentSimPath(), { force: true });
113023
- }
113024
- function markOpenPending() {
113025
- writeSecureJsonAtomic(
113026
- getCurrentSimPath(),
113027
- {
113028
- version: CURRENT_SIM_VERSION,
113029
- plane: "local",
113030
- pendingOpen: true,
113031
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
113032
- },
113033
- { durable: false }
113034
- );
113035
- }
113036
- function assertNoPendingOpen() {
113037
- if (!isOpenPending()) return;
113038
- throw new PendingOpenError(
113039
- "the last `peach open` did not pin a sim, so this command would land on whichever tab is connected. run `peach open` again, `peach use <sim>`, or pass --sim <id>"
113040
- );
113041
- }
113042
- function isOpenPending() {
113043
- const filepath = getCurrentSimPath();
113044
- if (!(0, import_fs6.existsSync)(filepath)) return false;
113045
- try {
113046
- const parsed = JSON.parse((0, import_fs6.readFileSync)(filepath, "utf8"));
113047
- return parsed !== null && typeof parsed === "object" && Reflect.get(parsed, "pendingOpen") === true;
113048
- } catch {
113049
- return false;
113050
- }
113051
- }
113052
- var import_fs6, import_os2, import_path5, CURRENT_SIM_VERSION, CURRENT_SIM_PATH_ENV, IDENTITY_ENV_VARS, IMMORTAL_HOST_COMM_RE, INIT_COMM_RE, readCurrentSim, PendingOpenError;
113053
- var init_current_sim = __esm({
113054
- "cli/current-sim.ts"() {
113055
- "use strict";
113056
- import_fs6 = require("fs");
113057
- import_os2 = require("os");
113058
- import_path5 = require("path");
113059
- init_parent_pid();
113060
- init_secure_file();
113061
- CURRENT_SIM_VERSION = 2;
113062
- CURRENT_SIM_PATH_ENV = "PEACH_CLI_CURRENT_SIM_PATH";
113063
- IDENTITY_ENV_VARS = [
113064
- "PEACH_CLI_IDENTITY",
113065
- // explicit override — fastest path, skips all pid lookups
113066
- "CLAUDE_CODE_SESSION_ID",
113067
- // claude code, if ever set
113068
- "CODEX_THREAD_ID",
113069
- // codex / openai agent thread, stable across tool invocations
113070
- // a Team Machine session, per agent run. its other runners set no session
113071
- // variable of their own, and the terminal variables below are inherited from
113072
- // whatever shell started the daemon, so every such agent would share one key.
113073
- "TM_SESSION",
113074
- "TERM_SESSION_ID",
113075
- // macOS Terminal.app + iTerm2
113076
- "ITERM_SESSION_ID",
113077
- // iTerm2 (older variant)
113078
- "TMUX_PANE",
113079
- // tmux — stable per pane
113080
- "STY",
113081
- // GNU screen session
113082
- "KITTY_WINDOW_ID",
113083
- // kitty
113084
- "WEZTERM_PANE",
113085
- // wezterm
113086
- "ALACRITTY_WINDOW_ID",
113087
- // alacritty
113088
- "WINDOWID",
113089
- // X11 terminals
113090
- "VSCODE_INJECTION"
113091
- // vscode integrated terminal
113092
- ];
113093
- IMMORTAL_HOST_COMM_RE = /^(?:tmux|screen)|^tm$/i;
113094
- INIT_COMM_RE = /^(?:init|systemd|launchd|tini|docker-init|dumb-init|catatonit|s6-svscan|runsvdir)$/i;
113095
- readCurrentSim = readCurrentTarget;
113096
- PendingOpenError = class extends Error {
113097
- };
113098
- }
113099
- });
113100
-
113101
113491
  // cli/pause-aware-timeout.ts
113102
113492
  function pausedPids() {
113103
113493
  try {
@@ -113627,12 +114017,14 @@ function createBridge(wsPort, opts = {}) {
113627
114017
  plane: "local",
113628
114018
  async send(cmd, callOpts) {
113629
114019
  const effectiveTimeoutMs = callOpts?.timeoutMs ?? (opts.explicitTimeout ? commandTimeoutMs : callOpts?.defaultTimeoutMs) ?? commandTimeoutMs;
114020
+ const agent = commandAgent(cmd);
114021
+ const sent = agent ? { ...cmd, agent } : cmd;
113630
114022
  const sendOnce = async (defaultSimId, cmdOverride) => {
113631
114023
  await ready;
113632
114024
  if (terminalError) throw terminalError;
113633
114025
  const id = nextId++;
113634
114026
  return new Promise((resolve14, reject) => {
113635
- const payload = { ...cmdOverride ?? cmd, id };
114027
+ const payload = { ...cmdOverride ?? sent, id };
113636
114028
  if (payload.simId === void 0 && defaultSimId) {
113637
114029
  payload.simId = defaultSimId;
113638
114030
  }
@@ -113983,6 +114375,7 @@ var init_ws_bridge = __esm({
113983
114375
  init_cli_constants();
113984
114376
  init_home_paths();
113985
114377
  init_cloud_client();
114378
+ init_command_agent();
113986
114379
  init_current_sim();
113987
114380
  init_pause_aware_timeout();
113988
114381
  init_run_rnx();
@@ -114157,25 +114550,6 @@ var init_src2 = __esm({
114157
114550
  }
114158
114551
  });
114159
114552
 
114160
- // ../peach-kit/src/agent-identity.ts
114161
- function formatLockOwner(owner) {
114162
- const colon = owner.indexOf(":");
114163
- if (colon <= 0) return owner.length > 24 ? `${owner.slice(0, 21)}\u2026` : owner;
114164
- const source = owner.slice(0, colon);
114165
- const value = owner.slice(colon + 1);
114166
- if (source === "PEACH_CLI_IDENTITY" && value) return value;
114167
- const short = value.length > 12 ? `${value.slice(0, 8)}\u2026` : value;
114168
- if (source === "CLAUDE_CODE_SESSION_ID" || source === "CODEX_THREAD_ID") {
114169
- return `agent ${short}`;
114170
- }
114171
- return `${source} ${short}`;
114172
- }
114173
- var init_agent_identity = __esm({
114174
- "../peach-kit/src/agent-identity.ts"() {
114175
- "use strict";
114176
- }
114177
- });
114178
-
114179
114553
  // detox/launch-permissions.ts
114180
114554
  function buildPermissionSeedScript(seed) {
114181
114555
  const inbox = JSON.stringify(PERMISSION_BOOT_SEED_STORAGE_KEY);
@@ -116286,7 +116660,7 @@ function macDesktopLaunchHome(bridgePort) {
116286
116660
  (lock) => lock.bridgePort === bridgePort && isDevBridgeLockfileFresh(lock)
116287
116661
  );
116288
116662
  const homeKey = (0, import_node_crypto76.createHash)("sha256").update(home).digest("hex");
116289
- const dir = (0, import_path7.join)((0, import_os3.tmpdir)(), "peach-desktop-launch", homeKey, String(bridgePort));
116663
+ const dir = (0, import_path7.join)((0, import_os4.tmpdir)(), "peach-desktop-launch", homeKey, String(bridgePort));
116290
116664
  (0, import_fs8.mkdirSync)(dir, { recursive: true });
116291
116665
  if ((0, import_fs8.existsSync)(home)) {
116292
116666
  for (const name3 of (0, import_fs8.readdirSync)(home)) {
@@ -116391,14 +116765,14 @@ function buildMacLaunchUrl(url, opts, nativeApp = false) {
116391
116765
  }
116392
116766
  return deepLink.toString();
116393
116767
  }
116394
- var import_child_process6, import_fs8, import_node_crypto76, import_os3, import_path7, import_url2, import_meta2, _sootsimRoot;
116768
+ var import_child_process6, import_fs8, import_node_crypto76, import_os4, import_path7, import_url2, import_meta2, _sootsimRoot;
116395
116769
  var init_desktop_companion = __esm({
116396
116770
  "cli/desktop-companion.ts"() {
116397
116771
  "use strict";
116398
116772
  import_child_process6 = require("child_process");
116399
116773
  import_fs8 = require("fs");
116400
116774
  import_node_crypto76 = require("node:crypto");
116401
- import_os3 = require("os");
116775
+ import_os4 = require("os");
116402
116776
  import_path7 = require("path");
116403
116777
  import_url2 = require("url");
116404
116778
  init_desktop_host_delivery();
@@ -116952,7 +117326,7 @@ async function launch(opts) {
116952
117326
  }
116953
117327
  }
116954
117328
  const cdpPort = requestedCdpPort ?? await freePort();
116955
- const errLog = (0, import_path8.join)((0, import_os4.tmpdir)(), playwrightHostLogName(Date.now(), process.pid));
117329
+ const errLog = (0, import_path8.join)((0, import_os5.tmpdir)(), playwrightHostLogName(Date.now(), process.pid));
116956
117330
  const connectAckFile = `${errLog}.connected`;
116957
117331
  const admittedFile = `${errLog}.admitted`;
116958
117332
  const completionFile = `${errLog}.completed`;
@@ -117022,14 +117396,14 @@ async function launch(opts) {
117022
117396
  (0, import_fs9.closeSync)(errFd);
117023
117397
  }
117024
117398
  }
117025
- var import_child_process7, import_fs9, import_net3, import_os4, import_path8, playwrightDriver;
117399
+ var import_child_process7, import_fs9, import_net3, import_os5, import_path8, playwrightDriver;
117026
117400
  var init_playwright = __esm({
117027
117401
  "cli/drivers/playwright.ts"() {
117028
117402
  "use strict";
117029
117403
  import_child_process7 = require("child_process");
117030
117404
  import_fs9 = require("fs");
117031
117405
  import_net3 = require("net");
117032
- import_os4 = require("os");
117406
+ import_os5 = require("os");
117033
117407
  import_path8 = require("path");
117034
117408
  init_bridge_constants();
117035
117409
  init_cli_version();
@@ -117452,11 +117826,11 @@ function option(flag, description, hidden) {
117452
117826
  function example(command, description, hidden) {
117453
117827
  return hidden ? { command, description, hidden } : { command, description };
117454
117828
  }
117455
- function verb(v7, description, usage, examples, notes, extras) {
117829
+ function verb2(v7, description, usage, examples, notes, extras) {
117456
117830
  return { verb: v7, description, usage, examples, notes, ...extras };
117457
117831
  }
117458
- function inspectVerbPathKey(group, verb2) {
117459
- return `${group ?? ""}:${verb2}`;
117832
+ function inspectVerbPathKey(group, verb3) {
117833
+ return `${group ?? ""}:${verb3}`;
117460
117834
  }
117461
117835
  var REDACT_OPTION, cliCommandMetas, cliCommandMetaById, cliCommandMetaByName, cliInspectVerbMetas, cliInspectVerbMetasByVerb, cliInspectVerbMetaByPath, cliInspectVerbMetaByVerb;
117462
117836
  var init_meta = __esm({
@@ -119901,7 +120275,7 @@ var init_meta = __esm({
119901
120275
  }
119902
120276
  }
119903
120277
  cliInspectVerbMetas = [
119904
- verb(
120278
+ verb2(
119905
120279
  "describe",
119906
120280
  "show visible UI elements with type, text, position, size, and style. formats the pruned visible semantic tree.",
119907
120281
  [
@@ -119949,7 +120323,7 @@ var init_meta = __esm({
119949
120323
  seeAlso: ["tree", "a11y", "find"]
119950
120324
  }
119951
120325
  ),
119952
- verb(
120326
+ verb2(
119953
120327
  "find",
119954
120328
  "unified finder (text, testid, role, type, pressable, visible, interactive-targets)",
119955
120329
  [
@@ -120004,7 +120378,7 @@ var init_meta = __esm({
120004
120378
  seeAlso: ["describe", "node", "selector"]
120005
120379
  }
120006
120380
  ),
120007
- verb(
120381
+ verb2(
120008
120382
  "count",
120009
120383
  "show total node count",
120010
120384
  ["peach get count [--json]"],
@@ -120017,7 +120391,7 @@ var init_meta = __esm({
120017
120391
  options: [option("--json", "emit { nodes: n } for scripts")]
120018
120392
  }
120019
120393
  ),
120020
- verb(
120394
+ verb2(
120021
120395
  "layout",
120022
120396
  "measure layout: bare for every visible element on the screen (box + radius/padding/fontSize), or with an id for one node",
120023
120397
  ["peach get layout [id] [--json]"],
@@ -120041,7 +120415,7 @@ var init_meta = __esm({
120041
120415
  seeAlso: ["describe", "find", "node"]
120042
120416
  }
120043
120417
  ),
120044
- verb(
120418
+ verb2(
120045
120419
  "tree",
120046
120420
  "dump the node tree",
120047
120421
  ["peach get tree [depth] [--json] [--boxes]"],
@@ -120063,7 +120437,7 @@ var init_meta = __esm({
120063
120437
  seeAlso: ["describe", "a11y", "node"]
120064
120438
  }
120065
120439
  ),
120066
- verb(
120440
+ verb2(
120067
120441
  "a11y",
120068
120442
  "dump the accessibility tree with roles and labels",
120069
120443
  ["peach get a11y [depth]"],
@@ -120076,7 +120450,7 @@ var init_meta = __esm({
120076
120450
  seeAlso: ["describe", "tree", "layout"]
120077
120451
  }
120078
120452
  ),
120079
- verb(
120453
+ verb2(
120080
120454
  "node",
120081
120455
  "resolve testID/id/text to a full node JSON",
120082
120456
  ["peach get node <matcher>"],
@@ -120089,7 +120463,7 @@ var init_meta = __esm({
120089
120463
  seeAlso: ["find", "layout"]
120090
120464
  }
120091
120465
  ),
120092
- verb(
120466
+ verb2(
120093
120467
  "tap",
120094
120468
  "tap a testID, absolute coordinates, or a node resolved from --testid / --text",
120095
120469
  [
@@ -120113,7 +120487,7 @@ var init_meta = __esm({
120113
120487
  order: 10
120114
120488
  }
120115
120489
  ),
120116
- verb(
120490
+ verb2(
120117
120491
  "double-tap",
120118
120492
  "tap the same spot twice with a short gap",
120119
120493
  [
@@ -120135,7 +120509,7 @@ var init_meta = __esm({
120135
120509
  order: 20
120136
120510
  }
120137
120511
  ),
120138
- verb(
120512
+ verb2(
120139
120513
  "tap-text",
120140
120514
  "find a node by text content and tap its center",
120141
120515
  [
@@ -120171,7 +120545,7 @@ var init_meta = __esm({
120171
120545
  order: 30
120172
120546
  }
120173
120547
  ),
120174
- verb(
120548
+ verb2(
120175
120549
  "tap-id",
120176
120550
  "alias of `tap <testid>` that always reads its argument as a testID, numeric ids included",
120177
120551
  ["peach do tap-id <id>"],
@@ -120185,7 +120559,7 @@ var init_meta = __esm({
120185
120559
  order: 40
120186
120560
  }
120187
120561
  ),
120188
- verb(
120562
+ verb2(
120189
120563
  "tap-best",
120190
120564
  "tap by query: try testID first, then visible text. one command, two strategies",
120191
120565
  ["peach do tap-best <query>"],
@@ -120205,7 +120579,7 @@ var init_meta = __esm({
120205
120579
  order: 41
120206
120580
  }
120207
120581
  ),
120208
- verb(
120582
+ verb2(
120209
120583
  "scan",
120210
120584
  "inject a synthetic barcode scan into the active expo-camera scan session",
120211
120585
  ["peach do scan <text> [--format <web-format>]"],
@@ -120228,7 +120602,7 @@ var init_meta = __esm({
120228
120602
  order: 10
120229
120603
  }
120230
120604
  ),
120231
- verb(
120605
+ verb2(
120232
120606
  "type",
120233
120607
  "type text through the iOS keyboard (requires a focused input)",
120234
120608
  ["peach do type <text>"],
@@ -120242,7 +120616,7 @@ var init_meta = __esm({
120242
120616
  order: 10
120243
120617
  }
120244
120618
  ),
120245
- verb(
120619
+ verb2(
120246
120620
  "type-into",
120247
120621
  "find an input by testID, tap to focus, then type text",
120248
120622
  ["peach do type-into <id> <text>"],
@@ -120256,7 +120630,7 @@ var init_meta = __esm({
120256
120630
  order: 20
120257
120631
  }
120258
120632
  ),
120259
- verb(
120633
+ verb2(
120260
120634
  "key",
120261
120635
  "press a special keyboard key",
120262
120636
  ["peach do key <name>"],
@@ -120270,7 +120644,7 @@ var init_meta = __esm({
120270
120644
  order: 30
120271
120645
  }
120272
120646
  ),
120273
- verb(
120647
+ verb2(
120274
120648
  "key-sequence",
120275
120649
  "press multiple visual keyboard keys in order",
120276
120650
  ["peach do key-sequence <key> [<key> ...]"],
@@ -120284,7 +120658,7 @@ var init_meta = __esm({
120284
120658
  order: 40
120285
120659
  }
120286
120660
  ),
120287
- verb(
120661
+ verb2(
120288
120662
  "keycode",
120289
120663
  "press DOM-style key codes through the visual keyboard",
120290
120664
  ["peach do keycode <code> [<code> ...]"],
@@ -120298,13 +120672,13 @@ var init_meta = __esm({
120298
120672
  order: 50
120299
120673
  }
120300
120674
  ),
120301
- verb("dismiss", "dismiss the keyboard", ["peach do dismiss"], void 0, void 0, {
120675
+ verb2("dismiss", "dismiss the keyboard", ["peach do dismiss"], void 0, void 0, {
120302
120676
  group: "do",
120303
120677
  subgroup: "text input",
120304
120678
  shortDescription: "dismiss the iOS keyboard",
120305
120679
  order: 60
120306
120680
  }),
120307
- verb(
120681
+ verb2(
120308
120682
  "scroll",
120309
120683
  "scroll a scrollview by testID",
120310
120684
  ["peach do scroll <id> <x> <y>", "peach do scroll --testid <id> <x> <y>"],
@@ -120321,7 +120695,7 @@ var init_meta = __esm({
120321
120695
  order: 10
120322
120696
  }
120323
120697
  ),
120324
- verb(
120698
+ verb2(
120325
120699
  "drag",
120326
120700
  "drag from one point to another using real PointerEvent dispatch",
120327
120701
  ["peach do drag <x1> <y1> <x2> <y2> [steps] [stepMs]"],
@@ -120335,7 +120709,7 @@ var init_meta = __esm({
120335
120709
  order: 20
120336
120710
  }
120337
120711
  ),
120338
- verb(
120712
+ verb2(
120339
120713
  "swipe",
120340
120714
  "swipe gesture (drag with fewer steps)",
120341
120715
  ["peach do swipe <x1> <y1> <x2> <y2> [steps] [stepMs]"],
@@ -120349,7 +120723,7 @@ var init_meta = __esm({
120349
120723
  order: 30
120350
120724
  }
120351
120725
  ),
120352
- verb(
120726
+ verb2(
120353
120727
  "long-press",
120354
120728
  "hold a press on a testID or at coordinates",
120355
120729
  [
@@ -120371,7 +120745,7 @@ var init_meta = __esm({
120371
120745
  order: 40
120372
120746
  }
120373
120747
  ),
120374
- verb(
120748
+ verb2(
120375
120749
  "touch",
120376
120750
  "low-level touch primitives; a pointer lives within one batch, so chain its phases with --then",
120377
120751
  ["peach do touch <down|move|up|cancel> <x> <y> [pointerId] --then touch ..."],
@@ -120389,7 +120763,7 @@ var init_meta = __esm({
120389
120763
  order: 50
120390
120764
  }
120391
120765
  ),
120392
- verb(
120766
+ verb2(
120393
120767
  "gesture",
120394
120768
  "preset gestures such as scrolls and edge swipes",
120395
120769
  ["peach do gesture <preset> [durationMs]"],
@@ -120411,7 +120785,7 @@ var init_meta = __esm({
120411
120785
  order: 60
120412
120786
  }
120413
120787
  ),
120414
- verb(
120788
+ verb2(
120415
120789
  "pinch",
120416
120790
  "two-pointer pinch helper",
120417
120791
  ["peach do pinch <x1> <y1> <x2> <y2> <x1'> <y1'> <x2'> <y2'> [steps] [stepMs]"],
@@ -120425,7 +120799,7 @@ var init_meta = __esm({
120425
120799
  order: 70
120426
120800
  }
120427
120801
  ),
120428
- verb(
120802
+ verb2(
120429
120803
  "state",
120430
120804
  "dump raw runtime state (shell, worker, keyboard, node, scroll, hit, gesture, ownership)",
120431
120805
  [
@@ -120462,7 +120836,7 @@ var init_meta = __esm({
120462
120836
  ),
120463
120837
  // `shell` is a top-level command; its help comes from the CliCommandMeta
120464
120838
  // entry above, not a verb meta. see renderCliCommandHelp dispatch.
120465
- verb(
120839
+ verb2(
120466
120840
  "js",
120467
120841
  "evaluate javascript in the browser context",
120468
120842
  ["peach debug js <expression> [--tenant]"],
@@ -120480,7 +120854,7 @@ var init_meta = __esm({
120480
120854
  seeAlso: ["state"]
120481
120855
  }
120482
120856
  ),
120483
- verb(
120857
+ verb2(
120484
120858
  "errors",
120485
120859
  "show recent console errors",
120486
120860
  ["peach get errors [n|clear] [--json]"],
@@ -120498,7 +120872,7 @@ var init_meta = __esm({
120498
120872
  seeAlso: ["warnings", "requests", "logs"]
120499
120873
  }
120500
120874
  ),
120501
- verb(
120875
+ verb2(
120502
120876
  "warnings",
120503
120877
  "show recent console warnings",
120504
120878
  ["peach get warnings [n] [--json]"],
@@ -120512,7 +120886,7 @@ var init_meta = __esm({
120512
120886
  seeAlso: ["errors", "logs"]
120513
120887
  }
120514
120888
  ),
120515
- verb(
120889
+ verb2(
120516
120890
  "requests",
120517
120891
  "show recent failed network requests",
120518
120892
  ["peach get requests [n|all n|clear] [--json]"],
@@ -120530,7 +120904,7 @@ var init_meta = __esm({
120530
120904
  seeAlso: ["errors", "network"]
120531
120905
  }
120532
120906
  ),
120533
- verb(
120907
+ verb2(
120534
120908
  "diagnosis",
120535
120909
  'composed "what just went wrong?" report',
120536
120910
  ["peach get diagnosis [--since <duration>] [--include <csv>] [--json]"],
@@ -120557,7 +120931,7 @@ var init_meta = __esm({
120557
120931
  seeAlso: ["errors", "warnings", "requests", "network"]
120558
120932
  }
120559
120933
  ),
120560
- verb(
120934
+ verb2(
120561
120935
  "animations",
120562
120936
  "list every active animation with id, kind, progress, and current value",
120563
120937
  ["peach get animations", "peach get animations --json"],
@@ -120573,7 +120947,7 @@ var init_meta = __esm({
120573
120947
  seeAlso: ["animation", "stop-animation", "state"]
120574
120948
  }
120575
120949
  ),
120576
- verb(
120950
+ verb2(
120577
120951
  "animation",
120578
120952
  "full detail for a single active animation by id",
120579
120953
  ["peach get animation <id>"],
@@ -120586,7 +120960,7 @@ var init_meta = __esm({
120586
120960
  seeAlso: ["animations", "stop-animation"]
120587
120961
  }
120588
120962
  ),
120589
- verb(
120963
+ verb2(
120590
120964
  "state",
120591
120965
  "runtime dashboard: url, active animation counts, diagnostics, shell scene",
120592
120966
  ["peach get state"],
@@ -120599,7 +120973,7 @@ var init_meta = __esm({
120599
120973
  seeAlso: ["animations", "errors", "keyboard"]
120600
120974
  }
120601
120975
  ),
120602
- verb(
120976
+ verb2(
120603
120977
  "memory",
120604
120978
  "per-worker live object counts (nodes, paragraphs, yoga nodes, pictures, raster images) + image cache + JS heaps; --watch samples over time and reports per-counter slopes",
120605
120979
  [
@@ -120631,7 +121005,7 @@ var init_meta = __esm({
120631
121005
  seeAlso: ["state", "perf"]
120632
121006
  }
120633
121007
  ),
120634
- verb(
121008
+ verb2(
120635
121009
  "stop-animation",
120636
121010
  "stop a running animation by id, or stop all active animations",
120637
121011
  ["peach do stop-animation <id|all>"],
@@ -120647,7 +121021,7 @@ var init_meta = __esm({
120647
121021
  seeAlso: ["animations", "animation"]
120648
121022
  }
120649
121023
  ),
120650
- verb(
121024
+ verb2(
120651
121025
  "trace",
120652
121026
  "opt-in trace recorders: shell animation frames or per-tick animation values",
120653
121027
  [
@@ -120669,7 +121043,7 @@ var init_meta = __esm({
120669
121043
  seeAlso: ["animations", "animation", "stop-animation"]
120670
121044
  }
120671
121045
  ),
120672
- verb(
121046
+ verb2(
120673
121047
  "image-audit",
120674
121048
  "for every image the compositor actually drew, how many source pixels it landed on each device pixel",
120675
121049
  ["peach debug image-audit [--min <ratio>] [--all] [--json]"],
@@ -120698,7 +121072,7 @@ var init_meta = __esm({
120698
121072
  seeAlso: ["screenshot", "memory"]
120699
121073
  }
120700
121074
  ),
120701
- verb(
121075
+ verb2(
120702
121076
  "snapshot",
120703
121077
  "capture a tree snapshot (layout + transform + opacity) for later diffing",
120704
121078
  ["peach debug snapshot [label]"],
@@ -120715,7 +121089,7 @@ var init_meta = __esm({
120715
121089
  seeAlso: ["snapshots", "diff", "state"]
120716
121090
  }
120717
121091
  ),
120718
- verb(
121092
+ verb2(
120719
121093
  "snapshots",
120720
121094
  "list the labels of every captured tree snapshot",
120721
121095
  ["peach debug snapshots"],
@@ -120728,7 +121102,7 @@ var init_meta = __esm({
120728
121102
  seeAlso: ["snapshot", "diff"]
120729
121103
  }
120730
121104
  ),
120731
- verb(
121105
+ verb2(
120732
121106
  "diff",
120733
121107
  "compare two captured snapshots: added / removed / changed nodes",
120734
121108
  ["peach debug diff <labelA> <labelB>"],
@@ -120746,7 +121120,7 @@ var init_meta = __esm({
120746
121120
  seeAlso: ["snapshot", "snapshots", "clear-snapshots"]
120747
121121
  }
120748
121122
  ),
120749
- verb(
121123
+ verb2(
120750
121124
  "clear-snapshots",
120751
121125
  "drop a labeled snapshot (or all snapshots if no label is given)",
120752
121126
  ["peach debug clear-snapshots [label]"],
@@ -120762,7 +121136,7 @@ var init_meta = __esm({
120762
121136
  seeAlso: ["snapshot", "snapshots", "diff"]
120763
121137
  }
120764
121138
  ),
120765
- verb(
121139
+ verb2(
120766
121140
  "find",
120767
121141
  "dump engine-internal nodes by category (e.g. all Sheet.Frame portals)",
120768
121142
  ["peach debug find sheets", "peach debug find portals"],
@@ -120785,7 +121159,7 @@ var init_meta = __esm({
120785
121159
  seeAlso: ["state", "describe"]
120786
121160
  }
120787
121161
  ),
120788
- verb(
121162
+ verb2(
120789
121163
  "record",
120790
121164
  "toggle the debug event ring buffer (off / on)",
120791
121165
  ["peach debug record [on|off]"],
@@ -120802,7 +121176,7 @@ var init_meta = __esm({
120802
121176
  seeAlso: ["recent", "clear-events"]
120803
121177
  }
120804
121178
  ),
120805
- verb(
121179
+ verb2(
120806
121180
  "recent",
120807
121181
  "tail the last N events from the debug ring buffer (optionally filtered by channel)",
120808
121182
  [
@@ -120827,7 +121201,7 @@ var init_meta = __esm({
120827
121201
  seeAlso: ["record", "clear-events"]
120828
121202
  }
120829
121203
  ),
120830
- verb(
121204
+ verb2(
120831
121205
  "clear-events",
120832
121206
  "drop everything currently in the debug event ring buffer",
120833
121207
  ["peach debug clear-events"],
@@ -120840,7 +121214,7 @@ var init_meta = __esm({
120840
121214
  seeAlso: ["record", "recent"]
120841
121215
  }
120842
121216
  ),
120843
- verb(
121217
+ verb2(
120844
121218
  "sample-color",
120845
121219
  "average the canvas color over a pixel or rect; returns hex + rgba",
120846
121220
  [
@@ -120869,7 +121243,7 @@ var init_meta = __esm({
120869
121243
  seeAlso: ["screenshot"]
120870
121244
  }
120871
121245
  ),
120872
- verb(
121246
+ verb2(
120873
121247
  "screenshot",
120874
121248
  "capture the canvas (full or a cropped area) as PNG",
120875
121249
  [
@@ -120895,7 +121269,7 @@ var init_meta = __esm({
120895
121269
  seeAlso: ["sample-color", "record"]
120896
121270
  }
120897
121271
  ),
120898
- verb(
121272
+ verb2(
120899
121273
  "url",
120900
121274
  "show the current page URL",
120901
121275
  ["peach get url [--json]"],
@@ -120908,7 +121282,7 @@ var init_meta = __esm({
120908
121282
  options: [option("--json", "emit { url } for scripts")]
120909
121283
  }
120910
121284
  ),
120911
- verb(
121285
+ verb2(
120912
121286
  "reload",
120913
121287
  "reload the page and wait for reconnection",
120914
121288
  ["peach do reload"],
@@ -120922,7 +121296,7 @@ var init_meta = __esm({
120922
121296
  order: 10
120923
121297
  }
120924
121298
  ),
120925
- verb(
121299
+ verb2(
120926
121300
  "globals",
120927
121301
  "list all __sootsim* globals available in the browser",
120928
121302
  ["peach get globals"],
@@ -120934,7 +121308,7 @@ var init_meta = __esm({
120934
121308
  shortDescription: "list available __sootsim* globals"
120935
121309
  }
120936
121310
  ),
120937
- verb(
121311
+ verb2(
120938
121312
  "sleep",
120939
121313
  "simple local pause between commands",
120940
121314
  ["peach do sleep [seconds]"],
@@ -120948,7 +121322,7 @@ var init_meta = __esm({
120948
121322
  order: 40
120949
121323
  }
120950
121324
  ),
120951
- verb(
121325
+ verb2(
120952
121326
  "wait",
120953
121327
  "wait for the current sim to reconnect",
120954
121328
  ["peach do wait [seconds]"],
@@ -120962,7 +121336,7 @@ var init_meta = __esm({
120962
121336
  order: 20
120963
121337
  }
120964
121338
  ),
120965
- verb(
121339
+ verb2(
120966
121340
  "settle",
120967
121341
  "wait until the visible layout is stable (default max 3s)",
120968
121342
  ["peach do settle [seconds] [--strict]"],
@@ -120982,7 +121356,7 @@ var init_meta = __esm({
120982
121356
  order: 30
120983
121357
  }
120984
121358
  ),
120985
- verb(
121359
+ verb2(
120986
121360
  "ready",
120987
121361
  "block until the guest app bundle is loaded and painted",
120988
121362
  ["peach wait ready [--max-ms <ms>] [--painted]"],
@@ -121009,7 +121383,7 @@ var init_meta = __esm({
121009
121383
  order: 10
121010
121384
  }
121011
121385
  ),
121012
- verb(
121386
+ verb2(
121013
121387
  "idle",
121014
121388
  "block until animations, rAF queue, and layout are all settled",
121015
121389
  ["peach wait idle [--max-ms <ms>] [--strict]"],
@@ -121026,7 +121400,7 @@ var init_meta = __esm({
121026
121400
  order: 20
121027
121401
  }
121028
121402
  ),
121029
- verb(
121403
+ verb2(
121030
121404
  "selector",
121031
121405
  "block until a node with <testid> or --text is visible with non-zero layout (or absent with --gone)",
121032
121406
  [
@@ -121069,7 +121443,7 @@ var init_meta = __esm({
121069
121443
  order: 30
121070
121444
  }
121071
121445
  ),
121072
- verb(
121446
+ verb2(
121073
121447
  "event",
121074
121448
  "block until a semantic timeline event of <kind> appears",
121075
121449
  [
@@ -121113,7 +121487,7 @@ var init_meta = __esm({
121113
121487
  order: 40
121114
121488
  }
121115
121489
  ),
121116
- verb(
121490
+ verb2(
121117
121491
  "dispatch",
121118
121492
  "dispatch a raw keyboard key (bypasses visual shift state)",
121119
121493
  ["peach do dispatch <char>"],
@@ -121127,7 +121501,7 @@ var init_meta = __esm({
121127
121501
  order: 70
121128
121502
  }
121129
121503
  ),
121130
- verb(
121504
+ verb2(
121131
121505
  "keyboard",
121132
121506
  "on-screen keyboard state (type, returnKey, autoCap, mode, shift, accessory)",
121133
121507
  ["peach get keyboard [--json]"],
@@ -121141,7 +121515,7 @@ var init_meta = __esm({
121141
121515
  seeAlso: ["type", "dismiss", "state"]
121142
121516
  }
121143
121517
  ),
121144
- verb(
121518
+ verb2(
121145
121519
  "screens",
121146
121520
  "list the current tenant route, navigation stack, active app, modal stack, and keyboard",
121147
121521
  ["peach get screens [--json]"],
@@ -121168,8 +121542,8 @@ var init_meta = __esm({
121168
121542
  cliInspectVerbMetaByPath.set(inspectVerbPathKey(meta.group, meta.verb), meta);
121169
121543
  }
121170
121544
  cliInspectVerbMetaByVerb = new Map(
121171
- Array.from(cliInspectVerbMetasByVerb, ([verb2, metas]) => [
121172
- verb2,
121545
+ Array.from(cliInspectVerbMetasByVerb, ([verb3, metas]) => [
121546
+ verb3,
121173
121547
  metas.find((meta) => !meta.group) ?? metas[0]
121174
121548
  ])
121175
121549
  );
@@ -121338,10 +121712,10 @@ function realPathOrSelf(p) {
121338
121712
  }
121339
121713
  }
121340
121714
  function macPlistPath() {
121341
- return (0, import_path9.resolve)((0, import_os5.homedir)(), "Library/LaunchAgents", `${SERVICE_LABEL_MAC}.plist`);
121715
+ return (0, import_path9.resolve)((0, import_os6.homedir)(), "Library/LaunchAgents", `${SERVICE_LABEL_MAC}.plist`);
121342
121716
  }
121343
121717
  function linuxUnitPath() {
121344
- return (0, import_path9.resolve)((0, import_os5.homedir)(), ".config/systemd/user", `${SERVICE_NAME_LINUX}.service`);
121718
+ return (0, import_path9.resolve)((0, import_os6.homedir)(), ".config/systemd/user", `${SERVICE_NAME_LINUX}.service`);
121345
121719
  }
121346
121720
  function getDaemonServiceStatus() {
121347
121721
  if (shouldSkipPersistentDaemon()) return { supported: false, installed: false };
@@ -121606,13 +121980,13 @@ async function daemonRestart() {
121606
121980
  console.error(` unsupported platform: ${process.platform}`);
121607
121981
  peachExit(1);
121608
121982
  }
121609
- var import_child_process8, import_fs10, import_os5, import_path9, SERVICE_LABEL_MAC, SERVICE_NAME_LINUX, LOG_DIR, LOG_DIR_LINUX, LSOF;
121983
+ var import_child_process8, import_fs10, import_os6, import_path9, SERVICE_LABEL_MAC, SERVICE_NAME_LINUX, LOG_DIR, LOG_DIR_LINUX, LSOF;
121610
121984
  var init_daemon = __esm({
121611
121985
  "cli/commands/daemon.ts"() {
121612
121986
  "use strict";
121613
121987
  import_child_process8 = require("child_process");
121614
121988
  import_fs10 = require("fs");
121615
- import_os5 = require("os");
121989
+ import_os6 = require("os");
121616
121990
  import_path9 = require("path");
121617
121991
  init_bridge_constants();
121618
121992
  init_desktop_host_delivery();
@@ -121625,8 +121999,8 @@ var init_daemon = __esm({
121625
121999
  init_daemon_mac_app();
121626
122000
  SERVICE_LABEL_MAC = "dev.sootsim.daemon";
121627
122001
  SERVICE_NAME_LINUX = "sootsim-daemon";
121628
- LOG_DIR = (0, import_path9.resolve)((0, import_os5.homedir)(), "Library/Logs/sootsim");
121629
- LOG_DIR_LINUX = (0, import_path9.resolve)((0, import_os5.homedir)(), ".local/state/sootsim");
122002
+ LOG_DIR = (0, import_path9.resolve)((0, import_os6.homedir)(), "Library/Logs/sootsim");
122003
+ LOG_DIR_LINUX = (0, import_path9.resolve)((0, import_os6.homedir)(), ".local/state/sootsim");
121630
122004
  LSOF = process.platform === "darwin" ? "/usr/sbin/lsof" : "lsof";
121631
122005
  }
121632
122006
  });
@@ -121830,7 +122204,7 @@ examples:
121830
122204
  }
121831
122205
  console.log();
121832
122206
  }
121833
- const workDir = (0, import_path10.join)((0, import_os6.tmpdir)(), `peach-install-${Date.now()}`);
122207
+ const workDir = (0, import_path10.join)((0, import_os7.tmpdir)(), `peach-install-${Date.now()}`);
121834
122208
  const downloadPath = (0, import_path10.join)(workDir, target.filename);
121835
122209
  let lastDraw = 0;
121836
122210
  process.stdout.write(` Downloading ${target.filename}...
@@ -121930,13 +122304,13 @@ async function installNativeHost(args, force) {
121930
122304
  console.log(" peach desktop Launch the native desktop host");
121931
122305
  console.log(" peach open <target> --driver desktop Open a demo or bundle in it");
121932
122306
  }
121933
- var import_child_process9, import_fs11, import_os6, import_path10, DOWNLOAD_BASE;
122307
+ var import_child_process9, import_fs11, import_os7, import_path10, DOWNLOAD_BASE;
121934
122308
  var init_install_desktop = __esm({
121935
122309
  "cli/commands/install-desktop.ts"() {
121936
122310
  "use strict";
121937
122311
  import_child_process9 = require("child_process");
121938
122312
  import_fs11 = require("fs");
121939
- import_os6 = require("os");
122313
+ import_os7 = require("os");
121940
122314
  import_path10 = require("path");
121941
122315
  init_desktop_host_delivery();
121942
122316
  init_home_paths();
@@ -124162,8 +124536,18 @@ var init_metro_bundle_assets = __esm({
124162
124536
  var stream_exports = {};
124163
124537
  __export(stream_exports, {
124164
124538
  STREAM_FLAG: () => STREAM_FLAG,
124539
+ readLocalStreamRecord: () => readLocalStreamRecord,
124165
124540
  runStreamCommand: () => runStreamCommand
124166
124541
  });
124542
+ function readLocalStreamRecord(simId) {
124543
+ const file = (0, import_node_path151.join)(rnxHomeDir(), "streams", `${encodeURIComponent(simId)}.json`);
124544
+ try {
124545
+ return recordSchema.parse(JSON.parse((0, import_node_fs148.readFileSync)(file, "utf8")));
124546
+ } catch (error) {
124547
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
124548
+ throw error;
124549
+ }
124550
+ }
124167
124551
  async function runStreamCommand(args, opts = {}) {
124168
124552
  const parsed = parseBridgeCliArgs(args, { port: opts.port });
124169
124553
  const action = parsed.positional[0] ?? "status";
@@ -124204,13 +124588,7 @@ async function runStreamCommand(args, opts = {}) {
124204
124588
  };
124205
124589
  if (action === "stop") {
124206
124590
  await callInBridge(bridge, "SootSim.bridges.videoStream.stop");
124207
- let record6 = null;
124208
- try {
124209
- record6 = recordSchema.parse(JSON.parse((0, import_node_fs148.readFileSync)(file, "utf8")));
124210
- } catch (error) {
124211
- if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
124212
- throw error;
124213
- }
124591
+ const record6 = readLocalStreamRecord(simId);
124214
124592
  if (record6) await stopSession(record6);
124215
124593
  (0, import_node_fs148.rmSync)(file, { force: true });
124216
124594
  console.log(" stream: off");
@@ -137070,16 +137448,16 @@ async function readKotlinApp(moduleArg, options) {
137070
137448
  const name3 = element.attributes[`${ANDROID_NS}name`];
137071
137449
  if (!name3) throw new Error(`${manifestFile}: <${element.name}> has no android:name`);
137072
137450
  if (element.name === "activity") return className2(name3);
137073
- const targetName = element.attributes[`${ANDROID_NS}targetActivity`];
137451
+ const targetName2 = element.attributes[`${ANDROID_NS}targetActivity`];
137074
137452
  const activity = activities.find(
137075
- (candidate) => className2(candidate.attributes[`${ANDROID_NS}name`] ?? "") === className2(targetName ?? "")
137453
+ (candidate) => className2(candidate.attributes[`${ANDROID_NS}name`] ?? "") === className2(targetName2 ?? "")
137076
137454
  );
137077
- if (!targetName || !activity)
137455
+ if (!targetName2 || !activity)
137078
137456
  throw new Error(
137079
137457
  `${manifestFile}: activity-alias ${name3} targets no declared activity`
137080
137458
  );
137081
137459
  if (!enabled(activity)) return null;
137082
- return className2(targetName);
137460
+ return className2(targetName2);
137083
137461
  };
137084
137462
  const applicationEnabled = enabled(application);
137085
137463
  let chosen;
@@ -142084,8 +142462,8 @@ function randomInputText(step) {
142084
142462
  throw new Error("not a random input step");
142085
142463
  }
142086
142464
  }
142087
- function normalizeBareStringStep(verb2) {
142088
- switch (verb2) {
142465
+ function normalizeBareStringStep(verb3) {
142466
+ switch (verb3) {
142089
142467
  case "back":
142090
142468
  return { back: true };
142091
142469
  case "hideKeyboard":
@@ -142112,7 +142490,7 @@ function normalizeBareStringStep(verb2) {
142112
142490
  case "scrollUp":
142113
142491
  return { scroll: { direction: "UP" } };
142114
142492
  default:
142115
- return { [verb2]: true };
142493
+ return { [verb3]: true };
142116
142494
  }
142117
142495
  }
142118
142496
  function parseFlowSteps(content) {