@swmansion/argent 0.34.1-next.99 → 0.35.1-next.0

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.
Files changed (32) hide show
  1. package/bin/argent-android-devtools-0.4.0.apk +0 -0
  2. package/bin/darwin/argent-macos-helper +0 -0
  3. package/bin/darwin/ax-service +0 -0
  4. package/bin/darwin/simulator-server +0 -0
  5. package/bin/darwin/tvos-ax-service +0 -0
  6. package/bin/darwin/tvos-hid-daemon +0 -0
  7. package/bin/linux/simulator-server +0 -0
  8. package/bin/linux-arm64/simulator-server +0 -0
  9. package/bin/network-inspector/network-inspector.jar +0 -0
  10. package/bin/tcp/ax-service +0 -0
  11. package/bin/win32/simulator-server.exe +0 -0
  12. package/dist/cli-cmds.mjs +187 -182
  13. package/dist/installer.mjs +353 -222
  14. package/dist/mcp-server.mjs +235 -6
  15. package/dist/tool-server.cjs +1500 -975
  16. package/dylibs/libArgentAudio.dylib +0 -0
  17. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  18. package/dylibs/libKeyboardPatch.dylib +0 -0
  19. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  20. package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
  21. package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
  22. package/dylibs/tcp/argent-audio-feeder +0 -0
  23. package/dylibs/tcp/libArgentAudio.dylib +0 -0
  24. package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
  25. package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
  26. package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
  27. package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
  28. package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
  29. package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
  30. package/package.json +2 -2
  31. package/skills/argent-device-interact/SKILL.md +1 -1
  32. package/skills/argent-test-ui-flow/SKILL.md +1 -1
@@ -36495,6 +36495,10 @@ async function toMcpContent(result, outputHint, ctx, args) {
36495
36495
  }
36496
36496
  return [{ type: "text", text: stringifyForText(result) }];
36497
36497
  }
36498
+ function joinTextOnlyContent(blocks) {
36499
+ if (blocks.length < 2 || !blocks.every((b) => b.type === "text")) return blocks;
36500
+ return [{ type: "text", text: blocks.map((b) => b.text).join("\n") }];
36501
+ }
36498
36502
  var LINE_BREAK_THRESHOLD = 160;
