dsh-ssh-hub 0.0.0-stage → 0.2.0

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 (133) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +271 -2
  3. package/cordis.patch.yml +16 -0
  4. package/icon.svg +3 -0
  5. package/lib/client.js +13975 -0
  6. package/lib/index.js +6908 -0
  7. package/lib/types/activity/history.d.ts +50 -0
  8. package/lib/types/alerting/notify.d.ts +89 -0
  9. package/lib/types/alerting/prompt-summary.d.ts +28 -0
  10. package/lib/types/alerting/rules.d.ts +135 -0
  11. package/lib/types/alerting/tools.d.ts +30 -0
  12. package/lib/types/audit/audit-log.d.ts +84 -0
  13. package/lib/types/audit/recorder.d.ts +50 -0
  14. package/lib/types/client/api.d.ts +222 -0
  15. package/lib/types/client/index.d.ts +45 -0
  16. package/lib/types/client/locales.d.ts +319 -0
  17. package/lib/types/client/native-panel.d.ts +70 -0
  18. package/lib/types/client/panel/ClusterTab.d.ts +7 -0
  19. package/lib/types/client/panel/DeployTab.d.ts +10 -0
  20. package/lib/types/client/panel/FleetTab.d.ts +10 -0
  21. package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
  22. package/lib/types/client/panel/HostsTab.d.ts +25 -0
  23. package/lib/types/client/panel/LogsTab.d.ts +10 -0
  24. package/lib/types/client/panel/SshPanel.d.ts +14 -0
  25. package/lib/types/client/panel/TerminalTab.d.ts +27 -0
  26. package/lib/types/client/panel/TransferTab.d.ts +7 -0
  27. package/lib/types/client/panel/TunnelEditDialog.d.ts +15 -0
  28. package/lib/types/client/panel/TunnelsTab.d.ts +27 -0
  29. package/lib/types/client/panel/controller.d.ts +253 -0
  30. package/lib/types/client/panel/helpers.d.ts +45 -0
  31. package/lib/types/client/panel/tabs.d.ts +62 -0
  32. package/lib/types/client/panel/xterm.css.d.ts +2 -0
  33. package/lib/types/client/settings-binding.d.ts +71 -0
  34. package/lib/types/deploy/orchestrator.d.ts +158 -0
  35. package/lib/types/deploy/tools.d.ts +14 -0
  36. package/lib/types/dsh-home.d.ts +16 -0
  37. package/lib/types/engine/cluster.d.ts +19 -0
  38. package/lib/types/engine/connection-pool.d.ts +183 -0
  39. package/lib/types/engine/proxy-command.d.ts +36 -0
  40. package/lib/types/engine/pty.d.ts +32 -0
  41. package/lib/types/engine/sftp.d.ts +20 -0
  42. package/lib/types/engine/terminal-sessions.d.ts +67 -0
  43. package/lib/types/engine/tunnel-discovery.d.ts +89 -0
  44. package/lib/types/engine/tunnel-remarks.d.ts +49 -0
  45. package/lib/types/engine/tunnel.d.ts +76 -0
  46. package/lib/types/engine.d.ts +103 -0
  47. package/lib/types/http.d.ts +59 -0
  48. package/lib/types/index.d.ts +128 -0
  49. package/lib/types/inspect/checks.d.ts +118 -0
  50. package/lib/types/inspect/inspection.d.ts +111 -0
  51. package/lib/types/inspect/tools.d.ts +50 -0
  52. package/lib/types/logs/search.d.ts +131 -0
  53. package/lib/types/logs/tools.d.ts +6 -0
  54. package/lib/types/loopback.d.ts +64 -0
  55. package/lib/types/monitor/loop.d.ts +133 -0
  56. package/lib/types/monitor/metrics.d.ts +151 -0
  57. package/lib/types/mount-once.d.ts +55 -0
  58. package/lib/types/protocol.d.ts +524 -0
  59. package/lib/types/routes.d.ts +82 -0
  60. package/lib/types/security/known-hosts.d.ts +153 -0
  61. package/lib/types/security/master-secret.d.ts +157 -0
  62. package/lib/types/security/redact.d.ts +44 -0
  63. package/lib/types/security/secrets.d.ts +70 -0
  64. package/lib/types/ssh-config.d.ts +42 -0
  65. package/lib/types/store.d.ts +183 -0
  66. package/lib/types/tool-surface.d.ts +72 -0
  67. package/lib/types/tools.d.ts +56 -0
  68. package/locale/en.json +6 -0
  69. package/locale/zh.json +6 -0
  70. package/package.json +126 -6
  71. package/src/activity/history.ts +117 -0
  72. package/src/alerting/notify.ts +212 -0
  73. package/src/alerting/prompt-summary.ts +71 -0
  74. package/src/alerting/rules.ts +281 -0
  75. package/src/alerting/tools.ts +263 -0
  76. package/src/audit/audit-log.ts +199 -0
  77. package/src/audit/recorder.ts +73 -0
  78. package/src/client/api.ts +782 -0
  79. package/src/client/css-modules.d.ts +5 -0
  80. package/src/client/index.ts +150 -0
  81. package/src/client/locales.ts +654 -0
  82. package/src/client/native-panel.tsx +141 -0
  83. package/src/client/panel/ClusterTab.tsx +141 -0
  84. package/src/client/panel/DeployTab.tsx +314 -0
  85. package/src/client/panel/FleetTab.tsx +494 -0
  86. package/src/client/panel/HostFormDialog.tsx +289 -0
  87. package/src/client/panel/HostsTab.tsx +395 -0
  88. package/src/client/panel/LogsTab.tsx +208 -0
  89. package/src/client/panel/SshPanel.tsx +105 -0
  90. package/src/client/panel/TerminalTab.tsx +550 -0
  91. package/src/client/panel/TransferTab.tsx +238 -0
  92. package/src/client/panel/TunnelEditDialog.tsx +174 -0
  93. package/src/client/panel/TunnelsTab.tsx +328 -0
  94. package/src/client/panel/controller.ts +507 -0
  95. package/src/client/panel/helpers.ts +84 -0
  96. package/src/client/panel/panel.module.css +1734 -0
  97. package/src/client/panel/tabs.ts +52 -0
  98. package/src/client/panel/xterm.css.ts +2 -0
  99. package/src/client/settings-binding.ts +184 -0
  100. package/src/deploy/orchestrator.ts +326 -0
  101. package/src/deploy/tools.ts +225 -0
  102. package/src/dsh-home.ts +42 -0
  103. package/src/engine/cluster.ts +60 -0
  104. package/src/engine/connection-pool.ts +721 -0
  105. package/src/engine/proxy-command.ts +248 -0
  106. package/src/engine/pty.ts +78 -0
  107. package/src/engine/sftp.ts +229 -0
  108. package/src/engine/terminal-sessions.ts +280 -0
  109. package/src/engine/tunnel-discovery.ts +353 -0
  110. package/src/engine/tunnel-remarks.ts +120 -0
  111. package/src/engine/tunnel.ts +300 -0
  112. package/src/engine.ts +195 -0
  113. package/src/http.ts +127 -0
  114. package/src/index.ts +690 -0
  115. package/src/inspect/checks.ts +251 -0
  116. package/src/inspect/inspection.ts +321 -0
  117. package/src/inspect/tools.ts +366 -0
  118. package/src/logs/search.ts +251 -0
  119. package/src/logs/tools.ts +160 -0
  120. package/src/loopback.ts +119 -0
  121. package/src/monitor/loop.ts +265 -0
  122. package/src/monitor/metrics.ts +333 -0
  123. package/src/mount-once.ts +142 -0
  124. package/src/protocol.ts +534 -0
  125. package/src/routes.ts +998 -0
  126. package/src/security/known-hosts.ts +342 -0
  127. package/src/security/master-secret.ts +334 -0
  128. package/src/security/redact.ts +119 -0
  129. package/src/security/secrets.ts +152 -0
  130. package/src/ssh-config.ts +182 -0
  131. package/src/store.ts +757 -0
  132. package/src/tool-surface.ts +96 -0
  133. package/src/tools.ts +550 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Native panel registration for the SSH panel.
