@swmansion/argent 0.34.1-next.33 → 0.34.1-next.35

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.
package/dist/cli-cmds.mjs CHANGED
@@ -36256,7 +36256,7 @@ function isCi(env = process.env) {
36256
36256
  var SESSION_ID2 = randomUUID5();
36257
36257
  function readCliVersion() {
36258
36258
  if (true) {
36259
- return "0.34.1-next.33";
36259
+ return "0.34.1-next.35";
36260
36260
  }
36261
36261
  return "0.0.0";
36262
36262
  }
@@ -16942,7 +16942,7 @@ function isCi(env = process.env) {
16942
16942
  var SESSION_ID = randomUUID4();
16943
16943
  function readCliVersion() {
16944
16944
  if (true) {
16945
- return "0.34.1-next.33";
16945
+ return "0.34.1-next.35";
16946
16946
  }
16947
16947
  return "0.0.0";
16948
16948
  }
@@ -101440,7 +101440,7 @@ function isCi(env = process.env) {
101440
101440
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101441
101441
  function readCliVersion() {
101442
101442
  if (true) {
101443
- return "0.34.1-next.33";
101443
+ return "0.34.1-next.35";
101444
101444
  }
101445
101445
  return "0.0.0";
101446
101446
  }
@@ -151244,6 +151244,7 @@ init_external_devices();
151244
151244
  var import_node_crypto13 = require("node:crypto");
151245
151245
  init_src2();
151246
151246
  init_device_info();
151247
+ init_external_devices();
151247
151248
  init_macos_app_kind();
151248
151249
  function deviceKey2(target) {
151249
151250
  const logicalId = target.reactNative?.logicalDeviceId;
@@ -151275,14 +151276,37 @@ function describeDevice(target) {
151275
151276
  if (macBundleId) return `Mac app ${macBundleId} (${logicalId})`;
151276
151277
  return logicalId ? `${target.deviceName ?? "unknown"} (${logicalId})` : `${target.deviceName ?? "unknown"} (legacy inspector \u2014 no logicalDeviceId)`;
151277
151278
  }
151278
- function macosAppTargets(pool, bundleId, port) {
151279
- const own2 = pool.filter((t) => macosAppBundleIdOf(t)?.toLowerCase() === bundleId.toLowerCase());
151280
- if (own2.length) return own2;
151279
+ function metroDevices(pool) {
151281
151280
  const devices2 = /* @__PURE__ */ new Map();
151282
151281
  for (const t of pool) {
151283
151282
  const key2 = deviceKey2(t);
151284
151283
  if (key2 && !devices2.has(key2)) devices2.set(key2, describeDevice(t));
151285
151284
  }
151285
+ return devices2;
151286
+ }
151287
+ function targetsOfOnlyDeviceNamed(pool, name) {
151288
+ if (name === void 0) return void 0;
151289
+ const named = pool.filter((t) => t.deviceName === name);
151290
+ return new Set(named.map(deviceKey2)).size === 1 ? named : void 0;
151291
+ }
151292
+ function nameMetroLists(simulatorName) {
151293
+ return simulatorName.split("&")[0].replaceAll("+", " ");
151294
+ }
151295
+ async function simulatorNameOnSharedMetro(deviceId, targets) {
151296
+ if (isExternalId(deviceId)) return void 0;
151297
+ const device = resolveDevice(deviceId);
151298
+ if (device.platform !== "ios" || device.kind !== "simulator") return void 0;
151299
+ if (metroDevices(targets).size < 2) return void 0;
151300
+ const simulators = await listIosSimulators().catch(() => []);
151301
+ const booted = simulators.filter((sim) => sim.state === "Booted");
151302
+ const name = booted.find((sim) => sim.udid === deviceId)?.name;
151303
+ if (name === void 0 || nameMetroLists(name) !== name) return void 0;
151304
+ return booted.filter((sim) => nameMetroLists(sim.name) === name).length === 1 ? name : void 0;
151305
+ }
151306
+ function macosAppTargets(pool, bundleId, port) {
151307
+ const own2 = pool.filter((t) => macosAppBundleIdOf(t)?.toLowerCase() === bundleId.toLowerCase());
151308
+ if (own2.length) return own2;
151309
+ const devices2 = metroDevices(pool);
151286
151310
  const catalyst = trackedMacosAppKind(bundleId) === "catalyst";
151287
151311
  const noVendorId = catalyst && !trackedMacosAppVendorId(bundleId) ? `argent does not know the identifierForVendor of the Mac Catalyst app ${bundleId}, which React Native puts in the runtime's id: argent's library reports it when argent starts the app, and the library of this start did not. Run restart-app, then retry; if this message stays, update argent. ` : "";
151288
151312
  throw new FailureError(
@@ -151310,14 +151334,14 @@ function selectTarget(targets, port, options) {
151310
151334
  } else if (typeof options?.deviceId === "string" && options.deviceId) {
151311
151335
  const deviceId = options.deviceId;
151312
151336
  const filtered = candidates.filter((t) => t.reactNative?.logicalDeviceId === deviceId);
151337
+ const simulatorName = typeof options.simulatorName === "string" ? options.simulatorName : void 0;
151338
+ const sameName = targetsOfOnlyDeviceNamed(pool, simulatorName);
151313
151339
  if (filtered.length) {
151314
151340
  candidates = filtered;
151341
+ } else if (sameName) {
151342
+ candidates = sameName;
151315
151343
  } else {
151316
- const distinctDevices = /* @__PURE__ */ new Map();
151317
- for (const t of pool) {
151318
- const key2 = deviceKey2(t);
151319
- if (key2 && !distinctDevices.has(key2)) distinctDevices.set(key2, describeDevice(t));
151320
- }
151344
+ const distinctDevices = metroDevices(pool);
151321
151345
  if (distinctDevices.size > 1) {
151322
151346
  const listed = [...distinctDevices.values()].join(", ");
151323
151347
  throw new FailureError(
@@ -151751,7 +151775,8 @@ var jsRuntimeDebuggerBlueprint = {
151751
151775
  });
151752
151776
  const selected = selectTarget(metro.targets, port, {
151753
151777
  ...options,
151754
- deviceId
151778
+ deviceId,
151779
+ simulatorName: await simulatorNameOnSharedMetro(deviceId, metro.targets)
151755
151780
  });
151756
151781
  const onPublishedBundler = publishedMetroPort(deviceId, port) === void 0;
151757
151782
  const proxied = onPublishedBundler ? externalJsDebuggerUrl(deviceId) : void 0;
@@ -170911,12 +170936,12 @@ async function parseCpuFile(filePath, targetPid = null) {
170911
170936
  }
170912
170937
  }
170913
170938
  async function parseHangsFile(filePath) {
170914
- if (!filePath) return [];
170939
+ if (!filePath) return null;
170915
170940
  try {
170916
170941
  const xml = await import_fs8.promises.readFile(filePath, "utf8");
170917
- return parseHangsXml(xml);
170942
+ return /<node(?=[\s/>])/.test(xml) ? parseHangsXml(xml) : null;
170918
170943
  } catch {
170919
- return [];
170944
+ return null;
170920
170945
  }
170921
170946
  }
170922
170947
  async function parseLeaksFile(filePath) {
@@ -171273,12 +171298,13 @@ function aggregateLeaks(rawLeaks) {
171273
171298
 
171274
171299
  // ../tool-server/src/utils/ios-profiler/pipeline/index.ts
171275
171300
  async function runIosProfilerPipeline(files, options = {}) {
171276
- const [cpuSamples, rawHangs, rawLeaks] = await Promise.all([
171301
+ const [cpuSamples, hangsTable, rawLeaks] = await Promise.all([
171277
171302
  parseCpuFile(files.cpu ?? null, options.cpuFilterPid ?? null),
171278
171303
  parseHangsFile(files.hangs ?? null),
171279
171304
  parseLeaksFile(files.leaks ?? null)
171280
171305
  ]);
171281
171306
  for (const sample of cpuSamples) sample.stack = withAppCallsThroughArgent(sample.stack);
171307
+ const rawHangs = hangsTable ?? [];
171282
171308
  const suspensions = options.appSuspensions != null ? suspendedTimeInHangs(rawHangs, options.appSuspensions) : null;
171283
171309
  const correlated = correlateHangsWithCpu(rawHangs, cpuSamples, suspensions?.suspendedNs);
171284
171310
  const { hangSampleTimestamps } = correlated;
@@ -171292,6 +171318,7 @@ async function runIosProfilerPipeline(files, options = {}) {
171292
171318
  bottlenecks,
171293
171319
  cpuSamples,
171294
171320
  uiHangs,
171321
+ hangsRecorded: hangsTable !== null,
171295
171322
  cpuHotspots,
171296
171323
  memoryLeaks,
171297
171324
  toolingCpuMs: {
@@ -173101,9 +173128,8 @@ async function analyzeNativeProfilerIos(api) {
173101
173128
  error_kind: "validation"
173102
173129
  });
173103
173130
  }
173104
- const [cpuMissing, hangsMissing, leaksMissing] = await Promise.all([
173131
+ const [cpuMissing, leaksMissing] = await Promise.all([
173105
173132
  checkExportFileMissing(api.exportedFiles.cpu ?? null),
173106
- checkExportFileMissing(api.exportedFiles.hangs ?? null),
173107
173133
  checkExportFileMissing(api.exportedFiles.leaks ?? null)
173108
173134
  ]);
173109
173135
  const appSuspensions = api.platform === "macos" ? api.appSuspensions : null;
@@ -173111,6 +173137,7 @@ async function analyzeNativeProfilerIos(api) {
173111
173137
  bottlenecks,
173112
173138
  cpuSamples,
173113
173139
  uiHangs,
173140
+ hangsRecorded,
173114
173141
  cpuHotspots,
173115
173142
  memoryLeaks,
173116
173143
  toolingCpuMs,
@@ -173124,6 +173151,7 @@ async function analyzeNativeProfilerIos(api) {
173124
173151
  api.parsedData = {
173125
173152
  cpuSamples,
173126
173153
  uiHangs,
173154
+ hangsRecorded,
173127
173155
  cpuHotspots,
173128
173156
  memoryLeaks,
173129
173157
  leaksRecorded,
@@ -173146,8 +173174,9 @@ async function analyzeNativeProfilerIos(api) {
173146
173174
  }
173147
173175
  if (!api.exportedFiles.hangs) {
173148
173176
  exportErrors.hangs = skipped ?? "Hangs export failed \u2014 no potential-hangs table found in trace.";
173149
- } else if (hangsMissing) {
173150
- exportErrors.hangs = `Hangs export ${hangsMissing} \u2014 the trace export claims it succeeded but the file is gone or unreadable, so no hang data could be analyzed. Re-run native-profiler-stop.`;
173177
+ } else if (!hangsRecorded) {
173178
+ const hangsMissing = await checkExportFileMissing(api.exportedFiles.hangs);
173179
+ exportErrors.hangs = hangsMissing ? `Hangs export ${hangsMissing} \u2014 no hang data could be analyzed. Re-run native-profiler-stop.` : `Could not read a potential-hangs table from \`${api.exportedFiles.hangs}\`.`;
173151
173180
  }
173152
173181
  if (api.exportedFiles.leaks && leaksMissing) {
173153
173182
  exportErrors.leaks = `Leaks export ${leaksMissing} \u2014 the trace export claims it succeeded but the file is gone or unreadable, so no leak data could be analyzed. Re-run native-profiler-stop.`;
@@ -179175,6 +179204,7 @@ Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-pr
179175
179204
  init_zod();
179176
179205
  init_src2();
179177
179206
  init_device_info();
179207
+ var HANGS_NOT_RECORDED = "_No UI hang data was recorded._";
179178
179208
  var stackQueryMode = {
179179
179209
  hang_stacks: "hang stacks",
179180
179210
  function_callers: "function callers",
@@ -179303,7 +179333,7 @@ function renderFunctionCallersIos(cpuSamples, functionName, topN2) {
179303
179333
  }
179304
179334
  return lines.join("\n");
179305
179335
  }
179306
- function renderThreadBreakdownIos(cpuSamples, cpuHotspots, threadFilter, topN2) {
179336
+ function renderThreadBreakdownIos(cpuSamples, cpuHotspots, threadFilter, topN2, hangsRecorded = true) {
179307
179337
  const threadWeight = /* @__PURE__ */ new Map();
179308
179338
  const threadSamples = /* @__PURE__ */ new Map();
179309
179339
  for (const sample of cpuSamples) {
@@ -179319,10 +179349,10 @@ function renderThreadBreakdownIos(cpuSamples, cpuHotspots, threadFilter, topN2)
179319
179349
  }
179320
179350
  const lines = [
179321
179351
  `## Thread CPU Breakdown${threadFilter ? ` (filter: "${threadFilter}")` : ""}`,
179322
- "",
179323
- "| Thread | Weight (ms) | % | Samples |",
179324
- "|---|---|---|---|"
179352
+ ""
179325
179353
  ];
179354
+ if (!hangsRecorded) lines.push(HANGS_NOT_RECORDED, "");
179355
+ lines.push("| Thread | Weight (ms) | % | Samples |", "|---|---|---|---|");
179326
179356
  for (const [thread, weight] of sorted) {
179327
179357
  const weightMs = Math.round(weight / 1e6);
179328
179358
  const pct = totalWeight > 0 ? (weight / totalWeight * 100).toFixed(1) : "0";
@@ -179340,8 +179370,9 @@ function renderThreadBreakdownIos(cpuSamples, cpuHotspots, threadFilter, topN2)
179340
179370
  lines.push("| Function | Weight (ms) | % | During Hang |");
179341
179371
  lines.push("|---|---|---|---|");
179342
179372
  for (const h of threadHotspots.slice(0, topN2)) {
179373
+ const hangStatus = hangsRecorded ? h.duringHang ? "Yes" : "No" : "Not recorded";
179343
179374
  lines.push(
179344
- `| \`${escapeMarkdownTableCell(demangleSymbol(h.dominantFunction))}\` | ${h.totalWeightMs} | ${h.weightPercentage}% | ${h.duringHang ? "Yes" : "No"} |`
179375
+ `| \`${escapeMarkdownTableCell(demangleSymbol(h.dominantFunction))}\` | ${h.totalWeightMs} | ${h.weightPercentage}% | ${hangStatus} |`
179345
179376
  );
179346
179377
  }
179347
179378
  }
@@ -179408,6 +179439,7 @@ async function executeIos(api, params) {
179408
179439
  error_kind: "validation"
179409
179440
  });
179410
179441
  }
179442
+ if (!data.hangsRecorded) return HANGS_NOT_RECORDED;
179411
179443
  return renderHangStacksIos(data.cpuSamples, data.uiHangs, params.hang_index, params.top_n);
179412
179444
  }
179413
179445
  case "function_callers": {
@@ -179426,7 +179458,8 @@ async function executeIos(api, params) {
179426
179458
  data.cpuSamples,
179427
179459
  data.cpuHotspots,
179428
179460
  params.thread,
179429
- params.top_n
179461
+ params.top_n,
179462
+ data.hangsRecorded
179430
179463
  );
179431
179464
  case "leak_stacks":
179432
179465
  return renderLeakStacksIos(
@@ -179633,6 +179666,7 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
179633
179666
  );
179634
179667
  }
179635
179668
  let uiHangs;
179669
+ let hangsRecorded = true;
179636
179670
  let memoryLeaks;
179637
179671
  let leaksRecorded;
179638
179672
  if (nativeApi.platform === "android") {
@@ -179661,6 +179695,7 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
179661
179695
  });
179662
179696
  }
179663
179697
  uiHangs = nativeApi.parsedData.uiHangs;
179698
+ hangsRecorded = nativeApi.parsedData.hangsRecorded;
179664
179699
  memoryLeaks = nativeApi.parsedData.memoryLeaks;
179665
179700
  leaksRecorded = nativeApi.parsedData.leaksRecorded;
179666
179701
  }
@@ -179759,7 +179794,7 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
179759
179794
  "React Profiler + Native Profiler \u2014 Cross-Tool Correlation",
179760
179795
  "",
179761
179796
  `**React Profiler:** ${nonMarginCommits.length} hot commits `,
179762
- `**Native Profiler:** ${uiHangs.length} hangs, ` + (leaksRecorded ? `${memoryLeaks.length} leaks` : `leaks not recorded`),
179797
+ `**Native Profiler:** ${hangsRecorded ? `${uiHangs.length} hangs` : "hangs not recorded"}, ` + (leaksRecorded ? `${memoryLeaks.length} leaks` : `leaks not recorded`),
179763
179798
  "",
179764
179799
  `**Clock offset:** React started ${(Math.abs(reactWallStart - nativeWallStart) / 1e3).toFixed(1)}s ${reactWallStart > nativeWallStart ? "after" : "before"} native profiler`,
179765
179800
  ""
@@ -180220,12 +180255,13 @@ async function loadNativeSession(debugDir, sessionId, api, appProcessOverride) {
180220
180255
  path56.join(debugDir, `native-profiler-${sessionId}.trace`)
180221
180256
  );
180222
180257
  const appSuspensions = metadata?.appSuspensions ?? null;
180223
- const { cpuSamples, uiHangs, cpuHotspots, memoryLeaks } = await runIosProfilerPipeline(files, {
180258
+ const { cpuSamples, uiHangs, hangsRecorded, cpuHotspots, memoryLeaks } = await runIosProfilerPipeline(files, {
180224
180259
  appSuspensions
180225
180260
  });
180226
180261
  api.parsedData = {
180227
180262
  cpuSamples,
180228
180263
  uiHangs,
180264
+ hangsRecorded,
180229
180265
  cpuHotspots,
180230
180266
  memoryLeaks,
180231
180267
  // Stop writes no raw_leaks.xml when the trace had no Leaks table.
@@ -180246,7 +180282,7 @@ async function loadNativeSession(debugDir, sessionId, api, appProcessOverride) {
180246
180282
  `Loaded native profiler session \`${sessionId}\`.`,
180247
180283
  "",
180248
180284
  `- CPU samples: ${cpuSamples.length}`,
180249
- `- UI hangs: ${files.hangs ? uiHangs.length : "not recorded"}`,
180285
+ `- UI hangs: ${hangsRecorded ? uiHangs.length : "not recorded"}`,
180250
180286
  `- CPU hotspots: ${cpuHotspots.length}`,
180251
180287
  `- Memory leaks: ${files.leaks ? memoryLeaks.length : "not recorded"}`,
180252
180288
  "",
@@ -180496,7 +180532,7 @@ function createStopAllSimulatorServersTool(registry2) {
180496
180532
  id: "stop-all-simulator-servers",
180497
180533
  description: `Stop the services a device owns - simulator-server processes (iOS + Android), native devtools, the iOS accessibility service, TV-control daemons, Chromium CDP sessions, screen recordings, native profiler sessions, Android native network capture (started by native-network-logs), and JS-runtime debugger sessions along with the network inspectors and React profiler sessions that ride on them - freeing their spawned processes, sockets and ports. Call this when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services mid-flow - not just because a task finished, since the next task reuses these services and would start cold again. To end only the native network capture of one app, call native-network-logs with stop: true instead.
180498
180534
  PASS \`devices\` with the device ids this session used: one tool-server serves every agent, subagent and CLI call using this argent install, and an unscoped call tears down THEIR devices too. Omit \`devices\` only when a machine-wide cleanup is what you actually want. An EMPTY array stops nothing; it does not ask for the machine-wide sweep.
180499
- A JS-runtime debugger session is keyed by the id you called \`debugger-connect\` with. On a Metro serving two or more devices that id is not a udid or serial - connect refuses those and tells you to re-target with the \`logicalDeviceId\` it returns - so a scope built from \`list-devices\` ids cannot reach that session. Pass any such \`logicalDeviceId\` in \`devices\` ALONGSIDE the device id.
180535
+ A JS-runtime debugger session is keyed by the id you called \`debugger-connect\` with. On a Metro serving two or more devices that id can be a \`logicalDeviceId\`: connect refuses a serial, or a simulator udid it cannot match to one Metro device by name, and tells you to re-target with the \`logicalDeviceId\` it returns. A scope built from \`list-devices\` ids cannot reach that session. Pass any such \`logicalDeviceId\` in \`devices\` ALONGSIDE the device id.
180500
180536
  Returns { stopped }: the URNs of the live services that were shut down; empty means nothing was still running. { unmatched }, present only when a supplied id owns no service here, lists those ids, so a typo or a device NAME passed instead of an id does not read as a clean machine. It is NOT proof the id is wrong: a Vega device you only booted and drove with the remote registers no service and lands here, as does any device this session never started anything on. { left_running } lists the URNs of live debugger sessions (and the network inspectors / React profiler sessions riding on them) whose id no device scope can name; re-call with the id after each URN's \`<namespace>:<port>:\` prefix to reap them. { aborted: true } means the request was cancelled part-way: the rest was left untouched and \`unmatched\` / \`left_running\` were not computed.
180501
180537
  Fails if the input has an unknown key (e.g. \`udids\` instead of \`devices\`); otherwise it always succeeds, and reaping nothing is a result, not a failure.`,
180502
180538
  zodSchema: zodSchema66,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.34.1-next.33",
3
+ "version": "0.34.1-next.35",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",
@@ -14,7 +14,7 @@ Physical iPhone: not supported; every `debugger-*` tool rejects `kind: "device"`
14
14
 
15
15
  ## 2. Tools
16
16
 
17
- Pass the same `device_id`, the id from `list-devices`, to every call. With two or more devices on one Metro, `debugger-connect` refuses a udid or serial and returns a `logicalDeviceId`: use that as `device_id` from then on, and include it in `stop-all-simulator-servers`' `devices` at teardown, or the debugger session outlives yours.
17
+ Pass the same `device_id`, the id from `list-devices`, to every call. With two or more devices on one Metro, `debugger-connect` refuses a serial, or a simulator udid it cannot match to one Metro device by name, and returns a `logicalDeviceId`: use that as `device_id` from then on, and include it in `stop-all-simulator-servers`' `devices` at teardown, or the debugger session outlives yours.
18
18
 
19
19
  | Tool | Use for |
20
20
  | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |