@jmanuelcorral/bond-app 0.1.5 → 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.
Files changed (70) hide show
  1. package/README.md +211 -17
  2. package/app/brand/TOKENS.md +5 -5
  3. package/app/layouts/bond.json +10 -14
  4. package/app/mods/bond-agents/api.js +35 -0
  5. package/app/mods/bond-agents/branch.svg +1 -0
  6. package/app/mods/bond-agents/brand.js +53 -2
  7. package/app/mods/bond-agents/config.js +4 -0
  8. package/app/mods/bond-agents/eye-off.svg +1 -0
  9. package/app/mods/bond-agents/eye.svg +1 -0
  10. package/app/mods/bond-agents/main.js +308 -327
  11. package/app/mods/bond-agents/model.js +354 -5
  12. package/app/mods/bond-board/api.js +35 -0
  13. package/app/mods/bond-board/branch.svg +1 -0
  14. package/app/mods/bond-board/brand.js +53 -2
  15. package/app/mods/bond-board/config.js +4 -0
  16. package/app/mods/bond-board/main.js +686 -444
  17. package/app/mods/bond-board/model.js +99 -25
  18. package/app/mods/bond-pane/close.svg +1 -0
  19. package/app/mods/bond-pane/hide.svg +1 -0
  20. package/app/mods/bond-pane/main.js +103 -0
  21. package/app/mods/bond-pane/mod.json +1 -0
  22. package/app/mods/bond-pane/model.js +18 -0
  23. package/app/mods/bond-pane/split-down.svg +1 -0
  24. package/app/mods/bond-pane/split-right.svg +1 -0
  25. package/app/mods/bond-pane/unzoom.svg +1 -0
  26. package/app/mods/bond-pane/zoom.svg +1 -0
  27. package/app/mods/bond-settings/api.js +35 -0
  28. package/app/mods/bond-settings/brand.js +53 -2
  29. package/app/mods/bond-settings/config.js +4 -0
  30. package/app/mods/bond-settings/main.js +1159 -278
  31. package/app/mods/bond-settings/mod.json +1 -1
  32. package/app/mods/bond-status/api.js +35 -0
  33. package/app/mods/bond-status/brand.js +53 -2
  34. package/app/mods/bond-status/config.js +4 -0
  35. package/app/mods/bond-status/main.js +37 -15
  36. package/app/mods/bond-status/model.js +19 -1
  37. package/app/mods/bond-tabs/brand.js +53 -2
  38. package/app/mods/bond-tabs/main.js +45 -3
  39. package/app/mods/bond-titlebar/brand.js +53 -2
  40. package/app/mods/bond-titlebar/main.js +85 -29
  41. package/app/mods/bond-titlebar/version.js +3 -0
  42. package/app/themes/bond-dark.json +5 -5
  43. package/app/themes/bond-light.json +5 -5
  44. package/package.json +1 -1
  45. package/runner/Dockerfile +16 -2
  46. package/runner/SPIKE-BOND.md +6 -2
  47. package/runner/entrypoint.sh +16 -0
  48. package/runner/setup.sh +439 -8
  49. package/runner/versions.env +32 -1
  50. package/scripts/app-install.ts +60 -1
  51. package/src/cli.ts +53 -3
  52. package/src/core/agy-login.ts +682 -0
  53. package/src/core/delivery.ts +3 -1
  54. package/src/core/orchestrator.ts +736 -78
  55. package/src/core/repo-host.ts +60 -0
  56. package/src/core/setup.ts +62 -1
  57. package/src/core/watchdog.ts +6 -6
  58. package/src/db/database.ts +41 -1
  59. package/src/db/settings-repo.ts +332 -7
  60. package/src/db/ticket-repo.ts +46 -20
  61. package/src/index.ts +4 -4
  62. package/src/runner/azure-devops-client.ts +163 -0
  63. package/src/runner/docker-client.ts +59 -9
  64. package/src/runner/github-client.ts +30 -3
  65. package/src/runner/hc-client.ts +33 -5
  66. package/src/runner/image-builder.ts +123 -5
  67. package/src/runner/jira-client.ts +368 -0
  68. package/src/runner/tool-catalog.ts +84 -0
  69. package/src/server/app.ts +377 -5
  70. package/src/types.ts +129 -2
