// Copyright (c) Microsoft. All rights reserved. using System.Net.Sockets; namespace Aspire.Hosting.ApplicationModel; /// /// Represents a DevUI resource for testing AI agents in a distributed application. /// /// /// DevUI aggregates agents from multiple backend services and provides a unified /// web interface for testing and debugging AI agents using the OpenAI Responses protocol. /// The aggregator runs as an in-process reverse proxy within the AppHost, requiring no /// external container image. /// /// The name of the DevUI resource. public class DevUIResource(string name) : Resource(name), IResourceWithEndpoints, IResourceWithWaitSupport { internal const string PrimaryEndpointName = "http"; /// /// Initializes a new instance of the class with endpoint annotations. /// /// The name of the resource. /// An optional fixed port. If null, a dynamic port is assigned. internal DevUIResource(string name, int? port) : this(name) { this.Port = port; this.Annotations.Add(new EndpointAnnotation( ProtocolType.Tcp, uriScheme: "http", name: PrimaryEndpointName, port: port, isProxied: false) { TargetHost = "localhost" }); } /// /// Gets the optional fixed port for the DevUI web interface. /// internal int? Port { get; } /// /// Gets the primary HTTP endpoint for the DevUI web interface. /// public EndpointReference PrimaryEndpoint => field ??= new(this, PrimaryEndpointName); }