@swmansion/argent 0.35.1-next.83 → 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 +390 -43
- package/dist/client.js +8 -1
- package/dist/installer.mjs +4 -1
- package/dist/mcp-server.mjs +214 -187
- package/dist/tool-server.cjs +101 -22
- package/package.json +2 -2
- package/skills/argent-device-interact/SKILL.md +1 -1
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) {
|
|
@@ -38933,7 +39122,7 @@ function isCi(env = process.env) {
|
|
|
38933
39122
|
var SESSION_ID2 = randomUUID5();
|
|
38934
39123
|
function readCliVersion() {
|
|
38935
39124
|
if (true) {
|
|
38936
|
-
return "0.35.1-next.
|
|
39125
|
+
return "0.35.1-next.84";
|
|
38937
39126
|
}
|
|
38938
39127
|
return "0.0.0";
|
|
38939
39128
|
}
|
|
@@ -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
|
@@ -17175,7 +17175,7 @@ function isCi(env = process.env) {
|
|
|
17175
17175
|
var SESSION_ID = randomUUID4();
|
|
17176
17176
|
function readCliVersion() {
|
|
17177
17177
|
if (true) {
|
|
17178
|
-
return "0.35.1-next.
|
|
17178
|
+
return "0.35.1-next.84";
|
|
17179
17179
|
}
|
|
17180
17180
|
return "0.0.0";
|
|
17181
17181
|
}
|
|
@@ -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) {
|