@proagentstore/cli 0.4.145 → 0.4.146
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { maskedPageScreenshot } from "./local-browser/replay.js";
|
|
1
2
|
/**
|
|
2
3
|
* Detect an anti-bot human challenge on the page (reCAPTCHA, hCaptcha,
|
|
3
4
|
* Cloudflare Turnstile, generic captcha). These can't be solved by the model,
|
|
@@ -74,13 +75,13 @@ export async function challengeSolved(page) {
|
|
|
74
75
|
})
|
|
75
76
|
.catch(() => false);
|
|
76
77
|
}
|
|
77
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Capture a downscaled JPEG screenshot as a data URL for the human-takeover UI — the STILL stored with a
|
|
80
|
+
* handoff. Form controls are blurred first and no still is kept when that cannot be confirmed (#1067): a
|
|
81
|
+
* handoff can be raised mid-form, and the person acts through the live takeover view (which is not
|
|
82
|
+
* blurred — it is the control surface), never through this preview.
|
|
83
|
+
*/
|
|
78
84
|
export async function captureScreenshotDataUrl(page) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return `data:image/jpeg;base64,${buf.toString("base64")}`;
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
85
|
+
const shot = await maskedPageScreenshot(page, { quality: 55, timeout: 8_000 });
|
|
86
|
+
return shot ? `data:image/jpeg;base64,${shot}` : undefined;
|
|
86
87
|
}
|
|
@@ -19,6 +19,29 @@ export const MASK_FORM_CONTROLS = `() => {
|
|
|
19
19
|
return document.getElementById(${JSON.stringify(MASK_ID)}) ? "masked" : "unmasked";
|
|
20
20
|
}`;
|
|
21
21
|
export const UNMASK_FORM_CONTROLS = `() => { const s = document.getElementById(${JSON.stringify(MASK_ID)}); if (s) s.remove(); return "unmasked"; }`;
|
|
22
|
+
/**
|
|
23
|
+
* The same form-control policy for a Playwright `Page` (#1067) — the legacy workflow browser tasks
|
|
24
|
+
* (`runtime_task`: JOB_APPLY / BROWSER_TASK), whose per-action frames were taken with nothing blurred,
|
|
25
|
+
* so a step that had just typed a phone number stored it in plain pixels. Blur, capture, unblur — and
|
|
26
|
+
* NO frame (undefined) when the blur cannot be confirmed, exactly as {@link ShotRecorder.capture}. The
|
|
27
|
+
* unblur runs even when the capture throws, so a failed frame never leaves the page blurred.
|
|
28
|
+
*/
|
|
29
|
+
export async function maskedPageScreenshot(page, opts) {
|
|
30
|
+
try {
|
|
31
|
+
if ((await page.evaluate(`(${MASK_FORM_CONTROLS})()`)) !== "masked")
|
|
32
|
+
return undefined;
|
|
33
|
+
try {
|
|
34
|
+
const buf = await page.screenshot({ type: "jpeg", quality: opts.quality, scale: "css", timeout: opts.timeout });
|
|
35
|
+
return buf.toString("base64");
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
await page.evaluate(`(${UNMASK_FORM_CONTROLS})()`).catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
22
45
|
const textOf = (r) => (r.content ?? []).map((c) => c.text ?? "").join("\n");
|
|
23
46
|
export class ShotRecorder {
|
|
24
47
|
cap;
|
|
@@ -16,6 +16,7 @@ import { RunnerStore } from "./store.js";
|
|
|
16
16
|
import { CodingRuntime } from "./coding/runtime.js";
|
|
17
17
|
import { LocalBrowserRuntime } from "./local-browser/runtime.js";
|
|
18
18
|
import { LOCAL_BROWSER_TASK_TYPE } from "./local-browser/contract.js";
|
|
19
|
+
import { maskedPageScreenshot } from "./local-browser/replay.js";
|
|
19
20
|
import { LocalArtifactRuntime } from "./local-artifact/runtime.js";
|
|
20
21
|
import { LOCAL_ARTIFACT_TASK_TYPE } from "./local-artifact/contract.js";
|
|
21
22
|
import { LocalApplyRuntime } from "./local-apply/runtime.js";
|
|
@@ -908,17 +909,13 @@ export class LocalRunner {
|
|
|
908
909
|
return head.slice(0, 400);
|
|
909
910
|
}
|
|
910
911
|
/** A small JPEG screenshot (base64, no data: prefix) of the page — one per action,
|
|
911
|
-
* so the cloud can store it per step and the whole run can be replayed visually.
|
|
912
|
+
* so the cloud can store it per step and the whole run can be replayed visually.
|
|
913
|
+
* Form controls are BLURRED first, and no frame is kept when that cannot be confirmed (#1067) —
|
|
914
|
+
* the Scout/Runner replay policy (#1063), which this legacy path used to skip.
|
|
915
|
+
* scale:"css" avoids 2× retina bloat; a short timeout means a stuck page never delays the
|
|
916
|
+
* action (the screenshot is best-effort, not the point). */
|
|
912
917
|
async shot(page) {
|
|
913
|
-
|
|
914
|
-
// scale:"css" avoids 2× retina bloat; a short timeout means a stuck page
|
|
915
|
-
// never delays the action (the screenshot is best-effort, not the point).
|
|
916
|
-
const buf = await page.screenshot({ type: "jpeg", quality: 45, scale: "css", timeout: 8_000 });
|
|
917
|
-
return buf.toString("base64");
|
|
918
|
-
}
|
|
919
|
-
catch {
|
|
920
|
-
return undefined;
|
|
921
|
-
}
|
|
918
|
+
return maskedPageScreenshot(page, { quality: 45, timeout: 8_000 });
|
|
922
919
|
}
|
|
923
920
|
/**
|
|
924
921
|
* After a WRITE action, read the field's REAL value back via the standard
|