@jmanuelcorral/bond-app 0.2.2 → 0.3.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/app/mods/bond-agents/main.js +446 -28
- package/app/mods/bond-agents/model.js +236 -0
- package/app/mods/bond-board/main.js +170 -16
- package/app/mods/bond-board/model.js +63 -2
- package/app/mods/bond-settings/main.js +128 -2
- package/package.json +1 -1
- package/runner/versions.env +1 -1
- package/src/config.ts +3 -0
- package/src/core/agent-flags.ts +38 -0
- package/src/core/agent-waiting.ts +38 -0
- package/src/core/agy-login.ts +56 -4
- package/src/core/doctor.ts +58 -12
- package/src/core/handoff.ts +161 -0
- package/src/core/hub-session.ts +14 -2
- package/src/core/hub.ts +3 -3
- package/src/core/loop.ts +241 -0
- package/src/core/orchestrator.ts +961 -181
- package/src/core/pi-compaction.ts +98 -0
- package/src/core/stuck.ts +192 -0
- package/src/db/database.ts +31 -1
- package/src/db/run-repo.ts +38 -3
- package/src/db/settings-repo.ts +138 -0
- package/src/db/ticket-repo.ts +74 -5
- package/src/runner/hc-client.ts +27 -4
- package/src/server/app.ts +175 -3
- package/src/types.ts +74 -0
|
@@ -121,12 +121,16 @@ export function hubPushDestinations(ticket, run) {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** P5: the hub analysis for the card: status, gaps (with their fix) and notes. */
|
|
124
|
+
const HUB_OPINION_GAPS = new Set(["missing_repo", "agent_not_ready"]);
|
|
125
|
+
|
|
124
126
|
export function analysisInfo(run) {
|
|
125
127
|
const a = run?.hub_analysis;
|
|
126
128
|
if (!a || !Array.isArray(a.gaps)) return null;
|
|
127
129
|
return {
|
|
128
130
|
status: a.status,
|
|
129
|
-
gaps: a.gaps.map((g) => ({ id: g.id, message: g.message, fixable: Boolean(g.fix) })),
|
|
131
|
+
gaps: a.gaps.map((g) => ({ id: g.id, kind: g.kind ?? null, message: g.message, fixable: Boolean(g.fix) })),
|
|
132
|
+
// «Seguir sin ellos»: every gap is the hub agent's opinion, which a person may overrule.
|
|
133
|
+
opinionOnly: a.gaps.length > 0 && a.gaps.every((g) => HUB_OPINION_GAPS.has(g.kind)),
|
|
130
134
|
fixable: a.gaps.filter((g) => g.fix).length,
|
|
131
135
|
warnings: Array.isArray(a.warnings) ? a.warnings : [],
|
|
132
136
|
summary: a.agent_summary ?? null,
|
|
@@ -261,6 +265,7 @@ export function buildCards(tickets, runs, agentStatus = {}, now = Date.now()) {
|
|
|
261
265
|
canFinish: Boolean(run && (run.state === "running" || run.state === "waiting")),
|
|
262
266
|
hubBlocked,
|
|
263
267
|
canApprove: hubBlocked && Boolean(analysis && analysis.fixable > 0),
|
|
268
|
+
canProceed: hubBlocked && Boolean(analysis?.opinionOnly),
|
|
264
269
|
prUrl: run?.pr_url ?? null,
|
|
265
270
|
prNumber: run?.pr_number ?? null,
|
|
266
271
|
};
|
|
@@ -379,6 +384,11 @@ export async function finishRun(api, runId) {
|
|
|
379
384
|
return api(`/runs/${encodeURIComponent(runId)}/finish`, { method: "POST", body: {} });
|
|
380
385
|
}
|
|
381
386
|
|
|
387
|
+
/** «Seguir sin ellos»: start the hub team despite the hub agent's gaps. */
|
|
388
|
+
export async function proceedHub(api, runId) {
|
|
389
|
+
return api(`/runs/${encodeURIComponent(runId)}/hub/proceed`, { method: "POST", body: {} });
|
|
390
|
+
}
|
|
391
|
+
|
|
382
392
|
/** P5 «Aprobar arreglos»: apply the analysis' fixes in the hub and analyse again. */
|
|
383
393
|
export async function approveHubFixes(api, runId) {
|
|
384
394
|
return api(`/runs/${encodeURIComponent(runId)}/hub/approve`, { method: "POST", body: {} });
|
|
@@ -504,6 +514,11 @@ export function validateNewTicket(form) {
|
|
|
504
514
|
body.bondify = f.bondify !== undefined ? Boolean(f.bondify) : true;
|
|
505
515
|
// «Docker en el run»: on unless unticked (decision 2026-11-25); always sent explicitly.
|
|
506
516
|
body.docker = f.docker !== false;
|
|
517
|
+
// Issue #4 (P2): «Login de Azure» only when ticked (the form ticks it while there is a session); its subscription when it differs (D4).
|
|
518
|
+
if (f.azure_login) {
|
|
519
|
+
body.azure_login = true;
|
|
520
|
+
if (f.azure_subscription) body.azure_subscription = String(f.azure_subscription);
|
|
521
|
+
}
|
|
507
522
|
if (model) body.model = model;
|
|
508
523
|
if ((mode !== "repo" || f.is_hub || Boolean(f.hub_url)) && f.team_engine) {
|
|
509
524
|
body.team_engine = f.team_engine === "herdr" ? "herdr" : "hc";
|
|
@@ -553,7 +568,7 @@ export function validateNewTicket(form) {
|
|
|
553
568
|
body.repos = repos;
|
|
554
569
|
} else {
|
|
555
570
|
const url = String(f.hub ?? "").trim();
|
|
556
|
-
if (!GITHUB_URL.test(url)) errors.hub = "URL
|
|
571
|
+
if (!GITHUB_URL.test(url) && !AZURE_URL.test(url)) errors.hub = "URL del hub: https://github.com/org/hub o https://dev.azure.com/org/proyecto/_git/hub";
|
|
557
572
|
body.hub_url = url;
|
|
558
573
|
if (base) body.hub_base = base;
|
|
559
574
|
}
|
|
@@ -593,6 +608,21 @@ export function validateNewTicket(form) {
|
|
|
593
608
|
}
|
|
594
609
|
}
|
|
595
610
|
|
|
611
|
+
// LOOP P1 (issue #2): «Modo loop», hub tickets only (v1, D7). Iterations 1-1000, or
|
|
612
|
+
// «sin límite» (null). Not sent at all when off: the API keeps it disabled.
|
|
613
|
+
if (f.loop) {
|
|
614
|
+
const isHub = mode === "hub" || mode === "list" || Boolean(f.is_hub) || Boolean(f.hub_url);
|
|
615
|
+
if (!isHub) {
|
|
616
|
+
errors.loop = "El modo loop solo está disponible en tickets de hub";
|
|
617
|
+
} else if (f.loop_unlimited) {
|
|
618
|
+
body.loop = { enabled: true, max_iterations: null };
|
|
619
|
+
} else {
|
|
620
|
+
const n = Number(String(f.loop_max ?? "").trim());
|
|
621
|
+
if (!Number.isInteger(n) || n < 1 || n > 1000) errors.loop = "Iteraciones: un entero de 1 a 1000, o «sin límite»";
|
|
622
|
+
else body.loop = { enabled: true, max_iterations: n };
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
596
626
|
return { ok: Object.keys(errors).length === 0, errors, body };
|
|
597
627
|
}
|
|
598
628
|
|
|
@@ -732,3 +762,34 @@ export async function resolvePullRequest(api, url, hubUrl) {
|
|
|
732
762
|
if (hubUrl) params.set("hub_url", String(hubUrl).trim());
|
|
733
763
|
return api(`/prs/resolve?${params.toString()}`);
|
|
734
764
|
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* The query of GET /repos/devcontainer (devcontainer? hub?) for a repo URL, with the branch:
|
|
768
|
+
* `owner=&repo=` for GitHub, `url=` for Azure Repos (dev.azure.com or *.visualstudio.com), whose
|
|
769
|
+
* API reads hub.toml with the Azure credential. null for anything else. Before, only GitHub was
|
|
770
|
+
* checked, so an Azure hub stayed «Un repo» in «Nuevo ticket».
|
|
771
|
+
*/
|
|
772
|
+
export function repoCheckQuery(url, base = "") {
|
|
773
|
+
const u = String(url ?? "").trim();
|
|
774
|
+
const ref = base ? `&ref=${encodeURIComponent(base)}` : "";
|
|
775
|
+
const gh = /github\.com[/:]([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/.exec(u);
|
|
776
|
+
if (gh) return { key: `${gh[1]}/${gh[2]}@${base}`, label: `${gh[1]}/${gh[2]}`, query: `owner=${encodeURIComponent(gh[1])}&repo=${encodeURIComponent(gh[2])}${ref}` };
|
|
777
|
+
if (AZURE_URL.test(u)) {
|
|
778
|
+
const name = /\/_git\/([^/?#]+)/.exec(u)?.[1] ?? u;
|
|
779
|
+
return { key: `${u}@${base}`, label: decodeURIComponent(name), query: `url=${encodeURIComponent(u)}${ref}` };
|
|
780
|
+
}
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* What the run's first tab (INIT_TAB) runs: a note saying the run is being prepared (an
|
|
786
|
+
* analysed hub can take minutes before gru starts), then a shell. The tab closes on its own
|
|
787
|
+
* once the run's leader has its own (initTabToClose). Same text as bond-agents' INIT_ARGV.
|
|
788
|
+
*/
|
|
789
|
+
export const INIT_ARGV = ["sh", "-c", [
|
|
790
|
+
"printf '\\n bond-app · preparando el run\\n\\n'",
|
|
791
|
+
"printf ' Se clona el código y, en un hub, un agente de solo lectura revisa si al hub le falta\\n'",
|
|
792
|
+
"printf ' algo para la historia (hasta 5 minutos). Después arranca gru, el agente principal,\\n'",
|
|
793
|
+
"printf ' y esta pestaña se cierra sola. El estado está en el panel Agentes.\\n\\n'",
|
|
794
|
+
"exec sh",
|
|
795
|
+
].join("; ")];
|
|
@@ -95,6 +95,19 @@ const LOGIN_TEXT = {
|
|
|
95
95
|
success: (email) => `✓ Sesión de copilot guardada${email ? `: ${email}` : ""}`,
|
|
96
96
|
successSub: "El token no sale del orquestador ni se muestra aquí. El contenedor efímero se ha destruido. Para revocarlo: github.com/settings/applications (GitHub Copilot CLI).",
|
|
97
97
|
},
|
|
98
|
+
// Issue #4 (P1): the person's Azure session with az's device code.
|
|
99
|
+
azure: {
|
|
100
|
+
button: "Iniciar sesión en Azure…",
|
|
101
|
+
title: "Iniciar sesión en Azure",
|
|
102
|
+
intro: "az inicia sesión con tu cuenta de Microsoft (código de dispositivo). Ojo: los runs con «Login de Azure» actúan en Azure con tus permisos, producción incluida. La sesión se guarda en el orquestador (0600) y llega a cada run por stdin.",
|
|
103
|
+
starting: "Iniciando contenedor y az…",
|
|
104
|
+
startingSub: "Pidiendo un código de dispositivo a Microsoft…",
|
|
105
|
+
placeholder: "",
|
|
106
|
+
step2: "2. Escribe este código en esa página e inicia sesión:",
|
|
107
|
+
authenticating: "Esperando a que inicies sesión en Microsoft…",
|
|
108
|
+
success: (email) => `✓ Sesión de Azure guardada${email ? `: ${email}` : ""}`,
|
|
109
|
+
successSub: "Los tokens no salen del orquestador ni se muestran aquí. El contenedor efímero se ha destruido. Elige la suscripción por defecto en Ajustes → Azure.",
|
|
110
|
+
},
|
|
98
111
|
};
|
|
99
112
|
|
|
100
113
|
/** « · caduca el AAAA-MM-DD» for credentials with a known expiry (claude's setup-token). */
|
|
@@ -105,7 +118,7 @@ export const SECTIONS = [
|
|
|
105
118
|
{ id: "orchestrator", label: "Orquestador" },
|
|
106
119
|
{ id: "agents", label: "Agentes" },
|
|
107
120
|
{ id: "github", label: "GitHub" },
|
|
108
|
-
{ id: "azure", label: "Azure
|
|
121
|
+
{ id: "azure", label: "Azure" },
|
|
109
122
|
{ id: "jira", label: "Jira" },
|
|
110
123
|
{ id: "image", label: "Imagen" },
|
|
111
124
|
{ id: "advanced", label: "Avanzado" },
|
|
@@ -286,6 +299,11 @@ export default class BondSettings extends View {
|
|
|
286
299
|
this.setup = null; // W-P2 «Configuración»: el agregado de GET /setup
|
|
287
300
|
this.conn = null; // «Orquestador»: { state, detail } de diagnose()
|
|
288
301
|
this.connBusy = null; // "reconnect" | "restart" | "start" mientras dura la acción
|
|
302
|
+
// LOOP P1 (issue #2): the loop defaults (GET/PUT /settings/loop).
|
|
303
|
+
this.loopMax = InputState.new({ value: "10", placeholder: "10" });
|
|
304
|
+
this.loopStall = InputState.new({ value: "3", placeholder: "3" });
|
|
305
|
+
this.loopMsg = null;
|
|
306
|
+
this.loopLoaded = false;
|
|
289
307
|
this.doctor = null; // GET /doctor: informe de doctor sin secretos
|
|
290
308
|
this.doctorBusy = false;
|
|
291
309
|
this.doctorError = null;
|
|
@@ -318,12 +336,26 @@ export default class BondSettings extends View {
|
|
|
318
336
|
this.doctorLoaded = true;
|
|
319
337
|
this.loadDoctor(cx);
|
|
320
338
|
}
|
|
339
|
+
if (!this.loopLoaded) {
|
|
340
|
+
this.loopLoaded = true;
|
|
341
|
+
cx.spawn(async (cx) => {
|
|
342
|
+
try {
|
|
343
|
+
const d = await api("/settings/loop");
|
|
344
|
+
if (d) {
|
|
345
|
+
this.loopMax.set_value(String(d.max_iterations));
|
|
346
|
+
this.loopStall.set_value(String(d.stall_iterations));
|
|
347
|
+
}
|
|
348
|
+
} catch {}
|
|
349
|
+
cx.notify();
|
|
350
|
+
});
|
|
351
|
+
}
|
|
321
352
|
cx.spawn(async (cx) => {
|
|
322
353
|
if (!this.connBusy) this.conn = await diagnose();
|
|
323
354
|
try {
|
|
324
355
|
this.creds = (await api("/settings/credentials")) ?? [];
|
|
325
356
|
this.github = (await api("/settings/github")) ?? { configured: false };
|
|
326
357
|
this.azureDevOps = (await api("/settings/azure-devops")) ?? { configured: false };
|
|
358
|
+
this.azureLogin = (await api("/settings/azure-login")) ?? { configured: false };
|
|
327
359
|
this.jira = (await api("/settings/jira")) ?? { configured: false };
|
|
328
360
|
if (!this.favBusy) this.favorites = (await api("/repos/favorites"))?.favorites ?? [];
|
|
329
361
|
if (this.jira?.configured) {
|
|
@@ -988,6 +1020,64 @@ export default class BondSettings extends View {
|
|
|
988
1020
|
});
|
|
989
1021
|
}
|
|
990
1022
|
|
|
1023
|
+
// ---- Issue #4 (P1): the Azure session for the runs ---------------------------------------
|
|
1024
|
+
|
|
1025
|
+
openAzureLogin() {
|
|
1026
|
+
openOverlay({ mod: "bond-settings", kind: "dialog", modal: true, width: 480, height: 0.92, props: { view: "agy-login", agent: "azure" } });
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
setAzureSubscription(id, cx) {
|
|
1030
|
+
if (this.azureLoginBusy) return;
|
|
1031
|
+
this.azureLoginBusy = true;
|
|
1032
|
+
cx.notify();
|
|
1033
|
+
cx.spawn(async (cx) => {
|
|
1034
|
+
try {
|
|
1035
|
+
this.azureLogin = await api("/settings/azure-login", { method: "PUT", body: { subscription_id: id } });
|
|
1036
|
+
} catch (e) {
|
|
1037
|
+
this.error = `Azure: ${String(e?.message ?? e)}`;
|
|
1038
|
+
}
|
|
1039
|
+
this.azureLoginBusy = false;
|
|
1040
|
+
cx.notify();
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
logoutAzure(cx) {
|
|
1045
|
+
cx.spawn(async (cx) => {
|
|
1046
|
+
try {
|
|
1047
|
+
this.azureLogin = await api("/settings/azure-login", { method: "DELETE" });
|
|
1048
|
+
notify({ title: "Sesión de Azure cerrada", body: "bond-app la ha olvidado; para revocarla del todo: myaccount.microsoft.com → Dispositivos / Sesiones.", level: "info" });
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
this.error = `Azure: ${String(e?.message ?? e)}`;
|
|
1051
|
+
}
|
|
1052
|
+
cx.notify();
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
azureLoginBlock() {
|
|
1057
|
+
const t = theme();
|
|
1058
|
+
const az = this.azureLogin ?? { configured: false };
|
|
1059
|
+
const on = Boolean(az.configured);
|
|
1060
|
+
const days = az.expires_at ? Math.floor((Date.parse(az.expires_at) - Date.now()) / 86_400_000) : null;
|
|
1061
|
+
const expiry = az.expired ? "caducada: vuelve a iniciar sesión" : days === null ? "" : `caduca en ~${days} días`;
|
|
1062
|
+
const subs = az.subscriptions ?? [];
|
|
1063
|
+
const chip = (sub) => h_flex().id(`azure-sub-${sub.id}`).flex_none().h(24).px(9).items_center().rounded(UI.radius).border_1()
|
|
1064
|
+
.border_color(az.subscription?.id === sub.id ? t.accent : t.input).bg(az.subscription?.id === sub.id ? t.selected : t.surface)
|
|
1065
|
+
.text_size(12).text_color(az.subscription?.id === sub.id ? t.foreground : t.muted).tooltip(sub.id)
|
|
1066
|
+
.cursor_pointer().hover((st) => st.bg(t.hover)).on_click((_e, cx) => this.setAzureSubscription(sub.id, cx))
|
|
1067
|
+
.child(sub.name);
|
|
1068
|
+
return v_flex().gap(10)
|
|
1069
|
+
.child(this.sectionTitle("Sesión de Azure", "Para que los agentes de un run usen az (recursos, Key Vault, AKS…) sin hacer az login dentro."))
|
|
1070
|
+
.child(this.status("azure-login-status", on ? `Sesión de ${az.user ?? "Azure"}${expiry ? ` · ${expiry}` : ""}` : "Sin sesión",
|
|
1071
|
+
on ? (az.expired ? t.blocked : this.tone(t, "ok")) : t.dim))
|
|
1072
|
+
.when(on && subs.length > 0, (el) => el.child(v_flex().gap(4)
|
|
1073
|
+
.child(div().pt(2).text_size(UI.text.small).font_semibold().text_color(t.muted).child("Suscripción por defecto"))
|
|
1074
|
+
.child(h_flex().flex_wrap().gap(6).children(subs.map(chip)))))
|
|
1075
|
+
.child(this.note("Solo la reciben los tickets con «Login de Azure», que viene marcado mientras haya sesión (desmárcalo en el ticket que no la necesite). Con tu cuenta, el agente tiene en Azure tus mismos permisos, producción incluida: para el día a día, mejor un service principal con permisos acotados (fase siguiente)."))
|
|
1076
|
+
.child(h_flex().gap(6)
|
|
1077
|
+
.child(this.button("azure-login", on ? "Volver a iniciar sesión…" : "Iniciar sesión en Azure…", !on, () => this.openAzureLogin()))
|
|
1078
|
+
.when(on, (el) => el.child(this.button("azure-logout", "Cerrar sesión de Azure", false, (cx) => this.logoutAzure(cx)))));
|
|
1079
|
+
}
|
|
1080
|
+
|
|
991
1081
|
azureSection() {
|
|
992
1082
|
const t = theme();
|
|
993
1083
|
const az = this.azureDevOps;
|
|
@@ -1018,7 +1108,9 @@ export default class BondSettings extends View {
|
|
|
1018
1108
|
.child(h_flex().gap(6)
|
|
1019
1109
|
.child(this.button("azure-save", this.azureBusy ? "Comprobando…" : "Guardar", true, (cx) => this.saveAzure(cx)))
|
|
1020
1110
|
.when(stored, (el) => el.child(this.button("azure-remove", "Quitar", false, (cx) => this.removeAzure(cx)))))
|
|
1021
|
-
.child(this.note("Se comprueba contra la organización al guardar; el PAT se guarda en el orquestador y llega a cada run por stdin, nunca a la imagen."))
|
|
1111
|
+
.child(this.note("Se comprueba contra la organización al guardar; el PAT se guarda en el orquestador y llega a cada run por stdin, nunca a la imagen."))
|
|
1112
|
+
.child(div().w_full().h(1).bg(t.border))
|
|
1113
|
+
.child(this.azureLoginBlock());
|
|
1022
1114
|
}
|
|
1023
1115
|
|
|
1024
1116
|
jiraSection() {
|
|
@@ -1279,6 +1371,7 @@ export default class BondSettings extends View {
|
|
|
1279
1371
|
.child(row("Asistente", s ? (s.setup_done ? "terminado" : "sin terminar") : "—"))
|
|
1280
1372
|
.child(row("Credenciales", "En el orquestador, 0600; llegan a cada run por stdin.")))
|
|
1281
1373
|
.child(this.doctorBlock())
|
|
1374
|
+
.child(this.loopBlock())
|
|
1282
1375
|
.child(this.favoritesBlock())
|
|
1283
1376
|
.child(h_flex().child(this.button("wiz-reopen", "Abrir el asistente", false, (cx) => {
|
|
1284
1377
|
this.view = "wizard";
|
|
@@ -1288,6 +1381,39 @@ export default class BondSettings extends View {
|
|
|
1288
1381
|
})));
|
|
1289
1382
|
}
|
|
1290
1383
|
|
|
1384
|
+
/** LOOP P1 (issue #2): a new ticket's loop iterations and the rounds without progress that stop it. */
|
|
1385
|
+
loopBlock() {
|
|
1386
|
+
const t = theme();
|
|
1387
|
+
const input = (state) => div().w(80).child(Input.new(state).h(UI.button + 4).px(10).rounded(UI.radius).border_1().border_color(t.input).bg(t.background).text_size(12));
|
|
1388
|
+
const row = (label, control, hint) => h_flex().gap(10).items_center()
|
|
1389
|
+
.child(div().w(150).flex_none().text_size(UI.text.small).text_color(t.muted).child(label))
|
|
1390
|
+
.child(control)
|
|
1391
|
+
.child(div().flex_1().min_w(0).text_size(UI.text.tiny).text_color(t.dim).child(hint));
|
|
1392
|
+
return v_flex().id("loop-block").gap(8)
|
|
1393
|
+
.child(div().text_size(UI.text.body).font_semibold().text_color(t.foreground).child("Modo loop"))
|
|
1394
|
+
.child(row("Iteraciones", input(this.loopMax), "Por defecto en un ticket nuevo con «Modo loop» (cada ticket puede cambiarlo o quitar el límite)."))
|
|
1395
|
+
.child(row("Atasco tras", input(this.loopStall), "Vueltas de gru sin avance que paran el bucle y piden a una persona."))
|
|
1396
|
+
.child(h_flex().gap(10).items_center()
|
|
1397
|
+
.child(this.button("loop-save", "Guardar", false, (cx) => this.saveLoop(cx)))
|
|
1398
|
+
.when(Boolean(this.loopMsg), (el) => el.child(div().text_size(UI.text.small).text_color(this.loopMsg?.error ? t.blocked : t.dim).child(this.loopMsg?.text ?? ""))));
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
saveLoop(cx) {
|
|
1402
|
+
const num = (st) => Number(String(st.value() ?? "").trim());
|
|
1403
|
+
const body = { max_iterations: num(this.loopMax), stall_iterations: num(this.loopStall) };
|
|
1404
|
+
cx.spawn(async (cx) => {
|
|
1405
|
+
try {
|
|
1406
|
+
const d = await api("/settings/loop", { method: "PUT", body });
|
|
1407
|
+
this.loopMax.set_value(String(d.max_iterations));
|
|
1408
|
+
this.loopStall.set_value(String(d.stall_iterations));
|
|
1409
|
+
this.loopMsg = { text: "Guardado" };
|
|
1410
|
+
} catch (e) {
|
|
1411
|
+
this.loopMsg = { text: String(e?.message ?? e), error: true };
|
|
1412
|
+
}
|
|
1413
|
+
cx.notify();
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1291
1417
|
doctorBlock() {
|
|
1292
1418
|
const t = theme();
|
|
1293
1419
|
const d = this.doctor;
|
package/package.json
CHANGED
package/runner/versions.env
CHANGED
|
@@ -24,7 +24,7 @@ SUPI_VERSION=11.0.1
|
|
|
24
24
|
# 1.16.4: antes de esa versión bond no tiene comando `tui` (spike runner/SPIKE-BOND.md).
|
|
25
25
|
# `bond-app setup` exige al menos esta versión en la máquina: hasta 1.16.8 bond traía su propio
|
|
26
26
|
# bin `bond-app` (con una bond-app 0.1.x dentro) y npm no deja instalar bond-app encima.
|
|
27
|
-
BOND_VERSION=1.
|
|
27
|
+
BOND_VERSION=1.17.0
|
|
28
28
|
|
|
29
29
|
# gh y azure-cli salen de los repos apt oficiales (GitHub y Microsoft); se dejan
|
|
30
30
|
# en «latest» del repo. AZURE_CLI_VERSION admite el pin «2.xx.y» (sufijo ~bookworm
|
package/src/config.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface AppConfig {
|
|
|
37
37
|
runnerLauncher: 'bond' | 'pi';
|
|
38
38
|
/** P4 criterion 3: verification failures in a row before the run goes to `blocked`. */
|
|
39
39
|
maxVerifyFailures: number;
|
|
40
|
+
/** Issue #3 P3: how often the stuck-agent check runs (full context, exhausted budget); 0 = off. */
|
|
41
|
+
stuckCheckIntervalMs: number;
|
|
40
42
|
/** P4: time limit of each verify command. */
|
|
41
43
|
verifyTimeoutMs: number;
|
|
42
44
|
/**
|
|
@@ -154,6 +156,7 @@ export function loadConfig(overrides: Partial<AppConfig> = {}): AppConfig {
|
|
|
154
156
|
agentCommand: parseAgentCommand(process.env.BOND_APP_AGENT_COMMAND),
|
|
155
157
|
runnerLauncher: process.env.RUNNER_LAUNCHER === 'pi' ? 'pi' : 'bond',
|
|
156
158
|
maxVerifyFailures: Math.max(1, parseInt(process.env.BOND_APP_MAX_VERIFY_FAILURES || '3', 10) || 3),
|
|
159
|
+
stuckCheckIntervalMs: Math.max(0, parseInt(process.env.BOND_APP_STUCK_CHECK_MS || '60000', 10) || 0),
|
|
157
160
|
verifyTimeoutMs: 10 * 60 * 1000,
|
|
158
161
|
analysisCommand: parseAnalysisCommand(process.env.BOND_APP_ANALYSIS_COMMAND),
|
|
159
162
|
analysisTimeoutMs: 5 * 60 * 1000,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOOP P0 (issue #2): the options that let each agent kind work unattended in a run's
|
|
3
|
+
* container, which is its sandbox (runs are `runner`, never root). One table for every launch:
|
|
4
|
+
* single-repo runs (bare and `bond tui`), the hub leader gru, and «Relanzar con resumen». Before
|
|
5
|
+
* this, the hub's gru got none, and a claude, codex, copilot or agy leader stopped at its first
|
|
6
|
+
* permission prompt.
|
|
7
|
+
*/
|
|
8
|
+
import type { SupportedAgent } from '../types.ts';
|
|
9
|
+
|
|
10
|
+
export interface UnattendedFlags {
|
|
11
|
+
/** Options right after the program name. */
|
|
12
|
+
before: string[];
|
|
13
|
+
/** The option that introduces the first message (agy and copilot: `-i`), or null. */
|
|
14
|
+
promptFlag: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const FLAGS: Record<SupportedAgent, UnattendedFlags> = {
|
|
18
|
+
pi: { before: [], promptFlag: null },
|
|
19
|
+
claude: { before: ['--dangerously-skip-permissions'], promptFlag: null },
|
|
20
|
+
// --dangerously-bypass-hook-trust: bond's agent-state hook would stop it at «Hooks need review».
|
|
21
|
+
codex: { before: ['--dangerously-bypass-approvals-and-sandbox', '--dangerously-bypass-hook-trust'], promptFlag: null },
|
|
22
|
+
agy: { before: ['--dangerously-skip-permissions'], promptFlag: '-i' },
|
|
23
|
+
copilot: { before: ['--yolo'], promptFlag: '-i' },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function unattendedFlags(kind: SupportedAgent): UnattendedFlags {
|
|
27
|
+
return FLAGS[kind];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The argv tail for a first message: `[-i] <prompt…>` for agy and copilot, the prompt alone
|
|
32
|
+
* otherwise, and nothing without a prompt (a bare `-i` makes agy exit 2).
|
|
33
|
+
*/
|
|
34
|
+
export function promptArgs(kind: SupportedAgent, prompt: string[]): string[] {
|
|
35
|
+
if (!prompt.length) return [];
|
|
36
|
+
const flag = FLAGS[kind].promptFlag;
|
|
37
|
+
return flag ? [flag, ...prompt] : [...prompt];
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LOOP P0 (issue #2): one definition of «this agent waits for someone» and «this is the run's
|
|
3
|
+
* leader», shared by the waiting check, the team status and the nudge. These predicates were
|
|
4
|
+
* written out again in each of them, for hc terminals and for herdr agents.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Terminal or agent names that mean the run's leader. */
|
|
8
|
+
const LEADER_NAMES = new Set(['gru', 'hub leader', 'hub-leader', 'leader', 'orquestador']);
|
|
9
|
+
|
|
10
|
+
const atHubRoot = (cwd?: string) => cwd?.replace(/\/+$/, '') === '/workspace/hub';
|
|
11
|
+
|
|
12
|
+
/** An hc terminal (hc engine): waiting when blocked, or idle/done after at least one turn. */
|
|
13
|
+
export function isTerminalWaiting(t: { status?: string | null; turn?: number }): boolean {
|
|
14
|
+
if (t.status === 'blocked' || t.status === 'waiting') return true;
|
|
15
|
+
return (t.status === 'idle' || t.status === 'done') && (t.turn ?? 0) > 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A herdr agent (herdr engine): waiting when blocked, asking a question, or idle/done after one completion. */
|
|
19
|
+
export function isHerdrAgentWaiting(a: { agent_status?: string; completion_seq?: number | string; question?: unknown }): boolean {
|
|
20
|
+
if (a.agent_status === 'blocked' || a.agent_status === 'waiting') return true;
|
|
21
|
+
if (a.question) return true;
|
|
22
|
+
const seq = typeof a.completion_seq === 'number' ? a.completion_seq : Number(a.completion_seq || 0);
|
|
23
|
+
return (a.agent_status === 'idle' || a.agent_status === 'done') && seq > 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The leader among hc terminals: by name, at the hub root, or the run's first terminal. */
|
|
27
|
+
export function isLeaderTerminal(t: { name?: string; cwd?: string; address?: string }): boolean {
|
|
28
|
+
if (t.name && LEADER_NAMES.has(t.name)) return true;
|
|
29
|
+
if (atHubRoot(t.cwd)) return true;
|
|
30
|
+
return Boolean(t.address?.endsWith('/t1'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The leader among herdr agents: by name, at the hub root, or the first pane under a generic name. */
|
|
34
|
+
export function isLeaderHerdrAgent(a: { name?: string; cwd?: string; pane_id?: string }): boolean {
|
|
35
|
+
if (a.name && LEADER_NAMES.has(a.name)) return true;
|
|
36
|
+
if (atHubRoot(a.cwd)) return true;
|
|
37
|
+
return a.pane_id === 'w1:p1' && (!a.name || a.name === 'pi' || a.name === 'agent' || a.name === 'gru');
|
|
38
|
+
}
|
package/src/core/agy-login.ts
CHANGED
|
@@ -5,7 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
6
|
import http from 'node:http';
|
|
7
7
|
import type { AgyLoginSessionState, AgyLoginStatus } from '../types.ts';
|
|
8
|
-
import { credentialAccount } from '../db/settings-repo.ts';
|
|
8
|
+
import { azureSubscriptions, credentialAccount, type AzureLoginDoc } from '../db/settings-repo.ts';
|
|
9
9
|
import { restrictPathSync } from './permissions.ts';
|
|
10
10
|
|
|
11
11
|
const execFileAsync = promisify(execFile);
|
|
@@ -134,13 +134,13 @@ export interface LoginContext {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
export interface AgentLoginSpec {
|
|
137
|
-
agent: 'agy' | 'claude' | 'codex' | 'copilot';
|
|
137
|
+
agent: 'agy' | 'claude' | 'codex' | 'copilot' | 'azure';
|
|
138
138
|
/** What runs in the login container's tmux session. */
|
|
139
139
|
command: string;
|
|
140
140
|
/** Before the URL shows: answer the CLI's menus (agy picks «Google OAuth»); throws to fail. */
|
|
141
141
|
onPane(pane: string, send: (keys: string, literal?: boolean) => Promise<void>, first: boolean): Promise<void>;
|
|
142
142
|
/** After the code: the result once ready ({content, email}), null while waiting; throws on failure. */
|
|
143
|
-
collect(pane: string, readTokenFile: () => Promise<string | null>): Promise<{ content: string; email?: string } | null>;
|
|
143
|
+
collect(pane: string, readTokenFile: () => Promise<string | null>, readFile?: (path: string) => Promise<string | null>): Promise<{ content: string; email?: string } | null>;
|
|
144
144
|
/** Ms between typing the code and Enter (claude's TUI takes a paste, then the key). */
|
|
145
145
|
enterDelayMs?: number;
|
|
146
146
|
/** The file `collect`'s readTokenFile reads in the container (default: agy's token). */
|
|
@@ -310,6 +310,54 @@ export const COPILOT_LOGIN_SPEC: AgentLoginSpec = {
|
|
|
310
310
|
},
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Issue #4 (P1, D1): the person's Azure session with `az login --use-device-code`. The person
|
|
315
|
+
* opens microsoft.com/devicelogin and types the code; az then writes ~/.azure (the profile
|
|
316
|
+
* with the subscriptions, and the MSAL token cache). Both files are the result (D3), with the
|
|
317
|
+
* default subscription. login_experience_v2 off: az never asks which subscription.
|
|
318
|
+
*/
|
|
319
|
+
export const AZURE_PROFILE_PATH = '/home/runner/.azure/azureProfile.json';
|
|
320
|
+
export const AZURE_MSAL_PATH = '/home/runner/.azure/msal_token_cache.json';
|
|
321
|
+
|
|
322
|
+
export const AZURE_LOGIN_SPEC: AgentLoginSpec = {
|
|
323
|
+
agent: 'azure',
|
|
324
|
+
command: 'az login --use-device-code --output none',
|
|
325
|
+
tokenPath: AZURE_PROFILE_PATH,
|
|
326
|
+
device: true,
|
|
327
|
+
async prepare(ctx) {
|
|
328
|
+
await ctx.exec(['az', 'config', 'set', 'core.login_experience_v2=off', 'core.collect_telemetry=false', 'core.only_show_errors=true']);
|
|
329
|
+
},
|
|
330
|
+
async onPane(pane) {
|
|
331
|
+
if (/az: (command )?not found|executable file not found/i.test(pane)) {
|
|
332
|
+
throw new Error('az (Azure CLI) no está en la imagen del runner: reconstrúyela en Ajustes → Imagen');
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
extract(pane) {
|
|
336
|
+
const text = pane.replace(ANSI, '').replace(/\s+/g, ' ');
|
|
337
|
+
const m = /(https:\/\/(?:microsoft\.com\/devicelogin|login\.microsoft(?:online)?\.com\/[\w/.-]*device[\w/.-]*))\S*\s+and enter the code ([A-Z0-9]{6,12})/i.exec(text);
|
|
338
|
+
return m ? { url: m[1], user_code: m[2] } : null;
|
|
339
|
+
},
|
|
340
|
+
async collect(pane, readProfile, readFile) {
|
|
341
|
+
const text = pane.replace(ANSI, '');
|
|
342
|
+
if (/No subscriptions found/i.test(text)) {
|
|
343
|
+
throw new Error('La cuenta no tiene suscripciones de Azure en ese tenant: bond-app necesita al menos una');
|
|
344
|
+
}
|
|
345
|
+
if (/AADSTS\d+|code (has )?expired|authorization_declined|access_denied/i.test(text)) {
|
|
346
|
+
throw new Error('Azure no autorizó el login (código caducado o denegado): vuelve a empezar');
|
|
347
|
+
}
|
|
348
|
+
// The files are the proof: az exits once signed in and its tmux pane goes with it.
|
|
349
|
+
const profile = (await readProfile())?.replace(/^\uFEFF/, '') ?? null;
|
|
350
|
+
if (!profile || !readFile) return null;
|
|
351
|
+
const subs = azureSubscriptions(profile);
|
|
352
|
+
if (subs.length === 0) return null;
|
|
353
|
+
const msal = await readFile(AZURE_MSAL_PATH);
|
|
354
|
+
if (!msal || !/"RefreshToken"/.test(msal)) return null;
|
|
355
|
+
const chosen = subs.find((x) => x.default) ?? subs[0];
|
|
356
|
+
const doc: AzureLoginDoc = { version: 1, profile, msal, subscription_id: chosen.id };
|
|
357
|
+
return { content: JSON.stringify(doc), email: chosen.user || 'Azure' };
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
|
|
313
361
|
export interface AgyLoginManagerOptions {
|
|
314
362
|
driver?: AgyLoginDriver;
|
|
315
363
|
runnerImage: string;
|
|
@@ -596,7 +644,11 @@ export class AgyLoginManager {
|
|
|
596
644
|
const pane = this.spec.agent === 'agy' ? '' : await this.driver.captureTmuxPane(sessionName);
|
|
597
645
|
let result: { content: string; email?: string } | null;
|
|
598
646
|
try {
|
|
599
|
-
result = await this.spec.collect(
|
|
647
|
+
result = await this.spec.collect(
|
|
648
|
+
pane,
|
|
649
|
+
() => this.driver.readContainerTokenFile(containerName, this.spec.tokenPath),
|
|
650
|
+
(file) => this.driver.readContainerTokenFile(containerName, file),
|
|
651
|
+
);
|
|
600
652
|
} catch (err: unknown) {
|
|
601
653
|
await this.handleError((err as Error).message);
|
|
602
654
|
return;
|
package/src/core/doctor.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { checkHttpHealth } from '../cli.ts';
|
|
|
13
13
|
import { getServiceStatus, type ServiceDeps } from './service.ts';
|
|
14
14
|
import { defaultDataDir, defaultHerdrAppHome } from './paths.ts';
|
|
15
15
|
import { checkIcaclsOutput, currentWindowsUsername } from './permissions.ts';
|
|
16
|
+
import type { AzureLoginSummary } from '../types.ts';
|
|
16
17
|
|
|
17
18
|
const execFileAsync = promisify(execFile);
|
|
18
19
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
@@ -57,6 +58,8 @@ export interface DoctorDeps {
|
|
|
57
58
|
runCommand?: (cmd: string, args: string[], timeoutMs?: number) => Promise<CommandOutput>;
|
|
58
59
|
checkHealth?: (host: string, port: number, timeoutMs?: number) => Promise<{ ok: boolean; statusCode?: number; data?: unknown }>;
|
|
59
60
|
fetchSetupState?: (host: string, port: number, token: string, timeoutMs?: number) => Promise<SetupStateSummary | null>;
|
|
61
|
+
/** Issue #4: the Azure session as the orchestrator sees it (GET /api/v1/settings/azure-login). */
|
|
62
|
+
fetchAzureLogin?: (host: string, port: number, token: string, timeoutMs?: number) => Promise<AzureLoginSummary | null>;
|
|
60
63
|
checkApp?: (home: string) => AppIntegrationCheckResult;
|
|
61
64
|
getFreeSpaceBytes?: (targetPath: string) => number | null;
|
|
62
65
|
nodeVersion?: string;
|
|
@@ -126,18 +129,27 @@ async function defaultRunCommand(cmd: string, args: string[], timeoutMs = 10_000
|
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
function defaultFetchSetupState(
|
|
132
|
+
function defaultFetchSetupState(host: string, port: number, token: string, timeoutMs = 1500): Promise<SetupStateSummary | null> {
|
|
133
|
+
return fetchApiJson<SetupStateSummary>(host, port, token, '/api/v1/setup', timeoutMs);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function defaultFetchAzureLogin(host: string, port: number, token: string, timeoutMs = 1500): Promise<AzureLoginSummary | null> {
|
|
137
|
+
return fetchApiJson<AzureLoginSummary>(host, port, token, '/api/v1/settings/azure-login', timeoutMs);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function fetchApiJson<T>(
|
|
130
141
|
host: string,
|
|
131
142
|
port: number,
|
|
132
143
|
token: string,
|
|
144
|
+
apiPath: string,
|
|
133
145
|
timeoutMs = 1500
|
|
134
|
-
): Promise<
|
|
146
|
+
): Promise<T | null> {
|
|
135
147
|
return new Promise((resolve) => {
|
|
136
148
|
const req = http.get(
|
|
137
149
|
{
|
|
138
150
|
host,
|
|
139
151
|
port,
|
|
140
|
-
path:
|
|
152
|
+
path: apiPath,
|
|
141
153
|
headers: {
|
|
142
154
|
Host: `${host}:${port}`,
|
|
143
155
|
Authorization: `Bearer ${token}`,
|
|
@@ -153,7 +165,7 @@ function defaultFetchSetupState(
|
|
|
153
165
|
res.on('end', () => {
|
|
154
166
|
if (res.statusCode === 200) {
|
|
155
167
|
try {
|
|
156
|
-
resolve(JSON.parse(body) as
|
|
168
|
+
resolve(JSON.parse(body) as T);
|
|
157
169
|
} catch {
|
|
158
170
|
resolve(null);
|
|
159
171
|
}
|
|
@@ -206,6 +218,7 @@ export async function runDoctor(options: DoctorOptions = {}): Promise<DoctorRepo
|
|
|
206
218
|
const runCommand = deps.runCommand ?? defaultRunCommand;
|
|
207
219
|
const checkHealth = deps.checkHealth ?? checkHttpHealth;
|
|
208
220
|
const fetchSetupState = deps.fetchSetupState ?? defaultFetchSetupState;
|
|
221
|
+
const fetchAzureLogin = deps.fetchAzureLogin ?? defaultFetchAzureLogin;
|
|
209
222
|
const checkApp = deps.checkApp ?? checkAppInstalled;
|
|
210
223
|
const getFreeSpaceBytes = deps.getFreeSpaceBytes ?? defaultGetFreeSpaceBytes;
|
|
211
224
|
const platform = normalizePlatform(deps.platform ?? process.platform);
|
|
@@ -633,15 +646,15 @@ export async function runDoctor(options: DoctorOptions = {}): Promise<DoctorRepo
|
|
|
633
646
|
|
|
634
647
|
// 10. Runner image
|
|
635
648
|
let liveSetup: SetupStateSummary | null = null;
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
apiToken = '';
|
|
643
|
-
}
|
|
649
|
+
let apiToken = process.env.BOND_APP_AUTH_TOKEN || '';
|
|
650
|
+
if (!apiToken && healthOk && fs.existsSync(tokenPath)) {
|
|
651
|
+
try {
|
|
652
|
+
apiToken = fs.readFileSync(tokenPath, 'utf8').trim();
|
|
653
|
+
} catch {
|
|
654
|
+
apiToken = '';
|
|
644
655
|
}
|
|
656
|
+
}
|
|
657
|
+
if (!explicitImage && healthOk) {
|
|
645
658
|
if (apiToken) {
|
|
646
659
|
try {
|
|
647
660
|
liveSetup = await fetchSetupState(host, port, apiToken, 1500);
|
|
@@ -742,6 +755,17 @@ export async function runDoctor(options: DoctorOptions = {}): Promise<DoctorRepo
|
|
|
742
755
|
}
|
|
743
756
|
}
|
|
744
757
|
|
|
758
|
+
// Issue #4: the Azure session for the runs (optional: only tickets with «Login de Azure» use it).
|
|
759
|
+
if (healthOk && apiToken) {
|
|
760
|
+
let az: AzureLoginSummary | null = null;
|
|
761
|
+
try {
|
|
762
|
+
az = await fetchAzureLogin(host, port, apiToken, 1500);
|
|
763
|
+
} catch {
|
|
764
|
+
az = null;
|
|
765
|
+
}
|
|
766
|
+
if (az) checks.push(azureLoginCheck(az));
|
|
767
|
+
}
|
|
768
|
+
|
|
745
769
|
const summary = {
|
|
746
770
|
ok: checks.filter((c) => c.status === 'ok').length,
|
|
747
771
|
warn: checks.filter((c) => c.status === 'warn').length,
|
|
@@ -755,3 +779,25 @@ export async function runDoctor(options: DoctorOptions = {}): Promise<DoctorRepo
|
|
|
755
779
|
summary,
|
|
756
780
|
};
|
|
757
781
|
}
|
|
782
|
+
|
|
783
|
+
/** Issue #4: the Azure session line of doctor: who, which subscription, and until when. */
|
|
784
|
+
export function azureLoginCheck(az: AzureLoginSummary, now = Date.now()): DoctorCheck {
|
|
785
|
+
const fix = 'Inicia sesión en Ajustes → Azure → «Iniciar sesión en Azure»';
|
|
786
|
+
if (!az.configured) {
|
|
787
|
+
return { id: 'azure-login', name: 'Azure login', status: 'ok', essential: false, detail: 'sin sesión (opcional: solo la usan los tickets con «Login de Azure»)', meta: { configured: false } };
|
|
788
|
+
}
|
|
789
|
+
const sub = az.subscription ? `${az.subscription.name} (${az.subscription.id})` : 'sin suscripción';
|
|
790
|
+
const ends = az.expires_at ? Date.parse(az.expires_at) : NaN;
|
|
791
|
+
const days = Number.isFinite(ends) ? Math.floor((ends - now) / 86_400_000) : null;
|
|
792
|
+
const expired = az.expired || (days !== null && days < 0);
|
|
793
|
+
const soon = !expired && days !== null && days < 14;
|
|
794
|
+
return {
|
|
795
|
+
id: 'azure-login',
|
|
796
|
+
name: 'Azure login',
|
|
797
|
+
status: expired || soon || !az.subscription ? 'warn' : 'ok',
|
|
798
|
+
essential: false,
|
|
799
|
+
detail: `${az.user || 'cuenta desconocida'} · ${sub} · ${expired ? 'caducada' : days === null ? 'caducidad desconocida' : `caduca en ~${days} días`}`,
|
|
800
|
+
fix: expired || soon || !az.subscription ? fix : undefined,
|
|
801
|
+
meta: { configured: true, user: az.user, subscription: az.subscription ?? null, expires_at: az.expires_at ?? null },
|
|
802
|
+
};
|
|
803
|
+
}
|