@milabench/bujang 0.1.12 → 0.1.14
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/api.d.ts +23 -5
- package/dist/constants.d.ts +6 -0
- package/dist/index.js +6231 -5068
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +113 -12
- package/dist/views/JobDataOverview.d.ts +4 -3
- package/dist/views/OverviewPanels.d.ts +37 -0
- package/dist/views/PipelineEditor.d.ts +5 -0
- package/dist/views/PipelinesView.d.ts +1 -1
- package/dist/views/ScheduleDialog.d.ts +14 -0
- package/dist/views/SweepDialog.d.ts +51 -0
- package/dist/views/dataCharts.d.ts +56 -0
- package/package.json +1 -1
- package/src/api.ts +52 -4
- package/src/constants.ts +3 -0
- package/src/types.ts +113 -13
- package/src/views/JanitorView.tsx +101 -32
- package/src/views/JobDataOverview.tsx +126 -213
- package/src/views/JobLogs.tsx +13 -6
- package/src/views/JobSubmit.tsx +377 -318
- package/src/views/JobsView.tsx +34 -21
- package/src/views/LogDisplay.tsx +2 -2
- package/src/views/OverviewPanels.tsx +341 -0
- package/src/views/PipelineEditor.tsx +3 -3
- package/src/views/PipelinesView.tsx +387 -164
- package/src/views/ScheduleDialog.tsx +98 -0
- package/src/views/SettingsView.tsx +131 -1
- package/src/views/SweepDialog.tsx +520 -0
- package/src/views/dataCharts.tsx +261 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schedule: the job of the submit page as a scheduled job (a name and a cron expression). The
|
|
3
|
+
* submit page builds the request (script, Slurm settings) and closes the dialog once it is saved.
|
|
4
|
+
*/
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
import { Button, Dialog, HStack, Input, NativeSelect, Text, VStack } from '@chakra-ui/react';
|
|
7
|
+
|
|
8
|
+
const CRON_PRESETS: { label: string; cron: string }[] = [
|
|
9
|
+
{ label: 'Daily at midnight', cron: '0 0 * * *' },
|
|
10
|
+
{ label: 'Weekly on Sunday at 2am', cron: '0 2 * * 0' },
|
|
11
|
+
{ label: 'Monthly on the 1st', cron: '0 0 1 * *' },
|
|
12
|
+
{ label: 'Weekdays at midnight', cron: '0 0 * * 1-5' },
|
|
13
|
+
{ label: 'Custom', cron: '' },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
interface ScheduleDialogProps {
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
onSave: (name: string, cron: string) => void;
|
|
19
|
+
isSaving: boolean;
|
|
20
|
+
/** default name: the template or job name */
|
|
21
|
+
baseName: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ScheduleDialog: React.FC<ScheduleDialogProps> = ({ onClose, onSave, isSaving, baseName }) => {
|
|
25
|
+
const [name, setName] = useState(baseName.replace(/\.sh$/, ''));
|
|
26
|
+
const [preset, setPreset] = useState(CRON_PRESETS[0].cron);
|
|
27
|
+
const [custom, setCustom] = useState(CRON_PRESETS[0].cron);
|
|
28
|
+
const cron = (preset === '' ? custom : preset).trim();
|
|
29
|
+
const issue = !name.trim() ? 'give the schedule a name' : !cron ? 'give a cron expression' : null;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Dialog.Root open onOpenChange={(details) => { if (!details.open) onClose(); }} size="md">
|
|
33
|
+
<Dialog.Backdrop />
|
|
34
|
+
<Dialog.Positioner>
|
|
35
|
+
<Dialog.Content>
|
|
36
|
+
<Dialog.Header py={3} px={4} borderBottom="1px solid" borderColor="var(--color-border)">
|
|
37
|
+
<Dialog.Title fontSize="md" color="var(--color-text)">Schedule this job</Dialog.Title>
|
|
38
|
+
</Dialog.Header>
|
|
39
|
+
<Dialog.Body px={4} py={4}>
|
|
40
|
+
<VStack align="stretch" gap={3}>
|
|
41
|
+
<HStack gap={3}>
|
|
42
|
+
<Text minW="90px" fontSize="sm" color="var(--color-text)">Name</Text>
|
|
43
|
+
<Input size="sm" value={name} onChange={(e) => setName(e.target.value)} placeholder="Schedule name" />
|
|
44
|
+
</HStack>
|
|
45
|
+
<HStack gap={3}>
|
|
46
|
+
<Text minW="90px" fontSize="sm" color="var(--color-text)">When</Text>
|
|
47
|
+
<NativeSelect.Root size="sm">
|
|
48
|
+
<NativeSelect.Field
|
|
49
|
+
value={preset}
|
|
50
|
+
onChange={(e) => {
|
|
51
|
+
setPreset(e.target.value);
|
|
52
|
+
if (e.target.value !== '') setCustom(e.target.value);
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
{CRON_PRESETS.map(p => (
|
|
56
|
+
<option key={p.cron || '__custom'} value={p.cron}>{p.label}</option>
|
|
57
|
+
))}
|
|
58
|
+
</NativeSelect.Field>
|
|
59
|
+
<NativeSelect.Indicator />
|
|
60
|
+
</NativeSelect.Root>
|
|
61
|
+
</HStack>
|
|
62
|
+
<HStack gap={3}>
|
|
63
|
+
<Text minW="90px" fontSize="sm" color="var(--color-text)">Cron</Text>
|
|
64
|
+
<Input
|
|
65
|
+
size="sm"
|
|
66
|
+
fontFamily="mono"
|
|
67
|
+
placeholder="* * * * *"
|
|
68
|
+
value={preset === '' ? custom : preset}
|
|
69
|
+
onChange={(e) => { setCustom(e.target.value); setPreset(''); }}
|
|
70
|
+
/>
|
|
71
|
+
</HStack>
|
|
72
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
73
|
+
Saves the script and the Slurm settings of the form as they are now.
|
|
74
|
+
</Text>
|
|
75
|
+
</VStack>
|
|
76
|
+
</Dialog.Body>
|
|
77
|
+
<Dialog.Footer py={3} px={4} borderTop="1px solid" borderColor="var(--color-border)">
|
|
78
|
+
{issue && <Text fontSize="sm" color="var(--color-text-muted)" mr="auto">{issue}</Text>}
|
|
79
|
+
<Button variant="ghost" size="sm" onClick={onClose} color="var(--color-text)">Cancel</Button>
|
|
80
|
+
<Button
|
|
81
|
+
size="sm"
|
|
82
|
+
onClick={() => onSave(name.trim(), cron)}
|
|
83
|
+
disabled={!!issue}
|
|
84
|
+
loading={isSaving}
|
|
85
|
+
bg="var(--color-primary)"
|
|
86
|
+
color="var(--color-primary-text)"
|
|
87
|
+
_hover={{ bg: 'var(--color-primary-hover)' }}
|
|
88
|
+
>
|
|
89
|
+
Schedule
|
|
90
|
+
</Button>
|
|
91
|
+
</Dialog.Footer>
|
|
92
|
+
</Dialog.Content>
|
|
93
|
+
</Dialog.Positioner>
|
|
94
|
+
</Dialog.Root>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export default ScheduleDialog;
|
|
@@ -16,10 +16,12 @@ import {
|
|
|
16
16
|
NativeSelect,
|
|
17
17
|
Checkbox,
|
|
18
18
|
Alert,
|
|
19
|
+
Textarea,
|
|
19
20
|
} from '@chakra-ui/react';
|
|
20
21
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
21
22
|
import { Link } from 'react-router-dom';
|
|
22
23
|
import {
|
|
24
|
+
LuBot,
|
|
23
25
|
LuDatabase,
|
|
24
26
|
LuFolder,
|
|
25
27
|
LuInfo,
|
|
@@ -86,6 +88,7 @@ const SECTIONS: { id: string; label: string }[] = [
|
|
|
86
88
|
{ id: 'secrets', label: 'Secrets' },
|
|
87
89
|
{ id: 'folders', label: 'Folders' },
|
|
88
90
|
{ id: 'database', label: 'Database' },
|
|
91
|
+
{ id: 'mcp', label: 'Agents (MCP)' },
|
|
89
92
|
];
|
|
90
93
|
|
|
91
94
|
const formatBytes = (n: number | null | undefined) => {
|
|
@@ -160,7 +163,7 @@ const OriginBadge: React.FC<{ origin: SettingsOrigin }> = ({ origin }) => {
|
|
|
160
163
|
};
|
|
161
164
|
|
|
162
165
|
/** Badges of an editable field: origin, env override, restart needed */
|
|
163
|
-
const FieldBadges: React.FC<{ field: SettingsField
|
|
166
|
+
const FieldBadges: React.FC<{ field: SettingsField<unknown>; fileLabel?: string }> = ({ field }) => (
|
|
164
167
|
<HStack gap={1} wrap="wrap">
|
|
165
168
|
<OriginBadge origin={field.origin} />
|
|
166
169
|
{field.env && (
|
|
@@ -231,6 +234,45 @@ const GeneralCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
231
234
|
|
|
232
235
|
// ─── Folders ────────────────────────────────────────────────────────
|
|
233
236
|
|
|
237
|
+
/** show_examples: list the example scripts and pipelines (built-in, *_example*); saved at once */
|
|
238
|
+
const ExamplesToggle: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
239
|
+
const queryClient = useQueryClient();
|
|
240
|
+
const field = info.fields.show_examples;
|
|
241
|
+
const editable = info.writable && !!info.user_file.path && !field.overridden;
|
|
242
|
+
const save = useMutation({
|
|
243
|
+
mutationFn: (value: boolean) => updateSettings({ show_examples: value }),
|
|
244
|
+
onSuccess: (out) => {
|
|
245
|
+
queryClient.setQueryData(SETTINGS_KEY, out.settings);
|
|
246
|
+
// the dropdowns of the submit, scheduled jobs and pipelines pages
|
|
247
|
+
queryClient.invalidateQueries({ queryKey: ['slurm-templates'] });
|
|
248
|
+
queryClient.invalidateQueries({ queryKey: ['pipeline-template-files'] });
|
|
249
|
+
},
|
|
250
|
+
onError: fail('Could not save show_examples'),
|
|
251
|
+
});
|
|
252
|
+
return (
|
|
253
|
+
<Field.Root>
|
|
254
|
+
<HStack justify="space-between" w="100%" wrap="wrap" gap={2}>
|
|
255
|
+
<Checkbox.Root
|
|
256
|
+
checked={field.value !== false}
|
|
257
|
+
disabled={!editable || save.isPending}
|
|
258
|
+
onCheckedChange={(e) => save.mutate(!!e.checked)}
|
|
259
|
+
>
|
|
260
|
+
<Checkbox.HiddenInput />
|
|
261
|
+
<Checkbox.Control />
|
|
262
|
+
<Checkbox.Label color="var(--color-text)" fontSize="sm">
|
|
263
|
+
List the example scripts and pipelines (show_examples)
|
|
264
|
+
</Checkbox.Label>
|
|
265
|
+
</Checkbox.Root>
|
|
266
|
+
<FieldBadges field={field} />
|
|
267
|
+
</HStack>
|
|
268
|
+
<Field.HelperText color="var(--color-text-muted)">
|
|
269
|
+
The built-in examples and the files named <Mono>*_example*</Mono> (plugins). Unchecked, they are left out
|
|
270
|
+
of the script and pipeline lists but still found by name. Your saved scripts are always listed.
|
|
271
|
+
</Field.HelperText>
|
|
272
|
+
</Field.Root>
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
|
|
234
276
|
export const FoldersCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
235
277
|
const queryClient = useQueryClient();
|
|
236
278
|
const { local_cache, workdir } = info.fields;
|
|
@@ -309,6 +351,8 @@ export const FoldersCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
|
309
351
|
</HStack>
|
|
310
352
|
)}
|
|
311
353
|
|
|
354
|
+
<ExamplesToggle info={info} />
|
|
355
|
+
|
|
312
356
|
<KV
|
|
313
357
|
rows={[
|
|
314
358
|
[
|
|
@@ -928,6 +972,91 @@ export const SecretsCard: React.FC<{ writable: boolean }> = ({ writable }) => {
|
|
|
928
972
|
);
|
|
929
973
|
};
|
|
930
974
|
|
|
975
|
+
// ─── Agents (MCP) ───────────────────────────────────────────────────
|
|
976
|
+
|
|
977
|
+
/** mcp_instructions: what the MCP server tells the agents when they connect */
|
|
978
|
+
const McpCard: React.FC<{ info: SettingsInfo }> = ({ info }) => {
|
|
979
|
+
const queryClient = useQueryClient();
|
|
980
|
+
const field = info.fields.mcp_instructions;
|
|
981
|
+
const fallback = info.general.mcp.default_instructions;
|
|
982
|
+
const initial = field.value ?? fallback;
|
|
983
|
+
const [text, setText] = useState(initial);
|
|
984
|
+
useEffect(() => setText(initial), [initial]);
|
|
985
|
+
|
|
986
|
+
const save = useMutation({
|
|
987
|
+
// the default text sent back: nothing to keep in the user file
|
|
988
|
+
mutationFn: (value: string | null) =>
|
|
989
|
+
updateSettings({ mcp_instructions: value && value.trim() !== fallback.trim() ? value : null }),
|
|
990
|
+
onSuccess: (out) => {
|
|
991
|
+
queryClient.setQueryData(SETTINGS_KEY, out.settings);
|
|
992
|
+
toaster.create({
|
|
993
|
+
title: 'Agent instructions saved',
|
|
994
|
+
description: out.applied.length
|
|
995
|
+
? 'Agents get them from their next connection.'
|
|
996
|
+
: 'They are overridden: see the badges.',
|
|
997
|
+
type: 'success',
|
|
998
|
+
});
|
|
999
|
+
},
|
|
1000
|
+
onError: fail('Could not save the agent instructions'),
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
const editable = info.writable && !!info.user_file.path && !field.overridden && field.editable;
|
|
1004
|
+
const isDefault = field.value == null;
|
|
1005
|
+
return (
|
|
1006
|
+
<Section
|
|
1007
|
+
id="mcp"
|
|
1008
|
+
icon={<LuBot />}
|
|
1009
|
+
title="Agents (MCP)"
|
|
1010
|
+
subtitle={<>
|
|
1011
|
+
What the MCP server tells an agent when it connects: how to use the tools, what to log, your house
|
|
1012
|
+
rules. It is sent at the start of every agent session, keep it short. Sessions already open keep the
|
|
1013
|
+
instructions they started with.
|
|
1014
|
+
</>}
|
|
1015
|
+
>
|
|
1016
|
+
<Field.Root>
|
|
1017
|
+
<HStack justify="space-between" w="100%" wrap="wrap" gap={2}>
|
|
1018
|
+
<Field.Label color="var(--color-text)">
|
|
1019
|
+
Instructions (<Mono>mcp_instructions</Mono>){isDefault ? ', the default ones' : ''}
|
|
1020
|
+
</Field.Label>
|
|
1021
|
+
<FieldBadges field={field} />
|
|
1022
|
+
</HStack>
|
|
1023
|
+
<Textarea
|
|
1024
|
+
{...inputStyle}
|
|
1025
|
+
size="sm"
|
|
1026
|
+
fontFamily="mono"
|
|
1027
|
+
rows={8}
|
|
1028
|
+
value={text}
|
|
1029
|
+
maxLength={4000}
|
|
1030
|
+
disabled={!editable || save.isPending}
|
|
1031
|
+
onChange={(e) => setText(e.target.value)}
|
|
1032
|
+
/>
|
|
1033
|
+
<Field.HelperText color="var(--color-text-muted)">
|
|
1034
|
+
{text.length} / 4000 characters. Empty or unchanged: the default instructions.
|
|
1035
|
+
</Field.HelperText>
|
|
1036
|
+
</Field.Root>
|
|
1037
|
+
<HStack gap={2}>
|
|
1038
|
+
<Button
|
|
1039
|
+
size="sm"
|
|
1040
|
+
colorPalette="blue"
|
|
1041
|
+
disabled={!editable || text === initial || save.isPending}
|
|
1042
|
+
loading={save.isPending}
|
|
1043
|
+
onClick={() => save.mutate(text)}
|
|
1044
|
+
>
|
|
1045
|
+
Save
|
|
1046
|
+
</Button>
|
|
1047
|
+
<Button
|
|
1048
|
+
size="sm"
|
|
1049
|
+
variant="outline"
|
|
1050
|
+
disabled={!editable || isDefault || save.isPending}
|
|
1051
|
+
onClick={() => save.mutate(null)}
|
|
1052
|
+
>
|
|
1053
|
+
Back to the default
|
|
1054
|
+
</Button>
|
|
1055
|
+
</HStack>
|
|
1056
|
+
</Section>
|
|
1057
|
+
);
|
|
1058
|
+
};
|
|
1059
|
+
|
|
931
1060
|
// ─── Page ───────────────────────────────────────────────────────────
|
|
932
1061
|
|
|
933
1062
|
export const SettingsView: React.FC = () => {
|
|
@@ -965,6 +1094,7 @@ export const SettingsView: React.FC = () => {
|
|
|
965
1094
|
<SecretsCard writable={info.writable} />
|
|
966
1095
|
<FoldersCard info={info} />
|
|
967
1096
|
<DatabaseCard info={info} />
|
|
1097
|
+
<McpCard info={info} />
|
|
968
1098
|
</VStack>
|
|
969
1099
|
)}
|
|
970
1100
|
</Box>
|