-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into component_config_imp_vd
- Loading branch information
Showing
41 changed files
with
2,211 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
dotnet/src/Microsoft.AutoGen/Contracts/AgentsRegistryState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// AgentsRegistryState.cs | ||
using System.Collections.Concurrent; | ||
|
||
namespace Microsoft.AutoGen.Contracts; | ||
public class AgentsRegistryState | ||
{ | ||
public ConcurrentDictionary<string, HashSet<string>> AgentsToEventsMap { get; set; } = new ConcurrentDictionary<string, HashSet<string>>(); | ||
public ConcurrentDictionary<string, HashSet<string>> AgentsToTopicsMap { get; set; } = []; | ||
public ConcurrentDictionary<string, HashSet<string>> TopicToAgentTypesMap { get; set; } = []; | ||
public ConcurrentDictionary<string, HashSet<string>> EventsToAgentTypesMap { get; set; } = []; | ||
public ConcurrentDictionary<string, HashSet<Subscription>> GuidSubscriptionsMap { get; set; } = []; | ||
public ConcurrentDictionary<string, AgentId> AgentTypes { get; set; } = []; | ||
public string Etag { get; set; } = Guid.NewGuid().ToString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// IAgent.cs | ||
|
||
using Google.Protobuf; | ||
|
||
namespace Microsoft.AutoGen.Contracts; | ||
|
||
public interface IAgent | ||
{ | ||
AgentId AgentId { get; } | ||
IAgentRuntime Worker { get; } | ||
ValueTask<List<Subscription>> GetSubscriptionsAsync(); | ||
ValueTask<AddSubscriptionResponse> SubscribeAsync(string topic); | ||
ValueTask<RemoveSubscriptionResponse> UnsubscribeAsync(Guid id); | ||
ValueTask<RemoveSubscriptionResponse> UnsubscribeAsync(string topic); | ||
Task StoreAsync(AgentState state, CancellationToken cancellationToken = default); | ||
Task<T> ReadAsync<T>(AgentId agentId, CancellationToken cancellationToken = default) where T : IMessage, new(); | ||
ValueTask PublishMessageAsync(IMessage message, string topic, string source, string key, CancellationToken token = default); | ||
ValueTask PublishMessageAsync<T>(T message, string topic, string source, CancellationToken token = default) where T : IMessage; | ||
ValueTask PublishMessageAsync<T>(T message, string topic, CancellationToken token = default) where T : IMessage; | ||
ValueTask PublishMessageAsync<T>(T message, CancellationToken token = default) where T : IMessage; | ||
Task<RpcResponse> HandleRequestAsync(RpcRequest request); | ||
Task HandleObjectAsync(object item, CancellationToken cancellationToken = default); | ||
} |
103 changes: 103 additions & 0 deletions
103
dotnet/src/Microsoft.AutoGen/Contracts/IAgentRuntime.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// IAgentRuntime.cs | ||
|
||
using Google.Protobuf; | ||
namespace Microsoft.AutoGen.Contracts; | ||
|
||
/// <summary> | ||
/// Defines the common surface for agent runtime implementations. | ||
/// </summary> | ||
public interface IAgentRuntime | ||
{ | ||
/// <summary> | ||
/// Gets the dependency injection service provider for the runtime. | ||
/// </summary> | ||
IServiceProvider RuntimeServiceProvider { get; } | ||
|
||
/// <summary> | ||
/// Registers a new agent type asynchronously. | ||
/// </summary> | ||
/// <param name="request">The request containing the agent type details.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
ValueTask RegisterAgentTypeAsync(RegisterAgentTypeRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// to be removed in favor of send_message | ||
/// Sends a request to and agent. | ||
/// </summary> | ||
/// <param name="agent">The agent sending the request.</param> | ||
/// <param name="request">The request to be sent.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
ValueTask RuntimeSendRequestAsync(IAgent agent, RpcRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Sends a response to the above request. | ||
/// /// to be removed in favor of send_message | ||
/// </summary> | ||
/// <param name="response">The response to be sent.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
ValueTask RuntimeSendResponseAsync(RpcResponse response, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Sends a message directly to another agent. | ||
/// </summary> | ||
/// <param name="message">The message to be sent.</param> | ||
/// <param name="recipient">The recipient of the message.</param> | ||
/// <param name="sender">The agent sending the message.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the response to th message.</returns> | ||
ValueTask<RpcResponse> SendMessageAsync(IMessage message, AgentId recipient, AgentId? sender, CancellationToken? cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Publishes a message to a topic. | ||
/// </summary> | ||
/// <param name="message">The message to be published.</param> | ||
/// <param name="topic">The topic to publish the message to.</param> | ||
/// <param name="sender">The agent sending the message.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
ValueTask PublishMessageAsync(IMessage message, TopicId topic, IAgent? sender, CancellationToken? cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Saves the state of an agent asynchronously. | ||
/// </summary> | ||
/// <param name="value">The state to be saved.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
ValueTask SaveStateAsync(AgentState value, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Loads the state of an agent asynchronously. | ||
/// </summary> | ||
/// <param name="agentId">The ID of the agent whose state is to be loaded.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation, containing the agent state.</returns> | ||
ValueTask<AgentState> LoadStateAsync(AgentId agentId, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Adds a subscription to a topic. | ||
/// </summary> | ||
/// <param name="request">The request containing the subscription types.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation, containing the response.</returns> | ||
ValueTask<AddSubscriptionResponse> AddSubscriptionAsync(AddSubscriptionRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Removes a subscription. | ||
/// </summary> | ||
/// <param name="request">The request containing the subscription id.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation, containing the response.</returns> | ||
ValueTask<RemoveSubscriptionResponse> RemoveSubscriptionAsync(RemoveSubscriptionRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets the list of subscriptions. | ||
/// </summary> | ||
/// <param name="request">The request containing the subscription query details.</param> | ||
/// <param name="cancellationToken">A token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation, containing the list of subscriptions.</returns> | ||
ValueTask<List<Subscription>> GetSubscriptionsAsync(GetSubscriptionsRequest request, CancellationToken cancellationToken = default); | ||
} |
Oops, something went wrong.