@swmansion/argent 0.30.2-next.7 → 0.30.2-next.8

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
@@ -35577,7 +35577,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
35577
35577
  var SESSION_ID2 = randomUUID5();
35578
35578
  function readCliVersion() {
35579
35579
  if (true) {
35580
- return "0.30.2-next.7";
35580
+ return "0.30.2-next.8";
35581
35581
  }
35582
35582
  return "0.0.0";
35583
35583
  }
@@ -16899,7 +16899,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16899
16899
  var SESSION_ID = randomUUID4();
16900
16900
  function readCliVersion() {
16901
16901
  if (true) {
16902
- return "0.30.2-next.7";
16902
+ return "0.30.2-next.8";
16903
16903
  }
16904
16904
  return "0.0.0";
16905
16905
  }
@@ -28764,6 +28764,64 @@ async function startMcpServer(options) {
28764
28764
  reconnect,
28765
28765
  extraHeaders: aiClientHeaders
28766
28766
  });
28767
+ async function awaitScreenSettled(udid, toolName) {
28768
+ const maxWaitMs = getAutoScreenshotDelayMs(toolName);
28769
+ if (maxWaitMs === 0) return true;
28770
+ try {
28771
+ const idle = await callTool("await-screen-idle", { udid, timeoutMs: maxWaitMs });
28772
+ await spyLog({
28773
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
28774
+ event: "auto_screenshot_readiness",
28775
+ name: toolName,
28776
+ maxWaitMs,
28777
+ ...idle.result
28778
+ });
28779
+ return idle.result?.settled === true;
28780
+ } catch {
28781
+ await new Promise((r) => setTimeout(r, maxWaitMs));
28782
+ return false;
28783
+ }
28784
+ }
28785
+ async function captureScreenshotBlocks(udid) {
28786
+ try {
28787
+ const { result } = await callTool("screenshot", { udid });
28788
+ const blocks = await toMcpContent(result, "image", {
28789
+ toolsUrl: TOOLS_URL,
28790
+ authToken: AUTH_TOKEN,
28791
+ deviceId: udid
28792
+ });
28793
+ if (!blocks.some((b) => b.type === "image")) return [];
28794
+ return [{ type: "text", text: "--- Screen after action ---" }, ...blocks];
28795
+ } catch {
28796
+ return [];
28797
+ }
28798
+ }
28799
+ async function captureTreeBlocks(udid, toolName) {
28800
+ const t1 = Date.now();
28801
+ try {
28802
+ const d = await callTool("describe", { udid });
28803
+ const desc = d.result?.description;
28804
+ await spyLog({
28805
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
28806
+ event: "auto_describe",
28807
+ name: toolName,
28808
+ durationMs: Date.now() - t1,
28809
+ chars: typeof desc === "string" ? desc.length : 0
28810
+ });
28811
+ if (typeof desc !== "string" || desc.length === 0) return [];
28812
+ return [{ type: "text", text: `${AUTO_DESCRIBE_HEADER}
28813
+ ${desc}` }];
28814
+ } catch (e) {
28815
+ await spyLog({
28816
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
28817
+ event: "auto_describe",
28818
+ name: toolName,
28819
+ durationMs: Date.now() - t1,
28820
+ error: String(e instanceof Error ? e.message : e)
28821
+ });
28822
+ return [];
28823
+ }
28824
+ }
28767
28825
  const server = new Server(
28768
28826
  { name: "argent", version: getInstalledVersion() },
28769
28827
  {
@@ -28831,72 +28889,11 @@ async function startMcpServer(options) {
28831
28889
  }
28832
28890
  ];
28833
28891
  } else if (udid && (wantScreenshot || wantTree)) {
28834
- const maxWaitMs = getAutoScreenshotDelayMs(params.name);
28835
- if (maxWaitMs > 0) {
28836
- try {
28837
- const idle = await callTool("await-screen-idle", { udid, timeoutMs: maxWaitMs });
28838
- await spyLog({
28839
- ts: (/* @__PURE__ */ new Date()).toISOString(),
28840
- event: "auto_screenshot_readiness",
28841
- name: params.name,
28842
- maxWaitMs,
28843
- ...idle.result
28844
- });
28845
- } catch {
28846
- await new Promise((r) => setTimeout(r, maxWaitMs));
28847
- }
28848
- }
28849
- if (wantScreenshot) {
28850
- try {
28851
- const screenshotResult = await callTool("screenshot", { udid });
28852
- const screenshotContent = await toMcpContent(screenshotResult.result, "image", {
28853
- toolsUrl: TOOLS_URL,
28854
- authToken: AUTH_TOKEN,
28855
- deviceId: udid
28856
- });
28857
- const hasImage = screenshotContent.some((b) => b.type === "image");
28858
- if (hasImage) {
28859
- content = [
28860
- ...content,
28861
- {
28862
- type: "text",
28863
- text: "--- Screen after action ---"
28864
- },
28865
- ...screenshotContent
28866
- ];
28867
- }
28868
- } catch {
28869
- }
28870
- }
28871
- if (wantTree) {
28872
- const t1 = Date.now();
28873
- try {
28874
- const d = await callTool("describe", { udid });
28875
- const desc = d.result?.description;
28876
- if (typeof desc === "string" && desc.length > 0) {
28877
- content = [
28878
- ...content,
28879
- { type: "text", text: `${AUTO_DESCRIBE_HEADER}
28880
- ${desc}` }
28881
- ];
28882
- }
28883
- await spyLog({
28884
- ts: (/* @__PURE__ */ new Date()).toISOString(),
28885
- event: "auto_describe",
28886
- name: params.name,
28887
- durationMs: Date.now() - t1,
28888
- chars: typeof desc === "string" ? desc.length : 0
28889
- });
28890
- } catch (e) {
28891
- await spyLog({
28892
- ts: (/* @__PURE__ */ new Date()).toISOString(),
28893
- event: "auto_describe",
28894
- name: params.name,
28895
- durationMs: Date.now() - t1,
28896
- error: String(e instanceof Error ? e.message : e)
28897
- });
28898
- }
28899
- }
28892
+ const screenSettled = await awaitScreenSettled(udid, params.name);
28893
+ const screenshot = wantScreenshot ? captureScreenshotBlocks(udid) : Promise.resolve([]);
28894
+ if (!screenSettled) await screenshot;
28895
+ const tree = wantTree ? captureTreeBlocks(udid, params.name) : Promise.resolve([]);
28896
+ content = [...content, ...await screenshot, ...await tree];
28900
28897
  }
28901
28898
  if (note) {
28902
28899
  content = [{ type: "text", text: note }, ...content];
@@ -100944,7 +100944,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
100944
100944
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
100945
100945
  function readCliVersion() {
100946
100946
  if (true) {
100947
- return "0.30.2-next.7";
100947
+ return "0.30.2-next.8";
100948
100948
  }
100949
100949
  return "0.0.0";
100950
100950
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.30.2-next.7",
3
+ "version": "0.30.2-next.8",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator and Android Emulator control",
6
6
  "license": "Apache-2.0",