@xmoon76/dsh-pi-tui 0.5.5 → 0.5.6

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 (48) hide show
  1. package/README.en.md +30 -47
  2. package/README.md +30 -30
  3. package/cordis.patch.yml +77 -7
  4. package/dist/{bootstrap-DLOydLLj.mjs → bootstrap-DQ4YPL-7.mjs} +12416 -7243
  5. package/dist/builtins.mjs +3 -8
  6. package/dist/{application-runtime-CbBO4bY-.mjs → client-bootstrap-Cr1JCaF5.mjs} +3098 -1747
  7. package/dist/{dist-C7QMk0ws.mjs → dist-CIsR7cz4.mjs} +510 -224
  8. package/dist/{extensions-pcFiH7Qe.mjs → extensions-Bp0L37lP.mjs} +527 -249
  9. package/dist/extensions.mjs +1 -1
  10. package/dist/{host-bootstrap-CKdfLkNS.mjs → host-bootstrap-DilsvA6f.mjs} +106 -13
  11. package/dist/host-foundation-probe--5jtvHVe.mjs +413 -0
  12. package/dist/host-runtime.d.mts +10 -6
  13. package/dist/host-runtime.mjs +877 -10
  14. package/dist/index.d.mts +11 -17
  15. package/dist/index.mjs +13328 -6828
  16. package/dist/local-client.mjs +408 -61
  17. package/dist/{local-discovery-CXnLT4GF.mjs → local-discovery-C9VMjc0K.mjs} +10 -6
  18. package/dist/{local-discovery-DVFFpfBG.mjs → local-discovery-CDaQHA_R.mjs} +1 -1
  19. package/dist/local-host.mjs +188 -36
  20. package/dist/{local-transport-C9aonplC.mjs → local-transport-BVwFYq_Y.mjs} +1 -1
  21. package/dist/{context-summary-D9mhxPXL.mjs → pasted-path-range-CMnxuGPx.mjs} +6166 -227
  22. package/dist/{context-summary-Bz0AGXa1.mjs → pasted-path-range-r6qzV_tC.mjs} +5927 -444
  23. package/dist/{pi-tui-remote-contribution-DRk6Tl3J.mjs → pi-tui-remote-contribution-B0EQsP0N.mjs} +27 -20
  24. package/dist/{pi-tui-terminal-progress-contract-XTQKj-WW.mjs → pi-tui-terminal-progress-contract-MLXZ-i3t.mjs} +2 -2
  25. package/dist/pi-tui-web-access-contract-BN8Cc_Ho.mjs +118 -0
  26. package/dist/{runtime-status-0lp9CM0V.mjs → runtime-status-Cj1nFOdS.mjs} +72 -214
  27. package/dist/{session-4keoXjk0.mjs → session-BKGXyh80.mjs} +7487 -2562
  28. package/dist/{session-B2zqv4wr.mjs → session-CPt_U8_f.mjs} +7486 -2560
  29. package/dist/{startup-Ct2UUjUL.mjs → startup-7BYWuvBU.mjs} +121 -6
  30. package/dist/startup.mjs +1 -1
  31. package/dist/{terminal-progress-source-BhufrZ74.mjs → terminal-progress-source-DrqQhtT8.mjs} +305 -45
  32. package/dist/visual-tools.d.mts +2 -2
  33. package/dist/visual-tools.mjs +26 -31
  34. package/dist/web-preferences.d.mts +29 -0
  35. package/dist/web-preferences.mjs +15 -0
  36. package/dist/web-roster-CjqnUXNk.mjs +285 -0
  37. package/generated/dsh-presets/cordis.patch.yml +5 -3
  38. package/generated/dsh-presets/ptc.patch.yml +7 -7
  39. package/generated/dsh-presets/standard.patch.yml +6 -4
  40. package/package.json +182 -168
  41. package/dist/client-bootstrap-DwSFzcTW.mjs +0 -872
  42. package/dist/custom-items-CKrOBCox.mjs +0 -655
  43. package/dist/dispose-cause-BzcXo4hu.mjs +0 -123
  44. package/dist/host-foundation-probe-CYHsbAw6.mjs +0 -143
  45. package/dist/host-prerequisites-9JBTtVNu.mjs +0 -36
  46. package/dist/runtime-Bh5OsftD.mjs +0 -6798
  47. package/dist/runtime-C5ROZqFj.mjs +0 -2
  48. package/dist/terminal-progress-source-CsBinCJ_.mjs +0 -965
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { S as scopeFromInstalledProfile, _ as installedPackageRootFromEntry, h as bindProcessSeat, i as cleanupOwnedFiles, m as LocalScopeError, p as LOCAL_PROTOCOL, v as readInstalledDshVersion, x as removeOwnedScratch, y as readLinuxStarttime } from "./local-discovery-CXnLT4GF.mjs";
2
+ import { S as scopeFromInstalledProfile, _ as installedPackageRootFromEntry, h as bindProcessSeat, i as cleanupOwnedFiles, m as LocalScopeError, p as LOCAL_PROTOCOL, v as readInstalledDshVersion, x as removeOwnedScratch, y as readLinuxStarttime } from "./local-discovery-C9VMjc0K.mjs";
3
3
  import { n as createEntryDiag, r as writeEntryRecord, t as attachEntryControl } from "./entry-control-DnduyDiw.mjs";
