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
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@
**/__pycache__/**
private.*
.venv
**/temp/

# Temporary directories
**/temp/
**/tmp/
temp/
tmp/

Comment thread
akshaydeo marked this conversation as resolved.
# Specific transport ignores
transports/bifrost-http/logs/
transports/bifrost-http/tmp/
18 changes: 18 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"printWidth": 140,
"singleQuote": true,
"semi": false,
"bracketSpacing": true,
"bracketSameLine": false,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all",
"plugins": [
"prettier-plugin-tailwindcss"
],
"tailwindFunctions": [
"cn",
"classNames"
]
}
135 changes: 135 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Makefile for Bifrost

# Variables
CONFIG_FILE ?= transports/config.example.json
PORT ?= 8080
POOL_SIZE ?= 300
PLUGINS ?= maxim
PROMETHEUS_LABELS ?=

# Colors for output
RED=\033[0;31m
GREEN=\033[0;32m
YELLOW=\033[1;33m
BLUE=\033[0;34m
CYAN=\033[0;36m
NC=\033[0m # No Color

.PHONY: help dev dev-ui build run install-air clean test install-ui
Comment thread
akshaydeo marked this conversation as resolved.

# Default target
help: ## Show this help message
@echo "$(BLUE)Bifrost Development - Available Commands:$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(YELLOW)Environment Variables:$(NC)"
@echo " CONFIG_FILE Path to config file (default: transports/config.example.json)"
@echo " PORT Server port (default: 8080)"
@echo " POOL_SIZE Connection pool size (default: 300)"
@echo " PLUGINS Comma-separated plugins to load (default: maxim)"
@echo " PROMETHEUS_LABELS Labels for Prometheus metrics"


install-ui:
@which node > /dev/null || (echo "$(RED)Error: Node.js is not installed. Please install Node.js first.$(NC)" && exit 1)
@which npm > /dev/null || (echo "$(RED)Error: npm is not installed. Please install npm first.$(NC)" && exit 1)
@echo "$(GREEN)Node.js and npm are installed$(NC)"
@cd ui && npm install
@which next > /dev/null || (echo "$(YELLOW)Installing nextjs...$(NC)" && npm install -g next)
@echo "$(GREEN)UI deps are in sync$(NC)"

Comment thread
akshaydeo marked this conversation as resolved.
install-air: ## Install air for hot reloading (if not already installed)
@which air > /dev/null || (echo "$(YELLOW)Installing air for hot reloading...$(NC)" && go install github.com/air-verse/air@latest)
@echo "$(GREEN)Air is ready$(NC)"

Comment thread
akshaydeo marked this conversation as resolved.
dev-http: install-ui install-air ## Start complete development environment (UI + API with proxy)
@echo "$(GREEN)Starting Bifrost complete development environment...$(NC)"
@echo "$(YELLOW)This will start:$(NC)"
@echo " 1. UI development server (localhost:3000)"
@echo " 2. API server with UI proxy (localhost:$(PORT)/ui)"
@echo "$(CYAN)Access everything at: http://localhost:$(PORT)/ui$(NC)"
@echo ""
@echo "$(YELLOW)Starting UI development server...$(NC)"
@cd ui && npm run dev &
@sleep 3
@echo "$(YELLOW)Starting API server with UI proxy...$(NC)"
@cd transports/bifrost-http && BIFROST_UI_DEV=true air -c .air.toml -- \
-port "$(PORT)" \
-plugins "$(PLUGINS)" \
$(if $(PROMETHEUS_LABELS),-prometheus-labels "$(PROMETHEUS_LABELS)")

build: ## Build bifrost-http binary
@echo "$(GREEN)Building bifrost-http...$(NC)"
@cd transports/bifrost-http && go build -o ../../tmp/bifrost-http .
@echo "$(GREEN)Built: tmp/bifrost-http$(NC)"

run: build ## Build and run bifrost-http (no hot reload)
@echo "$(GREEN)Running bifrost-http...$(NC)"
@./tmp/bifrost-http \
-config "$(CONFIG_FILE)" \
-port "$(PORT)" \
-pool-size $(POOL_SIZE) \
-plugins "$(PLUGINS)" \
$(if $(PROMETHEUS_LABELS),-prometheus-labels "$(PROMETHEUS_LABELS)")


clean: ## Clean build artifacts and temporary files
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
@rm -rf tmp/
@rm -f transports/bifrost-http/build-errors.log
@rm -rf transports/bifrost-http/tmp/
@echo "$(GREEN)Clean complete$(NC)"

test: ## Run tests for bifrost-http
@echo "$(GREEN)Running bifrost-http tests...$(NC)"
@cd transports/bifrost-http && go test -v ./...

test-core: ## Run core tests
@echo "$(GREEN)Running core tests...$(NC)"
@cd core && go test -v ./...

test-plugins: ## Run plugin tests
@echo "$(GREEN)Running plugin tests...$(NC)"
@cd plugins && find . -name "*.go" -path "*/tests/*" -o -name "*_test.go" | head -1 > /dev/null && \
for dir in $$(find . -name "*_test.go" -exec dirname {} \; | sort -u); do \
echo "Testing $$dir..."; \
cd $$dir && go test -v ./... && cd - > /dev/null; \
done || echo "No plugin tests found"

test-all: test-core test-plugins test ## Run all tests

# Quick start with example config
quick-start: ## Quick start with example config and maxim plugin
@echo "$(GREEN)Quick starting Bifrost with example configuration...$(NC)"
@$(MAKE) dev CONFIG_FILE=transports/config.example.json PLUGINS=maxim

Comment thread
akshaydeo marked this conversation as resolved.
# Docker targets
docker-build: ## Build Docker image
@echo "$(GREEN)Building Docker image...$(NC)"
@cd transports && docker build -t bifrost .
@echo "$(GREEN)Docker image built: bifrost$(NC)"

docker-run: ## Run Docker container
@echo "$(GREEN)Running Docker container...$(NC)"
@docker run -p $(PORT):$(PORT) \
-v $(PWD)/$(CONFIG_FILE):/app/config/config.json \
--env-file <(env | grep -E '^(OPENAI|ANTHROPIC|AZURE|AWS|COHERE|VERTEX)_') \
bifrost
Comment thread
akshaydeo marked this conversation as resolved.

# Linting and formatting
lint: ## Run linter for Go code
@echo "$(GREEN)Running golangci-lint...$(NC)"
@golangci-lint run ./...

fmt: ## Format Go code
@echo "$(GREEN)Formatting Go code...$(NC)"
@gofmt -s -w .
@goimports -w .

# Git hooks and development setup
setup-git-hooks: ## Set up Git hooks for development
@echo "$(GREEN)Setting up Git hooks...$(NC)"
@echo "#!/bin/sh\nmake fmt\nmake lint" > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo "$(GREEN)Git hooks installed$(NC)"
68 changes: 68 additions & 0 deletions transports/bifrost-http/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "./tmp"

[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "ui", "node_modules"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_root = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[proxy]
enabled = false
proxy_port = 8090
app_port = 8080

[screen]
clear_on_rebuild = false
keep_scroll = true

# Watch directories
[[build.watch_dirs]]
dir = "."

[[build.watch_dirs]]
dir = "../../core"

[[build.watch_dirs]]
dir = "./handlers"

[[build.watch_dirs]]
dir = "./integrations"

[[build.watch_dirs]]
dir = "./lib"

[[build.watch_dirs]]
dir = "./plugins"
11 changes: 0 additions & 11 deletions ui/.prettierrc

This file was deleted.

128 changes: 13 additions & 115 deletions ui/app/config/page.tsx
Original file line number Diff line number Diff line change
@@ -1,119 +1,17 @@
"use client";
'use client'

import { useState, useEffect } from "react";
import Header from "@/components/header";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Badge } from "@/components/ui/badge";
import { Settings, Database, Zap } from "lucide-react";
import { useToast } from "@/hooks/use-toast";
import { ProviderResponse } from "@/lib/types/config";
import { apiService } from "@/lib/api";
import CoreSettingsList from "@/components/config/core-settings-list";
import ProvidersList from "@/components/config/providers-list";
import MCPClientsList from "@/components/config/mcp-clients-lists";
import { MCPClient } from "@/lib/types/mcp";
import FullPageLoader from "@/components/full-page-loader";
import CoreSettingsList from '@/components/config/core-settings-list'

export default function ConfigPage() {
const [activeTab, setActiveTab] = useState("providers");
const [isLoadingProviders, setIsLoadingProviders] = useState(true);
const [isLoadingMcpClients, setIsLoadingMcpClients] = useState(true);
const [providers, setProviders] = useState<ProviderResponse[]>([]);
const [mcpClients, setMcpClients] = useState<MCPClient[]>([]);

const { toast } = useToast();

// Load configuration data
useEffect(() => {
loadProviders();
loadMcpClients();
}, []);

const loadProviders = async () => {
const [data, error] = await apiService.getProviders();
setIsLoadingProviders(false);

if (error) {
toast({
title: "Error",
description: error,
variant: "destructive",
});
return;
}
setProviders(data?.providers || []);
};

const loadMcpClients = async () => {
const [data, error] = await apiService.getMCPClients();
setIsLoadingMcpClients(false);

if (error) {
toast({
title: "Error",
description: error,
variant: "destructive",
});
return;
}

setMcpClients(data || []);
};

return (
<div className="bg-background">
{isLoadingProviders || isLoadingMcpClients ? (
<FullPageLoader />
) : (
<div className="space-y-6">
{/* Page Header */}
<div>
<h1 className="text-3xl font-bold">Configuration</h1>
<p className="text-muted-foreground mt-2">Configure AI providers, API keys, and system settings for your Bifrost instance.</p>
</div>

{/* Configuration Tabs */}
<Tabs value={activeTab} onValueChange={setActiveTab} className="space-y-6">
<TabsList className="grid h-12 w-full grid-cols-3">
<TabsTrigger value="providers" className="flex items-center gap-2">
<Database className="h-4 w-4" />
Providers
<Badge variant="default" className="ml-1">
{providers.length}
</Badge>
</TabsTrigger>
<TabsTrigger value="mcp" className="flex items-center gap-2">
<Zap className="h-4 w-4" />
MCP Clients
{mcpClients.length > 0 && (
<Badge variant="default" className="ml-1">
{mcpClients.length}
</Badge>
)}
</TabsTrigger>
<TabsTrigger value="core" className="flex items-center gap-2">
<Settings className="h-4 w-4" />
Core Settings
</TabsTrigger>
</TabsList>

{/* Providers Tab */}
<TabsContent value="providers" className="space-y-4">
<ProvidersList providers={providers} onRefresh={loadProviders} />
</TabsContent>

{/* MCP Tools Tab */}
<TabsContent value="mcp" className="space-y-4">
<MCPClientsList />
</TabsContent>

{/* Core Settings Tab */}
<TabsContent value="core" className="space-y-4">
<CoreSettingsList />
</TabsContent>
</Tabs>
</div>
)}
</div>
);
return (
<div className="bg-background space-y-6">
{/* Page Header */}
<div>
<h1 className="text-3xl font-bold">Configuration</h1>
<p className="text-muted-foreground mt-2">Configure AI providers, API keys, and system settings for your Bifrost instance.</p>
</div>

<CoreSettingsList />
</div>
)
}
Loading