@legios/quartermaster 0.1.12 → 0.1.14
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 +28 -14
- package/bin/qm +39 -10
- package/bin/qm-barra.swift +143 -25
- package/bin/qm-indicator +219 -29
- package/bin/qm-tray +10 -0
- package/bin/qm-tray.ps1 +493 -60
- package/bin/qm.mjs +25 -0
- package/dist/adapters/barra.js +129 -13
- package/dist/adapters/barra.js.map +1 -1
- package/dist/adapters/codex.js +24 -0
- package/dist/adapters/codex.js.map +1 -1
- package/dist/adapters/opencode.js +31 -10
- package/dist/adapters/opencode.js.map +1 -1
- package/dist/adapters/zai.js +221 -0
- package/dist/adapters/zai.js.map +1 -0
- package/dist/cli/qm.js +228 -65
- package/dist/cli/qm.js.map +1 -1
- package/dist/core/relevancia.js +111 -0
- package/dist/core/relevancia.js.map +1 -0
- package/dist/render/tablero.html +19 -11
- package/extension/gnome43/quartermaster@legios/extension.js +261 -0
- package/extension/gnome43/quartermaster@legios/metadata.json +11 -0
- package/extension/gnome43/quartermaster@legios/stylesheet.css +10 -0
- package/extension/quartermaster@legios/metadata.json +1 -1
- package/package.json +3 -2
- package/scripts/bumpear.mjs +9 -0
- package/scripts/gate-bandeja.ps1 +267 -19
- package/scripts/gate-lazo.py +396 -0
- package/scripts/gate-tarjetas.py +46 -1
- package/scripts/hacer-deb.sh +10 -1
- package/src/render/tablero.html +19 -11
package/README.md
CHANGED
|
@@ -49,16 +49,18 @@ brew install legiosai/tap/quartermaster # macOS and Linux
|
|
|
49
49
|
npm install -g @legios/quartermaster # anywhere
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
**The bar item, on
|
|
53
|
-
|
|
52
|
+
**The bar item, on all three:** the first time you run `qm` in a terminal, it
|
|
53
|
+
asks once whether to put it in the bar and start it at every login — the menu
|
|
54
|
+
bar on macOS, the top bar on GNOME, the notification area on Windows. The
|
|
54
55
|
install itself can't: brew can't start anything from a formula, the `.deb` drops
|
|
55
|
-
the files and leaves,
|
|
56
|
-
|
|
57
|
-
quartermaster` on macOS, and
|
|
56
|
+
the files and leaves, npm's postinstall won't register anything either, and a
|
|
57
|
+
tool that reads OAuth tokens shouldn't register login agents nobody asked for.
|
|
58
|
+
Without the question: `brew services start quartermaster` on macOS, and
|
|
58
59
|
|
|
59
60
|
```sh
|
|
60
|
-
qm-indicator --instalar-extension # the item that opens the panel on click
|
|
61
|
+
qm-indicator --instalar-extension # Linux: the item that opens the panel on click
|
|
61
62
|
qm-indicator --instalar-arranque # and start it once: qm-indicator &
|
|
63
|
+
bin/qm-tray --instalar-arranque # Windows, from WSL: then run bin/qm-tray
|
|
62
64
|
```
|
|
63
65
|
|
|
64
66
|
Saying yes on Linux **also installs the GNOME extension**, which is what makes a
|
|
@@ -74,7 +76,9 @@ extension already in place, or a GNOME Shell to install ours into. Without those
|
|
|
74
76
|
the process would start anyway and nothing would appear up there, which is worse
|
|
75
77
|
than not offering. `qm --diagnostico` says which one is missing.
|
|
76
78
|
|
|
77
|
-
**Windows:**
|
|
79
|
+
**Windows:** `npm install -g @legios/quartermaster` inside WSL works too, and
|
|
80
|
+
the first `qm` asks the same question — the tray ships in the package. For a
|
|
81
|
+
native install without WSL, the installer from the [latest
|
|
78
82
|
release](https://github.com/legiosai/quartermaster/releases/latest). Per-user
|
|
79
83
|
and no UAC: it puts `qm` on your `PATH`, the tray in the Start menu, and — if
|
|
80
84
|
you leave the box ticked — the tray in startup.
|
|
@@ -219,18 +223,27 @@ quota response it got in each profile's `.claude.json`, so quartermaster reads
|
|
|
219
223
|
it from disk — which means it still works on a profile whose token expired,
|
|
220
224
|
the exact state the motivating monitor died in.
|
|
221
225
|
|
|
222
|
-
The only thing that ever leaves is one request, and only when you ask
|
|
223
|
-
(`--refrescar`, or `--calentar`, which is what the panels run):
|
|
226
|
+
The only thing that ever leaves is one request per vendor, and only when you ask
|
|
227
|
+
for it (`--refrescar`, or `--calentar`, which is what the panels run):
|
|
224
228
|
|
|
225
229
|
```
|
|
226
230
|
GET https://api.anthropic.com/api/oauth/usage
|
|
231
|
+
GET https://api.z.ai/api/monitor/usage/quota/limit # only if you use z.ai
|
|
227
232
|
```
|
|
228
233
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
234
|
+
Each one is the same host that vendor's own tool already talks to, with the
|
|
235
|
+
credential it already stored, asking about your own account, with a 60-second
|
|
236
|
+
floor. No account, no cloud, no telemetry, and zero runtime dependencies. **It
|
|
237
|
+
never refreshes a token** — a locked non-goal, with a test.
|
|
232
238
|
|
|
233
|
-
The
|
|
239
|
+
The z.ai one is the exception to "no credential", and it is worth knowing which
|
|
240
|
+
direction it runs: opencode stores GLM, MiniMax and Kimi plans as API keys, and
|
|
241
|
+
those plans leave no percentage anywhere on disk. The opencode rows therefore
|
|
242
|
+
show what disk can prove — tokens spent, and the reset time a `429` already told
|
|
243
|
+
you — and the percentage only after you ask for it once. It is cached like every
|
|
244
|
+
other number, so the panels get a bar without ever touching the key themselves.
|
|
245
|
+
|
|
246
|
+
The full table, and the straight paragraph about both endpoints being
|
|
234
247
|
undocumented, are in [`SECURITY.md`](SECURITY.md).
|
|
235
248
|
|
|
236
249
|
## Package managers
|
|
@@ -273,7 +286,8 @@ What each channel needs configured is in
|
|
|
273
286
|
src/core/ profiles, types. Knows nothing about keychains or HTTP.
|
|
274
287
|
src/adapters/ credentials (keychain / file), transcripts (JSONL), quota
|
|
275
288
|
from the cache (.claude.json) and from the endpoint (HTTP),
|
|
276
|
-
Codex (JSON-RPC)
|
|
289
|
+
Codex (JSON-RPC), opencode (SQLite) and z.ai (HTTP — the
|
|
290
|
+
only file that opens opencode's auth.json).
|
|
277
291
|
src/cli/ qm, and one demo per milestone.
|
|
278
292
|
src/render/ bars and formatting for the terminal, and the dashboard.
|
|
279
293
|
bin/ the launchers — qm (POSIX), qm.cmd + buscar-node.cmd
|
package/bin/qm
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
# interactivos— el shebang de siempre falla con un error de sintaxis que no le
|
|
8
8
|
# dice nada a nadie. Así que acá se busca un Node que sirva antes de arrancar.
|
|
9
9
|
#
|
|
10
|
-
# Orden: $QM_NODE, el del PATH, y después
|
|
10
|
+
# Orden: $QM_NODE, el del PATH, y después lo que hayan guardado los manejadores
|
|
11
|
+
# de versiones —nvm, fnm y volta— de mayor a menor.
|
|
11
12
|
|
|
12
13
|
set -e
|
|
13
14
|
|
|
@@ -18,19 +19,47 @@ sirve() {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
NODO=""
|
|
22
|
+
|
|
23
|
+
# Cada manejador de versiones guarda los Node con una forma distinta:
|
|
24
|
+
#
|
|
25
|
+
# nvm $NVM_DIR/versions/node/v22.22.2/bin/node
|
|
26
|
+
# fnm $FNM_DIR/node-versions/v22.22.2/installation/bin/node
|
|
27
|
+
# volta $VOLTA_HOME/tools/image/node/22.22.2/bin/node
|
|
28
|
+
#
|
|
29
|
+
# Se recorren de mayor a menor VERSIÓN y no alfabéticamente, para que v9 no le
|
|
30
|
+
# gane a v22. La `v` del nombre se saca antes de ordenar porque volta no la
|
|
31
|
+
# pone, y después se prueban las dos formas del nombre.
|
|
32
|
+
#
|
|
33
|
+
# Acá faltaban fnm y volta, y el README decía que estaban. Se notó de la peor
|
|
34
|
+
# manera posible: el indicador de GNOME arranca desde el autostart, que NO tiene
|
|
35
|
+
# el PATH de un shell interactivo —ahí es donde fnm se carga—, así que no
|
|
36
|
+
# encontraba Node, se quedaba mostrando los números de la sesión anterior, y lo
|
|
37
|
+
# único que lo decía era un renglón en el journal.
|
|
38
|
+
buscar_en() {
|
|
39
|
+
raiz=$1
|
|
40
|
+
medio=$2
|
|
41
|
+
[ -d "$raiz" ] || return 1
|
|
42
|
+
for d in $(ls -1 "$raiz" 2>/dev/null | sed 's/^v//' | sort -t. -k1,1n -k2,2n -k3,3n -r); do
|
|
43
|
+
for nombre in "v$d" "$d"; do
|
|
44
|
+
if sirve "$raiz/$nombre$medio"; then
|
|
45
|
+
NODO="$raiz/$nombre$medio"
|
|
46
|
+
return 0
|
|
47
|
+
fi
|
|
48
|
+
done
|
|
49
|
+
done
|
|
50
|
+
return 1
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
if [ -n "$QM_NODE" ] && sirve "$QM_NODE"; then
|
|
22
54
|
NODO="$QM_NODE"
|
|
23
55
|
elif sirve "$(command -v node 2>/dev/null)"; then
|
|
24
56
|
NODO="$(command -v node)"
|
|
25
57
|
else
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
break
|
|
32
|
-
fi
|
|
33
|
-
done
|
|
58
|
+
buscar_en "${NVM_DIR:-$HOME/.nvm}/versions/node" "/bin/node" \
|
|
59
|
+
|| buscar_en "${FNM_DIR:-$HOME/.local/share/fnm}/node-versions" "/installation/bin/node" \
|
|
60
|
+
|| buscar_en "$HOME/Library/Application Support/fnm/node-versions" "/installation/bin/node" \
|
|
61
|
+
|| buscar_en "${VOLTA_HOME:-$HOME/.volta}/tools/image/node" "/bin/node" \
|
|
62
|
+
|| true
|
|
34
63
|
fi
|
|
35
64
|
|
|
36
65
|
# `src/adapters/opencode.ts` usa node:sqlite, que es experimental, así que Node
|
|
@@ -56,7 +85,7 @@ if [ -z "$NODO" ]; then
|
|
|
56
85
|
echo "qm necesita Node >= 22.6 y no encontré ninguno." >&2
|
|
57
86
|
echo "Lee TypeScript sin paso de build, y eso recién existe desde 22.6." >&2
|
|
58
87
|
echo "" >&2
|
|
59
|
-
echo " nvm install 22 # o
|
|
88
|
+
echo " nvm install 22 # o fnm install 22, o como prefieras" >&2
|
|
60
89
|
echo " QM_NODE=/ruta/a/node qm # o decile cuál usar" >&2
|
|
61
90
|
exit 1
|
|
62
91
|
fi
|
package/bin/qm-barra.swift
CHANGED
|
@@ -31,6 +31,12 @@ import Foundation
|
|
|
31
31
|
let SEGUNDOS_SONDEO: TimeInterval = 300
|
|
32
32
|
// Coalescer escrituras: Claude Code reescribe .claude.json varias veces seguidas.
|
|
33
33
|
let DEBOUNCE: TimeInterval = 1.5
|
|
34
|
+
/// Cada cuánto mira el vigía, y a partir de qué atraso da la alarma. El plazo
|
|
35
|
+
/// son cuatro sondeos: con la cadencia en su techo, un calentado que no ocurrió
|
|
36
|
+
/// en veinte minutos no es lentitud, es que el lazo se cortó.
|
|
37
|
+
let VIGIA_SEGUNDOS: TimeInterval = 60
|
|
38
|
+
let VIGIA_PLAZO: TimeInterval = 20 * 60
|
|
39
|
+
|
|
34
40
|
/// Piso para cualquier cadencia que salga a la RED.
|
|
35
41
|
///
|
|
36
42
|
/// La primera versión bajaba a 20 s cuando una barra pasaba el 90 %, y como
|
|
@@ -370,6 +376,25 @@ struct PerfilVista {
|
|
|
370
376
|
let presupuesto: Presupuesto?
|
|
371
377
|
/// Cuándo se usó por última vez, según qm. Existe también en --breve.
|
|
372
378
|
let ultimoUso: Date?
|
|
379
|
+
/// Va al final y no encabeza. Lo decide qm; acá sólo se dibuja.
|
|
380
|
+
let dormida: Bool
|
|
381
|
+
/// Por qué, en palabras. Prosa para mostrar, no para parsear.
|
|
382
|
+
let porque: [String]
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/// Quién frena primero en toda la máquina, ya resuelto por qm.
|
|
386
|
+
///
|
|
387
|
+
/// Antes esto se decidía acá adentro, recorriendo los perfiles y quedándose con
|
|
388
|
+
/// el `frena` de porcentaje más alto. Era la misma elección escrita seis veces
|
|
389
|
+
/// —una por pantalla— y las seis coincidían sólo por casualidad: el día que el
|
|
390
|
+
/// criterio cambió (una cuenta dormida en 100 % ya no encabeza), cinco se
|
|
391
|
+
/// quedaron con el criterio viejo. CONTRIBUTING.md: una regla que un renderer
|
|
392
|
+
/// reimplementa es un bug del CLI.
|
|
393
|
+
struct Lider {
|
|
394
|
+
let perfil: String
|
|
395
|
+
let ventana: Ventana
|
|
396
|
+
/// true si NO quedaba ninguna despierta: el encabezado es lo único que hay.
|
|
397
|
+
let dormida: Bool
|
|
373
398
|
}
|
|
374
399
|
|
|
375
400
|
// Las reglas del núcleo no se reimplementan acá: `qm` manda `mostrar`, `frena`,
|
|
@@ -388,7 +413,7 @@ func fecha(_ s: Any?) -> Date? {
|
|
|
388
413
|
|
|
389
414
|
// ── leer a qm ────────────────────────────────────────────────────────────
|
|
390
415
|
enum Lectura {
|
|
391
|
-
case ok([PerfilVista])
|
|
416
|
+
case ok([PerfilVista], Lider?)
|
|
392
417
|
/// Silencio es el bug: si no hay número, hay una frase.
|
|
393
418
|
case falla(String)
|
|
394
419
|
}
|
|
@@ -479,9 +504,27 @@ func leer() -> Lectura {
|
|
|
479
504
|
edadSegundos: cuota["edadSegundos"] as? Int,
|
|
480
505
|
proyeccion: proy,
|
|
481
506
|
presupuesto: pre,
|
|
482
|
-
ultimoUso: fecha(p["ultimoUso"])
|
|
507
|
+
ultimoUso: fecha(p["ultimoUso"]),
|
|
508
|
+
dormida: ((p["relevancia"] as? [String: Any])?["dormida"] as? Bool) ?? false,
|
|
509
|
+
porque: ((p["relevancia"] as? [String: Any])?["porque"] as? [String]) ?? [])
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
var lider: Lider? = nil
|
|
513
|
+
if let l = raiz["frenaPrimero"] as? [String: Any],
|
|
514
|
+
let nombre = l["perfil"] as? String,
|
|
515
|
+
let v = l["ventana"] as? [String: Any] {
|
|
516
|
+
lider = Lider(perfil: nombre,
|
|
517
|
+
ventana: Ventana(clave: v["clave"] as? String ?? "?",
|
|
518
|
+
alcance: v["alcance"] as? String,
|
|
519
|
+
porcentaje: v["porcentaje"] as? Int ?? 0,
|
|
520
|
+
severidad: v["severidad"] as? String ?? "normal",
|
|
521
|
+
activa: v["activa"] as? Bool ?? false,
|
|
522
|
+
reinicia: fecha(v["reinicia"]),
|
|
523
|
+
grupo: v["grupo"] as? String,
|
|
524
|
+
preocupa: v["preocupa"] as? Bool ?? false),
|
|
525
|
+
dormida: (l["dormida"] as? Bool) ?? false)
|
|
483
526
|
}
|
|
484
|
-
return .ok(perfiles)
|
|
527
|
+
return .ok(perfiles, lider)
|
|
485
528
|
}
|
|
486
529
|
|
|
487
530
|
// ── avisos ───────────────────────────────────────────────────────────────
|
|
@@ -521,20 +564,14 @@ final class VistaResumen: NSView {
|
|
|
521
564
|
private let nivel: Nivel
|
|
522
565
|
private let reinicia: Date?
|
|
523
566
|
|
|
524
|
-
init?(_ perfiles: [PerfilVista]) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
mejor = (p, v, i)
|
|
530
|
-
}
|
|
531
|
-
i += 1
|
|
532
|
-
}
|
|
533
|
-
guard let (p, v, _) = mejor else { return nil }
|
|
534
|
-
cuenta = corto(p.nombre)
|
|
567
|
+
init?(_ lider: Lider?, _ perfiles: [PerfilVista]) {
|
|
568
|
+
guard let l = lider else { return nil }
|
|
569
|
+
let p = perfiles.first(where: { $0.nombre == l.perfil })
|
|
570
|
+
let v = l.ventana
|
|
571
|
+
cuenta = corto(p?.nombre ?? l.perfil)
|
|
535
572
|
barra = v.nombre
|
|
536
573
|
pct = v.porcentaje
|
|
537
|
-
nivel = nivelDe(v.porcentaje, preocupa: v.preocupa || (p
|
|
574
|
+
nivel = nivelDe(v.porcentaje, preocupa: v.preocupa || (p?.proyeccion?.chocas ?? false))
|
|
538
575
|
reinicia = v.reinicia
|
|
539
576
|
super.init(frame: NSRect(x: 0, y: 0, width: 340, height: 74))
|
|
540
577
|
}
|
|
@@ -845,6 +882,13 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
845
882
|
}
|
|
846
883
|
var pendiente: DispatchWorkItem?
|
|
847
884
|
var reloj: Timer?
|
|
885
|
+
/// Cuándo terminó el último calentado, y si el vigía ya avisó de este corte.
|
|
886
|
+
/// Es lo que mira `vigia`: la pregunta no es «¿está armado el timer?» —eso
|
|
887
|
+
/// se puede creer y estar equivocado— sino «¿cuándo fue la última vez que
|
|
888
|
+
/// de verdad le preguntamos al servidor?».
|
|
889
|
+
var calentadoEn: Date?
|
|
890
|
+
var vigiaAviso = false
|
|
891
|
+
var relojVigia: Timer?
|
|
848
892
|
/// Sin esto macOS le aplica App Nap —es una app sin ventanas— y los timers
|
|
849
893
|
/// se corren minutos. Medido: un sondeo de 5 min que no disparó en 7.
|
|
850
894
|
var actividad: NSObjectProtocol?
|
|
@@ -892,6 +936,7 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
892
936
|
options: [.userInitiated, .idleSystemSleepDisabled],
|
|
893
937
|
reason: "mirar la cuota a tiempo")
|
|
894
938
|
refrescar()
|
|
939
|
+
armarVigia()
|
|
895
940
|
calentarCodex()
|
|
896
941
|
}
|
|
897
942
|
|
|
@@ -915,9 +960,32 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
915
960
|
|
|
916
961
|
var minutosAlTecho: Double? = nil
|
|
917
962
|
|
|
918
|
-
|
|
963
|
+
/// Agenda el próximo calentado, y NUNCA lo aleja.
|
|
964
|
+
///
|
|
965
|
+
/// Esto se llama al final del armado del menú, y el menú se arma en cada
|
|
966
|
+
/// `refrescar()` — que acá lo dispara el vigía de archivos, y Claude Code
|
|
967
|
+
/// reescribe su .claude.json cada veinte segundos. Rearmar siempre
|
|
968
|
+
/// significaba correr la fecha del calentado con cada escritura ajena:
|
|
969
|
+
/// el calentado no llegaba a vencer nunca.
|
|
970
|
+
///
|
|
971
|
+
/// Del lado de GNOME, que tiene la misma forma con el sondeo periódico en
|
|
972
|
+
/// vez del vigía de archivos, pasó de verdad: medido el 2026-09-15, un solo
|
|
973
|
+
/// calentado al arrancar y siete horas y media sin ninguno, con la bandera
|
|
974
|
+
/// libre y un temporizador armado todo el tiempo —armado y reiniciado, que
|
|
975
|
+
/// es distinto de disparado—.
|
|
976
|
+
///
|
|
977
|
+
/// La regla es simple: una fecha más lejos que la que ya hay no reemplaza a
|
|
978
|
+
/// nada. Apretar la cadencia sigue andando, porque ésa siempre es más cerca.
|
|
979
|
+
func programar(forzando: Bool = false) {
|
|
980
|
+
let cuanto = cadencia()
|
|
981
|
+
let cuando = Date().addingTimeInterval(cuanto)
|
|
982
|
+
// `forzando` es para el vigía: cuando el calentado está parado, la fecha
|
|
983
|
+
// agendada YA VENCIÓ, así que cualquier fecha nueva es «más lejos» y la
|
|
984
|
+
// guarda la rechazaría. La defensa contra el hambre desactivaba a la
|
|
985
|
+
// defensa contra el silencio.
|
|
986
|
+
if !forzando, let r = reloj, r.isValid, cuando >= r.fireDate { return }
|
|
919
987
|
reloj?.invalidate()
|
|
920
|
-
let t = Timer(timeInterval:
|
|
988
|
+
let t = Timer(timeInterval: cuanto, repeats: false) { _ in
|
|
921
989
|
// Codex primero: su número no está en ningún disco hasta que
|
|
922
990
|
// alguien lo pide, y el refresco de abajo lee del cache.
|
|
923
991
|
self.calentarCodex()
|
|
@@ -929,6 +997,47 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
929
997
|
reloj = t
|
|
930
998
|
}
|
|
931
999
|
|
|
1000
|
+
/// Que el calentado no pueda dejar de ocurrir en silencio.
|
|
1001
|
+
///
|
|
1002
|
+
/// `programar()` arma un Timer de UNA sola vez, y el único lugar que lo
|
|
1003
|
+
/// vuelve a armar es el final del armado del menú. Cualquier corte en esa
|
|
1004
|
+
/// cadena apaga el calentado para toda la vida del proceso y sin ruido.
|
|
1005
|
+
///
|
|
1006
|
+
/// Pasó del lado de GNOME, que tiene la misma forma: el 2026-09-15, con
|
|
1007
|
+
/// 0.1.13, el indicador de Linux dejó de preguntarle al endpoint y estuvo
|
|
1008
|
+
/// siete horas y media sin escribir una línea, con el proceso vivo y el
|
|
1009
|
+
/// item redibujándose. Acá no se esperó a que pasara.
|
|
1010
|
+
///
|
|
1011
|
+
/// Esto mira desde afuera, se repite solo y no depende del calentado: si
|
|
1012
|
+
/// pasó el plazo sin una lectura, lo ANOTA una vez y lo rearma.
|
|
1013
|
+
func armarVigia() {
|
|
1014
|
+
// Con la hora de arranque y no en nil: si el PRIMER calentado nunca
|
|
1015
|
+
// termina, un vigía que espera a tener una marca no mira nunca.
|
|
1016
|
+
if calentadoEn == nil { calentadoEn = Date() }
|
|
1017
|
+
relojVigia?.invalidate()
|
|
1018
|
+
let t = Timer(timeInterval: VIGIA_SEGUNDOS, repeats: true) { [weak self] _ in
|
|
1019
|
+
self?.vigia()
|
|
1020
|
+
}
|
|
1021
|
+
t.tolerance = 0
|
|
1022
|
+
RunLoop.main.add(t, forMode: .common)
|
|
1023
|
+
relojVigia = t
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
func vigia() {
|
|
1027
|
+
guard let desde = calentadoEn else { return }
|
|
1028
|
+
let atraso = Date().timeIntervalSince(desde)
|
|
1029
|
+
guard atraso > VIGIA_PLAZO else {
|
|
1030
|
+
vigiaAviso = false
|
|
1031
|
+
return
|
|
1032
|
+
}
|
|
1033
|
+
// Una vez por corte, no una por minuto: el log tiene que poder leerse.
|
|
1034
|
+
if !vigiaAviso {
|
|
1035
|
+
registrar("el calentado no ocurre hace \(duracion(Int(atraso))): lo rearmo")
|
|
1036
|
+
vigiaAviso = true
|
|
1037
|
+
}
|
|
1038
|
+
programar(forzando: true)
|
|
1039
|
+
}
|
|
1040
|
+
|
|
932
1041
|
/// Refresca las dos puntas —el endpoint de cada perfil de Claude y el de
|
|
933
1042
|
/// Codex— y deja los números en el cache de qm, para que las lecturas de la
|
|
934
1043
|
/// barra —que son `--breve`— sigan tardando milisegundos y encuentren algo
|
|
@@ -986,6 +1095,8 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
986
1095
|
self.motivosCalentado.insert(m)
|
|
987
1096
|
registrar(m)
|
|
988
1097
|
}
|
|
1098
|
+
self.calentadoEn = Date()
|
|
1099
|
+
self.vigiaAviso = false
|
|
989
1100
|
self.refrescar()
|
|
990
1101
|
}
|
|
991
1102
|
}
|
|
@@ -1058,7 +1169,7 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
1058
1169
|
item.button?.image = icono("exclamationmark.triangle.fill")
|
|
1059
1170
|
agregar(menu, porque, activo: false)
|
|
1060
1171
|
|
|
1061
|
-
case .ok(let perfiles):
|
|
1172
|
+
case .ok(let perfiles, let lider):
|
|
1062
1173
|
if ultimaFalla != nil { registrar("lectura de qm volvió a andar") }
|
|
1063
1174
|
ultimaFalla = nil
|
|
1064
1175
|
vigilar(perfiles)
|
|
@@ -1069,7 +1180,7 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
1069
1180
|
var iCuenta = 0
|
|
1070
1181
|
var peorPct = 0
|
|
1071
1182
|
|
|
1072
|
-
if let resumen = VistaResumen(perfiles) {
|
|
1183
|
+
if let resumen = VistaResumen(lider, perfiles) {
|
|
1073
1184
|
let fila = NSMenuItem()
|
|
1074
1185
|
fila.view = resumen
|
|
1075
1186
|
menu.addItem(fila)
|
|
@@ -1092,7 +1203,9 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
1092
1203
|
// El `!` no es sólo severidad: también avisa que a este
|
|
1093
1204
|
// ritmo tocás el techo ANTES del reinicio.
|
|
1094
1205
|
let chocas = p.proyeccion?.chocas ?? false
|
|
1095
|
-
|
|
1206
|
+
// Una cuenta dormida no alarma: el «!» avisa de algo que te
|
|
1207
|
+
// va a frenar, y una cuenta que nadie usa no frena nada.
|
|
1208
|
+
let esLaProyectada = { (v: Ventana) in !p.dormida && chocas && v.clave == cual.clave }
|
|
1096
1209
|
|
|
1097
1210
|
let ses = p.sesion
|
|
1098
1211
|
let sem = p.semanal
|
|
@@ -1100,18 +1213,23 @@ final class Barra: NSObject, NSApplicationDelegate {
|
|
|
1100
1213
|
piezas.append(Trozo(
|
|
1101
1214
|
nombre: corto(p.nombre), producto: p.producto, indice: piezas.count,
|
|
1102
1215
|
sesion: ses?.porcentaje,
|
|
1103
|
-
sesionAlerta: ses.map { $0.preocupa || esLaProyectada($0) } ?? false,
|
|
1216
|
+
sesionAlerta: ses.map { !p.dormida && ($0.preocupa || esLaProyectada($0)) } ?? false,
|
|
1104
1217
|
semanal: sem?.porcentaje,
|
|
1105
|
-
semanalAlerta: sem.map { $0.preocupa || esLaProyectada($0) } ?? false,
|
|
1218
|
+
semanalAlerta: sem.map { !p.dormida && ($0.preocupa || esLaProyectada($0)) } ?? false,
|
|
1106
1219
|
diario: p.presupuesto?.pctDiario,
|
|
1107
1220
|
viejo: viejo,
|
|
1108
1221
|
perfil: p.nombre,
|
|
1109
1222
|
reiniciaSesion: ses?.reinicia,
|
|
1110
1223
|
reiniciaSemanal: sem?.reinicia,
|
|
1111
1224
|
ultimoUso: p.ultimoUso))
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1225
|
+
// El color del ícono sigue a lo que te frena DE VERDAD: una
|
|
1226
|
+
// cuenta dormida en 100 % dejaba la barra de menú en rojo
|
|
1227
|
+
// permanente por una cuenta que nadie usa.
|
|
1228
|
+
if !p.dormida { peorPct = max(peorPct, cual.porcentaje) }
|
|
1229
|
+
if !p.dormida {
|
|
1230
|
+
revisarAvisos(p, visibles)
|
|
1231
|
+
revisarLiberadas(p, visibles)
|
|
1232
|
+
}
|
|
1115
1233
|
}
|
|
1116
1234
|
}
|
|
1117
1235
|
|