@dotrino/terminal-agent 0.47.2 → 0.47.4
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/bin/terminal.js +2 -0
- package/desktop.js +3 -0
- package/package.json +4 -4
- package/service.js +15 -7
package/bin/terminal.js
CHANGED
|
@@ -370,6 +370,7 @@ async function desktop () {
|
|
|
370
370
|
if (!r.ok) {
|
|
371
371
|
const why = {
|
|
372
372
|
'could-not-check': t(`No se pudo mirar (${r.reason}). No es que estés al día: es que no se sabe.`, `Could not check (${r.reason}). That does not mean you are up to date: it is unknown.`),
|
|
373
|
+
'node-too-old': t(`NO se instala nada: con este Node (${process.version}) no se puede comprobar la firma. Hace falta Node 22.12 o más reciente (o 20.19): https://nodejs.org`, `Nothing is installed: this Node (${process.version}) cannot check the signature. It needs Node 22.12 or newer (or 20.19): https://nodejs.org`),
|
|
373
374
|
NO_VERIFIER: t('NO se instala nada: a este programa le falta la pieza que comprueba la firma. Reinstálalo con: npm install -g @dotrino/terminal-agent', 'Nothing is installed: this program is missing the piece that checks the signature. Reinstall it with: npm install -g @dotrino/terminal-agent'),
|
|
374
375
|
'not-writable': t(`NO se instala nada: no puedo escribir donde está la app (${r.reason}). Bájala de https://terminal.dotrino.com/`, `Nothing is installed: I cannot write where the app is (${r.reason}). Get it from https://terminal.dotrino.com/`)
|
|
375
376
|
}[r.code] || t(`NO se instala nada: ${r.reason}`, `Nothing is installed: ${r.reason}`)
|
|
@@ -535,6 +536,7 @@ async function service () {
|
|
|
535
536
|
try { r = installService({ name, cli, dir, running: own }) } catch (e) { explain(e) }
|
|
536
537
|
console.log(t(`Servicio del perfil «${name}» puesto: ${r.file}`, `Service for profile "${name}" installed: ${r.file}`))
|
|
537
538
|
if (r.started) console.log(t('El agente ya corre como servicio.', 'The agent now runs as a service.'))
|
|
539
|
+
else if (r.startReason) console.log(t('Desde una sesión SSH, Windows no deja a esta cuenta dejarlo corriendo ahora: arranca la próxima vez que inicies sesión en Windows.', `It cannot be left running from this SSH session (${r.startReason}): it starts the next time you log in to Windows.`))
|
|
538
540
|
else console.log(t('Ahora mismo corre un agente que levantó una ventana, y no se toca para no cerrar sus consolas. El servicio toma el relevo cuando ese termine o al próximo arranque.', 'Right now an agent started by a window is running, and it is left alone so its consoles stay open. The service takes over when it ends or at the next start.'))
|
|
539
541
|
if (r.kind === 'launchd') console.log(t('Arranca solo cuando inicias sesión en esta Mac.', 'It starts by itself when you log in to this Mac.'))
|
|
540
542
|
else if (r.kind === 'run-key') console.log(t('Arranca solo cuando inicias sesión en Windows.', 'It starts by itself when you log in to Windows.'))
|
package/desktop.js
CHANGED
|
@@ -201,6 +201,9 @@ export async function updateDesktop ({ exe, current, check = false, say = () =>
|
|
|
201
201
|
try {
|
|
202
202
|
let got
|
|
203
203
|
try { got = await fetchVerifiedImpl(pick.asset, { repo: REPO, product: PRODUCT, version: current, dir }) } catch (e) {
|
|
204
|
+
// La comprobación (sigstore → @npmcli/agent) carga módulos ESM con `require()`: Node lo
|
|
205
|
+
// admite desde 20.19 y 22.12. Con uno anterior no hay con qué verificar, y se dice cuál falta.
|
|
206
|
+
if (e.code === 'ERR_REQUIRE_ESM') return fail('node-too-old', `Node ${process.version} cannot load the signature checker (needs 20.19 or 22.12 and later)`)
|
|
204
207
|
return fail(e.code || 'download-failed', e.message)
|
|
205
208
|
}
|
|
206
209
|
// Lo que no pasa la verificación no se deja en el disco: nadie debe instalarlo a mano.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.4",
|
|
4
4
|
"description": "Dotrino Terminal: las ventanas de esta máquina (dotrino-terminal) y su agente, que deja abrir esas mismas consolas desde los otros aparatos de tu cuenta, cifrado punto a punto.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"type-check": "tsc --noEmit"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dotrino/identity": "0.
|
|
36
|
+
"@dotrino/identity": "0.116.0",
|
|
37
37
|
"@dotrino/proxy-client": "0.32.0",
|
|
38
38
|
"@dotrino/remote-agent": "0.18.3",
|
|
39
39
|
"@dotrino/update": "0.9.0",
|
|
40
|
-
"@dotrino/vault": "0.
|
|
40
|
+
"@dotrino/vault": "0.86.0",
|
|
41
41
|
"@xterm/addon-serialize": "0.13.0",
|
|
42
42
|
"@xterm/headless": "5.5.0",
|
|
43
43
|
"jsonc-parser": "3.3.1",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"sigstore": "5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
48
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"repository": {
|
package/service.js
CHANGED
|
@@ -139,15 +139,22 @@ const psQuote = (s) => `'${String(s).replace(/'/g, "''")}'`
|
|
|
139
139
|
* al cerrarla mata todo lo que lanzó, y Node no puede pedir salirse de él. Ahí lo crea WMI
|
|
140
140
|
* (`Win32_Process.Create`), que lo lanza fuera de la sesión, y con la misma línea que queda en
|
|
141
141
|
* `HKCU\…\Run`: así se prueba también la que correrá al iniciar sesión.
|
|
142
|
+
*
|
|
143
|
+
* Una cuenta sin administrador no puede pedirle eso a WMI desde SSH. Entonces no queda nada
|
|
144
|
+
* corriendo ahora (lo que se lanzara moriría al cerrar la sesión) y se devuelve el motivo: la
|
|
145
|
+
* entrada de `Run` ya está puesta y lo arranca al iniciar sesión.
|
|
146
|
+
*
|
|
147
|
+
* @returns {{ ok: true } | { ok: false, reason: string }}
|
|
142
148
|
*/
|
|
143
149
|
function spawnSupervisor ({ name, node, cli, spawn, run, env }) {
|
|
144
150
|
if (env.SSH_CONNECTION || env.SSH_CLIENT) {
|
|
145
151
|
const script = `$r = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{ CommandLine = ${psQuote(runCommand({ name, node, cli }))} }; if ($r.ReturnValue -ne 0) { throw "Win32_Process.Create returned $($r.ReturnValue)" }`
|
|
146
|
-
|
|
147
|
-
return
|
|
152
|
+
const r = quiet(run, 'powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script])
|
|
153
|
+
return r.ok ? { ok: true } : { ok: false, reason: 'Windows (WMI) does not let this account start it from SSH' }
|
|
148
154
|
}
|
|
149
155
|
const child = spawn(node, [cli, 'supervise', '--name', name], { detached: true, windowsHide: true, stdio: 'ignore', env: { ...env, DOTRINO_SUPERVISOR: '1' } })
|
|
150
156
|
child.unref()
|
|
157
|
+
return { ok: true }
|
|
151
158
|
}
|
|
152
159
|
|
|
153
160
|
/**
|
|
@@ -195,15 +202,15 @@ function stopSupervised (dir) {
|
|
|
195
202
|
* Dos agentes con el mismo enlace son la misma llave, y parar ese cerraría sus consolas: el
|
|
196
203
|
* servicio queda puesto y toma el relevo cuando ese agente termine o al próximo arranque.
|
|
197
204
|
*
|
|
198
|
-
* @returns {{ kind:'systemd'|'launchd'|'run-key', file:string, started:boolean, boot?:boolean, lingerReason?:string }}
|
|
205
|
+
* @returns {{ kind:'systemd'|'launchd'|'run-key', file:string, started:boolean, boot?:boolean, lingerReason?:string, startReason?:string }}
|
|
199
206
|
*/
|
|
200
207
|
export function installService ({ name, node = process.execPath, cli, dir, running = false, pathEnv = process.env.PATH || '', platform = process.platform, home = os.homedir(), user = os.userInfo().username, uid = process.getuid?.(), run = execFileSync, spawn = childSpawn, env = process.env }) {
|
|
201
208
|
const kind = platformOf({ platform, run })
|
|
202
209
|
if (kind === 'run-key') {
|
|
203
210
|
must(run, 'reg', ['add', RUN_KEY, '/v', runValue(name), '/t', 'REG_SZ', '/d', runCommand({ name, node, cli }), '/f'])
|
|
204
211
|
if (running) return { kind, file: runKeyFile(name), started: false }
|
|
205
|
-
spawnSupervisor({ name, node, cli, spawn, run, env })
|
|
206
|
-
return { kind, file: runKeyFile(name), started:
|
|
212
|
+
const s = spawnSupervisor({ name, node, cli, spawn, run, env })
|
|
213
|
+
return { kind, file: runKeyFile(name), started: s.ok, ...(s.ok ? {} : { startReason: s.reason }) }
|
|
207
214
|
}
|
|
208
215
|
if (kind === 'launchd') {
|
|
209
216
|
const file = plistPath(name, home)
|
|
@@ -238,8 +245,9 @@ export function startService ({ name, dir, node = process.execPath, cli, platfor
|
|
|
238
245
|
if (platform === 'win32') {
|
|
239
246
|
if (!hasRunKey(name, run)) return false
|
|
240
247
|
const pid = readPid(supervisorPidFile(dir))
|
|
241
|
-
if (
|
|
242
|
-
|
|
248
|
+
if (pid && alive(pid)) return true
|
|
249
|
+
// Sin poder dejarlo corriendo (cuenta normal por SSH), lo levanta la ventana, como sin servicio.
|
|
250
|
+
return spawnSupervisor({ name, node, cli, spawn, run, env }).ok
|
|
243
251
|
}
|
|
244
252
|
if (platform === 'darwin') {
|
|
245
253
|
const file = plistPath(name, home)
|