@fish-under-sea/dsh-ssh-fish 1.0.2 → 2.0.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 (43) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +7 -5
  3. package/README.md +7 -5
  4. package/README.zh.md +7 -5
  5. package/icon.png +0 -0
  6. package/lib/client.js +783 -170
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +128 -14
  9. package/lib/types/client/api.d.ts +21 -0
  10. package/lib/types/client/locales.d.ts +13 -2
  11. package/lib/types/client/panel/TerminalTab.d.ts +12 -7
  12. package/lib/types/client/panel/controller.d.ts +185 -21
  13. package/lib/types/engine/connection-pool.d.ts +52 -1
  14. package/lib/types/engine.d.ts +7 -0
  15. package/lib/types/index.d.ts +10 -0
  16. package/lib/types/loopback.d.ts +41 -1
  17. package/lib/types/protocol.d.ts +18 -1
  18. package/lib/types/store.d.ts +7 -0
  19. package/lib/types/tool-surface.d.ts +1 -0
  20. package/lib/types/tools.d.ts +1 -0
  21. package/locale/en.json +6 -0
  22. package/locale/zh.json +6 -0
  23. package/package.json +25 -22
  24. package/src/client/api.ts +70 -0
  25. package/src/client/index.ts +1 -2
  26. package/src/client/locales.ts +26 -4
  27. package/src/client/panel/HostFormDialog.tsx +16 -2
  28. package/src/client/panel/HostsTab.tsx +3 -0
  29. package/src/client/panel/SshPanel.tsx +7 -15
  30. package/src/client/panel/TerminalTab.tsx +371 -151
  31. package/src/client/panel/controller.ts +370 -30
  32. package/src/client/panel/panel.module.css +108 -0
  33. package/src/client/settings-binding.ts +0 -1
  34. package/src/engine/connection-pool.ts +96 -4
  35. package/src/engine.ts +10 -0
  36. package/src/index.ts +16 -1
  37. package/src/loopback.ts +57 -1
  38. package/src/protocol.ts +18 -1
  39. package/src/routes.ts +4 -1
  40. package/src/store.ts +26 -0
  41. package/src/tool-surface.ts +1 -0
  42. package/src/tools.ts +9 -4
  43. package/icon.svg +0 -3
