Skip to content

Commit 9c317a8

Browse files
authored
Merge branch 'master' into implement-agent-skills
2 parents 605f4d9 + 39a7421 commit 9c317a8

275 files changed

Lines changed: 6084 additions & 1208 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BotSharp.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.DeepSeekAI"
127127
EndProject
128128
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Core.Realtime", "src\Infrastructure\BotSharp.Core.Realtime\BotSharp.Core.Realtime.csproj", "{781F1465-365C-0F22-1775-25025DAFA4C7}"
129129
EndProject
130-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.PizzaBot.MCPServer", "tests\BotSharp.PizzaBot.MCPServer\BotSharp.PizzaBot.MCPServer.csproj", "{8D2AD45F-836A-516F-DE6A-71443CEBB18A}"
131-
EndProject
132130
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Test.ComputerUse", "tests\BotSharp.Test.ComputerUse\BotSharp.Test.ComputerUse.csproj", "{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D}"
133131
EndProject
134132
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BotSharp.Plugin.OsDriver", "src\Plugins\BotSharp.Plugin.OsDriver\BotSharp.Plugin.OsDriver.csproj", "{B268E2F0-060F-8466-7D81-ABA4D735CA59}"
@@ -998,7 +996,6 @@ Global
998996
{AFD64412-4D6A-452E-82A2-79E5D8842E29} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
999997
{AF329442-B48E-4B48-A18A-1C869D1BA6F5} = {D5293208-2BEF-42FC-A64C-5954F61720BA}
1000998
{781F1465-365C-0F22-1775-25025DAFA4C7} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}
1001-
{8D2AD45F-836A-516F-DE6A-71443CEBB18A} = {32FAFFFE-A4CB-4FEE-BF7C-84518BBC6DCC}
1002999
{C19D9AC1-97DD-8E65-E8DB-D295A095AA2D} = {32FAFFFE-A4CB-4FEE-BF7C-84518BBC6DCC}
10031000
{B268E2F0-060F-8466-7D81-ABA4D735CA59} = {51AFE054-AE99-497D-A593-69BAEFB5106F}
10041001
{970BE341-9AC8-99A5-6572-E703C1E02FCB} = {E29DC6C4-5E57-48C5-BCB0-6B8F84782749}

Directory.Packages.props

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
<PackageVersion Include="A2A" Version="0.3.3-preview" />
77
<PackageVersion Include="CsvHelper" Version="33.1.0" />
88
<PackageVersion Include="FuzzySharp" Version="2.0.2" />
9-
<PackageVersion Include="Google_GenerativeAI" Version="3.4.1" />
10-
<PackageVersion Include="Google_GenerativeAI.Live" Version="3.4.1" />
9+
<PackageVersion Include="Google_GenerativeAI" Version="3.6.3" />
10+
<PackageVersion Include="Google_GenerativeAI.Live" Version="3.6.3" />
1111
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
1212
<PackageVersion Include="Polly" Version="8.4.2" />
13+
<PackageVersion Include="RabbitMQ.Client" Version="7.2.0" />
1314
<PackageVersion Include="SharpFuzz" Version="2.2.0" />
1415
<PackageVersion Include="SharpHook" Version="5.3.9" />
1516
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.12" />
@@ -25,14 +26,14 @@
2526
<PackageVersion Include="DistributedLock.Redis" Version="1.1.1" />
2627
<PackageVersion Include="Fluid.Core" Version="2.11.1" />
2728
<PackageVersion Include="Nanoid" Version="3.1.0" />
28-
<PackageVersion Include="Anthropic.SDK" Version="5.8.0" />
29+
<PackageVersion Include="Anthropic.SDK" Version="5.10.0" />
2930
<PackageVersion Include="NAudio" Version="2.2.1" />
3031
<PackageVersion Include="NAudio.Core" Version="2.2.1" />
3132
<PackageVersion Include="Whisper.net" Version="1.8.1" />
3233
<PackageVersion Include="Whisper.net.Runtime" Version="1.8.1" />
3334
<PackageVersion Include="NCrontab" Version="3.3.3" />
3435
<PackageVersion Include="Azure.AI.OpenAI" Version="2.7.0-beta.1" />
35-
<PackageVersion Include="OpenAI" Version="2.8.0" />
36+
<PackageVersion Include="OpenAI" Version="2.9.1" />
3637
<PackageVersion Include="MailKit" Version="4.14.1" />
3738
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.0" />
3839
<PackageVersion Include="MySql.Data" Version="9.5.0" />
@@ -101,8 +102,8 @@
101102
<PackageVersion Include="MSTest.TestAdapter" Version="4.0.2" />
102103
<PackageVersion Include="MSTest.TestFramework" Version="4.0.2" />
103104
<PackageVersion Include="Shouldly" Version="4.3.0" />
104-
<PackageVersion Include="ModelContextProtocol" Version="0.4.0-preview.3" />
105-
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.4.0-preview.3" />
105+
<PackageVersion Include="ModelContextProtocol" Version="1.2.0" />
106+
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="1.2.0" />
106107
</ItemGroup>
107108
<ItemGroup>
108109
<PackageVersion Include="BotSharp.Core" Version="$(BotSharpVersion)" />

