feat: add multi-gateway management with auto port detection

- Add GatewayManager for multi-profile gateway lifecycle management
- Auto-detect running gateways on startup via PID + health check
- Port conflict detection: check managed gateways, allocated ports, and
  system-level port availability (TCP bind test)
- Two-phase startup: sequential port resolution, parallel process launch
- Use `gateway start/restart` on normal systems, `gateway run --replace`
  on WSL/Docker
- Wait for health check before returning start/stop responses
- Add Gateways page with card-based layout showing profile status
- Reorganize sidebar navigation into collapsible groups
- Hide API server settings (now auto-managed by GatewayManager)
- Profile switch reloads page; Ctrl+C no longer stops gateways
- Remove redundant ensureApiServerConfig from index.ts and profiles.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-18 13:07:12 +08:00
parent 35481e452d
commit 4b6de351bd
15 changed files with 1170 additions and 467 deletions
@@ -0,0 +1,51 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { fetchGateways, startGateway, stopGateway, type GatewayStatus } from '@/api/hermes/gateways'
export const useGatewayStore = defineStore('gateways', () => {
const gateways = ref<GatewayStatus[]>([])
const loading = ref(false)
async function fetchStatus() {
loading.value = true
try {
const data = await fetchGateways()
gateways.value = Array.isArray(data) ? data : Object.values(data || {})
} finally {
loading.value = false
}
}
async function start(name: string) {
loading.value = true
try {
const status = await startGateway(name)
// Update the specific gateway in the list
const idx = gateways.value.findIndex(g => g.profile === name)
if (idx >= 0) {
gateways.value[idx] = status
} else {
gateways.value.push(status)
}
} finally {
loading.value = false
}
}
async function stop(name: string) {
loading.value = true
try {
await stopGateway(name)
// Update the specific gateway in the list
const gw = gateways.value.find(g => g.profile === name)
if (gw) {
gw.running = false
gw.pid = undefined
}
} finally {
loading.value = false
}
}
return { gateways, loading, fetchStatus, start, stop }
})