peachsim 0.1.708 → 0.1.710

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 (84) hide show
  1. package/cli/commands/control.ts +55 -1
  2. package/cli/current-sim.ts +15 -1
  3. package/cli/drivers/playwright-sim-host.ts +14 -1
  4. package/cli/drivers/playwright.ts +36 -3
  5. package/cli/main.ts +8 -0
  6. package/cli/outbound-endpoints.ts +95 -27
  7. package/cli/parent-pid.ts +91 -15
  8. package/cli/ws-bridge.ts +5 -0
  9. package/dist-lib/agent-daemon-client.cjs +1 -1
  10. package/dist-lib/agent-events.cjs +1 -1
  11. package/dist-lib/agent-identity.cjs +1 -1
  12. package/dist-lib/agent-sessions.cjs +1 -1
  13. package/dist-lib/attached-projects.cjs +1 -1
  14. package/dist-lib/auth/shared-session.cjs +1 -1
  15. package/dist-lib/backend-origin.cjs +1 -1
  16. package/dist-lib/beta.cjs +1 -1
  17. package/dist-lib/beta.mjs +1 -1
  18. package/dist-lib/bridge-constants.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.cjs +1 -1
  20. package/dist-lib/bridge-contract-input.mjs +1 -1
  21. package/dist-lib/bridge-contract.cjs +1 -1
  22. package/dist-lib/bridge-contract.mjs +1 -1
  23. package/dist-lib/capture-contract.cjs +1 -1
  24. package/dist-lib/capture-contract.mjs +1 -1
  25. package/dist-lib/cli-constants.cjs +1 -1
  26. package/dist-lib/cloud-contract.cjs +1 -1
  27. package/dist-lib/cloud-contract.mjs +1 -1
  28. package/dist-lib/cloud-test-args.cjs +1 -1
  29. package/dist-lib/cloud-test-args.mjs +1 -1
  30. package/dist-lib/cloud.cjs +1 -1
  31. package/dist-lib/cloud.mjs +1 -1
  32. package/dist-lib/config.cjs +1 -1
  33. package/dist-lib/detox/index.cjs +78 -5
  34. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  35. package/dist-lib/home-paths.cjs +1 -1
  36. package/dist-lib/host/bridge-host.cjs +172 -30
  37. package/dist-lib/host/fetch-proxy-handler.cjs +45 -21
  38. package/dist-lib/host/fetch-proxy-overrides.cjs +2 -2
  39. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  40. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  41. package/dist-lib/host/websocket-proxy.cjs +1 -1
  42. package/dist-lib/index.cjs +78 -5
  43. package/dist-lib/jump-to-source-babel.cjs +1 -1
  44. package/dist-lib/jump-to-source-native.cjs +1 -1
  45. package/dist-lib/kotlin-host.cjs +1 -1
  46. package/dist-lib/menu.cjs +1 -1
  47. package/dist-lib/menu.mjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  50. package/dist-lib/metro-production-bundle.cjs +1 -1
  51. package/dist-lib/metro-production-bundle.mjs +1 -1
  52. package/dist-lib/metro.cjs +1 -1
  53. package/dist-lib/native-app-identity.cjs +1 -1
  54. package/dist-lib/native-app-identity.mjs +1 -1
  55. package/dist-lib/native-firebase-metadata.cjs +1 -1
  56. package/dist-lib/native-firebase-metadata.mjs +1 -1
  57. package/dist-lib/plist.cjs +1 -1
  58. package/dist-lib/plist.mjs +1 -1
  59. package/dist-lib/profiles.cjs +1 -1
  60. package/dist-lib/public-brand.cjs +1 -1
  61. package/dist-lib/react-native-host-modules.cjs +1 -1
  62. package/dist-lib/react-native-host-modules.mjs +1 -1
  63. package/dist-lib/render-mode.cjs +1 -1
  64. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  65. package/dist-lib/sdk.cjs +1 -1
  66. package/dist-lib/sdk.mjs +1 -1
  67. package/dist-lib/skills.cjs +333 -53
  68. package/dist-lib/swift-compile.cjs +8 -2
  69. package/dist-lib/swift-compile.mjs +8 -2
  70. package/dist-lib/swift-package.cjs +1 -1
  71. package/dist-lib/swift-package.mjs +1 -1
  72. package/dist-lib/swift-submit.cjs +2 -2
  73. package/dist-lib/swift-submit.mjs +2 -2
  74. package/dist-lib/swift-toolchain.cjs +1 -1
  75. package/dist-lib/swift.cjs +1 -1
  76. package/dist-lib/vite-swift.cjs +9 -3
  77. package/dist-lib/vite.cjs +1 -1
  78. package/package.json +2 -1
  79. package/src/host/bridge-host.ts +65 -0
  80. package/src/host/fetch-proxy-handler.ts +52 -23
  81. package/src/host/fetch-proxy-overrides.ts +5 -1
  82. package/src/host/fetch-proxy-transport.ts +82 -0
  83. package/src/swift-compile.ts +8 -2
  84. package/src/swift-submit.ts +2 -1
@@ -881,6 +881,9 @@ export interface BuildShellUrlOptions {
881
881
  // shell pins at boot over the device profile's own version. an oracle on a
882
882
  // newer os than the profile compares only when the sim runs that os era.
883
883
  osVersion?: string
884
+ // appearance scheme (light|dark|auto) stamped as ?theme=, which the shell
885
+ // reads at boot over the persisted scheme. set by `peach open -t/--theme`.
886
+ theme?: string
884
887
  resolvedBundle?: ResolvedDevBundle
885
888
  project?: ResolvedAppProject | null
886
889
  // deterministic-capture mode, stamped onto the engine URL as ?proof=1. the
@@ -951,6 +954,7 @@ export async function buildShellUrl(
951
954
  !opts.posture &&
952
955
  !opts.orientation &&
953
956
  !opts.osVersion &&
957
+ !opts.theme &&
954
958
  !opts.env?.length &&
955
959
  !opts.dotEnv
956
960
  )
@@ -961,6 +965,7 @@ export async function buildShellUrl(
961
965
  if (opts.posture) url.searchParams.set('posture', opts.posture)
962
966
  if (opts.orientation) url.searchParams.set('orientation', opts.orientation)
963
967
  if (opts.osVersion) url.searchParams.set('osVersion', opts.osVersion)
968
+ if (opts.theme) url.searchParams.set('theme', opts.theme)
964
969
  if (opts.proof) url.searchParams.set('proof', '1')
965
970
  for (const entry of opts.env ?? []) url.searchParams.append('env', entry)
966
971
  return url.toString()
@@ -1179,6 +1184,21 @@ export function signalDriverLaunchConnected(result: DriverLaunchResult): boolean
1179
1184
  }
1180
1185
  }
1181
1186
 
1187
+ // the playwright host exits fast with [unserved] when its initial navigation
1188
+ // is connection-refused: nothing serves the url, so no sim can ever
1189
+ // register. surface that as the failure instead of the generic host-crashed
1190
+ // line below.
1191
+ function readUnservedUrl(result: DriverLaunchResult): string | null {
1192
+ if (!result.diagnosticLogPath) return null
1193
+ try {
1194
+ const detail = fs.readFileSync(result.diagnosticLogPath, 'utf8')
1195
+ const match = detail.match(/\[unserved\] nothing serves (\S+)/)
1196
+ return match ? match[1] : null
1197
+ } catch {
1198
+ return null
1199
+ }
1200
+ }
1201
+
1182
1202
  function printDriverDiagnosticLogTail(result: DriverLaunchResult) {
1183
1203
  if (!result.diagnosticLogPath) return
1184
1204
  try {
@@ -1509,6 +1529,8 @@ export async function runOpenCommand(
1509
1529
  '--os-version',
1510
1530
  '--viewport',
1511
1531
  '--env',
1532
+ '--theme',
1533
+ '-t',
1512
1534
  ],
1513
1535
  })
1514
1536
  const requestedProfileId = args.find((_, i) => args[i - 1] === '--profile')
@@ -1552,6 +1574,30 @@ export async function runOpenCommand(
1552
1574
  rnxExit(1)
1553
1575
  }
1554
1576
 
