@@ -51,33 +51,6 @@ function getDefaultConfigForEvaluator(
5151 return DEFAULT_EVALUATOR_CONFIGS [ evaluatorId ] ?? { } ;
5252}
5353
54- function buildJsonDraftControl ( agentName : string ) {
55- return {
56- id : 0 ,
57- name : `json-control-for-${ sanitizeControlNamePart ( agentName ) } ` ,
58- control : {
59- description : '' ,
60- enabled : true ,
61- execution : 'server' as const ,
62- scope : {
63- step_types : [ 'llm' ] ,
64- stages : [ 'post' ] as ( 'post' | 'pre' ) [ ] ,
65- } ,
66- condition : {
67- selector : {
68- path : '*' ,
69- } ,
70- evaluator : {
71- name : 'regex' ,
72- config : getDefaultConfigForEvaluator ( 'regex' ) ,
73- } ,
74- } ,
75- action : { decision : 'deny' as const } ,
76- tags : [ ] ,
77- } ,
78- } ;
79- }
80-
8154type AddNewControlModalProps = {
8255 opened : boolean ;
8356 onClose : ( ) => void ;
@@ -117,12 +90,6 @@ export function AddNewControlModal({
11790 } ) ;
11891 } ;
11992
120- const handleFromJsonClick = ( ) => {
121- openModal ( MODAL_NAMES . CONTROL_STORE , {
122- submodal : SUBMODAL_NAMES . CREATE ,
123- } ) ;
124- } ;
125-
12693 const handleEditModalClose = ( ) => {
12794 closeSubmodal ( ) ;
12895 } ;
@@ -143,34 +110,31 @@ export function AddNewControlModal({
143110 } , [ evaluatorsData ] ) ;
144111
145112 const draftControl = useMemo ( ( ) => {
146- if ( selectedEvaluator ) {
147- const name = `${ sanitizeControlNamePart ( selectedEvaluator . name ) } -control-for-${ sanitizeControlNamePart ( agentName ) } ` ;
148- return {
149- id : 0 ,
150- name,
151- control : {
152- description : selectedEvaluator . description ,
153- enabled : true ,
154- execution : 'server' as const ,
155- scope : {
156- step_types : [ 'llm' ] ,
157- stages : [ 'post' ] as ( 'post' | 'pre' ) [ ] ,
113+ if ( ! selectedEvaluator ) return null ;
114+ const name = `${ sanitizeControlNamePart ( selectedEvaluator . name ) } -control-for-${ sanitizeControlNamePart ( agentName ) } ` ;
115+ return {
116+ id : 0 ,
117+ name,
118+ control : {
119+ description : selectedEvaluator . description ,
120+ enabled : true ,
121+ execution : 'server' as const ,
122+ scope : {
123+ step_types : [ 'llm' ] ,
124+ stages : [ 'post' ] as ( 'post' | 'pre' ) [ ] ,
125+ } ,
126+ condition : {
127+ selector : {
128+ path : '*' ,
158129 } ,
159- condition : {
160- selector : {
161- path : '*' ,
162- } ,
163- evaluator : {
164- name : selectedEvaluator . id ,
165- config : getDefaultConfigForEvaluator ( selectedEvaluator . id ) ,
166- } ,
130+ evaluator : {
131+ name : selectedEvaluator . id ,
132+ config : getDefaultConfigForEvaluator ( selectedEvaluator . id ) ,
167133 } ,
168- action : { decision : 'deny' as const } ,
169134 } ,
170- } ;
171- }
172-
173- return buildJsonDraftControl ( agentName ) ;
135+ action : { decision : 'deny' as const } ,
136+ } ,
137+ } ;
174138 } , [ selectedEvaluator , agentName ] ) ;
175139
176140 const columns : ColumnDef < EvaluatorInfo & { id : string } > [ ] = [
@@ -255,7 +219,7 @@ export function AddNewControlModal({
255219 </ Button >
256220 </ Group >
257221 < Text size = "sm" c = "dimmed" >
258- Select an evaluator to create a new control or start from JSON
222+ Select an evaluator to create a new control
259223 </ Text >
260224 </ Box >
261225 < Divider />
@@ -276,30 +240,20 @@ export function AddNewControlModal({
276240 value = { searchQuery }
277241 onChange = { ( e ) => setSearchQuery ( e . target . value ) }
278242 />
279- < Group gap = "md" wrap = "nowrap" >
280- < Button
281- variant = "outline"
243+ < Text size = "sm" c = "dimmed" >
244+ Learn here on how to add new type of evaluator.{ ' ' }
245+ < Text
246+ component = "a"
247+ href = "https://github.com/agentcontrol/agent-control/blob/main/README.md"
248+ c = "blue"
282249 size = "sm"
283- data-testid = "from-json-button"
284- onClick = { handleFromJsonClick }
250+ td = "none"
251+ target = "_blank"
252+ rel = "noreferrer"
285253 >
286- From JSON
287- </ Button >
288- < Text size = "sm" c = "dimmed" >
289- Learn here on how to add new type of evaluator.{ ' ' }
290- < Text
291- component = "a"
292- href = "https://github.com/agentcontrol/agent-control/blob/main/README.md"
293- c = "blue"
294- size = "sm"
295- td = "none"
296- target = "_blank"
297- rel = "noreferrer"
298- >
299- Docs ↗
300- </ Text >
254+ Docs ↗
301255 </ Text >
302- </ Group >
256+ </ Text >
303257 </ Group >
304258
305259 { /* Table or Empty State */ }
@@ -353,7 +307,6 @@ export function AddNewControlModal({
353307 control = { draftControl }
354308 agentId = { agentId }
355309 mode = "create"
356- initialEditorMode = { selectedEvaluator ? 'form' : 'json' }
357310 onClose = { handleEditModalClose }
358311 onSuccess = { handleEditModalSuccess }
359312 />
0 commit comments