4.1 Bridge reconnection: Fixed data race on callCount (atomic.Int32), added exponential backoff verification test (HTTP 403 rejection path), added server shutdown detection test. 4.2 Bridge auth: Added Token field to Config, WithToken option, Authorization Bearer header in dial() when token is non-empty. Tests verify header presence and absence. 4.3 Tool handler tests: 49 tests covering all 11 IDE tool handlers (5 chat/session, 3 build, 3 dashboard) with nil bridge (error path) and connected mock bridge (success path). JSON round-trip tests for all input/output types. Added stub documentation comments to all tool handler functions. Co-Authored-By: Virgil <virgil@lethean.io>
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
// Package ide provides an MCP subsystem that bridges the desktop IDE to
|
|
// a Laravel core-agentic backend over WebSocket.
|
|
package ide
|
|
|
|
import "time"
|
|
|
|
// Config holds connection and workspace settings for the IDE subsystem.
|
|
type Config struct {
|
|
// LaravelWSURL is the WebSocket endpoint for the Laravel core-agentic backend.
|
|
LaravelWSURL string
|
|
|
|
// WorkspaceRoot is the local path used as the default workspace context.
|
|
WorkspaceRoot string
|
|
|
|
// Token is the Bearer token sent in the Authorization header during
|
|
// WebSocket upgrade. When empty, no auth header is sent.
|
|
Token string
|
|
|
|
// ReconnectInterval controls how long to wait between reconnect attempts.
|
|
ReconnectInterval time.Duration
|
|
|
|
// MaxReconnectInterval caps exponential backoff for reconnection.
|
|
MaxReconnectInterval time.Duration
|
|
}
|
|
|
|
// DefaultConfig returns sensible defaults for local development.
|
|
func DefaultConfig() Config {
|
|
return Config{
|
|
LaravelWSURL: "ws://localhost:9876/ws",
|
|
WorkspaceRoot: ".",
|
|
ReconnectInterval: 2 * time.Second,
|
|
MaxReconnectInterval: 30 * time.Second,
|
|
}
|
|
}
|
|
|
|
// Option configures the IDE subsystem.
|
|
type Option func(*Config)
|
|
|
|
// WithLaravelURL sets the Laravel WebSocket endpoint.
|
|
func WithLaravelURL(url string) Option {
|
|
return func(c *Config) { c.LaravelWSURL = url }
|
|
}
|
|
|
|
// WithWorkspaceRoot sets the workspace root directory.
|
|
func WithWorkspaceRoot(root string) Option {
|
|
return func(c *Config) { c.WorkspaceRoot = root }
|
|
}
|
|
|
|
// WithReconnectInterval sets the base reconnect interval.
|
|
func WithReconnectInterval(d time.Duration) Option {
|
|
return func(c *Config) { c.ReconnectInterval = d }
|
|
}
|
|
|
|
// WithToken sets the Bearer token for WebSocket authentication.
|
|
func WithToken(token string) Option {
|
|
return func(c *Config) { c.Token = token }
|
|
}
|