@deepseek-insight/dsi 0.6.18 → 0.6.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.
Files changed (29) hide show
  1. package/bin/dsi.mjs +30 -7
  2. package/build/client/_app/immutable/assets/{2.C7lNCQCV.css → 2.BqRWIIgD.css} +1 -1
  3. package/build/client/_app/immutable/chunks/BNsgelmQ.js +1 -0
  4. package/build/client/_app/immutable/chunks/{Bqotzgnw.js → BbvYWcEs.js} +1 -1
  5. package/build/client/_app/immutable/chunks/C9uc32GW.js +1 -0
  6. package/build/client/_app/immutable/chunks/{CtUqZStl.js → tw7vR7yM.js} +2 -2
  7. package/build/client/_app/immutable/entry/{app.CGvLdbvX.js → app.BAD3jsui.js} +2 -2
  8. package/build/client/_app/immutable/entry/start.CFzOCQr3.js +1 -0
  9. package/build/client/_app/immutable/nodes/{1.CiNEHoEh.js → 1.COHJn6QL.js} +1 -1
  10. package/build/client/_app/immutable/nodes/{2.5NpWuIn7.js → 2.CpHpu496.js} +64 -64
  11. package/build/client/_app/version.json +1 -1
  12. package/build/handler.js +4 -4
  13. package/build/index.js +4 -4
  14. package/build/server/chunks/chunks/{internal2.js-C4ukUWRE.js → internal2.js-BDzd2OUR.js} +2 -2
  15. package/build/server/chunks/chunks/{state.js-OSxIx7MQ.js → state.js-Cb31UwpL.js} +2 -2
  16. package/build/server/chunks/entries/pages/{_error.svelte.js-2wYgv54Z.js → _error.svelte.js-BqHQUTpg.js} +3 -3
  17. package/build/server/chunks/entries/pages/{_page.svelte.js-BvcQOPvs.js → _page.svelte.js-CWiGV7R5.js} +328 -149
  18. package/build/server/chunks/{handler-D0h_ogA5.js → handler-CPdXYlKK.js} +3 -3
  19. package/build/server/chunks/{index.js-C43GYBhl.js → index.js-CNYTOWSB.js} +2 -2
  20. package/build/server/chunks/{manifest.js-DN0QODc_.js → manifest.js-CQRa1JdF.js} +4 -4
  21. package/build/server/chunks/nodes/1.js-BQXeCZbQ.js +9 -0
  22. package/build/server/chunks/nodes/{2.js-_OZDbZ-E.js → 2.js-CL8x9-EN.js} +4 -4
  23. package/package.json +2 -2
  24. package/template/.dsi/prompts.sqlite-shm +0 -0
  25. package/template/.dsi/prompts.sqlite-wal +0 -0
  26. package/build/client/_app/immutable/chunks/D-YP16Kb.js +0 -1
  27. package/build/client/_app/immutable/chunks/D21lpWN6.js +0 -1
  28. package/build/client/_app/immutable/entry/start.-NibTCMf.js +0 -1
  29. package/build/server/chunks/nodes/1.js-Da_l90xT.js +0 -9
package/bin/dsi.mjs CHANGED
@@ -383,6 +383,19 @@ function portInUse(port) {
383
383
  });
384
384
  }
385
385
 
