peachsim 0.1.2476 → 0.1.2478

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 (139) hide show
  1. package/cli/agent-note.ts +14 -0
  2. package/cli/command-agent.ts +2 -0
  3. package/cli/commands/control.ts +3 -2
  4. package/cli/commands/stream.ts +28 -8
  5. package/dist-lib/agent-daemon-client.cjs +1 -1
  6. package/dist-lib/agent-events.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +2 -2
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +5 -5
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +3 -3
  17. package/dist-lib/bundle-channel.cjs +5382 -5067
  18. package/dist-lib/capture-contract.cjs +1 -1
  19. package/dist-lib/capture-contract.mjs +3 -3
  20. package/dist-lib/cloud-contract.cjs +2 -1
  21. package/dist-lib/cloud-contract.mjs +3 -3
  22. package/dist-lib/cloud-test-args.cjs +1 -1
  23. package/dist-lib/cloud-test-args.mjs +2 -2
  24. package/dist-lib/cloud.cjs +2 -1
  25. package/dist-lib/cloud.mjs +7 -7
  26. package/dist-lib/config.cjs +1 -1
  27. package/dist-lib/config.mjs +5 -5
  28. package/dist-lib/detox/index.cjs +5 -2
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/esm-chunks/{acorn-XUDP7FUU.mjs → acorn-FQLOTPEI.mjs} +3 -3
  31. package/dist-lib/esm-chunks/{chunk-5J6SH5PL.mjs → chunk-25VCIHSN.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-MS423IWH.mjs → chunk-355SS4SH.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-YA55AHKP.mjs → chunk-3IZX74HE.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-E254ZLN5.mjs → chunk-CIMYKM6N.mjs} +10 -8
  35. package/dist-lib/esm-chunks/{chunk-YKTS6JGV.mjs → chunk-FFCS7MFJ.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-YZGIW7I6.mjs → chunk-GGYYAJR7.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-T5HVFQ3M.mjs → chunk-GY7RVEFV.mjs} +4 -4
  38. package/dist-lib/esm-chunks/{chunk-XVVVMJ7H.mjs → chunk-ICJOTWER.mjs} +3 -3
  39. package/dist-lib/esm-chunks/{chunk-FG6NDDVL.mjs → chunk-JUPWMWSX.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-VXDXNH7I.mjs → chunk-LCAQS5UW.mjs} +2 -2
  41. package/dist-lib/esm-chunks/{chunk-BIODQMYB.mjs → chunk-MLVSAVNL.mjs} +2 -1
  42. package/dist-lib/esm-chunks/{chunk-AUTNUR7W.mjs → chunk-MQM5KR5X.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-DFHVJLBP.mjs → chunk-OVBWXPD7.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-ACRNH6CJ.mjs → chunk-Q47VNBNR.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-7TOYW4KW.mjs → chunk-RSSHYN7S.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-DRUSXLT2.mjs → chunk-TUJL2AP2.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-XUNG5UYW.mjs → chunk-UETOLHI7.mjs} +2059 -3500
  48. package/dist-lib/esm-chunks/{chunk-G7ZQ4MZU.mjs → chunk-VAQFAFOC.mjs} +37 -7
  49. package/dist-lib/esm-chunks/{chunk-GR4GWWVO.mjs → chunk-VORKZFQK.mjs} +1 -1
  50. package/dist-lib/esm-chunks/chunk-XEZ4K3TZ.mjs +1475 -0
  51. package/dist-lib/esm-chunks/{chunk-VW34BZCP.mjs → chunk-XSSZZ2HY.mjs} +1 -1
  52. package/dist-lib/esm-chunks/{metro-layout-parser-GQPBXOFJ.mjs → metro-layout-parser-MRCK7YD5.mjs} +3 -3
  53. package/dist-lib/esm-chunks/{swift-package-prebuilt-IMNLLYSA.mjs → swift-package-prebuilt-LYR2P26A.mjs} +10 -9
  54. package/dist-lib/esm-chunks/{swift-sdk-app-module-LZE3N3OS.mjs → swift-sdk-app-module-CXY5TKBA.mjs} +15 -13
  55. package/dist-lib/esm-chunks/{swift-sdk-image-E2QZGC53.mjs → swift-sdk-image-6L3AMATS.mjs} +13 -12
  56. package/dist-lib/esm-chunks/swift-sdk-image-producer-C4TNZ4UM.mjs +294 -0
  57. package/dist-lib/expo-swift-bundle.cjs +4362 -4047
  58. package/dist-lib/expo-swift-metadata.cjs +1 -1
  59. package/dist-lib/expo-swift-metadata.mjs +7 -7
  60. package/dist-lib/home-paths.cjs +1 -1
  61. package/dist-lib/host/bridge-host.cjs +5284 -4966
  62. package/dist-lib/host/fetch-proxy-handler.cjs +5 -5
  63. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  64. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  65. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  66. package/dist-lib/host/websocket-proxy.cjs +1 -1
  67. package/dist-lib/index.cjs +4 -1
  68. package/dist-lib/kotlin-host.cjs +1 -1
  69. package/dist-lib/menu.cjs +1 -1
  70. package/dist-lib/menu.mjs +3 -3
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +4 -4
  75. package/dist-lib/native-app-identity-project.cjs +2 -2
  76. package/dist-lib/native-app-identity-project.mjs +17 -15
  77. package/dist-lib/native-app-identity.cjs +1 -1
  78. package/dist-lib/native-app-identity.mjs +6 -6
  79. package/dist-lib/native-firebase-metadata.cjs +1 -1
  80. package/dist-lib/native-firebase-metadata.mjs +3 -3
  81. package/dist-lib/pdfium-raster.cjs +1 -1
  82. package/dist-lib/pdfium-raster.mjs +2 -2
  83. package/dist-lib/plist.cjs +1 -1
  84. package/dist-lib/plist.mjs +3 -3
  85. package/dist-lib/profiles.cjs +1 -1
  86. package/dist-lib/public-brand.cjs +1 -1
  87. package/dist-lib/public-origins-lib-esm.json +92 -81
  88. package/dist-lib/public-origins-lib.json +74 -69
  89. package/dist-lib/react-native-host-modules.cjs +1 -1
  90. package/dist-lib/react-native-host-modules.mjs +2 -2
  91. package/dist-lib/reap-browser.cjs +1 -1
  92. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  93. package/dist-lib/sdk.cjs +1 -1
  94. package/dist-lib/sdk.mjs +7 -7
  95. package/dist-lib/skills.cjs +5903 -5569
  96. package/dist-lib/swift-compile.cjs +1280 -965
  97. package/dist-lib/swift-compile.mjs +10 -9
  98. package/dist-lib/swift-package.cjs +1 -1
  99. package/dist-lib/swift-package.mjs +3 -3
  100. package/dist-lib/swift-submit.cjs +1 -1
  101. package/dist-lib/swift-submit.mjs +5 -5
  102. package/dist-lib/swift-svg-raster.cjs +1 -1
  103. package/dist-lib/swift-svg-raster.mjs +2 -2
  104. package/dist-lib/swift-toolchain.cjs +1 -1
  105. package/dist-lib/swift.cjs +1 -1
  106. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  108. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  109. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  110. package/dist-lib/vendor/acorn.cjs +1 -1
  111. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  112. package/dist-lib/vendor/ignore.cjs +1 -1
  113. package/dist-lib/vendor/magic-string.cjs +1 -1
  114. package/dist-lib/vendor/plist.cjs +1 -1
  115. package/dist-lib/vendor/smol-toml.cjs +1 -1
  116. package/dist-lib/vendor/stream-json.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  119. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  120. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  121. package/dist-lib/vendor/sucrase.cjs +1 -1
  122. package/dist-lib/vendor/terser.cjs +1 -1
  123. package/dist-lib/vendor/valibot.cjs +1 -1
  124. package/dist-lib/vendor/ws.cjs +1 -1
  125. package/dist-lib/vendor/zod.cjs +1 -1
  126. package/dist-lib/worklet-executable.cjs +1 -1
  127. package/dist-lib/worklet-executable.mjs +3 -3
  128. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +4 -2
  129. package/dist-types/packages/peach-globals/src/compositorBridgeContract.d.ts +1 -0
  130. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  131. package/dist-types/packages/peach-globals/src/replayBridgeContract.d.ts +3 -2
  132. package/package.json +1 -1
  133. package/runtime-companion.json +1 -1
  134. package/src/bridge-contract.ts +1 -0
  135. package/src/cloud-contract.ts +1 -0
  136. package/src/host/bridge-host.ts +7 -1
  137. package/src/swift-compile.ts +1 -0
  138. package/src/swift-sdk-image-producer.ts +336 -0
  139. package/src/swift-sdk-image.ts +37 -1
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2476 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2478 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // ../contrast-runtime-delivery/src/version.ts
4
4
  function isValidRuntimeVersion(value) {
@@ -1,5 +1,5 @@
1
- /*! peach v0.1.2476 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
- import "./chunk-YA55AHKP.mjs";
1
+ /*! peach v0.1.2478 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ import "./chunk-3IZX74HE.mjs";
3
3
 
4
4
  // src/metro-layout-parser.ts
5
5
  var whitespace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/y;
@@ -8,7 +8,7 @@ var lineBreak = /[\r\n\u2028\u2029]/;
8
8
  var metroLayoutParser;
9
9
  async function loadMetroLayoutParser() {
10
10
  if (metroLayoutParser) return metroLayoutParser;
11
- const { Parser } = await import("./acorn-XUDP7FUU.mjs");
11
+ const { Parser } = await import("./acorn-FQLOTPEI.mjs");
12
12
  metroLayoutParser = Parser.extend(
13
13
  (Base) => {
14
14
  const parseFunctionBody = Reflect.get(Base.prototype, "parseFunctionBody");
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2476 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2478 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  compileTargets,
4
4
  fetchNativeEntry,
@@ -6,18 +6,19 @@ import {
6
6
  swiftAvailableModules,
7
7
  swiftDistributionAt,
8
8
  swiftImportNames
9
- } from "./chunk-XUNG5UYW.mjs";
9
+ } from "./chunk-UETOLHI7.mjs";
10
+ import "./chunk-XEZ4K3TZ.mjs";
10
11
  import {
11
12
  SWIFT_REMOTE_PACKAGES_DIR
12
- } from "./chunk-7TOYW4KW.mjs";
13
+ } from "./chunk-RSSHYN7S.mjs";
13
14
  import {
14
15
  manifestCalls
15
- } from "./chunk-5J6SH5PL.mjs";
16
- import "./chunk-DFHVJLBP.mjs";
17
- import "./chunk-ACRNH6CJ.mjs";
18
- import "./chunk-VW34BZCP.mjs";
19
- import "./chunk-AUTNUR7W.mjs";
20
- import "./chunk-YA55AHKP.mjs";
16
+ } from "./chunk-25VCIHSN.mjs";
17
+ import "./chunk-OVBWXPD7.mjs";
18
+ import "./chunk-Q47VNBNR.mjs";
19
+ import "./chunk-XSSZZ2HY.mjs";
20
+ import "./chunk-MQM5KR5X.mjs";
21
+ import "./chunk-3IZX74HE.mjs";
21
22
 
22
23
  // src/swift-package-prebuilt.ts
23
24
  import { createHash } from "node:crypto";
@@ -1,13 +1,13 @@
1
- /*! peach v0.1.2476 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2478 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  SWIFT_SDK_APP_MEMORY_BASE,
4
4
  SWIFT_SDK_APP_TABLE_BASE,
5
5
  SWIFT_SDK_MEMORY_BASE,
6
6
  SWIFT_SDK_PIECE_FIELDS,
7
7
  readSwiftSdkManifest
8
- } from "./chunk-G7ZQ4MZU.mjs";
9
- import "./chunk-E254ZLN5.mjs";
10
- import "./chunk-DRUSXLT2.mjs";
8
+ } from "./chunk-VAQFAFOC.mjs";
9
+ import "./chunk-CIMYKM6N.mjs";
10
+ import "./chunk-TUJL2AP2.mjs";
11
11
  import {
12
12
  ADDEND_RELOCATIONS,
13
13
  KEEP_WASM_NAMES,
@@ -17,7 +17,6 @@ import {
17
17
  NATIVE_SDK_THUNK_SECTION,
18
18
  SWIFT_PRUNED_LINK_MAP,
19
19
  SWIFT_SDK_FUNCTION_ADDRESS_PREFIX,
20
- SWIFT_WASM_TRIPLE,
21
20
  chunkKey,
22
21
  constructorKeys,
23
22
  guestLazyExports,
@@ -35,14 +34,17 @@ import {
35
34
  wasmReader,
36
35
  wasmSections,
37
36
  writeWasmCustomSection
38
- } from "./chunk-XUNG5UYW.mjs";
39
- import "./chunk-7TOYW4KW.mjs";
40
- import "./chunk-5J6SH5PL.mjs";
41
- import "./chunk-DFHVJLBP.mjs";
42
- import "./chunk-ACRNH6CJ.mjs";
43
- import "./chunk-VW34BZCP.mjs";
44
- import "./chunk-AUTNUR7W.mjs";
45
- import "./chunk-YA55AHKP.mjs";
37
+ } from "./chunk-UETOLHI7.mjs";
38
+ import {
39
+ SWIFT_WASM_TRIPLE
40
+ } from "./chunk-XEZ4K3TZ.mjs";
41
+ import "./chunk-RSSHYN7S.mjs";
42
+ import "./chunk-25VCIHSN.mjs";
43
+ import "./chunk-OVBWXPD7.mjs";
44
+ import "./chunk-Q47VNBNR.mjs";
45
+ import "./chunk-XSSZZ2HY.mjs";
46
+ import "./chunk-MQM5KR5X.mjs";
47
+ import "./chunk-3IZX74HE.mjs";
46
48
 
47
49
  // src/swift-sdk-app-module.ts
48
50
  import { execFile } from "node:child_process";
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2476 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2478 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  SWIFT_SDK_APP_MEMORY_BASE,
4
4
  SWIFT_SDK_APP_TABLE_BASE,
@@ -15,17 +15,18 @@ import {
15
15
  swiftSdkImageFile,
16
16
  swiftSdkImageKey,
17
17
  swiftSdkImageProducts
18
- } from "./chunk-G7ZQ4MZU.mjs";
19
- import "./chunk-E254ZLN5.mjs";
20
- import "./chunk-DRUSXLT2.mjs";
21
- import "./chunk-XUNG5UYW.mjs";
22
- import "./chunk-7TOYW4KW.mjs";
23
- import "./chunk-5J6SH5PL.mjs";
24
- import "./chunk-DFHVJLBP.mjs";
25
- import "./chunk-ACRNH6CJ.mjs";
26
- import "./chunk-VW34BZCP.mjs";
27
- import "./chunk-AUTNUR7W.mjs";
28
- import "./chunk-YA55AHKP.mjs";
18
+ } from "./chunk-VAQFAFOC.mjs";
19
+ import "./chunk-CIMYKM6N.mjs";
20
+ import "./chunk-TUJL2AP2.mjs";
21
+ import "./chunk-UETOLHI7.mjs";
22
+ import "./chunk-XEZ4K3TZ.mjs";
23
+ import "./chunk-RSSHYN7S.mjs";
24
+ import "./chunk-25VCIHSN.mjs";
25
+ import "./chunk-OVBWXPD7.mjs";
26
+ import "./chunk-Q47VNBNR.mjs";
27
+ import "./chunk-XSSZZ2HY.mjs";
28
+ import "./chunk-MQM5KR5X.mjs";
29
+ import "./chunk-3IZX74HE.mjs";
29
30
  export {
30
31
  SWIFT_SDK_APP_MEMORY_BASE,
31
32
  SWIFT_SDK_APP_TABLE_BASE,
@@ -0,0 +1,294 @@
1
+ /*! peach v0.1.2478 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ import {
3
+ swiftCacheDir,
4
+ windowAdmission,
5
+ withSwiftRootLock
6
+ } from "./chunk-XEZ4K3TZ.mjs";
7
+ import {
8
+ isRecord
9
+ } from "./chunk-MQM5KR5X.mjs";
10
+ import "./chunk-3IZX74HE.mjs";
11
+
12
+ // src/swift-sdk-image-producer.ts
13
+ import { execFile, execFileSync } from "node:child_process";
14
+ import { randomUUID } from "node:crypto";
15
+ import {
16
+ existsSync,
17
+ mkdirSync,
18
+ readFileSync,
19
+ renameSync,
20
+ rmSync,
21
+ writeFileSync
22
+ } from "node:fs";
23
+ import path from "node:path";
24
+ import { setTimeout as sleep } from "node:timers/promises";
25
+ import { promisify } from "node:util";
26
+ var run = promisify(execFile);
27
+ var environmentNames = [
28
+ "CONTRAST_BUILDERS_ROOT",
29
+ "PEACH_HOME",
30
+ "PEACH_SWIFT_SDKS_PATH",
31
+ "CONTRAST_SWIFT_TOOLCHAINS",
32
+ "PEACH_SWIFT_PRIVATE_COMPILER_RELEASE",
33
+ "PEACH_SWIFT_NAMES"
34
+ ];
35
+ function readRequest(file) {
36
+ const value = JSON.parse(readFileSync(file, "utf8"));
37
+ if (!isRecord(value) || typeof value.key !== "string" || !/^[a-f0-9]{32}$/.test(value.key) || typeof value.launchId !== "string" || typeof value.created !== "number" || typeof value.scopedLookups !== "boolean" || !Array.isArray(value.imports) || value.imports.some((name) => typeof name !== "string") || typeof value.cache !== "string" || !path.isAbsolute(value.cache) || !isRecord(value.environment) || Object.entries(value.environment).some(
38
+ ([name, item]) => !environmentNames.some((allowed) => allowed === name) || typeof item !== "string"
39
+ ))
40
+ throw new Error(`invalid Swift SDK producer request: ${file}`);
41
+ const environment = {};
42
+ for (const name of environmentNames) {
43
+ const item = value.environment[name];
44
+ if (typeof item === "string") environment[name] = item;
45
+ }
46
+ return {
47
+ key: value.key,
48
+ launchId: value.launchId,
49
+ created: value.created,
50
+ scopedLookups: value.scopedLookups,
51
+ imports: value.imports,
52
+ cache: value.cache,
53
+ environment
54
+ };
55
+ }
56
+ function swiftSdkProducerRequest(file) {
57
+ return readRequest(file);
58
+ }
59
+ function applySwiftSdkProducerEnvironment(environment) {
60
+ for (const name of environmentNames) {
61
+ const value = environment[name];
62
+ if (value === void 0) delete process.env[name];
63
+ else process.env[name] = value;
64
+ }
65
+ }
66
+ function writeSwiftSdkProducerResult(file, launchId, error) {
67
+ const temporary = `${file}.${randomUUID()}`;
68
+ writeFileSync(temporary, JSON.stringify({ launchId, error: error ?? null }));
69
+ renameSync(temporary, file);
70
+ }
71
+ var launcher = `set -eu
72
+ tm detach "$TM_SESSION" >/dev/null
73
+ printf '%s\\n' "$TM_SESSION" > "$1.tmp"
74
+ mv "$1.tmp" "$1"
75
+ shift
76
+ export GIT_ALTERNATE_OBJECT_DIRECTORIES="$2/objects"
77
+ set +e
78
+ env -u TM_WINDOW -u TM_WAIT_DEADLINE_MS -u TM_EXEC_OUTER_DEADLINE_MS -u REMOTE_BUILD_DEADLINE -u TM_EXEC_ADMITTED -u LINUX_BUILD_SCOPE -u TM_EXEC_CPU_CORES -u TM_EXEC_LINUX_MEMORY_MAX -u CONTRAST_HEAVY_ADMITTED -u CONTRAST_HEAVY_CPU_CORES tm exec --local --kind build-linux --cores "$1" --timeout 90m --param wait=true --param "source-snapshot=$2" --param "delivery-dir=$4" --param "serial-key=swift-sdk-$5" -- bun scripts/ops/produce-swift-sdk-image.ts "$3" </dev/null
79
+ status=$?
80
+ if bun -e 'try { if (JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8")).released !== true) process.exit(1) } catch { process.exit(1) }' "$4/cleanup.json"; then rm -rf "$2"; fi
81
+ exit "$status"
82
+ `;
83
+ function retainSnapshotObjects(repo, capture) {
84
+ const target = path.join(capture, "objects");
85
+ const original = readFileSync(path.join(target, "info/alternates"), "utf8").trim();
86
+ const inherited = path.join(original, "info/alternates");
87
+ const retainedAlternates = existsSync(inherited) ? readFileSync(inherited, "utf8").split("\n").filter(Boolean).map((entry) => path.resolve(original, entry)) : [];
88
+ const env = {
89
+ ...process.env,
90
+ GIT_OBJECT_DIRECTORY: target,
91
+ GIT_NO_LAZY_FETCH: "1"
92
+ };
93
+ delete env.GIT_ALTERNATE_OBJECT_DIRECTORIES;
94
+ const roots = ["source-commit", "staged-tree", "worktree-tree"].map(
95
+ (file) => readFileSync(path.join(capture, file), "utf8").trim()
96
+ );
97
+ const inventoryArgs = [
98
+ "-C",
99
+ repo,
100
+ "rev-list",
101
+ "--objects",
102
+ "--no-object-names",
103
+ "--missing=print",
104
+ "--no-walk",
105
+ ...roots
106
+ ];
107
+ const inventory = execFileSync("git", inventoryArgs, {
108
+ encoding: "utf8",
109
+ env,
110
+ maxBuffer: 64 * 1024 * 1024
111
+ });
112
+ if (inventory.split("\n").some((line) => line.startsWith("?")))
113
+ throw new Error("Swift SDK producer snapshot is missing source objects");
114
+ const history = execFileSync(
115
+ "git",
116
+ ["-C", repo, "rev-list", "--first-parent", roots[0]],
117
+ {
118
+ encoding: "utf8",
119
+ env,
120
+ maxBuffer: 64 * 1024 * 1024
121
+ }
122
+ );
123
+ mkdirSync(path.join(target, "pack"), { recursive: true });
124
+ execFileSync("git", ["-C", repo, "pack-objects", path.join(target, "pack/source")], {
125
+ input: `${inventory}${history}`,
126
+ env,
127
+ stdio: ["pipe", "ignore", "inherit"]
128
+ });
129
+ rmSync(path.join(target, "info/alternates"), { force: true });
130
+ const retained = execFileSync("git", inventoryArgs, {
131
+ encoding: "utf8",
132
+ env,
133
+ maxBuffer: 64 * 1024 * 1024
134
+ });
135
+ if (retained.split("\n").some((line) => line.startsWith("?")))
136
+ throw new Error("Swift SDK producer could not retain its source objects");
137
+ if (retainedAlternates.length)
138
+ writeFileSync(
139
+ path.join(target, "info/alternates"),
140
+ `${retainedAlternates.join("\n")}
141
+ `
142
+ );
143
+ }
144
+ function producerSession(file) {
145
+ if (!existsSync(file)) return null;
146
+ const session = readFileSync(file, "utf8").trim();
147
+ if (!/^[a-z0-9-]+$/.test(session))
148
+ throw new Error(`invalid Swift SDK producer session: ${file}`);
149
+ const status = JSON.parse(
150
+ execFileSync("tm", ["show", "record", session], { encoding: "utf8" })
151
+ );
152
+ if (!isRecord(status) || typeof status.state !== "string")
153
+ throw new Error(`cannot inspect Swift SDK producer ${session}`);
154
+ return { session, state: status.state };
155
+ }
156
+ function producerSettled(directory) {
157
+ if (producerSession(path.join(directory, "session"))?.state !== "exited") return false;
158
+ const receipt = path.join(directory, "delivery/cleanup.json");
159
+ if (!existsSync(receipt)) return false;
160
+ const value = JSON.parse(readFileSync(receipt, "utf8"));
161
+ return isRecord(value) && value.released === true;
162
+ }
163
+ async function produceSwiftSdkImage(input) {
164
+ const root = path.join(swiftCacheDir(), "swift-sdk-image-producers", input.key);
165
+ const current = path.join(root, "current");
166
+ input.signal?.throwIfAborted();
167
+ const claim = await withSwiftRootLock(
168
+ `${root}.claim`,
169
+ async () => {
170
+ if (input.ready()) return null;
171
+ if (existsSync(current)) {
172
+ const generation = readFileSync(current, "utf8").trim();
173
+ if (!/^[a-f0-9-]{36}$/.test(generation))
174
+ throw new Error(`invalid Swift SDK producer generation: ${current}`);
175
+ const directory3 = path.join(root, generation);
176
+ const request2 = readRequest(path.join(directory3, "request.json"));
177
+ if (request2.launchId !== generation)
178
+ throw new Error(`Swift SDK producer generation differs: ${directory3}`);
179
+ const session = producerSession(path.join(directory3, "session"));
180
+ if (session) {
181
+ if (!producerSettled(directory3)) return { directory: directory3, request: request2 };
182
+ rmSync(path.join(directory3, "snapshot"), {
183
+ recursive: true,
184
+ force: true
185
+ });
186
+ } else if (Date.now() - request2.created <= 6e4) {
187
+ return { directory: directory3, request: request2 };
188
+ }
189
+ }
190
+ const repo = path.resolve(input.moduleRoot, "../..");
191
+ const launchId = randomUUID();
192
+ const directory2 = path.join(root, launchId);
193
+ const requestFile = path.join(directory2, "request.json");
194
+ const sessionFile2 = path.join(directory2, "session");
195
+ const capture = path.join(root, `.capture-${launchId}`);
196
+ mkdirSync(root, { recursive: true });
197
+ try {
198
+ execFileSync(
199
+ "bash",
200
+ [path.join(repo, "scripts/lib/remote-source-snapshot.sh"), repo, capture],
201
+ {
202
+ stdio: "inherit"
203
+ }
204
+ );
205
+ retainSnapshotObjects(repo, capture);
206
+ mkdirSync(directory2);
207
+ renameSync(capture, path.join(directory2, "snapshot"));
208
+ const environment = {};
209
+ for (const name of environmentNames) {
210
+ const value = process.env[name];
211
+ if (value !== void 0) environment[name] = value;
212
+ }
213
+ const record = {
214
+ key: input.key,
215
+ launchId,
216
+ created: Date.now(),
217
+ scopedLookups: input.scopedLookups,
218
+ imports: [...input.imports],
219
+ cache: swiftCacheDir(),
220
+ environment
221
+ };
222
+ writeFileSync(requestFile, JSON.stringify(record), { flag: "wx" });
223
+ const next = `${current}.${launchId}`;
224
+ writeFileSync(next, launchId, { flag: "wx" });
225
+ renameSync(next, current);
226
+ const admitted = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
227
+ const cores = Number.isSafeInteger(admitted) && admitted > 0 ? Math.max(4, admitted) : 4;
228
+ const launched = await run(
229
+ "tm",
230
+ [
231
+ "run",
232
+ "--here",
233
+ "--in-place",
234
+ "--quiet",
235
+ "--no-finish-notice",
236
+ "--slug",
237
+ `swift-sdk-image-${record.launchId.slice(0, 8)}`,
238
+ "--",
239
+ "/bin/sh",
240
+ "-c",
241
+ launcher,
242
+ "swift-sdk-image",
243
+ sessionFile2,
244
+ String(cores),
245
+ path.join(directory2, "snapshot"),
246
+ requestFile,
247
+ path.join(directory2, "delivery"),
248
+ input.frameworkKey
249
+ ],
250
+ { cwd: repo }
251
+ );
252
+ if (!launched.stdout.trim())
253
+ throw new Error(`Swift SDK producer launch was not confirmed: ${directory2}`);
254
+ return { directory: directory2, request: record };
255
+ } finally {
256
+ rmSync(capture, { recursive: true, force: true });
257
+ }
258
+ },
259
+ input.signal
260
+ );
261
+ if (!claim) return;
262
+ const { directory, request } = claim;
263
+ const sessionFile = path.join(directory, "session");
264
+ const resultFile = path.join(directory, "result.json");
265
+ if (request.key !== input.key || request.cache !== swiftCacheDir())
266
+ throw new Error(`Swift SDK producer identity mismatch: ${directory}`);
267
+ for (; ; ) {
268
+ if (existsSync(resultFile)) {
269
+ const result = JSON.parse(readFileSync(resultFile, "utf8"));
270
+ if (!isRecord(result) || result.launchId !== request.launchId || !(result.error === null || typeof result.error === "string"))
271
+ throw new Error(`invalid Swift SDK producer result: ${resultFile}`);
272
+ if (result.error) throw new Error(`Swift SDK producer failed: ${result.error}`);
273
+ return;
274
+ }
275
+ const status = producerSession(sessionFile);
276
+ if (status) {
277
+ if (status.state === "exited") {
278
+ if (existsSync(resultFile)) continue;
279
+ throw new Error(
280
+ `Swift SDK producer ${status.session} exited without a result; inspect its session before retrying`
281
+ );
282
+ }
283
+ } else if (Date.now() - request.created > 6e4) {
284
+ throw new Error(`Swift SDK producer launch is unconfirmed: ${directory}`);
285
+ }
286
+ await sleep(2e3, void 0, { signal: input.signal });
287
+ }
288
+ }
289
+ export {
290
+ applySwiftSdkProducerEnvironment,
291
+ produceSwiftSdkImage,
292
+ swiftSdkProducerRequest,
293
+ writeSwiftSdkProducerResult
294
+ };