@milabench/bujang 0.1.2 → 0.1.4
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 +3 -2
- package/dist/api.d.ts +65 -1
- package/dist/context.d.ts +5 -10
- package/dist/index.d.ts +8 -3
- package/dist/index.js +4750 -2910
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +8 -1
- package/dist/routes.d.ts +1 -1
- package/dist/types.d.ts +332 -0
- package/dist/views/AgentActivityView.d.ts +2 -0
- package/dist/views/JobArtifacts.d.ts +9 -0
- package/dist/views/JobDataOverview.d.ts +9 -0
- package/dist/views/JobMarks.d.ts +17 -0
- package/dist/views/PipelineEditor.d.ts +24 -0
- package/dist/views/PipelineGraph.d.ts +49 -0
- package/dist/views/PipelinesView.d.ts +3 -0
- package/dist/views/SettingsView.d.ts +3 -0
- package/package.json +7 -1
- package/src/api.ts +206 -0
- package/src/context.tsx +7 -13
- package/src/index.ts +8 -3
- package/src/paths.ts +22 -6
- package/src/routes.tsx +5 -2
- package/src/types.ts +307 -0
- package/src/views/AgentActivityView.tsx +115 -5
- package/src/views/JobArtifacts.tsx +89 -0
- package/src/views/JobDataOverview.tsx +594 -0
- package/src/views/JobDetails.tsx +3 -0
- package/src/views/JobLogs.tsx +47 -162
- package/src/views/JobMarks.tsx +233 -0
- package/src/views/JobSubmit.tsx +4 -4
- package/src/views/JobsView.tsx +245 -54
- package/src/views/PipelineEditor.tsx +779 -0
- package/src/views/PipelineGraph.tsx +197 -0
- package/src/views/PipelinesView.tsx +363 -1087
- package/src/views/SettingsView.tsx +910 -0
package/src/types.ts
CHANGED
|
@@ -244,6 +244,21 @@ export interface PersitedJobInfo {
|
|
|
244
244
|
acc: SlurmJobAccounting;
|
|
245
245
|
/** Submitted by an agent through the MCP server */
|
|
246
246
|
agent?: AgentTag | null;
|
|
247
|
+
/** Marked important by the user */
|
|
248
|
+
important?: boolean;
|
|
249
|
+
/** The manual groups of the job (groups/<group>/<job id>) */
|
|
250
|
+
groups?: string[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** GET/POST /jobs/<jr>/marks: whether a job is important, its groups, every group, git */
|
|
254
|
+
export interface JobMarks {
|
|
255
|
+
jr_job_id: string;
|
|
256
|
+
important: boolean;
|
|
257
|
+
groups: string[];
|
|
258
|
+
/** every group known, with its number of jobs */
|
|
259
|
+
all_groups: Record<string, number>;
|
|
260
|
+
/** the local cache is in a git repository: the job folder can be committed */
|
|
261
|
+
git: boolean;
|
|
247
262
|
}
|
|
248
263
|
|
|
249
264
|
export interface SlurmPartition {
|
|
@@ -330,6 +345,8 @@ export interface PipelineRunResponse {
|
|
|
330
345
|
success: boolean;
|
|
331
346
|
run_id: string;
|
|
332
347
|
name: string;
|
|
348
|
+
/** the saved pipeline it was started from (null for a definition sent as is) */
|
|
349
|
+
template?: string | null;
|
|
333
350
|
}
|
|
334
351
|
|
|
335
352
|
/** submitting: the jobs are being submitted; failed: the submission failed (nothing runs) */
|
|
@@ -339,6 +356,8 @@ export type PipelineSubmissionStatus = 'submitting' | 'submitted' | 'failed';
|
|
|
339
356
|
export interface PipelineRunSummary {
|
|
340
357
|
run_id: string;
|
|
341
358
|
name: string;
|
|
359
|
+
/** the saved pipeline it was started from; runs older than this field have none */
|
|
360
|
+
template?: string | null;
|
|
342
361
|
started: number;
|
|
343
362
|
status: PipelineSubmissionStatus;
|
|
344
363
|
error?: string | null;
|
|
@@ -347,6 +366,10 @@ export interface PipelineRunSummary {
|
|
|
347
366
|
/** A step of a run with its current state (sacct/squeue state, HELD, or the ssh step state) */
|
|
348
367
|
export interface PipelineRunStep extends PipelineJob {
|
|
349
368
|
step?: string;
|
|
369
|
+
/** the value of the sweep variable of its parallel group (what tells it apart from its siblings) */
|
|
370
|
+
sweep?: string;
|
|
371
|
+
/** the env variable `sweep` is the value of */
|
|
372
|
+
sweep_key?: string;
|
|
350
373
|
after?: string[];
|
|
351
374
|
held?: boolean;
|
|
352
375
|
state?: string;
|
|
@@ -362,6 +385,8 @@ export interface PipelineRunStatus {
|
|
|
362
385
|
state?: 'running' | 'failing' | 'failed' | 'completed' | 'unknown';
|
|
363
386
|
steps?: PipelineRunStep[];
|
|
364
387
|
log?: string;
|
|
388
|
+
/** the definition the run was started with (the saved pipeline may have changed since) */
|
|
389
|
+
definition?: PipelineNode | null;
|
|
365
390
|
}
|
|
366
391
|
|
|
367
392
|
export interface PipelineSequential {
|
|
@@ -374,6 +399,8 @@ export interface PipelineParallel {
|
|
|
374
399
|
type: 'parallel';
|
|
375
400
|
name: string;
|
|
376
401
|
jobs: PipelineNode[];
|
|
402
|
+
/** display only: the env variable that tells the children apart (e.g. ARGS), shown instead of their script */
|
|
403
|
+
sweep?: string;
|
|
377
404
|
}
|
|
378
405
|
|
|
379
406
|
export interface Pipeline {
|
|
@@ -418,6 +445,7 @@ export interface PipelineTemplate {
|
|
|
418
445
|
export interface PipelineTemplatePayload {
|
|
419
446
|
name: string;
|
|
420
447
|
type: 'pipeline';
|
|
448
|
+
description?: string;
|
|
421
449
|
definition: PipelineNode;
|
|
422
450
|
job_id: string | null;
|
|
423
451
|
}
|
|
@@ -540,3 +568,282 @@ export interface AgentSession {
|
|
|
540
568
|
pipelines: string[];
|
|
541
569
|
last_note: string | null;
|
|
542
570
|
}
|
|
571
|
+
|
|
572
|
+
// ─── Settings (/settings routes) ───────────────────────────────────
|
|
573
|
+
|
|
574
|
+
/** Where a value comes from: env var, a config source (plugin / user file), the default or the host's code. */
|
|
575
|
+
export interface SettingsOrigin {
|
|
576
|
+
kind: 'env' | 'default' | 'code' | 'workdir' | 'plugin' | 'user' | 'explicit' | 'defaults' | string;
|
|
577
|
+
name: string;
|
|
578
|
+
path: string | null;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** One editable field of the user file (local_cache, workdir, database_url). */
|
|
582
|
+
export interface SettingsField {
|
|
583
|
+
/** Value the running server uses (database_url: password masked). */
|
|
584
|
+
value: string | null;
|
|
585
|
+
/** Value in the user file, null when absent. */
|
|
586
|
+
file: string | null;
|
|
587
|
+
origin: SettingsOrigin;
|
|
588
|
+
/** Name of the BUJANG_* variable when it is set (it wins over the file). */
|
|
589
|
+
env: string | null;
|
|
590
|
+
/** Something above the user file sets it (env, code, another source): the file has no effect. */
|
|
591
|
+
overridden: boolean;
|
|
592
|
+
/** Only read at startup. */
|
|
593
|
+
restart: boolean;
|
|
594
|
+
/** The file differs from the running value and will apply after a restart. */
|
|
595
|
+
pending: boolean;
|
|
596
|
+
editable: boolean;
|
|
597
|
+
reason: string | null;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export type SettingsFieldName = 'local_cache' | 'workdir' | 'database_url';
|
|
601
|
+
|
|
602
|
+
export interface SettingsCluster {
|
|
603
|
+
name: string;
|
|
604
|
+
ssh: string;
|
|
605
|
+
remote_folder: string;
|
|
606
|
+
origin: SettingsOrigin;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export interface SettingsDatabaseTable {
|
|
610
|
+
name: string;
|
|
611
|
+
exists: boolean;
|
|
612
|
+
rows: number | null;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export interface SettingsDatabase {
|
|
616
|
+
host_provided: boolean;
|
|
617
|
+
kind: 'engine' | 'sessionmaker' | 'callable' | 'url' | null;
|
|
618
|
+
/** Password masked. */
|
|
619
|
+
url: string | null;
|
|
620
|
+
backend: string | null;
|
|
621
|
+
sqlite_path: string | null;
|
|
622
|
+
host: string | null;
|
|
623
|
+
name: string | null;
|
|
624
|
+
editable: boolean;
|
|
625
|
+
enabled: boolean;
|
|
626
|
+
tables: SettingsDatabaseTable[];
|
|
627
|
+
error: string | null;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export interface SettingsMcp {
|
|
631
|
+
/** Served by this app itself (bujang serve), at `path`. */
|
|
632
|
+
mounted: boolean;
|
|
633
|
+
path: string | null;
|
|
634
|
+
/** Absolute URL the server knows (BUJANG_URL, BujangConfig.mcp_url, serve_in_background). */
|
|
635
|
+
url: string | null;
|
|
636
|
+
/** Turned off (--no-mcp). */
|
|
637
|
+
disabled: boolean;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
export interface SettingsGeneral {
|
|
641
|
+
version: string;
|
|
642
|
+
plugins: { name: string; version: string | null; ssh_config: boolean }[];
|
|
643
|
+
default_cluster: string | null;
|
|
644
|
+
clusters: string[];
|
|
645
|
+
server: { standalone: boolean; host: string | null; url: string | null };
|
|
646
|
+
mcp: SettingsMcp;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export interface ConfigSourceInfo {
|
|
650
|
+
kind: string;
|
|
651
|
+
name: string;
|
|
652
|
+
path: string | null;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export interface SettingsInfo {
|
|
656
|
+
writable: boolean;
|
|
657
|
+
read_only_reason: string | null;
|
|
658
|
+
user_file: { path: string | null; exists: boolean; user_config_dir: string | null; error: string | null };
|
|
659
|
+
fields: Record<SettingsFieldName, SettingsField>;
|
|
660
|
+
secrets_file: string;
|
|
661
|
+
clusters: SettingsCluster[];
|
|
662
|
+
sources: {
|
|
663
|
+
sources: ConfigSourceInfo[];
|
|
664
|
+
plugins: { name: string; config_dir: string; version: string | null; ssh_config: string | null }[];
|
|
665
|
+
clusters: Record<string, { source: ConfigSourceInfo; sources: ConfigSourceInfo[] }>;
|
|
666
|
+
profiles: Record<string, { source: ConfigSourceInfo }>;
|
|
667
|
+
scripts: string[];
|
|
668
|
+
};
|
|
669
|
+
database: SettingsDatabase;
|
|
670
|
+
general: SettingsGeneral;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export interface SettingsUpdateResponse {
|
|
674
|
+
written: { path: string; keys: string[] } | null;
|
|
675
|
+
applied: string[];
|
|
676
|
+
restart: string[];
|
|
677
|
+
settings: SettingsInfo;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export interface SettingsSecret {
|
|
681
|
+
name: string;
|
|
682
|
+
source: 'file' | 'toml';
|
|
683
|
+
/** An environment variable of the same name wins over the file. */
|
|
684
|
+
env_shadowed: boolean;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
export interface SettingsSecrets {
|
|
688
|
+
secrets: SettingsSecret[];
|
|
689
|
+
/** The .secrets file the set / delete routes write (null: secrets.toml is used). */
|
|
690
|
+
file: string | null;
|
|
691
|
+
editable: boolean;
|
|
692
|
+
providers: { kind: string; name: string; available: boolean }[];
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
export interface SshPluginStatus {
|
|
696
|
+
name: string;
|
|
697
|
+
version: string | null;
|
|
698
|
+
ssh_config: string;
|
|
699
|
+
placeholders: string[];
|
|
700
|
+
aliases: string[];
|
|
701
|
+
installed: boolean;
|
|
702
|
+
installed_version: string | null;
|
|
703
|
+
up_to_date: boolean | null;
|
|
704
|
+
/** Placeholder values remembered in the block. */
|
|
705
|
+
values: Record<string, string>;
|
|
706
|
+
line: number | null;
|
|
707
|
+
duplicates: number;
|
|
708
|
+
/** Host entries outside the block with the same alias (ssh uses the first one). */
|
|
709
|
+
conflicts: { alias: string; line: number; text: string }[];
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
export interface SshSettings {
|
|
713
|
+
file: string;
|
|
714
|
+
default_file: string;
|
|
715
|
+
exists: boolean;
|
|
716
|
+
plugins: SshPluginStatus[];
|
|
717
|
+
other_blocks: { name: string; version: string | null }[];
|
|
718
|
+
error: string | null;
|
|
719
|
+
writable: boolean;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
export interface SshPlanRequest {
|
|
723
|
+
file?: string;
|
|
724
|
+
plugins?: string[];
|
|
725
|
+
values?: Record<string, string>;
|
|
726
|
+
dedupe?: boolean;
|
|
727
|
+
/** Install / remove: the `base` of the preview; the server refuses when the file changed since. */
|
|
728
|
+
base?: string;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export interface SshPlan {
|
|
732
|
+
file: string;
|
|
733
|
+
action: 'install' | 'remove';
|
|
734
|
+
changed: boolean;
|
|
735
|
+
diff: string;
|
|
736
|
+
messages: string[];
|
|
737
|
+
warnings: string[];
|
|
738
|
+
aliases: string[];
|
|
739
|
+
base: string;
|
|
740
|
+
// install / remove only
|
|
741
|
+
backup?: string | null;
|
|
742
|
+
written?: boolean;
|
|
743
|
+
alias_failures?: string[];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
export interface SshCheckResult {
|
|
747
|
+
host: string;
|
|
748
|
+
cluster: string;
|
|
749
|
+
ok: boolean;
|
|
750
|
+
ssh: 'ok' | 'auth' | 'hostkey' | 'dns' | 'timeout' | 'refused' | 'unreachable' | 'jump' | 'error' | '?';
|
|
751
|
+
master: string;
|
|
752
|
+
slurm: string;
|
|
753
|
+
workdir: string;
|
|
754
|
+
latency: number | null;
|
|
755
|
+
remote_hostname: string | null;
|
|
756
|
+
message: string;
|
|
757
|
+
hints: string[];
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
export interface SshTestResponse {
|
|
761
|
+
ok: boolean;
|
|
762
|
+
timeout: number;
|
|
763
|
+
file: string | null;
|
|
764
|
+
results: SshCheckResult[];
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** GET /update: the running version against the latest release on PyPI (checked once a day). */
|
|
768
|
+
export interface UpdateCheck {
|
|
769
|
+
/** BUJANG_UPDATE_CHECK=0 turns the check off */
|
|
770
|
+
enabled: boolean;
|
|
771
|
+
current: string;
|
|
772
|
+
latest: string | null;
|
|
773
|
+
update_available: boolean;
|
|
774
|
+
/** unix time of the last PyPI request */
|
|
775
|
+
checked_at: number | null;
|
|
776
|
+
error: string | null;
|
|
777
|
+
install: { kind: 'editable' | 'uv-tool' | 'pip' | 'uv-pip' | 'unknown'; command: string[] | null; hint: string | null };
|
|
778
|
+
/** POST /update works here (writable standalone server with a known installer) */
|
|
779
|
+
can_update: boolean;
|
|
780
|
+
reason: string | null;
|
|
781
|
+
running: boolean;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/** POST /update */
|
|
785
|
+
export interface UpdateResult {
|
|
786
|
+
success: boolean;
|
|
787
|
+
command: string[];
|
|
788
|
+
output: string;
|
|
789
|
+
previous: string;
|
|
790
|
+
installed?: string | null;
|
|
791
|
+
/** the server stops and starts the new version */
|
|
792
|
+
restarting?: boolean;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/** GET /organizers: per organizer folder (clusters, experiments, ...), its values and the jobs under each */
|
|
796
|
+
export interface OrganizerGroups {
|
|
797
|
+
name: string;
|
|
798
|
+
groups: { value: string; jobs: string[] }[];
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/** GET /jobs/<jr>/artifacts: the files of the artifact folders of a job (output/, runs/, results/) */
|
|
802
|
+
export interface JobArtifacts {
|
|
803
|
+
jr_job_id: string;
|
|
804
|
+
folders: string[];
|
|
805
|
+
files: { path: string; size: number; mtime: number; media_type: string; report: boolean }[];
|
|
806
|
+
truncated: boolean;
|
|
807
|
+
/** HTML reports run sandboxed: their scripts cannot reach the bujang API */
|
|
808
|
+
sandboxed: boolean;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/** A field of the rows of an event of a JSONL file (dotted name for nested values: gpudata.0.power) */
|
|
812
|
+
export interface JobDataField {
|
|
813
|
+
name: string;
|
|
814
|
+
type: 'number' | 'string' | 'boolean' | 'mixed';
|
|
815
|
+
count: number;
|
|
816
|
+
min?: number;
|
|
817
|
+
max?: number;
|
|
818
|
+
/** distinct values of a string field, null when there are too many */
|
|
819
|
+
values?: string[] | null;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** GET /jobs/<jr>/data: the JSONL files of the artifact folders of a job and their schema */
|
|
823
|
+
export interface JobData {
|
|
824
|
+
jr_job_id: string;
|
|
825
|
+
folders: string[];
|
|
826
|
+
files: {
|
|
827
|
+
path: string;
|
|
828
|
+
size?: number;
|
|
829
|
+
mtime?: number;
|
|
830
|
+
rows?: number;
|
|
831
|
+
/** per event ("" for the records without an event envelope), its row count and fields */
|
|
832
|
+
events?: { event: string; count: number; truncated: boolean; fields: JobDataField[] }[];
|
|
833
|
+
error?: string;
|
|
834
|
+
}[];
|
|
835
|
+
truncated: boolean;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/** GET /sync: when the job index was last synced with the clusters (POST /sync adds `synced`) */
|
|
839
|
+
export interface SyncStatus {
|
|
840
|
+
/** unix time of the last background sync, null before the first one */
|
|
841
|
+
last: number | null;
|
|
842
|
+
scanned: number | null;
|
|
843
|
+
clusters: Record<string, number | null>;
|
|
844
|
+
/** seconds between two background syncs, null when the server does not run them */
|
|
845
|
+
interval: number | null;
|
|
846
|
+
jobs: number;
|
|
847
|
+
synced?: Record<string, boolean>;
|
|
848
|
+
skipped?: string;
|
|
849
|
+
}
|
|
@@ -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}>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Badge, Box, Card, Heading, HStack, Link, Table, Text } from '@chakra-ui/react';
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { LuDownload, LuExternalLink, LuFileText } from 'react-icons/lu';
|
|
5
|
+
import { getJobArtifacts, jobArtifactUrl } from '../api';
|
|
6
|
+
import type { ApiError, JobArtifacts } from '../types';
|
|
7
|
+
|
|
8
|
+
const formatSize = (bytes: number) => {
|
|
9
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
10
|
+
const units = ['KB', 'MB', 'GB', 'TB'];
|
|
11
|
+
let value = bytes / 1024;
|
|
12
|
+
let unit = 0;
|
|
13
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
14
|
+
value /= 1024;
|
|
15
|
+
unit += 1;
|
|
16
|
+
}
|
|
17
|
+
return `${value.toFixed(value < 10 ? 1 : 0)} ${units[unit]}`;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The reports and other files of a job's results/ and output/ folders, delivered by the server:
|
|
22
|
+
* an HTML report opens in a new tab (its images and scripts load next to it), the rest downloads.
|
|
23
|
+
* Nothing is shown when the job has none.
|
|
24
|
+
*/
|
|
25
|
+
export const JobArtifactsCard: React.FC<{ jrJobId: string }> = ({ jrJobId }) => {
|
|
26
|
+
const { data, error } = useQuery<JobArtifacts, ApiError>({
|
|
27
|
+
queryKey: ['bujang-job-artifacts', jrJobId],
|
|
28
|
+
queryFn: () => getJobArtifacts(jrJobId),
|
|
29
|
+
staleTime: 30_000,
|
|
30
|
+
retry: false,
|
|
31
|
+
});
|
|
32
|
+
if (error || !data || data.files.length === 0) return null;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Card.Root bg="var(--color-bg-card)" border="1px solid" borderColor="var(--color-border)">
|
|
36
|
+
<Card.Header pb={0}>
|
|
37
|
+
<HStack justify="space-between" flexWrap="wrap" gap={2}>
|
|
38
|
+
<Heading size="md">Reports & artifacts</Heading>
|
|
39
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
40
|
+
{data.folders.map((f) => `${f}/`).join(', ')} of the job folder
|
|
41
|
+
{data.sandboxed ? ' · reports run sandboxed' : ''}
|
|
42
|
+
{data.truncated ? ' · first files only' : ''}
|
|
43
|
+
</Text>
|
|
44
|
+
</HStack>
|
|
45
|
+
</Card.Header>
|
|
46
|
+
<Card.Body>
|
|
47
|
+
<Table.Root size="sm" variant="line">
|
|
48
|
+
<Table.Body>
|
|
49
|
+
{data.files.map((file) => {
|
|
50
|
+
const url = jobArtifactUrl(jrJobId, file.path);
|
|
51
|
+
return (
|
|
52
|
+
<Table.Row key={file.path} borderColor="var(--color-border)">
|
|
53
|
+
<Table.Cell borderColor="var(--color-border)">
|
|
54
|
+
<HStack gap={2}>
|
|
55
|
+
{file.report && <LuFileText />}
|
|
56
|
+
<Link
|
|
57
|
+
href={url}
|
|
58
|
+
target="_blank"
|
|
59
|
+
rel="noopener noreferrer"
|
|
60
|
+
fontFamily="mono"
|
|
61
|
+
fontSize="sm"
|
|
62
|
+
color="var(--color-primary)"
|
|
63
|
+
{...(file.report ? {} : { download: file.path.split('/').pop() })}
|
|
64
|
+
>
|
|
65
|
+
{file.path}
|
|
66
|
+
</Link>
|
|
67
|
+
{file.report && <Badge size="sm" colorPalette="blue">report</Badge>}
|
|
68
|
+
</HStack>
|
|
69
|
+
</Table.Cell>
|
|
70
|
+
<Table.Cell borderColor="var(--color-border)" color="var(--color-text-muted)" fontSize="xs" whiteSpace="nowrap">
|
|
71
|
+
{formatSize(file.size)}
|
|
72
|
+
</Table.Cell>
|
|
73
|
+
<Table.Cell borderColor="var(--color-border)" color="var(--color-text-muted)" fontSize="xs" whiteSpace="nowrap">
|
|
74
|
+
{new Date(file.mtime * 1000).toLocaleString()}
|
|
75
|
+
</Table.Cell>
|
|
76
|
+
<Table.Cell borderColor="var(--color-border)" textAlign="end">
|
|
77
|
+
<Box as="span" color="var(--color-text-muted)" title={file.report ? 'Open in a new tab' : 'Download'}>
|
|
78
|
+
{file.report ? <LuExternalLink /> : <LuDownload />}
|
|
79
|
+
</Box>
|
|
80
|
+
</Table.Cell>
|
|
81
|
+
</Table.Row>
|
|
82
|
+
);
|
|
83
|
+
})}
|
|
84
|
+
</Table.Body>
|
|
85
|
+
</Table.Root>
|
|
86
|
+
</Card.Body>
|
|
87
|
+
</Card.Root>
|
|
88
|
+
);
|
|
89
|
+
};
|