mcp-ssh-manager 4.0.1 → 4.0.2
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/CHANGELOG.md +47 -0
- package/Formula/ssh-manager.rb +2 -2
- package/README.md +6 -4
- package/brand/README.md +1 -0
- package/desktop/electron/electron-builder.yml +1 -0
- package/desktop/electron/local-shell.mjs +41 -0
- package/desktop/electron/main.js +7 -11
- package/desktop/electron/package-lock.json +2 -2
- package/desktop/electron/package.json +1 -1
- package/dist/ui/app.js +1 -1
- package/docs/MIGRATION.md +1 -1
- package/package.json +6 -3
- package/scripts/render-social-preview.mjs +36 -0
- package/server.json +2 -2
- package/src/config-loader.js +2 -1
- package/src/index.js +13 -5
- package/src/shell-quote.js +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.0.2] - 2026-11-01
|
|
11
|
+
|
|
12
|
+
**Commands reach a Mac, and the desktop terminal behaves like your own.**
|
|
13
|
+
A patch release: no setting, file or default changes for anyone upgrading
|
|
14
|
+
(the release pipeline upgrades 3.8.5, 3.8.6, 3.8.7, 4.0.0 and 4.0.1 from the
|
|
15
|
+
registry to this version and back). The desktop app updates itself from 4.0.x.
|
|
16
|
+
|
|
17
|
+
The Windows installer is **not Authenticode-signed** in this release either,
|
|
18
|
+
for the same reason as 4.0.0 (the public certificate waits on the company's
|
|
19
|
+
registration): Windows shows *"Windows protected your PC"*, *More info → Run
|
|
20
|
+
anyway*, and `ssh-manager app` checks the installer against the SHA-256 in
|
|
21
|
+
`release-manifest-win32.json`. macOS builds are signed and notarized.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- **Commands sent to a macOS server no longer fail before they start** (#115,
|
|
26
|
+
thanks to Henrik Tilly, @htilly). Every bounded command (`ssh_execute` and the
|
|
27
|
+
tools built on it) was wrapped in `timeout`, which a stock Mac does not have:
|
|
28
|
+
it failed with exit 127, `timeout: command not found`, whatever the command
|
|
29
|
+
was. The wrapper now finds `timeout` or Homebrew's `gtimeout` on the server
|
|
30
|
+
and, with neither, runs the command without it (the client-side limit still
|
|
31
|
+
applies). It works under any login shell, csh and tcsh included; Linux
|
|
32
|
+
servers still use their own `timeout`, with the same exit codes.
|
|
33
|
+
- **The desktop app's terminal starts a login shell.** Opened from the Dock or
|
|
34
|
+
Finder, the app only has macOS's bare `PATH`, and the terminal read none of the
|
|
35
|
+
profile files (`~/.zprofile`, `~/.bash_profile`) where Homebrew and most
|
|
36
|
+
installers add theirs: `brew`, `node` or any tool installed outside `/usr/bin`
|
|
37
|
+
answered "command not found" there while working in Terminal.app or Warp. The
|
|
38
|
+
shell is now started with `-l` on macOS and Linux.
|
|
39
|
+
- **The terminal keeps your keystrokes in order.** Each key went to the shell
|
|
40
|
+
on its own request, several at once, and the control plane wrote them as
|
|
41
|
+
they arrived: typed fast, or on a busy machine, `mo --help` could reach the
|
|
42
|
+
shell as `mo- elh-p`, a different command from the one on screen. Keystrokes
|
|
43
|
+
now leave one request at a time, in order, in every terminal (local and
|
|
44
|
+
remote, in the app and in `ssh-manager control`).
|
|
45
|
+
|
|
46
|
+
### Changed
|
|
47
|
+
|
|
48
|
+
- **The desktop app's terminal on Windows is PowerShell.** It opened `cmd.exe`
|
|
49
|
+
(what `COMSPEC` names on every Windows machine), the old Command Prompt.
|
|
50
|
+
It now starts Windows PowerShell (`powershell.exe`, present on Windows 10 and
|
|
51
|
+
11), the shell Windows Terminal opens by default. `cmd.exe` is still one
|
|
52
|
+
`cmd` away inside it.
|
|
53
|
+
- **Dependencies.** MCP SDK 1.32.2; dotenv 18, loaded quietly so it adds no line
|
|
54
|
+
to the log; `@hono/node-server` 2.1.5 (GHSA-rmxm-3fg6-px4f, in a part of the
|
|
55
|
+
SDK this stdio server never loads); CI actions and development tools.
|
|
56
|
+
|
|
10
57
|
## [4.0.1] - 2026-10-26
|
|
11
58
|
|
|
12
59
|
**The application tells you about updates, and nothing changes in the engine.**
|
package/Formula/ssh-manager.rb
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
class SshManager < Formula
|
|
14
14
|
desc "SSH server management for AI agents, with approval and audit"
|
|
15
15
|
homepage "https://github.com/bvisible/mcp-ssh-manager"
|
|
16
|
-
url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.0.
|
|
17
|
-
sha256 "
|
|
16
|
+
url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.0.1.tgz"
|
|
17
|
+
sha256 "c931cb956869345975c59f953329be71eb75c893b8810dbe6121f26ccedc1880"
|
|
18
18
|
license "MIT"
|
|
19
19
|
|
|
20
20
|
depends_on "node"
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
23
23
|
[](https://www.npmjs.com/package/mcp-ssh-manager)
|
|
24
|
-
[](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2)
|
|
25
25
|
[](https://claude.ai/code)
|
|
26
26
|
[](https://openai.com/codex)
|
|
27
27
|
[](https://modelcontextprotocol.io)
|
|
@@ -54,9 +54,9 @@ An MCP SSH server is the most dangerous tool you can hand an agent: a shell on m
|
|
|
54
54
|
|
|
55
55
|
## Choose your workspace
|
|
56
56
|
|
|
57
|
-
**Desktop application (`4.0.
|
|
57
|
+
**Desktop application (`4.0.2`):** one installation with its own runtime,
|
|
58
58
|
terminal, file browser and server settings. No separate Node.js or npm
|
|
59
|
-
installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.
|
|
59
|
+
installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2):
|
|
60
60
|
|
|
61
61
|
| Platform | File | Signature |
|
|
62
62
|
|---|---|---|
|
|
@@ -64,7 +64,7 @@ installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases
|
|
|
64
64
|
| Windows x64 / arm64 | `…-setup.exe` | **Not code-signed in 4.0.x.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
|
|
65
65
|
| Linux x64 | `.deb`, `.AppImage` | Unsigned, as Linux packages usually are |
|
|
66
66
|
|
|
67
|
-
**Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.0.
|
|
67
|
+
**Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.0.2,
|
|
68
68
|
and the V4 engine runs without an interface, from your existing `.env`, TOML or
|
|
69
69
|
process variables — no automatic import, no forced wizard, no approval prompt
|
|
70
70
|
unless you enable one per server. The one behaviour that tightens is **SSH
|
|
@@ -685,6 +685,8 @@ The hero animation ships twice, light and dark, swapped by `<picture>` on `prefe
|
|
|
685
685
|
|
|
686
686
|
## What's new
|
|
687
687
|
|
|
688
|
+
**[4.0.2](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2) — commands reach a Mac, and the desktop terminal is your own.** Commands sent to a macOS server no longer fail with `timeout: command not found` before they start (thanks to Henrik Tilly, [#115](https://github.com/bvisible/mcp-ssh-manager/pull/115)); the desktop terminal starts a login shell, so what Homebrew installed is found as in Terminal or Warp, and PowerShell on Windows; keystrokes reach the shell in the order they were typed; dependencies refreshed. Nothing to change on upgrade.
|
|
689
|
+
|
|
688
690
|
**[4.0.1](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.1) — the application tells you about updates.** *Options → Updates*, a mark on the sidebar and a notification once per version, so a new release no longer goes unnoticed in a menu you never open; a tidier Servers toolbar; the interface is built when the package is made rather than committed (what you install is byte for byte the same); and the npm, registry and GitHub descriptions say what V4 is. No change to the engine's behaviour.
|
|
689
691
|
|
|
690
692
|
**[4.0.0](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.0) — the control plane.** See what an agent is running on your servers, with its output, and stop it before it runs. A desktop application for macOS, Windows and Linux, installed from the engine with `ssh-manager app`; an encrypted vault for credentials; human approval per server; a shell on your own machine alongside the remote ones. Everything new is opt-in — an npm install upgraded from 3.8.x keeps behaving as 3.8.x, which [a test installs from the registry and proves](docs/TESTING-V4.md). The Windows application is not code-signed in this release. [What changes and how to go back](docs/MIGRATION.md).
|
package/brand/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
| `wordmark.svg` | The logo: **ssh** solid, **manager** outlined. Supplied, not derived. |
|
|
6
6
|
| `icon.svg` | The app icon — the mark on its tile. Everything else is generated from this. |
|
|
7
7
|
| `mark.svg` | The mark alone, no tile, `currentColor` for the white parts. |
|
|
8
|
+
| `social-preview.html` | The GitHub social preview (1280×640), rendered to `docs/images/social-preview.png` and `@2x` by `npm run brand:social`. The window in it is the README's own capture of the real application (`docs/images/v4-waiting-app.png`, made by the screenshot rig), so the image follows the interface when the rig is re-run. |
|
|
8
9
|
|
|
9
10
|
## The icon
|
|
10
11
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the desktop application starts for "a terminal on this machine": the
|
|
5
|
+
* file, its arguments and its environment. Kept apart from main.js so a plain
|
|
6
|
+
* Node test can run it (main.js needs Electron).
|
|
7
|
+
*
|
|
8
|
+
* It is the user's own shell, started as a *login* shell on macOS and Linux.
|
|
9
|
+
* An application opened from the Dock or Finder gets launchd's bare PATH
|
|
10
|
+
* (/usr/bin:/bin:/usr/sbin:/sbin), and the directories Homebrew and most
|
|
11
|
+
* installers add live in ~/.zprofile or ~/.bash_profile, which only a login
|
|
12
|
+
* shell reads. Without `-l`, `brew`, `node` or any tool installed outside
|
|
13
|
+
* /usr/bin was "command not found" here and fine in Terminal.app or Warp,
|
|
14
|
+
* which both start login shells.
|
|
15
|
+
*
|
|
16
|
+
* On Windows it is PowerShell, the shell Windows Terminal opens by default and
|
|
17
|
+
* the one people use there today. COMSPEC is not consulted: it names cmd.exe on
|
|
18
|
+
* every Windows machine, so it says nothing about what the user chose. Windows
|
|
19
|
+
* PowerShell (powershell.exe) ships with Windows 10 and 11, unlike PowerShell 7.
|
|
20
|
+
* It has no `-l`; it reads its own profile.
|
|
21
|
+
*
|
|
22
|
+
* @param {{ platform?: string, env?: Record<string, string|undefined> }} [options]
|
|
23
|
+
* @returns {{ file: string, args: string[], env: Record<string, string|undefined> }}
|
|
24
|
+
*/
|
|
25
|
+
export function localShellLaunch({ platform = process.platform, env = process.env } = {}) {
|
|
26
|
+
const file = platform === 'win32'
|
|
27
|
+
? 'powershell.exe'
|
|
28
|
+
: env.SHELL || (platform === 'darwin' ? '/bin/zsh' : '/bin/bash');
|
|
29
|
+
|
|
30
|
+
const childEnv = { ...env, TERM: 'xterm-256color' };
|
|
31
|
+
// Electron sets this when it runs as a plain Node process; inherited by a
|
|
32
|
+
// shell it makes every `electron` the user runs behave as node instead.
|
|
33
|
+
delete childEnv.ELECTRON_RUN_AS_NODE;
|
|
34
|
+
|
|
35
|
+
return { file, args: platform === 'win32' ? [] : ['-l'], env: childEnv };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The name the interface shows for the shell (`zsh`, `cmd.exe`). */
|
|
39
|
+
export function localShellName(file, platform = process.platform) {
|
|
40
|
+
return (platform === 'win32' ? path.win32 : path.posix).basename(file);
|
|
41
|
+
}
|
package/desktop/electron/main.js
CHANGED
|
@@ -29,6 +29,7 @@ import { createRequire } from 'module';
|
|
|
29
29
|
// electron-updater is CommonJS: named imports do not resolve through the bridge.
|
|
30
30
|
import electronUpdater from 'electron-updater';
|
|
31
31
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
32
|
+
import { localShellLaunch, localShellName } from './local-shell.mjs';
|
|
32
33
|
|
|
33
34
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
34
35
|
|
|
@@ -108,17 +109,12 @@ function localShellProvider() {
|
|
|
108
109
|
|
|
109
110
|
return async ({ cols, rows, cwd }) => {
|
|
110
111
|
// The user's own login shell, because that is what "a terminal on this
|
|
111
|
-
// machine" means to them — their aliases, their prompt, their PATH.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
// machine" means to them — their aliases, their prompt, their PATH. A
|
|
113
|
+
// login shell: opened from the Dock this process has launchd's bare PATH,
|
|
114
|
+
// and only a login shell reads the profile that adds Homebrew's.
|
|
115
|
+
const { file, args, env } = localShellLaunch();
|
|
115
116
|
|
|
116
|
-
const
|
|
117
|
-
// Electron sets this when it runs as a plain Node process; inherited by a
|
|
118
|
-
// shell it makes every `electron` the user runs behave as node instead.
|
|
119
|
-
delete env.ELECTRON_RUN_AS_NODE;
|
|
120
|
-
|
|
121
|
-
const term = pty.spawn(shellPath, [], {
|
|
117
|
+
const term = pty.spawn(file, args, {
|
|
122
118
|
name: 'xterm-256color',
|
|
123
119
|
cols,
|
|
124
120
|
rows,
|
|
@@ -127,7 +123,7 @@ function localShellProvider() {
|
|
|
127
123
|
});
|
|
128
124
|
|
|
129
125
|
return {
|
|
130
|
-
shell:
|
|
126
|
+
shell: localShellName(file),
|
|
131
127
|
onData: handler => term.onData(handler),
|
|
132
128
|
onExit: handler => term.onExit(() => handler()),
|
|
133
129
|
// node-pty writes strings. What arrives is the UTF-8 of exactly what the
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-manager-desktop",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "ssh-manager-desktop",
|
|
9
|
-
"version": "4.0.
|
|
9
|
+
"version": "4.0.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"electron-updater": "^6.8.9",
|
package/dist/ui/app.js
CHANGED
|
@@ -94,7 +94,7 @@ Error generating stack: `+c.message+`
|
|
|
94
94
|
*
|
|
95
95
|
* This source code is licensed under the MIT license found in the
|
|
96
96
|
* LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/var mx;function t3(){if(mx)return zm;mx=1;var e=Ch();function t(g,b){return g===b&&(g!==0||1/g===1/b)||g!==g&&b!==b}var s=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function f(g,b){var y=b(),x=n({inst:{value:y,getSnapshot:b}}),S=x[0].inst,E=x[1];return l(function(){S.value=y,S.getSnapshot=b,m(S)&&E({inst:S})},[g,y,b]),a(function(){return m(S)&&E({inst:S}),g(function(){m(S)&&E({inst:S})})},[g]),u(y),y}function m(g){var b=g.getSnapshot;g=g.value;try{var y=b();return!s(g,y)}catch{return!0}}function d(g,b){return b()}var _=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:f;return zm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:_,zm}var px;function i3(){return px||(px=1,Om.exports=t3()),Om.exports}var s3=i3();const r3=(e,t)=>{if(Un(t))return t;if(FM(t)&&Un(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const s=e[e.length-1];return typeof s=="function"?"":s}return e},n3={t:r3,ready:!1},a3=()=>()=>{},Zg=(e,t={})=>{var V,I,J;const{i18n:s}=t,{i18n:n,defaultNS:a}=w.useContext(JM)||{},l=s||n||ZM();l&&!l.reportNamespaces&&(l.reportNamespaces=new e3),l||Np(l,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const u=w.useMemo(()=>{var $;return{...GM(),...($=l==null?void 0:l.options)==null?void 0:$.react,...t}},[l,t]),{useSuspense:f,keyPrefix:m}=u,d=a||((V=l==null?void 0:l.options)==null?void 0:V.defaultNS),_=Un(d)?[d]:d||["translation"],g=w.useMemo(()=>_,_);(J=(I=l==null?void 0:l.reportNamespaces)==null?void 0:I.addUsedNamespaces)==null||J.call(I,g);const b=w.useRef(0),y=w.useCallback($=>{if(!l)return a3;const{bindI18n:B,bindI18nStore:K}=u,q=()=>{b.current+=1,$()};return B&&l.on(B,q),K&&l.store.on(K,q),()=>{B&&B.split(" ").forEach(M=>l.off(M,q)),K&&K.split(" ").forEach(M=>l.store.off(M,q))}},[l,u]),x=w.useRef(),S=w.useCallback(()=>{if(!l)return n3;const $=!!(l.isInitialized||l.initializedStoreOnce)&&g.every(U=>UM(U,l,u)),B=t.lng||l.language,K=b.current,q=x.current;if(q&&q.ready===$&&q.lng===B&&q.keyPrefix===m&&q.revision===K)return q;const H={t:l.getFixedT(B,u.nsMode==="fallback"?g:g[0],m),ready:$,lng:B,keyPrefix:m,revision:K};return x.current=H,H},[l,g,m,u,t.lng]),[E,k]=w.useState(0),{t:T,ready:D}=s3.useSyncExternalStore(y,S,S);w.useEffect(()=>{if(l&&!D&&!f){const $=()=>k(B=>B+1);t.lng?fx(l,t.lng,g,$):jp(l,g,$)}},[l,t.lng,g,D,f,E]);const R=l||{},z=w.useRef(null),L=w.useRef(),j=$=>{const B=Object.getOwnPropertyDescriptors($);B.__original&&delete B.__original;const K=Object.create(Object.getPrototypeOf($),B);if(!Object.prototype.hasOwnProperty.call(K,"__original"))try{Object.defineProperty(K,"__original",{value:$,writable:!1,enumerable:!1,configurable:!1})}catch{}return K},A=w.useMemo(()=>{const $=R,B=$==null?void 0:$.language;let K=$;$&&(z.current&&z.current.__original===$?L.current!==B?(K=j($),z.current=K,L.current=B):K=z.current:(K=j($),z.current=K,L.current=B));const q=!D&&!f?(...H)=>(Np(l,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),T(...H)):T,M=[q,K,D];return M.t=q,M.i18n=K,M.ready=D,M},[T,R,D,R.resolvedLanguage,R.language,R.languages]);if(l&&f&&!D)throw new Promise($=>{const B=()=>$();t.lng?fx(l,t.lng,g,B):jp(l,g,B)});return A},o3={browse:"Browse files",cancel:"Cancel",connect:"Connect SSH",delete:"Delete",edit:"Edit"},l3={columnModified:"Modified",columnName:"Name",columnSize:"Size",contextCompressZip:"Compress to Zip",contextCopyPath:"Copy Path",contextDelete:"Delete",contextDownload:"Download",contextExtractZip:"Extract Zip",contextGetInfo:"Get Info",contextNewFile:"New File",contextNewFolder:"New Folder",contextOpen:"Open",contextOpenTerminal:"Open Terminal",contextQuickLook:"Quick Look",contextRefresh:"Refresh",contextRename:"Rename",contextShowInFinder:"Show in Finder",contextUpload:"Upload",copyPath:"Copy path",download:"Download",emptyDirectory:"Empty directory",goUp:"Go up",hideHidden:"Hide hidden files",home:"Home (~)",modified:"Modified",name:"Name",newFolder:"New folder",openInCode:"Open in Code",openInEditor:"Open in editor",openTerminal:"Open terminal here",permissions:"Permissions",refresh:"Refresh",root:"Root (/)",setDefault:"Set as default directory",showHidden:"Show hidden files",size:"Size",statusHidden:"hidden",statusItems:"items",statusLink:"link",statusSelected:"selected",upload:"Upload"},c3={addFirst:"Add a server",dupDialog:{description:"A {{type}} session is already open for {{name}}.",goExisting:"Go to existing",openNew:"Open new",title:"Connection already open"},emptyDescription:"Connect to your SSH servers to manage files, run commands, and access your infrastructure remotely.",emptyTitle:"Add your first server",import:"Import",noResults:"No servers match your search",status:{browserActive:"File browser active",browserAndTerminal:"File browser + SSH terminal",terminalActive:"SSH terminal active"}},u3={actions:o3,files:l3,servers:c3};hi.use(QM).init({resources:{en:{translation:u3}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},returnEmptyString:!1});const h3=new URLSearchParams(window.location.search).get("token")??"";function Kt(e,t={}){const s=new URLSearchParams({token:h3});for(const[n,a]of Object.entries(t))a!==void 0&&s.set(n,String(a));return`${e}?${s}`}async function Pi(e,t){const s=await fetch(Kt(e,t));if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??s.statusText);return s.json()}async function qe(e,t,s){const n=await fetch(Kt(e,s),{method:"POST",headers:t===void 0?{}:{"content-type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)});if(!n.ok)throw new Error((await n.json().catch(()=>({}))).error??n.statusText);return n.json()}function d3(e){return{id:e.name,name:e.name,host:e.host,port:e.port??22,username:e.user??"",privateKey:e.keyPath,defaultDirectory:e.defaultDir,category:e.group,mode:e.mode,approval:e.approval,accounts:e.accounts,description:e.description,proxyJump:e.proxyJump,proxyCommand:e.proxyCommand,platform:e.platform,forwardAgent:e.forwardAgent,allowPatterns:e.allowPatterns,denyPatterns:e.denyPatterns,auditLog:e.auditLog}}const Lm={sources:()=>Pi("/api/import/sources"),preview:e=>qe("/api/import/preview",e),apply:e=>qe("/api/import/apply",{servers:e})},Ya={async list(){return(await Pi("/api/servers")).servers.map(d3)},async save(e){await qe("/api/servers",{name:e.name,host:e.host,port:e.port,user:e.username,password:e.password,keyPath:e.privateKey,passphrase:e.passphrase,defaultDir:e.defaultDirectory,group:e.category,mode:e.mode,approval:e.approval,description:e.description,proxyJump:e.proxyJump,proxyCommand:e.proxyCommand,platform:e.platform,forwardAgent:e.forwardAgent,allowPatterns:e.allowPatterns,denyPatterns:e.denyPatterns,auditLog:e.auditLog})},async remove(e){const t=await fetch(Kt("/api/servers",{name:e}),{method:"DELETE"});if(!t.ok)throw new Error(t.statusText)}},Pn={list:e=>Pi("/api/commands",{server:e}),save:async e=>(await qe("/api/commands",e)).command,remove:async e=>{const t=await fetch(Kt("/api/commands",{id:e}),{method:"DELETE"});if(!t.ok)throw new Error(t.statusText)}},Tp={state:()=>Pi("/api/migration"),run:e=>qe("/api/migration",{servers:e})},Ua={list:(e,t)=>Pi("/api/files",{server:e,path:t}),write:(e,t,s)=>qe("/api/files/write",{content:s},{server:e,path:t}),mkdir:(e,t)=>qe("/api/files/mkdir",{server:e,path:t}),rename:(e,t,s)=>qe("/api/files/rename",{server:e,from:t,to:s}),remove:(e,t,s)=>qe("/api/files/delete",{server:e,path:t,isDirectory:s}),downloadUrl:(e,t)=>Kt("/api/files/read",{server:e,path:t}),async upload(e,t,s){const n=await fetch(Kt("/api/files/write",{server:e,path:t}),{method:"POST",body:s});if(!n.ok)throw new Error((await n.json().catch(()=>({}))).error??n.statusText)}},Fa={list:e=>Pi("/api/local/files",{path:e}),mkdir:e=>qe("/api/local/mkdir",{path:e}),rename:(e,t)=>qe("/api/local/rename",{from:e,to:t}),remove:(e,t)=>qe("/api/local/delete",{path:e,isDirectory:t}),touch:e=>qe("/api/local/touch",{path:e}),reveal:e=>qe("/api/local/reveal",{path:e})},pC={start:e=>qe("/api/transfer",e)},f3=new TextEncoder,m3=e=>btoa(String.fromCharCode(...e)),p3=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),g3={async open(e,t,s){const{id:n}=await qe("/api/terminal",{...e,cols:t,rows:s}),a=new EventSource(Kt("/api/terminal/stream",{id:n}));let l=null;return a.onerror=()=>{a.readyState===EventSource.CLOSED&&(l==null||l())},{id:n,write:u=>{fetch(Kt("/api/terminal/input",{id:n}),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({data:m3(f3.encode(u))})})},resize:(u,f)=>{fetch(Kt("/api/terminal/resize",{id:n}),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({cols:u,rows:f})})},onData:u=>{const f=m=>u(p3(JSON.parse(m.data).chunk));return a.addEventListener("message",f),()=>a.removeEventListener("message",f)},onExit:u=>{l=u},close:async()=>{a.close(),await fetch(Kt("/api/terminal",{id:n}),{method:"DELETE"})}}}},gx={get:(e=500)=>Pi("/api/history",{limit:e}),clear:async()=>{const e=await fetch(Kt("/api/history"),{method:"DELETE"});if(!e.ok)throw new Error(e.statusText)}},Rp={get:()=>Pi("/api/thresholds"),save:e=>qe("/api/thresholds",e)},v3={check:e=>qe("/api/health",void 0,{name:e})},Mp={save:e=>qe("/api/groups",e),remove:async e=>{const t=await fetch(Kt("/api/groups",{name:e}),{method:"DELETE"});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error??t.statusText)},run:(e,t)=>qe("/api/groups/run",{group:e,command:t})},_3={forget:async(e,t)=>{const s=await fetch(Kt("/api/hostkey",{host:e,port:t}),{method:"DELETE"});if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??s.statusText)}},gC=["pending","resolved","expired"],Nl=new Set;let er=null,Ap="connecting";function vx(e){Ap=e;for(const t of[...Nl])t({type:"connection",status:e})}const Tt={get:()=>Pi("/api/state"),streams:()=>Pi("/api/streams"),options:()=>Pi("/api/options"),decide:(e,t)=>qe("/api/decide",{id:e,decision:t?"allow":"deny"}),subscribe(e){return Nl.add(e),er||(er=new EventSource(Kt("/api/events")),Ap="connecting",er.addEventListener("open",()=>vx("connected")),er.addEventListener("error",()=>vx("disconnected")),er.addEventListener("message",t=>{let s;try{s=JSON.parse(t.data)}catch{return}for(const n of[...Nl])n(s)})),e({type:"connection",status:Ap}),()=>{Nl.delete(e),Nl.size===0&&(er==null||er.close(),er=null)}}},Bm={status:async()=>{const e=await fetch(Kt("/api/desktop"));if(e.status===404)return null;if(!e.ok)throw new Error((await e.json().catch(()=>({}))).error??e.statusText);return e.json()},install:()=>qe("/api/desktop/install"),open:()=>qe("/api/desktop/open")},_x={status:()=>Pi("/api/agents"),use:(e,t)=>qe("/api/agents/use",{client:e,engine:t})},Mu={status:async()=>{const e=await fetch(Kt("/api/app-update"));if(e.status===404)return null;if(!e.ok)throw new Error((await e.json().catch(()=>({}))).error??e.statusText);return e.json()},check:()=>qe("/api/app-update/check"),download:()=>qe("/api/app-update/download"),install:()=>qe("/api/app-update/install")},gl={status:()=>Pi("/api/vault/status"),backup:e=>qe("/api/vault/backup",{passphrase:e}),preview:(e,t)=>qe("/api/vault/restore",{content:e,passphrase:t}),restore:(e,t,s)=>qe("/api/vault/restore",{content:e,passphrase:t,revision:s,confirm:!0})};let eo={};async function y3(){try{const e=await fetch(Kt("/api/preferences"));if(!e.ok)return;const{preferences:t}=await e.json();if(t&&typeof t=="object"){eo={...eo,...t};for(const[s,n]of Object.entries(eo))try{localStorage.setItem(s,String(n))}catch{}}}catch{}}function vo(e){if(e in eo)return eo[e];try{return localStorage.getItem(e)}catch{return null}}function _o(e,t){eo[e]=t;try{localStorage.setItem(e,t)}catch{}fetch(Kt("/api/preferences"),{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:t})}).catch(()=>{})}const yx=e=>{let t;const s=new Set,n=(d,_)=>{const g=typeof d=="function"?d(t):d;if(!Object.is(g,t)){const b=t;t=_??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(y=>y(t,b))}},a=()=>t,f={setState:n,getState:a,getInitialState:()=>m,subscribe:d=>(s.add(d),()=>s.delete(d))},m=t=e(n,a,f);return f},b3=(e=>e?yx(e):yx),x3=e=>e;function S3(e,t=x3){const s=ci.useSyncExternalStore(e.subscribe,ci.useCallback(()=>t(e.getState()),[e,t]),ci.useCallback(()=>t(e.getInitialState()),[e,t]));return ci.useDebugValue(s),s}const bx=e=>{const t=b3(e),s=n=>S3(t,n);return Object.assign(s,t),s},Gl=(e=>e?bx(e):bx),vC="ssh-manager.theme",_C=()=>window.matchMedia("(prefers-color-scheme: dark)");function Xu(){try{return _C().matches?"dark":"light"}catch{return"light"}}function yC(){const e=vo(vC);return e==="light"||e==="dark"?e:"system"}function Zu(e){document.documentElement.classList.toggle("dark",e==="dark"),document.documentElement.style.colorScheme=e}const Uh=Gl(e=>{const t=yC(),s=t==="system"?Xu():t;Zu(s);try{_C().addEventListener("change",()=>{e(n=>{if(n.mode!=="system")return n;const a=Xu();return Zu(a),{resolved:a}})})}catch{}return{mode:t,resolved:s,setMode:n=>{const a=n==="system"?Xu():n;Zu(a),_o(vC,n),e({mode:n,resolved:a})}}});function w3(){const e=yC(),t=e==="system"?Xu():e;Zu(t),Uh.setState({mode:e,resolved:t})}const bC="ssh-manager.sidebar-expanded";function xC(){return vo(bC)!=="false"}const Ie=Gl((e,t)=>({view:"servers",tabs:[],activeTabId:null,expanded:xC(),pendingCount:0,handedOver:!1,setHandedOver:s=>e({handedOver:s}),setView:s=>e({view:s,activeTabId:null}),optionsTab:"appearance",setOptionsTab:s=>e({optionsTab:s}),wantsImport:!1,setWantsImport:s=>e({wantsImport:s}),wantsAdd:!1,setWantsAdd:s=>e({wantsAdd:s}),serverDraft:null,setServerDraft:s=>e({serverDraft:s}),addTab:s=>{const n=t().tabs.find(l=>l.id===s.id);if(n)return e({activeTabId:n.id});const a={closable:!0,...s};e(l=>({tabs:[...l.tabs,a],activeTabId:a.id}))},activateTab:s=>e({activeTabId:s}),removeTab:s=>e(n=>{var u;const a=n.tabs.filter(f=>f.id!==s),l=n.activeTabId===s?((u=a.at(-1))==null?void 0:u.id)??null:n.activeTabId;return{tabs:a,activeTabId:l}}),updateTab:(s,n)=>e(a=>({tabs:a.tabs.map(l=>l.id===s?{...l,...n}:l)})),toggleExpanded:()=>e(s=>{const n=!s.expanded;return _o(bC,String(n)),{expanded:n}}),setPendingCount:s=>e({pendingCount:s})}));function C3(){Ie.setState({expanded:xC()})}const SC="ssh-manager.view-settings";function wC(){try{const e=JSON.parse(vo(SC)??"{}");return{serverViewMode:(e==null?void 0:e.serverViewMode)==="list"?"list":"grid",collapsedCategories:Array.isArray(e==null?void 0:e.collapsedCategories)?e.collapsedCategories.filter(t=>typeof t=="string"):[]}}catch{return{}}}const $l=Gl((e,t)=>({serverViewMode:"grid",collapsedCategories:[],...wC(),toggleCategoryCollapse:s=>{const{collapsedCategories:n}=t(),a=n.includes(s)?n.filter(l=>l!==s):[...n,s];t().updateSetting("collapsedCategories",a)},updateSetting:(s,n)=>{e({[s]:n});const{serverViewMode:a,collapsedCategories:l}=t();_o(SC,JSON.stringify({serverViewMode:a,collapsedCategories:l}))}}));function E3(){$l.setState({serverViewMode:"grid",collapsedCategories:[],...wC()})}const zt=Gl((e,t)=>({servers:[],loading:!0,error:null,searchQuery:"",categoryFilter:null,viewMode:"grid",editMode:!1,sortBy:"name",sortDirection:"asc",setSearchQuery:s=>e({searchQuery:s}),setCategoryFilter:s=>e({categoryFilter:s}),setViewMode:s=>{$l.getState().updateSetting("serverViewMode",s),e({viewMode:s})},setEditMode:s=>e({editMode:s}),setSortBy:s=>e({sortBy:s}),setSortDirection:s=>e({sortDirection:s}),load:async()=>{try{e({servers:await Ya.list(),loading:!1,error:null})}catch(s){e({loading:!1,error:s.message})}},save:async s=>{await Ya.save(s),e({servers:await Ya.list()})},remove:async s=>{await Ya.remove(s),e({servers:await Ya.list()})},getFilteredServers:()=>{const{servers:s,searchQuery:n,sortBy:a,sortDirection:l}=t();let u=s;if(n.trim()){const f=n.toLowerCase();u=s.filter(m=>m.name.toLowerCase().includes(f)||m.host.toLowerCase().includes(f)||m.username.toLowerCase().includes(f)||(m.category||"").toLowerCase().includes(f))}return[...u].sort((f,m)=>{const d=a==="host"?f.host.localeCompare(m.host):f.name.localeCompare(m.name);return l==="asc"?d:-d})},getServersByCategory:()=>{const{categoryFilter:s}=t(),n=new Map;for(const a of t().getFilteredServers()){const l=a.category||"Uncategorized";s!==null&&l!==s||(n.has(l)||n.set(l,[]),n.get(l).push(a))}return n}}));/**
|
|
97
|
+
*/var mx;function t3(){if(mx)return zm;mx=1;var e=Ch();function t(g,b){return g===b&&(g!==0||1/g===1/b)||g!==g&&b!==b}var s=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function f(g,b){var y=b(),x=n({inst:{value:y,getSnapshot:b}}),S=x[0].inst,E=x[1];return l(function(){S.value=y,S.getSnapshot=b,m(S)&&E({inst:S})},[g,y,b]),a(function(){return m(S)&&E({inst:S}),g(function(){m(S)&&E({inst:S})})},[g]),u(y),y}function m(g){var b=g.getSnapshot;g=g.value;try{var y=b();return!s(g,y)}catch{return!0}}function d(g,b){return b()}var _=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:f;return zm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:_,zm}var px;function i3(){return px||(px=1,Om.exports=t3()),Om.exports}var s3=i3();const r3=(e,t)=>{if(Un(t))return t;if(FM(t)&&Un(t.defaultValue))return t.defaultValue;if(typeof e=="function")return"";if(Array.isArray(e)){const s=e[e.length-1];return typeof s=="function"?"":s}return e},n3={t:r3,ready:!1},a3=()=>()=>{},Zg=(e,t={})=>{var V,I,J;const{i18n:s}=t,{i18n:n,defaultNS:a}=w.useContext(JM)||{},l=s||n||ZM();l&&!l.reportNamespaces&&(l.reportNamespaces=new e3),l||Np(l,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const u=w.useMemo(()=>{var $;return{...GM(),...($=l==null?void 0:l.options)==null?void 0:$.react,...t}},[l,t]),{useSuspense:f,keyPrefix:m}=u,d=a||((V=l==null?void 0:l.options)==null?void 0:V.defaultNS),_=Un(d)?[d]:d||["translation"],g=w.useMemo(()=>_,_);(J=(I=l==null?void 0:l.reportNamespaces)==null?void 0:I.addUsedNamespaces)==null||J.call(I,g);const b=w.useRef(0),y=w.useCallback($=>{if(!l)return a3;const{bindI18n:B,bindI18nStore:K}=u,q=()=>{b.current+=1,$()};return B&&l.on(B,q),K&&l.store.on(K,q),()=>{B&&B.split(" ").forEach(M=>l.off(M,q)),K&&K.split(" ").forEach(M=>l.store.off(M,q))}},[l,u]),x=w.useRef(),S=w.useCallback(()=>{if(!l)return n3;const $=!!(l.isInitialized||l.initializedStoreOnce)&&g.every(U=>UM(U,l,u)),B=t.lng||l.language,K=b.current,q=x.current;if(q&&q.ready===$&&q.lng===B&&q.keyPrefix===m&&q.revision===K)return q;const H={t:l.getFixedT(B,u.nsMode==="fallback"?g:g[0],m),ready:$,lng:B,keyPrefix:m,revision:K};return x.current=H,H},[l,g,m,u,t.lng]),[E,k]=w.useState(0),{t:T,ready:D}=s3.useSyncExternalStore(y,S,S);w.useEffect(()=>{if(l&&!D&&!f){const $=()=>k(B=>B+1);t.lng?fx(l,t.lng,g,$):jp(l,g,$)}},[l,t.lng,g,D,f,E]);const R=l||{},z=w.useRef(null),L=w.useRef(),j=$=>{const B=Object.getOwnPropertyDescriptors($);B.__original&&delete B.__original;const K=Object.create(Object.getPrototypeOf($),B);if(!Object.prototype.hasOwnProperty.call(K,"__original"))try{Object.defineProperty(K,"__original",{value:$,writable:!1,enumerable:!1,configurable:!1})}catch{}return K},A=w.useMemo(()=>{const $=R,B=$==null?void 0:$.language;let K=$;$&&(z.current&&z.current.__original===$?L.current!==B?(K=j($),z.current=K,L.current=B):K=z.current:(K=j($),z.current=K,L.current=B));const q=!D&&!f?(...H)=>(Np(l,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),T(...H)):T,M=[q,K,D];return M.t=q,M.i18n=K,M.ready=D,M},[T,R,D,R.resolvedLanguage,R.language,R.languages]);if(l&&f&&!D)throw new Promise($=>{const B=()=>$();t.lng?fx(l,t.lng,g,B):jp(l,g,B)});return A},o3={browse:"Browse files",cancel:"Cancel",connect:"Connect SSH",delete:"Delete",edit:"Edit"},l3={columnModified:"Modified",columnName:"Name",columnSize:"Size",contextCompressZip:"Compress to Zip",contextCopyPath:"Copy Path",contextDelete:"Delete",contextDownload:"Download",contextExtractZip:"Extract Zip",contextGetInfo:"Get Info",contextNewFile:"New File",contextNewFolder:"New Folder",contextOpen:"Open",contextOpenTerminal:"Open Terminal",contextQuickLook:"Quick Look",contextRefresh:"Refresh",contextRename:"Rename",contextShowInFinder:"Show in Finder",contextUpload:"Upload",copyPath:"Copy path",download:"Download",emptyDirectory:"Empty directory",goUp:"Go up",hideHidden:"Hide hidden files",home:"Home (~)",modified:"Modified",name:"Name",newFolder:"New folder",openInCode:"Open in Code",openInEditor:"Open in editor",openTerminal:"Open terminal here",permissions:"Permissions",refresh:"Refresh",root:"Root (/)",setDefault:"Set as default directory",showHidden:"Show hidden files",size:"Size",statusHidden:"hidden",statusItems:"items",statusLink:"link",statusSelected:"selected",upload:"Upload"},c3={addFirst:"Add a server",dupDialog:{description:"A {{type}} session is already open for {{name}}.",goExisting:"Go to existing",openNew:"Open new",title:"Connection already open"},emptyDescription:"Connect to your SSH servers to manage files, run commands, and access your infrastructure remotely.",emptyTitle:"Add your first server",import:"Import",noResults:"No servers match your search",status:{browserActive:"File browser active",browserAndTerminal:"File browser + SSH terminal",terminalActive:"SSH terminal active"}},u3={actions:o3,files:l3,servers:c3};hi.use(QM).init({resources:{en:{translation:u3}},lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},returnEmptyString:!1});const h3=new URLSearchParams(window.location.search).get("token")??"";function Kt(e,t={}){const s=new URLSearchParams({token:h3});for(const[n,a]of Object.entries(t))a!==void 0&&s.set(n,String(a));return`${e}?${s}`}async function Pi(e,t){const s=await fetch(Kt(e,t));if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??s.statusText);return s.json()}async function qe(e,t,s){const n=await fetch(Kt(e,s),{method:"POST",headers:t===void 0?{}:{"content-type":"application/json"},body:t===void 0?void 0:JSON.stringify(t)});if(!n.ok)throw new Error((await n.json().catch(()=>({}))).error??n.statusText);return n.json()}function d3(e){return{id:e.name,name:e.name,host:e.host,port:e.port??22,username:e.user??"",privateKey:e.keyPath,defaultDirectory:e.defaultDir,category:e.group,mode:e.mode,approval:e.approval,accounts:e.accounts,description:e.description,proxyJump:e.proxyJump,proxyCommand:e.proxyCommand,platform:e.platform,forwardAgent:e.forwardAgent,allowPatterns:e.allowPatterns,denyPatterns:e.denyPatterns,auditLog:e.auditLog}}const Lm={sources:()=>Pi("/api/import/sources"),preview:e=>qe("/api/import/preview",e),apply:e=>qe("/api/import/apply",{servers:e})},Ya={async list(){return(await Pi("/api/servers")).servers.map(d3)},async save(e){await qe("/api/servers",{name:e.name,host:e.host,port:e.port,user:e.username,password:e.password,keyPath:e.privateKey,passphrase:e.passphrase,defaultDir:e.defaultDirectory,group:e.category,mode:e.mode,approval:e.approval,description:e.description,proxyJump:e.proxyJump,proxyCommand:e.proxyCommand,platform:e.platform,forwardAgent:e.forwardAgent,allowPatterns:e.allowPatterns,denyPatterns:e.denyPatterns,auditLog:e.auditLog})},async remove(e){const t=await fetch(Kt("/api/servers",{name:e}),{method:"DELETE"});if(!t.ok)throw new Error(t.statusText)}},Pn={list:e=>Pi("/api/commands",{server:e}),save:async e=>(await qe("/api/commands",e)).command,remove:async e=>{const t=await fetch(Kt("/api/commands",{id:e}),{method:"DELETE"});if(!t.ok)throw new Error(t.statusText)}},Tp={state:()=>Pi("/api/migration"),run:e=>qe("/api/migration",{servers:e})},Ua={list:(e,t)=>Pi("/api/files",{server:e,path:t}),write:(e,t,s)=>qe("/api/files/write",{content:s},{server:e,path:t}),mkdir:(e,t)=>qe("/api/files/mkdir",{server:e,path:t}),rename:(e,t,s)=>qe("/api/files/rename",{server:e,from:t,to:s}),remove:(e,t,s)=>qe("/api/files/delete",{server:e,path:t,isDirectory:s}),downloadUrl:(e,t)=>Kt("/api/files/read",{server:e,path:t}),async upload(e,t,s){const n=await fetch(Kt("/api/files/write",{server:e,path:t}),{method:"POST",body:s});if(!n.ok)throw new Error((await n.json().catch(()=>({}))).error??n.statusText)}},Fa={list:e=>Pi("/api/local/files",{path:e}),mkdir:e=>qe("/api/local/mkdir",{path:e}),rename:(e,t)=>qe("/api/local/rename",{from:e,to:t}),remove:(e,t)=>qe("/api/local/delete",{path:e,isDirectory:t}),touch:e=>qe("/api/local/touch",{path:e}),reveal:e=>qe("/api/local/reveal",{path:e})},pC={start:e=>qe("/api/transfer",e)},f3=new TextEncoder,m3=e=>btoa(String.fromCharCode(...e)),p3=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)),g3={async open(e,t,s){const{id:n}=await qe("/api/terminal",{...e,cols:t,rows:s}),a=new EventSource(Kt("/api/terminal/stream",{id:n}));let l=null;a.onerror=()=>{a.readyState===EventSource.CLOSED&&(l==null||l())};let u="",f=!1;const m=async()=>{f=!0;try{for(;u;){const d=u;u="";try{await fetch(Kt("/api/terminal/input",{id:n}),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({data:m3(f3.encode(d))})})}catch{}}}finally{f=!1}};return{id:n,write:d=>{u+=d,f||m()},resize:(d,_)=>{fetch(Kt("/api/terminal/resize",{id:n}),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({cols:d,rows:_})})},onData:d=>{const _=g=>d(p3(JSON.parse(g.data).chunk));return a.addEventListener("message",_),()=>a.removeEventListener("message",_)},onExit:d=>{l=d},close:async()=>{a.close(),await fetch(Kt("/api/terminal",{id:n}),{method:"DELETE"})}}}},gx={get:(e=500)=>Pi("/api/history",{limit:e}),clear:async()=>{const e=await fetch(Kt("/api/history"),{method:"DELETE"});if(!e.ok)throw new Error(e.statusText)}},Rp={get:()=>Pi("/api/thresholds"),save:e=>qe("/api/thresholds",e)},v3={check:e=>qe("/api/health",void 0,{name:e})},Mp={save:e=>qe("/api/groups",e),remove:async e=>{const t=await fetch(Kt("/api/groups",{name:e}),{method:"DELETE"});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error??t.statusText)},run:(e,t)=>qe("/api/groups/run",{group:e,command:t})},_3={forget:async(e,t)=>{const s=await fetch(Kt("/api/hostkey",{host:e,port:t}),{method:"DELETE"});if(!s.ok)throw new Error((await s.json().catch(()=>({}))).error??s.statusText)}},gC=["pending","resolved","expired"],Nl=new Set;let er=null,Ap="connecting";function vx(e){Ap=e;for(const t of[...Nl])t({type:"connection",status:e})}const Tt={get:()=>Pi("/api/state"),streams:()=>Pi("/api/streams"),options:()=>Pi("/api/options"),decide:(e,t)=>qe("/api/decide",{id:e,decision:t?"allow":"deny"}),subscribe(e){return Nl.add(e),er||(er=new EventSource(Kt("/api/events")),Ap="connecting",er.addEventListener("open",()=>vx("connected")),er.addEventListener("error",()=>vx("disconnected")),er.addEventListener("message",t=>{let s;try{s=JSON.parse(t.data)}catch{return}for(const n of[...Nl])n(s)})),e({type:"connection",status:Ap}),()=>{Nl.delete(e),Nl.size===0&&(er==null||er.close(),er=null)}}},Bm={status:async()=>{const e=await fetch(Kt("/api/desktop"));if(e.status===404)return null;if(!e.ok)throw new Error((await e.json().catch(()=>({}))).error??e.statusText);return e.json()},install:()=>qe("/api/desktop/install"),open:()=>qe("/api/desktop/open")},_x={status:()=>Pi("/api/agents"),use:(e,t)=>qe("/api/agents/use",{client:e,engine:t})},Mu={status:async()=>{const e=await fetch(Kt("/api/app-update"));if(e.status===404)return null;if(!e.ok)throw new Error((await e.json().catch(()=>({}))).error??e.statusText);return e.json()},check:()=>qe("/api/app-update/check"),download:()=>qe("/api/app-update/download"),install:()=>qe("/api/app-update/install")},gl={status:()=>Pi("/api/vault/status"),backup:e=>qe("/api/vault/backup",{passphrase:e}),preview:(e,t)=>qe("/api/vault/restore",{content:e,passphrase:t}),restore:(e,t,s)=>qe("/api/vault/restore",{content:e,passphrase:t,revision:s,confirm:!0})};let eo={};async function y3(){try{const e=await fetch(Kt("/api/preferences"));if(!e.ok)return;const{preferences:t}=await e.json();if(t&&typeof t=="object"){eo={...eo,...t};for(const[s,n]of Object.entries(eo))try{localStorage.setItem(s,String(n))}catch{}}}catch{}}function vo(e){if(e in eo)return eo[e];try{return localStorage.getItem(e)}catch{return null}}function _o(e,t){eo[e]=t;try{localStorage.setItem(e,t)}catch{}fetch(Kt("/api/preferences"),{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:t})}).catch(()=>{})}const yx=e=>{let t;const s=new Set,n=(d,_)=>{const g=typeof d=="function"?d(t):d;if(!Object.is(g,t)){const b=t;t=_??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(y=>y(t,b))}},a=()=>t,f={setState:n,getState:a,getInitialState:()=>m,subscribe:d=>(s.add(d),()=>s.delete(d))},m=t=e(n,a,f);return f},b3=(e=>e?yx(e):yx),x3=e=>e;function S3(e,t=x3){const s=ci.useSyncExternalStore(e.subscribe,ci.useCallback(()=>t(e.getState()),[e,t]),ci.useCallback(()=>t(e.getInitialState()),[e,t]));return ci.useDebugValue(s),s}const bx=e=>{const t=b3(e),s=n=>S3(t,n);return Object.assign(s,t),s},Gl=(e=>e?bx(e):bx),vC="ssh-manager.theme",_C=()=>window.matchMedia("(prefers-color-scheme: dark)");function Xu(){try{return _C().matches?"dark":"light"}catch{return"light"}}function yC(){const e=vo(vC);return e==="light"||e==="dark"?e:"system"}function Zu(e){document.documentElement.classList.toggle("dark",e==="dark"),document.documentElement.style.colorScheme=e}const Uh=Gl(e=>{const t=yC(),s=t==="system"?Xu():t;Zu(s);try{_C().addEventListener("change",()=>{e(n=>{if(n.mode!=="system")return n;const a=Xu();return Zu(a),{resolved:a}})})}catch{}return{mode:t,resolved:s,setMode:n=>{const a=n==="system"?Xu():n;Zu(a),_o(vC,n),e({mode:n,resolved:a})}}});function w3(){const e=yC(),t=e==="system"?Xu():e;Zu(t),Uh.setState({mode:e,resolved:t})}const bC="ssh-manager.sidebar-expanded";function xC(){return vo(bC)!=="false"}const Ie=Gl((e,t)=>({view:"servers",tabs:[],activeTabId:null,expanded:xC(),pendingCount:0,handedOver:!1,setHandedOver:s=>e({handedOver:s}),setView:s=>e({view:s,activeTabId:null}),optionsTab:"appearance",setOptionsTab:s=>e({optionsTab:s}),wantsImport:!1,setWantsImport:s=>e({wantsImport:s}),wantsAdd:!1,setWantsAdd:s=>e({wantsAdd:s}),serverDraft:null,setServerDraft:s=>e({serverDraft:s}),addTab:s=>{const n=t().tabs.find(l=>l.id===s.id);if(n)return e({activeTabId:n.id});const a={closable:!0,...s};e(l=>({tabs:[...l.tabs,a],activeTabId:a.id}))},activateTab:s=>e({activeTabId:s}),removeTab:s=>e(n=>{var u;const a=n.tabs.filter(f=>f.id!==s),l=n.activeTabId===s?((u=a.at(-1))==null?void 0:u.id)??null:n.activeTabId;return{tabs:a,activeTabId:l}}),updateTab:(s,n)=>e(a=>({tabs:a.tabs.map(l=>l.id===s?{...l,...n}:l)})),toggleExpanded:()=>e(s=>{const n=!s.expanded;return _o(bC,String(n)),{expanded:n}}),setPendingCount:s=>e({pendingCount:s})}));function C3(){Ie.setState({expanded:xC()})}const SC="ssh-manager.view-settings";function wC(){try{const e=JSON.parse(vo(SC)??"{}");return{serverViewMode:(e==null?void 0:e.serverViewMode)==="list"?"list":"grid",collapsedCategories:Array.isArray(e==null?void 0:e.collapsedCategories)?e.collapsedCategories.filter(t=>typeof t=="string"):[]}}catch{return{}}}const $l=Gl((e,t)=>({serverViewMode:"grid",collapsedCategories:[],...wC(),toggleCategoryCollapse:s=>{const{collapsedCategories:n}=t(),a=n.includes(s)?n.filter(l=>l!==s):[...n,s];t().updateSetting("collapsedCategories",a)},updateSetting:(s,n)=>{e({[s]:n});const{serverViewMode:a,collapsedCategories:l}=t();_o(SC,JSON.stringify({serverViewMode:a,collapsedCategories:l}))}}));function E3(){$l.setState({serverViewMode:"grid",collapsedCategories:[],...wC()})}const zt=Gl((e,t)=>({servers:[],loading:!0,error:null,searchQuery:"",categoryFilter:null,viewMode:"grid",editMode:!1,sortBy:"name",sortDirection:"asc",setSearchQuery:s=>e({searchQuery:s}),setCategoryFilter:s=>e({categoryFilter:s}),setViewMode:s=>{$l.getState().updateSetting("serverViewMode",s),e({viewMode:s})},setEditMode:s=>e({editMode:s}),setSortBy:s=>e({sortBy:s}),setSortDirection:s=>e({sortDirection:s}),load:async()=>{try{e({servers:await Ya.list(),loading:!1,error:null})}catch(s){e({loading:!1,error:s.message})}},save:async s=>{await Ya.save(s),e({servers:await Ya.list()})},remove:async s=>{await Ya.remove(s),e({servers:await Ya.list()})},getFilteredServers:()=>{const{servers:s,searchQuery:n,sortBy:a,sortDirection:l}=t();let u=s;if(n.trim()){const f=n.toLowerCase();u=s.filter(m=>m.name.toLowerCase().includes(f)||m.host.toLowerCase().includes(f)||m.username.toLowerCase().includes(f)||(m.category||"").toLowerCase().includes(f))}return[...u].sort((f,m)=>{const d=a==="host"?f.host.localeCompare(m.host):f.name.localeCompare(m.name);return l==="asc"?d:-d})},getServersByCategory:()=>{const{categoryFilter:s}=t(),n=new Map;for(const a of t().getFilteredServers()){const l=a.category||"Uncategorized";s!==null&&l!==s||(n.has(l)||n.set(l,[]),n.get(l).push(a))}return n}}));/**
|
|
98
98
|
* @license lucide-react v0.474.0 - ISC
|
|
99
99
|
*
|
|
100
100
|
* This source code is licensed under the ISC license.
|
package/docs/MIGRATION.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Upgrading from 3.8 to 4.0
|
|
2
2
|
|
|
3
|
-
**4.0 is released, on npm and as a desktop application**; the latest is 4.0.
|
|
3
|
+
**4.0 is released, on npm and as a desktop application**; the latest is 4.0.2 ([release](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2)).
|
|
4
4
|
The last 3.8 release is 3.8.7, for anyone who pins the 3.8 line.
|
|
5
5
|
|
|
6
6
|
The upgrade path preserves headless npm/CLI use. The application, vault import
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-ssh-manager",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"mcpName": "io.github.bvisible/mcp-ssh-manager",
|
|
5
5
|
"description": "MCP server for SSH: let AI agents (Claude Code, Codex, any MCP client) run commands, transfer files and manage servers over SSH, with human approval, an encrypted vault and a live audit trail.",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"setup": "npm install && pip install -r tools/requirements.txt",
|
|
15
15
|
"configure": "python tools/server-manager.py",
|
|
16
16
|
"test-connection": "python tools/test-connection.py",
|
|
17
|
-
"test": "npm run test:lockfile && npm run test:sudostdin && npm run test:vault && npm run test:recovery && npm run test:upgrade && npm run test:notify && npm run test:commands && npm run test:commandlog && npm run test:portability && npm run test:approval && npm run test:controlplane && npm run test:terminal && npm run test:files && npm run test:livestream && npm run test:skills && npm run test:redaction && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:policynames && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:certpath && npm run test:agentannounce && npm run test:autherrors && npm run test:envchoice && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:quoteprops && npm run test:backupinjection && npm run test:dbrowcount && npm run test:migration && npm run test:security && npm run test:hostkeys && npm run test:proxy && npm run test:working-directory && npm run test:groups-persistence && npm run test:release && npm run test:cli-experience && npm run test:desktop-install && npm run test:agent-clients && npm run test:appupdate && npm run test:preview && npm run test:desktop-smoke && npm run test:cli-edit",
|
|
17
|
+
"test": "npm run test:lockfile && npm run test:sudostdin && npm run test:vault && npm run test:recovery && npm run test:upgrade && npm run test:notify && npm run test:commands && npm run test:commandlog && npm run test:portability && npm run test:approval && npm run test:controlplane && npm run test:terminal && npm run test:files && npm run test:livestream && npm run test:skills && npm run test:redaction && npm run test:profiles && npm run test:aliases && npm run test:hooks && npm run test:tools && npm run test:policy && npm run test:policynames && npm run test:ping && npm run test:config && npm run test:fieldnames && npm run test:groups && npm run test:agentforward && npm run test:certpath && npm run test:agentannounce && npm run test:autherrors && npm run test:envchoice && npm run test:lifecycle && npm run test:tunnel && npm run test:sync && npm run test:sync-path && npm run test:dbquoting && npm run test:dbinjection && npm run test:quoteprops && npm run test:backupinjection && npm run test:dbrowcount && npm run test:migration && npm run test:security && npm run test:hostkeys && npm run test:proxy && npm run test:working-directory && npm run test:groups-persistence && npm run test:release && npm run test:cli-experience && npm run test:desktop-install && npm run test:agent-clients && npm run test:appupdate && npm run test:preview && npm run test:desktop-smoke && npm run test:local-shell && npm run test:cli-edit && npm run test:timeoutwrap",
|
|
18
18
|
"test:lockfile": "node tests/test-lockfile.js",
|
|
19
19
|
"test:sudostdin": "node tests/test-sudo-stdin.js",
|
|
20
20
|
"test:vault": "node tests/test-secret-store.js",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"test:quoteprops": "node tests/test-shell-quote-properties.js",
|
|
47
47
|
"test:backupinjection": "node tests/test-backup-monitor-injection.js",
|
|
48
48
|
"test:dbrowcount": "node tests/test-database-row-count.js",
|
|
49
|
+
"test:timeoutwrap": "node tests/test-timeout-wrapper.js",
|
|
49
50
|
"test:cli-edit": "node tests/test-cli-edit-server.js",
|
|
50
51
|
"test:all": "npm test && npm run typecheck && ./scripts/validate.sh",
|
|
51
52
|
"validate": "./scripts/validate.sh",
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
"test:terminal": "node tests/test-terminal.js",
|
|
56
57
|
"test:files": "node tests/test-files.js",
|
|
57
58
|
"build:ui": "node scripts/build-interface.mjs",
|
|
59
|
+
"brand:social": "node scripts/render-social-preview.mjs",
|
|
58
60
|
"prepack": "node scripts/build-interface.mjs",
|
|
59
61
|
"test:recovery": "node tests/test-vault-recovery.js",
|
|
60
62
|
"test:upgrade": "node tests/test-upgrade.js",
|
|
@@ -77,6 +79,7 @@
|
|
|
77
79
|
"test:ui": "npm --prefix ui run test:e2e",
|
|
78
80
|
"test:preview": "node tests/test-preview-candidate.js",
|
|
79
81
|
"test:desktop-smoke": "node tests/test-desktop-smoke.js",
|
|
82
|
+
"test:local-shell": "node tests/test-local-shell.js",
|
|
80
83
|
"test:policynames": "node tests/test-policy-name-resolution.js"
|
|
81
84
|
},
|
|
82
85
|
"keywords": [
|
|
@@ -127,7 +130,7 @@
|
|
|
127
130
|
"dependencies": {
|
|
128
131
|
"@iarna/toml": "^2.2.5",
|
|
129
132
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
130
|
-
"dotenv": "^
|
|
133
|
+
"dotenv": "^18.0.9",
|
|
131
134
|
"ssh2": "^1.17.0",
|
|
132
135
|
"zod": "^4.6.7"
|
|
133
136
|
},
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Renders brand/social-preview.html into the GitHub social preview image
|
|
3
|
+
// (docs/images/social-preview.png at 1280x640, and @2x). Needs the built interface
|
|
4
|
+
// for its fonts (npm run build:ui) and Playwright from ui/ (npm ci --prefix ui).
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
11
|
+
if (!fs.existsSync(path.join(root, 'dist', 'ui', 'assets', 'Karla-Variable.woff2'))) {
|
|
12
|
+
console.error('The fonts come from the built interface: run `npm run build:ui` first.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
let chromium;
|
|
16
|
+
try {
|
|
17
|
+
({ chromium } = createRequire(path.join(root, 'ui', 'package.json'))('@playwright/test'));
|
|
18
|
+
} catch {
|
|
19
|
+
console.error('Playwright is not installed in ui/: run `npm ci --prefix ui` first.');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const html = pathToFileURL(path.join(root, 'brand', 'social-preview.html')).href;
|
|
23
|
+
const browser = await chromium.launch();
|
|
24
|
+
try {
|
|
25
|
+
for (const [scale, name] of [[1, 'social-preview.png'], [2, 'social-preview@2x.png']]) {
|
|
26
|
+
const page = await browser.newPage({ viewport: { width: 1280, height: 640 }, deviceScaleFactor: scale });
|
|
27
|
+
await page.goto(html);
|
|
28
|
+
await page.evaluate(() => document.fonts.ready);
|
|
29
|
+
await page.waitForTimeout(300);
|
|
30
|
+
await page.screenshot({ path: path.join(root, 'docs', 'images', name) });
|
|
31
|
+
await page.close();
|
|
32
|
+
console.log(`docs/images/${name}`);
|
|
33
|
+
}
|
|
34
|
+
} finally {
|
|
35
|
+
await browser.close();
|
|
36
|
+
}
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/bvisible/mcp-ssh-manager",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "4.0.
|
|
9
|
+
"version": "4.0.2",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "mcp-ssh-manager",
|
|
14
|
-
"version": "4.0.
|
|
14
|
+
"version": "4.0.2",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|
package/src/config-loader.js
CHANGED
|
@@ -293,7 +293,8 @@ export class ConfigLoader {
|
|
|
293
293
|
* Load configuration from .env file
|
|
294
294
|
*/
|
|
295
295
|
loadEnvConfig(envPath) {
|
|
296
|
-
|
|
296
|
+
// quiet: since dotenv 17 every load (and reload) is announced on the log otherwise.
|
|
297
|
+
const result = dotenv.config({ path: envPath, processEnv: {}, quiet: true });
|
|
297
298
|
if (result.error) {
|
|
298
299
|
throw result.error;
|
|
299
300
|
}
|
package/src/index.js
CHANGED
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
import { loadToolConfig, isToolEnabled } from './tool-config-manager.js';
|
|
152
152
|
import { evaluatePolicy } from './policy.js';
|
|
153
153
|
import { needsApproval, isControlPlaneListening, requestDecision, buildRequest, isApprovalExempt, isReadOnlyAction, HANDLER_GATED_TOOLS } from './approval.js';
|
|
154
|
-
import { shellQuote, shellPath, safeInteger } from './shell-quote.js';
|
|
154
|
+
import { shellQuote, shellPath, safeInteger, withRemoteTimeout } from './shell-quote.js';
|
|
155
155
|
import { openStream } from './live-stream.js';
|
|
156
156
|
import { auditLog, sanitize } from './audit.js';
|
|
157
157
|
|
|
@@ -163,7 +163,8 @@ const envFilePath = envChoice.path;
|
|
|
163
163
|
// Said at startup and repeated wherever a missing server would otherwise be
|
|
164
164
|
// the only clue: an empty configuration used to fail without a word (#90).
|
|
165
165
|
const envProblem = envFileProblem(envChoice);
|
|
166
|
-
|
|
166
|
+
// quiet: since dotenv 17 every load is announced on the log otherwise.
|
|
167
|
+
const envFile = dotenv.config({ path: envFilePath, processEnv: {}, quiet: true });
|
|
167
168
|
const envFileValues = envFile.parsed || {};
|
|
168
169
|
|
|
169
170
|
function getRuntimeEnv(name) {
|
|
@@ -365,9 +366,10 @@ async function execCommandWithTimeout(ssh, command, options = {}, timeoutMs = 30
|
|
|
365
366
|
const useSystemTimeout = timeoutMs > 0 && timeoutMs < 300000 && !rawCommand; // Max 5 minutes, not for raw commands
|
|
366
367
|
|
|
367
368
|
if (useSystemTimeout) {
|
|
368
|
-
//
|
|
369
|
-
|
|
370
|
-
|
|
369
|
+
// The remote host's own `timeout` (or Homebrew's `gtimeout`), found on the
|
|
370
|
+
// target rather than assumed: a stock Mac has neither, and every wrapped
|
|
371
|
+
// command failed there with exit 127 (#115). See withRemoteTimeout.
|
|
372
|
+
const wrappedCommand = withRemoteTimeout(command, Math.ceil(timeoutMs / 1000));
|
|
371
373
|
|
|
372
374
|
try {
|
|
373
375
|
const result = await ssh.execCommand(wrappedCommand, {
|
|
@@ -399,6 +401,12 @@ async function execCommandWithTimeout(ssh, command, options = {}, timeoutMs = 30
|
|
|
399
401
|
}
|
|
400
402
|
}
|
|
401
403
|
}
|
|
404
|
+
// On a target with no timeout binary (a stock Mac) it is the client-side
|
|
405
|
+
// limit that stops the command, and its message would name the wrapper and
|
|
406
|
+
// the grace period: say what the caller sent and the limit they asked for.
|
|
407
|
+
if (error.message.startsWith('Command timeout after')) {
|
|
408
|
+
throw new Error(`Command timeout after ${timeoutMs}ms: ${command.substring(0, 100)}...`);
|
|
409
|
+
}
|
|
402
410
|
throw error;
|
|
403
411
|
}
|
|
404
412
|
} else {
|
package/src/shell-quote.js
CHANGED
|
@@ -36,6 +36,32 @@ export function shellPath(value) {
|
|
|
36
36
|
return shellQuote(text);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// Finds the timeout binary on the target, then runs the command under it. Run by
|
|
40
|
+
// `sh` with the seconds as $1 and the command as $2, so neither is ever spliced
|
|
41
|
+
// into this text. Stock Linux has `timeout`; macOS has neither unless Homebrew's
|
|
42
|
+
// coreutils adds `gtimeout`; with neither, the command still runs (the local SSH
|
|
43
|
+
// exec timeout bounds it) instead of failing with exit 127 (#115).
|
|
44
|
+
const REMOTE_TIMEOUT_SCRIPT = 'if t=$(command -v timeout 2>/dev/null || command -v gtimeout 2>/dev/null);'
|
|
45
|
+
+ ' then exec "$t" "$1" sh -c "$2"; else exec sh -c "$2"; fi';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Wrap a command so the remote host kills it after `seconds`.
|
|
49
|
+
*
|
|
50
|
+
* The result is a single simple command made only of single-quoted words
|
|
51
|
+
* (`sh -c '<script>' sh <seconds> '<command>'`), because the SSH server hands it
|
|
52
|
+
* to the account's login shell, which is not always a POSIX one: csh and tcsh
|
|
53
|
+
* (FreeBSD's root, some old accounts) reject `$(...)` and `if ... fi` written at
|
|
54
|
+
* the top level, and a wrapper that resolves the binary there failed on them
|
|
55
|
+
* where the old bare `timeout ...` worked. The probing happens inside `sh`.
|
|
56
|
+
*
|
|
57
|
+
* @param {string} command - The command as the user wrote it, run by `sh -c`
|
|
58
|
+
* @param {number} seconds - Whole seconds before the remote side kills it
|
|
59
|
+
* @returns {string} The wrapped command
|
|
60
|
+
*/
|
|
61
|
+
export function withRemoteTimeout(command, seconds) {
|
|
62
|
+
return `sh -c ${shellQuote(REMOTE_TIMEOUT_SCRIPT)} sh ${safeInteger(seconds, 1)} ${shellQuote(command)}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
39
65
|
/**
|
|
40
66
|
* Coerce a value to a safe non-negative integer for use in a command.
|
|
41
67
|
*
|