@swmansion/argent 0.35.1-next.85 → 0.35.1-next.86

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.
@@ -1429,16 +1429,20 @@ var init_event_emitter = __esm({
1429
1429
  });
1430
1430
 
1431
1431
  // ../registry/src/types.ts
1432
+ function isValidSession(session) {
1433
+ return /^[\x21-\x7e]{1,128}$/.test(session);
1434
+ }
1432
1435
  function isLiveServiceState(state3) {
1433
1436
  return state3 === "RUNNING" /* RUNNING */ || state3 === "STARTING" /* STARTING */;
1434
1437
  }
1435
- var LINKED_CALL_HEADER, E2E_DIR_CLIENT_HEADER, CLIENT_SECRETS_HEADER, CLIENT_SECRET_SOURCES_HEADER;
1438
+ var LINKED_CALL_HEADER, E2E_DIR_CLIENT_HEADER, CLIENT_SECRETS_HEADER, SESSION_HEADER, CLIENT_SECRET_SOURCES_HEADER;
1436
1439
  var init_types = __esm({
1437
1440
  "../registry/src/types.ts"() {
1438
1441
  "use strict";
1439
1442
  LINKED_CALL_HEADER = "x-argent-linked";
1440
1443
  E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
1441
1444
  CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
1445
+ SESSION_HEADER = "x-argent-session";
1442
1446
  CLIENT_SECRET_SOURCES_HEADER = "x-argent-client-secret-sources";
1443
1447
  }
1444
1448
  });
