@@ -630,9 +630,9 @@ impl std::fmt::Debug for Agent {
630630}
631631
632632impl Agent {
633- /// Create from a config file path or inline HCL string.
633+ /// Create from a config file path or inline ACL-compatible string.
634634 ///
635- /// Auto-detects: `.hcl` file path vs inline HCL .
635+ /// Auto-detects: `.acl`/legacy `. hcl` file path vs inline ACL-compatible config .
636636 pub async fn new ( config_source : impl Into < String > ) -> Result < Self > {
637637 let source = config_source. into ( ) ;
638638
@@ -652,7 +652,7 @@ impl Agent {
652652
653653 let config = if matches ! (
654654 path. extension( ) . and_then( |ext| ext. to_str( ) ) ,
655- Some ( "hcl " | "json " )
655+ Some ( "acl " | "hcl " )
656656 ) {
657657 if !path. exists ( ) {
658658 return Err ( CodeError :: Config ( format ! (
@@ -663,34 +663,24 @@ impl Agent {
663663
664664 CodeConfig :: from_file ( path)
665665 . with_context ( || format ! ( "Failed to load config: {}" , path. display( ) ) ) ?
666- } else if matches ! ( path. extension( ) . and_then( |ext| ext. to_str( ) ) , Some ( "acl" ) ) {
667- // Load .acl file
668- if !path. exists ( ) {
669- return Err ( CodeError :: Config ( format ! (
670- "Config file not found: {}" ,
671- path. display( )
672- ) ) ) ;
673- }
674- let content = std:: fs:: read_to_string ( path)
675- . map_err ( |e| CodeError :: Config ( format ! ( "Failed to read ACL file: {}" , e) ) ) ?;
676- CodeConfig :: from_acl ( & content)
677- . with_context ( || format ! ( "Failed to parse ACL config: {}" , path. display( ) ) ) ?
678666 } else if source. trim ( ) . starts_with ( '{' ) {
679- // Try to parse as JSON string
680- serde_json:: from_str ( & source)
681- . map_err ( |e| CodeError :: Config ( format ! ( "Failed to parse JSON config: {}" , e) ) ) ?
682- } else if source. trim ( ) . starts_with ( "providers \" " ) {
683- // ACL string (starts with ACL labeled block like providers "openai" { })
684- CodeConfig :: from_acl ( & source) . context ( "Failed to parse config as ACL string" ) ?
667+ return Err ( CodeError :: Config (
668+ "JSON config is not supported; use ACL-compatible .acl/.hcl config" . into ( ) ,
669+ )
670+ . into ( ) ) ;
671+ } else if matches ! ( path. extension( ) . and_then( |ext| ext. to_str( ) ) , Some ( "json" ) ) {
672+ return Err ( CodeError :: Config (
673+ "JSON config files are not supported; use .acl or legacy .hcl" . into ( ) ,
674+ )
675+ . into ( ) ) ;
685676 } else {
686- // Try to parse as ACL string (legacy format without quotes)
687677 CodeConfig :: from_acl ( & source) . context ( "Failed to parse config as ACL string" ) ?
688678 } ;
689679
690680 Self :: from_config ( config) . await
691681 }
692682
693- /// Create from a config file path or inline HCL string.
683+ /// Create from a config file path or inline ACL-compatible string.
694684 ///
695685 /// Alias for [`Agent::new()`] — provides a consistent API with
696686 /// the Python and Node.js SDKs.
@@ -3382,7 +3372,7 @@ dir content
33823372 async fn test_new_with_existing_hcl_file_uses_file_loading ( ) {
33833373 let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
33843374 let config_path = temp_dir. path ( ) . join ( "agent.hcl" ) ;
3385- std:: fs:: write ( & config_path, "this is not valid hcl " ) . unwrap ( ) ;
3375+ std:: fs:: write ( & config_path, "this is not valid acl " ) . unwrap ( ) ;
33863376
33873377 let err = Agent :: new ( config_path. display ( ) . to_string ( ) )
33883378 . await
@@ -3391,7 +3381,7 @@ dir content
33913381
33923382 assert ! ( msg. contains( "Failed to load config" ) ) ;
33933383 assert ! ( msg. contains( "agent.hcl" ) ) ;
3394- assert ! ( !msg. contains( "Failed to parse config as HCL string" ) ) ;
3384+ assert ! ( !msg. contains( "Failed to parse config as ACL string" ) ) ;
33953385 }
33963386
33973387 #[ tokio:: test]
@@ -3406,7 +3396,7 @@ dir content
34063396
34073397 assert ! ( msg. contains( "Config file not found" ) ) ;
34083398 assert ! ( msg. contains( "agent.hcl" ) ) ;
3409- assert ! ( !msg. contains( "Failed to parse config as HCL string" ) ) ;
3399+ assert ! ( !msg. contains( "Failed to parse config as ACL string" ) ) ;
34103400 }
34113401
34123402 #[ test]
0 commit comments