@@ -23,7 +23,6 @@ import (
2323
2424 "azureaiagent/internal/exterrors"
2525 "azureaiagent/internal/pkg/agents/agent_yaml"
26- "azureaiagent/internal/pkg/agents/registry_api"
2726 "azureaiagent/internal/project"
2827
2928 "github.com/Azure/azure-sdk-for-go/sdk/azcore"
@@ -594,7 +593,7 @@ func (a *InitAction) Run(ctx context.Context) error {
594593 }
595594
596595 // Prompt for manifest parameters (e.g. tool credentials) after project selection
597- agentManifest , err = registry_api .ProcessManifestParameters (
596+ agentManifest , err = agent_yaml .ProcessManifestParameters (
598597 ctx , agentManifest , a .azdClient , a .flags .NoPrompt ,
599598 )
600599 if err != nil {
@@ -721,13 +720,8 @@ func getExistingEnvironment(ctx context.Context, envName string, azdClient *azde
721720}
722721
723722// manifestHasModelResources returns true if the manifest contains any model resources
724- // that need deployment configuration. Prompt agents always have a model. Hosted agents
725- // only need model config if they have resources with kind "model".
723+ // that need deployment configuration (i.e. resources with kind "model").
726724func manifestHasModelResources (manifest * agent_yaml.AgentManifest ) bool {
727- if _ , ok := manifest .Template .(agent_yaml.PromptAgent ); ok {
728- return true
729- }
730-
731725 if manifest .Resources != nil {
732726 for _ , resource := range manifest .Resources {
733727 if _ , ok := resource .(agent_yaml.ModelResource ); ok {
@@ -1152,67 +1146,6 @@ func (a *InitAction) isGitHubUrl(manifestPointer string) bool {
11521146 strings .Contains (hostname , "github" )
11531147}
11541148
1155- type RegistryManifest struct {
1156- registryName string
1157- manifestName string
1158- manifestVersion string // Defaults to "" if not specified in URL
1159- }
1160-
1161- func (a * InitAction ) isRegistryUrl (manifestPointer string ) (bool , * RegistryManifest ) {
1162- // Check if it matches the format "azureml://registries/{registryName}/agentmanifests/{manifestName}[/versions/{manifestVersion}]"
1163- if ! strings .HasPrefix (manifestPointer , "azureml://" ) {
1164- return false , nil
1165- }
1166-
1167- // Remove the "azureml://" prefix
1168- path := strings .TrimPrefix (manifestPointer , "azureml://" )
1169-
1170- // Split by "/" to get all path components
1171- parts := strings .Split (path , "/" )
1172-
1173- // Should have either 4 parts (without version) or 6 parts (with version)
1174- // Format 1: "registries", registryName, "agentmanifests", manifestName
1175- // Format 2: "registries", registryName, "agentmanifests", manifestName, "versions", manifestVersion
1176- if len (parts ) != 4 && len (parts ) != 6 {
1177- return false , nil
1178- }
1179-
1180- // Validate the expected path structure for the first 4 parts
1181- if parts [0 ] != "registries" || parts [2 ] != "agentmanifests" {
1182- return false , nil
1183- }
1184-
1185- // All basic parts should be non-empty
1186- registryName := strings .TrimSpace (parts [1 ])
1187- manifestName := strings .TrimSpace (parts [3 ])
1188-
1189- if registryName == "" || manifestName == "" {
1190- return false , nil
1191- }
1192-
1193- var manifestVersion string
1194-
1195- // If we have 6 parts, validate the version structure
1196- if len (parts ) == 6 {
1197- if parts [4 ] != "versions" {
1198- return false , nil
1199- }
1200- manifestVersion = strings .TrimSpace (parts [5 ])
1201- if manifestVersion == "" {
1202- return false , nil
1203- }
1204- } else {
1205- // If no version specified, default to ""
1206- manifestVersion = ""
1207- }
1208-
1209- return true , & RegistryManifest {
1210- registryName : registryName ,
1211- manifestName : manifestName ,
1212- manifestVersion : manifestVersion ,
1213- }
1214- }
1215-
12161149func (a * InitAction ) downloadAgentYaml (
12171150 ctx context.Context , manifestPointer string , targetDir string ) (* agent_yaml.AgentManifest , string , error ) {
12181151 if manifestPointer == "" {
@@ -1394,62 +1327,11 @@ func (a *InitAction) downloadAgentYaml(
13941327 }
13951328
13961329 content = []byte (contentStr )
1397- } else if isRegistry , registryManifest := a .isRegistryUrl (manifestPointer ); isRegistry {
1398- // Handle registry URLs
1399- manifestClient := registry_api .NewRegistryAgentManifestClient (registryManifest .registryName , a .credential )
1400-
1401- var versionResult * registry_api.Manifest
1402- if registryManifest .manifestVersion == "" {
1403- // No version specified, get latest version from GetAllLatest
1404- log .Printf ("No version provided for manifest '%s', retrieving latest version" , registryManifest .manifestName )
1405-
1406- allManifests , err := manifestClient .GetAllLatest (ctx )
1407- if err != nil {
1408- return nil , "" , fmt .Errorf ("getting latest manifests: %w" , err )
1409- }
1410-
1411- // Find the manifest with matching name
1412- for _ , manifest := range allManifests {
1413- if manifest .Name == registryManifest .manifestName {
1414- versionResult = & manifest
1415- break
1416- }
1417- }
1418-
1419- if versionResult == nil {
1420- return nil , "" , fmt .Errorf ("manifest '%s' not found in registry '%s'" , registryManifest .manifestName , registryManifest .registryName )
1421- }
1422- } else {
1423- // Specific version requested
1424- fmt .Println (output .WithGrayFormat ("Downloading manifest from registry..." ))
1425- log .Printf ("Downloading manifest from registry: %s" , manifestPointer )
1426-
1427- manifest , err := manifestClient .GetManifest (ctx , registryManifest .manifestName , registryManifest .manifestVersion )
1428- if err != nil {
1429- return nil , "" , fmt .Errorf ("getting materialized manifest: %w" , err )
1430- }
1431- versionResult = manifest
1432- }
1433-
1434- // Process the manifest into a maml format
1435- processedManifest , err := registry_api .ProcessRegistryManifest (ctx , versionResult , a .azdClient )
1436- if err != nil {
1437- return nil , "" , fmt .Errorf ("processing manifest with parameters: %w" , err )
1438- }
1439-
1440- log .Print ("Retrieved and processed manifest from registry" )
1441-
1442- // Convert to YAML bytes for the content variable
1443- manifestBytes , err := yaml .Marshal (processedManifest )
1444- if err != nil {
1445- return nil , "" , fmt .Errorf ("marshaling agent manifest to YAML: %w" , err )
1446- }
1447- content = manifestBytes
14481330 } else {
14491331 // If we reach here, the manifest pointer didn't match any known type
14501332 return nil , "" , exterrors .Validation (
14511333 exterrors .CodeInvalidManifestPointer ,
1452- fmt .Sprintf ("manifest pointer '%s' is not a valid local file path, GitHub URL, or registry URL" , manifestPointer ),
1334+ fmt .Sprintf ("manifest pointer '%s' is not a valid local file path or GitHub URL" , manifestPointer ),
14531335 "provide a valid URL or an existing local agent.yaml/agent.yml path" ,
14541336 )
14551337 }
@@ -1494,14 +1376,6 @@ func (a *InitAction) downloadAgentYaml(
14941376 }
14951377 }
14961378
1497- _ , isPromptAgent := agentManifest .Template .(agent_yaml.PromptAgent )
1498- if isPromptAgent {
1499- agentManifest , err = agent_yaml .ProcessPromptAgentToolsConnections (ctx , agentManifest , a .azdClient )
1500- if err != nil {
1501- return nil , "" , fmt .Errorf ("failed to process prompt agent tools connections: %w" , err )
1502- }
1503- }
1504-
15051379 // Create target directory if it doesn't exist
15061380 //nolint:gosec // project scaffold directory should be readable and traversable
15071381 if err := os .MkdirAll (targetDir , 0755 ); err != nil {
0 commit comments