@@ -10,7 +10,7 @@ import {
1010
1111describe ( 'DynamicAgentConfigSchema' , ( ) => {
1212 const validBaseTemplate = {
13- id : 'test_agent ' ,
13+ id : 'test-agent ' ,
1414 version : '1.0.0' ,
1515 displayName : 'Test Agent' ,
1616 parentPrompt : 'A test agent' ,
@@ -143,7 +143,7 @@ describe('DynamicAgentConfigSchema', () => {
143143 describe ( 'Invalid Templates' , ( ) => {
144144 it ( 'should reject template with missing required fields' , ( ) => {
145145 const template = {
146- id : 'test_agent ' ,
146+ id : 'test-agent ' ,
147147 // Missing other required fields
148148 }
149149
@@ -201,6 +201,55 @@ describe('DynamicAgentConfigSchema', () => {
201201 expect ( result . success ) . toBe ( false )
202202 } )
203203
204+ it ( 'should reject template with invalid agent ID format' , ( ) => {
205+ const invalidIds = [
206+ 'Test_Agent' , // uppercase and underscore
207+ 'test agent' , // space
208+ 'test.agent' , // dot
209+ 'test@agent' , // special character
210+ 'Test-Agent' , // uppercase
211+ '123_test' , // underscore
212+ 'test/agent' , // slash
213+ ]
214+
215+ invalidIds . forEach ( ( id ) => {
216+ const template = {
217+ ...validBaseTemplate ,
218+ id,
219+ }
220+
221+ const result = DynamicAgentConfigSchema . safeParse ( template )
222+ expect ( result . success ) . toBe ( false )
223+ if ( ! result . success ) {
224+ expect ( result . error . issues [ 0 ] . message ) . toContain (
225+ 'lowercase letters, numbers, and hyphens'
226+ )
227+ }
228+ } )
229+ } )
230+
231+ it ( 'should accept template with valid agent ID format' , ( ) => {
232+ const validIds = [
233+ 'test-agent' ,
234+ 'test123' ,
235+ 'agent-v2' ,
236+ 'my-custom-agent-123' ,
237+ 'a' ,
238+ '123' ,
239+ 'test-agent-with-many-hyphens' ,
240+ ]
241+
242+ validIds . forEach ( ( id ) => {
243+ const template = {
244+ ...validBaseTemplate ,
245+ id,
246+ }
247+
248+ const result = DynamicAgentConfigSchema . safeParse ( template )
249+ expect ( result . success ) . toBe ( true )
250+ } )
251+ } )
252+
204253 it ( 'should accept template with any parentInstructions agent ID at schema level' , ( ) => {
205254 const template = {
206255 ...validBaseTemplate ,
@@ -359,4 +408,4 @@ describe('DynamicAgentConfigSchema', () => {
359408 )
360409 } )
361410 } )
362- } )
411+ } )
0 commit comments