@@ -356,7 +356,7 @@ describe("agent invocation", () => {
356356 } ) ;
357357
358358 expect ( ( ) => greet . use ( [ null as unknown as any ] as any ) ) . toThrow (
359- "Agent addon entries must be functions." ,
359+ "Agent addon entries must be functions (entry at index 0 is null) ." ,
360360 ) ;
361361 } ) ;
362362
@@ -771,7 +771,7 @@ describe("agent invocation", () => {
771771 mocks . setSendAndWaitImpl ( async ( ) => JSON . stringify ( "ok" ) ) ;
772772 const guarded = agent ( { name : "guarded" , addons : [ null as unknown as any ] as any } ) ;
773773 await expect ( guarded ( "go" ) ) . rejects . toThrow (
774- "Agent addon entries must be functions." ,
774+ "Agent addon entries must be functions (entry at index 0 is null) ." ,
775775 ) ;
776776 } ) ;
777777
@@ -1166,6 +1166,8 @@ describe("toJsonSchema", () => {
11661166 expect ( toJsonSchema ( s . nonEmptyString ( "A non-empty value" ) ) ) . toEqual ( { type : "string" , minLength : 1 , description : "A non-empty value" } ) ;
11671167 expect ( toJsonSchema ( s . url ) ) . toEqual ( { type : "string" , format : "uri" } ) ;
11681168 expect ( toJsonSchema ( s . url ( "A URL" ) ) ) . toEqual ( { type : "string" , format : "uri" , description : "A URL" } ) ;
1169+ expect ( toJsonSchema ( s . path ) ) . toEqual ( { type : "string" , format : "path" } ) ;
1170+ expect ( toJsonSchema ( s . path ( "source path" ) ) ) . toEqual ( { type : "string" , format : "path" , description : "source path" } ) ;
11691171 } ) ;
11701172
11711173 it ( "includes description when present" , ( ) => {
@@ -1365,6 +1367,27 @@ describe("s.url", () => {
13651367 } ) ;
13661368} ) ;
13671369
1370+ describe ( "s.path" , ( ) => {
1371+ it ( "serializes to {type:'string', format:'path'}" , ( ) => {
1372+ expect ( toJsonSchema ( s . path ) ) . toEqual ( { type : "string" , format : "path" } ) ;
1373+ expect ( toJsonSchema ( s . path ( "source file" ) ) ) . toEqual ( { type : "string" , format : "path" , description : "source file" } ) ;
1374+ } ) ;
1375+
1376+ it ( "accepts any string value" , ( ) => {
1377+ const result = analyzeResponse ( JSON . stringify ( "src/index.ts" ) , s . path , "test" , 1 ) ;
1378+ expect ( result . ok ) . toBe ( true ) ;
1379+ } ) ;
1380+
1381+ it ( "is usable as an object field" , ( ) => {
1382+ const schema = s . object ( { filePath : s . path } ) ;
1383+ expect ( toJsonSchema ( schema ) ) . toEqual ( {
1384+ type : "object" ,
1385+ properties : { filePath : { type : "string" , format : "path" } } ,
1386+ required : [ "filePath" ] ,
1387+ } ) ;
1388+ } ) ;
1389+ } ) ;
1390+
13681391describe ( "s.null" , ( ) => {
13691392 it ( "serializes to {type:'null'}" , ( ) => {
13701393 expect ( toJsonSchema ( s . null ) ) . toEqual ( { type : "null" } ) ;
0 commit comments