@leg3ndy/otto-bridge 0.6.5 → 0.6.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.
package/README.md CHANGED
@@ -33,10 +33,10 @@ Enquanto o pacote nao estiver publicado, voce pode gerar um tarball local:
33
33
 
34
34
  ```bash
35
35
  npm pack
36
- npm install -g ./leg3ndy-otto-bridge-0.6.5.tgz
36
+ npm install -g ./leg3ndy-otto-bridge-0.6.6.tgz
37
37
  ```
38
38
 
39
- No `0.6.5`, `playwright` deixa de ser opcional no `otto-bridge`. O primeiro `npm install -g @leg3ndy/otto-bridge` pode demorar mais porque instala o browser persistente usado pelo WhatsApp Web e pelos fluxos web em background do bridge.
39
+ No `0.6.6`, `playwright` deixa de ser opcional no `otto-bridge`. O primeiro `npm install -g @leg3ndy/otto-bridge` pode demorar mais porque instala o browser persistente usado pelo WhatsApp Web e pelos fluxos web em background do bridge.
40
40
 
41
41
  ## Publicacao
42
42
 
@@ -106,7 +106,7 @@ otto-bridge run --executor clawd-cursor --clawd-url http://127.0.0.1:3847
106
106
 
107
107
  ### WhatsApp Web em background
108
108
 
109
- Fluxo recomendado no `0.6.5`:
109
+ Fluxo recomendado no `0.6.6`:
110
110
 
111
111
  ```bash
112
112
  otto-bridge extensions --install whatsappweb
@@ -116,7 +116,7 @@ otto-bridge extensions --status whatsappweb
116
116
 
117
117
  O setup agora abre o login do WhatsApp Web em um browser persistente do proprio bridge. Depois do QR code, o Otto usa a sessao local em background, sem depender de aba visivel no Safari.
118
118
 
119
- Contrato do `0.6.5`:
119
+ Contrato do `0.6.6`:
120
120
 
121
121
  - `otto-bridge extensions --setup whatsappweb`: autentica a sessao uma vez
122
122
  - `otto-bridge run`: mantem o browser persistente do WhatsApp vivo em background enquanto o runtime estiver ativo
@@ -2164,7 +2164,7 @@ end repeat
2164
2164
  if (!availability.ok) {
2165
2165
  return null;
2166
2166
  }
2167
- const browser = new WhatsAppBackgroundBrowser({ headless: true });
2167
+ const browser = new WhatsAppBackgroundBrowser({ headless: false, background: true });
2168
2168
  await browser.start();
2169
2169
  this.whatsappBackgroundBrowser = browser;
2170
2170
  return browser;
package/dist/types.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const BRIDGE_CONFIG_VERSION = 1;
2
- export const BRIDGE_VERSION = "0.6.5";
2
+ export const BRIDGE_VERSION = "0.6.6";
3
3
  export const BRIDGE_PACKAGE_NAME = "@leg3ndy/otto-bridge";
4
4
  export const DEFAULT_API_BASE_URL = "http://localhost:8000";
5
5
  export const DEFAULT_POLL_INTERVAL_MS = 3000;
@@ -99,11 +99,12 @@ export class WhatsAppBackgroundBrowser {
99
99
  const playwright = await loadPlaywrightModule();
100
100
  await ensureWhatsAppBrowserUserDataDir();
101
101
  this.context = await playwright.chromium.launchPersistentContext(getWhatsAppBrowserUserDataDir(), {
102
- headless: this.options.headless !== false,
102
+ headless: this.options.headless === true,
103
103
  viewport: { width: 1440, height: 960 },
104
104
  locale: "pt-BR",
105
105
  timezoneId: "America/Sao_Paulo",
106
106
  args: [
107
+ ...(this.options.background ? ["--start-minimized"] : []),
107
108
  "--disable-backgrounding-occluded-windows",
108
109
  "--disable-renderer-backgrounding",
109
110
  "--disable-background-timer-throttling",
@@ -113,6 +114,9 @@ export class WhatsAppBackgroundBrowser {
113
114
  const pages = this.context.pages();
114
115
  this.page = pages[0] || await this.context.newPage();
115
116
  await this.ensureWhatsAppPage();
117
+ if (this.options.background) {
118
+ await this.minimizeWindow();
119
+ }
116
120
  }
117
121
  async close() {
118
122
  const current = this.context;
@@ -126,6 +130,28 @@ export class WhatsAppBackgroundBrowser {
126
130
  async waitForTimeout(timeoutMs) {
127
131
  await this.page?.waitForTimeout(Math.max(0, Number(timeoutMs || 0)));
128
132
  }
133
+ async minimizeWindow() {
134
+ const context = this.context;
135
+ const page = this.page;
136
+ if (!context || !page || typeof context.newCDPSession !== "function") {
137
+ return;
138
+ }
139
+ try {
140
+ const session = await context.newCDPSession(page);
141
+ const windowInfo = await session.send("Browser.getWindowForTarget");
142
+ const windowId = Number(windowInfo.windowId || 0);
143
+ if (Number.isFinite(windowId) && windowId > 0) {
144
+ await session.send("Browser.setWindowBounds", {
145
+ windowId,
146
+ bounds: { windowState: "minimized" },
147
+ });
148
+ }
149
+ await session.detach?.().catch(() => undefined);
150
+ }
151
+ catch {
152
+ // If minimization fails, keep the runtime alive anyway.
153
+ }
154
+ }
129
155
  async getSessionState() {
130
156
  const state = await this.withPage(async (page) => {
131
157
  await this.ensureWhatsAppPage();
@@ -502,7 +528,7 @@ export async function detectWhatsAppBackgroundStatus() {
502
528
  notes: availability.reason || "Playwright nao esta disponivel para verificar o WhatsApp Web em background.",
503
529
  };
504
530
  }
505
- const browser = new WhatsAppBackgroundBrowser({ headless: true });
531
+ const browser = new WhatsAppBackgroundBrowser({ headless: false, background: true });
506
532
  try {
507
533
  const state = await browser.waitForStableSessionState({
508
534
  timeoutMs: DEFAULT_EXPECTED_CONNECTED_TIMEOUT_MS,
@@ -522,7 +548,7 @@ export async function detectWhatsAppBackgroundStatus() {
522
548
  }
523
549
  }
524
550
  async function verifyWhatsAppBackgroundSessionPersistence(options) {
525
- const browser = new WhatsAppBackgroundBrowser({ headless: true });
551
+ const browser = new WhatsAppBackgroundBrowser({ headless: false, background: true });
526
552
  try {
527
553
  options?.log?.("Confirmando se a sessao persistiu no browser em background do bridge...");
528
554
  const state = await browser.waitForStableSessionState({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leg3ndy/otto-bridge",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local companion for Otto Bridge device pairing and WebSocket runtime.",