@swmansion/argent 0.34.1-next.105 → 0.34.1-next.107

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
@@ -38575,7 +38575,7 @@ function isCi(env = process.env) {
38575
38575
  var SESSION_ID2 = randomUUID5();
38576
38576
  function readCliVersion() {
38577
38577
  if (true) {
38578
- return "0.34.1-next.105";
38578
+ return "0.34.1-next.106";
38579
38579
  }
38580
38580
  return "0.0.0";
38581
38581
  }
@@ -16998,7 +16998,7 @@ function isCi(env = process.env) {
16998
16998
  var SESSION_ID = randomUUID4();
16999
16999
  function readCliVersion() {
17000
17000
  if (true) {
17001
- return "0.34.1-next.105";
17001
+ return "0.34.1-next.106";
17002
17002
  }
17003
17003
  return "0.0.0";
17004
17004
  }
@@ -72948,7 +72948,7 @@ function isCi(env = process.env) {
72948
72948
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
72949
72949
  function readCliVersion() {
72950
72950
  if (true) {
72951
- return "0.34.1-next.105";
72951
+ return "0.34.1-next.106";
72952
72952
  }
72953
72953
  return "0.0.0";
72954
72954
  }
@@ -101345,6 +101345,22 @@ function createTabsManager(deps) {
101345
101345
  // ../tool-server/src/chromium-server/network.ts
101346
101346
  var MAX_RECORDS2 = 1e3;
101347
101347
  var shapesTraffic = (c) => c.offline || c.latency > 0 || c.downloadThroughput >= 0 || c.uploadThroughput >= 0;
101348
+ function unreadBodyLength(headers) {
101349
+ let length;
101350
+ let noStore = false;
101351
+ for (const [name, value] of Object.entries(headers ?? {})) {
101352
+ const header = name.toLowerCase();
101353
+ if (header === "transfer-encoding") return void 0;
101354
+ if (header === "content-encoding" && value.trim().toLowerCase() !== "identity") {
101355
+ return void 0;
101356
+ }
101357
+ if (header === "content-length") length = value.trim();
101358
+ if (header === "cache-control") {
101359
+ noStore ||= value.split(/[,\n]/).some((d) => d.trim().toLowerCase() === "no-store");
101360
+ }
101361
+ }
101362
+ return noStore && length !== void 0 && /^\d+$/.test(length) ? Number(length) : void 0;
101363
+ }
101348
101364
  function createNetworkManager(deps) {
101349
101365
  const { cdp } = deps;
101350
101366
  const order = [];
@@ -101353,6 +101369,7 @@ function createNetworkManager(deps) {
101353
101369
  let lastSeq = 0;
101354
101370
  let mark;
101355
101371
  let conditions = null;
101372
+ const bodyBytesLeft = /* @__PURE__ */ new WeakMap();
101356
101373
  function record2(requestId) {
101357
101374
  let rec = byId.get(requestId);
101358
101375
  if (!rec) {
@@ -101396,6 +101413,25 @@ function createNetworkManager(deps) {
101396
101413
  if (resp.headers) rec.responseHeaders = { ...rec.responseHeaders ?? {}, ...resp.headers };
101397
101414
  rec.fromCache = resp.fromDiskCache;
101398
101415
  rec.resourceType = params.type ?? rec.resourceType;
101416
+ const length = params.type === "Fetch" ? unreadBodyLength(resp.headers) : void 0;
101417
+ if (length !== void 0) bodyBytesLeft.set(rec, length);
101418
+ break;
101419
+ }
101420
+ // For a fetch() whose response is not stored (Cache-Control: no-store), Chrome
101421
+ // sends loadingFinished only once the page reads the body to its end, and never
101422
+ // for a body the page leaves unread. Such a body ended once the page got all of it.
101423
+ case "Network.dataReceived": {
101424
+ const rec = byId.get(params.requestId);
101425
+ const left = rec ? bodyBytesLeft.get(rec) : void 0;
101426
+ if (rec && left !== void 0) {
101427
+ const after = left - params.dataLength;
101428
+ bodyBytesLeft.set(rec, after);
101429
+ if (after <= 0 && !rec.finished) {
101430
+ rec.finished = true;
101431
+ const at = params.timestamp;
101432
+ if (rec.startTs && at !== void 0) rec.durationMs = (at - rec.startTs) * 1e3;
101433
+ }
101434
+ }
101399
101435
  break;
101400
101436
  }
101401
101437
  // The *ExtraInfo events carry on-the-wire headers (Authorization, Set-Cookie, …)
@@ -130187,7 +130223,7 @@ function killDetachedEmulator(child) {
130187
130223
  } catch {
130188
130224
  }
130189
130225
  }
130190
- async function assertScreencapAlive(serial, budgetMs = STAGE_BUDGET.firstRealFrameHot) {
130226
+ async function assertScreencapAlive(serial, onFailure, budgetMs = STAGE_BUDGET.firstRealFrameHot) {
130191
130227
  const deadline = Date.now() + budgetMs;
130192
130228
  let lastReading = null;
130193
130229
  while (Date.now() < deadline) {
@@ -130201,9 +130237,9 @@ async function assertScreencapAlive(serial, budgetMs = STAGE_BUDGET.firstRealFra
130201
130237
  if (Date.now() >= deadline) break;
130202
130238
  await new Promise((r) => setTimeout(r, 1500));
130203
130239
  }
130204
- await killEmulatorQuietly(serial);
130240
+ if (onFailure === "replace") await killEmulatorQuietly(serial);
130205
130241
  throw new FailureError(
130206
- `hot-boot composite did not restore within ${budgetMs / 1e3}s \u2014 \`screencap\` last returned ${JSON.stringify(lastReading ?? "no probe response")}. Falling back to cold boot so screenshots are usable.`,
130242
+ `hot-boot composite did not restore within ${budgetMs / 1e3}s \u2014 \`screencap\` last returned ${JSON.stringify(lastReading ?? "no probe response")}. ` + (onFailure === "replace" ? "Falling back to cold boot so screenshots are usable." : `Left ${serial} running. Pass \`force: true\` to replace it.`),
130207
130243
  {
130208
130244
  error_code: FAILURE_CODES.BOOT_ANDROID_HOT_BOOT_FRAME_UNUSABLE,
130209
130245
  failure_stage: "boot_android_hot_boot_frame",
@@ -130753,7 +130789,7 @@ async function avdInstances(avdName, listed) {
130753
130789
  readOnly.add(serial);
130754
130790
  if (boot.pinned) pinned.add(serial);
130755
130791
  }
130756
- return { readOnly, pinned };
130792
+ return { processes, readOnly, pinned };
130757
130793
  }
130758
130794
  function bootsClash(a, b) {
130759
130795
  if (a.port !== void 0 && a.port === b.port) return true;
@@ -130930,16 +130966,18 @@ async function bootAndroidImpl(params, overallDeadline) {
130930
130966
  );
130931
130967
  const blocks = (p) => !params.readOnly || !p.readOnly;
130932
130968
  let alreadyRunning = params.readOnly ? candidates.find((d) => instances.readOnly.has(d.serial)) : candidates.find((d) => !instances.readOnly.has(d.serial)) ?? candidates[0];
130933
- if (params.readOnly && portSerial !== null && !alreadyRunning && candidates[0]) {
130934
- const processes = await readEmulatorProcessesForAvd(params.avdName);
130969
+ let preserveOnProbeFailure = false;
130970
+ if (params.readOnly && !alreadyRunning && candidates[0]) {
130971
+ const { processes } = instances;
130935
130972
  const known = processes !== null && processes.length > 0;
130936
130973
  if (known && processes.every((p) => p.readOnly)) {
130937
130974
  alreadyRunning = candidates[0];
130938
- } else if (!params.force) {
130975
+ preserveOnProbeFailure = portSerial === null;
130976
+ } else if (portSerial !== null && !params.force) {
130939
130977
  throw portInUseError(
130940
130978
  known ? `${portSerial} already runs AVD "${params.avdName}" writable. Pass \`force: true\` to shut it down and boot it read-only, or pick another \`port\`.` : `${portSerial} already runs AVD "${params.avdName}", and Argent cannot tell whether it runs read-only: ${processes === null ? "the process list of this host is not available" : "its process is not in the process list"}. Use that emulator as it is, or pick another \`port\`.`
130941
130979
  );
130942
- } else {
130980
+ } else if (portSerial !== null) {
130943
130981
  alreadyRunning = candidates[0];
130944
130982
  }
130945
130983
  }
@@ -130953,7 +130991,10 @@ async function bootAndroidImpl(params, overallDeadline) {
130953
130991
  killedRunning = true;
130954
130992
  } else {
130955
130993
  try {
130956
- await assertScreencapAlive(alreadyRunning.serial);
130994
+ await assertScreencapAlive(
130995
+ alreadyRunning.serial,
130996
+ preserveOnProbeFailure ? "preserve" : "replace"
130997
+ );
130957
130998
  const note = await runningGuestVulkanNote(alreadyRunning.serial, params.guestVulkan);
130958
130999
  return {
130959
131000
  platform: "android",
@@ -130962,7 +131003,8 @@ async function bootAndroidImpl(params, overallDeadline) {
130962
131003
  booted: true,
130963
131004
  ...note ? { note } : {}
130964
131005
  };
130965
- } catch (_err) {
131006
+ } catch (err) {
131007
+ if (preserveOnProbeFailure) throw err;
130966
131008
  await dropKilledEmulator(alreadyRunning.serial);
130967
131009
  }
130968
131010
  }
@@ -131043,7 +131085,7 @@ async function bootAndroidImpl(params, overallDeadline) {
131043
131085
  expectedSerial,
131044
131086
  pinnedElsewhere
131045
131087
  });
131046
- await assertScreencapAlive(result.serial);
131088
+ await assertScreencapAlive(result.serial, "replace");
131047
131089
  rememberReadOnly(result.serial, result.pid);
131048
131090
  return {
131049
131091
  platform: "android",
@@ -140849,6 +140891,22 @@ function truncateBody(body, mimeType) {
140849
140891
  return body.length > MAX_BODY_SIZE ? `${cutMarker(`${body.length} chars`, mimeType)}
140850
140892
  ${body.slice(0, MAX_BODY_SIZE)}...` : body;
140851
140893
  }
140894
+ async function chromiumResponseBody(cdp, rec) {
140895
+ try {
140896
+ const out = await cdp.send("Network.getResponseBody", { requestId: rec.requestId });
140897
+ if (out.body != null) return { body: out.body, base64Encoded: out.base64Encoded === true };
140898
+ } catch {
140899
+ }
140900
+ if (!rec.finished || rec.failed) return void 0;
140901
+ try {
140902
+ const out = await cdp.send("Network.streamResourceContent", {
140903
+ requestId: rec.requestId
140904
+ });
140905
+ if (out.bufferedData != null) return { body: out.bufferedData, base64Encoded: true };
140906
+ } catch {
140907
+ }
140908
+ return void 0;
140909
+ }
140852
140910
  function utf8Text(bytes) {
140853
140911
  try {
140854
140912
  return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
@@ -140940,19 +140998,14 @@ If the ID is not found, the tool returns a message. Refresh the log if that happ
140940
140998
  mimeType: rec.mimeType ?? ""
140941
140999
  };
140942
141000
  if (params.includeBody) {
140943
- try {
140944
- const out = await chromium.cdp.send("Network.getResponseBody", {
140945
- requestId: rec.requestId
140946
- });
140947
- if (out.body != null) {
140948
- const body = out.base64Encoded ? utf8Text(Buffer.from(out.body, "base64")) : out.body;
140949
- if (typeof body !== "string") {
140950
- resp.body = `[body omitted: binary ${resp.mimeType || "data"}, ${body.length} bytes]`;
140951
- } else {
140952
- resp.body = truncateBody(body, resp.mimeType);
140953
- }
141001
+ const out = await chromiumResponseBody(chromium.cdp, rec);
141002
+ if (out) {
141003
+ const body = out.base64Encoded ? utf8Text(Buffer.from(out.body, "base64")) : out.body;
141004
+ if (typeof body !== "string") {
141005
+ resp.body = `[body omitted: binary ${resp.mimeType || "data"}, ${body.length} bytes]`;
141006
+ } else {
141007
+ resp.body = truncateBody(body, resp.mimeType);
140954
141008
  }
140955
- } catch {
140956
141009
  }
140957
141010
  }
140958
141011
  details2.response = resp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.34.1-next.105",
3
+ "version": "0.34.1-next.107",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
6
6
  "license": "Apache-2.0",
@@ -98,5 +98,5 @@
98
98
  "vitest": "^5.0.5",
99
99
  "yaml": "^2.9.1"
100
100
  },
101
- "gitHead": "c89f0f6d8b61a8cd09c9264a21ebae1c753936c9"
101
+ "gitHead": "f0dea93a2fc29b298309a896bc3d2177cc7b4004"
102
102
  }