stim 1.10.1 → 1.12.0

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 (72) hide show
  1. package/dist/{build-progress-BXx-ZBe4.mjs → activity-CCZJs__P.mjs} +9 -182
  2. package/dist/{android-787HhP5w.mjs → android-75Sk2rIR.mjs} +81 -19
  3. package/dist/{android-Bu4mbDzc.mjs → android-B7X-8H7h.mjs} +426 -106
  4. package/dist/{android-DPov-fv2.mjs → android-BQiKJYK0.mjs} +1 -1
  5. package/dist/{android-cas-CITmIeWY.mjs → android-cas-DzLPXiEn.mjs} +7 -7
  6. package/dist/{app-install-Cfmqr3TQ.mjs → app-install-CsZi0SAT.mjs} +1 -1
  7. package/dist/{workspaces-wrH6dXfu.mjs → budget-DbzW5VTD.mjs} +651 -32
  8. package/dist/{dev-client-DExzPiOa.mjs → build-plan-CqntbR7b.mjs} +514 -38
  9. package/dist/build-progress-h60GPV27.mjs +179 -0
  10. package/dist/{cache-manifest-Pubfp8wV.mjs → cache-manifest-DWPF4RKJ.mjs} +1 -1
  11. package/dist/cache-manifest.mjs +1 -1
  12. package/dist/cli.mjs +16 -16
  13. package/dist/collector-run.mjs +4 -4
  14. package/dist/{command-output-D5z2_bcF.mjs → command-output-BWCj5Vh-.mjs} +1 -1
  15. package/dist/{config-BEq0Qw_a.mjs → config-0jCcMM0E.mjs} +10 -1
  16. package/dist/{dependency-state-r9UesA9a.mjs → dependency-state-DNN0yfx6.mjs} +1 -1
  17. package/dist/{deps-DP4eWqea.mjs → deps-CO-_7UOm.mjs} +2 -2
  18. package/dist/{device-Czh5kO8A.mjs → device-9r9xRYDa.mjs} +49 -11
  19. package/dist/{device-lease-CbEaIk7b.mjs → device-lease-B9LAXIUH.mjs} +55 -55
  20. package/dist/{device-pool-BBWLAr55.mjs → device-pool-BoezJd-c.mjs} +4 -4
  21. package/dist/{device-remote-powUHdbK.mjs → device-remote-C0_o-tJH.mjs} +254 -579
  22. package/dist/{doctor-CmqK1LcQ.mjs → doctor-LfDlbR-N.mjs} +20 -19
  23. package/dist/{error-diagnostics-xxWKNO3-.mjs → error-diagnostics-CCxjn31V.mjs} +7 -7
  24. package/dist/{gc-zCDpmdHU.mjs → gc-C4nQFcTX.mjs} +220 -282
  25. package/dist/{guide-DwmaD_Wa.mjs → guide-BPBlh9ML.mjs} +512 -73
  26. package/dist/{guide-status-CWvti2Lg.mjs → guide-status-i9ogHt4v.mjs} +2 -2
  27. package/dist/{idle--jn7pBNe.mjs → idle-S3tFZ53_.mjs} +7 -6
  28. package/dist/{in-use-CNIWU-r-.mjs → in-use-D9XYEgFD.mjs} +7 -7
  29. package/dist/{ios-CbdqTqOc.mjs → ios-CDzWL1mj.mjs} +302 -88
  30. package/dist/{ios-COGcGEcN.mjs → ios-CZWOHTTc.mjs} +24 -19
  31. package/dist/{ios-device-DNjPXBnb.mjs → ios-device-D9cLxVr5.mjs} +1 -1
  32. package/dist/{launch-verify-BhgkYAws.mjs → launch-verify-B2oR_kFN.mjs} +2 -2
  33. package/dist/logs-SzuYudOj.mjs +485 -0
  34. package/dist/merge-state-ytFQCeh4.mjs +262 -0
  35. package/dist/{metro-BWLOJ_Wr.mjs → metro-Dzo30hvJ.mjs} +1 -1
  36. package/dist/{named-ports-DiTfSz6p.mjs → named-ports-Dn1o61D9.mjs} +3 -3
  37. package/dist/{ownership-BfPNRf3-.mjs → ownership-B8d4kXBx.mjs} +49 -16
  38. package/dist/{ownership-D2xbLVoz.mjs → ownership-Dqnrjrio.mjs} +2 -2
  39. package/dist/{ports-CLSSFOuz.mjs → ports-Dp_QTwTC.mjs} +3 -3
  40. package/dist/{project-BXZzOABt.mjs → project-B8rbutVC.mjs} +4 -72
  41. package/dist/{reload-CymyF6Kk.mjs → reload-nocmx8KB.mjs} +9 -9
  42. package/dist/remote-cache-BRsRZru5.mjs +526 -0
  43. package/dist/{server-bare-DVbb7kXH.mjs → server-bare-Gn3ssSdK.mjs} +1 -1
  44. package/dist/{server-expo-BvOCeakp.mjs → server-expo-CeT1nIIk.mjs} +2 -2
  45. package/dist/server-expo-eWi9Coof.mjs +2 -0
  46. package/dist/{settings-DOugPlPz.mjs → settings-BlyDn2Oz.mjs} +14 -5
  47. package/dist/{settings-EWYNwe72.mjs → settings-bE-Gu3Ti.mjs} +23 -11
  48. package/dist/settings.schema.json +73 -1
  49. package/dist/{simslim-DZUxzsjq.mjs → simslim-COtEEP7x.mjs} +152 -96
  50. package/dist/{slot-launch-Dk4oTREM.mjs → slot-launch-DIACGEfH.mjs} +4 -4
  51. package/dist/{spawn-claims-CUleC2cM.mjs → spawn-claims-PT8aQpCa.mjs} +25 -2
  52. package/dist/{start-qWapeB4W.mjs → start-BFstVBlx.mjs} +1 -1
  53. package/dist/{start-RbmFPeZ7.mjs → start-BboE1HIS.mjs} +108 -17
  54. package/dist/{state-WGdIbi_d.mjs → state-DcDgzfu3.mjs} +15 -3
  55. package/dist/{stats-BAgJaLA4.mjs → stats-D8rUTPHd.mjs} +1 -1
  56. package/dist/{stats-DBYJ5bxL.mjs → stats-DiCtmluY.mjs} +4 -4
  57. package/dist/{status-Dr4fRkym.mjs → status-BUASYyy_.mjs} +92 -33
  58. package/dist/{status-Zp8kvexe.mjs → status-DI9Tjo7T.mjs} +255 -38
  59. package/dist/stim-desktop-D0xhpZt8.mjs +29 -0
  60. package/dist/stop-BI7QY76M.mjs +3 -0
  61. package/dist/{stop-DcEv5sk-.mjs → stop-Bn6v-GvS.mjs} +205 -37
  62. package/dist/supervisor-run.mjs +11 -11
  63. package/dist/{workspace-process-lock-BXA96myD.mjs → workspace-process-lock-BvvJTfo_.mjs} +10 -5
  64. package/dist/{worktree-DEG2o9F8.mjs → worktree-B5sTRskL.mjs} +1 -1
  65. package/dist/{worktree-Bd4dRvx7.mjs → worktree-ChDL5fO1.mjs} +17 -16
  66. package/dist/{worktree-BlizKDpZ.mjs → worktree-DeBQSVtR.mjs} +3 -1
  67. package/dist/{xcode-B2tBkf0m.mjs → xcode-BzplpQzc.mjs} +7 -7
  68. package/package.json +5 -5
  69. package/dist/budget-nDCEwtJv.mjs +0 -620
  70. package/dist/logs-MARIy6m9.mjs +0 -209
  71. package/dist/server-expo-DBVTdult.mjs +0 -2
  72. package/dist/stop-DI4BG4Os.mjs +0 -3
