@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
|
@@ -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: "
|
|
7
|
-
{ id: "running", label: "
|
|
8
|
-
{ id: "waiting", label: "
|
|
9
|
-
{ id: "finished", label: "
|
|
10
|
-
{ id: "error", label: "
|
|
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
|
|
22
|
-
|
|
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) ·
|
|
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", "
|
|
449
|
+
export const AGENTS = ["pi", "claude", "codex", "copilot", "agy"];
|
|
421
450
|
|
|
422
|
-
/** Where a new ticket works: one repo
|
|
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,20 +481,30 @@ 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
|
-
|
|
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
|
|
|
458
490
|
const base = String(f.base ?? "").trim();
|
|
459
491
|
if (base && !BRANCH.test(base)) errors.base = "Rama no válida";
|
|
460
492
|
|
|
493
|
+
const model = agent === "pi" && f.model ? String(f.model).trim() : null;
|
|
494
|
+
|
|
461
495
|
const body = { title, agent };
|
|
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;
|
|
499
|
+
if (model) body.model = model;
|
|
462
500
|
if (mode !== "repo" && f.team_engine) {
|
|
463
501
|
body.team_engine = f.team_engine === "herdr" ? "herdr" : "hc";
|
|
464
502
|
}
|
|
465
503
|
if (mode === "repo") {
|
|
466
504
|
const url = String(f.repo ?? "").trim();
|
|
467
|
-
if (!GITHUB_URL.test(url)
|
|
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
|
+
}
|
|
468
508
|
body.repo_url = url;
|
|
469
509
|
if (base) body.base_branch = base;
|
|
470
510
|
} else if (mode === "list") {
|
|
@@ -503,8 +543,10 @@ export function validateNewTicket(form) {
|
|
|
503
543
|
const budget = Number(String(f.budget ?? "").replace(",", "."));
|
|
504
544
|
if (!Number.isFinite(budget) || budget <= 0 || budget > 1000) errors.budget = "Tope en USD: un número mayor que 0 y hasta 1000";
|
|
505
545
|
else body.budget_usd = budget;
|
|
506
|
-
|
|
507
|
-
|
|
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";
|
|
508
550
|
else body.timeout_minutes = timeout;
|
|
509
551
|
|
|
510
552
|
const description = String(f.description ?? "").trim();
|
|
@@ -516,10 +558,18 @@ export function validateNewTicket(form) {
|
|
|
516
558
|
else if (verify.some((c) => c.length > 2000)) errors.verify = "Un comando es demasiado largo";
|
|
517
559
|
else body.verify_commands = verify;
|
|
518
560
|
|
|
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
|
+
}
|
|
566
|
+
|
|
519
567
|
const issueUrl = String(f.issue_url ?? f.issue ?? "").trim();
|
|
520
568
|
if (issueUrl) {
|
|
521
|
-
|
|
522
|
-
|
|
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)";
|
|
523
573
|
} else {
|
|
524
574
|
body.issue_url = issueUrl;
|
|
525
575
|
}
|
|
@@ -533,6 +583,67 @@ export async function createTicket(api, body) {
|
|
|
533
583
|
return api("/tickets", { method: "POST", body });
|
|
534
584
|
}
|
|
535
585
|
|
|
586
|
+
/**
|
|
587
|
+
* Plan bond-app-nuevo-ticket (P2): issues to link a ticket to — the ones assigned to the
|
|
588
|
+
* user on the provider (open; `ready` first). The backend answers `github_not_configured`
|
|
589
|
+
* when there is no session, and `github_api_error` when the provider refuses.
|
|
590
|
+
*/
|
|
591
|
+
export async function listAssignedIssues(api, provider = "github") {
|
|
592
|
+
return api(`/issues/assigned?provider=${encodeURIComponent(provider)}`);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** Paso 1 de la búsqueda combinada: repos por nombre (buscador de GitHub). */
|
|
596
|
+
export async function searchRepos(api, term) {
|
|
597
|
+
return api(`/repos/search?provider=github&q=${encodeURIComponent(term)}`);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/** Paso 2: issues abiertas de un repo (ready primero, las asignadas a mí después). */
|
|
601
|
+
export async function listRepoIssues(api, owner, repo) {
|
|
602
|
+
return api(`/issues/repo?provider=github&owner=${encodeURIComponent(owner)}&repo=${encodeURIComponent(repo)}`);
|
|
603
|
+
}
|
|
604
|
+
|
|
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>`). */
|
|
615
|
+
export function issueTicketId(issue) {
|
|
616
|
+
const url = String(issue?.url ?? "").trim();
|
|
617
|
+
const m = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/issues\/([1-9][0-9]*)(?:[#?].*)?$/.exec(url);
|
|
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;
|
|
645
|
+
}
|
|
646
|
+
|
|
536
647
|
/** P7: Delete ticket and tear down all associated resources (container, network, machine, worktrees, branches). */
|
|
537
648
|
export async function deleteTicket(api, ticketId, force = false) {
|
|
538
649
|
const query = force ? "?force=true" : "";
|
|
@@ -543,3 +654,13 @@ export async function deleteTicket(api, ticketId, force = false) {
|
|
|
543
654
|
export async function getDeletePreview(api, ticketId) {
|
|
544
655
|
return api(`/tickets/${encodeURIComponent(ticketId)}/delete_preview`);
|
|
545
656
|
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* W-P2: does the board offer the setup wizard on load? Only when the orchestrator
|
|
660
|
+
* says the setup is not complete and the person has never finished the wizard
|
|
661
|
+
* (setup_done). With setup_done the wizard never bothers again; Ajustes is the
|
|
662
|
+
* permanent editor with «Reabrir asistente» (D-W2).
|
|
663
|
+
*/
|
|
664
|
+
export function needsWizard(state) {
|
|
665
|
+
return Boolean(state) && state.complete === false && state.setup_done === false;
|
|
666
|
+
}
|
|
@@ -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: "
|
|
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
|
};
|