@dotrino/terminal-agent 0.21.0 → 0.22.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/consoles.js +17 -1
- package/package.json +1 -1
package/consoles.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* Todo en MEMORIA: nada de lo que sale por una shell se escribe al disco. Si el agente se
|
|
14
14
|
* reinicia, las consolas se pierden (y se dice: la app ve que ya no están).
|
|
15
15
|
*/
|
|
16
|
+
import fs from 'node:fs'
|
|
17
|
+
import os from 'node:os'
|
|
16
18
|
import { createRequire } from 'node:module'
|
|
17
19
|
|
|
18
20
|
const require = createRequire(import.meta.url)
|
|
@@ -39,6 +41,20 @@ const GAP_MS = 2000 // un hueco mayor que este corta la racha: eran cambi
|
|
|
39
41
|
export const QUIET_MS = Math.max(1, Number(process.env.DOTRINO_TERMINAL_IDLE_SECONDS) || 10) * 1000
|
|
40
42
|
const MIN_TASK_MS = 3000 // menos que esto no fue «una tarea»: no se marca como terminada
|
|
41
43
|
|
|
44
|
+
/**
|
|
45
|
+
* La carpeta en la que está AHORA el proceso de una consola (la shell), con `~` por la carpeta
|
|
46
|
+
* personal. El título no sirve para esto: lo pone el programa que corre dentro, y uno como Claude
|
|
47
|
+
* Code pone el nombre de su sesión, sin carpeta. En Linux se lee de /proc; donde no hay /proc
|
|
48
|
+
* (macOS) no se sabe, y se dice con `null` en vez de dar la carpeta de arranque por buena.
|
|
49
|
+
*/
|
|
50
|
+
export function cwdOf (pid) {
|
|
51
|
+
if (!pid) return null
|
|
52
|
+
let dir
|
|
53
|
+
try { dir = fs.readlinkSync(`/proc/${pid}/cwd`) } catch (_) { return null }
|
|
54
|
+
const home = os.homedir()
|
|
55
|
+
return dir === home ? '~' : dir.startsWith(home + '/') ? '~' + dir.slice(home.length) : dir
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
const randomId = () => [...crypto.getRandomValues(new Uint8Array(8))].map((x) => x.toString(16).padStart(2, '0')).join('')
|
|
43
59
|
|
|
44
60
|
class Console {
|
|
@@ -226,7 +242,7 @@ class Console {
|
|
|
226
242
|
const watchers = [...this.viewers].filter((v) => v.origin).map((v) => ({ origin: v.origin, device: v.device || null, tag: v.tag || null }))
|
|
227
243
|
const d = this.decider()
|
|
228
244
|
const sizeBy = d ? { origin: d.origin || null, device: d.device || null, tag: d.tag || null, pinned: !!d && d === this.pinnedViewer() } : null
|
|
229
|
-
return { id: this.id, n: this.n, activity: this.busy ? 'busy' : 'idle', doneAt: this.doneAt, sizeBy, origin: this.origin, title: this.title, cols: this.cols, rows: this.rows, createdAt: this.createdAt, lastActive: this.lastActive, viewers: this.viewers.size, watchers }
|
|
245
|
+
return { id: this.id, n: this.n, activity: this.busy ? 'busy' : 'idle', doneAt: this.doneAt, sizeBy, origin: this.origin, title: this.title, cwd: cwdOf(this.pty?.pid), cols: this.cols, rows: this.rows, createdAt: this.createdAt, lastActive: this.lastActive, viewers: this.viewers.size, watchers }
|
|
230
246
|
}
|
|
231
247
|
}
|
|
232
248
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotrino/terminal-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.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": {
|