4
+ import { t as PI_TUI_WEB_ACCESS_ROWS } from "./web-roster-CjqnUXNk.mjs";
4
5
  import { i as runDetached } from "./tasks-D_z5Yjjr.mjs";
6
+ import { r as PI_TUI_WEB_ACCESS_NAMESPACE } from "./pi-tui-web-access-contract-BN8Cc_Ho.mjs";
5
7
  import { createRequire } from "node:module";
6
8
  import { randomUUID } from "node:crypto";
7
9
  import { existsSync, mkdtempSync, realpathSync, writeFileSync } from "node:fs";
@@ -430,36 +432,6 @@ var HostActivityObserver = class {
430
432
  for (const dispose of subscriptions.reverse()) dispose();
431
433
  }
432
434
  };
433
- //#endregion
434
- //#region src/app/remote-process/local-host-entry.ts
435
- /**
436
- * M4-B1 Host-only process entry.
437
- *
438
- * Boots the ordinary DSH profile through the real launcher
439
- * (`@deepseek-ai/dsh/profile-boot` → `@deepseek-ai/dsh-app-boot` → Loader /
440
- * Include) rather than a hand-built Context. The launcher-owned Host-only
441
- * overlay disables exactly the TUI runner and the Client extension host /
442
- * builtins and adds exactly one official Connection row and one API-remotes
443
- * event source. Every other Host-plane row keeps its production source.
444
- *
445
- * Before the profile Context exists this process claims one Linux abstract
446
- * socket for the canonical DSH profile; losing that kernel claim is a clean
447
- * non-fault exit. After boot it registers one authenticated identity Fetch
448
- * route, publishes the private launch material, and commits `instance.json`
449
- * as its last Ready step. Process-lifetime SIGTERM/SIGINT admission is
450
- * installed before the registry becomes discoverable: a signal observed while
451
- * publication is still in flight is kept as one pending stop intent and runs
452
- * the ordinary owner-governed shutdown once the published identity and the
453
- * official shutdown owner are both available, never emitting Ready for a
454
- * stop-requested Host.
455
- *
456
- * The entry is an internal qualification artifact, not a package export or a
457
- * CLI command: the launcher supplies the DSH installation anchor, profile name
458
- * and scratch directory through `SPLIT_PROCESS_DSH_ANCHOR` /
459
- * `SPLIT_PROCESS_PROFILE` / `SPLIT_PROCESS_SCRATCH`.
460
- *
461
- * @module app/remote-process/local-host-entry
462
- */
463
435
  /**
464
436
  * The Host-only overlay applied over the profile's own patch stack. It keeps
465
437
  * `tui-startup` mounted for the consumers that genuinely need its parsed
@@ -469,7 +441,8 @@ var HostActivityObserver = class {
469
441
  * the three surface rows that must not exist in a Host-only PID, then adds the
470
442
  * two B1 rows plus the official Session-serving rows and the ONE built-in
471
443
  * PiTui Host Runtime row. The base Gateway, webserver, workspace-files,
472
- * credentials, agents, sessions and jobs are reused, never mounted twice.
444
+ * workspace-controller, credentials, agents, sessions and jobs are reused,
445
+ * never mounted twice.
473
446
  */
