@milabench/bujang 0.1.2 → 0.1.3

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/dist/paths.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ import type { IconType } from 'react-icons';
1
2
  /** Names of the bujang views. */
2
- export type BujangView = 'jobs' | 'submitJob' | 'jobDetails' | 'jobLogs' | 'pipelines' | 'scheduled' | 'agent';
3
+ export type BujangView = 'jobs' | 'submitJob' | 'jobDetails' | 'jobLogs' | 'pipelines' | 'pipelineDetails' | 'scheduled' | 'agent' | 'settings';
3
4
  /** URL builders the views use to link to each other. */
4
5
  export interface BujangPaths {
5
6
  jobs: () => string;
@@ -7,9 +8,13 @@ export interface BujangPaths {
7
8
  jobDetails: (slurmJobId: string | number, jrJobId: string) => string;
8
9
  jobLogs: (slurmJobId: string | number, jrJobId: string) => string;
9
10
  pipelines: () => string;
11
+ /** One saved pipeline: its graph and its runs, `runId` shows that run. */
12
+ pipelineDetails: (name: string, runId?: string) => string;
10
13
  scheduled: () => string;
11
14
  /** Agent activity, optionally filtered on one session. */
12
15
  agent: (session?: string) => string;
16
+ /** Settings: folders, database, SSH, secrets (read-only unless the server allows edits). */
17
+ settings: () => string;
13
18
  }
14
19
  /** Default URL layout (react-router patterns), relative to the host's basePath. */
15
20
  export declare const defaultRoutePatterns: Record<BujangView, string>;
@@ -21,6 +26,8 @@ export interface BujangNavItem {
21
26
  view: BujangView;
22
27
  label: string;
23
28
  path: string;
29
+ /** Icon of the entry (a react-icons component); optional, hosts can ignore it. */
30
+ icon?: IconType;
24
31
  }
25
32
  /** Sidebar entries for the top-level bujang views. */
26
33
  export declare function bujangNavItems(paths?: BujangPaths): BujangNavItem[];
package/dist/routes.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface BujangRouteObject {
15
15
  /**
16
16
  * Route objects for the default bujang URL layout under `basePath`:
17
17
  * /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
18
- * /pipelines, /scheduled, /agent.
18
+ * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /settings.
19
19
  */
20
20
  export declare function bujangRoutes(options?: BujangRoutesOptions): BujangRouteObject[];
21
21
  /** The same routes as <Route> elements, to drop inside a host's <Routes>. */
package/dist/types.d.ts CHANGED
@@ -295,6 +295,8 @@ export interface PipelineRunResponse {
295
295
  success: boolean;
296
296
  run_id: string;
297
297
  name: string;
298
+ /** the saved pipeline it was started from (null for a definition sent as is) */
299
+ template?: string | null;
298
300
  }
299
301
  /** submitting: the jobs are being submitted; failed: the submission failed (nothing runs) */
300
302
  export type PipelineSubmissionStatus = 'submitting' | 'submitted' | 'failed';
@@ -302,6 +304,8 @@ export type PipelineSubmissionStatus = 'submitting' | 'submitted' | 'failed';
302
304
  export interface PipelineRunSummary {
303
305
  run_id: string;
304
306
  name: string;
307
+ /** the saved pipeline it was started from; runs older than this field have none */
308
+ template?: string | null;
305
309
  started: number;
306
310
  status: PipelineSubmissionStatus;
307
311
  error?: string | null;
@@ -309,6 +313,10 @@ export interface PipelineRunSummary {
309
313
  /** A step of a run with its current state (sacct/squeue state, HELD, or the ssh step state) */
310
314
  export interface PipelineRunStep extends PipelineJob {
311
315
  step?: string;
316
+ /** the value of the sweep variable of its parallel group (what tells it apart from its siblings) */
317
+ sweep?: string;
318
+ /** the env variable `sweep` is the value of */
319
+ sweep_key?: string;
312
320
  after?: string[];
313
321
  held?: boolean;
314
322
  state?: string;
@@ -322,6 +330,8 @@ export interface PipelineRunStatus {
322
330
  state?: 'running' | 'failing' | 'failed' | 'completed' | 'unknown';
323
331
  steps?: PipelineRunStep[];
324
332
  log?: string;
333
+ /** the definition the run was started with (the saved pipeline may have changed since) */
334
+ definition?: PipelineNode | null;
325
335
  }
326
336
  export interface PipelineSequential {
327
337
  type: 'sequential';
@@ -332,6 +342,8 @@ export interface PipelineParallel {
332
342
  type: 'parallel';
333
343
  name: string;
334
344
  jobs: PipelineNode[];
345
+ /** display only: the env variable that tells the children apart (e.g. ARGS), shown instead of their script */
346
+ sweep?: string;
335
347
  }
336
348
  export interface Pipeline {
337
349
  type: 'pipeline';
@@ -369,6 +381,7 @@ export interface PipelineTemplate {
369
381
  export interface PipelineTemplatePayload {
370
382
  name: string;
371
383
  type: 'pipeline';
384
+ description?: string;
372
385
  definition: PipelineNode;
373
386
  job_id: string | null;
374
387
  }
@@ -472,3 +485,278 @@ export interface AgentSession {
472
485
  pipelines: string[];
473
486
  last_note: string | null;
474
487
  }
488
+ /** Where a value comes from: env var, a config source (plugin / user file), the default or the host's code. */
489
+ export interface SettingsOrigin {
490
+ kind: 'env' | 'default' | 'code' | 'workdir' | 'plugin' | 'user' | 'explicit' | 'defaults' | string;
491
+ name: string;
492
+ path: string | null;
493
+ }
494
+ /** One editable field of the user file (local_cache, workdir, database_url). */
495
+ export interface SettingsField {
496
+ /** Value the running server uses (database_url: password masked). */
497
+ value: string | null;
498
+ /** Value in the user file, null when absent. */
499
+ file: string | null;
500
+ origin: SettingsOrigin;
501
+ /** Name of the BUJANG_* variable when it is set (it wins over the file). */
502
+ env: string | null;
503
+ /** Something above the user file sets it (env, code, another source): the file has no effect. */
504
+ overridden: boolean;
505
+ /** Only read at startup. */
506
+ restart: boolean;
507
+ /** The file differs from the running value and will apply after a restart. */
508
+ pending: boolean;
509
+ editable: boolean;
510
+ reason: string | null;
511
+ }
512
+ export type SettingsFieldName = 'local_cache' | 'workdir' | 'database_url';
513
+ export interface SettingsCluster {
514
+ name: string;
515
+ ssh: string;
516
+ remote_folder: string;
517
+ origin: SettingsOrigin;
518
+ }
519
+ export interface SettingsDatabaseTable {
520
+ name: string;
521
+ exists: boolean;
522
+ rows: number | null;
523
+ }
524
+ export interface SettingsDatabase {
525
+ host_provided: boolean;
526
+ kind: 'engine' | 'sessionmaker' | 'callable' | 'url' | null;
527
+ /** Password masked. */
528
+ url: string | null;
529
+ backend: string | null;
530
+ sqlite_path: string | null;
531
+ host: string | null;
532
+ name: string | null;
533
+ editable: boolean;
534
+ enabled: boolean;
535
+ tables: SettingsDatabaseTable[];
536
+ error: string | null;
537
+ }
538
+ export interface SettingsMcp {
539
+ /** Served by this app itself (bujang serve), at `path`. */
540
+ mounted: boolean;
541
+ path: string | null;
542
+ /** Absolute URL the server knows (BUJANG_URL, BujangConfig.mcp_url, serve_in_background). */
543
+ url: string | null;
544
+ /** Turned off (--no-mcp). */
545
+ disabled: boolean;
546
+ }
547
+ export interface SettingsGeneral {
548
+ version: string;
549
+ plugins: {
550
+ name: string;
551
+ version: string | null;
552
+ ssh_config: boolean;
553
+ }[];
554
+ default_cluster: string | null;
555
+ clusters: string[];
556
+ server: {
557
+ standalone: boolean;
558
+ host: string | null;
559
+ url: string | null;
560
+ };
561
+ mcp: SettingsMcp;
562
+ }
563
+ export interface ConfigSourceInfo {
564
+ kind: string;
565
+ name: string;
566
+ path: string | null;
567
+ }
568
+ export interface SettingsInfo {
569
+ writable: boolean;
570
+ read_only_reason: string | null;
571
+ user_file: {
572
+ path: string | null;
573
+ exists: boolean;
574
+ user_config_dir: string | null;
575
+ error: string | null;
576
+ };
577
+ fields: Record<SettingsFieldName, SettingsField>;
578
+ secrets_file: string;
579
+ clusters: SettingsCluster[];
580
+ sources: {
581
+ sources: ConfigSourceInfo[];
582
+ plugins: {
583
+ name: string;
584
+ config_dir: string;
585
+ version: string | null;
586
+ ssh_config: string | null;
587
+ }[];
588
+ clusters: Record<string, {
589
+ source: ConfigSourceInfo;
590
+ sources: ConfigSourceInfo[];
591
+ }>;
592
+ profiles: Record<string, {
593
+ source: ConfigSourceInfo;
594
+ }>;
595
+ scripts: string[];
596
+ };
597
+ database: SettingsDatabase;
598
+ general: SettingsGeneral;
599
+ }
600
+ export interface SettingsUpdateResponse {
601
+ written: {
602
+ path: string;
603
+ keys: string[];
604
+ } | null;
605
+ applied: string[];
606
+ restart: string[];
607
+ settings: SettingsInfo;
608
+ }
609
+ export interface SettingsSecret {
610
+ name: string;
611
+ source: 'file' | 'toml';
612
+ /** An environment variable of the same name wins over the file. */
613
+ env_shadowed: boolean;
614
+ }
615
+ export interface SettingsSecrets {
616
+ secrets: SettingsSecret[];
617
+ /** The .secrets file the set / delete routes write (null: secrets.toml is used). */
618
+ file: string | null;
619
+ editable: boolean;
620
+ providers: {
621
+ kind: string;
622
+ name: string;
623
+ available: boolean;
624
+ }[];
625
+ }
626
+ export interface SshPluginStatus {
627
+ name: string;
628
+ version: string | null;
629
+ ssh_config: string;
630
+ placeholders: string[];
631
+ aliases: string[];
632
+ installed: boolean;
633
+ installed_version: string | null;
634
+ up_to_date: boolean | null;
635
+ /** Placeholder values remembered in the block. */
636
+ values: Record<string, string>;
637
+ line: number | null;
638
+ duplicates: number;
639
+ /** Host entries outside the block with the same alias (ssh uses the first one). */
640
+ conflicts: {
641
+ alias: string;
642
+ line: number;
643
+ text: string;
644
+ }[];
645
+ }
646
+ export interface SshSettings {
647
+ file: string;
648
+ default_file: string;
649
+ exists: boolean;
650
+ plugins: SshPluginStatus[];
651
+ other_blocks: {
652
+ name: string;
653
+ version: string | null;
654
+ }[];
655
+ error: string | null;
656
+ writable: boolean;
657
+ }
658
+ export interface SshPlanRequest {
659
+ file?: string;
660
+ plugins?: string[];
661
+ values?: Record<string, string>;
662
+ dedupe?: boolean;
663
+ /** Install / remove: the `base` of the preview; the server refuses when the file changed since. */
664
+ base?: string;
665
+ }
666
+ export interface SshPlan {
667
+ file: string;
668
+ action: 'install' | 'remove';
669
+ changed: boolean;
670
+ diff: string;
671
+ messages: string[];
672
+ warnings: string[];
673
+ aliases: string[];
674
+ base: string;
675
+ backup?: string | null;
676
+ written?: boolean;
677
+ alias_failures?: string[];
678
+ }
679
+ export interface SshCheckResult {
680
+ host: string;
681
+ cluster: string;
682
+ ok: boolean;
683
+ ssh: 'ok' | 'auth' | 'hostkey' | 'dns' | 'timeout' | 'refused' | 'unreachable' | 'jump' | 'error' | '?';
684
+ master: string;
685
+ slurm: string;
686
+ workdir: string;
687
+ latency: number | null;
688
+ remote_hostname: string | null;
689
+ message: string;
690
+ hints: string[];
691
+ }
692
+ export interface SshTestResponse {
693
+ ok: boolean;
694
+ timeout: number;
695
+ file: string | null;
696
+ results: SshCheckResult[];
697
+ }
698
+ /** GET /update: the running version against the latest release on PyPI (checked once a day). */
699
+ export interface UpdateCheck {
700
+ /** BUJANG_UPDATE_CHECK=0 turns the check off */
701
+ enabled: boolean;
702
+ current: string;
703
+ latest: string | null;
704
+ update_available: boolean;
705
+ /** unix time of the last PyPI request */
706
+ checked_at: number | null;
707
+ error: string | null;
708
+ install: {
709
+ kind: 'editable' | 'uv-tool' | 'pip' | 'uv-pip' | 'unknown';
710
+ command: string[] | null;
711
+ hint: string | null;
712
+ };
713
+ /** POST /update works here (writable standalone server with a known installer) */
714
+ can_update: boolean;
715
+ reason: string | null;
716
+ running: boolean;
717
+ }
718
+ /** POST /update */
719
+ export interface UpdateResult {
720
+ success: boolean;
721
+ command: string[];
722
+ output: string;
723
+ previous: string;
724
+ installed?: string | null;
725
+ /** the server stops and starts the new version */
726
+ restarting?: boolean;
727
+ }
728
+ /** GET /organizers: per organizer folder (clusters, experiments, ...), its values and the jobs under each */
729
+ export interface OrganizerGroups {
730
+ name: string;
731
+ groups: {
732
+ value: string;
733
+ jobs: string[];
734
+ }[];
735
+ }
736
+ /** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (results/, output/) */
737
+ export interface JobArtifacts {
738
+ jr_job_id: string;
739
+ folders: string[];
740
+ files: {
741
+ path: string;
742
+ size: number;
743
+ mtime: number;
744
+ media_type: string;
745
+ report: boolean;
746
+ }[];
747
+ truncated: boolean;
748
+ /** HTML reports run sandboxed: their scripts cannot reach the bujang API */
749
+ sandboxed: boolean;
750
+ }
751
+ /** GET /sync: when the job index was last synced with the clusters (POST /sync adds `synced`) */
752
+ export interface SyncStatus {
753
+ /** unix time of the last background sync, null before the first one */
754
+ last: number | null;
755
+ scanned: number | null;
756
+ clusters: Record<string, number | null>;
757
+ /** seconds between two background syncs, null when the server does not run them */
758
+ interval: number | null;
759
+ jobs: number;
760
+ synced?: Record<string, boolean>;
761
+ skipped?: string;
762
+ }
@@ -4,5 +4,7 @@ import type { AgentTag } from '../types';
4
4
  export declare const AgentBadge: React.FC<{
5
5
  tag?: AgentTag | null;
6
6
  }>;
7
+ /** How to connect an agent to the MCP endpoint (hidden when the server does not say where it is). */
8
+ export declare const McpHelp: React.FC;
7
9
  export declare const AgentActivityView: React.FC;
8
10
  export default AgentActivityView;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ /**
3
+ * The reports and other files of a job's results/ and output/ folders, delivered by the server:
4
+ * an HTML report opens in a new tab (its images and scripts load next to it), the rest downloads.
5
+ * Nothing is shown when the job has none.
6
+ */
7
+ export declare const JobArtifactsCard: React.FC<{
8
+ jrJobId: string;
9
+ }>;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import type { PipelineNode, PipelineTemplatePayload, SlurmProfile } from '../types';
3
+ /**
4
+ * A pipeline file (`{ type: 'pipeline', name, description, definition, job_id }`); the older
5
+ * `pipelineName` / `rootNode` fields are read for template files written before the server format.
6
+ */
7
+ export interface PipelineTemplateFileData {
8
+ type?: string;
9
+ name?: string;
10
+ description?: string;
11
+ definition?: PipelineNode;
12
+ job_id?: string | null;
13
+ pipelineName?: string;
14
+ rootNode?: unknown;
15
+ }
16
+ /** The pipeline editor: a compact tree on the left, the selected step on the right */
17
+ export declare const PipelineBuilder: React.FC<{
18
+ isOpen: boolean;
19
+ onClose: () => void;
20
+ profiles: SlurmProfile[];
21
+ templates: string[];
22
+ loadedTemplateData?: PipelineTemplateFileData | null;
23
+ onSaveTemplate: (data: PipelineTemplatePayload) => void;
24
+ }>;
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import type { PipelineNode } from '../types';
3
+ /** A job of the graph: its step label (the same as the server's, `0.prepare`, `1.runs/0.a`) and what it waits on */
4
+ export interface GraphStep {
5
+ id: string;
6
+ step: string;
7
+ script: string;
8
+ profile: string;
9
+ /** what the step sets (its "env"): tells apart the steps of one script */
10
+ env?: Record<string, string>;
11
+ after: string[];
12
+ /** the sweep variable of its parallel group (nearest one) and its value: what tells it apart from its siblings */
13
+ sweepKey?: string;
14
+ sweep?: string;
15
+ }
16
+ /**
17
+ * The sweep variable of a parallel group: its `sweep`, else the env variable every job of the group sets,
18
+ * each to another value (the first one in the order of the first job; the server guesses the same way)
19
+ */
20
+ export declare const groupSweepKey: (group: PipelineNode) => string | undefined;
21
+ /** The value of the sweep variable `key` for a job, undefined when the job does not set it */
22
+ export declare const sweepValue: (env: Record<string, string> | undefined, key: string | undefined) => string | undefined;
23
+ interface Group {
24
+ id: string;
25
+ kind: 'sequential' | 'parallel';
26
+ name: string;
27
+ steps: string[];
28
+ groups: Group[];
29
+ }
30
+ /**
31
+ * The steps of a definition with their dependencies (sequential: each child waits on the one before;
32
+ * parallel: the children share the dependencies, the next node waits on all of them).
33
+ */
34
+ export declare function pipelineSteps(root: PipelineNode): {
35
+ steps: GraphStep[];
36
+ root: Group | null;
37
+ };
38
+ /** Above this many steps the mermaid graph is unreadable: it is not drawn */
39
+ export declare const MAX_GRAPH_STEPS = 10;
40
+ /** Whether the graph of `root` is small enough to draw (at most MAX_GRAPH_STEPS steps) */
41
+ export declare const graphIsDrawable: (root: PipelineNode) => boolean;
42
+ /** Mermaid flowchart of a pipeline; `states`: step label -> state, colours the steps of a run */
43
+ export declare function pipelineMermaid(root: PipelineNode, states?: Record<string, string>, dark?: boolean): string;
44
+ /** The pipeline graph, rendered by mermaid (loaded on first use) */
45
+ export declare const PipelineGraph: React.FC<{
46
+ definition: PipelineNode;
47
+ states?: Record<string, string>;
48
+ }>;
49
+ export {};
@@ -1,2 +1,5 @@
1
1
  import React from 'react';
2
+ /** /pipelines: the saved pipelines */
2
3
  export declare const PipelinesView: React.FC;
4
+ /** /pipelines/:pipelineName: the graph of a pipeline, Run, the run shown (?run=, else the latest) and its runs */
5
+ export declare const PipelineDetailsView: React.FC;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const SettingsView: React.FC;
3
+ export default SettingsView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milabench/bujang",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -68,5 +68,8 @@
68
68
  "type": "git",
69
69
  "url": "git+https://github.com/milabench/bujang.git",
70
70
  "directory": "ui"
71
+ },
72
+ "dependencies": {
73
+ "mermaid": "^11.17.2"
71
74
  }
72
75
  }
package/src/api.ts CHANGED
@@ -27,6 +27,18 @@ import type {
27
27
  ScheduledJobTemplateDiff,
28
28
  AgentEvent,
29
29
  AgentSession,
30
+ SettingsInfo,
31
+ SettingsUpdateResponse,
32
+ UpdateCheck,
33
+ OrganizerGroups,
34
+ SyncStatus,
35
+ JobArtifacts,
36
+ UpdateResult,
37
+ SettingsSecrets,
38
+ SshSettings,
39
+ SshPlan,
40
+ SshPlanRequest,
41
+ SshTestResponse,
30
42
  } from './types';
31
43
 
32
44
  export const DEFAULT_API_BASE = '/api/slurm';
@@ -428,6 +440,141 @@ export const listSlurmSecrets = async (): Promise<string[]> => {
428
440
  };
429
441
 
430
442
 
443
+ /** Add or replace a secret of the .secrets file. The value is sent once and never returned. */
444
+ export const setSlurmSecret = async (key: string, value: string): Promise<{ success: boolean; message?: string }> => {
445
+ try {
446
+ const response = await api.post('/secrets/set', { key, value });
447
+ return response.data;
448
+ } catch (error) { return handleError(error); }
449
+ };
450
+
451
+ export const deleteSlurmSecret = async (name: string): Promise<{ success: boolean; message?: string }> => {
452
+ try {
453
+ const response = await api.delete(`/secrets/delete/${encodeURIComponent(name)}`);
454
+ return response.data;
455
+ } catch (error) { return handleError(error); }
456
+ };
457
+
458
+
459
+ // Settings (writes answer 403 when the server is read-only)
460
+ export const getSettings = async (): Promise<SettingsInfo> => {
461
+ try {
462
+ const response = await api.get('/settings');
463
+ return response.data;
464
+ } catch (error) { return handleError(error); }
465
+ };
466
+
467
+ /** Write local_cache / workdir / database_url (null: remove it) to the user file. */
468
+ export const updateSettings = async (
469
+ values: Partial<Record<'local_cache' | 'workdir' | 'database_url', string | null>>,
470
+ ): Promise<SettingsUpdateResponse> => {
471
+ try {
472
+ const response = await api.put('/settings', values);
473
+ return response.data;
474
+ } catch (error) { return handleError(error); }
475
+ };
476
+
477
+ /** The files of results/ and output/ of a job folder (reports first). */
478
+ export const getJobArtifacts = async (jrJobId: string): Promise<JobArtifacts> => {
479
+ try {
480
+ const response = await api.get(`/jobs/${encodeURIComponent(jrJobId)}/artifacts`, { timeout: 30000 });
481
+ return response.data;
482
+ } catch (error) { return handleError(error); }
483
+ };
484
+
485
+ /** URL of an artifact, to open in a tab: its relative links (images, scripts) resolve next to it. */
486
+ export const jobArtifactUrl = (jrJobId: string, path: string): string =>
487
+ `${currentBase}/jobs/${encodeURIComponent(jrJobId)}/artifacts/${path.split('/').map(encodeURIComponent).join('/')}`;
488
+
489
+ /** When the job index was last synced with the clusters. */
490
+ export const getSyncStatus = async (): Promise<SyncStatus> => {
491
+ try {
492
+ const response = await api.get('/sync');
493
+ return response.data;
494
+ } catch (error) { return handleError(error); }
495
+ };
496
+
497
+ /** rsync the clusters with active jobs now and index what changed (can take a few seconds). */
498
+ export const syncNow = async (): Promise<SyncStatus> => {
499
+ try {
500
+ const response = await api.post('/sync', {}, { timeout: 120_000 });
501
+ return response.data;
502
+ } catch (error) { return handleError(error); }
503
+ };
504
+
505
+ /** The organizer folders (clusters/, experiments/, ...): their values and the job ids under each. */
506
+ export const getOrganizers = async (): Promise<OrganizerGroups[]> => {
507
+ try {
508
+ const response = await api.get('/organizers');
509
+ return response.data;
510
+ } catch (error) { return handleError(error); }
511
+ };
512
+
513
+ /** The running version against PyPI; the server asks PyPI once a day, `force` asks now. */
514
+ export const getUpdateCheck = async (force = false): Promise<UpdateCheck> => {
515
+ try {
516
+ const response = await api.get('/update', { params: { force: force ? 1 : undefined } });
517
+ return response.data;
518
+ } catch (error) { return handleError(error); }
519
+ };
520
+
521
+ /** Upgrade bujang on the server, which then restarts (403 when read-only, 409 for a source checkout). */
522
+ export const installUpdate = async (): Promise<UpdateResult> => {
523
+ try {
524
+ const response = await api.post('/update', {}, { timeout: 660_000 });
525
+ return response.data;
526
+ } catch (error) { return handleError(error); }
527
+ };
528
+
529
+ /** Secret names, their source and env shadowing (never the values). */
530
+ export const getSettingsSecrets = async (): Promise<SettingsSecrets> => {
531
+ try {
532
+ const response = await api.get('/settings/secrets');
533
+ return response.data;
534
+ } catch (error) { return handleError(error); }
535
+ };
536
+
537
+ export const getSshSettings = async (file?: string): Promise<SshSettings> => {
538
+ try {
539
+ const response = await api.get('/settings/ssh', { params: { file: file || undefined } });
540
+ return response.data;
541
+ } catch (error) { return handleError(error); }
542
+ };
543
+
544
+ /** The diff of an install (default) or remove, nothing written. */
545
+ export const planSshConfig = async (request: SshPlanRequest & { action?: 'install' | 'remove' }): Promise<SshPlan> => {
546
+ try {
547
+ const response = await api.post('/settings/ssh/plan', request);
548
+ return response.data;
549
+ } catch (error) { return handleError(error); }
550
+ };
551
+
552
+ export const installSshConfig = async (request: SshPlanRequest): Promise<SshPlan> => {
553
+ try {
554
+ const response = await api.post('/settings/ssh/install', request);
555
+ return response.data;
556
+ } catch (error) { return handleError(error); }
557
+ };
558
+
559
+ export const removeSshConfig = async (request: SshPlanRequest): Promise<SshPlan> => {
560
+ try {
561
+ const response = await api.post('/settings/ssh/remove', request);
562
+ return response.data;
563
+ } catch (error) { return handleError(error); }
564
+ };
565
+
566
+ /** `bujang ssh test`: read only, never prompts; can take up to ~3 x (timeout + 5) s. */
567
+ export const testSshConnections = async (
568
+ request: { clusters?: string[]; timeout?: number; file?: string } = {},
569
+ ): Promise<SshTestResponse> => {
570
+ const timeout = request.timeout ?? 10;
571
+ try {
572
+ const response = await api.post('/settings/ssh/test', request, { timeout: (3 * (timeout + 5) + 10) * 1000 });
573
+ return response.data;
574
+ } catch (error) { return handleError(error); }
575
+ };
576
+
577
+
431
578
  // Pipeline template file management (matching server endpoints)
432
579
  export const getPipelineTemplatesList = async (): Promise<string[]> => {
433
580
  try {