src/BotSharp.AppHost/BotSharp.AppHost.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />
44
<PropertyGroup>
@@ -17,7 +17,6 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\..\tests\BotSharp.PizzaBot.MCPServer\BotSharp.PizzaBot.MCPServer.csproj" />
2120
<ProjectReference Include="..\BotSharp.ServiceDefaults\BotSharp.ServiceDefaults.csproj" />
2221
<ProjectReference Include="..\WebStarter\WebStarter.csproj" />
2322
</ItemGroup>

src/BotSharp.AppHost/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
var apiService = builder.AddProject<Projects.WebStarter>("apiservice")
44
.WithExternalHttpEndpoints();
5-
var mcpService = builder.AddProject<Projects.BotSharp_PizzaBot_MCPServer>("mcpservice")
6-
.WithExternalHttpEndpoints();
75

86
builder.AddNpmApp("BotSharpUI", "../../../BotSharp-UI")
97
.WithReference(apiService)

src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,45 @@ public void SetAgent(Agent agent)
2424
_agent = agent;
2525
}
2626

27-
public virtual bool OnAgentLoading(ref string id)
27+
public virtual Task<string?> OnAgentLoading(string id)
2828
{
29-
return true;
29+
return Task.FromResult<string?>(id);
3030
}
3131

32-
public virtual bool OnInstructionLoaded(string template, IDictionary<string, object> dict)
32+
public virtual Task<bool> OnInstructionLoaded(string template, IDictionary<string, object> dict)
3333
{
3434
dict["current_date"] = $"{DateTime.Now:MMM dd, yyyy}";
3535
dict["current_time"] = $"{DateTime.Now:hh:mm tt}";
3636
dict["current_weekday"] = $"{DateTime.Now:dddd}";
3737
dict["current_utc_datetime"] = $"{DateTime.UtcNow}";
3838

39-
return true;
39+
return Task.FromResult(true);
4040
}
4141

42-
public virtual bool OnFunctionsLoaded(List<FunctionDef> functions)
42+
public virtual Task<bool> OnFunctionsLoaded(List<FunctionDef> functions)
4343
{
4444
_agent.Functions = functions;
45-
return true;
45+
return Task.FromResult(true);
4646
}
4747

48-
public virtual bool OnSamplesLoaded(List<string> samples)
48+
public virtual Task<bool> OnSamplesLoaded(List<string> samples)
4949
{
5050
_agent.Samples = samples;
51-
return true;
51+
return Task.FromResult(true);
5252
}
5353

54-
public virtual void OnAgentLoaded(Agent agent)
54+
public virtual Task OnAgentLoaded(Agent agent)
5555
{
56+
return Task.CompletedTask;
5657
}
5758

58-
public virtual void OnAgentUtilityLoaded(Agent agent)
59+
public virtual Task OnAgentUtilityLoaded(Agent agent)
5960
{
60-
61+
return Task.CompletedTask;
6162
}
6263

63-
public virtual void OnAgentMcpToolLoaded(Agent agent)
64+
public virtual Task OnAgentMcpToolLoaded(Agent agent)
6465
{
65-
66+
return Task.CompletedTask;
6667
}
6768
}

src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ public interface IAgentHook : IHookBase
1010

1111
/// <summary>
1212
/// Triggered when agent is loading.
13-
/// Return different agent for redirection purpose.
13+
/// Return different agent id for redirection purpose.
1414
/// </summary>
1515
/// <param name="id">Agent Id</param>
16-
/// <returns></returns>
17-
bool OnAgentLoading(ref string id);
16+
/// <returns>New agent id if redirection is needed, null otherwise</returns>
17+
Task<string?> OnAgentLoading(string id);
1818

