Skip to content

Commit 6307b90

Browse files
brojdit-barongithub-actions[bot]
authored
fix: browser preview improvements (#2580)
Co-authored-by: Aleksei Kudriashov <[email protected]> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Dominik Broj <[email protected]>
1 parent 5ae2aa0 commit 6307b90

Some content is hidden

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

52 files changed

+13559
-3680
lines changed

docs/openapi.json

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45134,6 +45134,39 @@
4513445134
}
4513545135
]
4513645136
},
45137+
"browserState": {
45138+
"nullable": true,
45139+
"anyOf": [
45140+
{
45141+
"anyOf": [
45142+
{
45143+
"type": "string"
45144+
},
45145+
{
45146+
"type": "number"
45147+
},
45148+
{
45149+
"type": "boolean"
45150+
},
45151+
{
45152+
"type": "string",
45153+
"nullable": true,
45154+
"enum": [
45155+
null
45156+
]
45157+
}
45158+
]
45159+
},
45160+
{
45161+
"type": "object",
45162+
"additionalProperties": {}
45163+
},
45164+
{
45165+
"type": "array",
45166+
"items": {}
45167+
}
45168+
]
45169+
},
4513745170
"artifact": {
4513845171
"nullable": true,
4513945172
"type": "string"
@@ -45198,6 +45231,7 @@
4519845231
"selectedProvider",
4519945232
"hasCustomToolSelection",
4520045233
"todoList",
45234+
"browserState",
4520145235
"artifact",
4520245236
"createdAt",
4520345237
"updatedAt",
@@ -45565,6 +45599,39 @@
4556545599
}
4556645600
]
4556745601
},
45602+
"browserState": {
45603+
"nullable": true,
45604+
"anyOf": [
45605+
{
45606+
"anyOf": [
45607+
{
45608+
"type": "string"
45609+
},
45610+
{
45611+
"type": "number"
45612+
},
45613+
{
45614+
"type": "boolean"
45615+
},
45616+
{
45617+
"type": "string",
45618+
"nullable": true,
45619+
"enum": [
45620+
null
45621+
]
45622+
}
45623+
]
45624+
},
45625+
{
45626+
"type": "object",
45627+
"additionalProperties": {}
45628+
},
45629+
{
45630+
"type": "array",
45631+
"items": {}
45632+
}
45633+
]
45634+
},
4556845635
"artifact": {
4556945636
"nullable": true,
4557045637
"type": "string"
@@ -45629,6 +45696,7 @@
4562945696
"selectedProvider",
4563045697
"hasCustomToolSelection",
4563145698
"todoList",
45699+
"browserState",
4563245700
"artifact",
4563345701
"createdAt",
4563445702
"updatedAt",
@@ -45961,6 +46029,39 @@
4596146029
}
4596246030
]
4596346031
},
46032+
"browserState": {
46033+
"nullable": true,
46034+
"anyOf": [
46035+
{
46036+
"anyOf": [
46037+
{
46038+
"type": "string"
46039+
},
46040+
{
46041+
"type": "number"
46042+
},
46043+
{
46044+
"type": "boolean"
46045+
},
46046+
{
46047+
"type": "string",
46048+
"nullable": true,
46049+
"enum": [
46050+
null
46051+
]
46052+
}
46053+
]
46054+
},
46055+
{
46056+
"type": "object",
46057+
"additionalProperties": {}
46058+
},
46059+
{
46060+
"type": "array",
46061+
"items": {}
46062+
}
46063+
]
46064+
},
4596446065
"artifact": {
4596546066
"nullable": true,
4596646067
"type": "string"
@@ -46025,6 +46126,7 @@
4602546126
"selectedProvider",
4602646127
"hasCustomToolSelection",
4602746128
"todoList",
46129+
"browserState",
4602846130
"artifact",
4602946131
"createdAt",
4603046132
"updatedAt",
@@ -46403,6 +46505,39 @@
4640346505
}
4640446506
]
4640546507
},
46508+
"browserState": {
46509+
"nullable": true,
46510+
"anyOf": [
46511+
{
46512+
"anyOf": [
46513+
{
46514+
"type": "string"
46515+
},
46516+
{
46517+
"type": "number"
46518+
},
46519+
{
46520+
"type": "boolean"
46521+
},
46522+
{
46523+
"type": "string",
46524+
"nullable": true,
46525+
"enum": [
46526+
null
46527+
]
46528+
}
46529+
]
46530+
},
46531+
{
46532+
"type": "object",
46533+
"additionalProperties": {}
46534+
},
46535+
{
46536+
"type": "array",
46537+
"items": {}
46538+
}
46539+
]
46540+
},
4640646541
"artifact": {
4640746542
"nullable": true,
4640846543
"type": "string"
@@ -46467,6 +46602,7 @@
4646746602
"selectedProvider",
4646846603
"hasCustomToolSelection",
4646946604
"todoList",
46605+
"browserState",
4647046606
"artifact",
4647146607
"createdAt",
4647246608
"updatedAt",
@@ -47329,6 +47465,39 @@
4732947465
}
4733047466
]
4733147467
},
47468+
"browserState": {
47469+
"nullable": true,
47470+
"anyOf": [
47471+
{
47472+
"anyOf": [
47473+
{
47474+
"type": "string"
47475+
},
47476+
{
47477+
"type": "number"
47478+
},
47479+
{
47480+
"type": "boolean"
47481+
},
47482+
{
47483+
"type": "string",
47484+
"nullable": true,
47485+
"enum": [
47486+
null
47487+
]
47488+
}
47489+
]
47490+
},
47491+
{
47492+
"type": "object",
47493+
"additionalProperties": {}
47494+
},
47495+
{
47496+
"type": "array",
47497+
"items": {}
47498+
}
47499+
]
47500+
},
4733247501
"artifact": {
4733347502
"nullable": true,
4733447503
"type": "string"
@@ -47393,6 +47562,7 @@
4739347562
"selectedProvider",
4739447563
"hasCustomToolSelection",
4739547564
"todoList",
47565+
"browserState",
4739647566
"artifact",
4739747567
"createdAt",
4739847568
"updatedAt",
@@ -47753,6 +47923,39 @@
4775347923
}
4775447924
]
4775547925
},
47926+
"browserState": {
47927+
"nullable": true,
47928+
"anyOf": [
47929+
{
47930+
"anyOf": [
47931+
{
47932+
"type": "string"
47933+
},
47934+
{
47935+
"type": "number"
47936+
},
47937+
{
47938+
"type": "boolean"
47939+
},
47940+
{
47941+
"type": "string",
47942+
"nullable": true,
47943+
"enum": [
47944+
null
47945+
]
47946+
}
47947+
]
47948+
},
47949+
{
47950+
"type": "object",
47951+
"additionalProperties": {}
47952+
},
47953+
{
47954+
"type": "array",
47955+
"items": {}
47956+
}
47957+
]
47958+
},
4775647959
"artifact": {
4775747960
"nullable": true,
4775847961
"type": "string"
@@ -47817,6 +48020,7 @@
4781748020
"selectedProvider",
4781848021
"hasCustomToolSelection",
4781948022
"todoList",
48023+
"browserState",
4782048024
"artifact",
4782148025
"createdAt",
4782248026
"updatedAt",

platform/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ ARCHESTRA_ORCHESTRATOR_K8S_NAMESPACE=default
103103

104104
# Logging
105105
ARCHESTRA_LOGGING_LEVEL=info
106+
ARCHESTRA_BROWSER_STREAM_LOG_SCREENSHOTS=false
107+
ARCHESTRA_BROWSER_STREAM_LOG_TAB_SYNC=false
106108

107109

108110
# Enterprise license toggle
@@ -218,3 +220,4 @@ LIGHTRAG_QDRANT_API_KEY=
218220
LIGHTRAG_LLM_MODEL=gpt-4o-mini
219221
LIGHTRAG_EMBEDDING_MODEL=text-embedding-3-small
220222
LIGHTRAG_EMBEDDING_DIM=1536
223+

platform/backend/src/clients/chat-mcp-client.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,9 @@ export async function getChatMcpTools({
625625
try {
626626
// For browser tools, ensure the correct conversation tab is selected first
627627
// Only if browser streaming feature is enabled
628-
// Lazily loaded to avoid circular dependency (browser-stream.ts imports from chat-mcp-client.ts)
628+
// Lazily loaded to avoid circular dependency (browser-stream.feature.ts imports from chat-mcp-client.ts)
629629
const { browserStreamFeature } = await import(
630-
"@/services/browser-stream-feature"
630+
"@/features/browser-stream/services/browser-stream.feature"
631631
);
632632

633633
if (
@@ -746,6 +746,40 @@ export async function getChatMcpTools({
746746
throw new Error(errorMessage);
747747
}
748748

749+
if (conversationId && mcpTool.name.includes("browser_tabs")) {
750+
const { browserStreamFeature } = await import(
751+
"@/features/browser-stream/services/browser-stream.feature"
752+
);
753+
if (browserStreamFeature.isEnabled()) {
754+
await browserStreamFeature.syncTabMappingFromTabsToolCall({
755+
agentId,
756+
conversationId,
757+
userContext: { userId, userIsProfileAdmin },
758+
toolArguments,
759+
toolResultContent: result.content,
760+
tabsToolName: mcpTool.name,
761+
});
762+
}
763+
}
764+
765+
// Sync navigation history when browser_navigate tool is used
766+
if (conversationId && mcpTool.name.includes("browser_navigate")) {
767+
const navigateUrl = toolArguments?.url;
768+
if (typeof navigateUrl === "string" && navigateUrl) {
769+
const { browserStreamFeature } = await import(
770+
"@/features/browser-stream/services/browser-stream.feature"
771+
);
772+
if (browserStreamFeature.isEnabled()) {
773+
await browserStreamFeature.syncNavigationFromToolCall({
774+
agentId,
775+
conversationId,
776+
userContext: { userId, userIsProfileAdmin },
777+
url: navigateUrl,
778+
});
779+
}
780+
}
781+
}
782+
749783
// Convert MCP content to string for AI SDK
750784
return (result.content as Array<{ type: string; text?: string }>)
751785
.map((item: { type: string; text?: string }) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "conversations" ADD COLUMN "browser_state" jsonb;

0 commit comments

Comments
 (0)