peachsim 0.1.789 → 0.1.790

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 (74) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/agent-identity.cjs +1 -1
  4. package/dist-lib/agent-sessions.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cli-constants.cjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/home-paths.cjs +1 -1
  28. package/dist-lib/host/bridge-host.cjs +83 -14
  29. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  30. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  32. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  33. package/dist-lib/host/websocket-proxy.cjs +1 -1
  34. package/dist-lib/index.cjs +1 -1
  35. package/dist-lib/jump-to-source-babel.cjs +1 -1
  36. package/dist-lib/jump-to-source-native.cjs +1 -1
  37. package/dist-lib/kotlin-host.cjs +1 -1
  38. package/dist-lib/menu.cjs +1 -1
  39. package/dist-lib/menu.mjs +1 -1
  40. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  42. package/dist-lib/metro-production-bundle.cjs +1 -1
  43. package/dist-lib/metro-production-bundle.mjs +1 -1
  44. package/dist-lib/metro.cjs +1 -1
  45. package/dist-lib/native-app-identity.cjs +1 -1
  46. package/dist-lib/native-app-identity.mjs +1 -1
  47. package/dist-lib/native-firebase-metadata.cjs +1 -1
  48. package/dist-lib/native-firebase-metadata.mjs +1 -1
  49. package/dist-lib/plist.cjs +1 -1
  50. package/dist-lib/plist.mjs +1 -1
  51. package/dist-lib/profiles.cjs +1 -1
  52. package/dist-lib/public-brand.cjs +1 -1
  53. package/dist-lib/react-native-host-modules.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.mjs +1 -1
  55. package/dist-lib/render-mode.cjs +1 -1
  56. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  57. package/dist-lib/sdk.cjs +1 -1
  58. package/dist-lib/sdk.mjs +1 -1
  59. package/dist-lib/skills.cjs +101 -26
  60. package/dist-lib/swift-compile.cjs +52 -1
  61. package/dist-lib/swift-compile.mjs +52 -1
  62. package/dist-lib/swift-package.cjs +1 -1
  63. package/dist-lib/swift-package.mjs +1 -1
  64. package/dist-lib/swift-submit.cjs +1 -1
  65. package/dist-lib/swift-submit.mjs +1 -1
  66. package/dist-lib/swift-toolchain.cjs +1 -1
  67. package/dist-lib/swift.cjs +1 -1
  68. package/dist-lib/vite-swift.cjs +54 -3
  69. package/dist-lib/vite.cjs +1 -1
  70. package/package.json +1 -1
  71. package/src/host/bridge-host.ts +5 -24
  72. package/src/host/lease-owner.test.ts +32 -0
  73. package/src/host/lease-owner.ts +40 -0
  74. package/src/swift-compile.ts +81 -9
@@ -0,0 +1,40 @@
1
+ // true when the process group still has members. ESRCH = the group is gone;
2
+ // EPERM = alive but owned by another user, which still counts as alive. any
3
+ // other failure (or a bogus id) resolves alive, so a lease is only ever freed
4
+ // on positive proof its owner session is gone — never kill(-1) (everyone).
5
+ function isProcessGroupAlive(pgid: number): boolean {
6
+ if (!Number.isInteger(pgid) || pgid <= 1) return true
7
+ try {
8
+ process.kill(-pgid, 0)
9
+ return true
10
+ } catch (error) {
11
+ const code = error && typeof error === 'object' ? Reflect.get(error, 'code') : null
12
+ return code !== 'ESRCH'
13
+ }
14
+ }
15
+
16
+ // a cli lease is free once its owner is provably gone: the owning process
17
+ // group has no members, or a `gppid-<pid>` identity's own process exited (its
18
+ // group can outlive it through children it started, such as a booted sim).
19
+ export function isCliLeaseOwnerGone(
20
+ lease: { kind: 'cli' | 'user-active'; cliIdentityKey: string; ownerPgid?: number },
21
+ isGroupAlive: (pgid: number) => boolean = isProcessGroupAlive,
22
+ isPidAlive: (pid: number) => boolean = isProcessAlive,
23
+ ): boolean {
24
+ if (lease.kind !== 'cli') return false
25
+ if (lease.ownerPgid !== undefined && !isGroupAlive(lease.ownerPgid)) return true
26
+ const owner = /^gppid-(\d+)$/.exec(lease.cliIdentityKey)
27
+ return owner !== null && !isPidAlive(Number(owner[1]))
28
+ }
29
+
30
+ // same proof rule as the group check: only ESRCH frees.
31
+ function isProcessAlive(pid: number): boolean {
32
+ if (!Number.isInteger(pid) || pid <= 1) return true
33
+ try {
34
+ process.kill(pid, 0)
35
+ return true
36
+ } catch (error) {
37
+ const code = error && typeof error === 'object' ? Reflect.get(error, 'code') : null
38
+ return code !== 'ESRCH'
39
+ }
40
+ }
@@ -4,6 +4,7 @@ import {
4
4
  cpSync,
5
5
  existsSync,
6
6
  mkdirSync,
7
+ mkdtempSync,
7
8
  readFileSync,
8
9
  readdirSync,
9
10
  realpathSync,
@@ -287,14 +288,14 @@ const OPTIONAL_FRAMEWORK_DEPENDENCIES: Record<string, string[]> = {
287
288
  FBSDKCoreKit_Basics: [],
288
289
  Intercom: [],
289
290
  FirebaseCore: [],
290
- FirebaseSharedSwift: ["FirebaseCore"],
291
- FirebaseFirestoreInternal: ["FirebaseCore"],
292
- FirebaseAnalytics: ["FirebaseCore"],
293
- FirebaseAppCheck: ["FirebaseCore"],
294
- FirebaseAuth: ["FirebaseCore"],
295
- FirebaseCrashlytics: ["FirebaseCore"],
296
- FirebaseFirestore: ["FirebaseCore", "FirebaseSharedSwift", "FirebaseFirestoreInternal"],
297
- FirebaseStorage: ["FirebaseCore"],
291
+ FirebaseSharedSwift: ['FirebaseCore'],
292
+ FirebaseFirestoreInternal: ['FirebaseCore'],
293
+ FirebaseAnalytics: ['FirebaseCore'],
294
+ FirebaseAppCheck: ['FirebaseCore'],
295
+ FirebaseAuth: ['FirebaseCore'],
296
+ FirebaseCrashlytics: ['FirebaseCore'],
297
+ FirebaseFirestore: ['FirebaseCore', 'FirebaseSharedSwift', 'FirebaseFirestoreInternal'],
298
+ FirebaseStorage: ['FirebaseCore'],
298
299
  FBAudienceNetwork: [],
299
300
  }
300
301
  const OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES))
