super-dsh 0.3.1 → 0.3.2-d

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 (46) hide show
  1. package/client/index.js +135 -14
  2. package/package.json +1 -1
  3. package/remote/helper-bin/MANIFEST.json +35 -0
  4. package/remote/helper-bin/aarch64-apple-darwin/BUILT-VER +1 -0
  5. package/remote/helper-bin/aarch64-apple-darwin/superd-run +0 -0
  6. package/remote/helper-bin/aarch64-unknown-linux-musl/BUILT-VER +1 -0
  7. package/remote/helper-bin/aarch64-unknown-linux-musl/superd-run +0 -0
  8. package/remote/helper-bin/x86_64-pc-windows-gnu/BUILT-VER +1 -0
  9. package/remote/helper-bin/x86_64-pc-windows-gnu/superd-run.exe +0 -0
  10. package/remote/helper-bin/x86_64-unknown-linux-musl/BUILT-VER +1 -0
  11. package/remote/helper-bin/x86_64-unknown-linux-musl/superd-run +0 -0
  12. package/remote/hub-pty-pump.mjs +97 -0
  13. package/remote/plugin.d.ts +519 -197
  14. package/remote/plugin.js +2516 -754
  15. package/remote/provenance.json +36 -21
  16. package/superd-hub/dist/a2a-host.d.ts +11 -3
  17. package/superd-hub/dist/a2a-host.js +7 -7
  18. package/superd-hub/dist/a2a-row.js +7 -1
  19. package/superd-hub/dist/carrier.d.ts +9 -7
  20. package/superd-hub/dist/carrier.js +3 -3
  21. package/superd-hub/dist/client/pill-geometry.d.ts +70 -0
  22. package/superd-hub/dist/client/pill-geometry.js +49 -0
  23. package/superd-hub/dist/client/switch.d.ts +15 -0
  24. package/superd-hub/dist/client/switch.js +54 -1
  25. package/superd-hub/dist/companions.js +8 -6
  26. package/superd-hub/dist/fusion-transport.d.ts +18 -1
  27. package/superd-hub/dist/fusion-transport.js +44 -5
  28. package/superd-hub/dist/gateway.js +8 -1
  29. package/superd-hub/dist/hub-route.d.ts +5 -2
  30. package/superd-hub/dist/hub-route.js +6 -6
  31. package/superd-hub/dist/hub-tool.d.ts +1 -1
  32. package/superd-hub/dist/hub-tool.js +1 -1
  33. package/superd-hub/dist/remote-provider.js +70 -36
  34. package/superd-hub/dist/rpc.d.ts +5 -0
  35. package/superd-hub/dist/rpc.js +20 -1
  36. package/superd-hub/dist/switch-core.d.ts +41 -0
  37. package/superd-hub/dist/switch-core.js +40 -0
  38. package/superd-hub/dist/targets.d.ts +7 -0
  39. package/superd-hub/dist/world-lifecycle.js +1 -1
  40. package/superd-hub/lib/client/index.js +135 -14
  41. package/superd-hub/dist/exec-pty-channel.d.ts +0 -58
  42. package/superd-hub/dist/exec-pty-channel.js +0 -162
  43. package/superd-hub/dist/exec-pty-framing.d.ts +0 -34
  44. package/superd-hub/dist/exec-pty-framing.js +0 -89
  45. package/superd-hub/dist/exec-pty-session.d.ts +0 -78
  46. package/superd-hub/dist/exec-pty-session.js +0 -228
package/client/index.js CHANGED
@@ -898,6 +898,16 @@ function machineLabelsFrom(list) {
898
898
  * roster-probe failure → revert to native + a visible toast, never a page
899
899
  * lock).
900
900
  *
