@proagentstore/cli 0.4.3 → 0.4.5
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.
|
@@ -594,6 +594,11 @@ export class LocalRunner {
|
|
|
594
594
|
const initial = this.browserContext.pages()[0];
|
|
595
595
|
if (initial)
|
|
596
596
|
this.trackPage(initial);
|
|
597
|
+
// A seeded real profile can restore MANY tabs on launch; keep a single clean
|
|
598
|
+
// workspace tab so the agent's page is unambiguous and visible (not lost among
|
|
599
|
+
// restored blank tabs — the "why is the window blank?" symptom).
|
|
600
|
+
await this.closeStalePages().catch(() => undefined);
|
|
601
|
+
await this.activePage?.bringToFront().catch(() => undefined);
|
|
597
602
|
return this.browserContext;
|
|
598
603
|
}
|
|
599
604
|
/** Mark a page as the active one; fall back to the newest remaining page when it closes. */
|
|
@@ -623,11 +628,15 @@ export class LocalRunner {
|
|
|
623
628
|
/** The page the brain drives and the human takes over — created on demand. */
|
|
624
629
|
async getActivePage() {
|
|
625
630
|
const context = await this.getBrowserContext();
|
|
626
|
-
if (this.activePage
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
+
if (!this.activePage || this.activePage.isClosed()) {
|
|
632
|
+
this.activePage = context.pages().at(-1) ?? (await context.newPage());
|
|
633
|
+
}
|
|
634
|
+
// Keep the agent's working tab in the FOREGROUND so the user actually SEES what
|
|
635
|
+
// the agent is doing (and can act on it during a takeover). Without this, on a
|
|
636
|
+
// real Chrome profile that restores several tabs, the agent may drive a
|
|
637
|
+
// background tab while the user stares at a blank foreground tab.
|
|
638
|
+
await this.activePage.bringToFront().catch(() => undefined);
|
|
639
|
+
return this.activePage;
|
|
631
640
|
}
|
|
632
641
|
/** The CDP endpoint of the launched Chrome (from DevToolsActivePort in its profile). */
|
|
633
642
|
async readCdpEndpoint() {
|
|
@@ -774,7 +783,14 @@ export class LocalRunner {
|
|
|
774
783
|
const mcp = await this.getMcp();
|
|
775
784
|
const res = await mcp.callTool("browser_snapshot");
|
|
776
785
|
const full = this.extractSnapshot(mcp.textOf(res));
|
|
777
|
-
|
|
786
|
+
// The brain must see the WHOLE form or it can't finish. Real ATS forms are big
|
|
787
|
+
// (a single Coles step is ~31k chars); the old 16k cap cut the page in half, so
|
|
788
|
+
// the brain never saw the Submit button or the bottom required/EEO fields and
|
|
789
|
+
// scroll-looped hunting for controls that were truncated out of its view. Claude
|
|
790
|
+
// Sonnet's context easily holds a full page per turn (the accumulating action log
|
|
791
|
+
// is what's bounded, not the one-shot snapshot). Keep a generous ceiling only to
|
|
792
|
+
// guard against a pathological megapage.
|
|
793
|
+
const MAX = 60_000;
|
|
778
794
|
const snapshot = full.length > MAX ? `${full.slice(0, MAX)}\n… [snapshot truncated]` : full;
|
|
779
795
|
return {
|
|
780
796
|
url: page.url(),
|