@jmanuelcorral/bond-app 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -23
- 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 +4 -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 +308 -327
- package/app/mods/bond-agents/model.js +376 -5
- 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 +4 -0
- package/app/mods/bond-board/main.js +1000 -449
- package/app/mods/bond-board/model.js +170 -28
- 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 +4 -0
- package/app/mods/bond-settings/main.js +1216 -272
- package/app/mods/bond-settings/mod.json +1 -1
- 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 +4 -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 +85 -29
- 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 +16 -2
- package/runner/SPIKE-BOND.md +6 -2
- package/runner/entrypoint.sh +16 -0
- package/runner/setup.sh +439 -8
- package/runner/versions.env +32 -1
- package/scripts/app-install.ts +322 -27
- package/src/cli.ts +562 -21
- package/src/config.ts +15 -3
- package/src/core/agy-login.ts +683 -0
- package/src/core/delivery.ts +125 -6
- package/src/core/doctor.ts +748 -0
- package/src/core/hub-session.ts +108 -91
- package/src/core/hub.ts +40 -8
- package/src/core/orchestrator.ts +1481 -187
- package/src/core/paths.ts +107 -0
- package/src/core/permissions.ts +143 -0
- package/src/core/pr-source.ts +147 -0
- package/src/core/repo-host.ts +60 -0
- package/src/core/service-windows.ts +180 -0
- package/src/core/service.ts +861 -0
- package/src/core/setup-install.ts +1380 -0
- package/src/core/setup.ts +62 -1
- package/src/core/watchdog.ts +6 -6
- package/src/db/database.ts +54 -7
- package/src/db/settings-repo.ts +332 -7
- package/src/db/ticket-repo.ts +73 -25
- package/src/index.ts +4 -4
- package/src/runner/azure-devops-client.ts +273 -0
- package/src/runner/docker-client.ts +93 -9
- package/src/runner/github-client.ts +148 -3
- package/src/runner/hc-client.ts +33 -5
- package/src/runner/image-builder.ts +123 -5
- package/src/runner/jira-client.ts +368 -0
- package/src/runner/tool-catalog.ts +84 -0
- package/src/server/app.ts +467 -8
- package/src/types.ts +140 -2
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
// bond-agents: the bond layout's right-hand Agents panel (P7 Ampliación / criterion 8).
|
|
2
2
|
// Shows per run what the live table showed: agents, repo, state, commits, files,
|
|
3
3
|
// fetched from GET /api/v1/runs/:id/team-status within the container.
|
|
4
|
-
import { View, div } from "gpui-kit";
|
|
4
|
+
import { View, div, svg, image } from "gpui-kit";
|
|
5
5
|
import { v_flex, h_flex } from "gpui-base";
|
|
6
|
-
import { theme, run, shared } from "herdr";
|
|
6
|
+
import { theme, run, shared, setShared, panes, spaces, terminals } from "herdr";
|
|
7
7
|
import { api } from "./api.js";
|
|
8
8
|
import { UI, stateColor } from "./brand.js";
|
|
9
|
-
import { POLL_MS, SELECTED_RUN_KEY, SELECTED_TICKET_KEY, REFRESH_KEY, LIVE_STATES, buildAgentsSections } from "./model.js";
|
|
9
|
+
import { POLL_MS, SELECTED_RUN_KEY, SELECTED_TICKET_KEY, REFRESH_KEY, LIVE_STATES, buildAgentsSections, isAgentTerminal, runAgentAddrs, HIDDEN_KEY, INIT_TAB, agentIcon, isLeaderRow, rowName, rowRole, rowStats, attentionOf, machineOf, runMachine, readHidden, pruneHidden, planTabs, planPanels, panelBuildSteps, initTabToClose } from "./model.js";
|
|
10
|
+
|
|
11
|
+
// Per-run view mode, shared: { runId: true } for PANELES (E2: one tab of the run's space
|
|
12
|
+
// split in up to MAX_PANELS agents); absent is PESTAÑAS (one tab per agent). The layout
|
|
13
|
+
// file is never rewritten: both modes are native spaces, tabs and splits.
|
|
14
|
+
const PANELS_KEY = "bond.agents.panels";
|
|
15
|
+
|
|
16
|
+
/** A run's state in the board's words (the session header and the cards say the same). */
|
|
17
|
+
const RUN_STATE_ES = {
|
|
18
|
+
ready: "LISTO", queued: "EN COLA", analyzing: "ANALIZANDO", running: "EN CURSO", verifying: "VERIFICANDO",
|
|
19
|
+
waiting: "EN ESPERA", blocked: "EN ESPERA", finished: "TERMINADO", pr_ready: "PR LISTA", failed: "ERROR", error: "ERROR",
|
|
20
|
+
};
|
|
10
21
|
|
|
11
22
|
export default class BondAgents extends View {
|
|
12
23
|
init(_props, cx) {
|
|
13
24
|
this.runs = [];
|
|
14
25
|
this.tickets = [];
|
|
15
26
|
this.teamStatusByRun = {};
|
|
27
|
+
this.terminalsByRun = {};
|
|
16
28
|
this.loadError = null;
|
|
17
29
|
this.selectedRunId = shared(SELECTED_RUN_KEY) ?? null;
|
|
18
30
|
this.selectedTicketId = shared(SELECTED_TICKET_KEY) ?? null;
|
|
@@ -52,24 +64,35 @@ export default class BondAgents extends View {
|
|
|
52
64
|
this.tickets = tickets ?? [];
|
|
53
65
|
this.loadError = null;
|
|
54
66
|
|
|
55
|
-
// Fetch team status only for the selected run
|
|
67
|
+
// Fetch team status and terminals only for the selected run
|
|
56
68
|
const statusMap = {};
|
|
69
|
+
const terminalsMap = {};
|
|
57
70
|
const targetRun = this.selectedRunId
|
|
58
71
|
? this.runs.find((r) => r.id === this.selectedRunId)
|
|
59
72
|
: (this.selectedTicketId ? this.runs.find((r) => r.ticket_id === this.selectedTicketId) : null);
|
|
60
73
|
|
|
61
74
|
if (targetRun) {
|
|
62
75
|
try {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
const [statusRes, termRes] = await Promise.allSettled([
|
|
77
|
+
api(`/runs/${targetRun.id}/team-status`),
|
|
78
|
+
api(`/runs/${targetRun.id}/terminals`),
|
|
79
|
+
]);
|
|
80
|
+
if (statusRes.status === "fulfilled" && Array.isArray(statusRes.value)) {
|
|
81
|
+
statusMap[targetRun.id] = statusRes.value;
|
|
82
|
+
}
|
|
83
|
+
if (termRes.status === "fulfilled" && Array.isArray(termRes.value)) {
|
|
84
|
+
terminalsMap[targetRun.id] = termRes.value;
|
|
66
85
|
}
|
|
67
86
|
} catch {
|
|
68
|
-
// Graceful fallback if
|
|
87
|
+
// Graceful fallback if endpoints are unavailable
|
|
69
88
|
}
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
this.teamStatusByRun = statusMap;
|
|
92
|
+
this.terminalsByRun = terminalsMap;
|
|
93
|
+
|
|
94
|
+
// C1: Reconcile view mode idempotently on EVERY refresh
|
|
95
|
+
await this.reconcileView();
|
|
73
96
|
} catch (e) {
|
|
74
97
|
this.loadError = String(e?.message ?? e);
|
|
75
98
|
}
|
|
@@ -77,327 +100,290 @@ export default class BondAgents extends View {
|
|
|
77
100
|
});
|
|
78
101
|
}
|
|
79
102
|
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
isRunLive(run) {
|
|
104
|
+
if (!run || typeof run !== "object") return false;
|
|
105
|
+
const state = String(run.state || "").toLowerCase();
|
|
106
|
+
return ["running", "waiting", "verifying", "blocked", "analyzing"].includes(state);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
selectedRun() {
|
|
110
|
+
return this.selectedRunId
|
|
111
|
+
? this.runs.find((r) => r.id === this.selectedRunId)
|
|
112
|
+
: (this.selectedTicketId ? this.runs.find((r) => r.ticket_id === this.selectedTicketId) : null);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
runTitle(run) {
|
|
116
|
+
const ticket = this.tickets.find((t) => t.id === run?.ticket_id);
|
|
117
|
+
return String(ticket?.title || run?.id || "run");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** E4: the hidden list, with the dead terminals of `machine` forgotten (saved if it changed). */
|
|
121
|
+
syncHidden(machine, liveAddrs) {
|
|
122
|
+
const current = shared(HIDDEN_KEY);
|
|
123
|
+
const next = pruneHidden(readHidden(current), machine, liveAddrs);
|
|
124
|
+
if (JSON.stringify([...readHidden(current)].sort()) !== JSON.stringify(next)) setShared(HIDDEN_KEY, next);
|
|
125
|
+
return new Set(next);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setHidden(addr, hide) {
|
|
129
|
+
const set = readHidden(shared(HIDDEN_KEY));
|
|
130
|
+
if (hide === set.has(addr)) return;
|
|
131
|
+
if (hide) set.add(addr);
|
|
132
|
+
else set.delete(addr);
|
|
133
|
+
setShared(HIDDEN_KEY, [...set].sort());
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** E1: show the run's space (its machine's), making it when missing. space.new brings a
|
|
137
|
+
* shell in an INIT_TAB tab that the reconciler closes once the orchestrator has its own. */
|
|
138
|
+
showRunSpace(machine, title) {
|
|
139
|
+
if (!machine) return;
|
|
140
|
+
const sp = (spaces() ?? []).find((s) => s.machine === machine);
|
|
141
|
+
if (sp) {
|
|
142
|
+
if (!sp.active) run("space.select", { id: sp.id });
|
|
143
|
+
} else {
|
|
144
|
+
run("space.new", { machine, name: title, tab: INIT_TAB });
|
|
85
145
|
}
|
|
86
146
|
}
|
|
87
147
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
148
|
+
/**
|
|
149
|
+
* One reconciler, run on every refresh (C1, E3): the desired view (the run's live agents,
|
|
150
|
+
* its mode, the hidden list) against what really shows (panes() of the run's machine).
|
|
151
|
+
*/
|
|
152
|
+
async reconcileView() {
|
|
153
|
+
try {
|
|
154
|
+
const targetRun = this.selectedRun();
|
|
155
|
+
// The selected run's terminals are known only if /terminals answered this refresh.
|
|
156
|
+
const termsKnown = Boolean(targetRun && Array.isArray(this.terminalsByRun[targetRun.id]));
|
|
157
|
+
if (!targetRun || !this.isRunLive(targetRun)) return;
|
|
158
|
+
// /terminals failed this refresh: leave tabs and layout as they are (no churn).
|
|
159
|
+
if (!termsKnown) return;
|
|
100
160
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
.child(
|
|
152
|
-
div()
|
|
153
|
-
.px(4)
|
|
154
|
-
.py(0.5)
|
|
155
|
-
.rounded(4)
|
|
156
|
-
.bg(t.raised)
|
|
157
|
-
.border_1()
|
|
158
|
-
.border_color(t.border)
|
|
159
|
-
.text_size(UI.text.tiny)
|
|
160
|
-
.font_family("JetBrains Mono")
|
|
161
|
-
.text_color(isLeader ? (t.bond_indigo ?? t.accent) : t.dim)
|
|
162
|
-
.child(roleTag)
|
|
163
|
-
)
|
|
164
|
-
)
|
|
165
|
-
.child(
|
|
166
|
-
div()
|
|
167
|
-
.text_size(UI.text.tiny)
|
|
168
|
-
.font_family("JetBrains Mono")
|
|
169
|
-
.text_color(t.muted)
|
|
170
|
-
.truncate()
|
|
171
|
-
.child(repoLabel)
|
|
172
|
-
)
|
|
173
|
-
)
|
|
174
|
-
)
|
|
175
|
-
.child(
|
|
176
|
-
h_flex()
|
|
177
|
-
.gap(3)
|
|
178
|
-
.items_center()
|
|
179
|
-
.px(5)
|
|
180
|
-
.py(1)
|
|
181
|
-
.rounded(UI.radius)
|
|
182
|
-
.bg(t.raised)
|
|
183
|
-
.border_1()
|
|
184
|
-
.border_color(t.border)
|
|
185
|
-
.text_size(UI.text.tiny)
|
|
186
|
-
.font_family("JetBrains Mono")
|
|
187
|
-
.text_color(toneColor)
|
|
188
|
-
.child(icon)
|
|
189
|
-
.child(label)
|
|
190
|
-
)
|
|
191
|
-
)
|
|
192
|
-
// Stats box
|
|
193
|
-
.child(
|
|
194
|
-
v_flex()
|
|
195
|
-
.p(6)
|
|
196
|
-
.rounded(UI.radius)
|
|
197
|
-
.bg(t.raised)
|
|
198
|
-
.border_1()
|
|
199
|
-
.border_color(t.border)
|
|
200
|
-
.gap(2)
|
|
201
|
-
.font_family("JetBrains Mono")
|
|
202
|
-
.text_size(UI.text.tiny)
|
|
203
|
-
.text_color(t.dim)
|
|
204
|
-
.child(
|
|
205
|
-
h_flex()
|
|
206
|
-
.items_center()
|
|
207
|
-
.justify_between()
|
|
208
|
-
.child(div().child("Git Worktree:"))
|
|
209
|
-
.child(div().font_semibold().text_color(t.working).child(`${ahead} commits · ${files} ficheros`))
|
|
210
|
-
)
|
|
211
|
-
.when(Boolean(row.branch), (el) =>
|
|
212
|
-
el.child(
|
|
213
|
-
h_flex()
|
|
214
|
-
.items_center()
|
|
215
|
-
.justify_between()
|
|
216
|
-
.child(div().child("Rama:"))
|
|
217
|
-
.child(div().text_color(t.muted).truncate().child(String(row.branch)))
|
|
218
|
-
)
|
|
219
|
-
)
|
|
220
|
-
)
|
|
221
|
-
// Question block if waiting
|
|
222
|
-
.when(Boolean(row.question), (el) => {
|
|
223
|
-
const qText = typeof row.question === "object"
|
|
224
|
-
? String(row.question.text ?? JSON.stringify(row.question))
|
|
225
|
-
: String(row.question);
|
|
226
|
-
return el.child(
|
|
227
|
-
v_flex()
|
|
228
|
-
.w_full()
|
|
229
|
-
.p(6)
|
|
230
|
-
.rounded(UI.radius)
|
|
231
|
-
.bg(t.popover)
|
|
232
|
-
.border_1()
|
|
233
|
-
.border_color(t.bond_waiting ?? t.blocked)
|
|
234
|
-
.gap(2)
|
|
235
|
-
.font_family("JetBrains Mono")
|
|
236
|
-
.child(
|
|
237
|
-
div()
|
|
238
|
-
.text_size(UI.text.tiny)
|
|
239
|
-
.font_semibold()
|
|
240
|
-
.text_color(t.bond_waiting ?? t.blocked)
|
|
241
|
-
.child("Esperando respuesta:")
|
|
242
|
-
)
|
|
243
|
-
.child(
|
|
244
|
-
div()
|
|
245
|
-
.text_size(UI.text.small)
|
|
246
|
-
.text_color(t.foreground)
|
|
247
|
-
.child(qText)
|
|
248
|
-
)
|
|
249
|
-
);
|
|
250
|
-
})
|
|
251
|
-
// Action: focus agent terminal
|
|
252
|
-
.when(Boolean(row.pane), (el) =>
|
|
253
|
-
el.child(
|
|
254
|
-
h_flex()
|
|
255
|
-
.justify_end()
|
|
256
|
-
.pt(1)
|
|
257
|
-
.child(
|
|
258
|
-
div()
|
|
259
|
-
.text_size(UI.text.tiny)
|
|
260
|
-
.font_family("JetBrains Mono")
|
|
261
|
-
.text_color(t.accent)
|
|
262
|
-
.cursor_pointer()
|
|
263
|
-
.hover((s) => s.text_color(t.foreground))
|
|
264
|
-
.on_click(() => this.focusAgent(row))
|
|
265
|
-
.child("Sincronizar Terminal >")
|
|
266
|
-
)
|
|
267
|
-
)
|
|
268
|
-
);
|
|
161
|
+
const liveTerms = this.terminalsByRun[targetRun.id].filter((t) => {
|
|
162
|
+
if (t.exit_code !== null && t.exit_code !== undefined) return false;
|
|
163
|
+
if (t.state && t.state !== "live") return false;
|
|
164
|
+
return true;
|
|
165
|
+
});
|
|
166
|
+
// C7: only coding agents are shown as tabs or blocks; dev servers/shells are not.
|
|
167
|
+
const agentAddrs = runAgentAddrs(liveTerms);
|
|
168
|
+
const machine = runMachine(targetRun);
|
|
169
|
+
const space = (spaces() ?? []).find((s) => s.machine === machine) ?? null;
|
|
170
|
+
if (!space) {
|
|
171
|
+
// The run is selected but its space is gone (closed, or emptied): make it again.
|
|
172
|
+
this.showRunSpace(machine, this.runTitle(targetRun));
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const paneList = (panes() ?? []).filter((p) => p?.terminal && machineOf(p.terminal) === machine);
|
|
176
|
+
const hidden = this.syncHidden(machine, liveTerms.map((t) => t.address));
|
|
177
|
+
|
|
178
|
+
const canKeep = Boolean(space?.active);
|
|
179
|
+
const park = (list) => {
|
|
180
|
+
for (const addr of list) {
|
|
181
|
+
try {
|
|
182
|
+
run("terminal.park", { terminal: addr });
|
|
183
|
+
} catch {}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
if (this.isPanels(targetRun.id)) {
|
|
187
|
+
// PANELES (E2): rebuilt in two passes (park now, build on a pass where none shows).
|
|
188
|
+
const plan = planPanels({ machine, agentAddrs, paneList, hidden, canKeep });
|
|
189
|
+
park(plan.park);
|
|
190
|
+
for (const [cmd, args] of panelBuildSteps(plan.build, plan.baseShown)) {
|
|
191
|
+
try {
|
|
192
|
+
run(cmd, args);
|
|
193
|
+
} catch {}
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
const plan = planTabs({ machine, agentAddrs, paneList, hidden, canKeep });
|
|
197
|
+
park(plan.park);
|
|
198
|
+
for (const addr of plan.keep) {
|
|
199
|
+
try {
|
|
200
|
+
run("terminal.keep", { terminal: addr, place: "tab" });
|
|
201
|
+
} catch {}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const init = initTabToClose(space, panes() ?? [], machine, agentAddrs, agentAddrs[0] ?? null);
|
|
205
|
+
if (init) {
|
|
206
|
+
try {
|
|
207
|
+
run("tab.close", { id: init });
|
|
208
|
+
} catch {}
|
|
209
|
+
}
|
|
210
|
+
} catch {}
|
|
269
211
|
}
|
|
270
212
|
|
|
213
|
+
/** «Sincronizar Terminal»: un-hide the agent and bring it to the front, giving it a tab
|
|
214
|
+
* in its run's space when it has no pane (E4) — in PANELES too, for an agent beyond the
|
|
215
|
+
* grid; a hidden one of the grid goes back to it on the next rebuild. terminal.keep only
|
|
216
|
+
* lands in the shown space of its own machine, so that space is shown first. */
|
|
217
|
+
focusAgent(row) {
|
|
218
|
+
if (!row.pane) return;
|
|
219
|
+
const addr = String(row.pane);
|
|
220
|
+
try {
|
|
221
|
+
if (!addr.includes("/")) {
|
|
222
|
+
run("pane.focus", { pane: addr });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
this.setHidden(addr, false);
|
|
226
|
+
const hasPane = (panes() ?? []).some((p) => p?.terminal === addr);
|
|
227
|
+
if (!hasPane) {
|
|
228
|
+
this.showRunSpace(machineOf(addr), this.runTitle(this.selectedRun()));
|
|
229
|
+
run("terminal.keep", { terminal: addr, place: "tab" });
|
|
230
|
+
}
|
|
231
|
+
run("pane.focus", { terminal: addr });
|
|
232
|
+
} catch {}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** «Ocultar» (E4): the pane goes, the agent keeps running; back only with «Sincronizar». */
|
|
236
|
+
hideAgent(row) {
|
|
237
|
+
const addr = String(row?.pane ?? "");
|
|
238
|
+
if (!addr.includes("/")) return;
|
|
239
|
+
this.setHidden(addr, true);
|
|
240
|
+
try {
|
|
241
|
+
run("terminal.park", { terminal: addr });
|
|
242
|
+
} catch {}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
panelModes() {
|
|
246
|
+
const m = shared(PANELS_KEY);
|
|
247
|
+
return m && typeof m === "object" ? m : {};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
isPanels(runId) {
|
|
251
|
+
return Boolean(runId && this.panelModes()[runId]);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** PESTAÑAS <-> PANELES for one run; other runs keep their mode. */
|
|
255
|
+
togglePanels(runId) {
|
|
256
|
+
if (!runId) return;
|
|
257
|
+
const modes = { ...this.panelModes() };
|
|
258
|
+
if (modes[runId]) delete modes[runId];
|
|
259
|
+
else modes[runId] = true;
|
|
260
|
+
setShared(PANELS_KEY, modes);
|
|
261
|
+
this.reconcileView();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** One agent as a list row (lista compacta, 2026-11-23): its icon, name, state with a fixed
|
|
265
|
+
* width (never past the edge), «program · role», stats only when there are some. Click:
|
|
266
|
+
* its terminal; the eye button hides it (or shows it again when hidden). */
|
|
267
|
+
agentRow(row, t, hidden = false) {
|
|
268
|
+
const name = rowName(row);
|
|
269
|
+
const leader = isLeaderRow(row);
|
|
270
|
+
const slug = String(row.pane ?? name).replace(/[^a-zA-Z0-9]/g, "_");
|
|
271
|
+
let program = null;
|
|
272
|
+
try {
|
|
273
|
+
program = row.pane ? (terminals() ?? []).find((x) => x.address === row.pane)?.program ?? null : null;
|
|
274
|
+
} catch {}
|
|
275
|
+
const pic = agentIcon(program, row.agent?.kind || row.agentName);
|
|
276
|
+
// «en espera» in the waiting yellow (its style tone is the red `blocked`); the rest as styled.
|
|
277
|
+
const tone = row.style?.label === "En espera" ? stateColor(t, "waiting") : (t[row.style?.tone] ?? t.dim);
|
|
278
|
+
const stateLabel = String(row.style?.label ?? "—").toLowerCase();
|
|
279
|
+
const stats = rowStats(row);
|
|
280
|
+
const remote = String(row.pane ?? "").includes("/");
|
|
281
|
+
const mono = (el) => el.font_family("JetBrains Mono");
|
|
282
|
+
|
|
283
|
+
const avatar = div().size(26).flex_none().rounded(UI.radius).bg(t.raised).border_1()
|
|
284
|
+
.border_color(leader ? (t.bond_indigo ?? t.accent) : t.border)
|
|
285
|
+
.flex().items_center().justify_center()
|
|
286
|
+
.child(pic
|
|
287
|
+
? (pic.tint ? svg(pic.icon).size(15).text_color(t.foreground) : image(pic.icon).w(15).h(15))
|
|
288
|
+
: mono(div().text_size(UI.text.tiny).font_semibold().text_color(t.muted)).child(leader ? "👑" : name.slice(0, 2).toUpperCase()));
|
|
289
|
+
|
|
290
|
+
return h_flex().id(`agent-row-${name}-${slug}`).w_full().min_w(0).items_start().gap(8).px(6).py(6)
|
|
291
|
+
.rounded(UI.radius).cursor_pointer().hover((st) => st.bg(t.hover))
|
|
292
|
+
.when(hidden, (el) => el.opacity(0.6))
|
|
293
|
+
.on_click(() => this.focusAgent(row))
|
|
294
|
+
.child(avatar)
|
|
295
|
+
.child(v_flex().flex_1().min_w(0).gap(1)
|
|
296
|
+
.child(h_flex().w_full().min_w(0).items_center().gap(6)
|
|
297
|
+
.child(mono(div().flex_1().min_w(0).truncate().text_size(UI.text.body).font_semibold().text_color(t.foreground)).child(name))
|
|
298
|
+
.child(mono(h_flex().flex_none().items_center().gap(4).text_size(UI.text.tiny).text_color(tone))
|
|
299
|
+
.child(div().size(6).flex_none().rounded(3).bg(tone))
|
|
300
|
+
.child(div().max_w(76).truncate().child(stateLabel))))
|
|
301
|
+
.child(mono(div().w_full().truncate().text_size(UI.text.tiny).text_color(t.dim)).child(rowRole(row)))
|
|
302
|
+
.when(Boolean(stats), (el) => el.child(mono(div().w_full().truncate().text_size(UI.text.tiny).text_color(t.muted)).child(stats))))
|
|
303
|
+
.when(remote, (el) => el.child(
|
|
304
|
+
div().id(`agent-${hidden ? "show" : "hide"}-${slug}`).flex_none().p(3).rounded(4).text_color(t.dim)
|
|
305
|
+
.hover((st) => st.bg(t.raised).text_color(t.foreground))
|
|
306
|
+
.tooltip(hidden ? "Mostrar (vuelve a su pestaña)" : "Ocultar (el agente sigue vivo)")
|
|
307
|
+
.on_click((_e, cx) => {
|
|
308
|
+
cx.stop_propagation();
|
|
309
|
+
if (hidden) this.focusAgent(row);
|
|
310
|
+
else this.hideAgent(row);
|
|
311
|
+
})
|
|
312
|
+
.child(svg(`mods/bond-agents/${hidden ? "eye" : "eye-off"}.svg`).size(14))));
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** The run: title (two lines at most), branch and state, the PESTAÑAS | PANELES switch,
|
|
316
|
+
* one attention notice when an agent waits for the person, then the agents and the
|
|
317
|
+
* hidden ones apart. */
|
|
271
318
|
renderSection(s, t) {
|
|
272
|
-
const
|
|
273
|
-
const
|
|
319
|
+
const color = stateColor(t, s.state) ?? t.foreground;
|
|
320
|
+
const waitColor = stateColor(t, "waiting");
|
|
274
321
|
const title = String(s.title ?? s.run?.id ?? s.ticket?.id ?? "Run");
|
|
275
|
-
const stateText = String(s.state ?? "").toUpperCase();
|
|
322
|
+
const stateText = RUN_STATE_ES[s.state] ?? String(s.state ?? "").toUpperCase();
|
|
323
|
+
const hiddenSet = readHidden(shared(HIDDEN_KEY));
|
|
324
|
+
const isHidden = (r) => String(r.pane ?? "").includes("/") && hiddenSet.has(String(r.pane));
|
|
325
|
+
const shown = s.rows.filter((r) => !isHidden(r));
|
|
326
|
+
const hiddenRows = s.rows.filter(isHidden);
|
|
327
|
+
const att = attentionOf(shown, s.state === "waiting" ? s.run?.failure_reason : null);
|
|
328
|
+
const panels = Boolean(s.run && this.isPanels(s.run.id));
|
|
329
|
+
const mono = (el) => el.font_family("JetBrains Mono");
|
|
330
|
+
const divider = () => div().w_full().h(1).bg(t.border);
|
|
276
331
|
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
.
|
|
280
|
-
.
|
|
281
|
-
.
|
|
282
|
-
.
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
.
|
|
293
|
-
.child(
|
|
294
|
-
div()
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
)
|
|
303
|
-
.child(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
.font_family("JetBrains Mono")
|
|
313
|
-
.font_semibold()
|
|
314
|
-
.text_color(color)
|
|
315
|
-
.child(stateText)
|
|
316
|
-
)
|
|
317
|
-
)
|
|
318
|
-
.when(Boolean(s.run?.failure_reason), (el) =>
|
|
319
|
-
el.child(
|
|
320
|
-
h_flex()
|
|
321
|
-
.p(6)
|
|
322
|
-
.rounded(UI.radius)
|
|
323
|
-
.bg(t.popover)
|
|
324
|
-
.border_1()
|
|
325
|
-
.border_color(t.border)
|
|
326
|
-
.gap(4)
|
|
327
|
-
.items_center()
|
|
328
|
-
.font_family("JetBrains Mono")
|
|
329
|
-
.text_size(UI.text.small)
|
|
330
|
-
.child(div().font_semibold().text_color(t.bond_waiting ?? t.blocked).flex_none().child("motivo:"))
|
|
331
|
-
.child(div().text_color(t.foreground).truncate().child(String(s.run.failure_reason)))
|
|
332
|
-
)
|
|
333
|
-
)
|
|
332
|
+
const seg = (id, label, on) => mono(div().id(id).flex_1().py(3).rounded(UI.radius).flex().justify_center()
|
|
333
|
+
.text_size(UI.text.tiny).font_semibold().cursor_pointer()
|
|
334
|
+
.bg(on ? t.surface : t.raised).text_color(on ? t.foreground : t.dim)
|
|
335
|
+
.border_1().border_color(on ? t.border : t.raised)
|
|
336
|
+
.hover((st) => st.text_color(t.foreground))
|
|
337
|
+
.on_click(() => {
|
|
338
|
+
if (!on && s.run) this.togglePanels(s.run.id);
|
|
339
|
+
}))
|
|
340
|
+
.child(label);
|
|
341
|
+
|
|
342
|
+
return v_flex().id(`agents-section-${s.run?.id ?? s.ticket?.id ?? "run"}`).w_full().min_w(0).gap(8)
|
|
343
|
+
// Run header: the title and branch are in the session header beside it; here only the
|
|
344
|
+
// run's state (its title as tooltip) and the PESTAÑAS | PANELES switch.
|
|
345
|
+
.child(v_flex().w_full().min_w(0).gap(5)
|
|
346
|
+
.child(h_flex().id("agents-run-state").w_full().min_w(0).items_center().gap(6).tooltip(title)
|
|
347
|
+
.child(mono(div().flex_1().min_w(0).truncate().text_size(UI.text.tiny).text_color(t.dim)).child("Run"))
|
|
348
|
+
.child(mono(h_flex().flex_none().items_center().gap(4).text_size(UI.text.tiny).font_semibold().text_color(color))
|
|
349
|
+
.child(div().size(6).rounded(3).bg(color))
|
|
350
|
+
.child(stateText)))
|
|
351
|
+
.when(Boolean(s.run), (el) => el.child(h_flex().w_full().p(2).gap(2).rounded(UI.radius).bg(t.raised).border_1().border_color(t.border)
|
|
352
|
+
.child(seg("agents-mode-tabs", "Pestañas", !panels))
|
|
353
|
+
.child(seg("agents-mode-panels", "Paneles", panels)))))
|
|
354
|
+
// One attention notice
|
|
355
|
+
.when(Boolean(att), (el) => el.child(v_flex().w_full().p(8).gap(4).rounded(UI.radius).bg(t.popover).border_1().border_color(waitColor)
|
|
356
|
+
.child(h_flex().items_center().gap(6)
|
|
357
|
+
.child(div().size(7).rounded(4).flex_none().bg(waitColor))
|
|
358
|
+
.child(div().flex_1().min_w(0).truncate().text_size(UI.text.small).font_semibold().font_family(UI.fontSans).text_color(waitColor).child(`${att.name} te necesita`)))
|
|
359
|
+
.when(Boolean(att.text), (sub) => sub.child(div().text_size(UI.text.small).font_family(UI.fontSans).text_color(t.foreground).child(`«${att.text}»`)))
|
|
360
|
+
.when(Boolean(att.row?.pane), (sub) => sub.child(h_flex().justify_end()
|
|
361
|
+
.child(mono(div().id("agents-answer").text_size(UI.text.tiny).font_semibold().text_color(t.accent).cursor_pointer()
|
|
362
|
+
.hover((st) => st.text_color(t.foreground)).on_click(() => this.focusAgent(att.row))).child("Responder →"))))))
|
|
363
|
+
// Why it failed, when nobody is waiting (a waiting run says it in the notice)
|
|
364
|
+
.when(!att && Boolean(s.run?.failure_reason), (el) => el.child(h_flex().w_full().min_w(0).gap(4).items_center()
|
|
365
|
+
.child(mono(div().flex_none().text_size(UI.text.tiny).font_semibold().text_color(color)).child("motivo:"))
|
|
366
|
+
.child(mono(div().flex_1().min_w(0).truncate().text_size(UI.text.tiny).text_color(t.foreground)).child(String(s.run.failure_reason)))))
|
|
334
367
|
.when(Boolean(s.run?.hub_analysis || s.ticket?.analysis), (el) => {
|
|
335
368
|
const a = s.run?.hub_analysis || s.ticket?.analysis;
|
|
336
369
|
const gaps = Array.isArray(a?.gaps) ? a.gaps : [];
|
|
337
370
|
const fixable = gaps.filter((g) => g?.fix || g?.fixable).length;
|
|
338
371
|
const isReady = a?.status === "ready";
|
|
339
|
-
return el.child(
|
|
340
|
-
|
|
341
|
-
.
|
|
342
|
-
.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
.gap(4)
|
|
347
|
-
.font_family("JetBrains Mono")
|
|
348
|
-
.text_size(UI.text.small)
|
|
349
|
-
.child(
|
|
350
|
-
h_flex()
|
|
351
|
-
.items_center()
|
|
352
|
-
.gap(4)
|
|
353
|
-
.child(div().font_semibold().text_color(t.dim).child("bond hub check:"))
|
|
354
|
-
.child(
|
|
355
|
-
div()
|
|
356
|
-
.font_semibold()
|
|
357
|
-
.text_color(isReady ? t.working : t.blocked)
|
|
358
|
-
.child(isReady ? "análisis: listo" : `${gaps.length} ${gaps.length === 1 ? "hueco" : "huecos"} (${fixable} con arreglo)`)
|
|
359
|
-
)
|
|
360
|
-
)
|
|
361
|
-
.when(gaps.length > 0, (sub) =>
|
|
362
|
-
sub.children(
|
|
363
|
-
gaps.map((g) =>
|
|
364
|
-
div()
|
|
365
|
-
.text_size(UI.text.tiny)
|
|
366
|
-
.font_family("JetBrains Mono")
|
|
367
|
-
.text_color(t.dim)
|
|
368
|
-
.child(String(`· ${g?.message || g?.id || "hueco detectado"}${g?.fix || g?.fixable ? " (se arregla solo)" : ""}`))
|
|
369
|
-
)
|
|
370
|
-
)
|
|
371
|
-
)
|
|
372
|
-
.when(Boolean(a?.summary), (sub) =>
|
|
373
|
-
sub.child(
|
|
374
|
-
div()
|
|
375
|
-
.text_size(UI.text.tiny)
|
|
376
|
-
.font_family("JetBrains Mono")
|
|
377
|
-
.text_color(t.dim)
|
|
378
|
-
.child(String(`agente de hub: ${a.summary}`))
|
|
379
|
-
)
|
|
380
|
-
)
|
|
381
|
-
);
|
|
372
|
+
return el.child(mono(v_flex().w_full().p(8).gap(3).rounded(UI.radius).bg(t.popover).border_1().border_color(t.border).text_size(UI.text.tiny))
|
|
373
|
+
.child(h_flex().gap(4).items_center()
|
|
374
|
+
.child(div().font_semibold().text_color(t.dim).child("bond hub check:"))
|
|
375
|
+
.child(div().font_semibold().text_color(isReady ? t.working : t.blocked)
|
|
376
|
+
.child(isReady ? "análisis: listo" : `${gaps.length} ${gaps.length === 1 ? "hueco" : "huecos"} (${fixable} con arreglo)`)))
|
|
377
|
+
.children(gaps.map((g) => div().text_color(t.dim).child(String(`· ${g?.message || g?.id || "hueco detectado"}${g?.fix || g?.fixable ? " (se arregla solo)" : ""}`))))
|
|
378
|
+
.when(Boolean(a?.summary), (sub) => sub.child(div().text_color(t.dim).child(String(`agente de hub: ${a.summary}`)))));
|
|
382
379
|
})
|
|
383
|
-
.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
.child("Sin equipo de agentes activo")
|
|
391
|
-
)
|
|
392
|
-
)
|
|
393
|
-
.when(s.rows.length > 0, (el) =>
|
|
394
|
-
el.child(
|
|
395
|
-
v_flex()
|
|
396
|
-
.w_full()
|
|
397
|
-
.gap(6)
|
|
398
|
-
.children(s.rows.map((r) => this.agentRow(r, t)))
|
|
399
|
-
)
|
|
400
|
-
);
|
|
380
|
+
.child(divider())
|
|
381
|
+
.when(s.rows.length === 0, (el) => el.child(mono(div().p(6).text_size(UI.text.small).text_color(t.dim)).child("Sin equipo de agentes activo")))
|
|
382
|
+
.when(shown.length > 0, (el) => el.child(v_flex().w_full().gap(2).children(shown.map((r) => this.agentRow(r, t, false)))))
|
|
383
|
+
.when(hiddenRows.length > 0, (el) => el
|
|
384
|
+
.child(divider())
|
|
385
|
+
.child(mono(div().px(6).text_size(UI.text.tiny).font_semibold().text_color(t.dim)).child(`Ocultos (${hiddenRows.length})`))
|
|
386
|
+
.child(v_flex().w_full().gap(2).children(hiddenRows.map((r) => this.agentRow(r, t, true)))));
|
|
401
387
|
}
|
|
402
388
|
|
|
403
389
|
render() {
|
|
@@ -408,7 +394,8 @@ export default class BondAgents extends View {
|
|
|
408
394
|
this.tickets,
|
|
409
395
|
this.selectedRunId,
|
|
410
396
|
this.teamStatusByRun,
|
|
411
|
-
this.selectedTicketId
|
|
397
|
+
this.selectedTicketId,
|
|
398
|
+
this.terminalsByRun
|
|
412
399
|
);
|
|
413
400
|
const hasRun = Boolean(sections[0]?.run);
|
|
414
401
|
const activeCount = sections[0]?.rows?.length ?? 0;
|
|
@@ -431,18 +418,12 @@ export default class BondAgents extends View {
|
|
|
431
418
|
.justify_between()
|
|
432
419
|
.p(2)
|
|
433
420
|
.child(
|
|
434
|
-
|
|
435
|
-
.
|
|
436
|
-
.
|
|
437
|
-
.
|
|
438
|
-
.
|
|
439
|
-
|
|
440
|
-
.text_size(UI.text.title)
|
|
441
|
-
.font_bold()
|
|
442
|
-
.font_family(UI.fontSans)
|
|
443
|
-
.text_color(t.foreground)
|
|
444
|
-
.child("AGENTES")
|
|
445
|
-
)
|
|
421
|
+
div()
|
|
422
|
+
.text_size(UI.text.small)
|
|
423
|
+
.font_semibold()
|
|
424
|
+
.font_family(UI.fontSans)
|
|
425
|
+
.text_color(t.muted)
|
|
426
|
+
.child("AGENTES")
|
|
446
427
|
)
|
|
447
428
|
.child(
|
|
448
429
|
h_flex()
|