474
447
  const HOST_ONLY_PATCH = `# M4-B1 Host-only profile overlay: production Host rows only.
475
448
  - id: tui-app
@@ -484,6 +457,32 @@ const HOST_ONLY_PATCH = `# M4-B1 Host-only profile overlay: production Host rows
484
457
  inject: []
485
458
  - id: workspace-files
486
459
  inject: []
460
+ # The bundle's ONE official Workspace Controller row, retuned IN PLACE: the
461
+ # Host is a long-lived Workspace Remote owner, not a CLI startup side effect,
462
+ # yet the row (its ID, package, config and the class's own
463
+ # remoteAccess/typert/workspaceRegistry injects) stays the bundle's. A second
464
+ # row here would register the \`workspace\` namespace twice.
465
+ - id: workspace-controller
466
+ inject: []
467
+
468
+ # Host Schedule management (S5-PR4): the bundle's ONE official Schedule row
469
+ # stays this bundle's row; the overlay only drops its Direct tuiStartup
470
+ # admission gate so the Host timer keeps running after the Client and the Web
471
+ # UI are gone. sessionController remains the readiness barrier and resolves to
472
+ # the existing split-host-session-controller below. Never insert a second
473
+ # Schedule row here.
474
+ - id: pi-tui-schedule
475
+ inject: [sessionController]
476
+ # The three Direct-only activation prerequisites are DISABLED here: the
477
+ # overlay already mounts the split-host-connection / split-host-file-upload /
478
+ # split-host-session-controller rows exactly once, and a second Connection,
479
+ # FileUploads or Session controller would give one Host PID two owners.
480
+ - id: pi-tui-direct-connection
481
+ disabled: true
482
+ - id: pi-tui-direct-file-upload
483
+ disabled: true
484
+ - id: pi-tui-direct-session-controller
485
+ disabled: true
487
486
 
488
487
  - insert:
489
488
  # One official Connection owner (loopback /connect + /api) behind the
