@linxin666/dsh-ssh 0.4.19 → 0.4.21
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.
- package/README.i18n.yaml +2 -2
- package/README.md +13 -2
- package/README.zh.md +13 -2
- package/lib/client.js +726 -109
- package/lib/client.js.map +1 -1
- package/lib/index.js +1074 -352
- package/lib/types/client/api.d.ts +8 -4
- package/lib/types/client/locales.d.ts +27 -1
- package/lib/types/client/panel/HostFormDialog.d.ts +3 -3
- package/lib/types/client/panel/HostsTab.d.ts +3 -3
- package/lib/types/client/panel/KeysTab.d.ts +8 -0
- package/lib/types/client/panel/controller.d.ts +1 -1
- package/lib/types/connection-trust.d.ts +26 -0
- package/lib/types/engine/cluster.d.ts +7 -2
- package/lib/types/engine/connection-pool.d.ts +11 -2
- package/lib/types/engine/sftp.d.ts +5 -0
- package/lib/types/engine/terminal-sessions.d.ts +5 -3
- package/lib/types/index.d.ts +6 -5
- package/lib/types/protocol.d.ts +41 -0
- package/lib/types/routes.d.ts +3 -0
- package/lib/types/service.d.ts +148 -0
- package/lib/types/store.d.ts +16 -4
- package/package.json +1 -1
- package/src/client/api.ts +147 -58
- package/src/client/locales.ts +55 -2
- package/src/client/panel/HostFormDialog.tsx +76 -17
- package/src/client/panel/HostsTab.tsx +50 -25
- package/src/client/panel/KeysTab.tsx +192 -0
- package/src/client/panel/SshPanel.tsx +4 -1
- package/src/client/panel/TerminalTab.tsx +14 -9
- package/src/client/panel/TunnelsTab.tsx +24 -7
- package/src/client/panel/controller.ts +77 -12
- package/src/client/panel/helpers.ts +3 -2
- package/src/connection-trust.ts +70 -0
- package/src/engine/cluster.ts +45 -13
- package/src/engine/connection-pool.ts +279 -96
- package/src/engine/proxy-command.ts +27 -10
- package/src/engine/sftp.ts +69 -35
- package/src/engine/terminal-sessions.ts +110 -35
- package/src/engine/tunnel.ts +20 -2
- package/src/engine.ts +5 -8
- package/src/index.ts +113 -39
- package/src/protocol.ts +45 -0
- package/src/routes.ts +130 -23
- package/src/service.ts +158 -0
- package/src/store.ts +324 -104
- package/src/tools.ts +3 -5
package/src/service.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cordis service `dsh-ssh` publishes to sibling plugins.
|
|
3
|
+
*
|
|
4
|
+
* A plugin that needs the host inventory or the shared connection pool injects
|
|
5
|
+
* this service (`ctx.inject(['dshSsh'], ...)`) instead of importing this
|
|
6
|
+
* package. The face is a thin forwarder over the same `SshEngine` instance the
|
|
7
|
+
* routes, the agent tools and the panel drive, so a consumer shares one host
|
|
8
|
+
* store and one connection pool with the surfaces the user already operates.
|
|
9
|
+
*
|
|
10
|
+
* This module is the published contract and is deliberately import-free: a
|
|
11
|
+
* consuming package restates these declarations verbatim and resolves the
|
|
12
|
+
* service by {@link DSH_SSH_SERVICE} at runtime, so the two packages share a
|
|
13
|
+
* shape without sharing a module. Only the members named here exist — the web
|
|
14
|
+
* terminal, tunnels, cluster runs, directory listing and any streaming log
|
|
15
|
+
* stay behind the plugin's own surfaces.
|
|
16
|
+
*
|
|
17
|
+
* @module @linxin666/dsh-ssh/service
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Cordis service name the host half publishes the face under. */
|
|
21
|
+
export const DSH_SSH_SERVICE = 'dshSsh'
|
|
22
|
+
|
|
23
|
+
/** Version of this contract; a consumer restates the number it was built against. */
|
|
24
|
+
export const DSH_SSH_API_VERSION = 1
|
|
25
|
+
|
|
26
|
+
/** Authentication flavors a host entry may carry. */
|
|
27
|
+
export type DshSshAuthKind = 'key' | 'password' | 'agent'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* One host as the service reports it: the fields the plugin's own
|
|
31
|
+
* `SshHostSummary` already publishes, minus the `proxyCommand` text.
|
|
32
|
+
*
|
|
33
|
+
* The omission is the trust boundary, not an oversight. A ProxyCommand is a
|
|
34
|
+
* shell line the host process executes with its own privileges, so no consumer
|
|
35
|
+
* receives it — the agent tools project it to a boolean for the same reason.
|
|
36
|
+
* Passwords, key passphrases and private-key paths are absent as well: this
|
|
37
|
+
* face describes a host, it never hands out credentials.
|
|
38
|
+
*/
|
|
39
|
+
export interface DshSshHost {
|
|
40
|
+
/** Stable, user-chosen identifier every operation addresses. */
|
|
41
|
+
alias: string
|
|
42
|
+
/** Hostname or IP of the target. */
|
|
43
|
+
host: string
|
|
44
|
+
/** SSH port. */
|
|
45
|
+
port: number
|
|
46
|
+
/** Login user. */
|
|
47
|
+
user: string
|
|
48
|
+
/** Authentication flavor the stored entry uses. */
|
|
49
|
+
auth: DshSshAuthKind
|
|
50
|
+
/** Whether the configured private-key file exists on this machine (key auth only). */
|
|
51
|
+
keyReady: boolean
|
|
52
|
+
/** Jump chain: local aliases connected through in order. */
|
|
53
|
+
proxyJump: string[]
|
|
54
|
+
/** Free-form note. */
|
|
55
|
+
description?: string
|
|
56
|
+
/** Deployment environment label. */
|
|
57
|
+
environment?: string
|
|
58
|
+
/** Free-form tags. */
|
|
59
|
+
tags: string[]
|
|
60
|
+
/** Physical location note. */
|
|
61
|
+
location?: string
|
|
62
|
+
/** Whether this host's sessions forward the local ssh-agent. */
|
|
63
|
+
forwardAgent: boolean
|
|
64
|
+
/** Creation timestamp (ms). */
|
|
65
|
+
createdAt: number
|
|
66
|
+
/** Last-change timestamp (ms). */
|
|
67
|
+
updatedAt: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Ceiling and cancellation for one remote command. */
|
|
71
|
+
export interface DshSshExecOptions {
|
|
72
|
+
/** Wall-clock ceiling for the remote command; the engine default applies when absent. */
|
|
73
|
+
timeoutMs?: number
|
|
74
|
+
/** Aborting closes the remote channel and settles the call as a cancelled command. */
|
|
75
|
+
signal?: AbortSignal
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** One finished remote command. */
|
|
79
|
+
export interface DshSshExecResult {
|
|
80
|
+
/** Whether the command exited zero. */
|
|
81
|
+
success: boolean
|
|
82
|
+
/** Remote exit code, or null when the channel died without one. */
|
|
83
|
+
exitCode: number | null
|
|
84
|
+
/** Whether the ceiling stopped the run. */
|
|
85
|
+
timedOut: boolean
|
|
86
|
+
/** Captured standard output, verbatim. */
|
|
87
|
+
stdout: string
|
|
88
|
+
/** Captured standard error, verbatim. */
|
|
89
|
+
stderr: string
|
|
90
|
+
/** Round trip in milliseconds. */
|
|
91
|
+
durationMs: number
|
|
92
|
+
/** Connection error message when the command never ran. */
|
|
93
|
+
error?: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Outcome of one upload. */
|
|
97
|
+
export interface DshSshUploadResult {
|
|
98
|
+
/** Bytes written. */
|
|
99
|
+
bytes: number
|
|
100
|
+
/** Files written (one for a single-file upload). */
|
|
101
|
+
files: number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Outcome of one download. */
|
|
105
|
+
export interface DshSshDownloadResult {
|
|
106
|
+
/** Bytes written locally. */
|
|
107
|
+
bytes: number
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The face a sibling plugin receives under the `dshSsh` service name.
|
|
112
|
+
*
|
|
113
|
+
* Every member is a forward: no gate, no cache and no state of its own lives
|
|
114
|
+
* here, so a consumer is refused by exactly what refuses the GUI and the agent
|
|
115
|
+
* tools, and a settings change to the plugin reaches all of them at once.
|
|
116
|
+
*/
|
|
117
|
+
export interface DshSshService {
|
|
118
|
+
/** Contract version this face implements. */
|
|
119
|
+
readonly apiVersion: typeof DSH_SSH_API_VERSION
|
|
120
|
+
/** The host inventory the plugin's own surfaces read. */
|
|
121
|
+
readonly hosts: {
|
|
122
|
+
/** Every configured host, secret-free, in store order. */
|
|
123
|
+
list(): DshSshHost[]
|
|
124
|
+
/** One host by alias, or undefined when the alias is not configured. */
|
|
125
|
+
find(alias: string): DshSshHost | undefined
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Run one command on a host through the shared pool.
|
|
129
|
+
* @param alias - configured host alias.
|
|
130
|
+
* @param command - command line handed to the remote shell.
|
|
131
|
+
* @param options - ceiling and cancellation.
|
|
132
|
+
* @returns the finished command.
|
|
133
|
+
*/
|
|
134
|
+
exec(alias: string, command: string, options?: DshSshExecOptions): Promise<DshSshExecResult>
|
|
135
|
+
/**
|
|
136
|
+
* Upload one local file to an absolute remote path.
|
|
137
|
+
* @param alias - configured host alias.
|
|
138
|
+
* @param localPath - file on this machine (a directory is not part of this face).
|
|
139
|
+
* @param remotePath - absolute destination path on the host.
|
|
140
|
+
* @returns bytes and files written.
|
|
141
|
+
*/
|
|
142
|
+
upload(alias: string, localPath: string, remotePath: string): Promise<DshSshUploadResult>
|
|
143
|
+
/**
|
|
144
|
+
* Download one remote file to a local path.
|
|
145
|
+
* @param alias - configured host alias.
|
|
146
|
+
* @param remotePath - file on the host.
|
|
147
|
+
* @param localPath - destination path on this machine.
|
|
148
|
+
* @returns bytes written.
|
|
149
|
+
*/
|
|
150
|
+
download(alias: string, remotePath: string, localPath: string): Promise<DshSshDownloadResult>
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare module '@deepseek-ai/cordis' {
|
|
154
|
+
interface Context {
|
|
155
|
+
/** The dsh-ssh face, published while the plugin's master switch is on. */
|
|
156
|
+
dshSsh: DshSshService
|
|
157
|
+
}
|
|
158
|
+
}
|