@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
|
@@ -22,6 +22,10 @@ export const STATE_STYLES = {
|
|
|
22
22
|
"idle-waiting": { icon: "⏳", label: "En espera", tone: "blocked" },
|
|
23
23
|
working: { icon: "🔄", label: "Trabajando", tone: "working" },
|
|
24
24
|
blocked: { icon: "⛔", label: "Bloqueado", tone: "blocked" },
|
|
25
|
+
arrancando: { icon: "🚀", label: "Arrancando", tone: "working" },
|
|
26
|
+
live: { icon: "⚡", label: "Live", tone: "working" },
|
|
27
|
+
idle: { icon: "💤", label: "Idle", tone: "dim" },
|
|
28
|
+
"sin estado": { icon: "•", label: "Sin estado", tone: "dim" },
|
|
25
29
|
};
|
|
26
30
|
|
|
27
31
|
export function stateInfo(state) {
|
|
@@ -39,7 +43,7 @@ export function formatFiles(files) {
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
export function repoDisplayName(row, ticket) {
|
|
42
|
-
if (row?.agent?.name === "hub leader" || row?.path === "/workspace/hub") {
|
|
46
|
+
if (row?.agent?.name === "hub leader" || row?.path === "/workspace/hub" || row?.repo === "orquestador") {
|
|
43
47
|
return row?.repo || "orquestador";
|
|
44
48
|
}
|
|
45
49
|
if (row?.repo && row.repo !== ".") return String(row.repo);
|
|
@@ -47,6 +51,91 @@ export function repoDisplayName(row, ticket) {
|
|
|
47
51
|
return "-";
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
// C7 (plan bond-app-agentes-modos-view P2): only coding agents count as agents in the
|
|
55
|
+
// panel. A program is the one hc detected for the terminal (`agent` / `program.key`),
|
|
56
|
+
// falling back to the terminal's name. Dev servers and shells (npm, node, zsh...) are
|
|
57
|
+
// not agents: they get no row, no count in "N activos" and no block in PANELES.
|
|
58
|
+
export const CODING_AGENTS = [
|
|
59
|
+
"bond", "pi", "antigravity", "agy", "claude", "codex", "copilot", "opencode",
|
|
60
|
+
"gemini", "aider", "amp", "goose", "qwen", "crush", "cursor", "kiro", "droid",
|
|
61
|
+
];
|
|
62
|
+
export const NON_AGENT_PROGRAMS = [
|
|
63
|
+
"npm", "npx", "pnpm", "yarn", "bun", "bunx", "deno", "node", "nodejs", "vite",
|
|
64
|
+
"zsh", "bash", "sh", "dash", "fish", "nu", "pwsh", "shell", "python", "python3",
|
|
65
|
+
"uv", "make", "cargo", "go", "docker", "tail", "less", "watch", "nvim", "vim",
|
|
66
|
+
];
|
|
67
|
+
const LEADER_NAMES = ["gru", "agent", "hub leader", "hub-leader", "leader", "orquestador"];
|
|
68
|
+
|
|
69
|
+
function programTokens(program) {
|
|
70
|
+
const raw = String(program ?? "").trim().toLowerCase();
|
|
71
|
+
if (!raw) return [];
|
|
72
|
+
const base = raw.split(/[\\/]/).pop() ?? raw;
|
|
73
|
+
return base.split(/[^a-z0-9]+/).filter(Boolean);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** True if the detected program name is a known coding agent (claude-code, dev-agy-1, pi). */
|
|
77
|
+
export function isCodingAgentProgram(program) {
|
|
78
|
+
const tokens = programTokens(program);
|
|
79
|
+
if (tokens.length === 0) return false;
|
|
80
|
+
if (NON_AGENT_PROGRAMS.includes(tokens[0])) return false;
|
|
81
|
+
return tokens.some((t) => CODING_AGENTS.includes(t));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* True if a terminal of a run (from /runs/:id/terminals or herdr terminals()) is a coding
|
|
86
|
+
* agent. The run's orchestrator terminal (/t1 or a leader name) always is. A bare address
|
|
87
|
+
* string carries no program, so it is kept (callers filter objects before planning).
|
|
88
|
+
*/
|
|
89
|
+
export function isAgentTerminal(term) {
|
|
90
|
+
if (!term) return false;
|
|
91
|
+
if (typeof term === "string") return true;
|
|
92
|
+
const addr = String(term.address ?? term.terminal ?? "");
|
|
93
|
+
if (addr.endsWith("/t1") || LEADER_NAMES.includes(String(term.name ?? ""))) return true;
|
|
94
|
+
const program = term.agent || term.program?.key || term.name;
|
|
95
|
+
return isCodingAgentProgram(program);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Team-status row filter (C7): leader rows and rows without a program stay; a row whose
|
|
99
|
+
* detected program (agent.kind) is not a coding agent (e.g. npm in a hub) goes. */
|
|
100
|
+
export function isAgentRow(row) {
|
|
101
|
+
const agent = row?.agent ?? {};
|
|
102
|
+
const pane = String(agent.pane ?? row?.pane ?? "");
|
|
103
|
+
if (pane.endsWith("/t1") || row?.repo === "orquestador" || row?.path === "/workspace/hub") return true;
|
|
104
|
+
if (LEADER_NAMES.includes(String(agent.name ?? ""))) return true;
|
|
105
|
+
if (!agent.kind) return true;
|
|
106
|
+
return isCodingAgentProgram(agent.kind);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* herdr-app's icons (icons/<name>.svg in its home) for the coding agents, and whether each is a
|
|
111
|
+
* one-color glyph to tint (`currentColor`) or a picture with its own colors. Used when herdr
|
|
112
|
+
* has not detected the terminal's program (its `program.icon` wins).
|
|
113
|
+
*/
|
|
114
|
+
const AGENT_ICONS = {
|
|
115
|
+
// pi's icon is plain white: tinted like copilot and opencode so it shows on the light theme.
|
|
116
|
+
pi: true, antigravity: false, claude: false, codex: false, crush: false, gemini: false,
|
|
117
|
+
copilot: true, opencode: true,
|
|
118
|
+
};
|
|
119
|
+
const ICON_ALIASES = { agy: "antigravity", "claude-code": "claude", "github-copilot": "copilot", "gemini-cli": "gemini" };
|
|
120
|
+
|
|
121
|
+
/** The icon of an agent row: herdr's program for its terminal, else the agent kind's icon.
|
|
122
|
+
* { icon, tint } or null (then the row shows initials). */
|
|
123
|
+
export function agentIcon(program, kind) {
|
|
124
|
+
if (program?.icon) return { icon: program.icon, tint: Boolean(program.tint) };
|
|
125
|
+
const k = String(kind ?? "").trim().toLowerCase();
|
|
126
|
+
const name = ICON_ALIASES[k] ?? k;
|
|
127
|
+
return Object.prototype.hasOwnProperty.call(AGENT_ICONS, name) ? { icon: `icons/${name}.svg`, tint: AGENT_ICONS[name] } : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The terminal's own name to show before its program («gru · pi», «kevin · antigravity»):
|
|
131
|
+
* gru, a minion or any given name; not hc's generic `agent` nor `tN`, nor the program again. */
|
|
132
|
+
export function terminalName(term) {
|
|
133
|
+
const name = String(term?.name ?? "").trim();
|
|
134
|
+
if (!name || name === "agent" || /^t\d+$/.test(name)) return null;
|
|
135
|
+
const kind = String(term?.agent ?? term?.program?.key ?? "").trim();
|
|
136
|
+
return name === kind ? null : name;
|
|
137
|
+
}
|
|
138
|
+
|
|
50
139
|
/**
|
|
51
140
|
* Builds the display list of run sections for the agents panel.
|
|
52
141
|
* Shows ONLY the selected card's run/ticket; when none is selected, returns empty array
|
|
@@ -56,8 +145,9 @@ export function repoDisplayName(row, ticket) {
|
|
|
56
145
|
* @param {string|null} selectedRunId - Run ID selected in the board (shared)
|
|
57
146
|
* @param {Record<string, Array>} teamStatusByRun - Map of runId -> team status rows
|
|
58
147
|
* @param {string|null} [selectedTicketId] - Ticket ID selected in the board (shared)
|
|
148
|
+
* @param {Record<string, Array>} [terminalsByRun] - Map of runId -> live terminals from /runs/:id/terminals (P4)
|
|
59
149
|
*/
|
|
60
|
-
export function buildAgentsSections(runs, tickets, selectedRunId, teamStatusByRun, selectedTicketId) {
|
|
150
|
+
export function buildAgentsSections(runs, tickets, selectedRunId, teamStatusByRun, selectedTicketId, terminalsByRun) {
|
|
61
151
|
if (!selectedRunId && !selectedTicketId) {
|
|
62
152
|
return [];
|
|
63
153
|
}
|
|
@@ -74,7 +164,111 @@ export function buildAgentsSections(runs, tickets, selectedRunId, teamStatusByRu
|
|
|
74
164
|
|
|
75
165
|
if (targetRun) {
|
|
76
166
|
const ticket = ticketMap.get(targetRun.ticket_id) || null;
|
|
77
|
-
|
|
167
|
+
let rows = teamStatusByRun?.[targetRun.id] ? teamStatusByRun[targetRun.id].filter(isAgentRow) : [];
|
|
168
|
+
|
|
169
|
+
// Fallback if rows is empty (e.g. while API request is in flight)
|
|
170
|
+
if (rows.length === 0) {
|
|
171
|
+
let state = "sin estado";
|
|
172
|
+
let status = "sin estado";
|
|
173
|
+
let question = undefined;
|
|
174
|
+
if (targetRun.state === "queued" || targetRun.state === "ready") {
|
|
175
|
+
state = "arrancando";
|
|
176
|
+
status = "arrancando";
|
|
177
|
+
} else if (targetRun.state === "waiting") {
|
|
178
|
+
state = "en espera";
|
|
179
|
+
status = "en espera";
|
|
180
|
+
question = targetRun.failure_reason || undefined;
|
|
181
|
+
} else if (targetRun.state === "running") {
|
|
182
|
+
state = "arrancando";
|
|
183
|
+
status = "arrancando";
|
|
184
|
+
} else if (targetRun.state === "finished") {
|
|
185
|
+
state = "lista";
|
|
186
|
+
status = "finished";
|
|
187
|
+
} else if (targetRun.state === "failed") {
|
|
188
|
+
state = "bloqueado";
|
|
189
|
+
status = "failed";
|
|
190
|
+
}
|
|
191
|
+
rows = [{
|
|
192
|
+
branch: ticket?.target_branch || "",
|
|
193
|
+
path: ticket?.mode === "hub" ? "/workspace/hub" : "/workspace/repo",
|
|
194
|
+
repo: "orquestador",
|
|
195
|
+
state,
|
|
196
|
+
ahead: 0,
|
|
197
|
+
files: [],
|
|
198
|
+
dirty: 0,
|
|
199
|
+
integrated: false,
|
|
200
|
+
agent: {
|
|
201
|
+
name: ticket?.mode === "hub" ? "hub leader" : (ticket?.agent || "pi"),
|
|
202
|
+
kind: ticket?.agent || "pi",
|
|
203
|
+
status,
|
|
204
|
+
question,
|
|
205
|
+
pane: targetRun.hc_terminal || (targetRun.hc_machine ? `${targetRun.hc_machine}/t1` : null),
|
|
206
|
+
},
|
|
207
|
+
}];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// P4: Merge delegate terminals reported by GET /runs/:id/terminals
|
|
211
|
+
const runTerminals = terminalsByRun?.[targetRun.id];
|
|
212
|
+
if (Array.isArray(runTerminals) && runTerminals.length > 0) {
|
|
213
|
+
const knownPanes = new Set(
|
|
214
|
+
rows.map((r) => r?.agent?.pane || r?.pane).filter(Boolean)
|
|
215
|
+
);
|
|
216
|
+
if (targetRun.hc_terminal) knownPanes.add(targetRun.hc_terminal);
|
|
217
|
+
if (targetRun.hc_machine) knownPanes.add(`${targetRun.hc_machine}/t1`);
|
|
218
|
+
|
|
219
|
+
const liveTerminals = runTerminals.filter((t) => {
|
|
220
|
+
if (t.exit_code !== null && t.exit_code !== undefined) return false;
|
|
221
|
+
if (t.state && t.state !== "live") return false;
|
|
222
|
+
return isAgentTerminal(t); // C7: dev servers and shells are not agents
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
for (const term of liveTerminals) {
|
|
226
|
+
const addr = term.address;
|
|
227
|
+
const isLeader = addr?.endsWith('/t1') || term.name === 'gru' || term.name === 'agent' || term.name === 'hub leader';
|
|
228
|
+
if (isLeader) {
|
|
229
|
+
if (rows[0]) {
|
|
230
|
+
rows[0].agent = rows[0].agent || {};
|
|
231
|
+
if (!rows[0].agent.pane || rows[0].agent.pane.endsWith('/t1')) {
|
|
232
|
+
rows[0].agent.pane = addr;
|
|
233
|
+
}
|
|
234
|
+
if (term.status && (!rows[0].agent.status || rows[0].agent.status === 'sin estado')) {
|
|
235
|
+
rows[0].agent.status = term.status;
|
|
236
|
+
}
|
|
237
|
+
rows[0].minion = rows[0].minion || terminalName(term);
|
|
238
|
+
}
|
|
239
|
+
knownPanes.add(addr);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (knownPanes.has(addr)) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const agentName = term.agent || term.name || "delegado";
|
|
248
|
+
const where = term.where || term.cwd || "/workspace/repo";
|
|
249
|
+
const status = term.status || term.state || "working";
|
|
250
|
+
rows.push({
|
|
251
|
+
branch: ticket?.target_branch || "",
|
|
252
|
+
path: where,
|
|
253
|
+
where,
|
|
254
|
+
repo: where,
|
|
255
|
+
state: typeof status === "string" ? status : (status?.state || "trabajando"),
|
|
256
|
+
ahead: 0,
|
|
257
|
+
files: [],
|
|
258
|
+
dirty: 0,
|
|
259
|
+
integrated: false,
|
|
260
|
+
isDelegate: true,
|
|
261
|
+
minion: terminalName(term),
|
|
262
|
+
agent: {
|
|
263
|
+
name: agentName,
|
|
264
|
+
kind: agentName,
|
|
265
|
+
status,
|
|
266
|
+
pane: addr,
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
knownPanes.add(addr);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
78
272
|
|
|
79
273
|
return [{
|
|
80
274
|
run: targetRun,
|
|
@@ -92,12 +286,13 @@ export function buildAgentsSections(runs, tickets, selectedRunId, teamStatusByRu
|
|
|
92
286
|
...r,
|
|
93
287
|
agentName: agent.name || agent.kind || "agente",
|
|
94
288
|
agentStatus,
|
|
95
|
-
pane: agent.pane ?? null,
|
|
289
|
+
pane: agent.pane ?? r.pane ?? null,
|
|
96
290
|
question: agent.question ?? null,
|
|
97
291
|
aheadLabel: formatAhead(r?.ahead),
|
|
98
292
|
filesLabel: formatFiles(r?.files),
|
|
99
|
-
repoLabel: repoDisplayName(r, ticket),
|
|
100
|
-
|
|
293
|
+
repoLabel: r.isDelegate ? (r.where || r.path || "delegado") : repoDisplayName(r, ticket),
|
|
294
|
+
where: r.where || r.path || null,
|
|
295
|
+
style: stateInfo(typeof stateKey === "string" ? stateKey : stateKey?.state),
|
|
101
296
|
};
|
|
102
297
|
}),
|
|
103
298
|
}];
|
|
@@ -119,3 +314,202 @@ export function buildAgentsSections(runs, tickets, selectedRunId, teamStatusByRu
|
|
|
119
314
|
|
|
120
315
|
return [];
|
|
121
316
|
}
|
|
317
|
+
|
|
318
|
+
// --- Plan bond-app-pestanas-paneles P1: each live run in its own space (E1), a
|
|
319
|
+
// desired-vs-actual reconciler for PESTAÑAS (E3) and hiding without killing (E4). ---
|
|
320
|
+
|
|
321
|
+
/** Addresses the person hid (terminal.park): they stay out until «Sincronizar». Shared
|
|
322
|
+
* with bond-tabs, which hides from the tab bar. */
|
|
323
|
+
export const HIDDEN_KEY = "bond.agents.hidden";
|
|
324
|
+
/** Name of the first tab `space.new` makes (with a shell nobody asked for): closed once the
|
|
325
|
+
* run's orchestrator has its own tab in the space. */
|
|
326
|
+
export const INIT_TAB = "bond-init";
|
|
327
|
+
|
|
328
|
+
/** "bond-run-x/t3" -> "bond-run-x"; null for a terminal of this computer. */
|
|
329
|
+
export function machineOf(addr) {
|
|
330
|
+
const s = String(addr ?? "");
|
|
331
|
+
const i = s.indexOf("/");
|
|
332
|
+
return i > 0 ? s.slice(0, i) : null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** The run's hc machine: hc_machine, else the machine of its terminal. */
|
|
336
|
+
export function runMachine(run) {
|
|
337
|
+
return run?.hc_machine || machineOf(run?.hc_terminal) || null;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const termIndex = (addr) => {
|
|
341
|
+
const m = /\/t(\d+)$/.exec(String(addr ?? ""));
|
|
342
|
+
return m ? Number(m[1]) : Number.MAX_SAFE_INTEGER;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/** The orchestrator (/t1) first, then the rest by terminal number, without duplicates. */
|
|
346
|
+
export function orderLeaderFirst(addrs) {
|
|
347
|
+
return [...new Set((addrs ?? []).filter(Boolean))].sort((a, b) => termIndex(a) - termIndex(b) || (a < b ? -1 : a > b ? 1 : 0));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** The hidden list from shared, as a Set (anything else: empty). */
|
|
351
|
+
export function readHidden(value) {
|
|
352
|
+
return new Set(Array.isArray(value) ? value.filter((a) => typeof a === "string" && a) : []);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** Hidden addresses of `machine` that are no longer live are forgotten; other machines' stay. */
|
|
356
|
+
export function pruneHidden(hidden, machine, liveAddrs) {
|
|
357
|
+
const live = new Set(liveAddrs ?? []);
|
|
358
|
+
return [...readHidden([...(hidden ?? [])])].filter((a) => machineOf(a) !== machine || live.has(a)).sort();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** Agents per PANELES tab (E2): the orchestrator and up to 3 delegates. */
|
|
362
|
+
export const MAX_PANELS = 4;
|
|
363
|
+
|
|
364
|
+
/** Agent panes of `machine`: [{tab, terminal}] whose terminal is one of `agentAddrs`. */
|
|
365
|
+
function agentPanesOf(machine, agentAddrs, paneList) {
|
|
366
|
+
const agents = new Set((agentAddrs ?? []).filter((a) => machineOf(a) === machine));
|
|
367
|
+
return (paneList ?? []).filter((p) => p && p.terminal && agents.has(p.terminal));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* PESTAÑAS (E3): what to keep and park so the run's space shows one tab per live agent,
|
|
372
|
+
* the orchestrator first, minus the hidden ones. Only agent terminals of the run's machine
|
|
373
|
+
* are touched: a shell the person opened in the space is never parked.
|
|
374
|
+
* An agent sharing a tab with another one (the PANELES grid) is parked this pass and given
|
|
375
|
+
* its own tab on the next: park + keep of the same terminal in one pass is not reliable
|
|
376
|
+
* (spike 2026-11-23). `terminal.keep` only lands in the shown space and fails on another
|
|
377
|
+
* machine's, so nothing is kept unless the run's space is shown (`canKeep`).
|
|
378
|
+
* `paneList`: panes() as [{tab, terminal}].
|
|
379
|
+
*/
|
|
380
|
+
export function planTabs({ machine, agentAddrs = [], paneList = [], hidden = [], canKeep = false } = {}) {
|
|
381
|
+
if (!machine) return { keep: [], park: [] };
|
|
382
|
+
const hid = readHidden([...hidden]);
|
|
383
|
+
const agents = orderLeaderFirst(agentAddrs.filter((a) => machineOf(a) === machine));
|
|
384
|
+
const panes = agentPanesOf(machine, agents, paneList);
|
|
385
|
+
const shown = new Set(panes.map((p) => p.terminal));
|
|
386
|
+
const byTab = new Map();
|
|
387
|
+
for (const p of panes) byTab.set(p.tab, [...(byTab.get(p.tab) ?? []), p.terminal]);
|
|
388
|
+
const extras = new Set();
|
|
389
|
+
for (const list of byTab.values()) for (const a of orderLeaderFirst(list).slice(1)) extras.add(a);
|
|
390
|
+
const park = agents.filter((a) => shown.has(a) && (hid.has(a) || extras.has(a)));
|
|
391
|
+
const keep = canKeep ? agents.filter((a) => !hid.has(a) && !shown.has(a)) : [];
|
|
392
|
+
return { keep, park };
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* PANELES (E2): the run's agents (orchestrator first, minus hidden, at most MAX_PANELS)
|
|
397
|
+
* as native splits of the tab of the first of them (the base). When that tab already holds
|
|
398
|
+
* exactly them, nothing changes. Otherwise, in two passes: first `park` the strays (the
|
|
399
|
+
* other agents of the grid wherever they show, and any other agent in the base's tab), then,
|
|
400
|
+
* with the base alone, `build` the rest around it. The base is never parked: a space whose
|
|
401
|
+
* every tab goes is closed by herdr-app, and the run would vanish from the window.
|
|
402
|
+
* Agents beyond MAX_PANELS are left as they are (one opened as a tab with «Sincronizar»
|
|
403
|
+
* stays). Nothing is touched while another space is shown (`canKeep` false), except
|
|
404
|
+
* parking hidden agents.
|
|
405
|
+
* @returns {{ park: string[], build: string[], baseShown: boolean }}
|
|
406
|
+
*/
|
|
407
|
+
export function planPanels({ machine, agentAddrs = [], paneList = [], hidden = [], canKeep = false } = {}) {
|
|
408
|
+
const none = (park = []) => ({ park, build: [], baseShown: false });
|
|
409
|
+
if (!machine) return none();
|
|
410
|
+
const hid = readHidden([...hidden]);
|
|
411
|
+
const agents = orderLeaderFirst(agentAddrs.filter((a) => machineOf(a) === machine));
|
|
412
|
+
const panes = agentPanesOf(machine, agents, paneList);
|
|
413
|
+
const hiddenShown = [...new Set(panes.filter((p) => hid.has(p.terminal)).map((p) => p.terminal))];
|
|
414
|
+
const want = agents.filter((a) => !hid.has(a)).slice(0, MAX_PANELS);
|
|
415
|
+
if (!want.length) return none(hiddenShown);
|
|
416
|
+
const base = want[0];
|
|
417
|
+
const baseTab = panes.find((p) => p.terminal === base)?.tab ?? null;
|
|
418
|
+
const inGrid = baseTab ? panes.filter((p) => p.tab === baseTab && !hid.has(p.terminal)).map((p) => p.terminal) : [];
|
|
419
|
+
const same = baseTab && inGrid.length === want.length && want.every((a) => inGrid.includes(a));
|
|
420
|
+
if (same || !canKeep) return none(hiddenShown);
|
|
421
|
+
const wantSet = new Set(want);
|
|
422
|
+
const stray = [...new Set(panes
|
|
423
|
+
.filter((p) => p.terminal !== base && (wantSet.has(p.terminal) || p.tab === baseTab || hid.has(p.terminal)))
|
|
424
|
+
.map((p) => p.terminal))];
|
|
425
|
+
if (stray.length) return none(orderLeaderFirst(stray));
|
|
426
|
+
return { park: [], build: want, baseShown: Boolean(baseTab) };
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** The commands that build a PANELES grid (2x2 at most) around the base `build[0]`:
|
|
430
|
+
* [command, args] pairs; the base gets its tab first unless it already shows. */
|
|
431
|
+
export function panelBuildSteps(build, baseShown = false) {
|
|
432
|
+
const [a, b, c, d] = build ?? [];
|
|
433
|
+
if (!a) return [];
|
|
434
|
+
const steps = baseShown ? [] : [["terminal.keep", { terminal: a, place: "tab" }]];
|
|
435
|
+
if (b) steps.push(["pane.focus", { terminal: a }], ["terminal.keep", { terminal: b, place: "right" }]);
|
|
436
|
+
if (c) steps.push(["pane.focus", { terminal: a }], ["terminal.keep", { terminal: c, place: "down" }]);
|
|
437
|
+
if (d) steps.push(["pane.focus", { terminal: b }], ["terminal.keep", { terminal: d, place: "down" }]);
|
|
438
|
+
steps.push(["pane.focus", { terminal: a }]);
|
|
439
|
+
return steps;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* The INIT_TAB of the run's space to close once the orchestrator shows in another tab of
|
|
444
|
+
* that space (its shell was made by space.new, not by the person), else null. Never a tab
|
|
445
|
+
* that holds an agent: tab.close ends every terminal in it.
|
|
446
|
+
* `space`: a SpaceInfo; `paneList`: panes() ({tab, terminal}); `agentAddrs`: live agents.
|
|
447
|
+
*/
|
|
448
|
+
export function initTabToClose(space, paneList, machine, agentAddrs = []) {
|
|
449
|
+
if (!space || !machine || space.machine !== machine) return null;
|
|
450
|
+
const init = (space.tabs ?? []).find((t) => t.name === INIT_TAB);
|
|
451
|
+
if (!init) return null;
|
|
452
|
+
const agents = new Set(agentAddrs ?? []);
|
|
453
|
+
if ((paneList ?? []).some((p) => p.tab === init.id && agents.has(p.terminal))) return null;
|
|
454
|
+
const tabIds = new Set((space.tabs ?? []).filter((t) => t.id !== init.id).map((t) => t.id));
|
|
455
|
+
const leaderShown = (paneList ?? []).some((p) => tabIds.has(p.tab) && termIndex(p.terminal) === 1 && machineOf(p.terminal) === machine);
|
|
456
|
+
return leaderShown ? init.id : null;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// --- Panel Agentes, lista compacta (2026-11-23): one row per agent, no nested cards. ---
|
|
460
|
+
|
|
461
|
+
/** Is this row the run's orchestrator (gru / the hub leader)? */
|
|
462
|
+
export function isLeaderRow(row) {
|
|
463
|
+
const pane = String(row?.pane ?? row?.agent?.pane ?? "");
|
|
464
|
+
return row?.repo === "orquestador" || row?.repoLabel === "orquestador" || row?.agent?.name === "hub leader"
|
|
465
|
+
|| row?.path === "/workspace/hub" || pane.endsWith("/t1");
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** The row's name: its terminal's (gru, a minion), else its program's. */
|
|
469
|
+
export function rowName(row) {
|
|
470
|
+
return String(row?.minion || row?.agentName || "agente");
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** Short program names for the role line (the command people type). */
|
|
474
|
+
const KIND_SHORT = { antigravity: "agy", "claude-code": "claude", "github-copilot": "copilot", "gemini-cli": "gemini" };
|
|
475
|
+
|
|
476
|
+
/** «agy · orquestador», «pi · delegado», «claude · web» (a hub worker shows its repo). */
|
|
477
|
+
export function rowRole(row) {
|
|
478
|
+
const raw = String(row?.agentName || row?.agent?.kind || "agente");
|
|
479
|
+
const kind = KIND_SHORT[raw.toLowerCase()] ?? raw;
|
|
480
|
+
const role = isLeaderRow(row) ? "orquestador" : row?.isDelegate ? "delegado" : String(row?.repoLabel || "worker");
|
|
481
|
+
return `${kind} · ${role}`;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** «3 commits · 5 ficheros», or null when there is nothing to say (no empty dashes). */
|
|
485
|
+
export function rowStats(row) {
|
|
486
|
+
const ahead = Number(row?.ahead) || 0;
|
|
487
|
+
const files = Array.isArray(row?.files) ? row.files.length : Number(row?.files) || 0;
|
|
488
|
+
const dirty = Number(row?.dirty) || 0;
|
|
489
|
+
const parts = [];
|
|
490
|
+
if (ahead > 0) parts.push(`${ahead} ${ahead === 1 ? "commit" : "commits"}`);
|
|
491
|
+
if (files > 0 || dirty > 0) parts.push(`${files || dirty} ${(files || dirty) === 1 ? "fichero" : "ficheros"}`);
|
|
492
|
+
return parts.length ? parts.join(" · ") : null;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const GENERIC_WAIT = /^\s*esperando respuesta\s*:?/i;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* The one attention notice of a run: the first row that waits for the person (a question,
|
|
499
|
+
* or a waiting state), as { row, name, text }; `text` is the question itself, or null when
|
|
500
|
+
* it only says «Esperando respuesta: x» (the title already says who). Null when none waits.
|
|
501
|
+
*/
|
|
502
|
+
export function attentionOf(rows, runReason = null) {
|
|
503
|
+
// The run's own reason (failure_reason of a waiting run) is the question when no row has one.
|
|
504
|
+
const fallback = runReason == null ? "" : String(runReason);
|
|
505
|
+
for (const row of rows ?? []) {
|
|
506
|
+
const q = row?.question ?? (isLeaderRow(row) && fallback ? fallback : null);
|
|
507
|
+
const text = q == null ? "" : typeof q === "object" ? String(q.text ?? "") : String(q);
|
|
508
|
+
const waiting = row?.style?.tone === "blocked" || /espera|blocked|bloque/i.test(String(row?.agentStatus ?? ""));
|
|
509
|
+
if (text.trim() || waiting) {
|
|
510
|
+
return { row, name: rowName(row), text: text.trim() && !GENERIC_WAIT.test(text) ? text.trim() : null };
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"><circle cx="4.5" cy="3.5" r="1.5"/><circle cx="4.5" cy="12.5" r="1.5"/><circle cx="11.5" cy="5.5" r="1.5"/><path d="M4.5 5v6M11.5 7c0 2.5-3 2.5-6.5 4"/></svg>
|
|
@@ -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
|
};
|