Class GatewayConnectionService
Manages TUI connection to a running Gateway instance. When connected, agent execution is delegated to Gateway instead of running in-process.
public sealed class GatewayConnectionService : IAsyncDisposable
- Inheritance
-
GatewayConnectionService
- Implements
- Inherited Members
Constructors
GatewayConnectionService(string)
public GatewayConnectionService(string gatewayUrl)
Parameters
gatewayUrlstring
Properties
ActiveAgentId
public string? ActiveAgentId { get; }
Property Value
GatewayUrl
public string GatewayUrl { get; }
Property Value
IsConnected
public bool IsConnected { get; }
Property Value
Methods
ConnectAsync(CancellationToken)
Connect to Gateway and verify it's running.
public Task<bool> ConnectAsync(CancellationToken ct = default)
Parameters
Returns
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
EnsureAgentAsync(string?, string?, CancellationToken)
Get or spawn an agent, returning its ID.
public Task<string?> EnsureAgentAsync(string? provider = null, string? model = null, CancellationToken ct = default)
Parameters
providerstringmodelstringctCancellationToken
Returns
GetLatestSessionAsync(CancellationToken)
Returns the most recent persisted session ID, or null when none exist.
public Task<string?> GetLatestSessionAsync(CancellationToken ct = default)
Parameters
Returns
GetProvidersAsync(CancellationToken)
Get available providers.
public Task<ProviderInfo[]> GetProvidersAsync(CancellationToken ct = default)
Parameters
Returns
- Task<ProviderInfo[]>
GetSessionsAsync(int, CancellationToken)
Get sessions list.
public Task<SessionInfo[]> GetSessionsAsync(int limit = 50, CancellationToken ct = default)
Parameters
limitintctCancellationToken
Returns
- Task<SessionInfo[]>
GetStatusAsync(CancellationToken)
Get Gateway status summary.
public Task<GatewayStatus?> GetStatusAsync(CancellationToken ct = default)
Parameters
Returns
PrintStatus()
Print connection status to console.
public void PrintStatus()
SendMessageAsync(string, CancellationToken)
Send a message and get the full response (non-streaming).
public Task<string?> SendMessageAsync(string message, CancellationToken ct = default)
Parameters
messagestringctCancellationToken
Returns
SendMessageStreamingAsync(string, CancellationToken)
Send a message and stream the response.
public IAsyncEnumerable<string> SendMessageStreamingAsync(string message, CancellationToken ct = default)
Parameters
messagestringctCancellationToken