@jmanuelcorral/bond-app 0.1.4 → 0.1.6
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 +241 -7
- package/app/brand/TOKENS.md +5 -5
- package/app/layouts/bond.json +10 -14
- package/app/mods/bond-agents/api.js +35 -0
- package/app/mods/bond-agents/branch.svg +1 -0
- package/app/mods/bond-agents/brand.js +53 -2
- package/app/mods/bond-agents/config.js +8 -0
- package/app/mods/bond-agents/eye-off.svg +1 -0
- package/app/mods/bond-agents/eye.svg +1 -0
- package/app/mods/bond-agents/main.js +316 -330
- package/app/mods/bond-agents/model.js +400 -6
- package/app/mods/bond-board/api.js +35 -0
- package/app/mods/bond-board/branch.svg +1 -0
- package/app/mods/bond-board/brand.js +53 -2
- package/app/mods/bond-board/config.js +8 -0
- package/app/mods/bond-board/main.js +1054 -366
- package/app/mods/bond-board/model.js +138 -17
- package/app/mods/bond-pane/close.svg +1 -0
- package/app/mods/bond-pane/hide.svg +1 -0
- package/app/mods/bond-pane/main.js +103 -0
- package/app/mods/bond-pane/mod.json +1 -0
- package/app/mods/bond-pane/model.js +18 -0
- package/app/mods/bond-pane/split-down.svg +1 -0
- package/app/mods/bond-pane/split-right.svg +1 -0
- package/app/mods/bond-pane/unzoom.svg +1 -0
- package/app/mods/bond-pane/zoom.svg +1 -0
- package/app/mods/bond-settings/api.js +35 -0
- package/app/mods/bond-settings/brand.js +53 -2
- package/app/mods/bond-settings/config.js +8 -0
- package/app/mods/bond-settings/main.js +1645 -87
- package/app/mods/bond-settings/mod.json +1 -1
- package/app/mods/bond-settings/pi-models.js +144 -0
- package/app/mods/bond-status/api.js +35 -0
- package/app/mods/bond-status/brand.js +53 -2
- package/app/mods/bond-status/config.js +8 -0
- package/app/mods/bond-status/main.js +37 -15
- package/app/mods/bond-status/model.js +19 -1
- package/app/mods/bond-tabs/brand.js +53 -2
- package/app/mods/bond-tabs/main.js +45 -3
- package/app/mods/bond-titlebar/brand.js +53 -2
- package/app/mods/bond-titlebar/main.js +115 -55
- package/app/mods/bond-titlebar/version.js +3 -0
- package/app/themes/bond-dark.json +5 -5
- package/app/themes/bond-light.json +5 -5
- package/package.json +1 -1
- package/runner/Dockerfile +58 -15
- package/runner/SPIKE-BOND.md +89 -0
- package/runner/build-config/.none +0 -0
- package/runner/build-creds/.none +0 -0
- package/runner/config.example/README.md +27 -0
- package/runner/config.example/pi/models.json +22 -0
- package/runner/credentials.example.env +27 -0
- package/runner/entrypoint.sh +16 -0
- package/runner/setup.sh +927 -0
- package/runner/versions.env +61 -0
- package/scripts/app-install.ts +64 -1
- package/src/cli.ts +53 -3
- package/src/config.ts +8 -0
- package/src/core/agy-login.ts +682 -0
- package/src/core/delivery.ts +3 -1
- package/src/core/hub-session.ts +9 -7
- package/src/core/orchestrator.ts +1186 -168
- package/src/core/repo-host.ts +60 -0
- package/src/core/setup.ts +239 -0
- package/src/core/watchdog.ts +6 -6
- package/src/db/database.ts +55 -1
- package/src/db/settings-repo.ts +440 -7
- package/src/db/ticket-repo.ts +73 -17
- package/src/index.ts +4 -4
- package/src/runner/azure-devops-client.ts +163 -0
- package/src/runner/docker-client.ts +84 -5
- package/src/runner/github-client.ts +146 -0
- package/src/runner/hc-client.ts +40 -5
- package/src/runner/image-builder.ts +268 -10
- package/src/runner/jira-client.ts +368 -0
- package/src/runner/tool-catalog.ts +84 -0
- package/src/server/app.ts +585 -9
- package/src/types.ts +168 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "place": "none", "title": "bond · ajustes" }
|
|
1
|
+
{ "place": "none", "title": "bond · ajustes", "overlay": { "kind": "dialog", "width": 820, "height": 0.82 } }
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// bond-settings: builder de la config de pi (W-P3). El paso 2 del wizard pregunta
|
|
2
|
+
// cuatro campos de un endpoint «modelo local / OpenAI-compatible» —nombre del provider,
|
|
3
|
+
// base URL, API key opcional y modelos (ids, uno por línea)— y aquí se construye la
|
|
4
|
+
// entrada `providers.<nombre>` de `models.json`, que es lo que guarda
|
|
5
|
+
// PUT /settings/credentials/pi (runner/setup.sh la hornea en ~/.pi/agent/models.json).
|
|
6
|
+
//
|
|
7
|
+
// Puro JavaScript, sin imports de herdr ni gpui, para que Node pueda importarlo en
|
|
8
|
+
// tests (tests/unit/pi-models-builder.test.ts).
|
|
9
|
+
//
|
|
10
|
+
// El esquema es el mínimo estable documentado por pi (docs de models.json): un provider
|
|
11
|
+
// nuevo necesita `baseUrl` y `api`; cada modelo, el mínimo con lo que pi exige o fija
|
|
12
|
+
// mal por defecto: `cost` a 0 (los cuatro campos), `input` texto+imagen, ventana de
|
|
13
|
+
// contexto y salida máxima. Todo lo demás (headers, compat, sampling…) se cubre
|
|
14
|
+
// pegando el JSON completo en el modo avanzado del diálogo.
|
|
15
|
+
|
|
16
|
+
/** Ventana de contexto con la que se emite cada modelo (plan W-P3). */
|
|
17
|
+
export const PI_CONTEXT_WINDOW = 131072;
|
|
18
|
+
/** Máximo de tokens de salida con el que se emite cada modelo (plan W-P3). */
|
|
19
|
+
export const PI_MAX_TOKENS = 8192;
|
|
20
|
+
|
|
21
|
+
/** Los ids de `models.json` suelen ir en minúsculas; se conservan tal cual los escribe. */
|
|
22
|
+
const URL_RE = /^(https?:\/\/)([^\s/]+)(\/[^\s]*)?$/i;
|
|
23
|
+
|
|
24
|
+
/** Texto del textarea de modelos → ids únicos, en orden, sin líneas vacías. */
|
|
25
|
+
export function parseModelIds(text) {
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const line of String(text ?? "").split(/\r?\n/)) {
|
|
28
|
+
const id = line.trim();
|
|
29
|
+
if (id) seen.add(id);
|
|
30
|
+
}
|
|
31
|
+
return [...seen];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Valida y normaliza la base URL. Devuelve null si no es http(s) con host.
|
|
36
|
+
* Sin ruta (o ruta "/") se añade "/v1", que es donde sirven Ollama, LM Studio, vLLM
|
|
37
|
+
* y compañía; con ruta se respeta tal cual, solo se quita la barra final.
|
|
38
|
+
*/
|
|
39
|
+
export function normalizeBaseUrl(raw) {
|
|
40
|
+
const url = String(raw ?? "").trim();
|
|
41
|
+
const m = URL_RE.exec(url);
|
|
42
|
+
if (!m) return null;
|
|
43
|
+
const [, scheme, host, path] = m;
|
|
44
|
+
if (!host) return null;
|
|
45
|
+
if (!path || path === "/") return `${scheme}${host}/v1`;
|
|
46
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Construye el documento `models.json` para un provider OpenAI-compatible.
|
|
51
|
+
* Devuelve { error } si algo no valida, o { name, configJson } con el documento ya
|
|
52
|
+
* serializado (lo que se envía como config_json a PUT /settings/credentials/pi).
|
|
53
|
+
*/
|
|
54
|
+
export function buildPiModelsDoc({ name, baseUrl, apiKey, modelsText } = {}) {
|
|
55
|
+
const pname = String(name ?? "").trim();
|
|
56
|
+
if (!pname) return { error: "El provider necesita un nombre." };
|
|
57
|
+
if (/\s/.test(pname)) return { error: "El nombre del provider no puede llevar espacios." };
|
|
58
|
+
const url = normalizeBaseUrl(baseUrl);
|
|
59
|
+
if (!url) return { error: "La base URL tiene que empezar por http:// o https://." };
|
|
60
|
+
const models = parseModelIds(modelsText);
|
|
61
|
+
if (models.length === 0) return { error: "Escribe al menos un modelo, uno por línea." };
|
|
62
|
+
const entry = { baseUrl: url, api: "openai-completions" };
|
|
63
|
+
const key = String(apiKey ?? "").trim();
|
|
64
|
+
if (key) entry.apiKey = key; // vacía → campo ausente, no vacío (criterio 2)
|
|
65
|
+
entry.models = models.map((id) => ({
|
|
66
|
+
id,
|
|
67
|
+
input: ["text", "image"],
|
|
68
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
69
|
+
contextWindow: PI_CONTEXT_WINDOW,
|
|
70
|
+
maxTokens: PI_MAX_TOKENS,
|
|
71
|
+
}));
|
|
72
|
+
const doc = {
|
|
73
|
+
$schema: "https://pi.dev/schemas/models.schema.json",
|
|
74
|
+
providers: { [pname]: entry },
|
|
75
|
+
};
|
|
76
|
+
return { error: null, name: pname, configJson: JSON.stringify(doc, null, 2) };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** null si `text` es JSON válido; si no, el mensaje de error para el diálogo. */
|
|
80
|
+
export function validateConfigJson(text) {
|
|
81
|
+
try {
|
|
82
|
+
JSON.parse(String(text ?? ""));
|
|
83
|
+
return null;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return `JSON no válido: ${String(e?.message ?? e)}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// --- W-P4: multiselector de modelos y modelo de sugerencias ------------------------------
|
|
90
|
+
|
|
91
|
+
/** Marcas de nombre que delatan un modelo barato/ligero (heurística estilo bond setup). */
|
|
92
|
+
const CHEAP_MODEL_RE = /flash|mini|small|nano|lite|haiku|express|0[.-]6b|1[.-]5b/i;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Heurística para proponer «el modelo de sugerencias» (supi) entre los marcados, como
|
|
96
|
+
* hace bond setup: primero uno gratis (OpenRouter los marca con «:free»), luego uno de
|
|
97
|
+
* nombre barato/ligero (flash, mini, small, nano, 0.6b…), y si no, el primero.
|
|
98
|
+
* Devuelve null con la lista vacía («sin sugerencias»).
|
|
99
|
+
*/
|
|
100
|
+
export function suggestSuggestionModel(ids) {
|
|
101
|
+
const list = (Array.isArray(ids) ? ids : []).map((id) => String(id ?? "").trim()).filter(Boolean);
|
|
102
|
+
if (list.length === 0) return null;
|
|
103
|
+
return (
|
|
104
|
+
list.find((id) => /free/i.test(id)) ||
|
|
105
|
+
list.find((id) => CHEAP_MODEL_RE.test(id)) ||
|
|
106
|
+
list[0]
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Marcas que delatan modelos diminutos habitualmente sin soporte de tools/function calling. */
|
|
111
|
+
const NO_TOOLS_RE = /(?:^|[-_/])(?:0\.[0-9]+|[1-3](?:\.[0-9]+)?)b\b|nano|tiny/i;
|
|
112
|
+
/** Indicios de soporte de herramientas / código / instrucciones. */
|
|
113
|
+
const TOOL_HINT_RE = /tool|func|coder|code|instruct|agent/i;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Heurística para proponer «el modelo de trabajo por defecto» para pi entre los marcados:
|
|
117
|
+
* primero uno con indicios de tools sin ser enano, si no el primero que no sea enano
|
|
118
|
+
* (sin tools como 2b), y si todos son enanos, el primero de la lista.
|
|
119
|
+
* Devuelve null con la lista vacía.
|
|
120
|
+
*/
|
|
121
|
+
export function suggestDefaultModel(ids) {
|
|
122
|
+
const list = (Array.isArray(ids) ? ids : []).map((id) => String(id ?? "").trim()).filter(Boolean);
|
|
123
|
+
if (list.length === 0) return null;
|
|
124
|
+
const withTool = list.find((id) => TOOL_HINT_RE.test(id) && !NO_TOOLS_RE.test(id));
|
|
125
|
+
if (withTool) return withTool;
|
|
126
|
+
const nonTiny = list.find((id) => !NO_TOOLS_RE.test(id));
|
|
127
|
+
if (nonTiny) return nonTiny;
|
|
128
|
+
return list[0];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* El textarea de modelos es la fuente de verdad de los ids marcados; el multiselector
|
|
133
|
+
* cargado del provider añade y quita líneas aquí (criterio 2: en el models.json solo
|
|
134
|
+
* entran los modelos marcados). Devuelve el texto nuevo, un id por línea.
|
|
135
|
+
*/
|
|
136
|
+
export function toggleModelLine(text, id) {
|
|
137
|
+
const ids = parseModelIds(text);
|
|
138
|
+
const wanted = String(id ?? "").trim();
|
|
139
|
+
if (!wanted) return ids.join("\n");
|
|
140
|
+
const i = ids.indexOf(wanted);
|
|
141
|
+
if (i >= 0) ids.splice(i, 1);
|
|
142
|
+
else ids.push(wanted);
|
|
143
|
+
return ids.join("\n");
|
|
144
|
+
}
|
|
@@ -64,6 +64,41 @@ export async function health() {
|
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** Forget the cached token, so the next call reads its file again (Ajustes «Reconectar»). */
|
|
68
|
+
export function resetToken() {
|
|
69
|
+
token = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Why the mods can or cannot talk to the orchestrator, for Ajustes: { state, detail }.
|
|
74
|
+
* state: "ok", "down" (no /health), "no-token" (no token file), "bad-token" (the file's
|
|
75
|
+
* token is not this orchestrator's: usually another --data-dir) or "error".
|
|
76
|
+
*/
|
|
77
|
+
export async function diagnose() {
|
|
78
|
+
try {
|
|
79
|
+
await health();
|
|
80
|
+
} catch {
|
|
81
|
+
return { state: "down", detail: `${CONFIG.api} no responde` };
|
|
82
|
+
}
|
|
83
|
+
token = null;
|
|
84
|
+
try {
|
|
85
|
+
await api("/setup");
|
|
86
|
+
return { state: "ok", detail: CONFIG.api };
|
|
87
|
+
} catch (e) {
|
|
88
|
+
const msg = String(e?.message ?? e);
|
|
89
|
+
if (msg.startsWith("no hay token")) return { state: "no-token", detail: msg };
|
|
90
|
+
if (/unauthorized|HTTP 401/i.test(msg)) {
|
|
91
|
+
return { state: "bad-token", detail: `el token de ${tokenPath()} no es el de este orquestador (¿arrancado con otro --data-dir?)` };
|
|
92
|
+
}
|
|
93
|
+
return { state: "error", detail: msg };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The command that starts this orchestrator (written by app:install), or a default. */
|
|
98
|
+
export function startCommand() {
|
|
99
|
+
return Array.isArray(CONFIG.start) && CONFIG.start.length ? CONFIG.start : ["bond-app", "start"];
|
|
100
|
+
}
|
|
101
|
+
|
|
67
102
|
/** The API's base URL, for messages. */
|
|
68
103
|
export function apiUrl() {
|
|
69
104
|
return CONFIG.api;
|
|
@@ -18,6 +18,7 @@ export const UI = {
|
|
|
18
18
|
button: 26,
|
|
19
19
|
folded: 34, // width of a folded (empty) board column
|
|
20
20
|
columnWidth: 270, // fixed column width
|
|
21
|
+
columnMax: 560, // an open board column is never wider than this
|
|
21
22
|
fontFamily: "JetBrains Mono",
|
|
22
23
|
fontSans: "Geist",
|
|
23
24
|
};
|
|
@@ -26,7 +27,7 @@ export const UI = {
|
|
|
26
27
|
const STATE_FALLBACK = {
|
|
27
28
|
ready: "idle",
|
|
28
29
|
running: "working",
|
|
29
|
-
waiting: "
|
|
30
|
+
waiting: "working",
|
|
30
31
|
finished: "done",
|
|
31
32
|
error: "blocked",
|
|
32
33
|
verifying: "accent",
|
|
@@ -41,9 +42,24 @@ const STATE_THEME_KEY = {
|
|
|
41
42
|
error: "bond_error",
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Running is green and waiting yellow (2026-11-23: less red on the board). A theme without
|
|
47
|
+
* bond_* colors falls back to herdr's palette, which has neither (its `working` is yellow,
|
|
48
|
+
* `blocked` red): these get fixed hues, [light, dark], AA-safe as fills on either.
|
|
49
|
+
*/
|
|
50
|
+
const STATE_HEX = {
|
|
51
|
+
running: ["#047857", "#34d399"],
|
|
52
|
+
waiting: ["#a16207", "#facc15"],
|
|
53
|
+
blocked: ["#a16207", "#facc15"],
|
|
54
|
+
};
|
|
55
|
+
|
|
44
56
|
/** The color of a board column or state (`ready`, `running`, ...) in theme `t`. */
|
|
45
57
|
export function stateColor(t, id) {
|
|
46
|
-
|
|
58
|
+
const own = t[`bond_${id}`] ?? t[STATE_THEME_KEY[id]];
|
|
59
|
+
if (own) return own;
|
|
60
|
+
const hex = STATE_HEX[id];
|
|
61
|
+
if (hex) return hex[isDark(t) ? 1 : 0];
|
|
62
|
+
return t[STATE_FALLBACK[id]] ?? t.accent;
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
/** Relative luminance of `#rrggbb[aa]` (WCAG), 0..1. */
|
|
@@ -71,3 +87,38 @@ export function logo(t) {
|
|
|
71
87
|
wordmarkRatio: 398 / 108,
|
|
72
88
|
};
|
|
73
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Ajustes as a modal dialog (plan bond-app-ajustes-imagen P1): what every bond-* mod passes
|
|
93
|
+
* to herdr's openOverlay to open it. `section` picks the section (orchestrator, agents,
|
|
94
|
+
* github, image, advanced); `{ view: "wizard", step }` opens the first-launch walk.
|
|
95
|
+
*/
|
|
96
|
+
export function settingsOverlay(props = {}) {
|
|
97
|
+
return { mod: "bond-settings", kind: "dialog", modal: true, width: 820, height: 0.7, props: { view: "settings", ...props } };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* «Nuevo ticket» (Qué · Dónde · Quién): every button that opens it passes this, so the
|
|
102
|
+
* dialog always has its height (its body scrolls; without a height it collapses).
|
|
103
|
+
*/
|
|
104
|
+
export function createOverlay() {
|
|
105
|
+
return { mod: "bond-board", kind: "dialog", modal: true, width: 820, height: 0.92, props: { view: "create" } };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Fixed hues bond uses outside the state palette (host badges, the favorite star, the
|
|
110
|
+
* theme button), [light, dark]: readable on either theme, never a hex that only suits one.
|
|
111
|
+
*/
|
|
112
|
+
const MARK_HEX = {
|
|
113
|
+
github: ["#6d28d9", "#a78bfa"],
|
|
114
|
+
azure: ["#0067b8", "#3b9cff"],
|
|
115
|
+
jira: ["#0055cc", "#579dff"],
|
|
116
|
+
star: ["#b45309", "#f5b301"],
|
|
117
|
+
sun: ["#b45309", "#f59e0b"],
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** The color of mark `key` (github, azure, jira, star, sun) in theme `t`. */
|
|
121
|
+
export function markColor(t, key) {
|
|
122
|
+
const hex = MARK_HEX[key];
|
|
123
|
+
return hex ? hex[isDark(t) ? 1 : 0] : t.accent;
|
|
124
|
+
}
|
|
@@ -5,4 +5,12 @@ export const CONFIG = {
|
|
|
5
5
|
api: "http://127.0.0.1:3000/api/v1",
|
|
6
6
|
// null: ~/.bond-app/token (the orchestrator's default data dir)
|
|
7
7
|
tokenFile: null,
|
|
8
|
+
// Gasto/costes fuera por defecto (decisión 2026-11-19): el orquestador sigue
|
|
9
|
+
// registrando cost_usd, pero la UI no lo muestra hasta que una configuración
|
|
10
|
+
// en Ajustes lo active. Entonces esto será el valor de esa configuración.
|
|
11
|
+
costs: false,
|
|
12
|
+
// How to start the orchestrator (Ajustes «Arrancar orquestador»): app:install writes the
|
|
13
|
+
// node and bin/bond-app.js it was installed from, with the port and data dir. null:
|
|
14
|
+
// `bond-app start`.
|
|
15
|
+
start: null,
|
|
8
16
|
};
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
// bond-status: the bond layout's status bar (P6 criterion 4). At a glance: whether the
|
|
2
|
-
// orchestrator's API answers, the GitHub credential (D20),
|
|
3
|
-
// against the minimums bond-app is tested
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
2
|
+
// orchestrator's API answers, the GitHub credential (D20), Azure DevOps and Jira when they
|
|
3
|
+
// are configured, herdr-app's and hc's versions against the minimums bond-app is tested
|
|
4
|
+
// with (and a newer herdr-app waiting for a restart), and how many runs are active.
|
|
5
|
+
// Clicking the API, GitHub, Azure or Jira item opens its section of Ajustes.
|
|
6
|
+
// It only reads: GET /health (no token), /settings/{github,azure-devops,jira} and /runs,
|
|
7
|
+
// every 5 s. A token problem (no token file, a rotated token: 401) is told apart from the
|
|
8
|
+
// API being down.
|
|
7
9
|
import { View, div } from "gpui-kit";
|
|
8
10
|
import { h_flex } from "gpui-base";
|
|
9
|
-
import { theme, updates, run } from "herdr";
|
|
11
|
+
import { theme, updates, openOverlay, run, exec, checking } from "herdr";
|
|
10
12
|
import { api, health } from "./api.js";
|
|
11
|
-
import { UI } from "./brand.js";
|
|
13
|
+
import { UI, settingsOverlay, stateColor } from "./brand.js";
|
|
12
14
|
import { statusSummary, compareVersions, MIN_HERDR_APP, MIN_HC, POLL_MS } from "./model.js";
|
|
13
15
|
|
|
14
16
|
export default class BondStatus extends View {
|
|
15
17
|
init(_props, cx) {
|
|
16
18
|
this.state = { api: null, github: null, runs: null }; // null: not known yet
|
|
19
|
+
this.appInstalled = null; // herdr-app on disk, when newer than the running window
|
|
20
|
+
if (!checking()) {
|
|
21
|
+
cx.spawn(async (cx) => {
|
|
22
|
+
try {
|
|
23
|
+
const r = await exec("herdr-app", ["--version"], { on: null, timeout: 5000 });
|
|
24
|
+
this.appInstalled = /(\d+\.\d+\.\d+)/.exec(String(r?.stdout ?? ""))?.[1] ?? null;
|
|
25
|
+
cx.notify();
|
|
26
|
+
} catch {}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
17
29
|
this.refresh(cx);
|
|
18
30
|
cx.timer.every(POLL_MS, (cx) => this.refresh(cx));
|
|
19
31
|
}
|
|
@@ -27,9 +39,14 @@ export default class BondStatus extends View {
|
|
|
27
39
|
await health();
|
|
28
40
|
next.api = { ok: true };
|
|
29
41
|
try {
|
|
30
|
-
const [github, runs] = await Promise.all([
|
|
42
|
+
const [github, runs, azure, jira] = await Promise.all([
|
|
43
|
+
api("/settings/github"), api("/runs"),
|
|
44
|
+
api("/settings/azure-devops").catch(() => null), api("/settings/jira").catch(() => null),
|
|
45
|
+
]);
|
|
31
46
|
next.github = github ?? { configured: false };
|
|
32
47
|
next.runs = runs ?? [];
|
|
48
|
+
next.azure = azure;
|
|
49
|
+
next.jira = jira;
|
|
33
50
|
} catch (e) {
|
|
34
51
|
next.error = String(e?.message ?? e);
|
|
35
52
|
}
|
|
@@ -43,8 +60,8 @@ export default class BondStatus extends View {
|
|
|
43
60
|
});
|
|
44
61
|
}
|
|
45
62
|
|
|
46
|
-
openSettings() {
|
|
47
|
-
|
|
63
|
+
openSettings(section) {
|
|
64
|
+
openOverlay(settingsOverlay(section ? { section } : {}));
|
|
48
65
|
}
|
|
49
66
|
|
|
50
67
|
item(id, dot, text, color, onClick) {
|
|
@@ -59,18 +76,23 @@ export default class BondStatus extends View {
|
|
|
59
76
|
render() {
|
|
60
77
|
const t = theme();
|
|
61
78
|
const u = updates();
|
|
62
|
-
const s = statusSummary(this.state, { app: u?.app?.version ?? null, core: u?.core?.version ?? null });
|
|
63
|
-
const tone = { ok: t
|
|
79
|
+
const s = statusSummary(this.state, { app: u?.app?.version ?? null, core: u?.core?.version ?? null, appReady: u?.app?.ready ?? null, appInstalled: this.appInstalled });
|
|
80
|
+
const tone = { ok: stateColor(t, "running"), warn: t.bond_blocked ?? t.blocked, bad: t.blocked, unknown: t.dim };
|
|
64
81
|
const version = (name, have, min) => {
|
|
65
82
|
const ok = have && compareVersions(have, min) >= 0;
|
|
66
83
|
return this.item(`st-${name}`, null, `${name} ${have ?? "?"}${ok ? "" : ` (mín. ${min})`}`, ok ? t.dim : t.blocked);
|
|
67
84
|
};
|
|
68
85
|
return h_flex().id("bond-status").size_full().px(8).gap(4).items_center().bg(t.chrome)
|
|
69
86
|
.border_t(1).border_color(t.border).text_size(UI.text.small).font_family("JetBrains Mono").text_color(t.muted)
|
|
70
|
-
.child(this.item("st-api", tone[s.api.tone], s.api.text, null, () => this.openSettings()))
|
|
71
|
-
.child(this.item("st-github", tone[s.github.tone], s.github.text, null, () => this.openSettings()))
|
|
72
|
-
.child(this.item("st-
|
|
87
|
+
.child(this.item("st-api", tone[s.api.tone], s.api.text, null, () => this.openSettings("orchestrator")))
|
|
88
|
+
.child(this.item("st-github", tone[s.github.tone], s.github.text, null, () => this.openSettings("github")))
|
|
89
|
+
.when(Boolean(s.azure), (el) => el.child(this.item("st-azure", tone[s.azure.tone], s.azure.text, null, () => this.openSettings("azure"))))
|
|
90
|
+
.when(Boolean(s.jira), (el) => el.child(this.item("st-jira", tone[s.jira.tone], s.jira.text, null, () => this.openSettings("jira"))))
|
|
91
|
+
.child(this.item("st-runs", s.runs.active > 0 ? stateColor(t, "running") : t.dim, s.runs.text, null, null))
|
|
73
92
|
.child(div().flex_1())
|
|
93
|
+
.when(Boolean(s.versions.appNewer), (el) => el.child(this.item("st-app-update", t.accent,
|
|
94
|
+
s.versions.appRestart ? `herdr-app ${s.versions.appNewer}: reiniciar` : `herdr-app ${s.versions.appNewer} instalado: reinicia la app`,
|
|
95
|
+
t.accent, s.versions.appRestart ? () => run("app.update") : null)))
|
|
74
96
|
.child(version("herdr-app", s.versions.app, MIN_HERDR_APP))
|
|
75
97
|
.child(version("hc", s.versions.core, MIN_HC));
|
|
76
98
|
}
|
|
@@ -66,10 +66,28 @@ export function statusSummary(state, versions) {
|
|
|
66
66
|
const runsItem = runs === null
|
|
67
67
|
? { active: 0, text: "runs: ?" }
|
|
68
68
|
: { active, text: active === 1 ? "1 run activo" : `${active} runs activos` };
|
|
69
|
+
// Azure DevOps and Jira are optional: an item only when configured (else nothing to say).
|
|
70
|
+
const azure = api?.ok && state?.azure?.configured
|
|
71
|
+
? { tone: "ok", text: `Azure: ${String(state.azure.org_url ?? "").split("/").filter(Boolean).pop() || "conectado"}` }
|
|
72
|
+
: null;
|
|
73
|
+
const jira = api?.ok && state?.jira?.configured
|
|
74
|
+
? { tone: "ok", text: `Jira: ${String(state.jira.site ?? "").replace(/^https:\/\//, "").replace(/\.atlassian\.net\/?$/, "") || "conectado"}` }
|
|
75
|
+
: null;
|
|
76
|
+
// A newer herdr-app waiting: downloaded by the app (`ready`, a click restarts into it) or
|
|
77
|
+
// installed on disk while this window still runs the old one (restart it by hand).
|
|
78
|
+
const appNewer = [versions?.appReady, versions?.appInstalled]
|
|
79
|
+
.filter((v) => v && versions?.app && compareVersions(v, versions.app) > 0)[0] ?? null;
|
|
69
80
|
return {
|
|
70
81
|
api: apiItem,
|
|
71
82
|
github: githubItem,
|
|
83
|
+
azure,
|
|
84
|
+
jira,
|
|
72
85
|
runs: runsItem,
|
|
73
|
-
versions: {
|
|
86
|
+
versions: {
|
|
87
|
+
app: versions?.app ?? null,
|
|
88
|
+
core: versions?.core ?? null,
|
|
89
|
+
appNewer,
|
|
90
|
+
appRestart: Boolean(appNewer && appNewer === versions?.appReady),
|
|
91
|
+
},
|
|
74
92
|
};
|
|
75
93
|
}
|
|
@@ -18,6 +18,7 @@ export const UI = {
|
|
|
18
18
|
button: 26,
|
|
19
19
|
folded: 34, // width of a folded (empty) board column
|
|
20
20
|
columnWidth: 270, // fixed column width
|
|
21
|
+
columnMax: 560, // an open board column is never wider than this
|
|
21
22
|
fontFamily: "JetBrains Mono",
|
|
22
23
|
fontSans: "Geist",
|
|
23
24
|
};
|
|
@@ -26,7 +27,7 @@ export const UI = {
|
|
|
26
27
|
const STATE_FALLBACK = {
|
|
27
28
|
ready: "idle",
|
|
28
29
|
running: "working",
|
|
29
|
-
waiting: "
|
|
30
|
+
waiting: "working",
|
|
30
31
|
finished: "done",
|
|
31
32
|
error: "blocked",
|
|
32
33
|
verifying: "accent",
|
|
@@ -41,9 +42,24 @@ const STATE_THEME_KEY = {
|
|
|
41
42
|
error: "bond_error",
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Running is green and waiting yellow (2026-11-23: less red on the board). A theme without
|
|
47
|
+
* bond_* colors falls back to herdr's palette, which has neither (its `working` is yellow,
|
|
48
|
+
* `blocked` red): these get fixed hues, [light, dark], AA-safe as fills on either.
|
|
49
|
+
*/
|
|
50
|
+
const STATE_HEX = {
|
|
51
|
+
running: ["#047857", "#34d399"],
|
|
52
|
+
waiting: ["#a16207", "#facc15"],
|
|
53
|
+
blocked: ["#a16207", "#facc15"],
|
|
54
|
+
};
|
|
55
|
+
|
|
44
56
|
/** The color of a board column or state (`ready`, `running`, ...) in theme `t`. */
|
|
45
57
|
export function stateColor(t, id) {
|
|
46
|
-
|
|
58
|
+
const own = t[`bond_${id}`] ?? t[STATE_THEME_KEY[id]];
|
|
59
|
+
if (own) return own;
|
|
60
|
+
const hex = STATE_HEX[id];
|
|
61
|
+
if (hex) return hex[isDark(t) ? 1 : 0];
|
|
62
|
+
return t[STATE_FALLBACK[id]] ?? t.accent;
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
/** Relative luminance of `#rrggbb[aa]` (WCAG), 0..1. */
|
|
@@ -71,3 +87,38 @@ export function logo(t) {
|
|
|
71
87
|
wordmarkRatio: 398 / 108,
|
|
72
88
|
};
|
|
73
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Ajustes as a modal dialog (plan bond-app-ajustes-imagen P1): what every bond-* mod passes
|
|
93
|
+
* to herdr's openOverlay to open it. `section` picks the section (orchestrator, agents,
|
|
94
|
+
* github, image, advanced); `{ view: "wizard", step }` opens the first-launch walk.
|
|
95
|
+
*/
|
|
96
|
+
export function settingsOverlay(props = {}) {
|
|
97
|
+
return { mod: "bond-settings", kind: "dialog", modal: true, width: 820, height: 0.7, props: { view: "settings", ...props } };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* «Nuevo ticket» (Qué · Dónde · Quién): every button that opens it passes this, so the
|
|
102
|
+
* dialog always has its height (its body scrolls; without a height it collapses).
|
|
103
|
+
*/
|
|
104
|
+
export function createOverlay() {
|
|
105
|
+
return { mod: "bond-board", kind: "dialog", modal: true, width: 820, height: 0.92, props: { view: "create" } };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Fixed hues bond uses outside the state palette (host badges, the favorite star, the
|
|
110
|
+
* theme button), [light, dark]: readable on either theme, never a hex that only suits one.
|
|
111
|
+
*/
|
|
112
|
+
const MARK_HEX = {
|
|
113
|
+
github: ["#6d28d9", "#a78bfa"],
|
|
114
|
+
azure: ["#0067b8", "#3b9cff"],
|
|
115
|
+
jira: ["#0055cc", "#579dff"],
|
|
116
|
+
star: ["#b45309", "#f5b301"],
|
|
117
|
+
sun: ["#b45309", "#f59e0b"],
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** The color of mark `key` (github, azure, jira, star, sun) in theme `t`. */
|
|
121
|
+
export function markColor(t, key) {
|
|
122
|
+
const hex = MARK_HEX[key];
|
|
123
|
+
return hex ? hex[isDark(t) ? 1 : 0] : t.accent;
|
|
124
|
+
}
|
|
@@ -4,17 +4,37 @@
|
|
|
4
4
|
// Key differences from herdr's stock tabs:
|
|
5
5
|
// 1. Never draws window buttons (minimize, maximize, close): window buttons belong
|
|
6
6
|
// only to bond-titlebar.
|
|
7
|
-
// 2. Does not allow closing run terminal tabs (
|
|
7
|
+
// 2. Does not allow closing run terminal tabs (tab.close ends their terminals: it would kill
|
|
8
|
+
// the agent). In a run's space the × hides instead: terminal.park, the agent keeps running,
|
|
9
|
+
// and the Agents panel brings it back with «Sincronizar Terminal» (plan
|
|
10
|
+
// bond-app-pestanas-paneles, E4).
|
|
8
11
|
// 3. Right-hand button toggles/collapses the console view ('main' block) using
|
|
9
12
|
// layout.hide / layout.show, without ever killing the run terminal or pane.
|
|
10
13
|
// 4. Clicking a tab while the console is collapsed restores it automatically.
|
|
11
14
|
|
|
12
15
|
import { View, div, svg, image } from "gpui-kit";
|
|
13
16
|
import { h_flex, ScrollHandle } from "gpui-base";
|
|
14
|
-
import { spaces, panes, run, openOverlay, theme, layout } from "herdr";
|
|
17
|
+
import { spaces, panes, terminals, run, openOverlay, theme, layout, shared, setShared } from "herdr";
|
|
15
18
|
import { UI } from "./brand.js";
|
|
16
19
|
|
|
17
20
|
const ICONS = "mods/bond-tabs";
|
|
21
|
+
// Shared with bond-agents (model.js HIDDEN_KEY): addresses hidden until «Sincronizar».
|
|
22
|
+
const HIDDEN_KEY = "bond.agents.hidden";
|
|
23
|
+
|
|
24
|
+
/** Hide a run tab's terminals: park them (they keep running) and remember them as hidden. */
|
|
25
|
+
function hideTab(tabId) {
|
|
26
|
+
const addrs = (panes() ?? []).filter((p) => p.tab === tabId && p.terminal && p.terminal.includes("/")).map((p) => p.terminal);
|
|
27
|
+
if (!addrs.length) return;
|
|
28
|
+
const cur = shared(HIDDEN_KEY);
|
|
29
|
+
const set = new Set(Array.isArray(cur) ? cur : []);
|
|
30
|
+
for (const a of addrs) set.add(a);
|
|
31
|
+
setShared(HIDDEN_KEY, [...set].sort());
|
|
32
|
+
for (const a of addrs) {
|
|
33
|
+
try {
|
|
34
|
+
run("terminal.park", { terminal: a });
|
|
35
|
+
} catch {}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
18
38
|
|
|
19
39
|
function findNode(node, id) {
|
|
20
40
|
if (!node || typeof node !== "object") return null;
|
|
@@ -86,7 +106,15 @@ export default class BondTabs extends View {
|
|
|
86
106
|
const program =
|
|
87
107
|
allPanes.find((p) => p.tab === c.id && p.program?.agent)?.program ??
|
|
88
108
|
allPanes.find((p) => p.tab === c.id)?.program;
|
|
89
|
-
|
|
109
|
+
// Unnamed (herdr shows its position, «1»): the agent and its terminal, as the pane
|
|
110
|
+
// header says it («gru · pi»), else the program.
|
|
111
|
+
const unnamed = c.named === false || /^tb\d+$/.test(c.name) || /^\d+$/.test(c.name);
|
|
112
|
+
const term = allPanes.find((p) => p.tab === c.id && p.program?.agent)?.terminal ?? allPanes.find((p) => p.tab === c.id)?.terminal ?? "";
|
|
113
|
+
const termName = String((terminals() ?? []).find((x) => x.address === term)?.name ?? "").trim();
|
|
114
|
+
const progName = program?.name ?? "Terminal";
|
|
115
|
+
const name = !unnamed ? c.name
|
|
116
|
+
: termName && termName !== progName && !/^t\d+$/.test(termName) && termName !== "agent"
|
|
117
|
+
? `${termName} · ${progName}` : progName;
|
|
90
118
|
|
|
91
119
|
return h_flex()
|
|
92
120
|
.id(`tab-${c.id}`)
|
|
@@ -169,6 +197,20 @@ export default class BondTabs extends View {
|
|
|
169
197
|
.when(c.status === "blocked" || c.status === "done", (el) =>
|
|
170
198
|
el.child(div().size(6).rounded(3).bg(t[c.status]))
|
|
171
199
|
)
|
|
200
|
+
.when(c.active && isRun, (el) =>
|
|
201
|
+
el.child(
|
|
202
|
+
div()
|
|
203
|
+
.id(`hide-${c.id}`)
|
|
204
|
+
.text_color(t.dim)
|
|
205
|
+
.hover((s) => s.text_color(t.foreground))
|
|
206
|
+
.on_mouse_down("left", stop)
|
|
207
|
+
.on_click((_e, cx) => {
|
|
208
|
+
cx.stop_propagation();
|
|
209
|
+
hideTab(c.id);
|
|
210
|
+
})
|
|
211
|
+
.child(svg(`${ICONS}/close.svg`).size(12))
|
|
212
|
+
)
|
|
213
|
+
)
|
|
172
214
|
.when(c.active && !isRun, (el) =>
|
|
173
215
|
el.child(
|
|
174
216
|
div()
|
|
@@ -18,6 +18,7 @@ export const UI = {
|
|
|
18
18
|
button: 26,
|
|
19
19
|
folded: 34, // width of a folded (empty) board column
|
|
20
20
|
columnWidth: 270, // fixed column width
|
|
21
|
+
columnMax: 560, // an open board column is never wider than this
|
|
21
22
|
fontFamily: "JetBrains Mono",
|
|
22
23
|
fontSans: "Geist",
|
|
23
24
|
};
|
|
@@ -26,7 +27,7 @@ export const UI = {
|
|
|
26
27
|
const STATE_FALLBACK = {
|
|
27
28
|
ready: "idle",
|
|
28
29
|
running: "working",
|
|
29
|
-
waiting: "
|
|
30
|
+
waiting: "working",
|
|
30
31
|
finished: "done",
|
|
31
32
|
error: "blocked",
|
|
32
33
|
verifying: "accent",
|
|
@@ -41,9 +42,24 @@ const STATE_THEME_KEY = {
|
|
|
41
42
|
error: "bond_error",
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Running is green and waiting yellow (2026-11-23: less red on the board). A theme without
|
|
47
|
+
* bond_* colors falls back to herdr's palette, which has neither (its `working` is yellow,
|
|
48
|
+
* `blocked` red): these get fixed hues, [light, dark], AA-safe as fills on either.
|
|
49
|
+
*/
|
|
50
|
+
const STATE_HEX = {
|
|
51
|
+
running: ["#047857", "#34d399"],
|
|
52
|
+
waiting: ["#a16207", "#facc15"],
|
|
53
|
+
blocked: ["#a16207", "#facc15"],
|
|
54
|
+
};
|
|
55
|
+
|
|
44
56
|
/** The color of a board column or state (`ready`, `running`, ...) in theme `t`. */
|
|
45
57
|
export function stateColor(t, id) {
|
|
46
|
-
|
|
58
|
+
const own = t[`bond_${id}`] ?? t[STATE_THEME_KEY[id]];
|
|
59
|
+
if (own) return own;
|
|
60
|
+
const hex = STATE_HEX[id];
|
|
61
|
+
if (hex) return hex[isDark(t) ? 1 : 0];
|
|
62
|
+
return t[STATE_FALLBACK[id]] ?? t.accent;
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
/** Relative luminance of `#rrggbb[aa]` (WCAG), 0..1. */
|
|
@@ -71,3 +87,38 @@ export function logo(t) {
|
|
|
71
87
|
wordmarkRatio: 398 / 108,
|
|
72
88
|
};
|
|
73
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Ajustes as a modal dialog (plan bond-app-ajustes-imagen P1): what every bond-* mod passes
|
|
93
|
+
* to herdr's openOverlay to open it. `section` picks the section (orchestrator, agents,
|
|
94
|
+
* github, image, advanced); `{ view: "wizard", step }` opens the first-launch walk.
|
|
95
|
+
*/
|
|
96
|
+
export function settingsOverlay(props = {}) {
|
|
97
|
+
return { mod: "bond-settings", kind: "dialog", modal: true, width: 820, height: 0.7, props: { view: "settings", ...props } };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* «Nuevo ticket» (Qué · Dónde · Quién): every button that opens it passes this, so the
|
|
102
|
+
* dialog always has its height (its body scrolls; without a height it collapses).
|
|
103
|
+
*/
|
|
104
|
+
export function createOverlay() {
|
|
105
|
+
return { mod: "bond-board", kind: "dialog", modal: true, width: 820, height: 0.92, props: { view: "create" } };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Fixed hues bond uses outside the state palette (host badges, the favorite star, the
|
|
110
|
+
* theme button), [light, dark]: readable on either theme, never a hex that only suits one.
|
|
111
|
+
*/
|
|
112
|
+
const MARK_HEX = {
|
|
113
|
+
github: ["#6d28d9", "#a78bfa"],
|
|
114
|
+
azure: ["#0067b8", "#3b9cff"],
|
|
115
|
+
jira: ["#0055cc", "#579dff"],
|
|
116
|
+
star: ["#b45309", "#f5b301"],
|
|
117
|
+
sun: ["#b45309", "#f59e0b"],
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** The color of mark `key` (github, azure, jira, star, sun) in theme `t`. */
|
|
121
|
+
export function markColor(t, key) {
|
|
122
|
+
const hex = MARK_HEX[key];
|
|
123
|
+
return hex ? hex[isDark(t) ? 1 : 0] : t.accent;
|
|
124
|
+
}
|