3
+ *
4
+ * The panel is an official-style center-column page, not a DOM takeover: it
5
+ * contributes a row into the sidebar shell's own global panel list
6
+ * (`sidebar.panellist`) and its page into the layout's keyed `main` slot. The
7
+ * shell then owns the row box, the label, the active highlight, the collapsed
8
+ * rail and the panel switch, exactly as it does for the shipped Plugins and
9
+ * Schedule pages and for the task board and the skill center.
10
+ *
11
+ * Both registrations go through `ctx.slots.inject`, which fires only once the
12
+ * owning shell entry has declared the seat: load order between this plugin and
13
+ * ui-layout / ui-sidebar therefore does not matter, and neither does a shell
14
+ * that cannot serve the seats (the callback simply never runs).
15
+ *
16
+ * The terminal's PTY shell lives on the host and outlives this page (see
17
+ * engine/terminal-sessions.ts), so the layout unmounting a deselected page
18
+ * costs the view its xterm instance, not the remote session: the terminal tab
19
+ * reattaches by session id when the page mounts again.
20
+ *
21
+ * @module @linxin666/dsh-client-ssh/client
22
+ */
23
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
24
+ import type { SshApi } from './api.ts';
25
+ import { SSH_PANEL_ID, type PanelController } from './panel/controller.ts';
26
+ import { type TerminalFontSource } from './panel/helpers.ts';
27
+ /** The panel id shared by the sidebar row and the main-slot occupant. */
28
+ export { SSH_PANEL_ID };
29
+ /**
30
+ * The sidebar row glyph the shell asks for at its own size and active state.
31
+ * The shell owns the button, label, tooltip and rail geometry; this component
32
+ * draws only the glyph, like every other panel row.
33
+ *
34
+ * The glyph carries `data-dsh-panel-entry` because it is the only DOM this
35
+ * panel's own code owns inside that shell-owned row: the L2 contract (skins)
36
+ * resolves which row belongs to which plugin through it, since the shell
37
+ * stamps no per-entry hook of its own (see contracts/semantic-attrs-v1.md).
38
+ * @param props - the shell's icon share: square edge and selection state.
39
+ * @returns the decorative terminal glyph.
40
+ */
41
+ export declare function SshPanelIcon({ size }: {
42
+ size: number;
43
+ active: boolean;
44
+ }): React.ReactElement;
45
+ /**
46
+ * The main-slot page. The layout mounts it only while this panel is selected;
47
+ * the wrapper carries the pinned `data-dsh-ssh-view` semantic anchor (L2
48
+ * contract, skins) the takeover container used to own.
49
+ * @param props - the framework main-slot share plus this entry's injected face.
50
+ * @returns the SSH panel page.
51
+ */
52
+ export declare function SshPanelPage({ controller, api, terminalFont }: {
53
+ controller: PanelController;
54
+ api: SshApi;
55
+ terminalFont?: TerminalFontSource;
56
+ }): React.ReactElement;
57
+ /**
58
+ * Register the SSH panel's sidebar row and center-column page.
59
+ *
60
+ * Both seats are declared by shell plugins this package does not depend on at
61
+ * runtime, so each registration is wrapped in `ctx.slots.inject`: the callback
62
+ * runs only after the owning entry declares the seat, and a shell that never
63
+ * declares it leaves the panel simply absent instead of failing boot.
64
+ * @param ctx - client root context (services: slots).
65
+ * @param controller - the controller the page and the row drive.
66
+ * @param api - the SSH API client the page operates through.
67
+ * @param terminalFont - live terminal-font setting source (issue #577).
68
+ * @returns disposer releasing both registrations.
69
+ */
70
+ export declare function registerSshPanel(ctx: ClientContext, controller: PanelController, api: SshApi, terminalFont?: TerminalFontSource): () => void;
@@ -0,0 +1,7 @@
1
+ import type { SshApi } from '../api.ts';
2
+ /** Cluster tab props. */
3
+ export interface ClusterTabProps {
4
+ api: SshApi;
5
+ }
6
+ /** The cluster execution tab. */
7
+ export declare function ClusterTab({ api }: ClusterTabProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { SshApi } from '../api.ts';
2
+ /** Deploy tab props. */
3
+ export interface DeployTabProps {
4
+ /** The SSH API client. */
5
+ api: SshApi;
6
+ /** Whether the panel is open, so refreshes only run while visible. */
7
+ active: boolean;
8
+ }
9
+ /** The deploy tab. */
10
+ export declare function DeployTab({ api, active }: DeployTabProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { SshApi } from '../api.ts';
2
+ /** Fleet tab props. */
3
+ export interface FleetTabProps {
4
+ /** The SSH API client. */
5
+ api: SshApi;
6
+ /** Whether the panel is open, so refreshes only run while visible. */
7
+ active: boolean;
8
+ }
9
+ /** The fleet monitoring tab. */
10
+ export declare function FleetTab({ api, active }: FleetTabProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { SshApi } from '../api.ts';
2
+ import type { SshHostSummary } from '../../protocol.ts';
3
+ /** Host form dialog props. */
4
+ export interface HostFormDialogProps {
5
+ api: SshApi;
6
+ /** The host being edited; null/undefined means create. */
7
+ editing?: SshHostSummary | null;
8
+ onClose: () => void;
9
+ onSaved: (host: SshHostSummary) => void;
10
+ }
11
+ /** The create/edit host modal. */
12
+ export declare function HostFormDialog({ api, editing, onClose, onSaved }: HostFormDialogProps): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { SshApi } from '../api.ts';
2
+ import type { SshHostSummary } from '../../protocol.ts';
3
+ /** Hosts tab props. */
4
+ export interface HostsTabProps {
5
+ api: SshApi;
6
+ /** Connect the given alias in the terminal tab. */
7
+ onConnect: (alias: string) => void;
8
+ }
9
+ /** Host list grouping modes (#379). */
10
+ export type HostGroupBy = 'none' | 'environment' | 'tags';
11
+ /** One collapsible group section of the grouped host list. */
12
+ export interface HostGroup {
13
+ /** Group key: the environment name, one tag, or '' for the ungrouped bucket. */
14
+ key: string;
15
+ hosts: SshHostSummary[];
16
+ }
17
+ /**
18
+ * Bucket hosts into collapsible groups (#379). Grouping by tags places a
19
+ * multi-tag host in every one of its tag groups (folder view); hosts without
20
+ * the grouping key land in the '' bucket, which always sorts last. Groups
21
+ * sort alphabetically; host order inside a group follows the API listing.
22
+ */
23
+ export declare function groupHosts(hosts: SshHostSummary[], groupBy: HostGroupBy): HostGroup[];
24
+ /** The hosts table plus its toolbar and dialogs. */
25
+ export declare function HostsTab({ api, onConnect }: HostsTabProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import type { SshApi } from '../api.ts';
2
+ /** Logs tab props. */
3
+ export interface LogsTabProps {
4
+ /** The SSH API client. */
5
+ api: SshApi;
6
+ /** Whether the panel is open, so refreshes only run while visible. */
7
+ active: boolean;
8
+ }
9
+ /** The logs tab. */
10
+ export declare function LogsTab({ api, active }: LogsTabProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { SshApi } from '../api.ts';
2
+ import type { PanelController } from './controller.ts';
3
+ import { type TerminalFontSource } from './helpers.ts';
4
+ /** Panel shell props. */
5
+ export interface SshPanelProps {
6
+ /** The panel state owner (open/close/toggle, active tab, terminal session). */
7
+ controller: PanelController;
8
+ /** The SSH API client every tab operates through. */
9
+ api: SshApi;
10
+ /** Live terminal-font setting source handed to the terminal tab (issue #577). */
11
+ terminalFont?: TerminalFontSource;
12
+ }
13
+ /** The tabbed SSH panel. */
14
+ export declare function SshPanel({ controller, api, terminalFont }: SshPanelProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import type { SshApi } from '../api.ts';
2
+ import type { PanelController } from './controller.ts';
3
+ import { type TerminalFontSource } from './helpers.ts';
4
+ /** Terminal tab props. */
5
+ export interface TerminalTabProps {
6
+ api: SshApi;
7
+ /** The panel controller that owns the tabs and their host session ids. */
8
+ controller: PanelController;
9
+ /** Alias preselected by a "connect" action from the hosts tab. */
10
+ presetAlias?: string;
11
+ /**
12
+ * Live terminal-font setting source (issue #577). Absent in tests and
13
+ * legacy mounts: the font then comes from the CSS custom-property chain.
14
+ */
15
+ terminalFont?: TerminalFontSource;
16
+ }
17
+ /**
18
+ * Whether the visible challenge form may answer on the bound socket: the form
19
+ * and the socket must belong to the same tab. Both are read at submit time, and
20
+ * the window between a tab switch's commit and the effect that rebinds the
21
+ * socket is exactly when they can disagree.
22
+ * @param linkTabId - the tab the bound socket belongs to.
23
+ * @param formTabId - the tab whose challenge form is on screen.
24
+ */
25
+ export declare function challengeBelongsToLink(linkTabId: string | undefined, formTabId: string | undefined): boolean;
26
+ /** The terminal view with its tab strip. */
27
+ export declare function TerminalTab({ api, controller, presetAlias, terminalFont }: TerminalTabProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { SshApi } from '../api.ts';
2
+ /** Transfer tab props. */
3
+ export interface TransferTabProps {
4
+ api: SshApi;
5
+ }
6
+ /** The upload/download tab. */
7
+ export declare function TransferTab({ api }: TransferTabProps): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import type { SshApi } from '../api.ts';
2
+ import type { TunnelInfo } from '../../protocol.ts';
3
+ /** Tunnel edit dialog props. */
4
+ export interface TunnelEditDialogProps {
5
+ api: SshApi;
6
+ /** The tunnel being edited. */
7
+ tunnel: TunnelInfo;
8
+ onClose: () => void;
9
+ /** Receives the outcome text so the tab can announce it once. */
10
+ onSaved: (notice: string) => void;
11
+ }
12
+ /** Whether this forward can be re-pointed from the panel. */
13
+ export declare function isEditableRouting(tunnel: TunnelInfo): boolean;
14
+ /** The tunnel edit modal. */
15
+ export declare function TunnelEditDialog({ api, tunnel, onClose, onSaved }: TunnelEditDialogProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ import type { SshApi } from '../api.ts';
2
+ import type { TunnelInfo } from '../../protocol.ts';
3
+ /** Live-tunnel polling interval while the tab and page are visible (ms). */
4
+ export declare const TUNNEL_POLL_MS = 5000;
5
+ /**
6
+ * Return `next` only when the tunnel list changed in a user-visible way
7
+ * (identity, ordering or any renderable field), else `null` so a poll tick
8
+ * with no real change keeps the previous reference and React skips the
9
+ * re-render. `prev === null` (first load) always accepts the list.
10
+ */
11
+ export declare function diffTunnels(prev: TunnelInfo[] | null, next: TunnelInfo[]): TunnelInfo[] | null;
12
+ /** Tunnels tab props. */
13
+ export interface TunnelsTabProps {
14
+ api: SshApi;
15
+ /** Pause automatic reads while the owning panel is closed, preserving form state. */
16
+ active?: boolean;
17
+ }
18
+ /** The tunnels tab. */
19
+ /**
20
+ * Whether any forward is one this plugin can stop.
21
+ *
22
+ * External forwards belong to processes we did not start, so "Stop all" must not
23
+ * be offered when they are all there is: the button would look enabled and do
24
+ * nothing. Kept as a pure function so the rule can be asserted without a browser.
25
+ */
26
+ export declare function hasOwnedTunnels(tunnels: TunnelInfo[] | null): boolean;
27
+ export declare function TunnelsTab({ api, active }: TunnelsTabProps): import("react").JSX.Element;
@@ -0,0 +1,253 @@
1
+ /**
2
+ * SSH panel controller: the single owner of the panel's view state.
3
+ *
4
+ * Framework-free (structural runtime faces, task-board core/controller.ts
5
+ * style) so the sidebar row and the React panel share one tiny subscription
6
+ * surface. The state lives only for the browser session (no persistence).
7
+ *
8
+ * The active tab, the hosts-tab connect request, the terminal tabs and their
9
+ * host session ids live here rather than inside the panel components: the
10
+ * layout mounts a keyed page only while its panel is selected, so
11
+ * component-local state would reset the tab on every panel switch and lose
12
+ * the ids a reattach needs.
13
+ *
14
+ * Terminal tabs (issue #1950) are records, not sockets. One tab is the tab
15
+ * shown in the single xterm; a tab that is not shown either owns a detached
16
+ * host session (reattached by id, which replays the host scrollback) or no
17
+ * session at all. The controller is also the place where a still-connecting
18
+ * socket is adopted when a view goes away: a connection that has not reported
19
+ * its session id yet cannot be detached, so dropping it would leave the host
20
+ * PTY with no owner (the orphan the reference implementation produced).
21
+ */
22
+ import type { TerminalConnection } from '../api.ts';
23
+ /** The panel's tab identifiers. */
24
+ export type SshTab = 'hosts' | 'terminal' | 'transfer' | 'tunnels' | 'cluster' | 'deploy' | 'logs' | 'fleet';
25
+ /** Stable id shared by the sidebar panel row and the main-slot page. */
26
+ export declare const SSH_PANEL_ID = "ssh";
27
+ /** Lifecycle of one terminal tab. */
28
+ export type TerminalTabStatus =
29
+ /** Socket open, the host has not reported a session id yet. */
30
+ 'connecting'
31
+ /** The host reported a session id; the shell is live. */
32
+ | 'connected'
33
+ /** The remote shell ended. The tab keeps its screen; the session id is cleared. */
34
+ | 'exited'
35
+ /** The connection failed. The tab keeps the reason; the session id is cleared. */
36
+ | 'error';
37
+ /** A keyboard-interactive challenge waiting for this tab's answer. */
38
+ export interface TerminalAuthPrompt {
39
+ name: string;
40
+ instructions: string;
41
+ prompts: Array<{
42
+ prompt: string;
43
+ echo: boolean;
44
+ }>;
45
+ }
46
+ /** One terminal tab, independent of the socket that currently serves it. */
47
+ export interface TerminalTabRecord {
48
+ /** Local tab id, stable across panel switches (never the host session id). */
49
+ id: string;
50
+ /** Host alias this tab opened. Several tabs may share one alias. */
51
+ alias: string;
52
+ status: TerminalTabStatus;
53
+ /** Host-side PTY session id, present only while the shell is live. */
54
+ sessionId?: string;
55
+ /** Exit or failure text for the `exited` / `error` states. */
56
+ detail?: string;
57
+ /** Code of a close that never reached the host; the tab is kept. */
58
+ closeError?: string;
59
+ /** Challenge captured for this tab, whoever was on screen when it arrived. */
60
+ authPrompt?: TerminalAuthPrompt;
61
+ /**
62
+ * The answer being typed for {@link TerminalTabRecord.authPrompt}, owned by
63
+ * this tab: one shared draft let a challenge on tab B inherit (and submit)
64
+ * the characters typed for tab A.
65
+ */
66
+ authAnswers?: string[];
67
+ }
68
+ /** The terminal fields a later step may change on one tab. */
69
+ export type TerminalTabPatch = Omit<TerminalTabRecord, 'id' | 'alias'>;
70
+ /** What to do with an adopted connection once the host reports its session. */
71
+ export type TerminalLinkIntent = 'detach' | 'close';
72
+ /** Immutable controller snapshot for UI subscriptions. */
73
+ export interface PanelControllerSnapshot {
74
+ /** Whether the center column shows this panel. */
75
+ panelOpen: boolean;
76
+ /** The tab the panel is showing. */
77
+ activeTab: SshTab;
78
+ /** Every terminal tab, in strip order. */
79
+ terminalTabs: readonly TerminalTabRecord[];
80
+ /** The tab the single xterm is bound to, or undefined when there is none. */
81
+ activeTerminalTabId: string | undefined;
82
+ /** Host picked in the terminal toolbar; the next tab opens on it. */
83
+ draftAlias: string;
84
+ }
85
+ /**
86
+ * The layout's panel-navigation face: selecting the panel is the layout's
87
+ * business, and this is the one call that asks for it (null returns the column
88
+ * to the conversation). Optional, so a shell-less composition keeps the pure
89
+ * state transitions testable.
90
+ */
91
+ export interface PanelNavigationFace {
92
+ /** Select this panel, or null to hand the column back to the conversation. */
93
+ select(panelId: string | null): void;
94
+ }
95
+ /** Controller dependencies. */
96
+ export interface PanelControllerDeps {
97
+ /** Layout panel selection; absent keeps the controller state-only. */
98
+ panel?: PanelNavigationFace;
99
+ }
100
+ /** The panel state owner the sidebar row and the view both read. */
101
+ export declare class PanelController {
102
+ private readonly deps;
103
+ private panelOpen;
104
+ private activeTab;
105
+ private terminalTabs;
106
+ private activeTerminalTabId;
107
+ private draftAlias;
108
+ private nextTerminalTabSeq;
109
+ private listeners;
110
+ /**
111
+ * Last screen of each tab, kept outside the snapshot: terminal output must
112
+ * not re-render the panel on every chunk, and only the terminal view reads
113
+ * this (when a tab has no session left to replay from).
114
+ */
115
+ private readonly retainedScreens;
116
+ /**
117
+ * Sockets that outlived their view while still connecting. Their session id
118
+ * is unknown, so they cannot be detached yet; keeping them here is what
119
+ * prevents a host PTY with no owner.
120
+ */
121
+ private readonly adoptedLinks;
122
+ /** Cached so getSnapshot is referentially stable between changes. */
123
+ private snapshot;
124
+ constructor(deps?: PanelControllerDeps);
125
+ getSnapshot(): PanelControllerSnapshot;
126
+ subscribe(fn: () => void): () => void;
127
+ /**
128
+ * Show the panel. The layout owns which panel the column renders, so the
129
+ * state flip and the selection travel together; the selection is requested
130
+ * after the snapshot flips, so a subscriber never observes "open" while the
131
+ * shell still shows the conversation.
132
+ */
133
+ open(): void;
134
+ /** Return the column to the conversation, asking the layout explicitly. */
135
+ close(): void;
136
+ toggle(): void;
137
+ /**
138
+ * Reflect a selection made outside this controller (the user clicked another
139
+ * sidebar row, or the layout dropped the panel id).
140
+ * @param panelId - the layout's current panel id, or null for the conversation.
141
+ */
142
+ syncPanelSelection(panelId: string | null): void;
143
+ /** Switch tabs, keeping every other piece of view state. */
144
+ setActiveTab(tab: SshTab): void;
145
+ /**
146
+ * Hand the terminal tab a host to connect to (the hosts-tab "connect"
147
+ * action): the tab exists before the view does, so a panel switch during the
148
+ * handshake still shows the connecting tab and adopts its socket.
149
+ * @param alias - the configured host alias.
150
+ */
151
+ requestConnect(alias: string): void;
152
+ /**
153
+ * Add a terminal tab on the alias and make it the shown one. Several tabs
154
+ * may target one alias on purpose: each owns its own host PTY.
155
+ * @param alias - the configured host alias.
156
+ * @returns the new tab id.
157
+ */
158
+ openTerminalTab(alias: string): string;
159
+ /**
160
+ * Show an existing tab and make the toolbar follow its host, so a new tab
161
+ * opens on the host the user is looking at.
162
+ * @param id - the tab id.
163
+ */
164
+ setActiveTerminalTab(id: string): void;
165
+ /**
166
+ * Remove one tab and forget its screen. When the shown tab closes, the
167
+ * neighbours decide what the xterm shows next: the tab that took its place,
168
+ * else the one before it, else nothing.
169
+ * @param id - the tab id.
170
+ */
171
+ closeTerminalTab(id: string): void;
172
+ /** The tab record with this id, or undefined when it no longer exists. */
173
+ terminalTab(id: string): TerminalTabRecord | undefined;
174
+ /**
175
+ * Apply a partial update to one tab; a tab that was closed in the meantime
176
+ * is left alone rather than resurrected.
177
+ * @param id - the tab id.
178
+ * @param patch - the fields to change.
179
+ */
180
+ patchTerminalTab(id: string, patch: Partial<TerminalTabPatch>): void;
181
+ /**
182
+ * Record the host session of a ready tab and clear the challenge it carried.
183
+ * @param id - the tab id.
184
+ * @param sessionId - the id the host reported on its ready frame.
185
+ */
186
+ readyTerminalTab(id: string, sessionId: string): void;
187
+ /**
188
+ * The remote shell ended: the tab keeps its screen and its place, and the
189
+ * dead session id is dropped so nothing tries to reattach to it.
190
+ * @param id - the tab id.
191
+ * @param detail - why it ended, when the transport said.
192
+ */
193
+ exitTerminalTab(id: string, detail?: string): void;
194
+ /**
195
+ * The connection failed. The tab stays with the reason so the user can read
196
+ * it and close the tab themselves.
197
+ * @param id - the tab id.
198
+ * @param detail - the failure text.
199
+ */
200
+ failTerminalTab(id: string, detail: string): void;
201
+ /**
202
+ * A background close never reached the host. The tab keeps its live session
203
+ * id (so a retry can still end it) and says so instead of vanishing.
204
+ * @param id - the tab id.
205
+ * @param reason - the reason code shown by the view.
206
+ */
207
+ markTerminalCloseFailed(id: string, reason: string): void;
208
+ /**
209
+ * Store the keyboard-interactive challenge this tab has to answer, with a
210
+ * blank answer of this challenge's own length. A prompt on another tab never
211
+ * touches this record, which is what keeps two challenges from sharing input.
212
+ * @param id - the tab id.
213
+ * @param prompt - the challenge the host asked for.
214
+ */
215
+ setTerminalAuthPrompt(id: string, prompt: TerminalAuthPrompt): void;
216
+ /**
217
+ * Record one character typed for this tab's challenge.
218
+ * @param id - the tab id.
219
+ * @param index - which prompt of the challenge.
220
+ * @param value - the field's current text.
221
+ */
222
+ setTerminalAuthAnswer(id: string, index: number, value: string): void;
223
+ /** Drop the challenge once it was answered, cancelled, or could not apply. */
224
+ clearTerminalAuthPrompt(id: string): void;
225
+ /** Choose the alias the next terminal tab opens on. */
226
+ setDraftAlias(alias: string): void;
227
+ /** Append one output chunk to the retained screen of a tab. */
228
+ appendTerminalOutput(id: string, chunk: string): void;
229
+ /** The retained screen of a tab, concatenated for a redraw. */
230
+ readTerminalOutput(id: string): string;
231
+ /** Forget the retained screen (a fresh replay from the host replaces it). */
232
+ clearTerminalOutput(id: string): void;
233
+ /**
234
+ * Keep a still-connecting socket alive after its view went away. The socket
235
+ * cannot be detached yet (no session id), so the intent is applied when the
236
+ * host reports it: `detach` leaves the shell for a later reattach, `close`
237
+ * ends the session of a tab the user closed.
238
+ * @param tabId - the tab the socket belongs to.
239
+ * @param connection - the live connection.
240
+ * @param intent - what to do once the session id arrives.
241
+ */
242
+ adoptTerminalLink(tabId: string, connection: TerminalConnection, intent: TerminalLinkIntent): void;
243
+ /**
244
+ * Take an adopted socket back when its tab is shown again, so the host never
245
+ * opens a second PTY for the same tab.
246
+ * @param tabId - the tab id.
247
+ * @returns the connection, or undefined when nothing was adopted.
248
+ */
249
+ reclaimTerminalLink(tabId: string): TerminalConnection | undefined;
250
+ private commit;
251
+ /** Ask the layout to select a panel; a shell without the face is a no-op. */
252
+ private selectPanel;
253
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Shared panel helpers: the active-dictionary pick (document-language based,
3
+ * task-board precedent) bound to the dsh-ssh interpolator in locales.ts, plus
4
+ * a small error-message extractor. All copy stays in the locale dictionaries.
5
+ */
6
+ import { type SshKey } from '../locales.ts';
7
+ /** Template values accepted by the interpolator. */
8
+ export type TranslateValues = Record<string, string | number>;
9
+ /** Active dictionary, picked by the document language at call time. */
10
+ export declare function dictionary(): Record<string, string>;
11
+ /** Wire the SDK translate seat; pass undefined to restore the document-language pick. */
12
+ export declare function setRuntimeTranslate(t: ((key: SshKey, values?: TranslateValues) => string) | undefined): void;
13
+ /** Translate a key with optional {name} template params (current language). */
14
+ export declare function tt(key: SshKey, values?: TranslateValues): string;
15
+ /** Human-readable error text from an unknown thrown value. */
16
+ export declare function errorMessage(error: unknown): string;
17
+ /**
18
+ * The terminal font stack used before issue #577, kept as the last resort
19
+ * when neither the plugin setting nor a CSS custom property names a font.
20
+ */
21
+ export declare const TERMINAL_FONT_FALLBACK = "Menlo, Consolas, \"Liberation Mono\", monospace";
22
+ /**
23
+ * Live source of the user's configured terminal font family: the client
24
+ * entry binds the dsh-ssh settings namespace into one of these and hands it
25
+ * to the panel, so a settings change re-applies without a remount.
26
+ */
27
+ export interface TerminalFontSource {
28
+ /** Current configured family, or undefined when unset / not yet loaded. */
29
+ get(): string | undefined;
30
+ /** Subscribe to changes; the returned function unsubscribes. */
31
+ subscribe(listener: () => void): () => void;
32
+ }
33
+ /**
34
+ * Resolve the xterm `fontFamily` (issue #577). xterm's DOM renderer takes
35
+ * the font only from constructor/options, so a plain stylesheet rule cannot
36
+ * retarget it — the value must be read back into the options. The chain,
37
+ * first non-empty value wins:
38
+ * 1. `override` — the `terminalFontFamily` plugin setting;
39
+ * 2. `--dsh-ssh-terminal-font` — dedicated hook for skins and user CSS
40
+ * (e.g. a Nerd Font for powerline glyphs);
41
+ * 3. `--ds-font-family-code` — the official code-font token several skins
42
+ * already remap;
43
+ * 4. {@link TERMINAL_FONT_FALLBACK}.
44
+ */
45
+ export declare function resolveTerminalFontFamily(override?: string): string;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The panel's tab table, in one place.
3
+ *
4
+ * It lives apart from the component so the shell and the tests read the same
5
+ * list. The bug this prevents is specific and easy to repeat: a tab component
6
+ * exists, its locale keys exist, and nothing renders it — which looks like a
7
+ * working feature in review because every file involved is correct on its own.
8
+ */
9
+ import type { SshKey } from '../locales.ts';
10
+ import type { SshTab } from './controller.ts';
11
+ /** One entry in the panel's tab bar. */
12
+ export interface SshTabSpec {
13
+ /** The tab id, also the value stored in the controller. */
14
+ id: SshTab;
15
+ /** The locale key for its label. */
16
+ labelKey: SshKey;
17
+ }
18
+ /**
19
+ * The tabs, in display order.
20
+ *
21
+ * `satisfies` rather than a plain annotation: it keeps the literal types while
22
+ * proving the array is exhaustive against {@link SshTab}, so adding a member to
23
+ * the union without adding a tab fails the type check instead of shipping a tab
24
+ * nobody can reach.
25
+ */
26
+ export declare const SSH_TABS: readonly [{
27
+ readonly id: "hosts";
28
+ readonly labelKey: "tab.hosts";
29
+ }, {
30
+ readonly id: "terminal";
31
+ readonly labelKey: "tab.terminal";
32
+ }, {
33
+ readonly id: "transfer";
34
+ readonly labelKey: "tab.transfer";
35
+ }, {
36
+ readonly id: "tunnels";
37
+ readonly labelKey: "tab.tunnels";
38
+ }, {
39
+ readonly id: "cluster";
40
+ readonly labelKey: "tab.cluster";
41
+ }, {
42
+ readonly id: "deploy";
43
+ readonly labelKey: "tab.deploy";
44
+ }, {
45
+ readonly id: "logs";
46
+ readonly labelKey: "tab.logs";
47
+ }, {
48
+ readonly id: "fleet";
49
+ readonly labelKey: "tab.fleet";
50
+ }];
51
+ /**
52
+ * Every tab id, as a set for the exhaustiveness assertion below.
53
+ *
54
+ * Written as a type-level check rather than a runtime one: a missing tab is a
55
+ * build error, not a test failure discovered later.
56
+ */
57
+ type CoveredTab = (typeof SSH_TABS)[number]['id'];
58
+ /** Compile-time proof that the table covers the union exactly. */
59
+ export type TabsCoverEveryTab = Exclude<SshTab, CoveredTab> extends never ? true : never;
60
+ /** Compile-time proof that the table adds no id outside the union. */
61
+ export type TabsAddNoUnknownTab = Exclude<CoveredTab, SshTab> extends never ? true : never;
62
+ export {};
@@ -0,0 +1,2 @@
1
+ /** xterm.css text embedded at build-authoring time (the ?raw suffix is not resolvable by the tsdown/rolldown pipeline). Generated file — see the package docs. */
2
+ export declare const XTERM_CSS: string;