@@ -531,11 +530,54 @@ const HOST_ONLY_PATCH = `# M4-B1 Host-only profile overlay: production Host rows
531
530
  inject: [commands, connection]
532
531
 
533
532
  # The package's ONE built-in Host Runtime row: the private contribution plus
534
- # the two private business services. Business features are NOT separate
533
+ # the three private business services. Business features are NOT separate
535
534
  # Loader rows or package subpaths.
536
535
  - id: split-host-pi-tui-runtime
537
536
  name: '@xmoon76/dsh-pi-tui/host-runtime'
538
537
  inject: [typert, agents, fileReferences, workingDirectory]
538
+
539
+ # ── Official Web composition (M5-W PR-A/PR-B/PR-C) ──────────────────────────
540
+ # The official Browser Web rows, declared here ONCE and DISABLED BY DEFAULT.
541
+ # This declaration is the ONE roster the private 'piTuiWebAccess' Host service
542
+ # toggles at runtime: it flips 'disabled' on exactly these rows through
543
+ # 'Entry.update', never a second declaration, never a profile patch write, and
544
+ # never a separate Web process. The toggle is per Host lifetime; a cold boot
545
+ # starts from this default-off state UNLESS the profile's own
546
+ # 'pi-tui-web-preferences.autoStart' preference is on, in which case the boot
547
+ # sequence below enables the same roster before Ready ('/web' remains the
548
+ # immediate control of a running Host).
549
+ # Only the isolated qualification runs additionally override rows through
550
+ # SPLIT_PROCESS_EXTRA_PATCH; that internal test channel is not a user API.
551
+ #
552
+ # The roster is the official browser graph of the installed DSH family minus
553
+ # every row whose authority ALREADY exists in this Host: the second
554
+ # 'connection', 'api-remotes', 'file-upload', 'workspace'/'workspace-controller',
555
+ # 'session-controller', 'settings-controller', 'webserver', 'frontend-static'
556
+ # fallback and 'web-startup' parser are NOT declared here. The mandatory
557
+ # client-dependency closure of the official UIs ('ui-context-menu',
558
+ # 'ui-file-drag'), the official Client file-actions / message-quotes features
559
+ # and the 'workspace-changes' Host recorder that 'ui-deliverables' injects are
560
+ # part of it. 'workspace-changes' is declared BEFORE its consumer because the
561
+ # toggle activates one row at a time and awaits each fiber.
562
+ # 'terminal-controller' is the ONE official Host row added on top of the
563
+ # browser roster (the real Browser x TUI composition needs it).
564
+ #
565
+ # 'web-runtime' owns the single 'frontend-static' fallback over the official
566
+ # dist and is explicitly told to stay silent: no browser launch, no printed
567
+ # token URL and no DSH_WEB_URL shell variable.
568
+ - insert:
569
+ ${PI_TUI_WEB_ACCESS_ROWS.map(({ id, name }) => [
570
+ ` - id: ${id}`,
571
+ ` name: '${name}'`,
572
+ " disabled: true",
573
+ ...id === "web-runtime" ? [
574
+ " inject: [webServer]",
575
+ " config:",
576
+ " openBrowser: false",
577
+ " printUrl: false",
578
+ " surfaceContext: false"
579
+ ] : []
580
+ ].join("\n")).join("\n")}
539
581
  `;
540
582
  /** Resolve one published DSH subpath from the installation anchor supplied by the launcher. */
541
583
  async function loadOfficialDsh(anchor) {
@@ -576,6 +618,70 @@ async function waitForQualificationBarrier(path) {
576
618
  await new Promise((resolve) => setTimeout(resolve, 20));
577
619
  }
578
620
  }