36499
36503
  function isJsonOmitted(value) {
36500
36504
  return value === void 0 || typeof value === "function" || typeof value === "symbol";
@@ -37182,6 +37186,183 @@ function describedTree(result) {
37182
37186
  return `${hintLine}${description}`;
37183
37187
  }
37184
37188
 
37189
+ // ../argent-mcp/src/unchanged-screenshot.ts
37190
+ import { createHash as createHash5, randomInt as randomInt2 } from "node:crypto";
37191
+ import { inflateSync } from "node:zlib";
37192
+ var MAX_UNCHANGED_SCREENSHOTS_IN_A_ROW = 3;
37193
+ var UNCHANGED_SCREENSHOT_MAX_AGE_MS = 5 * 6e4;
37194
+ var PNG_SIGNATURE2 = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
37195
+ var MAX_DECODED_SCANLINE_BYTES = 64 * 1024 * 1024;
37196
+ function screenshotIdLine(id) {
37197
+ return `Screenshot id: ${id}`;
37198
+ }
37199
+ function unchangedScreenshotNote(id, tool) {
37200
+ return `Screenshot matches \`${id}\` from an earlier \`${tool}\` result (pixels unchanged). Call \`screenshot\` if you need a fresh image.`;
37201
+ }
37202
+ function paeth(a, b, c) {
37203
+ const p = a + b - c;
37204
+ const pa = Math.abs(p - a);
37205
+ const pb = Math.abs(p - b);
37206
+ const pc = Math.abs(p - c);
37207
+ if (pa <= pb && pa <= pc) return a;
37208
+ if (pb <= pc) return b;
37209
+ return c;
37210
+ }
37211
+ function channelsForColorType(colorType) {
37212
+ switch (colorType) {
37213
+ case 0:
37214
+ return 1;
37215
+ // Grayscale
37216
+ case 2:
37217
+ return 3;
37218
+ // RGB
37219
+ case 4:
37220
+ return 2;
37221
+ // Grayscale + Alpha
37222
+ case 6:
37223
+ return 4;
37224
+ // RGBA
37225
+ default:
37226
+ return 0;
37227
+ }
37228
+ }
37229
+ function fingerprintPng(png) {
37230
+ const pixelDigest = tryFingerprintPngPixels(png);
37231
+ if (pixelDigest !== null) return pixelDigest;
37232
+ return createHash5("sha256").update("raw:").update(png).digest("hex");
37233
+ }
37234
+ function tryFingerprintPngPixels(png) {
37235
+ if (png.length < PNG_SIGNATURE2.length + 25) return null;
37236
+ if (!png.subarray(0, PNG_SIGNATURE2.length).equals(PNG_SIGNATURE2)) return null;
37237
+ let width = 0;
37238
+ let height = 0;
37239
+ let colorType = -1;
37240
+ let hasIhdr = false;
37241
+ const idatChunks = [];
37242
+ let offset = PNG_SIGNATURE2.length;
37243
+ while (offset + 12 <= png.length) {
37244
+ const length = png.readUInt32BE(offset);
37245
+ const type = png.toString("ascii", offset + 4, offset + 8);
37246
+ const dataStart = offset + 8;
37247
+ const dataEnd = dataStart + length;
37248
+ if (dataEnd + 4 > png.length) return null;
37249
+ if (type === "IHDR") {
37250
+ if (length !== 13) return null;
37251
+ width = png.readUInt32BE(dataStart);
37252
+ height = png.readUInt32BE(dataStart + 4);
37253
+ const bitDepth = png[dataStart + 8];
37254
+ colorType = png[dataStart + 9];
37255
+ const compression = png[dataStart + 10];
37256
+ const filter = png[dataStart + 11];
37257
+ const interlace = png[dataStart + 12];
37258
+ if (width <= 0 || height <= 0 || bitDepth !== 8 || compression !== 0 || filter !== 0 || interlace !== 0) {
37259
+ return null;
37260
+ }
37261
+ hasIhdr = true;
37262
+ } else if (type === "IDAT") {
37263
+ idatChunks.push(png.subarray(dataStart, dataEnd));
37264
+ } else if (type === "IEND") {
37265
+ break;
37266
+ }
37267
+ offset = dataEnd + 4;
37268
+ }
37269
+ if (!hasIhdr || idatChunks.length === 0) return null;
37270
+ const bpp = channelsForColorType(colorType);
37271
+ if (bpp === 0) return null;
37272
+ const stride = width * bpp;
37273
+ const expectedBytes = height * (1 + stride);
37274
+ if (!Number.isSafeInteger(expectedBytes) || expectedBytes > MAX_DECODED_SCANLINE_BYTES) {
37275
+ return null;
37276
+ }
37277
+ let inflated;
37278
+ try {
37279
+ const compressed = idatChunks.length === 1 ? idatChunks[0] : Buffer.concat(idatChunks);
37280
+ inflated = inflateSync(compressed, { maxOutputLength: expectedBytes });
37281
+ } catch {
37282
+ return null;
37283
+ }
37284
+ if (inflated.length !== expectedBytes) return null;
37285
+ const hash = createHash5("sha256");
37286
+ hash.update(`pixels:${width}x${height}:${colorType}:`);
37287
+ let prev = new Uint8Array(stride);
37288
+ let curr = new Uint8Array(stride);
37289
+ for (let y = 0; y < height; y++) {
37290
+ const rowStart = y * (1 + stride);
37291
+ const filterType = inflated[rowStart];
37292
+ for (let x = 0; x < stride; x++) {
37293
+ const raw2 = inflated[rowStart + 1 + x];
37294
+ const a = x >= bpp ? curr[x - bpp] : 0;
37295
+ const b = prev[x];
37296
+ const c = x >= bpp ? prev[x - bpp] : 0;
37297
+ switch (filterType) {
37298
+ case 0:
37299
+ curr[x] = raw2;
37300
+ break;
37301
+ case 1:
37302
+ curr[x] = raw2 + a & 255;
37303
+ break;
37304
+ case 2:
37305
+ curr[x] = raw2 + b & 255;
37306
+ break;
37307
+ case 3:
37308
+ curr[x] = raw2 + (a + b >>> 1) & 255;
37309
+ break;
37310
+ case 4:
37311
+ curr[x] = raw2 + paeth(a, b, c) & 255;
37312
+ break;
37313
+ default:
37314
+ return null;
37315
+ }
37316
+ }
37317
+ hash.update(curr);
37318
+ const swap = prev;
37319
+ prev = curr;
37320
+ curr = swap;
37321
+ }
37322
+ return hash.digest("hex");
37323
+ }
37324
+ function randomTag2() {
37325
+ return randomInt2(36 ** 3).toString(36).padStart(3, "0");
37326
+ }
37327
+ function createScreenshotMemory(now = Date.now, tag = randomTag2()) {
37328
+ const lastSent = /* @__PURE__ */ new Map();
37329
+ let count = 0;
37330
+ const record2 = (udid, digest, toolName) => {
37331
+ const id = `${tag}-${++count}`;
37332
+ lastSent.set(udid, {
37333
+ id,
37334
+ digest,
37335
+ tool: normalizeToolName(toolName),
37336
+ sentAt: now(),
37337
+ notes: 0
37338
+ });
37339
+ return id;
37340
+ };
37341
+ return {
37342
+ sent(udid, png, toolName) {
37343
+ return record2(udid, fingerprintPng(png), toolName);
37344
+ },
37345
+ afterAction(udid, png, toolName) {
37346
+ const digest = fingerprintPng(png);
37347
+ const last = lastSent.get(udid);
37348
+ const identical = last !== void 0 && last.digest === digest;
37349
+ if (last !== void 0 && identical && last.notes < MAX_UNCHANGED_SCREENSHOTS_IN_A_ROW && now() - last.sentAt <= UNCHANGED_SCREENSHOT_MAX_AGE_MS) {
37350
+ last.notes += 1;
37351
+ return {
37352
+ noteText: unchangedScreenshotNote(last.id, last.tool),
37353
+ identical: true,
37354
+ note: true
37355
+ };
37356
+ }
37357
+ const id = record2(udid, digest, toolName);
37358
+ return { id, identical, note: false };
37359
+ },
37360
+ forget(udid) {
37361
+ lastSent.delete(udid);
37362
+ }
37363
+ };
37364
+ }
37365
+
37185
37366
  // ../argent-mcp/src/keyword-facts.ts
37186
37367
  var SHOWS_KEYWORDS = [
37187
37368
  /^claude-code\b/,
@@ -37636,7 +37817,7 @@ function debuggerLogRegistryText(result) {
37636
37817
  }
37637
37818
 
37638
37819
  // ../argent-mcp/src/instructions.ts
37639
- var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Use the platform the user named; otherwise prefer a device list-devices shows already running, and do not default to iOS. In a single-platform project, boot that platform. Prefer these tools over raw xcrun or adb commands, which are a fallback. Prefer launch-app or open-url over tapping home-screen icons. If the task may need a saved e2e test, load the argent-create-e2e skill (argent-qa-e2e for acceptance tests) before the first launch or in-app action: recording is not retroactive. Load the matching argent-* skill before React Native build or debug work, profiling, a physical phone, a Mac app or a TV. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. When the tree matches or differs slightly from an earlier tree, the result names that earlier tree by its tree id (unchanged note or `-` gone / `+` new lines) in place of repeating it. If a tap fails twice, stop retrying and call a discovery tool again. Use await-ui-element to wait for the UI instead of polling with screenshots. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup. The argent CLI manages the toolkit: argent --help lists its commands.";
37820
+ var SERVER_INSTRUCTIONS = "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Use the platform the user named; otherwise prefer a device list-devices shows already running, and do not default to iOS. In a single-platform project, boot that platform. Prefer these tools over raw xcrun or adb commands, which are a fallback. Prefer launch-app or open-url over tapping home-screen icons. If the task may need a saved e2e test, load the argent-create-e2e skill (argent-qa-e2e for acceptance tests) before the first launch or in-app action: recording is not retroactive. Load the matching argent-* skill before React Native build or debug work, profiling, a physical phone, a Mac app or a TV. Interaction tools return the screen after the action: a screenshot plus the accessibility element tree with normalized tap frames. Take coordinates from that tree; call describe only when no fresh tree is available \u2014 never guess coordinates from pixels. When the screenshot or tree matches (or the tree differs slightly from) an earlier result, it names that earlier result by its screenshot or tree id (unchanged note or `-` gone / `+` new lines) in place of repeating it. If a tap fails twice, stop retrying and call a discovery tool again. Use await-ui-element to wait for the UI instead of polling with screenshots. Do not stop simulator servers when a task finishes: the next task reuses them. Call stop-all-simulator-servers when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, always with devices: [...] naming the devices this session used. Never stop a Metro the user started unless they ask. One tool-server is shared by every agent using this argent install, so an unscoped call tears down their devices too \u2014 reserve it for a deliberate machine-wide cleanup. The argent CLI manages the toolkit: argent --help lists its commands.";
37640
37821
 
37641
37822
  // ../argent-mcp/src/installed-version.ts
37642
37823
  import * as fs12 from "node:fs";
@@ -37767,6 +37948,13 @@ var import_semver = __toESM(require_semver2(), 1);
37767
37948
 
37768
37949
  // ../argent-mcp/src/release-highlights.ts
37769
37950
  var RELEASE_HIGHLIGHTS = {
37951
+ "0.35.0": [
37952
+ "UI sessions use less agent context: Argent skips unchanged automatic screenshots and sends just the changed lines for small element tree updates.",
37953
+ "Capture native network requests from iOS and Mac apps and inspect their headers and bodies.",
37954
+ "Run a directory of E2E tests as a suite with `suite.config.yaml`.",
37955
+ "Record the screen of a Mac app or a cabled iPhone.",
37956
+ "`argent doctor` checks your local Argent setup."
37957
+ ],
37770
37958
  "0.34.0": [
37771
37959
  "Profile Mac apps with the native profiler, and react-native-macos apps with the React profiler.",
37772
37960
  "e2e script steps run TypeScript (.mts, .ts) and .js files.",
@@ -37831,6 +38019,7 @@ async function startMcpServer(options) {
37831
38019
  const whatsNewOn = whatsNewEnabled();
37832
38020
  const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
37833
38021
  const trees = createTreeMemory();
38022
+ const screenshots = createScreenshotMemory();
37834
38023
  let TOOLS_URL;
37835
38024
  let AUTH_TOKEN;
37836
38025
  const resolved = await getResolvedToolsUrl();
@@ -37916,7 +38105,8 @@ async function startMcpServer(options) {
37916
38105
  return false;
37917
38106
  }
37918
38107
  }
37919
- async function captureScreenshotBlocks(udid, signal) {
38108
+ async function captureScreenshotBlocks(udid, toolName, signal) {
38109
+ const t1 = Date.now();
37920
38110
  try {
37921
38111
  const { result } = await callTool("screenshot", { udid }, { signal });
37922
38112
  const blocks = await toMcpContent(result, "image", {
@@ -37925,8 +38115,33 @@ async function startMcpServer(options) {
37925
38115
  deviceId: udid,
37926
38116
  signal
37927
38117
  });
37928
- if (!blocks.some((b) => b.type === "image")) return [];
37929
- return [{ type: "text", text: "--- Screen after action ---" }, ...blocks];
38118
+ const img = blocks.find(
38119
+ (b) => b.type === "image"
38120
+ );
38121
+ if (!img) return [];
38122
+ const png = Buffer.from(img.data, "base64");
38123
+ const shown = screenshots.afterAction(udid, png, toolName);
38124
+ await spyLog({
38125
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
38126
+ event: "auto_screenshot",
38127
+ name: toolName,
38128
+ durationMs: Date.now() - t1,
38129
+ bytes: png.length,
38130
+ identical: shown.identical,
38131
+ note: shown.note
38132
+ });
38133
+ if (shown.note) {
38134
+ return [{ type: "text", text: `--- Screen after action ---
38135
+ ${shown.noteText}` }];
38136
+ }
38137
+ return [
38138
+ {
38139
+ type: "text",
38140
+ text: `--- Screen after action ---
38141
+ ${screenshotIdLine(shown.id)}`
38142
+ },
38143
+ ...blocks
38144
+ ];
37930
38145
  } catch {
37931
38146
  return [];
37932
38147
  }
@@ -38004,6 +38219,7 @@ ${shown.text}` }];
38004
38219
  const t0 = Date.now();
38005
38220
  const callSignal = SAVES_FILES_AFTER_CANCEL.has(canonicalToolId(params.name)) ? void 0 : signal;
38006
38221
  let treeUdid;
38222
+ let screenshotUdid;
38007
38223
  await spyLog({
38008
38224
  ts: (/* @__PURE__ */ new Date()).toISOString(),
38009
38225
  event: "tool_called",
@@ -38043,6 +38259,16 @@ ${shown.text}` }];
38043
38259
  content = await toMcpContent(result, outputHint, ctx, params.arguments);
38044
38260
  }
38045
38261
  const udid = getUdidFromArgs(params.arguments);
38262
+ if (udid && autoScreenshotOn && canonicalToolId(params.name) === "screenshot") {
38263
+ const img = content.find(
38264
+ (b) => b.type === "image"
38265
+ );
38266
+ if (img) {
38267
+ screenshotUdid = udid;
38268
+ const id = screenshots.sent(udid, Buffer.from(img.data, "base64"), "screenshot");
38269
+ content = [...content, { type: "text", text: screenshotIdLine(id) }];
38270
+ }
38271
+ }
38046
38272
  if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe") {
38047
38273
  const tree = describedTree(result);
38048
38274
  if (tree !== void 0) {
@@ -38068,9 +38294,10 @@ ${shown.text}` }];
38068
38294
  }
38069
38295
  } else if (udid && (wantScreenshot || wantTree)) {
38070
38296
  const screenSettled = await awaitScreenSettled(udid, params.name, signal);
38297
+ if (wantScreenshot) screenshotUdid = udid;
38071
38298
  if (wantTree) treeUdid = udid;
38072
38299
  const captured = await withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
38073
- const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, captureSignal) : Promise.resolve([]);
38300
+ const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, params.name, captureSignal) : Promise.resolve([]);
38074
38301
  if (!screenSettled) await screenshot;
38075
38302
  const tree = wantTree ? captureTreeBlocks(udid, params.name, captureSignal) : Promise.resolve([]);
38076
38303
  return [...await screenshot, ...await tree];
@@ -38082,9 +38309,11 @@ ${shown.text}` }];
38082
38309
  }
38083
38310
  content = [...content, ...whatsNewBlocks()];
38084
38311
  if (treeUdid !== void 0 && signal.aborted) trees.forget(treeUdid);
38085
- return { content };
38312
+ if (screenshotUdid !== void 0 && signal.aborted) screenshots.forget(screenshotUdid);
38313
+ return { content: joinTextOnlyContent(content) };
38086
38314
  } catch (err) {
38087
38315
  if (treeUdid !== void 0) trees.forget(treeUdid);
38316
+ if (screenshotUdid !== void 0) screenshots.forget(screenshotUdid);
38088
38317
  await spyLog({
38089
38318
  ts: (/* @__PURE__ */ new Date()).toISOString(),
38090
38319
  event: "tool_result",