Skip to content

Commit c8228b7

Browse files
committed
feat: Improve cross-platform compatibility and connection reliability
- Add SSE keep-alive mechanism to prevent client timeout errors - Store database in platform-specific application data directories: - macOS: ~/Library/Application Support/agent-browser/ - Windows: %APPDATA%/agent-browser/ - Ensure proper data persistence when running as binary - Improve cursor configuration for cross-platform support
1 parent e39ea53 commit c8228b7

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

internal/app/app.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package app
44
import (
55
"context"
66
"net/http"
7+
"os"
8+
"path/filepath"
79

810
"github.com/co-browser/agent-browser/internal/backend"
911
"github.com/co-browser/agent-browser/internal/backend/database"
@@ -38,8 +40,31 @@ var defaultServers = []DefaultServer{
3840

3941
// provideDBConfig returns the database configuration.
4042
func provideDBConfig() database.Config {
43+
// Get the platform-specific user config directory
44+
userConfigDir, err := os.UserConfigDir()
45+
if err != nil {
46+
// Fallback to current directory if we can't get the config dir
47+
return database.Config{
48+
Path: "agent-browser.db",
49+
}
50+
}
51+
52+
// Create application-specific directory within the config dir
53+
appDataDir := filepath.Join(userConfigDir, "agent-browser")
54+
55+
// Create directory if it doesn't exist
56+
if err := os.MkdirAll(appDataDir, 0750); err != nil {
57+
// Fallback to current directory if we can't create the app data dir
58+
return database.Config{
59+
Path: "agent-browser.db",
60+
}
61+
}
62+
63+
// Use platform-specific path for the database
64+
dbPath := filepath.Join(appDataDir, "agent-browser.db")
65+
4166
return database.Config{
42-
Path: "agent-browser.db", // TODO: Make this configurable via env vars
67+
Path: dbPath,
4368
}
4469
}
4570

internal/mcp/server.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package mcp
44
import (
55
"context"
66
"fmt"
7+
"time"
78

89
"github.com/co-browser/agent-browser/internal/events"
910
"github.com/co-browser/agent-browser/internal/log"
@@ -78,7 +79,10 @@ func NewMCPComponents(p MCPParams) (MCPResult, error) {
7879
mcpServer.AddTool(tool, tools.HelloHandler)
7980

8081
// Create SSE server
81-
sseServer := server.NewSSEServer(mcpServer)
82+
sseServer := server.NewSSEServer(mcpServer,
83+
server.WithKeepAlive(true), // Enable keep-alive to prevent client timeout
84+
server.WithKeepAliveInterval(15*time.Second), // Send ping every 15 seconds
85+
)
8286

8387
return MCPResult{
8488
Server: mcpServer,

0 commit comments

Comments
 (0)