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,5 @@
1
+ /** CSS Modules ambient declaration for the tsdown virtual loader. */
2
+ declare module '*.module.css' {
3
+ const classes: Record<string, string>
4
+ export default classes
5
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Browser-half entry for the dsh-ssh plugin — runs inside the dsh web GUI.
3
+ *
4
+ * Registers the dsh-ssh locale dictionaries and mounts the two DOM surfaces:
5
+ * the sidebar entry row (toggles the panel) and the SSH operations panel in
6
+ * the center column. Failure policy: DOM mounting problems are logged, never
7
+ * thrown — the web shell fails the whole boot when a plugin apply throws, and
8
+ * an external plugin must not take the GUI down.
9
+ *
10
+ * Export discipline (packages/client rule): the /client surface carries what
11
+ * cordis loading needs plus types only — all value exports stay internal.
12
+ */
13
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
14
+ // Type-only: pulls the locale plugin's Context merge (ctx.locale).
15
+ import type {} from '@deepseek-ai/dsh-client-locale/client'
16
+ // Type-only: pulls the shared-forms Context merge (ctx.configForms).
17
+ import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
18
+ // Type-only: pulls the ctx.slots merge (the renderer owns the slot registry since 0.1.2).
19
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
20
+ // Type-only: pulls the LocaleNamespaceMap merge table.
21
+ import type {} from '@deepseek-ai/dsh-client-ui-slots'
22
+ import { SshApi } from './api.ts'
23
+ import { en, zh, type SshKey } from './locales.ts'
24
+ import { registerSshPanel } from './native-panel.tsx'
25
+ import { PanelController, SSH_PANEL_ID } from './panel/controller.ts'
26
+ import type { TerminalFontSource } from './panel/helpers.ts'
27
+ import { setRuntimeTranslate } from './panel/helpers.ts'
28
+ import { bindSettingsReader } from './settings-binding.ts'
29
+
30
+
31
+ /** Locale namespace this plugin owns. */
32
+ const NS = 'dsh-ssh'
33
+
34
+ /**
35
+ * Family settings namespace the terminal-font preference is addressed by
36
+ * (issue #577); dsh-web-settings maps it to the owning profile entry id.
37
+ */
38
+ const SETTINGS_NS = 'dsh-ssh'
39
+
40
+ /** The dsh-ssh settings section the browser half reads. */
41
+ interface SshClientSettings {
42
+ /** User-configured xterm fontFamily; empty/undefined means the CSS chain. */
43
+ terminalFontFamily?: string
44
+ }
45
+
46
+ /** The one field this plugin's own Config schema declares (its entry identity on the shared settings surface). */
47
+ const TERMINAL_FONT_FIELD = 'terminalFontFamily' satisfies keyof SshClientSettings
48
+
49
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
50
+ interface LocaleNamespaceMap {
51
+ /** dsh-ssh surface copy. */
52
+ 'dsh-ssh': SshKey
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Required services (fiber inject waiting — the runtime must be up first).
58
+ *
59
+ * Only services this half truly cannot work without are listed. `configForms`
60
+ * is intentionally absent: it is optional (one terminal-font preference), and
61
+ * declaring it here makes the client fiber wait forever on a family that does
62
+ * not provide it, so `apply` never runs and the panel silently never appears.
63
+ * Optional services are read through `ctx.get` and degrade instead.
64
+ */
65
+ export const inject = ['slots', 'locale', 'layout']
66
+
67
+ /** Type-only surface (export discipline: no value exports beyond the plugin contract). */
68
+ export type { PanelControllerSnapshot } from './panel/controller.ts'
69
+ export type { SshPanelProps } from './panel/SshPanel.tsx'
70
+ export type { HostsTabProps } from './panel/HostsTab.tsx'
71
+ export type { HostFormDialogProps } from './panel/HostFormDialog.tsx'
72
+ export type { TerminalTabProps } from './panel/TerminalTab.tsx'
73
+ export type { TransferTabProps } from './panel/TransferTab.tsx'
74
+ export type { TunnelsTabProps } from './panel/TunnelsTab.tsx'
75
+ export type { ClusterTabProps } from './panel/ClusterTab.tsx'
76
+ export type { SshKey } from './locales.ts'
77
+
78
+ /**
79
+ * Mount the SSH panel.
80
+ * @param ctx - client root context (locale service).
81
+ */
82
+ export function apply(ctx: ClientContext): void {
83
+ // No telemetry. The upstream base plugin sent one anonymous install
84
+ // heartbeat per browser per UTC day to dsh-market.com; a fleet tool that
85
+ // holds credentials and knows the operator's server fleet has no business
86
+ // reporting its installation to a third party.
87
+
88
+ ctx.effect(() => {
89
+ try {
90
+ return ctx.locale.register(NS, { zh, en })
91
+ } catch {
92
+ return () => {}
93
+ }
94
+ }, 'dsh-ssh: dictionaries')
95
+
96
+ // Wire the SDK translate seat into the module-level tt (sidebar row and
97
+ // other plain-DOM callers): reads the active locale at call time, so they
98
+ // follow the Language setting without a reload.
99
+ try { setRuntimeTranslate(ctx.locale.bind(NS)) } catch { /* locale missing: document-language fallback stays */ }
100
+
101
+ // Panel navigation belongs to the layout service: the panel asks it to
102
+ // select its own panel id (or the conversation) instead of taking over the
103
+ // center column at the DOM level. The lookup stays lazy so a selection
104
+ // issued before the service settles still lands once it does, and the face
105
+ // throws by contract before the layout root entry mounts, which the
106
+ // controller tolerates.
107
+ const controller = new PanelController({
108
+ panel: {
109
+ select: panelId => {
110
+ const layout = (ctx as unknown as { get?(name: string): unknown }).get?.('layout') as { selectPanel?: (id: string | null) => void } | undefined
111
+ layout?.selectPanel?.(panelId)
112
+ },
113
+ },
114
+ })
115
+ const api = new SshApi()
116
+ // Live terminal-font preference (issue #577): the field lives in this
117
+ // plugin's own profile entry, whose settings page the Host generates from
118
+ // the plugin Config schema; the panel re-applies a change to open terminals
119
+ // without a reconnect.
120
+ const settings = bindSettingsReader<SshClientSettings>(ctx, SETTINGS_NS, TERMINAL_FONT_FIELD)
121
+ const terminalFont: TerminalFontSource = {
122
+ get: () => {
123
+ const snapshot = settings.getSnapshot()
124
+ return snapshot.status === 'ready' ? snapshot.value?.terminalFontFamily : undefined
125
+ },
126
+ subscribe: (listener) => settings.subscribe(listener),
127
+ }
128
+ ctx.effect(() => () => { settings.dispose() }, 'dsh-ssh: settings binding')
129
+ const disposers: Array<() => void> = []
130
+ try {
131
+ disposers.push(registerSshPanel(ctx, controller, api, terminalFont))
132
+ // The layout's panel selection is reconciled back into the controller, so
133
+ // the panel follows the user clicking another panel row.
134
+ const layoutFace = (ctx as unknown as { get?(name: string): unknown }).get?.('layout') as { panelInfo?: { subscribe(listener: () => void): () => void; getSnapshot(): { activePanelId: unknown } } } | undefined
135
+ if (layoutFace?.panelInfo !== undefined) {
136
+ const sync = (): void => {
137
+ const active = layoutFace.panelInfo!.getSnapshot().activePanelId
138
+ controller.syncPanelSelection(active === SSH_PANEL_ID ? SSH_PANEL_ID : null)
139
+ }
140
+ sync()
141
+ disposers.push(layoutFace.panelInfo.subscribe(sync))
142
+ }
143
+ } catch (error) {
144
+ // Registration failures degrade the panel, never the GUI.
145
+ console.warn('[dsh-ssh] panel registration failed:', error)
146
+ }
147
+ ctx.effect(() => () => {
148
+ for (const dispose of disposers.splice(0)) dispose()
149
+ }, 'dsh-ssh: ui mounts')
150
+ }