@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/src/context.tsx CHANGED
@@ -35,6 +35,11 @@ export interface BujangProviderProps {
35
35
  * (e.g. to push job results to a database).
36
36
  */
37
37
  pushJobData?: (jrJobId: string) => Promise<PushJobDataResult>;
38
+ /**
39
+ * URL of the MCP endpoint shown on the Agent Activity page (e.g. when the host serves it on
40
+ * its own port). Default: what the server reports, else `<origin>/mcp` when it mounts it.
41
+ */
42
+ mcpUrl?: string;
38
43
  children?: React.ReactNode;
39
44
  }
40
45
 
@@ -45,6 +50,7 @@ export interface BujangContextValue {
45
50
  titleSuffix: string;
46
51
  colorMode?: 'light' | 'dark';
47
52
  pushJobData?: (jrJobId: string) => Promise<PushJobDataResult>;
53
+ mcpUrl?: string;
48
54
  }
49
55
 
50
56
  const defaultContext: BujangContextValue = {
@@ -65,6 +71,7 @@ export function BujangProvider({
65
71
  titleSuffix = 'bujang',
66
72
  colorMode,
67
73
  pushJobData,
74
+ mcpUrl,
68
75
  children,
69
76
  }: BujangProviderProps): React.ReactElement {
70
77
  // Configure synchronously so the children's first queries use it.
@@ -87,7 +94,8 @@ export function BujangProvider({
87
94
  titleSuffix,
88
95
  colorMode,
89
96
  pushJobData,
90
- }), [apiBase, basePath, paths, usePageTitle, titleSuffix, colorMode, pushJobData]);
97
+ mcpUrl,
98
+ }), [apiBase, basePath, paths, usePageTitle, titleSuffix, colorMode, pushJobData, mcpUrl]);
91
99
 
