Port Agent Runtime abstractions / inprocess runtime (#149)

This commit is contained in:
Stephen Toub
2025-07-09 09:08:45 -04:00
committed by GitHub
parent 31dfdcb3ce
commit 4a0f8dcbe0
97 changed files with 3801 additions and 156 deletions
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.Extensions.AI.Agents.Runtime.InProcess.Tests;
public class TestSubscription(string topicType, string agentType, string? id = null) : ISubscriptionDefinition
{
public string Id { get; } = id ?? Guid.NewGuid().ToString();
public string TopicType { get; } = topicType;
public AgentId MapToAgent(TopicId topic)
{
if (!this.Matches(topic))
{
throw new InvalidOperationException("TopicId does not match the subscription.");
}
return new AgentId(agentType, topic.Source);
}
public bool Equals(ISubscriptionDefinition? other) => this.Id == other?.Id;
public override bool Equals([NotNullWhen(true)] object? obj) => obj is TestSubscription other && other.Equals(this);
public override int GetHashCode() => this.Id.GetHashCode();
public bool Matches(TopicId topic)
{
return topic.Type == this.TopicType;
}
}