@lightcone-ai/daemon 0.9.18 → 0.9.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.9.18",
3
+ "version": "0.9.20",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -173,18 +173,18 @@ export class BrowserLoginSession {
173
173
  });
174
174
  }
175
175
 
176
- send(method, params = {}) {
176
+ send(method, params = {}, timeoutMs = 10_000) {
177
177
  return new Promise((resolve, reject) => {
178
178
  if (!this._ws) return reject(new Error('WebSocket not connected'));
179
179
  const id = this._nextId++;
180
- const timer = setTimeout(() => { this._pending.delete(id); reject(new Error(`CDP timeout for ${method}`)); }, 10_000);
180
+ const timer = setTimeout(() => { this._pending.delete(id); reject(new Error(`CDP timeout for ${method}`)); }, timeoutMs);
181
181
  this._pending.set(id, { resolve, reject, timer });
182
182
  this._ws.send(JSON.stringify({ id, method, params }));
183
183
  });
184
184
  }
185
185
 
186
186
  async screenshot() {
187
- const result = await this.send('Page.captureScreenshot', { format: 'jpeg', quality: 70 });
187
+ const result = await this.send('Page.captureScreenshot', { format: 'jpeg', quality: 50, clip: { x: 0, y: 0, width: 800, height: 900, scale: 0.75 } }, 30_000);
188
188
  return result.data;
189
189
  }
190
190
 
@@ -194,12 +194,17 @@ export class BrowserLoginSession {
194
194
  }
195
195
 
196
196
  _startPolling(connection) {
197
+ let _screenshotInProgress = false;
197
198
  this._screenshotTimer = setInterval(async () => {
199
+ if (_screenshotInProgress) return;
200
+ _screenshotInProgress = true;
198
201
  try {
199
202
  const screenshot = await this.screenshot();
200
203
  connection.send({ type: 'browser:screenshot', platform: this._platform, screenshot });
201
204
  } catch (err) {
202
205
  console.error(`[BrowserLogin][${this._platform}] Screenshot error:`, err.message);
206
+ } finally {
207
+ _screenshotInProgress = false;
203
208
  }
204
209
  }, SCREENSHOT_INTERVAL_MS);
205
210