@dotrino/terminal-agent 0.41.2 → 0.42.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/bin/terminal.js +34 -0
- package/index.js +22 -1
- package/package.json +2 -2
package/bin/terminal.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* dotrino-terminal vscode [--name <n>] la terminal embebida de VS Code abre consolas de aquí
|
|
18
18
|
* dotrino-terminal vscode --off lo deshace
|
|
19
19
|
* dotrino-terminal desktop update [--check] actualiza la app de escritorio (la ventana)
|
|
20
|
+
* dotrino-terminal updates [--json] [--desktop <versión>]
|
|
21
|
+
* qué versiones nuevas hay (del cliente y de la app)
|
|
20
22
|
* dotrino-terminal service install|uninstall|status [--name <n>]
|
|
21
23
|
* el agente como servicio: arranca solo con la máquina
|
|
22
24
|
*
|
|
@@ -87,6 +89,8 @@ if (args.includes('-h') || args.includes('--help')) {
|
|
|
87
89
|
dotrino-terminal desktop update actualiza la app de escritorio (la ventana): baja la
|
|
88
90
|
versión nueva, comprueba su firma y la instala
|
|
89
91
|
(--check solo mira si hay una)
|
|
92
|
+
dotrino-terminal updates [--json] dice si hay versión nueva de dotrino-terminal y de la app
|
|
93
|
+
(--desktop <versión> es la app que tienes; no instala nada)
|
|
90
94
|
dotrino-terminal service install [--name <n>] deja el agente como servicio de tu usuario: arranca
|
|
91
95
|
solo al encender la máquina, sin abrir ninguna ventana
|
|
92
96
|
dotrino-terminal service uninstall [--name <n>] lo quita (para el agente: cierra sus consolas)
|
|
@@ -125,6 +129,8 @@ Cerrar la ventana no cierra la consola: sigue abierta y se retoma después.`, `u
|
|
|
125
129
|
dotrino-terminal desktop update update the desktop app (the window): downloads the
|
|
126
130
|
new version, checks its signature and installs it
|
|
127
131
|
(--check only looks for one)
|
|
132
|
+
dotrino-terminal updates [--json] say whether there is a new version of dotrino-terminal and of
|
|
133
|
+
the app (--desktop <version> is the app you have; installs nothing)
|
|
128
134
|
dotrino-terminal service install [--name <n>] run the agent as a service of your user: it starts
|
|
129
135
|
by itself when the machine boots, with no window open
|
|
130
136
|
dotrino-terminal service uninstall [--name <n>] remove it (stops the agent: closes its consoles)
|
|
@@ -242,6 +248,32 @@ function vscode () {
|
|
|
242
248
|
if (!off) console.log(t('\nLas terminales nuevas del editor ya abren aquí. Si actualizas o cambias de Node, vuelve a correr esta orden.', '\nNew terminals in the editor now open here. If you update or switch Node, run this command again.'))
|
|
243
249
|
}
|
|
244
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Qué versiones nuevas hay, sin instalar nada: del cliente (npm) y, con `--desktop <versión>`,
|
|
253
|
+
* de la app de escritorio. La app lo pregunta al arrancar (ella no tiene red). Cada una dice
|
|
254
|
+
* `newer` o por qué no se pudo mirar: «no se pudo mirar» no es «al día».
|
|
255
|
+
*/
|
|
256
|
+
async function updates () {
|
|
257
|
+
const { latestVersion, isNewer } = await import('@dotrino/update')
|
|
258
|
+
const one = async (current, ask) => {
|
|
259
|
+
const r = await ask()
|
|
260
|
+
return r.ok ? { current, latest: r.version, newer: isNewer(r.version, current) } : { current, error: r.reason }
|
|
261
|
+
}
|
|
262
|
+
const out = { agent: await one(VERSION, () => latestVersion({ source: 'npm', pkg: '@dotrino/terminal-agent', product: 'dotrino-terminal', version: VERSION })) }
|
|
263
|
+
const app = opt('--desktop')
|
|
264
|
+
if (app) {
|
|
265
|
+
const { latestDesktop } = await import('../desktop.js')
|
|
266
|
+
out.desktop = await one(app, () => latestDesktop({ version: app }))
|
|
267
|
+
}
|
|
268
|
+
if (args.includes('--json')) { console.log(JSON.stringify(out)); return }
|
|
269
|
+
const say = (name, x) => console.log(x.error
|
|
270
|
+
? t(`${name}: no se pudo mirar (${x.error}).`, `${name}: could not check (${x.error}).`)
|
|
271
|
+
: x.newer ? t(`${name}: hay ${x.latest} y tienes ${x.current}.`, `${name}: ${x.latest} is out and you have ${x.current}.`)
|
|
272
|
+
: t(`${name}: al día (${x.current}).`, `${name}: up to date (${x.current}).`))
|
|
273
|
+
say('dotrino-terminal', out.agent)
|
|
274
|
+
if (out.desktop) say(t('La app', 'The app'), out.desktop)
|
|
275
|
+
}
|
|
276
|
+
|
|
245
277
|
/** Dónde está la app de escritorio, si no lo dijo quien llama: la del PATH. */
|
|
246
278
|
function findDesktop (name) {
|
|
247
279
|
for (const d of (process.env.PATH || '').split(path.delimiter)) {
|
|
@@ -530,6 +562,7 @@ async function farRequest (conn, msg, type) {
|
|
|
530
562
|
}
|
|
531
563
|
const farMessage = (r) => ({
|
|
532
564
|
'not-linked': t('esta máquina no está enlazada con tu bóveda, así que no ve tus otras máquinas. Enlázala con: dotrino-terminal link', 'this machine is not linked to your vault, so it cannot see your other machines. Link it with: dotrino-terminal link'),
|
|
565
|
+
'no-acta': t('no se pudo preguntar a tu bóveda qué máquinas tienes. Comprueba que esté encendida y que esta máquina tenga conexión.', 'could not ask your vault which machines you have. Check that it is on and that this machine is online.'),
|
|
533
566
|
'no-machine': t('no hay ninguna máquina encendida con ese id o nombre (mira «dotrino-terminal machines»).', 'no machine with that id or name is on (see "dotrino-terminal machines").'),
|
|
534
567
|
'ambiguous-machine': t('hay más de una máquina con ese nombre: usa su id (mira «dotrino-terminal machines»).', 'more than one machine has that name: use its id (see "dotrino-terminal machines").')
|
|
535
568
|
}[r.code] || `${r.message} (${r.code})`)
|
|
@@ -845,6 +878,7 @@ try {
|
|
|
845
878
|
if (cmd === 'lock') { await lock(); process.exit(0) }
|
|
846
879
|
if (cmd === 'vscode') { vscode(); process.exit(0) }
|
|
847
880
|
if (cmd === 'desktop') { await desktop(); process.exit(0) }
|
|
881
|
+
if (cmd === 'updates') { await updates(); process.exit(0) }
|
|
848
882
|
if (cmd === 'service') { await service(); process.exit(0) }
|
|
849
883
|
if (cmd === 'note') { await note(); process.exit(0) }
|
|
850
884
|
const dir = opt('--dir') || dataDir(opt('--name'))
|
package/index.js
CHANGED
|
@@ -48,6 +48,8 @@ export { LABEL }
|
|
|
48
48
|
|
|
49
49
|
/** Cada cuánto mira un agente sin enlazar si ya lo enlazaron. */
|
|
50
50
|
export const LINK_POLL_MS = 2000
|
|
51
|
+
/** Cada cuánto se reintenta la parte remota cuando no pudo arrancar (sin red, proxio caído). */
|
|
52
|
+
const REMOTE_RETRY_MS = 15_000
|
|
51
53
|
|
|
52
54
|
export function loadPty () {
|
|
53
55
|
// node-pty (Microsoft, el de VS Code) ≥ 1.2 trae los binarios DENTRO del paquete para Linux,
|
|
@@ -300,7 +302,26 @@ export async function startAgent (opts = {}) {
|
|
|
300
302
|
})
|
|
301
303
|
let watcher = null
|
|
302
304
|
if (loadLink(dir)) {
|
|
303
|
-
try { remote = await startRemote() } catch (e) {
|
|
305
|
+
try { remote = await startRemote() } catch (e) {
|
|
306
|
+
// SIN RED AL ARRANCAR (o con el proxio caído) LAS VENTANAS DE ESTA MÁQUINA ABREN IGUAL:
|
|
307
|
+
// una terminal no puede depender de internet. Antes el agente moría aquí y, con la
|
|
308
|
+
// máquina enlazada, no se podía abrir ni una consola local. La parte remota se
|
|
309
|
+
// reintenta por detrás hasta que salga; mientras, se dice.
|
|
310
|
+
console.error(`[terminal-agent] the remote side did not start (${e.message}); local windows work, retrying every ${REMOTE_RETRY_MS / 1000} s`)
|
|
311
|
+
opts.onLinkError?.(e)
|
|
312
|
+
let trying = false
|
|
313
|
+
watcher = setInterval(() => {
|
|
314
|
+
if (trying) return
|
|
315
|
+
trying = true
|
|
316
|
+
startRemote().then((r) => {
|
|
317
|
+
if (stopped) { r.close(); return }
|
|
318
|
+
clearInterval(watcher); watcher = null
|
|
319
|
+
remote = r
|
|
320
|
+
opts.onLinked?.(r)
|
|
321
|
+
}).catch(() => {}).finally(() => { trying = false })
|
|
322
|
+
}, REMOTE_RETRY_MS)
|
|
323
|
+
watcher.unref()
|
|
324
|
+
}
|
|
304
325
|
} else {
|
|
305
326
|
// Sin enlace: se mira cada poco si aparece (`dotrino-terminal link` desde una ventana).
|
|
306
327
|
// Al aparecer se enciende la parte remota SIN reiniciar, así las consolas abiertas siguen.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
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,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@dotrino/identity": "0.107.2",
|
|
35
35
|
"@dotrino/proxy-client": "0.30.3",
|
|
36
|
-
"@dotrino/remote-agent": "0.18.
|
|
36
|
+
"@dotrino/remote-agent": "0.18.2",
|
|
37
37
|
"@dotrino/update": "0.8.0",
|
|
38
38
|
"@dotrino/vault": "0.82.1",
|
|
39
39
|
"@xterm/addon-serialize": "0.13.0",
|