901
+ * Live-install staleness (2026-10-18): the fusion flag global and the
902
+ * transport script are baked into the SERVED index, so a page that booted
903
+ * before super-dsh was installed runs the freshly hot-loaded client half
904
+ * against a stale page — `fusionPage()` reads false and every switch
905
+ * affordance stays hidden until a manual restart. {@link fusionReloadDecision}
906
+ * is the pure decision behind the client half's heal: one roster answer later,
907
+ * reload the page once. The transport must precede app boot (its upload hook
908
+ * `__DSH_FILE_UPLOAD__` is read at construction), so a client-side flag flip
909
+ * can never arm a stale page honestly — the page must be re-served.
910
+ *
901
911
  * Host-half on purpose: plain TS with every effect injected through
902
912
  * {@link SwitchHost} — no DOM, no client imports — so `test/client-switch.test.mjs`
903
913
  * imports it from `dist/` like every other host module. The client half
@@ -1343,6 +1353,22 @@ function switchAffordance(fusion) {
1343
1353
  hint: FUSION_OFF_HINT
1344
1354
  };
1345
1355
  }
1356
+ /** The sessionStorage marker guarding the stale-page reload: one per tab session. */
1357
+ const FUSION_RELOAD_MARKER = "superd.fusion-armed.reload";
1358
+ /**
1359
+ * The live-install staleness decision (host-half pure so the node tests pin
1360
+ * the table from `dist/`). The host's `hub.fusion` field is the ONLY thing
1361
+ * that distinguishes a page-booted-before-install from a deliberately
1362
+ * flag-off deployment — without it the reload would loop forever on every
1363
+ * `enabled: false` composition (the client half loads there too).
1364
+ */
1365
+ function fusionReloadDecision(input) {
1366
+ if (input.flagPresent) return "armed";
1367
+ if (input.markerPresent) return "already-reloaded";
1368
+ if (input.hubFusion === true) return "reload";
1369
+ if (input.hubFusion === false) return "row-off";
1370
+ return "host-silent";
1371
+ }
1346
1372
  /**
1347
1373
  * The active agent's display name for the Hub row's right-edge selector: the
1348
1374
  * roster label of the atom's `activeAgent` key — the name the selector's
@@ -1621,6 +1647,53 @@ function createReadinessWaiter(faces, options = {}) {
1621
1647
  function fusionPage() {
1622
1648
  return globalThis.__SUPERD_UI_FUSION__ === true;
1623
1649
  }
1650
+ /**
1651
+ * The sessionStorage marker read (undefined-safe: a storage failure is
1652
+ * `false` — the probe then reloads without the loop guard, which only
1653
+ * matters for a host that reports fusion but never bakes the flag).
1654
+ */
1655
+ function staleReloadMarker() {
1656
+ try {
1657
+ return globalThis.sessionStorage?.getItem(FUSION_RELOAD_MARKER) !== null;
1658
+ } catch {
1659
+ return false;
1660
+ }
1661
+ }
1662
+ /**
1663
+ * Live-install staleness probe (2026-10-18): the ONE call the client entry
1664
+ * makes when the page does not carry the fusion flag. A flag-absent page is
1665
+ * either a pre-install page (the client half hot-loaded into HTML served
1666
+ * before the row mounted — the fresh-install case where the Hub row renders
1667
+ * but every switch affordance stays hidden until a manual restart) or a
1668
+ * deliberate flag-off deployment (T-E). The roster's additive `hub.fusion`
1669
+ * answers which; on an armed host the page re-boots ONCE — the marker keeps
1670
+ * a misbehaving host from ever looping the tab. Every failure mode (fetch
1671
+ * error, non-OK, old host without the field) degrades to no action: the
1672
+ * flag-off shapes below are the honest rendering of an unanswered probe.
1673
+ *
1674
+ * Fire-and-forget by contract — never throws, never blocks the apply.
1675
+ */
1676
+ function probeStaleFusionPage() {
1677
+ (async () => {
1678
+ let hubFusion;
1679
+ try {
1680
+ const response = await fetch("/api/agent-runtime", { credentials: "same-origin" });
1681
+ if (!response.ok) return;
1682
+ hubFusion = (await response.json()).hub?.fusion;
1683
+ } catch {
1684
+ return;
1685
+ }
1686
+ if (fusionReloadDecision({
1687
+ flagPresent: fusionPage(),
1688
+ markerPresent: staleReloadMarker(),
1689
+ hubFusion
1690
+ }) !== "reload") return;
1691
+ try {
1692
+ globalThis.sessionStorage?.setItem(FUSION_RELOAD_MARKER, "1");
1693
+ } catch {}
1694
+ globalThis.location?.reload();
1695
+ })();
1696
+ }
1624
1697
  /** The page atom, when the page carries one (it always does on a fusion page). */