@@ -14,7 +14,10 @@ import { startProxyCommand, type ProxyTarget } from './proxy-command.ts'
14
14
  export interface EngineOptions {
15
15
  /** Connections idle longer than this are closed (ms). */
16
16
  idleTimeoutMs?: number
17
- /** SSH handshake timeout (ms). */
17
+ /**
18
+ * Ceiling for the whole pre-ready sequence (ms): TCP connect, SSH key
19
+ * exchange and user authentication. Passed to ssh2's `readyTimeout`.
20
+ */
18
21
  connectTimeoutMs?: number
19
22
  /** Keepalive ping interval (ms). */
20
23
  keepaliveIntervalMs?: number
@@ -28,10 +31,17 @@ export interface EngineOptions {
28
31
  sftpConcurrency?: number
29
32
  }
30
33
 
34
+ /**
35
+ * Default ceiling for TCP connect, SSH key exchange and user authentication
36
+ * together (ms). Password authentication behind PAM / LDAP can outlast the
37
+ * previous 15 s ceiling while the server still eventually accepts it.
38
+ */
39
+ export const DEFAULT_CONNECT_TIMEOUT_MS = 30_000
40
+
31
41
  /** Default engine knobs (applied when an option is omitted). */
32
42
  export const DEFAULTS: Required<EngineOptions> = {
33
43
  idleTimeoutMs: 30 * 60_000,
34
- connectTimeoutMs: 15_000,
44
+ connectTimeoutMs: DEFAULT_CONNECT_TIMEOUT_MS,
35
45
  keepaliveIntervalMs: 15_000,
36
46
  maxOutputBytes: 2 * 1024 * 1024,
37
47
  defaultExecTimeoutMs: 60_000,
@@ -93,19 +103,62 @@ export function buildConnectConfig(entry: SshHostEntry, sock: ConnectConfig['soc
93
103
  config.passphrase = entry.auth.passphrase
94
104
  }
95
105
  }
106
+ // Agent forwarding is additive: it never changes how the host
107
+ // authenticates, it only lets this connection broker signatures from the
108
+ // local agent for the remote side (OpenSSH ForwardAgent / ssh -A).
109
+ if (entry.forwardAgent === true) {
110
+ // Agent auth already resolved an endpoint, and reusing it keeps the
111
+ // forwarded agent identical to the one that authenticated.
112
+ const agentPath = typeof config.agent === 'string'
113
+ ? config.agent
114
+ : resolveForwardAgentPath(entry.auth.agentPath)
115
+ if (agentPath === undefined) {
116
+ // ssh2's own message for this case ("You must set a valid agent path to
117
+ // allow agent forwarding") names neither the host nor a way out, so the
118
+ // engine refuses first with an actionable one.
119
+ throw new Error('agent forwarding is enabled for this host but no ssh-agent endpoint is available: '
120
+ + 'set SSH_AUTH_SOCK, start Pageant on Windows, or configure an agent path')
121
+ }
122
+ config.agent = agentPath
123
+ config.agentForward = true
124
+ }
96
125
  return config
97
126
  }
98
127
 
128
+ /**
129
+ * The default ssh-agent endpoint on Windows: the named pipe the native
130
+ * OpenSSH ssh-agent service listens on. ssh2 connects to a named pipe for any
131
+ * path matching its Windows pipe form, so the default is a real endpoint
132
+ * rather than a protocol name (#1910). PuTTY Pageant is still reachable — it
133
+ * is what the literal `pageant` agent path selects — but it is no longer the
134
+ * assumption.
135
+ */
136
+ export const WINDOWS_AGENT_PIPE = '\\\\.\\pipe\\openssh-ssh-agent'
137
+
99
138
  /** Resolve the ssh2 agent path for 'agent' auth. */
100
139
  export function resolveAgentPath(agentPath?: string): string | undefined {
101
140
  const explicit = normalizeAgentPath(agentPath)
102
141
  if (explicit !== undefined) return explicit
103
142
  const sock = process.env.SSH_AUTH_SOCK
104
143
  if (sock !== undefined && sock !== '') return sock
105
- if (process.platform === 'win32') return 'pageant'
144
+ if (process.platform === 'win32') return WINDOWS_AGENT_PIPE
106
145
  return undefined
107
146
  }
108
147
 
148
+ /**
149
+ * Resolve the ssh-agent endpoint that forwarding brokers signatures through:
150
+ * an explicitly configured agent path wins, then SSH_AUTH_SOCK, then the
151
+ * native OpenSSH named pipe on Windows. Undefined means no endpoint exists on
152
+ * this machine.
153
+ *
154
+ * Forwarding shares the auth resolution on purpose — the endpoint a host
155
+ * signs through is the same one it authenticates with — but it is a separate
156
+ * name so the forwarding path can evolve without touching auth.
157
+ */
158
+ export function resolveForwardAgentPath(agentPath?: string): string | undefined {
159
+ return resolveAgentPath(agentPath)
160
+ }
161
+
109
162
  /** Keyboard-interactive handler callback for 2FA / dynamic prompt flow. */
110
163
  export type KeyboardInteractiveHandler = (
111
164
  name: string,
@@ -115,11 +168,40 @@ export type KeyboardInteractiveHandler = (
115
168
  finish: (responses: string[]) => void,
116
169
  ) => void
117
170
 
171
+ /**
172
+ * Name the phase that actually stalled. ssh2 reports every pre-ready timeout
173
+ * as "Timed out while waiting for handshake", including one that expires
174
+ * during user authentication after a completed key exchange.
175
+ *
176
+ * @param timeoutMs - the configured `readyTimeout` (0 disables it).
177
+ * @param handshakeComplete - whether ssh2 completed the key exchange.
178
+ * @returns the operator-facing timeout message.
179
+ */
180
+ export function readyTimeoutMessage(timeoutMs: number | undefined, handshakeComplete: boolean): string {
181
+ const budget = typeof timeoutMs === 'number' && timeoutMs > 0 ? ' after ' + timeoutMs + ' ms' : ''
182
+ const hint = ' - raise the dsh-ssh connectTimeoutMs setting if this host is slow'
183
+ return handshakeComplete
184
+ ? 'SSH authentication timed out' + budget + ': TCP connect and key exchange completed, but the server did not finish authenticating the user' + hint
185
+ : 'SSH connection timed out' + budget + ' before key exchange completed: TCP connect or the SSH key exchange did not finish' + hint
186
+ }
187
+
188
+ /**
189
+ * Whether ssh2 ended the attempt with its pre-ready timeout. The level is the
190
+ * stable discriminator; the message is reused for connect, key exchange and
191
+ * authentication alike.
192
+ */
193
+ export function isReadyTimeout(error: Error): boolean {
194
+ return (error as Error & { level?: unknown }).level === 'client-timeout'
195
+ }
196
+
118
197
  /** Connect one ssh2 client (resolve on ready, reject on error/close). */
119
198
  export function connectClient(config: ConnectConfig, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<Client> {
120
199
  return new Promise((resolve, reject) => {
121
200
  const client = new Client()
122
201
  let settled = false
202
+ // Key exchange completion is the only public phase boundary ssh2 exposes
203
+ // between "TCP connect / SSH handshake" and "user authentication".
204
+ let handshakeComplete = false
123
205
  const fail = (error: unknown): void => {
124
206
  if (settled) return
125
207
  settled = true
@@ -131,8 +213,12 @@ export function connectClient(config: ConnectConfig, onKeyboardInteractive?: Key
131
213
  try { (sock as { destroy: () => void }).destroy() } catch { /* already closed */ }
132
214
  }
133
215
  try { client.destroy() } catch { /* already closed */ }
134
- reject(error instanceof Error ? error : new Error(String(error)))
216
+ const cause = error instanceof Error ? error : new Error(String(error))
217
+ reject(isReadyTimeout(cause) ? new Error(readyTimeoutMessage(config.readyTimeout, handshakeComplete)) : cause)
135
218
  }
219
+ client.once('handshake', () => {
220
+ handshakeComplete = true
221
+ })
136
222
  client.once('ready', () => {
137
223
  if (settled) return
138
224
  settled = true
@@ -228,6 +314,12 @@ export function parseJumpSpec(spec: string): { host: string; port?: number; user
228
314
  * Resolve one ProxyJump spec: an alias configured in this plugin wins, and any
229
315
  * other value is read as an OpenSSH address whose credentials come from the
230
316
  * target entry (an ad-hoc hop has no stored auth of its own).
317
+ *
318
+ * An address hop deliberately carries no forwardAgent flag: OpenSSH's
319
+ * ForwardAgent is a per-Host setting and an ad-hoc address was never
320
+ * configured, so it must never inherit the target's opt-in. A hop written as
321
+ * an alias uses that alias's own entry, which is how a user forwards on a
322
+ * bastion on purpose.
231
323
  */
232
324
  export function resolveHop(engine: PoolEngine, entry: SshHostEntry, spec: string): SshHostEntry {
233
325
  const configured = engine.store.find(spec)
package/src/engine.ts CHANGED
@@ -51,6 +51,16 @@ export class SshEngine {
51
51
  this.sweepTimer.unref?.()
52
52
  }
53
53
 
54
+ /**
55
+ * Change the pre-ready ceiling (TCP connect + key exchange + user
56
+ * authentication) for connections opened from now on. A pooled connection
57
+ * keeps serving until it reconnects, because the ceiling governs the
58
+ * connect path only.
59
+ */
60
+ setConnectTimeout(timeoutMs: number): void {
61
+ this.opts.connectTimeoutMs = timeoutMs
62
+ }
63
+
54
64
  // ---------------------------------------------------------------- config
55
65
 
56
66
  /** Secret-free host list (filtered by the optional query). */
package/src/index.ts CHANGED
@@ -14,6 +14,7 @@ import type {} from '@deepseek-ai/dsh-host-webserver'
14
14
  import type {} from '@deepseek-ai/dsh-system-prompt'
15
15
  import type {} from '@deepseek-ai/dsh-tools'
16
16
  import { SshEngine } from './engine.ts'
17
+ import { DEFAULT_CONNECT_TIMEOUT_MS } from './engine/connection-pool.ts'
17
18
  import { makeRoutes } from './routes.ts'
18
19
  import { HostStore } from './store.ts'
19
20
  import { sshClusterTool, sshDownloadTool, sshExecTool, sshListTool, sshTunnelTool, sshUploadTool } from './tools.ts'
@@ -54,6 +55,13 @@ export interface Config {
54
55
  * Nerd Font stack here to render powerline/Nerd glyphs.
55
56
  */
56
57
  terminalFontFamily?: string
58
+ /**
59
+ * Ceiling for the whole pre-ready SSH sequence in milliseconds: TCP
60
+ * connect, key exchange and user authentication (default 30000). Raise it
61
+ * for hosts whose password authentication is slow (for example PAM / LDAP
62
+ * behind a distant directory service).
63
+ */
64
+ connectTimeoutMs?: number
57
65
  }
58
66
 
59
67
  /** The stable reference a `volatile()` config field resolves to; its owner updates it in place. */
@@ -70,6 +78,7 @@ export interface ResolvedConfig {
70
78
  announceToAgent?: ConfigField<boolean>
71
79
  enabled?: ConfigField<boolean>
72
80
  terminalFontFamily?: ConfigField<string>
81
+ connectTimeoutMs?: ConfigField<number>
73
82
  }
74
83
 
75
84
  /**
@@ -84,6 +93,8 @@ export const Config = z.object({
84
93
  announceToAgent: z.boolean().default(false).volatile(),
85
94
  enabled: z.boolean().default(true).volatile(),
86
95
  terminalFontFamily: z.string().default('').volatile(),
96
+ connectTimeoutMs: z.number().step(1).min(1_000).max(600_000).default(DEFAULT_CONNECT_TIMEOUT_MS).volatile()
97
+ .description('TCP connect, SSH key exchange and user authentication timeout in milliseconds; raise it for hosts whose authentication is slow.'),
87
98
  })
88
99
 
89
100
  /** Schema defaults, re-read for hand-built test contexts (the loader applies them normally). */
@@ -136,7 +147,7 @@ export const apply = mountOnce('@fish-under-sea/dsh-ssh-fish', applyImpl)
136
147
 
137
148
  function applyImpl(ctx: Context, config?: ResolvedConfig): void {
138
149
  const store = new HostStore()
139
- const engine = new SshEngine(store)
150
+ const engine = new SshEngine(store, { connectTimeoutMs: readConfigField(config?.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS) })
140
151
  ctx.effect(() => () => { engine.dispose() }, 'dsh-ssh: engine')
141
152
 
142
153
  const resolve = (): { announceToAgent: boolean; enabled: boolean } => {
@@ -176,6 +187,10 @@ function applyImpl(ctx: Context, config?: ResolvedConfig): void {
176
187
  // is kept under one disposer: re-registering first tears the old one down
177
188
  // so duplicate-name registrations never throw.
178
189
  const sync = (): void => {
190
+ // A settings edit reaches this instance without a remount; apply the
191
+ // connection ceiling before re-deriving the surfaces so connections opened
192
+ // by the request that follows use the new value.
193
+ engine.setConnectTimeout(readConfigField(config?.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS))
179
194
  const value = resolve()
180
195
  if (disposeSection !== undefined) {
181
196
  disposeSection()
package/src/loopback.ts CHANGED
@@ -8,6 +8,19 @@
8
8
  * Semantics: RFC 5735 IPv4 127/8, ::1, IPv4-mapped ::ffff:127/8 (matching the
9
9
  * remote-web-ui gate), localhost hostnames, plus the browser same-origin
10
10
  * markers (sec-fetch-site and Origin) for the request-level fence.
11
+ *
12
+ * A reverse proxy in front of the host rewrites the Host header to its own
13
+ * upstream literal (a Cloudflare tunnel, frp and an nginx reverse proxy all
14
+ * dial 127.0.0.1:<port>), and the socket the origin sees is the proxy's, which
15
+ * is loopback by construction. Both halves of the fence then hold for a public
16
+ * request. Forwarding headers are the signal that a hop stands in between: a
17
+ * request that carries CF-Connecting-IP or X-Forwarded-For is answered through
18
+ * a proxy and is never treated as a local one (issue #1906).
19
+ *
20
+ * An operator who runs that proxy or tunnel themselves can opt into the
21
+ * narrower case: isForwardedLoopbackRequest describes a forwarded request that
22
+ * still landed on this machine's loopback upstream, and a route family admits
23
+ * it only behind its own default-off switch (issue #1918).
11
24
  * @module dsh-web-shared/host/loopback
12
25
  */
13
26
 
@@ -36,13 +49,29 @@ export function isLoopbackHostname(hostname: string): boolean {
36
49
  return isIPv4Loopback(hostname)
37
50
  }
38
51
 
52
+ /**
53
+ * Whether a reverse proxy stood between the client and this host: the request
54
+ * carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
55
+ * hop that forwards traffic, so the request did not originate on this machine.
56
+ * @param request - node HTTP request.
57
+ * @returns true when a forwarding header is present.
58
+ */
59
+ export function isProxiedRequest(request: IncomingMessage): boolean {
60
+ return request.headers['cf-connecting-ip'] !== undefined
61
+ || request.headers['x-forwarded-for'] !== undefined
62
+ }
63
+
39
64
  /**
40
65
  * Request-level trust fence: a loopback socket address AND a loopback Host
41
66
  * header, plus browser same-origin markers. The socket address is
42
- * authoritative; X-Forwarded-For is never trusted.
67
+ * authoritative for a direct connection; a request that carries a forwarding
68
+ * header is refused outright, because a proxy in front of the host makes both
69
+ * the socket address and the Host header describe the proxy rather than the
70
+ * client. X-Forwarded-For is therefore never evidence *for* loopback.
43
71
  */
44
72
  export function isLoopbackRequest(request: IncomingMessage): boolean {
45
73
  if (!isLoopbackAddress(request.socket.remoteAddress)) return false
74
+ if (isProxiedRequest(request)) return false
46
75
  const host = request.headers.host
47
76
  if (typeof host !== 'string') return false
48
77
  let hostUrl: URL
@@ -61,3 +90,30 @@ export function isLoopbackRequest(request: IncomingMessage): boolean {
61
90
  return false
62
91
  }
63
92
  }
93
+
94
+ /**
95
+ * Whether a forwarded request landed on this machine's loopback upstream: a
96
+ * forwarding header (the proxy's own stamp), a loopback socket address (the
97
+ * proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
98
+ * the authority to its upstream literal).
99
+ *
100
+ * This is a fact about the route, not a trust decision. A public request to a
101
+ * tunnel satisfies all three by construction, because the proxy is the client
102
+ * of this process: only a caller that operates the proxy can decide it stands
103
+ * for the browser, which is why every consumer keeps this behind an explicit
104
+ * default-off switch and its own browser markers. isLoopbackRequest is
105
+ * unchanged and still refuses a forwarded request (issue #1906).
106
+ * @param request - node HTTP request.
107
+ * @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
108
+ */
109
+ export function isForwardedLoopbackRequest(request: IncomingMessage): boolean {
110
+ if (!isProxiedRequest(request)) return false
111
+ if (!isLoopbackAddress(request.socket.remoteAddress)) return false
112
+ const host = request.headers.host
113
+ if (typeof host !== 'string') return false
114
+ try {
115
+ return isLoopbackHostname(new URL('http://' + host).hostname)
116
+ } catch {
117
+ return false
118
+ }
119
+ }
package/src/protocol.ts CHANGED
@@ -29,7 +29,7 @@ export interface SshHostEntry {
29
29
  /**
30
30
  * ssh-agent endpoint for 'agent' auth. A socket path, the special value
31
31
  * 'pageant' (PuTTY Pageant on Windows), or undefined for auto-detect
32
- * (SSH_AUTH_SOCK, then Pageant on Windows).
32
+ * (SSH_AUTH_SOCK, then the native OpenSSH named pipe on Windows).
33
33
  */
34
34
  agentPath?: string
35
35
  }
@@ -50,6 +50,12 @@ export interface SshHostEntry {
50
50
  tags: string[]
51
51
  /** Physical location note. */
52
52
  location?: string
53
+ /**
54
+ * Opt-in ssh-agent forwarding (OpenSSH ForwardAgent / ssh -A): the host's
55
+ * sessions request agent forwarding so the remote can sign with this
56
+ * machine's agent. Default off; stored only when enabled.
57
+ */
58
+ forwardAgent?: boolean
53
59
  createdAt: number
54
60
  updatedAt: number
55
61
  }
@@ -70,6 +76,12 @@ export interface SshHostSummary {
70
76
  environment?: string
71
77
  tags: string[]
72
78
  location?: string
79
+ /**
80
+ * Whether agent forwarding is enabled. Always projected as a definite
81
+ * boolean: the browser and the tool bridge need a value even for entries
82
+ * stored before the feature existed.
83
+ */
84
+ forwardAgent: boolean
73
85
  createdAt: number
74
86
  updatedAt: number
75
87
  }
@@ -160,6 +172,11 @@ export interface HostPayload {
160
172
  environment?: string
161
173
  tags?: string[]
162
174
  location?: string
175
+ /**
176
+ * Agent forwarding for this host. Omitted on update keeps the stored value;
177
+ * false clears it (PATCH semantics).
178
+ */
179
+ forwardAgent?: boolean
163
180
  }
164
181
 
165
182
  /** Why one ssh_config Host block was not imported. */
package/src/routes.ts CHANGED
@@ -130,8 +130,11 @@ const maxUploadBytes = deps.maxUploadBytes ?? MAX_UPLOAD_BYTES
130
130
  // Connection-relevant changes invalidate the pooled connection:
131
131
  // without this the pool would keep running commands on the old
132
132
  // host/credentials until the idle sweep (up to 30 min later).
133
+ // Agent forwarding belongs here too: it is fixed per connection
134
+ // (ssh2 negotiates it when the channel opens), so toggling it must
135
+ // reconnect or the new setting silently never takes effect.
133
136
  const patch = body as Record<string, unknown>
134
- if (['host', 'port', 'user', 'auth', 'proxyJump', 'proxyCommand'].some(key => patch[key] !== undefined)) {
137
+ if (['host', 'port', 'user', 'auth', 'proxyJump', 'proxyCommand', 'forwardAgent'].some(key => patch[key] !== undefined)) {
135
138
  engine.dropAlias(alias)
136
139
  }
137
140
  writeJson(res, 200, { host: store.summarize(entry) })
package/src/store.ts CHANGED
@@ -72,6 +72,9 @@ export function validateHostPayload(payload: unknown): string | undefined {
72
72
  if (p.tags !== undefined && (!Array.isArray(p.tags) || p.tags.some(x => typeof x !== 'string'))) {
73
73
  return 'tags must be an array of strings'
74
74
  }
75
+ if (p.forwardAgent !== undefined && typeof p.forwardAgent !== 'boolean') {
76
+ return 'forwardAgent must be a boolean'
77
+ }
75
78
  return undefined
76
79
  }
77
80
 
@@ -136,6 +139,9 @@ export class HostStore {
136
139
  ...(entry.environment !== undefined ? { environment: entry.environment } : {}),
137
140
  tags: [...entry.tags],
138
141
  ...(entry.location !== undefined ? { location: entry.location } : {}),
142
+ // Always a definite boolean, unlike the conditional optional fields:
143
+ // the tool bridge rejects undefined-valued JSON properties.
144
+ forwardAgent: entry.forwardAgent === true,
139
145
  createdAt: entry.createdAt,
140
146
  updatedAt: entry.updatedAt,
141
147
  }
@@ -171,6 +177,9 @@ export class HostStore {
171
177
  environment: payload.environment?.trim() || undefined,
172
178
  tags: [...(payload.tags ?? [])].map(tag => tag.trim()).filter(tag => tag !== ''),
173
179
  location: payload.location?.trim() || undefined,
180
+ // Stored only when enabled, so a store file written without agent
181
+ // forwarding stays byte-identical to the pre-feature format.
182
+ forwardAgent: payload.forwardAgent === true ? true : undefined,
174
183
  createdAt: now,
175
184
  updatedAt: now,
176
185
  }
@@ -201,6 +210,9 @@ export class HostStore {
201
210
  if (patch.proxyCommand !== undefined && typeof patch.proxyCommand !== 'string') {
202
211
  throw new Error('proxyCommand must be a string when provided')
203
212
  }
213
+ if (patch.forwardAgent !== undefined && typeof patch.forwardAgent !== 'boolean') {
214
+ throw new Error('forwardAgent must be a boolean')
215
+ }
204
216
  // The mutual exclusion is checked on the MERGED view: a patch that only
205
217
  // adds one transport must not slip past a stored value of the other.
206
218
  const mergedProxyCommand = patch.proxyCommand !== undefined
@@ -250,6 +262,8 @@ export class HostStore {
250
262
  if (patch.environment !== undefined) entry.environment = patch.environment.trim() || undefined
251
263
  if (patch.tags !== undefined) entry.tags = [...patch.tags].map(tag => tag.trim()).filter(tag => tag !== '')
252
264
  if (patch.location !== undefined) entry.location = patch.location.trim() || undefined
265
+ // PATCH semantics: an omitted key keeps the stored value, false clears it.
266
+ if (patch.forwardAgent !== undefined) entry.forwardAgent = patch.forwardAgent === true ? true : undefined
253
267
  entry.updatedAt = Date.now()
254
268
  this.save(file)
255
269
  return entry
@@ -326,6 +340,7 @@ export class HostStore {
326
340
  environment: block.props.environment,
327
341
  tags: (block.props.tags ?? '').split(',').map(tag => tag.trim()).filter(tag => tag !== ''),
328
342
  location: block.props.location,
343
+ forwardAgent: parseForwardAgentValue(block.props.forwardagent),
329
344
  }
330
345
  try {
331
346
  this.create(payload)
@@ -411,6 +426,17 @@ export function normalizeProxyCommand(raw: string | undefined): string | undefin
411
426
  return trimmed
412
427
  }
413
428
 
429
+ /**
430
+ * Read an ssh_config `ForwardAgent` value into the stored boolean flag. Only
431
+ * an explicit yes/true/on enables forwarding; an absent value, no/false/off,
432
+ * and anything unrecognized leave it off instead of failing the import — an
433
+ * unknown keyword must never cost the user the whole Host block.
434
+ */
435
+ export function parseForwardAgentValue(raw: string | undefined): boolean {
436
+ const value = raw?.trim().toLowerCase()
437
+ return value === 'yes' || value === 'true' || value === 'on'
438
+ }
439
+
414
440
  /** Expand a leading `~` in a filesystem path. */
415
441
  export function expandHome(path: string): string {
416
442
  if (path === '~') return homedir()
@@ -32,6 +32,7 @@
32
32
  export const PLUGIN_TOOL_SECTION_ORDERS = {
33
33
  ssh: 150,
34
34
  'task-board': 200,
35
+ agents: 220,
35
36
  } as const
36
37
 
37
38
  /** One plugin id keyed by {@link PLUGIN_TOOL_SECTION_ORDERS}. */
package/src/tools.ts CHANGED
@@ -28,6 +28,7 @@ export interface AgentHostRow {
28
28
  keyReady: boolean
29
29
  proxyJump: string[]
30
30
  proxyCommandConfigured: boolean
31
+ forwardAgent: boolean
31
32
  description?: string
32
33
  environment?: string
33
34
  tags: string[]
@@ -52,11 +53,14 @@ function renderHosts(hosts: AgentHostRow[]): string {
52
53
  host.user,
53
54
  host.auth,
54
55
  host.proxyJump.length > 0 ? 'jump:' + host.proxyJump.join(',') : host.proxyCommandConfigured ? 'proxy-command' : '-',
56
+ // Forwarding is a security-relevant opt-in (the remote can sign with this
57
+ // machine's agent), so the model must see it in the table, not only in JSON.
58
+ host.forwardAgent ? 'yes' : '-',
55
59
  host.environment ?? '-',
56
60
  (host.tags.length > 0 ? host.tags.join(',') : '-'),
57
61
  host.description ?? '',
58
62
  ].join(' | '))
59
- return ['alias | host | port | user | auth | proxy | environment | tags | description', '--- | --- | --- | --- | --- | --- | --- | --- | ---', ...rows].join('\n')
63
+ return ['alias | host | port | user | auth | proxy | forward | environment | tags | description', '--- | --- | --- | --- | --- | --- | --- | --- | --- | ---', ...rows].join('\n')
60
64
  }
61
65
 
62
66
  /** Render one exec result (mirrors the bash-tool exit-code convention). */
@@ -91,7 +95,7 @@ function renderTunnel(tunnel: TunnelInfo): string {
91
95
  export function sshListTool(engine: SshEngine) {
92
96
  return defineTool({
93
97
  name: 'ssh_list',
94
- description: 'List configured SSH hosts (alias, host, user, auth, environment, tags, description). Use ssh_exec etc. with the alias.',
98
+ description: 'List configured SSH hosts (alias, host, user, auth, agent forwarding, environment, tags, description). Use ssh_exec etc. with the alias.',
95
99
  parameters: {
96
100
  query: { type: 'string', description: 'Optional fuzzy match against alias, description, host, and tags.' },
97
101
  },
@@ -115,6 +119,7 @@ export function sshListTool(engine: SshEngine) {
115
119
  keyReady: { type: 'boolean', required: true },
116
120
  proxyJump: { type: 'array', items: { type: 'string' }, required: true },
117
121
  proxyCommandConfigured: { type: 'boolean', required: true },
122
+ forwardAgent: { type: 'boolean', required: true },
118
123
  description: { type: 'string' },
119
124
  environment: { type: 'string' },
120
125
  tags: { type: 'array', items: { type: 'string' }, required: true },
@@ -144,7 +149,7 @@ export function sshExecTool(engine: SshEngine) {
144
149
  parameters: {
145
150
  alias: { type: 'string', required: true, description: 'Host alias from ssh_list.' },
146
151
  command: { type: 'string', required: true, description: 'The shell command to run remotely.' },
147
- timeoutMs: { type: 'integer', description: 'Timeout in milliseconds (default 60000).' },
152
+ timeoutMs: { type: 'integer', description: 'Remote command execution timeout in milliseconds (default 60000); it starts after the connection is ready. The connection and authentication ceiling is the dsh-ssh connectTimeoutMs setting, not this argument.' },
148
153
  },
149
154
  output: {
150
155
  schema: {
@@ -362,7 +367,7 @@ export function sshClusterTool(engine: SshEngine) {
362
367
  aliases: { type: 'array', items: { type: 'string' }, description: 'Optional alias filter; at least one of aliases, environment, or tags is required.' },
363
368
  environment: { type: 'string', description: 'Optional environment filter; at least one selector is required.' },
364
369
  tags: { type: 'array', items: { type: 'string' }, description: 'Optional ALL-tags filter; at least one selector is required.' },
365
- timeoutMs: { type: 'integer', description: 'Per-host timeout in milliseconds.' },
370
+ timeoutMs: { type: 'integer', description: 'Per-host command execution timeout in milliseconds (default 60000); it does not extend the connection and authentication ceiling (the dsh-ssh connectTimeoutMs setting).' },
366
371
  maxWorkers: { type: 'integer', description: 'Concurrency cap (default 8).' },
367
372
  },
368
373
  output: {
package/icon.svg DELETED
@@ -1,3 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
2
- <path fill="#4d6bfe" fill-rule="evenodd" d="M 67.5 120 L 70.5 120 L 72.5 121 L 80.5 129 L 81.5 129 L 84.5 132 L 85.5 132 L 90.5 136 L 93.5 137 L 95.5 139 L 101.5 142 L 103.5 142 L 106.5 144 L 111.5 145 L 112.5 146 L 115.5 146 L 119.5 148 Q 122.75 147.25 123.5 149 L 127.5 149 L 128.5 150 L 133.5 150 L 134.5 151 L 140.5 151 L 141.5 152 L 150.5 152 L 151.5 153 L 160.5 153 L 161.5 154 L 171.5 154 L 172.5 155 L 178.5 155 L 179.5 156 Q 183.5 155 184.5 157 L 189.5 157 Q 190.5 159 194.5 158 L 195.5 159 L 197.5 159 L 198.5 160 L 200.5 160 L 201.5 161 L 206.5 162 L 209.5 164 L 211.5 164 L 219.5 168 L 224.5 172 L 227.5 173 L 247 191.5 L 247 192.5 L 253 199.5 L 255.5 204 L 258 201.5 L 263 193.5 L 272.5 183 L 273.5 183 L 280.5 176 L 281.5 176 L 292.5 168 L 300.5 164 L 302.5 164 L 305.5 162 L 307.5 162 L 308.5 161 L 310.5 161 L 314.5 159 L 317.5 159 L 318.5 158 Q 321.75 158.75 322.5 157 L 326.5 157 L 327.5 156 L 331.5 156 L 332.5 155 L 337.5 155 L 338.5 154 L 348.5 154 L 349.5 153 L 358.5 153 L 359.5 152 L 368.5 152 L 369.5 151 L 376.5 151 L 377.5 150 L 383.5 150 L 384.5 149 L 388.5 149 L 389.5 148 L 392.5 148 L 393.5 147 L 396.5 147 L 397.5 146 L 399.5 146 L 400.5 145 L 405.5 144 L 423.5 135 L 426.5 132 L 431.5 129 L 439.5 121 L 441.5 120 L 444.5 120 L 448 123.5 L 448 140.5 L 447 141.5 L 447 149.5 L 446 150.5 L 446 154.5 L 445 155.5 Q 445.75 158.75 444 159.5 L 444 163.5 Q 442.25 164.25 443 167.5 L 440 173.5 L 439 178.5 L 435 185.5 L 435 187.5 L 432 193.5 L 430 195.5 L 429 198.5 L 427 200.5 L 425 204.5 L 419 211.5 L 419 212.5 L 402.5 229 L 401.5 229 L 394.5 235 L 393.5 235 L 388.5 239 L 385.5 240 L 383.5 242 L 371.5 248 L 369.5 248 L 364.5 251 L 362.5 251 L 361.5 252 L 359.5 252 L 358.5 253 L 356.5 253 L 355.5 254 L 353.5 254 L 349.5 256 L 342.5 257 L 338.5 259 L 335.5 259 L 334.5 260 L 327.5 261 L 326.5 262 L 324.5 262 L 323.5 263 L 321.5 263 L 320.5 264 L 318.5 264 L 317.5 265 L 312.5 266 L 309.5 268 L 307.5 268 L 295.5 275 L 288 282.5 Q 287.5 286 285 287.5 Q 285.5 290 284 290.5 L 284 293.5 L 283 294.5 L 283 311.5 L 284 312.5 L 284 318.5 L 285 319.5 L 285 323.5 L 286 324.5 L 286 328.5 Q 288 329.5 287 333.5 L 288 334.5 L 288 337.5 L 289 338.5 L 289 341.5 L 290 342.5 L 290 345.5 L 291 346.5 L 292 353.5 L 293 354.5 L 293 356.5 L 295 360.5 L 295 363.5 L 296 364.5 L 296 367.5 L 297 368.5 L 297 370.5 L 298 371.5 L 298 373.5 L 299 374.5 L 299 376.5 L 301 380.5 L 301 386.5 L 298.5 389 L 294.5 391 Q 292 390.5 291.5 392 L 286.5 392 L 285.5 393 L 272.5 393 L 271.5 394 L 240.5 394 L 239.5 393 L 227.5 393 L 226.5 392 L 221.5 392 Q 220.75 390.25 217.5 391 L 212 387.5 L 211 385.5 L 211 381.5 L 212 380.5 Q 211.5 378 213 377.5 L 213 374.5 L 214 373.5 L 214 371.5 L 216 367.5 L 216 364.5 L 217 363.5 L 217 361.5 L 219 357.5 L 219 354.5 L 221 350.5 L 221 347.5 L 222 346.5 L 222 343.5 L 223 342.5 L 223 339.5 L 224 338.5 L 224 335.5 L 225 334.5 Q 224.25 331.25 226 330.5 L 226 326.5 L 227 325.5 Q 226 321.5 228 320.5 L 228 315.5 L 229 314.5 L 229 292.5 L 228 291.5 L 227 286.5 L 225 284.5 L 223 280.5 L 219.5 277 L 218.5 277 L 212.5 272 L 202.5 267 L 200.5 267 L 197.5 265 L 194.5 265 L 193.5 264 L 191.5 264 L 190.5 263 L 188.5 263 L 184.5 261 L 181.5 261 L 180.5 260 L 173.5 259 L 172.5 258 L 170.5 258 L 166.5 256 L 159.5 255 L 158.5 254 L 156.5 254 L 155.5 253 L 150.5 252 L 147.5 250 L 145.5 250 L 142.5 248 L 140.5 248 L 128.5 242 L 123.5 238 L 120.5 237 L 109.5 228 L 108.5 228 L 95 214.5 L 95 213.5 L 87 204.5 L 84 198.5 L 82 196.5 L 80 191.5 L 77 187.5 L 77 185.5 L 72 175.5 L 72 173.5 L 71 172.5 L 71 170.5 L 69 166.5 L 69 163.5 L 68 162.5 Q 68.75 159.25 67 158.5 L 67 154.5 L 66 153.5 L 66 148.5 L 65 147.5 L 65 139.5 L 64 138.5 L 64 124.5 L 67.5 120 Z"/>
3
- </svg>