Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion crates/agent-gateway/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import "embed"

// WebUIAssets contains the embedded WebUI build output served by the HTTP server.
//
//go:embed web/dist
// The all: prefix is required because Vite may emit chunks whose names begin
// with "_" (for example, lodash's _baseFor chunk). Plain directory embeds
// silently exclude files and directories beginning with "." or "_".
//
//go:embed all:web/dist
var WebUIAssets embed.FS
56 changes: 56 additions & 0 deletions crates/agent-gateway/embed_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package gateway

import (
"io/fs"
"os"
"sort"
"testing"
)

func TestWebUIAssetsIncludeEntireDistTree(t *testing.T) {
diskFiles := regularFileSizes(t, os.DirFS("."), "web/dist")
embeddedFiles := regularFileSizes(t, WebUIAssets, "web/dist")

var missing []string
for file, size := range diskFiles {
embeddedSize, ok := embeddedFiles[file]
if !ok {
missing = append(missing, file)
continue
}
if embeddedSize != size {
t.Fatalf("embedded WebUI asset %q size = %d, want %d", file, embeddedSize, size)
}
}

if len(missing) > 0 {
sort.Strings(missing)
t.Fatalf("embedded WebUI assets are missing files from web/dist: %v", missing)
}
}

func regularFileSizes(t *testing.T, fileSystem fs.FS, root string) map[string]int64 {
t.Helper()

files := make(map[string]int64)
err := fs.WalkDir(fileSystem, root, func(path string, entry fs.DirEntry, walkErr error) error {
if walkErr != nil {
return walkErr
}
if entry.IsDir() {
return nil
}
info, err := entry.Info()
if err != nil {
return err
}
if info.Mode().IsRegular() {
files[path] = info.Size()
}
return nil
})
if err != nil {
t.Fatalf("walk %q: %v", root, err)
}
return files
}
10 changes: 10 additions & 0 deletions crates/agent-gateway/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Config struct {
TLSCert string
TLSKey string
RequestTimeout time.Duration
ChatStartTimeout time.Duration
ChatRenderStartTimeout time.Duration
HeartbeatPeriod time.Duration
WebSocketHeartbeatPeriod time.Duration
WebSocketWriteTimeout time.Duration
Expand All @@ -32,6 +34,8 @@ func Load() *Config {
flag.StringVar(&cfg.TLSCert, "tls-cert", getenv("LIVEAGENT_GATEWAY_TLS_CERT", ""), "TLS certificate path")
flag.StringVar(&cfg.TLSKey, "tls-key", getenv("LIVEAGENT_GATEWAY_TLS_KEY", ""), "TLS private key path")
flag.DurationVar(&cfg.RequestTimeout, "request-timeout", getenvDuration("LIVEAGENT_GATEWAY_REQUEST_TIMEOUT", 2*time.Minute), "request timeout for non-streaming API calls")
flag.DurationVar(&cfg.ChatStartTimeout, "chat-start-timeout", getenvDuration("LIVEAGENT_GATEWAY_CHAT_START_TIMEOUT", 15*time.Second), "timeout waiting for the desktop backend to accept a remote chat request")
flag.DurationVar(&cfg.ChatRenderStartTimeout, "chat-render-start-timeout", getenvDuration("LIVEAGENT_GATEWAY_CHAT_RENDER_START_TIMEOUT", 45*time.Second), "timeout waiting for the desktop app to start an accepted remote chat request")
flag.DurationVar(&cfg.HeartbeatPeriod, "heartbeat-period", getenvDuration("LIVEAGENT_GATEWAY_HEARTBEAT_PERIOD", 30*time.Second), "ping interval for agent connection")
flag.DurationVar(&cfg.WebSocketHeartbeatPeriod, "websocket-heartbeat-period", getenvDuration("LIVEAGENT_GATEWAY_WS_HEARTBEAT_PERIOD", 15*time.Second), "ping interval for browser WebSocket connections")
flag.DurationVar(&cfg.WebSocketWriteTimeout, "websocket-write-timeout", getenvDuration("LIVEAGENT_GATEWAY_WS_WRITE_TIMEOUT", 10*time.Second), "write timeout for browser WebSocket connections")
Expand All @@ -49,6 +53,12 @@ func Load() *Config {
if cfg.GRPCMaxMessageBytes <= 0 {
cfg.GRPCMaxMessageBytes = DefaultGRPCMaxMessageBytes
}
if cfg.ChatStartTimeout <= 0 {
cfg.ChatStartTimeout = 15 * time.Second
}
if cfg.ChatRenderStartTimeout <= 0 {
cfg.ChatRenderStartTimeout = 45 * time.Second
}
if cfg.WebSocketHeartbeatPeriod <= 0 {
cfg.WebSocketHeartbeatPeriod = 15 * time.Second
}
Expand Down
Loading
Loading