@@ -0,0 +1,262 @@
1
+ import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
2
+ import { statSync } from "node:fs";
3
+ //#region src/workspace/merge-state.ts
4
+ const FETCH_TIMEOUT_MS = 3e4;
5
+ const FETCH_FRESH_MS = 6e5;
6
+ const GIT_TIMEOUT_MS = 6e4;
7
+ const REMOTE_PREFIX = "refs/remotes/origin/";
8
+ function failure(error) {
9
+ const { stderr, message } = error;
10
+ const text = String(stderr ?? "").trim() || String(message ?? error);
11
+ return text.split("\n")[0] ?? text;
12
+ }
13
+ function fetchedRecently(repo, now) {
14
+ const path = getExecutor().runFileQuiet("git", [
15
+ "-C",
16
+ repo,
17
+ "rev-parse",
18
+ "--path-format=absolute",
19
+ "--git-path",
20
+ "FETCH_HEAD"
21
+ ])?.trim();
22
+ try {
23
+ return Boolean(path) && now - statSync(path).mtimeMs < FETCH_FRESH_MS;
24
+ } catch {
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * Fetches the default branch that `origin/HEAD` names into its remote-tracking ref, bounded by a timeout and never
30
+ * prompting for credentials. It skips the fetch when the checkout fetched anything in the last 10 minutes.
31
+ */
32
+ function fetchDefaultBranch(repo, now = Date.now()) {
33
+ const exec = getExecutor();
34
+ const ref = exec.runFileQuiet("git", [
35
+ "-C",
36
+ repo,
37
+ "symbolic-ref",
38
+ "--quiet",
39
+ "refs/remotes/origin/HEAD"
40
+ ])?.trim();
41
+ if (!ref?.startsWith(REMOTE_PREFIX)) return { error: `origin/HEAD is not set; run \`git -C ${repo} remote set-head origin --auto\`` };
42
+ const branch = ref.slice(20);
43
+ if (fetchedRecently(repo, now)) return {
44
+ ref,
45
+ name: `origin/${branch}`
46
+ };
47
+ try {
48
+ exec.runFile("git", [
49
+ "-C",
50
+ repo,
51
+ "fetch",
52
+ "--quiet",
53
+ "--no-tags",
54
+ "--no-recurse-submodules",
55
+ "origin",
56
+ `+refs/heads/${branch}:${ref}`
57
+ ], {
58
+ timeoutMs: FETCH_TIMEOUT_MS,
59
+ env: { GIT_TERMINAL_PROMPT: "0" }
60
+ });
61
+ } catch (error) {
62
+ return { error: `git fetch origin ${branch} failed: ${failure(error)}` };
63
+ }
64
+ return {
65
+ ref,
66
+ name: `origin/${branch}`
67
+ };
68
+ }
69
+ function notMerged(detail) {
70
+ return {
71
+ merged: false,
72
+ unknown: false,
73
+ detail
74
+ };
75
+ }
76
+ function currentBranch(path) {
77
+ const ref = getExecutor().runFileQuiet("git", [
78
+ "-C",
79
+ path,
80
+ "symbolic-ref",
81
+ "--quiet",
82
+ "HEAD"
83
+ ])?.trim();
84
+ return ref?.startsWith("refs/heads/") ? ref : null;
85
+ }
86
+ function upstreamGone(path, branch) {
87
+ if (!branch) return false;
88
+ const [upstream, state] = (getExecutor().runFileQuiet("git", [
89
+ "-C",
90
+ path,
91
+ "for-each-ref",
92
+ "--format=%(upstream)%00%(upstream:track)",
93
+ branch
94
+ ]) ?? "").trim().split("\0");
95
+ return Boolean(upstream) && state === "[gone]";
96
+ }
97
+ function committedOn(path, branch, head) {
98
+ if (!branch) return false;
99
+ const exec = getExecutor();
100
+ return (exec.runFileQuiet("git", [
101
+ "-C",
102
+ path,
103
+ "reflog",
104
+ "show",
105
+ "--format=%H %gs",
106
+ branch
107
+ ]) ?? "").split("\n").some((entry) => {
108
+ const [sha = "", ...subject] = entry.split(" ");
109
+ return /^(commit|cherry-pick|rebase|revert)\b/.test(subject.join(" ")) && exec.runFileQuiet("git", [
110
+ "-C",
111
+ path,
112
+ "merge-base",
113
+ "--is-ancestor",
114
+ sha,
115
+ head
116
+ ]) !== null;
117
+ });
118
+ }
119
+ /**
120
+ * Whether the worktree's HEAD is merged into `target`, and when: `mergedAt` is the committer date, in epoch
121
+ * milliseconds, of the commit on `target` that brought the work in, the latest one for a rebase merge.
122
+ * The signals, all local git:
123
+ * - HEAD is an ancestor of the default branch, off its first-parent line, and the branch's reflog shows a commit made
124
+ * on it that HEAD contains, so a merge commit brought the branch's own work in. A branch with no commit of its own
125
+ * is not merged.
126
+ * - The branch changes the tree, has no merge commits, and every commit since the merge base has the same
127
+ * `git patch-id --verbatim` as a commit on the default branch (a rebase merge).
128
+ * - The branch changes the tree and its whole diff since the merge base has the same verbatim patch id as a commit on
129
+ * the default branch, limited to the files the branch changes (a squash merge).
130
+ * Anything git cannot answer is unknown, never merged. `coversUnpushed` is true for a patch-equivalent HEAD whose
131
+ * upstream branch was deleted: its commits exist only locally, but their change is on the default branch.
132
+ */
133
+ function mergeState(path, { ref, name }, { timeoutMs = GIT_TIMEOUT_MS } = {}) {
134
+ const git = (args, input) => getExecutor().runFile("git", [
135
+ "--literal-pathspecs",
136
+ "-C",
137
+ path,
138
+ ...args
139
+ ], {
140
+ timeoutMs,
141
+ input
142
+ });
143
+ const patch = (args) => getExecutor().runFile("git", [
144
+ "--literal-pathspecs",
145
+ "-C",
146
+ path,
147
+ ...args
148
+ ], {
149
+ timeoutMs,
150
+ untrimmed: true
151
+ });
152
+ const patchIdCommits = (text) => new Map(text ? git(["patch-id", "--verbatim"], text).split("\n").flatMap((line) => {
153
+ const [id, commit] = line.split(" ");
154
+ return id && commit ? [[id, commit]] : [];
155
+ }) : []);
156
+ const patchIds = (text) => [...patchIdCommits(text).keys()];
157
+ const committedAt = (commits) => {
158
+ const times = commits.length ? git([
159
+ "show",
160
+ "-s",
161
+ "--format=%ct",
162
+ ...commits
163
+ ]).split("\n").map(Number) : [];
164
+ if (!times.length || !times.every(Number.isFinite)) throw new Error(`no committer date for ${commits.join(" ")}`);
165
+ return Math.max(...times) * 1e3;
166
+ };
167
+ const diffOptions = ["--no-color", "--no-ext-diff"];
168
+ const noOwnCommits = notMerged(`no commits of its own beyond ${name}`);
169
+ try {
170
+ const head = git([
171
+ "rev-parse",
172
+ "--verify",
173
+ "HEAD^{commit}"
174
+ ]);
175
+ const base = git([
176
+ "merge-base",
177
+ head,
178
+ ref
179
+ ]);
180
+ const branch = currentBranch(path);
181
+ if (base === head) {
182
+ if (git(["rev-parse", ref]) === head || git([
183
+ "rev-list",
184
+ "--first-parent",
185
+ "--parents",
186
+ `${head}..${ref}`
187
+ ]).split("\n").some((line) => line.split(" ")[1] === head) || !committedOn(path, branch, head)) return noOwnCommits;
188
+ const descendants = new Set(git([
189
+ "rev-list",
190
+ "--ancestry-path",
191
+ `${head}..${ref}`
192
+ ]).split("\n"));
193
+ const landed = git([
194
+ "rev-list",
195
+ "--first-parent",
196
+ "--reverse",
197
+ `${head}..${ref}`
198
+ ]).split("\n").find((commit) => descendants.has(commit));
199
+ if (!landed) throw new Error(`no commit on ${name} merges ${head}`);
200
+ return {
201
+ merged: true,
202
+ into: name,
203
+ head,
204
+ coversUnpushed: false,
205
+ mergedAt: committedAt([landed])
206
+ };
207
+ }
208
+ const files = git([
209
+ "diff",
210
+ "--name-only",
211
+ "--no-renames",
212
+ "-z",
213
+ base,
214
+ head
215
+ ]).split("\0").filter(Boolean);
216
+ if (!files.length) return notMerged(`no net change beyond ${name}`);
217
+ const log = (range, pathspec = []) => patch([
218
+ "log",
219
+ "-p",
220
+ "--no-merges",
221
+ ...diffOptions,
222
+ "--format=commit %H",
223
+ range,
224
+ "--",
225
+ ...pathspec
226
+ ]);
227
+ const upstream = patchIdCommits(log(`${base}..${ref}`, files));
228
+ const patchEquivalent = (ids) => ({
229
+ merged: true,
230
+ into: name,
231
+ head,
232
+ coversUnpushed: upstreamGone(path, branch),
233
+ mergedAt: committedAt(ids.map((id) => upstream.get(id)))
234
+ });
235
+ const squash = patchIds(patch([
236
+ "diff",
237
+ ...diffOptions,
238
+ base,
239
+ head
240
+ ]));
241
+ if (squash.length === 1 && upstream.has(squash[0])) return patchEquivalent(squash);
242
+ if (!git([
243
+ "rev-list",
244
+ "--merges",
245
+ `${base}..${head}`
246
+ ])) {
247
+ const own = patchIds(log(`${base}..${head}`));
248
+ if (own.length && own.every((id) => upstream.has(id))) return patchEquivalent(own);
249
+ }
250
+ return notMerged(`not merged into ${name}`);
251
+ } catch (error) {
252
+ const timedOut = error?.code === "ETIMEDOUT" ? { timedOut: true } : {};
253
+ return {
254
+ merged: false,
255
+ unknown: true,
256
+ detail: `merge state unknown: ${failure(error)}`,
257
+ ...timedOut
258
+ };
259
+ }
260
+ }
261
+ //#endregion
262
+ export { mergeState as n, fetchDefaultBranch as t };
@@ -1,4 +1,4 @@
1
- import { D as process_identity_exports, M as isOnMountedVolume, N as listMountedVolumes, g as loadConfig$1, n as allMetroPorts, r as claimMetroPort, y as releaseMetroPort } from "./config-BEq0Qw_a.mjs";
1
+ import { N as isOnMountedVolume, O as process_identity_exports, P as listMountedVolumes, _ as loadConfig$1, b as releaseMetroPort, n as allMetroPorts, r as claimMetroPort } from "./config-0jCcMM0E.mjs";
2
2
  import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
3
3
  import { existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { existsSync as existsSync$1, readlinkSync, realpathSync as realpathSync$1 } from "fs";
@@ -1,7 +1,7 @@
1
- import { D as process_identity_exports, T as withConfigLock, f as getProject, g as loadConfig, s as ensureConfig, u as getConfigDir, x as saveConfig } from "./config-BEq0Qw_a.mjs";
1
+ import { E as withConfigLock, O as process_identity_exports, S as saveConfig, _ as loadConfig, c as ensureConfig, d as getConfigDir, p as getProject } from "./config-0jCcMM0E.mjs";
2
2
  import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
3
- import { c as signalProcessTree, n as listeningPids, u as isPortFree } from "./metro-BWLOJ_Wr.mjs";
4
- import { t as withWorkspaceProcessLock } from "./workspace-process-lock-BXA96myD.mjs";
3
+ import { c as signalProcessTree, n as listeningPids, u as isPortFree } from "./metro-Dzo30hvJ.mjs";
4
+ import { t as withWorkspaceProcessLock } from "./workspace-process-lock-BvvJTfo_.mjs";
5
5
  import { realpathSync } from "node:fs";
6
6
  //#region src/named-ports.ts
7
7
  const FIRST_PORT = 8900;
@@ -1,14 +1,16 @@
1
- import { D as process_identity_exports, H as projectDeviceSlots, I as assignSlotDevice, O as acquireAvdClaim, T as withConfigLock, U as removeSlotDevice, d as getConfigPath, g as loadConfig, k as ownership_claim_exports, s as ensureConfig, u as getConfigDir, x as saveConfig, z as deviceSlotPlatforms } from "./config-BEq0Qw_a.mjs";
1
+ import { A as ownership_claim_exports, B as deviceSlotPlatforms, E as withConfigLock, L as assignSlotDevice, O as process_identity_exports, S as saveConfig, U as projectDeviceSlots, W as removeSlotDevice, _ as loadConfig, c as ensureConfig, d as getConfigDir, f as getConfigPath, k as acquireAvdClaim } from "./config-0jCcMM0E.mjs";
2
2
  import { t as getExecutor } from "./exec-DK8KaVHK.mjs";
3
- import { c as signalProcessTree, i as pidExists } from "./metro-BWLOJ_Wr.mjs";
4
- import { r as workspaceProcessLockPath, t as withWorkspaceProcessLock } from "./workspace-process-lock-BXA96myD.mjs";
3
+ import { c as signalProcessTree, i as pidExists } from "./metro-Dzo30hvJ.mjs";
4
+ import { r as workspaceProcessLockPath, t as withWorkspaceProcessLock } from "./workspace-process-lock-BvvJTfo_.mjs";
5
5
  import { t as createLineReader } from "./process-output-Fpl8PYi8.mjs";
6
- import { l as phaseLine } from "./command-output-D5z2_bcF.mjs";
7
- import { A as ownedAvdDirectory, C as isStimOwnedAvdName, D as listOrphanedAvdDirectories, G as wipeAvdUserData, H as sleepSync, P as ownedAvdSystemImage, U as waitForAndroidEmulatorShutdown, V as shutdownAndroidEmulator, f as avdStorageRoots, g as deleteAvd, j as ownedAvdMatchesConfiguration, l as assertOwnedAvdStopped, u as avdPathExists, z as resolveOwnedAvdSerial } from "./android-787HhP5w.mjs";
8
- import { S as resolveOwnedIosSim, a as deleteParkedIosSim, d as listIosDeviceTypes, g as parseRuntimeVersion, h as parkedSimName, i as deleteIosSim, o as eraseIosSim, v as renameIosSim, w as shutdownIosSim } from "./ios-COGcGEcN.mjs";
9
- import { closeSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, unlinkSync } from "node:fs";
10
- import { basename, dirname, join, resolve, sep } from "node:path";
6
+ import { l as phaseLine } from "./command-output-BWCj5Vh-.mjs";
7
+ import { i as readAgentDeviceRecords } from "./activity-CCZJs__P.mjs";
8
+ import { A as listOrphanedAvdDirectories, F as ownedAvdMatchesConfiguration, K as shutdownAndroidEmulator, P as ownedAvdDirectory, R as ownedAvdSystemImage, T as isStimOwnedAvdName, W as resolveOwnedAvdSerial, Y as waitForAndroidEmulatorShutdown, Z as wipeAvdUserData, d as assertOwnedAvdStopped, f as avdPathExists, m as avdStorageRoots, q as sleepSync, v as deleteAvd } from "./android-75Sk2rIR.mjs";
9
+ import { S as resolveOwnedIosSim, a as deleteParkedIosSim, d as listIosDeviceTypes, g as parseRuntimeVersion, h as parkedSimName, i as deleteIosSim, o as eraseIosSim, v as renameIosSim, w as shutdownIosSim } from "./ios-CZWOHTTc.mjs";
10
+ import { closeSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, unlinkSync } from "node:fs";
11
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
11
12
  import { createHash, randomUUID } from "node:crypto";
13
+ import { homedir } from "node:os";
12
14
  import { isDeepStrictEqual } from "node:util";
13
15
  import { resolve4 } from "node:dns/promises";
14
16
  import { request } from "node:https";
@@ -22,17 +24,41 @@ function parseAgentDeviceSessions(output) {
22
24
  const id = row.platform === "ios" ? row.device_udid : row.id;
23
25
  if (row.platform !== "ios" && row.platform !== "android" || typeof row.name !== "string" || !row.name.trim() || typeof id !== "string" || !id || typeof row.createdAt !== "number" || !Number.isFinite(row.createdAt) || row.platform === "ios" && row.id !== void 0 && row.id !== id) return [];
24
26
  return [{
25
- name: row.name,
27
+ name: typeof row.address === "string" && row.address.trim() ? row.address : row.name,
26
28
  platform: row.platform,
27
29
  id,
30
+ device: typeof row.device === "string" ? row.device : null,
28
31
  createdAt: row.createdAt
29
32
  }];
30
33
  });
31
34
  }
35
+ function isOwnDeviceSession(session, device, owner) {
36
+ if (session.platform !== device.platform || session.id !== device.id) return false;
37
+ if (device.platform === "android" && session.device !== device.avdName.replaceAll("_", " ")) return false;
38
+ if (!owner) return true;
39
+ return owner.claims.some((claim) => claim.session === session.name && claim.workspace !== null && within(owner.workspace, claim.workspace));
40
+ }
41
+ function within(root, path) {
42
+ const rest = relative(root, path);
43
+ return rest === "" || !isAbsolute(rest) && rest.split(sep)[0] !== "..";
44
+ }
45
+ function canonical(path) {
46
+ try {
47
+ return realpathSync(path);
48
+ } catch {
49
+ return null;
50
+ }
51
+ }
52
+ function deviceClaims(device) {
53
+ return readAgentDeviceRecords(homedir()).filter((record) => record.kind === "claim" && record.deviceId === device.id).map((record) => ({
54
+ session: record.session,
55
+ workspace: record.workspace && canonical(record.workspace)
56
+ }));
57
+ }
32
58
  function report(message) {
33
59
  process.stderr.write(`${phaseLine("device", message)}\n`);
34
60
  }
35
- function closeOwnedDeviceSessions(device, stillOwned) {
61
+ function closeOwnedDeviceSessions(device, stillOwned, workspace) {
36
62
  const exec = getExecutor();
37
63
  const deadline = Date.now() + 15e3;
38
64
  const run = (args) => {
@@ -56,7 +82,13 @@ function closeOwnedDeviceSessions(device, stillOwned) {
56
82
  ]));
57
83
  try {
58
84
  if (!exec.findExecutable("agent-device")) return;
59
- const sessions = list().filter((session) => session.platform === device.platform && session.id === device.id);
85
+ const root = workspace === void 0 ? void 0 : canonical(workspace);
86
+ if (root === null) return;
87
+ const owner = root === void 0 ? void 0 : {
88
+ workspace: root,
89
+ claims: deviceClaims(device)
90
+ };
91
+ const sessions = list().filter((session) => isOwnDeviceSession(session, device, owner));
60
92
  for (const session of sessions) try {
61
93
  if (!list().some((current) => current.name === session.name && current.platform === session.platform && current.id === session.id && current.createdAt === session.createdAt)) continue;
62
94
  if (!stillOwned()) return;
@@ -376,7 +408,7 @@ function parkOwnedIosSim(settled, udid, park) {
376
408
  })
377
409
  };
378
410
  }
379
- function teardownOwnedIosSim(udid, { del = false, label, park, shutdownClock = {} } = {}) {
411
+ function teardownOwnedIosSim(udid, { del = false, label, park, workspace, shutdownClock = {} } = {}) {
380
412
  let parkFallback;
381
413
  try {
382
414
  const resolved = resolveOwnedIosSim(udid);
@@ -389,7 +421,7 @@ function teardownOwnedIosSim(udid, { del = false, label, park, shutdownClock = {
389
421
  closeOwnedDeviceSessions({
390
422
  platform: "ios",
391
423
  id: udid
392
- }, () => Boolean(resolveOwnedIosSim(udid).sim));
424
+ }, () => Boolean(resolveOwnedIosSim(udid).sim), workspace);
393
425
  const current = resolveOwnedIosSim(udid);
394
426
  if (current.missing) return { status: "missing" };
395
427
  if (current.notOwned) return {
@@ -520,7 +552,7 @@ function teardownOwnedAvd(avdName, options = {}) {
520
552
  (0, ownership_claim_exports.releaseClaim)(claim);
521
553
  }
522
554
  }
523
- function teardownClaimedAvd(avdName, claim, { del = false, park, owner, orphanedDirectory, onlyIfMissing = false, waitForShutdown = waitForAndroidEmulatorShutdown, assertStopped = assertOwnedAvdStopped, resolveAvd = resolveOwnedAvdSerial }) {
555
+ function teardownClaimedAvd(avdName, claim, { del = false, park, owner, workspace, orphanedDirectory, onlyIfMissing = false, waitForShutdown = waitForAndroidEmulatorShutdown, assertStopped = assertOwnedAvdStopped, resolveAvd = resolveOwnedAvdSerial }) {
524
556
  let parkFallback;
525
557
  try {
526
558
  if (del) withConfigLock(() => assertAvdReferences(avdName, owner));
@@ -547,8 +579,9 @@ function teardownClaimedAvd(avdName, claim, { del = false, park, owner, orphaned
547
579
  };
548
580
  closeOwnedDeviceSessions({
549
581
  platform: "android",
550
- id: serial
551
- }, stillOwned);
582
+ id: serial,
583
+ avdName
584
+ }, stillOwned, workspace);
552
585
  if (!stillOwned()) throw new Error(`Owned AVD ${avdName} changed before shutdown; it was kept.`);
553
586
  waitForShutdown(avdName, (timeoutMs) => {
554
587
  (0, ownership_claim_exports.markClaimChildPending)(claim);
@@ -1,5 +1,5 @@
1
- import { D as process_identity_exports } from "./config-BEq0Qw_a.mjs";
2
- import { _ as withWorkspaceStateLock, i as pidExists, m as readWorkspaceState, y as writeWorkspaceState } from "./metro-BWLOJ_Wr.mjs";
1
+ import { O as process_identity_exports } from "./config-0jCcMM0E.mjs";
2
+ import { _ as withWorkspaceStateLock, i as pidExists, m as readWorkspaceState, y as writeWorkspaceState } from "./metro-Dzo30hvJ.mjs";
3
3
  import { realpathSync } from "node:fs";
4
4
  //#region src/collector/state.ts
5
5
  function collectorRoot(root) {
@@ -1,6 +1,6 @@
1
- import { f as getProject } from "./config-BEq0Qw_a.mjs";
2
- import { o as findProjectRoot } from "./project-BXZzOABt.mjs";
3
- import { n as getNamedPort, t as clearNamedPorts } from "./named-ports-DiTfSz6p.mjs";
1
+ import { p as getProject } from "./config-0jCcMM0E.mjs";
2
+ import { i as findProjectRoot } from "./project-B8rbutVC.mjs";
3
+ import { n as getNamedPort, t as clearNamedPorts } from "./named-ports-Dn1o61D9.mjs";
4
4
  //#region src/commands/ports.ts
5
5
  async function inProject(action) {
6
6
  try {
@@ -1,6 +1,6 @@
1
- import { c as findEnclosingWorktreeRoot, f as getProject } from "./config-BEq0Qw_a.mjs";
2
- import { y as repoRoot } from "./worktree-BlizKDpZ.mjs";
3
- import { existsSync, readFileSync, readdirSync, realpathSync } from "fs";
1
+ import { l as findEnclosingWorktreeRoot, p as getProject } from "./config-0jCcMM0E.mjs";
2
+ import { y as repoRoot } from "./worktree-DeBQSVtR.mjs";
3
+ import { existsSync, readFileSync, realpathSync } from "fs";
4
4
  import { basename, dirname, join, resolve } from "path";
5
5
  import { createRequire } from "module";
6
6
  //#region src/workspace/project.ts
@@ -176,73 +176,5 @@ function readAppConfigText(projectRoot) {
176
176
  }
177
177
  return null;
178
178
  }
179
- function detectBundleId(projectRoot) {
180
- const fromJson = readAppJson(projectRoot)?.expo?.ios?.bundleIdentifier;
181
- if (typeof fromJson === "string" && fromJson) return fromJson;
182
- const text = readAppConfigText(projectRoot);
183
- if (text) {
184
- const id = text.match(/bundleIdentifier\s*:\s*["']([^"']+)["']/)?.[1];
185
- if (id) return id;
186
- }
187
- return detectBundleIdFromPbxproj(projectRoot);
188
- }
189
- function detectAndroidPackage(projectRoot) {
190
- const fromJson = readAppJson(projectRoot)?.expo?.android?.package;
191
- if (typeof fromJson === "string" && fromJson) return fromJson;
192
- const text = readAppConfigText(projectRoot);
193
- if (text) {
194
- const pkg = text.match(/package\s*:\s*["']([^"']+)["']/)?.[1];
195
- if (pkg) return pkg;
196
- }
197
- return detectAndroidPackageFromGradle(projectRoot);
198
- }
199
- function detectBundleIdFromPbxproj(projectRoot) {
200
- const iosDir = join(projectRoot, "ios");
201
- if (!existsSync(iosDir)) return null;
202
- let entries;
203
- try {
204
- entries = readdirSync(iosDir, { withFileTypes: true });
205
- } catch {
206
- return null;
207
- }
208
- for (const entry of entries) {
209
- if (!entry.isDirectory() || !entry.name.endsWith(".xcodeproj")) continue;
210
- const pbx = join(iosDir, entry.name, "project.pbxproj");
211
- if (!existsSync(pbx)) continue;
212
- let text;
213
- try {
214
- text = readFileSync(pbx, "utf-8");
215
- } catch {
216
- continue;
217
- }
218
- const concrete = [...text.matchAll(/PRODUCT_BUNDLE_IDENTIFIER\s*=\s*([^;\s"]+)\s*;/g)].map((m) => m[1]).filter((id) => !!id && !id.startsWith("$") && !id.includes("("));
219
- if (concrete.length === 0) continue;
220
- const counts = {};
221
- for (const id of concrete) counts[id] = (counts[id] || 0) + 1;
222
- let best = null, bestCount = 0, bestLen = Infinity;
223
- for (const [id, count] of Object.entries(counts)) if (count > bestCount || count === bestCount && id.length < bestLen) {
224
- best = id;
225
- bestCount = count;
226
- bestLen = id.length;
227
- }
228
- return best;
229
- }
230
- return null;
231
- }
232
- function detectAndroidPackageFromGradle(projectRoot) {
233
- const gradle = join(projectRoot, "android", "app", "build.gradle");
234
- if (!existsSync(gradle)) return null;
235
- let text;
236
- try {
237
- text = readFileSync(gradle, "utf-8");
238
- } catch {
239
- return null;
240
- }
241
- const nsId = text.match(/namespace\s+["']([^"']+)["']/)?.[1];
242
- if (nsId) return nsId;
243
- const appId = text.match(/applicationId\s+["']([^"']+)["']/)?.[1];
244
- if (appId) return appId;
245
- return null;
246
- }
247
179
  //#endregion
248
- export { detectIsExpo as a, ownedDeviceLabel as c, detectBundleId as i, projectShortcut as l, appProjectProblem as n, findProjectRoot as o, detectAndroidPackage as r, isPackageResolvable as s, NO_PROJECT_REFUSAL as t, resolvePackageJson as u };
180
+ export { isPackageResolvable as a, readAppConfigText as c, findProjectRoot as i, readAppJson as l, appProjectProblem as n, ownedDeviceLabel as o, detectIsExpo as r, projectShortcut as s, NO_PROJECT_REFUSAL as t, resolvePackageJson as u };
@@ -1,12 +1,12 @@
1
- import { B as parseDeviceSlotKey, f as getProject, z as deviceSlotPlatforms } from "./config-BEq0Qw_a.mjs";
2
- import { h as recordWorkspaceUse, s as resolveProjectMetro } from "./metro-BWLOJ_Wr.mjs";
3
- import { o as findProjectRoot } from "./project-BXZzOABt.mjs";
4
- import { d as readWorkspaceLaunches } from "./state-WGdIbi_d.mjs";
5
- import { f as refuseNoProject, l as phaseLine } from "./command-output-D5z2_bcF.mjs";
6
- import { z as resolveOwnedAvdSerial } from "./android-787HhP5w.mjs";
7
- import { S as resolveOwnedIosSim } from "./ios-COGcGEcN.mjs";
8
- import { h as iosAppProcess, o as androidAppProcess } from "./app-install-Cfmqr3TQ.mjs";
9
- import { n as nativeRunCommand } from "./slot-launch-Dk4oTREM.mjs";
1
+ import { B as deviceSlotPlatforms, V as parseDeviceSlotKey, p as getProject } from "./config-0jCcMM0E.mjs";
2
+ import { h as recordWorkspaceUse, s as resolveProjectMetro } from "./metro-Dzo30hvJ.mjs";
3
+ import { i as findProjectRoot } from "./project-B8rbutVC.mjs";
4
+ import { f as readWorkspaceLaunches } from "./state-DcDgzfu3.mjs";
5
+ import { f as refuseNoProject, l as phaseLine } from "./command-output-BWCj5Vh-.mjs";
6
+ import { W as resolveOwnedAvdSerial } from "./android-75Sk2rIR.mjs";
7
+ import { S as resolveOwnedIosSim } from "./ios-CZWOHTTc.mjs";
8
+ import { h as iosAppProcess, o as androidAppProcess } from "./app-install-CsZi0SAT.mjs";
9
+ import { n as nativeRunCommand } from "./slot-launch-DIACGEfH.mjs";
10
10
  import chalk from "chalk";
11
11
  import { WebSocket } from "ws";
12
12
  //#region src/engine/reload.ts