@@ -2004,7 +2005,7 @@ function serialize<T>(root: string, work: () => Promise<T>): Promise<T> {
2004
2005
  return next
2005
2006
  }
2006
2007
 
2007
- /** the one local compiler used by the route host and Vite host. */
2008
+ /** the project compiler shared by route hosts, Vite and source probes. */
2008
2009
  export function compileSwiftProjectUnit(
2009
2010
  input: SwiftCompileInput,
2010
2011
  options: SwiftCompileOptions,
@@ -2019,6 +2020,77 @@ export function compileSwiftProjectUnit(
2019
2020
  }
2020
2021
  const hash = swiftArtifactHash(input, options.release, moduleRoot)
2021
2022
  return serialize(root, async () => {
2023
+ if (
2024
+ process.platform === 'darwin' &&
2025
+ process.env.TM_SESSION &&
2026
+ process.env.CI !== 'true' &&
2027
+ process.env.CONTRAST_HEAVY_ADMITTED !== '1' &&
2028
+ moduleRoot === path.resolve(import.meta.dirname, '../../sootsim-swift') &&
2029
+ !swiftDistributionAt(moduleRoot)
2030
+ ) {
2031
+ const requestRoot = mkdtempSync(path.join(root, '.builder-request-'))
2032
+ const output = path.join(requestRoot, 'output')
2033
+ const request = path.join(requestRoot, 'request.json')
2034
+ writeFileSync(
2035
+ request,
2036
+ JSON.stringify({
2037
+ input,
2038
+ hash,
2039
+ release: options.release,
2040
+ timeoutMs: options.timeoutMs,
2041
+ buildKey: createHash('sha256').update(root).digest('hex').slice(0, 32),
2042
+ }),
2043
+ )
2044
+ try {
2045
+ const repo = path.resolve(moduleRoot, '../..')
2046
+ const pending = run(
2047
+ 'bun',
2048
+ [
2049
+ path.join(repo, 'scripts/build/swift-project.ts'),
2050
+ '--request',
2051
+ request,
2052
+ '--output',
2053
+ output,
2054
+ ],
2055
+ { cwd: repo, timeout: options.timeoutMs, maxBuffer: 64 * 1024 * 1024 },
2056
+ )
2057
+ pending.child.stdout?.on('data', (bytes: Buffer) => process.stdout.write(bytes))
2058
+ pending.child.stderr?.on('data', (bytes: Buffer) => process.stderr.write(bytes))
2059
+ await pending
2060
+ const receipt: unknown = JSON.parse(
2061
+ readFileSync(path.join(output, 'artifact.json'), 'utf8'),
2062
+ )
2063
+ if (
2064
+ !receipt ||
2065
+ typeof receipt !== 'object' ||
2066
+ !('hash' in receipt) ||
2067
+ receipt.hash !== hash ||
2068
+ !('icu' in receipt) ||
2069
+ typeof receipt.icu !== 'string' ||
2070
+ !('wasm' in receipt) ||
2071
+ typeof receipt.wasm !== 'string'
2072
+ ) {
2073
+ throw new Error(
2074
+ 'swift-compile: builder artifact does not match the requested source',
2075
+ )
2076
+ }
2077
+ const bytes = readFileSync(path.join(output, 'app.wasm'))
2078
+ const gzip = readFileSync(path.join(output, 'icu.gz'))
2079
+ if (
2080
+ createHash('sha256').update(bytes).digest('hex') !== receipt.wasm ||
2081
+ createHash('sha256').update(gzip).digest('hex') !== receipt.icu ||
2082
+ bytes.length < 8 ||
2083
+ bytes.readUInt32LE(0) !== 0x6d736100
2084
+ ) {
2085
+ throw new Error(
2086
+ 'swift-compile: builder artifact digest or wasm header is invalid',
2087
+ )
2088
+ }
2089
+ return { hash, bytes, icu: { sha256: receipt.icu, gzip } }
2090
+ } finally {
2091
+ rmSync(requestRoot, { recursive: true, force: true })
2092
+ }
2093
+ }
2022
2094
  writeSwiftProject(layout, input, moduleRoot)
2023
2095
  const swift = path.join(options.toolchainBin, 'swift')
2024
2096
  if (!existsSync(swift)) {