@oya-ai/cli 1.0.196 → 1.0.197

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2324,14 +2324,22 @@ var configApi = (http) => ({
2324
2324
  set: (values) => http().request("POST", "/api/config", values)
2325
2325
  });
2326
2326
  var ENDED = ["failed", "stopped", "unknown_outcome"];
2327
+ var pollPause = (deadline) => {
2328
+ const left = deadline - Date.now();
2329
+ return left <= 0 ? Promise.resolve() : new Promise((r) => setTimeout(r, Math.min(READY_POLL_MS2, left)));
2330
+ };
2331
+ var notReady = (id, timeoutMs) => new OyaError(
2332
+ `Browser ${id} did not come up within ${Math.round(timeoutMs / MS_PER_SECOND)}s`,
2333
+ Status3.GATEWAY_TIMEOUT,
2334
+ null
2335
+ );
2327
2336
  async function waitUntilConnected(checks, id, timeoutMs) {
2328
2337
  const deadline = Date.now() + timeoutMs;
2329
- while (Date.now() < deadline) {
2338
+ for (; ; ) {
2330
2339
  if (await isUp(checks, id)) return;
2331
- await new Promise((r) => setTimeout(r, READY_POLL_MS2));
2340
+ if (Date.now() >= deadline) throw notReady(id, timeoutMs);
2341
+ await pollPause(deadline);
2332
2342
  }
2333
- const seconds = Math.round(timeoutMs / MS_PER_SECOND);
2334
- throw new OyaError(`Browser ${id} did not come up within ${seconds}s`, Status3.GATEWAY_TIMEOUT, null);
2335
2343
  }
2336
2344
  async function isUp(checks, id) {
2337
2345
  const all = await checks.list();
@@ -2392,15 +2400,18 @@ function openLink(link) {
2392
2400
  });
2393
2401
  child.unref();
2394
2402
  }
2403
+ var desktopTimeout = (link) => {
2404
+ const how = `Install it from ${DESKTOP_DOWNLOAD_URL} if needed, then open ${link} and click Connect.`;
2405
+ return new OyaError(`The Oya desktop app did not connect. ${how}`, Status3.GATEWAY_TIMEOUT, { link });
2406
+ };
2395
2407
  async function waitForDesktop(list3, link, timeoutMs, persona) {
2396
2408
  const deadline = Date.now() + timeoutMs;
2397
- while (Date.now() < deadline) {
2409
+ for (; ; ) {
2398
2410
  const found = desktopOf(await list3(), persona);
2399
2411
  if (found) return found;
2400
- await new Promise((r) => setTimeout(r, READY_POLL_MS2));
2412
+ if (Date.now() >= deadline) throw desktopTimeout(link);
2413
+ await pollPause(deadline);
2401
2414
  }
2402
- const how = `Install it from ${DESKTOP_DOWNLOAD_URL} if needed, then open ${link} and click Connect.`;
2403
- throw new OyaError(`The Oya desktop app did not connect. ${how}`, Status3.GATEWAY_TIMEOUT, { link });
2404
2415
  }
2405
2416
  async function handleOn(http, id) {
2406
2417
  const found = await http.request("GET", `/api/browsers/${segment(id)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oya-ai/cli",
3
- "version": "1.0.196",
3
+ "version": "1.0.197",
4
4
  "description": "Command line for the Oya browser control plane.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://oyabrowser.com",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "devDependencies": {
53
- "@oya-ai/browser": "1.0.196",
53
+ "@oya-ai/browser": "1.0.197",
54
54
  "@types/node": "^20.19.43",
55
55
  "tsup": "^8.5.1",
56
56
  "typescript": "^6.0.3"