@@ -3,11 +3,11 @@
3
3
 
4
4
  /** Board columns, in order: label and the ticket statuses each one shows (P7: 5 fixed columns). */
5
5
  export const COLUMNS = [
6
- { id: "ready", label: "Ready", states: ["ready", "queued", "analyzing"] },
7
- { id: "running", label: "Running", states: ["running", "verifying"] },
8
- { id: "waiting", label: "Waiting", states: ["waiting", "blocked"] },
9
- { id: "finished", label: "Finished", states: ["finished", "pr_ready"] },
10
- { id: "error", label: "Error", states: ["failed", "error"] },
6
+ { id: "ready", label: "Listos", states: ["ready", "queued", "analyzing"] },
7
+ { id: "running", label: "En curso", states: ["running", "verifying"] },
8
+ { id: "waiting", label: "En espera", states: ["waiting", "blocked"] },
9
+ { id: "finished", label: "Terminados", states: ["finished", "pr_ready"] },
10
+ { id: "error", label: "Con error", states: ["failed", "error"] },
11
11
  ];
12
12
 
13
13
  /** Run states that hold a container (and an hc session once running). */
@@ -18,8 +18,17 @@ export const POLL_MS = 3000;
18
18
 
19
19
  /** `https://github.com/org/repo(.git)` -> `org/repo`. */
20
20
  export function shortRepo(url) {
21
- const m = /github\.com\/([^/]+\/[^/]+?)(?:\.git)?$/.exec(String(url ?? ""));
22
- return m ? m[1] : String(url ?? "");
21
+ const u = String(url ?? "");
22
+ const m = /github\.com\/([^/]+\/[^/]+?)(?:\.git)?$/.exec(u);
23
+ if (m) return m[1];
24
+ // Azure Repos: «org/project/repo» (dev.azure.com or <org>.visualstudio.com).
25
+ const az = /dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+?)\/?$/.exec(u)
26
+ ?? /\/\/(?:[^@/]+@)?([^./]+)\.visualstudio\.com\/(?:DefaultCollection\/)?([^/]+)\/_git\/([^/]+?)\/?$/.exec(u);
27
+ if (az) {
28
+ const dec = (x) => { try { return decodeURIComponent(x); } catch { return x; } };
29
+ return `${az[1]}/${dec(az[2])}/${dec(az[3]).replace(/\.git$/, "")}`;
30
+ }
31
+ return u;
23
32
  }
24
33
 
25
34
  /**
@@ -225,6 +234,7 @@ export function buildCards(tickets, runs, agentStatus = {}, now = Date.now()) {
225
234
  column: cardColumn(status, run, hcInfo),
226
235
  story: t.story ?? null,
227
236
  issueUrl: t.issue_url ?? null,
237
+ repoUrl: t.repo_url ?? null,
228
238
  run,
229
239
  runState: run?.state ?? null,
230
240
  failureReason: run?.failure_reason ?? null,
@@ -257,6 +267,19 @@ export function buildCards(tickets, runs, agentStatus = {}, now = Date.now()) {
257
267
  });
258
268
  }
259
269
 
270
+ /**
271
+ * The card's issue chip: «VEL-123» for Jira, «#42» for GitHub (with its repo when it is not
272
+ * the ticket's), null without an issue.
273
+ */
274
+ export function issueChip(issueUrl, repoKey = null) {
275
+ const url = String(issueUrl ?? "");
276
+ const jira = /\/browse\/([A-Z][A-Z0-9]+-\d+)/.exec(url);
277
+ if (jira) return { label: jira[1], host: "jira", url };
278
+ const gh = /github\.com\/([^/]+)\/([^/]+)\/issues\/(\d+)/.exec(url);
279
+ if (gh) return { label: repoKey && `${gh[1]}/${gh[2]}`.toLowerCase() !== String(repoKey).toLowerCase() ? `${gh[2]}#${gh[3]}` : `#${gh[3]}`, host: "github", url };
280
+ return null;
281
+ }
282
+
260
283
  /** hc's agent status: `{app, state}` (hc 0.1.20) or a bare string (older cores). */
