@jmanuelcorral/bond-app 0.2.2 → 0.3.1
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/api.js +27 -0
- package/app/mods/bond-agents/main.js +446 -28
- package/app/mods/bond-agents/model.js +239 -0
- package/app/mods/bond-board/api.js +27 -0
- package/app/mods/bond-board/main.js +170 -16
- package/app/mods/bond-board/model.js +63 -2
- package/app/mods/bond-settings/api.js +27 -0
- package/app/mods/bond-settings/main.js +192 -4
- package/app/mods/bond-status/api.js +27 -0
- package/app/mods/bond-status/main.js +14 -3
- package/app/mods/bond-status/model.js +13 -0
- package/package.json +1 -1
- package/runner/versions.env +1 -1
- package/src/cli.ts +101 -0
- package/src/config.ts +9 -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/diagnose.ts +279 -0
- 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 +987 -181
- package/src/core/pi-compaction.ts +98 -0
- package/src/core/service.ts +34 -0
- package/src/core/setup-install.ts +5 -2
- package/src/core/stuck.ts +204 -0
- package/src/core/updates.ts +155 -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/index.ts +2 -0
- package/src/runner/hc-client.ts +27 -4
- package/src/server/app.ts +181 -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("; ")];
|
|
@@ -99,6 +99,33 @@ export function startCommand() {
|
|
|
99
99
|
return Array.isArray(CONFIG.start) && CONFIG.start.length ? CONFIG.start : ["bond-app", "start"];
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* `bond-app update` with the same bond-app that starts the orchestrator (CONFIG.start up to
|
|
104
|
+
* «start»), in a shell that stays open so the person reads how it went.
|
|
105
|
+
*/
|
|
106
|
+
export function updateCommand() {
|
|
107
|
+
return bondAppCommand(["update"], "bond-app update ha terminado: ya puedes cerrar esta pestaña.");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* `bond-app diagnose` (with --issue: it shows what it will send and asks before opening the
|
|
112
|
+
* issue), with the same data dir the orchestrator uses.
|
|
113
|
+
*/
|
|
114
|
+
export function diagnoseCommand(issue = false) {
|
|
115
|
+
const start = startCommand();
|
|
116
|
+
const d = start.indexOf("--data-dir");
|
|
117
|
+
const dataDir = d >= 0 && start[d + 1] ? ["--data-dir", start[d + 1]] : [];
|
|
118
|
+
return bondAppCommand(["diagnose", ...dataDir, ...(issue ? ["--issue"] : [])], "Listo: ya puedes cerrar esta pestaña.");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A bond-app subcommand with the bond-app that starts the orchestrator, in a shell that stays open. */
|
|
122
|
+
function bondAppCommand(args, done) {
|
|
123
|
+
const start = startCommand();
|
|
124
|
+
const i = start.indexOf("start");
|
|
125
|
+
const cmd = [...(i > 0 ? start.slice(0, i) : ["bond-app"]), ...args];
|
|
126
|
+
return ["sh", "-c", `"$@"; echo; echo "${done}"; exec sh`, `bond-app-${args[0]}`, ...cmd];
|
|
127
|
+
}
|
|
128
|
+
|
|
102
129
|
/** The API's base URL, for messages. */
|
|
103
130
|
export function apiUrl() {
|
|
104
131
|
return CONFIG.api;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import { View, div, svg, image } from "gpui-kit";
|
|
34
34
|
import { v_flex, h_flex, InputState, Input, TextareaState, Textarea } from "gpui-base";
|
|
35
35
|
import { props, theme, openOverlay, closeOverlay, notify, shared, setShared, exec, run } from "herdr";
|
|
36
|
-
import { api, diagnose, health, resetToken, startCommand, apiUrl } from "./api.js";
|
|
36
|
+
import { api, diagnose, health, resetToken, startCommand, updateCommand, diagnoseCommand, apiUrl } from "./api.js";
|
|
37
37
|
import { UI, stateColor } from "./brand.js";
|
|
38
38
|
import { buildPiModelsDoc, validateConfigJson, normalizeBaseUrl, parseModelIds, suggestSuggestionModel, suggestDefaultModel, toggleModelLine } from "./pi-models.js";
|
|
39
39
|
|
|
@@ -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;
|
|
@@ -317,6 +335,20 @@ export default class BondSettings extends View {
|
|
|
317
335
|
if (!this.doctorLoaded) {
|
|
318
336
|
this.doctorLoaded = true;
|
|
319
337
|
this.loadDoctor(cx);
|
|
338
|
+
this.loadUpdates(cx);
|
|
339
|
+
}
|
|
340
|
+
if (!this.loopLoaded) {
|
|
341
|
+
this.loopLoaded = true;
|
|
342
|
+
cx.spawn(async (cx) => {
|
|
343
|
+
try {
|
|
344
|
+
const d = await api("/settings/loop");
|
|
345
|
+
if (d) {
|
|
346
|
+
this.loopMax.set_value(String(d.max_iterations));
|
|
347
|
+
this.loopStall.set_value(String(d.stall_iterations));
|
|
348
|
+
}
|
|
349
|
+
} catch {}
|
|
350
|
+
cx.notify();
|
|
351
|
+
});
|
|
320
352
|
}
|
|
321
353
|
cx.spawn(async (cx) => {
|
|
322
354
|
if (!this.connBusy) this.conn = await diagnose();
|
|
@@ -324,6 +356,7 @@ export default class BondSettings extends View {
|
|
|
324
356
|
this.creds = (await api("/settings/credentials")) ?? [];
|
|
325
357
|
this.github = (await api("/settings/github")) ?? { configured: false };
|
|
326
358
|
this.azureDevOps = (await api("/settings/azure-devops")) ?? { configured: false };
|
|
359
|
+
this.azureLogin = (await api("/settings/azure-login")) ?? { configured: false };
|
|
327
360
|
this.jira = (await api("/settings/jira")) ?? { configured: false };
|
|
328
361
|
if (!this.favBusy) this.favorites = (await api("/repos/favorites"))?.favorites ?? [];
|
|
329
362
|
if (this.jira?.configured) {
|
|
@@ -352,6 +385,65 @@ export default class BondSettings extends View {
|
|
|
352
385
|
});
|
|
353
386
|
}
|
|
354
387
|
|
|
388
|
+
/** «Hay versión nueva»: what the orchestrator learnt from npm; «Comprobar ahora» asks again. */
|
|
389
|
+
loadUpdates(cx, force = false) {
|
|
390
|
+
this.updatesBusy = force;
|
|
391
|
+
cx.spawn(async (cx) => {
|
|
392
|
+
try {
|
|
393
|
+
this.updates = await api("/system/updates", force ? { method: "POST", body: {} } : undefined);
|
|
394
|
+
} catch {}
|
|
395
|
+
this.updatesBusy = false;
|
|
396
|
+
cx.notify();
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** `bond-app update` in a space of its own on this computer: bond-app, bond, mods and service. */
|
|
401
|
+
runUpdate() {
|
|
402
|
+
try {
|
|
403
|
+
run("space.new", { name: "bond-app update", machine: "", argv: updateCommand() });
|
|
404
|
+
notify({ title: "Actualizando bond-app", body: "Mira el espacio «bond-app update»: al terminar, el orquestador se reinicia.", level: "info" });
|
|
405
|
+
} catch (e) {
|
|
406
|
+
this.error = `Actualizar: ${String(e?.message ?? e)}`;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** «Exportar diagnóstico» / «Abrir issue»: bond-app diagnose in a space of its own (works with the orchestrator down). */
|
|
411
|
+
runDiagnose(issue) {
|
|
412
|
+
try {
|
|
413
|
+
run("space.new", { name: issue ? "bond-app issue" : "bond-app diagnose", machine: "", argv: diagnoseCommand(issue) });
|
|
414
|
+
} catch (e) {
|
|
415
|
+
this.error = `Diagnóstico: ${String(e?.message ?? e)}`;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
diagnoseBlock() {
|
|
420
|
+
const t = theme();
|
|
421
|
+
return v_flex().id("diagnose-block").gap(8)
|
|
422
|
+
.child(h_flex().gap(8).items_center()
|
|
423
|
+
.child(div().flex_1().text_size(UI.text.body).font_semibold().text_color(t.foreground).child("Informar de un problema"))
|
|
424
|
+
.child(this.button("diagnose-zip", "Exportar diagnóstico", false, () => this.runDiagnose(false)))
|
|
425
|
+
.child(this.button("diagnose-issue", "Abrir issue en GitHub", false, () => this.runDiagnose(true))))
|
|
426
|
+
.child(this.note("Un zip con los logs del orquestador y de herdr-app, el estado de la instalación, las versiones, el servicio y los últimos runs, sin tokens ni credenciales. «Abrir issue» te enseña lo que va a enviar y te pregunta antes; el zip lo adjuntas tú a la issue."));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
versionsBlock() {
|
|
430
|
+
const t = theme();
|
|
431
|
+
const u = this.updates;
|
|
432
|
+
const row = (id, name, p) => h_flex().id(id).gap(8).items_center()
|
|
433
|
+
.child(div().w(90).flex_none().text_size(UI.text.small).font_semibold().text_color(t.foreground).child(name))
|
|
434
|
+
.child(div().flex_1().text_size(UI.text.small).text_color(p?.update ? this.tone(t, "waiting") : t.muted)
|
|
435
|
+
.child(p ? `${p.installed ?? "?"}${p.latest ? (p.update ? ` → ${p.latest} disponible` : " (la última)") : ""}` : "…"));
|
|
436
|
+
return v_flex().id("versions-block").gap(8)
|
|
437
|
+
.child(h_flex().gap(8).items_center()
|
|
438
|
+
.child(div().flex_1().text_size(UI.text.body).font_semibold().text_color(t.foreground).child("Versiones"))
|
|
439
|
+
.child(this.button("updates-check", this.updatesBusy ? "Comprobando…" : "Comprobar ahora", false, (cx) => this.loadUpdates(cx, true)))
|
|
440
|
+
.when(Boolean(u?.available), (el) => el.child(this.button("updates-run", "Actualizar", true, () => this.runUpdate()))))
|
|
441
|
+
.child(row("version-bond-app", "bond-app", u?.bond_app))
|
|
442
|
+
.child(row("version-bond", "bond", u?.bond))
|
|
443
|
+
.when(Boolean(u?.error), (el) => el.child(this.note(`No se pudo consultar npm: ${u.error}`)))
|
|
444
|
+
.child(this.note("Se comprueba al arrancar el orquestador y una vez al día. «Actualizar» ejecuta bond-app update (bond-app, bond, mods y servicio); si la imagen del runner queda vieja, te avisa para reconstruirla."));
|
|
445
|
+
}
|
|
446
|
+
|
|
355
447
|
loadDoctor(cx) {
|
|
356
448
|
if (this.doctorBusy) return;
|
|
357
449
|
this.doctorBusy = true;
|
|
@@ -988,6 +1080,64 @@ export default class BondSettings extends View {
|
|
|
988
1080
|
});
|
|
989
1081
|
}
|
|
990
1082
|
|
|
1083
|
+
// ---- Issue #4 (P1): the Azure session for the runs ---------------------------------------
|
|
1084
|
+
|
|
1085
|
+
openAzureLogin() {
|
|
1086
|
+
openOverlay({ mod: "bond-settings", kind: "dialog", modal: true, width: 480, height: 0.92, props: { view: "agy-login", agent: "azure" } });
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
setAzureSubscription(id, cx) {
|
|
1090
|
+
if (this.azureLoginBusy) return;
|
|
1091
|
+
this.azureLoginBusy = true;
|
|
1092
|
+
cx.notify();
|
|
1093
|
+
cx.spawn(async (cx) => {
|
|
1094
|
+
try {
|
|
1095
|
+
this.azureLogin = await api("/settings/azure-login", { method: "PUT", body: { subscription_id: id } });
|
|
1096
|
+
} catch (e) {
|
|
1097
|
+
this.error = `Azure: ${String(e?.message ?? e)}`;
|
|
1098
|
+
}
|
|
1099
|
+
this.azureLoginBusy = false;
|
|
1100
|
+
cx.notify();
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
logoutAzure(cx) {
|
|
1105
|
+
cx.spawn(async (cx) => {
|
|
1106
|
+
try {
|
|
1107
|
+
this.azureLogin = await api("/settings/azure-login", { method: "DELETE" });
|
|
1108
|
+
notify({ title: "Sesión de Azure cerrada", body: "bond-app la ha olvidado; para revocarla del todo: myaccount.microsoft.com → Dispositivos / Sesiones.", level: "info" });
|
|
1109
|
+
} catch (e) {
|
|
1110
|
+
this.error = `Azure: ${String(e?.message ?? e)}`;
|
|
1111
|
+
}
|
|
1112
|
+
cx.notify();
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
azureLoginBlock() {
|
|
1117
|
+
const t = theme();
|
|
1118
|
+
const az = this.azureLogin ?? { configured: false };
|
|
1119
|
+
const on = Boolean(az.configured);
|
|
1120
|
+
const days = az.expires_at ? Math.floor((Date.parse(az.expires_at) - Date.now()) / 86_400_000) : null;
|
|
1121
|
+
const expiry = az.expired ? "caducada: vuelve a iniciar sesión" : days === null ? "" : `caduca en ~${days} días`;
|
|
1122
|
+
const subs = az.subscriptions ?? [];
|
|
1123
|
+
const chip = (sub) => h_flex().id(`azure-sub-${sub.id}`).flex_none().h(24).px(9).items_center().rounded(UI.radius).border_1()
|
|
1124
|
+
.border_color(az.subscription?.id === sub.id ? t.accent : t.input).bg(az.subscription?.id === sub.id ? t.selected : t.surface)
|
|
1125
|
+
.text_size(12).text_color(az.subscription?.id === sub.id ? t.foreground : t.muted).tooltip(sub.id)
|
|
1126
|
+
.cursor_pointer().hover((st) => st.bg(t.hover)).on_click((_e, cx) => this.setAzureSubscription(sub.id, cx))
|
|
1127
|
+
.child(sub.name);
|
|
1128
|
+
return v_flex().gap(10)
|
|
1129
|
+
.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."))
|
|
1130
|
+
.child(this.status("azure-login-status", on ? `Sesión de ${az.user ?? "Azure"}${expiry ? ` · ${expiry}` : ""}` : "Sin sesión",
|
|
1131
|
+
on ? (az.expired ? t.blocked : this.tone(t, "ok")) : t.dim))
|
|
1132
|
+
.when(on && subs.length > 0, (el) => el.child(v_flex().gap(4)
|
|
1133
|
+
.child(div().pt(2).text_size(UI.text.small).font_semibold().text_color(t.muted).child("Suscripción por defecto"))
|
|
1134
|
+
.child(h_flex().flex_wrap().gap(6).children(subs.map(chip)))))
|
|
1135
|
+
.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)."))
|
|
1136
|
+
.child(h_flex().gap(6)
|
|
1137
|
+
.child(this.button("azure-login", on ? "Volver a iniciar sesión…" : "Iniciar sesión en Azure…", !on, () => this.openAzureLogin()))
|
|
1138
|
+
.when(on, (el) => el.child(this.button("azure-logout", "Cerrar sesión de Azure", false, (cx) => this.logoutAzure(cx)))));
|
|
1139
|
+
}
|
|
1140
|
+
|
|
991
1141
|
azureSection() {
|
|
992
1142
|
const t = theme();
|
|
993
1143
|
const az = this.azureDevOps;
|
|
@@ -1018,7 +1168,9 @@ export default class BondSettings extends View {
|
|
|
1018
1168
|
.child(h_flex().gap(6)
|
|
1019
1169
|
.child(this.button("azure-save", this.azureBusy ? "Comprobando…" : "Guardar", true, (cx) => this.saveAzure(cx)))
|
|
1020
1170
|
.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."))
|
|
1171
|
+
.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."))
|
|
1172
|
+
.child(div().w_full().h(1).bg(t.border))
|
|
1173
|
+
.child(this.azureLoginBlock());
|
|
1022
1174
|
}
|
|
1023
1175
|
|
|
1024
1176
|
jiraSection() {
|
|
@@ -1278,7 +1430,10 @@ export default class BondSettings extends View {
|
|
|
1278
1430
|
.child(row("API", apiUrl()))
|
|
1279
1431
|
.child(row("Asistente", s ? (s.setup_done ? "terminado" : "sin terminar") : "—"))
|
|
1280
1432
|
.child(row("Credenciales", "En el orquestador, 0600; llegan a cada run por stdin.")))
|
|
1433
|
+
.child(this.versionsBlock())
|
|
1281
1434
|
.child(this.doctorBlock())
|
|
1435
|
+
.child(this.diagnoseBlock())
|
|
1436
|
+
.child(this.loopBlock())
|
|
1282
1437
|
.child(this.favoritesBlock())
|
|
1283
1438
|
.child(h_flex().child(this.button("wiz-reopen", "Abrir el asistente", false, (cx) => {
|
|
1284
1439
|
this.view = "wizard";
|
|
@@ -1288,6 +1443,39 @@ export default class BondSettings extends View {
|
|
|
1288
1443
|
})));
|
|
1289
1444
|
}
|
|
1290
1445
|
|
|
1446
|
+
/** LOOP P1 (issue #2): a new ticket's loop iterations and the rounds without progress that stop it. */
|
|
1447
|
+
loopBlock() {
|
|
1448
|
+
const t = theme();
|
|
1449
|
+
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));
|
|
1450
|
+
const row = (label, control, hint) => h_flex().gap(10).items_center()
|
|
1451
|
+
.child(div().w(150).flex_none().text_size(UI.text.small).text_color(t.muted).child(label))
|
|
1452
|
+
.child(control)
|
|
1453
|
+
.child(div().flex_1().min_w(0).text_size(UI.text.tiny).text_color(t.dim).child(hint));
|
|
1454
|
+
return v_flex().id("loop-block").gap(8)
|
|
1455
|
+
.child(div().text_size(UI.text.body).font_semibold().text_color(t.foreground).child("Modo loop"))
|
|
1456
|
+
.child(row("Iteraciones", input(this.loopMax), "Por defecto en un ticket nuevo con «Modo loop» (cada ticket puede cambiarlo o quitar el límite)."))
|
|
1457
|
+
.child(row("Atasco tras", input(this.loopStall), "Vueltas de gru sin avance que paran el bucle y piden a una persona."))
|
|
1458
|
+
.child(h_flex().gap(10).items_center()
|
|
1459
|
+
.child(this.button("loop-save", "Guardar", false, (cx) => this.saveLoop(cx)))
|
|
1460
|
+
.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 ?? ""))));
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
saveLoop(cx) {
|
|
1464
|
+
const num = (st) => Number(String(st.value() ?? "").trim());
|
|
1465
|
+
const body = { max_iterations: num(this.loopMax), stall_iterations: num(this.loopStall) };
|
|
1466
|
+
cx.spawn(async (cx) => {
|
|
1467
|
+
try {
|
|
1468
|
+
const d = await api("/settings/loop", { method: "PUT", body });
|
|
1469
|
+
this.loopMax.set_value(String(d.max_iterations));
|
|
1470
|
+
this.loopStall.set_value(String(d.stall_iterations));
|
|
1471
|
+
this.loopMsg = { text: "Guardado" };
|
|
1472
|
+
} catch (e) {
|
|
1473
|
+
this.loopMsg = { text: String(e?.message ?? e), error: true };
|
|
1474
|
+
}
|
|
1475
|
+
cx.notify();
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1291
1479
|
doctorBlock() {
|
|
1292
1480
|
const t = theme();
|
|
1293
1481
|
const d = this.doctor;
|
|
@@ -1299,7 +1487,7 @@ export default class BondSettings extends View {
|
|
|
1299
1487
|
return v_flex().id("doctor-block").gap(8)
|
|
1300
1488
|
.child(h_flex().gap(8).items_center()
|
|
1301
1489
|
.child(div().flex_1().text_size(UI.text.body).font_semibold().text_color(t.foreground).child("Estado de la instalación"))
|
|
1302
|
-
.child(this.button("doctor-refresh", this.doctorBusy ? "
|
|
1490
|
+
.child(this.button("doctor-refresh", this.doctorBusy ? "Comprobando…" : "Volver a comprobar", false, (cx) => this.loadDoctor(cx))))
|
|
1303
1491
|
.when(Boolean(summaryText), (el) => el.child(div().id("doctor-summary").text_size(UI.text.small).text_color(t.muted).child(summaryText)))
|
|
1304
1492
|
.when(Boolean(this.doctorError), (el) => el.child(div().id("doctor-error").text_size(UI.text.small).text_color(t.blocked).child(this.doctorError)))
|
|
1305
1493
|
.when(!d && !this.doctorError, (el) => el.child(this.note(this.doctorBusy ? "Comprobando…" : "Sin datos de diagnóstico.")))
|
|
@@ -99,6 +99,33 @@ export function startCommand() {
|
|
|
99
99
|
return Array.isArray(CONFIG.start) && CONFIG.start.length ? CONFIG.start : ["bond-app", "start"];
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/**
|
|
103
|
+
* `bond-app update` with the same bond-app that starts the orchestrator (CONFIG.start up to
|
|
104
|
+
* «start»), in a shell that stays open so the person reads how it went.
|
|
105
|
+
*/
|
|
106
|
+
export function updateCommand() {
|
|
107
|
+
return bondAppCommand(["update"], "bond-app update ha terminado: ya puedes cerrar esta pestaña.");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* `bond-app diagnose` (with --issue: it shows what it will send and asks before opening the
|
|
112
|
+
* issue), with the same data dir the orchestrator uses.
|
|
113
|
+
*/
|
|
114
|
+
export function diagnoseCommand(issue = false) {
|
|
115
|
+
const start = startCommand();
|
|
116
|
+
const d = start.indexOf("--data-dir");
|
|
117
|
+
const dataDir = d >= 0 && start[d + 1] ? ["--data-dir", start[d + 1]] : [];
|
|
118
|
+
return bondAppCommand(["diagnose", ...dataDir, ...(issue ? ["--issue"] : [])], "Listo: ya puedes cerrar esta pestaña.");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A bond-app subcommand with the bond-app that starts the orchestrator, in a shell that stays open. */
|
|
122
|
+
function bondAppCommand(args, done) {
|
|
123
|
+
const start = startCommand();
|
|
124
|
+
const i = start.indexOf("start");
|
|
125
|
+
const cmd = [...(i > 0 ? start.slice(0, i) : ["bond-app"]), ...args];
|
|
126
|
+
return ["sh", "-c", `"$@"; echo; echo "${done}"; exec sh`, `bond-app-${args[0]}`, ...cmd];
|
|
127
|
+
}
|
|
128
|
+
|
|
102
129
|
/** The API's base URL, for messages. */
|
|
103
130
|
export function apiUrl() {
|
|
104
131
|
return CONFIG.api;
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
import { View, div } from "gpui-kit";
|
|
10
10
|
import { h_flex } from "gpui-base";
|
|
11
11
|
import { theme, updates, openOverlay, run, exec, checking } from "herdr";
|
|
12
|
-
import { api, health } from "./api.js";
|
|
12
|
+
import { api, health, updateCommand } from "./api.js";
|
|
13
13
|
import { UI, settingsOverlay, stateColor } from "./brand.js";
|
|
14
|
-
import { statusSummary, compareVersions, MIN_HERDR_APP, MIN_HC, POLL_MS } from "./model.js";
|
|
14
|
+
import { statusSummary, updateNotice, compareVersions, MIN_HERDR_APP, MIN_HC, POLL_MS } from "./model.js";
|
|
15
15
|
|
|
16
16
|
export default class BondStatus extends View {
|
|
17
17
|
init(_props, cx) {
|
|
@@ -39,10 +39,12 @@ export default class BondStatus extends View {
|
|
|
39
39
|
await health();
|
|
40
40
|
next.api = { ok: true };
|
|
41
41
|
try {
|
|
42
|
-
const [github, runs, azure, jira] = await Promise.all([
|
|
42
|
+
const [github, runs, azure, jira, updates] = await Promise.all([
|
|
43
43
|
api("/settings/github"), api("/runs"),
|
|
44
44
|
api("/settings/azure-devops").catch(() => null), api("/settings/jira").catch(() => null),
|
|
45
|
+
api("/system/updates").catch(() => null),
|
|
45
46
|
]);
|
|
47
|
+
next.updates = updates;
|
|
46
48
|
next.github = github ?? { configured: false };
|
|
47
49
|
next.runs = runs ?? [];
|
|
48
50
|
next.azure = azure;
|
|
@@ -60,6 +62,13 @@ export default class BondStatus extends View {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
/** «Actualizar»: `bond-app update` in a space of its own on this computer (never a run's). */
|
|
66
|
+
runUpdate() {
|
|
67
|
+
try {
|
|
68
|
+
run("space.new", { name: "bond-app update", machine: "", argv: updateCommand() });
|
|
69
|
+
} catch {}
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
openSettings(section) {
|
|
64
73
|
openOverlay(settingsOverlay(section ? { section } : {}));
|
|
65
74
|
}
|
|
@@ -77,6 +86,7 @@ export default class BondStatus extends View {
|
|
|
77
86
|
const t = theme();
|
|
78
87
|
const u = updates();
|
|
79
88
|
const s = statusSummary(this.state, { app: u?.app?.version ?? null, core: u?.core?.version ?? null, appReady: u?.app?.ready ?? null, appInstalled: this.appInstalled });
|
|
89
|
+
const upd = updateNotice(this.state.updates);
|
|
80
90
|
const tone = { ok: stateColor(t, "running"), warn: t.bond_blocked ?? t.blocked, bad: t.blocked, unknown: t.dim };
|
|
81
91
|
const version = (name, have, min) => {
|
|
82
92
|
const ok = have && compareVersions(have, min) >= 0;
|
|
@@ -90,6 +100,7 @@ export default class BondStatus extends View {
|
|
|
90
100
|
.when(Boolean(s.jira), (el) => el.child(this.item("st-jira", tone[s.jira.tone], s.jira.text, null, () => this.openSettings("jira"))))
|
|
91
101
|
.child(this.item("st-runs", s.runs.active > 0 ? stateColor(t, "running") : t.dim, s.runs.text, null, null))
|
|
92
102
|
.child(div().flex_1())
|
|
103
|
+
.when(Boolean(upd), (el) => el.child(this.item("st-bond-update", t.accent, upd.text, t.accent, () => this.runUpdate())))
|
|
93
104
|
.when(Boolean(s.versions.appNewer), (el) => el.child(this.item("st-app-update", t.accent,
|
|
94
105
|
s.versions.appRestart ? `herdr-app ${s.versions.appNewer}: reiniciar` : `herdr-app ${s.versions.appNewer} instalado: reinicia la app`,
|
|
95
106
|
t.accent, s.versions.appRestart ? () => run("app.update") : null)))
|
|
@@ -91,3 +91,16 @@ export function statusSummary(state, versions) {
|
|
|
91
91
|
},
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* «Hay versión nueva» in the status bar: what is newer (bond-app first, then bond), from the
|
|
97
|
+
* orchestrator's GET /system/updates. Null when everything is up to date or not known yet.
|
|
98
|
+
*/
|
|
99
|
+
export function updateNotice(u) {
|
|
100
|
+
if (!u || !u.available) return null;
|
|
101
|
+
const parts = [];
|
|
102
|
+
if (u.bond_app?.update) parts.push(`bond-app ${u.bond_app.latest}`);
|
|
103
|
+
if (u.bond?.update) parts.push(`bond ${u.bond.latest}`);
|
|
104
|
+
if (!parts.length) return null;
|
|
105
|
+
return { text: `${parts.join(" y ")} disponible${parts.length > 1 ? "s" : ""}: actualizar` };
|
|
106
|
+
}
|
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
|