@swmansion/argent 0.34.1-next.98 → 0.35.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.
- 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/simulator-server +0 -0
- package/bin/darwin/tvos-ax-service +0 -0
- package/bin/darwin/tvos-hid-daemon +0 -0
- package/bin/linux/simulator-server +0 -0
- package/bin/linux-arm64/simulator-server +0 -0
- package/bin/network-inspector/network-inspector.jar +0 -0
- package/bin/tcp/ax-service +0 -0
- package/bin/win32/simulator-server.exe +0 -0
- package/dist/cli-cmds.mjs +187 -182
- package/dist/installer.mjs +353 -222
- package/dist/mcp-server.mjs +450 -11
- package/dist/tool-server.cjs +1430 -951
- 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/argent-audio-feeder +0 -0
- package/dylibs/tcp/libArgentAudio.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
- package/skills/argent-device-interact/SKILL.md +1 -1
- package/skills/argent-test-ui-flow/SKILL.md +1 -1
package/dist/mcp-server.mjs
CHANGED
|
@@ -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";
|
|
@@ -36931,12 +36935,176 @@ function getAutoScreenshotDelayMs(toolName) {
|
|
|
36931
36935
|
import { randomInt } from "node:crypto";
|
|
36932
36936
|
var MAX_UNCHANGED_IN_A_ROW = 3;
|
|
36933
36937
|
var UNCHANGED_MAX_AGE_MS = 5 * 6e4;
|
|
36938
|
+
var MAX_DIFF_RATIO = 0.6;
|
|
36939
|
+
var MAX_EDIT_DISTANCE = 256;
|
|
36940
|
+
var CONTEXT_LINES = 1;
|
|
36934
36941
|
function treeIdLine(id) {
|
|
36935
36942
|
return `Tree id: ${id}`;
|
|
36936
36943
|
}
|
|
36937
36944
|
function unchangedTreeNote(id, tool) {
|
|
36938
36945
|
return `Element tree matches \`${id}\` from an earlier \`${tool}\` result. Actions may have effects the tree omits. Call \`describe\` if you lack that tree.`;
|
|
36939
36946
|
}
|
|
36947
|
+
function treeDiffHeader(id, tool) {
|
|
36948
|
+
return `Diff against \`${id}\` (\`${tool}\`) \u2014 all other lines match \`${id}\` (- gone, + new; call \`describe\` if you lack \`${id}\`):`;
|
|
36949
|
+
}
|
|
36950
|
+
function countLines(lines) {
|
|
36951
|
+
const counts = /* @__PURE__ */ new Map();
|
|
36952
|
+
for (const line of lines) counts.set(line, (counts.get(line) ?? 0) + 1);
|
|
36953
|
+
return counts;
|
|
36954
|
+
}
|
|
36955
|
+
function isMultisetSubset(subset, superset) {
|
|
36956
|
+
if (subset.length === 0) return true;
|
|
36957
|
+
if (subset.length > superset.length) return false;
|
|
36958
|
+
const counts = countLines(superset);
|
|
36959
|
+
for (const line of subset) {
|
|
36960
|
+
const left = counts.get(line) ?? 0;
|
|
36961
|
+
if (left === 0) return false;
|
|
36962
|
+
counts.set(line, left - 1);
|
|
36963
|
+
}
|
|
36964
|
+
return true;
|
|
36965
|
+
}
|
|
36966
|
+
function treeMetaSignature(tree) {
|
|
36967
|
+
const meta2 = [];
|
|
36968
|
+
for (const line of tree.split("\n")) {
|
|
36969
|
+
if (line.startsWith("Hint: ") || line.startsWith("Source: ") || line.startsWith("Mode: ")) {
|
|
36970
|
+
meta2.push(line);
|
|
36971
|
+
} else if (line.trim() !== "") {
|
|
36972
|
+
break;
|
|
36973
|
+
}
|
|
36974
|
+
}
|
|
36975
|
+
return meta2.join("\n");
|
|
36976
|
+
}
|
|
36977
|
+
function myersDiff(a, b, maxD) {
|
|
36978
|
+
const n = a.length;
|
|
36979
|
+
const m = b.length;
|
|
36980
|
+
const limit = Math.min(maxD, n + m);
|
|
36981
|
+
const offset = limit;
|
|
36982
|
+
const v = new Int32Array(2 * limit + 1);
|
|
36983
|
+
const trace = [];
|
|
36984
|
+
for (let d = 0; d <= limit; d++) {
|
|
36985
|
+
trace.push(v.slice());
|
|
36986
|
+
for (let k = -d; k <= d; k += 2) {
|
|
36987
|
+
let x;
|
|
36988
|
+
if (k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1]) {
|
|
36989
|
+
x = v[offset + k + 1];
|
|
36990
|
+
} else {
|
|
36991
|
+
x = v[offset + k - 1] + 1;
|
|
36992
|
+
}
|
|
36993
|
+
let y = x - k;
|
|
36994
|
+
while (x < n && y < m && a[x] === b[y]) {
|
|
36995
|
+
x++;
|
|
36996
|
+
y++;
|
|
36997
|
+
}
|
|
36998
|
+
v[offset + k] = x;
|
|
36999
|
+
if (x === n && y === m) {
|
|
37000
|
+
const ops = [];
|
|
37001
|
+
let bx = n;
|
|
37002
|
+
let by = m;
|
|
37003
|
+
for (let step = d; step > 0; step--) {
|
|
37004
|
+
const prevV = trace[step];
|
|
37005
|
+
const bk = bx - by;
|
|
37006
|
+
const prevK = bk === -step || bk !== step && prevV[offset + bk - 1] < prevV[offset + bk + 1] ? bk + 1 : bk - 1;
|
|
37007
|
+
const prevX = prevV[offset + prevK];
|
|
37008
|
+
const prevY = prevX - prevK;
|
|
37009
|
+
while (bx > prevX && by > prevY) {
|
|
37010
|
+
bx--;
|
|
37011
|
+
by--;
|
|
37012
|
+
ops.push({ kind: "eq", line: a[bx] });
|
|
37013
|
+
}
|
|
37014
|
+
if (bx === prevX) {
|
|
37015
|
+
by--;
|
|
37016
|
+
ops.push({ kind: "ins", line: b[by] });
|
|
37017
|
+
} else {
|
|
37018
|
+
bx--;
|
|
37019
|
+
ops.push({ kind: "del", line: a[bx] });
|
|
37020
|
+
}
|
|
37021
|
+
}
|
|
37022
|
+
while (bx > 0 && by > 0) {
|
|
37023
|
+
bx--;
|
|
37024
|
+
by--;
|
|
37025
|
+
ops.push({ kind: "eq", line: a[bx] });
|
|
37026
|
+
}
|
|
37027
|
+
ops.reverse();
|
|
37028
|
+
return ops;
|
|
37029
|
+
}
|
|
37030
|
+
}
|
|
37031
|
+
}
|
|
37032
|
+
return null;
|
|
37033
|
+
}
|
|
37034
|
+
function diffLines(before, after) {
|
|
37035
|
+
let prefix = 0;
|
|
37036
|
+
const minLen = Math.min(before.length, after.length);
|
|
37037
|
+
while (prefix < minLen && before[prefix] === after[prefix]) prefix++;
|
|
37038
|
+
let suffix = 0;
|
|
37039
|
+
while (suffix < minLen - prefix && before[before.length - 1 - suffix] === after[after.length - 1 - suffix]) {
|
|
37040
|
+
suffix++;
|
|
37041
|
+
}
|
|
37042
|
+
const midBefore = before.slice(prefix, before.length - suffix);
|
|
37043
|
+
const midAfter = after.slice(prefix, after.length - suffix);
|
|
37044
|
+
const midOps = midBefore.length === 0 && midAfter.length === 0 ? [] : myersDiff(midBefore, midAfter, MAX_EDIT_DISTANCE);
|
|
37045
|
+
if (midOps === null) return null;
|
|
37046
|
+
const ops = [];
|
|
37047
|
+
for (let i = 0; i < prefix; i++) ops.push({ kind: "eq", line: before[i] });
|
|
37048
|
+
for (const op of midOps) ops.push(op);
|
|
37049
|
+
for (let i = before.length - suffix; i < before.length; i++) {
|
|
37050
|
+
ops.push({ kind: "eq", line: before[i] });
|
|
37051
|
+
}
|
|
37052
|
+
return ops;
|
|
37053
|
+
}
|
|
37054
|
+
function renderHunks(ops) {
|
|
37055
|
+
const visible = new Uint8Array(ops.length);
|
|
37056
|
+
for (let i = 0; i < ops.length; i++) {
|
|
37057
|
+
if (ops[i].kind === "eq") continue;
|
|
37058
|
+
const start = Math.max(0, i - CONTEXT_LINES);
|
|
37059
|
+
const end = Math.min(ops.length - 1, i + CONTEXT_LINES);
|
|
37060
|
+
for (let j = start; j <= end; j++) visible[j] = 1;
|
|
37061
|
+
}
|
|
37062
|
+
const out = [];
|
|
37063
|
+
let inHunk = false;
|
|
37064
|
+
let hadHunk = false;
|
|
37065
|
+
for (let i = 0; i < ops.length; i++) {
|
|
37066
|
+
if (!visible[i]) {
|
|
37067
|
+
inHunk = false;
|
|
37068
|
+
continue;
|
|
37069
|
+
}
|
|
37070
|
+
if (!inHunk) {
|
|
37071
|
+
if (hadHunk) out.push("...");
|
|
37072
|
+
inHunk = true;
|
|
37073
|
+
hadHunk = true;
|
|
37074
|
+
}
|
|
37075
|
+
const op = ops[i];
|
|
37076
|
+
if (op.kind === "del") out.push(`- ${op.line}`);
|
|
37077
|
+
else if (op.kind === "ins") out.push(`+ ${op.line}`);
|
|
37078
|
+
else out.push(` ${op.line}`);
|
|
37079
|
+
}
|
|
37080
|
+
return out;
|
|
37081
|
+
}
|
|
37082
|
+
function splitTreeLines(tree) {
|
|
37083
|
+
const trimmed = tree.endsWith("\n") ? tree.slice(0, -1) : tree;
|
|
37084
|
+
return trimmed.split("\n");
|
|
37085
|
+
}
|
|
37086
|
+
function computeTreeDiff(base, next, id, tool) {
|
|
37087
|
+
if (treeMetaSignature(base) !== treeMetaSignature(next)) return null;
|
|
37088
|
+
if (base === next) {
|
|
37089
|
+
return { mode: "unchanged", text: unchangedTreeNote(id, tool), removed: [], added: [] };
|
|
37090
|
+
}
|
|
37091
|
+
const before = splitTreeLines(base);
|
|
37092
|
+
const after = splitTreeLines(next);
|
|
37093
|
+
const ops = diffLines(before, after);
|
|
37094
|
+
if (ops === null) return null;
|
|
37095
|
+
const removed = [];
|
|
37096
|
+
const added = [];
|
|
37097
|
+
for (const op of ops) {
|
|
37098
|
+
if (op.kind === "del") removed.push(op.line);
|
|
37099
|
+
else if (op.kind === "ins") added.push(op.line);
|
|
37100
|
+
}
|
|
37101
|
+
if (removed.length === 0 && added.length === 0) {
|
|
37102
|
+
return { mode: "unchanged", text: unchangedTreeNote(id, tool), removed, added };
|
|
37103
|
+
}
|
|
37104
|
+
const text = [treeDiffHeader(id, tool), ...renderHunks(ops)].join("\n");
|
|
37105
|
+
if (text.length > Math.floor(next.length * MAX_DIFF_RATIO)) return null;
|
|
37106
|
+
return { mode: "diff", text, removed, added };
|
|
37107
|
+
}
|
|
36940
37108
|
function randomTag() {
|
|
36941
37109
|
return randomInt(36 ** 3).toString(36).padStart(3, "0");
|
|
36942
37110
|
}
|
|
@@ -36945,7 +37113,14 @@ function createTreeMemory(now = Date.now, tag = randomTag()) {
|
|
|
36945
37113
|
let count = 0;
|
|
36946
37114
|
const sent = (udid, tree, toolName) => {
|
|
36947
37115
|
const id = `${tag}-${++count}`;
|
|
36948
|
-
lastSent.set(udid, {
|
|
37116
|
+
lastSent.set(udid, {
|
|
37117
|
+
id,
|
|
37118
|
+
tree,
|
|
37119
|
+
tool: normalizeToolName(toolName),
|
|
37120
|
+
sentAt: now(),
|
|
37121
|
+
shortResults: 0,
|
|
37122
|
+
priorDiff: null
|
|
37123
|
+
});
|
|
36949
37124
|
return id;
|
|
36950
37125
|
};
|
|
36951
37126
|
return {
|
|
@@ -36953,13 +37128,50 @@ function createTreeMemory(now = Date.now, tag = randomTag()) {
|
|
|
36953
37128
|
afterAction(udid, tree, toolName) {
|
|
36954
37129
|
const last = lastSent.get(udid);
|
|
36955
37130
|
const identical = last !== void 0 && last.tree === tree;
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
37131
|
+
const canShorten = last !== void 0 && last.shortResults < MAX_UNCHANGED_IN_A_ROW && now() - last.sentAt <= UNCHANGED_MAX_AGE_MS;
|
|
37132
|
+
if (canShorten) {
|
|
37133
|
+
if (identical) {
|
|
37134
|
+
if (last.priorDiff === null) {
|
|
37135
|
+
last.shortResults += 1;
|
|
37136
|
+
return {
|
|
37137
|
+
text: unchangedTreeNote(last.id, last.tool),
|
|
37138
|
+
mode: "unchanged",
|
|
37139
|
+
identical: true,
|
|
37140
|
+
note: true
|
|
37141
|
+
};
|
|
37142
|
+
}
|
|
37143
|
+
} else {
|
|
37144
|
+
const diff = computeTreeDiff(last.tree, tree, last.id, last.tool);
|
|
37145
|
+
if (diff !== null) {
|
|
37146
|
+
if (diff.mode === "unchanged") {
|
|
37147
|
+
if (last.priorDiff === null) {
|
|
37148
|
+
last.shortResults += 1;
|
|
37149
|
+
return {
|
|
37150
|
+
text: diff.text,
|
|
37151
|
+
mode: "unchanged",
|
|
37152
|
+
identical: true,
|
|
37153
|
+
note: true
|
|
37154
|
+
};
|
|
37155
|
+
}
|
|
37156
|
+
} else {
|
|
37157
|
+
const monotonic = last.priorDiff === null || isMultisetSubset(last.priorDiff.removed, diff.removed) && isMultisetSubset(last.priorDiff.added, diff.added);
|
|
37158
|
+
if (monotonic) {
|
|
37159
|
+
last.shortResults += 1;
|
|
37160
|
+
last.priorDiff = { removed: diff.removed, added: diff.added };
|
|
37161
|
+
return {
|
|
37162
|
+
text: diff.text,
|
|
37163
|
+
mode: "diff",
|
|
37164
|
+
identical: false,
|
|
37165
|
+
note: false
|
|
37166
|
+
};
|
|
37167
|
+
}
|
|
37168
|
+
}
|
|
37169
|
+
}
|
|
37170
|
+
}
|
|
36959
37171
|
}
|
|
36960
37172
|
const id = sent(udid, tree, toolName);
|
|
36961
37173
|
return { text: `${treeIdLine(id)}
|
|
36962
|
-
${tree}`, identical, note: false };
|
|
37174
|
+
${tree}`, mode: "full", identical, note: false };
|
|
36963
37175
|
},
|
|
36964
37176
|
forget(udid) {
|
|
36965
37177
|
lastSent.delete(udid);
|
|
@@ -36974,6 +37186,183 @@ function describedTree(result) {
|
|
|
36974
37186
|
return `${hintLine}${description}`;
|
|
36975
37187
|
}
|
|
36976
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
|
+
|
|
36977
37366
|
// ../argent-mcp/src/keyword-facts.ts
|
|
36978
37367
|
var SHOWS_KEYWORDS = [
|
|
36979
37368
|
/^claude-code\b/,
|
|
@@ -37428,7 +37817,7 @@ function debuggerLogRegistryText(result) {
|
|
|
37428
37817
|
}
|
|
37429
37818
|
|
|
37430
37819
|
// ../argent-mcp/src/instructions.ts
|
|
37431
|
-
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.
|
|
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.";
|
|
37432
37821
|
|
|
37433
37822
|
// ../argent-mcp/src/installed-version.ts
|
|
37434
37823
|
import * as fs12 from "node:fs";
|
|
@@ -37559,6 +37948,13 @@ var import_semver = __toESM(require_semver2(), 1);
|
|
|
37559
37948
|
|
|
37560
37949
|
// ../argent-mcp/src/release-highlights.ts
|
|
37561
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
|
+
],
|
|
37562
37958
|
"0.34.0": [
|
|
37563
37959
|
"Profile Mac apps with the native profiler, and react-native-macos apps with the React profiler.",
|
|
37564
37960
|
"e2e script steps run TypeScript (.mts, .ts) and .js files.",
|
|
@@ -37623,6 +38019,7 @@ async function startMcpServer(options) {
|
|
|
37623
38019
|
const whatsNewOn = whatsNewEnabled();
|
|
37624
38020
|
const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
|
|
37625
38021
|
const trees = createTreeMemory();
|
|
38022
|
+
const screenshots = createScreenshotMemory();
|
|
37626
38023
|
let TOOLS_URL;
|
|
37627
38024
|
let AUTH_TOKEN;
|
|
37628
38025
|
const resolved = await getResolvedToolsUrl();
|
|
@@ -37708,7 +38105,8 @@ async function startMcpServer(options) {
|
|
|
37708
38105
|
return false;
|
|
37709
38106
|
}
|
|
37710
38107
|
}
|
|
37711
|
-
async function captureScreenshotBlocks(udid, signal) {
|
|
38108
|
+
async function captureScreenshotBlocks(udid, toolName, signal) {
|
|
38109
|
+
const t1 = Date.now();
|
|
37712
38110
|
try {
|
|
37713
38111
|
const { result } = await callTool("screenshot", { udid }, { signal });
|
|
37714
38112
|
const blocks = await toMcpContent(result, "image", {
|
|
@@ -37717,8 +38115,33 @@ async function startMcpServer(options) {
|
|
|
37717
38115
|
deviceId: udid,
|
|
37718
38116
|
signal
|
|
37719
38117
|
});
|
|
37720
|
-
|
|
37721
|
-
|
|
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
|
+
];
|
|
37722
38145
|
} catch {
|
|
37723
38146
|
return [];
|
|
37724
38147
|
}
|
|
@@ -37735,6 +38158,8 @@ async function startMcpServer(options) {
|
|
|
37735
38158
|
name: toolName,
|
|
37736
38159
|
durationMs: Date.now() - t1,
|
|
37737
38160
|
chars: tree?.length ?? 0,
|
|
38161
|
+
sentChars: shown?.text.length ?? 0,
|
|
38162
|
+
mode: shown?.mode,
|
|
37738
38163
|
// `identical` is the repeat rate; `note` is what the agent was spared.
|
|
37739
38164
|
identical: shown?.identical ?? false,
|
|
37740
38165
|
note: shown?.note ?? false
|
|
@@ -37794,6 +38219,7 @@ ${shown.text}` }];
|
|
|
37794
38219
|
const t0 = Date.now();
|
|
37795
38220
|
const callSignal = SAVES_FILES_AFTER_CANCEL.has(canonicalToolId(params.name)) ? void 0 : signal;
|
|
37796
38221
|
let treeUdid;
|
|
38222
|
+
let screenshotUdid;
|
|
37797
38223
|
await spyLog({
|
|
37798
38224
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
37799
38225
|
event: "tool_called",
|
|
@@ -37833,6 +38259,16 @@ ${shown.text}` }];
|
|
|
37833
38259
|
content = await toMcpContent(result, outputHint, ctx, params.arguments);
|
|
37834
38260
|
}
|
|
37835
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
|
+
}
|
|
37836
38272
|
if (udid && autoDescribeOn && canonicalToolId(params.name) === "describe") {
|
|
37837
38273
|
const tree = describedTree(result);
|
|
37838
38274
|
if (tree !== void 0) {
|
|
@@ -37858,9 +38294,10 @@ ${shown.text}` }];
|
|
|
37858
38294
|
}
|
|
37859
38295
|
} else if (udid && (wantScreenshot || wantTree)) {
|
|
37860
38296
|
const screenSettled = await awaitScreenSettled(udid, params.name, signal);
|
|
38297
|
+
if (wantScreenshot) screenshotUdid = udid;
|
|
37861
38298
|
if (wantTree) treeUdid = udid;
|
|
37862
38299
|
const captured = await withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
|
|
37863
|
-
const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, captureSignal) : Promise.resolve([]);
|
|
38300
|
+
const screenshot = wantScreenshot ? captureScreenshotBlocks(udid, params.name, captureSignal) : Promise.resolve([]);
|
|
37864
38301
|
if (!screenSettled) await screenshot;
|
|
37865
38302
|
const tree = wantTree ? captureTreeBlocks(udid, params.name, captureSignal) : Promise.resolve([]);
|
|
37866
38303
|
return [...await screenshot, ...await tree];
|
|
@@ -37872,9 +38309,11 @@ ${shown.text}` }];
|
|
|
37872
38309
|
}
|
|
37873
38310
|
content = [...content, ...whatsNewBlocks()];
|
|
37874
38311
|
if (treeUdid !== void 0 && signal.aborted) trees.forget(treeUdid);
|
|
37875
|
-
|
|
38312
|
+
if (screenshotUdid !== void 0 && signal.aborted) screenshots.forget(screenshotUdid);
|
|
38313
|
+
return { content: joinTextOnlyContent(content) };
|
|
37876
38314
|
} catch (err) {
|
|
37877
38315
|
if (treeUdid !== void 0) trees.forget(treeUdid);
|
|
38316
|
+
if (screenshotUdid !== void 0) screenshots.forget(screenshotUdid);
|
|
37878
38317
|
await spyLog({
|
|
37879
38318
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
37880
38319
|
event: "tool_result",
|