peachsim 0.1.2441 → 0.1.2457

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 (170) hide show
  1. package/README.md +4 -49
  2. package/cli/app-catalog.ts +8 -7
  3. package/cli/app-stubs.ts +98 -70
  4. package/cli/cloud-box-artifact.ts +2 -5
  5. package/cli/cloud-client.ts +12 -1
  6. package/cli/commands/box.ts +41 -2
  7. package/cli/commands/compat.ts +5 -3
  8. package/cli/commands/cpu-profile.ts +11 -14
  9. package/cli/commands/diagnose.ts +5 -18
  10. package/cli/commands/inspect/describe.ts +4 -8
  11. package/cli/commands/maestro-generate.ts +4 -8
  12. package/cli/commands/mode.ts +3 -19
  13. package/cli/commands/perf.ts +3 -19
  14. package/cli/commands/permissions.ts +2 -6
  15. package/cli/commands/platform.ts +22 -14
  16. package/cli/commands/react.ts +7 -21
  17. package/cli/commands/record-three.ts +6 -10
  18. package/cli/commands/record.ts +38 -62
  19. package/cli/commands/screenshot-command.ts +8 -25
  20. package/cli/commands/storage.ts +4 -16
  21. package/cli/commands/three-mode.ts +6 -10
  22. package/cli/outbound-endpoints.ts +4 -5
  23. package/cli/parse-args.ts +45 -0
  24. package/cli/remote-metro.ts +1 -1
  25. package/cli/remote-simulators.ts +5 -1
  26. package/cli/send-to-box.ts +3 -1
  27. package/detox/index.ts +20 -1
  28. package/dist-lib/agent-daemon-client.cjs +2 -2
  29. package/dist-lib/agent-events.cjs +1 -1
  30. package/dist-lib/attached-projects.cjs +1 -1
  31. package/dist-lib/auth/shared-session.cjs +1 -1
  32. package/dist-lib/backend-origin.cjs +1 -1
  33. package/dist-lib/beta.cjs +1 -1
  34. package/dist-lib/beta.mjs +2 -2
  35. package/dist-lib/bridge-constants.cjs +1 -1
  36. package/dist-lib/bridge-contract-input.cjs +1 -1
  37. package/dist-lib/bridge-contract-input.mjs +5 -5
  38. package/dist-lib/bridge-contract.cjs +1 -1
  39. package/dist-lib/bridge-contract.mjs +3 -3
  40. package/dist-lib/bundle-channel.cjs +240 -316
  41. package/dist-lib/capture-contract.cjs +1 -1
  42. package/dist-lib/capture-contract.mjs +3 -3
  43. package/dist-lib/cloud-contract.cjs +14 -1
  44. package/dist-lib/cloud-contract.mjs +5 -3
  45. package/dist-lib/cloud-test-args.cjs +1 -1
  46. package/dist-lib/cloud-test-args.mjs +2 -2
  47. package/dist-lib/cloud.cjs +1 -1
  48. package/dist-lib/cloud.mjs +7 -7
  49. package/dist-lib/config.cjs +1 -6
  50. package/dist-lib/config.mjs +5 -9
  51. package/dist-lib/detox/index.cjs +17 -5
  52. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  53. package/dist-lib/esm-chunks/{acorn-FRQNHKFC.mjs → acorn-73XUBXBT.mjs} +3 -3
  54. package/dist-lib/esm-chunks/{chunk-IRMC5BCX.mjs → chunk-7V2QJGVI.mjs} +1 -1
  55. package/dist-lib/esm-chunks/{chunk-PMGJ7FLI.mjs → chunk-BHQEYJAF.mjs} +1 -1
  56. package/dist-lib/esm-chunks/{chunk-BAYRN7ZL.mjs → chunk-DSPFMVBM.mjs} +1 -1
  57. package/dist-lib/esm-chunks/{chunk-4HEUXQGM.mjs → chunk-GA73RJSG.mjs} +4 -4
  58. package/dist-lib/esm-chunks/{chunk-ABMB3G7I.mjs → chunk-IGBAFWZ3.mjs} +3 -3
  59. package/dist-lib/esm-chunks/{chunk-ZCMAKWHN.mjs → chunk-IKZDUGT6.mjs} +1 -1
  60. package/dist-lib/esm-chunks/{chunk-VAQJQDWI.mjs → chunk-IP5ZV36U.mjs} +1 -1
  61. package/dist-lib/esm-chunks/{chunk-O4EOBXAP.mjs → chunk-KGHQ4GK2.mjs} +1 -1
  62. package/dist-lib/esm-chunks/{chunk-4BZ3Z3IQ.mjs → chunk-KY63O76W.mjs} +2 -2
  63. package/dist-lib/esm-chunks/{chunk-QYYJESMK.mjs → chunk-LJ74MO6Y.mjs} +1 -1
  64. package/dist-lib/esm-chunks/{chunk-DJMWTW2B.mjs → chunk-LJX42YVT.mjs} +1 -1
  65. package/dist-lib/esm-chunks/{chunk-XO5GX4PI.mjs → chunk-O4KAW2JJ.mjs} +1 -1
  66. package/dist-lib/esm-chunks/{chunk-6A6JEVIF.mjs → chunk-OIFM356B.mjs} +1 -1
  67. package/dist-lib/esm-chunks/{chunk-NPLEBOWJ.mjs → chunk-P63DPATT.mjs} +1 -1
  68. package/dist-lib/esm-chunks/{chunk-VCAJFWZD.mjs → chunk-SCCOZKCP.mjs} +1 -1
  69. package/dist-lib/esm-chunks/{chunk-QUBR7LHU.mjs → chunk-TAZL253K.mjs} +41 -15
  70. package/dist-lib/esm-chunks/{chunk-ORYS5CC4.mjs → chunk-UBXCWZL3.mjs} +1 -1
  71. package/dist-lib/esm-chunks/{chunk-4ZRMJ5YO.mjs → chunk-ZQWWO33G.mjs} +14 -2
  72. package/dist-lib/esm-chunks/{metro-layout-parser-AUAVE5VL.mjs → metro-layout-parser-HNQRTPVE.mjs} +3 -3
  73. package/dist-lib/expo-swift-bundle.cjs +197 -336
  74. package/dist-lib/expo-swift-metadata.cjs +1 -1
  75. package/dist-lib/expo-swift-metadata.mjs +7 -7
  76. package/dist-lib/home-paths.cjs +1 -1
  77. package/dist-lib/host/bridge-host.cjs +276 -381
  78. package/dist-lib/host/fetch-proxy-handler.cjs +35 -43
  79. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  80. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  81. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  82. package/dist-lib/host/websocket-proxy.cjs +4 -2
  83. package/dist-lib/index.cjs +2 -105
  84. package/dist-lib/kotlin-host.cjs +6 -4
  85. package/dist-lib/menu.cjs +1 -1
  86. package/dist-lib/menu.mjs +3 -3
  87. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  88. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  89. package/dist-lib/metro-production-bundle.cjs +1 -1
  90. package/dist-lib/metro-production-bundle.mjs +4 -4
  91. package/dist-lib/native-app-identity-project.cjs +2 -2
  92. package/dist-lib/native-app-identity-project.mjs +12 -12
  93. package/dist-lib/native-app-identity.cjs +1 -1
  94. package/dist-lib/native-app-identity.mjs +6 -6
  95. package/dist-lib/native-firebase-metadata.cjs +1 -1
  96. package/dist-lib/native-firebase-metadata.mjs +3 -3
  97. package/dist-lib/pdfium-raster.cjs +1 -1
  98. package/dist-lib/pdfium-raster.mjs +2 -2
  99. package/dist-lib/plist.cjs +1 -1
  100. package/dist-lib/plist.mjs +3 -3
  101. package/dist-lib/profiles.cjs +1 -1
  102. package/dist-lib/public-brand.cjs +1 -1
  103. package/dist-lib/public-origins-lib-esm.json +64 -64
  104. package/dist-lib/public-origins-lib-static.json +1 -1
  105. package/dist-lib/public-origins-lib.json +107 -85
  106. package/dist-lib/react-native-host-modules.cjs +1 -1
  107. package/dist-lib/react-native-host-modules.mjs +2 -2
  108. package/dist-lib/reap-browser.cjs +1 -1
  109. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  110. package/dist-lib/sdk.cjs +1 -1
  111. package/dist-lib/sdk.mjs +7 -7
  112. package/dist-lib/skills.cjs +310 -310
  113. package/dist-lib/swift-compile.cjs +37 -11
  114. package/dist-lib/swift-compile.mjs +8 -8
  115. package/dist-lib/swift-package.cjs +1 -1
  116. package/dist-lib/swift-package.mjs +3 -3
  117. package/dist-lib/swift-submit.cjs +1 -1
  118. package/dist-lib/swift-submit.mjs +5 -5
  119. package/dist-lib/swift-toolchain.cjs +1 -1
  120. package/dist-lib/swift.cjs +1 -1
  121. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  122. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +14770 -0
  123. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +2790 -0
  124. package/dist-lib/vendor/acorn.cjs +1 -1
  125. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  126. package/dist-lib/vendor/ignore.cjs +1 -1
  127. package/dist-lib/vendor/magic-string.cjs +1 -1
  128. package/dist-lib/vendor/plist.cjs +1 -1
  129. package/dist-lib/vendor/prism.wasm +0 -0
  130. package/dist-lib/vendor/smol-toml.cjs +1 -1
  131. package/dist-lib/vendor/stream-json.cjs +1 -1
  132. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  133. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  134. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  135. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  136. package/dist-lib/vendor/sucrase.cjs +1 -1
  137. package/dist-lib/vendor/terser.cjs +1 -1
  138. package/dist-lib/vendor/valibot.cjs +1 -1
  139. package/dist-lib/vendor/ws.cjs +3710 -0
  140. package/dist-lib/vendor/zod.cjs +1 -1
  141. package/dist-lib/worklet-executable.cjs +1 -1
  142. package/dist-lib/worklet-executable.mjs +3 -3
  143. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +0 -3
  144. package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
  145. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
  146. package/dist-types/packages/peach-engine/src/engine/text-line-break.d.ts +3 -1
  147. package/dist-types/packages/peach-engine/src/engine/text-paint.d.ts +1 -0
  148. package/dist-types/packages/peach-engine/src/engine/text-runs.d.ts +6 -1
  149. package/kotlin/sdk.tar.gz +0 -0
  150. package/package.json +22 -14
  151. package/skills/peach-setup/references/native-config.md +3 -3
  152. package/src/app-config.ts +7 -15
  153. package/src/cloud-contract.ts +35 -0
  154. package/src/config.ts +2 -6
  155. package/src/estree-walk.ts +13 -0
  156. package/src/host/network-policy.ts +4 -1
  157. package/src/index.ts +0 -1
  158. package/src/one-native-app-config.ts +14 -15
  159. package/src/podspec-prism.ts +7 -1
  160. package/src/process-group.ts +4 -1
  161. package/src/process-table.ts +6 -1
  162. package/src/swift-compile.ts +38 -8
  163. package/src/swift-host.ts +10 -4
  164. package/cli/commands/box/bundle-plane.ts +0 -154
  165. package/dist-lib/jump-to-source-babel.cjs +0 -131
  166. package/dist-lib/jump-to-source-native.cjs +0 -235
  167. package/src/java-static-imports.ts +0 -68
  168. package/src/jump-to-source-babel.ts +0 -143
  169. package/src/jump-to-source-native.ts +0 -200
  170. package/src/kotlin-jvm-sources.ts +0 -35
