@swmansion/argent 0.33.1-next.24 → 0.33.1-next.25

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
@@ -36070,7 +36070,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
36070
36070
  var SESSION_ID2 = randomUUID5();
36071
36071
  function readCliVersion() {
36072
36072
  if (true) {
36073
- return "0.33.1-next.24";
36073
+ return "0.33.1-next.25";
36074
36074
  }
36075
36075
  return "0.0.0";
36076
36076
  }
@@ -16987,7 +16987,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16987
16987
  var SESSION_ID = randomUUID4();
16988
16988
  function readCliVersion() {
16989
16989
  if (true) {
16990
- return "0.33.1-next.24";
16990
+ return "0.33.1-next.25";
16991
16991
  }
16992
16992
  return "0.0.0";
16993
16993
  }
@@ -618,13 +618,13 @@ export interface ArgentToolArgs {
618
618
  "profiler-combined-report": {
619
619
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
620
620
  port?: number;
621
- /** iOS Simulator/device UDID or Android serial */
621
+ /** Device ID from list-devices used for the native profile (iOS simulator UDID, Android serial, or Mac app ID). */
622
622
  device_id: string;
623
623
  };
624
624
  "profiler-commit-query": {
625
625
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
626
626
  port?: number;
627
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
627
+ /** Device ID used to record or load the React profile. For a Mac app, use its ID from list-devices. */
628
628
  device_id: string;
629
629
  /** Query mode; see Modes in the tool description. */
630
630
  mode: "by_component" | "by_time_range" | "by_index" | "cascade_tree" | "render_counts";
@@ -645,7 +645,7 @@ export interface ArgentToolArgs {
645
645
  "profiler-cpu-query": {
646
646
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
647
647
  port?: number;
648
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
648
+ /** Device ID used to record or load the React profile. For a Mac app, use its ID from list-devices. */
649
649
  device_id: string;
650
650
  /** Query mode; see Modes in the tool description. */
651
651
  mode: "top_functions" | "time_window" | "call_tree" | "component_cpu";
@@ -731,12 +731,12 @@ export interface ArgentToolArgs {
731
731
  "react-profiler-analyze": {
732
732
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
733
733
  port?: number;
734
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
734
+ /** Device ID used to record or load the React profile. For a Mac app, use its ID from list-devices. */
735
735
  device_id: string;
736
736
  /** Absolute path to the RN project root for session context detection */
737
737
  project_root: string;
738
- /** Target platform */
739
- platform?: "ios" | "android";
738
+ /** Platform for source lookup when the recording does not identify one. */
739
+ platform?: "ios" | "android" | "macos";
740
740
  /** React Native version (e.g. "0.73.4") */
741
741
  rn_version?: string;
742
742
  /** User actions to annotate the report's commits with: each commit shows the action that preceded it. */
@@ -756,7 +756,7 @@ export interface ArgentToolArgs {
756
756
  "react-profiler-cpu-summary": {
757
757
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
758
758
  port?: number;
759
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
759
+ /** Device ID used to record or load the React profile. For a Mac app, use its ID from list-devices. */
760
760
  device_id: string;
761
761
  /** Number of top hotspot functions to return */
762
762
  top_n?: number;
@@ -766,7 +766,7 @@ export interface ArgentToolArgs {
766
766
  "react-profiler-fiber-tree": {
767
767
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
768
768
  port?: number;
769
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
769
+ /** Device ID of the app to inspect. For a Mac app, use its ID from list-devices. During a recording, use the ID passed to react-profiler-start. */
770
770
  device_id: string;
771
771
  /** Maximum tree depth to traverse */
772
772
  max_depth?: number;
@@ -776,7 +776,7 @@ export interface ArgentToolArgs {
776
776
  "react-profiler-renders": {
777
777
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
778
778
  port?: number;
779
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
779
+ /** Device ID of the app to inspect. For a Mac app, use its ID from list-devices. During a recording, use the ID passed to react-profiler-start. */
780
780
  device_id: string;
781
781
  /** Number of components to return */
782
782
  top_n?: number;
@@ -784,7 +784,7 @@ export interface ArgentToolArgs {
784
784
  "react-profiler-start": {
785
785
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
786
786
  port?: number;
787
- /** Device id from list-devices: the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial). */
787
+ /** Device ID from list-devices, including a Mac app ID. For iOS or Android on a shared Metro, use the target's logicalDeviceId if asked to disambiguate. */
788
788
  device_id: string;
789
789
  /** CPU sampling interval in microseconds */
790
790
  sample_interval_us?: number;
@@ -794,13 +794,13 @@ export interface ArgentToolArgs {
794
794
  "react-profiler-status": {
795
795
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
796
796
  port?: number;
797
- /** Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId). */
797
+ /** Device ID of the app to inspect. For a Mac app, use its ID from list-devices. During a recording, use the ID passed to react-profiler-start. */
798
798
  device_id: string;
799
799
  };
800
800
  "react-profiler-stop": {
801
801
  /** Metro port. Omit it to use this device's port (8081 by default). Ignored for Chromium, whose CDP port is in device_id. */
802
802
  port?: number;
803
- /** Device id from list-devices: the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial). */
803
+ /** Device ID passed to react-profiler-start. For a Mac app, use its ID from list-devices. */
804
804
  device_id: string;
805
805
  };
806
806
  "reinstall-app": {
@@ -82212,7 +82212,7 @@ var require_websocket = __commonJS({
82212
82212
  var http6 = require("http");
82213
82213
  var net10 = require("net");
82214
82214
  var tls = require("tls");
82215
- var { randomBytes: randomBytes2, createHash: createHash6 } = require("crypto");
82215
+ var { randomBytes: randomBytes2, createHash: createHash7 } = require("crypto");
82216
82216
  var { Duplex, Readable: Readable2 } = require("stream");
82217
82217
  var { URL: URL2 } = require("url");
82218
82218
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -82893,7 +82893,7 @@ var require_websocket = __commonJS({
82893
82893
  abortHandshake(websocket, socket, "Invalid Upgrade header");
82894
82894
  return;
82895
82895
  }
82896
- const digest = createHash6("sha1").update(key2 + GUID).digest("base64");
82896
+ const digest = createHash7("sha1").update(key2 + GUID).digest("base64");
82897
82897
  if (res.headers["sec-websocket-accept"] !== digest) {
82898
82898
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
82899
82899
  return;
@@ -83262,7 +83262,7 @@ var require_websocket_server = __commonJS({
83262
83262
  var EventEmitter2 = require("events");
83263
83263
  var http6 = require("http");
83264
83264
  var { Duplex } = require("stream");
83265
- var { createHash: createHash6 } = require("crypto");
83265
+ var { createHash: createHash7 } = require("crypto");
83266
83266
  var extension2 = require_extension();
83267
83267
  var PerMessageDeflate2 = require_permessage_deflate();
83268
83268
  var subprotocol2 = require_subprotocol();
@@ -83569,7 +83569,7 @@ var require_websocket_server = __commonJS({
83569
83569
  );
83570
83570
  }
83571
83571
  if (this._state > RUNNING) return abortHandshake(socket, 503);
83572
- const digest = createHash6("sha1").update(key2 + GUID).digest("base64");
83572
+ const digest = createHash7("sha1").update(key2 + GUID).digest("base64");
83573
83573
  const headers = [
83574
83574
  "HTTP/1.1 101 Switching Protocols",
83575
83575
  "Upgrade: websocket",
@@ -101279,7 +101279,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
101279
101279
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
101280
101280
  function readCliVersion() {
101281
101281
  if (true) {
101282
- return "0.33.1-next.24";
101282
+ return "0.33.1-next.25";
101283
101283
  }
101284
101284
  return "0.0.0";
101285
101285
  }
@@ -144063,6 +144063,10 @@ var RN_ONLY_TOOL_CAPABILITY = {
144063
144063
  appleRemote: { simulator: true },
144064
144064
  android: { emulator: true, device: true, unknown: true }
144065
144065
  };
144066
+ var REACT_PROFILER_TOOL_CAPABILITY = {
144067
+ ...RN_ONLY_TOOL_CAPABILITY,
144068
+ macos: { app: true }
144069
+ };
144066
144070
  function debuggerServiceRef(params) {
144067
144071
  const deviceId = canonicalDeviceId(params.device_id);
144068
144072
  if (deviceId && deviceId.startsWith(CHROMIUM_ID_PREFIX)) {
@@ -147602,7 +147606,9 @@ init_device_info();
147602
147606
  init_external_devices();
147603
147607
 
147604
147608
  // ../tool-server/src/utils/debugger/target-selection.ts
147609
+ var import_node_crypto13 = require("node:crypto");
147605
147610
  init_src2();
147611
+ init_device_info();
147606
147612
  function deviceKey(target) {
147607
147613
  const logicalId = target.reactNative?.logicalDeviceId;
147608
147614
  if (logicalId) return logicalId;
@@ -147613,12 +147619,41 @@ function deviceKey(target) {
147613
147619
  }
147614
147620
  return target.deviceName;
147615
147621
  }
147616
- var seenLogicalDeviceIds = /* @__PURE__ */ new Set();
147617
- function listDevices(devices) {
147618
- return [...devices].map(
147619
- (d) => d.logicalId ? `${d.name ?? "unknown"} (${d.logicalId})` : `${d.name ?? "unknown"} (legacy inspector \u2014 no logicalDeviceId)`
147620
- ).join(", ");
147622
+ function macosAppBundleIdOf(target) {
147623
+ const logicalId = target.reactNative?.logicalDeviceId;
147624
+ const bundleId = target.appId ?? target.description;
147625
+ if (!logicalId || !bundleId) return void 0;
147626
+ for (const mode of ["fusebox", "legacy"]) {
147627
+ const id = (0, import_node_crypto13.createHash)("sha256").update(`apple--${bundleId}-${mode}`).digest("hex").slice(0, 40);
147628
+ if (id === logicalId) return bundleId;
147629
+ }
147630
+ return void 0;
147631
+ }
147632
+ function describeDevice(target) {
147633
+ const macBundleId = macosAppBundleIdOf(target);
147634
+ const logicalId = target.reactNative?.logicalDeviceId;
147635
+ if (macBundleId) return `Mac app ${macBundleId} (${logicalId})`;
147636
+ return logicalId ? `${target.deviceName ?? "unknown"} (${logicalId})` : `${target.deviceName ?? "unknown"} (legacy inspector \u2014 no logicalDeviceId)`;
147637
+ }
147638
+ function macosAppTargets(pool, bundleId, port) {
147639
+ const own2 = pool.filter((t) => macosAppBundleIdOf(t)?.toLowerCase() === bundleId.toLowerCase());
147640
+ if (own2.length) return own2;
147641
+ const devices = /* @__PURE__ */ new Map();
147642
+ for (const t of pool) {
147643
+ const key2 = deviceKey(t);
147644
+ if (key2 && !devices.has(key2)) devices.set(key2, describeDevice(t));
147645
+ }
147646
+ throw new FailureError(
147647
+ `No JS runtime of the Mac app ${bundleId} is connected to Metro on port ${port}. Metro lists: ${[...devices.values()].join(", ")}. If the app does not run, start it (launch-app), wait a few seconds for the bundle to load, then retry. Otherwise the app must be a Debug build of react-native-macos 0.76 or later that loads its bundle from this Metro; a Release build has no JS debugger. If the app uses another Metro, pass that port.`,
147648
+ {
147649
+ error_code: FAILURE_CODES.DEBUGGER_TARGET_DEVICE_MISMATCH,
147650
+ failure_stage: "debugger_select_target",
147651
+ failure_area: "tool_server",
147652
+ error_kind: "not_found"
147653
+ }
147654
+ );
147621
147655
  }
147656
+ var seenLogicalDeviceIds = /* @__PURE__ */ new Set();
147622
147657
  function selectTarget(targets, port, options) {
147623
147658
  const pool = targets;
147624
147659
  for (const t of pool) {
@@ -147626,7 +147661,10 @@ function selectTarget(targets, port, options) {
147626
147661
  if (id) seenLogicalDeviceIds.add(id);
147627
147662
  }
147628
147663
  let candidates = pool;
147629
- if (typeof options?.deviceId === "string" && options.deviceId) {
147664
+ const macosBundleId = typeof options?.deviceId === "string" && options.deviceId.startsWith(MACOS_APP_ID_PREFIX) ? options.deviceId.slice(MACOS_APP_ID_PREFIX.length) : null;
147665
+ if (macosBundleId !== null) {
147666
+ candidates = macosAppTargets(pool, macosBundleId, port);
147667
+ } else if (typeof options?.deviceId === "string" && options.deviceId) {
147630
147668
  const deviceId = options.deviceId;
147631
147669
  const filtered = candidates.filter((t) => t.reactNative?.logicalDeviceId === deviceId);
147632
147670
  if (filtered.length) {
@@ -147635,15 +147673,10 @@ function selectTarget(targets, port, options) {
147635
147673
  const distinctDevices = /* @__PURE__ */ new Map();
147636
147674
  for (const t of pool) {
147637
147675
  const key2 = deviceKey(t);
147638
- if (key2 && !distinctDevices.has(key2)) {
147639
- distinctDevices.set(key2, {
147640
- name: t.deviceName,
147641
- logicalId: t.reactNative?.logicalDeviceId
147642
- });
147643
- }
147676
+ if (key2 && !distinctDevices.has(key2)) distinctDevices.set(key2, describeDevice(t));
147644
147677
  }
147645
147678
  if (distinctDevices.size > 1) {
147646
- const listed = listDevices(distinctDevices.values());
147679
+ const listed = [...distinctDevices.values()].join(", ");
147647
147680
  throw new FailureError(
147648
147681
  `No debugger target matches device_id "${deviceId}". ${distinctDevices.size} devices are connected to Metro on port ${port}: ${listed}. Re-target with the logicalDeviceId in parentheses \u2014 that is what debugger-connect returns and what subsequent debugger-* calls must pass. A legacy-inspector device (RN 0.72 / Vega) reports none and cannot be singled out of a shared Metro: give it its own Metro port.`,
147649
147682
  {
@@ -147656,7 +147689,7 @@ function selectTarget(targets, port, options) {
147656
147689
  }
147657
147690
  if (seenLogicalDeviceIds.has(deviceId)) {
147658
147691
  throw new FailureError(
147659
- `Device with logicalDeviceId "${deviceId}" is no longer attached to Metro on port ${port} \u2014 its app likely exited or reloaded onto another Metro. Not falling back to the remaining device: ${listDevices(distinctDevices.values())}. If the app exited, relaunch it on the target device (launch-app / restart-app), then retry with the same id: a relaunched app keeps its logicalDeviceId. If it was reinstalled (reinstall-app), iOS can give it a new logicalDeviceId: when the device listed above is your target, retry with the id shown for it.`,
147692
+ `Device with logicalDeviceId "${deviceId}" is no longer attached to Metro on port ${port} \u2014 its app likely exited or reloaded onto another Metro. Not falling back to the remaining device: ${[...distinctDevices.values()].join(", ")}. If the app exited, relaunch it on the target device (launch-app / restart-app), then retry with the same id: a relaunched app keeps its logicalDeviceId. If it was reinstalled (reinstall-app), iOS can give it a new logicalDeviceId: when the device listed above is your target, retry with the id shown for it.`,
147660
147693
  {
147661
147694
  error_code: FAILURE_CODES.DEBUGGER_METRO_NO_TARGETS,
147662
147695
  failure_stage: "debugger_select_target",
@@ -158184,7 +158217,7 @@ init_device_info();
158184
158217
  init_capability();
158185
158218
 
158186
158219
  // ../tool-server/src/utils/sub-invoke.ts
158187
- var import_node_crypto13 = require("node:crypto");
158220
+ var import_node_crypto14 = require("node:crypto");
158188
158221
  init_src2();
158189
158222
  async function invokeSubTool(registry2, ctx, toolId, args, extra) {
158190
158223
  const signal = ctx?.signal;
@@ -158198,7 +158231,7 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
158198
158231
  if (!recordChildInvocation) {
158199
158232
  return signal || Object.keys(forwarded).length > 0 ? registry2.invokeTool(toolId, args, { ...signal ? { signal } : {}, ...forwarded }) : registry2.invokeTool(toolId, args);
158200
158233
  }
158201
- const toolInvocationId = (0, import_node_crypto13.randomUUID)();
158234
+ const toolInvocationId = (0, import_node_crypto14.randomUUID)();
158202
158235
  const release2 = recordChildInvocation(toolInvocationId, args);
158203
158236
  try {
158204
158237
  return await registry2.invokeTool(toolId, args, {
@@ -162207,7 +162240,7 @@ init_zod();
162207
162240
  init_src2();
162208
162241
 
162209
162242
  // ../tool-server/src/utils/debugger/runtime-device.ts
162210
- var import_node_crypto14 = require("node:crypto");
162243
+ var import_node_crypto15 = require("node:crypto");
162211
162244
  var import_node_child_process46 = require("node:child_process");
162212
162245
  var import_node_util35 = require("node:util");
162213
162246
  init_adb();
@@ -162215,7 +162248,7 @@ var execFileAsync35 = (0, import_node_util35.promisify)(import_node_child_proces
162215
162248
  var LOG_READ_TIMEOUT_MS = 5e3;
162216
162249
  var RETRY_DELAY_MS = 300;
162217
162250
  async function findRuntimeDevice(cdp) {
162218
- const marker = `argent-device-probe:${(0, import_node_crypto14.randomUUID)()}`;
162251
+ const marker = `argent-device-probe:${(0, import_node_crypto15.randomUUID)()}`;
162219
162252
  const logged = await cdp.evaluate(
162220
162253
  `(function () {
162221
162254
  if (typeof nativeLoggingHook !== "function") return false;
@@ -162394,7 +162427,7 @@ function safeGetState(registry2, urn) {
162394
162427
  var zodSchema45 = external_exports.object({
162395
162428
  port: metroPortField,
162396
162429
  device_id: external_exports.string().describe(
162397
- "Device id from list-devices: the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial)."
162430
+ "Device ID from list-devices<flag:macos-apps>, including a Mac app ID</flag:macos-apps>. For iOS or Android on a shared Metro, use the target's logicalDeviceId if asked to disambiguate."
162398
162431
  ),
162399
162432
  sample_interval_us: external_exports.coerce.number().int().positive().default(100).describe("CPU sampling interval in microseconds"),
162400
162433
  force: external_exports.boolean().default(false).describe(
@@ -162404,9 +162437,8 @@ var zodSchema45 = external_exports.object({
162404
162437
  function createReactProfilerStartTool(registry2) {
162405
162438
  return {
162406
162439
  id: "react-profiler-start",
162407
- description: `Start CPU profiling + React commit capture on the connected Hermes runtime.
162408
- Use when you need to profile a user interaction.
162409
- On an iOS simulator or Android device, also call native-profiler-start in the same message with the same device_id, unless the user has said no to native profiling. profiler-combined-report then correlates the two.
162440
+ description: `Record Hermes CPU samples and React commits during an interaction.<flag:macos-apps> For a Mac app, use a react-native-macos 0.76+ Debug build that loads JavaScript from Metro. The profiler connects without debugger-connect.</flag:macos-apps>
162441
+ On an iOS simulator, Android device<flag:macos-apps>, or Mac app</flag:macos-apps>, call native-profiler-start in parallel on the same target for a combined report, unless the user declines native profiling.
162410
162442
  After starting, ask the user to perform the interaction to profile, then call react-profiler-stop.
162411
162443
  Returns { started_at, startedAtEpochMs, hermes_version, detected_architecture }. On Android, a warning names the apps with native network capture on (started by native-network-logs): their timings in the profile can differ. If a session is already running, returns { already_running: true, mine, owner, \u2026 } instead, without clobbering its data, unless it is another tool-server's stale run, has no owner record, or is a lost run of this tool-server: start replaces those. mine: true means this tool-server started the run: if it is yours, call react-profiler-stop. With stale: true it may be another agent's: follow the note. Otherwise, BEFORE OVERTAKING with { force: true }, ask the user for approval first, as how_to_reclaim explains. A start that replaces a run reports it in took_over.
162412
162444
  Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot be established.`,
@@ -162416,7 +162448,7 @@ Fails if the Hermes runtime is not reachable or the Metro CDP connection cannot
162416
162448
  completedMsg: ({ result }) => result.already_running ? "React profiler was already running" : "Started React profiler",
162417
162449
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to start React profiler: ${failureSignal2.error_code}`
162418
162450
  },
162419
- capability: RN_ONLY_TOOL_CAPABILITY,
162451
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
162420
162452
  services: () => ({}),
162421
162453
  async execute(_services, params) {
162422
162454
  const deviceId = canonicalDeviceId(params.device_id);
@@ -163477,7 +163509,7 @@ function stopInProgressError() {
163477
163509
  var zodSchema46 = external_exports.object({
163478
163510
  port: metroPortField,
163479
163511
  device_id: external_exports.string().describe(
163480
- "Device id from list-devices: the SAME id you passed to debugger-connect (iOS simulator UDID or Android serial)."
163512
+ "Device ID passed to react-profiler-start<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>."
163481
163513
  )
163482
163514
  });
163483
163515
  function createReactProfilerStopTool(registry2) {
@@ -163498,7 +163530,7 @@ Fails if no active profiling session exists, another stop is running, the CDP co
163498
163530
  completedMsg: () => "Stopped React profiler",
163499
163531
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to stop React profiler: ${failureSignal2.error_code}`
163500
163532
  },
163501
- capability: RN_ONLY_TOOL_CAPABILITY,
163533
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
163502
163534
  services: () => ({}),
163503
163535
  async execute(_services, params) {
163504
163536
  const port = metroPort(params);
@@ -163787,13 +163819,21 @@ init_zod();
163787
163819
  var zodSchema47 = external_exports.object({
163788
163820
  port: metroPortField,
163789
163821
  device_id: external_exports.string().describe(
163790
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
163822
+ "Device ID of the app to inspect<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>. During a recording, use the ID passed to react-profiler-start."
163791
163823
  )
163792
163824
  });
163825
+ function innermostMessage(err) {
163826
+ let current = err;
163827
+ for (let depth = 0; depth < 8 && current instanceof Error; depth++) {
163828
+ if (!(current.cause instanceof Error)) return current.message;
163829
+ current = current.cause;
163830
+ }
163831
+ return current instanceof Error ? current.message : String(current);
163832
+ }
163793
163833
  function createReactProfilerStatusTool(registry2) {
163794
163834
  return {
163795
163835
  id: "react-profiler-status",
163796
- description: `Check the state of the React profiler session. Use when resuming after an interruption (debugger disconnect, unexpected error, agent pause) to decide whether to continue with react-profiler-stop, start a new session, or reconnect the debugger. Returns { session_status, is_running, current_owner, note, \u2026 }: session_status is active, saved, lost, taken_over, not_started or no_react_runtime, and note says what to do next.`,
163836
+ description: `Check whether a React recording is running, saved, lost, or taken over. Use after an interruption to decide whether to collect the recording or start again. If the runtime is unavailable, session_status is no_react_runtime and note gives the reason.`,
163797
163837
  zodSchema: zodSchema47,
163798
163838
  readOnly: true,
163799
163839
  interaction: {
@@ -163802,7 +163842,7 @@ function createReactProfilerStatusTool(registry2) {
163802
163842
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to check React profiler: ${failureSignal2.error_code}`
163803
163843
  },
163804
163844
  // RN-only: companion to react-profiler-start.
163805
- capability: RN_ONLY_TOOL_CAPABILITY,
163845
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
163806
163846
  services: () => ({}),
163807
163847
  async execute(_services, params) {
163808
163848
  const port = metroPort(params);
@@ -163831,9 +163871,9 @@ function createReactProfilerStatusTool(registry2) {
163831
163871
  let api;
163832
163872
  try {
163833
163873
  api = await registry2.resolveService(psUrn);
163834
- } catch {
163874
+ } catch (err) {
163835
163875
  return noRuntime(
163836
- "Unable to resolve a React profiler session \u2014 the Hermes runtime may not be reachable. Reconnect the debugger and retry."
163876
+ `Unable to resolve a React profiler session: the Hermes runtime may not be reachable. ${innermostMessage(err)}`
163837
163877
  );
163838
163878
  }
163839
163879
  const stopInProgress2 = () => ({
@@ -163993,6 +164033,7 @@ init_zod();
163993
164033
  var import_fs5 = require("fs");
163994
164034
  var import_path6 = require("path");
163995
164035
  init_src2();
164036
+ init_capability();
163996
164037
 
163997
164038
  // ../tool-server/src/utils/react-profiler/pipeline/session-context.ts
163998
164039
  var import_fs2 = require("fs");
@@ -164057,7 +164098,9 @@ async function detectSessionContext(input2) {
164057
164098
  }
164058
164099
  }
164059
164100
  } else {
164060
- const podfile = await readFileSafe((0, import_path3.join)(projectRoot, "ios", "Podfile"));
164101
+ const podfile = await readFileSafe(
164102
+ (0, import_path3.join)(projectRoot, platform === "macos" ? "macos" : "ios", "Podfile")
164103
+ );
164061
164104
  if (podfile) {
164062
164105
  if (newArchDefault && (podfile.includes("RCT_NEW_ARCH_ENABLED'] = '0'") || podfile.includes("RCT_NEW_ARCH_ENABLED=0"))) {
164063
164106
  rnArchitecture = "bridge";
@@ -164692,7 +164735,7 @@ function collectMemoizedNames(root) {
164692
164735
  visit2(root);
164693
164736
  return names;
164694
164737
  }
164695
- var PLATFORM_SUFFIX = /\.(web|ios|android|native)\.[jt]sx?$/;
164738
+ var PLATFORM_SUFFIX = /\.(web|ios|android|macos|native)\.[jt]sx?$/;
164696
164739
  var EXTENSION = /\.[jt]sx?$/;
164697
164740
  var NOT_APP_CODE = /\.(test|spec|stories)\.[jt]sx?$/;
164698
164741
  var NOT_BUNDLED = 3;
@@ -165450,7 +165493,7 @@ async function fileArtifact(store, p, kind) {
165450
165493
  }
165451
165494
  function recordedPlatform(profile) {
165452
165495
  for (const node2 of profile?.nodes ?? []) {
165453
- const match = /[?&]platform=(ios|android)\b/.exec(node2.callFrame.url);
165496
+ const match = /[?&]platform=(ios|android|macos)\b/.exec(node2.callFrame.url);
165454
165497
  if (match) return match[1];
165455
165498
  }
165456
165499
  return void 0;
@@ -165472,10 +165515,10 @@ var annotationSchema = external_exports.object({
165472
165515
  var zodSchema48 = external_exports.object({
165473
165516
  port: metroPortField,
165474
165517
  device_id: external_exports.string().describe(
165475
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
165518
+ "Device ID used to record or load the React profile<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>."
165476
165519
  ),
165477
165520
  project_root: external_exports.string().describe("Absolute path to the RN project root for session context detection"),
165478
- platform: external_exports.enum(["ios", "android"]).optional().describe("Target platform"),
165521
+ platform: external_exports.enum(["ios", "android", "macos"]).optional().describe("Platform for source lookup when the recording does not identify one.").meta({ [FLAG_ENUM_META_KEY]: { macos: MACOS_APPS_FLAG } }),
165479
165522
  rn_version: external_exports.coerce.string().default("unknown").describe('React Native version (e.g. "0.73.4")'),
165480
165523
  annotations: external_exports.array(annotationSchema).optional().describe(
165481
165524
  "User actions to annotate the report's commits with: each commit shows the action that preceded it."
@@ -165500,7 +165543,7 @@ Fails if react-profiler-stop has not been called or no profiling data is stored.
165500
165543
  },
165501
165544
  // RN-only: reads commit data captured via the React DevTools backend, which
165502
165545
  // Chromium does not have.
165503
- capability: RN_ONLY_TOOL_CAPABILITY,
165546
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
165504
165547
  services: () => ({}),
165505
165548
  async execute(_services, params, ctx) {
165506
165549
  const sessionPaths = getCachedProfilerPaths(
@@ -165702,7 +165745,7 @@ When several files define a component with the same name (e.g. platform variants
165702
165745
  // Declared so the tool catalogue groups this with the other react-profiler-*
165703
165746
  // tools; the HTTP gate itself is a no-op here, as there is no device arg to
165704
165747
  // inspect.
165705
- capability: RN_ONLY_TOOL_CAPABILITY,
165748
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
165706
165749
  fileInputs,
165707
165750
  services: () => ({}),
165708
165751
  async execute(_services, params) {
@@ -165817,7 +165860,7 @@ function renderMarkdownTable(entries) {
165817
165860
  var zodSchema50 = external_exports.object({
165818
165861
  port: metroPortField,
165819
165862
  device_id: external_exports.string().describe(
165820
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
165863
+ "Device ID used to record or load the React profile<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>."
165821
165864
  ),
165822
165865
  top_n: external_exports.coerce.number().int().positive().default(20).describe("Number of top hotspot functions to return"),
165823
165866
  react_only: external_exports.boolean().default(false).describe("If true, only show React component functions (PascalCase names)")
@@ -165842,7 +165885,7 @@ Fails if react-profiler-stop has not been called or no CPU profile is stored.`,
165842
165885
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to summarize React CPU profile: ${failureSignal2.error_code}`
165843
165886
  },
165844
165887
  // RN-only: reads a Hermes CPU profile; Chromium's V8 sample format differs.
165845
- capability: RN_ONLY_TOOL_CAPABILITY,
165888
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
165846
165889
  services: () => ({}),
165847
165890
  async execute(_services, params) {
165848
165891
  const sessionPaths = getCachedProfilerPaths(metroPort(params), params.device_id);
@@ -165939,7 +165982,7 @@ function renderMarkdownTable2(entries) {
165939
165982
  var zodSchema51 = external_exports.object({
165940
165983
  port: metroPortField,
165941
165984
  device_id: external_exports.string().describe(
165942
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
165985
+ "Device ID of the app to inspect<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>. During a recording, use the ID passed to react-profiler-start."
165943
165986
  ),
165944
165987
  top_n: external_exports.coerce.number().int().positive().default(20).describe("Number of components to return")
165945
165988
  });
@@ -165962,7 +166005,7 @@ Fails if the React DevTools hook is not present in the runtime or the app is not
165962
166005
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to read React render activity: ${failureSignal2.error_code}`
165963
166006
  },
165964
166007
  // RN-only: queries the React DevTools backend hook on the live runtime.
165965
- capability: RN_ONLY_TOOL_CAPABILITY,
166008
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
165966
166009
  services: (params) => ({
165967
166010
  // Same key as react-profiler-start, so a forwarded logicalDeviceId reads its run.
165968
166011
  profilerSession: `${REACT_PROFILER_SESSION_NAMESPACE}:${metroPort(params)}:${canonicalDeviceId(params.device_id)}`
@@ -166121,7 +166164,7 @@ function buildFiberTreeScript(maxDepth, filter) {
166121
166164
  var zodSchema52 = external_exports.object({
166122
166165
  port: metroPortField,
166123
166166
  device_id: external_exports.string().describe(
166124
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
166167
+ "Device ID of the app to inspect<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>. During a recording, use the ID passed to react-profiler-start."
166125
166168
  ),
166126
166169
  max_depth: external_exports.coerce.number().int().positive().default(10).describe("Maximum tree depth to traverse"),
166127
166170
  filter: external_exports.string().optional().describe("Regex string to filter component names")
@@ -166140,7 +166183,7 @@ Fails if the React DevTools hook is not present or no fiber roots have been comm
166140
166183
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to read React fiber tree: ${failureSignal2.error_code}`
166141
166184
  },
166142
166185
  // RN-only: walks the fiber tree via the React DevTools backend hook.
166143
- capability: RN_ONLY_TOOL_CAPABILITY,
166186
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
166144
166187
  services: (params) => ({
166145
166188
  // Same key as react-profiler-start, so a forwarded logicalDeviceId reads its run.
166146
166189
  profilerSession: `${REACT_PROFILER_SESSION_NAMESPACE}:${metroPort(params)}:${canonicalDeviceId(params.device_id)}`
@@ -169060,6 +169103,7 @@ async function stopXctraceRecording(api) {
169060
169103
  api.exportSkipReason = diagnostics2.skipped ?? null;
169061
169104
  api.recordedMs = null;
169062
169105
  api.appSuspensions = suspensionSpans(suspensions2, diagnostics2);
169106
+ anchorAtTraceStart(api, diagnostics2);
169063
169107
  await saveSessionMetadata(api, traceFile);
169064
169108
  let warning2 = wasTimeout ? "Recording timed out at 10 min cap; exported the partial trace. Call native-profiler-start again for a fresh recording." : `xctrace exited before stop was called (code=${exitInfo?.code ?? "?"}, signal=${exitInfo?.signal ?? "?"}); exported the partial trace. ` + (api.platform === "macos" ? "Common causes: restart-app or launch-app started the app again, or xctrace was ended from outside. " : "Common causes: attached app terminated, simulator daemon restart. ") + "Call native-profiler-start again for a fresh recording.";
169065
169109
  if (ended2) warning2 = `${warning2} ${APP_ENDED_NOTE}`;
@@ -169137,6 +169181,7 @@ async function stopXctraceRecording(api) {
169137
169181
  api.exportSkipReason = diagnostics.skipped ?? null;
169138
169182
  api.recordedMs = api.platform === "macos" && api.wallClockStartMs !== null ? recordedMs : null;
169139
169183
  api.appSuspensions = suspensionSpans(suspensions, diagnostics);
169184
+ anchorAtTraceStart(api, diagnostics);
169140
169185
  await saveSessionMetadata(api, api.traceFile);
169141
169186
  if (ended) {
169142
169187
  warning = [warning, APP_ENDED_NOTE].filter(Boolean).join(" ");
@@ -169168,6 +169213,11 @@ function endSuspensionWatch(api) {
169168
169213
  api.suspensionWatch = null;
169169
169214
  return watch ? watch.end() : null;
169170
169215
  }
169216
+ function anchorAtTraceStart(api, diagnostics) {
169217
+ if (api.platform === "macos" && diagnostics.traceStartMs !== void 0) {
169218
+ api.wallClockStartMs = diagnostics.traceStartMs;
169219
+ }
169220
+ }
169171
169221
  function suspensionSpans(windows, diagnostics) {
169172
169222
  if (!windows || diagnostics.traceStartMs === void 0) return null;
169173
169223
  return suspensionSpansInTrace(windows, diagnostics.traceStartMs, diagnostics.traceDurationMs);
@@ -172818,7 +172868,7 @@ var timeRangeSchema = external_exports.object({
172818
172868
  var zodSchema58 = external_exports.object({
172819
172869
  port: metroPortField,
172820
172870
  device_id: metroDeviceIdParam(
172821
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
172871
+ "Device ID used to record or load the React profile<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>."
172822
172872
  ),
172823
172873
  mode: external_exports.enum(["by_component", "by_time_range", "by_index", "cascade_tree", "render_counts"]).describe("Query mode; see Modes in the tool description."),
172824
172874
  component_name: external_exports.string().optional().describe("Component name; optional for render_counts, which it narrows to one component"),
@@ -172848,7 +172898,7 @@ Fails if react-profiler-stop has not been called.`,
172848
172898
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to query React commits: ${failureSignal2.error_code}`
172849
172899
  },
172850
172900
  // Reads React commit data captured via the React DevTools backend.
172851
- capability: RN_ONLY_TOOL_CAPABILITY,
172901
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
172852
172902
  services: () => ({}),
172853
172903
  async execute(_services, params) {
172854
172904
  const commitTree = await getCommitData(metroPort(params), params.device_id);
@@ -173217,7 +173267,7 @@ var timeWindowSchema = external_exports.object({
173217
173267
  var zodSchema59 = external_exports.object({
173218
173268
  port: metroPortField,
173219
173269
  device_id: metroDeviceIdParam(
173220
- "Device logicalDeviceId from debugger-connect (iOS simulator UDID or Android logicalDeviceId)."
173270
+ "Device ID used to record or load the React profile<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>."
173221
173271
  ),
173222
173272
  mode: external_exports.enum(["top_functions", "time_window", "call_tree", "component_cpu"]).describe("Query mode; see Modes in the tool description."),
173223
173273
  time_window_ms: timeWindowSchema.optional().describe(
@@ -173254,7 +173304,7 @@ Fails if no CPU profile is stored; run react-profiler-stop (and ideally react-pr
173254
173304
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to query CPU profile: ${failureSignal2.error_code}`
173255
173305
  },
173256
173306
  // RN-only: reads Hermes-format CPU profiles; Chromium's V8 sample format differs.
173257
- capability: RN_ONLY_TOOL_CAPABILITY,
173307
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
173258
173308
  services: () => ({}),
173259
173309
  async execute(_services, params) {
173260
173310
  const sessionPaths = getCachedProfilerPaths(metroPort(params), params.device_id);
@@ -173729,7 +173779,9 @@ function buildPerfettoAnchor(wallClockStartMs) {
173729
173779
  // ../tool-server/src/tools/profiler/combined/profiler-combined-report.ts
173730
173780
  var zodSchema61 = external_exports.object({
173731
173781
  port: metroPortField,
173732
- device_id: metroDeviceIdParam("iOS Simulator/device UDID or Android serial")
173782
+ device_id: metroDeviceIdParam(
173783
+ "Device ID from list-devices used for the native profile (iOS simulator UDID, Android serial<flag:macos-apps>, or Mac app ID</flag:macos-apps>)."
173784
+ )
173733
173785
  });
173734
173786
  var profilerCombinedReportTool = {
173735
173787
  id: "profiler-combined-report",
@@ -173745,11 +173797,12 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
173745
173797
  completedMsg: () => "Built combined performance report",
173746
173798
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to build combined performance report: ${failureSignal2.error_code}`
173747
173799
  },
173748
- // iOS reads xctrace output; Android re-queries the Perfetto .pftrace via
173749
- // loadAndroidCombinedData. Chromium has no native trace capture.
173800
+ // iOS and Mac apps read xctrace output; Android re-queries the Perfetto
173801
+ // .pftrace via loadAndroidCombinedData. Chromium has no native trace capture.
173750
173802
  capability: {
173751
173803
  apple: { simulator: true },
173752
- android: { emulator: true, device: true, unknown: true }
173804
+ android: { emulator: true, device: true, unknown: true },
173805
+ macos: { app: true }
173753
173806
  },
173754
173807
  // The Android branch re-queries the .pftrace, so a cold trace-processor engine
173755
173808
  // re-pays the full parse past the 30s MCP fetch timeout, whose abort replays
@@ -173914,7 +173967,7 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
173914
173967
  `**React Profiler:** ${nonMarginCommits.length} hot commits `,
173915
173968
  `**Native Profiler:** ${uiHangs.length} hangs, ` + (leaksRecorded ? `${memoryLeaks.length} leaks` : `leaks not recorded`),
173916
173969
  "",
173917
- `**Clock offset:** React started ${((reactWallStart - nativeWallStart) / 1e3).toFixed(1)}s ${reactWallStart > nativeWallStart ? "after" : "before"} native profiler`,
173970
+ `**Clock offset:** React started ${(Math.abs(reactWallStart - nativeWallStart) / 1e3).toFixed(1)}s ${reactWallStart > nativeWallStart ? "after" : "before"} native profiler`,
173918
173971
  ""
173919
173972
  ];
173920
173973
  if (correlations.length > 0) {
@@ -174002,7 +174055,8 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
174002
174055
  mountComponents,
174003
174056
  // From parsedData, not the live session field: a recording started
174004
174057
  // after analyze must not re-label the data rendered here.
174005
- nativeApi.parsedData?.mallocStackLogging ?? null
174058
+ nativeApi.parsedData?.mallocStackLogging ?? null,
174059
+ nativeApi.platform === "macos"
174006
174060
  )
174007
174061
  );
174008
174062
  }
@@ -174031,7 +174085,7 @@ Fails if either react-profiler-analyze or native-profiler-analyze has not been c
174031
174085
  return lines.join("\n");
174032
174086
  }
174033
174087
  };
174034
- function renderCombinedMemoryLeaks(memoryLeaks, mountComponents, mallocStackLogging) {
174088
+ function renderCombinedMemoryLeaks(memoryLeaks, mountComponents, mallocStackLogging, macApp = false) {
174035
174089
  if (memoryLeaks.length === 0) return [];
174036
174090
  const attributedLeaks = memoryLeaks.filter((leak) => leak.attributed);
174037
174091
  const unattributedLeaks = memoryLeaks.filter((leak) => !leak.attributed);
@@ -174051,7 +174105,12 @@ function renderCombinedMemoryLeaks(memoryLeaks, mountComponents, mallocStackLogg
174051
174105
  if (unattributedLeaks.length > 0) {
174052
174106
  lines.push(
174053
174107
  ``,
174054
- renderUnattributedLeaksNote(unattributedLeaks, attributedLeaks.length, mallocStackLogging)
174108
+ renderUnattributedLeaksNote(
174109
+ unattributedLeaks,
174110
+ attributedLeaks.length,
174111
+ mallocStackLogging,
174112
+ macApp
174113
+ )
174055
174114
  );
174056
174115
  }
174057
174116
  lines.push("");
@@ -174064,7 +174123,6 @@ var import_fs21 = require("fs");
174064
174123
  var path48 = __toESM(require("path"));
174065
174124
  init_src2();
174066
174125
  init_device_info();
174067
- init_capability();
174068
174126
  var SESSION_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
174069
174127
  function assertSafeSessionId(sessionId) {
174070
174128
  if (!SESSION_ID_PATTERN.test(sessionId)) {
@@ -174437,7 +174495,7 @@ Use when you need to revisit past session data without capturing a new recording
174437
174495
  Modes:
174438
174496
  - list: Show all available profiling sessions in the project's debug directory.
174439
174497
  - load_react: Load a React profiler session (CPU profile + commit tree) into memory. Requires session_id.
174440
- - load_native: Restore native trace data (xctrace XML on iOS<flag:macos-apps> and Mac apps</flag:macos-apps>, .pftrace on Android). Requires session_id.<flag:macos-apps> Use this mode for Mac app IDs.</flag:macos-apps>
174498
+ - load_native: Restore native trace data (xctrace XML on iOS<flag:macos-apps> and Mac apps</flag:macos-apps>, .pftrace on Android). Requires session_id.
174441
174499
  Loading replaces the session in memory for this device_id (and Metro port, for React): the one the query tools and react-profiler-analyze read. The replaced session stays on disk; load it again by its session_id.
174442
174500
  Returns a summary of the loaded session or a session list for the list mode.
174443
174501
  Fails if the session_id is not found or the session's trace files are missing from disk.`,
@@ -174449,7 +174507,7 @@ Fails if the session_id is not found or the session's trace files are missing fr
174449
174507
  },
174450
174508
  // The Hermes, xctrace and perfetto formats this loads have no Chromium
174451
174509
  // equivalent; the gate fails at the call site, not inside the trace parser.
174452
- capability: { ...RN_ONLY_TOOL_CAPABILITY, macos: { app: true } },
174510
+ capability: REACT_PROFILER_TOOL_CAPABILITY,
174453
174511
  // load_native re-parses the whole export, which can outlast the 30s MCP fetch
174454
174512
  // timeout; an aborted call is replayed, not cancelled.
174455
174513
  longRunning: true,
@@ -174477,11 +174535,6 @@ Fails if the session_id is not found or the session's trace files are missing fr
174477
174535
  }
174478
174536
  );
174479
174537
  }
174480
- if (params.device_id && resolveDevice(params.device_id).platform === "macos") {
174481
- throw new InvalidToolInputError(
174482
- "A Mac app has no React profiler sessions: load_react takes the id of an iOS simulator or an Android device. Use load_native for the native profile of a Mac app."
174483
- );
174484
- }
174485
174538
  return loadReactSession(debugDir, params.session_id, metroPort(params), params.device_id);
174486
174539
  }
174487
174540
  case "load_native": {
@@ -177540,11 +177593,11 @@ function macosFlagHint(platform) {
177540
177593
  if (!reason2) return "";
177541
177594
  return reason2 === MACOS_APPS_FLAG_OFF_REASON ? " The macos-apps flag is off, so no Mac app is listed. Run: argent enable macos-apps." : ` No Mac app is listed: ${reason2}.`;
177542
177595
  }
177543
- function describeDevice(d) {
177596
+ function describeDevice2(d) {
177544
177597
  return `${deviceEntryId(d) ?? "?"} (${d.platform}${d.state ? `, ${d.state}` : ""})`;
177545
177598
  }
177546
177599
  function deviceResolutionError(message, all) {
177547
- const list = all ? ` Available devices: ${all.map(describeDevice).join(", ") || "none"}.` : "";
177600
+ const list = all ? ` Available devices: ${all.map(describeDevice2).join(", ") || "none"}.` : "";
177548
177601
  return new FailureError(message + list, {
177549
177602
  error_code: FAILURE_CODES.FLOW_DEVICE_RESOLUTION,
177550
177603
  failure_stage: "flow_device_resolution",
@@ -177657,7 +177710,7 @@ async function resolveFlowDevice(registry2, ctx, opts) {
177657
177710
  if (!anyMatch() && unknown2.length > 0) {
177658
177711
  throw unknownRuntimeKindError(
177659
177712
  requires,
177660
- unknown2.map(describeDevice),
177713
+ unknown2.map(describeDevice2),
177661
177714
  void 0,
177662
177715
  " Pass --device or --platform to choose a device."
177663
177716
  );
@@ -182584,7 +182637,7 @@ init_device_info();
182584
182637
  init_capability();
182585
182638
 
182586
182639
  // ../tool-server/src/tools/flows/flow-visual.ts
182587
- var import_node_crypto15 = require("node:crypto");
182640
+ var import_node_crypto16 = require("node:crypto");
182588
182641
  var fs72 = __toESM(require("node:fs/promises"));
182589
182642
  var os22 = __toESM(require("node:os"));
182590
182643
  var path57 = __toESM(require("node:path"));
@@ -184755,7 +184808,7 @@ async function runSnapshot(env, opts) {
184755
184808
  });
184756
184809
  const captureWarned = shot.warning !== void 0 ? { warning: shot.warning } : {};
184757
184810
  const { w, h } = await pngDimensions(shot.image.hostPath);
184758
- const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0, import_node_crypto15.createHash)("sha256").update(cropIdentity(opts.cropOn)).digest("hex").slice(0, 8)}`;
184811
+ const cropSuffix = opts.cropOn === void 0 ? "" : `-crop-${(0, import_node_crypto16.createHash)("sha256").update(cropIdentity(opts.cropOn)).digest("hex").slice(0, 8)}`;
184759
184812
  const snapshotKey = `${opts.name}__${authoringPlatform(env.device.platform)}-${w}x${h}${cropSuffix}`;
184760
184813
  const key2 = `${snapshotKey}.png`;
184761
184814
  const baselinePath = opts.clientFlowPath === void 0 ? path57.join(baselineDir(opts.flowsDir, opts.flowName), key2) : clientBaselinePath(opts.clientFlowPath, opts.flowName, key2);
@@ -187235,7 +187288,7 @@ var dismissUpdateTool = {
187235
187288
  };
187236
187289
 
187237
187290
  // ../tool-server/src/tools/screenshot-diff/index.ts
187238
- var import_node_crypto16 = __toESM(require("node:crypto"));
187291
+ var import_node_crypto17 = __toESM(require("node:crypto"));
187239
187292
  var import_promises21 = __toESM(require("fs/promises"));
187240
187293
  var import_node_os17 = __toESM(require("node:os"));
187241
187294
  var import_path9 = __toESM(require("path"));
@@ -187390,7 +187443,7 @@ async function resolveOutputDir(params, options) {
187390
187443
  const dir = import_path9.default.join(
187391
187444
  import_node_os17.default.tmpdir(),
187392
187445
  "argent-screenshot-diff",
187393
- import_node_crypto16.default.randomBytes(6).toString("hex")
187446
+ import_node_crypto17.default.randomBytes(6).toString("hex")
187394
187447
  );
187395
187448
  await import_promises21.default.mkdir(dir, { recursive: true });
187396
187449
  return dir;
@@ -187495,7 +187548,7 @@ async function captureIosDeviceLiveInput(params) {
187495
187548
  return writeLivePng(params.outputDir, params.name, png);
187496
187549
  }
187497
187550
  async function writeLivePng(outputDir, name, png) {
187498
- const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
187551
+ const suffix = import_node_crypto17.default.randomBytes(4).toString("hex");
187499
187552
  const destination = import_path9.default.join(outputDir, `${name}-${suffix}.live.png`);
187500
187553
  await import_promises21.default.mkdir(outputDir, { recursive: true });
187501
187554
  await import_promises21.default.writeFile(destination, png);
@@ -187513,7 +187566,7 @@ async function captureHarmonyLiveInput(params) {
187513
187566
  }
187514
187567
  await ensureDep("hdc");
187515
187568
  const captured = await captureHarmonyScreenshotPng({ connectKey: params.connectKey, scale: 1 });
187516
- const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
187569
+ const suffix = import_node_crypto17.default.randomBytes(4).toString("hex");
187517
187570
  const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
187518
187571
  try {
187519
187572
  await import_promises21.default.mkdir(params.outputDir, { recursive: true });
@@ -187549,7 +187602,7 @@ async function captureLiveInput(params) {
187549
187602
  params.peekFor?.(params.device)
187550
187603
  );
187551
187604
  }
187552
- const suffix = import_node_crypto16.default.randomBytes(4).toString("hex");
187605
+ const suffix = import_node_crypto17.default.randomBytes(4).toString("hex");
187553
187606
  const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
187554
187607
  await import_promises21.default.mkdir(params.outputDir, { recursive: true });
187555
187608
  await import_promises21.default.copyFile(capture.path, destination);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.33.1-next.24",
3
+ "version": "0.33.1-next.25",
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",
@@ -37,7 +37,7 @@ description: Drive a native Mac app (AppKit, SwiftUI, react-native-macos) throug
37
37
 
38
38
  ## Profiling
39
39
 
40
- Use `argent-native-profiler`. Instruments can pause the app during leak checks, delaying actions and inspection. After `MACOS_APP_RPC_TIMEOUT`, use `describe` before retrying because the action may already have taken effect.
40
+ Use `argent-native-profiler` for native profiling or `argent-react-native-profiler` to capture React performance on a react-native-macos app. Instruments can pause the app during leak checks, delaying actions and inspection. After `MACOS_APP_RPC_TIMEOUT`, use `describe` before retrying because the action may already have taken effect.
41
41
 
42
42
  ## E2E tests
43
43
 
@@ -45,4 +45,4 @@ Read `references/e2e.md` before recording or writing a test for a Mac app.
45
45
 
46
46
  ## react-native-macos
47
47
 
48
- A Debug build loads JavaScript from Metro: start Metro before `boot-device` (see `argent-react-native-app-workflow`). Use `describe` to inspect the screen and the native profiler to measure performance. The JavaScript debugger and React profiler are unavailable for Mac apps.
48
+ Start Metro before launching a react-native-macos Debug build with `boot-device`. See `argent-react-native-app-workflow` for Metro setup. Use `describe` to inspect the screen. The JavaScript debugger tools are unavailable for Mac apps.
@@ -7,7 +7,12 @@ This skill is complementary to `argent-react-native-optimization`, not a replace
7
7
 
8
8
  Physical iPhone: not supported; `react-profiler-*` reject `kind: "device"`. Profile on a simulator.
9
9
 
10
- For Mac apps (`platform: "macos"`), including react-native-macos, use `argent-native-profiler`.
10
+ For react-native-macos, start Metro and use `argent-macos-app-interact` to launch a Debug build of
11
+ version 0.76 or later with Hermes. Pass the Mac app's `device_id` from `list-devices` and call
12
+ `react-profiler-start` directly. Use the same ID and Metro port for the rest of the session.
13
+ If Metro cannot find the runtime, make sure the app is running, wait for its bundle to load, and
14
+ check the port (8081 by default). Retry with the same app ID, even if Metro lists other devices.
15
+ If the retry fails, report the error.
11
16
 
12
17
  ## 1. Tools
13
18