1577
+ // -t / --theme <light|dark|auto> seeds the appearance for the opened sim,
1578
+ // stamped on the engine URL as ?theme= next to ?device=: the shell reads it
1579
+ // at boot over the persisted scheme. without this the flag fell into the
1580
+ // positional target (`peach open -t dark` opened `?open=-t`) and the theme
1581
+ // was silently dropped. validated up here so a bad flag fails before the
1582
+ // bridge spawns.
1583
+ const themeFlagIndex = args.findIndex((arg) => arg === '--theme' || arg === '-t')
1584
+ const themeArg = themeFlagIndex === -1 ? undefined : args[themeFlagIndex + 1]
1585
+ if (themeFlagIndex !== -1 && themeArg === undefined) {
1586
+ console.error(' peach open: --theme expects light, dark, or auto')
1587
+ rnxExit(1)
1588
+ }
1589
+ if (
1590
+ themeArg !== undefined &&
1591
+ themeArg !== 'light' &&
1592
+ themeArg !== 'dark' &&
1593
+ themeArg !== 'auto'
1594
+ ) {
1595
+ console.error(
1596
+ ` peach open: --theme must be light, dark, or auto, got "${themeArg}"`,
1597
+ )
1598
+ rnxExit(1)
1599
+ }
1600
+
1555
1601
  if (isAppDeepLinkTarget(target)) {
1556
1602
  if (openInNewSim) {
1557
1603
  console.error(
@@ -1798,6 +1844,7 @@ export async function runOpenCommand(
1798
1844
  posture: postureArg,
1799
1845
  orientation: orientationArg,
1800
1846
  osVersion: osVersionArg,
1847
+ theme: themeArg,
1801
1848
  resolvedBundle,
1802
1849
  project,
1803
1850
  proof: args.includes('--proof'),
@@ -2041,7 +2088,14 @@ export async function runOpenCommand(
2041
2088
  )
2042
2089
  if (outcome.kind === 'host-exit') {
2043
2090
  printDriverDiagnosticLogTail(result)
2044
- console.error(` ${driver.name} host crashed — sim is no longer attached`)
2091
+ const unserved = readUnservedUrl(result)
2092
+ if (unserved) {
2093
+ console.error(
2094
+ ` nothing serves ${unserved} — start the shell or daemon that owns it, then try again`,
2095
+ )
2096
+ } else {
2097
+ console.error(` ${driver.name} host crashed — sim is no longer attached`)
2098
+ }
2045
2099
  rnxExit(1)
2046
2100
  }
2047
2101
  if (outcome.kind === 'timeout') {
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync, rmSync } from 'fs'
2
2
  import { tmpdir } from 'os'
3
3
  import { basename, dirname, join, resolve } from 'path'
4
- import { getParentPid, getProcessComm } from './parent-pid'
4
+ import { getParentPid, getProcessComm, getProcessPgid } from './parent-pid'
5
5
  import { writeSecureJsonAtomic } from './secure-file'
6
6
 
7
7
  const CURRENT_SIM_VERSION = 2 as const
@@ -145,6 +145,20 @@ export function getStableOwnerPid(): number | null {
145
145
  return findTopAncestor(process.ppid)
146
146
  }
147
147
 
148
+ // the process group of the stable owning session, for leases that must die
149
+ // with the session: the bridge frees a cli lease whose owner group no longer
150
+ // exists instead of blocking other callers until the TTL burns out. the
151
+ // owner's group, not this process's own — an interactive shell runs each
152
+ // command in a fresh foreground group, so our own pgid would die with every
153
+ // invocation and no lease would ever survive it. null when ancestry is
154
+ // unreadable; the lease then behaves as before (TTL only).
155
+ export function getOwnerProcessGroupId(): number | null {
156
+ const owner = getStableOwnerPid()
157
+ if (!owner || owner <= 1) return null
158
+ const pgid = getProcessPgid(owner)
159
+ return pgid !== null && pgid > 1 ? pgid : null
160
+ }
161
+
148
162
  export function getCurrentSimPath() {
149
163
  if (process.env[CURRENT_SIM_PATH_ENV]) {
150
164
  return resolve(process.env[CURRENT_SIM_PATH_ENV])
@@ -49,6 +49,7 @@ const url = process.env.SOOTSIM_PW_URL;
49
49
  // window.__sootsimBridgePort so the page skips its shell-port heuristic (which
50
50
  // assumes the default offset and breaks when the dev bridge drifted).
51
51
  const bridgePort = process.env.SOOTSIM_PW_BRIDGE_PORT || '';
52
+ const fetchProxySpki = process.env.PEACH_PW_FETCH_PROXY_SPKI || '';
52
53
  const headless = process.env.SOOTSIM_PW_HEADLESS === '1';
53
54
  const callerUserDataDir = process.env.SOOTSIM_PW_USERDATADIR || '';
54
55
  // pid of the session that launched us (its topmost non-init ancestor). when
@@ -403,6 +404,7 @@ const cleanupProfile = () => {
403
404
  opts.args.push('--enable-features=Vulkan');
404
405
  }
405
406
  opts.args.push(${JSON.stringify(chromeDisabledFeaturesSwitch())});
407
+ if (fetchProxySpki) opts.args.push('--ignore-certificate-errors-spki-list=' + fetchProxySpki);
406
408
  if (cdpPort) opts.args.push('--remote-debugging-port=' + cdpPort);
407
409
  if (extraChromeArgs.length) opts.args.push(...extraChromeArgs);
408
410
  // headed: size the OS window to the (phone-shaped) viewport too, plus
@@ -584,7 +586,18 @@ const cleanupProfile = () => {
584
586
  try {
585
587
  await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 });
586
588
  } catch (err) {
587
- process.stderr.write('[goto] ' + String((err && err.message) || err) + '\\n');
589
+ const message = String((err && err.message) || err);
590
+ process.stderr.write('[goto] ' + message + '\\n');
591
+ // nothing serves this url: the page is a dead error document that can
592
+ // never register, and nothing re-navigates — waiting out the connect
593
+ // timeout burns 125s proving it (peach test on an unserved shell). exit
594
+ // now so the caller fails fast. a goto TIMEOUT keeps waiting (a
595
+ // slow-but-alive server may still finish loading the page); only
596
+ // connection-level failures, where no server exists at all, are fatal.
597
+ if (/ERR_CONNECTION_REFUSED|ERR_ADDRESS_UNREACHABLE|ERR_NAME_NOT_RESOLVED/.test(message)) {
598
+ process.stderr.write('[unserved] nothing serves ' + url + '; closing playwright host\\n');
599
+ void shutdown(3);
600
+ }
588
601
  }
589
602
  keepAlive = setInterval(() => {}, 1 << 30);
590
603
  // browser disconnect (e.g. user killed chrome from outside) → tear down.
@@ -100,6 +100,38 @@ async function launch(opts: DriverLaunchOptions): Promise<DriverLaunchResult> {
100
100
  }
101
101
  }
102
102
 
103
+ const targetUrl = new URL(opts.url)
104
+ let fetchProxySpki = ''
105
+ if (opts.bridgePort) {
106
+ try {
107
+ const response = await fetch(
108
+ `http://127.0.0.1:${opts.bridgePort}/__peach/fetch-transport`,
109
+ { signal: AbortSignal.timeout(10_000) },
110
+ )
111
+ if (!response.ok) throw new Error(`transport discovery returned ${response.status}`)
112
+ const descriptor: unknown = await response.json()
113
+ if (!descriptor || typeof descriptor !== 'object')
114
+ throw new Error('invalid fetch transport')
115
+ const origin = Reflect.get(descriptor, 'origin')
116
+ const spki = Reflect.get(descriptor, 'spki')
117
+ if (
118
+ typeof origin !== 'string' ||
119
+ !/^https:\/\/127\.0\.0\.1:\d+$/.test(origin) ||
120
+ typeof spki !== 'string' ||
121
+ !/^[A-Za-z0-9+/]{43}=$/.test(spki)
122
+ ) {
123
+ throw new Error('invalid fetch transport')
124
+ }
125
+ targetUrl.searchParams.set('fetchProxyOrigin', origin)
126
+ fetchProxySpki = spki
127
+ } catch (error) {
128
+ return {
129
+ launched: false,
130
+ message: `fetch transport discovery failed: ${String(error)}`,
131
+ }
132
+ }
133
+ }
134
+
103
135
  // keep browser discovery, installation, and the detached host on one exact
104
136
  // cache contract even if another caller mutates process.env during launch.
105
137
  const playwrightEnv = { ...process.env }
@@ -137,7 +169,8 @@ async function launch(opts: DriverLaunchOptions): Promise<DriverLaunchResult> {
137
169
  ...playwrightEnv,
138
170
  SOOTSIM_PW_MODULE: resolved.modulePath,
139
171
  SOOTSIM_PW_EXECUTABLE: provisioning.executablePath,
140
- SOOTSIM_PW_URL: opts.url,
172
+ SOOTSIM_PW_URL: targetUrl.href,
173
+ PEACH_PW_FETCH_PROXY_SPKI: fetchProxySpki,
141
174
  SOOTSIM_PW_BRIDGE_PORT: opts.bridgePort ? String(opts.bridgePort) : '',
142
175
  SOOTSIM_PW_HEADLESS: (opts.headless ?? true) ? '1' : '0',
143
176
  SOOTSIM_PW_USERDATADIR: resolveUserDataDir(opts),
@@ -196,10 +229,10 @@ async function launch(opts: DriverLaunchOptions): Promise<DriverLaunchResult> {
196
229
  const ownerNote = ` — browser closes after ${idleMinutes} min with no peach command, or when pid ${ownerPid}${ownerComm ? ` (${ownerComm})` : ''} exits`
197
230
  return {
198
231
  launched: true,
199
- message: `playwright chrome launched → ${opts.url}${ownerNote}`,
232
+ message: `playwright chrome launched → ${targetUrl.href}${ownerNote}`,
200
233
  pid: child.pid,
201
234
  target: resolved.spec,
202
- attachUrl: opts.url,
235
+ attachUrl: targetUrl.href,
203
236
  connectAckFile,
204
237
  diagnosticLogPath: errLog,
205
238
  }
package/cli/main.ts CHANGED
@@ -302,6 +302,14 @@ const commandArgsWithSim = globalSimTarget
302
302
  ? ['--sim', globalSimTarget, ...parsed.commandArgs]
303
303
  : parsed.commandArgs
304
304
 
305
+ // an invalid theme used to die silently inside settingsStore.apply (the
306
+ // schema options reject it and apply returns false), so `peach --theme
307
+ // appearance open 8081` opened with no theme and no error. refuse it here.
308
+ if (theme && theme !== 'light' && theme !== 'dark' && theme !== 'auto') {
309
+ console.error(` peach: --theme must be light, dark, or auto, got "${theme}"`)
310
+ await exitWithFlush(1)
311
+ }
312
+
305
313
  // apply device/theme to settings store if provided
306
314
  if (device || theme) {
307
315
  const { settingsStore } = await import('peach-engine/settings/store')
@@ -170,6 +170,34 @@ export const OUTBOUND_ENDPOINTS: Record<string, OutboundEndpointDeclaration> = {
170
170
  payload:
171
171
  'platform and architecture only, carried in the release asset name; fires only for peach test --cloud with a live dev stack when no cloudflared binary is installed',
172
172
  },
173
+ kotlin_toolchain_download: {
174
+ category: 'explicit-user-action',
175
+ destination:
176
+ 'the pinned downloads in packages/peachsim/kotlin/toolchain.json (dl.google.com, github.com, repo1.maven.org, registry.npmjs.org, r2.rnxsim.com)',
177
+ preConsent: false,
178
+ payload:
179
+ 'HTTP GET of a pinned, sha256-checked toolchain file; fires only when the user builds a Kotlin app and the file is not cached',
180
+ },
181
+ linux_browser_libs_download: {
182
+ category: 'runtime-delivery',
183
+ destination: 'https://r2.rnxsim.com/rnx-cli/ linux browser library tarball and its .sha256',
184
+ preConsent: true,
185
+ payload:
186
+ 'lock id and architecture only, carried in the object key; fires on Linux when the browser lacks shared libraries, with a notice on stderr',
187
+ },
188
+ linux_browser_libs_publish: {
189
+ category: 'release-delivery',
190
+ destination: 'https://archive.ubuntu.com/ubuntu and https://ports.ubuntu.com/ubuntu-ports',
191
+ preConsent: false,
192
+ payload: 'HTTP GET of Ubuntu 20.04 package indexes and packages, run only by the maintainer publish script',
193
+ },
194
+ unlisted_site_report: {
195
+ category: 'bounded-diagnostics',
196
+ destination: 'PostHog capture endpoint (VITE_POSTHOG_HOST, default https://us.i.posthog.com)',
197
+ preConsent: true,
198
+ payload:
199
+ 'one peach_unlisted_site event with the page hostname, site-gate mode and runtime version, sent once per page from a runtime on a host that is neither Peach-hosted nor private, and only where browser analytics are allowed',
200
+ },
173
201
  }
174
202
 
175
203
  export interface OutboundCallDeclaration {
@@ -179,7 +207,7 @@ export interface OutboundCallDeclaration {
179
207
 
180
208
  // generated from the AST-level check below, then reviewed and classified.
181
209
  // a new fetch, websocket, node HTTP request, or TCP connection has no entry and
182
- // fails the package test until its destination and consent behavior are declared.
210
+ // fails scripts/check/outbound-endpoints.ts until its destination and consent behavior are declared.
183
211
  export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> = {
184
212
  'packages/peachsim/cli/cloud-client.ts :: fetch :: `${apiOrigin}/v1/boxes`': {
185
213
  category: 'peach_cloud_sim',
@@ -329,7 +357,7 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
329
357
  // about splitting these if bridgeWsUrl ever returns a remote endpoint.
330
358
  'packages/peachsim/cli/commands/box/plane-share.ts :: websocket :: bridgeWsUrl(port)': {
331
359
  category: 'local_development',
332
- count: 2,
360
+ count: 1,
333
361
  },
334
362
  'packages/contrast-runtime-delivery/src/index.ts :: fetch :: url': {
335
363
  category: 'runtime_delivery',
@@ -382,16 +410,8 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
382
410
  category: 'same_origin_runtime',
383
411
  count: 1,
384
412
  },
385
- 'packages/peach-engine/src/engine/app-font-loader.ts :: fetch :: manifestFetchUrl(origin)':
386
- { category: 'local_development', count: 1 },
387
- 'packages/peach-engine/src/engine/app-font-registry.ts :: fetch :: resolvedUrl': {
388
- category: 'guest_app_network',
389
- count: 1,
390
- },
391
413
  'packages/peach-engine/src/engine/emoji-metrics-font-loader.ts :: fetch :: attemptedBundledUrl':
392
414
  { category: 'same_origin_runtime', count: 1 },
393
- 'packages/peach-engine/src/engine/image-loader.ts :: fetch :: resolveImageFetchUri(uri)':
394
- { category: 'guest_app_network', count: 1 },
395
415
  'packages/peach-engine/src/engine/language-font-loader.ts :: fetch :: url': {
396
416
  category: 'same_origin_runtime',
397
417
  count: 1,
@@ -405,14 +425,9 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
405
425
  category: 'same_origin_runtime',
406
426
  count: 1,
407
427
  },
408
- 'packages/peach-engine/src/ios/sf-symbol-catalog.ts :: fetch :: `${catalogBaseUrl}${asset}.json`':
409
- {
410
- category: 'symbol_catalog_delivery',
411
- count: 1,
412
- },
413
428
  'packages/peach-engine/src/engine/system-font-extras.ts :: fetch :: url': {
414
429
  category: 'same_origin_runtime',
415
- count: 1,
430
+ count: 2,
416
431
  },
417
432
  'packages/peach-engine/src/ExternalApp.tsx :: fetch :: getBundleProxyUrl(devServerUrl)':
418
433
  { category: 'guest_app_network', count: 1 },
@@ -600,11 +615,6 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
600
615
  category: 'cli_release_publish',
601
616
  count: 1,
602
617
  },
603
- 'packages/peachsim/scripts/publish-cli-binaries.ts :: fetch :: `${publicOrigin}/${channelKey}?sourceSha=${sourceSha}`':
604
- {
605
- category: 'cli_release_publish',
606
- count: 1,
607
- },
608
618
  'packages/peachsim/cli/commands/upload.ts :: fetch :: url': {
609
619
  category: 'presigned_upload',
610
620
  count: 1,
@@ -650,12 +660,6 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
650
660
  category: 'guest_app_network',
651
661
  count: 1,
652
662
  },
653
- 'packages/peachsim/src/dev-server-open.ts :: http.get :: `http://127.0.0.1:${port}/__server-scan`':
654
- { category: 'local_development', count: 1 },
655
- "packages/peachsim/src/host/fetch-proxy-handler.ts :: transport.request :: { hostname: normalizeHostname(targetUrl.hostname), port: targetUrl.port || (targetUrl.protocol === 'https:' ? 443 : 80), path: targetUrl.pathname + targetUrl.search, method, headers: targetHeaders, ...loopbackTlsOptions(targetUrl), }":
656
- { category: 'guest_app_network', count: 1 },
657
- "packages/peachsim/src/host/fetch-proxy-handler.ts :: transport.request :: { hostname: normalizeHostname(targetUrl.hostname), port: targetUrl.port || (targetUrl.protocol === 'https:' ? 443 : 80), path: targetUrl.pathname + targetUrl.search, method: req.method, headers: fwdHeaders, ...loopbackTlsOptions(targetUrl), }":
658
- { category: 'guest_app_network', count: 1 },
659
663
  'packages/peachsim/src/host/websocket-proxy.ts :: node-request :: upstreamRequestUrl': {
660
664
  category: 'guest_app_network',
661
665
  count: 1,
@@ -664,6 +668,46 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
664
668
  category: 'contrast_user_action',
665
669
  count: 1,
666
670
  },
671
+ 'packages/peach-engine/src/components/native-ui/ShellWebViewHost.tsx :: fetch :: url':
672
+ { category: 'guest_app_network', count: 1 },
673
+ 'packages/peach-engine/src/engine/android-roboto-font.ts :: fetch :: url':
674
+ { category: 'same_origin_runtime', count: 1 },
675
+ 'packages/peach-engine/src/engine/expo-app-config.ts :: fetch :: `${metroOrigin}/__peach-native-firebase-config`':
676
+ { category: 'local_development', count: 1 },
677
+ 'packages/peach-engine/src/engine/inspect-source-chain.ts :: fetch :: `${origin}/symbolicate`':
678
+ { category: 'local_development', count: 1 },
679
+ 'packages/peach-engine/src/engine/ios-cascade.ts :: fetch :: url':
680
+ { category: 'same_origin_runtime', count: 1 },
681
+ 'packages/peach-engine/src/engine/text-hyphenation-en-us.ts :: xml-http-request :: <none>':
682
+ { category: 'same_origin_runtime', count: 1 },
683
+ 'packages/peach-engine/src/expo-swift-modules.tsx :: fetch :: address':
684
+ { category: 'local_development', count: 1 },
685
+ 'packages/peach-engine/src/ios/apps/PhotosApp.tsx :: fetch :: currentImage.uri':
686
+ { category: 'same_origin_runtime', count: 1 },
687
+ 'packages/peach-engine/src/ios/sf-symbol-catalog.ts :: fetch :: `${SF_SYMBOL_CATALOG_URL}${asset}.json`':
688
+ { category: 'symbol_catalog_delivery', count: 1 },
689
+ 'packages/peach-engine/src/render-worker/audio-host.ts :: fetch :: session.src!':
690
+ { category: 'guest_app_network', count: 1 },
691
+ 'packages/peach-engine/src/render-worker/native-resource-demand-host.ts :: fetch :: url':
692
+ { category: 'same_origin_runtime', count: 1 },
693
+ "packages/peach-engine/src/render-worker/site-gate.ts :: fetch :: `${posthogHost.replace(/\\/+$/, '')}/capture/`":
694
+ { category: 'unlisted_site_report', count: 1 },
695
+ 'packages/peach-engine/src/render-worker/video-thumbnail-host.ts :: fetch :: uri':
696
+ { category: 'guest_app_network', count: 1 },
697
+ 'packages/peachsim/cli/app-fonts.ts :: fetch :: `${origin}/status`':
698
+ { category: 'local_development', count: 1 },
699
+ 'packages/peachsim/cli/app-splash.ts :: fetch :: `${origin}/manifest`':
700
+ { category: 'local_development', count: 1 },
701
+ 'packages/peachsim/cli/drivers/linux-browser-libs.ts :: fetch :: `${url}.sha256`':
702
+ { category: 'linux_browser_libs_download', count: 1 },
703
+ 'packages/peachsim/scripts/linux-browser-libs.ts :: fetch :: url':
704
+ { category: 'linux_browser_libs_publish', count: 1 },
705
+ "packages/peachsim/src/host/fetch-proxy-handler.ts :: transport.request :: { hostname: normalizeHostname(targetUrl.hostname), port: targetUrl.port || (targetUrl.protocol === 'https:' ? 443 : 80), path: targetUrl.pathname + targetUrl.search, method, headers: targetHeaders, agent: fetchProxyAgentFor(targetUrl), ...loopbackTlsOptions(targetUrl), }":
706
+ { category: 'guest_app_network', count: 1 },
707
+ "packages/peachsim/src/host/fetch-proxy-handler.ts :: transport.request :: { hostname: normalizeHostname(targetUrl.hostname), port: targetUrl.port || (targetUrl.protocol === 'https:' ? 443 : 80), path: targetUrl.pathname + targetUrl.search, method: req.method, headers: fwdHeaders, agent: fetchProxyAgentFor(targetUrl), ...loopbackTlsOptions(targetUrl), }":
708
+ { category: 'guest_app_network', count: 1 },
709
+ 'packages/peachsim/src/kotlin-host.ts :: fetch :: download.url':
710
+ { category: 'kotlin_toolchain_download', count: 1 },
667
711
  }
668
712
 
669
713
  interface DetectedOutboundCall {
@@ -905,3 +949,27 @@ export function detectOutboundCalls(repositoryRoot: string): DetectedOutboundCal
905
949
  .map(([key, count]) => ({ key, count }))
906
950
  .sort((a, b) => a.key.localeCompare(b.key))
907
951
  }
952
+
953
+ // every detected call has a declaration with its count, and every declaration
954
+ // still names a call. scripts/check/outbound-endpoints.ts fails on any line.
955
+ export function undeclaredOutboundCalls(repositoryRoot: string): string[] {
956
+ const failures: string[] = []
957
+ const seen = new Set<string>()
958
+ for (const call of detectOutboundCalls(repositoryRoot)) {
959
+ seen.add(call.key)
960
+ const declaration = DECLARED_OUTBOUND_CALLS[call.key]
961
+ if (!declaration) {
962
+ failures.push(`undeclared: ${call.key} (count ${call.count})`)
963
+ continue
964
+ }
965
+ if (declaration.count !== call.count) {
966
+ failures.push(
967
+ `count changed: ${call.key} (declared ${declaration.count}, found ${call.count})`,
968
+ )
969
+ }
970
+ }
971
+ for (const key of Object.keys(DECLARED_OUTBOUND_CALLS)) {
972
+ if (!seen.has(key)) failures.push(`stale declaration: ${key}`)
973
+ }
974
+ return failures
975
+ }
package/cli/parent-pid.ts CHANGED
@@ -14,6 +14,7 @@ type CommLookup = (pid: number) => string | null
14
14
 
15
15
  let cached: Lookup | null = null
16
16
  let cachedComm: CommLookup | null = null
17
+ let cachedPgid: Lookup | null = null
17
18
 
18
19
  export function getParentPid(pid: number): number | null {
19
20
  if (!cached) cached = build()
@@ -36,6 +37,18 @@ export function getProcessComm(pid: number): string | null {
36
37
  }
37
38
  }
38
39
 
40
+ // process group id for a pid, or null when unreadable. process.getpgid
41
+ // exists on node but not on bun, so this mirrors the ppid lookup backends
42
+ // instead of branching runtimes at the call site.
43
+ export function getProcessPgid(pid: number): number | null {
44
+ if (!cachedPgid) cachedPgid = buildPgid()
45
+ try {
46
+ return cachedPgid(pid)
47
+ } catch {
48
+ return null
49
+ }
50
+ }
51
+
39
52
  function buildComm(): CommLookup {
40
53
  if (process.platform === 'linux') {
41
54
  return (pid) => {
@@ -78,40 +91,74 @@ function build(): Lookup {
78
91
  return () => null
79
92
  }
80
93
 
81
- // one snapshot of the whole process tree, shared by the ppid and comm lookups.
82
- // macOS has no /proc and Node cannot call libproc, so each lookup used to shell
83
- // out to `lsof -R -p <pid>` with a 2000ms budget — measured at 3.5s, 7.1s and
84
- // 7.9s on a loaded box, so every hop of an ancestor walk timed out, the walk
85
- // resolved to null, and `contrast ide open` launched a browser host with an
86
- // empty owner pid that `ide close` could never attribute. `ps -eo pid,ppid,comm`
87
- // answers for every process at once in ~0.1-0.9s. the short TTL keeps one walk
88
- // on one snapshot while a long-lived caller still sees the tree change.
94
+ function buildPgid(): Lookup {
95
+ if (process.platform === 'linux') {
96
+ return (pid) => {
97
+ try {
98
+ const raw = readFileSync(`/proc/${pid}/stat`, 'utf8')
99
+ const end = raw.lastIndexOf(')')
100
+ if (end < 0) return null
101
+ const rest = raw
102
+ .slice(end + 1)
103
+ .trim()
104
+ .split(/\s+/)
105
+ // fields after (comm): state, ppid, pgrp, ...
106
+ const pgid = Number(rest[2])
107
+ return Number.isFinite(pgid) && pgid > 0 ? pgid : null
108
+ } catch {
109
+ return null
110
+ }
111
+ }
112
+ }
113
+ if (process.platform === 'darwin') {
114
+ const ffi = tryBuildDarwinPgidFfi()
115
+ if (ffi) return ffi
116
+ return (pid) => {
117
+ const pgid = readProcessTable().get(pid)?.pgid
118
+ return pgid !== undefined && pgid > 0 ? pgid : null
119
+ }
120
+ }
121
+ return () => null
122
+ }
123
+
124
+ // one snapshot of the whole process tree, shared by the ppid, pgid and comm
125
+ // lookups. macOS has no /proc and Node cannot call libproc, so each lookup
126
+ // used to shell out to `lsof -R -p <pid>` with a 2000ms budget — measured at
127
+ // 3.5s, 7.1s and 7.9s on a loaded box, so every hop of an ancestor walk timed
128
+ // out, the walk resolved to null, and `contrast ide open` launched a browser
129
+ // host with an empty owner pid that `ide close` could never attribute.
130
+ // `ps -eo pid,ppid,pgid,comm` answers for every process at once in ~0.1-0.9s.
131
+ // the short TTL keeps one walk on one snapshot while a long-lived caller
132
+ // still sees the tree change.
89
133
  const PROCESS_TABLE_TTL_MS = 2000
90
- let processTable: { readAt: number; rows: Map<number, { ppid: number; comm: string }> } =
91
- { readAt: 0, rows: new Map() }
134
+ let processTable: {
135
+ readAt: number
136
+ rows: Map<number, { ppid: number; pgid: number; comm: string }>
137
+ } = { readAt: 0, rows: new Map() }
92
138
 
93
- function readProcessTable(): Map<number, { ppid: number; comm: string }> {
139
+ function readProcessTable(): Map<number, { ppid: number; pgid: number; comm: string }> {
94
140
  const now = Date.now()
95
141
  if (processTable.readAt && now - processTable.readAt < PROCESS_TABLE_TTL_MS) {
96
142
  return processTable.rows
97
143
  }
98
- const rows = new Map<number, { ppid: number; comm: string }>()
144
+ const rows = new Map<number, { ppid: number; pgid: number; comm: string }>()
99
145
  try {
100
- const out = execFileSync('ps', ['-eo', 'pid=,ppid=,comm='], {
146
+ const out = execFileSync('ps', ['-eo', 'pid=,ppid=,pgid=,comm='], {
101
147
  encoding: 'utf8',
102
148
  timeout: 5000,
103
149
  maxBuffer: 8 * 1024 * 1024,
104
150
  stdio: ['ignore', 'pipe', 'ignore'],
105
151
  })
106
152
  for (const line of out.split('\n')) {
107
- const parsed = line.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/)
153
+ const parsed = line.trim().match(/^(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/)
108
154
  if (!parsed) continue
109
155
  // libproc reports pbi_comm — the executable's basename, truncated to
110
156
  // MAXCOMLEN — and the immortal-host patterns are written against that
111
157
  // shape, while `ps -o comm` prints the full path. normalize to one.
112
158
  rows.set(Number(parsed[1]), {
113
159
  ppid: Number(parsed[2]),
114
- comm: (parsed[3].split('/').at(-1) ?? '').slice(0, PBI_COMM_LEN),
160
+ pgid: Number(parsed[3]),
161
+ comm: (parsed[4].split('/').at(-1) ?? '').slice(0, PBI_COMM_LEN),
115
162
  })
116
163
  }
117
164
  } catch {
@@ -202,3 +249,32 @@ function tryBuildDarwinCommFfi(): CommLookup | null {
202
249
  return null
203
250
  }
204
251
  }
252
+
253
+ // uint32 pbi_pgid — after the 12 leading 4-byte fields, pbi_comm[16],
254
+ // pbi_name[32] and pbi_nfiles. source: <sys/proc_info.h> in the macOS SDK.
255
+ const PBI_PGID_OFFSET = 100
256
+
257
+ function tryBuildDarwinPgidFfi(): Lookup | null {
258
+ if (!process.versions?.bun) return null
259
+ try {
260
+ const r = createRequire(import.meta.url)
261
+ const { dlopen, FFIType } = r('bun:ffi')
262
+ const lib = dlopen('/usr/lib/libproc.dylib', {
263
+ proc_pidinfo: {
264
+ args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32],
265
+ returns: FFIType.i32,
266
+ },
267
+ })
268
+ const buf = Buffer.alloc(PROC_BSDINFO_SIZE)
269
+ return (pid) => {
270
+ const ret = Number(
271
+ lib.symbols.proc_pidinfo(pid, PROC_PIDTBSDINFO, 0n, buf, PROC_BSDINFO_SIZE),
272
+ )
273
+ if (ret <= 0) return null
274
+ const pgid = buf.readUInt32LE(PBI_PGID_OFFSET)
275
+ return pgid > 0 ? pgid : null
276
+ }
277
+ } catch {
278
+ return null
279
+ }
280
+ }
package/cli/ws-bridge.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  import { createCloudBridgeForParsed } from './cloud-client'
26
26
  import {
27
27
  getCliIdentity,
28
+ getOwnerProcessGroupId,
28
29
  readCurrentSim,
29
30
  readCurrentSimId,
30
31
  saveCurrentSimId,
@@ -592,6 +593,10 @@ export function createBridge(wsPort: number, opts: WsBridgeOptions = {}): WsBrid
592
593
  cliIdentityKey: identity.key,
593
594
  cliIdentitySource: identity.source,
594
595
  cliLabel: opts.cliLabel,
596
+ // lets the bridge free this cli's leases once its owning
597
+ // session is entirely gone, instead of blocking others
598
+ // until the TTL burns out. null when ancestry is unreadable.
599
+ cliOwnerPgid: getOwnerProcessGroupId(),
595
600
  }),
596
601
  )
597
602
  } catch {}
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.708 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.710 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;