Skip to content

Commit d6672cb

Browse files
author
Visagan Guruparan
committed
Update web driver to handle mutiple tasks per agent
1 parent 24657bd commit d6672cb

20 files changed

+50
-28
lines changed

src/Infrastructure/BotSharp.Abstraction/Infrastructures/Enums/StateConst.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public class StateConst
1616

1717
public const string SUB_CONVERSATION_ID = "sub_conversation_id";
1818
public const string ORIGIN_CONVERSATION_ID = "origin_conversation_id";
19+
public const string WEB_DRIVER_TASK_ID = "web_driver_task_id";
1920
}

src/Plugins/BotSharp.Plugin.WebDriver/Functions/ChangeCheckboxFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3434
message.Data = await _browser.ScreenshotAsync(new MessageInfo
3535
{
3636
AgentId = message.CurrentAgentId,
37-
ContextId = convService.ConversationId,
37+
ContextId = webDriverService.GetMessageContext(message),
3838
MessageId = message.MessageId
3939
}, path);
4040

src/Plugins/BotSharp.Plugin.WebDriver/Functions/ChangeListValueFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3434
message.Data = await _browser.ScreenshotAsync(new MessageInfo
3535
{
3636
AgentId = message.CurrentAgentId,
37-
ContextId = convService.ConversationId,
37+
ContextId = webDriverService.GetMessageContext(message),
3838
MessageId = message.MessageId
3939
}, path);
4040

src/Plugins/BotSharp.Plugin.WebDriver/Functions/CheckRadioButtonFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3434
message.Data = await _browser.ScreenshotAsync(new MessageInfo
3535
{
3636
AgentId = message.CurrentAgentId,
37-
ContextId = convService.ConversationId,
37+
ContextId = webDriverService.GetMessageContext(message),
3838
MessageId = message.MessageId
3939
}, path);
4040

src/Plugins/BotSharp.Plugin.WebDriver/Functions/ClickButtonFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3434
message.Data = await _browser.ScreenshotAsync(new MessageInfo
3535
{
3636
AgentId = message.CurrentAgentId,
37-
ContextId = convService.ConversationId,
37+
ContextId = webDriverService.GetMessageContext(message),
3838
MessageId = message.MessageId
3939
}, path);
4040

src/Plugins/BotSharp.Plugin.WebDriver/Functions/ClickElementFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3434
message.Data = await _browser.ScreenshotAsync(new MessageInfo
3535
{
3636
AgentId = message.CurrentAgentId,
37-
ContextId = convService.ConversationId,
37+
ContextId = webDriverService.GetMessageContext(message),
3838
MessageId = message.MessageId
3939
}, path);
4040

src/Plugins/BotSharp.Plugin.WebDriver/Functions/ExtractDataFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task<bool> Execute(RoleDialogModel message)
2828
message.Data = await _browser.ScreenshotAsync(new MessageInfo
2929
{
3030
AgentId = message.CurrentAgentId,
31-
ContextId = convService.ConversationId,
31+
ContextId = webDriverService.GetMessageContext(message),
3232
MessageId = message.MessageId
3333
}, path);
3434

src/Plugins/BotSharp.Plugin.WebDriver/Functions/GoToPageFn.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3131
var result = await _browser.GoToPage(new MessageInfo
3232
{
3333
AgentId = message.CurrentAgentId,
34-
ContextId = convService.ConversationId,
34+
ContextId = webDriverService.GetMessageContext(message),
3535
MessageId = message.MessageId
3636
}, new PageActionArgs
3737
{
@@ -45,7 +45,7 @@ public async Task<bool> Execute(RoleDialogModel message)
4545
message.Data = await _browser.ScreenshotAsync(new MessageInfo
4646
{
4747
AgentId = message.CurrentAgentId,
48-
ContextId = convService.ConversationId,
48+
ContextId = webDriverService.GetMessageContext(message),
4949
MessageId = message.MessageId
5050
}, path);
5151

src/Plugins/BotSharp.Plugin.WebDriver/Functions/HttpRequestFn.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using BotSharp.Plugin.WebDriver.Services;
2+
13
namespace BotSharp.Plugin.WebDriver.Functions;
24

35
public class HttpRequestFn : IFunctionCallback
@@ -20,12 +22,13 @@ public async Task<bool> Execute(RoleDialogModel message)
2022
var args = JsonSerializer.Deserialize<HttpRequestParams>(message.FunctionArgs);
2123

2224
var agentService = _services.GetRequiredService<IAgentService>();
25+
var webDriverService = _services.GetRequiredService<WebDriverService>();
2326
var agent = await agentService.LoadAgent(message.CurrentAgentId);
2427
var result = await _browser.SendHttpRequest(new MessageInfo
2528
{
2629
AgentId = agent.Id,
2730
MessageId = message.MessageId,
28-
ContextId = convService.ConversationId
31+
ContextId = webDriverService.GetMessageContext(message)
2932
}, args);
3033

3134
message.Content = result.IsSuccess ?

src/Plugins/BotSharp.Plugin.WebDriver/Functions/InputUserPasswordFn.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task<bool> Execute(RoleDialogModel message)
3333
message.Data = await _browser.ScreenshotAsync(new MessageInfo
3434
{
3535
AgentId = message.CurrentAgentId,
36-
ContextId = convService.ConversationId,
36+
ContextId = webDriverService.GetMessageContext(message),
3737
MessageId = message.MessageId
3838
}, path);
3939

0 commit comments

Comments
 (0)