386
+ /** Poll until something LISTENS on 127.0.0.1:port — the same net probe as
387
+ * portInUse, inverted. The browser-open gate (bug 2026-10-17): the page
388
+ * used to open on a fixed 2s timer, landing on a host that had not bound
389
+ * yet (boot variance, or a first-run pin still downloading). Returns
390
+ * false on budget exhaustion; the caller opens anyway, best-effort. */
391
+ async function waitPortListening(port, budgetMs) {
392
+ for (let waited = 0; waited < budgetMs; waited += 500) {
393
+ if (await portInUse(port)) return true;
394
+ await new Promise((resolve) => setTimeout(resolve, 500));
395
+ }
396
+ return portInUse(port);
397
+ }
398
+
386
399
  /** The dsh host hard-fails on a busy 3080 with a long Cordis stack; catch
387
400
  * it before the pair spawns. First sweep the known orphan shapes
388
401
  * (pkill -f — same BSD/procps flag set on macOS and Linux), wait for the
@@ -448,7 +461,7 @@ async function runSyncedPair(extraArgs, dev = 'build', execArgv = []) {
448
461
  // pointless — the plugin boots the host on 3080 AFTER vite is up, and
449
462
  // a stale 3080 from a foreign floor is that floor's business (the
450
463
  // embedded boot fails loud in the plugin, killing nothing).
451
- warnIfFirstRunDownload();
464
+ const firstRun = warnIfFirstRunDownload();
452
465
  // IN-PROCESS: the plugin reads its port from DSH_HOST_PORT (default 3080)
453
466
  // — the UI half MUST dial the same port, so DSH_HOST_PORT participates in
454
467
  // the dshBase derivation exactly like a forwarded --port flag. (Smoke
@@ -471,8 +484,15 @@ async function runSyncedPair(extraArgs, dev = 'build', execArgv = []) {
471
484
  });
472
485
  const ui = mode === 'build' ? startDsiServer(uiPort, dshBase) : startDsiDevServer(uiPort, dshBase, mode, execArgv);
473
486
  // The browser follows the UI: the built page (5174) — or, in --dev mode,
474
- // the dev server (5175).
475
- openBrowser(`http://localhost:${uiPort}/`);
487
+ // the dev server (5175). Gated on the HOST actually listening (bug
488
+ // 2026-10-17): the fixed 2s timer lost every race the host booted slower
489
+ // than — a first-run pin still downloading worst of all. Budget: 30s for a
490
+ // cached pin, 5 minutes while a new pin downloads. On exhaustion it still
491
+ // opens (best-effort, the old behavior) and says so.
492
+ void waitPortListening(hostPort, firstRun ? 300000 : 30000).then((up) => {
493
+ if (!up) console.log(`dsi dsh: host port ${hostPort} not listening after the wait — opening the page anyway; refresh once the host prints its URL`);
494
+ openBrowser(`http://localhost:${uiPort}/`, 0);
495
+ });
476
496
  for (const signal of ['SIGINT', 'SIGTERM']) {
477
497
  process.on(signal, () => {
478
498
  if (host) host.kill(signal); // in-process: no host child — vite close hook stops it
@@ -803,13 +823,16 @@ function dshPackageCached(version) {
803
823
  * npm exec suppresses its download progress entirely, so a FIRST run of a
804
824
  * new pinned dsh installs for minutes with zero output while the DSI half
805
825
  * is already serving a floor whose every /api call fails. This heads-up
806
- * fires before the host spawns, only when the pin is NOT yet cached. */
826
+ * fires before the host spawns, only when the pin is NOT yet cached.
827
+ * Returns true when the pin needs downloading — the readiness gate below
828
+ * spends a longer budget waiting for the host in that case. */
807
829
  function warnIfFirstRunDownload() {
808
- if (process.env.DSH_WEB_CMD !== undefined) return;
830
+ if (process.env.DSH_WEB_CMD !== undefined) return false;
809
831
  // The env override (same one dsh-web-synced.sh honors) wins over the pin.
810
832
  const version = process.env.DSH_WEB_VERSION ?? dshWebVersion();
811
- if (dshPackageCached(version)) return;
812
- console.log(`dsi dsh: fetching @deepseek-ai/dsh@${version} — first run for this pin, the download can take a few minutes; the DSI page may open before the host answers, just refresh once it prints its URL`);
833
+ if (dshPackageCached(version)) return false;
834
+ console.log(`dsi dsh: fetching @deepseek-ai/dsh@${version} — first run for this pin, the download can take a few minutes; the browser opens once the host answers`);
835
+ return true;
813
836
  }
814
837
 
815
838
  /** The host port a forwarded --port <n> (or --port=<n>) names, else null.