@linxin666/dsh-ssh 0.4.21 → 0.4.23
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 +2 -1
- package/README.zh.md +2 -1
- package/lib/client.js +246 -19
- package/lib/client.js.map +1 -1
- package/lib/index.js +39 -25
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/locales.d.ts +2 -0
- package/lib/types/client/native-panel.d.ts +4 -1
- package/lib/types/client/panel/SshPanel.d.ts +4 -1
- package/lib/types/client/panel/TransferTab.d.ts +4 -1
- package/lib/types/client/panel/TunnelsTab.d.ts +3 -1
- package/lib/types/client/panel/controller.d.ts +6 -0
- package/lib/types/client/panel/directory-dialog.d.ts +44 -0
- package/lib/types/client/session-activity.d.ts +34 -0
- package/lib/types/connection-trust.d.ts +2 -4
- package/lib/types/dsh-home.d.ts +13 -3
- package/lib/types/tool-surface.d.ts +6 -2
- package/package.json +26 -26
- package/src/client/index.ts +4 -2
- package/src/client/locales.ts +4 -0
- package/src/client/native-panel.tsx +37 -4
- package/src/client/panel/SshPanel.tsx +8 -3
- package/src/client/panel/TransferTab.tsx +27 -1
- package/src/client/panel/TunnelsTab.tsx +7 -1
- package/src/client/panel/controller.ts +21 -0
- package/src/client/panel/directory-dialog.ts +107 -0
- package/src/client/session-activity.tsx +168 -0
- package/src/connection-trust.ts +6 -14
- package/src/dsh-home.ts +35 -12
- package/src/engine/tunnel.ts +4 -3
- package/src/routes.ts +4 -7
- package/src/tool-surface.ts +17 -2
- package/src/tools.ts +3 -0
package/src/engine/tunnel.ts
CHANGED
|
@@ -82,6 +82,8 @@ export async function startTunnel(
|
|
|
82
82
|
const onLinkClosed = (): void => { abortTunnel(engine, id) }
|
|
83
83
|
const detachLink = (): void => { client.off('close', onLinkClosed) }
|
|
84
84
|
const server = createServer((socket) => {
|
|
85
|
+
// Install this before requesting the SSH channel so early errors stay local.
|
|
86
|
+
socket.on('error', () => { destroyQuietly(socket) })
|
|
85
87
|
sockets.add(socket)
|
|
86
88
|
socket.on('close', () => { sockets.delete(socket) })
|
|
87
89
|
// The link can die between taking the record above and this connection.
|
|
@@ -103,14 +105,13 @@ export async function startTunnel(
|
|
|
103
105
|
destroyQuietly(stream)
|
|
104
106
|
return
|
|
105
107
|
}
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
+
// Either close or a channel error tears down the pair. A socket error
|
|
109
|
+
// destroys the socket and triggers the same cleanup through close.
|
|
108
110
|
const destroy = (): void => {
|
|
109
111
|
destroyQuietly(socket)
|
|
110
112
|
try { stream.close() } catch { /* gone */ }
|
|
111
113
|
}
|
|
112
114
|
stream.on('error', destroy)
|
|
113
|
-
socket.on('error', destroy)
|
|
114
115
|
stream.on('close', destroy)
|
|
115
116
|
socket.on('close', destroy)
|
|
116
117
|
stream.pipe(socket).pipe(stream)
|
package/src/routes.ts
CHANGED
|
@@ -10,14 +10,11 @@
|
|
|
10
10
|
import { closeSync, createReadStream, createWriteStream, mkdirSync, openSync } from 'node:fs'
|
|
11
11
|
import { unlink } from 'node:fs/promises'
|
|
12
12
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
13
|
-
import {
|
|
13
|
+
import { join, posix } from 'node:path'
|
|
14
14
|
import { tmpdir } from 'node:os'
|
|
15
15
|
import { randomBytes } from 'node:crypto'
|
|
16
16
|
import { WebSocketServer } from 'ws'
|
|
17
17
|
import type { WebRoute, WebUpgradeRoute } from '@deepseek-ai/dsh-host-webserver'
|
|
18
|
-
|
|
19
|
-
type AuthAwareWebRoute = WebRoute & { readonly auth: 'anonymous' }
|
|
20
|
-
type AuthAwareWebUpgradeRoute = WebUpgradeRoute & { readonly auth: 'anonymous' }
|
|
21
18
|
import type { SshEngine } from './engine.ts'
|
|
22
19
|
import { hasClusterSelector } from './engine/cluster.ts'
|
|
23
20
|
import { TerminalSessionRegistry } from './engine/terminal-sessions.ts'
|
|
@@ -502,7 +499,7 @@ const maxUploadBytes = deps.maxUploadBytes ?? MAX_UPLOAD_BYTES
|
|
|
502
499
|
res.writeHead(200, {
|
|
503
500
|
'content-type': 'application/octet-stream',
|
|
504
501
|
'content-length': String(outcome.bytes),
|
|
505
|
-
'content-disposition': `attachment; filename="${safeAttachmentFilename(basename(remotePath))}"`,
|
|
502
|
+
'content-disposition': `attachment; filename="${safeAttachmentFilename(posix.basename(remotePath))}"`,
|
|
506
503
|
'referrer-policy': 'no-referrer',
|
|
507
504
|
})
|
|
508
505
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -597,8 +594,8 @@ const maxUploadBytes = deps.maxUploadBytes ?? MAX_UPLOAD_BYTES
|
|
|
597
594
|
}
|
|
598
595
|
|
|
599
596
|
return {
|
|
600
|
-
routes: routes.map((route):
|
|
601
|
-
upgrade: { ...upgrade, auth: 'anonymous' }
|
|
597
|
+
routes: routes.map((route): WebRoute => ({ ...route, auth: 'anonymous' })),
|
|
598
|
+
upgrade: { ...upgrade, auth: 'anonymous' },
|
|
602
599
|
terminalSessions,
|
|
603
600
|
}
|
|
604
601
|
}
|
package/src/tool-surface.ts
CHANGED
|
@@ -63,11 +63,15 @@ export interface SectionScopeContext {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* Build a section provider that renders
|
|
67
|
-
*
|
|
66
|
+
* Build a section provider that renders `text` only while at least one of
|
|
67
|
+
* `toolNames` is visible to the rendering scope.
|
|
68
68
|
*
|
|
69
69
|
* The native convention: a tool that a restriction, a preset, or a missing
|
|
70
70
|
* registry removed must not leave guidance behind telling the model to call it.
|
|
71
|
+
* Under a 0.2.3-alpha.3+ PTC root registry (`PtcToolRegistry`), `tools.get(name,
|
|
72
|
+
* scope)` exposes only the `run_code` transport while binding registered tools
|
|
73
|
+
* inside programs; when `run_code` is active in the rendering scope, fall back
|
|
74
|
+
* to checking the unscoped registry so guidance does not vanish under PTC.
|
|
71
75
|
* An unreadable registry renders the text unchanged — guidance that outlives a
|
|
72
76
|
* momentary read failure is recoverable; guidance for a tool that is gone is
|
|
73
77
|
* not.
|
|
@@ -91,6 +95,17 @@ export function visibleToolText(
|
|
|
91
95
|
return text
|
|
92
96
|
}
|
|
93
97
|
}
|
|
98
|
+
if (context.scope !== undefined && toolNames.length > 0) {
|
|
99
|
+
try {
|
|
100
|
+
if (tools.get('run_code', context.scope) !== undefined) {
|
|
101
|
+
for (const name of toolNames) {
|
|
102
|
+
if (tools.get(name) !== undefined) return text
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} catch {
|
|
106
|
+
return text
|
|
107
|
+
}
|
|
108
|
+
}
|
|
94
109
|
return ''
|
|
95
110
|
}
|
|
96
111
|
}
|
package/src/tools.ts
CHANGED
|
@@ -96,6 +96,7 @@ function renderTunnel(tunnel: TunnelInfo): string {
|
|
|
96
96
|
export function sshListTool(engine: SshEngine) {
|
|
97
97
|
return defineTool({
|
|
98
98
|
name: 'ssh_list',
|
|
99
|
+
environment: 'independent',
|
|
99
100
|
description: 'List configured SSH hosts (alias, host, user, auth, agent forwarding, environment, tags, description). Use ssh_exec etc. with the alias.',
|
|
100
101
|
parameters: {
|
|
101
102
|
query: { type: 'string', description: 'Optional fuzzy match against alias, description, host, and tags.' },
|
|
@@ -146,6 +147,7 @@ export function sshListTool(engine: SshEngine) {
|
|
|
146
147
|
export function sshExecTool(engine: SshEngine) {
|
|
147
148
|
return defineTool({
|
|
148
149
|
name: 'ssh_exec',
|
|
150
|
+
environment: 'explicit',
|
|
149
151
|
description: 'Execute a shell command on a REMOTE SSH host by alias; the command runs on the remote host, never on this machine. For commands on this machine, use the local bash tool. Prefer combining independent read-only queries into one command.',
|
|
150
152
|
parameters: {
|
|
151
153
|
alias: { type: 'string', required: true, description: 'Host alias from ssh_list.' },
|
|
@@ -362,6 +364,7 @@ export function sshTunnelTool(engine: SshEngine) {
|
|
|
362
364
|
export function sshClusterTool(engine: SshEngine) {
|
|
363
365
|
return defineTool({
|
|
364
366
|
name: 'ssh_cluster',
|
|
367
|
+
environment: 'explicit',
|
|
365
368
|
description: 'Run one command concurrently across selected SSH hosts; at least one aliases, environment, or tags filter is required.',
|
|
366
369
|
parameters: {
|
|
367
370
|
command: { type: 'string', required: true, description: 'The shell command to run on every matched host.' },
|