92
100
  return (
93
101
  <BujangContext.Provider value={value}>
package/src/index.ts CHANGED
@@ -3,12 +3,16 @@ export { JobsView } from './views/JobsView';
3
3
  export { JobSubmitView } from './views/JobSubmitView';
4
4
  export { JobDetailsView } from './views/JobDetails';
5
5
  export { JobLogsView } from './views/JobLogs';
6
- export { PipelinesView } from './views/PipelinesView';
6
+ export { PipelinesView, PipelineDetailsView } from './views/PipelinesView';
7
+ export { PipelineGraph, pipelineMermaid, pipelineSteps } from './views/PipelineGraph';
8
+ export type { GraphStep } from './views/PipelineGraph';
7
9
  export { ScheduledJobsView } from './views/ScheduledJobsView';
8
- export { AgentActivityView, AgentBadge } from './views/AgentActivityView';
10
+ export { AgentActivityView, AgentBadge, McpHelp } from './views/AgentActivityView';
11
+ export { SettingsView } from './views/SettingsView';
9
12
  export { JobSubmissionForm } from './views/JobSubmit';
10
13
  export type { JobSubmissionInitialData } from './views/JobSubmit';
11
14
  export { LogDisplay } from './views/LogDisplay';
15
+ export { JobArtifactsCard } from './views/JobArtifacts';
12
16
 
13
17
  // Provider, paths, routes
14
18
  export { BujangProvider, useBujang, useBujangPaths } from './context';
package/src/paths.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import type { IconType } from 'react-icons';
2
+ import { LuBot, LuCalendarClock, LuList, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
3
+
1
4
  /** Names of the bujang views. */
2
5
  export type BujangView =
3
6
  | 'jobs'
@@ -5,8 +8,10 @@ export type BujangView =
5
8
  | 'jobDetails'
6
9
  | 'jobLogs'
7
10
  | 'pipelines'
11
+ | 'pipelineDetails'
8
12
  | 'scheduled'
9
- | 'agent';
13
+ | 'agent'
14
+ | 'settings';
10
15
 
11
16
  /** URL builders the views use to link to each other. */
12
17
  export interface BujangPaths {
@@ -15,9 +20,13 @@ export interface BujangPaths {
15
20
  jobDetails: (slurmJobId: string | number, jrJobId: string) => string;
16
21
  jobLogs: (slurmJobId: string | number, jrJobId: string) => string;
17
22
  pipelines: () => string;
23
+ /** One saved pipeline: its graph and its runs, `runId` shows that run. */
24
+ pipelineDetails: (name: string, runId?: string) => string;
18
25
  scheduled: () => string;
19
26
  /** Agent activity, optionally filtered on one session. */
20
27
  agent: (session?: string) => string;
28
+ /** Settings: folders, database, SSH, secrets (read-only unless the server allows edits). */
29
+ settings: () => string;
21
30
  }
22
31
 
23
32
  /** Default URL layout (react-router patterns), relative to the host's basePath. */
@@ -27,8 +36,10 @@ export const defaultRoutePatterns: Record<BujangView, string> = {
27
36
  jobDetails: '/jobrunner/:slurmJobId/:jrJobId',
28
37
  jobLogs: '/joblogs/:slurmJobId/:jrJobId',
29
38
  pipelines: '/pipelines',
39
+ pipelineDetails: '/pipelines/:pipelineName',
30
40
  scheduled: '/scheduled',
31
41
  agent: '/agent',
42
+ settings: '/settings',
32
43
  };
33
44
 
34
45
  /** Normalise "", "/", "/x/" to "", "", "/x". */
@@ -48,8 +59,10 @@ export function createBujangPaths(basePath: string = ''): BujangPaths {
48
59
  jobDetails: (slurmJobId, jrJobId) => `${b}/jobrunner/${seg(slurmJobId)}/${seg(jrJobId)}`,
49
60
  jobLogs: (slurmJobId, jrJobId) => `${b}/joblogs/${seg(slurmJobId)}/${seg(jrJobId)}`,
50
61
  pipelines: () => `${b}/pipelines`,
62
+ pipelineDetails: (name, runId) => `${b}/pipelines/${seg(name)}${runId ? `?run=${encodeURIComponent(runId)}` : ''}`,
51
63
  scheduled: () => `${b}/scheduled`,
52
64
  agent: (session) => (session ? `${b}/agent?session=${encodeURIComponent(session)}` : `${b}/agent`),
65
+ settings: () => `${b}/settings`,
53
66
  };
54
67
  }
55
68
 
@@ -57,15 +70,18 @@ export interface BujangNavItem {
57
70
  view: BujangView;
58
71
  label: string;
59
72
  path: string;
73
+ /** Icon of the entry (a react-icons component); optional, hosts can ignore it. */
74
+ icon?: IconType;
60
75
  }
61
76
 
62
77
  /** Sidebar entries for the top-level bujang views. */
63
78
  export function bujangNavItems(paths: BujangPaths = createBujangPaths()): BujangNavItem[] {
64
79
  return [
65
- { view: 'jobs', label: 'Jobs', path: paths.jobs() },
66
- { view: 'submitJob', label: 'Submit Job', path: paths.submitJob() },
67
- { view: 'scheduled', label: 'Scheduled Jobs', path: paths.scheduled() },
68
- { view: 'pipelines', label: 'Pipelines', path: paths.pipelines() },
69
- { view: 'agent', label: 'Agent Activity', path: paths.agent() },
80
+ { view: 'jobs', label: 'Jobs', path: paths.jobs(), icon: LuList },
81
+ { view: 'submitJob', label: 'Submit Job', path: paths.submitJob(), icon: LuSend },
82
+ { view: 'scheduled', label: 'Scheduled Jobs', path: paths.scheduled(), icon: LuCalendarClock },
83
+ { view: 'pipelines', label: 'Pipelines', path: paths.pipelines(), icon: LuWorkflow },
84
+ { view: 'agent', label: 'Agent Activity', path: paths.agent(), icon: LuBot },
85
+ { view: 'settings', label: 'Settings', path: paths.settings(), icon: LuSettings },
70
86
  ];
71
87
  }
package/src/routes.tsx CHANGED
@@ -6,9 +6,10 @@ import { JobsView } from './views/JobsView';
6
6
  import { JobSubmitView } from './views/JobSubmitView';
7
7
  import { JobDetailsView } from './views/JobDetails';
8
8
  import { JobLogsView } from './views/JobLogs';
9
- import { PipelinesView } from './views/PipelinesView';
9
+ import { PipelineDetailsView, PipelinesView } from './views/PipelinesView';
10
10
  import { ScheduledJobsView } from './views/ScheduledJobsView';
11
11
  import { AgentActivityView } from './views/AgentActivityView';
12
+ import { SettingsView } from './views/SettingsView';
12
13
 
13
14
  export interface BujangRoutesOptions {
14
15
  /** Prefix the routes are mounted under, e.g. "/slurm". Must match BujangProvider's basePath. Default "". */
@@ -30,14 +31,16 @@ const elements: Record<BujangView, () => React.ReactElement> = {
30
31
  jobDetails: () => <JobDetailsView />,
31
32
  jobLogs: () => <JobLogsView />,
32
33
  pipelines: () => <PipelinesView />,
34
+ pipelineDetails: () => <PipelineDetailsView />,
33
35
  scheduled: () => <ScheduledJobsView />,
34
36
  agent: () => <AgentActivityView />,
37
+ settings: () => <SettingsView />,
35
38
  };
36
39
 
37
40
  /**
38
41
  * Route objects for the default bujang URL layout under `basePath`:
39
42
  * /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
40
- * /pipelines, /scheduled, /agent.
43
+ * /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /settings.
41
44
  */
42
45
  export function bujangRoutes(options: BujangRoutesOptions = {}): BujangRouteObject[] {
43
46
  const base = normalizeBasePath(options.basePath);
package/src/types.ts CHANGED
@@ -330,6 +330,8 @@ export interface PipelineRunResponse {
330
330
  success: boolean;
331
331
  run_id: string;
332
332
  name: string;
333
+ /** the saved pipeline it was started from (null for a definition sent as is) */
334
+ template?: string | null;
333
335
  }
334
336
 
335
337
  /** submitting: the jobs are being submitted; failed: the submission failed (nothing runs) */
@@ -339,6 +341,8 @@ export type PipelineSubmissionStatus = 'submitting' | 'submitted' | 'failed';
339
341
  export interface PipelineRunSummary {
340
342
  run_id: string;
341
343
  name: string;
344
+ /** the saved pipeline it was started from; runs older than this field have none */
345
+ template?: string | null;
342
346
  started: number;
343
347
  status: PipelineSubmissionStatus;
344
348
  error?: string | null;
@@ -347,6 +351,10 @@ export interface PipelineRunSummary {
347
351
  /** A step of a run with its current state (sacct/squeue state, HELD, or the ssh step state) */
348
352
  export interface PipelineRunStep extends PipelineJob {
349
353
  step?: string;
354
+ /** the value of the sweep variable of its parallel group (what tells it apart from its siblings) */
355
+ sweep?: string;
356
+ /** the env variable `sweep` is the value of */
357
+ sweep_key?: string;
350
358
  after?: string[];
351
359
  held?: boolean;
352
360
  state?: string;
@@ -362,6 +370,8 @@ export interface PipelineRunStatus {
362
370
  state?: 'running' | 'failing' | 'failed' | 'completed' | 'unknown';
363
371
  steps?: PipelineRunStep[];
364
372
  log?: string;
373
+ /** the definition the run was started with (the saved pipeline may have changed since) */
374
+ definition?: PipelineNode | null;
365
375
  }
366
376
 
367
377
  export interface PipelineSequential {
@@ -374,6 +384,8 @@ export interface PipelineParallel {
374
384
  type: 'parallel';
375
385
  name: string;
376
386
  jobs: PipelineNode[];
387
+ /** display only: the env variable that tells the children apart (e.g. ARGS), shown instead of their script */
388
+ sweep?: string;
377
389
  }
378
390
 
379
391
  export interface Pipeline {
@@ -418,6 +430,7 @@ export interface PipelineTemplate {
418
430
  export interface PipelineTemplatePayload {
419
431
  name: string;
420
432
  type: 'pipeline';
433
+ description?: string;
421
434
  definition: PipelineNode;
422
435
  job_id: string | null;
423
436
  }
@@ -540,3 +553,255 @@ export interface AgentSession {
540
553
  pipelines: string[];
541
554
  last_note: string | null;
542
555
  }
556
+
557
+ // ─── Settings (/settings routes) ───────────────────────────────────
558
+
559
+ /** Where a value comes from: env var, a config source (plugin / user file), the default or the host's code. */
560
+ export interface SettingsOrigin {
561
+ kind: 'env' | 'default' | 'code' | 'workdir' | 'plugin' | 'user' | 'explicit' | 'defaults' | string;
562
+ name: string;
563
+ path: string | null;
564
+ }
565
+
566
+ /** One editable field of the user file (local_cache, workdir, database_url). */
567
+ export interface SettingsField {
568
+ /** Value the running server uses (database_url: password masked). */
569
+ value: string | null;
570
+ /** Value in the user file, null when absent. */
571
+ file: string | null;
572
+ origin: SettingsOrigin;
573
+ /** Name of the BUJANG_* variable when it is set (it wins over the file). */
574
+ env: string | null;
575
+ /** Something above the user file sets it (env, code, another source): the file has no effect. */
576
+ overridden: boolean;
577
+ /** Only read at startup. */
578
+ restart: boolean;
579
+ /** The file differs from the running value and will apply after a restart. */
580
+ pending: boolean;
581
+ editable: boolean;
582
+ reason: string | null;
583
+ }
584
+
585
+ export type SettingsFieldName = 'local_cache' | 'workdir' | 'database_url';
586
+
587
+ export interface SettingsCluster {
588
+ name: string;
589
+ ssh: string;
590
+ remote_folder: string;
591
+ origin: SettingsOrigin;
592
+ }
593
+
594
+ export interface SettingsDatabaseTable {
595
+ name: string;
596
+ exists: boolean;
597
+ rows: number | null;
598
+ }
599
+
600
+ export interface SettingsDatabase {
601
+ host_provided: boolean;
602
+ kind: 'engine' | 'sessionmaker' | 'callable' | 'url' | null;
603
+ /** Password masked. */
604
+ url: string | null;
605
+ backend: string | null;
606
+ sqlite_path: string | null;
607
+ host: string | null;
608
+ name: string | null;
609
+ editable: boolean;
610
+ enabled: boolean;
611
+ tables: SettingsDatabaseTable[];
612
+ error: string | null;
613
+ }
614
+
615
+ export interface SettingsMcp {
616
+ /** Served by this app itself (bujang serve), at `path`. */
617
+ mounted: boolean;
618
+ path: string | null;
619
+ /** Absolute URL the server knows (BUJANG_URL, BujangConfig.mcp_url, serve_in_background). */
620
+ url: string | null;
621
+ /** Turned off (--no-mcp). */
622
+ disabled: boolean;
623
+ }
624
+
625
+ export interface SettingsGeneral {
626
+ version: string;
627
+ plugins: { name: string; version: string | null; ssh_config: boolean }[];
628
+ default_cluster: string | null;
629
+ clusters: string[];
630
+ server: { standalone: boolean; host: string | null; url: string | null };
631
+ mcp: SettingsMcp;
632
+ }
633
+
634
+ export interface ConfigSourceInfo {
635
+ kind: string;
636
+ name: string;
637
+ path: string | null;
638
+ }
639
+
640
+ export interface SettingsInfo {
641
+ writable: boolean;
642
+ read_only_reason: string | null;
643
+ user_file: { path: string | null; exists: boolean; user_config_dir: string | null; error: string | null };
644
+ fields: Record<SettingsFieldName, SettingsField>;
645
+ secrets_file: string;
646
+ clusters: SettingsCluster[];
647
+ sources: {
648
+ sources: ConfigSourceInfo[];
649
+ plugins: { name: string; config_dir: string; version: string | null; ssh_config: string | null }[];
650
+ clusters: Record<string, { source: ConfigSourceInfo; sources: ConfigSourceInfo[] }>;
651
+ profiles: Record<string, { source: ConfigSourceInfo }>;
652
+ scripts: string[];
653
+ };
654
+ database: SettingsDatabase;
655
+ general: SettingsGeneral;
656
+ }
657
+
658
+ export interface SettingsUpdateResponse {
659
+ written: { path: string; keys: string[] } | null;
660
+ applied: string[];
661
+ restart: string[];
662
+ settings: SettingsInfo;
663
+ }
664
+
665
+ export interface SettingsSecret {
666
+ name: string;
667
+ source: 'file' | 'toml';
668
+ /** An environment variable of the same name wins over the file. */
669
+ env_shadowed: boolean;
670
+ }
671
+
672
+ export interface SettingsSecrets {
673
+ secrets: SettingsSecret[];
674
+ /** The .secrets file the set / delete routes write (null: secrets.toml is used). */
675
+ file: string | null;
676
+ editable: boolean;
677
+ providers: { kind: string; name: string; available: boolean }[];
678
+ }
679
+
680
+ export interface SshPluginStatus {
681
+ name: string;
682
+ version: string | null;
683
+ ssh_config: string;
684
+ placeholders: string[];
685
+ aliases: string[];
686
+ installed: boolean;
687
+ installed_version: string | null;
688
+ up_to_date: boolean | null;
689
+ /** Placeholder values remembered in the block. */
690
+ values: Record<string, string>;
691
+ line: number | null;
692
+ duplicates: number;
693
+ /** Host entries outside the block with the same alias (ssh uses the first one). */
694
+ conflicts: { alias: string; line: number; text: string }[];
695
+ }
696
+
697
+ export interface SshSettings {
698
+ file: string;
699
+ default_file: string;
700
+ exists: boolean;
701
+ plugins: SshPluginStatus[];
702
+ other_blocks: { name: string; version: string | null }[];
703
+ error: string | null;
704
+ writable: boolean;
705
+ }
706
+
707
+ export interface SshPlanRequest {
708
+ file?: string;
709
+ plugins?: string[];
710
+ values?: Record<string, string>;
711
+ dedupe?: boolean;
712
+ /** Install / remove: the `base` of the preview; the server refuses when the file changed since. */
713
+ base?: string;
714
+ }
715
+
716
+ export interface SshPlan {
717
+ file: string;
718
+ action: 'install' | 'remove';
719
+ changed: boolean;
720
+ diff: string;
721
+ messages: string[];
722
+ warnings: string[];
723
+ aliases: string[];
724
+ base: string;
725
+ // install / remove only
726
+ backup?: string | null;
727
+ written?: boolean;
728
+ alias_failures?: string[];
729
+ }
730
+
731
+ export interface SshCheckResult {
732
+ host: string;
733
+ cluster: string;
734
+ ok: boolean;
735
+ ssh: 'ok' | 'auth' | 'hostkey' | 'dns' | 'timeout' | 'refused' | 'unreachable' | 'jump' | 'error' | '?';
736
+ master: string;
737
+ slurm: string;
738
+ workdir: string;
739
+ latency: number | null;
740
+ remote_hostname: string | null;
741
+ message: string;
742
+ hints: string[];
743
+ }
744
+
745
+ export interface SshTestResponse {
746
+ ok: boolean;
747
+ timeout: number;
748
+ file: string | null;
749
+ results: SshCheckResult[];
750
+ }
751
+
752
+ /** GET /update: the running version against the latest release on PyPI (checked once a day). */
753
+ export interface UpdateCheck {
754
+ /** BUJANG_UPDATE_CHECK=0 turns the check off */
755
+ enabled: boolean;
756
+ current: string;
757
+ latest: string | null;
758
+ update_available: boolean;
759
+ /** unix time of the last PyPI request */
760
+ checked_at: number | null;
761
+ error: string | null;
762
+ install: { kind: 'editable' | 'uv-tool' | 'pip' | 'uv-pip' | 'unknown'; command: string[] | null; hint: string | null };
763
+ /** POST /update works here (writable standalone server with a known installer) */
764
+ can_update: boolean;
765
+ reason: string | null;
766
+ running: boolean;
767
+ }
768
+
769
+ /** POST /update */
770
+ export interface UpdateResult {
771
+ success: boolean;
772
+ command: string[];
773
+ output: string;
774
+ previous: string;
775
+ installed?: string | null;
776
+ /** the server stops and starts the new version */
777
+ restarting?: boolean;
778
+ }
779
+
780
+ /** GET /organizers: per organizer folder (clusters, experiments, ...), its values and the jobs under each */
781
+ export interface OrganizerGroups {
782
+ name: string;
783
+ groups: { value: string; jobs: string[] }[];
784
+ }
785
+
786
+ /** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (results/, output/) */
787
+ export interface JobArtifacts {
788
+ jr_job_id: string;
789
+ folders: string[];
790
+ files: { path: string; size: number; mtime: number; media_type: string; report: boolean }[];
791
+ truncated: boolean;
792
+ /** HTML reports run sandboxed: their scripts cannot reach the bujang API */
793
+ sandboxed: boolean;
794
+ }
795
+
796
+ /** GET /sync: when the job index was last synced with the clusters (POST /sync adds `synced`) */
797
+ export interface SyncStatus {
798
+ /** unix time of the last background sync, null before the first one */
799
+ last: number | null;
800
+ scanned: number | null;
801
+ clusters: Record<string, number | null>;
802
+ /** seconds between two background syncs, null when the server does not run them */
803
+ interval: number | null;
804
+ jobs: number;
805
+ synced?: Record<string, boolean>;
806
+ skipped?: string;
807
+ }
@@ -1,6 +1,6 @@
1
1
  import React, { useMemo, useState } from 'react';
2
2
  import { Link as RouterLink, useSearchParams } from 'react-router-dom';
3
- import { useBujangPaths } from '../context';
3
+ import { useBujang, useBujangPaths } from '../context';
4
4
  import type { BujangPaths } from '../paths';
5
5
  import {
6
6
  Box,
@@ -13,12 +13,13 @@ import {
13
13
  Code,
14
14
  Link,
15
15
  Button,
16
+ IconButton,
16
17
  } from '@chakra-ui/react';
17
18
  import { useQuery } from '@tanstack/react-query';
18
- import { LuBot, LuChevronDown, LuChevronRight } from 'react-icons/lu';
19
+ import { LuBot, LuCheck, LuChevronDown, LuChevronRight, LuCopy } from 'react-icons/lu';
19
20
  import { Tooltip } from '../components/tooltip';
20
- import { getAgentActivity, getAgentSessions } from '../api';
21
- import type { AgentEvent, AgentSession, AgentTag } from '../types';
21
+ import { getAgentActivity, getAgentSessions, getSettings } from '../api';
22
+ import type { AgentEvent, AgentSession, AgentTag, SettingsInfo } from '../types';
22
23
  import { usePageTitle } from '../hooks/usePageTitle';
23
24
 
24
25
  const POLL_MS = 5_000;
@@ -63,6 +64,112 @@ export const AgentBadge: React.FC<{ tag?: AgentTag | null }> = ({ tag }) => {
63
64
  );
64
65
  };
65
66
 
67
+ /**
68
+ * Where agents connect: `mcpUrl` of BujangProvider, else the URL the server reports, else
69
+ * `<origin>/mcp` when this server mounts the endpoint itself. null: nothing to show (the host does
70
+ * not serve it, or does not say where); 'off': `bujang serve --no-mcp`.
71
+ */
72
+ function useMcpUrl(): string | 'off' | null | undefined {
73
+ const { mcpUrl } = useBujang();
74
+ const { data, isError } = useQuery<SettingsInfo>({
75
+ queryKey: ['bujang-settings'],
76
+ queryFn: getSettings,
77
+ enabled: !mcpUrl,
78
+ retry: false,
79
+ staleTime: 60_000,
80
+ });
81
+ if (mcpUrl) return mcpUrl;
82
+ if (isError) return null;
83
+ if (!data) return undefined;
84
+ const mcp = data.general.mcp;
85
+ // mounted on this app: where the browser reached it works behind any host, port or tunnel
86
+ if (mcp.mounted) return `${window.location.origin}${mcp.path || '/mcp'}`;
87
+ if (mcp.url) return mcp.url;
88
+ if (mcp.disabled) return 'off';
89
+ return null;
90
+ }
91
+
92
+ async function copyText(text: string): Promise<boolean> {
93
+ try {
94
+ await navigator.clipboard.writeText(text);
95
+ return true;
96
+ } catch {
97
+ // http on a non-localhost origin: no clipboard API
98
+ const area = document.createElement('textarea');
99
+ area.value = text;
100
+ document.body.appendChild(area);
101
+ area.select();
102
+ const ok = document.execCommand('copy');
103
+ area.remove();
104
+ return ok;
105
+ }
106
+ }
107
+
108
+ /** How to connect an agent to the MCP endpoint (hidden when the server does not say where it is). */
109
+ export const McpHelp: React.FC = () => {
110
+ const url = useMcpUrl();
111
+ const [copied, setCopied] = useState(false);
112
+ if (url === undefined || url === null) return null;
113
+
114
+ const box = {
115
+ mb: 6,
116
+ px: 4,
117
+ py: 3,
118
+ borderWidth: '1px',
119
+ borderRadius: 'md',
120
+ borderColor: 'var(--color-border)',
121
+ bg: 'var(--color-bg-card)',
122
+ } as const;
123
+
124
+ if (url === 'off') {
125
+ return (
126
+ <Box {...box}>
127
+ <Text fontSize="sm" color="var(--color-text-muted)">
128
+ MCP endpoint is off (<Code fontSize="xs">--no-mcp</Code>): agents cannot connect to this server.
129
+ </Text>
130
+ </Box>
131
+ );
132
+ }
133
+
134
+ const command = `claude mcp add --transport http bujang ${url} --header "X-Agent-Name: my-agent"`;
135
+ const copy = async () => {
136
+ if (await copyText(command)) {
137
+ setCopied(true);
138
+ window.setTimeout(() => setCopied(false), 1500);
139
+ }
140
+ };
141
+ return (
142
+ <Box {...box}>
143
+ <Text fontSize="sm" fontWeight="semibold" color="var(--color-text)" mb={2}>
144
+ Connect an agent: MCP endpoint <Code fontSize="xs">{url}</Code>
145
+ </Text>
146
+ <HStack gap={2} align="center">
147
+ <Code
148
+ flex={1}
149
+ minW={0}
150
+ display="block"
151
+ whiteSpace="pre-wrap"
152
+ wordBreak="break-all"
153
+ p={2}
154
+ fontSize="xs"
155
+ bg="var(--color-bg-stripe)"
156
+ color="var(--color-text)"
157
+ >
158
+ {command}
159
+ </Code>
160
+ <Tooltip content={copied ? 'Copied' : 'Copy the command'} showArrow>
161
+ <IconButton aria-label="Copy the command" size="sm" variant="outline" onClick={copy}>
162
+ {copied ? <LuCheck /> : <LuCopy />}
163
+ </IconButton>
164
+ </Tooltip>
165
+ </HStack>
166
+ <Text fontSize="xs" mt={2} color="var(--color-text-muted)">
167
+ The <Code fontSize="xs">X-Agent-Name</Code> header names the agent in this activity log.
168
+ </Text>
169
+ </Box>
170
+ );
171
+ };
172
+
66
173
  const SessionCard: React.FC<{ s: AgentSession; selected: boolean; onSelect: () => void }> = ({ s, selected, onSelect }) => (
67
174
  <Box
68
175
  as="button"
@@ -98,6 +205,8 @@ const ResultLinks: React.FC<{ result?: Record<string, unknown> | null }> = ({ re
98
205
  if (!result) return null;
99
206
  const jr = result.jr_job_id as string | undefined;
100
207
  const run = result.run_id as string | undefined;
208
+ // the saved pipeline it was started from, else its name (the page lists the runs of that name)
209
+ const pipeline = (result.template ?? result.name) as string | undefined;
101
210
  return (
102
211
  <>
103
212
  {jr && (
@@ -107,7 +216,7 @@ const ResultLinks: React.FC<{ result?: Record<string, unknown> | null }> = ({ re
107
216
  )}
108
217
  {run && (
109
218
  <Link asChild color="var(--color-link, #3182ce)" fontFamily="mono" fontSize="sm">
110
- <RouterLink to={paths.pipelines()}>pipeline {run}</RouterLink>
219
+ <RouterLink to={pipeline ? paths.pipelineDetails(pipeline, run) : paths.pipelines()}>pipeline {run}</RouterLink>
111
220
  </Link>
112
221
  )}
113
222
  </>
@@ -227,6 +336,7 @@ export const AgentActivityView: React.FC = () => {
227
336
  What the agents connected through the bujang MCP server are doing: their notes, the jobs
228
337
  they submitted and why, and every call they made to the API. Refreshes every 5 seconds.
229
338
  </Text>
339
+ <McpHelp />
230
340
 
231
341
  <HStack align="start" gap={6}>
232
342
  <VStack w="340px" flexShrink={0} align="stretch" gap={2}>