@swmansion/argent 0.36.1-next.13 → 0.36.1-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli-cmds.mjs CHANGED
@@ -39193,7 +39193,7 @@ function isCi(env = process.env) {
39193
39193
  var SESSION_ID2 = randomUUID5();
39194
39194
  function readCliVersion() {
39195
39195
  if (true) {
39196
- return "0.36.1-next.13";
39196
+ return "0.36.1-next.14";
39197
39197
  }
39198
39198
  return "0.0.0";
39199
39199
  }
@@ -17199,7 +17199,7 @@ function isCi(env = process.env) {
17199
17199
  var SESSION_ID = randomUUID4();
17200
17200
  function readCliVersion() {
17201
17201
  if (true) {
17202
- return "0.36.1-next.13";
17202
+ return "0.36.1-next.14";
17203
17203
  }
17204
17204
  return "0.0.0";
17205
17205
  }
@@ -38688,7 +38688,7 @@ async function startMcpServer(options) {
38688
38688
  const autoDescribeOn = autoDescribeEnabled();
38689
38689
  const whatsNewOn = whatsNewEnabled();
38690
38690
  const installedVersion = getInstalledVersion();
38691
- const highlightsVersion = true ? "0.36.1-next.13" : installedVersion;
38691
+ const highlightsVersion = true ? "0.36.1-next.14" : installedVersion;
38692
38692
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
38693
38693
  const trees = createTreeMemory();
38694
38694
  const screenshots = createScreenshotMemory();
@@ -23289,6 +23289,7 @@ var init_registry = __esm({
23289
23289
  blueprint,
23290
23290
  state: "IDLE" /* IDLE */,
23291
23291
  instance: null,
23292
+ initAbort: null,
23292
23293
  initPromise: null,
23293
23294
  dependents: /* @__PURE__ */ new Set()
23294
23295
  };
@@ -23317,11 +23318,18 @@ var init_registry = __esm({
23317
23318
  return node2.initPromise;
23318
23319
  }
23319
23320
  this._transition(node2, "STARTING" /* STARTING */);
23320
- const initPromise = this._initialize(node2, [...resolutionPath, urn], options);
23321
+ const initAbort = new AbortController();
23322
+ node2.initAbort = initAbort;
23323
+ const initPromise = this._initialize(
23324
+ node2,
23325
+ [...resolutionPath, urn],
23326
+ initAbort.signal,
23327
+ options
23328
+ );
23321
23329
  node2.initPromise = initPromise;
23322
23330
  return initPromise;
23323
23331
  }
23324
- async _initialize(node2, resolutionPath, options) {
23332
+ async _initialize(node2, resolutionPath, signal, options) {
23325
23333
  const { urn, blueprint } = node2;
23326
23334
  const { payload } = parseURN(urn);
23327
23335
  try {
@@ -23332,7 +23340,13 @@ var init_registry = __esm({
23332
23340
  const depNode = this.services.get(depUrn);
23333
23341
  depNode.dependents.add(urn);
23334
23342
  }
23335
- const instance = await blueprint.factory(resolvedDeps, payload, options);
23343
+ if (signal.aborted) {
23344
+ throw new ServiceInitializationError(urn, "Service was terminated during initialization", {
23345
+ cause: terminatingSignalCause("Service was terminated during initialization")
23346
+ });
23347
+ }
23348
+ const instance = await blueprint.factory(resolvedDeps, payload, options, signal);
23349
+ if (!signal.aborted) node2.initAbort = null;
23336
23350
  if (node2.state !== "STARTING" /* STARTING */) {
23337
23351
  try {
23338
23352
  await instance.dispose();
@@ -23352,6 +23366,12 @@ var init_registry = __esm({
23352
23366
  });
23353
23367
  return instance.api;
23354
23368
  } catch (error63) {
23369
+ if (signal.aborted) {
23370
+ throw new ServiceInitializationError(urn, "Service was terminated during initialization", {
23371
+ cause: terminatingSignalCause("Service was terminated during initialization")
23372
+ });
23373
+ }
23374
+ node2.initAbort = null;
23355
23375
  const cause = error63 instanceof Error ? error63 : new Error(String(error63));
23356
23376
  this._transition(node2, "ERROR" /* ERROR */, cause);
23357
23377
  node2.initPromise = null;
@@ -23387,6 +23407,8 @@ var init_registry = __esm({
23387
23407
  if (!node2 || node2.state === "IDLE" /* IDLE */ || node2.state === "TERMINATING" /* TERMINATING */)
23388
23408
  return;
23389
23409
  this._transition(node2, "TERMINATING" /* TERMINATING */);
23410
+ node2.initAbort?.abort();
23411
+ node2.initAbort = null;
23390
23412
  for (const depUrn of [...node2.dependents]) {
23391
23413
  await this._teardown(depUrn, cause);
23392
23414
  }
@@ -73485,7 +73507,7 @@ function isCi(env = process.env) {
73485
73507
  var SESSION_ID = (0, import_node_crypto4.randomUUID)();
73486
73508
  function readCliVersion() {
73487
73509
  if (true) {
73488
- return "0.36.1-next.13";
73510
+ return "0.36.1-next.14";
73489
73511
  }
73490
73512
  return "0.0.0";
73491
73513
  }
@@ -103954,6 +103976,7 @@ var NATIVE_DEVTOOLS_INIT_RETRY_COOLDOWN_MS = 3e4;
103954
103976
  var NATIVE_DEVTOOLS_AGE_SLOP_MS = 3e3;
103955
103977
  var NATIVE_DEVTOOLS_CONNECT_BUDGET_MS = 15e3;
103956
103978
  var LENT_RELEASE_TIMEOUT_MS = 1e3;
103979
+ var NATIVE_DEVTOOLS_ATTACH_HANDSHAKE_TIMEOUT_MS = 2e3;
103957
103980
  function buildAppStateMessage(bundleId, state3) {
103958
103981
  switch (state3) {
103959
103982
  case "not_running":
@@ -104152,7 +104175,7 @@ var nativeDevtoolsBlueprint = {
104152
104175
  getURN(device) {
104153
104176
  return nativeDevtoolsRef(device).urn;
104154
104177
  },
104155
- async factory(_deps, _payload, options) {
104178
+ async factory(_deps, _payload, options, signal) {
104156
104179
  const opts = options;
104157
104180
  if (!opts?.device) {
104158
104181
  throw new FailureError(
@@ -104573,7 +104596,7 @@ var nativeDevtoolsBlueprint = {
104573
104596
  } catch {
104574
104597
  }
104575
104598
  }
104576
- const serveAgentConnection = (socket) => {
104599
+ const serveAgentConnection = (socket, onHandshake) => {
104577
104600
  let bundleId = null;
104578
104601
  let conn = null;
104579
104602
  attachNdjsonReader(socket, {
@@ -104662,6 +104685,7 @@ var nativeDevtoolsBlueprint = {
104662
104685
  }
104663
104686
  if (conn.pid === void 0) void readConnectionPid(bundleId, conn);
104664
104687
  else wakeConnectionWaiters();
104688
+ onHandshake?.();
104665
104689
  return;
104666
104690
  }
104667
104691
  if (msg.type === "CDP" && conn) {
@@ -104687,8 +104711,12 @@ var nativeDevtoolsBlueprint = {
104687
104711
  let lentConnectedAt = 0;
104688
104712
  let disposed = false;
104689
104713
  if (lentSocketPath) {
104714
+ let pending = null;
104715
+ const hangUp = () => pending?.destroy(new Error("the service was torn down"));
104716
+ signal?.addEventListener("abort", hangUp, { once: true });
104690
104717
  lentSocket = await new Promise((resolve24, reject) => {
104691
104718
  const socket = net3.connect(lentSocketPath);
104719
+ pending = socket;
104692
104720
  const onError = (err) => {
104693
104721
  socket.destroy();
104694
104722
  reject(
@@ -104708,9 +104736,34 @@ var nativeDevtoolsBlueprint = {
104708
104736
  socket.off("error", onError);
104709
104737
  resolve24(socket);
104710
104738
  });
104739
+ if (signal?.aborted) hangUp();
104711
104740
  });
104741
+ const attached = lentSocket;
104712
104742
  lentConnectedAt = performance.now();
104713
- serveAgentConnection(lentSocket);
104743
+ const hungUpBeforeHandshake = await new Promise((resolve24) => {
104744
+ const finish = (hungUp) => {
104745
+ clearTimeout(timer);
104746
+ attached.off("close", onClose);
104747
+ resolve24(hungUp);
104748
+ };
104749
+ const onClose = () => finish(true);
104750
+ const timer = setTimeout(() => finish(false), NATIVE_DEVTOOLS_ATTACH_HANDSHAKE_TIMEOUT_MS);
104751
+ attached.once("close", onClose);
104752
+ serveAgentConnection(attached, () => finish(false));
104753
+ if (attached.destroyed) onClose();
104754
+ });
104755
+ signal?.removeEventListener("abort", hangUp);
104756
+ if (hungUpBeforeHandshake) {
104757
+ throw new FailureError(
104758
+ `${NATIVE_DEVTOOLS_NAMESPACE} lost the agent connection its provider was lending before the provider named the app it serves. Retry the call to attach again; if it keeps failing, run list-devices to see what the provider is offering now.`,
104759
+ {
104760
+ error_code: FAILURE_CODES.NATIVE_DEVTOOLS_ATTACH_LOST,
104761
+ error_kind: "network",
104762
+ failure_area: "tool_server",
104763
+ failure_stage: "native_devtools_attach"
104764
+ }
104765
+ );
104766
+ }
104714
104767
  lentSocket.once("close", () => {
104715
104768
  if (disposed) return;
104716
104769
  events.emit(
@@ -105169,6 +105222,7 @@ function execSimctl(args, options = {}) {
105169
105222
  // ../tool-server/src/utils/simulator-watcher.ts
105170
105223
  var POLL_INTERVAL_MS = 1e4;
105171
105224
  var MAX_BACKOFF_TICKS = 29;
105225
+ var MAX_ATTACH_BACKOFF_POLLS = 30;
105172
105226
  var ARM_WAIT_MS = 15e3;
105173
105227
  var NATIVE_DEVTOOLS_URN_PREFIX = `${NATIVE_DEVTOOLS_NAMESPACE}:`;
105174
105228
  var armTarget = () => Promise.resolve();
@@ -105211,10 +105265,11 @@ async function getBootedUdids(signal) {
105211
105265
  async function initUdid(registry2, udid, trackedServices) {
105212
105266
  const started = await runningNativeDevtools(registry2, udid);
105213
105267
  const service = started ?? await resolveNativeDevtools(registry2, udid);
105214
- if (!service) return;
105268
+ if (!service) return false;
105215
105269
  trackedServices.set(udid, service);
105216
105270
  await started?.reverifyEnv().catch(() => {
105217
105271
  });
105272
+ return true;
105218
105273
  }
105219
105274
  function simulatorNativeDevtoolsRef(udid) {
105220
105275
  return nativeDevtoolsRef({ id: udid, platform: "ios", kind: "simulator" });
@@ -105286,6 +105341,7 @@ function startSimulatorWatcher(registry2) {
105286
105341
  }
105287
105342
  return true;
105288
105343
  }
105344
+ const attachBackoff = /* @__PURE__ */ new Map();
105289
105345
  function withoutForeignSimulators(booted) {
105290
105346
  const ours = /* @__PURE__ */ new Set();
105291
105347
  const claimed = /* @__PURE__ */ new Set();
@@ -105375,12 +105431,32 @@ function startSimulatorWatcher(registry2) {
105375
105431
  }
105376
105432
  consecutiveTimeouts = 0;
105377
105433
  await handBackClaimed(claimed);
105378
- const newUdids = [...booted].filter(
105379
- (udid) => targetedUdids.has(udid.toUpperCase()) && !trackedServices.has(udid)
105380
- );
105381
- const pendingAttempts = newUdids.map(
105382
- (udid) => initUdid(registry2, udid, trackedServices)
105383
- );
105434
+ for (const udid of attachBackoff.keys()) {
105435
+ if (!booted.has(udid) || !claimed.has(udid)) attachBackoff.delete(udid);
105436
+ }
105437
+ const newUdids = [...booted].filter((udid) => {
105438
+ if (!targetedUdids.has(udid.toUpperCase()) || trackedServices.has(udid)) return false;
105439
+ const backoff = attachBackoff.get(udid);
105440
+ if (backoff && backoff.pollsLeft > 0) {
105441
+ backoff.pollsLeft -= 1;
105442
+ return false;
105443
+ }
105444
+ return true;
105445
+ });
105446
+ const attemptInit = async (udid) => {
105447
+ const attached = await initUdid(registry2, udid, trackedServices);
105448
+ if (!claimed.has(udid)) return;
105449
+ if (attached) {
105450
+ attachBackoff.delete(udid);
105451
+ return;
105452
+ }
105453
+ const failures = (attachBackoff.get(udid)?.failures ?? 0) + 1;
105454
+ attachBackoff.set(udid, {
105455
+ failures,
105456
+ pollsLeft: Math.min(2 ** (failures - 1), MAX_ATTACH_BACKOFF_POLLS)
105457
+ });
105458
+ };
105459
+ const pendingAttempts = newUdids.map((udid) => attemptInit(udid));
105384
105460
  for (const [udid, service] of trackedServices) {
105385
105461
  if (!booted.has(udid)) continue;
105386
105462
  if (!service.isEnvSetup()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.36.1-next.13",
3
+ "version": "0.36.1-next.14",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server, CLI, and skills by Software Mansion that let AI coding agents control, test, debug, and profile apps on iOS simulators, Android emulators, physical devices, TVs, and desktop apps",
6
6
  "license": "Apache-2.0",
@@ -99,5 +99,5 @@
99
99
  "vitest": "^5.0.5",
100
100
  "yaml": "^2.9.1"
101
101
  },
102
- "gitHead": "575477bf7e776dca6058975c5f034c1c23a34bc0"
102
+ "gitHead": "0a21b3d562488e4e5142e3a79b65e198e2208326"
103
103
  }