1625
1698
  function uiState() {
1626
1699
  const state = globalThis.__SUPERD_UI_STATE__;
@@ -3880,6 +3953,38 @@ function HubPage() {
3880
3953
  });
3881
3954
  }
3882
3955
 
3956
+ //#endregion
3957
+ //#region src/client/pill-geometry.ts
3958
+ /**
3959
+ * Derive the scroll-invariant offsets from one same-frame measurement.
3960
+ * Measuring the DELTAS (not absolute coordinates) is the whole point: they
3961
+ * survive any scroll of any ancestor, so nothing needs to re-run while the
3962
+ * sidebar scrolls.
3963
+ */
3964
+ function measurePillBox(input) {
3965
+ return {
3966
+ dx: input.row.right - input.wrap.left,
3967
+ cy: (input.row.top + input.row.bottom) / 2 - input.wrap.top
3968
+ };
3969
+ }
3970
+ /** The row's own horizontal padding (native `.panelRow`): the selector's inset. */
3971
+ const PILL_ROW_INSET = 8;
3972
+ /**
3973
+ * The pill's placement, wrapper-relative: its right edge sits `inset` px
3974
+ * inside the row's right edge, vertically centered on the row
3975
+ * (`translateY(-50%)`). `selectorWidth` is the render-time pill width (the
3976
+ * mark is present only while an agent is active), so it stays a render
3977
+ * concern; the measured box is not.
3978
+ */
3979
+ function pillStyle(box, selectorWidth, inset = PILL_ROW_INSET) {
3980
+ return {
3981
+ position: "absolute",
3982
+ left: box.dx - inset - selectorWidth,
3983
+ top: box.cy,
3984
+ transform: "translateY(-50%)"
3985
+ };
3986
+ }
3987
+
3883
3988
  //#endregion
3884
3989
  //#region src/client/HubPanelIcon.tsx
3885
3990
  /** Runtime-mark edge inside the selector, and the chevron's own default edge. */
@@ -3893,8 +3998,6 @@ const CHEVRON_SIZE = 14;
3893
3998
  const SELECTOR_HEIGHT = 28;
3894
3999
  const SELECTOR_PAD = 8;
3895
4000
  const SELECTOR_GAP = 4;
3896
- /** The row's own horizontal padding (native `.panelRow`): the selector's inset. */
3897
- const ROW_INSET = 8;
3898
4001
  function HubPanelIcon({ size }) {
3899
4002
  const wide = size <= 16;
3900
4003
  const rootRef = react.useRef(null);
@@ -3917,16 +4020,25 @@ function HubPanelIcon({ size }) {
3917
4020
  }, [fusion]);
