@agent-native/core 0.163.3 → 0.163.4

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.
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- ok: boolean;
19
18
  error?: undefined;
19
+ ok: boolean;
20
20
  }>>;
@@ -26,8 +26,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
26
26
  expiresAt?: undefined;
27
27
  ttlSeconds?: undefined;
28
28
  } | {
29
+ error?: undefined;
29
30
  token: string;
30
31
  expiresAt: string;
31
32
  ttlSeconds: number;
32
- error?: undefined;
33
33
  }>>;
@@ -20,6 +20,6 @@ export declare function createTranscribeVoiceHandler(): import("h3").EventHandle
20
20
  error: string;
21
21
  text?: undefined;
22
22
  } | {
23
- text: string;
24
23
  error?: undefined;
24
+ text: string;
25
25
  }>>;
@@ -2229,10 +2229,9 @@ function isNitroEnvironmentUnavailable(error) {
2229
2229
  }
2230
2230
  const NITRO_STARTUP_SETTLE_MS = 1_000;
2231
2231
  const NITRO_STARTUP_TIMEOUT_MS = 30_000;
2232
- const NITRO_STARTUP_RETRY_KEY = "__agent_native_nitro_startup_retry";
2233
- const NITRO_STARTUP_RETRY_MAX = 5;
2234
2232
  const NITRO_STARTUP_RETRY_DELAY_MS = 1_000;
2235
- const NITRO_STARTUP_RETRY_RESET_MS = 15_000;
2233
+ const NITRO_STARTUP_RETRY_MAX_DELAY_MS = 3_000;
2234
+ const NITRO_STARTUP_SLOW_HINT_MS = 8_000;
2236
2235
  function nitroModuleGraphSignature(environment) {
2237
2236
  const graph = environment
2238
2237
  ?.moduleGraph;
@@ -2259,6 +2258,9 @@ function isHtmlDocumentRequest(req) {
2259
2258
  (req.headers.accept ?? "").includes("text/html"));
2260
2259
  }
2261
2260
  function sendNitroStartingResponse(req, res) {
2261
+ // Fetch-poll this URL instead of location.reload(). Reloading after the
2262
+ // startup gate opens stacks Nitro SSR compiles, and a 5-reload cap left
2263
+ // the tab stuck on this page for the rest of a multi-minute first boot.
2262
2264
  res.statusCode = 503;
2263
2265
  res.setHeader("cache-control", "no-store");
2264
2266
  res.setHeader("content-type", "text/html; charset=utf-8");
@@ -2287,42 +2289,38 @@ function sendNitroStartingResponse(req, res) {
2287
2289
  </main>
2288
2290
  <script>
2289
2291
  (() => {
2290
- const key = ${JSON.stringify(NITRO_STARTUP_RETRY_KEY)};
2291
- const maxRetries = ${NITRO_STARTUP_RETRY_MAX};
2292
- const resetAfterMs = ${NITRO_STARTUP_RETRY_RESET_MS};
2293
- const retryDelayMs = ${NITRO_STARTUP_RETRY_DELAY_MS};
2294
2292
  const status = document.getElementById("agent-native-nitro-retry-status");
2295
- const now = Date.now();
2296
- let count = 0;
2297
- let lastAttemptAt = 0;
2298
-
2299
- try {
2300
- const stored = JSON.parse(sessionStorage.getItem(key) || "null");
2301
- if (stored && typeof stored === "object") {
2302
- count = Number.isFinite(stored.count) ? stored.count : 0;
2303
- lastAttemptAt = Number.isFinite(stored.at) ? stored.at : 0;
2293
+ const startedAt = Date.now();
2294
+ let delayMs = ${NITRO_STARTUP_RETRY_DELAY_MS};
2295
+ const maxDelayMs = ${NITRO_STARTUP_RETRY_MAX_DELAY_MS};
2296
+ const slowHintMs = ${NITRO_STARTUP_SLOW_HINT_MS};
2297
+ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2298
+ const setStatus = (text) => {
2299
+ if (status) status.textContent = text;
2300
+ };
2301
+ const poll = async () => {
2302
+ setStatus("Waiting for the dev server…");
2303
+ while (true) {
2304
+ if (Date.now() - startedAt >= slowHintMs) {
2305
+ setStatus("Still starting… first boot can take a couple of minutes.");
2306
+ }
2307
+ try {
2308
+ const res = await fetch(location.href, {
2309
+ cache: "no-store",
2310
+ headers: { Accept: "text/html" },
2311
+ });
2312
+ if (res.status !== 503) {
2313
+ location.reload();
2314
+ return;
2315
+ }
2316
+ } catch {
2317
+ // Connection reset mid-boot; keep polling.
2318
+ }
2319
+ await wait(delayMs);
2320
+ delayMs = Math.min(delayMs + 500, maxDelayMs);
2304
2321
  }
2305
- } catch (error) {
2306
- // A blocked session store is handled below by showing a manual retry.
2307
- }
2308
-
2309
- if (now - lastAttemptAt > resetAfterMs) count = 0;
2310
- if (count >= maxRetries) {
2311
- if (status) status.textContent = "The server is still unavailable. Refresh when it is ready.";
2312
- return;
2313
- }
2314
-
2315
- const nextState = JSON.stringify({ count: count + 1, at: now });
2316
- try {
2317
- sessionStorage.setItem(key, nextState);
2318
- if (sessionStorage.getItem(key) !== nextState) throw new Error("unavailable");
2319
- } catch (error) {
2320
- if (status) status.textContent = "Refresh manually when the server is ready.";
2321
- return;
2322
- }
2323
-
2324
- if (status) status.textContent = "Retrying in one second…";
2325
- setTimeout(() => window.location.reload(), retryDelayMs);
2322
+ };
2323
+ void poll();
2326
2324
  })();
2327
2325
  </script>
2328
2326
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.163.3",
3
+ "version": "0.163.4",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {