@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.
Files changed (80) hide show
  1. package/README.md +280 -23
  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 +376 -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 +1000 -449
  17. package/app/mods/bond-board/model.js +170 -28
  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 +1216 -272
  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 +322 -27
  51. package/src/cli.ts +562 -21
  52. package/src/config.ts +15 -3
  53. package/src/core/agy-login.ts +683 -0
  54. package/src/core/delivery.ts +125 -6
  55. package/src/core/doctor.ts +748 -0
  56. package/src/core/hub-session.ts +108 -91
  57. package/src/core/hub.ts +40 -8
  58. package/src/core/orchestrator.ts +1481 -187
  59. package/src/core/paths.ts +107 -0
  60. package/src/core/permissions.ts +143 -0
  61. package/src/core/pr-source.ts +147 -0
  62. package/src/core/repo-host.ts +60 -0
  63. package/src/core/service-windows.ts +180 -0
  64. package/src/core/service.ts +861 -0
  65. package/src/core/setup-install.ts +1380 -0
  66. package/src/core/setup.ts +62 -1
  67. package/src/core/watchdog.ts +6 -6
  68. package/src/db/database.ts +54 -7
  69. package/src/db/settings-repo.ts +332 -7
  70. package/src/db/ticket-repo.ts +73 -25
  71. package/src/index.ts +4 -4
  72. package/src/runner/azure-devops-client.ts +273 -0
  73. package/src/runner/docker-client.ts +93 -9
  74. package/src/runner/github-client.ts +148 -3
  75. package/src/runner/hc-client.ts +33 -5
  76. package/src/runner/image-builder.ts +123 -5
  77. package/src/runner/jira-client.ts +368 -0
  78. package/src/runner/tool-catalog.ts +84 -0
  79. package/src/server/app.ts +467 -8
  80. package/src/types.ts +140 -2
package/src/types.ts CHANGED
@@ -35,7 +35,7 @@ export type FailureReason =
35
35
  | 'invalid_issue_url'
36
36
  | 'issue_inaccessible';
37
37
 
38
- export const SUPPORTED_AGENTS = ['pi', 'claude', 'codex', 'opencode', 'copilot', 'crush', 'agy'] as const;
38
+ export const SUPPORTED_AGENTS = ['pi', 'claude', 'codex', 'copilot', 'agy'] as const;
39
39
  export type SupportedAgent = (typeof SUPPORTED_AGENTS)[number];
40
40
 
41
41
  export function isValidAgent(agent: string): agent is SupportedAgent {
@@ -45,7 +45,7 @@ export function isValidAgent(agent: string): agent is SupportedAgent {
45
45
  /**
46
46
  * Wizard plan (D-W3, image plan D-B): the agents runner/setup.sh can bake into the image,
47
47
  * which are the ones the setup wizard offers and `agents_selected` validates against.
48
- * opencode/crush/coding-by-stdin are not selectable yet.
48
+ * Since 2026-11-24 the same five as SUPPORTED_AGENTS (opencode and crush were dropped).
49
49
  */
50
50
  export const SETUP_AGENTS = ['pi', 'claude', 'codex', 'copilot', 'agy'] as const;
51
51
  export type SetupAgent = (typeof SETUP_AGENTS)[number];
@@ -84,6 +84,12 @@ export interface Ticket {
84
84
  issue_url?: string | null;
85
85
  /** P7: user story read from the linked issue (or given). */
86
86
  story?: string | null;
87
+ /**
88
+ * Plan bond-app-ticket-desde-pr (D3): the remote work the ticket starts from — a PR's web
89
+ * URL, or a branch URL (GitHub `/tree/<b>`, Azure `?version=GB<b>`) when it has no PR.
90
+ * With it, `target_branch` is that existing branch and the run works on it.
91
+ */
92
+ source_pr_url?: string | null;
87
93
  /** The single repo (mode `single`), or the first one of the session for display. */
88
94
  repo_url: string;
89
95
  base_branch: string;
@@ -97,6 +103,7 @@ export interface Ticket {
97
103
  mode: TicketMode;
98
104
  target_branch: string;
99
105
  budget_usd: number;
106
+ /** Max minutes before the watchdog terminates the run; 0 (the default) = no timeout. */
100
107
  timeout_minutes: number;
101
108
  agent: string;
102
109
  model?: string;
@@ -105,6 +112,8 @@ export interface Ticket {
105
112
  verify_commands: string[];
106
113
  /** P4 (D-U): auto-bondify the cloned repo if not already bondified; default true. */
107
114
  bondify: boolean;
115
+ /** Plan bond-app-ajustes-imagen P4: Docker inside the run (privileged container); default false. */
116
+ docker?: boolean;
108
117
  /** P9: engine for bond team inside run container: 'hc' (default, native panes) or 'herdr' (TUI mode). */
109
118
  team_engine?: 'hc' | 'herdr';
110
119
  status: RunState;
@@ -119,6 +128,11 @@ export interface CreateTicketInput {
119
128
  /** P7: linked GitHub issue URL. */
120
129
  issue_url?: string;
121
130
  story?: string;
131
+ /**
132
+ * Plan bond-app-ticket-desde-pr (D3): a PR or branch URL to start from. `POST /tickets`
133
+ * resolves it and fills repo, branches, id and (if missing) title and story from it.
134
+ */
135
+ source_pr_url?: string;
122
136
  /** One of: repo_url (single repo), repos (list; two or more create a hub) or hub_url. */
123
137
  repo_url?: string;
124
138
  base_branch?: string;
@@ -128,6 +142,7 @@ export interface CreateTicketInput {
128
142
  repo_agents?: Record<string, string>;
129
143
  target_branch?: string;
130
144
  budget_usd?: number;
145
+ /** Timeout in minutes; 0 (the default) = no timeout, negative is rejected. */
131
146
  timeout_minutes?: number;
132
147
  agent?: string;
133
148
  model?: string;
@@ -135,6 +150,8 @@ export interface CreateTicketInput {
135
150
  verify_commands?: string[];
136
151
  /** P4 (D-U): auto-bondify the cloned repo if not already bondified; default true. */
137
152
  bondify?: boolean;
153
+ /** Plan bond-app-ajustes-imagen P4: Docker inside the run (privileged container); default false. */
154
+ docker?: boolean;
138
155
  /** P9: engine for bond team inside run container: 'hc' (default) or 'herdr'. */
139
156
  team_engine?: 'hc' | 'herdr';
140
157
  }
@@ -172,6 +189,24 @@ export function parseGitHubIssueUrl(url: string): { owner: string; repo: string;
172
189
  };
173
190
  }
174
191
 
192
+ /** Plan bond-app-azure-jira P2: validate Jira issue URL: https://<site>.atlassian.net/browse/<KEY-123> */
193
+ export function validateJiraIssueUrl(url: string): boolean {
194
+ if (!url || typeof url !== 'string') return false;
195
+ const clean = url.trim().replace(/[#?].*$/, '');
196
+ return /^https:\/\/[a-zA-Z0-9_-]+\.atlassian\.net\/browse\/[a-zA-Z0-9_-]+$/.test(clean);
197
+ }
198
+
199
+ /** Plan bond-app-azure-jira P2: parse Jira issue URL into site and issueKey. */
200
+ export function parseJiraIssueUrl(url: string): { site: string; issueKey: string } {
201
+ const clean = url.trim().replace(/[#?].*$/, '');
202
+ const m = /^https:\/\/([a-zA-Z0-9_-]+\.atlassian\.net)\/browse\/([a-zA-Z0-9_-]+)$/.exec(clean);
203
+ if (!m) throw new Error(`Not a Jira issue URL: '${url}'`);
204
+ return {
205
+ site: `https://${m[1]}`,
206
+ issueKey: m[2],
207
+ };
208
+ }
209
+
175
210
  export interface Run {
176
211
  id: string;
177
212
  ticket_id: string;
@@ -310,6 +345,41 @@ export interface AgentCredentialSummary {
310
345
  provider?: string;
311
346
  configured: boolean;
312
347
  updated_at?: string;
348
+ /** P1: account email for agy (read from id_token_email of antigravity-oauth-token; never the token). */
349
+ email?: string;
350
+ /** claude: when its `claude setup-token` token ends (one year after it was stored). */
351
+ expires_at?: string;
352
+ }
353
+
354
+ export type AgyLoginStatus =
355
+ | 'idle'
356
+ | 'starting'
357
+ | 'waiting_code'
358
+ | 'authenticating'
359
+ | 'success'
360
+ | 'error';
361
+
362
+ export interface AgyLoginSessionState {
363
+ status: AgyLoginStatus;
364
+ url?: string;
365
+ /** Device flows (copilot): the code the person types at `url`; nothing to paste back. */
366
+ user_code?: string;
367
+ /** True when the login finishes by itself once authorized (no code to submit). */
368
+ device?: boolean;
369
+ /** The orchestrator catches the browser's return itself (codex); pasting is the fallback. */
370
+ auto?: boolean;
371
+ email?: string;
372
+ error?: string;
373
+ }
374
+
375
+ /** Plan bond-app-azure-jira P1: what the API says about the Azure DevOps PAT (never the PAT). */
376
+ export interface AzureDevOpsCredentialSummary {
377
+ configured: boolean;
378
+ org_url?: string;
379
+ account?: string;
380
+ /** The PAT also reaches the run's agents (AZURE_DEVOPS_* variables). */
381
+ agents_enabled?: boolean;
382
+ updated_at?: string;
313
383
  }
314
384
 
315
385
  /** D20: what the API says about the stored GitHub credential (never the token). */
@@ -324,6 +394,19 @@ export interface GitHubCredentialSummary {
324
394
  export interface RunnerImageInfo {
325
395
  present: boolean;
326
396
  agents?: string[];
397
+ /** Plan bond-app-ajustes-imagen P2: tool groups and extra apt packages it was built with. */
398
+ tools?: string[];
399
+ apt_extra?: string[];
400
+ /** Filled by the setup state: what it lacks against the selection (⟳ in Ajustes). */
401
+ stale?: boolean;
402
+ missing_agents?: string[];
403
+ missing_tools?: string[];
404
+ extra_tools?: string[];
405
+ apt_changed?: boolean;
406
+ /** Fingerprint of the recipe it was built with (image label); absent on older images. */
407
+ recipe?: string;
408
+ /** The recipe (Dockerfile, setup.sh, versions.env…) changed since it was built. */
409
+ recipe_changed?: boolean;
327
410
  }
328
411
 
329
412
  /** W-P1: the aggregated setup state the wizard and the Ajustes panel read. */
@@ -341,6 +424,11 @@ export interface SetupState {
341
424
  default_model: string | null;
342
425
  /** P3: full model ids configured for pi (provider/id). */
343
426
  models: string[];
427
+ /** Plan bond-app-ajustes-imagen P2: tool groups and extra apt packages chosen for the image. */
428
+ tools_selected: string[];
429
+ apt_extra: string[];
430
+ /** The tool groups the image can carry (id, label, description, default, size_mb). */
431
+ catalog: Array<{ id: string; label: string; description: string; default: boolean; size_mb: number }>;
344
432
  }
345
433
 
346
434
  /** gh / GitHub tokens: gho_…, ghp_…, github_pat_… — one word, no whitespace. */
@@ -353,6 +441,42 @@ export function validateGitHubLogin(login: unknown): login is string {
353
441
  return typeof login === 'string' && /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(login);
354
442
  }
355
443
 
444
+ /** Plan bond-app-azure-jira P2: Jira Cloud credential. */
445
+ export interface JiraCredential {
446
+ site: string;
447
+ email: string;
448
+ token: string;
449
+ agents_enabled: boolean;
450
+ account_name?: string | null;
451
+ updated_at: string;
452
+ }
453
+
454
+ export interface JiraCredentialSummary {
455
+ configured: boolean;
456
+ site?: string;
457
+ email?: string;
458
+ agents_enabled?: boolean;
459
+ account_name?: string | null;
460
+ updated_at?: string;
461
+ }
462
+
463
+ export function validateJiraSite(site: unknown): site is string {
464
+ if (typeof site !== 'string') return false;
465
+ return /^https:\/\/[a-zA-Z0-9_-]+\.atlassian\.net\/?$/.test(site.trim());
466
+ }
467
+
468
+ export function normalizeJiraSite(site: string): string {
469
+ return site.trim().replace(/\/+$/, '');
470
+ }
471
+
472
+ export function validateJiraEmail(email: unknown): email is string {
473
+ return typeof email === 'string' && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
474
+ }
475
+
476
+ export function validateJiraToken(token: unknown): token is string {
477
+ return typeof token === 'string' && token.trim().length > 0;
478
+ }
479
+
356
480
  /** P7: Row of `bond team status --json` inside the run's container. */
357
481
  export interface TeamStatusRow {
358
482
  branch: string;
@@ -376,3 +500,17 @@ export interface TeamStatusRow {
376
500
  notice?: boolean;
377
501
  };
378
502
  }
503
+
504
+ /** P4: Live terminal of a run machine reported by hc. */
505
+ export interface RunTerminal {
506
+ address: string;
507
+ name: string;
508
+ agent: string;
509
+ state: string;
510
+ status: unknown;
511
+ turn: number;
512
+ where: string;
513
+ cwd: string;
514
+ labels?: Record<string, string>;
515
+ exit_code?: number | null;
516
+ }