@fish-under-sea/dsh-ssh-fish 2.2.3 → 2.3.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.
- package/README.en.md +4 -4
- package/README.md +4 -4
- package/package.json +1 -1
- package/README.i18n.yaml +0 -6
- package/README.zh.md +0 -31
- package/lib/client.js +0 -17100
- package/lib/client.js.map +0 -1
- package/lib/index.js +0 -3625
- package/lib/types/client/api.d.ts +0 -162
- package/lib/types/client/index.d.ts +0 -37
- package/lib/types/client/locales.d.ts +0 -175
- package/lib/types/client/native-panel.d.ts +0 -70
- package/lib/types/client/panel/ClusterTab.d.ts +0 -7
- package/lib/types/client/panel/HostFormDialog.d.ts +0 -12
- package/lib/types/client/panel/HostsTab.d.ts +0 -25
- package/lib/types/client/panel/SshPanel.d.ts +0 -14
- package/lib/types/client/panel/TerminalTab.d.ts +0 -27
- package/lib/types/client/panel/TransferTab.d.ts +0 -7
- package/lib/types/client/panel/TunnelsTab.d.ts +0 -19
- package/lib/types/client/panel/controller.d.ts +0 -253
- package/lib/types/client/panel/helpers.d.ts +0 -45
- package/lib/types/client/panel/xterm.css.d.ts +0 -2
- package/lib/types/client/settings-binding.d.ts +0 -61
- package/lib/types/dsh-home.d.ts +0 -16
- package/lib/types/engine/cluster.d.ts +0 -19
- package/lib/types/engine/connection-pool.d.ts +0 -163
- package/lib/types/engine/proxy-command.d.ts +0 -36
- package/lib/types/engine/pty.d.ts +0 -32
- package/lib/types/engine/sftp.d.ts +0 -20
- package/lib/types/engine/terminal-sessions.d.ts +0 -67
- package/lib/types/engine/tunnel.d.ts +0 -36
- package/lib/types/engine.d.ts +0 -96
- package/lib/types/http.d.ts +0 -59
- package/lib/types/index.d.ts +0 -93
- package/lib/types/loopback.d.ts +0 -64
- package/lib/types/mount-once.d.ts +0 -55
- package/lib/types/protocol.d.ts +0 -256
- package/lib/types/routes.d.ts +0 -33
- package/lib/types/ssh-config.d.ts +0 -34
- package/lib/types/store.d.ts +0 -78
- package/lib/types/tool-surface.d.ts +0 -72
- package/lib/types/tools.d.ts +0 -43
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { WebSocket } from 'ws';
|
|
2
|
-
import type { KeyboardInteractiveHandler } from './connection-pool.ts';
|
|
3
|
-
import type { ShellSession } from './pty.ts';
|
|
4
|
-
/** What the registry needs from the engine (swappable in tests). */
|
|
5
|
-
export interface TerminalSessionDeps {
|
|
6
|
-
/** Open one PTY shell for the alias (engine.openShell). */
|
|
7
|
-
openShell(alias: string, size: {
|
|
8
|
-
cols: number;
|
|
9
|
-
rows: number;
|
|
10
|
-
}, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<ShellSession>;
|
|
11
|
-
/** @returns the current time (defaults to Date.now). */
|
|
12
|
-
now?: () => number;
|
|
13
|
-
/** Bounded scrollback per session. */
|
|
14
|
-
maxBufferBytes?: number;
|
|
15
|
-
/** Idle window before a detached session is reaped. */
|
|
16
|
-
idleMs?: number;
|
|
17
|
-
/** Grace window an exited session is kept for reattaching views. */
|
|
18
|
-
exitGraceMs?: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The host's terminal session table: open one session per connect, attach any
|
|
22
|
-
* number of sockets, and keep the shell alive across detach.
|
|
23
|
-
*/
|
|
24
|
-
export declare class TerminalSessionRegistry {
|
|
25
|
-
private readonly sessions;
|
|
26
|
-
private readonly deps;
|
|
27
|
-
private readonly maxBufferBytes;
|
|
28
|
-
private readonly idleMs;
|
|
29
|
-
private readonly exitGraceMs;
|
|
30
|
-
constructor(deps: TerminalSessionDeps);
|
|
31
|
-
/** Open a new session for the alias and attach the requesting socket to it. */
|
|
32
|
-
open(ws: WebSocket, alias: string, size: {
|
|
33
|
-
cols: number;
|
|
34
|
-
rows: number;
|
|
35
|
-
}): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Attach a socket to an existing session, replaying its scrollback first.
|
|
38
|
-
* @returns false when the session is unknown (expired or already reaped).
|
|
39
|
-
*/
|
|
40
|
-
attach(ws: WebSocket, sessionId: string, size: {
|
|
41
|
-
cols: number;
|
|
42
|
-
rows: number;
|
|
43
|
-
}): boolean;
|
|
44
|
-
/** End every session (host teardown, plugin dispose). */
|
|
45
|
-
dispose(): void;
|
|
46
|
-
/** Number of live sessions (introspection for tests and diagnostics). */
|
|
47
|
-
size(): number;
|
|
48
|
-
/** Wire one socket's frames and lifecycle onto a session. */
|
|
49
|
-
private bind;
|
|
50
|
-
/** Remove a socket from its session, keeping the shell alive. */
|
|
51
|
-
private detach;
|
|
52
|
-
/** End the session a socket is attached to (explicit close from the view). */
|
|
53
|
-
private end;
|
|
54
|
-
/** Mark a session exited and keep it briefly so a reattaching view sees it. */
|
|
55
|
-
private finish;
|
|
56
|
-
/** Append output to the replay buffer, trimmed to the byte cap. */
|
|
57
|
-
private pushOutput;
|
|
58
|
-
/** Broadcast one frame to every attached socket, honoring backpressure. */
|
|
59
|
-
private send;
|
|
60
|
-
private sendTo;
|
|
61
|
-
/** Pause while any attached socket is backed up; resume once all drained. */
|
|
62
|
-
private applyBackpressure;
|
|
63
|
-
/** Answer a keyboard-interactive challenge through whoever is attached. */
|
|
64
|
-
private keyboardInteractive;
|
|
65
|
-
private scheduleReap;
|
|
66
|
-
private clearReap;
|
|
67
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local port-forward tunnels: one loopback-only listener per tunnel, pinned
|
|
3
|
-
* to a pooled connection so an idle sweep never closes it, with per-tunnel
|
|
4
|
-
* socket tracking and stop (single / alias-scoped / all).
|
|
5
|
-
*/
|
|
6
|
-
import { type Server as NetServer, type Socket } from 'node:net';
|
|
7
|
-
import type { TunnelInfo } from '../protocol.ts';
|
|
8
|
-
import { type PoolEngine, type PoolRecord } from './connection-pool.ts';
|
|
9
|
-
/** One active tunnel record (server + pinned connection + live sockets). */
|
|
10
|
-
export interface TunnelRecord {
|
|
11
|
-
info: TunnelInfo;
|
|
12
|
-
server: NetServer;
|
|
13
|
-
alias: string;
|
|
14
|
-
/** The pooled connection this tunnel pins; siblings on one alias may share it. */
|
|
15
|
-
record: PoolRecord;
|
|
16
|
-
sockets: Set<Socket>;
|
|
17
|
-
/** Detach the link-death hook startTunnel installs on the pooled client. */
|
|
18
|
-
detachLink?: () => void;
|
|
19
|
-
}
|
|
20
|
-
/** The engine slice the tunnel module needs (adds the tunnel registry). */
|
|
21
|
-
export interface TunnelEngine extends PoolEngine {
|
|
22
|
-
readonly tunnels: Map<string, TunnelRecord>;
|
|
23
|
-
nextTunnelId: number;
|
|
24
|
-
}
|
|
25
|
-
/** Start a local port-forward tunnel (listens on 127.0.0.1 only). */
|
|
26
|
-
export declare function startTunnel(engine: TunnelEngine, alias: string, options: {
|
|
27
|
-
remotePort: number;
|
|
28
|
-
remoteHost?: string;
|
|
29
|
-
localPort?: number;
|
|
30
|
-
}): Promise<TunnelInfo>;
|
|
31
|
-
/** All active tunnels. */
|
|
32
|
-
export declare function listTunnels(engine: TunnelEngine): TunnelInfo[];
|
|
33
|
-
/** Stop one tunnel (closes the listener, live sockets, and the pinned connection). */
|
|
34
|
-
export declare function stopTunnel(engine: TunnelEngine, id: string): boolean;
|
|
35
|
-
/** Stop all tunnels (optionally for one alias). */
|
|
36
|
-
export declare function stopAllTunnels(engine: TunnelEngine, alias?: string): number;
|
package/lib/types/engine.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The SSH engine facade: a per-alias persistent connection pool (ssh2) with
|
|
3
|
-
* multi-hop jump support, command execution, PTY shells, SFTP transfers,
|
|
4
|
-
* local port-forward tunnels and cluster execution. The heavy lifting lives
|
|
5
|
-
* in the engine/ modules (connection-pool, pty, sftp, tunnel, cluster); this
|
|
6
|
-
* class composes them behind one new SshEngine instance per plugin apply.
|
|
7
|
-
*/
|
|
8
|
-
import type { ClusterResult, ExecResult, SshHostSummary, TestResult, TransferProgress, TunnelInfo } from './protocol.ts';
|
|
9
|
-
import type { HostStore } from './store.ts';
|
|
10
|
-
import { type EngineOptions, type KeyboardInteractiveHandler, type PoolRecord } from './engine/connection-pool.ts';
|
|
11
|
-
import { type ShellSession } from './engine/pty.ts';
|
|
12
|
-
import { type TunnelRecord } from './engine/tunnel.ts';
|
|
13
|
-
export type { EngineOptions, KeyboardInteractiveHandler } from './engine/connection-pool.ts';
|
|
14
|
-
export type { ShellSession } from './engine/pty.ts';
|
|
15
|
-
export type { PoolRecord } from './engine/connection-pool.ts';
|
|
16
|
-
export type { TunnelRecord } from './engine/tunnel.ts';
|
|
17
|
-
/**
|
|
18
|
-
* The engine. Owns the pool, tunnels, and all operations. One instance per
|
|
19
|
-
* plugin apply; dispose() closes every connection.
|
|
20
|
-
*/
|
|
21
|
-
export declare class SshEngine {
|
|
22
|
-
readonly store: HostStore;
|
|
23
|
-
readonly opts: Required<EngineOptions>;
|
|
24
|
-
readonly pool: Map<string, PoolRecord>;
|
|
25
|
-
readonly acquireQueue: Map<string, Promise<PoolRecord>>;
|
|
26
|
-
readonly tunnels: Map<string, TunnelRecord>;
|
|
27
|
-
nextTunnelId: number;
|
|
28
|
-
private sweepTimer;
|
|
29
|
-
/**
|
|
30
|
-
* @param store - the host config store.
|
|
31
|
-
* @param options - engine knobs (defaults applied).
|
|
32
|
-
*/
|
|
33
|
-
constructor(store: HostStore, options?: EngineOptions);
|
|
34
|
-
/**
|
|
35
|
-
* Change the pre-ready ceiling (TCP connect + key exchange + user
|
|
36
|
-
* authentication) for connections opened from now on. A pooled connection
|
|
37
|
-
* keeps serving until it reconnects, because the ceiling governs the
|
|
38
|
-
* connect path only.
|
|
39
|
-
*/
|
|
40
|
-
setConnectTimeout(timeoutMs: number): void;
|
|
41
|
-
/** Secret-free host list (filtered by the optional query). */
|
|
42
|
-
list(query?: string): SshHostSummary[];
|
|
43
|
-
/** One host summary by alias. */
|
|
44
|
-
find(alias: string): SshHostSummary | undefined;
|
|
45
|
-
/** Run one command on `alias` (reusing the pooled connection). */
|
|
46
|
-
exec(alias: string, command: string, timeoutMs?: number, signal?: AbortSignal): Promise<ExecResult>;
|
|
47
|
-
/** Run one command against many hosts concurrently. */
|
|
48
|
-
cluster(options: {
|
|
49
|
-
command: string;
|
|
50
|
-
aliases?: string[];
|
|
51
|
-
environment?: string;
|
|
52
|
-
tags?: string[];
|
|
53
|
-
timeoutMs?: number;
|
|
54
|
-
maxWorkers?: number;
|
|
55
|
-
signal?: AbortSignal;
|
|
56
|
-
}): Promise<ClusterResult[]>;
|
|
57
|
-
/** Open a PTY shell session for the web terminal (standalone connection). */
|
|
58
|
-
openShell(alias: string, size: {
|
|
59
|
-
cols: number;
|
|
60
|
-
rows: number;
|
|
61
|
-
}, onKeyboardInteractive?: KeyboardInteractiveHandler): Promise<ShellSession>;
|
|
62
|
-
/** Upload one local file (or directory tree) to a remote path. */
|
|
63
|
-
upload(alias: string, localPath: string, remotePath: string, recursive: boolean, onProgress?: (progress: TransferProgress) => void): Promise<{
|
|
64
|
-
bytes: number;
|
|
65
|
-
files: number;
|
|
66
|
-
}>;
|
|
67
|
-
/** Download one remote file to a local path. */
|
|
68
|
-
download(alias: string, remotePath: string, localPath: string, onProgress?: (progress: TransferProgress) => void): Promise<{
|
|
69
|
-
bytes: number;
|
|
70
|
-
}>;
|
|
71
|
-
/** List a remote directory (file browser). */
|
|
72
|
-
ls(alias: string, path: string): Promise<import('./protocol.ts').RemoteDirEntry[]>;
|
|
73
|
-
/** Start a local port-forward tunnel (listens on 127.0.0.1 only). */
|
|
74
|
-
startTunnel(alias: string, options: {
|
|
75
|
-
remotePort: number;
|
|
76
|
-
remoteHost?: string;
|
|
77
|
-
localPort?: number;
|
|
78
|
-
}): Promise<TunnelInfo>;
|
|
79
|
-
/** All active tunnels. */
|
|
80
|
-
listTunnels(): TunnelInfo[];
|
|
81
|
-
/** Stop one tunnel (closes the listener, live sockets, and the pinned connection). */
|
|
82
|
-
stopTunnel(id: string): boolean;
|
|
83
|
-
/** Stop all tunnels (optionally for one alias). */
|
|
84
|
-
stopAllTunnels(alias?: string): number;
|
|
85
|
-
/**
|
|
86
|
-
* Drop every live artifact bound to one alias: stop its tunnels and close
|
|
87
|
-
* the pooled connection. Host entries that are deleted or whose connection
|
|
88
|
-
* fields change must never keep serving a stale, previously authenticated
|
|
89
|
-
* connection — the next operation re-connects from the current config.
|
|
90
|
-
*/
|
|
91
|
-
dropAlias(alias: string): void;
|
|
92
|
-
/** Probe connectivity with a cross-platform shell command. */
|
|
93
|
-
test(alias: string): Promise<TestResult>;
|
|
94
|
-
/** Close every pooled connection and tunnel. */
|
|
95
|
-
dispose(): void;
|
|
96
|
-
}
|
package/lib/types/http.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared JSON body/response helpers for the host route families: one strict
|
|
3
|
-
* bounded body reader, one lenient bounded body reader, one JSON object
|
|
4
|
-
* narrow, one JSON writer, and the outbound request-init helper that keeps a
|
|
5
|
-
* host fetch body decodable (withIdentityEncoding). Previously the readers
|
|
6
|
-
* were copy-pasted across the
|
|
7
|
-
* package route files (routes.ts, update-routes.ts, mobile-api.ts, and each
|
|
8
|
-
* family's route module) with drifting contracts: body caps ranging 4 KiB to
|
|
9
|
-
* 1 MiB and four distinct overflow behaviors (reject, undefined, null, throw).
|
|
10
|
-
*
|
|
11
|
-
* Packages receive this file as a generated copy via scripts/sync-shared.mjs;
|
|
12
|
-
* edit this shared source and re-run the sync instead of editing a copy.
|
|
13
|
-
* Consumer code is migrated onto it in follow-up waves; no call site changes
|
|
14
|
-
* belong in the same change as its introduction.
|
|
15
|
-
* @module dsh-web-shared/host/http
|
|
16
|
-
*/
|
|
17
|
-
import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'node:http';
|
|
18
|
-
/**
|
|
19
|
-
* Strict bounded body reader: parse a request body of at most maxBytes as
|
|
20
|
-
* JSON.
|
|
21
|
-
* @throws 'body too large' past the cap, or the JSON.parse error for an
|
|
22
|
-
* invalid or empty payload.
|
|
23
|
-
*/
|
|
24
|
-
export declare function readBoundedJson(req: IncomingMessage, maxBytes: number): Promise<unknown>;
|
|
25
|
-
/**
|
|
26
|
-
* Lenient bounded body reader: parse a request body as JSON, or null on an
|
|
27
|
-
* empty body, invalid JSON, or a body past maxBytes (default 64 KiB).
|
|
28
|
-
* Overflow destroys the request instead of draining the remainder (no drain
|
|
29
|
-
* call, matching the current repo-wide behavior); callers must not keep
|
|
30
|
-
* reading the request afterwards. With objectOnly, non-JSON-object payloads
|
|
31
|
-
* also yield null.
|
|
32
|
-
*/
|
|
33
|
-
export declare function readJsonBody(req: IncomingMessage, opts?: {
|
|
34
|
-
maxBytes?: number;
|
|
35
|
-
objectOnly?: boolean;
|
|
36
|
-
}): Promise<unknown | null>;
|
|
37
|
-
/** Narrow a value to a JSON object, or undefined when it is not one. */
|
|
38
|
-
export declare function asJsonObject(value: unknown): Record<string, unknown> | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Request init that asks a remote origin for an uncompressed body.
|
|
41
|
-
*
|
|
42
|
-
* The DSH host boots `@deepseek-ai/dsh-http-proxy`, whose top-level import of
|
|
43
|
-
* the npm `undici` copy replaces the legacy `undici.globalDispatcher.1` slot
|
|
44
|
-
* Node's built-in `fetch()` reads. That cross-major wrapper drops the
|
|
45
|
-
* `content-encoding` header and automatic decompression, so a plain fetch
|
|
46
|
-
* resolves to raw gzip/brotli/zstd bytes — compressed noise no JSON or text
|
|
47
|
-
* consumer can read. Every host fetch that parses a remote body must request
|
|
48
|
-
* identity encoding. Caller headers survive; `accept-encoding` is forced to
|
|
49
|
-
* `identity` because a caller value has no decoder behind it in this host.
|
|
50
|
-
* @param init - the caller's request init (signal, headers, method, ...).
|
|
51
|
-
* @returns a copy with `accept-encoding: identity` merged in.
|
|
52
|
-
*/
|
|
53
|
-
export declare function withIdentityEncoding(init?: RequestInit): RequestInit;
|
|
54
|
-
/**
|
|
55
|
-
* Write one JSON response. Default headers are the family defaults
|
|
56
|
-
* (content-type and referrer-policy); caller headers are appended or
|
|
57
|
-
* override them.
|
|
58
|
-
*/
|
|
59
|
-
export declare function writeJson(res: ServerResponse, status: number, body: unknown, headers?: OutgoingHttpHeaders): void;
|
package/lib/types/index.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-ssh — host half. Mounts the SSH engine (persistent ssh2 connection
|
|
3
|
-
* pool, exec / PTY shell / SFTP / tunnels / cluster), the /api/dsh-ssh route
|
|
4
|
-
* family plus the terminal WebSocket upgrade, the agent tools (ssh_list,
|
|
5
|
-
* ssh_exec, ssh_upload, ssh_download, ssh_tunnel, ssh_cluster), and a
|
|
6
|
-
* system-prompt announcement. The browser half (./client) renders the host
|
|
7
|
-
* manager and web terminal. Everything rides official NPM SDK packages —
|
|
8
|
-
* no dsh source changes.
|
|
9
|
-
*/
|
|
10
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
-
import z from '@deepseek-ai/schemastery';
|
|
12
|
-
/** Stable cordis plugin name. */
|
|
13
|
-
export declare const name = "ssh";
|
|
14
|
-
/** Services required before the SSH surfaces can mount. */
|
|
15
|
-
export declare const inject: string[];
|
|
16
|
-
declare module '@deepseek-ai/cordis' {
|
|
17
|
-
interface Events {
|
|
18
|
-
/**
|
|
19
|
-
* Volatile config values were committed into the running instance without a
|
|
20
|
-
* remount (cordis-plugin-loader); dispatched to the owning fiber only.
|
|
21
|
-
* @param paths - the changed config paths, as key arrays.
|
|
22
|
-
* @mode emit
|
|
23
|
-
*/
|
|
24
|
-
'loader/volatile-update'(paths: readonly (readonly string[])[]): void;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/** Plugin config as a profile patch declares it, before schema resolution. */
|
|
28
|
-
export interface Config {
|
|
29
|
-
/**
|
|
30
|
-
* When true, a system-prompt section announces the SSH plugin to every agent
|
|
31
|
-
* (tools + host store). Off by default to keep prompts clean.
|
|
32
|
-
*/
|
|
33
|
-
announceToAgent?: boolean;
|
|
34
|
-
/** Master switch for the plugin (routes, tools, prompt section). */
|
|
35
|
-
enabled?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* xterm `fontFamily` for the web terminal (issue #577). Empty (default)
|
|
38
|
-
* defers to the CSS chain: `--dsh-ssh-terminal-font`, then the official
|
|
39
|
-
* `--ds-font-family-code` token, then the built-in monospace stack. Set a
|
|
40
|
-
* Nerd Font stack here to render powerline/Nerd glyphs.
|
|
41
|
-
*/
|
|
42
|
-
terminalFontFamily?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Ceiling for the whole pre-ready SSH sequence in milliseconds: TCP
|
|
45
|
-
* connect, key exchange and user authentication (default 30000). Raise it
|
|
46
|
-
* for hosts whose password authentication is slow (for example PAM / LDAP
|
|
47
|
-
* behind a distant directory service).
|
|
48
|
-
*/
|
|
49
|
-
connectTimeoutMs?: number;
|
|
50
|
-
}
|
|
51
|
-
/** The stable reference a `volatile()` config field resolves to; its owner updates it in place. */
|
|
52
|
-
interface ConfigRef<T> {
|
|
53
|
-
/** @returns the field's current value. */
|
|
54
|
-
get(): T;
|
|
55
|
-
}
|
|
56
|
-
/** One resolved config field: a live reference, or a plain value from a hand-built context. */
|
|
57
|
-
type ConfigField<T> = ConfigRef<T> | T;
|
|
58
|
-
/** The config the Host hands to {@link apply} — the runtime face of {@link Config}. */
|
|
59
|
-
export interface ResolvedConfig {
|
|
60
|
-
announceToAgent?: ConfigField<boolean>;
|
|
61
|
-
enabled?: ConfigField<boolean>;
|
|
62
|
-
terminalFontFamily?: ConfigField<string>;
|
|
63
|
-
connectTimeoutMs?: ConfigField<number>;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Plugin config schema. Under the 0.1.7 settings model this schema IS the
|
|
67
|
-
* entry's settings page: the Host derives one form per profile entry from it
|
|
68
|
-
* and serves it through the shared configuration forms. Every field is
|
|
69
|
-
* `volatile()`, which is what puts it on that page and what lets an edit reach
|
|
70
|
-
* a running instance without a remount: the loader commits the new value into
|
|
71
|
-
* the field's reference and announces `loader/volatile-update` on this fiber.
|
|
72
|
-
*/
|
|
73
|
-
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
74
|
-
announceToAgent: z<boolean, boolean, "volatile-defined">;
|
|
75
|
-
enabled: z<boolean, boolean, "volatile-defined">;
|
|
76
|
-
terminalFontFamily: z<string, string, "volatile-defined">;
|
|
77
|
-
connectTimeoutMs: z<number, number, "volatile-defined">;
|
|
78
|
-
}>>, Schemastery.ObjectT<NoInfer<{
|
|
79
|
-
announceToAgent: z<boolean, boolean, "volatile-defined">;
|
|
80
|
-
enabled: z<boolean, boolean, "volatile-defined">;
|
|
81
|
-
terminalFontFamily: z<string, string, "volatile-defined">;
|
|
82
|
-
connectTimeoutMs: z<number, number, "volatile-defined">;
|
|
83
|
-
}>>, "plain">;
|
|
84
|
-
/** Model-facing announcement: plugin presence, capabilities, and limits. */
|
|
85
|
-
export declare const SSH_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-ssh \u63D2\u4EF6\uFF08DSH \u8FDC\u7A0B SSH \u8FD0\u7EF4\uFF09\uFF1A\u4FA7\u8FB9\u680F\u300CSSH\u300D\u5165\u53E3\uFF1B\u5728 dsh-web \u63D2\u4EF6\u5168\u5BB6\u6876\u4ED3\u5E93\uFF08packages/dsh-ssh\uFF09\u7EDF\u4E00\u7EF4\u62A4\u3002\u80FD\u529B\uFF1A\u4E3B\u673A\u914D\u7F6E\u5B58 $DSH_HOME/dsh-ssh.json\uFF08\u9ED8\u8BA4 ~/.dsh\uFF09\uFF08\u53EF\u4ECE ~/.ssh/config \u5BFC\u5165\uFF09\uFF1B\u6301\u4E45\u8FDE\u63A5\u6C60\u590D\u7528\u957F\u8FDE\u63A5\uFF08\u7A7A\u95F2 30 \u5206\u949F\u81EA\u52A8\u65AD\u5F00\uFF09\uFF1Bssh_list \u5217\u51FA\u4E3B\u673A\u3001ssh_exec \u6267\u884C\u8FDC\u7A0B\u547D\u4EE4\u3001ssh_upload/ssh_download \u4F20\u8F93\u6587\u4EF6\u3001ssh_tunnel \u672C\u5730\u7AEF\u53E3\u8F6C\u53D1\uFF08\u8BBF\u95EE\u8FDC\u7A0B\u6570\u636E\u5E93/\u5185\u7F51\u670D\u52A1\uFF09\u3001ssh_cluster \u6309 aliases/environment/tags \u81F3\u5C11\u4E00\u79CD\u975E\u7A7A selector \u7B5B\u9009\u540E\u96C6\u7FA4\u5E76\u53D1\u6267\u884C\uFF1B\u652F\u6301\u5BC6\u94A5/\u5BC6\u7801/ssh-agent \u8BA4\u8BC1\u3001passphrase \u5BC6\u94A5\u3001ProxyJump \u8DF3\u677F\u673A\uFF08\u522B\u540D\u6216 [user@]host[:port] \u5730\u5740\uFF09\u4E0E OpenSSH \u8BED\u4E49\u7684 ProxyCommand\uFF08\u8DF3\u8FC7\u5821\u5792\u673A\u5BA2\u6237\u7AEF\u573A\u666F\uFF0C\u53EA\u80FD\u7531\u7528\u6237\u5728 GUI \u914D\u7F6E\uFF0Cagent \u4E0D\u53EF\u5199\uFF09\uFF1BWeb \u7EC8\u7AEF\u8D70 WebSocket\u3002\u9650\u5236\uFF1A\u4E3B\u673A\u64CD\u4F5C\u7531\u7528\u6237\u5728 GUI \u4E2D\u914D\u7F6E\u540E agent \u65B9\u53EF\u4F7F\u7528\uFF1B\u5BC6\u7801\u4EE5\u660E\u6587\u5B58\u5728\u7528\u6237\u4E3B\u76EE\u5F55\u79C1\u6709\u6587\u4EF6\uFF08\u6743\u9650 0600\uFF09\uFF1B\u547D\u4EE4\u8F93\u51FA\u539F\u6837\u8FD4\u56DE\u3001\u53EF\u80FD\u542B\u654F\u611F\u4FE1\u606F\uFF1B\u65AD\u7EBF\u91CD\u8FDE\u53EF\u80FD\u91CD\u653E\u975E\u5E42\u7B49\u547D\u4EE4\uFF1B\u4F20\u8F93/\u6267\u884C\u6D88\u8017\u771F\u5B9E\u8FDC\u7A0B\u8D44\u6E90\uFF0C\u5148\u786E\u8BA4\u518D\u64CD\u4F5C\u3002\u8DEF\u5F84\u533A\u5206\uFF1A\u672C\u673A\uFF08dsh host\uFF09\u4E0A\u7684\u6587\u4EF6\u4E0E\u547D\u4EE4\u4E00\u5F8B\u7528\u672C\u5730\u5DE5\u5177\uFF08read / write / edit / bash\uFF09\uFF0Cssh_* \u5DE5\u5177\u53EA\u9488\u5BF9\u8FDC\u7A0B\u4E3B\u673A\u4E0A\u7684\u8DEF\u5F84\u3002\u7528\u6237\u63D0\u5230\u300CSSH / \u8FDC\u7A0B\u670D\u52A1\u5668 / \u670D\u52A1\u5668\u64CD\u4F5C / \u8DF3\u677F\u673A / \u96A7\u9053 / \u90E8\u7F72 / \u4E0A\u4F20\u4E0B\u8F7D\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
|
|
86
|
-
/**
|
|
87
|
-
* Mount the SSH engine, routes, tools, and announcement.
|
|
88
|
-
* @param ctx - host plugin context carrying webServer/tools/systemPrompt.
|
|
89
|
-
* @param config - resolved plugin config (schema defaults applied by the loader).
|
|
90
|
-
*/
|
|
91
|
-
export declare const apply: typeof applyImpl;
|
|
92
|
-
declare function applyImpl(ctx: Context, config?: ResolvedConfig): void;
|
|
93
|
-
export {};
|
package/lib/types/loopback.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loopback trust fence shared by the host route families: socket address,
|
|
3
|
-
* Host header, and browser same-origin markers. Packages receive this file as
|
|
4
|
-
* a generated copy via scripts/sync-shared.mjs; edit the shared source and
|
|
5
|
-
* re-run the sync instead of editing a copy.
|
|
6
|
-
*
|
|
7
|
-
* Semantics: RFC 5735 IPv4 127/8, ::1, IPv4-mapped ::ffff:127/8 (matching the
|
|
8
|
-
* remote-web-ui gate), localhost hostnames, plus the browser same-origin
|
|
9
|
-
* markers (sec-fetch-site and Origin) for the request-level fence.
|
|
10
|
-
*
|
|
11
|
-
* A reverse proxy in front of the host rewrites the Host header to its own
|
|
12
|
-
* upstream literal (a Cloudflare tunnel, frp and an nginx reverse proxy all
|
|
13
|
-
* dial 127.0.0.1:<port>), and the socket the origin sees is the proxy's, which
|
|
14
|
-
* is loopback by construction. Both halves of the fence then hold for a public
|
|
15
|
-
* request. Forwarding headers are the signal that a hop stands in between: a
|
|
16
|
-
* request that carries CF-Connecting-IP or X-Forwarded-For is answered through
|
|
17
|
-
* a proxy and is never treated as a local one (issue #1906).
|
|
18
|
-
*
|
|
19
|
-
* An operator who runs that proxy or tunnel themselves can opt into the
|
|
20
|
-
* narrower case: isForwardedLoopbackRequest describes a forwarded request that
|
|
21
|
-
* still landed on this machine's loopback upstream, and a route family admits
|
|
22
|
-
* it only behind its own default-off switch (issue #1918).
|
|
23
|
-
* @module dsh-web-shared/host/loopback
|
|
24
|
-
*/
|
|
25
|
-
import type { IncomingMessage } from 'node:http';
|
|
26
|
-
/** IPv4 127/8 predicate (four decimal octets, first == 127). */
|
|
27
|
-
export declare function isIPv4Loopback(v4: string): boolean;
|
|
28
|
-
/** Whether a socket remote address names the loopback range (127/8, ::1, IPv4-mapped). */
|
|
29
|
-
export declare function isLoopbackAddress(address: string | undefined): boolean;
|
|
30
|
-
/** Whether a normalized URL hostname names the loopback authority (localhost, [::1], 127/8). */
|
|
31
|
-
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether a reverse proxy stood between the client and this host: the request
|
|
34
|
-
* carries CF-Connecting-IP or X-Forwarded-For. Either header is stamped by a
|
|
35
|
-
* hop that forwards traffic, so the request did not originate on this machine.
|
|
36
|
-
* @param request - node HTTP request.
|
|
37
|
-
* @returns true when a forwarding header is present.
|
|
38
|
-
*/
|
|
39
|
-
export declare function isProxiedRequest(request: IncomingMessage): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Request-level trust fence: a loopback socket address AND a loopback Host
|
|
42
|
-
* header, plus browser same-origin markers. The socket address is
|
|
43
|
-
* authoritative for a direct connection; a request that carries a forwarding
|
|
44
|
-
* header is refused outright, because a proxy in front of the host makes both
|
|
45
|
-
* the socket address and the Host header describe the proxy rather than the
|
|
46
|
-
* client. X-Forwarded-For is therefore never evidence *for* loopback.
|
|
47
|
-
*/
|
|
48
|
-
export declare function isLoopbackRequest(request: IncomingMessage): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Whether a forwarded request landed on this machine's loopback upstream: a
|
|
51
|
-
* forwarding header (the proxy's own stamp), a loopback socket address (the
|
|
52
|
-
* proxy dials 127.0.0.1:<port>), and a loopback Host header (the proxy rewrote
|
|
53
|
-
* the authority to its upstream literal).
|
|
54
|
-
*
|
|
55
|
-
* This is a fact about the route, not a trust decision. A public request to a
|
|
56
|
-
* tunnel satisfies all three by construction, because the proxy is the client
|
|
57
|
-
* of this process: only a caller that operates the proxy can decide it stands
|
|
58
|
-
* for the browser, which is why every consumer keeps this behind an explicit
|
|
59
|
-
* default-off switch and its own browser markers. isLoopbackRequest is
|
|
60
|
-
* unchanged and still refuses a forwarded request (issue #1906).
|
|
61
|
-
* @param request - node HTTP request.
|
|
62
|
-
* @returns true when a forwarding header, a loopback socket, and a loopback Host all hold.
|
|
63
|
-
*/
|
|
64
|
-
export declare function isForwardedLoopbackRequest(request: IncomingMessage): boolean;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host single-instance guard shared by the plugin family. The family bundle
|
|
3
|
-
* (dsh-web-all / dsh-skins) namespaces every child row id (web-ui-*), so
|
|
4
|
-
* the loader accepts a standalone install of the same package side by side;
|
|
5
|
-
* without this guard the second instance would still re-register the same
|
|
6
|
-
* webserver routes, tools, settings namespaces, and system-prompt sections
|
|
7
|
-
* and fail the boot. mountOnce makes a mount of an already-mounted package a
|
|
8
|
-
* no-op for as long as the first instance lives (the browser half is already
|
|
9
|
-
* deduped by package name in the client module host).
|
|
10
|
-
*
|
|
11
|
-
* A no-op is only safe while the holder is ALIVE. The holder can be disposed
|
|
12
|
-
* long after the refused mount ran its course: the Host reloads a profile by
|
|
13
|
-
* creating the new loader entries before the old ones are torn down (a
|
|
14
|
-
* plugin-manager enable/disable/install write, a settings-driven row reload,
|
|
15
|
-
* HMR), so the new aggregate shell entry mounts its family plugin while the
|
|
16
|
-
* previous entry still owns the name. Dropping that refused mount lost the
|
|
17
|
-
* plugin for good - the previous entry then disposed its own mount, releasing
|
|
18
|
-
* the name with nobody left to take it, and the family row stayed listed as
|
|
19
|
-
* active while its host routes 404ed (the task-board panel showed
|
|
20
|
-
* "board.hostError.notMounted", no degraded record appeared, and only a Host
|
|
21
|
-
* restart recovered it).
|
|
22
|
-
*
|
|
23
|
-
* The refused mount is therefore QUEUED, not dropped, and replayed the moment
|
|
24
|
-
* the holder releases the name - if the waiting fiber is still alive then. The
|
|
25
|
-
* single-instance guarantee is unchanged: exactly one mount is live per
|
|
26
|
-
* package name, and the replay re-enters the guard so a later mount still
|
|
27
|
-
* dedupes against it.
|
|
28
|
-
*
|
|
29
|
-
* The registry rides a global symbol so two module instances of the same
|
|
30
|
-
* package (npm copy vs repository link) still share one verdict. That symbol
|
|
31
|
-
* is a CROSS-REPOSITORY contract, not this file's private state: the four
|
|
32
|
-
* satellite packages (dsh-skins / dsh-pet / dsh-presets /
|
|
33
|
-
* dsh-community-plugins) are separate repositories carrying their own copy of
|
|
34
|
-
* this guard, rebuilt on their own schedule, so the value under `MOUNTED`
|
|
35
|
-
* must keep the shape every published copy reads (a `Set` of package names
|
|
36
|
-
* with `has`/`add`/`delete`). The wait queues this guard added therefore live
|
|
37
|
-
* under their own additive key, and the registry reads back a `Set` even when
|
|
38
|
-
* some other build left a different value there. Changing `MOUNTED`'s shape
|
|
39
|
-
* in place broke that contract once: a satellite's legacy copy created a
|
|
40
|
-
* `Set`, the family's new copy read it as a `Map`, and every family row
|
|
41
|
-
* mounted after it failed with "claims.get is not a function".
|
|
42
|
-
*
|
|
43
|
-
* cordis `ctx.effect` runs its callback immediately and treats the callback's
|
|
44
|
-
* return value as the fiber disposer, so the unmarker is returned, not run.
|
|
45
|
-
*/
|
|
46
|
-
/**
|
|
47
|
-
* Wrap a cordis plugin apply so the package runs at most once per process.
|
|
48
|
-
* The first mount registers normally and releases the name when its fiber
|
|
49
|
-
* disposes; a mount refused while that name is held waits for the release and
|
|
50
|
-
* then runs, unless its own fiber disposes first.
|
|
51
|
-
* @param packageName - npm package identity shared by every install source.
|
|
52
|
-
* @param fn - the original plugin apply.
|
|
53
|
-
* @returns an apply of the same shape.
|
|
54
|
-
*/
|
|
55
|
-
export declare function mountOnce<T extends (...args: any[]) => unknown>(packageName: string, fn: T): T;
|