@proagentstore/cli 0.4.4 → 0.4.6

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 && !this.activePage.isClosed())
627
- return this.activePage;
628
- const page = context.pages().at(-1) ?? (await context.newPage());
629
- this.activePage = page;
630
- return page;
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() {
@@ -680,6 +689,17 @@ export class LocalRunner {
680
689
  const head = (cut >= 0 ? text.slice(0, cut) : text).replace(/```[a-z]*\n?|```/g, " ").replace(/\s+/g, " ").trim();
681
690
  return head.slice(0, 400);
682
691
  }
692
+ /** A small JPEG screenshot (base64, no data: prefix) of the page — one per action,
693
+ * so the cloud can store it per step and the whole run can be replayed visually. */
694
+ async shot(page) {
695
+ try {
696
+ const buf = await page.screenshot({ type: "jpeg", quality: 45 });
697
+ return buf.toString("base64");
698
+ }
699
+ catch {
700
+ return undefined;
701
+ }
702
+ }
683
703
  /**
684
704
  * After a WRITE action, read the field's REAL value back via the standard
685
705
  * browser_evaluate tool (evaluates on the element by ref — no reinvented DOM
@@ -823,6 +843,7 @@ export class LocalRunner {
823
843
  url: active.url(),
824
844
  title: await active.title().catch(() => ""),
825
845
  challenge: await detectHumanChallenge(active),
846
+ screenshot: await this.shot(active),
826
847
  };
827
848
  }
828
849
  const mcp = await this.getMcp();
@@ -846,6 +867,7 @@ export class LocalRunner {
846
867
  title: await settled.title().catch(() => ""),
847
868
  challenge: await detectHumanChallenge(settled),
848
869
  feedback: dialogMsg ? `a native dialog was accepted: "${dialogMsg}"` : "a native dialog was accepted",
870
+ screenshot: await this.shot(settled),
849
871
  };
850
872
  }
851
873
  if (res.isError)
@@ -878,6 +900,7 @@ export class LocalRunner {
878
900
  title: await active.title().catch(() => ""),
879
901
  challenge: await detectHumanChallenge(active),
880
902
  feedback: feedback || undefined,
903
+ screenshot: await this.shot(active),
881
904
  };
882
905
  }
883
906
  // ── Agent-driven application lifecycle (called by the remote Workflow brain) ──
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proagentstore/cli",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "CLI for creating, publishing, and running ProAgentStore agents",
5
5
  "license": "MIT",
6
6
  "type": "module",