@@ -1829,6 +1833,8 @@ var init_failure_codes = __esm({
1829
1833
  HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
1830
1834
  HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
1831
1835
  HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
1836
+ // Another session holds a claim on the device the call names.
1837
+ DEVICE_IN_USE: "DEVICE_IN_USE",
1832
1838
  // The client's POST /upload of a file input was refused, so the call was not sent.
1833
1839
  FILE_INPUT_UPLOAD_FAILED: "FILE_INPUT_UPLOAD_FAILED",
1834
1840
  CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
@@ -18335,8 +18341,8 @@ function finalize(ctx, schema) {
18335
18341
  const root = ctx.seen.get(schema);
18336
18342
  if (!root)
18337
18343
  throw new Error("Unprocessed schema. This is a bug in Zod.");
18338
- const flattenRef = (zodSchema90) => {
18339
- const seen = ctx.seen.get(zodSchema90);
18344
+ const flattenRef = (zodSchema91) => {
18345
+ const seen = ctx.seen.get(zodSchema91);
18340
18346
  if (seen.ref === null)
18341
18347
  return;
18342
18348
  const schema2 = seen.def ?? seen.schema;
@@ -18354,7 +18360,7 @@ function finalize(ctx, schema) {
18354
18360
  assignProps(schema2, refSchema);
18355
18361
  }
18356
18362
  assignProps(schema2, _cached);
18357
- const isParentRef = zodSchema90._zod.parent === ref;
18363
+ const isParentRef = zodSchema91._zod.parent === ref;
18358
18364
  if (isParentRef) {
18359
18365
  for (const key2 in schema2) {
18360
18366
  if (key2 === "$ref" || key2 === "allOf")
@@ -18374,7 +18380,7 @@ function finalize(ctx, schema) {
18374
18380
  }
18375
18381
  }
18376
18382
  }
18377
- const parent = zodSchema90._zod.parent;
18383
+ const parent = zodSchema91._zod.parent;
18378
18384
  if (parent && parent !== ref) {
18379
18385
  flattenRef(parent);
18380
18386
  const parentSeen = ctx.seen.get(parent);
@@ -18392,7 +18398,7 @@ function finalize(ctx, schema) {
18392
18398
  }
18393
18399
  }
18394
18400
  ctx.override({
18395
- zodSchema: zodSchema90,
18401
+ zodSchema: zodSchema91,
18396
18402
  jsonSchema: schema2,
18397
18403
  path: seen.path ?? []
18398
18404
  });
@@ -21827,10 +21833,10 @@ function convertBaseSchema(schema, ctx) {
21827
21833
  }
21828
21834
  ctx.processing.add(refPath);
21829
21835
  const resolved = resolveRef(refPath, ctx);
21830
- const zodSchema91 = convertSchema(resolved, ctx);
21831
- ctx.refs.set(refPath, zodSchema91);
21836
+ const zodSchema92 = convertSchema(resolved, ctx);
21837
+ ctx.refs.set(refPath, zodSchema92);
21832
21838
  ctx.processing.delete(refPath);
21833
- return zodSchema91;
21839
+ return zodSchema92;
21834
21840
  }
21835
21841
  if (schema.enum !== void 0) {
21836
21842
  const enumValues = schema.enum;
@@ -21872,7 +21878,7 @@ function convertBaseSchema(schema, ctx) {
21872
21878
  if (!type) {
21873
21879
  return z.any();
21874
21880
  }
21875
- let zodSchema90;
21881
+ let zodSchema91;
21876
21882
  switch (type) {
21877
21883
  case "string": {
21878
21884
  let stringSchema = z.string();
@@ -21941,7 +21947,7 @@ function convertBaseSchema(schema, ctx) {
21941
21947
  if (schema.pattern) {
21942
21948
  stringSchema = stringSchema.regex(new RegExp(schema.pattern));
21943
21949
  }
21944
- zodSchema90 = stringSchema;
21950
+ zodSchema91 = stringSchema;
21945
21951
  break;
21946
21952
  }
21947
21953
  case "number":
@@ -21966,15 +21972,15 @@ function convertBaseSchema(schema, ctx) {
21966
21972
  if (typeof schema.multipleOf === "number") {
21967
21973
  numberSchema = numberSchema.multipleOf(schema.multipleOf);
21968
21974
  }
21969
- zodSchema90 = numberSchema;
21975
+ zodSchema91 = numberSchema;
21970
21976
  break;
21971
21977
  }
21972
21978
  case "boolean": {
21973
- zodSchema90 = z.boolean();
21979
+ zodSchema91 = z.boolean();
21974
21980
  break;
21975
21981
  }
21976
21982
  case "null": {
21977
- zodSchema90 = z.null();
21983
+ zodSchema91 = z.null();
21978
21984
  break;
21979
21985
  }
21980
21986
  case "object": {
@@ -22001,21 +22007,21 @@ function convertBaseSchema(schema, ctx) {
22001
22007
  }
22002
22008
  schemasToIntersect.push(...looseRecords);
22003
22009
  if (schemasToIntersect.length === 0) {
22004
- zodSchema90 = z.object({}).passthrough();
22010
+ zodSchema91 = z.object({}).passthrough();
22005
22011
  } else if (schemasToIntersect.length === 1) {
22006
- zodSchema90 = schemasToIntersect[0];
22012
+ zodSchema91 = schemasToIntersect[0];
22007
22013
  } else {
22008
22014
  let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
22009
22015
  for (let i = 2; i < schemasToIntersect.length; i++) {
22010
22016
  result = z.intersection(result, schemasToIntersect[i]);
22011
22017
  }
22012
- zodSchema90 = result;
22018
+ zodSchema91 = result;
22013
22019
  }
22014
22020
  if (schema.additionalProperties === false) {
22015
22021
  const propertyKeys = Object.keys(shape);
22016
22022
  const patterns = patternKeys.map((p) => new RegExp(p));
22017
- const basePatternSchema = zodSchema90;
22018
- zodSchema90 = zodSchema90.check((payload) => {
22023
+ const basePatternSchema = zodSchema91;
22024
+ zodSchema91 = zodSchema91.check((payload) => {
22019
22025
  if (!isPlainObject2(payload.value))
22020
22026
  return;
22021
22027
  const unrecognized = [];
@@ -22039,11 +22045,11 @@ function convertBaseSchema(schema, ctx) {
22039
22045
  } else {
22040
22046
  const objectSchema = z.object(shape);
22041
22047
  if (schema.additionalProperties === false) {
22042
- zodSchema90 = objectSchema.strict();
22048
+ zodSchema91 = objectSchema.strict();
22043
22049
  } else if (additionalSchema) {
22044
- zodSchema90 = objectSchema.catchall(additionalSchema);
22050
+ zodSchema91 = objectSchema.catchall(additionalSchema);
22045
22051
  } else {
22046
- zodSchema90 = objectSchema.passthrough();
22052
+ zodSchema91 = objectSchema.passthrough();
22047
22053
  }
22048
22054
  }
22049
22055
  const hasKeyGuard = schema.propertyNames !== void 0 && schema.propertyNames !== true;
@@ -22055,7 +22061,7 @@ function convertBaseSchema(schema, ctx) {
22055
22061
  const keyJSONSchema = typeof schema.propertyNames === "object" && schema.propertyNames.type === void 0 ? { type: "string", ...schema.propertyNames } : schema.propertyNames;
22056
22062
  keySchema = convertSchema(keyJSONSchema, ctx);
22057
22063
  }
22058
- zodSchema90 = checkObjectGuards(zodSchema90, { keySchema, minProperties, maxProperties });
22064
+ zodSchema91 = checkObjectGuards(zodSchema91, { keySchema, minProperties, maxProperties });
22059
22065
  }
22060
22066
  break;
22061
22067
  }
@@ -22068,12 +22074,12 @@ function convertBaseSchema(schema, ctx) {
22068
22074
  const positionalItems = applyMinItems(tupleItems, minItems);
22069
22075
  const rest = !Array.isArray(items) ? getTupleRest(items, ctx) : void 0;
22070
22076
  const tupleSchema = z.tuple(positionalItems);
22071
- zodSchema90 = rest ? tupleSchema.rest(rest) : tupleSchema;
22077
+ zodSchema91 = rest ? tupleSchema.rest(rest) : tupleSchema;
22072
22078
  if (typeof schema.minItems === "number") {
22073
- zodSchema90 = zodSchema90.check(z.minLength(schema.minItems));
22079
+ zodSchema91 = zodSchema91.check(z.minLength(schema.minItems));
22074
22080
  }
22075
22081
  if (typeof schema.maxItems === "number") {
22076
- zodSchema90 = zodSchema90.check(z.maxLength(schema.maxItems));
22082
+ zodSchema91 = zodSchema91.check(z.maxLength(schema.maxItems));
22077
22083
  }
22078
22084
  } else if (Array.isArray(items)) {
22079
22085
  const minItems = typeof schema.minItems === "number" ? schema.minItems : 0;
@@ -22081,12 +22087,12 @@ function convertBaseSchema(schema, ctx) {
22081
22087
  const positionalItems = applyMinItems(tupleItems, minItems);
22082
22088
  const rest = getTupleRest(schema.additionalItems, ctx);
22083
22089
  const tupleSchema = z.tuple(positionalItems);
22084
- zodSchema90 = rest ? tupleSchema.rest(rest) : tupleSchema;
22090
+ zodSchema91 = rest ? tupleSchema.rest(rest) : tupleSchema;
22085
22091
  if (typeof schema.minItems === "number") {
22086
- zodSchema90 = zodSchema90.check(z.minLength(schema.minItems));
22092
+ zodSchema91 = zodSchema91.check(z.minLength(schema.minItems));
22087
22093
  }
22088
22094
  if (typeof schema.maxItems === "number") {
22089
- zodSchema90 = zodSchema90.check(z.maxLength(schema.maxItems));
22095
+ zodSchema91 = zodSchema91.check(z.maxLength(schema.maxItems));
22090
22096
  }
22091
22097
  } else if (items !== void 0) {
22092
22098
  const element = convertSchema(items, ctx);
@@ -22097,12 +22103,12 @@ function convertBaseSchema(schema, ctx) {
22097
22103
  if (typeof schema.maxItems === "number") {
22098
22104
  arraySchema = arraySchema.max(schema.maxItems);
22099
22105
  }
22100
- zodSchema90 = arraySchema;
22106
+ zodSchema91 = arraySchema;
22101
22107
  } else {
22102
- zodSchema90 = z.array(z.any());
22108
+ zodSchema91 = z.array(z.any());
22103
22109
  }
22104
22110
  if (schema.uniqueItems === true || schema.contains !== void 0) {
22105
- zodSchema90 = checkArrayGuards(zodSchema90, {
22111
+ zodSchema91 = checkArrayGuards(zodSchema91, {
22106
22112
  uniqueItems: schema.uniqueItems === true,
22107
22113
  containsSchema: schema.contains !== void 0 ? convertSchema(schema.contains, ctx) : void 0,
22108
22114
  minContains: typeof schema.minContains === "number" ? schema.minContains : void 0,
@@ -22114,7 +22120,7 @@ function convertBaseSchema(schema, ctx) {
22114
22120
  default:
22115
22121
  throw new Error(`Unsupported type: ${type}`);
22116
22122
  }
22117
- return zodSchema90;
22123
+ return zodSchema91;
22118
22124
  }
22119
22125
  function convertSchema(schema, ctx) {
22120
22126
  if (typeof schema === "boolean") {
@@ -73410,7 +73416,7 @@ function isCi(env = process.env) {
73410
73416
  var SESSION_ID = (0, import_node_crypto4.randomUUID)();
73411
73417
  function readCliVersion() {
73412
73418
  if (true) {
73413
- return "0.35.1-next.84";
73419
+ return "0.35.1-next.86";
73414
73420
  }
73415
73421
  return "0.0.0";
73416
73422
  }
@@ -74273,8 +74279,8 @@ var import_express3 = __toESM(require_express2());
74273
74279
  var import_bytes2 = __toESM(require_bytes());
74274
74280
  var import_node_fs14 = require("node:fs");
74275
74281
  var import_promises16 = require("node:fs/promises");
74276
- var import_node_os12 = require("node:os");
74277
- var import_node_path17 = require("node:path");
74282
+ var import_node_os13 = require("node:os");
74283
+ var import_node_path18 = require("node:path");
74278
74284
  init_src();
74279
74285
  var import_node_crypto17 = require("node:crypto");
74280
74286
 
@@ -81285,8 +81291,8 @@ function consumePendingSigningDetectionNote(udid) {
81285
81291
 
81286
81292
  // ../tool-server/src/preview.ts
81287
81293
  var import_node_fs11 = __toESM(require("node:fs"));
81288
- var import_node_os8 = __toESM(require("node:os"));
81289
- var import_node_path14 = __toESM(require("node:path"));
81294
+ var import_node_os9 = __toESM(require("node:os"));
81295
+ var import_node_path15 = __toESM(require("node:path"));
81290
81296
  var import_express = __toESM(require_express2());
81291
81297
  init_src();
81292
81298
 
@@ -108598,6 +108604,285 @@ async function resolveRunningVvdSerial() {
108598
108604
 
108599
108605
  // ../tool-server/src/tools/devices/list-devices.ts
108600
108606
  init_external_devices();
108607
+
108608
+ // ../tool-server/src/utils/device-claims.ts
108609
+ init_src2();
108610
+ init_adb();
108611
+
108612
+ // ../tool-server/src/utils/emulator-console.ts
108613
+ var import_node_os8 = require("node:os");
108614
+ var import_node_path14 = require("node:path");
108615
+ init_adb();
108616
+ async function runEmuConsole(serial, args) {
108617
+ const { stdout } = await runAdb(["-s", serial, "emu", ...args], { timeoutMs: 1e4 });
108618
+ const verdict = replyLines(stdout).at(-1);
108619
+ if (verdict?.startsWith("KO:")) {
108620
+ throw new Error(
108621
+ `emulator console rejected \`${args.join(" ")}\` \u2014 ${describeConsoleReply(stdout)}`
108622
+ );
108623
+ }
108624
+ return stdout;
108625
+ }
108626
+ function describeConsoleReply(stdout) {
108627
+ const lines = replyLines(stdout);
108628
+ const reply = lines.join("; ") || "empty reply";
108629
+ if (!lines.at(-1)?.startsWith("KO: unknown command")) return reply;
108630
+ const tokenFile = (0, import_node_path14.join)((0, import_node_os8.homedir)(), ".emulator_console_auth_token");
108631
+ const fileKind = process.platform === "win32" ? "a file" : "a regular file, not a symlink,";
108632
+ return `${reply} (adb authenticates to the console with ${tokenFile}, which must be ${fileKind} holding the emulator's token)`;
108633
+ }
108634
+ function replyLines(stdout) {
108635
+ return stdout.split("\n").map((line) => line.trim()).filter(Boolean);
108636
+ }
108637
+
108638
+ // ../tool-server/src/utils/device-claims.ts
108639
+ init_device_info();
108640
+ init_external_devices();
108641
+ var CLAIM_IDLE_SECONDS = 60;
108642
+ var CLAIM_IDLE_TIMEOUT_MS = CLAIM_IDLE_SECONDS * 1e3;
108643
+ var BOOT_PROBE_DEADLINE_MS = 3e3;
108644
+ var CAPTURE_HOLD_MS = 30 * 6e4;
108645
+ var CAPTURE_STOPS = {
108646
+ "network-capture-stop": "network-capture-start",
108647
+ "screen-recording-stop": "screen-recording-start",
108648
+ "react-profiler-stop": "react-profiler-start",
108649
+ "native-profiler-stop": "native-profiler-start"
108650
+ };
108651
+ var CAPTURE_STARTS = new Set(Object.values(CAPTURE_STOPS));
108652
+ var RECORDED_STEP_TOOL = "e2e-add-step";
108653
+ var RELEASE_DEVICE_TOOL_ID = "release-device";
108654
+ var UUID_SHAPE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
108655
+ function foldCase(device) {
108656
+ return device.toLowerCase();
108657
+ }
108658
+ function androidBootId(serial) {
108659
+ return adbShell(serial, "cat /proc/sys/kernel/random/boot_id", { timeoutMs: 5e3 }).then(
108660
+ (out) => out.trim() || null,
108661
+ () => null
108662
+ );
108663
+ }
108664
+ function emulatorProcessId(serial) {
108665
+ return runEmuConsole(serial, ["avd", "discoverypath"]).then(
108666
+ (out) => out.split("\n")[0]?.trim() || null,
108667
+ () => null
108668
+ );
108669
+ }
108670
+ function withinDeadline(read) {
108671
+ let timer;
108672
+ const deadline = new Promise((resolve24) => {
108673
+ timer = setTimeout(() => resolve24(null), BOOT_PROBE_DEADLINE_MS);
108674
+ });
108675
+ return Promise.race([read, deadline]).finally(() => clearTimeout(timer));
108676
+ }
108677
+ function chromiumBrowserId(port) {
108678
+ return ensureCdpReachable(port, AbortSignal.timeout(2e3)).then(
108679
+ (version3) => version3.webSocketDebuggerUrl ?? null,
108680
+ () => null
108681
+ );
108682
+ }
108683
+ function bootIdentity(device) {
108684
+ const port = parseChromiumCdpPort(device);
108685
+ if (port !== null) return chromiumBrowserId(port);
108686
+ if (isAndroidEmulatorSerial(device)) return emulatorProcessId(device);
108687
+ if (classifyDevice(device) === "android") return androidBootId(device);
108688
+ return Promise.resolve(null);
108689
+ }
108690
+ var DeviceClaims = class {
108691
+ constructor(idleTimeoutMs = CLAIM_IDLE_TIMEOUT_MS, now = () => Date.now(), identify = bootIdentity) {
108692
+ this.idleTimeoutMs = idleTimeoutMs;
108693
+ this.now = now;
108694
+ this.identify = identify;
108695
+ }
108696
+ idleTimeoutMs;
108697
+ now;
108698
+ identify;
108699
+ claims = /* @__PURE__ */ new Map();
108700
+ /**
108701
+ * Claims every device for `session` for the length of one call of `toolId`,
108702
+ * or names the first one another session holds. Call `done` when the call
108703
+ * ends, saying whether it succeeded.
108704
+ */
108705
+ async claim(session, devices2, toolId, args) {
108706
+ for (const device of devices2) {
108707
+ const claim2 = this.liveClaim(device);
108708
+ if (claim2 === void 0 || claim2.session === session) continue;
108709
+ if (!await this.isAnotherBoot(claim2)) return { ok: false, device };
108710
+ this.drop(claim2);
108711
+ return this.claim(session, devices2, toolId, args);
108712
+ }
108713
+ const held2 = devices2.map((device) => this.hold(device, session));
108714
+ return {
108715
+ ok: true,
108716
+ done: (succeeded = false, result) => {
108717
+ for (const claim2 of held2) {
108718
+ if (toolId !== void 0) this.trackCapture(claim2, toolId, args, succeeded, result);
108719
+ claim2.activeCalls -= 1;
108720
+ claim2.lastUsedAt = this.now();
108721
+ claim2.boot = this.reidentify(claim2);
108722
+ if (claim2.released && claim2.activeCalls === 0) this.drop(claim2);
108723
+ }
108724
+ }
108725
+ };
108726
+ }
108727
+ /**
108728
+ * Releases `session`'s claim on `device`, or on every device it holds. A
108729
+ * device with a call in flight stays claimed until that call ends. Returns
108730
+ * the released devices.
108731
+ */
108732
+ release(session, device) {
108733
+ const released = [];
108734
+ for (const key2 of [...this.claims.keys()]) {
108735
+ const claim2 = this.liveClaim(key2);
108736
+ if (!claim2 || claim2.released || claim2.session !== session) continue;
108737
+ if (device !== void 0 && key2 !== foldCase(device)) continue;
108738
+ if (claim2.activeCalls > 0) claim2.released = true;
108739
+ else this.claims.delete(key2);
108740
+ released.push(claim2.device);
108741
+ }
108742
+ return released;
108743
+ }
108744
+ /** Ends the capture holds on `devices`, or on every device, once their captures were stopped. */
108745
+ endCaptures(devices2) {
108746
+ const keys = devices2 && new Set(devices2.map((device) => foldCase(claimKey(device))));
108747
+ for (const [key2, claim2] of this.claims) {
108748
+ if (!keys || keys.has(key2)) claim2.captures.clear();
108749
+ }
108750
+ }
108751
+ async ownerOf(device, session) {
108752
+ const claim2 = this.liveClaim(device);
108753
+ if (!claim2) return void 0;
108754
+ if (claim2.session === session) return "this session";
108755
+ if (!await this.isAnotherBoot(claim2)) return "another session";
108756
+ this.drop(claim2);
108757
+ return void 0;
108758
+ }
108759
+ async isAnotherBoot(claim2) {
108760
+ if (claim2.activeCalls > 0) return false;
108761
+ const seen = claim2.lastUsedAt;
108762
+ const [claimed, current] = await Promise.all([
108763
+ withinDeadline(claim2.boot),
108764
+ withinDeadline(this.identify(claim2.device))
108765
+ ]);
108766
+ if (claim2.activeCalls > 0 || claim2.lastUsedAt !== seen) return false;
108767
+ return claimed !== null && current !== null && claimed !== current;
108768
+ }
108769
+ /** A failed read keeps the last known boot, so a restart during an outage is still caught. */
108770
+ reidentify(claim2) {
108771
+ const known = claim2.boot;
108772
+ return this.identify(claim2.device).then((current) => current ?? known);
108773
+ }
108774
+ trackCapture(claim2, toolId, args, succeeded, result) {
108775
+ const recorded = toolId === RECORDED_STEP_TOOL;
108776
+ const tool = recorded ? recordedCommand(args) : toolId;
108777
+ if (tool === void 0) return;
108778
+ const answer = recorded ? result?.toolResult : result;
108779
+ if (succeeded && CAPTURE_STARTS.has(tool)) {
108780
+ const holdMs = captureHoldMs(answer);
108781
+ if (holdMs !== void 0) claim2.captures.set(tool, this.now() + holdMs);
108782
+ }
108783
+ const start2 = CAPTURE_STOPS[tool];
108784
+ if (start2 !== void 0) claim2.captures.delete(start2);
108785
+ }
108786
+ drop(claim2) {
108787
+ const key2 = foldCase(claim2.device);
108788
+ if (this.claims.get(key2) === claim2) this.claims.delete(key2);
108789
+ }
108790
+ liveClaim(device) {
108791
+ const claim2 = this.claims.get(foldCase(device));
108792
+ if (!claim2) return void 0;
108793
+ const idleSince = Math.max(claim2.lastUsedAt, ...claim2.captures.values());
108794
+ if (claim2.activeCalls === 0 && this.now() - idleSince > this.idleTimeoutMs) {
108795
+ this.claims.delete(foldCase(device));
108796
+ return void 0;
108797
+ }
108798
+ return claim2;
108799
+ }
108800
+ hold(device, session) {
108801
+ const existing = this.liveClaim(device);
108802
+ const claim2 = existing ?? {
108803
+ device,
108804
+ session,
108805
+ lastUsedAt: this.now(),
108806
+ activeCalls: 0,
108807
+ boot: this.identify(device),
108808
+ captures: /* @__PURE__ */ new Map()
108809
+ };
108810
+ claim2.activeCalls += 1;
108811
+ claim2.lastUsedAt = this.now();
108812
+ claim2.released = false;
108813
+ this.claims.set(foldCase(device), claim2);
108814
+ return claim2;
108815
+ }
108816
+ };
108817
+ function recordedCommand(args) {
108818
+ const command2 = args?.command;
108819
+ return typeof command2 === "string" ? canonicalToolId(command2) : void 0;
108820
+ }
108821
+ function captureHoldMs(result) {
108822
+ const answer = result ?? {};
108823
+ if (answer.already_running === true) return void 0;
108824
+ if (typeof answer.timeLimitSeconds !== "number") return CAPTURE_HOLD_MS;
108825
+ return Math.min(answer.timeLimitSeconds * 1e3, CAPTURE_HOLD_MS);
108826
+ }
108827
+ var DeviceInUseError = class extends Error {
108828
+ constructor(device) {
108829
+ super(deviceInUseMessage(device));
108830
+ this.name = "DeviceInUseError";
108831
+ withFailureSignal(this, {
108832
+ error_code: FAILURE_CODES.DEVICE_IN_USE,
108833
+ failure_stage: "picked_device_claim",
108834
+ failure_area: "tool_server",
108835
+ error_kind: "validation"
108836
+ });
108837
+ }
108838
+ };
108839
+ var deviceClaims = new DeviceClaims();
108840
+ function claimKey(deviceId) {
108841
+ const nativeId = externalNativeId(deviceId);
108842
+ const id = canonicalDeviceId(nativeId) ?? nativeId;
108843
+ return UUID_SHAPE.test(id) ? id.toUpperCase() : id;
108844
+ }
108845
+ function parseJson(text) {
108846
+ try {
108847
+ return JSON.parse(text);
108848
+ } catch {
108849
+ return void 0;
108850
+ }
108851
+ }
108852
+ function claimTargets(args) {
108853
+ if (!args || typeof args !== "object") return [];
108854
+ const record2 = args;
108855
+ const ids = [record2.udid, record2.device_id, record2.device];
108856
+ if (Array.isArray(record2.devices)) ids.push(...record2.devices);
108857
+ const named = ids.filter(
108858
+ (id) => typeof id === "string" && id.length > 0 && id !== CLOUD_ANDROID_DEVICE_ID
108859
+ );
108860
+ const stepTargets = typeof record2.args === "string" ? claimTargets(parseJson(record2.args)) : [];
108861
+ return [.../* @__PURE__ */ new Set([...named.map(claimKey), ...stepTargets])];
108862
+ }
108863
+ function parseSession(header) {
108864
+ if (header === void 0) return void 0;
108865
+ const session = header.trim();
108866
+ return isValidSession(session) ? session : null;
108867
+ }
108868
+ function deviceInUseMessage(device) {
108869
+ return `Device ${device} is in use by another Argent session. Pick another device from list-devices, retry after ${CLAIM_IDLE_SECONDS} s (the claim ends once the device is idle that long), or ask the user.`;
108870
+ }
108871
+ async function heldByAnotherSession(session, deviceId) {
108872
+ if (!session) return false;
108873
+ return await deviceClaims.ownerOf(claimKey(deviceId), session) === "another session";
108874
+ }
108875
+ async function claimPickedDevice(session, deviceId) {
108876
+ if (!session) return () => {
108877
+ };
108878
+ const claim2 = await deviceClaims.claim(session, [claimKey(deviceId)]);
108879
+ if (!claim2.ok) {
108880
+ throw new DeviceInUseError(claim2.device);
108881
+ }
108882
+ return claim2.done;
108883
+ }
108884
+
108885
+ // ../tool-server/src/tools/devices/list-devices.ts
108601
108886
  var import_node_child_process24 = require("node:child_process");
108602
108887
  var import_node_util19 = require("node:util");
108603
108888
  var execFileAsync18 = (0, import_node_util19.promisify)(import_node_child_process24.execFile);
@@ -108790,6 +109075,17 @@ async function withDeadline(p, fallback, label) {
108790
109075
  if (timer) clearTimeout(timer);
108791
109076
  }
108792
109077
  }
109078
+ function listedDeviceId(device) {
109079
+ if ("udid" in device && typeof device.udid === "string") return device.udid;
109080
+ if ("serial" in device && typeof device.serial === "string") return device.serial;
109081
+ if ("id" in device && typeof device.id === "string") return device.id;
109082
+ return void 0;
109083
+ }
109084
+ async function withClaim(device, session) {
109085
+ const id = listedDeviceId(device);
109086
+ const claim2 = id === void 0 ? void 0 : await deviceClaims.ownerOf(claimKey(id), session);
109087
+ return claim2 ? { ...device, claim: claim2 } : device;
109088
+ }
108793
109089
  function toListedExternal(device) {
108794
109090
  return {
108795
109091
  capabilities: Array.from(device.capabilities).sort(),
@@ -108815,7 +109111,7 @@ var zodSchema2 = external_exports.object({});
108815
109111
  var listDevicesTool = {
108816
109112
  id: "list-devices",
108817
109113
  description: `List available targets (ready devices first): iOS simulators/iPhones, Android emulators/AVDs/phones, Chromium apps, Vega devices, <flag:harmonyos>HarmonyOS, </flag:harmonyos><flag:macos-apps>Mac apps, </flag:macos-apps>and Argent Cloud simulators (\`ios-remote\`).
108818
- Use when starting a session to discover target ids. Returns { devices, notes? }. Pass a ready device's \`udid\`, \`serial\`, or \`id\` to other tools; start stopped targets via \`boot-device\`. Use physical phones (\`kind: 'device'\`) only when asked. \`runtimeKind: 'tv'\` uses \`tv-remote\`, not gestures. Fails if device discovery errors; surface \`notes\` if a needed platform is unavailable.`,
109114
+ Use when starting a session to discover target ids. Returns { devices, notes? }. Pass a ready device's \`udid\`, \`serial\`, or \`id\` to other tools; start stopped targets via \`boot-device\`. Use physical phones (\`kind: 'device'\`) only when asked. \`runtimeKind: 'tv'\` uses \`tv-remote\`, not gestures. Fails if device discovery errors; surface \`notes\` if a needed platform is unavailable. Skip a device with \`claim: 'another session'\`: another Argent session drives it.`,
108819
109115
  zodSchema: zodSchema2,
108820
109116
  alwaysLoad: true,
108821
109117
  searchHint: "list devices simulators emulators avd serial udid ios android chromium vega <flag:harmonyos>harmony harmonyos </flag:harmonyos>app fire tv session start",
@@ -108826,7 +109122,7 @@ Use when starting a session to discover target ids. Returns { devices, notes? }.
108826
109122
  failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to list devices: ${failureSignal2.error_code}`
108827
109123
  },
108828
109124
  services: () => ({}),
108829
- async execute(_services, _params) {
109125
+ async execute(_services, _params, ctx) {
108830
109126
  const harmonyEnabled = isHarmonyEnabled();
108831
109127
  const xcodeInstallPending = ["simctl", "devicectl"].filter(xcodeFirstLaunchPending);
108832
109128
  const [
@@ -109002,6 +109298,7 @@ Use when starting a session to discover target ids. Returns { devices, notes? }.
109002
109298
  ...external.map(toListedExternal)
109003
109299
  ];
109004
109300
  devices2.sort((a, b) => readinessRank(a) - readinessRank(b));
109301
+ const listed = await Promise.all(devices2.map((device) => withClaim(device, ctx?.session)));
109005
109302
  const [localIos, androidSdk] = await Promise.all([
109006
109303
  xcodeInstallPending.includes("simctl") ? true : canRunLocalIos(ios.simulators.length > 0),
109007
109304
  android.length > 0 || avds.length > 0 ? true : androidSdkFound()
@@ -109023,7 +109320,7 @@ Use when starting a session to discover target ids. Returns { devices, notes? }.
109023
109320
  ...external.length > 0 ? [EXTERNAL_DEVICES_HINT] : [],
109024
109321
  ...adbPrefix ? [adbServerHint(adbPrefix)] : []
109025
109322
  ];
109026
- return { devices: devices2, ...notes.length > 0 ? { notes } : {} };
109323
+ return { devices: listed, ...notes.length > 0 ? { notes } : {} };
109027
109324
  }
109028
109325
  };
109029
109326
 
@@ -115436,9 +115733,9 @@ function hasUnreadWebView(node2) {
115436
115733
  // ../tool-server/src/preview.ts
115437
115734
  function findUiFile(name) {
115438
115735
  const candidates = [
115439
- import_node_path14.default.join(__dirname, "preview-ui", name),
115440
- import_node_path14.default.resolve(__dirname, "..", "..", "..", "ui", name),
115441
- import_node_path14.default.resolve(__dirname, "..", "..", "ui", name)
115736
+ import_node_path15.default.join(__dirname, "preview-ui", name),
115737
+ import_node_path15.default.resolve(__dirname, "..", "..", "..", "ui", name),
115738
+ import_node_path15.default.resolve(__dirname, "..", "..", "ui", name)
115442
115739
  ];
115443
115740
  for (const p of candidates) {
115444
115741
  if (import_node_fs11.default.existsSync(p)) return p;
@@ -115447,7 +115744,7 @@ function findUiFile(name) {
115447
115744
  }
115448
115745
  function serveUiFile(res, filePath, contentType) {
115449
115746
  res.set("Cache-Control", "no-store, must-revalidate");
115450
- res.type(contentType).sendFile(import_node_path14.default.basename(filePath), { root: import_node_path14.default.dirname(filePath) });
115747
+ res.type(contentType).sendFile(import_node_path15.default.basename(filePath), { root: import_node_path15.default.dirname(filePath) });
115451
115748
  }
115452
115749
  function wsUrlFromHttp(httpUrl2) {
115453
115750
  const u = new URL(httpUrl2);
@@ -115777,7 +116074,7 @@ data: ${JSON.stringify(data)}
115777
116074
  const MAX_PREVIEW_BYTES = 25 * 1024 * 1024;
115778
116075
  const allowedRoots = (() => {
115779
116076
  const roots = /* @__PURE__ */ new Set();
115780
- for (const r of [import_node_os8.default.tmpdir(), process.cwd(), "/tmp"]) {
116077
+ for (const r of [import_node_os9.default.tmpdir(), process.cwd(), "/tmp"]) {
115781
116078
  try {
115782
116079
  roots.add(import_node_fs11.default.realpathSync(r));
115783
116080
  } catch {
@@ -115807,9 +116104,9 @@ data: ${JSON.stringify(data)}
115807
116104
  return;
115808
116105
  }
115809
116106
  const contained = allowedRoots.some(
115810
- (root) => real === root || real.startsWith(root + import_node_path14.default.sep)
116107
+ (root) => real === root || real.startsWith(root + import_node_path15.default.sep)
115811
116108
  );
115812
- const mime = IMG_MIME[import_node_path14.default.extname(real).toLowerCase()];
116109
+ const mime = IMG_MIME[import_node_path15.default.extname(real).toLowerCase()];
115813
116110
  if (!contained || !mime || size > MAX_PREVIEW_BYTES) {
115814
116111
  res.status(404).end();
115815
116112
  return;
@@ -115955,8 +116252,8 @@ function streamDirectoryAsArchive(id, entry, req, res) {
115955
116252
 
115956
116253
  // ../tool-server/src/file-inputs.ts
115957
116254
  var import_promises13 = require("node:fs/promises");
115958
- var import_node_os9 = require("node:os");
115959
- var import_node_path15 = require("node:path");
116255
+ var import_node_os10 = require("node:os");
116256
+ var import_node_path16 = require("node:path");
115960
116257
  var import_bytes = __toESM(require_bytes());
115961
116258
  init_src2();
115962
116259
  var MAX_UPLOAD_BYTES = 32 * 1024 * 1024;
@@ -116012,8 +116309,8 @@ function decodeContent(wire) {
116012
116309
  }
116013
116310
  async function materializeUpload(wire) {
116014
116311
  const data = decodeContent(wire);
116015
- const dir = await (0, import_promises13.mkdtemp)((0, import_node_path15.join)((0, import_node_os9.tmpdir)(), "argent-file-input-"));
116016
- const filePath = (0, import_node_path15.join)(dir, sanitizeFilename((0, import_node_path15.basename)(wire.path)));
116312
+ const dir = await (0, import_promises13.mkdtemp)((0, import_node_path16.join)((0, import_node_os10.tmpdir)(), "argent-file-input-"));
116313
+ const filePath = (0, import_node_path16.join)(dir, sanitizeFilename((0, import_node_path16.basename)(wire.path)));
116017
116314
  await (0, import_promises13.writeFile)(filePath, data);
116018
116315
  return { filePath, dir };
116019
116316
  }
@@ -116036,10 +116333,10 @@ async function extractTarUpload(wire, uploadId, meta3, tempDirs, lookupUpload) {
116036
116333
  );
116037
116334
  }
116038
116335
  const extractDir = await (0, import_promises13.mkdtemp)(
116039
- (0, import_node_path15.join)((0, import_node_os9.tmpdir)(), `argent-tar-upload-${entry.sha256.slice(0, 16)}-`)
116336
+ (0, import_node_path16.join)((0, import_node_os10.tmpdir)(), `argent-tar-upload-${entry.sha256.slice(0, 16)}-`)
116040
116337
  );
116041
116338
  tempDirs.push(extractDir);
116042
- const uploaded = await safeExtractArchive(entry.tarPath, extractDir, (0, import_node_path15.basename)(wire.path));
116339
+ const uploaded = await safeExtractArchive(entry.tarPath, extractDir, (0, import_node_path16.basename)(wire.path));
116043
116340
  return { value: uploaded, meta: { ...meta3, viaUpload: true } };
116044
116341
  } catch (err) {
116045
116342
  if (err instanceof FileInputError) throw err;
@@ -116139,7 +116436,7 @@ async function resolveMembers(members2, tempDirs, lookupUpload) {
116139
116436
  return out;
116140
116437
  }
116141
116438
  function unexpandedPathError(wire) {
116142
- if ((0, import_node_path15.isAbsolute)(wire.path) || import_node_path15.win32.isAbsolute(wire.path)) return void 0;
116439
+ if ((0, import_node_path16.isAbsolute)(wire.path) || import_node_path16.win32.isAbsolute(wire.path)) return void 0;
116143
116440
  return new FileInputError(
116144
116441
  `Path "${wire.path}" is not an absolute path. ` + (isUnexpandedPath(wire.path) ? `Nothing expands "~", variables, commands or URLs in a file argument, ` : `The tool-server resolves a relative path against its own working directory, `) + `so pass the file's absolute path.`
116145
116442
  );
@@ -117848,7 +118145,7 @@ init_src2();
117848
118145
  // ../tool-server/src/utils/ios-device/provisioning-profiles.ts
117849
118146
  var import_node_child_process28 = require("node:child_process");
117850
118147
  var import_node_fs13 = require("node:fs");
117851
- var import_node_os10 = require("node:os");
118148
+ var import_node_os11 = require("node:os");
117852
118149
  var path35 = __toESM(require("node:path"));
117853
118150
  var import_node_util20 = require("node:util");
117854
118151
  var execFileAsync19 = (0, import_node_util20.promisify)(import_node_child_process28.execFile);
@@ -117875,7 +118172,7 @@ function parseProvisioningProfile(xml) {
117875
118172
  async function readInstalledProfiles() {
117876
118173
  const files = (await Promise.all(
117877
118174
  PROFILE_DIRECTORIES.map(async (directory) => {
117878
- const absolute = path35.join((0, import_node_os10.homedir)(), directory);
118175
+ const absolute = path35.join((0, import_node_os11.homedir)(), directory);
117879
118176
  const names = await import_node_fs13.promises.readdir(absolute).catch(() => []);
117880
118177
  return names.filter((name) => name.endsWith(".mobileprovision")).map((name) => path35.join(absolute, name));
117881
118178
  })
@@ -124179,8 +124476,8 @@ async function describeVega(_serial) {
124179
124476
  }
124180
124477
 
124181
124478
  // ../tool-server/src/tools/describe/platforms/harmony/index.ts
124182
- var import_node_os11 = require("node:os");
124183
- var import_node_path16 = require("node:path");
124479
+ var import_node_os12 = require("node:os");
124480
+ var import_node_path17 = require("node:path");
124184
124481
  var import_promises15 = require("node:fs/promises");
124185
124482
 
124186
124483
  // ../tool-server/src/utils/harmony-uitest.ts
@@ -124703,7 +125000,7 @@ function pollHarmonyTree(connectKey, budgetMs) {
124703
125000
  return describeHarmony(connectKey, budgetMs);
124704
125001
  }
124705
125002
  async function describeHarmony(connectKey, timeoutMs = HARMONY_INTERACTION_TIMEOUT_MS) {
124706
- const localPath = (0, import_node_path16.join)((0, import_node_os11.tmpdir)(), `argent-harmony-dump-${process.hrtime.bigint()}.json`);
125003
+ const localPath = (0, import_node_path17.join)((0, import_node_os12.tmpdir)(), `argent-harmony-dump-${process.hrtime.bigint()}.json`);
124707
125004
  const deadline = Date.now() + timeoutMs;
124708
125005
  const display = await harmonyDisplay(
124709
125006
  connectKey,
@@ -128506,13 +128803,13 @@ function checkTokenExemptAccess(req, policy) {
128506
128803
  }
128507
128804
  function interfaceAddresses() {
128508
128805
  const out = [];
128509
- for (const list of Object.values((0, import_node_os12.networkInterfaces)())) {
128806
+ for (const list of Object.values((0, import_node_os13.networkInterfaces)())) {
128510
128807
  for (const a of list ?? []) out.push(a.address.split("%")[0]);
128511
128808
  }
128512
128809
  return out;
128513
128810
  }
128514
128811
  function machineHostnames() {
128515
- const name = (0, import_node_os12.hostname)().toLowerCase();
128812
+ const name = (0, import_node_os13.hostname)().toLowerCase();
128516
128813
  if (!name) return [];
128517
128814
  const bare = name.endsWith(".local") ? name.slice(0, -".local".length) : name;
128518
128815
  return [bare, `${bare}.local`];
@@ -128669,7 +128966,7 @@ function createHttpApp(registry2, options) {
128669
128966
  return;
128670
128967
  }
128671
128968
  const id = (0, import_node_crypto17.randomUUID)();
128672
- const tarPath = (0, import_node_path17.join)((0, import_node_os12.tmpdir)(), `argent-upload-${id}.tar.gz`);
128969
+ const tarPath = (0, import_node_path18.join)((0, import_node_os13.tmpdir)(), `argent-upload-${id}.tar.gz`);
128673
128970
  const ws = (0, import_node_fs14.createWriteStream)(tarPath);
128674
128971
  let received2 = 0;
128675
128972
  let released = false;
@@ -128804,6 +129101,13 @@ function createHttpApp(registry2, options) {
128804
129101
  res.status(404).json({ error: `Tool "${name}" not found` });
128805
129102
  return;
128806
129103
  }
129104
+ const session = parseSession(firstHeader(req.headers[SESSION_HEADER]));
129105
+ if (session === null) {
129106
+ res.status(400).json({
129107
+ error: `The ${SESSION_HEADER} header (ARGENT_SESSION for the CLI and the SDK) must be 1 to 128 printable ASCII characters without spaces.`
129108
+ });
129109
+ return;
129110
+ }
128807
129111
  let clientSecrets;
128808
129112
  const clientSecretsHeader = firstHeader(req.headers[CLIENT_SECRETS_HEADER]);
128809
129113
  if (clientSecretsHeader !== void 0) {
@@ -128978,6 +129282,37 @@ function createHttpApp(registry2, options) {
128978
129282
  }
128979
129283
  }
128980
129284
  if (callerGone) return;
129285
+ let endClaim;
129286
+ if (session && def.id !== RELEASE_DEVICE_TOOL_ID) {
129287
+ const claim2 = await deviceClaims.claim(
129288
+ session,
129289
+ claimTargets(parsedData),
129290
+ def.id,
129291
+ parsedData
129292
+ );
129293
+ if (!claim2.ok) {
129294
+ emitHttpFailure(
129295
+ {
129296
+ error_code: FAILURE_CODES.DEVICE_IN_USE,
129297
+ failure_stage: "http_device_claim",
129298
+ failure_area: "http",
129299
+ error_kind: "validation"
129300
+ },
129301
+ parsedData
129302
+ );
129303
+ res.status(409).json({
129304
+ error: deviceInUseMessage(claim2.device),
129305
+ error_code: FAILURE_CODES.DEVICE_IN_USE,
129306
+ error_kind: "validation"
129307
+ });
129308
+ return;
129309
+ }
129310
+ endClaim = claim2.done;
129311
+ if (callerGone) {
129312
+ endClaim(false, void 0);
129313
+ return;
129314
+ }
129315
+ }
128981
129316
  const controller = new AbortController();
128982
129317
  res.on("close", () => {
128983
129318
  if (!res.writableFinished) controller.abort();
@@ -129012,6 +129347,8 @@ function createHttpApp(registry2, options) {
129012
129347
  }
129013
129348
  toolCallsInFlight++;
129014
129349
  const endCloudCall = startCloudCall(toolId, cloudTargets, parsedData);
129350
+ let succeeded = false;
129351
+ let result;
129015
129352
  try {
129016
129353
  const data = await registry2.invokeTool(name, parsedData, {
129017
129354
  signal: controller.signal,
@@ -129024,10 +129361,13 @@ function createHttpApp(registry2, options) {
129024
129361
  // `.argent/flows/`, so the recorder keeps its recordings there.
129025
129362
  ...firstHeader(req.headers[E2E_DIR_CLIENT_HEADER]) === "1" ? {} : { legacyE2eDir: true },
129026
129363
  ...clientSecrets ? { clientSecrets } : {},
129364
+ ...session ? { session } : {},
129027
129365
  toolInvocationId,
129028
129366
  ...recordChildInvocation ? { recordChildInvocation } : {},
129029
129367
  ...wantsStream ? { emitProgress: (event2) => writeLine({ event: "progress", data: event2 }) } : {}
129030
129368
  });
129369
+ succeeded = true;
129370
+ result = data;
129031
129371
  const { updateInstallable, currentVersion, installableVersion } = getUpdateState();
129032
129372
  const shouldNotify = updateInstallable && !isUpdatingAutomatically(installableVersion) && !isUpdateNoteSuppressed();
129033
129373
  if (shouldNotify) {
@@ -129096,6 +129436,11 @@ function createHttpApp(registry2, options) {
129096
129436
  res.status(400).json({ error: attribute(unsupportedErr.message), ...errorSignalFields(err) });
129097
129437
  return;
129098
129438
  }
129439
+ const deviceInUseErr = findErrorInCauseChain(err, DeviceInUseError);
129440
+ if (deviceInUseErr) {
129441
+ res.status(409).json({ error: attribute(deviceInUseErr.message), ...errorSignalFields(err) });
129442
+ return;
129443
+ }
129099
129444
  const invalidInputErr = findErrorInCauseChain(err, InvalidToolInputError);
129100
129445
  if (invalidInputErr) {
129101
129446
  res.status(400).json({ error: attribute(invalidInputErr.message), ...errorSignalFields(err) });
@@ -129124,6 +129469,7 @@ function createHttpApp(registry2, options) {
129124
129469
  idleTimer.touch();
129125
129470
  if (keepAlive) clearInterval(keepAlive);
129126
129471
  releaseInvocationMeta?.();
129472
+ endClaim?.(succeeded, result);
129127
129473
  }
129128
129474
  }
129129
129475
  );
@@ -129172,12 +129518,12 @@ function createHttpApp(registry2, options) {
129172
129518
  // ../tool-server/src/event-log.ts
129173
129519
  var import_bunyan = __toESM(require_bunyan());
129174
129520
  var import_node_fs15 = require("node:fs");
129175
- var import_node_path18 = require("node:path");
129521
+ var import_node_path19 = require("node:path");
129176
129522
  init_src2();
129177
129523
  function createToolServerEventLog({
129178
129524
  filePath
129179
129525
  }) {
129180
- (0, import_node_fs15.mkdirSync)((0, import_node_path18.dirname)(filePath), { recursive: true });
129526
+ (0, import_node_fs15.mkdirSync)((0, import_node_path19.dirname)(filePath), { recursive: true });
129181
129527
  (0, import_node_fs15.writeFileSync)(filePath, "");
129182
129528
  const fileStream = (0, import_node_fs15.createWriteStream)(filePath, { flags: "a" });
129183
129529
  let disposed = false;
@@ -133893,7 +134239,7 @@ init_src2();
133893
134239
 
133894
134240
  // ../tool-server/src/utils/debugger/scripts/network-interceptor.ts
133895
134241
  var import_node_crypto21 = require("node:crypto");
133896
- var import_node_os13 = require("node:os");
134242
+ var import_node_os14 = require("node:os");
133897
134243
  init_src3();
133898
134244
  var BINARY_BODY_TYPES = /^(image\/(?!svg)|audio\/|video\/|font\/|application\/(octet-stream|pdf|zip|gzip|wasm|x-protobuf)$)/;
133899
134245
  var NETWORK_INTERCEPTOR_SCRIPT = `(function() {
@@ -134974,7 +135320,7 @@ var NETWORK_CAPTURE_MARK_SCRIPT = `(function() {
134974
135320
  })()`;
134975
135321
  var HOLDER = JSON.stringify((0, import_node_crypto21.randomUUID)());
134976
135322
  function holderRecord(capturing2) {
134977
- return JSON.stringify({ capturing: capturing2, pid: process.pid, host: (0, import_node_os13.hostname)() });
135323
+ return JSON.stringify({ capturing: capturing2, pid: process.pid, host: (0, import_node_os14.hostname)() });
134978
135324
  }
134979
135325
  function makeNetworkCaptureControlScript(paused) {
134980
135326
  return `(function() {
@@ -135021,7 +135367,7 @@ function exitedHolders(answer) {
135021
135367
  }
135022
135368
  return Object.keys(holders).filter((key2) => {
135023
135369
  const { pid, host } = holders[key2];
135024
- return host === (0, import_node_os13.hostname)() && typeof pid === "number" && !isProcessAlive(pid);
135370
+ return host === (0, import_node_os14.hostname)() && typeof pid === "number" && !isProcessAlive(pid);
135025
135371
  });
135026
135372
  }
135027
135373
  function makeNetworkLogReadScript(start2, limit, metroPort2) {
@@ -136232,13 +136578,40 @@ function clearLostProfilerRun(port, deviceId) {
136232
136578
  for (const key2 of findLostRun(port, deviceId)?.keys ?? []) lostRuns.delete(key2);
136233
136579
  }
136234
136580
 
136581
+ // ../tool-server/src/tools/devices/release-device.ts
136582
+ init_zod();
136583
+ init_capability();
136584
+ var zodSchema11 = external_exports.object({
136585
+ udid: external_exports.string().optional().describe("The device to release. Omit it to release every device of the session.")
136586
+ }).strict();
136587
+ var releaseDeviceTool = {
136588
+ id: RELEASE_DEVICE_TOOL_ID,
136589
+ description: "Release a device you are done with, so that another Argent session can use it.",
136590
+ zodSchema: zodSchema11,
136591
+ interaction: {
136592
+ startedMsg: () => "Releasing devices",
136593
+ completedMsg: ({ result }) => `Released ${result.released.length} ${result.released.length === 1 ? "device" : "devices"}`,
136594
+ failedMsg: ({ failureSignal: failureSignal2 }) => `Failed to release devices: ${failureSignal2.error_code}`
136595
+ },
136596
+ services: () => ({}),
136597
+ async execute(_services, params, ctx) {
136598
+ if (!ctx?.session) {
136599
+ throw new InvalidToolInputError(
136600
+ "release-device needs a session. Set ARGENT_SESSION to the value the session used."
136601
+ );
136602
+ }
136603
+ const device = params.udid === void 0 ? void 0 : claimKey(params.udid);
136604
+ return { released: deviceClaims.release(ctx.session, device) };
136605
+ }
136606
+ };
136607
+
136235
136608
  // ../tool-server/src/tools/devices/boot-device.ts
136236
136609
  var import_node_child_process38 = require("node:child_process");
136237
136610
  var import_node_fs20 = require("node:fs");
136238
136611
  var import_promises18 = require("node:fs/promises");
136239
136612
  var import_node_net4 = require("node:net");
136240
- var import_node_os15 = require("node:os");
136241
- var import_node_path22 = require("node:path");
136613
+ var import_node_os16 = require("node:os");
136614
+ var import_node_path23 = require("node:path");
136242
136615
  var import_node_util28 = require("node:util");
136243
136616
  init_zod();
136244
136617
  init_src();
@@ -136247,11 +136620,11 @@ init_adb();
136247
136620
 
136248
136621
  // ../tool-server/src/utils/android-read-only-boots.ts
136249
136622
  var import_node_fs17 = __toESM(require("node:fs"));
136250
- var import_node_path19 = __toESM(require("node:path"));
136623
+ var import_node_path20 = __toESM(require("node:path"));
136251
136624
  init_src();
136252
136625
  var ownRecords = /* @__PURE__ */ new Map();
136253
136626
  function recordsFilePath() {
136254
- return process.env.ARGENT_ANDROID_READ_ONLY_BOOTS_FILE ?? import_node_path19.default.join(argentHomeDir(), "android-read-only-boots.json");
136627
+ return process.env.ARGENT_ANDROID_READ_ONLY_BOOTS_FILE ?? import_node_path20.default.join(argentHomeDir(), "android-read-only-boots.json");
136255
136628
  }
136256
136629
  function isRecord5(value) {
136257
136630
  const v = value;
@@ -136273,7 +136646,7 @@ function persist(mutate) {
136273
136646
  const file2 = recordsFilePath();
136274
136647
  const records = loadPersisted();
136275
136648
  mutate(records);
136276
- import_node_fs17.default.mkdirSync(import_node_path19.default.dirname(file2), { recursive: true });
136649
+ import_node_fs17.default.mkdirSync(import_node_path20.default.dirname(file2), { recursive: true });
136277
136650
  import_node_fs17.default.writeFileSync(file2, JSON.stringify(Object.fromEntries(records)));
136278
136651
  } catch {
136279
136652
  }
@@ -136474,8 +136847,8 @@ async function readParentPids() {
136474
136847
 
136475
136848
  // ../tool-server/src/utils/linux-preflight.ts
136476
136849
  var fs51 = __toESM(require("node:fs"));
136477
- var import_node_os14 = require("node:os");
136478
- var import_node_path20 = require("node:path");
136850
+ var import_node_os15 = require("node:os");
136851
+ var import_node_path21 = require("node:path");
136479
136852
  var import_ini2 = __toESM(require_ini());
136480
136853
  function linuxBootDiagnostics(avdName) {
136481
136854
  if (process.platform !== "linux") return null;
@@ -136503,7 +136876,7 @@ function checkKvm() {
136503
136876
  var MIN_RAM_MB = 4096;
136504
136877
  var MIN_HEAP_MB = 512;
136505
136878
  function checkAvdSizing(avdName) {
136506
- const configPath = (0, import_node_path20.join)((0, import_node_os14.homedir)(), ".android", "avd", `${avdName}.avd`, "config.ini");
136879
+ const configPath = (0, import_node_path21.join)((0, import_node_os15.homedir)(), ".android", "avd", `${avdName}.avd`, "config.ini");
136507
136880
  let content;
136508
136881
  try {
136509
136882
  content = fs51.readFileSync(configPath, "utf8");
@@ -136539,7 +136912,7 @@ function readMb(config2, key2) {
136539
136912
  // ../tool-server/src/utils/simulator-app-launch.ts
136540
136913
  var import_node_child_process36 = require("node:child_process");
136541
136914
  var import_node_fs19 = __toESM(require("node:fs"));
136542
- var import_node_path21 = __toESM(require("node:path"));
136915
+ var import_node_path22 = __toESM(require("node:path"));
136543
136916
  var import_node_util27 = require("node:util");
136544
136917
  init_src();
136545
136918
  var execFileAsync26 = (0, import_node_util27.promisify)(import_node_child_process36.execFile);
@@ -136548,7 +136921,7 @@ var LAUNCH_WATCH_MS = 1e4;
136548
136921
  var LAUNCH_POLL_MS = 250;
136549
136922
  var launchLocks = /* @__PURE__ */ new Map();
136550
136923
  function verdictFilePath() {
136551
- return import_node_path21.default.join(argentHomeDir(), "simulator-app-launch.json");
136924
+ return import_node_path22.default.join(argentHomeDir(), "simulator-app-launch.json");
136552
136925
  }
136553
136926
  function loadVerdicts() {
136554
136927
  try {
@@ -136560,7 +136933,7 @@ function loadVerdicts() {
136560
136933
  }
136561
136934
  function persistVerdict(key2, verdict) {
136562
136935
  const filePath = verdictFilePath();
136563
- import_node_fs19.default.mkdirSync(import_node_path21.default.dirname(filePath), { recursive: true });
136936
+ import_node_fs19.default.mkdirSync(import_node_path22.default.dirname(filePath), { recursive: true });
136564
136937
  writeFileAtomicSync(filePath, JSON.stringify({ ...loadVerdicts(), [key2]: verdict }, null, 2));
136565
136938
  }
136566
136939
  async function bundleVersion(infoPlist) {
@@ -136573,7 +136946,7 @@ async function bundleVersion(infoPlist) {
136573
136946
  }
136574
136947
  async function launchKey(simulatorApp) {
136575
136948
  const [appBuild, coreSimulatorBuild] = await Promise.all([
136576
- bundleVersion(import_node_path21.default.join(simulatorApp, "Contents", "Info.plist")),
136949
+ bundleVersion(import_node_path22.default.join(simulatorApp, "Contents", "Info.plist")),
136577
136950
  bundleVersion(CORE_SIMULATOR_INFO_PLIST)
136578
136951
  ]);
136579
136952
  return `${simulatorApp} ${appBuild} / CoreSimulator ${coreSimulatorBuild}`;
@@ -136604,7 +136977,7 @@ function launchSimulatorApp(simulatorApp, launch) {
136604
136977
  }
136605
136978
  const verdict = loadVerdicts()[key2];
136606
136979
  if (verdict === "crashes") return false;
136607
- const executable = import_node_path21.default.join(simulatorApp, "Contents", "MacOS", "Simulator");
136980
+ const executable = import_node_path22.default.join(simulatorApp, "Contents", "MacOS", "Simulator");
136608
136981
  const watch = verdict !== "runs" && !await runningExecutables().then((running) => running.some(isSimulatorApp)).catch(() => true);
136609
136982
  await launch();
136610
136983
  if (!watch) return true;
@@ -137005,6 +137378,27 @@ async function bootMacosApp(registry2, opts) {
137005
137378
 
137006
137379
  // ../tool-server/src/tools/devices/boot-device.ts
137007
137380
  var execFileAsync27 = (0, import_node_util28.promisify)(import_node_child_process38.execFile);
137381
+ function bootedDeviceId(result) {
137382
+ if ("serial" in result) return result.serial;
137383
+ if ("udid" in result) return result.udid;
137384
+ if ("id" in result) return result.id;
137385
+ return void 0;
137386
+ }
137387
+ async function claimBooted(session, result) {
137388
+ const id = bootedDeviceId(result);
137389
+ if (id) (await claimPickedDevice(session, id))();
137390
+ return result;
137391
+ }
137392
+ function runningEmulatorHold(session) {
137393
+ let end = () => {
137394
+ };
137395
+ return {
137396
+ hold: async (serial) => {
137397
+ end = await claimPickedDevice(session, serial);
137398
+ },
137399
+ end: () => end()
137400
+ };
137401
+ }
137008
137402
  function bootTarget(params) {
137009
137403
  return params.udid ?? params.avdName ?? params.vvdImage ?? params.harmonyInstance ?? params.electronAppPath ?? params.macosAppPath ?? "device";
137010
137404
  }
@@ -137373,7 +137767,7 @@ async function openSimulatorWindow(udid) {
137373
137767
  const timeout = 5e3;
137374
137768
  const { stdout } = await execFileAsync27("xcode-select", ["-p"], { timeout });
137375
137769
  const developerDir2 = (0, import_node_fs20.realpathSync)(stdout.trim());
137376
- const simulatorApp = (0, import_node_path22.join)(developerDir2, "Applications", "Simulator.app");
137770
+ const simulatorApp = (0, import_node_path23.join)(developerDir2, "Applications", "Simulator.app");
137377
137771
  if ((0, import_node_fs20.existsSync)(simulatorApp)) {
137378
137772
  const launched = await launchSimulatorApp(
137379
137773
  simulatorApp,
@@ -137381,7 +137775,7 @@ async function openSimulatorWindow(udid) {
137381
137775
  );
137382
137776
  return launched ? void 0 : `${simulatorApp} exits right after launch on this host, so Argent no longer opens it and the device runs without a window. Delete ${verdictFilePath()} to try opening it again.`;
137383
137777
  }
137384
- const deviceHubApp = (0, import_node_path22.join)(developerDir2, "..", "Applications", "DeviceHub.app");
137778
+ const deviceHubApp = (0, import_node_path23.join)(developerDir2, "..", "Applications", "DeviceHub.app");
137385
137779
  if ((0, import_node_fs20.existsSync)(deviceHubApp)) {
137386
137780
  const url2 = `devices://device/open?id=${encodeURIComponent(udid)}`;
137387
137781
  await execFileAsync27("open", ["-a", deviceHubApp, url2], { timeout });
@@ -137474,7 +137868,7 @@ async function attemptBoot(params) {
137474
137868
  const portArg = params.emulatorArgs.indexOf("-port");
137475
137869
  const instance = portArg >= 0 ? `${params.avdName}-${params.emulatorArgs[portArg + 1]}` : params.avdName;
137476
137870
  const safeName = instance.replace(/[^\w.-]/g, "_");
137477
- const logPath = (0, import_node_path22.join)((0, import_node_os15.tmpdir)(), `argent-emulator-${safeName}.log`);
137871
+ const logPath = (0, import_node_path23.join)((0, import_node_os16.tmpdir)(), `argent-emulator-${safeName}.log`);
137478
137872
  emulatorLogFd = (0, import_node_fs20.openSync)(logPath, "w");
137479
137873
  stdio = ["ignore", emulatorLogFd, emulatorLogFd];
137480
137874
  }
@@ -137650,8 +138044,12 @@ async function attemptBoot(params) {
137650
138044
  }
137651
138045
  var GRPC_PORT_OFFSET = 3e3;
137652
138046
  var inFlightBoots = /* @__PURE__ */ new Map();
138047
+ async function withoutOthersClaims(devices2, session) {
138048
+ const held2 = await Promise.all(devices2.map((d) => heldByAnotherSession(session, d.serial)));
138049
+ return devices2.filter((_, i) => !held2[i]);
138050
+ }
137653
138051
  function inFlightBootKey(params) {
137654
- return `${params.avdName}\0${params.readOnly ? "ro" : "rw"}\0${params.port ?? ""}`;
138052
+ return `${params.avdName}\0${params.readOnly ? "ro" : "rw"}\0${params.port ?? ""}\0${params.session ?? ""}`;
137655
138053
  }
137656
138054
  async function avdInstances(avdName, listed) {
137657
138055
  const processes = await readEmulatorProcessesForAvd(avdName);
@@ -137849,9 +138247,10 @@ async function bootAndroidImpl(params, overallDeadline) {
137849
138247
  params.avdName,
137850
138248
  listed ? new Set(existingDevices.map((d) => d.serial)) : void 0
137851
138249
  );
137852
- const candidates = existingDevices.filter(
138250
+ const matching = existingDevices.filter(
137853
138251
  (d) => isRunningAvd(d, params.avdName) && (portSerial !== null ? d.serial === portSerial : !instances.pinned.has(d.serial) || !params.readOnly && !instances.readOnly.has(d.serial))
137854
138252
  );
138253
+ const candidates = params.readOnly && portSerial === null ? await withoutOthersClaims(matching, params.session) : matching;
137855
138254
  const blocks = (p) => !params.readOnly || !p.readOnly;
137856
138255
  let alreadyRunning = params.readOnly ? candidates.find((d) => instances.readOnly.has(d.serial)) : candidates.find((d) => !instances.readOnly.has(d.serial)) ?? candidates[0];
137857
138256
  let preserveOnProbeFailure = false;
@@ -137871,6 +138270,7 @@ async function bootAndroidImpl(params, overallDeadline) {
137871
138270
  }
137872
138271
  let killedRunning = false;
137873
138272
  if (alreadyRunning) {
138273
+ await params.holdRunning?.(alreadyRunning.serial);
137874
138274
  if (params.force) {
137875
138275
  const others = await blockersBesides(params.avdName, alreadyRunning.serial, blocks);
137876
138276
  if (others.length > 0) throw readOnlyConflictError(params, others);
@@ -138222,11 +138622,11 @@ async function startHarmonyEmulator(instanceName) {
138222
138622
  });
138223
138623
  }
138224
138624
  try {
138225
- for (const entry of (0, import_node_fs20.readdirSync)((0, import_node_os15.tmpdir)())) {
138625
+ for (const entry of (0, import_node_fs20.readdirSync)((0, import_node_os16.tmpdir)())) {
138226
138626
  if (!entry.startsWith("argent-harmony-") || !entry.endsWith(".log")) continue;
138227
138627
  try {
138228
- if (Date.now() - (0, import_node_fs20.statSync)((0, import_node_path22.join)((0, import_node_os15.tmpdir)(), entry)).mtimeMs > HARMONY_LOG_TTL_MS) {
138229
- (0, import_node_fs20.rmSync)((0, import_node_path22.join)((0, import_node_os15.tmpdir)(), entry), { force: true });
138628
+ if (Date.now() - (0, import_node_fs20.statSync)((0, import_node_path23.join)((0, import_node_os16.tmpdir)(), entry)).mtimeMs > HARMONY_LOG_TTL_MS) {
138629
+ (0, import_node_fs20.rmSync)((0, import_node_path23.join)((0, import_node_os16.tmpdir)(), entry), { force: true });
138230
138630
  }
138231
138631
  } catch {
138232
138632
  }
@@ -138234,7 +138634,7 @@ async function startHarmonyEmulator(instanceName) {
138234
138634
  } catch {
138235
138635
  }
138236
138636
  const safeName = instanceName.replace(/[^\w.-]/g, (c) => `%${c.codePointAt(0).toString(16)}`);
138237
- const logPath = (0, import_node_path22.join)((0, import_node_os15.tmpdir)(), `argent-harmony-${safeName}-${process.hrtime.bigint()}.log`);
138637
+ const logPath = (0, import_node_path23.join)((0, import_node_os16.tmpdir)(), `argent-harmony-${safeName}-${process.hrtime.bigint()}.log`);
138238
138638
  let logFd;
138239
138639
  try {
138240
138640
  logFd = (0, import_node_fs20.openSync)(logPath, "w");
@@ -138341,7 +138741,7 @@ async function waitForHarmonyTarget(before, deadline, checkAlive, expected) {
138341
138741
  }
138342
138742
  }
138343
138743
  async function waitForHarmonyDrivable(connectKey, deadline, checkAlive) {
138344
- const probePath = (0, import_node_path22.join)((0, import_node_os15.tmpdir)(), `argent-harmony-bootprobe-${process.hrtime.bigint()}.json`);
138744
+ const probePath = (0, import_node_path23.join)((0, import_node_os16.tmpdir)(), `argent-harmony-bootprobe-${process.hrtime.bigint()}.json`);
138345
138745
  let inFlight5 = null;
138346
138746
  try {
138347
138747
  for (; ; ) {
@@ -138576,7 +138976,7 @@ var capability2 = {
138576
138976
  harmony: { emulator: true },
138577
138977
  macos: { app: true, catalyst: true }
138578
138978
  };
138579
- var zodSchema11 = external_exports.object({
138979
+ var zodSchema12 = external_exports.object({
138580
138980
  udid: external_exports.string().optional().describe(
138581
138981
  "iOS simulator UDID from `list-devices`.<flag:macos-apps> Or Mac app id (`macos-app-<bundle id>`) to relaunch from its last path.</flag:macos-apps>"
138582
138982
  ),
@@ -138632,7 +139032,7 @@ function createBootDeviceTool(registry2) {
138632
139032
  description: `Start a target device or app and wait until ready: iOS simulator, Android emulator, Vega VVD, <flag:harmonyos>HarmonyOS emulator, </flag:harmonyos><flag:macos-apps>Mac app, </flag:macos-apps>or Electron app.
138633
139033
  Use when starting a stopped target; pass exactly one target key (\`udid\`, \`avdName\`, \`vvdImage\`, <flag:harmonyos>\`harmonyInstance\`, </flag:harmonyos><flag:macos-apps>\`macosAppPath\`, </flag:macos-apps>or \`electronAppPath\`).
138634
139034
  Returns a platform-tagged payload with the target id (\`udid\` / \`serial\` / \`id\`), \`booted\`, and optional \`note\`.<flag:harmonyos> HarmonyOS starts the instance via DevEco Studio's Emulator manager and waits for its \`hdc\` connect key as \`udid\` (images are served only in mainland China; \`note\` explains any unproven key/readiness).</flag:harmonyos> Fails if the target is missing or cannot boot (failed Android/Electron spawns are cleaned up automatically).`,
138635
- zodSchema: zodSchema11,
139035
+ zodSchema: zodSchema12,
138636
139036
  alwaysLoad: true,
138637
139037
  searchHint: "boot start launch simulator emulator avd device session ios android vega vvd firetv <flag:harmonyos>harmony harmonyos deveco </flag:harmonyos>cold hot",
138638
139038
  interaction: {
@@ -138670,12 +139070,15 @@ Returns a platform-tagged payload with the target id (\`udid\` / \`serial\` / \`
138670
139070
  );
138671
139071
  }
138672
139072
  if (hasMacos || hasUdid && classifyDevice(params.udid) === "macos") {
138673
- return bootMacosApp(registry2, {
138674
- appPath: params.macosAppPath,
138675
- deviceId: hasUdid ? params.udid : void 0,
138676
- args: params.macosAppArgs,
138677
- force: params.force
138678
- });
139073
+ return claimBooted(
139074
+ ctx?.session,
139075
+ await bootMacosApp(registry2, {
139076
+ appPath: params.macosAppPath,
139077
+ deviceId: hasUdid ? params.udid : void 0,
139078
+ args: params.macosAppArgs,
139079
+ force: params.force
139080
+ })
139081
+ );
138679
139082
  }
138680
139083
  if (hasUdid && params.udid === CLOUD_ANDROID_DEVICE_ID) {
138681
139084
  const cloud = await bootCloudAndroid(params, ctx?.signal);
@@ -138709,11 +139112,14 @@ Returns a platform-tagged payload with the target id (\`udid\` / \`serial\` / \`
138709
139112
  return bootIosRemote(params.udid, registry2, params.force);
138710
139113
  }
138711
139114
  if (platform === "harmony") {
138712
- return bootHarmony({
138713
- instanceName: harmonyInstanceName(params.udid),
138714
- bootTimeoutMs: params.bootTimeoutMs ?? HARMONY_BOOT_TIMEOUT_MS,
138715
- force: params.force
138716
- });
139115
+ return claimBooted(
139116
+ ctx?.session,
139117
+ await bootHarmony({
139118
+ instanceName: harmonyInstanceName(params.udid),
139119
+ bootTimeoutMs: params.bootTimeoutMs ?? HARMONY_BOOT_TIMEOUT_MS,
139120
+ force: params.force
139121
+ })
139122
+ );
138717
139123
  }
138718
139124
  const hint = platform === "ios" || platform === "macos" ? void 0 : nonIosUdidHint(params.udid, platform);
138719
139125
  if (hint) {
@@ -138737,38 +139143,57 @@ Returns a platform-tagged payload with the target id (\`udid\` / \`serial\` / \`
138737
139143
  });
138738
139144
  }
138739
139145
  }
138740
- return bootAndroid({
138741
- avdName: params.avdName,
138742
- bootTimeoutMs: params.bootTimeoutMs ?? 48e4,
138743
- force: params.force,
138744
- // An explicit argument always wins; the `boot-sound` flag only moves
138745
- // the default when the caller left `sound` unset. Read live per call
138746
- // so `argent enable/disable boot-sound` applies without a restart.
138747
- sound: params.sound ?? isFlagEnabled("boot-sound"),
138748
- guestVulkan: params.guestVulkan ?? androidGuestVulkanFromEnv(),
138749
- readOnly: params.readOnly ?? false,
138750
- port: params.port
138751
- });
139146
+ const running = runningEmulatorHold(ctx?.session);
139147
+ try {
139148
+ return await claimBooted(
139149
+ ctx?.session,
139150
+ await bootAndroid({
139151
+ avdName: params.avdName,
139152
+ bootTimeoutMs: params.bootTimeoutMs ?? 48e4,
139153
+ force: params.force,
139154
+ // An explicit argument always wins; the `boot-sound` flag only moves
139155
+ // the default when the caller left `sound` unset. Read live per call
139156
+ // so `argent enable/disable boot-sound` applies without a restart.
139157
+ sound: params.sound ?? isFlagEnabled("boot-sound"),
139158
+ guestVulkan: params.guestVulkan ?? androidGuestVulkanFromEnv(),
139159
+ readOnly: params.readOnly ?? false,
139160
+ port: params.port,
139161
+ session: ctx?.session,
139162
+ holdRunning: running.hold
139163
+ })
139164
+ );
139165
+ } finally {
139166
+ running.end();
139167
+ }
138752
139168
  }
138753
139169
  if (hasVega) {
138754
- return bootVega({
138755
- vvdImage: params.vvdImage,
138756
- bootTimeoutMs: params.bootTimeoutMs ?? 12e4,
138757
- force: params.force
138758
- });
139170
+ return claimBooted(
139171
+ ctx?.session,
139172
+ await bootVega({
139173
+ vvdImage: params.vvdImage,
139174
+ bootTimeoutMs: params.bootTimeoutMs ?? 12e4,
139175
+ force: params.force
139176
+ })
139177
+ );
138759
139178
  }
138760
139179
  if (hasHarmony) {
138761
- return bootHarmony({
138762
- instanceName: harmonyInstanceName(params.harmonyInstance),
138763
- bootTimeoutMs: params.bootTimeoutMs ?? HARMONY_BOOT_TIMEOUT_MS,
138764
- force: params.force
138765
- });
139180
+ return claimBooted(
139181
+ ctx?.session,
139182
+ await bootHarmony({
139183
+ instanceName: harmonyInstanceName(params.harmonyInstance),
139184
+ bootTimeoutMs: params.bootTimeoutMs ?? HARMONY_BOOT_TIMEOUT_MS,
139185
+ force: params.force
139186
+ })
139187
+ );
138766
139188
  }
138767
- return bootElectronApp({
138768
- appPath: params.electronAppPath,
138769
- port: params.electronPort,
138770
- extraArgs: params.electronArgs
138771
- });
139189
+ return claimBooted(
139190
+ ctx?.session,
139191
+ await bootElectronApp({
139192
+ appPath: params.electronAppPath,
139193
+ port: params.electronPort,
139194
+ extraArgs: params.electronArgs
139195
+ })
139196
+ );
138772
139197
  }
138773
139198
  };
138774
139199
  }
@@ -139389,7 +139814,7 @@ var capability3 = {
139389
139814
  harmony: { device: true },
139390
139815
  macos: { app: true, catalyst: true }
139391
139816
  };
139392
- var zodSchema12 = external_exports.object({
139817
+ var zodSchema13 = external_exports.object({
139393
139818
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`."),
139394
139819
  bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
139395
139820
  "App identifier (iOS<flag:macos-apps>/Mac app</flag:macos-apps> bundle id, Android package name, Vega interactive component app id from manifest.toml e.g. `com.example.app.main`,<flag:harmonyos> HarmonyOS bundle name from `bm dump -a`,</flag:harmonyos> or Chromium tag)."
@@ -139409,7 +139834,7 @@ Use when starting an app; prefer this over tapping home-screen icons.
139409
139834
  Returns { launched, bundleId, <flag:macos-apps>kind?, appPath?, args?, </flag:macos-apps>note?, networkCapture? }. Fails if the app is not installed.
139410
139835
  Common iOS ids: com.apple.Preferences, com.apple.mobilesafari, com.apple.MobileSMS, com.apple.Maps, com.apple.mobileslideshow, com.apple.MobileAddressBook.
139411
139836
  Common Android packages: com.android.settings, com.android.chrome, com.google.android.apps.maps.`,
139412
- zodSchema: zodSchema12,
139837
+ zodSchema: zodSchema13,
139413
139838
  alwaysLoad: true,
139414
139839
  searchHint: "open start app bundle id package simulator emulator chromium vega launch tvos apple tv fire tv",
139415
139840
  interaction: {
@@ -139693,7 +140118,7 @@ var capability4 = {
139693
140118
  harmony: { device: true },
139694
140119
  macos: { app: true, catalyst: true }
139695
140120
  };
139696
- var zodSchema13 = external_exports.object({
140121
+ var zodSchema14 = external_exports.object({
139697
140122
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`."),
139698
140123
  bundleId: external_exports.string().min(1).regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
139699
140124
  "App identifier (iOS<flag:macos-apps>/Mac app</flag:macos-apps> bundle id, Android package name, Vega interactive component app id<flag:harmonyos>, or HarmonyOS bundle name</flag:harmonyos>)."
@@ -139708,7 +140133,7 @@ function createRestartAppTool(registry2) {
139708
140133
  longRunning: true,
139709
140134
  description: `Terminate and relaunch an app (also refreshes native-devtools injection on iOS/tvOS).<flag:macos-apps> On a Mac app, quits and restarts the same .app in the background.</flag:macos-apps>
139710
140135
  Use when you need a clean in-memory app state without reinstalling. Returns { restarted, bundleId, <flag:macos-apps>kind?, appPath?, args?, note?, </flag:macos-apps>networkCapture? }. Fails if the app is not installed or fails to terminate.`,
139711
- zodSchema: zodSchema13,
140136
+ zodSchema: zodSchema14,
139712
140137
  alwaysLoad: true,
139713
140138
  searchHint: "terminate relaunch restart reset app bundle id package simulator emulator vega tvos fire tv<flag:harmonyos> harmony harmonyos</flag:harmonyos>",
139714
140139
  interaction: {
@@ -139753,7 +140178,7 @@ var capability5 = {
139753
140178
  vega: { vvd: true }
139754
140179
  };
139755
140180
  var VEGA_NOT_INSTALLED = /App could not be determined/i;
139756
- var zodSchema14 = external_exports.object({
140181
+ var zodSchema15 = external_exports.object({
139757
140182
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`."),
139758
140183
  bundleId: external_exports.string().min(1).regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe("App identifier. iOS: bundle id. Android: package name.")
139759
140184
  });
@@ -139763,7 +140188,7 @@ var terminateAppTool = {
139763
140188
  Use when a program needs the app closed between steps; agents use restart-app.
139764
140189
  Returns { terminated, bundleId }; terminated is false on iOS when the app was not running.
139765
140190
  Succeeds when the app is not running or not installed.`,
139766
- zodSchema: zodSchema14,
140191
+ zodSchema: zodSchema15,
139767
140192
  hideFromMcp: true,
139768
140193
  interaction: {
139769
140194
  startedMsg: ({ params }) => `Terminating ${params.bundleId}`,
@@ -139836,13 +140261,13 @@ init_zod();
139836
140261
  // ../tool-server/src/tools/reinstall-app/platforms/ios.ts
139837
140262
  var import_node_child_process43 = require("node:child_process");
139838
140263
  var import_node_util33 = require("node:util");
139839
- var import_node_path24 = require("node:path");
140264
+ var import_node_path25 = require("node:path");
139840
140265
  init_src2();
139841
140266
 
139842
140267
  // ../tool-server/src/tools/reinstall-app/validate-app.ts
139843
140268
  var import_node_child_process42 = require("node:child_process");
139844
140269
  var import_promises20 = require("node:fs/promises");
139845
- var import_node_path23 = require("node:path");
140270
+ var import_node_path24 = require("node:path");
139846
140271
  var import_node_util32 = require("node:util");
139847
140272
  init_capability();
139848
140273
 
@@ -139959,7 +140384,7 @@ function mismatch(bundleId, absolute, actual) {
139959
140384
  }
139960
140385
  async function assertIosAppBundle(absolute, bundleId, { readBundleId = true } = {}) {
139961
140386
  await requirePath(absolute, "directory", "an .app bundle directory");
139962
- const infoPlist = (0, import_node_path23.join)(absolute, "Info.plist");
140387
+ const infoPlist = (0, import_node_path24.join)(absolute, "Info.plist");
139963
140388
  if (!(await (0, import_promises20.stat)(infoPlist).catch(() => null))?.isFile()) {
139964
140389
  throw new InvalidToolInputError(
139965
140390
  `appPath ${absolute} has no Info.plist, so it is not an iOS .app bundle. Nothing was uninstalled.`
@@ -140024,7 +140449,7 @@ var iosImpl = {
140024
140449
  requires: ["xcrun"],
140025
140450
  handler: async (_services, params) => {
140026
140451
  const { udid, bundleId, appPath } = params;
140027
- const absolute = (0, import_node_path24.resolve)(appPath);
140452
+ const absolute = (0, import_node_path25.resolve)(appPath);
140028
140453
  await assertIosAppBundle(absolute, bundleId);
140029
140454
  const { nativeId, prefix } = await simctlTargetForUdid(udid);
140030
140455
  try {
@@ -140071,7 +140496,7 @@ var iosImpl = {
140071
140496
  };
140072
140497
 
140073
140498
  // ../tool-server/src/tools/reinstall-app/platforms/android.ts
140074
- var import_node_path25 = require("node:path");
140499
+ var import_node_path26 = require("node:path");
140075
140500
  init_src2();
140076
140501
  init_adb();
140077
140502
  async function isInstalled(udid, bundleId) {
@@ -140084,7 +140509,7 @@ var androidImpl3 = {
140084
140509
  requires: ["adb"],
140085
140510
  handler: async (_services, params) => {
140086
140511
  const { udid, bundleId, appPath } = params;
140087
- const absolute = (0, import_node_path25.resolve)(appPath);
140512
+ const absolute = (0, import_node_path26.resolve)(appPath);
140088
140513
  await assertApk(absolute, bundleId);
140089
140514
  const uninstall = await runAdb(["-s", udid, "uninstall", bundleId], {
140090
140515
  timeoutMs: 3e4
@@ -140136,7 +140561,7 @@ ${stderr}`;
140136
140561
  };
140137
140562
 
140138
140563
  // ../tool-server/src/tools/reinstall-app/platforms/ios-device.ts
140139
- var import_node_path26 = require("node:path");
140564
+ var import_node_path27 = require("node:path");
140140
140565
  init_capability();
140141
140566
  var iosDeviceImpl3 = {
140142
140567
  requires: ["xcrun"],
@@ -140146,7 +140571,7 @@ var iosDeviceImpl3 = {
140146
140571
  `${params.bundleId} is system UI: it is always running and cannot be reinstalled. Use launch-app to put it under automation.`
140147
140572
  );
140148
140573
  }
140149
- const absolute = (0, import_node_path26.resolve)(params.appPath);
140574
+ const absolute = (0, import_node_path27.resolve)(params.appPath);
140150
140575
  await assertIosAppBundle(absolute, params.bundleId);
140151
140576
  await ensureDeviceReady(params.udid);
140152
140577
  await uninstallApp(params.udid, params.bundleId);
@@ -140160,12 +140585,12 @@ var iosDeviceImpl3 = {
140160
140585
  };
140161
140586
 
140162
140587
  // ../tool-server/src/tools/reinstall-app/platforms/ios-remote.ts
140163
- var import_node_path27 = require("node:path");
140588
+ var import_node_path28 = require("node:path");
140164
140589
  var iosRemoteImpl3 = {
140165
140590
  requires: ["sim-remote"],
140166
140591
  handler: async (_services, params) => {
140167
140592
  const { udid, bundleId, appPath } = params;
140168
- const absolute = (0, import_node_path27.resolve)(appPath);
140593
+ const absolute = (0, import_node_path28.resolve)(appPath);
140169
140594
  await assertIosAppBundle(absolute, bundleId, { readBundleId: false });
140170
140595
  try {
140171
140596
  await simctlUninstall(udid, bundleId);
@@ -140177,13 +140602,13 @@ var iosRemoteImpl3 = {
140177
140602
  };
140178
140603
 
140179
140604
  // ../tool-server/src/tools/reinstall-app/platforms/vega.ts
140180
- var import_node_path28 = require("node:path");
140605
+ var import_node_path29 = require("node:path");
140181
140606
  init_src2();
140182
140607
  var vegaImpl3 = {
140183
140608
  requires: ["vega"],
140184
140609
  handler: async (_services, params) => {
140185
140610
  const { udid, bundleId, appPath } = params;
140186
- const absolute = (0, import_node_path28.resolve)(appPath);
140611
+ const absolute = (0, import_node_path29.resolve)(appPath);
140187
140612
  await assertVpkg(absolute);
140188
140613
  await vegaDevice(udid, ["uninstall-app", "-a", bundleId], { timeoutMs: 6e4 }).catch(
140189
140614
  () => {
@@ -140210,7 +140635,7 @@ ${stderr}`;
140210
140635
  };
140211
140636
 
140212
140637
  // ../tool-server/src/tools/reinstall-app/platforms/harmony.ts
140213
- var import_node_path29 = require("node:path");
140638
+ var import_node_path30 = require("node:path");
140214
140639
  init_src2();
140215
140640
  init_device_info();
140216
140641
  var INSTALLED = "msg:install bundle successfully.";
@@ -140221,7 +140646,7 @@ var harmonyImpl3 = {
140221
140646
  handler: async (_services, params, device) => {
140222
140647
  const { bundleId, appPath } = params;
140223
140648
  const connectKey = harmonyConnectKey(device.id);
140224
- const absolute = (0, import_node_path29.resolve)(appPath);
140649
+ const absolute = (0, import_node_path30.resolve)(appPath);
140225
140650
  await assertHap(absolute, bundleId);
140226
140651
  const uninstall = await runHdc(["-t", connectKey, "uninstall", bundleId], 6e4);
140227
140652
  if (!uninstall.stdout.includes(UNINSTALLED) && !uninstall.stdout.includes(NOT_INSTALLED)) {
@@ -140257,7 +140682,7 @@ var capability6 = {
140257
140682
  vega: { vvd: true },
140258
140683
  harmony: { device: true }
140259
140684
  };
140260
- var zodSchema15 = external_exports.object({
140685
+ var zodSchema16 = external_exports.object({
140261
140686
  udid: external_exports.string().min(1).describe(
140262
140687
  "Device id from `list-devices` (iOS UDID<flag:harmonyos>, HarmonyOS id,</flag:harmonyos> or Android serial)."
140263
140688
  ),
@@ -140275,7 +140700,7 @@ var reinstallAppTool = {
140275
140700
  description: `Install a fresh app package after uninstalling any existing build (clears app data and permissions).
140276
140701
  Use when installing a new build or resetting to clean state.
140277
140702
  Returns \`{ reinstalled, bundleId }\`. Fails if \`appPath\` is invalid or \`bundleId\` does not match it (not checked on Vega or remote simulators; checks run before uninstall), or if install fails. An uninstall error fails the call on Android and physical iPhones, and on a local simulator only when it times out; Vega and remote simulators ignore it.`,
140278
- zodSchema: zodSchema15,
140703
+ zodSchema: zodSchema16,
140279
140704
  interaction: {
140280
140705
  startedMsg: ({ params }) => `Reinstalling ${params.bundleId}`,
140281
140706
  completedMsg: ({ params }) => `Reinstalled ${params.bundleId}`,
@@ -140595,7 +141020,7 @@ var capability7 = {
140595
141020
  appleRemote: { simulator: true },
140596
141021
  android: { emulator: true, device: true, unknown: true }
140597
141022
  };
140598
- var zodSchema16 = external_exports.object({
141023
+ var zodSchema17 = external_exports.object({
140599
141024
  udid: external_exports.string().min(1).describe("Device id from `list-devices` (iOS simulator UDID or Android serial)."),
140600
141025
  action: external_exports.enum(PERMISSION_ACTIONS).describe("`grant` (pre-authorize), `deny`, or `reset` (re-prompt on next use)."),
140601
141026
  permission: external_exports.enum(PERMISSION_NAMES).describe("Permission name (`notifications` = Android-only; `reminders` = iOS-only)."),
@@ -140606,7 +141031,7 @@ var settingsPermissionsTool = {
140606
141031
  description: `Grant or deny an app's runtime permission, or reset it, without opening Settings. Use when setting up permissions before launching or triggering a prompt (changing permissions may terminate a running app).
140607
141032
  iOS sim: \`grant location\`/\`location-always\` requires the app installed first. Android: app must be installed and declare the mapped permissions in its manifest.
140608
141033
  Returns \`{ action, permission, bundleId, applied, skipped? }\`. Fails if nothing could be applied.`,
140609
- zodSchema: zodSchema16,
141034
+ zodSchema: zodSchema17,
140610
141035
  searchHint: "grant deny reset revoke app permissions privacy camera microphone location settings",
140611
141036
  interaction: {
140612
141037
  startedMsg: ({ params }) => `${permissionAction[params.action].started} ${params.permission} permission for ${params.bundleId}`,
@@ -140859,7 +141284,7 @@ var capability8 = {
140859
141284
  harmony: { device: true },
140860
141285
  macos: { app: true, catalyst: true }
140861
141286
  };
140862
- var zodSchema17 = external_exports.object({
141287
+ var zodSchema18 = external_exports.object({
140863
141288
  udid: external_exports.string().min(1).describe(
140864
141289
  "Device id from `list-devices` (iOS UDID, Android serial, <flag:harmonyos>HarmonyOS id, </flag:harmonyos>or Chromium id)."
140865
141290
  ),
@@ -140876,7 +141301,7 @@ var openUrlTool = {
140876
141301
  description: `Open a URL or deep-link scheme on the device.
140877
141302
  Use when navigating to a web page or deep-linking into an app (prefer custom schemes or \`launch-app\` over \`https://\` Universal/App Links). On Chromium, navigates the primary page (non-page schemes like \`tel:\`/\`mailto:\` fail). On physical iOS, the receiving app becomes active for automation.<flag:harmonyos> HarmonyOS opens URIs via \`aa start -U\`.</flag:harmonyos>
140878
141303
  Returns \`{ opened, url, note? }\`. Fails if no handler is registered<flag:harmonyos> (iOS/Android/HarmonyOS)</flag:harmonyos> or Chromium rejects navigation.`,
140879
- zodSchema: zodSchema17,
141304
+ zodSchema: zodSchema18,
140880
141305
  interaction: {
140881
141306
  startedMsg: ({ params }) => `Opening ${safeDestination(params.url)}`,
140882
141307
  completedMsg: ({ params }) => `Opened ${safeDestination(params.url)}`,
@@ -141057,34 +141482,6 @@ var import_node_path31 = require("node:path");
141057
141482
  var import_pngjs3 = __toESM(require_png());
141058
141483
  init_src2();
141059
141484
  init_adb();
141060
-
141061
- // ../tool-server/src/utils/emulator-console.ts
141062
- var import_node_os16 = require("node:os");
141063
- var import_node_path30 = require("node:path");
141064
- init_adb();
141065
- async function runEmuConsole(serial, args) {
141066
- const { stdout } = await runAdb(["-s", serial, "emu", ...args], { timeoutMs: 1e4 });
141067
- const verdict = replyLines(stdout).at(-1);
141068
- if (verdict?.startsWith("KO:")) {
141069
- throw new Error(
141070
- `emulator console rejected \`${args.join(" ")}\` \u2014 ${describeConsoleReply(stdout)}`
141071
- );
141072
- }
141073
- return stdout;
141074
- }
141075
- function describeConsoleReply(stdout) {
141076
- const lines = replyLines(stdout);
141077
- const reply = lines.join("; ") || "empty reply";
141078
- if (!lines.at(-1)?.startsWith("KO: unknown command")) return reply;
141079
- const tokenFile = (0, import_node_path30.join)((0, import_node_os16.homedir)(), ".emulator_console_auth_token");
141080
- const fileKind = process.platform === "win32" ? "a file" : "a regular file, not a symlink,";
141081
- return `${reply} (adb authenticates to the console with ${tokenFile}, which must be ${fileKind} holding the emulator's token)`;
141082
- }
141083
- function replyLines(stdout) {
141084
- return stdout.split("\n").map((line) => line.trim()).filter(Boolean);
141085
- }
141086
-
141087
- // ../tool-server/src/utils/vega-screen.ts
141088
141485
  async function captureVegaScreenshotPng(opts = {}) {
141089
141486
  return captureViaEmulatorConsole(opts);
141090
141487
  }
@@ -141271,7 +141668,7 @@ async function downscalePngInPlace(file2, scale, signal) {
141271
141668
  }).catch(() => {
141272
141669
  });
141273
141670
  }
141274
- var zodSchema18 = external_exports.object({
141671
+ var zodSchema19 = external_exports.object({
141275
141672
  udid: external_exports.string().describe("Target device id from `list-devices`."),
141276
141673
  rotation: external_exports.enum(["Portrait", "LandscapeLeft", "LandscapeRight", "PortraitUpsideDown"]).optional().describe(
141277
141674
  "Orientation override (rarely needed; captures already follow UI orientation).<flag:harmonyos> Rejected on HarmonyOS (captures display in current orientation).</flag:harmonyos> Ignored on physical iPhones."
@@ -141289,7 +141686,7 @@ function createScreenshotTool(registry2) {
141289
141686
  id: "screenshot",
141290
141687
  description: `Capture a PNG screenshot of the device screen.
141291
141688
  Use when you need a baseline image or the screen state after a delay (interaction tools already attach a screenshot). Returns { image }. Fails if the capture backend is unreachable.`,
141292
- zodSchema: zodSchema18,
141689
+ zodSchema: zodSchema19,
141293
141690
  alwaysLoad: true,
141294
141691
  searchHint: "device simulator emulator chromium screen image capture baseline tvos apple tv",
141295
141692
  readOnly: true,
@@ -141496,7 +141893,7 @@ async function tapHarmony(connectKey, x, y, clickCount, signal) {
141496
141893
  signal
141497
141894
  );
141498
141895
  }
141499
- var zodSchema19 = external_exports.object({
141896
+ var zodSchema20 = external_exports.object({
141500
141897
  udid: external_exports.string().describe("Target device id from `list-devices`."),
141501
141898
  x: external_exports.number().min(0).max(1).describe("Horizontal screen fraction [0,1]."),
141502
141899
  y: external_exports.number().min(0).max(1).describe("Vertical screen fraction [0,1]."),
@@ -141510,7 +141907,7 @@ var gestureTapTool = {
141510
141907
  id: "gesture-tap",
141511
141908
  description: `Press (tap, or click on Chromium<flag:macos-apps>/Mac</flag:macos-apps>) at normalized [0,1] coordinates taken from \`describe\`.
141512
141909
  Use when tapping a button, link, or control. Returns { tapped: true, timestampMs, reactivated?, warning? } (on physical iOS, \`reactivated: true\` means re-fronted; re-describe). Fails if the device backend is unreachable.`,
141513
- zodSchema: zodSchema19,
141910
+ zodSchema: zodSchema20,
141514
141911
  alwaysLoad: true,
141515
141912
  // A physical iPhone's first call waits out the runner build, past the MCP fetch timeout,
141516
141913
  // whose abort replays the call: the gesture would land once per replay.
@@ -141629,7 +142026,7 @@ var capability11 = {
141629
142026
  android: { emulator: true, device: true, unknown: true },
141630
142027
  harmony: { device: true }
141631
142028
  };
141632
- var zodSchema20 = external_exports.object({
142029
+ var zodSchema21 = external_exports.object({
141633
142030
  udid: external_exports.string().describe("Target device id from `list-devices`."),
141634
142031
  fromX: external_exports.number().min(0).max(1).describe("Start x [0,1]."),
141635
142032
  fromY: external_exports.number().min(0).max(1).describe("Start y [0,1]."),
@@ -141663,7 +142060,7 @@ var gestureSwipeTool = {
141663
142060
  description: `Execute a swipe/drag between two normalized [0,1] points on touch devices (swipe up, fromY > toY, to scroll down).
141664
142061
  Use when scrolling a list, dismissing a modal, or swiping between pages (not Chromium<flag:macos-apps>/Mac</flag:macos-apps>: use \`gesture-scroll\` / \`gesture-drag\`). Returns { swiped: true, timestampMs, reactivated?, warning? }. Fails if the touch backend is unreachable.
141665
142062
  Physical iOS: an edge gesture (back-swipe) needs \`fromX: 0\` exactly; \`durationMs\` sets drag speed, not time; \`momentum: false\` only rests 300ms at the end and does not damp.<flag:harmonyos> HarmonyOS: \`durationMs\` sets drag speed, clamped to 200\u201340000 px/s.</flag:harmonyos>`,
141666
- zodSchema: zodSchema20,
142063
+ zodSchema: zodSchema21,
141667
142064
  alwaysLoad: true,
141668
142065
  // A physical iPhone's first call waits out the runner build, past the MCP fetch timeout,
141669
142066
  // whose abort replays the call: the gesture would land once per replay.
@@ -141808,7 +142205,7 @@ var capability12 = {
141808
142205
  chromium: { app: true },
141809
142206
  macos: { app: true, catalyst: true }
141810
142207
  };
141811
- var zodSchema21 = external_exports.object({
142208
+ var zodSchema22 = external_exports.object({
141812
142209
  udid: external_exports.string().describe(
141813
142210
  "Chromium device id (`chromium-cdp-<port>`)<flag:macos-apps> or Mac app id</flag:macos-apps> from `list-devices`."
141814
142211
  ),
@@ -141827,7 +142224,7 @@ var gestureScrollTool = {
141827
142224
  description: `Send mouse-wheel scroll events at normalized [0,1] anchor (x, y) in Chromium<flag:macos-apps> or a Mac app</flag:macos-apps>.
141828
142225
  Use when scrolling desktop lists or off-screen content (use \`gesture-swipe\` on iOS/Android<flag:harmonyos>/HarmonyOS</flag:harmonyos>).
141829
142226
  Returns \`{ scrolled: true, timestampMs }\`. Fails if CDP is unreachable<flag:macos-apps> or nothing under the point scrolls on a Mac app</flag:macos-apps>.`,
141830
- zodSchema: zodSchema21,
142227
+ zodSchema: zodSchema22,
141831
142228
  searchHint: "scroll wheel list page chromium<flag:macos-apps> mac</flag:macos-apps> mouse down up content fold",
141832
142229
  interaction: {
141833
142230
  startedMsg: ({ params }) => `Scrolling ${scrollDirection(params)}`,
@@ -141884,7 +142281,7 @@ function hoverDescription(params, tense) {
141884
142281
  const at = `(${Math.round((params.x ?? 0) * 100)}%, ${Math.round((params.y ?? 0) * 100)}%)`;
141885
142282
  return `${tense === "present" ? "Hovering" : "Hovered"} at ${at}`;
141886
142283
  }
141887
- var zodSchema22 = external_exports.object({
142284
+ var zodSchema23 = external_exports.object({
141888
142285
  udid: external_exports.string().describe("Mac app device ID from `list-devices`."),
141889
142286
  x: external_exports.number().min(0).max(1).optional().describe(
141890
142287
  "Horizontal fraction of the area reported by `describe`, measured from the left. Required unless `leave` is true."
@@ -141909,7 +142306,7 @@ var gestureHoverTool = {
141909
142306
  description: `Move Argent's pointer in a Mac app to check hover effects, such as controls that appear on hover. Standard macOS tooltips are unavailable. Use \`gesture-tap\` directly to click a visible control. It moves the pointer before clicking.
141910
142307
  The pointer stays in place until another pointer action or until the user clicks, scrolls, or presses a key in the app. If user input interrupts the move, the call fails with \`MACOS_APP_POINTER_TAKEN_OVER\`. Retry once the user finishes.
141911
142308
  On \`MACOS_APP_LIBRARY_OUTDATED\`, run \`restart-app\` to reload the library, then retry.`,
141912
- zodSchema: zodSchema22,
142309
+ zodSchema: zodSchema23,
141913
142310
  searchHint: "hover mouse over mouseover pointer rollover mouseEnter mouse enter leave highlight reveal mac app",
141914
142311
  featureFlag: "macos-apps",
141915
142312
  interaction: {
@@ -142006,7 +142403,7 @@ async function runPointerDrag(from2, to, opts, pointer) {
142006
142403
  throw err;
142007
142404
  }
142008
142405
  }
142009
- var zodSchema23 = external_exports.object({
142406
+ var zodSchema24 = external_exports.object({
142010
142407
  udid: external_exports.string().describe(
142011
142408
  "Chromium device id (`chromium-cdp-<port>`)<flag:macos-apps> or Mac app id</flag:macos-apps> from `list-devices`."
142012
142409
  ),
@@ -142033,7 +142430,7 @@ var gestureDragTool = {
142033
142430
  description: `Drag the left mouse button between normalized [0,1] window points in Chromium<flag:macos-apps> or a Mac app</flag:macos-apps>.
142034
142431
  Use when dragging sliders, drag-and-drop items, or selecting text (use \`gesture-scroll\` to scroll desktop lists; use \`gesture-swipe\` on iOS/Android<flag:harmonyos>/HarmonyOS</flag:harmonyos>).<flag:macos-apps> Mac app: same start/end point = long press; drops stay inside the app's windows.</flag:macos-apps>
142035
142432
  Returns \`{ dragged: true, timestampMs }\`. Fails if the CDP session is unreachable.`,
142036
- zodSchema: zodSchema23,
142433
+ zodSchema: zodSchema24,
142037
142434
  searchHint: "drag drop slider mouse press move release chromium<flag:macos-apps> mac</flag:macos-apps> select",
142038
142435
  interaction: {
142039
142436
  startedMsg: ({ params }) => `Dragging from (${Math.round(params.fromX * 100)}%, ${Math.round(params.fromY * 100)}%) to (${Math.round(params.toX * 100)}%, ${Math.round(params.toY * 100)}%)`,
@@ -142316,7 +142713,7 @@ var eventSchema = external_exports.object({
142316
142713
  y2: external_exports.number().min(0).max(1).optional().describe("Second finger y."),
142317
142714
  delayMs: external_exports.number().optional().describe("Delay before event in ms (default 16).")
142318
142715
  });
142319
- var zodSchema24 = external_exports.object({
142716
+ var zodSchema25 = external_exports.object({
142320
142717
  udid: external_exports.string().describe("Target device id from `list-devices` (iOS UDID or Android serial)."),
142321
142718
  edge: external_exports.enum(screenEdges).optional().describe("Starting screen edge for a single-finger system gesture (local iOS simulator)."),
142322
142719
  events: external_exports.array(eventSchema).describe("Ordered touch events."),
@@ -142342,7 +142739,7 @@ Physical iOS: Down, optional Moves, then Up (\`x2\`/\`y2\` = second finger). Pla
142342
142739
  Simulator/emulator: a train that ends without Up leaves the finger down and returns \`{ held: true }\`, so \`screenshot\`/\`describe\` can observe a pressed state; the next call continues it (start with Move or Up), and any new Down first lifts it. Argent lifts a held finger after 30 seconds. Not with \`edge\` or on physical iOS.
142343
142740
  Example long-press + drag: \`[{"type":"Down","x":0.5,"y":0.6},{"type":"Move","x":0.5,"y":0.6,"delayMs":800},{"type":"Up","x":0.5,"y":0.3,"delayMs":500}]\`.
142344
142741
  Returns \`{ events, held?, reactivated? }\` (on physical iOS, \`reactivated: true\` means re-describe). Fails if device is not booted or events are invalid.`,
142345
- zodSchema: zodSchema24,
142742
+ zodSchema: zodSchema25,
142346
142743
  interaction: {
142347
142744
  startedMsg: () => "Performing custom gesture",
142348
142745
  completedMsg: () => "Performed custom gesture",
@@ -142442,7 +142839,7 @@ var capability16 = {
142442
142839
  android: { emulator: true, device: true, unknown: true },
142443
142840
  harmony: { device: true }
142444
142841
  };
142445
- var zodSchema25 = external_exports.object({
142842
+ var zodSchema26 = external_exports.object({
142446
142843
  udid: external_exports.string().describe(
142447
142844
  "Device id from `list-devices` (iOS UDID<flag:harmonyos>, HarmonyOS id,</flag:harmonyos> or Android serial)."
142448
142845
  ),
@@ -142462,7 +142859,7 @@ var gesturePinchTool = {
142462
142859
  description: `Send a two-finger pinch-to-zoom gesture in normalized [0,1] coords (\`startDistance < endDistance\` zooms in, e.g. 0.2\u21920.6; \`>\` zooms out).
142463
142860
  Use when zooming maps, photos, or zoomable views (use \`gesture-rotate\` to rotate).
142464
142861
  Returns \`{ pinched: true, timestampMs, reactivated? }\` (on physical iOS, \`reactivated: true\` means re-describe). Fails if the backend<flag:harmonyos> (\`hdc\` on HarmonyOS)</flag:harmonyos> is unreachable or a physical iPhone app is not in portrait.`,
142465
- zodSchema: zodSchema25,
142862
+ zodSchema: zodSchema26,
142466
142863
  interaction: {
142467
142864
  startedMsg: ({ params }) => `Pinching ${params.endDistance > params.startDistance ? "out" : "in"} at (${Math.round(params.centerX * 100)}%, ${Math.round(params.centerY * 100)}%)`,
142468
142865
  completedMsg: ({ params }) => `Pinched ${params.endDistance > params.startDistance ? "out" : "in"} at (${Math.round(params.centerX * 100)}%, ${Math.round(params.centerY * 100)}%)`,
@@ -142559,7 +142956,7 @@ var capability17 = {
142559
142956
  appleRemote: { simulator: true },
142560
142957
  android: { emulator: true, device: true, unknown: true }
142561
142958
  };
142562
- var zodSchema26 = external_exports.object({
142959
+ var zodSchema27 = external_exports.object({
142563
142960
  udid: external_exports.string().describe("Device id from `list-devices` (iOS UDID or Android serial)."),
142564
142961
  centerX: external_exports.number().describe("Normalized rotation center x."),
142565
142962
  centerY: external_exports.number().describe("Normalized rotation center y."),
@@ -142579,7 +142976,7 @@ var gestureRotateTool = {
142579
142976
  description: `Send a two-finger circular arc gesture in normalized [0,1] coords to rotate content from \`startAngle\` to \`endAngle\`. Pass \`radius\`, or \`radiusX\`+\`radiusY\` with \`radiusX\xB7width = radiusY\xB7height\` for a circular physical orbit (a single radius or equal values trace an ellipse on a non-square screen; one half of the pair alone is rejected).
142580
142977
  Use when rotating a map, photo, or canvas (use \`gesture-pinch\` for zoom).
142581
142978
  Returns \`{ rotated: true, timestampMs, reactivated? }\` (on physical iOS, \`reactivated: true\` means re-describe). Fails if the backend is unreachable or a physical iPhone app is not in portrait.`,
142582
- zodSchema: zodSchema26,
142979
+ zodSchema: zodSchema27,
142583
142980
  interaction: {
142584
142981
  startedMsg: ({ params }) => {
142585
142982
  const degrees = Math.abs(params.endAngle - params.startAngle);
@@ -142702,7 +143099,7 @@ var RUNNER_UNSUPPORTED_OPERATION_CODE = "UNSUPPORTED_OPERATION";
142702
143099
  function isPhysicalIosButton(button) {
142703
143100
  return PHYSICAL_IOS_BUTTONS.has(button);
142704
143101
  }
142705
- var zodSchema27 = external_exports.object({
143102
+ var zodSchema28 = external_exports.object({
142706
143103
  udid: external_exports.string().describe(
142707
143104
  "Target device id from `list-devices` (iOS UDID<flag:harmonyos>, HarmonyOS id,</flag:harmonyos> or Android serial)."
142708
143105
  ),
@@ -142715,7 +143112,7 @@ Supported buttons depend on the platform: buttons not present on the target (e.g
142715
143112
  Use when you need to trigger hardware button events.
142716
143113
  Returns { pressed: buttonName }.
142717
143114
  Fails if the device backend is not reachable: the simulator-server for iOS, <flag:harmonyos>\`hdc\` for HarmonyOS, </flag:harmonyos>or \`adb\` for Android.`,
142718
- zodSchema: zodSchema27,
143115
+ zodSchema: zodSchema28,
142719
143116
  interaction: {
142720
143117
  startedMsg: ({ params }) => `Pressing ${params.button} button`,
142721
143118
  completedMsg: ({ params }) => `Pressed ${params.button} button`,
@@ -144098,7 +144495,7 @@ var capability19 = {
144098
144495
  harmony: { device: true },
144099
144496
  macos: { app: true, catalyst: true }
144100
144497
  };
144101
- var zodSchema28 = external_exports.object({
144498
+ var zodSchema29 = external_exports.object({
144102
144499
  udid: external_exports.string().describe("Target device id from `list-devices`."),
144103
144500
  text: external_exports.string().optional().describe(
144104
144501
  "Text to type. Cannot be combined with `key`. Use `{{secret:NAME}}` for credentials, looked up where the MCP server started, first match wins: the `ARGENT_SECRET_NAME` env var, the project's `.argent/secrets.env`, `ARGENT_SECRET_NAME` in the project's `.env.local` or `.env`, then `~/.argent/secrets.env`. Ask the user to configure missing secrets there without sharing their values. Secret placeholders suppress the automatic screenshot for the call. Use one `run-sequence` to type a secret and press Enter with the same protection."
@@ -144134,7 +144531,7 @@ function createKeyboardTool(registry2) {
144134
144531
  description: `Type text or press a named key on the focused field (tap or focus the field first; with no focus input is silently dropped).
144135
144532
  Use when entering text or triggering named keys (enter, escape, backspace, arrows).
144136
144533
  Returns { typed, keys, cleared?, verified?, warning?, reactivated? }. Fails if an unsupported key or untypeable character is passed or the input backend is unreachable (partial typing is not rolled back: on an iOS simulator or Chromium, the characters before an untypeable one stay typed; re-read before retrying). On iOS simulators, typing into an empty field verifies readback (\`verified: false\` warns). React Native: after typing, the next tap outside may only close the keyboard (tap again if so); where the field submits on return, \`key: "enter"\` avoids the extra tap.`,
144137
- zodSchema: zodSchema28,
144534
+ zodSchema: zodSchema29,
144138
144535
  alwaysLoad: true,
144139
144536
  searchHint: "type text keyboard input named key enter escape arrow tv vega fire tv <flag:harmonyos>harmony harmonyos </flag:harmonyos>search field hid leanback",
144140
144537
  interaction: {
@@ -144450,7 +144847,7 @@ var capability21 = {
144450
144847
  appleRemote: { simulator: true },
144451
144848
  android: { emulator: true, device: true, unknown: true }
144452
144849
  };
144453
- var zodSchema29 = external_exports.object({
144850
+ var zodSchema30 = external_exports.object({
144454
144851
  udid: external_exports.string().describe("Target device id from `list-devices` (iOS UDID or Android serial)."),
144455
144852
  orientation: external_exports.enum(["Portrait", "LandscapeLeft", "LandscapeRight", "PortraitUpsideDown"]).describe("Target orientation")
144456
144853
  });
@@ -144464,7 +144861,7 @@ function createRotateTool(registry2) {
144464
144861
  Use when testing layout in a different orientation. Re-run \`describe\` afterwards: frame coordinates change with the orientation.
144465
144862
  On an unfolded foldable iOS simulator (the iPhone Duo), the value sets the orientation of the device, not of the UI: \`Portrait\` gives a landscape UI and \`LandscapeLeft\` gives a portrait UI. To fold or unfold the device, use \`fold\`.
144466
144863
  Returns { orientation }. Fails on a TV target, or if the target device is not booted.`,
144467
- zodSchema: zodSchema29,
144864
+ zodSchema: zodSchema30,
144468
144865
  interaction: {
144469
144866
  startedMsg: ({ params }) => `Rotating device to ${params.orientation}`,
144470
144867
  completedMsg: ({ params }) => `Rotated device to ${params.orientation}`,
@@ -145677,7 +146074,7 @@ var iosImpl6 = {
145677
146074
  };
145678
146075
  }
145679
146076
  };
145680
- var zodSchema30 = external_exports.object({
146077
+ var zodSchema31 = external_exports.object({
145681
146078
  udid: external_exports.string().describe(
145682
146079
  "Foldable device id from `list-devices` (iOS simulator UDID or Android emulator serial)."
145683
146080
  ),
@@ -145692,7 +146089,7 @@ var foldTool = {
145692
146089
  Use when testing an app across folded/unfolded postures (\`list-devices\` marks \`foldable: true\`; use \`rotate\` for orientation). Coordinates change with the active panel, so read the returned tree or call \`describe\` before tapping.
145693
146090
  iOS: fold to \`closed\`/\`open\` to guarantee a panel switch; returns \`{ activeScreen, screen, posture?, hingeAngle, warning? }\`. A remote iOS simulator returns it without the panel size. Android: returns \`{ posture?, deviceState, hingeAngle?, warning? }\` (use Pixel Fold AVD for accurate cover-panel coords).
145694
146091
  Fails if the device is not foldable or is a physical Android device.`,
145695
- zodSchema: zodSchema30,
146092
+ zodSchema: zodSchema31,
145696
146093
  searchHint: "fold unfold hinge foldable duo posture open closed half-open panel screen split view",
145697
146094
  interaction: {
145698
146095
  startedMsg: ({ params }) => `Folding device to ${targetLabel2(params)}`,
@@ -145817,7 +146214,7 @@ var buttonSchema = external_exports.preprocess(
145817
146214
  ).describe(
145818
146215
  'Single remote button or array path run in one call (e.g. ["up","right","select"]; prefer an array over repeated calls).'
145819
146216
  );
145820
- var zodSchema31 = external_exports.object({
146217
+ var zodSchema32 = external_exports.object({
145821
146218
  udid: external_exports.string().describe("TV device id from `list-devices` (Apple TV, Android TV, or Vega)."),
145822
146219
  button: buttonSchema,
145823
146220
  repeat: external_exports.number().int().min(1).max(50).optional().describe('Repeat `button` N times (default 1, e.g. `{ button: "down", repeat: 12 }`).')
@@ -145828,7 +146225,7 @@ function createTvRemoteTool(registry2) {
145828
146225
  description: `Press a TV remote / D-pad button (or array path) on Apple TV (tvOS), Android TV, or Vega (Fire TV).
145829
146226
  Use when navigating focus or pressing remote keys on a TV instead of touch gestures. Call \`describe\` first to locate focus; check the returned tree after.
145830
146227
  Returns \`{ pressed, count }\`. Fails on non-TV targets, or on Apple TV sim for rewind/fastForward/next/previous/volume/mute.`,
145831
- zodSchema: zodSchema31,
146228
+ zodSchema: zodSchema32,
145832
146229
  searchHint: "tv remote dpad d-pad navigate focus up down left right select ok back home menu play pause rewind fast forward sequence path apple tv tvos android tv leanback vega fire tv",
145833
146230
  interaction: {
145834
146231
  startedMsg: ({ params }) => `Pressing ${params.button} on TV remote${(params.repeat ?? 1) > 1 ? ` ${params.repeat} times` : ""}`,
@@ -146032,7 +146429,8 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
146032
146429
  ...flowStack ? { flowStack } : {},
146033
146430
  ...flowSecret ? { flowSecret } : {},
146034
146431
  ...extra?.flowOutput ? { flowOutput: extra.flowOutput } : {},
146035
- ...ctx?.clientSecrets ? { clientSecrets: ctx.clientSecrets } : {}
146432
+ ...ctx?.clientSecrets ? { clientSecrets: ctx.clientSecrets } : {},
146433
+ ...ctx?.session ? { session: ctx.session } : {}
146036
146434
  };
146037
146435
  if (!recordChildInvocation) {
146038
146436
  return signal || Object.keys(forwarded).length > 0 ? registry2.invokeTool(toolId, args, { ...signal ? { signal } : {}, ...forwarded }) : registry2.invokeTool(toolId, args);
@@ -146052,9 +146450,9 @@ async function invokeSubTool(registry2, ctx, toolId, args, extra) {
146052
146450
  }
146053
146451
  function describeNestedParamError(registry2, err, toolId, dispatchedArgs, authoredArgs) {
146054
146452
  if (getFailureSignal(err)?.error_code !== FAILURE_CODES.TOOL_INPUT_INVALID) return void 0;
146055
- const zodSchema90 = registry2.getTool(toolId)?.zodSchema;
146056
- if (!zodSchema90) return void 0;
146057
- const parsed2 = zodSchema90.safeParse(dispatchedArgs ?? {});
146453
+ const zodSchema91 = registry2.getTool(toolId)?.zodSchema;
146454
+ if (!zodSchema91) return void 0;
146455
+ const parsed2 = zodSchema91.safeParse(dispatchedArgs ?? {});
146058
146456
  if (parsed2.success) return void 0;
146059
146457
  return `Invalid params for tool "${toolId}": ${describeParamIssues(parsed2.error, authoredArgs)}`;
146060
146458
  }
@@ -146107,7 +146505,7 @@ var capability26 = {
146107
146505
  // A Mac app takes the mouse and keyboard steps; touch-only steps fail at their own gate.
146108
146506
  macos: { app: true, catalyst: true }
146109
146507
  };
146110
- var zodSchema32 = external_exports.object({
146508
+ var zodSchema33 = external_exports.object({
146111
146509
  udid: external_exports.string().describe("Target device id from `list-devices`, shared across all steps."),
146112
146510
  steps: external_exports.array(
146113
146511
  external_exports.object({
@@ -146182,7 +146580,7 @@ Allowed tools (coords are [0,1] screen fractions; ? = optional):
146182
146580
  tv-remote: button (string or string[]), repeat?
146183
146581
  await-ui-element: condition ("exists"|"visible"|"hidden"|"text"), selector, expectedText?, textMatch?, timeoutMs?, pollIntervalMs?
146184
146582
  await-network-request: bundleId, url, plus optional args (start capture first)`,
146185
- zodSchema: zodSchema32,
146583
+ zodSchema: zodSchema33,
146186
146584
  alwaysLoad: true,
146187
146585
  searchHint: "batch sequence multiple gesture steps sequentially",
146188
146586
  interaction: {
@@ -146264,7 +146662,7 @@ Allowed tools (coords are [0,1] screen fractions; ? = optional):
146264
146662
 
146265
146663
  // ../tool-server/src/tools/debugger/debugger-connect.ts
146266
146664
  init_zod();
146267
- var zodSchema33 = external_exports.object({
146665
+ var zodSchema34 = external_exports.object({
146268
146666
  port: metroPortField,
146269
146667
  device_id: external_exports.string().describe(
146270
146668
  "Device id from `list-devices`: iOS UDID, Android/Vega serial, <flag:macos-apps>Mac app id (`macos-app-<bundle id>`), </flag:macos-apps>or Chromium id (`chromium-cdp-<port>`). Reuse this same id on subsequent `debugger-*` calls (or pass the error's `logicalDeviceId` if shared Metro is ambiguous)."
@@ -146275,7 +146673,7 @@ var debuggerConnectTool = {
146275
146673
  description: `Connect to an app's JS debugger (React Native via Metro, or Chromium CDP) and start capturing console logs; reuses existing connections.<flag:macos-apps> Mac apps need a Debug build loading JS from Metro (react-native-macos 0.76+ or Mac Catalyst launched via Argent).</flag:macos-apps>
146276
146674
  Use when starting a debug session or before other \`debugger-*\` tools (keep the same \`device_id\`; retry with \`logicalDeviceId\` only if shared Metro reports ambiguity<flag:macos-apps>; Mac apps always keep the Mac app id</flag:macos-apps>).
146277
146675
  Returns connection info (plus \`note\` with prior log path after a crash). Fails if the runtime is unreachable.`,
146278
- zodSchema: zodSchema33,
146676
+ zodSchema: zodSchema34,
146279
146677
  interaction: {
146280
146678
  startedMsg: () => "Connecting JavaScript debugger",
146281
146679
  completedMsg: ({ result }) => `Connected JavaScript debugger to ${result.appName || result.deviceName}`,
@@ -146307,7 +146705,7 @@ Returns connection info (plus \`note\` with prior log path after a crash). Fails
146307
146705
  // ../tool-server/src/tools/debugger/debugger-status.ts
146308
146706
  init_zod();
146309
146707
  init_device_info();
146310
- var zodSchema34 = external_exports.object({
146708
+ var zodSchema35 = external_exports.object({
146311
146709
  port: metroPortField,
146312
146710
  device_id: external_exports.string().describe(
146313
146711
  "Device id from `debugger-connect`<flag:macos-apps> (macOS: Mac app id)</flag:macos-apps>."
@@ -146319,7 +146717,7 @@ function createDebuggerStatusTool(registry2) {
146319
146717
  description: `Check JS runtime debugger connectivity and diagnostics.
146320
146718
  Use when verifying debugger health before other \`debugger-*\` tools.
146321
146719
  Returns \`{ status: "connected", port, projectRoot, deviceName, appName, logicalDeviceId, isNewDebugger, loadedScripts, sourceMapReady }\` or \`{ status: "not_connected", reason, detail, guidance }\` (follow \`guidance\`; don't retry in a loop). Never fails when the runtime is simply unreachable.`,
146322
- zodSchema: zodSchema34,
146720
+ zodSchema: zodSchema35,
146323
146721
  readOnly: true,
146324
146722
  interaction: {
146325
146723
  startedMsg: () => "Checking JavaScript debugger",
@@ -146412,7 +146810,7 @@ function guardModuleLoadErrors(expression) {
146412
146810
  }
146413
146811
 
146414
146812
  // ../tool-server/src/tools/debugger/debugger-evaluate.ts
146415
- var zodSchema35 = external_exports.object({
146813
+ var zodSchema36 = external_exports.object({
146416
146814
  port: metroPortField,
146417
146815
  device_id: external_exports.string().describe(
146418
146816
  "Device id from `debugger-connect`<flag:macos-apps> (macOS: Mac app id)</flag:macos-apps>."
@@ -146424,7 +146822,7 @@ var debuggerEvaluateTool = {
146424
146822
  description: `Run JavaScript in the app runtime (Hermes on React Native/Vega<flag:macos-apps>/Mac apps</flag:macos-apps>; V8 on Chromium; awaits Promises).
146425
146823
  Use when inspecting runtime state (e.g. localStorage/sessionStorage on Chromium) or calling app functions.
146426
146824
  Returns \`{ result, deviceName, appName, logicalDeviceId }\` (JSON-serialized; cyclic objects fail). Fails if disconnected or the expression throws.`,
146427
- zodSchema: zodSchema35,
146825
+ zodSchema: zodSchema36,
146428
146826
  searchHint: "javascript js eval expression runtime app state localstorage sessionstorage web storage",
146429
146827
  interaction: {
146430
146828
  startedMsg: () => "Running JavaScript in the app",
@@ -146469,7 +146867,7 @@ Returns \`{ result, deviceName, appName, logicalDeviceId }\` (JSON-serialized; c
146469
146867
  init_zod();
146470
146868
  init_device_info();
146471
146869
  init_src2();
146472
- var zodSchema36 = external_exports.object({
146870
+ var zodSchema37 = external_exports.object({
146473
146871
  port: metroPortField,
146474
146872
  device_id: external_exports.string().describe(
146475
146873
  "Device id used with debugger-connect<flag:macos-apps>. For macOS, use the Mac app id</flag:macos-apps>."
@@ -146479,7 +146877,7 @@ var debuggerReloadMetroTool = {
146479
146877
  id: "debugger-reload-metro",
146480
146878
  description: `Restart the Metro JS bundle in the connected React Native app without restarting the native process.
146481
146879
  Use when you want to apply code changes or reset JS state. Returns { reloaded, port, method (cdp or http), deviceName, appName, logicalDeviceId }. Fails if Metro is not running on the given port.<flag:macos-apps> A Mac app reload targets only that app. If it fails, restart the app. A shared Metro reload would also reload other apps.</flag:macos-apps>`,
146482
- zodSchema: zodSchema36,
146880
+ zodSchema: zodSchema37,
146483
146881
  interaction: {
146484
146882
  startedMsg: () => "Reloading the app through Metro",
146485
146883
  completedMsg: () => "Reloaded the app through Metro",
@@ -147360,7 +147758,7 @@ function buildTextTree(data, opts) {
147360
147758
  }
147361
147759
  return lines.join("\n");
147362
147760
  }
147363
- var zodSchema37 = external_exports.object({
147761
+ var zodSchema38 = external_exports.object({
147364
147762
  port: metroPortField,
147365
147763
  device_id: external_exports.string().describe(
147366
147764
  "Device id from `debugger-connect`<flag:macos-apps> (macOS: Mac app id)</flag:macos-apps>."
@@ -147375,7 +147773,7 @@ function createDebuggerComponentTreeTool() {
147375
147773
  description: `Fetch a compact React Native component tree with text/accessibilityLabel, \`[testID=\u2026]\`, and normalized \`(tap: x,y)\`<flag:macos-apps> (Mac app window incl. title bar)</flag:macos-apps>.
147376
147774
  Use when you need React component names/nesting or missing Android \`testID\`s (use \`describe\` for tap targets; verify pruned wrappers with \`debugger-inspect-element\`).
147377
147775
  Returns a text tree. Fails if the Metro debugger is disconnected.<flag:macos-apps> Mac apps: uses the root with the most components; on Paper, use \`describe\` for tap points.</flag:macos-apps>`,
147378
- zodSchema: zodSchema37,
147776
+ zodSchema: zodSchema38,
147379
147777
  searchHint: "react native component tree testID testIDs selector component names hierarchy",
147380
147778
  readOnly: true,
147381
147779
  interaction: {
@@ -147915,7 +148313,7 @@ function filterInspectItems(items, includeSkipped = false) {
147915
148313
  }
147916
148314
  return result;
147917
148315
  }
147918
- var zodSchema38 = external_exports.object({
148316
+ var zodSchema39 = external_exports.object({
147919
148317
  port: metroPortField,
147920
148318
  device_id: external_exports.string().describe(
147921
148319
  "Device id from `debugger-connect`<flag:macos-apps> (macOS: Mac app id)</flag:macos-apps>."
@@ -147936,7 +148334,7 @@ var debuggerInspectElementTool = {
147936
148334
  description: `Inspect the React component hierarchy at logical pixel (x, y), from the tapped leaf upward with source file:line and code snippets.
147937
148335
  Use when finding the source file/line for a React Native element (multiply \`debugger-component-tree\` fractions by its Screen dimensions).
147938
148336
  Returns \`{ x, y, items, truncated?, hiddenCount? }\`. Fails if disconnected or (x, y) is off-screen.<flag:macos-apps> Mac apps: uses the window root with the most components; on Paper, native views can offset hits.</flag:macos-apps>`,
147939
- zodSchema: zodSchema38,
148337
+ zodSchema: zodSchema39,
147940
148338
  readOnly: true,
147941
148339
  interaction: {
147942
148340
  startedMsg: ({ params }) => `Inspecting element at (${params.x}, ${params.y})`,
@@ -148066,7 +148464,7 @@ var CONSOLE_LEVELS = [
148066
148464
  "count",
148067
148465
  "timeEnd"
148068
148466
  ];
148069
- var zodSchema39 = external_exports.object({
148467
+ var zodSchema40 = external_exports.object({
148070
148468
  port: metroPortField,
148071
148469
  device_id: external_exports.string().describe(
148072
148470
  "Device id from `debugger-connect`<flag:macos-apps> (macOS: Mac app id)</flag:macos-apps>."
@@ -148080,7 +148478,7 @@ function createDebuggerLogRegistryTool(registry2) {
148080
148478
  description: `Get a summary of JS console logs captured from React Native<flag:macos-apps> (including Mac apps)</flag:macos-apps> or Chromium, with newest \`entries\` inline (truncated to 300 chars).
148081
148479
  Use when investigating warnings, errors, or console output. Check \`entries\` first; Grep \`file\` for older/full lines (never Read it whole; up to 50k lines). Use \`debugger-status\` to check connection health.
148082
148480
  Returns \`{ status: "connected", file, entries, clusters, note? }\` (\`note\` flags missing/crashed prior sessions), or \`{ status: "not_connected", reason, guidance }\` (follow guidance; don't retry in a loop). Never fails when the runtime is simply unreachable.`,
148083
- zodSchema: zodSchema39,
148481
+ zodSchema: zodSchema40,
148084
148482
  readOnly: true,
148085
148483
  interaction: {
148086
148484
  startedMsg: () => "Reading app logs",
@@ -148307,7 +148705,7 @@ function renderChromiumPage(records, pageIndexParam, redact2) {
148307
148705
 
148308
148706
  ${lines.join("\n")}`;
148309
148707
  }
148310
- var zodSchema40 = external_exports.object({
148708
+ var zodSchema41 = external_exports.object({
148311
148709
  port: metroPortField,
148312
148710
  device_id: external_exports.string().describe(
148313
148711
  "Device ID from `list-devices` (or `logicalDeviceId` if shared Metro capture used it)<flag:macos-apps>; Mac app: Mac app id `macos-app-<bundle id>`</flag:macos-apps>."
@@ -148321,7 +148719,7 @@ var networkLogsTool = {
148321
148719
  description: `List captured JS HTTP requests (React Native) or active-tab requests (Chromium). Call \`network-capture-start\` first on iOS<flag:macos-apps>/Mac apps</flag:macos-apps>/Android (on Vega, reading starts capture). Use \`native-network-logs\` for native traffic.
148322
148720
  Use when finding requests or comparing API calls (pass an ID to \`view-network-request-details\` for headers/bodies).
148323
148721
  Returns a paginated list of request IDs, status, size, and timing. Fails if Chromium or the JS debugger is unreachable.`,
148324
- zodSchema: zodSchema40,
148722
+ zodSchema: zodSchema41,
148325
148723
  readOnly: true,
148326
148724
  interaction: {
148327
148725
  startedMsg: () => "Reading network activity",
@@ -148490,7 +148888,7 @@ function truncatePostData(postData, truncated, redact2) {
148490
148888
  return `${cutMarker(fullSize)}
148491
148889
  ${shownText(postData, MAX_BODY_SIZE, redact2)}...`;
148492
148890
  }
148493
- var zodSchema41 = external_exports.object({
148891
+ var zodSchema42 = external_exports.object({
148494
148892
  port: metroPortField,
148495
148893
  device_id: external_exports.string().describe(
148496
148894
  "Device ID for the log (or `logicalDeviceId` if JS capture used it)<flag:macos-apps>; Mac app: Mac app id</flag:macos-apps>."
@@ -148505,7 +148903,7 @@ var networkRequestTool = {
148505
148903
  description: `Read full details (status, timing, redacted headers, and bodies truncated to 1000 chars) for one captured HTTP request ID. Secret values exposed to Argent show as their {{secret:NAME}} placeholders; other credentials do not.
148506
148904
  Use when inspecting payloads or headers of a request from a network log or \`await-network-request\`.
148507
148905
  Returns request/response details, or a not-found message (refresh the log after JS reloads). Fails if the backing debugger/CDP target is unreachable.`,
148508
- zodSchema: zodSchema41,
148906
+ zodSchema: zodSchema42,
148509
148907
  readOnly: true,
148510
148908
  interaction: {
148511
148909
  startedMsg: ({ params }) => `Reading network request ${params.requestId}`,
@@ -150083,7 +150481,7 @@ function makeDescribeExecute(registry2) {
150083
150481
  }
150084
150482
  });
150085
150483
  }
150086
- var zodSchema42 = external_exports.object({
150484
+ var zodSchema43 = external_exports.object({
150087
150485
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`."),
150088
150486
  bundleId: external_exports.string().optional().describe(
150089
150487
  "iOS simulator only: fallback bundle id when AX-service returns empty (auto-detects frontmost if omitted)."
@@ -150101,7 +150499,7 @@ function createDescribeTool(registry2) {
150101
150499
  Use when you need tap coordinates or labels and have no fresh tree: interaction tools already attach one after each action (or reference an earlier \`Tree id\`).
150102
150500
  Returns \`{ description, source, hint? }\`: one line per element with role, label/value/id/hint, flags, and normalized \`[0,1]\` frame \`(x,y,w,h)\`, and \`tap=(x,y)\` where the center misses the control. Tap at \`tap\` when present, else at \`(x+w/2, y+h/2)\`. No z-order/occlusion info; check a screenshot if a tap hits an overlay or a text field shows its placeholder as value. Fails if the tree backend is unreachable.
150103
150501
  For UIKit view properties (iOS sim) use \`native-find-views\`; for React Native components/testIDs use \`debugger-component-tree\`.`,
150104
- zodSchema: zodSchema42,
150502
+ zodSchema: zodSchema43,
150105
150503
  alwaysLoad: true,
150106
150504
  searchHint: "accessibility element tree ui hierarchy tap coordinates ios android chromium vega <flag:harmonyos>harmony harmonyos </flag:harmonyos><flag:macos-apps>macos mac app </flag:macos-apps>dom tv tvos apple tv android tv fire tv focus focusable remote dpad",
150107
150505
  readOnly: true,
@@ -150439,7 +150837,7 @@ var capability28 = {
150439
150837
  appleRemote: { simulator: true },
150440
150838
  android: { emulator: true, device: true, unknown: true }
150441
150839
  };
150442
- var zodSchema43 = external_exports.object({
150840
+ var zodSchema44 = external_exports.object({
150443
150841
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`.")
150444
150842
  });
150445
150843
  function createUiTreeTool(registry2) {
@@ -150449,7 +150847,7 @@ function createUiTreeTool(registry2) {
150449
150847
  Use when a program needs element ancestry, such as an e2e engine's scoped selectors; agents use describe.
150450
150848
  Returns { schemaVersion, roots, truncated, alertVisible, keyboardVisible, foregroundApp, unsupportedFields }.
150451
150849
  Fails if the iOS ax-service predates the tree command; update argent.`,
150452
- zodSchema: zodSchema43,
150850
+ zodSchema: zodSchema44,
150453
150851
  readOnly: true,
150454
150852
  hideFromMcp: true,
150455
150853
  interaction: {
@@ -150511,7 +150909,7 @@ async function readAndroidForegroundApp(registry2, device) {
150511
150909
  const tree = adaptAndroidTree({ ...capture, truncated: false }, size);
150512
150910
  return { bundleId: tree.foregroundApp, alertVisible: tree.alertVisible };
150513
150911
  }
150514
- var zodSchema44 = external_exports.object({
150912
+ var zodSchema45 = external_exports.object({
150515
150913
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`.")
150516
150914
  });
150517
150915
  function createForegroundAppTool(registry2) {
@@ -150520,7 +150918,7 @@ function createForegroundAppTool(registry2) {
150520
150918
  description: `Read which app is in front, for SDK callers.
150521
150919
  Returns { bundleId, name, alertVisible }; under a system alert, bundleId is the app it covers.
150522
150920
  A field is unset when it is unknown.`,
150523
- zodSchema: zodSchema44,
150921
+ zodSchema: zodSchema45,
150524
150922
  readOnly: true,
150525
150923
  hideFromMcp: true,
150526
150924
  interaction: {
@@ -150564,7 +150962,7 @@ var capability30 = {
150564
150962
  android: { emulator: true, device: true, unknown: true },
150565
150963
  chromium: { app: true }
150566
150964
  };
150567
- var zodSchema45 = external_exports.object({
150965
+ var zodSchema46 = external_exports.object({
150568
150966
  udid: external_exports.string().min(1).describe("Target device id from `list-devices`."),
150569
150967
  text: external_exports.string().describe(
150570
150968
  'The text the focused field must hold afterwards; "" clears it. Supports `{{secret:<NAME>}}` placeholders like `keyboard`.'
@@ -150617,7 +151015,7 @@ function createFillTool(registry2) {
150617
151015
  description: `Set the text of the focused text field to exactly \`text\`, replacing what it holds; "" clears it. Tap the field first.
150618
151016
  Returns { verified }, never the text: true when the field was read back holding the text, false on a physical iPhone, where nothing can read it back.
150619
151017
  Fails with FILL_NO_FOCUSED_FIELD when nothing editable has focus, FILL_NOT_VERIFIED when the field does not read back the text or the device does not answer in time, FILL_UNSUPPORTED_FIELD for a field that cannot take the text (a date or time input, a newline in a single-line field; on Chromium also text over the field's maxlength, text a number input does not hold as a number, whitespace around an email address, or focus in a cross-origin frame, a closed shadow root or an <embed>; nothing is changed). Fails if the device's ax-service or devtools helper predates fill; update argent. Not supported on TV targets or Vega.`,
150620
- zodSchema: zodSchema45,
151018
+ zodSchema: zodSchema46,
150621
151019
  hideFromMcp: true,
150622
151020
  interaction: {
150623
151021
  // Never quote `text`: it may be a credential, and these messages reach
@@ -151202,7 +151600,7 @@ function jwtPayload(token) {
151202
151600
  return { ok: false, why: "is not a JWT: its payload is not base64url" };
151203
151601
  }
151204
151602
  try {
151205
- const payload = parseJson(Buffer.from(parts2[1], "base64url").toString("utf8"));
151603
+ const payload = parseJson2(Buffer.from(parts2[1], "base64url").toString("utf8"));
151206
151604
  if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
151207
151605
  return { ok: false, why: "is not a JWT: its payload is not a JSON object" };
151208
151606
  }
@@ -151211,7 +151609,7 @@ function jwtPayload(token) {
151211
151609
  return { ok: false, why: "is not a JWT: its payload is not JSON" };
151212
151610
  }
151213
151611
  }
151214
- function parseJson(text) {
151612
+ function parseJson2(text) {
151215
151613
  const keepDigits = (_key, value, context2) => typeof value === "number" && context2?.source !== void 0 && /^-?\d+$/.test(context2.source) && String(value) !== context2.source ? context2.source : value;
151216
151614
  return JSON.parse(text, keepDigits);
151217
151615
  }
@@ -151240,7 +151638,7 @@ function checkValue(check4, source, label) {
151240
151638
  } else if (check4.path !== void 0) {
151241
151639
  let json2;
151242
151640
  try {
151243
- json2 = parseJson(source.text);
151641
+ json2 = parseJson2(source.text);
151244
151642
  hit = lookupPath(json2, check4.path, label);
151245
151643
  at = `${label}.${check4.path}`;
151246
151644
  } catch {
@@ -151376,7 +151774,7 @@ var MIN_JS_READ_MS = 1e3;
151376
151774
  var BODY_READ_GRACE_MS = 1e3;
151377
151775
  var MAX_BODY_READ_MS = 1e4;
151378
151776
  var SHOWN_VALUE_CHARS = 200;
151379
- var zodSchema46 = external_exports.object({
151777
+ var zodSchema47 = external_exports.object({
151380
151778
  udid: external_exports.string().min(1).describe("Device ID used in `network-capture-start`."),
151381
151779
  bundleId: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe(
151382
151780
  "`bundleId` used in `network-capture-start` (Chromium: placeholder like `argent.capture`)."
@@ -151447,7 +151845,7 @@ function createAwaitNetworkRequestTool(registry2) {
151447
151845
  id: "await-network-request",
151448
151846
  description: `Wait for an HTTP request or check for no match with \`absent: true\`. Requires a \`network-capture-start\` window for the target. Unavailable on physical iPhones and Vega. On Chromium, match the final URL and method after redirects.
151449
151847
  Pass \`match.id\` to \`view-network-request-details\`. \`values\` shows previews of matched values and redacts sensitive headers. A header claim check can show the claim. Check \`cause\` and \`note\` on failure. \`success: false\` fails an e2e step and stops \`run-sequence\`.`,
151450
- zodSchema: zodSchema46,
151848
+ zodSchema: zodSchema47,
151451
151849
  searchHint: "wait await network request http api call fetch xhr response status url match after capture start e2e assert",
151452
151850
  readOnly: true,
151453
151851
  longRunning: true,
@@ -151892,7 +152290,7 @@ async function splashScreenShowing(serial) {
151892
152290
  return false;
151893
152291
  }
151894
152292
  }
151895
- var zodSchema47 = external_exports.object({
152293
+ var zodSchema48 = external_exports.object({
151896
152294
  udid: external_exports.string().min(1).describe(
151897
152295
  "Target device id from `list-devices` (iOS UDID, Android serial, Vega serial, <flag:harmonyos>HarmonyOS id, </flag:harmonyos><flag:macos-apps>Mac app id, </flag:macos-apps>or Chromium id)."
151898
152296
  ),
@@ -151932,7 +152330,7 @@ function createAwaitScreenIdleTool(registry2) {
151932
152330
  description: `Block until the screen has rendered content and held it for minStableMs, or the timeout elapses. It polls the same element tree as \`describe\`.
151933
152331
  Use when a launch or navigation must finish rendering before a screenshot or tap.
151934
152332
  Returns { settled, waitedMs, polls, launching?, note? }. If that is not seen before timeoutMs, it returns settled=false instead of failing. On Android, launching=true (and settled=false) means an app's splash screen was still showing.<flag:harmonyos> A note on settled=true means the screen it settled on is not live: a suspended HarmonyOS panel settles instantly on its last frame, and taps land nowhere until it is woken.</flag:harmonyos>`,
151935
- zodSchema: zodSchema47,
152333
+ zodSchema: zodSchema48,
151936
152334
  searchHint: "wait until screen settles idle stable stops changing animation transition rendered ready before screenshot",
151937
152335
  readOnly: true,
151938
152336
  interaction: {
@@ -152185,7 +152583,7 @@ function safeGetState(registry2, urn) {
152185
152583
  return null;
152186
152584
  }
152187
152585
  }
152188
- var zodSchema48 = external_exports.object({
152586
+ var zodSchema49 = external_exports.object({
152189
152587
  port: metroPortField,
152190
152588
  device_id: external_exports.string().describe(
152191
152589
  "Device ID from list-devices<flag:macos-apps>, including a Mac app ID</flag:macos-apps> (or `logicalDeviceId` on shared Metro if requested)."
@@ -152199,7 +152597,7 @@ function createReactProfilerStartTool(registry2) {
152199
152597
  description: `Start recording Hermes CPU samples and React commits. Use when profiling React Native performance (pair with \`native-profiler-start\` in parallel on iOS/Android<flag:macos-apps>/Mac apps</flag:macos-apps>, then stop with \`react-profiler-stop\`).<flag:macos-apps> Mac apps need a Debug build loading JS from Metro (react-native-macos 0.76+ or Mac Catalyst); connects without debugger-connect.</flag:macos-apps>
152200
152598
  Returns \`{ started_at, startedAtEpochMs, hermes_version, detected_architecture }\` or \`{ already_running: true, mine, owner, \u2026 }\` (ask approval before \`force: true\`). On iOS and Android, a warning names the apps with native network capture on.
152201
152599
  Fails if Hermes or Metro CDP is unreachable.`,
152202
- zodSchema: zodSchema48,
152600
+ zodSchema: zodSchema49,
152203
152601
  interaction: {
152204
152602
  startedMsg: () => "Starting React profiler",
152205
152603
  completedMsg: ({ result }) => result.already_running ? "React profiler was already running" : "Started React profiler",
@@ -153266,7 +153664,7 @@ function stopInProgressError() {
153266
153664
  error_kind: "not_found"
153267
153665
  });
153268
153666
  }
153269
- var zodSchema49 = external_exports.object({
153667
+ var zodSchema50 = external_exports.object({
153270
153668
  port: metroPortField,
153271
153669
  device_id: external_exports.string().describe(
153272
153670
  "Device ID passed to react-profiler-start<flag:macos-apps>. For a Mac app, use its ID from list-devices</flag:macos-apps>."
@@ -153278,7 +153676,7 @@ function createReactProfilerStopTool(registry2) {
153278
153676
  description: `Stop React profiling and store CPU samples + commit tree for \`react-profiler-analyze\`, \`profiler-commit-query\`, and \`profiler-cpu-query\`.
153279
153677
  Use when finishing an interaction recorded after \`react-profiler-start\`.
153280
153678
  Returns \`{ duration_ms, sample_count, fiber_renders_captured, total_react_commits, hot_commit_indices, react_render_ms, react_render_share_pct, react_render_peak_1s_pct, unattributed_*? }\`. Fails if no active session exists, CDP disconnected, or another session took over.`,
153281
- zodSchema: zodSchema49,
153679
+ zodSchema: zodSchema50,
153282
153680
  // Collection can outlast the MCP client's 30 s abort. The client would then
153283
153681
  // resend the call, and the resend fails on the stop still collecting.
153284
153682
  longRunning: true,
@@ -153573,7 +153971,7 @@ Returns \`{ duration_ms, sample_count, fiber_renders_captured, total_react_commi
153573
153971
 
153574
153972
  // ../tool-server/src/tools/profiler/react/react-profiler-status.ts
153575
153973
  init_zod();
153576
- var zodSchema50 = external_exports.object({
153974
+ var zodSchema51 = external_exports.object({
153577
153975
  port: metroPortField,
153578
153976
  device_id: external_exports.string().describe(
153579
153977
  "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."
@@ -153591,7 +153989,7 @@ function createReactProfilerStatusTool(registry2) {
153591
153989
  return {
153592
153990
  id: "react-profiler-status",
153593
153991
  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.`,
153594
- zodSchema: zodSchema50,
153992
+ zodSchema: zodSchema51,
153595
153993
  readOnly: true,
153596
153994
  interaction: {
153597
153995
  startedMsg: () => "Checking React profiler",
@@ -155268,7 +155666,7 @@ var annotationSchema = external_exports.object({
155268
155666
  offsetMs: external_exports.coerce.number().describe("Ms since profiling started (`tapTimestampMs - startedAtEpochMs`)."),
155269
155667
  label: external_exports.string().describe("Action label.")
155270
155668
  });
155271
- var zodSchema51 = external_exports.object({
155669
+ var zodSchema52 = external_exports.object({
155272
155670
  port: metroPortField,
155273
155671
  device_id: external_exports.string().describe(
155274
155672
  "Device ID from list-devices used for the profile<flag:macos-apps> (Mac app: its list-devices ID)</flag:macos-apps>."
@@ -155283,7 +155681,7 @@ var reactProfilerAnalyzeTool = {
155283
155681
  description: `Analyze stored React profiling data into a markdown report of hot commits (\u226516ms), render cascades, root causes, and top components.
155284
155682
  Use when \`react-profiler-stop\` has finished and you want to interpret the profile (drill down further with \`profiler-cpu-query\` / \`profiler-commit-query\`).
155285
155683
  Returns \`{ report, reportFile, hotCommitsTotal, hotCommitsShown, sessionFiles }\`. Fails if no profiling data is stored.`,
155286
- zodSchema: zodSchema51,
155684
+ zodSchema: zodSchema52,
155287
155685
  interaction: {
155288
155686
  startedMsg: () => "Analyzing React profile",
155289
155687
  completedMsg: () => "Analyzed React profile",
@@ -155468,7 +155866,7 @@ var import_fs6 = require("fs");
155468
155866
  var fileInputs = [
155469
155867
  { target: "project_root", path: "${project_root}", kind: "directory" }
155470
155868
  ];
155471
- var zodSchema52 = external_exports.object({
155869
+ var zodSchema53 = external_exports.object({
155472
155870
  component_name: external_exports.string().describe("Name of the React component to look up"),
155473
155871
  project_root: external_exports.string().describe("Absolute path to the RN project root")
155474
155872
  });
@@ -155478,7 +155876,7 @@ var reactProfilerComponentSourceTool = {
155478
155876
  Call this per-finding after react-profiler-analyze to inspect source before proposing a fix.
155479
155877
  Returns found: false if the component is not found in user-owned code (e.g. lives in node_modules).
155480
155878
  When several files define a component with the same name (e.g. platform variants like List.tsx and List.web.tsx), returns the primary match and lists the rest under otherMatches[] (file/line/col). Check it before assuming the returned file is the one you meant.`,
155481
- zodSchema: zodSchema52,
155879
+ zodSchema: zodSchema53,
155482
155880
  readOnly: true,
155483
155881
  // react-profiler-analyze runs the same AST lookup for each component in its
155484
155882
  // table (file, line and other matches) and adds the source of the located ones
@@ -155605,7 +156003,7 @@ function renderMarkdownTable(entries) {
155605
156003
  );
155606
156004
  return [header, sep12, ...rows].join("\n");
155607
156005
  }
155608
- var zodSchema53 = external_exports.object({
156006
+ var zodSchema54 = external_exports.object({
155609
156007
  port: metroPortField,
155610
156008
  device_id: external_exports.string().describe(
155611
156009
  "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>."
@@ -155620,7 +156018,7 @@ FOR DEDICATED CPU INVESTIGATION ONLY: do NOT call this as part of a normal profi
155620
156018
  Use react-profiler-analyze instead; it covers all React rendering performance analysis.
155621
156019
  Use when you specifically need to investigate JS CPU hotspots that are NOT tied to React rendering (e.g. regex slowness, cryptography, heavy computations).
155622
156020
  Fails if react-profiler-stop has not been called or no CPU profile is stored.`,
155623
- zodSchema: zodSchema53,
156021
+ zodSchema: zodSchema54,
155624
156022
  readOnly: true,
155625
156023
  // Agents use profiler-cpu-query mode top_functions, which reads the same
155626
156024
  // profile with per-sample intervals and idle filtered out, and has the same
@@ -155728,7 +156126,7 @@ function renderMarkdownTable2(entries) {
155728
156126
  );
155729
156127
  return [header, sep12, ...rows].join("\n");
155730
156128
  }
155731
- var zodSchema54 = external_exports.object({
156129
+ var zodSchema55 = external_exports.object({
155732
156130
  port: metroPortField,
155733
156131
  device_id: external_exports.string().describe(
155734
156132
  "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."
@@ -155741,7 +156139,7 @@ var reactProfilerRendersTool = {
155741
156139
  Returns a markdown table of the components with the longest total self render time. It reads the top 30 levels of the tree and does not count re-renders: record a profiling session for that.
155742
156140
  Use when you want a quick look at what is mounted in a live connected app, without a profiling session.
155743
156141
  Fails if the React DevTools hook is not present in the runtime or the app is not connected.`,
155744
- zodSchema: zodSchema54,
156142
+ zodSchema: zodSchema55,
155745
156143
  readOnly: true,
155746
156144
  // It walks only the top 30 fiber levels, above the screens of a real app
155747
156145
  // (Bluesky's first feed item sits at depth 446), and counts mounts, not
@@ -155910,7 +156308,7 @@ function buildFiberTreeScript(maxDepth, filter) {
155910
156308
  }
155911
156309
  })()`;
155912
156310
  }
155913
- var zodSchema55 = external_exports.object({
156311
+ var zodSchema56 = external_exports.object({
155914
156312
  port: metroPortField,
155915
156313
  device_id: external_exports.string().describe(
155916
156314
  "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."
@@ -155924,7 +156322,7 @@ var reactProfilerFiberTreeTool = {
155924
156322
  Use when tracing the ancestry of a library component.
155925
156323
  Returns a nested JSON tree of fiber nodes with name, tag, actualDuration, selfBaseDuration, and children.
155926
156324
  Fails if the React DevTools hook is not present or no fiber roots have been committed yet.`,
155927
- zodSchema: zodSchema55,
156325
+ zodSchema: zodSchema56,
155928
156326
  readOnly: true,
155929
156327
  interaction: {
155930
156328
  startedMsg: () => "Reading React fiber tree",
@@ -160527,7 +160925,7 @@ var capability32 = {
160527
160925
  android: { emulator: true, device: true, unknown: true },
160528
160926
  macos: { app: true, catalyst: true }
160529
160927
  };
160530
- var zodSchema56 = external_exports.object({
160928
+ var zodSchema57 = external_exports.object({
160531
160929
  device_id: metroDeviceIdParam(
160532
160930
  "Target device id from `list-devices` (iOS UDID<flag:macos-apps>, Mac app id</flag:macos-apps> or Android serial)."
160533
160931
  ),
@@ -160548,7 +160946,7 @@ var nativeProfilerStartTool = {
160548
160946
  description: `Start native profiling: Instruments (CPU, hangs, leaks) on iOS<flag:macos-apps> and Mac apps</flag:macos-apps>, or Perfetto (CPU, jank, memory) on Android.
160549
160947
  Use when profiling native performance. Launch the target app first, wait for this call to return before reproducing the scenario, then call \`native-profiler-stop\` while the app is still running.<flag:macos-apps> Mac apps need a dev-signed build launched via Argent (use "Time Profiler" if signing/WebKit blocks the bundled template, or set \`malloc_stack_logging: true\` for leak stacks).</flag:macos-apps>
160550
160948
  Returns \`{ status: "recording", pid, traceFile, warning? }\` (warns on iOS/Android if native network capture is active). Fails if the app, xctrace, or adb is unavailable.`,
160551
- zodSchema: zodSchema56,
160949
+ zodSchema: zodSchema57,
160552
160950
  interaction: {
160553
160951
  startedMsg: () => "Starting native profiler",
160554
160952
  completedMsg: () => "Started native profiler",
@@ -160615,7 +161013,7 @@ async function exportedFilesToArtifacts(store, files) {
160615
161013
  function registerTrace(store, traceFile) {
160616
161014
  return store.register({ hostPath: traceFile, kind: "native-profile-trace", archive: "tar.gz" });
160617
161015
  }
160618
- var zodSchema57 = external_exports.object({
161016
+ var zodSchema58 = external_exports.object({
160619
161017
  device_id: metroDeviceIdParam(
160620
161018
  "Target device id from `list-devices` (iOS UDID<flag:macos-apps>, Mac app id</flag:macos-apps> or Android serial)."
160621
161019
  )
@@ -160624,7 +161022,7 @@ var nativeProfilerStopTool = {
160624
161022
  id: "native-profiler-stop",
160625
161023
  description: `End a native profiling session started by native-profiler-start and save the trace as a downloadable artifact.
160626
161024
  On iOS<flag:macos-apps> and Mac apps</flag:macos-apps>, export CPU, hangs, and leaks XML from Instruments. Check warning and exportDiagnostics for partial or skipped exports. On Android, save the Perfetto .pftrace.`,
160627
- zodSchema: zodSchema57,
161025
+ zodSchema: zodSchema58,
160628
161026
  interaction: {
160629
161027
  startedMsg: () => "Stopping native profiler",
160630
161028
  completedMsg: ({ result }) => `Saved native profile ${result.traceFile.filename}`,
@@ -160673,7 +161071,7 @@ var capability34 = {
160673
161071
  android: { emulator: true, device: true, unknown: true },
160674
161072
  macos: { app: true, catalyst: true }
160675
161073
  };
160676
- var zodSchema58 = external_exports.object({
161074
+ var zodSchema59 = external_exports.object({
160677
161075
  device_id: metroDeviceIdParam(
160678
161076
  "Target device id from `list-devices` (iOS UDID<flag:macos-apps>, Mac app id</flag:macos-apps> or Android serial)."
160679
161077
  )
@@ -160683,7 +161081,7 @@ var nativeProfilerAnalyzeTool = {
160683
161081
  description: `Summarize a native trace saved by native-profiler-stop or restored with profiler-load. Returns a Markdown report with severity and suggested next steps.
160684
161082
  Instruments reports CPU hotspots, UI hangs, and memory leaks on iOS<flag:macos-apps> and Mac apps</flag:macos-apps>. Android reports also include jank reasons, main-thread state, garbage collection, and memory growth as a weak leak signal.
160685
161083
  Use profiler-stack-query for details behind a finding.`,
160686
- zodSchema: zodSchema58,
161084
+ zodSchema: zodSchema59,
160687
161085
  interaction: {
160688
161086
  startedMsg: () => "Analyzing native profile",
160689
161087
  completedMsg: () => "Analyzed native profile",
@@ -161279,7 +161677,7 @@ function optionalExportCrashNote(tables, xcodeVersion2, options = {}) {
161279
161677
  // ../tool-server/src/tools/profiler/native-profiler/launch-analysis/measure.ts
161280
161678
  var execFileAsync40 = (0, import_node_util41.promisify)(import_node_child_process51.execFile);
161281
161679
  var LAUNCH_ITERATIONS = 5;
161282
- async function measureLaunch(params, ctx) {
161680
+ async function measureLaunch(params, ctx, claimDevice) {
161283
161681
  let release3;
161284
161682
  try {
161285
161683
  const context2 = await prepareLaunch(
@@ -161287,7 +161685,8 @@ async function measureLaunch(params, ctx) {
161287
161685
  bundleId: params.bundle_id,
161288
161686
  deviceId: params.device_id,
161289
161687
  allowSimulator: params.allow_simulator,
161290
- checkDevice: ({ id }) => {
161688
+ checkDevice: async ({ id }) => {
161689
+ await claimDevice?.(id);
161291
161690
  release3 = reserveLaunchMeasurement(id);
161292
161691
  }
161293
161692
  },
@@ -161704,13 +162103,14 @@ async function writeProfilerSession(xml) {
161704
162103
  var RECORD_TIMEOUT_MS = 18e4;
161705
162104
  var ms2 = (ns) => Math.round(ns / 1e5) / 10;
161706
162105
  var DEFAULT_PROFILE_SECONDS = 8;
161707
- async function profileLaunch(params, ctx) {
162106
+ async function profileLaunch(params, ctx, claimDevice) {
161708
162107
  const context2 = await prepareLaunch(
161709
162108
  {
161710
162109
  bundleId: params.bundle_id,
161711
162110
  deviceId: params.device_id,
161712
162111
  allowSimulator: params.allow_simulator,
161713
- checkDevice: async ({ simulator }) => {
162112
+ checkDevice: async ({ id, simulator }) => {
162113
+ await claimDevice?.(id);
161714
162114
  if (!simulator) return;
161715
162115
  const version3 = await xcodeVersion();
161716
162116
  if (stallsSimulatorLaunchRecording(parseXcodeVersion(version3))) {
@@ -161973,7 +162373,7 @@ var launchAnalysisMode = {
161973
162373
  failed: "Failed to record iOS App Launch"
161974
162374
  }
161975
162375
  };
161976
- var zodSchema59 = external_exports.object({
162376
+ var zodSchema60 = external_exports.object({
161977
162377
  mode: external_exports.enum(["measure", "profile"]).describe("`measure`: 5 XCTest timed launches. `profile`: 1 Instruments App Launch trace."),
161978
162378
  bundle_id: external_exports.string().regex(BUNDLE_ID_PATTERN, BUNDLE_ID_MESSAGE).describe("Installed Release build bundle ID (not built or installed by this tool)."),
161979
162379
  device_id: external_exports.string().optional().describe("iPhone UDID (or booted simulator UDID with `allow_simulator: true`)."),
@@ -162001,18 +162401,28 @@ var nativeProfilerLaunchAnalysisTool = {
162001
162401
  description: `Profile or measure iOS app startup on an already-installed Release build (warms once, then measures).
162002
162402
  Use when benchmarking launch time (\`measure\`: 5 XCTest launches incl. extended tasks; signed runner on iPhone) or profiling pre-first-frame CPU work (\`profile\`: Instruments App Launch trace; follow \`profilerSession.next\` with \`profiler-load\` + \`profiler-stack-query\`).
162003
162403
  Returns \`samplesCollected\` (\`measure\`) or \`launchMs\` + \`profilerSession\` (\`profile\`). Fails if the app is not installed or no iPhone / allowed simulator is available.`,
162004
- zodSchema: zodSchema59,
162404
+ zodSchema: zodSchema60,
162005
162405
  services: () => ({}),
162006
162406
  async execute(_services, params, ctx) {
162007
- switch (params.mode) {
162008
- case "measure":
162009
- return measureLaunch(params, ctx);
162010
- case "profile":
162011
- return profileLaunch(params, ctx);
162012
- default: {
162013
- const mode = params.mode;
162014
- throw new Error(`Unknown mode: ${String(mode)}`);
162407
+ let endClaim = () => {
162408
+ };
162409
+ const claimDevice = async (deviceId) => {
162410
+ if (params.device_id === void 0)
162411
+ endClaim = await claimPickedDevice(ctx?.session, deviceId);
162412
+ };
162413
+ try {
162414
+ switch (params.mode) {
162415
+ case "measure":
162416
+ return await measureLaunch(params, ctx, claimDevice);
162417
+ case "profile":
162418
+ return await profileLaunch(params, ctx, claimDevice);
162419
+ default: {
162420
+ const mode = params.mode;
162421
+ throw new Error(`Unknown mode: ${String(mode)}`);
162422
+ }
162015
162423
  }
162424
+ } finally {
162425
+ endClaim();
162016
162426
  }
162017
162427
  }
162018
162428
  };
@@ -162702,7 +163112,7 @@ function resolveAudioSession(registry2, device) {
162702
163112
  }
162703
163113
 
162704
163114
  // ../tool-server/src/tools/audio/audio-input.ts
162705
- var zodSchema60 = external_exports.object({
163115
+ var zodSchema61 = external_exports.object({
162706
163116
  udid: external_exports.string().describe("Target iOS Simulator UDID from `list-devices`."),
162707
163117
  source: external_exports.enum(["file", "tone", "microphone"]).describe(
162708
163118
  "`file` plays `path`, `tone` a sine wave, `microphone` restores the real microphone."
@@ -162730,7 +163140,7 @@ function createAudioInputTool(registry2) {
162730
163140
  id: "audio-input",
162731
163141
  description: `Set what apps in an iOS Simulator hear as microphone input: an audio file, a tone, or the real microphone.
162732
163142
  A file starts playing on this call, so call it right before the action that makes the app record.`,
162733
- zodSchema: zodSchema60,
163143
+ zodSchema: zodSchema61,
162734
163144
  searchHint: "audio microphone input mock fake inject voice speech sound file tone simulator mic",
162735
163145
  interaction: {
162736
163146
  startedMsg: ({ params }) => `Setting simulator audio input to ${params.source}`,
@@ -164666,7 +165076,7 @@ var capability35 = {
164666
165076
  // argent's library records the app's window from inside the app.
164667
165077
  macos: { app: true, catalyst: true }
164668
165078
  };
164669
- var zodSchema61 = external_exports.object({
165079
+ var zodSchema62 = external_exports.object({
164670
165080
  udid: external_exports.string().describe(
164671
165081
  "Target ID from `list-devices`<flag:macos-apps> (Mac app: `macos-app-<bundle id>`)</flag:macos-apps>."
164672
165082
  ),
@@ -164682,7 +165092,7 @@ function createScreenRecordingStartTool(registry2) {
164682
165092
  description: `Start an MP4 recording of the device screen<flag:macos-apps> or Mac app window</flag:macos-apps>. Use when capturing video of an interaction or animation (use \`screenshot\` for a still image).
164683
165093
  Continues until \`screen-recording-stop\` or \`timeLimitSeconds\` (always retrieve via \`screen-recording-stop\`). Requires \`ffmpeg\` on simulators, Android, and wired iPhones (needs \`transportType: "wired"\` and camera access for \`ios-screen-stream\`). Unsupported on tvOS, Chromium<flag:harmonyos>, HarmonyOS</flag:harmonyos>, and Vega.<flag:macos-apps> Mac apps: needs a visible window on one display, no capture protection, no Screen Recording permission or ffmpeg; on \`MACOS_APP_LIBRARY_OUTDATED\`, run \`restart-app\` and retry.</flag:macos-apps>
164684
165094
  Returns \`{ outputFile }\` on the tool-server host. Fails if target is unavailable or already recording.`,
164685
- zodSchema: zodSchema61,
165095
+ zodSchema: zodSchema62,
164686
165096
  searchHint: "record video screen capture movie mp4 start filming screencast",
164687
165097
  interaction: {
164688
165098
  startedMsg: () => "Starting screen recording",
@@ -164826,7 +165236,7 @@ var capability36 = {
164826
165236
  android: { emulator: true, device: true, unknown: true },
164827
165237
  macos: { app: true, catalyst: true }
164828
165238
  };
164829
- var zodSchema62 = external_exports.object({
165239
+ var zodSchema63 = external_exports.object({
164830
165240
  udid: external_exports.string().describe(
164831
165241
  "Target ID from `list-devices`.<flag:macos-apps> For a Mac app, use its device ID, such as `macos-app-com.example.notes`.</flag:macos-apps>"
164832
165242
  )
@@ -164836,7 +165246,7 @@ var screenRecordingStopTool = {
164836
165246
  description: `Stop a screen recording and retrieve its MP4. Call this even after the time limit or an early capture exit. The tool downloads recordings from remote simulators.
164837
165247
  Returns the saved \`video\` and its \`durationMs\`. When trimming removes still sections, \`wallClockMs\` gives the original duration and \`trimmedMs\` gives the time removed. On a foldable simulator the video follows the active panel, keeps the first panel's size, and reports any \`panelSwitches\`.
164838
165248
  Check \`warning\` for capture problems, such as an undetected foldable panel.<flag:macos-apps> On a Mac app, a warning can report when the video held its last frame or omitted a protected window. Quitting or restarting the app or connecting to it from another Argent tool-server during capture can discard the recording. A stop error can include a path to a recoverable video.</flag:macos-apps>`,
164839
- zodSchema: zodSchema62,
165249
+ zodSchema: zodSchema63,
164840
165250
  searchHint: "stop end finish screen recording video capture save retrieve",
164841
165251
  interaction: {
164842
165252
  startedMsg: () => "Stopping screen recording",
@@ -165226,7 +165636,7 @@ var timeRangeSchema = external_exports.object({
165226
165636
  start: external_exports.coerce.number().describe("Start ms."),
165227
165637
  end: external_exports.coerce.number().describe("End ms.")
165228
165638
  });
165229
- var zodSchema63 = external_exports.object({
165639
+ var zodSchema64 = external_exports.object({
165230
165640
  port: metroPortField,
165231
165641
  device_id: metroDeviceIdParam(
165232
165642
  "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>."
@@ -165243,7 +165653,7 @@ var profilerCommitQueryTool = {
165243
165653
  description: `Query React commit data by mode: \`by_component\`, \`by_time_range\`, \`by_index\` (full fiber dump), \`cascade_tree\` (parent\u2192child triggers), or \`render_counts\` (counts/rates across ALL commits, incl. <16ms).
165244
165654
  Use when drilling into components, cascades, or time windows after \`react-profiler-analyze\`.
165245
165655
  Returns a markdown table or tree. Fails if \`react-profiler-stop\` has not been called.`,
165246
- zodSchema: zodSchema63,
165656
+ zodSchema: zodSchema64,
165247
165657
  readOnly: true,
165248
165658
  interaction: {
165249
165659
  startedMsg: ({ params }) => `Querying React commits ${params.mode.replace(/^by_/, "by ").replaceAll("_", " ")}`,
@@ -165679,7 +166089,7 @@ var timeWindowSchema = external_exports.object({
165679
166089
  start: external_exports.coerce.number().describe("Start ms."),
165680
166090
  end: external_exports.coerce.number().describe("End ms.")
165681
166091
  });
165682
- var zodSchema64 = external_exports.object({
166092
+ var zodSchema65 = external_exports.object({
165683
166093
  port: metroPortField,
165684
166094
  device_id: metroDeviceIdParam(
165685
166095
  "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>."
@@ -165697,7 +166107,7 @@ var profilerCpuQueryTool = {
165697
166107
  description: `Query Hermes CPU samples by mode: \`top_functions\` (global hotspots, optional \`time_window_ms\`), \`time_window\` (breakdown during \`time_window_ms\`), \`call_tree\` (callees/callers for \`function_name\`), or \`component_cpu\` (CPU across \`component_name\` commits).
165698
166108
  Use when drilling into JS CPU hotspots after \`react-profiler-analyze\`. Self-times measure sampled coverage per call path.
165699
166109
  Returns a markdown table or call tree. Fails if no CPU profile is stored (run \`react-profiler-stop\` first).`,
165700
- zodSchema: zodSchema64,
166110
+ zodSchema: zodSchema65,
165701
166111
  readOnly: true,
165702
166112
  interaction: {
165703
166113
  startedMsg: ({ params }) => `Querying CPU profile by ${params.mode.replaceAll("_", " ")}`,
@@ -166084,7 +166494,7 @@ async function executeAndroid(api, params) {
166084
166494
  topN: params.top_n
166085
166495
  });
166086
166496
  }
166087
- var zodSchema65 = external_exports.object({
166497
+ var zodSchema66 = external_exports.object({
166088
166498
  device_id: metroDeviceIdParam(
166089
166499
  "Target device id from `list-devices` (iOS UDID<flag:macos-apps>, Mac app id</flag:macos-apps> or Android serial)."
166090
166500
  ),
@@ -166103,7 +166513,7 @@ var profilerStackQueryTool = {
166103
166513
  description: `Query native profiler stacks after \`native-profiler-analyze\` or \`profiler-load\`: \`hang_stacks\` (by \`hang_index\`), \`function_callers\` (for \`function_name\`), \`thread_breakdown\`, or \`leak_stacks\` (iOS<flag:macos-apps>/Mac apps</flag:macos-apps>).
166104
166514
  Use when drilling into native hangs, callers, threads, or leaks.
166105
166515
  Returns a markdown breakdown. Fails if no native trace is loaded.`,
166106
- zodSchema: zodSchema65,
166516
+ zodSchema: zodSchema66,
166107
166517
  readOnly: true,
166108
166518
  interaction: {
166109
166519
  startedMsg: ({ params }) => `Querying native stacks by ${stackQueryMode[params.mode]}`,
@@ -166181,7 +166591,7 @@ function buildPerfettoAnchor(wallClockStartMs) {
166181
166591
  }
166182
166592
 
166183
166593
  // ../tool-server/src/tools/profiler/combined/profiler-combined-report.ts
166184
- var zodSchema66 = external_exports.object({
166594
+ var zodSchema67 = external_exports.object({
166185
166595
  port: metroPortField,
166186
166596
  device_id: metroDeviceIdParam(
166187
166597
  "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>)."
@@ -166194,7 +166604,7 @@ Maps native hangs to React commits using wall-clock time alignment.
166194
166604
  Call this tool when both profilers were run in parallel on the same session.
166195
166605
  Returns a markdown report correlating hangs with React commits, memory leaks, and investigation hints.
166196
166606
  Fails if either react-profiler-analyze or native-profiler-analyze has not been called first, or if the session stored no React commits.`,
166197
- zodSchema: zodSchema66,
166607
+ zodSchema: zodSchema67,
166198
166608
  readOnly: true,
166199
166609
  interaction: {
166200
166610
  startedMsg: () => "Building combined performance report",
@@ -166884,7 +167294,7 @@ var profilerLoadAction = {
166884
167294
  failure: "load"
166885
167295
  }
166886
167296
  };
166887
- var zodSchema67 = external_exports.object({
167297
+ var zodSchema68 = external_exports.object({
166888
167298
  mode: external_exports.enum(["list", "load_react", "load_native"]).describe("`list`, `load_react`, or `load_native`."),
166889
167299
  session_id: external_exports.string().regex(SESSION_ID_PATTERN, "session_id may only contain letters, digits, '_' and '-'").optional().describe("Session ID from `list` (required for `load_*`)."),
166890
167300
  port: metroPortField,
@@ -166896,7 +167306,7 @@ var profilerLoadTool = {
166896
167306
  description: `List or restore saved React/native profiling sessions from disk into memory for \`profiler-*-query\` / \`react-profiler-analyze\` (\`load_react\` loads CPU+commits; \`load_native\` loads xctrace on iOS<flag:macos-apps>/Mac apps</flag:macos-apps> or \`.pftrace\` on Android).
166897
167307
  Use when revisiting past sessions without re-recording (replaces the in-memory session for \`device_id\` without deleting disk files).
166898
167308
  Returns a session list or loaded summary. Fails if \`session_id\` or its files are missing.`,
166899
- zodSchema: zodSchema67,
167309
+ zodSchema: zodSchema68,
166900
167310
  interaction: {
166901
167311
  startedMsg: ({ params }) => profilerLoadAction[params.mode].started(params),
166902
167312
  completedMsg: ({ params }) => profilerLoadAction[params.mode].completed(params),
@@ -167058,7 +167468,7 @@ function unnameableSessionUrns(urns) {
167058
167468
  }
167059
167469
 
167060
167470
  // ../tool-server/src/tools/simulator/stop-simulator-server.ts
167061
- var zodSchema68 = external_exports.object({
167471
+ var zodSchema69 = external_exports.object({
167062
167472
  udid: external_exports.string().describe(
167063
167473
  "Target device id (iOS UDID, Android serial, or Chromium id) whose transport session to stop"
167064
167474
  )
@@ -167069,7 +167479,7 @@ function createStopSimulatorServerTool(registry2) {
167069
167479
  description: `Stop the transport session for one device (simulator-server, physical iOS runner, Chromium CDP, or TV daemons).
167070
167480
  Use when restarting a wedged transport or freeing one device without affecting others (not routinely after every task; use \`stop-all-simulator-servers\` with \`devices\` to also stop devtools/profilers/debuggers). On Chromium, also ends the JS debugger session.<flag:macos-apps> On Mac apps, also stops native capture (discarding records) and screen recording.</flag:macos-apps>
167071
167481
  Returns \`{ stopped, udid }\` (\`stopped: false\` if none was running). Fails only on invalid input.`,
167072
- zodSchema: zodSchema68,
167482
+ zodSchema: zodSchema69,
167073
167483
  interaction: {
167074
167484
  startedMsg: ({ params }) => `Stopping simulator server for ${params.udid}`,
167075
167485
  completedMsg: ({ params }) => `Stopped simulator server for ${params.udid}`,
@@ -167104,7 +167514,7 @@ Returns \`{ stopped, udid }\` (\`stopped: false\` if none was running). Fails on
167104
167514
  // ../tool-server/src/tools/simulator/stop-all-simulator-servers.ts
167105
167515
  init_zod();
167106
167516
  init_src2();
167107
- var zodSchema69 = external_exports.object({
167517
+ var zodSchema70 = external_exports.object({
167108
167518
  devices: external_exports.array(external_exports.string()).optional().describe(
167109
167519
  "Ids of the devices THIS session used (iOS UDID / Android serial / Chromium id), to scope the teardown to."
167110
167520
  )
@@ -167116,7 +167526,7 @@ function createStopAllSimulatorServersTool(registry2) {
167116
167526
  Use when cleaning up or ending a session, or when a skill asks to recycle services \u2014 not routinely after every task (services are reused). Use \`network-capture-stop\` to stop network capture while keeping recorded requests.
167117
167527
  Always pass \`devices\` with this session's device IDs (plus any \`logicalDeviceId\` used with \`debugger-connect\` on shared Metro) so other agents' devices aren't torn down; omit \`devices\` only for a machine-wide sweep. \`[]\` stops nothing.
167118
167528
  Returns \`{ stopped, unmatched?, left_running?, aborted? }\` (\`left_running\` names unscoped debugger URNs; re-call with the id after \`<ns>:<port>:\` to reap them). Fails if unknown keys (e.g. \`udids\`) are passed.`,
167119
- zodSchema: zodSchema69,
167529
+ zodSchema: zodSchema70,
167120
167530
  interaction: {
167121
167531
  // "all" only holds for the unscoped sweep; a scoped call touches just the
167122
167532
  // ids it was given.
@@ -167179,6 +167589,7 @@ Returns \`{ stopped, unmatched?, left_running?, aborted? }\` (\`left_running\` n
167179
167589
  }
167180
167590
  forgetJsCapturesOf(scoped ? devices2 : void 0, paused);
167181
167591
  forgetNativeUnavailableOf(scoped ? devices2 : void 0);
167592
+ deviceClaims.endCaptures(scoped ? devices2 : void 0);
167182
167593
  if (!scoped) return { stopped };
167183
167594
  const seen = /* @__PURE__ */ new Set();
167184
167595
  const unmatched = devices2.filter((id) => {
@@ -167320,13 +167731,13 @@ function listeningPids(port) {
167320
167731
  }
167321
167732
  return lines.map((s) => parseInt(s, 10));
167322
167733
  }
167323
- var zodSchema70 = external_exports.object({
167734
+ var zodSchema71 = external_exports.object({
167324
167735
  port: external_exports.number().int().min(1).max(65535).default(8081).describe("TCP port Metro is listening on")
167325
167736
  });
167326
167737
  var stopMetroTool = {
167327
167738
  id: "stop-metro",
167328
167739
  description: `Stop the Metro bundler process listening on \`port\`. Use when the user asks to stop Metro or when Metro must be restarted - do not offer it when a task wraps up, since the next task would wait on a cold Metro start. Returns { stopped, port, pids }: stopped=true when it sent SIGTERM to every listening pid it found (or the pid had already exited), stopped=false when it found none. Fails if the port lookup cannot run or times out, if it finds a listener but not the process that owns it, or if it cannot signal a listener it found (e.g. EPERM). On macOS another user's listener is detected only when no other listener on the port is visible, so it can survive stopped=true. This is DESTRUCTIVE: always ask the user for confirmation before calling this tool.`,
167329
- zodSchema: zodSchema70,
167740
+ zodSchema: zodSchema71,
167330
167741
  interaction: {
167331
167742
  startedMsg: ({ params }) => `Stopping Metro on port ${params.port}`,
167332
167743
  completedMsg: ({ params }) => `Stopped Metro on port ${params.port}`,
@@ -168892,7 +169303,7 @@ var MACOS_PLATFORM_FLAG = { [FLAG_ENUM_META_KEY]: { macos: MACOS_APPS_FLAG } };
168892
169303
  var fileInputs3 = [
168893
169304
  { target: "project_root", path: "${project_root}", kind: "probe" }
168894
169305
  ];
168895
- var zodSchema71 = external_exports.object({
169306
+ var zodSchema72 = external_exports.object({
168896
169307
  name: external_exports.string().describe("E2E test name (letters, digits, `_`, `-`)."),
168897
169308
  project_root: external_exports.string().describe("Absolute path to the project root containing `.argent/e2e/`."),
168898
169309
  executionPrerequisite: external_exports.string().optional().describe(
@@ -168915,7 +169326,7 @@ var flowStartRecordingTool = {
168915
169326
  Use when capturing a reusable sequence of device actions for replay; load the \`argent-create-e2e\` skill first. Not for Apple TV or Android TV.
168916
169327
  Record live steps with \`e2e-add-step\` (start standalone tests with \`restart-app\`; use \`executionPrerequisite\` for fragments), \`e2e-add-echo\`, and \`e2e-add-script\`, then call \`e2e-finish-recording\`. Edit the YAML only after finishing.
168917
169328
  Returns \`{ message, e2eTestFile, savedTo, restarted?, discardedSteps?, fragmentShutdown? }\`. Fails if the target file or directory cannot be written.`,
168918
- zodSchema: zodSchema71,
169329
+ zodSchema: zodSchema72,
168919
169330
  aliases: ["flow-start-recording"],
168920
169331
  interaction: {
168921
169332
  // Name the flow: concurrent recordings interleave in one log, and "flow
@@ -172297,7 +172708,7 @@ function withRecordedPanelKind(command2, args, toolResult, ranAction = args.acti
172297
172708
  var fileInputs4 = [
172298
172709
  { target: "project_root", path: "${project_root}", kind: "probe", collect: "step" }
172299
172710
  ];
172300
- var zodSchema72 = external_exports.object({
172711
+ var zodSchema73 = external_exports.object({
172301
172712
  name: external_exports.string().describe("E2E test name from `e2e-start-recording`."),
172302
172713
  project_root: external_exports.string().describe("Project root from `e2e-start-recording`."),
172303
172714
  command: external_exports.string().describe(
@@ -172315,7 +172726,7 @@ function createFlowAddStepTool(registry2) {
172315
172726
  description: `Execute one MCP tool live and append it to an open e2e recording (\`gesture-tap\` records as a portable \`tap\` selector; \`restart-app\` as \`launch\`; supports \`{{output:PATH}}\` references).
172316
172727
  Use when recording steps after \`e2e-start-recording\` (pass \`shutdown: true\` for cleanup steps; call recording tools like \`e2e-add-script\` directly).
172317
172728
  Returns \`{ message, toolResult, stepCount, recorded?, savedTo }\`. Fails if no recording is open or the step errors (nothing recorded).`,
172318
- zodSchema: zodSchema72,
172729
+ zodSchema: zodSchema73,
172319
172730
  aliases: ["flow-add-step"],
172320
172731
  interaction: {
172321
172732
  // Name the flow: recordings are concurrent, so several of these lines can
@@ -172627,7 +173038,7 @@ Returns \`{ message, toolResult, stepCount, recorded?, savedTo }\`. Fails if no
172627
173038
 
172628
173039
  // ../tool-server/src/tools/flows/flow-insert-echo.ts
172629
173040
  init_zod();
172630
- var zodSchema73 = external_exports.object({
173041
+ var zodSchema74 = external_exports.object({
172631
173042
  name: external_exports.string().describe("Name of the e2e test being recorded: the one passed to e2e-start-recording."),
172632
173043
  project_root: external_exports.string().describe(
172633
173044
  "Absolute path to the project root of the e2e test being recorded: the same value passed to e2e-start-recording."
@@ -172640,7 +173051,7 @@ var flowInsertEchoTool = {
172640
173051
  description: `Record an echo step in the e2e test named by \`name\` + \`project_root\`. Echo steps print a message when the e2e test is replayed, useful as labels between tool calls.
172641
173052
  Use when you want to annotate a recorded e2e test with a human-readable label or checkpoint message; pass \`shutdown: true\` to label its shutdown steps.
172642
173053
  Returns { message, stepCount, savedTo }. Fails if that e2e test has no recording in progress.`,
172643
- zodSchema: zodSchema73,
173054
+ zodSchema: zodSchema74,
172644
173055
  fileInputs: PROJECT_ROOT_INPUT,
172645
173056
  aliases: ["flow-add-echo"],
172646
173057
  interaction: {
@@ -172668,7 +173079,7 @@ Returns { message, stepCount, savedTo }. Fails if that e2e test has no recording
172668
173079
  // ../tool-server/src/tools/flows/flow-set-vars.ts
172669
173080
  init_zod();
172670
173081
  init_capability();
172671
- var zodSchema74 = external_exports.object({
173082
+ var zodSchema75 = external_exports.object({
172672
173083
  name: external_exports.string().describe("Test name passed to e2e-start-recording."),
172673
173084
  project_root: external_exports.string().describe("Absolute project root passed to e2e-start-recording."),
172674
173085
  vars: nameRecordSchema(external_exports.string().nullable(), "vars").describe(
@@ -172678,7 +173089,7 @@ var zodSchema74 = external_exports.object({
172678
173089
  var flowSetVarsTool = {
172679
173090
  id: "e2e-set-vars",
172680
173091
  description: `Update the test inputs in an active e2e recording. Call directly before recording steps that use \`{{var:NAME}}\`. Saves the defaults under \`vars:\` and returns them with secret placeholders intact.`,
172681
- zodSchema: zodSchema74,
173092
+ zodSchema: zodSchema75,
172682
173093
  fileInputs: PROJECT_ROOT_INPUT,
172683
173094
  interaction: {
172684
173095
  startedMsg: ({ params }) => `Setting vars for e2e test ${params.name}`,
@@ -172762,7 +173173,7 @@ function renderOutput(output2) {
172762
173173
  const kept = bytes.subarray(0, utf8SafeCut(bytes, OUTPUT_RENDER_LIMIT_BYTES));
172763
173174
  return { outputJson: kept.toString("utf8"), outputTruncated: true };
172764
173175
  }
172765
- var zodSchema75 = external_exports.object({
173176
+ var zodSchema76 = external_exports.object({
172766
173177
  name: external_exports.string().describe("E2E test name from `e2e-start-recording`."),
172767
173178
  project_root: external_exports.string().describe("Project root from `e2e-start-recording`."),
172768
173179
  path: external_exports.string().describe("Script path (.mjs/.mts/.js/.ts) relative to the test YAML."),
@@ -172782,7 +173193,7 @@ var flowAddScriptTool = deferredShutdownFirst({
172782
173193
  description: `Run a local JS/TS script and record it as a \`script:\` step (requires no \`argent link\` / \`ARGENT_TOOLS_URL\`).
172783
173194
  Use when the user requests a local script in an open recording (output is available to later steps via \`{{output:PATH}}\`).
172784
173195
  Returns \`{ status, reason?, outputJson?, stepCount, recorded? }\`. A failed script returns \`status: "fail"\` or \`"error"\` without recording (check \`reason\` and affected state before retrying). Fails on invalid input, no open recording, or recording over a link.`,
172785
- zodSchema: zodSchema75,
173196
+ zodSchema: zodSchema76,
172786
173197
  fileInputs: PROJECT_ROOT_INPUT,
172787
173198
  aliases: ["flow-add-script"],
172788
173199
  interaction: {
@@ -172937,7 +173348,7 @@ function anchoredWarnings(recorded, warnings, steps) {
172937
173348
  }
172938
173349
  return kept;
172939
173350
  }
172940
- var zodSchema76 = external_exports.object({
173351
+ var zodSchema77 = external_exports.object({
172941
173352
  name: external_exports.string().describe("E2E test name from `e2e-start-recording`."),
172942
173353
  project_root: external_exports.string().describe("Project root from `e2e-start-recording`.")
172943
173354
  });
@@ -172946,7 +173357,7 @@ var flowFinishRecordingTool = {
172946
173357
  description: `Finalize an open e2e recording (runs pending fragment cleanup first).
172947
173358
  Use when all steps have been recorded and you are ready to polish or replay the YAML (check any \`warning:\` lines in \`summary\` for recorded waits).
172948
173359
  Returns \`{ message, path, steps, shutdownSteps?, fragmentShutdown?, summary, e2eTestFile, savedTo }\`. Fails if no recording is open for \`name\` + \`project_root\`.`,
172949
- zodSchema: zodSchema76,
173360
+ zodSchema: zodSchema77,
172950
173361
  fileInputs: PROJECT_ROOT_INPUT,
172951
173362
  aliases: ["flow-finish-recording"],
172952
173363
  // It may run the fragments' shutdown, on the device.
@@ -176284,7 +176695,7 @@ async function bootChromiumForLaunch(state3, app) {
176284
176695
  if (retiring !== -1) {
176285
176696
  const [prev] = state3.owned.splice(retiring, 1);
176286
176697
  retiredId = prev.deviceId;
176287
- await teardownBootedChromium(registry2, prev);
176698
+ await retireOwned(state3, prev);
176288
176699
  }
176289
176700
  let booted;
176290
176701
  try {
@@ -176293,6 +176704,10 @@ async function bootChromiumForLaunch(state3, app) {
176293
176704
  return { ok: false, reason: await chromiumBootFailureReason(state3, err) };
176294
176705
  }
176295
176706
  state3.owned.push(booted);
176707
+ state3.endClaims.set(
176708
+ booted.deviceId,
176709
+ await claimPickedDevice(state3.ctx?.session, booted.deviceId)
176710
+ );
176296
176711
  state3.device = resolveDevice(booted.deviceId);
176297
176712
  await frontChromiumPage(registry2, state3.device);
176298
176713
  if (!await sleepOrAbort(POST_LAUNCH_SETTLE_MS, signal)) return ABORTED_OUTCOME;
@@ -176478,7 +176893,7 @@ Run the e2e test on the computer that runs the tool-server, with no link and no
176478
176893
  }
176479
176894
  );
176480
176895
  }
176481
- var zodSchema77 = external_exports.object({
176896
+ var zodSchema78 = external_exports.object({
176482
176897
  name: external_exports.string().optional().describe("Saved e2e test name in `<project_root>/.argent/e2e/` (or `.argent/flows/`)."),
176483
176898
  project_root: external_exports.string().describe(
176484
176899
  "Absolute path to the project root (script cwd; with e2e_test_path, run:/script:/baselines resolve beside the YAML)."
@@ -176519,7 +176934,7 @@ function createRunFlowTool(registry2) {
176519
176934
  description: `Run a saved YAML e2e test end to end. Use when replaying a recorded path or QA regression (use gesture tools for one-off actions, \`e2e-start-recording\` to author tests). Pass exactly one e2e test source: \`name\` or \`e2e_test_path\`.
176520
176935
  Returns a per-step report (\`ok: false\` on step failure). A main-step failure skips remaining main steps, then runs \`shutdown:\` steps (marked \`shutdown: true\`; failure sets \`shutdownFailed\`).
176521
176936
  Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the test, \`run:\` fragments, baselines, and absolute \`.png\`/\`.yaml\` args; steps needing other client files (e.g. \`script:\`, recording tools, directories) fail before step 1. Fails if the YAML is invalid, no unique matching device is booted, or pre-step link validation fails.`,
176522
- zodSchema: zodSchema77,
176937
+ zodSchema: zodSchema78,
176523
176938
  aliases: ["flow-execute"],
176524
176939
  interaction: {
176525
176940
  startedMsg: ({ params }) => `Running e2e test ${displayFlowName(params)}`,
@@ -176616,6 +177031,13 @@ Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the tes
176616
177031
  project
176617
177032
  );
176618
177033
  const device = resolved.device;
177034
+ let endClaim;
177035
+ try {
177036
+ endClaim = device && !params.device ? await claimPickedDevice(ctx?.session, device.id) : void 0;
177037
+ } catch (error63) {
177038
+ if (resolved.booted) await teardownBootedChromium(registry2, resolved.booted);
177039
+ throw error63;
177040
+ }
176619
177041
  const statusBarPinned = device !== null && await pinStatusBar(device, signal);
176620
177042
  if (device !== null && !signal?.aborted && mayRunSnapshotStep(flow)) {
176621
177043
  void warmSnapshotCapture(registry2, device);
@@ -176654,6 +177076,7 @@ Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the tes
176654
177076
  stopped: false,
176655
177077
  pinned: statusBarPinned,
176656
177078
  owned: resolved.booted ? [resolved.booted] : [],
177079
+ endClaims: new Map(endClaim && device ? [[device.id, endClaim]] : []),
176657
177080
  ...resolved.booted ? { hoistedBootMs: Date.now() - resolveStartedAt } : {},
176658
177081
  chromiumLaunched: false,
176659
177082
  snapshotApps: /* @__PURE__ */ new Map(),
@@ -176700,9 +177123,7 @@ Over a link (\`argent link\` / \`ARGENT_TOOLS_URL\`), the client uploads the tes
176700
177123
  } finally {
176701
177124
  aborted2 = state3.signal?.aborted === true;
176702
177125
  if (state3.pinned && device) await restoreStatusBar(device);
176703
- for (let i = state3.owned.length - 1; i >= 0; i--) {
176704
- await teardownBootedChromium(registry2, state3.owned[i]);
176705
- }
177126
+ await teardownOwned(state3);
176706
177127
  }
176707
177128
  const result = summarize(
176708
177129
  flowName,
@@ -177092,6 +177513,7 @@ function deferShutdown(state3) {
177092
177513
  stopped: false,
177093
177514
  pinned: false,
177094
177515
  owned: [],
177516
+ endClaims: /* @__PURE__ */ new Map(),
177095
177517
  output: output2,
177096
177518
  scriptLogBudget: createScriptLogBudget(),
177097
177519
  ...ctx?.emitProgress ? { onStepReport: ctx.emitProgress } : {},
@@ -177101,12 +177523,22 @@ function deferShutdown(state3) {
177101
177523
  try {
177102
177524
  await execShutdown(later);
177103
177525
  } finally {
177104
- for (let i = later.owned.length - 1; i >= 0; i--) {
177105
- await teardownBootedChromium(state3.registry, later.owned[i]);
177106
- }
177526
+ await teardownOwned(later);
177107
177527
  }
177108
177528
  };
177109
177529
  }
177530
+ async function teardownOwned(state3) {
177531
+ for (let i = state3.owned.length - 1; i >= 0; i--) await retireOwned(state3, state3.owned[i]);
177532
+ for (const end of state3.endClaims.values()) end();
177533
+ state3.endClaims.clear();
177534
+ }
177535
+ async function retireOwned(state3, booted) {
177536
+ await teardownBootedChromium(state3.registry, booted);
177537
+ const session = state3.ctx?.session;
177538
+ if (session) deviceClaims.release(session, claimKey(booted.deviceId));
177539
+ state3.endClaims.get(booted.deviceId)?.();
177540
+ state3.endClaims.delete(booted.deviceId);
177541
+ }
177110
177542
  async function drainShutdown(state3, floor, thrown) {
177111
177543
  while (state3.shutdownQueue.length > floor) {
177112
177544
  const next = state3.shutdownQueue.pop();
@@ -177665,7 +178097,7 @@ async function resolveFlowSource(params, fileInput, flowPathInput) {
177665
178097
  init_zod();
177666
178098
  init_src2();
177667
178099
  init_capability();
177668
- var zodSchema78 = external_exports.object({
178100
+ var zodSchema79 = external_exports.object({
177669
178101
  name: external_exports.string().optional().describe(
177670
178102
  "Name of a saved e2e test to check from `<project_root>/.argent/e2e`, or `.argent/flows` when it is not there."
177671
178103
  ),
@@ -177699,7 +178131,7 @@ each step that fails when it runs for a reason a device does not change, in this
177699
178131
  run: fragments and nested e2e tests its steps reach. Each problem holds at?, code? and message.
177700
178132
  at lists the steps from the e2e test to the problem, each { step, run?, e2e?, when? }.
177701
178133
  Pass exactly one e2e test source: name (under project_root) or e2e_test_path.`,
177702
- zodSchema: zodSchema78,
178134
+ zodSchema: zodSchema79,
177703
178135
  readOnly: true,
177704
178136
  // `argent e2e check` calls it.
177705
178137
  hideFromMcp: true,
@@ -177762,7 +178194,7 @@ var fileInputs5 = [
177762
178194
  },
177763
178195
  ...PROJECT_ROOT_INPUT
177764
178196
  ];
177765
- var zodSchema79 = external_exports.object({
178197
+ var zodSchema80 = external_exports.object({
177766
178198
  name: external_exports.string().optional().describe(
177767
178199
  'Name of a saved e2e test to inspect from `<project_root>/.argent/e2e`, or `.argent/flows` when it is not there (e.g. "settings-explore").'
177768
178200
  ),
@@ -177793,7 +178225,7 @@ correct account, correct screen) before committing to a run, or when relaying th
177793
178225
  Touches no device and needs none booted: it only reads the file.
177794
178226
  Fails if the e2e test file does not exist.
177795
178227
  Address the e2e test exactly as you will address it in e2e-execute: name or e2e_test_path, one and only one; supplying both or neither is rejected.`,
177796
- zodSchema: zodSchema79,
178228
+ zodSchema: zodSchema80,
177797
178229
  readOnly: true,
177798
178230
  // When its gates pass, e2e-execute without prerequisiteAcknowledged returns
177799
178231
  // the same executionPrerequisite, from the same resolveFlowSource, before any
@@ -178127,7 +178559,7 @@ async function readWorkspaceSnapshot(workspacePath) {
178127
178559
  var fileInputs6 = [
178128
178560
  { target: "workspacePath", path: "${workspacePath}", kind: "directory" }
178129
178561
  ];
178130
- var zodSchema80 = external_exports.object({
178562
+ var zodSchema81 = external_exports.object({
178131
178563
  workspacePath: external_exports.string().describe("Absolute path to the project root directory to inspect (e.g. /Users/dev/MyApp)")
178132
178564
  });
178133
178565
  var gatherWorkspaceDataTool = {
@@ -178142,7 +178574,7 @@ Makefile targets, lint-staged config, and a list of detected config files.
178142
178574
  Use when a program needs the project type (React Native, Expo, Flutter, native iOS/Android,
178143
178575
  or other), build commands, platform support, package manager or QA tooling.
178144
178576
  Items it cannot read are null or empty collections. Fails if workspacePath is not a directory on the tool-server host.`,
178145
- zodSchema: zodSchema80,
178577
+ zodSchema: zodSchema81,
178146
178578
  readOnly: true,
178147
178579
  hideFromMcp: true,
178148
178580
  interaction: {
@@ -178160,7 +178592,7 @@ Items it cannot read are null or empty collections. Fails if workspacePath is no
178160
178592
  // ../tool-server/src/tools/system/dismiss-update.ts
178161
178593
  init_zod();
178162
178594
  var MAX_HOURS = 24 * 365 * 10;
178163
- var zodSchema81 = external_exports.object({
178595
+ var zodSchema82 = external_exports.object({
178164
178596
  hours: external_exports.number().min(0).describe(
178165
178597
  "Hours until reminders resume: 168 is a week, 87600 is the longest, 0 turns them back on"
178166
178598
  )
@@ -178168,7 +178600,7 @@ var zodSchema81 = external_exports.object({
178168
178600
  var dismissUpdateTool = {
178169
178601
  id: "dismiss-update",
178170
178602
  description: "Postpone the Argent update reminder and the automatic update, on every tool-server of this Argent home, when the user wants it later or tomorrow, wants it stopped, or never wants it (87600 hours). Installs nothing. A memory or a reminder of your own does not change it. Returns { message, remindersResumeAt, persisted, pendingVersion }: tell the user when reminders resume, and if persisted is false, that it did not fully hold.",
178171
- zodSchema: zodSchema81,
178603
+ zodSchema: zodSchema82,
178172
178604
  hideWhen: isUpdateCheckDisabled,
178173
178605
  interaction: {
178174
178606
  startedMsg: () => "Dismissing Argent update",
@@ -178222,7 +178654,7 @@ var fileInputs7 = [
178222
178654
  { target: "currentPath", path: "${currentPath}", kind: "file", optional: true },
178223
178655
  { target: "outputDir", path: "${outputDir}", kind: "probe", optional: true }
178224
178656
  ];
178225
- var zodSchema82 = external_exports.object({
178657
+ var zodSchema83 = external_exports.object({
178226
178658
  baselinePath: external_exports.string().min(1).optional().describe("Saved baseline PNG path (omit when `captureBaseline: true`)."),
178227
178659
  currentPath: external_exports.string().min(1).optional().describe("Saved current PNG path (omit when `captureCurrent: true`)."),
178228
178660
  udid: external_exports.string().min(1).describe(
@@ -178244,7 +178676,7 @@ var screenshotDiffTool = {
178244
178676
  description: `Compare two PNG screenshots (saved files or one live capture<flag:harmonyos> on iOS, Android, or HarmonyOS</flag:harmonyos>) and return a visual-diff summary (status bar ignored).
178245
178677
  Use when checking pixel-visible regressions (layout, spacing, color, typography, clipping, overflow). Both images must have identical dimensions: save baselines with screenshot scale: 1.0, one per device model.<flag:macos-apps> Mac apps: resized windows fail as a dimension mismatch.</flag:macos-apps>
178246
178678
  Returns \`{ summary, diffPath?, contextDiffPath? }\` with normalized [0,1] changed regions. Fails if sources are invalid, dimensions differ, files cannot be read/written, or the capture backend<flag:harmonyos> (\`hdc\` on HarmonyOS)</flag:harmonyos> is unreachable.`,
178247
- zodSchema: zodSchema82,
178679
+ zodSchema: zodSchema83,
178248
178680
  searchHint: "compare screenshots png diff visual UI changes UI regression visual regression screenshot diff changed regions text ocr live capture<flag:harmonyos> harmony harmonyos</flag:harmonyos>",
178249
178681
  interaction: {
178250
178682
  startedMsg: () => "Comparing screenshots",
@@ -178592,7 +179024,7 @@ async function captureElementFrame(registry2, udid, match, opts = {}) {
178592
179024
 
178593
179025
  // ../tool-server/src/tools/variants/propose-variant.ts
178594
179026
  init_capability();
178595
- var zodSchema83 = external_exports.object({
179027
+ var zodSchema84 = external_exports.object({
178596
179028
  element: external_exports.string().min(1).max(200).describe(
178597
179029
  'Human name of the on-screen element this variant targets, e.g. "Foo button" or "profile header". Repeated calls with the same element accumulate multiple variants on it. Used as the default screen matcher when `match` is omitted.'
178598
179030
  ),
@@ -178645,7 +179077,7 @@ arrives as a follow-up message (this is the case in an \`argent lens\` CLI sessi
178645
179077
 
178646
179078
  Returns { round, elementId, variantId, element, variantCount, totalElements }: confirmation only;
178647
179079
  it does not wait for the user.`,
178648
- zodSchema: zodSchema83,
179080
+ zodSchema: zodSchema84,
178649
179081
  searchHint: "propose design variant alternative option for element non-blocking ab choice",
178650
179082
  featureFlag: "argent-lens",
178651
179083
  interaction: {
@@ -178681,7 +179113,7 @@ it does not wait for the user.`,
178681
179113
 
178682
179114
  // ../tool-server/src/tools/variants/await-user-selection.ts
178683
179115
  init_zod();
178684
- var zodSchema84 = external_exports.object({
179116
+ var zodSchema85 = external_exports.object({
178685
179117
  timeoutSeconds: external_exports.number().int().min(5).max(86400).optional().describe(
178686
179118
  "Max seconds to block this call before returning a re-awaitable { status: 'pending' } result (default 1800). The user's proposals stay live across timeouts; on 'pending' just call await_user_selection again. Lower this if your MCP client enforces a short request timeout."
178687
179119
  )
@@ -178709,7 +179141,7 @@ Returns one of:
178709
179141
 
178710
179142
  This tool is long-running; it intentionally holds the request open. It honors client
178711
179143
  disconnects (aborts cleanly).`,
178712
- zodSchema: zodSchema84,
179144
+ zodSchema: zodSchema85,
178713
179145
  searchHint: "await wait user selection choice variant blocking confirm picks complete",
178714
179146
  featureFlag: "argent-lens",
178715
179147
  // Hidden while an `argent lens` CLI session owns the preview window: there the
@@ -178762,7 +179194,7 @@ var tabAction = {
178762
179194
  var capability38 = {
178763
179195
  chromium: { app: true }
178764
179196
  };
178765
- var zodSchema85 = external_exports.object({
179197
+ var zodSchema86 = external_exports.object({
178766
179198
  udid: external_exports.string().describe("Chromium device id (`chromium-cdp-<port>`)."),
178767
179199
  action: external_exports.enum(["list", "select", "new", "close"]).describe("Tab operation."),
178768
179200
  tab: external_exports.string().optional().describe("Tab id (e.g. `t2`) or label (`select` required; `close` defaults to active)."),
@@ -178774,7 +179206,7 @@ var chromiumTabsTool = {
178774
179206
  description: `List and switch tabs/windows (or open/close them) in a Chromium (CDP) or Electron app (all UI tools target the active tab).
178775
179207
  Use when switching between multiple tabs/windows or opening/closing pages.
178776
179208
  Returns \`{ tabs: [{ tabId, targetId, title, url, active, label? }] }\`. Fails on non-Chromium targets or unknown tab ids.`,
178777
- zodSchema: zodSchema85,
179209
+ zodSchema: zodSchema86,
178778
179210
  searchHint: "tab tabs window windows switch select close new open multi-tab chromium electron",
178779
179211
  interaction: {
178780
179212
  startedMsg: ({ params }) => tabAction[params.action].started(params),
@@ -178891,7 +179323,7 @@ var cookieAction = {
178891
179323
  var capability39 = {
178892
179324
  chromium: { app: true }
178893
179325
  };
178894
- var zodSchema86 = external_exports.object({
179326
+ var zodSchema87 = external_exports.object({
178895
179327
  udid: external_exports.string().describe("Chromium device id (`chromium-cdp-<port>`)."),
178896
179328
  action: external_exports.enum(["get", "set", "delete", "clear"]).describe(
178897
179329
  "get: read cookies. set: create/update a cookie. delete: remove matching cookies. clear: remove ALL browser cookies across all domains (ignores url/domain)."
@@ -178911,7 +179343,7 @@ var chromiumCookiesTool = {
178911
179343
  description: `Read and write cookies (including HttpOnly) in a Chromium (CDP) app.
178912
179344
  Use when seeding an auth session or asserting cookie state (\`set\`/\`delete\` need \`url\` or \`domain\`). \`clear\` wipes ALL browser cookies across every domain (ignores \`url\`/\`domain\`); use \`get\` + \`delete\` to clear a single domain.
178913
179345
  Returns \`{ cookies, count }\` (\`get\`) or \`{ set }\` / \`{ deleted }\` / \`{ cleared }\`. Fails on non-Chromium targets or missing required params.`,
178914
- zodSchema: zodSchema86,
179346
+ zodSchema: zodSchema87,
178915
179347
  searchHint: "cookies cookie get set delete clear httponly samesite session auth chromium",
178916
179348
  interaction: {
178917
179349
  startedMsg: ({ params }) => `${cookieAction[params.action].started} browser cookies`,
@@ -178992,7 +179424,7 @@ var storageAction = {
178992
179424
  var capability40 = {
178993
179425
  chromium: { app: true }
178994
179426
  };
178995
- var zodSchema87 = external_exports.object({
179427
+ var zodSchema88 = external_exports.object({
178996
179428
  udid: external_exports.string().describe("Chromium device id from `list-devices` (e.g. `chromium-cdp-9222`)."),
178997
179429
  store: external_exports.enum(["local", "session"]).describe("`local`: localStorage. `session`: sessionStorage."),
178998
179430
  action: external_exports.enum(["get", "set", "remove", "clear"]).describe(
@@ -179006,7 +179438,7 @@ var chromiumStorageTool = {
179006
179438
  description: `Read and write localStorage / sessionStorage of a Chromium (CDP) app, for the origin of the active tab's page.
179007
179439
  Use when seeding feature flags / auth tokens before an e2e test or asserting persisted app state after one.
179008
179440
  Returns { value } for one key, { entries, count } for all keys, and { set } / { removed } / { cleared } for the writes. Fails if the device is not a Chromium (CDP) device, or the action is missing the \`key\` / \`value\` it needs.`,
179009
- zodSchema: zodSchema87,
179441
+ zodSchema: zodSchema88,
179010
179442
  searchHint: "storage localstorage sessionstorage local session get set remove clear key value chromium",
179011
179443
  // Agents read and write Web Storage with debugger-evaluate, which runs the same
179012
179444
  // Runtime.evaluate on the active page. The SDK and the e2e-full suite still call it.
@@ -179225,7 +179657,7 @@ async function stub(app, params) {
179225
179657
  });
179226
179658
  return { armed, mode, panelKind };
179227
179659
  }
179228
- var zodSchema88 = external_exports.object({
179660
+ var zodSchema89 = external_exports.object({
179229
179661
  udid: external_exports.string().describe("Mac app id from `list-devices` (macos-app-<bundle id>)."),
179230
179662
  action: external_exports.enum(["list", "choose", "cancel", "discard", "stub"]).describe(
179231
179663
  "list: the open file panels. choose: answer a panel with path or paths. cancel: cancel a panel. discard: answer a panel with its Delete or Don't Save button. stub: arm an answer or a cancel for the next panel the app presents (stubMode)."
@@ -179258,7 +179690,7 @@ For stub, panelKind names the kind of panel the answer is for; without it, paths
179258
179690
  A sandboxed app that argent started is given access to the chosen paths only. A save panel that lists file formats refuses a path whose extension matches none of them, also a path with no extension, unless it saves any file (public.data, public.item) or allows other file types. On macOS 15 and later, the extension picks the format. argent does not check a path for an open panel against the panel's allowed file types.
179259
179691
  Returns { panels } for list, { chosen, panel, kind, paths } for choose, { cancelled, panel } for cancel, { discarded, panel } for discard, { armed, mode, panelKind? } for stub.
179260
179692
  Fails if no panel appears within timeoutMs, if more than one panel is open and panel is not given, if a path is relative or does not exist (a save panel needs an existing folder), if a path for a save panel is an existing folder other than a document package the panel saves, if the path does not fit the panel choose finds (a folder for a panel of files, a file for a panel of folders, a refused extension), if discard finds no Delete or Don't Save button, or if the Mac app is not running.`,
179261
- zodSchema: zodSchema88,
179693
+ zodSchema: zodSchema89,
179262
179694
  searchHint: "file panel dialog open save choose pick file folder nsopenpanel nssavepanel mac app",
179263
179695
  featureFlag: "macos-apps",
179264
179696
  interaction: {
@@ -179360,7 +179792,7 @@ function renderMenus(items, depth, lines) {
179360
179792
  if (item.items) renderMenus(item.items, depth + 1, lines);
179361
179793
  }
179362
179794
  }
179363
- var zodSchema89 = external_exports.object({
179795
+ var zodSchema90 = external_exports.object({
179364
179796
  udid: external_exports.string().describe("Mac app id from `list-devices` (macos-app-<bundle id>)."),
179365
179797
  action: external_exports.enum(["list", "choose"]).describe(
179366
179798
  "list: the app's menu bar, one line per item. choose: run one menu item, by path or identifier."
@@ -179376,7 +179808,7 @@ var menuBarTool = {
179376
179808
  Use when a command lives in the app's menus. Use keyboard instead for a shortcut you already know, and file-panel for the open or save panel that a command shows.
179377
179809
  list returns { menuBar }, one line per item indented under its menu: the title (a menu ends with " >"), [disabled] or [checked], the shortcut in keyboard syntax, and id="..." when the item has one. choose takes path (the titles from the menu bar down, e.g. ["File", "Export..."]) or identifier, and returns { chosen } with the path; the command runs right after the reply.
179378
179810
  Fails if no item matches (the error lists the titles at that level), if the item is disabled or is a menu, if a menu of the app is open, or if the device is not a Mac app.`,
179379
- zodSchema: zodSchema89,
179811
+ zodSchema: zodSchema90,
179380
179812
  searchHint: "menu bar main menu command item file edit view window help choose mac app",
179381
179813
  featureFlag: "macos-apps",
179382
179814
  interaction: {
@@ -179468,6 +179900,7 @@ function createRegistry() {
179468
179900
  registry2.registerBlueprint(androidNetworkInspectorBlueprint);
179469
179901
  registry2.registerBlueprint(androidNetworkShaperBlueprint);
179470
179902
  registry2.registerTool(listDevicesTool);
179903
+ registry2.registerTool(releaseDeviceTool);
179471
179904
  registry2.registerTool(createBootDeviceTool(registry2));
179472
179905
  registry2.registerTool(createLaunchAppTool(registry2));
179473
179906
  registry2.registerTool(createRestartAppTool(registry2));