19-
bool OnInstructionLoaded(string template, IDictionary<string, object> dict);
19+
Task<bool> OnInstructionLoaded(string template, IDictionary<string, object> dict);
2020

21-
bool OnFunctionsLoaded(List<FunctionDef> functions);
21+
Task<bool> OnFunctionsLoaded(List<FunctionDef> functions);
2222

23-
bool OnSamplesLoaded(List<string> samples);
23+
Task<bool> OnSamplesLoaded(List<string> samples);
2424

25-
void OnAgentUtilityLoaded(Agent agent);
25+
Task OnAgentUtilityLoaded(Agent agent);
2626

27-
void OnAgentMcpToolLoaded(Agent agent);
27+
Task OnAgentMcpToolLoaded(Agent agent);
2828

2929
/// <summary>
3030
/// Triggered when agent is loaded completely.
3131
/// </summary>
3232
/// <param name="agent"></param>
3333
/// <returns></returns>
34-
void OnAgentLoaded(Agent agent);
34+
Task OnAgentLoaded(Agent agent);
3535
}

src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ public class AgentRule
88
[JsonPropertyName("disabled")]
99
public bool Disabled { get; set; }
1010

11-
[JsonPropertyName("criteria")]
12-
public string Criteria { get; set; } = string.Empty;
11+
[JsonPropertyName("config")]
12+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
13+
public RuleConfig? Config { get; set; }
1314
}
15+
16+
public class RuleConfig
17+
{
18+
[JsonPropertyName("topology_name")]
19+
public string? TopologyName { get; set; }
20+
}

src/Infrastructure/BotSharp.Abstraction/Coding/Contexts/CodeExecutionContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ public class CodeExecutionContext
44
{
55
public AgentCodeScript CodeScript { get; set; }
66
public List<KeyValue> Arguments { get; set; } = [];
7+
public string? InvokeFrom { get; set; }
78
}

src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using BotSharp.Abstraction.Repositories.Filters;
2-
using BotSharp.Abstraction.Users.Models;
32

43
namespace BotSharp.Abstraction.Conversations;
54

@@ -11,8 +10,8 @@ public interface IConversationService
1110
Task SetConversationId(string conversationId, List<MessageState> states, bool isReadOnly = false);
1211
Task<Conversation> GetConversation(string id, bool isLoadStates = false);
1312
Task<PagedItems<Conversation>> GetConversations(ConversationFilter filter);
14-
Task<Conversation> UpdateConversationTitle(string id, string title);
15-
Task<Conversation> UpdateConversationTitleAlias(string id, string titleAlias);
13+
Task<bool> UpdateConversationTitle(string id, string title);
14+
Task<bool> UpdateConversationTitleAlias(string id, string titleAlias);
1615
Task<bool> UpdateConversationTags(string conversationId, List<string> toAddTags, List<string> toDeleteTags);
1716
Task<bool> UpdateConversationMessage(string conversationId, UpdateMessageRequest request);
1817
Task<List<Conversation>> GetLastConversations();
@@ -41,7 +40,7 @@ Task<bool> SendMessage(string agentId,
4140
PostbackMessageModel? replyMessage,
4241
Func<RoleDialogModel, Task> onResponseReceived);
4342

44-
Task<List<RoleDialogModel>> GetDialogHistory(int lastCount = 100, bool fromBreakpoint = true, IEnumerable<string>? includeMessageTypes = null);
43+
Task<List<RoleDialogModel>> GetDialogHistory(int lastCount = 100, bool fromBreakpoint = true, IEnumerable<string>? includeMessageTypes = null, ConversationDialogFilter? filter = null);
4544
Task CleanHistory(string agentId);
4645

4746
/// <summary>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
using BotSharp.Abstraction.Repositories.Filters;
2+
13
namespace BotSharp.Abstraction.Conversations;
24

35
public interface IConversationStorage
46
{
57
Task Append(string conversationId, RoleDialogModel dialog);
68
Task Append(string conversationId, IEnumerable<RoleDialogModel> dialogs);
7-
Task<List<RoleDialogModel>> GetDialogs(string conversationId);
9+
Task<List<RoleDialogModel>> GetDialogs(string conversationId, ConversationDialogFilter? filter = null);
810
}

0 commit comments

Comments
 (0)