@@ -7,6 +7,7 @@ import yaml from 'yaml'
7
7
  import { isRecord } from '../../src/is-record'
8
8
  import { authHeaderValue, resolveCliAuth } from '../auth'
9
9
  import { MAESTRO_YAML_OPTIONS } from '../flow-file'
10
+ import { readStringFlag } from '../parse-args'
10
11
  import { registerRun, stepSummaryFromTrace } from '../run-registry'
11
12
  import {
12
13
  findUnexpectedFlowArgs,
@@ -24,14 +25,9 @@ const MAX_GENERATION_STEPS = 30
24
25
  const DESCRIBE_CONTEXT_LIMIT = 18_000
25
26
  const LLM_TIMEOUT_MS = 180_000
26
27
 
27
- function flagValue(args: string[], name: string): string | undefined {
28
- const index = args.indexOf(name)
29
- return index >= 0 ? args[index + 1] : undefined
30
- }
31
-
32
28
  function flagValueAny(args: string[], names: string[]): string | undefined {
33
29
  for (const name of names) {
34
- const value = flagValue(args, name)
30
+ const value = readStringFlag(args, name)
35
31
  if (value) return value
36
32
  }
37
33
  return undefined
@@ -546,8 +542,8 @@ export async function runMaestroGenerate(args: string[]): Promise<number> {
546
542
  ? (generationError ?? failedStep?.error ?? 'flow playback failed')
547
543
  : null,
548
544
  previewShareId: upload?.shareId ?? null,
549
- owner: flagValue(args, '--owner') ?? null,
550
- repo: flagValue(args, '--repo') ?? null,
545
+ owner: readStringFlag(args, '--owner') ?? null,
546
+ repo: readStringFlag(args, '--repo') ?? null,
551
547
  durationMs: Date.now() - startedAt,
552
548
  flowYamlSizeBytes: Buffer.byteLength(readFileSync(flowPath, 'utf8'), 'utf8'),
553
549
  ...stepSummaryFromTrace(traceSteps),
@@ -1,3 +1,4 @@
1
+ import { takeSubcommand } from '../parse-args'
1
2
  import { peachExit } from '../run-rnx'
2
3
  import { runAgentIndicatorMode } from './agent-indicator-mode'
3
4
  import { runScreenshotMode } from './screenshot-mode'
@@ -9,7 +10,6 @@ interface ModeOptions {
9
10
  verbose?: boolean
10
11
  }
11
12
 
12
- const VALUE_FLAGS = new Set(['--sim', '--port', '-p'])
13
13
  const SUBCOMMANDS = new Set([
14
14
  'screenshot',
15
15
  'three',
@@ -18,22 +18,6 @@ const SUBCOMMANDS = new Set([
18
18
  'agent-indicator',
19
19
  ])
20
20
 
21
- function findSubcommand(args: string[]): { name: string; index: number } | null {
22
- for (let i = 0; i < args.length; i++) {
23
- const arg = args[i]
24
- if (arg.startsWith('-')) {
25
- if (VALUE_FLAGS.has(arg)) i++
26
- continue
27
- }
28
- return SUBCOMMANDS.has(arg) ? { name: arg, index: i } : null
29
- }
30
- return null
31
- }
32
-
33
- function withoutSubcommand(args: string[], index: number): string[] {
34
- return [...args.slice(0, index), ...args.slice(index + 1)]
35
- }
36
-
37
21
  function printHelp(): void {
38
22
  console.log(`
39
23
  peach mode — toggle live display modes
@@ -48,7 +32,7 @@ usage:
48
32
  }
49
33
 
50
34
  export async function runMode(args: string[], opts: ModeOptions): Promise<void> {
51
- const sub = findSubcommand(args)
35
+ const sub = takeSubcommand(args, SUBCOMMANDS)
52
36
  if (!sub) {
53
37
  printHelp()
54
38
  if (!args.includes('--help') && !args.includes('-h')) {
@@ -57,7 +41,7 @@ export async function runMode(args: string[], opts: ModeOptions): Promise<void>
57
41
  return
58
42
  }
59
43
 
60
- const rest = withoutSubcommand(args, sub.index)
44
+ const rest = sub.args
61
45
  if (sub.name === 'screenshot') {
62
46
  await runScreenshotMode(rest, opts)
63
47
  return
@@ -1,3 +1,4 @@
1
+ import { takeSubcommand } from '../parse-args'
1
2
  import { runCpuProfile } from './cpu-profile'
2
3
  import { runInspect } from './inspect'
3
4
  import { runPerfRecord } from './perf-record'
@@ -8,25 +9,8 @@ interface PerfOptions {
8
9
  verbose?: boolean
9
10
  }
10
11
 
11
- const VALUE_FLAGS = new Set(['--sim', '--port', '-p'])
12
12
  const SUBCOMMANDS = new Set(['cpu', 'react', 'record', 'shell', 'scroll'])
13
13
 
14
- function findSubcommand(args: string[]): { name: string; index: number } | null {
15
- for (let i = 0; i < args.length; i++) {
16
- const arg = args[i]
17
- if (arg.startsWith('-')) {
18
- if (VALUE_FLAGS.has(arg)) i++
19
- continue
20
- }
21
- return SUBCOMMANDS.has(arg) ? { name: arg, index: i } : null
22
- }
23
- return null
24
- }
25
-
26
- function withoutSubcommand(args: string[], index: number): string[] {
27
- return [...args.slice(0, index), ...args.slice(index + 1)]
28
- }
29
-
30
14
  function printHelp(): void {
31
15
  console.log(`
32
16
  peach perf — performance profiling tools
@@ -52,13 +36,13 @@ examples:
52
36
  }
53
37
 
54
38
  export async function runPerf(args: string[], opts: PerfOptions): Promise<number> {
55
- const sub = findSubcommand(args)
39
+ const sub = takeSubcommand(args, SUBCOMMANDS)
56
40
  if (!sub) {
57
41
  printHelp()
58
42
  return args.includes('--help') || args.includes('-h') ? 0 : 1
59
43
  }
60
44
 
61
- const rest = withoutSubcommand(args, sub.index)
45
+ const rest = sub.args
62
46
  if (sub.name === 'cpu') return runCpuProfile(rest, opts)
63
47
  if (sub.name === 'react') return runReact(rest, opts)
64
48
  if (sub.name === 'record') return runPerfRecord(rest, opts)
@@ -1,3 +1,4 @@
1
+ import { readStringFlag } from '../parse-args'
1
2
  import {
2
3
  callInBridge,
3
4
  callInBridgeWrite,
@@ -65,11 +66,6 @@ function print(value: unknown, json: boolean): void {
65
66
  console.log(json ? JSON.stringify(value, null, 2) : value)
66
67
  }
67
68
 
68
- function flagValue(args: string[], flag: string): string | undefined {
69
- const index = args.indexOf(flag)
70
- return index >= 0 ? args[index + 1] : undefined
71
- }
72
-
73
69
  function permissionKind(value: string): SystemPermissionKind | null {
74
70
  return PERMISSION_KINDS.find((candidate) => candidate === value) ?? null
75
71
  }
@@ -177,7 +173,7 @@ export async function runPermissions(
177
173
  if (!kind) throw new Error(`unknown permission kind: ${kindValue}`)
178
174
  const status = permissionStatus(statusValue)
179
175
  if (!status) throw new Error(`unknown permission status: ${statusValue}`)
180
- const accuracyValue = flagValue(args, '--accuracy')
176
+ const accuracyValue = readStringFlag(args, '--accuracy')
181
177
  const accuracy =
182
178
  accuracyValue === 'full' || accuracyValue === 'reduced' ? accuracyValue : undefined
183
179
  if (accuracyValue && !accuracy) {
@@ -15,12 +15,13 @@ import {
15
15
  type DeviceModel,
16
16
  type RuntimePlatform,
17
17
  } from '../../src/device-catalog.ts'
18
+ import { isSootsimDevCheckout } from '../../src/home-paths'
18
19
  import { isRecord } from '../../src/is-record'
19
20
  import { toPeachDevelopmentBundleUrl } from '../../src/metro-production-bundle'
20
21
  import { rnxPublicBrand } from '../../src/public-brand'
21
22
  import { cloudBoxSimulatorId, cloudSimulatorPath } from '../../src/simulator-route'
22
23
  import { appNameFromPath } from '../app-project'
23
- import { UnsupportedRemoteHostError } from '../cloud-client'
24
+ import { NanoDevelopmentOnlyError, UnsupportedRemoteHostError } from '../cloud-client'
24
25
  import { resolveCheckoutRepo } from '../run-registry'
25
26
  import { rethrowIfExit } from '../run-rnx'
26
27
  import { SETTINGS_VALUE_FLAGS } from '../settings-flags'
@@ -54,6 +55,7 @@ function remoteInputFromArgs(
54
55
  name: string | null
55
56
  nativeProjectDir: string | undefined
56
57
  initialUrl: string | null
58
+ endpoint: string | undefined
57
59
  reuse: boolean
58
60
  fresh: boolean
59
61
  watch: boolean
@@ -63,6 +65,7 @@ function remoteInputFromArgs(
63
65
  let name: string | null = null
64
66
  let nativeProjectDir: string | undefined
65
67
  let initialUrl: string | null = null
68
+ let endpoint: string | undefined
66
69
  for (let index = 0; index < args.length; index++) {
67
70
  const arg = args[index]
68
71
  if (
@@ -79,6 +82,7 @@ function remoteInputFromArgs(
79
82
  if (!value) throw new Error(`peach remote ${platform} ${arg} requires a value`)
80
83
  if (arg === '--assets') assetsDirectory = value
81
84
  if (arg === '--name') name = value
85
+ if (arg === '--endpoint') endpoint = value
82
86
  if (arg === '--native-project') nativeProjectDir = value
83
87
  if (arg === '--url') initialUrl = value
84
88
  continue
@@ -146,6 +150,7 @@ function remoteInputFromArgs(
146
150
  name,
147
151
  nativeProjectDir,
148
152
  initialUrl,
153
+ endpoint,
149
154
  reuse,
150
155
  fresh,
151
156
  watch,
@@ -172,6 +177,10 @@ export async function runPlatformCommand(
172
177
  args: string[],
173
178
  opts: { port?: number } = {},
174
179
  ): Promise<number | undefined> {
180
+ if (args.includes('--nano') && !isSootsimDevCheckout()) {
181
+ console.error(` ${new NanoDevelopmentOnlyError().message}`)
182
+ return 1
183
+ }
175
184
  // device metadata comes from the runtime companion, so a first-use home
176
185
  // installs the runtime before anything resolves a device.
177
186
  await (await import('./control')).ensureRuntimeForOpen()
@@ -231,7 +240,7 @@ export async function runPlatformCommand(
231
240
  if (!args.includes('--nano')) {
232
241
  return await runRemoteBox(platform, args, selectedDevice)
233
242
  }
234
- return await runRemoteCreate(platform, args, selectedDevice)
243
+ return await runNanoCreate(platform, args, selectedDevice)
235
244
  } catch (error) {
236
245
  rethrowIfExit(error)
237
246
  const mode = args.includes('--nano') ? '--nano' : '--remote'
@@ -306,13 +315,7 @@ export function runRemotePlatformCommand(
306
315
  const REMOTE_COMMANDS_HELP =
307
316
  ' commands: describe, find, get tree|node|count|memory, wait ready|selector, do, reset, logs, state, screenshot'
308
317
 
309
- /**
310
- * `peach remote ios|android <bundle>` on the one customer plane: one typed
311
- * create through the instance API for both platforms, and a reattach to the
312
- * shell's own simulator when it already runs this bundle. the box stays the
313
- * host behind the API and is never created or addressed here.
314
- */
315
- async function runRemoteCreate(
318
+ async function runNanoCreate(
316
319
  platform: RuntimePlatform,
317
320
  args: string[],
318
321
  selectedDevice: string,
@@ -396,6 +399,7 @@ async function runRemoteCreate(
396
399
  authorization: header,
397
400
  accountId,
398
401
  platform,
402
+ apiOrigin: input.endpoint,
399
403
  reuse: input.reuse,
400
404
  assetsDirectory: input.assetsDirectory,
401
405
  })
@@ -615,6 +619,8 @@ async function runRemoteBox(
615
619
  source,
616
620
  appFontsWireSha256,
617
621
  } = await box.createPrebuiltBundleBox({
622
+ simulatorOrigin:
623
+ endpoint === rnxPublicBrand.boxOrigin ? rnxPublicBrand.origin : endpoint,
618
624
  artifact: existingArtifact ?? getArtifact,
619
625
  nativeProjectDir,
620
626
  ...(input.watch ? { bundleUpdate: { sequence: 1 } } : {}),
@@ -659,7 +665,12 @@ async function runRemoteBox(
659
665
  publishCloudSession(session)
660
666
  process.env[PEACH_CLOUD_SESSION_ENV] = serializeCloudSession(session)
661
667
 
668
+ const watchUrl = new URL(
669
+ cloudSimulatorPath(cloudBoxSimulatorId(session.boxId)),
670
+ siteOrigin,
671
+ ).href
662
672
  console.log(` box: ${created.id} (${artifact.bytes.length} bytes)`)
673
+ console.log(` simulator: ${watchUrl}`)
663
674
  console.log(` platform: ${platform}`)
664
675
  if (selectedDevice) console.log(` device: ${selectedDevice}`)
665
676
  console.log(` artifact: sha256:${artifactSha256}`)
@@ -671,10 +682,6 @@ async function runRemoteBox(
671
682
  for (const warning of artifact.warnings) console.warn(` warning: ${warning}`)
672
683
  console.log(REMOTE_COMMANDS_HELP)
673
684
  await awaitBootOrClose(session)
674
- const watchUrl = new URL(
675
- cloudSimulatorPath(cloudBoxSimulatorId(session.boxId)),
676
- siteOrigin,
677
- ).href
678
685
  console.log(` open ${watchUrl}`)
679
686
  const opened = await openInBrowser(watchUrl)
680
687
  if (!input.watch || opened !== 0) return opened
@@ -804,7 +811,8 @@ export async function runRemoteStop(args: string[]): Promise<number> {
804
811
  // stopping the project's own simulator forgets it, and the shell's with it
805
812
  const ownSession =
806
813
  (current?.service === 'sim' && current.simId === simId) ||
807
- (current?.service === 'box' && current.boxId === simId)
814
+ (current?.service === 'box' &&
815
+ (current.boxId === simId || cloudBoxSimulatorId(current.boxId) === simId))
808
816
  const descriptor = ownSession ? cloudSessionShellUpdate() : null
809
817
  const { auth, header } = authHeaderOrExit('remote stop')
810
818
  const accountId = cloudAccountIdOrExit(auth)
@@ -1,3 +1,4 @@
1
+ import { readRoundedPositiveFlag, readStringFlagWithEquals } from '../parse-args'
1
2
  import { formatTable } from '../ui'
2
3
  import {
3
4
  callInBridge,
@@ -63,21 +64,6 @@ examples:
63
64
  `)
64
65
  }
65
66
 
66
- function valueOf(args: string[], flag: string): string | undefined {
67
- const idx = args.indexOf(flag)
68
- if (idx >= 0 && idx + 1 < args.length) return args[idx + 1]
69
- const prefix = `${flag}=`
70
- const found = args.find((arg) => arg.startsWith(prefix))
71
- return found ? found.slice(prefix.length) : undefined
72
- }
73
-
74
- function numberFlag(args: string[], flag: string, fallback: number): number {
75
- const raw = valueOf(args, flag)
76
- if (raw === undefined) return fallback
77
- const value = Number(raw)
78
- return Number.isFinite(value) && value > 0 ? Math.round(value) : fallback
79
- }
80
-
81
67
  function printJson(value: unknown) {
82
68
  console.log(JSON.stringify(value, null, 2))
83
69
  }
@@ -204,7 +190,7 @@ export async function runReact(args: string[], opts: ReactOptions): Promise<numb
204
190
  'SootSim.bridges.reactProfile.start',
205
191
  {
206
192
  includeProps: args.includes('--include-props'),
207
- maxCommits: numberFlag(args, '--max-commits', 2000),
193
+ maxCommits: readRoundedPositiveFlag(args, '--max-commits', 2000),
208
194
  },
209
195
  )
210
196
  if (json) printJson(result)
@@ -229,7 +215,7 @@ export async function runReact(args: string[], opts: ReactOptions): Promise<numb
229
215
  // run slow + rerenders in parallel against the existing bridge.
230
216
  // demo-friendly: one command, one table per dimension, plus a
231
217
  // single duration-zero warning that's easy to call out on stage.
232
- const limit = numberFlag(args, '--limit', 10)
218
+ const limit = readRoundedPositiveFlag(args, '--limit', 10)
233
219
  const [slowResult, rerendersResult] = (await Promise.all([
234
220
  callInBridge(bridge, 'SootSim.bridges.reactProfile.slow', { limit }),
235
221
  callInBridge(bridge, 'SootSim.bridges.reactProfile.rerenders', { limit }),
@@ -281,7 +267,7 @@ export async function runReact(args: string[], opts: ReactOptions): Promise<numb
281
267
 
282
268
  if (first === 'slow') {
283
269
  const result = (await callInBridge(bridge, 'SootSim.bridges.reactProfile.slow', {
284
- limit: numberFlag(args, '--limit', 10),
270
+ limit: readRoundedPositiveFlag(args, '--limit', 10),
285
271
  })) as {
286
272
  rows?: SlowRow[]
287
273
  commits?: number
@@ -297,7 +283,7 @@ export async function runReact(args: string[], opts: ReactOptions): Promise<numb
297
283
  const result = (await callInBridge(
298
284
  bridge,
299
285
  'SootSim.bridges.reactProfile.rerenders',
300
- { limit: numberFlag(args, '--limit', 10) },
286
+ { limit: readRoundedPositiveFlag(args, '--limit', 10) },
301
287
  )) as { rows?: RerenderRow[]; commits?: number; error?: string }
302
288
  if (json) printJson(result)
303
289
  else printRerenders(result)
@@ -306,8 +292,8 @@ export async function runReact(args: string[], opts: ReactOptions): Promise<numb
306
292
 
307
293
  if (first === 'tree') {
308
294
  const result = (await callInBridge(bridge, 'SootSim.bridges.reactProfile.tree', {
309
- depth: numberFlag(args, '--depth', 3),
310
- find: valueOf(args, '--find'),
295
+ depth: readRoundedPositiveFlag(args, '--depth', 3),
296
+ find: readStringFlagWithEquals(args, '--find'),
311
297
  })) as { rows?: TreeRow[]; roots?: number; error?: string }
312
298
  if (json) printJson(result)
313
299
  else printTree(result)
@@ -15,6 +15,7 @@ import { existsSync, mkdirSync, unlinkSync, writeFileSync } from 'node:fs'
15
15
  import { homedir } from 'node:os'
16
16
  import { dirname, extname, join, resolve } from 'node:path'
17
17
  import { sleep } from '../../src/sleep'
18
+ import { readStringFlag } from '../parse-args'
18
19
  import {
19
20
  callInBridgeWrite,
20
21
  createBridgeFromParsed,
@@ -55,11 +56,6 @@ const CONFIGURE_VALUE_FLAGS = [
55
56
  const MAX_FILM_MS = 120_000
56
57
  const STAGE_BITRATE = 16_000_000
57
58
 
58
- function flagValue(args: string[], flag: string): string | undefined {
59
- const i = args.indexOf(flag)
60
- return i >= 0 ? args[i + 1] : undefined
61
- }
62
-
63
59
  async function evalInPage<T>(bridge: WsBridge, code: string, timeoutMs = 30_000) {
64
60
  return (await bridge.send({ type: 'evaluate', code }, { timeoutMs })) as T
65
61
  }
@@ -112,11 +108,11 @@ examples:
112
108
  return 1
113
109
  }
114
110
 
115
- const fps = Number.parseInt(flagValue(args, '--fps') ?? '30', 10)
116
- const scriptId = flagValue(args, '--script') ?? 'hero-arc'
111
+ const fps = Number.parseInt(readStringFlag(args, '--fps') ?? '30', 10)
112
+ const scriptId = readStringFlag(args, '--script') ?? 'hero-arc'
117
113
  const keepThree = args.includes('--keep-three')
118
114
  const flowName = flowPath.replace(/^.*\//, '').replace(/\.ya?ml$/, '')
119
- const outArg = flagValue(args, '--output')
115
+ const outArg = readStringFlag(args, '--output')
120
116
  const outPath = resolve(
121
117
  outArg ?? join(homedir(), 'Desktop', 'peach-recordings', `${flowName}.webm`),
122
118
  )
@@ -146,9 +142,9 @@ examples:
146
142
  console.log(` record --three: recording flow ${flowName} on the flat canvas`)
147
143
  const { runFlowPlayback } = await import('./flow')
148
144
  const playbackArgs = [flowPath]
149
- const simFlag = flagValue(args, '--sim')
145
+ const simFlag = readStringFlag(args, '--sim')
150
146
  if (simFlag) playbackArgs.push('--sim', simFlag)
151
- const slowFlag = flagValue(args, '--slow')
147
+ const slowFlag = readStringFlag(args, '--slow')
152
148
  if (slowFlag) playbackArgs.push('--slow', slowFlag)
153
149
  let t0 = 0
154
150
  const flowCode = await runFlowPlayback(playbackArgs, {
@@ -1,8 +1,3 @@
1
- // peach record — drives the engine's built-in canvas recorder over
2
- // the WS bridge. scene export opens an isolated viewer; encoding happens in the
3
- // running peach page (webm via MediaRecorder, mp4 via WebCodecs, gif
4
- // via gifenc, raw png frames via a shared bitmap sampler).
5
-
6
1
  import {
7
2
  existsSync,
8
3
  mkdirSync,
@@ -12,6 +7,10 @@ import {
12
7
  rmSync,
13
8
  writeFileSync,
14
9
  } from 'fs'
10
+ // peach record — drives the engine's built-in canvas recorder over
11
+ // the WS bridge. scene export opens an isolated viewer; encoding happens in the
12
+ // running peach page (webm via MediaRecorder, mp4 via WebCodecs, gif
13
+ // via gifenc, raw png frames via a shared bitmap sampler).
15
14
  import { homedir, tmpdir } from 'os'
16
15
  import { dirname, extname, join, resolve } from 'path'
17
16
  import { GITHUB_WORKFLOW_IDENTITY_HEADER } from '@peach/globals/github-workflow'
@@ -19,6 +18,7 @@ import { githubUploadIdentity, resolveCliAuth } from '../auth'
19
18
  import { getCliIdentityKey } from '../current-sim'
20
19
  import { githubWorkflowIdentityHeaders } from '../github-workflow-identity'
21
20
  import { openUrl } from '../open-url'
21
+ import { readStringFlag, takeSubcommand } from '../parse-args'
22
22
  import { previewCaptureKind } from '../preview-capture'
23
23
  import { ensureCliRecordingEntitlement, PRIVATE_PREVIEW_NOTE } from '../recording-access'
24
24
  import { resolveRunProvenance } from '../run-registry'
@@ -184,22 +184,6 @@ const RECORD_SUBCOMMANDS = new Set([
184
184
  'render',
185
185
  ])
186
186
 
187
- // the record subcommand (start/stop/cancel/status) is the first non-flag
188
- // positional — NOT necessarily args[0]. bin.ts prepends `--sim <id>` when a
189
- // global --sim target is set, so a naive args[0] check silently fell through
190
- // to the atomic-record path and started a spurious recording (F41).
191
- function findRecordSubcommand(args: string[]): { name: string; index: number } | null {
192
- for (let i = 0; i < args.length; i++) {
193
- const a = args[i]
194
- if (a.startsWith('-')) {
195
- if (RECORD_VALUE_FLAGS.has(a)) i++ // skip the flag's value
196
- continue
197
- }
198
- return RECORD_SUBCOMMANDS.has(a) ? { name: a, index: i } : null
199
- }
200
- return null
201
- }
202
-
203
187
  type RepoScope = { owner: string; repo: string } | null
204
188
 
205
189
  // git provenance for PR-preview shares, read from the github-actions env
@@ -208,8 +192,8 @@ type RepoScope = { owner: string; repo: string } | null
208
192
  // merged into the upload identity so the org/recent feed shows the same
209
193
  // branch / PR title + "sha · author" for previews as for branch-builds.
210
194
  function readRepoScope(args: string[]): RepoScope {
211
- const owner = valueOf(args, '--owner')?.trim()
212
- const repo = valueOf(args, '--repo')?.trim()
195
+ const owner = readStringFlag(args, '--owner')?.trim()
196
+ const repo = readStringFlag(args, '--repo')?.trim()
213
197
  if ((owner && !repo) || (!owner && repo)) {
214
198
  console.error(' --owner and --repo must be provided together')
215
199
  peachExit(1)
@@ -221,21 +205,19 @@ export async function runRecord(args: string[], opts: RecordOptions) {
221
205
  // note: `--help` / `-h` never reach here — bin.ts intercepts them and
222
206
  // renders the registry-driven help page (packages/peachsim/cli/catalog meta.ts).
223
207
 
224
- const sub = findRecordSubcommand(args)
208
+ const sub = takeSubcommand(args, RECORD_SUBCOMMANDS, RECORD_VALUE_FLAGS)
225
209
  if (sub) {
226
- // drop the subcommand token; the rest (incl. any --sim/--port) flows on
227
- // to the subcommand handlers, which parse bridge flags themselves.
228
- const rest = [...args.slice(0, sub.index), ...args.slice(sub.index + 1)]
210
+ const rest = sub.args
229
211
  if (sub.name === 'render') {
230
- const scene = valueOf(rest, '--scene')
231
- const shellUrl = valueOf(rest, '--shell-url')
232
- const output = valueOf(rest, '--output')
212
+ const scene = readStringFlag(rest, '--scene')
213
+ const shellUrl = readStringFlag(rest, '--shell-url')
214
+ const output = readStringFlag(rest, '--output')
233
215
  if (!scene || !shellUrl || !output)
234
216
  throw new Error('record render requires --scene, --shell-url and --output')
235
217
  const { renderSceneToVideo } = await import('../scene-video')
236
- const fps = Number(valueOf(rest, '--fps') ?? '60')
218
+ const fps = Number(readStringFlag(rest, '--fps') ?? '60')
237
219
  const format =
238
- valueOf(rest, '--format') ?? (extname(output) === '.webm' ? 'webm' : 'mp4')
220
+ readStringFlag(rest, '--format') ?? (extname(output) === '.webm' ? 'webm' : 'mp4')
239
221
  if (format !== 'mp4' && format !== 'webm')
240
222
  throw new Error('video format must be mp4 or webm')
241
223
  const result = await renderSceneToVideo({
@@ -250,8 +232,8 @@ export async function runRecord(args: string[], opts: RecordOptions) {
250
232
  : rest.includes('--shell-only')
251
233
  ? 'shell'
252
234
  : 'full',
253
- maxWidth: valueOf(rest, '--max-width')
254
- ? Number(valueOf(rest, '--max-width'))
235
+ maxWidth: readStringFlag(rest, '--max-width')
236
+ ? Number(readStringFlag(rest, '--max-width'))
255
237
  : undefined,
256
238
  },
257
239
  })
@@ -310,22 +292,22 @@ export async function runRecord(args: string[], opts: RecordOptions) {
310
292
  '--repo',
311
293
  ],
312
294
  })
313
- const mode = parseMode(valueOf(args, '--mode'))
295
+ const mode = parseMode(readStringFlag(args, '--mode'))
314
296
  const layers: 'tenant' | 'shell' | undefined = args.includes('--shell-only')
315
297
  ? 'shell'
316
298
  : args.includes('--no-shell')
317
299
  ? 'tenant'
318
300
  : undefined
319
- const formatArg = valueOf(args, '--format') as OutputFormat | undefined
301
+ const formatArg = readStringFlag(args, '--format') as OutputFormat | undefined
320
302
  if (formatArg && !['webm', 'mp4', 'gif', 'png'].includes(formatArg)) {
321
303
  console.error(` invalid --format "${formatArg}" — expected webm | mp4 | gif | png`)
322
304
  peachExit(1)
323
305
  }
324
- const outputArg = valueOf(args, '--output')
325
- const durationSec = Number(valueOf(args, '--duration') ?? '10')
306
+ const outputArg = readStringFlag(args, '--output')
307
+ const durationSec = Number(readStringFlag(args, '--duration') ?? '10')
326
308
  if (!Number.isFinite(durationSec) || durationSec <= 0) {
327
309
  console.error(
328
- ` invalid --duration "${valueOf(args, '--duration')}" — expected a positive number of seconds`,
310
+ ` invalid --duration "${readStringFlag(args, '--duration')}" — expected a positive number of seconds`,
329
311
  )
330
312
  peachExit(1)
331
313
  }
@@ -339,13 +321,13 @@ export async function runRecord(args: string[], opts: RecordOptions) {
339
321
  const MAX_DURATION_SEC = 600
340
322
  if (durationSec > MAX_DURATION_SEC) {
341
323
  console.error(
342
- ` invalid --duration "${valueOf(args, '--duration')}" — exceeds the ${MAX_DURATION_SEC}s (10m) maximum`,
324
+ ` invalid --duration "${readStringFlag(args, '--duration')}" — exceeds the ${MAX_DURATION_SEC}s (10m) maximum`,
343
325
  )
344
326
  peachExit(1)
345
327
  }
346
- const fps = Number(valueOf(args, '--fps') ?? '30')
328
+ const fps = Number(readStringFlag(args, '--fps') ?? '30')
347
329
  if (!Number.isFinite(fps) || fps <= 0) throw new Error('--fps must be positive')
348
- const framesArg = valueOf(args, '--frames')
330
+ const framesArg = readStringFlag(args, '--frames')
349
331
  // --frames is a count, not a duration — reject 0 / negatives / fractions
350
332
  // up front instead of silently "saving 0 frames" (F11-3), mirroring the
351
333
  // --duration guard above.
@@ -359,8 +341,8 @@ export async function runRecord(args: string[], opts: RecordOptions) {
359
341
  }
360
342
  }
361
343
  const openAfter = args.includes('--open')
362
- const maxWidth = valueOf(args, '--max-width')
363
- ? Number(valueOf(args, '--max-width'))
344
+ const maxWidth = readStringFlag(args, '--max-width')
345
+ ? Number(readStringFlag(args, '--max-width'))
364
346
  : undefined
365
347
  if (maxWidth !== undefined && (!Number.isFinite(maxWidth) || maxWidth <= 0))
366
348
  throw new Error('--max-width must be positive')
@@ -380,7 +362,7 @@ export async function runRecord(args: string[], opts: RecordOptions) {
380
362
  // --origin explicitly pins the billing/upload origin. it wins over the
381
363
  // saved desktop-session origin so a key minted against a local :3000
382
364
  // stack verifies there instead of prod (the e2e blocker — F12).
383
- const originOverride = valueOf(args, '--origin')
365
+ const originOverride = readStringFlag(args, '--origin')
384
366
  const repoScope = readRepoScope(args)
385
367
 
386
368
  // live / combined route through the recording store (events + optional
@@ -423,7 +405,7 @@ export async function runRecord(args: string[], opts: RecordOptions) {
423
405
  const started = await evalStoreStart(
424
406
  bridge,
425
407
  mode,
426
- previewCaptureKind(valueOf(args, '--capture')),
408
+ previewCaptureKind(readStringFlag(args, '--capture')),
427
409
  mode === 'combined' ? layers : undefined,
428
410
  )
429
411
  if (!started.ok) {
@@ -898,12 +880,6 @@ async function renderStoreScene(
898
880
  }
899
881
  }
900
882
 
901
- export function valueOf(args: string[], flag: string): string | undefined {
902
- const idx = args.indexOf(flag)
903
- if (idx < 0 || idx === args.length - 1) return undefined
904
- return args[idx + 1]
905
- }
906
-
907
883
  export function extToFormat(path?: string): OutputFormat | undefined {
908
884
  if (!path) return undefined
909
885
  const ext = extname(path).toLowerCase().replace(/^\./, '')
@@ -1046,7 +1022,7 @@ async function refuseLiveRecording(parsed: ParsedBridgeCliArgs) {
1046
1022
  }
1047
1023
 
1048
1024
  async function recordStart(args: string[], opts: RecordOptions) {
1049
- const mode = parseMode(valueOf(args, '--mode'))
1025
+ const mode = parseMode(readStringFlag(args, '--mode'))
1050
1026
  const parsed = parseBridgeCliArgs(args, {
1051
1027
  port: opts.port,
1052
1028
  // an explicit --timeout wins over the per-mode default
@@ -1070,9 +1046,9 @@ async function recordStart(args: string[], opts: RecordOptions) {
1070
1046
  : args.includes('--no-shell')
1071
1047
  ? 'tenant'
1072
1048
  : undefined
1073
- const outputExt = extname(valueOf(args, '--output') ?? '')
1049
+ const outputExt = extname(readStringFlag(args, '--output') ?? '')
1074
1050
  const formatArg =
1075
- (valueOf(args, '--format') as OutputFormat | undefined) ??
1051
+ (readStringFlag(args, '--format') as OutputFormat | undefined) ??
1076
1052
  (outputExt === '.mp4' ? 'mp4' : outputExt === '.webm' ? 'webm' : undefined)
1077
1053
  const format =
1078
1054
  formatArg === 'mp4' || (!formatArg && mode === 'combined') ? 'mp4' : 'webm'
@@ -1082,7 +1058,7 @@ async function recordStart(args: string[], opts: RecordOptions) {
1082
1058
  )
1083
1059
  peachExit(1)
1084
1060
  }
1085
- const fps = Number(valueOf(args, '--fps') ?? '30')
1061
+ const fps = Number(readStringFlag(args, '--fps') ?? '30')
1086
1062
  if (!Number.isFinite(fps) || fps <= 0) throw new Error('--fps must be positive')
1087
1063
  if (args.includes('--scene-only') && mode !== 'video')
1088
1064
  throw new Error('--scene-only requires --mode video')
@@ -1091,8 +1067,8 @@ async function recordStart(args: string[], opts: RecordOptions) {
1091
1067
  throw new Error('--scene-only cannot be used with --lockstep')
1092
1068
  if (mode === 'video' && lockstep && format !== 'mp4')
1093
1069
  throw new Error('--lockstep requires --format mp4')
1094
- const maxWidth = valueOf(args, '--max-width')
1095
- ? Number(valueOf(args, '--max-width'))
1070
+ const maxWidth = readStringFlag(args, '--max-width')
1071
+ ? Number(readStringFlag(args, '--max-width'))
1096
1072
  : undefined
1097
1073
  if (maxWidth !== undefined && (!Number.isFinite(maxWidth) || maxWidth <= 0))
1098
1074
  throw new Error('--max-width must be positive')
@@ -1131,18 +1107,18 @@ async function recordStart(args: string[], opts: RecordOptions) {
1131
1107
  // mirrors `flow --record`. the bypass only triggers for github-kind
1132
1108
  // auth (CI); local paid users still hit the billing check.
1133
1109
  await ensureCliRecordingEntitlement('record', {
1134
- originOverride: valueOf(args, '--origin'),
1110
+ originOverride: readStringFlag(args, '--origin'),
1135
1111
  allowGitHubAuth: true,
1136
1112
  })
1137
1113
  await assertStoreBridgesAvailable(bridge)
1138
1114
  await assertGuestBundleLoaded(bridge, mode)
1139
1115
  if (mode === 'combined') await assertTabVisibleForCapture(bridge)
1140
- await injectPreviewSessionAuth(bridge, valueOf(args, '--origin'), repoScope)
1116
+ await injectPreviewSessionAuth(bridge, readStringFlag(args, '--origin'), repoScope)
1141
1117
  writeRecordingState(session)
1142
1118
  const started = await evalStoreStart(
1143
1119
  bridge,
1144
1120
  mode,
1145
- previewCaptureKind(valueOf(args, '--capture')),
1121
+ previewCaptureKind(readStringFlag(args, '--capture')),
1146
1122
  mode === 'combined' ? layers : undefined,
1147
1123
  )
1148
1124
  if (!started.ok) {
@@ -1553,7 +1529,7 @@ async function recordStop(args: string[], opts: RecordOptions) {
1553
1529
 
1554
1530
  // the container is fixed at start; an --output naming the other video
1555
1531
  // container keeps its name but takes the recorded extension.
1556
- const requested = valueOf(args, '--output')
1532
+ const requested = readStringFlag(args, '--output')
1557
1533
  const requestedFormat = extToFormat(requested)
1558
1534
  const outputArg =
1559
1535
  requested &&