261
284
  export function statusText(status) {
262
285
  if (typeof status === "string") return status || null;
@@ -364,7 +387,13 @@ export async function approveHubFixes(api, runId) {
364
387
  /** "Estimated cost" shown before launching: the run's budget cap and timeout. */
365
388
  export function launchSummary(ticket) {
366
389
  const budget = Number(ticket?.budget_usd || 0).toFixed(2);
367
- return `Coste estimado: hasta $${budget} USD (tope del run) · timeout ${ticket?.timeout_minutes ?? "?"} min · agente ${ticket?.agent ?? "pi"}`;
390
+ return `Coste estimado: hasta $${budget} USD (tope del run) · ${timeoutLabel(ticket?.timeout_minutes)} · agente ${ticket?.agent ?? "pi"}`;
391
+ }
392
+
393
+ /** «sin timeout» for 0 or nothing (the default), «timeout N min» otherwise. */
394
+ export function timeoutLabel(minutes) {
395
+ const n = Number(minutes);
396
+ return Number.isFinite(n) && n > 0 ? `timeout ${n} min` : "sin timeout";
368
397
  }
369
398
 
370
399
  // ---- P6: header counters, filters and the new-ticket form ----
@@ -417,12 +446,11 @@ export function filterCards(cards, filter) {
417
446
  }
418
447
 
419
448
  /** Agents a ticket can name (the orchestrator's list, src/db/ticket-repo.ts). */
420
- export const AGENTS = ["pi", "claude", "codex", "opencode", "copilot", "crush", "agy"];
449
+ export const AGENTS = ["pi", "claude", "codex", "copilot", "agy"];
421
450
 
422
- /** Where a new ticket works: one repo, a list of repos (a new hub) or an existing hub. */
451
+ /** Where a new ticket works: one repo or an existing hub. */
423
452
  export const TICKET_MODES = [
424
453
  { id: "repo", label: "Un repo" },
425
- { id: "list", label: "Lista de repos" },
426
454
  { id: "hub", label: "Hub existente" },
427
455
  ];
428
456
 
@@ -436,6 +464,8 @@ export const TEAM_ENGINES = [
436
464
  export const MAX_REPOS = 8;
437
465
 
438
466
  const GITHUB_URL = /^https:\/\/github\.com\/[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+(?:\.git)?$/;
467
+ /** Plan bond-app-azure-jira P1: Azure Repos (dev.azure.com or the older visualstudio.com). */
468
+ const AZURE_URL = /^https:\/\/(?:[A-Za-z0-9][A-Za-z0-9_.-]*@)?(?:dev\.azure\.com\/[A-Za-z0-9][A-Za-z0-9_.-]*|[A-Za-z0-9][A-Za-z0-9_.-]*\.visualstudio\.com(?:\/DefaultCollection)?)\/[A-Za-z0-9_.~%'()+-]+\/_git\/[A-Za-z0-9_.~%'()+-]+\/?$/;
439
469
  const BRANCH = /^(?!-)(?!.*\.\.)(?!.*\/\/)(?!.*@\{)[A-Za-z0-9._/-]{1,200}(?<![./])$/;
440
470
 
441
471
  /**
@@ -451,7 +481,9 @@ export function validateNewTicket(form) {
451
481
  if (!title) errors.title = "Pon un título";
452
482
  else if (title.length > 200) errors.title = "Máximo 200 caracteres";
453
483
 
454
- const mode = TICKET_MODES.some((m) => m.id === f.mode) ? f.mode : "repo";
484
+ // El botón «Lista de repos» ya no se ofrece en el dialog (TICKET_MODES), pero el modo
485
+ // sigue siendo válido: la funcionalidad de equipo por lista de repos se conserva.
486
+ const mode = ["repo", "list", "hub"].includes(f.mode) ? f.mode : "repo";
455
487
  const agent = String(f.agent || "pi");
456
488
  if (!AGENTS.includes(agent)) errors.agent = `Agente desconocido: ${agent}`;
457
489
 
@@ -462,13 +494,17 @@ export function validateNewTicket(form) {
462
494
 
463
495
  const body = { title, agent };
464
496
  body.bondify = f.bondify !== undefined ? Boolean(f.bondify) : true;
497
+ // Plan bond-app-ajustes-imagen P4: only sent when ticked (privileged container).
498
+ if (f.docker === true) body.docker = true;
465
499
  if (model) body.model = model;
466
500
  if (mode !== "repo" && f.team_engine) {
467
501
  body.team_engine = f.team_engine === "herdr" ? "herdr" : "hc";
468
502
  }
469
503
  if (mode === "repo") {
470
504
  const url = String(f.repo ?? "").trim();
471
- if (!GITHUB_URL.test(url)) errors.repo = "URL de GitHub: https://github.com/org/repo";
505
+ if (!GITHUB_URL.test(url) && !AZURE_URL.test(url)) {
506
+ errors.repo = "URL de GitHub (https://github.com/org/repo) o de Azure Repos (https://dev.azure.com/org/proyecto/_git/repo)";
507
+ }
472
508
  body.repo_url = url;
473
509
  if (base) body.base_branch = base;
474
510
  } else if (mode === "list") {
@@ -507,8 +543,10 @@ export function validateNewTicket(form) {
507
543
  const budget = Number(String(f.budget ?? "").replace(",", "."));
508
544
  if (!Number.isFinite(budget) || budget <= 0 || budget > 1000) errors.budget = "Tope en USD: un número mayor que 0 y hasta 1000";
509
545
  else body.budget_usd = budget;
510
- const timeout = Number(f.timeout);
511
- if (!Number.isInteger(timeout) || timeout <= 0 || timeout > 1440) errors.timeout = "Minutos: un entero entre 1 y 1440";
546
+ // Empty or 0: no timeout (the default, decision 2026-11-24); otherwise whole minutes.
547
+ const timeoutText = String(f.timeout ?? "").trim();
548
+ const timeout = timeoutText === "" ? 0 : Number(timeoutText);
549
+ if (!Number.isInteger(timeout) || timeout < 0 || timeout > 1440) errors.timeout = "Minutos: un entero entre 0 (sin timeout) y 1440";
512
550
  else body.timeout_minutes = timeout;
513
551
 
514
552
  const description = String(f.description ?? "").trim();
@@ -520,14 +558,18 @@ export function validateNewTicket(form) {
520
558
  else if (verify.some((c) => c.length > 2000)) errors.verify = "Un comando es demasiado largo";
521
559
  else body.verify_commands = verify;
522
560
 
523
- // La US: el cuerpo de la issue elegida (check mediante); sin esto el agente arranca sin contexto.
524
- const story = String(f.story ?? "").trim();
525
- if (story) body.story = story.slice(0, 8000);
561
+ // La US: el cuerpo de la issue elegida (check mediante). Un "" explícito (check
562
+ // desmarcado a propósito) debe viajar tal cual: distingue «sin historia» de «sin dato».
563
+ if (f.story !== undefined && f.story !== null) {
564
+ body.story = String(f.story).trim().slice(0, 8000);
565
+ }
526
566
 
527
567
  const issueUrl = String(f.issue_url ?? f.issue ?? "").trim();
528
568
  if (issueUrl) {
529
- if (!/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/issues\/[1-9][0-9]*(?:[#?].*)?$/.test(issueUrl)) {
530
- errors.issue = "URL de GitHub Issue no válida (https://github.com/org/repo/issues/123)";
569
+ const isGh = /^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/issues\/[1-9][0-9]*(?:[#?].*)?$/.test(issueUrl);
570
+ const isJira = /^https:\/\/[A-Za-z0-9_-]+\.atlassian\.net\/browse\/[A-Za-z0-9_-]+(?:[#?].*)?$/.test(issueUrl);
571
+ if (!isGh && !isJira) {
572
+ errors.issue = "URL de issue no válida (GitHub o Jira Cloud: https://site.atlassian.net/browse/KEY-123)";
531
573
  } else {
532
574
  body.issue_url = issueUrl;
533
575
  }
@@ -560,14 +602,46 @@ export async function listRepoIssues(api, owner, repo) {
560
602
  return api(`/issues/repo?provider=github&owner=${encodeURIComponent(owner)}&repo=${encodeURIComponent(repo)}`);
561
603
  }
562
604
 
563
- /** D1: the id the backend will give the ticket for this issue (`gh-<owner>-<repo>-<n>`). */
605
+ /** Búsqueda de issues de Jira por texto y/o proyecto */
606
+ export async function searchJiraIssues(api, { q = "", project = "", mine = false } = {}) {
607
+ const params = new URLSearchParams();
608
+ if (q) params.set("q", q);
609
+ if (mine) params.set("mine", "1");
610
+ if (project) params.set("project", project);
611
+ return api(`/issues/jira/search?${params.toString()}`);
612
+ }
613
+
614
+ /** D1: the id the backend will give the ticket for this issue (`gh-<owner>-<repo>-<n>` or `jira-<site>-<key>`). */
564
615
  export function issueTicketId(issue) {
565
616
  const url = String(issue?.url ?? "").trim();
566
617
  const m = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/issues\/([1-9][0-9]*)(?:[#?].*)?$/.exec(url);
567
- if (!m) return null;
568
- const slug = (s) => s.replace(/[^A-Za-z0-9_.-]/g, "-").replace(/^[-.]+|[-.]+$/g, "");
569
- const id = `gh-${slug(m[1])}-${slug(m[2])}-${m[3]}`.replace(/\.{2,}/g, "-");
570
- return id.length <= 80 ? id : null;
618
+ if (m) {
619
+ const slug = (s) => s.replace(/[^A-Za-z0-9_.-]/g, "-").replace(/^[-.]+|[-.]+$/g, "");
620
+ const id = `gh-${slug(m[1])}-${slug(m[2])}-${m[3]}`.replace(/\.{2,}/g, "-");
621
+ return id.length <= 80 ? id : null;
622
+ }
623
+ const j = /^https:\/\/([a-zA-Z0-9_-]+)\.atlassian\.net\/browse\/([a-zA-Z0-9_-]+)(?:[#?].*)?$/.exec(url);
624
+ if (j) {
625
+ const slug = (s) => s.replace(/[^A-Za-z0-9_.-]/g, "-").replace(/^[-.]+|[-.]+$/g, "");
626
+ // El tenant entra en el id: dos sitios pueden compartir claves de proyecto.
627
+ const id = `jira-${slug(j[1].toLowerCase())}-${slug(j[2].toLowerCase())}`.replace(/\.{2,}/g, "-");
628
+ return id.length <= 80 ? id : null;
629
+ }
630
+ return null;
631
+ }
632
+
633
+ /**
634
+ * cambio de proveedor de historia: deja el estado de búsqueda/pools a cero para el
635
+ * proveedor entrante (sin resultados Jira obsoletos ni pools mezclados). Se pasa el
636
+ * propio objeto de la vista; devuelve el mismo para encadenar.
637
+ */
638
+ export function resetIssueProviderState(board) {
639
+ board.assignedPool = null;
640
+ board.issuePanel = null;
641
+ board.issues = null;
642
+ board.reposError = null;
643
+ board.jiraResults = null;
644
+ return board;
571
645
  }
572
646
 
573
647
  /** P7: Delete ticket and tear down all associated resources (container, network, machine, worktrees, branches). */
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><path d="M4 4l8 8M12 4l-8 8"/></svg>
@@ -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"><path d="M2 8s2.2-4 6-4 6 4 6 4-2.2 4-6 4-6-4-6-4z"/><circle cx="8" cy="8" r="1.8"/><path d="M3 13 13 3"/></svg>
@@ -0,0 +1,103 @@
1
+ // bond-pane: the header of each pane in the bond layout, like herdr-app's own: the
2
+ // program's icon, the terminal's name before the agent's (e.g. «kevin · agy», «gru · pi»), the folder,
3
+ // the agent's status, and buttons to split, zoom and close on hover. Props from the app:
4
+ // { pane, terminal }. Click: focus the pane.
5
+ //
6
+ // One difference (plan bond-app-pestanas-paneles, E4): in herdr-app, closing a pane ends its
7
+ // terminal. For an agent of a run (a terminal on another machine) the last button hides it
8
+ // instead: terminal.park, it keeps running, and the Agents panel brings it back with
9
+ // «Sincronizar Terminal». Shells and local terminals close as usual.
10
+
11
+ import { View, div, svg, image } from "gpui-kit";
12
+ import { h_flex } from "gpui-base";
13
+ import { panes, terminals, props, run, theme, home, shared, setShared } from "herdr";
14
+ import { isRunAgent, paneTitle } from "./model.js";
15
+
16
+ const ICONS = "mods/bond-pane";
17
+ // Shared with bond-agents (model.js HIDDEN_KEY) and bond-tabs.
18
+ const HIDDEN_KEY = "bond.agents.hidden";
19
+
20
+ function icon(p, size, color) {
21
+ if (!p?.icon) return null;
22
+ return p.tint ? svg(p.icon).size(size).flex_none().text_color(color) : image(p.icon).w(size).h(size).flex_none();
23
+ }
24
+
25
+ function folder(cwd) {
26
+ if (!cwd) return "";
27
+ const h = home();
28
+ return cwd === h ? "~" : cwd.startsWith(h + "/") ? "~" + cwd.slice(h.length) : cwd;
29
+ }
30
+
31
+ function hide(addr) {
32
+ const cur = shared(HIDDEN_KEY);
33
+ const set = new Set(Array.isArray(cur) ? cur : []);
34
+ set.add(addr);
35
+ setShared(HIDDEN_KEY, [...set].sort());
36
+ run("terminal.park", { terminal: addr });
37
+ }
38
+
39
+ export default class BondPane extends View {
40
+ init() {
41
+ this.hovered = false;
42
+ }
43
+
44
+ me() {
45
+ return (panes() ?? []).find((p) => p.pane === props()?.pane);
46
+ }
47
+
48
+ button(t, id, iconName, title, action) {
49
+ return div()
50
+ .id(id)
51
+ .p(3)
52
+ .rounded(4)
53
+ .text_color(t.dim)
54
+ .hover((s) => s.bg(t.hover).text_color(t.foreground))
55
+ .tooltip(title)
56
+ .on_click((_e, cx) => {
57
+ cx.stop_propagation();
58
+ action();
59
+ })
60
+ .child(svg(`${ICONS}/${iconName}.svg`).size(14));
61
+ }
62
+
63
+ render() {
64
+ const t = theme();
65
+ const p = this.me();
66
+ if (!p) return div();
67
+ const term = p.terminal ? (terminals() ?? []).find((x) => x.address === p.terminal) : null;
68
+ const base = ((p.program?.agent || p.program?.shell) && p.program.name) || p.title || p.program?.name || "shell";
69
+ const name = paneTitle(base, term?.name);
70
+ const pic = icon(p.program, 14, t.dim);
71
+ const st = p.status;
72
+ const pane = p.pane;
73
+ const runAgent = isRunAgent(p.terminal, p.program);
74
+ return h_flex()
75
+ .id(`pane-head-${pane}`)
76
+ .size_full()
77
+ .px(10)
78
+ .gap(8)
79
+ .items_center()
80
+ .bg(t.background)
81
+ .border_b(1)
82
+ .border_color(t.border)
83
+ .text_size(12)
84
+ .on_hover((hovered, cx) => {
85
+ this.hovered = hovered;
86
+ cx.notify();
87
+ })
88
+ .on_click(() => run("pane.focus", { pane }))
89
+ .when(Boolean(pic), (el) => el.child(pic))
90
+ .child(div().flex_none().truncate().max_w(300).font_medium().text_color(t.foreground).child(name))
91
+ .child(div().flex_1().truncate().text_color(t.dim).child(folder(p.cwd)))
92
+ .when(st === "working", (el) => el.child(svg("mods/workspace-chrome/spinner.svg").size(12).flex_none().text_color(t.working).spin(900)))
93
+ .when(st === "blocked", (el) => el.child(div().flex_none().px(6).h(18).flex().items_center().rounded(5).bg(t.blocked + "26").text_size(10.5).font_semibold().text_color(t.blocked).child("Te necesita")))
94
+ .when(st === "done", (el) => el.child(div().size(7).flex_none().rounded(4).bg(t.done)))
95
+ .when(this.hovered, (el) => el
96
+ .child(this.button(t, `bp-r-${pane}`, "split-right", "Dividir a la derecha", () => run("pane.split", { direction: "right", pane })))
97
+ .child(this.button(t, `bp-d-${pane}`, "split-down", "Dividir abajo", () => run("pane.split", { direction: "down", pane })))
98
+ .child(this.button(t, `bp-z-${pane}`, p.zoomed ? "unzoom" : "zoom", p.zoomed ? "Restaurar" : "Ampliar", () => run("pane.zoom", { pane })))
99
+ .child(runAgent
100
+ ? this.button(t, `bp-h-${pane}`, "hide", "Ocultar (el agente sigue vivo)", () => hide(p.terminal))
101
+ : this.button(t, `bp-x-${pane}`, "close", "Cerrar", () => run("pane.close", { pane }))));
102
+ }
103
+ }
@@ -0,0 +1 @@
1
+ { "place": "none", "title": "bond · cabecera de panel" }
@@ -0,0 +1,18 @@
1
+ // bond-pane: pure helpers of the pane header (testable without herdr-app).
2
+
3
+ /** An agent of a run: a terminal on another machine (`machine/tN`) running an agent,
4
+ * or the run's orchestrator (`/t1`). */
5
+ export function isRunAgent(terminal, program) {
6
+ const addr = String(terminal ?? "");
7
+ if (!addr.includes("/")) return false;
8
+ return Boolean(program?.agent) || /\/t1$/.test(addr);
9
+ }
10
+
11
+ /** «kevin · agy», «gru · pi»: the terminal's own name (gru, a minion) before its program;
12
+ * just the program when the name says nothing more (hc's `agent`, `tN`, the same word). */
13
+ export function paneTitle(name, termName) {
14
+ const n = String(name ?? "").trim() || "shell";
15
+ const t = String(termName ?? "").trim();
16
+ if (!t || t === n || /^t\d+$/.test(t) || t === "agent") return n;
17
+ return `${t} · ${n}`;
18
+ }
@@ -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"><rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M2 8h12"/></svg>
@@ -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"><rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M8 2.5v11"/></svg>
@@ -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"><path d="M13.5 6.5h-4v-4M2.5 9.5h4v4M9.5 6.5 14 2M6.5 9.5 2 14"/></svg>
@@ -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"><path d="M9.5 2.5h4v4M6.5 13.5h-4v-4M13.5 2.5 9 7M2.5 13.5 7 9"/></svg>
@@ -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: "blocked",
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
- return t[`bond_${id}`] ?? t[STATE_THEME_KEY[id]] ?? t[STATE_FALLBACK[id]] ?? t.accent;
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
+ }
@@ -9,4 +9,8 @@ export const CONFIG = {
9
9
  // registrando cost_usd, pero la UI no lo muestra hasta que una configuración
10
10
  // en Ajustes lo active. Entonces esto será el valor de esa configuración.
11
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,
12
16
  };