3918
4021
  const measure = react.useCallback(() => {
3919
4022
  const row = rootRef.current?.closest("button") ?? null;
3920
- if (row === null) {
4023
+ const wrap = selectorRef.current?.parentElement ?? null;
4024
+ if (row === null || wrap === null) {
3921
4025
  setBox(null);
3922
4026
  return;
3923
4027
  }
3924
- const rect = row.getBoundingClientRect();
3925
- setBox((prev) => prev !== null && prev.top === rect.top && prev.bottom === rect.bottom && prev.right === rect.right ? prev : {
3926
- top: rect.top,
3927
- bottom: rect.bottom,
3928
- right: rect.right
4028
+ const rowRect = row.getBoundingClientRect();
4029
+ const wrapRect = wrap.getBoundingClientRect();
4030
+ const next = measurePillBox({
4031
+ row: {
4032
+ top: rowRect.top,
4033
+ bottom: rowRect.bottom,
4034
+ right: rowRect.right
4035
+ },
4036
+ wrap: {
4037
+ left: wrapRect.left,
4038
+ top: wrapRect.top
4039
+ }
3929
4040
  });
4041
+ setBox((prev) => prev !== null && prev.dx === next.dx && prev.cy === next.cy ? prev : next);
3930
4042
  }, []);
3931
4043
  react.useLayoutEffect(() => {
3932
4044
  if (!wide || !switchUi.available) return;
@@ -4036,7 +4148,7 @@ function HubPanelIcon({ size }) {
4036
4148
  children: [
4037
4149
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HubGlyph, { size }),
4038
4150
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SuperdToastHost, {}),
4039
- wide && box !== null && switchUi.available && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.Menu, {
4151
+ wide && switchUi.available && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__deepseek_ai_dsh_client_ui_primitives.Menu, {
4040
4152
  open,
4041
4153
  onClose: () => {
4042
4154
  setOpen(false);
@@ -4057,10 +4169,11 @@ function HubPanelIcon({ size }) {
4057
4169
  "aria-expanded": open,
4058
4170
  title: activeLabel === void 0 ? "Agent selector" : `Agent selector: ${activeLabel}`,
4059
4171
  style: {
4060
- position: "fixed",
4061
- left: box.right - ROW_INSET - selectorWidth,
4062
- top: box.top + (box.bottom - box.top) / 2,
4063
- transform: "translateY(-50%)",
4172
+ ...pillStyle(box ?? {
4173
+ dx: 0,
4174
+ cy: 0
4175
+ }, selectorWidth),
4176
+ visibility: box === null ? "hidden" : "visible",
4064
4177
  display: "inline-flex",
4065
4178
  alignItems: "center",
4066
4179
  justifyContent: "center",
@@ -4105,9 +4218,17 @@ const inject = ["slots"];
4105
4218
  * absent (a composition without the sidebar renders nothing — every seat
4106
4219
  * here is an optional occupant by contract).
4107
4220
  *
4108
- * @param ctx - client root context.
4221
+ * Live-install staleness: the fusion flag is baked into the SERVED index, so
4222
+ * a page that booted before super-dsh was installed carries no flag even
4223
+ * though this very apply is the hot-loaded client half — the Hub row would
4224
+ * render with every switch affordance hidden until a manual restart. When
4225
+ * the flag is absent the entry probes the roster's `hub.fusion` once and
4226
+ * re-boots the page on an armed host (switch.ts `probeStaleFusionPage`; the
4227
+ * sessionStorage marker bounds it to one reload per tab session). A flag-off
4228
+ * deployment answers `false` and keeps the T-E inert shape with no reload.
4109
4229
  */
4110
4230
  function apply(ctx) {
4231
+ if (!fusionPage()) probeStaleFusionPage();
4111
4232
  ctx.inject(["slots"], (raw) => {
4112
4233
  const scope = raw;
4113
4234
  scope.effect(() => scope.slots.inject("main", () => scope.slots.register({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "super-dsh",
3
- "version": "0.3.1",
3
+ "version": "0.3.2-d",
4
4
  "description": "Super D for the DeepSeek Harness (DSH) — one dsh plugin that mounts the superd hub (runtime selector, roster, per-runtime agents) and joins local foreign-agent runtimes (OMP, Codex, Claude, Pi, Hermes, Antigravity) into the DSH Web UI. Each runtime keeps its native home and session store; the hub only bridges.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,35 @@
1
+ {
2
+ "format": 1,
3
+ "name": "superd-run",
4
+ "ver": "0.3.1-d.b596",
5
+ "protocol": 1,
6
+ "targets": {
7
+ "aarch64-apple-darwin": {
8
+ "file": "superd-run",
9
+ "bytes": 337808,
10
+ "sha256": "a8fd11a5e6a2cb146deb599414434a299ebf78c53cfc1d3e5f42617ee11c1706"
11
+ },
12
+ "aarch64-unknown-linux-musl": {
13
+ "file": "superd-run",
14
+ "bytes": 397592,
15
+ "sha256": "3a8660fa099f1e71de6e08313ee2aaace00503f74365475ee46e2d2a89228397"
16
+ },
17
+ "x86_64-pc-windows-gnu": {
18
+ "file": "superd-run.exe",
19
+ "bytes": 337408,
20
+ "sha256": "1372450238c5bda702b4529f4148aa79e80a255c3c125d1a6229afd4693e9d90"
21
+ },
22
+ "x86_64-unknown-linux-musl": {
23
+ "file": "superd-run",
24
+ "bytes": 447152,
25
+ "sha256": "05b428657942abf22a0ad609433d5cab6b6182fe389851345459a0274b5a6533"
26
+ }
27
+ },
28
+ "sources": {
29
+ "Cargo.toml": "129ab8360e9da872f9dfd6e713d81fe1389735a74d781f3d9c15e110f92d2757",
30
+ "build.rs": "c4fb356956b1ec700e99bdeca07d657a7d3b2a4026582db136411676da3d125e",
31
+ "src/main.rs": "47f1648ea1abc30583839edab219a9062c83d57be981c0505ab6bf79c6fbff54",
32
+ "src/unix.rs": "56c5f523b7b1a9efd50ef24ccdabc024bc065dd2f904fdbecdf0ca49fe7f3393",
33
+ "src/windows.rs": "6c1537424b1adc05ed17c7cf8bf376fb5711602b9da1697d596155bf21d541da"
34
+ }
35
+ }
@@ -0,0 +1 @@
1
+ 0.3.1-d.b596
@@ -0,0 +1 @@
1
+ 0.3.1-d.b596
@@ -0,0 +1 @@
1
+ 0.3.1-d.b596
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ // Hub PTY pump — the DUMB child of the canonical PTY session over a Hub
3
+ // machine (0.3.2-c). The session (better-dsh/src/remote/pty-session.ts)
4
+ // spawns `script -qfec 'stty -echo; … exec node <this file>' /dev/null`, so
5
+ // this process's stdin/stdout ride a host-side PTY; we forward those bytes
6
+ // over one WebSocket to the peer hub's dumb PTY executor
7
+ // (/api/superd/exec/pty: one WS = one `script -qfec bash /dev/null`, text
8
+ // frames = stream bytes, {"op":…} JSON frames = transport control, WS close
9
+ // = peer group-kill). All session intelligence (nonce framing, init
10
+ // handshake, env E-frames, two-stage interrupt, idle TTL) is in-band bytes
11
+ // produced by the SESSION — this pump never parses the stream, only the
12
+ // peer's control frames.
13
+ //
14
+ // Connection facts arrive via environment (never argv — credentials must not
15
+ // show up in `ps`):
16
+ // SUPERD_HUB_PTY_URL wss://…/api/superd/exec/pty (peer executor)
17
+ // SUPERD_HUB_PTY_COOKIE pairing cookie for the upgrade request
18
+ // SUPERD_HUB_PTY_WS ABSOLUTE path to a usable `ws` module (resolved by
19
+ // the caller before spawning; no resolution gamble
20
+ // here — a missing module is a creation-time error)
21
+ //
22
+ // Verbatim-asset discipline (helper-bin precedent): this file is copied
23
+ // byte-for-byte into lib/remote/ and the Super closure; no build step
24
+ // transforms it. Crash-proof by construction (mesh-gateway lesson): the
25
+ // 'error' listener is registered before anything can reject, and post-close
26
+ // sends are swallowed — the session's death path owns the teardown.
27
+ const PUMP_ENV_PREFIX = 'SUPERD_HUB_PTY_'
28
+ const [url, cookie, wsPath] = ['URL', 'COOKIE', 'WS'].map((k) => process.env[`SUPERD_HUB_PTY_${k}`])
29
+
30
+ // cookie may be legitimately empty (an unauthenticated test lane sends no header);
31
+ // the endpoint URL and the ws module path are the hard requirements.
32
+ if (url === undefined || url === '' || wsPath === undefined || wsPath === '') {
33
+ process.stderr.write(`hub-pty-pump: missing environment (${PUMP_ENV_PREFIX}URL/WS)\n`)
34
+ process.exit(1)
35
+ }
36
+
37
+ let WebSocket
38
+ try {
39
+ const require = (await import('node:module')).createRequire(import.meta.url)
40
+ const mod = require(wsPath)
41
+ WebSocket = typeof mod === 'function' ? mod : mod.default
42
+ } catch (err) {
43
+ process.stderr.write(`hub-pty-pump: cannot load ws module at ${wsPath} — ${err instanceof Error ? err.message : String(err)}\n`)
44
+ process.exit(1)
45
+ }
46
+ if (typeof WebSocket !== 'function') {
47
+ process.stderr.write('hub-pty-pump: the ws module did not yield a WebSocket constructor\n')
48
+ process.exit(1)
49
+ }
50
+
51
+ const socket = new WebSocket(url, { headers: cookie ? { cookie } : {} })
52
+ let opened = false
53
+ let forward = true
54
+
55
+ socket.on('error', (err) => {
56
+ // Always-on listener: an ECONNREFUSED or a rejected 401 upgrade must be a
57
+ // reported death, never an uncaught exception.
58
+ process.stderr.write(`hub-pty-pump: ${opened ? 'socket error' : 'connect failed'} — ${err instanceof Error ? err.message : String(err)}\n`)
59
+ })
60
+ socket.on('open', () => { opened = true; pumpStdin() })
61
+ socket.on('message', (data) => {
62
+ if (!forward) return
63
+ const text = typeof data === 'string' ? data : Array.isArray(data) ? Buffer.concat(data).toString('utf8') : Buffer.from(data).toString('utf8')
64
+ // Transport control frames (peer: {"op":"exit"} / {"op":"spawn-error"}) are
65
+ // addressed to THIS pump, not to the shell stream — the exit frame is
66
+ // followed by a socket close, which settles us below.
67
+ if (text.startsWith('{"op":')) {
68
+ try {
69
+ const parsed = JSON.parse(text)
70
+ if (typeof parsed.op === 'string') {
71
+ if (parsed.op === 'spawn-error' && typeof parsed.error === 'string') process.stderr.write(`hub-pty-pump: peer could not spawn the terminal — ${parsed.error}\n`)
72
+ return
73
+ }
74
+ } catch { /* not JSON after all: fall through and forward */ }
75
+ }
76
+ process.stdout.write(text)
77
+ })
78
+ socket.on('close', () => {
79
+ forward = false
80
+ // Before open this is a failed connection (diag already on stderr); after
81
+ // open it is the peer session ending — either way the child exiting is the
82
+ // session's dead signal.
83
+ process.exit(opened ? 0 : 1)
84
+ })
85
+
86
+ function pumpStdin() {
87
+ process.stdin.setEncoding('utf8')
88
+ process.stdin.on('data', (chunk) => {
89
+ if (!opened) return
90
+ try { socket.send(chunk) } catch { /* closing: the close handler exits us */ }
91
+ })
92
+ // The session's kill path tears down the process group; a plain stdin end
93
+ // (no kill) still means nobody will type more — close politely so the peer
94
+ // reaps its side.
95
+ process.stdin.on('end', () => { try { socket.close() } catch { /* already closing */ } })
96
+ process.stdin.on('error', () => { /* EPIPE on teardown: the close path owns the exit */ })
97
+ }