@swmansion/argent 0.34.1-next.95 → 0.34.1-next.97
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/bin/argent-android-devtools-0.4.0.apk +0 -0
- package/bin/darwin/argent-macos-helper +0 -0
- package/bin/darwin/ax-service +0 -0
- package/bin/darwin/tvos-ax-service +0 -0
- package/bin/darwin/tvos-hid-daemon +0 -0
- package/bin/network-inspector/network-inspector.jar +0 -0
- package/bin/tcp/ax-service +0 -0
- package/dist/cli-cmds.mjs +1 -1
- package/dist/installer.mjs +1 -1
- package/dist/mcp-server.mjs +135 -2
- package/dist/tool-args.generated.d.ts +1 -1
- package/dist/tool-server.cjs +192 -112
- package/dylibs/libArgentAudio.dylib +0 -0
- package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/libKeyboardPatch.dylib +0 -0
- package/dylibs/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
- package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
- package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
- package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
- package/package.json +2 -2
|
Binary file
|
|
Binary file
|
package/bin/darwin/ax-service
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/tcp/ax-service
CHANGED
|
Binary file
|
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.
|
|
38578
|
+
return "0.34.1-next.97";
|
|
38579
38579
|
}
|
|
38580
38580
|
return "0.0.0";
|
|
38581
38581
|
}
|
package/dist/installer.mjs
CHANGED
|
@@ -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.
|
|
17001
|
+
return "0.34.1-next.97";
|
|
17002
17002
|
}
|
|
17003
17003
|
return "0.0.0";
|
|
17004
17004
|
}
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -36495,8 +36495,141 @@ async function toMcpContent(result, outputHint, ctx, args) {
|
|
|
36495
36495
|
}
|
|
36496
36496
|
return [{ type: "text", text: stringifyForText(result) }];
|
|
36497
36497
|
}
|
|
36498
|
+
var LINE_BREAK_THRESHOLD = 160;
|
|
36499
|
+
function isJsonOmitted(value) {
|
|
36500
|
+
return value === void 0 || typeof value === "function" || typeof value === "symbol";
|
|
36501
|
+
}
|
|
36502
|
+
function isObjectWithoutToJson(value) {
|
|
36503
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.toJSON !== "function";
|
|
36504
|
+
}
|
|
36505
|
+
function isMultilineText(value) {
|
|
36506
|
+
return typeof value === "string" && value.includes("\n") && value.trim().length > 0;
|
|
36507
|
+
}
|
|
36508
|
+
function formatJsonNode(rootValue, rootTopLevel) {
|
|
36509
|
+
const stack = [];
|
|
36510
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
36511
|
+
const enter = (value, topLevel) => {
|
|
36512
|
+
if (isJsonOmitted(value)) return { text: "null", multiline: false };
|
|
36513
|
+
if (Array.isArray(value)) {
|
|
36514
|
+
if (value.length === 0) return { text: "[]", multiline: false };
|
|
36515
|
+
if (ancestors.has(value)) throw new TypeError("Converting circular structure to JSON");
|
|
36516
|
+
ancestors.add(value);
|
|
36517
|
+
stack.push({
|
|
36518
|
+
kind: "array",
|
|
36519
|
+
source: value,
|
|
36520
|
+
nextIndex: 0,
|
|
36521
|
+
items: [],
|
|
36522
|
+
hasStructured: false
|
|
36523
|
+
});
|
|
36524
|
+
return void 0;
|
|
36525
|
+
}
|
|
36526
|
+
if (isObjectWithoutToJson(value)) {
|
|
36527
|
+
const entries = Object.entries(value).filter(([, v]) => !isJsonOmitted(v));
|
|
36528
|
+
if (entries.length === 0) return { text: "{}", multiline: false };
|
|
36529
|
+
if (ancestors.has(value)) throw new TypeError("Converting circular structure to JSON");
|
|
36530
|
+
ancestors.add(value);
|
|
36531
|
+
stack.push({
|
|
36532
|
+
kind: "object",
|
|
36533
|
+
source: value,
|
|
36534
|
+
entries,
|
|
36535
|
+
nextIndex: 0,
|
|
36536
|
+
parts: [],
|
|
36537
|
+
topLevel,
|
|
36538
|
+
pendingKey: "",
|
|
36539
|
+
pendingStructured: false
|
|
36540
|
+
});
|
|
36541
|
+
return void 0;
|
|
36542
|
+
}
|
|
36543
|
+
return { text: JSON.stringify(value) ?? "null", multiline: false };
|
|
36544
|
+
};
|
|
36545
|
+
const rootLeaf = enter(rootValue, rootTopLevel);
|
|
36546
|
+
if (rootLeaf !== void 0) return rootLeaf;
|
|
36547
|
+
while (stack.length > 0) {
|
|
36548
|
+
const frame = stack[stack.length - 1];
|
|
36549
|
+
let completed;
|
|
36550
|
+
if (frame.kind === "array") {
|
|
36551
|
+
if (frame.nextIndex < frame.source.length) {
|
|
36552
|
+
const el = frame.source[frame.nextIndex++];
|
|
36553
|
+
if (el !== null && typeof el === "object") frame.hasStructured = true;
|
|
36554
|
+
const leaf = enter(el, false);
|
|
36555
|
+
if (leaf !== void 0) frame.items.push(leaf);
|
|
36556
|
+
continue;
|
|
36557
|
+
}
|
|
36558
|
+
stack.pop();
|
|
36559
|
+
ancestors.delete(frame.source);
|
|
36560
|
+
const anyMultiline = frame.items.some((item) => item.multiline);
|
|
36561
|
+
let flatLen = 2 + frame.items.length - 1;
|
|
36562
|
+
for (const item of frame.items) flatLen += item.text.length;
|
|
36563
|
+
completed = !anyMultiline && (flatLen <= LINE_BREAK_THRESHOLD || !frame.hasStructured) ? { text: `[${frame.items.map((i) => i.text).join(",")}]`, multiline: false } : { text: `[
|
|
36564
|
+
${frame.items.map((i) => i.text).join(",\n")}
|
|
36565
|
+
]`, multiline: true };
|
|
36566
|
+
} else {
|
|
36567
|
+
if (frame.nextIndex < frame.entries.length) {
|
|
36568
|
+
const [k, v] = frame.entries[frame.nextIndex++];
|
|
36569
|
+
const key = JSON.stringify(k);
|
|
36570
|
+
const structured = v !== null && typeof v === "object";
|
|
36571
|
+
const leaf = enter(v, false);
|
|
36572
|
+
if (leaf !== void 0) {
|
|
36573
|
+
frame.parts.push({ key, val: leaf, structured });
|
|
36574
|
+
} else {
|
|
36575
|
+
frame.pendingKey = key;
|
|
36576
|
+
frame.pendingStructured = structured;
|
|
36577
|
+
}
|
|
36578
|
+
continue;
|
|
36579
|
+
}
|
|
36580
|
+
stack.pop();
|
|
36581
|
+
ancestors.delete(frame.source);
|
|
36582
|
+
const anyMultiline = frame.parts.some((p) => p.val.multiline);
|
|
36583
|
+
const hasBigNested = frame.parts.some(
|
|
36584
|
+
(p) => p.val.multiline || p.structured && p.val.text.length > LINE_BREAK_THRESHOLD
|
|
36585
|
+
);
|
|
36586
|
+
let flatLen = 2 + frame.parts.length - 1;
|
|
36587
|
+
for (const p of frame.parts) flatLen += p.key.length + 1 + p.val.text.length;
|
|
36588
|
+
completed = !anyMultiline && (flatLen <= LINE_BREAK_THRESHOLD || !frame.topLevel && !hasBigNested) ? {
|
|
36589
|
+
text: `{${frame.parts.map((p) => `${p.key}:${p.val.text}`).join(",")}}`,
|
|
36590
|
+
multiline: false
|
|
36591
|
+
} : {
|
|
36592
|
+
text: `{
|
|
36593
|
+
${frame.parts.map((p) => `${p.key}:${p.val.text}`).join(",\n")}
|
|
36594
|
+
}`,
|
|
36595
|
+
multiline: true
|
|
36596
|
+
};
|
|
36597
|
+
}
|
|
36598
|
+
const parent = stack[stack.length - 1];
|
|
36599
|
+
if (!parent) return completed;
|
|
36600
|
+
if (parent.kind === "array") {
|
|
36601
|
+
parent.items.push(completed);
|
|
36602
|
+
} else {
|
|
36603
|
+
parent.parts.push({
|
|
36604
|
+
key: parent.pendingKey,
|
|
36605
|
+
val: completed,
|
|
36606
|
+
structured: parent.pendingStructured
|
|
36607
|
+
});
|
|
36608
|
+
}
|
|
36609
|
+
}
|
|
36610
|
+
return { text: "null", multiline: false };
|
|
36611
|
+
}
|
|
36498
36612
|
function stringifyForText(value) {
|
|
36499
|
-
|
|
36613
|
+
if (typeof value === "string") {
|
|
36614
|
+
return value.length > 0 ? value : '""';
|
|
36615
|
+
}
|
|
36616
|
+
if (isObjectWithoutToJson(value)) {
|
|
36617
|
+
const entries = Object.entries(value).filter(([, v]) => !isJsonOmitted(v));
|
|
36618
|
+
const multiline = entries.filter(([, v]) => isMultilineText(v));
|
|
36619
|
+
if (multiline.length > 0) {
|
|
36620
|
+
const rest = Object.fromEntries(entries.filter(([, v]) => !isMultilineText(v)));
|
|
36621
|
+
const sections = [];
|
|
36622
|
+
if (Object.keys(rest).length > 0) {
|
|
36623
|
+
sections.push(formatJsonNode(rest, true).text);
|
|
36624
|
+
}
|
|
36625
|
+
for (const [k, v] of multiline) {
|
|
36626
|
+
sections.push(`${k}:
|
|
36627
|
+
${v}`);
|
|
36628
|
+
}
|
|
36629
|
+
return sections.join("\n\n");
|
|
36630
|
+
}
|
|
36631
|
+
}
|
|
36632
|
+
return formatJsonNode(value, true).text;
|
|
36500
36633
|
}
|
|
36501
36634
|
async function legacyImageContent(result, suppressImage, signal) {
|
|
36502
36635
|
if (result && typeof result === "object" && "url" in result) {
|
|
@@ -36515,7 +36648,7 @@ async function legacyImageContent(result, suppressImage, signal) {
|
|
|
36515
36648
|
}
|
|
36516
36649
|
];
|
|
36517
36650
|
}
|
|
36518
|
-
return [{ type: "text", text:
|
|
36651
|
+
return [{ type: "text", text: stringifyForText(result) }];
|
|
36519
36652
|
}
|
|
36520
36653
|
function isRecord3(value) {
|
|
36521
36654
|
return value !== null && typeof value === "object";
|
|
@@ -979,7 +979,7 @@ export interface ArgentToolArgs {
|
|
|
979
979
|
captureCurrent?: boolean;
|
|
980
980
|
/** Orientation override for live baseline/current captures. Rejected on HarmonyOS, which captures the display in its current orientation and has no override. Ignored on physical iPhones. */
|
|
981
981
|
rotation?: "Portrait" | "LandscapeLeft" | "LandscapeRight" | "PortraitUpsideDown";
|
|
982
|
-
/** Directory where diff artifacts should be written (default: a temp directory).
|
|
982
|
+
/** Directory where diff artifacts should be written (default: a temp directory). */
|
|
983
983
|
outputDir?: string;
|
|
984
984
|
};
|
|
985
985
|
"settings-permissions": {
|
package/dist/tool-server.cjs
CHANGED
|
@@ -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.
|
|
72951
|
+
return "0.34.1-next.97";
|
|
72952
72952
|
}
|
|
72953
72953
|
return "0.0.0";
|
|
72954
72954
|
}
|
|
@@ -162588,12 +162588,16 @@ function captureAbortSignal(env, budgetMs) {
|
|
|
162588
162588
|
const bound = AbortSignal.timeout(budgetMs);
|
|
162589
162589
|
return env.signal ? AbortSignal.any([env.signal, bound]) : bound;
|
|
162590
162590
|
}
|
|
162591
|
-
function comparePixels(a, b, maskTopFraction = 0) {
|
|
162591
|
+
function comparePixels(a, b, maskTopFraction = 0, maskBottomFraction = 0) {
|
|
162592
162592
|
if (a.width !== b.width || a.height !== b.height) return "moving";
|
|
162593
162593
|
const maskedRows = Math.min(a.height, Math.floor(a.height * maskTopFraction));
|
|
162594
|
-
const
|
|
162594
|
+
const maskedBottomRows = Math.min(
|
|
162595
|
+
a.height - maskedRows,
|
|
162596
|
+
Math.floor(a.height * maskBottomFraction)
|
|
162597
|
+
);
|
|
162598
|
+
const total = a.width * (a.height - maskedRows - maskedBottomRows);
|
|
162595
162599
|
if (total <= 0) return "still";
|
|
162596
|
-
const limit = Math.min(a.data.length, b.data.length);
|
|
162600
|
+
const limit = Math.min(a.data.length, b.data.length, (a.height - maskedBottomRows) * a.width * 4);
|
|
162597
162601
|
let changed = 0;
|
|
162598
162602
|
for (let o = maskedRows * a.width * 4; o + 2 < limit; o += 4) {
|
|
162599
162603
|
const dr = a.data[o] - b.data[o];
|
|
@@ -162608,6 +162612,40 @@ function comparePixels(a, b, maskTopFraction = 0) {
|
|
|
162608
162612
|
if (changed > motionThreshold) return "moving";
|
|
162609
162613
|
return changed >= LOCALIZED_MOTION_MIN_PIXELS ? "localized" : "still";
|
|
162610
162614
|
}
|
|
162615
|
+
var SNAPSHOT_SETTLE_POLL_MS = 100;
|
|
162616
|
+
var SNAPSHOT_SETTLE_TIMEOUT_MS = 3e3;
|
|
162617
|
+
var SNAPSHOT_QUIET_AFTER_ACTION_MS = 300;
|
|
162618
|
+
var ANDROID_SNAPSHOT_QUIET_AFTER_ACTION_MS = 400;
|
|
162619
|
+
var SNAPSHOT_LOCALIZED_POLLS = 3;
|
|
162620
|
+
var HOME_INDICATOR_MASK_FRACTION = 0.02;
|
|
162621
|
+
async function settlesOnPixels(device) {
|
|
162622
|
+
if (device.platform === "android") return device.kind === "emulator";
|
|
162623
|
+
if (device.platform !== "ios" || isIosPhysicalDevice(device)) return false;
|
|
162624
|
+
return !await isTvOsSimulator(device.id);
|
|
162625
|
+
}
|
|
162626
|
+
async function settleOnPixels(env) {
|
|
162627
|
+
const deadline = Date.now() + SNAPSHOT_SETTLE_TIMEOUT_MS;
|
|
162628
|
+
const quietAfter = (env.lastActionAt ?? 0) + (env.device.platform === "android" ? ANDROID_SNAPSHOT_QUIET_AFTER_ACTION_MS : SNAPSHOT_QUIET_AFTER_ACTION_MS);
|
|
162629
|
+
const maskTopFraction = await statusBarMaskFraction(env.device);
|
|
162630
|
+
const maskBottomFraction = maskTopFraction > 0 ? HOME_INDICATOR_MASK_FRACTION : 0;
|
|
162631
|
+
let previous = await capturePixelsWithin(env, deadline, true);
|
|
162632
|
+
let compared = false;
|
|
162633
|
+
let localizedPolls = 0;
|
|
162634
|
+
while (Date.now() < deadline) {
|
|
162635
|
+
if (!await sleepOrAbort(SNAPSHOT_SETTLE_POLL_MS, env.signal)) return "aborted";
|
|
162636
|
+
const frame2 = await capturePixelsWithin(env, deadline, false);
|
|
162637
|
+
if (env.signal?.aborted) return "aborted";
|
|
162638
|
+
if (previous && frame2) {
|
|
162639
|
+
compared = true;
|
|
162640
|
+
const change = comparePixels(previous, frame2, maskTopFraction, maskBottomFraction);
|
|
162641
|
+
localizedPolls = change === "localized" ? localizedPolls + 1 : 0;
|
|
162642
|
+
const settled = change === "still" || localizedPolls >= SNAPSHOT_LOCALIZED_POLLS;
|
|
162643
|
+
if (settled && Date.now() >= quietAfter) return "still";
|
|
162644
|
+
}
|
|
162645
|
+
previous = frame2;
|
|
162646
|
+
}
|
|
162647
|
+
return compared ? "moving" : "blind";
|
|
162648
|
+
}
|
|
162611
162649
|
|
|
162612
162650
|
// ../tool-server/src/tools/flows/flow-actions.ts
|
|
162613
162651
|
var ABORTED_OUTCOME = {
|
|
@@ -167770,13 +167808,6 @@ var FUZZY_SAME_TEXT_CENTER_DISTANCE_PX = 60;
|
|
|
167770
167808
|
var MAX_TEXT_CHANGES = 10;
|
|
167771
167809
|
var DEFAULT_TEXT_CHANGE_MIN_CONFIDENCE = 0.7;
|
|
167772
167810
|
async function analyzeScreenshotTextChanges(options) {
|
|
167773
|
-
if (options.hasPixelDiff === false) {
|
|
167774
|
-
return {
|
|
167775
|
-
status: "skipped",
|
|
167776
|
-
provider: "ocr",
|
|
167777
|
-
changes: []
|
|
167778
|
-
};
|
|
167779
|
-
}
|
|
167780
167811
|
const [baselineOcr, currentOcr] = await Promise.all([
|
|
167781
167812
|
extractOcrTextBlocks(options.baselinePath),
|
|
167782
167813
|
extractOcrTextBlocks(options.currentPath)
|
|
@@ -168445,86 +168476,112 @@ var HORIZONTAL_TEXT_MERGE_HEIGHT_MULTIPLIER = 3;
|
|
|
168445
168476
|
var HORIZONTAL_TEXT_MERGE_MIN_GAP = 32;
|
|
168446
168477
|
var HORIZONTAL_TEXT_MERGE_MAX_GAP = 120;
|
|
168447
168478
|
var UNIFORM_BRIGHTNESS_DELTA_TOLERANCE = 4;
|
|
168448
|
-
|
|
168449
|
-
|
|
168450
|
-
|
|
168451
|
-
|
|
168452
|
-
|
|
168479
|
+
var DIFF_PNG_ENCODING = { filterType: 1, deflateLevel: 3 };
|
|
168480
|
+
var PNG_SIGNATURE2 = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
168481
|
+
var PNG_IHDR_CHUNK_LENGTH = 25;
|
|
168482
|
+
var PNG_IEND_CHUNK = Buffer.from([0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]);
|
|
168483
|
+
async function compareScreenshots(options) {
|
|
168484
|
+
const [baselineBytes, currentBytes] = await Promise.all([
|
|
168485
|
+
readPngFile(options.baselinePath),
|
|
168486
|
+
readPngFile(options.currentPath)
|
|
168453
168487
|
]);
|
|
168488
|
+
const identicalSize = baselineBytes.equals(currentBytes) ? completePngSize(baselineBytes) : void 0;
|
|
168489
|
+
if (identicalSize) {
|
|
168490
|
+
return {
|
|
168491
|
+
totalPixels: identicalSize.width * identicalSize.height,
|
|
168492
|
+
differentPixels: 0,
|
|
168493
|
+
mismatchPercentage: 0,
|
|
168494
|
+
imageSize: identicalSize
|
|
168495
|
+
};
|
|
168496
|
+
}
|
|
168497
|
+
const baseline = decodePng(baselineBytes, options.baselinePath);
|
|
168498
|
+
const current = decodePng(currentBytes, options.currentPath);
|
|
168454
168499
|
if (baseline.width !== current.width || baseline.height !== current.height) {
|
|
168455
|
-
return
|
|
168500
|
+
return {
|
|
168501
|
+
totalPixels: baseline.width * baseline.height,
|
|
168502
|
+
differentPixels: 0,
|
|
168503
|
+
mismatchPercentage: 0,
|
|
168504
|
+
dimensionMismatch: {
|
|
168505
|
+
expected: { width: baseline.width, height: baseline.height },
|
|
168506
|
+
actual: { width: current.width, height: current.height }
|
|
168507
|
+
}
|
|
168508
|
+
};
|
|
168456
168509
|
}
|
|
168510
|
+
const ignoreTopNormalizedY = (options.topMask ?? "status-bar") === "none" ? 0 : DEFAULT_IGNORE_TOP_NORMALIZED_Y;
|
|
168457
168511
|
const totalPixels = baseline.width * baseline.height;
|
|
168458
168512
|
const pixelDiff = markChangedPixels({
|
|
168459
168513
|
baseline,
|
|
168460
168514
|
current,
|
|
168461
|
-
thresholdSquared:
|
|
168462
|
-
ignoreTopNormalizedY
|
|
168463
|
-
});
|
|
168464
|
-
const regions = getChangedRegions({
|
|
168465
|
-
mask: pixelDiff.mask,
|
|
168466
|
-
baseline,
|
|
168467
|
-
current,
|
|
168468
|
-
joinGapPixels: settings.joinGapPixels
|
|
168515
|
+
thresholdSquared: DEFAULT_THRESHOLD * DEFAULT_THRESHOLD * MAX_RGB_DISTANCE_SQUARED2,
|
|
168516
|
+
ignoreTopNormalizedY
|
|
168469
168517
|
});
|
|
168518
|
+
return {
|
|
168519
|
+
totalPixels,
|
|
168520
|
+
differentPixels: pixelDiff.differentPixels,
|
|
168521
|
+
mismatchPercentage: totalPixels === 0 ? 0 : pixelDiff.differentPixels / totalPixels * 100,
|
|
168522
|
+
imageSize: { width: baseline.width, height: baseline.height },
|
|
168523
|
+
pixels: { baseline, current, mask: pixelDiff.mask, ignoreTopNormalizedY }
|
|
168524
|
+
};
|
|
168525
|
+
}
|
|
168526
|
+
async function writeContextDiff(comparison, destination) {
|
|
168527
|
+
if (!comparison.pixels || comparison.differentPixels === 0) return false;
|
|
168528
|
+
const diffImage = buildAnnotatedDiff(comparison.pixels, changedRegionsOf(comparison.pixels));
|
|
168529
|
+
await writePngFile(destination, downscalePng(diffImage, DEFAULT_CONTEXT_DIFF_SCALE));
|
|
168530
|
+
return true;
|
|
168531
|
+
}
|
|
168532
|
+
async function diffPngFiles(options) {
|
|
168533
|
+
const { pixels, ...comparison } = await compareScreenshots(options);
|
|
168534
|
+
if (!pixels || comparison.differentPixels === 0) {
|
|
168535
|
+
return summarizeResult({
|
|
168536
|
+
...comparison,
|
|
168537
|
+
regions: [],
|
|
168538
|
+
textAnalysis: { status: "skipped", provider: "ocr", changes: [] }
|
|
168539
|
+
});
|
|
168540
|
+
}
|
|
168541
|
+
const regions = changedRegionsOf(pixels);
|
|
168470
168542
|
const artifactPaths = resolveDiffArtifactPaths(options);
|
|
168471
|
-
|
|
168472
|
-
|
|
168473
|
-
|
|
168474
|
-
|
|
168475
|
-
|
|
168476
|
-
|
|
168477
|
-
contextDiffScale: settings.contextDiffScale
|
|
168478
|
-
});
|
|
168479
|
-
const mismatchPercentage = totalPixels === 0 ? 0 : pixelDiff.differentPixels / totalPixels * 100;
|
|
168543
|
+
const diffImage = buildAnnotatedDiff(pixels, regions);
|
|
168544
|
+
await writePngFile(artifactPaths.diffPath, diffImage);
|
|
168545
|
+
await writePngFile(
|
|
168546
|
+
artifactPaths.contextDiffPath,
|
|
168547
|
+
downscalePng(diffImage, DEFAULT_CONTEXT_DIFF_SCALE)
|
|
168548
|
+
);
|
|
168480
168549
|
const textAnalysis = await analyzeScreenshotTextChangesSafely({
|
|
168481
168550
|
baselinePath: options.baselinePath,
|
|
168482
168551
|
currentPath: options.currentPath,
|
|
168483
|
-
|
|
168484
|
-
|
|
168485
|
-
|
|
168486
|
-
ignoreTopPixels: ignoredTopRowsFor(baseline.height, settings.ignoreTopNormalizedY),
|
|
168552
|
+
baselineImage: pixels.baseline,
|
|
168553
|
+
currentImage: pixels.current,
|
|
168554
|
+
ignoreTopPixels: ignoredTopRowsFor(pixels.baseline.height, pixels.ignoreTopNormalizedY),
|
|
168487
168555
|
textChangeMinConfidence: DEFAULT_TEXT_CHANGE_MIN_CONFIDENCE
|
|
168488
168556
|
});
|
|
168489
168557
|
return summarizeResult({
|
|
168490
|
-
|
|
168491
|
-
differentPixels: pixelDiff.differentPixels,
|
|
168492
|
-
mismatchPercentage,
|
|
168493
|
-
imageSize: { width: baseline.width, height: baseline.height },
|
|
168558
|
+
...comparison,
|
|
168494
168559
|
diffPath: artifactPaths.diffPath,
|
|
168495
168560
|
contextDiffPath: artifactPaths.contextDiffPath,
|
|
168496
168561
|
regions,
|
|
168497
168562
|
textAnalysis
|
|
168498
168563
|
});
|
|
168499
168564
|
}
|
|
168500
|
-
function
|
|
168501
|
-
|
|
168502
|
-
|
|
168503
|
-
|
|
168504
|
-
|
|
168505
|
-
|
|
168506
|
-
|
|
168565
|
+
function completePngSize(bytes) {
|
|
168566
|
+
const complete = bytes.length >= PNG_SIGNATURE2.length + PNG_IHDR_CHUNK_LENGTH + PNG_IEND_CHUNK.length && bytes.subarray(0, PNG_SIGNATURE2.length).equals(PNG_SIGNATURE2) && bytes.toString("latin1", 12, 16) === "IHDR" && bytes.subarray(bytes.length - PNG_IEND_CHUNK.length).equals(PNG_IEND_CHUNK);
|
|
168567
|
+
return complete ? { width: bytes.readUInt32BE(16), height: bytes.readUInt32BE(20) } : void 0;
|
|
168568
|
+
}
|
|
168569
|
+
function changedRegionsOf(pixels) {
|
|
168570
|
+
return getChangedRegions({
|
|
168571
|
+
mask: pixels.mask,
|
|
168572
|
+
baseline: pixels.baseline,
|
|
168573
|
+
current: pixels.current,
|
|
168574
|
+
joinGapPixels: DEFAULT_REGION_MERGE_DISTANCE
|
|
168575
|
+
});
|
|
168576
|
+
}
|
|
168577
|
+
function buildAnnotatedDiff(pixels, regions) {
|
|
168578
|
+
const diffImage = buildContextDiff(pixels);
|
|
168579
|
+
drawRegionRectangles(diffImage, regions);
|
|
168580
|
+
return diffImage;
|
|
168507
168581
|
}
|
|
168508
168582
|
function summarizeResult(result) {
|
|
168509
168583
|
return { ...result, summary: formatScreenshotDiffSummary(result) };
|
|
168510
168584
|
}
|
|
168511
|
-
function buildDimensionMismatchResult(params) {
|
|
168512
|
-
return {
|
|
168513
|
-
totalPixels: params.baseline.width * params.baseline.height,
|
|
168514
|
-
differentPixels: 0,
|
|
168515
|
-
mismatchPercentage: 0,
|
|
168516
|
-
dimensionMismatch: {
|
|
168517
|
-
expected: { width: params.baseline.width, height: params.baseline.height },
|
|
168518
|
-
actual: { width: params.current.width, height: params.current.height }
|
|
168519
|
-
},
|
|
168520
|
-
regions: [],
|
|
168521
|
-
textAnalysis: {
|
|
168522
|
-
status: "skipped",
|
|
168523
|
-
provider: "ocr",
|
|
168524
|
-
changes: []
|
|
168525
|
-
}
|
|
168526
|
-
};
|
|
168527
|
-
}
|
|
168528
168585
|
function markChangedPixels(params) {
|
|
168529
168586
|
const totalPixels = params.baseline.width * params.baseline.height;
|
|
168530
168587
|
const baselineData = params.baseline.data;
|
|
@@ -168580,40 +168637,32 @@ function outputArtifactBaseName(filePath) {
|
|
|
168580
168637
|
const parsed2 = import_path8.default.parse(import_path8.default.basename(filePath));
|
|
168581
168638
|
return parsed2.name || parsed2.base;
|
|
168582
168639
|
}
|
|
168583
|
-
async function
|
|
168584
|
-
|
|
168585
|
-
|
|
168586
|
-
|
|
168587
|
-
|
|
168588
|
-
}
|
|
168589
|
-
drawRegionRectangles(diffImage, params.regions);
|
|
168590
|
-
await writePngFile(params.paths.diffPath, diffImage);
|
|
168591
|
-
await writePngFile(
|
|
168592
|
-
params.paths.contextDiffPath,
|
|
168593
|
-
downscalePng(diffImage, params.contextDiffScale)
|
|
168594
|
-
);
|
|
168640
|
+
async function readPngFile(filePath) {
|
|
168641
|
+
try {
|
|
168642
|
+
return await import_promises22.default.readFile(filePath);
|
|
168643
|
+
} catch (err) {
|
|
168644
|
+
throw unreadablePngError(filePath, err);
|
|
168645
|
+
}
|
|
168595
168646
|
}
|
|
168596
|
-
|
|
168647
|
+
function decodePng(buffer, filePath) {
|
|
168597
168648
|
try {
|
|
168598
|
-
const buffer = await import_promises22.default.readFile(filePath);
|
|
168599
168649
|
const png = import_pngjs6.PNG.sync.read(buffer);
|
|
168600
|
-
return {
|
|
168601
|
-
width: png.width,
|
|
168602
|
-
height: png.height,
|
|
168603
|
-
data: png.data
|
|
168604
|
-
};
|
|
168650
|
+
return { width: png.width, height: png.height, data: png.data };
|
|
168605
168651
|
} catch (err) {
|
|
168606
|
-
throw
|
|
168607
|
-
`Could not read PNG at ${filePath}: ${err instanceof Error ? err.message : String(err)}`,
|
|
168608
|
-
{
|
|
168609
|
-
error_code: FAILURE_CODES.SCREENSHOT_DIFF_INPUT_INVALID,
|
|
168610
|
-
failure_stage: "screenshot_diff_decode_failed",
|
|
168611
|
-
failure_area: "tool_server",
|
|
168612
|
-
error_kind: "validation"
|
|
168613
|
-
}
|
|
168614
|
-
);
|
|
168652
|
+
throw unreadablePngError(filePath, err);
|
|
168615
168653
|
}
|
|
168616
168654
|
}
|
|
168655
|
+
function unreadablePngError(filePath, err) {
|
|
168656
|
+
return new FailureError(
|
|
168657
|
+
`Could not read PNG at ${filePath}: ${err instanceof Error ? err.message : String(err)}`,
|
|
168658
|
+
{
|
|
168659
|
+
error_code: FAILURE_CODES.SCREENSHOT_DIFF_INPUT_INVALID,
|
|
168660
|
+
failure_stage: "screenshot_diff_decode_failed",
|
|
168661
|
+
failure_area: "tool_server",
|
|
168662
|
+
error_kind: "validation"
|
|
168663
|
+
}
|
|
168664
|
+
);
|
|
168665
|
+
}
|
|
168617
168666
|
async function analyzeScreenshotTextChangesSafely(options) {
|
|
168618
168667
|
try {
|
|
168619
168668
|
return await analyzeScreenshotTextChanges(options);
|
|
@@ -168651,7 +168700,7 @@ function luminanceFromOffset(data, offset) {
|
|
|
168651
168700
|
}
|
|
168652
168701
|
async function writePngFile(filePath, png) {
|
|
168653
168702
|
await import_promises22.default.mkdir(import_path8.default.dirname(filePath), { recursive: true });
|
|
168654
|
-
await import_promises22.default.writeFile(filePath, import_pngjs6.PNG.sync.write(png));
|
|
168703
|
+
await import_promises22.default.writeFile(filePath, import_pngjs6.PNG.sync.write(png, DIFF_PNG_ENCODING));
|
|
168655
168704
|
}
|
|
168656
168705
|
function downscalePng(source, scale) {
|
|
168657
168706
|
const resized = resizeDecodedPng(
|
|
@@ -168985,13 +169034,24 @@ async function cropPngFile(src, dest, frame2) {
|
|
|
168985
169034
|
await fs81.writeFile(dest, import_pngjs7.PNG.sync.write(out));
|
|
168986
169035
|
return { w, h };
|
|
168987
169036
|
}
|
|
168988
|
-
async function
|
|
168989
|
-
|
|
168990
|
-
|
|
168991
|
-
|
|
168992
|
-
|
|
168993
|
-
|
|
169037
|
+
async function warmSnapshotCapture(registry2, device) {
|
|
169038
|
+
try {
|
|
169039
|
+
if (!await settlesOnPixels(device)) return;
|
|
169040
|
+
const refs = isIosSimulator(device) ? [simulatorServerRef(device), axServiceRef(device)] : [simulatorServerRef(device)];
|
|
169041
|
+
await Promise.all(refs.map((ref) => registry2.resolveService(ref.urn, ref.options)));
|
|
169042
|
+
} catch {
|
|
169043
|
+
}
|
|
169044
|
+
}
|
|
169045
|
+
async function settleScreen(env) {
|
|
169046
|
+
if (await settlesOnPixels(env.device) && await settleOnPixels(env) !== "blind") return;
|
|
169047
|
+
if (!supportsFlowTree(env.device.platform)) return;
|
|
169048
|
+
try {
|
|
169049
|
+
await settleTree(env);
|
|
169050
|
+
} catch {
|
|
168994
169051
|
}
|
|
169052
|
+
}
|
|
169053
|
+
async function runSnapshot(env, opts) {
|
|
169054
|
+
if (opts.cropOn === void 0) await settleScreen(env);
|
|
168995
169055
|
if (env.signal?.aborted) {
|
|
168996
169056
|
return { status: "skip", reason: "run aborted during snapshot settle" };
|
|
168997
169057
|
}
|
|
@@ -169138,13 +169198,12 @@ async function runSnapshot(env, opts) {
|
|
|
169138
169198
|
};
|
|
169139
169199
|
}
|
|
169140
169200
|
const localBaseline = await hostBaseline(stored);
|
|
169141
|
-
|
|
169201
|
+
let outputDir;
|
|
169142
169202
|
let keepInOutputDir;
|
|
169143
169203
|
try {
|
|
169144
|
-
const result = await
|
|
169204
|
+
const result = await compareScreenshots({
|
|
169145
169205
|
baselinePath: localBaseline,
|
|
169146
169206
|
currentPath,
|
|
169147
|
-
outputDir,
|
|
169148
169207
|
// A crop compares EVERY pixel of the element's region, wherever it
|
|
169149
169208
|
// sits. Masking a crop's overlap with the screen's top status-bar band
|
|
169150
169209
|
// would degenerate into comparing nothing for an element inside the
|
|
@@ -169178,18 +169237,20 @@ async function runSnapshot(env, opts) {
|
|
|
169178
169237
|
baseline: await baselineArtifact(localBaseline),
|
|
169179
169238
|
current: await currentArtifact()
|
|
169180
169239
|
};
|
|
169181
|
-
|
|
169240
|
+
outputDir = await fs81.mkdtemp(path66.join(os27.tmpdir(), "argent-e2e-diff-"));
|
|
169241
|
+
const contextDiffPath = path66.join(outputDir, `${snapshotKey}-diff.png`);
|
|
169242
|
+
if (await writeContextDiff(result, contextDiffPath)) {
|
|
169182
169243
|
artifacts.diff = await store.register({
|
|
169183
|
-
hostPath:
|
|
169244
|
+
hostPath: contextDiffPath,
|
|
169184
169245
|
kind: "screenshot-diff-context",
|
|
169185
169246
|
mimeType: "image/png",
|
|
169186
169247
|
filename: `${snapshotKey}-diff.png`
|
|
169187
169248
|
});
|
|
169188
|
-
keepInOutputDir =
|
|
169249
|
+
keepInOutputDir = contextDiffPath;
|
|
169189
169250
|
}
|
|
169190
169251
|
return { ...captureWarned, status: "fail", reason: reason2, snapshotKey, artifacts };
|
|
169191
169252
|
} finally {
|
|
169192
|
-
await cleanupDiffDir(outputDir, keepInOutputDir);
|
|
169253
|
+
if (outputDir !== void 0) await cleanupDiffDir(outputDir, keepInOutputDir);
|
|
169193
169254
|
}
|
|
169194
169255
|
} finally {
|
|
169195
169256
|
if (cropDir !== void 0) {
|
|
@@ -170005,6 +170066,9 @@ Without a link, every step kind runs.`,
|
|
|
170005
170066
|
);
|
|
170006
170067
|
const device = resolved.device;
|
|
170007
170068
|
const statusBarPinned = device !== null && await pinStatusBar(device, signal);
|
|
170069
|
+
if (device !== null && !signal?.aborted && mayRunSnapshotStep(flow)) {
|
|
170070
|
+
void warmSnapshotCapture(registry2, device);
|
|
170071
|
+
}
|
|
170008
170072
|
if (device?.platform === "chromium" && !signal?.aborted) {
|
|
170009
170073
|
await frontChromiumPage(registry2, device);
|
|
170010
170074
|
}
|
|
@@ -170020,6 +170084,8 @@ Without a link, every step kind runs.`,
|
|
|
170020
170084
|
// its own, which is why that step spends this verdict rather than
|
|
170021
170085
|
// inheriting whatever the sub-run proved.
|
|
170022
170086
|
treeOutage: {},
|
|
170087
|
+
// The caller may have acted on the app right before this run.
|
|
170088
|
+
lastActionAt: Date.now(),
|
|
170023
170089
|
flowsDir,
|
|
170024
170090
|
viaUpload,
|
|
170025
170091
|
project,
|
|
@@ -170319,6 +170385,19 @@ function childScope(scope, overrides = {}) {
|
|
|
170319
170385
|
function depthOf(scope) {
|
|
170320
170386
|
return scope.depth ? { depth: scope.depth } : {};
|
|
170321
170387
|
}
|
|
170388
|
+
function mayRunSnapshotStep(flow) {
|
|
170389
|
+
return [...walkSteps(flow.steps)].some(
|
|
170390
|
+
({ step }) => step.kind === "snapshot" || step.kind === "run"
|
|
170391
|
+
);
|
|
170392
|
+
}
|
|
170393
|
+
var SCREEN_READING_STEPS = /* @__PURE__ */ new Set([
|
|
170394
|
+
"echo",
|
|
170395
|
+
"await",
|
|
170396
|
+
"assert",
|
|
170397
|
+
"idle",
|
|
170398
|
+
"wait",
|
|
170399
|
+
"snapshot"
|
|
170400
|
+
]);
|
|
170322
170401
|
async function execSteps(state3, steps, scope) {
|
|
170323
170402
|
for (const step of steps) {
|
|
170324
170403
|
const index = state3.reports.length;
|
|
@@ -170389,6 +170468,9 @@ async function execSteps(state3, steps, scope) {
|
|
|
170389
170468
|
scope.legacyPoints && step.kind === "tool" ? "native" : "upright",
|
|
170390
170469
|
() => execLeafStep(state3, step, index, scope)
|
|
170391
170470
|
);
|
|
170471
|
+
if (report.status !== "skip" && !SCREEN_READING_STEPS.has(step.kind)) {
|
|
170472
|
+
state3.lastActionAt = Date.now();
|
|
170473
|
+
}
|
|
170392
170474
|
if (report.status !== "skip") report.durationMs = Date.now() - startedAt;
|
|
170393
170475
|
if ((report.status === "fail" || report.status === "error") && !report.artifacts) {
|
|
170394
170476
|
const screen = await captureFailureScreen(state3);
|
|
@@ -171614,9 +171696,7 @@ var zodSchema79 = external_exports.object({
|
|
|
171614
171696
|
rotation: external_exports.enum(["Portrait", "LandscapeLeft", "LandscapeRight", "PortraitUpsideDown"]).optional().describe(
|
|
171615
171697
|
"Orientation override for live baseline/current captures. <flag:harmonyos>Rejected on HarmonyOS, which captures the display in its current orientation and has no override. </flag:harmonyos>Ignored on physical iPhones."
|
|
171616
171698
|
),
|
|
171617
|
-
outputDir: external_exports.string().min(1).optional().describe(
|
|
171618
|
-
"Directory where diff artifacts should be written (default: a temp directory). The diff images are returned in the result either way."
|
|
171619
|
-
)
|
|
171699
|
+
outputDir: external_exports.string().min(1).optional().describe("Directory where diff artifacts should be written (default: a temp directory).")
|
|
171620
171700
|
}).strict();
|
|
171621
171701
|
var screenshotDiffTool = {
|
|
171622
171702
|
id: "screenshot-diff",
|
|
@@ -171626,7 +171706,7 @@ Both images must have identical dimensions: save baselines with screenshot scale
|
|
|
171626
171706
|
Use when stable before/after screenshots exist and the expected result is pixel-visible: layout, spacing, color, typography, image/icon rendering, clipping, overflow, or text rendering.
|
|
171627
171707
|
Physical iPhones: live captures are device-wide and need no registered app.
|
|
171628
171708
|
<flag:macos-apps>Mac apps: a resized window fails as a dimension mismatch.
|
|
171629
|
-
</flag:macos-apps>Returns { summary, diffPath
|
|
171709
|
+
</flag:macos-apps>Returns { summary }, plus diffPath and contextDiffPath when pixels differ. The summary uses normalized [0,1] screen locations matching describe coordinates; diffPath is the full-size diff image and contextDiffPath is a downscaled image for MCP/agent display.
|
|
171630
171710
|
Ignores the fixed top status-bar band for both pixel and OCR text comparisons.
|
|
171631
171711
|
Fails if the input sources are invalid, PNG files cannot be read, outputDir cannot be written, or the simulator-server / emulator backend<flag:harmonyos>, or \`hdc\` on HarmonyOS,</flag:harmonyos> is not reachable.`,
|
|
171632
171712
|
zodSchema: zodSchema79,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.97",
|
|
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": "
|
|
101
|
+
"gitHead": "9c7ffba5a6037c9389f55a670dd55968e5c5cfde"
|
|
102
102
|
}
|