@mindstudio-ai/local-model-tunnel 0.5.62 → 0.5.64

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.
@@ -2206,6 +2206,12 @@ var ClientRegistry = class {
2206
2206
  hasConnected() {
2207
2207
  return this.clients.size > 0;
2208
2208
  }
2209
+ hasHeadless() {
2210
+ for (const client of this.clients.values()) {
2211
+ if (client.mode === "headless") return true;
2212
+ }
2213
+ return false;
2214
+ }
2209
2215
  count() {
2210
2216
  return this.clients.size;
2211
2217
  }
@@ -2368,6 +2374,10 @@ var DevProxy = class _DevProxy {
2368
2374
  lastMirrorSnapshot = null;
2369
2375
  /** Open /_/telemetry/presence SSE responses, drained on stop(). */
2370
2376
  sseConnections = /* @__PURE__ */ new Set();
2377
+ /** Waiters resolved when a headless (sandbox-owned) client registers via WS.
2378
+ * Lets the supervisor block on the real readiness signal instead of a
2379
+ * network-idle predicate that gets defeated by long-lived SSE responses. */
2380
+ headlessReadyWaiters = /* @__PURE__ */ new Set();
2371
2381
  /** Upstream dev server health tracking. */
2372
2382
  upstreamUp = true;
2373
2383
  healthCheckTimer = null;
@@ -2386,6 +2396,32 @@ var DevProxy = class _DevProxy {
2386
2396
  isBrowserConnected() {
2387
2397
  return this.clients.hasConnected();
2388
2398
  }
2399
+ /**
2400
+ * Resolve when a sandbox-owned headless client has registered via WS hello.
2401
+ * If one is already connected, resolves immediately. Otherwise queues a
2402
+ * one-shot waiter with a timeout. Used by `BrowserSupervisor` so it doesn't
2403
+ * declare `running` until the browser-agent is actually reachable for
2404
+ * commands — replacing the prior `networkidle0`-based readiness check
2405
+ * which is defeated by long-lived SSE responses (e.g. /_/telemetry/presence).
2406
+ */
2407
+ waitForHeadlessClient(timeoutMs = 15e3) {
2408
+ if (this.clients.hasHeadless()) return Promise.resolve();
2409
+ return new Promise((resolve3, reject) => {
2410
+ const waiter = {
2411
+ resolve: resolve3,
2412
+ reject,
2413
+ timer: setTimeout(() => {
2414
+ this.headlessReadyWaiters.delete(waiter);
2415
+ reject(
2416
+ new Error(
2417
+ `Sandbox browser-agent did not connect within ${timeoutMs}ms`
2418
+ )
2419
+ );
2420
+ }, timeoutMs)
2421
+ };
2422
+ this.headlessReadyWaiters.add(waiter);
2423
+ });
2424
+ }
2389
2425
  /**
2390
2426
  * Dispatch a command to the preferred browser client and wait for the result.
2391
2427
  * Commands are queued and executed one at a time per client (FIFO).
@@ -2572,6 +2608,11 @@ var DevProxy = class _DevProxy {
2572
2608
  }
2573
2609
  }
2574
2610
  this.sseConnections.clear();
2611
+ for (const w of this.headlessReadyWaiters) {
2612
+ clearTimeout(w.timer);
2613
+ w.reject(new Error("Proxy stopped"));
2614
+ }
2615
+ this.headlessReadyWaiters.clear();
2575
2616
  if (this.server) {
2576
2617
  log.info("proxy", "Dev proxy stopping");
2577
2618
  this.server.close();
@@ -2656,6 +2697,13 @@ var DevProxy = class _DevProxy {
2656
2697
  viewport,
2657
2698
  mirror: !!msg.mirror
2658
2699
  });
2700
+ if (mode === "headless" && this.headlessReadyWaiters.size > 0) {
2701
+ for (const w of this.headlessReadyWaiters) {
2702
+ clearTimeout(w.timer);
2703
+ w.resolve();
2704
+ }
2705
+ this.headlessReadyWaiters.clear();
2706
+ }
2659
2707
  ws.send(JSON.stringify({ type: "ack", clientId }));
2660
2708
  if (mode === "mirror" && this.lastMirrorSnapshot) {
2661
2709
  try {
@@ -3643,4 +3691,4 @@ export {
3643
3691
  watchConfigFile,
3644
3692
  watchManifestFiles
3645
3693
  };
3646
- //# sourceMappingURL=chunk-Y6UJ5YX5.js.map
3694
+ //# sourceMappingURL=chunk-7CY3GAYS.js.map