@swmansion/argent 0.35.1-next.84 → 0.35.1-next.85
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 +389 -42
- package/dist/client.js +8 -1
- package/dist/installer.mjs +3 -0
- package/dist/mcp-server.mjs +213 -186
- package/dist/tool-server.cjs +23 -3
- package/package.json +2 -2
package/dist/cli-cmds.mjs
CHANGED
|
@@ -34863,6 +34863,7 @@ function failedRun(result) {
|
|
|
34863
34863
|
function createToolsClient(options = {}) {
|
|
34864
34864
|
let cached3 = null;
|
|
34865
34865
|
let linkedNoticeShown = false;
|
|
34866
|
+
let cachedToolList;
|
|
34866
34867
|
const doFetch = options.fetchImpl ?? ((url2, init3) => fetch(url2, init3));
|
|
34867
34868
|
const diagnose = options.onDiagnostic ?? ((message) => void process.stderr.write(`${message}
|
|
34868
34869
|
`));
|
|
@@ -34895,13 +34896,16 @@ function createToolsClient(options = {}) {
|
|
|
34895
34896
|
async function fetchToolList(opts) {
|
|
34896
34897
|
opts?.signal?.throwIfAborted();
|
|
34897
34898
|
const { url: url2, token } = await baseUrl();
|
|
34899
|
+
if (cachedToolList?.url === url2) return cachedToolList.list;
|
|
34898
34900
|
const res = await doFetch(
|
|
34899
34901
|
`${url2}/tools`,
|
|
34900
34902
|
{ headers: { ...options.headers?.(), ...authHeaders2(token) }, signal: opts?.signal },
|
|
34901
34903
|
{ longRunning: false, carriesUpload: false }
|
|
34902
34904
|
);
|
|
34903
34905
|
if (!res.ok) throw new Error(`GET /tools failed: ${res.status} ${res.statusText}`);
|
|
34904
|
-
|
|
34906
|
+
const list = await res.json();
|
|
34907
|
+
if (options.cacheToolList) cachedToolList = { url: url2, list };
|
|
34908
|
+
return list;
|
|
34905
34909
|
}
|
|
34906
34910
|
async function fetchTools(opts) {
|
|
34907
34911
|
return (await fetchToolList(opts)).tools;
|
|
@@ -35390,6 +35394,191 @@ function getDeviceIdFromArgs(args) {
|
|
|
35390
35394
|
return void 0;
|
|
35391
35395
|
}
|
|
35392
35396
|
|
|
35397
|
+
// ../argent-tools-client/src/auto-capture.ts
|
|
35398
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
35399
|
+
var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
|
|
35400
|
+
"gesture-tap",
|
|
35401
|
+
"gesture-swipe",
|
|
35402
|
+
"gesture-scroll",
|
|
35403
|
+
"gesture-drag",
|
|
35404
|
+
"gesture-hover",
|
|
35405
|
+
"gesture-custom",
|
|
35406
|
+
"gesture-pinch",
|
|
35407
|
+
"gesture-rotate",
|
|
35408
|
+
"button",
|
|
35409
|
+
"keyboard",
|
|
35410
|
+
"paste",
|
|
35411
|
+
"rotate",
|
|
35412
|
+
"fold",
|
|
35413
|
+
"tv-remote",
|
|
35414
|
+
"launch-app",
|
|
35415
|
+
"restart-app",
|
|
35416
|
+
"open-url",
|
|
35417
|
+
"describe",
|
|
35418
|
+
"run-sequence",
|
|
35419
|
+
// A wait is almost always followed by a look at the screen it waited for.
|
|
35420
|
+
"await-ui-element",
|
|
35421
|
+
"file-panel",
|
|
35422
|
+
"menu-bar"
|
|
35423
|
+
]);
|
|
35424
|
+
var AUTO_SCREENSHOT_DELAY_MS_BY_TOOL = {
|
|
35425
|
+
"launch-app": 3e3,
|
|
35426
|
+
"restart-app": 3e3,
|
|
35427
|
+
"open-url": 2e3,
|
|
35428
|
+
"gesture-swipe": 1500,
|
|
35429
|
+
"gesture-scroll": 1500,
|
|
35430
|
+
"gesture-drag": 1500,
|
|
35431
|
+
"gesture-hover": 1500,
|
|
35432
|
+
"gesture-custom": 1500,
|
|
35433
|
+
"gesture-tap": 1500,
|
|
35434
|
+
"gesture-pinch": 1500,
|
|
35435
|
+
"gesture-rotate": 1500,
|
|
35436
|
+
// Only the settle after the last step; each step is an in-app action.
|
|
35437
|
+
"run-sequence": 3e3,
|
|
35438
|
+
"button": 1500,
|
|
35439
|
+
"tv-remote": 1500,
|
|
35440
|
+
"rotate": 1e3,
|
|
35441
|
+
// The fold tool already waits for the panel hand-over; the cap covers the
|
|
35442
|
+
// repaint after it.
|
|
35443
|
+
"fold": 1500,
|
|
35444
|
+
"keyboard": 300,
|
|
35445
|
+
"paste": 300,
|
|
35446
|
+
"describe": 100,
|
|
35447
|
+
// The wait returns on the first match, often mid-transition; the cap must
|
|
35448
|
+
// leave `await-screen-idle` room to see two identical reads.
|
|
35449
|
+
"await-ui-element": 1500
|
|
35450
|
+
};
|
|
35451
|
+
var DEFAULT_DELAY_MS = 1400;
|
|
35452
|
+
var LAUNCH_SETTLE_MS = 3e3;
|
|
35453
|
+
var CAPTURE_TIMEOUT_MS = 15e3;
|
|
35454
|
+
function autoScreenshotEnabled(options) {
|
|
35455
|
+
return !isFlagEnabled("disable-auto-screenshot", options);
|
|
35456
|
+
}
|
|
35457
|
+
var AUTO_DESCRIBE_TOOLS = /* @__PURE__ */ new Set([
|
|
35458
|
+
"gesture-tap",
|
|
35459
|
+
"gesture-swipe",
|
|
35460
|
+
"gesture-scroll",
|
|
35461
|
+
"gesture-drag",
|
|
35462
|
+
"gesture-hover",
|
|
35463
|
+
"gesture-custom",
|
|
35464
|
+
"gesture-pinch",
|
|
35465
|
+
"gesture-rotate",
|
|
35466
|
+
"button",
|
|
35467
|
+
"keyboard",
|
|
35468
|
+
"paste",
|
|
35469
|
+
"rotate",
|
|
35470
|
+
"fold",
|
|
35471
|
+
"tv-remote",
|
|
35472
|
+
"launch-app",
|
|
35473
|
+
"restart-app",
|
|
35474
|
+
"open-url",
|
|
35475
|
+
"run-sequence",
|
|
35476
|
+
"await-ui-element",
|
|
35477
|
+
"file-panel",
|
|
35478
|
+
"menu-bar"
|
|
35479
|
+
]);
|
|
35480
|
+
function autoDescribeEnabled(options) {
|
|
35481
|
+
return !isFlagEnabled("disable-auto-describe", options);
|
|
35482
|
+
}
|
|
35483
|
+
var PROFILING_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped while a profiler is recording on this device. Call screenshot or describe if you need to see the screen.";
|
|
35484
|
+
var SECRET_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped: the input contains a {{secret:\u2026}} placeholder, and a capture of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is captured normally, and shows the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret.";
|
|
35485
|
+
var AUTO_DESCRIBE_HEADER = "--- Elements after action (describe) ---";
|
|
35486
|
+
function shouldAutoDescribe(toolName, args) {
|
|
35487
|
+
const canonical = normalizeToolName(toolName);
|
|
35488
|
+
return AUTO_DESCRIBE_TOOLS.has(canonical) && !isListCall(canonical, args);
|
|
35489
|
+
}
|
|
35490
|
+
var SECRET_PLACEHOLDER_MARKER = "{{secret:";
|
|
35491
|
+
function containsSecretPlaceholder(args) {
|
|
35492
|
+
try {
|
|
35493
|
+
return JSON.stringify(args)?.includes(SECRET_PLACEHOLDER_MARKER) ?? false;
|
|
35494
|
+
} catch {
|
|
35495
|
+
return true;
|
|
35496
|
+
}
|
|
35497
|
+
}
|
|
35498
|
+
function getUdidFromArgs(args) {
|
|
35499
|
+
if (args && typeof args === "object" && "udid" in args && typeof args.udid === "string") {
|
|
35500
|
+
return args.udid;
|
|
35501
|
+
}
|
|
35502
|
+
return void 0;
|
|
35503
|
+
}
|
|
35504
|
+
function normalizeToolName(name) {
|
|
35505
|
+
const idx = name.lastIndexOf("__");
|
|
35506
|
+
return idx === -1 ? name : name.slice(idx + 2);
|
|
35507
|
+
}
|
|
35508
|
+
function shouldAutoScreenshot(toolName, args) {
|
|
35509
|
+
const canonical = normalizeToolName(toolName);
|
|
35510
|
+
return canonical !== "screenshot" && AUTO_SCREENSHOT_TOOLS.has(canonical) && !isListCall(canonical, args);
|
|
35511
|
+
}
|
|
35512
|
+
function isListCall(canonical, args) {
|
|
35513
|
+
return (canonical === "menu-bar" || canonical === "file-panel") && args?.action === "list";
|
|
35514
|
+
}
|
|
35515
|
+
function getAutoScreenshotDelayMs(toolName) {
|
|
35516
|
+
const canonical = normalizeToolName(toolName);
|
|
35517
|
+
const base = AUTO_SCREENSHOT_DELAY_MS_BY_TOOL[canonical] ?? DEFAULT_DELAY_MS;
|
|
35518
|
+
const envOverride = process.env.ARGENT_AUTO_SCREENSHOT_DELAY_MS;
|
|
35519
|
+
if (envOverride) {
|
|
35520
|
+
const envMs = parseInt(envOverride, 10);
|
|
35521
|
+
if (!Number.isNaN(envMs)) return Math.max(base, envMs);
|
|
35522
|
+
}
|
|
35523
|
+
return base;
|
|
35524
|
+
}
|
|
35525
|
+
function describedTree(result) {
|
|
35526
|
+
const { description, hint } = result ?? {};
|
|
35527
|
+
if (typeof description !== "string" || description.length === 0) return void 0;
|
|
35528
|
+
const hintLine = typeof hint === "string" && hint && !description.includes(hint) ? `Hint: ${hint}
|
|
35529
|
+
` : "";
|
|
35530
|
+
return `${hintLine}${description}`;
|
|
35531
|
+
}
|
|
35532
|
+
async function withDeadline(signal, ms, work) {
|
|
35533
|
+
const deadline = new AbortController();
|
|
35534
|
+
const timer = setTimeout(
|
|
35535
|
+
() => deadline.abort(new DOMException("The operation was aborted due to timeout", "TimeoutError")),
|
|
35536
|
+
ms
|
|
35537
|
+
);
|
|
35538
|
+
try {
|
|
35539
|
+
return await work(AbortSignal.any([signal, deadline.signal]));
|
|
35540
|
+
} finally {
|
|
35541
|
+
clearTimeout(timer);
|
|
35542
|
+
}
|
|
35543
|
+
}
|
|
35544
|
+
async function awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs) {
|
|
35545
|
+
const maxWaitMs = getAutoScreenshotDelayMs(toolName);
|
|
35546
|
+
if (maxWaitMs === 0) return { settled: true };
|
|
35547
|
+
const started = Date.now();
|
|
35548
|
+
const awaitIdle = async (timeoutMs) => await withDeadline(
|
|
35549
|
+
signal,
|
|
35550
|
+
timeoutMs + captureTimeoutMs,
|
|
35551
|
+
(s) => call("await-screen-idle", { udid, timeoutMs }, s)
|
|
35552
|
+
);
|
|
35553
|
+
try {
|
|
35554
|
+
let idle = await awaitIdle(maxWaitMs);
|
|
35555
|
+
if (idle?.launching === true && normalizeToolName(toolName) !== "describe") {
|
|
35556
|
+
idle = await awaitIdle(LAUNCH_SETTLE_MS);
|
|
35557
|
+
}
|
|
35558
|
+
return {
|
|
35559
|
+
settled: idle?.settled === true,
|
|
35560
|
+
readiness: { maxWaitMs, ...idle }
|
|
35561
|
+
};
|
|
35562
|
+
} catch {
|
|
35563
|
+
await sleep(Math.max(0, maxWaitMs - (Date.now() - started)), void 0, { signal }).catch(
|
|
35564
|
+
() => {
|
|
35565
|
+
}
|
|
35566
|
+
);
|
|
35567
|
+
return { settled: false };
|
|
35568
|
+
}
|
|
35569
|
+
}
|
|
35570
|
+
async function captureSettledScreen(options) {
|
|
35571
|
+
const { call, udid, toolName, signal, captureTimeoutMs } = options;
|
|
35572
|
+
const settledResult = await awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs);
|
|
35573
|
+
await options.onSettled?.(settledResult);
|
|
35574
|
+
return withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
|
|
35575
|
+
const screenshot = options.screenshot?.(captureSignal) ?? Promise.resolve([]);
|
|
35576
|
+
if (!settledResult.settled) await screenshot;
|
|
35577
|
+
const tree = options.tree?.(captureSignal) ?? Promise.resolve([]);
|
|
35578
|
+
return [...await screenshot, ...await tree];
|
|
35579
|
+
});
|
|
35580
|
+
}
|
|
35581
|
+
|
|
35393
35582
|
// ../../node_modules/@opentelemetry/api-logs/build/esm/types/LogRecord.js
|
|
35394
35583
|
var SeverityNumber;
|
|
35395
35584
|
(function(SeverityNumber2) {
|
|
@@ -41617,6 +41806,84 @@ ${renderSummary(report, { withDevice: true })}`);
|
|
|
41617
41806
|
return exitAfterFlush(report.ok ? 0 : 1);
|
|
41618
41807
|
}
|
|
41619
41808
|
|
|
41809
|
+
// ../argent-cli/src/run-capture.ts
|
|
41810
|
+
import { mkdir as mkdir5, writeFile as writeFile4 } from "node:fs/promises";
|
|
41811
|
+
import { join as join22 } from "node:path";
|
|
41812
|
+
var NO_CAPTURE = { lines: [] };
|
|
41813
|
+
var NEVER_ABORTED = new AbortController().signal;
|
|
41814
|
+
var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
41815
|
+
async function captureAfterAction(options) {
|
|
41816
|
+
const { client: client2, toolName, payload, profiling } = options;
|
|
41817
|
+
const udid = getUdidFromArgs(payload);
|
|
41818
|
+
const wantScreenshot = shouldAutoScreenshot(toolName, payload) && autoScreenshotEnabled(options.flagsPath);
|
|
41819
|
+
const wantTree = shouldAutoDescribe(toolName, payload) && autoDescribeEnabled(options.flagsPath);
|
|
41820
|
+
if (!udid || !(wantScreenshot || wantTree)) return NO_CAPTURE;
|
|
41821
|
+
if (containsSecretPlaceholder(payload)) return { lines: [], note: SECRET_CAPTURE_SKIPPED_NOTE };
|
|
41822
|
+
const call = async (name, args, s) => (await client2.callTool(name, args, { signal: s })).data;
|
|
41823
|
+
if (profiling) {
|
|
41824
|
+
if (toolName === "describe") return NO_CAPTURE;
|
|
41825
|
+
await awaitScreenSettled(call, udid, toolName, NEVER_ABORTED, CAPTURE_TIMEOUT_MS);
|
|
41826
|
+
return { lines: [], note: PROFILING_CAPTURE_SKIPPED_NOTE };
|
|
41827
|
+
}
|
|
41828
|
+
const captureScreenshot = async (s) => {
|
|
41829
|
+
const image = await takeScreenshot(client2, call, udid, s);
|
|
41830
|
+
return image ? [{ text: `Screen after action: ${image.localPath}`, image }] : [];
|
|
41831
|
+
};
|
|
41832
|
+
const captureTree = async (s) => {
|
|
41833
|
+
const tree = await readTree(call, udid, s);
|
|
41834
|
+
return tree === void 0 ? [] : [{ text: AUTO_DESCRIBE_HEADER }, { text: tree }];
|
|
41835
|
+
};
|
|
41836
|
+
const parts = await captureSettledScreen({
|
|
41837
|
+
call,
|
|
41838
|
+
udid,
|
|
41839
|
+
toolName,
|
|
41840
|
+
signal: NEVER_ABORTED,
|
|
41841
|
+
captureTimeoutMs: CAPTURE_TIMEOUT_MS,
|
|
41842
|
+
screenshot: wantScreenshot ? captureScreenshot : void 0,
|
|
41843
|
+
tree: wantTree ? captureTree : void 0
|
|
41844
|
+
});
|
|
41845
|
+
return {
|
|
41846
|
+
lines: parts.map((part) => part.text),
|
|
41847
|
+
screenshot: parts.find((part) => part.image)?.image
|
|
41848
|
+
};
|
|
41849
|
+
}
|
|
41850
|
+
async function takeScreenshot(client2, call, udid, signal) {
|
|
41851
|
+
try {
|
|
41852
|
+
const data = await call("screenshot", { udid }, signal);
|
|
41853
|
+
const { url: url2, token } = await client2.baseUrl();
|
|
41854
|
+
const { images } = await materializeArtifacts(data, {
|
|
41855
|
+
toolsUrl: url2,
|
|
41856
|
+
authToken: token,
|
|
41857
|
+
deviceId: udid,
|
|
41858
|
+
signal
|
|
41859
|
+
});
|
|
41860
|
+
return images[0] ?? await fetchLegacyScreenshot(data, udid, signal);
|
|
41861
|
+
} catch {
|
|
41862
|
+
return void 0;
|
|
41863
|
+
}
|
|
41864
|
+
}
|
|
41865
|
+
async function fetchLegacyScreenshot(data, udid, signal) {
|
|
41866
|
+
if (!data || typeof data !== "object") return void 0;
|
|
41867
|
+
const { url: url2 } = data;
|
|
41868
|
+
if (typeof url2 !== "string") return void 0;
|
|
41869
|
+
const res = await fetch(url2, { signal });
|
|
41870
|
+
if (!res.ok) return void 0;
|
|
41871
|
+
const png = Buffer.from(await res.arrayBuffer());
|
|
41872
|
+
if (!png.subarray(0, PNG_SIGNATURE.length).equals(PNG_SIGNATURE)) return void 0;
|
|
41873
|
+
const dir = artifactDir(udid);
|
|
41874
|
+
await mkdir5(dir, { recursive: true });
|
|
41875
|
+
const localPath = join22(dir, `screenshot-${Date.now()}.png`);
|
|
41876
|
+
await writeFile4(localPath, png);
|
|
41877
|
+
return { localPath, data: png, mimeType: "image/png" };
|
|
41878
|
+
}
|
|
41879
|
+
async function readTree(call, udid, signal) {
|
|
41880
|
+
try {
|
|
41881
|
+
return describedTree(await call("describe", { udid }, signal));
|
|
41882
|
+
} catch {
|
|
41883
|
+
return void 0;
|
|
41884
|
+
}
|
|
41885
|
+
}
|
|
41886
|
+
|
|
41620
41887
|
// ../argent-cli/src/run-device-env.ts
|
|
41621
41888
|
var DEVICE_ENV_VAR = "ARGENT_UDID";
|
|
41622
41889
|
var DEVICE_FIELDS = ["udid", "device_id"];
|
|
@@ -41706,8 +41973,10 @@ ${description}
|
|
|
41706
41973
|
console.log(" --args - Read the entire payload as JSON from stdin");
|
|
41707
41974
|
}
|
|
41708
41975
|
console.log(" --<field>-json <json> Pass a single field as JSON (objects/nested arrays)");
|
|
41709
|
-
console.log(" --json Print the raw JSON result");
|
|
41710
|
-
console.log(
|
|
41976
|
+
console.log(" --json Print only the raw JSON result");
|
|
41977
|
+
console.log(
|
|
41978
|
+
" --out <path> Save the image result, or the screen after an action, to <path>"
|
|
41979
|
+
);
|
|
41711
41980
|
console.log(" --help, -h Show this help");
|
|
41712
41981
|
const deviceField = requiredDeviceField(schema);
|
|
41713
41982
|
if (deviceField) console.log(`
|
|
@@ -41720,9 +41989,24 @@ async function fetchImageToFile(result, outPath) {
|
|
|
41720
41989
|
}
|
|
41721
41990
|
const res = await fetch(url2);
|
|
41722
41991
|
if (!res.ok) throw new Error(`Failed to download image: ${res.status} ${res.statusText}`);
|
|
41723
|
-
|
|
41992
|
+
writeImageFile(outPath, Buffer.from(await res.arrayBuffer()));
|
|
41993
|
+
}
|
|
41994
|
+
function drainStdout() {
|
|
41995
|
+
return new Promise((resolve26) => process.stdout.write("", () => resolve26()));
|
|
41996
|
+
}
|
|
41997
|
+
function onReaderClosed(exit) {
|
|
41998
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
41999
|
+
const otherHandlers = stream.listeners("error");
|
|
42000
|
+
stream.removeAllListeners("error");
|
|
42001
|
+
stream.on("error", (err) => {
|
|
42002
|
+
if (err.code === "EPIPE") void exit();
|
|
42003
|
+
else for (const handler of otherHandlers) handler.call(stream, err);
|
|
42004
|
+
});
|
|
42005
|
+
}
|
|
42006
|
+
}
|
|
42007
|
+
function writeImageFile(outPath, data) {
|
|
41724
42008
|
fs16.mkdirSync(path22.dirname(path22.resolve(outPath)), { recursive: true });
|
|
41725
|
-
fs16.writeFileSync(outPath,
|
|
42009
|
+
fs16.writeFileSync(outPath, data);
|
|
41726
42010
|
}
|
|
41727
42011
|
function renderResult(result, outputHint, images, json2) {
|
|
41728
42012
|
if (json2) return JSON.stringify(result, null, 2);
|
|
@@ -41752,7 +42036,8 @@ async function trackRunFailure(toolName, startedAt, signal) {
|
|
|
41752
42036
|
async function run(argv, options) {
|
|
41753
42037
|
init("cli");
|
|
41754
42038
|
const startedAt = performance.now();
|
|
41755
|
-
const
|
|
42039
|
+
const client2 = createToolsClient({ paths: options.paths, cacheToolList: true });
|
|
42040
|
+
const { fetchTool, callTool, baseUrl } = client2;
|
|
41756
42041
|
const [toolName, ...rest] = argv;
|
|
41757
42042
|
if (!toolName || toolName === "--help" || toolName === "-h") {
|
|
41758
42043
|
console.log(`Usage: argent run <tool> [flags]
|
|
@@ -41767,12 +42052,21 @@ Examples:
|
|
|
41767
42052
|
argent run run-sequence --udid <UDID> --steps-json '[{"tool":"button","args":{"button":"home"}}]'
|
|
41768
42053
|
argent run gesture-tap --args '{"udid":"<UDID>","x":0.5,"y":0.5}'
|
|
41769
42054
|
|
|
42055
|
+
After an interaction tool (gestures, key presses, app launches), argent run
|
|
42056
|
+
waits for the screen to settle, then prints a screenshot path and the element
|
|
42057
|
+
tree on stderr, so stdout holds only the result; after describe it adds only
|
|
42058
|
+
the screenshot. --out also saves that screenshot.
|
|
42059
|
+
\`argent enable disable-auto-screenshot\` and
|
|
42060
|
+
\`argent enable disable-auto-describe\` turn these off. --json prints only the
|
|
42061
|
+
result, without waiting.
|
|
42062
|
+
|
|
41770
42063
|
Set ARGENT_UDID to use that device when a tool needs --udid or --device_id
|
|
41771
42064
|
and the call does not pass one.
|
|
41772
42065
|
|
|
41773
|
-
Exits 1 when the tool fails
|
|
41774
|
-
|
|
41775
|
-
|
|
42066
|
+
Exits 1 when the tool fails, or when --out without --json gets no screen
|
|
42067
|
+
after an action. Also exits 1 when the result reports that the call did not
|
|
42068
|
+
do its job: an e2e test that does not pass, an await-ui-element or
|
|
42069
|
+
await-network-request wait with success=false, a run-sequence that a step
|
|
41776
42070
|
stopped, a debugger tool with no connection or an error, a native-devtools
|
|
41777
42071
|
precheck that stopped the tool, a native-profiler-analyze with status
|
|
41778
42072
|
analysis_failed, an e2e recording call that recorded nothing, or a baseline
|
|
@@ -41920,6 +42214,7 @@ settled=false or debugger-status's not_connected.
|
|
|
41920
42214
|
let result;
|
|
41921
42215
|
let note2;
|
|
41922
42216
|
let failure2;
|
|
42217
|
+
let profiling = false;
|
|
41923
42218
|
let images = [];
|
|
41924
42219
|
try {
|
|
41925
42220
|
const resp = await callTool(toolName, payload);
|
|
@@ -41933,6 +42228,7 @@ settled=false or debugger-status's not_connected.
|
|
|
41933
42228
|
images = materialized.images;
|
|
41934
42229
|
note2 = resp.note;
|
|
41935
42230
|
failure2 = resp.failure;
|
|
42231
|
+
profiling = resp.profiling === true;
|
|
41936
42232
|
} catch (err) {
|
|
41937
42233
|
const report = describeServerValidationFailure(err, payload, schema);
|
|
41938
42234
|
if (report) {
|
|
@@ -41947,39 +42243,90 @@ settled=false or debugger-status's not_connected.
|
|
|
41947
42243
|
});
|
|
41948
42244
|
process.exit(1);
|
|
41949
42245
|
}
|
|
41950
|
-
|
|
42246
|
+
const screenOut = json2 || meta3.outputHint === "image" ? void 0 : outPath;
|
|
42247
|
+
const wantsScreenOut = !!screenOut && shouldAutoScreenshot(toolName, payload);
|
|
42248
|
+
let screenOutWritten = false;
|
|
42249
|
+
let failureTracked;
|
|
42250
|
+
const trackFailureOnce = (signal) => failureTracked ??= trackRunFailure(toolName, startedAt, signal);
|
|
42251
|
+
const resultFailed = () => trackFailureOnce({
|
|
42252
|
+
error_code: FAILURE_CODES.CLI_RUN_TOOL_RESULT_FAILED,
|
|
42253
|
+
failure_stage: "cli_run_tool_result",
|
|
42254
|
+
failure_area: "cli",
|
|
42255
|
+
error_kind: "unknown"
|
|
42256
|
+
});
|
|
42257
|
+
const screenOutFailed = () => trackFailureOnce({
|
|
42258
|
+
error_code: FAILURE_CODES.CLI_RUN_SAVE_IMAGE_FAILED,
|
|
42259
|
+
failure_stage: "cli_run_save_image",
|
|
42260
|
+
failure_area: "cli",
|
|
42261
|
+
error_kind: "unknown"
|
|
42262
|
+
});
|
|
42263
|
+
let readerClosed = false;
|
|
42264
|
+
onReaderClosed(async () => {
|
|
42265
|
+
if (readerClosed) return;
|
|
42266
|
+
readerClosed = true;
|
|
42267
|
+
const outMissing = wantsScreenOut && !screenOutWritten;
|
|
42268
|
+
if (failure2) console.error(failure2);
|
|
42269
|
+
if (outMissing) console.error(`The output closed before ${screenOut} was written.`);
|
|
42270
|
+
process.exitCode = failure2 || outMissing ? 1 : 0;
|
|
42271
|
+
if (failure2) await resultFailed();
|
|
42272
|
+
else if (outMissing) await screenOutFailed();
|
|
42273
|
+
process.exit();
|
|
42274
|
+
});
|
|
42275
|
+
const saveImage = async (write) => {
|
|
41951
42276
|
try {
|
|
41952
|
-
|
|
41953
|
-
fs16.mkdirSync(path22.dirname(path22.resolve(outPath)), { recursive: true });
|
|
41954
|
-
fs16.writeFileSync(outPath, images[0].data);
|
|
41955
|
-
} else if (result && typeof result === "object") {
|
|
41956
|
-
await fetchImageToFile(result, outPath);
|
|
41957
|
-
}
|
|
42277
|
+
await write();
|
|
41958
42278
|
} catch (err) {
|
|
41959
42279
|
console.error(`Failed to save image: ${err instanceof Error ? err.message : err}`);
|
|
41960
|
-
await
|
|
41961
|
-
error_code: FAILURE_CODES.CLI_RUN_SAVE_IMAGE_FAILED,
|
|
41962
|
-
failure_stage: "cli_run_save_image",
|
|
41963
|
-
failure_area: "cli",
|
|
41964
|
-
error_kind: "unknown"
|
|
41965
|
-
});
|
|
42280
|
+
await screenOutFailed();
|
|
41966
42281
|
process.exit(1);
|
|
41967
42282
|
}
|
|
42283
|
+
};
|
|
42284
|
+
if (outPath && meta3.outputHint === "image") {
|
|
42285
|
+
await saveImage(async () => {
|
|
42286
|
+
if (images.length > 0) {
|
|
42287
|
+
writeImageFile(outPath, images[0].data);
|
|
42288
|
+
} else if (result && typeof result === "object") {
|
|
42289
|
+
await fetchImageToFile(result, outPath);
|
|
42290
|
+
}
|
|
42291
|
+
});
|
|
41968
42292
|
}
|
|
41969
42293
|
if (note2) console.error(note2);
|
|
41970
42294
|
console.log(renderResult(result, meta3.outputHint, images, json2));
|
|
41971
42295
|
if (outPath && meta3.outputHint === "image" && !json2) {
|
|
41972
42296
|
console.log(`Wrote: ${outPath}`);
|
|
41973
42297
|
}
|
|
42298
|
+
if (!json2) {
|
|
42299
|
+
const capture = await captureAfterAction({ client: client2, toolName, payload, profiling });
|
|
42300
|
+
if (readerClosed) return;
|
|
42301
|
+
const { screenshot } = capture;
|
|
42302
|
+
if (screenOut && screenshot) {
|
|
42303
|
+
await saveImage(async () => writeImageFile(screenOut, screenshot.data));
|
|
42304
|
+
screenOutWritten = true;
|
|
42305
|
+
}
|
|
42306
|
+
if (capture.note || capture.lines.length > 0 || wantsScreenOut) {
|
|
42307
|
+
await drainStdout();
|
|
42308
|
+
if (readerClosed) return;
|
|
42309
|
+
}
|
|
42310
|
+
if (capture.note) console.error(capture.note);
|
|
42311
|
+
for (const line of capture.lines) console.error(line);
|
|
42312
|
+
if (screenOutWritten) {
|
|
42313
|
+
console.error(`Wrote: ${screenOut}`);
|
|
42314
|
+
} else if (wantsScreenOut) {
|
|
42315
|
+
const reason = !autoScreenshotEnabled() ? "The disable-auto-screenshot flag is on" : profiling ? "A profiler is recording on this device" : "No screen was captured";
|
|
42316
|
+
console.error(`${reason}, so ${screenOut} was not written.`);
|
|
42317
|
+
}
|
|
42318
|
+
}
|
|
41974
42319
|
if (failure2) {
|
|
41975
|
-
await
|
|
42320
|
+
await drainStdout();
|
|
42321
|
+
if (readerClosed) return;
|
|
41976
42322
|
console.error(failure2);
|
|
41977
|
-
await
|
|
41978
|
-
|
|
41979
|
-
|
|
41980
|
-
|
|
41981
|
-
|
|
41982
|
-
|
|
42323
|
+
await resultFailed();
|
|
42324
|
+
await exitAfterFlush(1, [process.stderr]);
|
|
42325
|
+
}
|
|
42326
|
+
if (wantsScreenOut && !screenOutWritten) {
|
|
42327
|
+
await drainStdout();
|
|
42328
|
+
if (readerClosed) return;
|
|
42329
|
+
await screenOutFailed();
|
|
41983
42330
|
await exitAfterFlush(1, [process.stderr]);
|
|
41984
42331
|
}
|
|
41985
42332
|
}
|
|
@@ -42861,15 +43208,15 @@ function isSessionAlive(session) {
|
|
|
42861
43208
|
// ../argent-cli/src/lens-pty.ts
|
|
42862
43209
|
import { chmodSync, readdirSync as readdirSync3 } from "node:fs";
|
|
42863
43210
|
import { createRequire } from "node:module";
|
|
42864
|
-
import { dirname as dirname14, join as
|
|
43211
|
+
import { dirname as dirname14, join as join23 } from "node:path";
|
|
42865
43212
|
var nodeRequire = createRequire(import.meta.url);
|
|
42866
43213
|
function ensureSpawnHelperExecutable(req = nodeRequire) {
|
|
42867
43214
|
if (process.platform !== "darwin") return;
|
|
42868
43215
|
try {
|
|
42869
|
-
const prebuilds =
|
|
43216
|
+
const prebuilds = join23(dirname14(req.resolve("node-pty/package.json")), "prebuilds");
|
|
42870
43217
|
for (const entry of readdirSync3(prebuilds)) {
|
|
42871
43218
|
try {
|
|
42872
|
-
chmodSync(
|
|
43219
|
+
chmodSync(join23(prebuilds, entry, "spawn-helper"), 493);
|
|
42873
43220
|
} catch {
|
|
42874
43221
|
}
|
|
42875
43222
|
}
|
|
@@ -42900,7 +43247,7 @@ function ptyInjectBeats(text2) {
|
|
|
42900
43247
|
{ delayBeforeMs: BEAT_AFTER_TEXT_MS, data: ENTER }
|
|
42901
43248
|
];
|
|
42902
43249
|
}
|
|
42903
|
-
function
|
|
43250
|
+
function sleep2(ms) {
|
|
42904
43251
|
return new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
42905
43252
|
}
|
|
42906
43253
|
var DEFAULT_COLS = 80;
|
|
@@ -42957,7 +43304,7 @@ function startPtyProxy(opts) {
|
|
|
42957
43304
|
const waitForTypingPause = async () => {
|
|
42958
43305
|
const started = Date.now();
|
|
42959
43306
|
while (!disposed && lastUserInputAt > 0 && Date.now() - lastUserInputAt < QUIET_BEFORE_INJECT_MS && Date.now() - started < MAX_QUIET_WAIT_MS) {
|
|
42960
|
-
await
|
|
43307
|
+
await sleep2(QUIET_POLL_MS);
|
|
42961
43308
|
}
|
|
42962
43309
|
};
|
|
42963
43310
|
let queue = Promise.resolve();
|
|
@@ -42969,7 +43316,7 @@ function startPtyProxy(opts) {
|
|
|
42969
43316
|
queue = queue.then(async () => {
|
|
42970
43317
|
await waitForTypingPause();
|
|
42971
43318
|
for (const beat of beats) {
|
|
42972
|
-
if (beat.delayBeforeMs) await
|
|
43319
|
+
if (beat.delayBeforeMs) await sleep2(beat.delayBeforeMs);
|
|
42973
43320
|
if (disposed) return;
|
|
42974
43321
|
term.write(beat.data);
|
|
42975
43322
|
}
|
|
@@ -43122,14 +43469,14 @@ var SPAWN_GRACE_MS = 8e3;
|
|
|
43122
43469
|
var DEATH_CONFIRMATIONS = 3;
|
|
43123
43470
|
var SSE_RECONNECT_MS = 1e3;
|
|
43124
43471
|
var authHeaders3 = {};
|
|
43125
|
-
function
|
|
43472
|
+
function sleep3(ms) {
|
|
43126
43473
|
return new Promise((resolve26) => setTimeout(resolve26, ms));
|
|
43127
43474
|
}
|
|
43128
43475
|
var TRUST_PROMPT_RE = /trust this folder|do you trust|yes,? i trust|trust the files in this/i;
|
|
43129
43476
|
async function dismissTrustPrompt(session) {
|
|
43130
43477
|
const deadline = Date.now() + 12e3;
|
|
43131
43478
|
while (Date.now() < deadline) {
|
|
43132
|
-
await
|
|
43479
|
+
await sleep3(700);
|
|
43133
43480
|
const text2 = readSessionText(session);
|
|
43134
43481
|
if (text2 == null) {
|
|
43135
43482
|
pressEnter(session);
|
|
@@ -43159,7 +43506,7 @@ function dismissTrustPromptViaPty(proxy) {
|
|
|
43159
43506
|
});
|
|
43160
43507
|
}
|
|
43161
43508
|
async function injectSeedViaPty(proxy) {
|
|
43162
|
-
await
|
|
43509
|
+
await sleep3(5e3);
|
|
43163
43510
|
proxy.inject(buildSeedPrompt());
|
|
43164
43511
|
}
|
|
43165
43512
|
function isInteractiveTty() {
|
|
@@ -43203,7 +43550,7 @@ function planAgent(agentId) {
|
|
|
43203
43550
|
return { choose: installed };
|
|
43204
43551
|
}
|
|
43205
43552
|
async function injectSeedAfterBoot(session) {
|
|
43206
|
-
await
|
|
43553
|
+
await sleep3(5e3);
|
|
43207
43554
|
writeToSession(session, buildSeedPrompt());
|
|
43208
43555
|
}
|
|
43209
43556
|
function buildSeedPrompt() {
|
|
@@ -43501,7 +43848,7 @@ async function awaitAgentChoiceViaStream(baseUrl) {
|
|
|
43501
43848
|
}
|
|
43502
43849
|
reconnects++;
|
|
43503
43850
|
if (ac.signal.aborted || reconnects > AGENT_CHOICE_MAX_RECONNECTS) break;
|
|
43504
|
-
await
|
|
43851
|
+
await sleep3(SSE_RECONNECT_MS);
|
|
43505
43852
|
}
|
|
43506
43853
|
} finally {
|
|
43507
43854
|
ac.abort();
|
|
@@ -43571,7 +43918,7 @@ async function runRelaySession(baseUrl, inject, registerDeath, quiet) {
|
|
|
43571
43918
|
}
|
|
43572
43919
|
} catch {
|
|
43573
43920
|
}
|
|
43574
|
-
if (alive && !ac.signal.aborted) await
|
|
43921
|
+
if (alive && !ac.signal.aborted) await sleep3(SSE_RECONNECT_MS);
|
|
43575
43922
|
}
|
|
43576
43923
|
}
|
|
43577
43924
|
async function httpErrorMessage(res) {
|
|
@@ -44973,7 +45320,7 @@ import { styleText as styleText2, stripVTControlCharacters } from "node:util";
|
|
|
44973
45320
|
import process$1 from "node:process";
|
|
44974
45321
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
44975
45322
|
import { existsSync as existsSync8, lstatSync as lstatSync4, readdirSync as readdirSync4 } from "node:fs";
|
|
44976
|
-
import { dirname as dirname18, join as
|
|
45323
|
+
import { dirname as dirname18, join as join27 } from "node:path";
|
|
44977
45324
|
function isUnicodeSupported() {
|
|
44978
45325
|
if (process$1.platform !== "win32") {
|
|
44979
45326
|
return process$1.env.TERM !== "linux";
|
package/dist/client.js
CHANGED
|
@@ -11332,6 +11332,7 @@ function failedRun(result) {
|
|
|
11332
11332
|
function createToolsClient(options = {}) {
|
|
11333
11333
|
let cached = null;
|
|
11334
11334
|
let linkedNoticeShown = false;
|
|
11335
|
+
let cachedToolList;
|
|
11335
11336
|
const doFetch = options.fetchImpl ?? ((url, init) => fetch(url, init));
|
|
11336
11337
|
const diagnose = options.onDiagnostic ?? ((message) => void process.stderr.write(`${message}
|
|
11337
11338
|
`));
|
|
@@ -11364,13 +11365,16 @@ function createToolsClient(options = {}) {
|
|
|
11364
11365
|
async function fetchToolList(opts) {
|
|
11365
11366
|
opts?.signal?.throwIfAborted();
|
|
11366
11367
|
const { url, token } = await baseUrl();
|
|
11368
|
+
if (cachedToolList?.url === url) return cachedToolList.list;
|
|
11367
11369
|
const res = await doFetch(
|
|
11368
11370
|
`${url}/tools`,
|
|
11369
11371
|
{ headers: { ...options.headers?.(), ...authHeaders2(token) }, signal: opts?.signal },
|
|
11370
11372
|
{ longRunning: false, carriesUpload: false }
|
|
11371
11373
|
);
|
|
11372
11374
|
if (!res.ok) throw new Error(`GET /tools failed: ${res.status} ${res.statusText}`);
|
|
11373
|
-
|
|
11375
|
+
const list = await res.json();
|
|
11376
|
+
if (options.cacheToolList) cachedToolList = { url, list };
|
|
11377
|
+
return list;
|
|
11374
11378
|
}
|
|
11375
11379
|
async function fetchTools(opts) {
|
|
11376
11380
|
return (await fetchToolList(opts)).tools;
|
|
@@ -11859,6 +11863,9 @@ function getDeviceIdFromArgs(args) {
|
|
|
11859
11863
|
return void 0;
|
|
11860
11864
|
}
|
|
11861
11865
|
|
|
11866
|
+
// ../argent-tools-client/src/auto-capture.ts
|
|
11867
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
11868
|
+
|
|
11862
11869
|
// src/bundled-paths.ts
|
|
11863
11870
|
import * as fs11 from "node:fs";
|
|
11864
11871
|
import * as path15 from "node:path";
|
package/dist/installer.mjs
CHANGED
|
@@ -24960,6 +24960,9 @@ var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings"
|
|
|
24960
24960
|
var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
|
|
24961
24961
|
var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
24962
24962
|
|
|
24963
|
+
// ../argent-tools-client/src/auto-capture.ts
|
|
24964
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
24965
|
+
|
|
24963
24966
|
// ../argent-installer/src/update.ts
|
|
24964
24967
|
function getRequestedVersion(args) {
|
|
24965
24968
|
for (let i2 = 0; i2 < args.length; i2 += 1) {
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -22308,7 +22308,6 @@ var require_semver2 = __commonJS({
|
|
|
22308
22308
|
|
|
22309
22309
|
// ../argent-mcp/src/mcp-server.ts
|
|
22310
22310
|
import { join as join20 } from "node:path";
|
|
22311
|
-
import { setTimeout as sleep } from "node:timers/promises";
|
|
22312
22311
|
|
|
22313
22312
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
22314
22313
|
import process2 from "node:process";
|
|
@@ -35817,6 +35816,7 @@ function failedRun(result) {
|
|
|
35817
35816
|
function createToolsClient(options = {}) {
|
|
35818
35817
|
let cached2 = null;
|
|
35819
35818
|
let linkedNoticeShown = false;
|
|
35819
|
+
let cachedToolList;
|
|
35820
35820
|
const doFetch = options.fetchImpl ?? ((url, init) => fetch(url, init));
|
|
35821
35821
|
const diagnose = options.onDiagnostic ?? ((message) => void process.stderr.write(`${message}
|
|
35822
35822
|
`));
|
|
@@ -35849,13 +35849,16 @@ function createToolsClient(options = {}) {
|
|
|
35849
35849
|
async function fetchToolList(opts) {
|
|
35850
35850
|
opts?.signal?.throwIfAborted();
|
|
35851
35851
|
const { url, token } = await baseUrl();
|
|
35852
|
+
if (cachedToolList?.url === url) return cachedToolList.list;
|
|
35852
35853
|
const res = await doFetch(
|
|
35853
35854
|
`${url}/tools`,
|
|
35854
35855
|
{ headers: { ...options.headers?.(), ...authHeaders2(token) }, signal: opts?.signal },
|
|
35855
35856
|
{ longRunning: false, carriesUpload: false }
|
|
35856
35857
|
);
|
|
35857
35858
|
if (!res.ok) throw new Error(`GET /tools failed: ${res.status} ${res.statusText}`);
|
|
35858
|
-
|
|
35859
|
+
const list = await res.json();
|
|
35860
|
+
if (options.cacheToolList) cachedToolList = { url, list };
|
|
35861
|
+
return list;
|
|
35859
35862
|
}
|
|
35860
35863
|
async function fetchTools(opts) {
|
|
35861
35864
|
return (await fetchToolList(opts)).tools;
|
|
@@ -36344,6 +36347,191 @@ function getDeviceIdFromArgs(args) {
|
|
|
36344
36347
|
return void 0;
|
|
36345
36348
|
}
|
|
36346
36349
|
|
|
36350
|
+
// ../argent-tools-client/src/auto-capture.ts
|
|
36351
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
36352
|
+
var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
|
|
36353
|
+
"gesture-tap",
|
|
36354
|
+
"gesture-swipe",
|
|
36355
|
+
"gesture-scroll",
|
|
36356
|
+
"gesture-drag",
|
|
36357
|
+
"gesture-hover",
|
|
36358
|
+
"gesture-custom",
|
|
36359
|
+
"gesture-pinch",
|
|
36360
|
+
"gesture-rotate",
|
|
36361
|
+
"button",
|
|
36362
|
+
"keyboard",
|
|
36363
|
+
"paste",
|
|
36364
|
+
"rotate",
|
|
36365
|
+
"fold",
|
|
36366
|
+
"tv-remote",
|
|
36367
|
+
"launch-app",
|
|
36368
|
+
"restart-app",
|
|
36369
|
+
"open-url",
|
|
36370
|
+
"describe",
|
|
36371
|
+
"run-sequence",
|
|
36372
|
+
// A wait is almost always followed by a look at the screen it waited for.
|
|
36373
|
+
"await-ui-element",
|
|
36374
|
+
"file-panel",
|
|
36375
|
+
"menu-bar"
|
|
36376
|
+
]);
|
|
36377
|
+
var AUTO_SCREENSHOT_DELAY_MS_BY_TOOL = {
|
|
36378
|
+
"launch-app": 3e3,
|
|
36379
|
+
"restart-app": 3e3,
|
|
36380
|
+
"open-url": 2e3,
|
|
36381
|
+
"gesture-swipe": 1500,
|
|
36382
|
+
"gesture-scroll": 1500,
|
|
36383
|
+
"gesture-drag": 1500,
|
|
36384
|
+
"gesture-hover": 1500,
|
|
36385
|
+
"gesture-custom": 1500,
|
|
36386
|
+
"gesture-tap": 1500,
|
|
36387
|
+
"gesture-pinch": 1500,
|
|
36388
|
+
"gesture-rotate": 1500,
|
|
36389
|
+
// Only the settle after the last step; each step is an in-app action.
|
|
36390
|
+
"run-sequence": 3e3,
|
|
36391
|
+
"button": 1500,
|
|
36392
|
+
"tv-remote": 1500,
|
|
36393
|
+
"rotate": 1e3,
|
|
36394
|
+
// The fold tool already waits for the panel hand-over; the cap covers the
|
|
36395
|
+
// repaint after it.
|
|
36396
|
+
"fold": 1500,
|
|
36397
|
+
"keyboard": 300,
|
|
36398
|
+
"paste": 300,
|
|
36399
|
+
"describe": 100,
|
|
36400
|
+
// The wait returns on the first match, often mid-transition; the cap must
|
|
36401
|
+
// leave `await-screen-idle` room to see two identical reads.
|
|
36402
|
+
"await-ui-element": 1500
|
|
36403
|
+
};
|
|
36404
|
+
var DEFAULT_DELAY_MS = 1400;
|
|
36405
|
+
var LAUNCH_SETTLE_MS = 3e3;
|
|
36406
|
+
var CAPTURE_TIMEOUT_MS = 15e3;
|
|
36407
|
+
function autoScreenshotEnabled(options) {
|
|
36408
|
+
return !isFlagEnabled("disable-auto-screenshot", options);
|
|
36409
|
+
}
|
|
36410
|
+
var AUTO_DESCRIBE_TOOLS = /* @__PURE__ */ new Set([
|
|
36411
|
+
"gesture-tap",
|
|
36412
|
+
"gesture-swipe",
|
|
36413
|
+
"gesture-scroll",
|
|
36414
|
+
"gesture-drag",
|
|
36415
|
+
"gesture-hover",
|
|
36416
|
+
"gesture-custom",
|
|
36417
|
+
"gesture-pinch",
|
|
36418
|
+
"gesture-rotate",
|
|
36419
|
+
"button",
|
|
36420
|
+
"keyboard",
|
|
36421
|
+
"paste",
|
|
36422
|
+
"rotate",
|
|
36423
|
+
"fold",
|
|
36424
|
+
"tv-remote",
|
|
36425
|
+
"launch-app",
|
|
36426
|
+
"restart-app",
|
|
36427
|
+
"open-url",
|
|
36428
|
+
"run-sequence",
|
|
36429
|
+
"await-ui-element",
|
|
36430
|
+
"file-panel",
|
|
36431
|
+
"menu-bar"
|
|
36432
|
+
]);
|
|
36433
|
+
function autoDescribeEnabled(options) {
|
|
36434
|
+
return !isFlagEnabled("disable-auto-describe", options);
|
|
36435
|
+
}
|
|
36436
|
+
var PROFILING_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped while a profiler is recording on this device. Call screenshot or describe if you need to see the screen.";
|
|
36437
|
+
var SECRET_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped: the input contains a {{secret:\u2026}} placeholder, and a capture of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is captured normally, and shows the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret.";
|
|
36438
|
+
var AUTO_DESCRIBE_HEADER = "--- Elements after action (describe) ---";
|
|
36439
|
+
function shouldAutoDescribe(toolName, args) {
|
|
36440
|
+
const canonical = normalizeToolName(toolName);
|
|
36441
|
+
return AUTO_DESCRIBE_TOOLS.has(canonical) && !isListCall(canonical, args);
|
|
36442
|
+
}
|
|
36443
|
+
var SECRET_PLACEHOLDER_MARKER = "{{secret:";
|
|
36444
|
+
function containsSecretPlaceholder(args) {
|
|
36445
|
+
try {
|
|
36446
|
+
return JSON.stringify(args)?.includes(SECRET_PLACEHOLDER_MARKER) ?? false;
|
|
36447
|
+
} catch {
|
|
36448
|
+
return true;
|
|
36449
|
+
}
|
|
36450
|
+
}
|
|
36451
|
+
function getUdidFromArgs(args) {
|
|
36452
|
+
if (args && typeof args === "object" && "udid" in args && typeof args.udid === "string") {
|
|
36453
|
+
return args.udid;
|
|
36454
|
+
}
|
|
36455
|
+
return void 0;
|
|
36456
|
+
}
|
|
36457
|
+
function normalizeToolName(name) {
|
|
36458
|
+
const idx = name.lastIndexOf("__");
|
|
36459
|
+
return idx === -1 ? name : name.slice(idx + 2);
|
|
36460
|
+
}
|
|
36461
|
+
function shouldAutoScreenshot(toolName, args) {
|
|
36462
|
+
const canonical = normalizeToolName(toolName);
|
|
36463
|
+
return canonical !== "screenshot" && AUTO_SCREENSHOT_TOOLS.has(canonical) && !isListCall(canonical, args);
|
|
36464
|
+
}
|
|
36465
|
+
function isListCall(canonical, args) {
|
|
36466
|
+
return (canonical === "menu-bar" || canonical === "file-panel") && args?.action === "list";
|
|
36467
|
+
}
|
|
36468
|
+
function getAutoScreenshotDelayMs(toolName) {
|
|
36469
|
+
const canonical = normalizeToolName(toolName);
|
|
36470
|
+
const base = AUTO_SCREENSHOT_DELAY_MS_BY_TOOL[canonical] ?? DEFAULT_DELAY_MS;
|
|
36471
|
+
const envOverride = process.env.ARGENT_AUTO_SCREENSHOT_DELAY_MS;
|
|
36472
|
+
if (envOverride) {
|
|
36473
|
+
const envMs = parseInt(envOverride, 10);
|
|
36474
|
+
if (!Number.isNaN(envMs)) return Math.max(base, envMs);
|
|
36475
|
+
}
|
|
36476
|
+
return base;
|
|
36477
|
+
}
|
|
36478
|
+
function describedTree(result) {
|
|
36479
|
+
const { description, hint } = result ?? {};
|
|
36480
|
+
if (typeof description !== "string" || description.length === 0) return void 0;
|
|
36481
|
+
const hintLine = typeof hint === "string" && hint && !description.includes(hint) ? `Hint: ${hint}
|
|
36482
|
+
` : "";
|
|
36483
|
+
return `${hintLine}${description}`;
|
|
36484
|
+
}
|
|
36485
|
+
async function withDeadline(signal, ms, work) {
|
|
36486
|
+
const deadline = new AbortController();
|
|
36487
|
+
const timer = setTimeout(
|
|
36488
|
+
() => deadline.abort(new DOMException("The operation was aborted due to timeout", "TimeoutError")),
|
|
36489
|
+
ms
|
|
36490
|
+
);
|
|
36491
|
+
try {
|
|
36492
|
+
return await work(AbortSignal.any([signal, deadline.signal]));
|
|
36493
|
+
} finally {
|
|
36494
|
+
clearTimeout(timer);
|
|
36495
|
+
}
|
|
36496
|
+
}
|
|
36497
|
+
async function awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs) {
|
|
36498
|
+
const maxWaitMs = getAutoScreenshotDelayMs(toolName);
|
|
36499
|
+
if (maxWaitMs === 0) return { settled: true };
|
|
36500
|
+
const started = Date.now();
|
|
36501
|
+
const awaitIdle = async (timeoutMs) => await withDeadline(
|
|
36502
|
+
signal,
|
|
36503
|
+
timeoutMs + captureTimeoutMs,
|
|
36504
|
+
(s) => call("await-screen-idle", { udid, timeoutMs }, s)
|
|
36505
|
+
);
|
|
36506
|
+
try {
|
|
36507
|
+
let idle = await awaitIdle(maxWaitMs);
|
|
36508
|
+
if (idle?.launching === true && normalizeToolName(toolName) !== "describe") {
|
|
36509
|
+
idle = await awaitIdle(LAUNCH_SETTLE_MS);
|
|
36510
|
+
}
|
|
36511
|
+
return {
|
|
36512
|
+
settled: idle?.settled === true,
|
|
36513
|
+
readiness: { maxWaitMs, ...idle }
|
|
36514
|
+
};
|
|
36515
|
+
} catch {
|
|
36516
|
+
await sleep(Math.max(0, maxWaitMs - (Date.now() - started)), void 0, { signal }).catch(
|
|
36517
|
+
() => {
|
|
36518
|
+
}
|
|
36519
|
+
);
|
|
36520
|
+
return { settled: false };
|
|
36521
|
+
}
|
|
36522
|
+
}
|
|
36523
|
+
async function captureSettledScreen(options) {
|
|
36524
|
+
const { call, udid, toolName, signal, captureTimeoutMs } = options;
|
|
36525
|
+
const settledResult = await awaitScreenSettled(call, udid, toolName, signal, captureTimeoutMs);
|
|
36526
|
+
await options.onSettled?.(settledResult);
|
|
36527
|
+
return withDeadline(signal, captureTimeoutMs, async (captureSignal) => {
|
|
36528
|
+
const screenshot = options.screenshot?.(captureSignal) ?? Promise.resolve([]);
|
|
36529
|
+
if (!settledResult.settled) await screenshot;
|
|
36530
|
+
const tree = options.tree?.(captureSignal) ?? Promise.resolve([]);
|
|
36531
|
+
return [...await screenshot, ...await tree];
|
|
36532
|
+
});
|
|
36533
|
+
}
|
|
36534
|
+
|
|
36347
36535
|
// ../telemetry/src/debug.ts
|
|
36348
36536
|
import * as fs11 from "node:fs";
|
|
36349
36537
|
|
|
@@ -37200,132 +37388,6 @@ async function stepArtifactBlocks(artifacts, status, ctx, depth) {
|
|
|
37200
37388
|
return blocks;
|
|
37201
37389
|
}
|
|
37202
37390
|
|
|
37203
|
-
// ../argent-mcp/src/auto-capture.ts
|
|
37204
|
-
var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
|
|
37205
|
-
"gesture-tap",
|
|
37206
|
-
"gesture-swipe",
|
|
37207
|
-
"gesture-scroll",
|
|
37208
|
-
"gesture-drag",
|
|
37209
|
-
"gesture-hover",
|
|
37210
|
-
"gesture-custom",
|
|
37211
|
-
"gesture-pinch",
|
|
37212
|
-
"gesture-rotate",
|
|
37213
|
-
"button",
|
|
37214
|
-
"keyboard",
|
|
37215
|
-
"paste",
|
|
37216
|
-
"rotate",
|
|
37217
|
-
"fold",
|
|
37218
|
-
"tv-remote",
|
|
37219
|
-
"launch-app",
|
|
37220
|
-
"restart-app",
|
|
37221
|
-
"open-url",
|
|
37222
|
-
"describe",
|
|
37223
|
-
"run-sequence",
|
|
37224
|
-
// A wait is almost always followed by a look at the screen it waited for.
|
|
37225
|
-
"await-ui-element",
|
|
37226
|
-
"file-panel",
|
|
37227
|
-
"menu-bar"
|
|
37228
|
-
]);
|
|
37229
|
-
var AUTO_SCREENSHOT_DELAY_MS_BY_TOOL = {
|
|
37230
|
-
"launch-app": 3e3,
|
|
37231
|
-
"restart-app": 3e3,
|
|
37232
|
-
"open-url": 2e3,
|
|
37233
|
-
"gesture-swipe": 1500,
|
|
37234
|
-
"gesture-scroll": 1500,
|
|
37235
|
-
"gesture-drag": 1500,
|
|
37236
|
-
"gesture-hover": 1500,
|
|
37237
|
-
"gesture-custom": 1500,
|
|
37238
|
-
"gesture-tap": 1500,
|
|
37239
|
-
"gesture-pinch": 1500,
|
|
37240
|
-
"gesture-rotate": 1500,
|
|
37241
|
-
// Only the settle after the last step; each step is an in-app action.
|
|
37242
|
-
"run-sequence": 3e3,
|
|
37243
|
-
"button": 1500,
|
|
37244
|
-
"tv-remote": 1500,
|
|
37245
|
-
"rotate": 1e3,
|
|
37246
|
-
// The fold tool already waits for the panel hand-over; the cap covers the
|
|
37247
|
-
// repaint after it.
|
|
37248
|
-
"fold": 1500,
|
|
37249
|
-
"keyboard": 300,
|
|
37250
|
-
"paste": 300,
|
|
37251
|
-
"describe": 100,
|
|
37252
|
-
// The wait returns on the first match, often mid-transition; the cap must
|
|
37253
|
-
// leave `await-screen-idle` room to see two identical reads.
|
|
37254
|
-
"await-ui-element": 1500
|
|
37255
|
-
};
|
|
37256
|
-
var DEFAULT_DELAY_MS = 1400;
|
|
37257
|
-
var CAPTURE_TIMEOUT_MS = 15e3;
|
|
37258
|
-
function autoScreenshotEnabled(options) {
|
|
37259
|
-
return !isFlagEnabled("disable-auto-screenshot", options);
|
|
37260
|
-
}
|
|
37261
|
-
var AUTO_DESCRIBE_TOOLS = /* @__PURE__ */ new Set([
|
|
37262
|
-
"gesture-tap",
|
|
37263
|
-
"gesture-swipe",
|
|
37264
|
-
"gesture-scroll",
|
|
37265
|
-
"gesture-drag",
|
|
37266
|
-
"gesture-hover",
|
|
37267
|
-
"gesture-custom",
|
|
37268
|
-
"gesture-pinch",
|
|
37269
|
-
"gesture-rotate",
|
|
37270
|
-
"button",
|
|
37271
|
-
"keyboard",
|
|
37272
|
-
"paste",
|
|
37273
|
-
"rotate",
|
|
37274
|
-
"fold",
|
|
37275
|
-
"tv-remote",
|
|
37276
|
-
"launch-app",
|
|
37277
|
-
"restart-app",
|
|
37278
|
-
"open-url",
|
|
37279
|
-
"run-sequence",
|
|
37280
|
-
"await-ui-element",
|
|
37281
|
-
"file-panel",
|
|
37282
|
-
"menu-bar"
|
|
37283
|
-
]);
|
|
37284
|
-
function autoDescribeEnabled(options) {
|
|
37285
|
-
return !isFlagEnabled("disable-auto-describe", options);
|
|
37286
|
-
}
|
|
37287
|
-
var PROFILING_CAPTURE_SKIPPED_NOTE = "Auto-screenshot and element tree skipped while a profiler is recording on this device. Call screenshot or describe if you need to see the screen.";
|
|
37288
|
-
var AUTO_DESCRIBE_HEADER = "--- Elements after action (describe) ---";
|
|
37289
|
-
function shouldAutoDescribe(toolName, args) {
|
|
37290
|
-
const canonical = normalizeToolName(toolName);
|
|
37291
|
-
return AUTO_DESCRIBE_TOOLS.has(canonical) && !isListCall(canonical, args);
|
|
37292
|
-
}
|
|
37293
|
-
var SECRET_PLACEHOLDER_MARKER = "{{secret:";
|
|
37294
|
-
function containsSecretPlaceholder(args) {
|
|
37295
|
-
try {
|
|
37296
|
-
return JSON.stringify(args)?.includes(SECRET_PLACEHOLDER_MARKER) ?? false;
|
|
37297
|
-
} catch {
|
|
37298
|
-
return true;
|
|
37299
|
-
}
|
|
37300
|
-
}
|
|
37301
|
-
function getUdidFromArgs(args) {
|
|
37302
|
-
if (args && typeof args === "object" && "udid" in args && typeof args.udid === "string") {
|
|
37303
|
-
return args.udid;
|
|
37304
|
-
}
|
|
37305
|
-
return void 0;
|
|
37306
|
-
}
|
|
37307
|
-
function normalizeToolName(name) {
|
|
37308
|
-
const idx = name.lastIndexOf("__");
|
|
37309
|
-
return idx === -1 ? name : name.slice(idx + 2);
|
|
37310
|
-
}
|
|
37311
|
-
function shouldAutoScreenshot(toolName, args) {
|
|
37312
|
-
const canonical = normalizeToolName(toolName);
|
|
37313
|
-
return canonical !== "screenshot" && AUTO_SCREENSHOT_TOOLS.has(canonical) && !isListCall(canonical, args);
|
|
37314
|
-
}
|
|
37315
|
-
function isListCall(canonical, args) {
|
|
37316
|
-
return (canonical === "menu-bar" || canonical === "file-panel") && args?.action === "list";
|
|
37317
|
-
}
|
|
37318
|
-
function getAutoScreenshotDelayMs(toolName) {
|
|
37319
|
-
const canonical = normalizeToolName(toolName);
|
|
37320
|
-
const base = AUTO_SCREENSHOT_DELAY_MS_BY_TOOL[canonical] ?? DEFAULT_DELAY_MS;
|
|
37321
|
-
const envOverride = process.env.ARGENT_AUTO_SCREENSHOT_DELAY_MS;
|
|
37322
|
-
if (envOverride) {
|
|
37323
|
-
const envMs = parseInt(envOverride, 10);
|
|
37324
|
-
if (!Number.isNaN(envMs)) return Math.max(base, envMs);
|
|
37325
|
-
}
|
|
37326
|
-
return base;
|
|
37327
|
-
}
|
|
37328
|
-
|
|
37329
37391
|
// ../argent-mcp/src/unchanged-tree.ts
|
|
37330
37392
|
import { randomInt } from "node:crypto";
|
|
37331
37393
|
var MAX_UNCHANGED_IN_A_ROW = 3;
|
|
@@ -37573,13 +37635,6 @@ ${tree}`, mode: "full", identical, note: false };
|
|
|
37573
37635
|
}
|
|
37574
37636
|
};
|
|
37575
37637
|
}
|
|
37576
|
-
function describedTree(result) {
|
|
37577
|
-
const { description, hint } = result ?? {};
|
|
37578
|
-
if (typeof description !== "string" || description.length === 0) return void 0;
|
|
37579
|
-
const hintLine = typeof hint === "string" && hint && !description.includes(hint) ? `Hint: ${hint}
|
|
37580
|
-
` : "";
|
|
37581
|
-
return `${hintLine}${description}`;
|
|
37582
|
-
}
|
|
37583
37638
|
|
|
37584
37639
|
// ../argent-mcp/src/unchanged-screenshot.ts
|
|
37585
37640
|
import { createHash as createHash5, randomInt as randomInt2 } from "node:crypto";
|
|
@@ -38483,18 +38538,6 @@ function takeWhatsNewNote(current) {
|
|
|
38483
38538
|
|
|
38484
38539
|
// ../argent-mcp/src/mcp-server.ts
|
|
38485
38540
|
var SAVES_FILES_AFTER_CANCEL = /* @__PURE__ */ new Set(["screen-recording-stop", "native-profiler-stop"]);
|
|
38486
|
-
async function withDeadline(signal, ms, work) {
|
|
38487
|
-
const deadline = new AbortController();
|
|
38488
|
-
const timer = setTimeout(
|
|
38489
|
-
() => deadline.abort(new DOMException("The operation was aborted due to timeout", "TimeoutError")),
|
|
38490
|
-
ms
|
|
38491
|
-
);
|
|
38492
|
-
try {
|
|
38493
|
-
return await work(AbortSignal.any([signal, deadline.signal]));
|
|
38494
|
-
} finally {
|
|
38495
|
-
clearTimeout(timer);
|
|
38496
|
-
}
|
|
38497
|
-
}
|
|
38498
38541
|
async function startMcpServer(options) {
|
|
38499
38542
|
assertPrivateArgentHome();
|
|
38500
38543
|
if (shouldShowFirstRunNotice()) {
|
|
@@ -38562,31 +38605,15 @@ async function startMcpServer(options) {
|
|
|
38562
38605
|
reconnect,
|
|
38563
38606
|
extraHeaders: aiClientHeaders
|
|
38564
38607
|
});
|
|
38565
|
-
async
|
|
38566
|
-
|
|
38567
|
-
if (
|
|
38568
|
-
|
|
38569
|
-
|
|
38570
|
-
|
|
38571
|
-
|
|
38572
|
-
|
|
38573
|
-
|
|
38574
|
-
);
|
|
38575
|
-
await spyLog({
|
|
38576
|
-
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38577
|
-
event: "auto_screenshot_readiness",
|
|
38578
|
-
name: toolName,
|
|
38579
|
-
maxWaitMs,
|
|
38580
|
-
...idle.result
|
|
38581
|
-
});
|
|
38582
|
-
return idle.result?.settled === true;
|
|
38583
|
-
} catch {
|
|
38584
|
-
await sleep(Math.max(0, maxWaitMs - (Date.now() - started)), void 0, { signal }).catch(
|
|
38585
|
-
() => {
|
|
38586
|
-
}
|
|
38587
|
-
);
|
|
38588
|
-
return false;
|
|
38589
|
-
}
|
|
38608
|
+
const callForCapture = async (name, args, signal) => (await callTool(name, args, { signal })).result;
|
|
38609
|
+
async function logReadiness(toolName, settled) {
|
|
38610
|
+
if (!settled.readiness) return;
|
|
38611
|
+
await spyLog({
|
|
38612
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38613
|
+
event: "auto_screenshot_readiness",
|
|
38614
|
+
name: toolName,
|
|
38615
|
+
...settled.readiness
|
|
38616
|
+
});
|
|
38590
38617
|
}
|
|
38591
38618
|
async function captureScreenshotBlocks(udid, toolName, signal) {
|
|
38592
38619
|
const t1 = Date.now();
|
|
@@ -38763,27 +38790,27 @@ ${shown.text}` }];
|
|
|
38763
38790
|
const wantScreenshot = autoScreenshotOn && shouldAutoScreenshot(params.name, params.arguments);
|
|
38764
38791
|
const wantTree = autoDescribeOn && shouldAutoDescribe(params.name, params.arguments);
|
|
38765
38792
|
if (udid && (wantScreenshot || wantTree) && containsSecretPlaceholder(params.arguments)) {
|
|
38766
|
-
content = [
|
|
38767
|
-
...content,
|
|
38768
|
-
{
|
|
38769
|
-
type: "text",
|
|
38770
|
-
text: "Auto-screenshot and element tree skipped: the input contains a {{secret:\u2026}} placeholder, and a capture of this screen could reveal the typed secret. The secret is already typed \u2014 do not send the typing step again, or the field will hold two copies of it. Submit or navigate away, then verify the resulting screen as usual. Only this call is covered: the next call is captured normally, and shows the secret if the field is still on screen. To cover the submit as well, put the typing and the submit in ONE `run-sequence` the next time you type a secret."
|
|
38771
|
-
}
|
|
38772
|
-
];
|
|
38793
|
+
content = [...content, { type: "text", text: SECRET_CAPTURE_SKIPPED_NOTE }];
|
|
38773
38794
|
} else if (udid && (wantScreenshot || wantTree) && profiling) {
|
|
38774
38795
|
if (params.name !== "describe") {
|
|
38775
|
-
await
|
|
38796
|
+
await logReadiness(
|
|
38797
|
+
params.name,
|
|
38798
|
+
await awaitScreenSettled(callForCapture, udid, params.name, signal, captureTimeoutMs)
|
|
38799
|
+
);
|
|
38776
38800
|
content = [...content, { type: "text", text: PROFILING_CAPTURE_SKIPPED_NOTE }];
|
|
38777
38801
|
}
|
|
38778
38802
|
} else if (udid && (wantScreenshot || wantTree)) {
|
|
38779
|
-
const screenSettled = await awaitScreenSettled(udid, params.name, signal);
|
|
38780
38803
|
if (wantScreenshot) screenshotUdid = udid;
|
|
38781
38804
|
if (wantTree) treeUdid = udid;
|
|
38782
|
-
const captured = await
|
|
38783
|
-
|
|
38784
|
-
|
|
38785
|
-
|
|
38786
|
-
|
|
38805
|
+
const captured = await captureSettledScreen({
|
|
38806
|
+
call: callForCapture,
|
|
38807
|
+
udid,
|
|
38808
|
+
toolName: params.name,
|
|
38809
|
+
signal,
|
|
38810
|
+
captureTimeoutMs,
|
|
38811
|
+
screenshot: wantScreenshot ? (s) => captureScreenshotBlocks(udid, params.name, s) : void 0,
|
|
38812
|
+
tree: wantTree ? (s) => captureTreeBlocks(udid, params.name, s) : void 0,
|
|
38813
|
+
onSettled: (settled) => logReadiness(params.name, settled)
|
|
38787
38814
|
});
|
|
38788
38815
|
content = [...content, ...captured];
|
|
38789
38816
|
}
|
package/dist/tool-server.cjs
CHANGED
|
@@ -151847,6 +151847,7 @@ var TV_NO_CURSOR_STABLE_MS = 1200;
|
|
|
151847
151847
|
var DARK_TAIL_POLLS = 2;
|
|
151848
151848
|
var DARK_TAIL_MAX_MS = 2e3;
|
|
151849
151849
|
var TV_NO_CURSOR_NOTE = "no element holds focus on this screen, so a remote press may be lost";
|
|
151850
|
+
var LAUNCHING_NOTE = "an app is still launching: its splash screen is on screen";
|
|
151850
151851
|
var capability31 = {
|
|
151851
151852
|
apple: { simulator: true, device: true },
|
|
151852
151853
|
appleRemote: { simulator: true },
|
|
@@ -151883,6 +151884,14 @@ function unsettledNote(lastData, lastError, darkTailMs) {
|
|
|
151883
151884
|
if (lastData.hint) parts2.push(lastData.hint);
|
|
151884
151885
|
return parts2.join("; ");
|
|
151885
151886
|
}
|
|
151887
|
+
async function splashScreenShowing(serial) {
|
|
151888
|
+
try {
|
|
151889
|
+
const windows = await adbShell(serial, "dumpsys window visible", { timeoutMs: 2e3 });
|
|
151890
|
+
return windows.includes("Splash Screen ");
|
|
151891
|
+
} catch {
|
|
151892
|
+
return false;
|
|
151893
|
+
}
|
|
151894
|
+
}
|
|
151886
151895
|
var zodSchema47 = external_exports.object({
|
|
151887
151896
|
udid: external_exports.string().min(1).describe(
|
|
151888
151897
|
"Target device id from `list-devices` (iOS UDID, Android serial, Vega serial, <flag:harmonyos>HarmonyOS id, </flag:harmonyos><flag:macos-apps>Mac app id, </flag:macos-apps>or Chromium id)."
|
|
@@ -151922,7 +151931,7 @@ function createAwaitScreenIdleTool(registry2) {
|
|
|
151922
151931
|
id: AWAIT_SCREEN_IDLE_TOOL_ID,
|
|
151923
151932
|
description: `Block until the screen has rendered content and held it for minStableMs, or the timeout elapses. It polls the same element tree as \`describe\`.
|
|
151924
151933
|
Use when a launch or navigation must finish rendering before a screenshot or tap.
|
|
151925
|
-
Returns { settled, waitedMs, polls, note? }. If that is not seen before timeoutMs, it returns settled=false instead of failing.<flag:harmonyos> A note on settled=true means the screen it settled on is not live: a suspended HarmonyOS panel settles instantly on its last frame, and taps land nowhere until it is woken.</flag:harmonyos>`,
|
|
151934
|
+
Returns { settled, waitedMs, polls, launching?, note? }. If that is not seen before timeoutMs, it returns settled=false instead of failing. On Android, launching=true (and settled=false) means an app's splash screen was still showing.<flag:harmonyos> A note on settled=true means the screen it settled on is not live: a suspended HarmonyOS panel settles instantly on its last frame, and taps land nowhere until it is woken.</flag:harmonyos>`,
|
|
151926
151935
|
zodSchema: zodSchema47,
|
|
151927
151936
|
searchHint: "wait until screen settles idle stable stops changing animation transition rendered ready before screenshot",
|
|
151928
151937
|
readOnly: true,
|
|
@@ -151956,8 +151965,17 @@ Returns { settled, waitedMs, polls, note? }. If that is not seen before timeoutM
|
|
|
151956
151965
|
let stableSignature;
|
|
151957
151966
|
let stableSince = 0;
|
|
151958
151967
|
let lastReadAt = 0;
|
|
151968
|
+
let splashSeen = false;
|
|
151969
|
+
const readScreen = async (budgetMs) => {
|
|
151970
|
+
const data = await fetchTree(device, services, tvApi, androidIsTv, budgetMs);
|
|
151971
|
+
if (device.platform !== "android" || data.tree.children.length === 0) return data;
|
|
151972
|
+
const canSettle = minStableMs === 0 || treeSignature(data.tree) === stableSignature;
|
|
151973
|
+
if (!splashSeen && !canSettle) return data;
|
|
151974
|
+
splashSeen = await splashScreenShowing(device.id);
|
|
151975
|
+
return splashSeen ? { ...data, tree: { ...data.tree, children: [] } } : data;
|
|
151976
|
+
};
|
|
151959
151977
|
const poll = await pollDescribeTree({
|
|
151960
|
-
fetchTree:
|
|
151978
|
+
fetchTree: readScreen,
|
|
151961
151979
|
timeoutMs: params.timeoutMs ?? DEFAULT_TIMEOUT_MS5,
|
|
151962
151980
|
pollIntervalMs,
|
|
151963
151981
|
signal: ctx?.signal,
|
|
@@ -151985,11 +152003,13 @@ Returns { settled, waitedMs, polls, note? }. If that is not seen before timeoutM
|
|
|
151985
152003
|
const settled = poll.result === true;
|
|
151986
152004
|
const darkTailMs = Date.now() - lastReadAt;
|
|
151987
152005
|
const hung = lastReadAt > 0 && darkTailMs > Math.min(DARK_TAIL_POLLS * pollIntervalMs, DARK_TAIL_MAX_MS);
|
|
151988
|
-
const
|
|
152006
|
+
const launching = !settled && !poll.aborted && device.platform === "android" && await splashScreenShowing(device.id);
|
|
152007
|
+
const note = launching ? LAUNCHING_NOTE : settled ? poll.lastData?.stale ? poll.lastData.hint : void 0 : unsettledNote(poll.lastData, poll.lastError, hung ? darkTailMs : void 0);
|
|
151989
152008
|
const populatedNoCursor = tvApi && poll.lastData?.tree.children.length && !hasTvCursor(poll.lastData);
|
|
151990
152009
|
const cursorNote = populatedNoCursor ? TV_NO_CURSOR_NOTE : void 0;
|
|
151991
152010
|
return {
|
|
151992
152011
|
settled,
|
|
152012
|
+
...launching ? { launching } : {},
|
|
151993
152013
|
waitedMs: poll.elapsedMs,
|
|
151994
152014
|
polls: poll.polls,
|
|
151995
152015
|
...note || cursorNote ? { note: note ?? cursorNote } : {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.35.1-next.
|
|
3
|
+
"version": "0.35.1-next.85",
|
|
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": "b8bb524e5ad5658b82c3ec99e055c0af0e5fd7de"
|
|
102
102
|
}
|