621
+ /** The profile entry that owns the Web startup preference. */
622
+ const WEB_STARTUP_PREFERENCE_NAMESPACE = "pi-tui-web-preferences";
623
+ /**
624
+ * Apply the profile-owned Web startup preference BEFORE the Host becomes Ready.
625
+ *
626
+ * `autoStart` is read from the SAME `ctx` that already settled the profile: a
627
+ * missing settings service or a missing `pi-tui-web-preferences` section is a
628
+ * corrupted composition and fails the Host startup loudly (never "treated as
629
+ * Off"), while a failing Web enable is a bounded diagnostic: the Host keeps its
630
+ * Session/Agent/Gateway graph and publishes Ready with the Web frontend in
631
+ * whatever state the private service truthfully reports.
632
+ *
633
+ * The diagnostic is a FIXED record: a failure category and (when the service
634
+ * answered at all) the Host's own small state vocabulary. It never carries an
635
+ * exception message — a Host, Connection, Loader or plugin error text could
636
+ * contain a URL, launch token, cookie or profile path, which this pre-Ready path
637
+ * must never publish.
638
+ *
639
+ * @param context - the Host context that already settled the profile.
640
+ * @param emit - the structured record sink (the entry emits on its control channel).
641
+ */
642
+ async function applyWebStartupPreference(context, emit = writeEntryRecord) {
643
+ const settings = context.get("settings");
644
+ if (settings === void 0 || typeof settings.describe !== "function") throw new Error("local host entry: the Host has no settings service, so the Web startup preference cannot be read");
645
+ const descriptor = (settings.describe() ?? []).find((entry) => entry.ns === WEB_STARTUP_PREFERENCE_NAMESPACE);
646
+ if (descriptor === void 0) throw new Error("local host entry: the profile projects no \"pi-tui-web-preferences\" settings section");
647
+ const value = descriptor.value;
648
+ const autoStart = typeof value === "object" && value !== null && !Array.isArray(value) ? value.autoStart : void 0;
649
+ if (typeof autoStart !== "boolean") throw new Error("local host entry: \"pi-tui-web-preferences.autoStart\" is not a boolean");
650
+ if (!autoStart) return;
651
+ const unavailable = (failure, state) => {
652
+ emit({
653
+ m4a0: "diagnostic",
654
+ processRole: "host",
655
+ pid: process.pid,
656
+ code: "web-autostart-unavailable",
657
+ failure,
658
+ ...state === void 0 ? {} : { state }
659
+ });
660
+ };
661
+ const service = context.get(PI_TUI_WEB_ACCESS_NAMESPACE);
662
+ if (service === void 0) {
663
+ unavailable("service-missing");
664
+ return;
665
+ }
666
+ let status;
667
+ try {
668
+ status = await service.setEnabled(true);
669
+ } catch {
670
+ unavailable("mutation-failed");
671
+ return;
672
+ }
673
+ if (status.state !== "enabled") {
674
+ unavailable("not-enabled", status.state);
675
+ return;
676
+ }
677
+ emit({
678
+ m4a0: "web-autostart",
679
+ processRole: "host",
680
+ pid: process.pid,
681
+ phase: "pre-ready",
682
+ status: "enabled"
683
+ });
684
+ }
579
685
  /**
580
686
  * Publish the authenticated identity and private launch material, then commit
581
687
  * the registry as the Ready step. The route is registered before the registry
@@ -606,7 +712,7 @@ async function publishLocalHost(context, scope, processStarttime) {
606
712
  const connectUrl = connection.authenticatedUrl(`${origin}/connect`);
607
713
  const connectProbe = new URL(connectUrl);
608
714
  if (connectProbe.origin !== origin || connectProbe.pathname !== "/connect" || connectProbe.searchParams.getAll("token").length !== 1 || [...connectProbe.searchParams.keys()].length !== 1) throw new Error("local host entry: the Connection owner returned an unexpected launch URL");
609
- const { writeLaunchMaterial, writeLocalRecord } = await import("./local-discovery-DVFFpfBG.mjs");
715
+ const { writeLaunchMaterial, writeLocalRecord } = await import("./local-discovery-CDaQHA_R.mjs");
610
716
  writeLaunchMaterial(scope, identity, {
611
717
  schema: 1,
612
718
  instanceId,
@@ -722,8 +828,9 @@ async function runLocalHostEntryOwned(options, scratchOwner) {
722
828
  pid: process.pid,
723
829
  phase: "profile-booted"
724
830
  });
725
- const { settleHostEntries, collectHostEntryStatus } = await import("./host-bootstrap-CKdfLkNS.mjs");
831
+ const { settleHostEntries, collectHostEntryStatus } = await import("./host-bootstrap-DilsvA6f.mjs");
726
832
  await settleHostEntries(handle.ctx);
833
+ await applyWebStartupPreference(handle.ctx);
727
834
  const status = collectHostEntryStatus(handle.ctx, {
728
835
  profile: options.profile,
729
836
  processStartIdentity
@@ -956,6 +1063,20 @@ async function runLocalHostEntryOwned(options, scratchOwner) {
956
1063
  error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
957
1064
  });
958
1065
  }
1066
+ try {
1067
+ await drainHmrTransactions(handle?.ctx);
1068
+ } catch (drainError) {
1069
+ const message = drainError instanceof Error ? drainError.message : String(drainError);
1070
+ priorCleanupFailure ??= message;
1071
+ writeEntryRecord({
1072
+ m4a0: "cleanup-failure",
1073
+ processRole: "host",
1074
+ phase: "after-boot",
1075
+ pid: process.pid,
1076
+ step: "hmr-drain",
1077
+ error: message
1078
+ });
1079
+ }
959
1080
  await finishHostFailureCleanup(shutdownOwner, writeEntryRecord, priorCleanupFailure === void 0 ? void 0 : { priorCleanupFailure });
960
1081
  if (registration !== void 0) cleanupOwnedFiles(scope, registration.identity.instanceId);
961
1082
  process.exitCode = 1;
@@ -964,6 +1085,37 @@ async function runLocalHostEntryOwned(options, scratchOwner) {
964
1085
  await seat.close();
965
1086
  }
966
1087
  }
1088
+ /**
1089
+ * Drain the HMR service's serialized reload transactions before the failed
1090
+ * Host disposes its application tree.
1091
+ *
1092
+ * Cordis 4.1 unloads a provider fiber only after its dependent fibers finish,
1093
+ * and the built-in HMR service's own unload drains the reload queue that is
1094
+ * still holding the boot-time configuration refresh. Disposing the tree while
1095
+ * that refresh is queued therefore deadlocks: the HMR fiber waits for the
1096
+ * refresh, and the refresh waits for the Loader that is being disposed. The
1097
+ * launcher's shutdown then force-exits after its 5s grace before the cleanup
1098
+ * classification can be recorded. `runExclusive` is the public serialization
1099
+ * seam, so an empty operation joins the queue and resolves after the in-flight
1100
+ * transaction settled. A missing HMR service is a no-op; a queue that cannot
1101
+ * drain within the bound rejects so the caller reports a truthful cleanup
1102
+ * failure instead of claiming completion.
1103
+ *
1104
+ * @param context - the Host context whose HMR service (if any) is drained.
1105
+ * @param timeoutMs - the bound on the drain, so a stuck queue cannot hang exit.
1106
+ */
1107
+ async function drainHmrTransactions(context, timeoutMs = 3e3) {
1108
+ const hmr = context.get?.("hmr");
1109
+ if (typeof hmr?.runExclusive !== "function") return;
1110
+ let timer;
1111
+ try {
1112
+ await Promise.race([hmr.runExclusive(async () => void 0), new Promise((_resolve, reject) => {
1113
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error("local host entry: HMR transactions did not drain before failure cleanup")), timeoutMs);
1114
+ })]);
1115
+ } finally {
1116
+ if (timer !== void 0) clearTimeout(timer);
1117
+ }
1118
+ }
967
1119
  async function finishHostFailureCleanup(shutdownOwner, emit = writeEntryRecord, options = {}) {
968
1120
  try {
969
1121
  await shutdownOwner.shutdown(1);
@@ -1022,4 +1174,4 @@ if (import.meta.main) try {
1022
1174
  process.exit(1);
1023
1175
  }
1024
1176
  //#endregion
1025
- export { HOST_ONLY_PATCH, finishHostFailureCleanup, runLocalHostEntry };
1177
+ export { HOST_ONLY_PATCH, applyWebStartupPreference, drainHmrTransactions, finishHostFailureCleanup, runLocalHostEntry };
@@ -1,4 +1,4 @@
1
- import { a as connectForCookie, b as readProcessStarttime, l as readLaunchMaterial, m as LocalScopeError, u as readLocalRecord } from "./local-discovery-CXnLT4GF.mjs";
1
+ import { a as connectForCookie, b as readProcessStarttime, l as readLaunchMaterial, m as LocalScopeError, u as readLocalRecord } from "./local-discovery-C9VMjc0K.mjs";
2
2
  import { i as runDetached } from "./tasks-D_z5Yjjr.mjs";
3
3
  import { t as mergeCause } from "./dispose-cause-CNFuUnjR.mjs";
4
4
  import { createRequire } from "node:module";