@dotrino/terminal-agent 0.45.0 → 0.46.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.md +1 -0
- package/bin/terminal.js +31 -0
- package/far.js +4 -1
- package/index.js +17 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ dotrino-terminal vscode [--name <n>] # la terminal embebida de VS Code abre
|
|
|
53
53
|
dotrino-terminal claude # Claude Code mantiene la tarjeta de su consola: skill + hooks en ~/.claude (--off lo deshace, --status lo dice)
|
|
54
54
|
dotrino-terminal desktop update [--check] # actualiza la app de escritorio: baja, verifica la firma e instala
|
|
55
55
|
dotrino-terminal agents [--json] # con qué versión corre el agente de cada perfil
|
|
56
|
+
dotrino-terminal network [--name <n>] # el uso de red del agente: por dónde va cada conexión (directo, TURN o el proxio) y cuánto pasó
|
|
56
57
|
dotrino-terminal restart [--name <n>] # para el agente para que arranque con la versión instalada (cierra sus consolas; --stale: solo los atrasados)
|
|
57
58
|
dotrino-terminal service install|uninstall|status [--name <n>] # el agente como servicio del usuario
|
|
58
59
|
```
|
package/bin/terminal.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* dotrino-terminal updates [--json] [--desktop <versión>]
|
|
21
21
|
* qué versiones nuevas hay (del cliente y de la app)
|
|
22
22
|
* dotrino-terminal agents [--json] qué agente corre en cada perfil y con qué versión
|
|
23
|
+
* dotrino-terminal network [--name <n>] [--json] el uso de red del agente: por dónde va cada conexión
|
|
23
24
|
* dotrino-terminal restart [--name <n>] [--stale] [--yes]
|
|
24
25
|
* para el agente (cierra sus consolas) para que arranque
|
|
25
26
|
* con la versión instalada
|
|
@@ -97,6 +98,8 @@ if (args.includes('-h') || args.includes('--help')) {
|
|
|
97
98
|
(--desktop <versión> es la app que tienes; no instala nada)
|
|
98
99
|
dotrino-terminal agents [--json] qué agente corre en cada perfil, con qué versión y si va
|
|
99
100
|
por detrás de la instalada
|
|
101
|
+
dotrino-terminal network [--name <n>] el uso de red del agente: por dónde va cada conexión con
|
|
102
|
+
tus otros aparatos (directo, TURN o el proxy) y cuánto pasó
|
|
100
103
|
dotrino-terminal restart [--name <n>] para el agente para que arranque con la versión instalada
|
|
101
104
|
(cierra TODAS sus consolas; --stale: solo los que van por
|
|
102
105
|
detrás, en todos los perfiles; --yes no pregunta)
|
|
@@ -145,6 +148,8 @@ Cerrar la ventana no cierra la consola: sigue abierta y se retoma después.`, `u
|
|
|
145
148
|
the app (--desktop <version> is the app you have; installs nothing)
|
|
146
149
|
dotrino-terminal agents [--json] which agent runs in each profile, its version and whether
|
|
147
150
|
it is behind the installed one
|
|
151
|
+
dotrino-terminal network [--name <n>] the agent's network use: which path each connection with
|
|
152
|
+
your other devices takes (direct, TURN or the proxy) and how much
|
|
148
153
|
dotrino-terminal restart [--name <n>] stop the agent so it starts with the installed version
|
|
149
154
|
(closes ALL its consoles; --stale: only the ones behind,
|
|
150
155
|
in every profile; --yes does not ask)
|
|
@@ -464,6 +469,31 @@ async function restart () {
|
|
|
464
469
|
}
|
|
465
470
|
}
|
|
466
471
|
|
|
472
|
+
/**
|
|
473
|
+
* `dotrino-terminal network`: el uso de red del agente de este perfil. Por dónde va cada conexión
|
|
474
|
+
* con tus otros aparatos (directo, TURN o el proxio) y cuánto pasó por cada camino.
|
|
475
|
+
*/
|
|
476
|
+
async function network () {
|
|
477
|
+
const asked = opt('--name')
|
|
478
|
+
if (asked !== undefined && !isValidName(asked)) die(t(`nombre de perfil no válido: ${asked}`, `invalid profile name: ${asked}`))
|
|
479
|
+
const { dir } = resolveInstance(LABEL, asked)
|
|
480
|
+
let conn
|
|
481
|
+
try { conn = await connectLocal(dir) } catch (e) {
|
|
482
|
+
if (e.code !== 'ENOAGENT') throw e
|
|
483
|
+
console.log(t('Este perfil no tiene un agente corriendo: no hay conexiones.', 'This profile has no agent running: there are no connections.'))
|
|
484
|
+
return
|
|
485
|
+
}
|
|
486
|
+
const r = await Promise.race([request(conn, { type: 'net' }, 'net'), new Promise((resolve) => setTimeout(() => resolve(null), 5000))])
|
|
487
|
+
conn.close()
|
|
488
|
+
if (!r) die(t('el agente que corre es anterior a la 0.46.0 y no da su uso de red. Reinícialo con la versión nueva: dotrino-terminal restart', 'the running agent predates 0.46.0 and does not report its network use. Restart it with the new version: dotrino-terminal restart'))
|
|
489
|
+
if (r.type === 'fail') die(`${r.message} (${r.code})`)
|
|
490
|
+
if (args.includes('--json')) { console.log(JSON.stringify(r.transports)); return }
|
|
491
|
+
console.log(t('Esta ventana ↔ el agente de esta máquina: socket local (no toca la red).', 'This window ↔ this machine\'s agent: local socket (never touches the network).'))
|
|
492
|
+
console.log(t('El agente ↔ tus otros aparatos (route: direct = WebRTC directo, turn = WebRTC por TURN, proxy = por el proxy):\n', 'The agent ↔ your other devices (route: direct = direct WebRTC, turn = WebRTC via TURN, proxy = through the proxy):\n'))
|
|
493
|
+
process.stdout.write(r.report)
|
|
494
|
+
console.log(t('\nBytes del contenido, sin las cabeceras de la red. Acumulados desde que arrancó el agente.', '\nContent bytes, without network headers. Accumulated since the agent started.'))
|
|
495
|
+
}
|
|
496
|
+
|
|
467
497
|
/** El agente como servicio del usuario (systemd en Linux, launchd en macOS). */
|
|
468
498
|
async function service () {
|
|
469
499
|
const action = args[1]
|
|
@@ -1034,6 +1064,7 @@ try {
|
|
|
1034
1064
|
if (cmd === 'desktop') { await desktop(); process.exit(0) }
|
|
1035
1065
|
if (cmd === 'updates') { await updates(); process.exit(0) }
|
|
1036
1066
|
if (cmd === 'agents') { await agents(); process.exit(0) }
|
|
1067
|
+
if (cmd === 'network') { await network(); process.exit(0) }
|
|
1037
1068
|
if (cmd === 'restart') { await restart(); process.exit(0) }
|
|
1038
1069
|
if (cmd === 'service') { await service(); process.exit(0) }
|
|
1039
1070
|
if (cmd === 'note') { await note(); process.exit(0) }
|
package/far.js
CHANGED
|
@@ -262,8 +262,11 @@ export function makeFar ({ dir, loadLink, kind, discover = discoverReal, connect
|
|
|
262
262
|
refreshedAt = 1
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
/** Las máquinas que ya se conocen, sin preguntar a la red (para nombrarlas en un informe). */
|
|
266
|
+
const known = () => [...machines.values()].map((m) => ({ sub: m.sub, id: m.id, name: m.name }))
|
|
267
|
+
|
|
265
268
|
return {
|
|
266
|
-
list, via, send,
|
|
269
|
+
list, via, send, known,
|
|
267
270
|
close: () => { closed = true; clearTimeout(idle); release() }
|
|
268
271
|
}
|
|
269
272
|
}
|
package/index.js
CHANGED
|
@@ -38,6 +38,8 @@ import path from 'node:path'
|
|
|
38
38
|
import { createRequire } from 'node:module'
|
|
39
39
|
import { startRemoteAgent } from '@dotrino/remote-agent/agent'
|
|
40
40
|
import { dataDir, loadLink, LABEL } from './link.js'
|
|
41
|
+
import { listTransports, netReport } from '@dotrino/proxy-client'
|
|
42
|
+
import { shortId } from './far.js'
|
|
41
43
|
import { ConsoleHub, REPLAY_CHUNK, isTyped } from './consoles.js'
|
|
42
44
|
import { listenLocal } from './local.js'
|
|
43
45
|
import { makeGate } from './access.js'
|
|
@@ -257,6 +259,20 @@ export function serveSession (session, hub, { origin = 'remote', gate = null, up
|
|
|
257
259
|
* otras máquinas hay, y una orden suelta para una de ellas.
|
|
258
260
|
* Exportada para las pruebas.
|
|
259
261
|
*/
|
|
262
|
+
/**
|
|
263
|
+
* El uso de red de este agente: cada conexión con otro aparato, por qué camino va (directo,
|
|
264
|
+
* TURN o el proxio) y cuánto pasó por cada uno. El mismo informe que el modal de red del topbar.
|
|
265
|
+
* Una máquina de la cuenta sale con su nombre; cualquier otro aparato, con su id.
|
|
266
|
+
*/
|
|
267
|
+
export async function netOf (far) {
|
|
268
|
+
const transports = await Promise.all(listTransports().map(async (c) => {
|
|
269
|
+
try { return await c.stats() } catch (e) { return { url: c.url, error: e?.message || String(e) } }
|
|
270
|
+
}))
|
|
271
|
+
const names = new Map(far.known().map((m) => [m.id, m.name ? `${m.name} ${m.id}` : m.id]))
|
|
272
|
+
const label = async (pubkey) => { const id = await shortId(pubkey); return names.get(id) || id }
|
|
273
|
+
return { transports, report: await netReport(transports, { label }) }
|
|
274
|
+
}
|
|
275
|
+
|
|
260
276
|
export function serveLocal (session, hub, far, { uploadsDir = null } = {}) {
|
|
261
277
|
const h = { message: [], close: [] }
|
|
262
278
|
const inner = { device: null, send: (p) => session.send(p), on (ev, cb) { h[ev]?.push(cb); return this } }
|
|
@@ -265,6 +281,7 @@ export function serveLocal (session, hub, far, { uploadsDir = null } = {}) {
|
|
|
265
281
|
session.on('message', (msg) => {
|
|
266
282
|
if (!msg || typeof msg !== 'object') return
|
|
267
283
|
if (mode !== 'far' && msg.type === 'machines') { far.list().then((list) => session.send({ type: 'machines', list })).catch(failed); return }
|
|
284
|
+
if (mode !== 'far' && msg.type === 'net') { netOf(far).then((r) => session.send({ type: 'net', ...r })).catch(failed); return }
|
|
268
285
|
if (mode !== 'far' && msg.type === 'far') { far.send(msg.machine, msg.msg).catch(failed); return }
|
|
269
286
|
if (!mode) {
|
|
270
287
|
if (msg.type === 'via') { mode = 'far'; far.via(inner, msg.machine).catch(failed); return }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.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": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@dotrino/identity": "0.107.2",
|
|
37
|
-
"@dotrino/proxy-client": "0.
|
|
38
|
-
"@dotrino/remote-agent": "0.18.
|
|
37
|
+
"@dotrino/proxy-client": "0.31.0",
|
|
38
|
+
"@dotrino/remote-agent": "0.18.3",
|
|
39
39
|
"@dotrino/update": "0.9.0",
|
|
40
40
|
"@dotrino/vault": "0.82.1",
|
|
41
41
|
"@xterm/addon-serialize": "0.13.0",
|