peachsim 0.1.2499 → 0.1.2500

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 (135) hide show
  1. package/cli/agent-note.ts +76 -59
  2. package/cli/cloud-client.ts +59 -1
  3. package/cli/cloud-dispatch.ts +8 -1
  4. package/cli/commands/serve.ts +30 -5
  5. package/cli/commands/stream.ts +29 -33
  6. package/cli/outbound-endpoints.ts +2 -0
  7. package/cli/stream-record.ts +56 -0
  8. package/dist-lib/agent-daemon-client.cjs +1 -1
  9. package/dist-lib/agent-events.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +2 -2
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +5 -5
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +3 -3
  20. package/dist-lib/bundle-channel.cjs +1 -1
  21. package/dist-lib/capture-contract.cjs +1 -1
  22. package/dist-lib/capture-contract.mjs +3 -3
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +3 -3
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +2 -2
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +7 -7
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/config.mjs +5 -5
  31. package/dist-lib/detox/index.cjs +35 -19
  32. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  33. package/dist-lib/esm-chunks/{acorn-IYZTMBZB.mjs → acorn-FAFTHRIF.mjs} +3 -3
  34. package/dist-lib/esm-chunks/{chunk-NC3S3RUQ.mjs → chunk-2TEZ22ZJ.mjs} +5 -5
  35. package/dist-lib/esm-chunks/{chunk-GEPXMQLD.mjs → chunk-3WW5WG4Z.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-O5OXZSPW.mjs → chunk-B47KUDF6.mjs} +2 -2
  37. package/dist-lib/esm-chunks/{chunk-AMCGU7G3.mjs → chunk-BHMUWCQ3.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-O2NAIB7T.mjs → chunk-BZZDAC5F.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-TKVDALS6.mjs → chunk-COY6S3UO.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-JWXQPOE4.mjs → chunk-DVVPGZAO.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-BAG7H6CI.mjs → chunk-EE3RVR43.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-QSN7ACP5.mjs → chunk-FTW7FYVC.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-MKWEZN5Y.mjs → chunk-G5XQIR2J.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-L7PBNY33.mjs → chunk-GUWMIHAV.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-OUL5LFNX.mjs → chunk-HC2AC7SK.mjs} +4 -4
  46. package/dist-lib/esm-chunks/{chunk-KNSIBVRX.mjs → chunk-HQFK43EA.mjs} +12 -12
  47. package/dist-lib/esm-chunks/{chunk-ZVA3TIMK.mjs → chunk-JRVAB44R.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-4BQEG5SG.mjs → chunk-MAV7ERB4.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-2QXY3HHQ.mjs → chunk-NVK7HKIG.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-AD5AMO2H.mjs → chunk-SMNIC2BY.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{chunk-AF4M23XW.mjs → chunk-U2A7SW35.mjs} +1 -1
  52. package/dist-lib/esm-chunks/{chunk-SIG45VVY.mjs → chunk-X7BCKYHC.mjs} +1 -1
  53. package/dist-lib/esm-chunks/{chunk-YC6JAUGD.mjs → chunk-Z4J4KXU3.mjs} +3 -3
  54. package/dist-lib/esm-chunks/{chunk-RTF2ZDLQ.mjs → chunk-ZUTV47C5.mjs} +5 -5
  55. package/dist-lib/esm-chunks/{metro-layout-parser-BI54UMFP.mjs → metro-layout-parser-23DHUJCN.mjs} +3 -3
  56. package/dist-lib/esm-chunks/{swift-package-prebuilt-WQRBOQLW.mjs → swift-package-prebuilt-TVGODNLV.mjs} +10 -10
  57. package/dist-lib/esm-chunks/{swift-sdk-app-module-7GREAIPH.mjs → swift-sdk-app-module-CZGSZHEG.mjs} +13 -13
  58. package/dist-lib/esm-chunks/{swift-sdk-image-YVOFRTJS.mjs → swift-sdk-image-2ZL67WIA.mjs} +13 -13
  59. package/dist-lib/esm-chunks/{swift-sdk-image-producer-CBZRZQKH.mjs → swift-sdk-image-producer-F4O3V7LJ.mjs} +4 -4
  60. package/dist-lib/expo-swift-bundle.cjs +1 -1
  61. package/dist-lib/expo-swift-metadata.cjs +1 -1
  62. package/dist-lib/expo-swift-metadata.mjs +7 -7
  63. package/dist-lib/home-paths.cjs +1 -1
  64. package/dist-lib/host/bridge-host.cjs +92 -59
  65. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  66. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  67. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  68. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  69. package/dist-lib/host/websocket-proxy.cjs +1 -1
  70. package/dist-lib/index.cjs +98 -16
  71. package/dist-lib/kotlin-host.cjs +1 -1
  72. package/dist-lib/menu.cjs +1 -1
  73. package/dist-lib/menu.mjs +3 -3
  74. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  75. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  76. package/dist-lib/metro-production-bundle.cjs +1 -1
  77. package/dist-lib/metro-production-bundle.mjs +4 -4
  78. package/dist-lib/native-app-identity-project.cjs +1 -1
  79. package/dist-lib/native-app-identity-project.mjs +15 -15
  80. package/dist-lib/native-app-identity.cjs +1 -1
  81. package/dist-lib/native-app-identity.mjs +6 -6
  82. package/dist-lib/native-firebase-metadata.cjs +1 -1
  83. package/dist-lib/native-firebase-metadata.mjs +3 -3
  84. package/dist-lib/pdfium-raster.cjs +1 -1
  85. package/dist-lib/pdfium-raster.mjs +2 -2
  86. package/dist-lib/plist.cjs +1 -1
  87. package/dist-lib/plist.mjs +3 -3
  88. package/dist-lib/profiles.cjs +1 -1
  89. package/dist-lib/public-brand.cjs +1 -1
  90. package/dist-lib/public-origins-lib-esm.json +81 -80
  91. package/dist-lib/public-origins-lib.json +78 -71
  92. package/dist-lib/react-native-host-modules.cjs +1 -1
  93. package/dist-lib/react-native-host-modules.mjs +2 -2
  94. package/dist-lib/reap-browser.cjs +1 -1
  95. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  96. package/dist-lib/sdk.cjs +1 -1
  97. package/dist-lib/sdk.mjs +7 -7
  98. package/dist-lib/skills.cjs +543 -457
  99. package/dist-lib/swift-compile.cjs +1 -1
  100. package/dist-lib/swift-compile.mjs +10 -10
  101. package/dist-lib/swift-package.cjs +1 -1
  102. package/dist-lib/swift-package.mjs +3 -3
  103. package/dist-lib/swift-submit.cjs +1 -1
  104. package/dist-lib/swift-submit.mjs +5 -5
  105. package/dist-lib/swift-svg-raster.cjs +30 -20
  106. package/dist-lib/swift-svg-raster.mjs +31 -21
  107. package/dist-lib/swift-toolchain.cjs +1 -1
  108. package/dist-lib/swift.cjs +1 -1
  109. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  110. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  111. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  112. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  113. package/dist-lib/vendor/acorn.cjs +1 -1
  114. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  115. package/dist-lib/vendor/ignore.cjs +1 -1
  116. package/dist-lib/vendor/magic-string.cjs +1 -1
  117. package/dist-lib/vendor/plist.cjs +1 -1
  118. package/dist-lib/vendor/smol-toml.cjs +1 -1
  119. package/dist-lib/vendor/stream-json.cjs +1 -1
  120. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  121. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  122. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  123. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  124. package/dist-lib/vendor/sucrase.cjs +1 -1
  125. package/dist-lib/vendor/terser.cjs +1 -1
  126. package/dist-lib/vendor/valibot.cjs +1 -1
  127. package/dist-lib/vendor/ws.cjs +1 -1
  128. package/dist-lib/vendor/zod.cjs +1 -1
  129. package/dist-lib/worklet-executable.cjs +1 -1
  130. package/dist-lib/worklet-executable.mjs +3 -3
  131. package/dist-types/packages/peach-engine/src/engine/image-svg-raster.d.ts +1 -1
  132. package/dist-types/packages/peach-engine/vendor/camera/camera-heic.d.ts +2 -1
  133. package/package.json +1 -1
  134. package/src/svg-rasterizer-wasm.ts +44 -0
  135. package/src/swift-svg-raster.ts +10 -39
package/cli/agent-note.ts CHANGED
@@ -19,11 +19,16 @@ import {
19
19
  } from '../src/canvas-agent-note-delivery'
20
20
  import { rnxPublicBrand } from '../src/public-brand'
21
21
  import { authHeaderValue, resolveCliAuth } from './auth'
22
- import { resolveCloudSessionForParsed } from './cloud-client'
23
- import { readLocalStreamRecord } from './commands/stream'
22
+ import { createCloudBridgeForParsed, resolveCloudSessionForParsed } from './cloud-client'
24
23
  import { getCliIdentity, readCurrentTarget } from './current-sim'
24
+ import { readLocalStreamRecord, readSceneStreamForParsed } from './stream-record'
25
25
  import { CliUsageError } from './usage-error'
26
- import { callInBridge, createBridge, parseBridgeCliArgs } from './ws-bridge'
26
+ import {
27
+ callInBridge,
28
+ createBridge,
29
+ parseBridgeCliArgs,
30
+ type WsBridge,
31
+ } from './ws-bridge'
27
32
  import type { SootSimInspectInfo } from '@peach/globals'
28
33
 
29
34
  export function inspectArtifactDirectory(messageId: string): string {
@@ -127,12 +132,13 @@ function inboxTarget(args: string[], port?: number) {
127
132
  : identity.key,
128
133
  )
129
134
  : undefined
130
- const cloud = resolveCloudSessionForParsed(parsed)
135
+ const scene = readSceneStreamForParsed(parsed)
136
+ const cloud = scene ? null : resolveCloudSessionForParsed(parsed)
131
137
  const simId = cloud?.service === 'box' ? cloud.boxId : (cloud?.simId ?? parsed.simId)
132
- const stream = !cloud && simId ? readLocalStreamRecord(simId) : null
138
+ const stream = scene ?? (!cloud && simId ? readLocalStreamRecord(simId) : null)
133
139
  const pin = readCurrentTarget()
134
140
  const local =
135
- !cloud && simId
141
+ !cloud && !scene && simId
136
142
  ? {
137
143
  simId,
138
144
  port: parsed.explicitPort
@@ -160,7 +166,7 @@ function inboxTarget(args: string[], port?: number) {
160
166
  authorization: authHeaderValue(auth),
161
167
  }
162
168
  : null
163
- return { local, remote, simId, recipientId }
169
+ return { local, remote, simId, recipientId, parsed }
164
170
  }
165
171
 
166
172
  type CloudInbox = NonNullable<ReturnType<typeof inboxTarget>['remote']>
@@ -191,17 +197,12 @@ async function requestCloudNote<T>(
191
197
  }
192
198
  }
193
199
 
194
- async function takeCloudNote(
195
- remote: CloudInbox,
196
- recipientId: string,
197
- wait: boolean,
198
- grant?: string,
199
- ) {
200
+ async function takeCloudNote(remote: CloudInbox, recipientId: string, grant?: string) {
200
201
  const { data } = await requestCloudNote<{ message: AgentInspectMessage | null }>(
201
202
  remote,
202
203
  recipientId,
203
204
  'take',
204
- wait,
205
+ false,
205
206
  { grant },
206
207
  )
207
208
  return data.message
@@ -233,12 +234,7 @@ async function listenToStreamNotes(
233
234
  const delivery = await Promise.race([local, waitForCloud()])
234
235
  if ('id' in delivery) return delivery
235
236
  if (!(await client.cancelInspectListener(simId))) return await local
236
- const cloud = await takeCloudNote(
237
- remote,
238
- recipientId,
239
- false,
240
- delivery.grant ?? undefined,
241
- )
237
+ const cloud = await takeCloudNote(remote, recipientId, delivery.grant ?? undefined)
242
238
  if (cloud) return cloud
243
239
  } finally {
244
240
  stop.abort()
@@ -246,53 +242,74 @@ async function listenToStreamNotes(
246
242
  }
247
243
  }
248
244
 
249
- export async function listenForAgentInspect(args: string[], port?: number) {
250
- const { local, remote, simId, recipientId } = inboxTarget(args, port)
251
- if (remote && !local) {
252
- if (!recipientId)
253
- throw new CliUsageError(
254
- 'Set PEACH_CLI_IDENTITY to the identity driving the simulator.',
255
- )
256
- while (true) {
257
- const message = await takeCloudNote(remote, recipientId, true)
258
- if (message) return message
259
- }
260
- }
261
- if (!local) {
262
- throw new CliUsageError(
263
- simId
264
- ? 'Sign in to receive notes for the remote simulator.'
265
- : 'No current simulator. Run peach use <id> or pass --sim <id>.',
266
- )
267
- }
268
- const client = await connectToDaemon({
269
- port: local.port,
270
- commandTimeoutMs: 0,
271
- clientLabel: 'peach-agent-listen',
272
- })
273
- // the canvas lists an agent only while it acts, so a waiting agent says so
274
- // and the people watching can still pick its app and send a note
275
- const presence = createBridge(local.port, {
276
- simId: local.simId,
277
- commandTimeoutMs: 10_000,
278
- })
279
- const announce = () => void presence.send({ type: 'listen' }).catch(() => undefined)
245
+ async function listenWithPresence(
246
+ presence: WsBridge,
247
+ listen: () => Promise<AgentInspectMessage>,
248
+ ) {
249
+ const announce = () =>
250
+ void presence.send({ type: 'listen' }, { timeoutMs: 10_000 }).catch(() => undefined)
280
251
  announce()
281
252
  const announcing = setInterval(announce, LISTEN_PRESENCE_MS)
282
253
  try {
283
- if (remote && recipientId)
284
- return await nameCanvasNotePoint(
285
- await listenToStreamNotes(client, local.simId, remote, recipientId),
286
- local,
287
- )
288
- return await client.listenForInspect(local.simId, recipientId)
254
+ return await listen()
289
255
  } finally {
290
256
  clearInterval(announcing)
291
257
  presence.close()
292
- client.close()
293
258
  }
294
259
  }
295
260
 
261
+ export async function listenForAgentInspect(args: string[], port?: number) {
262
+ const { local, remote, simId, recipientId, parsed } = inboxTarget(args, port)
263
+ if (local) {
264
+ const client = await connectToDaemon({
265
+ port: local.port,
266
+ commandTimeoutMs: 0,
267
+ clientLabel: 'peach-agent-listen',
268
+ })
269
+ try {
270
+ return await listenWithPresence(
271
+ createBridge(local.port, { simId: local.simId }),
272
+ async () => {
273
+ if (remote && recipientId)
274
+ return nameCanvasNotePoint(
275
+ await listenToStreamNotes(client, local.simId, remote, recipientId),
276
+ local,
277
+ )
278
+ return client.listenForInspect(local.simId, recipientId)
279
+ },
280
+ )
281
+ } finally {
282
+ client.close()
283
+ }
284
+ }
285
+ const presence = remote ? createCloudBridgeForParsed(parsed) : null
286
+ if (remote && presence) {
287
+ if (!recipientId)
288
+ throw new CliUsageError(
289
+ 'Set PEACH_CLI_IDENTITY to the identity driving the simulator.',
290
+ )
291
+ return listenWithPresence(presence, async () => {
292
+ let grant: string | undefined
293
+ while (true) {
294
+ const result = await requestCloudNote<{ message: AgentInspectMessage | null }>(
295
+ remote,
296
+ recipientId,
297
+ 'take',
298
+ true,
299
+ { grant },
300
+ )
301
+ if (result.data.message) return result.data.message
302
+ grant = result.grant ?? grant
303
+ }
304
+ })
305
+ }
306
+ throw new CliUsageError(
307
+ simId
308
+ ? 'Sign in to receive notes for the remote simulator.'
309
+ : 'No current simulator. Run peach use <id> or pass --sim <id>.',
310
+ )
311
+ }
312
+
296
313
  export async function printPendingCanvasNote(args: string[], port?: number) {
297
314
  const { local, remote, recipientId } = inboxTarget(args, port)
298
315
  if (!recipientId) return
@@ -311,7 +328,7 @@ export async function printPendingCanvasNote(args: string[], port?: number) {
311
328
  client.close()
312
329
  }
313
330
  }
314
- if (!message && remote) message = await takeCloudNote(remote, recipientId, false)
331
+ if (!message && remote) message = await takeCloudNote(remote, recipientId)
315
332
  if (!message) return
316
333
  if (local) message = await nameCanvasNotePoint(message, local)
317
334
  const artifacts = saveCanvasNoteArtifacts(message)
@@ -69,6 +69,8 @@ import {
69
69
  import { commandAgent } from './command-agent.ts'
70
70
  import { detectProject } from './commands/detect.ts'
71
71
  import { resolveCheckoutRepo } from './run-registry.ts'
72
+ import { readSceneStreamForParsed, type SceneCommandEndpoint } from './stream-record'
73
+ import { CliUsageError } from './usage-error'
72
74
  import type { WsBridgeCommand } from '../src/bridge-contract.ts'
73
75
  import type {
74
76
  BridgeClaimResult,
@@ -1763,14 +1765,70 @@ export function createCloudBridgeForParsed(
1763
1765
  Pick<ParsedBridgeCliArgs, 'explicitTimeout' | 'commandTimeoutMs' | 'explicitPort'>
1764
1766
  >,
1765
1767
  ): WsBridge | null {
1768
+ const scene = readSceneStreamForParsed(parsed)
1769
+ const timeoutMs = parsed.explicitTimeout ? parsed.commandTimeoutMs : undefined
1770
+ if (scene) return new SceneBridge(scene.command, timeoutMs)
1766
1771
  const session = resolveCloudSessionForParsed(parsed)
1767
1772
  if (!session) return null
1768
- const timeoutMs = parsed.explicitTimeout ? parsed.commandTimeoutMs : undefined
1769
1773
  return session.service === 'box'
1770
1774
  ? new CloudBoxBridge(session, timeoutMs)
1771
1775
  : new CloudBridge(session, timeoutMs)
1772
1776
  }
1773
1777
 
1778
+ class SceneBridge implements WsBridge {
1779
+ readonly plane = 'cloud' as const
1780
+
1781
+ constructor(
1782
+ private readonly endpoint: SceneCommandEndpoint,
1783
+ private readonly explicitTimeoutMs?: number,
1784
+ ) {}
1785
+
1786
+ async send(
1787
+ command: WsBridgeCommand,
1788
+ options?: { timeoutMs?: number; defaultTimeoutMs?: number },
1789
+ ): Promise<unknown> {
1790
+ const timeoutMs =
1791
+ options?.timeoutMs ?? this.explicitTimeoutMs ?? options?.defaultTimeoutMs ?? 15_000
1792
+ const agent = commandAgent(command)
1793
+ const response = await fetch(`http://127.0.0.1:${this.endpoint.port}/command`, {
1794
+ method: 'POST',
1795
+ headers: {
1796
+ authorization: `Bearer ${this.endpoint.token}`,
1797
+ 'content-type': 'application/json',
1798
+ },
1799
+ body: JSON.stringify(cloudCommand(agent ? { ...command, agent } : command)),
1800
+ ...(timeoutMs ? { signal: AbortSignal.timeout(timeoutMs) } : {}),
1801
+ })
1802
+ if (!response.ok && response.headers.get('content-type') !== 'application/json')
1803
+ throw new CliUsageError(`Scene host returned HTTP ${response.status}.`)
1804
+ const body: unknown = await response.json()
1805
+ if (!response.ok)
1806
+ throw new Error(
1807
+ isRecord(body) && typeof body.error === 'string'
1808
+ ? body.error
1809
+ : `scene host returned HTTP ${response.status}`,
1810
+ )
1811
+ return body
1812
+ }
1813
+
1814
+ async listSims(): Promise<never> {
1815
+ throw new CliUsageError('Use peach list to see simulators on the local bridge.')
1816
+ }
1817
+ async resolveReloadedSim(): Promise<null> {
1818
+ return null
1819
+ }
1820
+ async focusSim(): Promise<never> {
1821
+ throw new Error('a scene host has no browser window to focus')
1822
+ }
1823
+ async closeSim(): Promise<never> {
1824
+ throw new Error('stop the scene host to close its simulator')
1825
+ }
1826
+ async claim(): Promise<never> {
1827
+ throw new Error('a scene host does not use CLI claims')
1828
+ }
1829
+ close(): void {}
1830
+ }
1831
+
1774
1832
  // deletes the box, which ends the simulator it holds. a cloud session box is
1775
1833
  // the prebuilt bundle `peach ios --remote` created, so it holds nothing but that
1776
1834
  // bundle: stopping it would only keep its name taken and its storage held. an
@@ -131,12 +131,19 @@ export async function dispatchCloudBoundary({
131
131
  }
132
132
  if (!CLOUD_TARGET_COMMANDS.has(command)) return { handled: false }
133
133
 
134
- const [{ parseBridgeCliArgs }, cloudClient, cloudSession] = await Promise.all([
134
+ const [
135
+ { parseBridgeCliArgs },
136
+ cloudClient,
137
+ cloudSession,
138
+ { readSceneStreamForParsed },
139
+ ] = await Promise.all([
135
140
  import('./ws-bridge'),
136
141
  import('./cloud-client'),
137
142
  import('./cloud-session'),
143
+ import('./stream-record'),
138
144
  ])
139
145
  const parsed = parseBridgeCliArgs(args)
146
+ if (readSceneStreamForParsed(parsed)) return { handled: false }
140
147
  const positionalTarget =
141
148
  command === 'claim' || command === 'close' ? firstVerb(parsed.positional) : null
142
149
  const target: Pick<typeof parsed, 'simId' | 'simIdSource'> = positionalTarget
@@ -10,6 +10,7 @@
10
10
 
11
11
  import { spawn } from 'node:child_process'
12
12
  import { basename, join, resolve } from 'node:path'
13
+ import { createInterface } from 'node:readline'
13
14
  import {
14
15
  assertPeachPortEnvironment,
15
16
  DEFAULT_SOOTSIM_BRIDGE_PORT,
@@ -28,6 +29,7 @@ import {
28
29
  findStaleDevBuildRoutes,
29
30
  } from '../dev-build-freshness'
30
31
  import { peachExit } from '../run-rnx'
32
+ import { sceneCommandEndpoint } from '../stream-record'
31
33
  import { registerSceneStream, STREAM_FLAG } from './stream'
32
34
  import { resolveDefaultUploadOrigin } from './upload'
33
35
 
@@ -133,18 +135,41 @@ examples:
133
135
  ...nodeArgs,
134
136
  ]
135
137
  }
136
- const child = spawn(program, launchArgs, { stdio: 'inherit' })
138
+ const child = spawn(program, launchArgs, {
139
+ stdio: ['inherit', stream ? 'pipe' : 'inherit', 'inherit'],
140
+ })
137
141
  const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'] satisfies NodeJS.Signals[]
138
142
  const forward = (signal: NodeJS.Signals) => child.kill(signal)
143
+ const exited = new Promise<number>((resolve, reject) => {
144
+ child.once('error', reject)
145
+ child.once('exit', (code) => resolve(code ?? 1))
146
+ })
139
147
  for (const signal of signals) process.on(signal, forward)
140
148
  try {
141
- const code = await new Promise<number>((resolve, reject) => {
142
- child.once('error', reject)
143
- child.once('exit', (code) => resolve(code ?? 1))
144
- })
149
+ let ready: Promise<void> | undefined
150
+ if (stream && child.stdout) {
151
+ const publishing = stream
152
+ const lines = createInterface({ input: child.stdout })
153
+ ready = new Promise<void>((resolve, reject) => {
154
+ lines.once('line', (line) => {
155
+ try {
156
+ publishing.recordCommand(sceneCommandEndpoint.parse(JSON.parse(line)))
157
+ resolve()
158
+ } catch (error) {
159
+ reject(error)
160
+ }
161
+ })
162
+ lines.once('close', () =>
163
+ reject(new Error('scene host stopped before startup')),
164
+ )
165
+ })
166
+ lines.on('line', (line) => console.log(line))
167
+ }
168
+ const [code] = await Promise.all([exited, ready])
145
169
  if (code !== 0) peachExit(code)
146
170
  } finally {
147
171
  for (const signal of signals) process.off(signal, forward)
172
+ if (child.exitCode === null && child.signalCode === null) child.kill()
148
173
  await stream?.stop()
149
174
  }
150
175
  return
@@ -1,38 +1,31 @@
1
- import { mkdirSync, readFileSync, rmSync, watch } from 'node:fs'
1
+ import { mkdirSync, watch } from 'node:fs'
2
2
  import { join } from 'node:path'
3
3
  import { z } from 'zod'
4
4
  import { rnxHomeDir } from '../../src/home-paths'
5
5
  import { rnxPublicBrand } from '../../src/public-brand'
6
6
  import { authHeaderOrExit, cloudAccountIdOrExit } from '../auth'
7
7
  import { resolveCheckoutRepo } from '../run-registry'
8
- import { writeSecureJsonAtomic } from '../secure-file'
8
+ import {
9
+ readLocalStreamRecord,
10
+ removeLocalStreamRecord,
11
+ writeLocalStreamRecord,
12
+ type SceneCommandEndpoint,
13
+ type StreamRecord,
14
+ } from '../stream-record'
9
15
  import { callInBridge, createBridgeFromParsed, parseBridgeCliArgs } from '../ws-bridge'
10
16
 
11
17
  export const STREAM_FLAG = '--stream'
12
18
  const registrationSchema = z.object({
13
- session: z.object({ id: z.string(), accountId: z.string(), url: z.string() }),
19
+ session: z.object({
20
+ id: z.string(),
21
+ accountId: z.string(),
22
+ externalId: z.string(),
23
+ url: z.string(),
24
+ }),
14
25
  url: z.string(),
15
26
  token: z.string(),
16
27
  credential: z.string(),
17
28
  })
18
- const recordSchema = z.object({
19
- sessionId: z.string(),
20
- accountId: z.string(),
21
- origin: z.string(),
22
- watchUrl: z.string(),
23
- })
24
-
25
- export function readLocalStreamRecord(simId: string) {
26
- const file = join(rnxHomeDir(), 'streams', `${encodeURIComponent(simId)}.json`)
27
- try {
28
- return recordSchema.parse(JSON.parse(readFileSync(file, 'utf8')))
29
- } catch (error) {
30
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null
31
- throw error
32
- }
33
- }
34
-
35
- type StreamRecord = z.infer<typeof recordSchema>
36
29
  type SignIn = ReturnType<typeof authHeaderOrExit>
37
30
 
38
31
  // a stream session on the signed-in account, watched at its /sim/<id> page
@@ -87,11 +80,21 @@ export async function registerSceneStream(body: { device: string; name: string }
87
80
  transport: 'scene',
88
81
  ...body,
89
82
  })
83
+ const simId = registration.session.externalId
90
84
  return {
91
85
  relay: registration.url,
92
86
  credential: registration.credential,
93
87
  watchUrl: record.watchUrl,
94
- stop,
88
+ recordCommand(command: SceneCommandEndpoint) {
89
+ writeLocalStreamRecord(simId, { ...record, command }, false)
90
+ },
91
+ async stop() {
92
+ try {
93
+ removeLocalStreamRecord(simId)
94
+ } finally {
95
+ await stop()
96
+ }
97
+ },
95
98
  }
96
99
  }
97
100
 
@@ -127,7 +130,6 @@ export async function runStreamCommand(
127
130
  throw new Error('Could not identify the local simulator.')
128
131
  const directory = join(rnxHomeDir(), 'streams')
129
132
  mkdirSync(directory, { recursive: true })
130
- const file = join(directory, `${encodeURIComponent(simId)}.json`)
131
133
  const state = await callInBridge<string>(bridge, 'SootSim.bridges.videoStream.state')
132
134
  if (action === 'status') {
133
135
  console.log(` stream: ${state}`)
@@ -138,7 +140,7 @@ export async function runStreamCommand(
138
140
  await callInBridge(bridge, 'SootSim.bridges.videoStream.stop')
139
141
  const record = readLocalStreamRecord(simId)
140
142
  if (record) await stopStreamSession(record, header)
141
- rmSync(file, { force: true })
143
+ removeLocalStreamRecord(simId)
142
144
  console.log(' stream: off')
143
145
  return
144
146
  }
@@ -172,8 +174,8 @@ export async function runStreamCommand(
172
174
  url: registration.url,
173
175
  token: registration.token,
174
176
  })
175
- writeSecureJsonAtomic(file, record, { durable: !opts.signal })
176
- removeRecord = () => rmSync(file, { force: true })
177
+ writeLocalStreamRecord(simId, record, !opts.signal)
178
+ removeRecord = () => removeLocalStreamRecord(simId)
177
179
  if (opts.onStarted) opts.onStarted(record.watchUrl)
178
180
  else {
179
181
  console.log(` simulator: ${record.watchUrl}`)
@@ -218,13 +220,7 @@ export async function runStreamCommand(
218
220
  let alive = setTimeout(checkStream, 5000)
219
221
  const watcher = watch(directory, (_event, filename) => {
220
222
  if (filename !== `${encodeURIComponent(simId)}.json`) return
221
- try {
222
- readFileSync(file)
223
- } catch (error) {
224
- if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
225
- finish()
226
- else throw error
227
- }
223
+ if (!readLocalStreamRecord(simId)) finish()
228
224
  })
229
225
  if (opts.signal) {
230
226
  opts.signal.addEventListener('abort', stopped, { once: true })
@@ -459,6 +459,8 @@ export const DECLARED_OUTBOUND_CALLS: Record<string, OutboundCallDeclaration> =
459
459
  { category: 'peach_cloud_sim', count: 2 },
460
460
  'packages/peachsim/cli/cloud-client.ts :: fetch :: `${this.session.apiOrigin}/v1/sims/${encodeURIComponent()}/commands`':
461
461
  { category: 'peach_cloud_sim', count: 1 },
462
+ 'packages/peachsim/cli/cloud-client.ts :: fetch :: `http://127.0.0.1:${this.endpoint.port}/command`':
463
+ { category: 'local_development', count: 1 },
462
464
  'packages/peachsim/cli/cloud-client.ts :: fetch :: bundleUrl': {
463
465
  category: 'guest_app_network',
464
466
  count: 1,
@@ -0,0 +1,56 @@
1
+ import { readFileSync, rmSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+ import { z } from 'zod'
4
+ import { rnxHomeDir } from '../src/home-paths'
5
+ import { writeSecureJsonAtomic } from './secure-file'
6
+ import type { ParsedBridgeCliArgs } from './ws-bridge'
7
+
8
+ export const sceneCommandEndpoint = z.object({
9
+ port: z.number().int().min(1).max(65535),
10
+ token: z.string().regex(/^[a-f0-9]{64}$/),
11
+ })
12
+
13
+ const streamRecord = z.object({
14
+ sessionId: z.string(),
15
+ accountId: z.string(),
16
+ origin: z.string(),
17
+ watchUrl: z.string(),
18
+ command: sceneCommandEndpoint.optional(),
19
+ })
20
+
21
+ export type StreamRecord = z.infer<typeof streamRecord>
22
+ export type SceneCommandEndpoint = z.infer<typeof sceneCommandEndpoint>
23
+
24
+ function streamRecordPath(simId: string) {
25
+ return join(rnxHomeDir(), 'streams', `${encodeURIComponent(simId)}.json`)
26
+ }
27
+
28
+ export function readLocalStreamRecord(simId: string): StreamRecord | null {
29
+ try {
30
+ return streamRecord.parse(JSON.parse(readFileSync(streamRecordPath(simId), 'utf8')))
31
+ } catch (error) {
32
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null
33
+ throw error
34
+ }
35
+ }
36
+
37
+ export function readSceneStreamForParsed(
38
+ parsed: Pick<ParsedBridgeCliArgs, 'simId'> &
39
+ Partial<Pick<ParsedBridgeCliArgs, 'explicitPort'>>,
40
+ ) {
41
+ const record =
42
+ !parsed.explicitPort && parsed.simId ? readLocalStreamRecord(parsed.simId) : null
43
+ return record?.command ? { ...record, command: record.command } : null
44
+ }
45
+
46
+ export function writeLocalStreamRecord(
47
+ simId: string,
48
+ record: StreamRecord,
49
+ durable: boolean,
50
+ ) {
51
+ writeSecureJsonAtomic(streamRecordPath(simId), record, { durable })
52
+ }
53
+
54
+ export function removeLocalStreamRecord(simId: string) {
55
+ rmSync(streamRecordPath(simId), { force: true })
56
+ }
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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 __defProp = Object.defineProperty;
package/dist-lib/beta.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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 __defProp = Object.defineProperty;
package/dist-lib/beta.mjs CHANGED
@@ -1,5 +1,5 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
- import "./esm-chunks/chunk-4BQEG5SG.mjs";
1
+ /*! peach v0.1.2500 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ import "./esm-chunks/chunk-MAV7ERB4.mjs";
3
3
 
4
4
  // src/beta.ts
5
5
  var IS_BETA = true;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  BridgeInputError,
4
4
  SEMANTIC_WAIT_MAX_TIMEOUT_MS,
@@ -17,10 +17,10 @@ import {
17
17
  parseSemanticWaitOptions,
18
18
  parseStateOptions,
19
19
  parseTapTarget
20
- } from "./esm-chunks/chunk-YC6JAUGD.mjs";
21
- import "./esm-chunks/chunk-JWXQPOE4.mjs";
22
- import "./esm-chunks/chunk-GEPXMQLD.mjs";
23
- import "./esm-chunks/chunk-4BQEG5SG.mjs";
20
+ } from "./esm-chunks/chunk-Z4J4KXU3.mjs";
21
+ import "./esm-chunks/chunk-DVVPGZAO.mjs";
22
+ import "./esm-chunks/chunk-3WW5WG4Z.mjs";
23
+ import "./esm-chunks/chunk-MAV7ERB4.mjs";
24
24
  export {
25
25
  BridgeInputError,
26
26
  SEMANTIC_WAIT_MAX_TIMEOUT_MS,
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (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 __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2499 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2500 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  HEADLESS_TENANT_FETCH_HUNG_MARKER,
4
4
  REFUSED_PERFORM_STEP_TYPES,
@@ -13,8 +13,8 @@ import {
13
13
  readyProbeHasContent,
14
14
  readyProbeIsReady,
15
15
  refusedPerformStepReason
16
- } from "./esm-chunks/chunk-JWXQPOE4.mjs";
17
- import "./esm-chunks/chunk-4BQEG5SG.mjs";
16
+ } from "./esm-chunks/chunk-DVVPGZAO.mjs";
17
+ import "./esm-chunks/chunk-MAV7ERB4.mjs";
18
18
  export {
19
19
  HEADLESS_TENANT_FETCH_HUNG_MARKER,
20
20
  REFUSED_PERFORM_STEP_TYPES,