477af66232
* feat(chat): polish syntax highlighting and tool payload rendering (#94) * [verified] feat(chat): polish syntax highlighting and tool payload rendering * [verified] fix(chat): tighten large tool payload rendering * docs: update data volume path in Docker docs Align documentation with docker-compose.yml change: hermes-web-ui-data -> hermes-web-ui, /app/dist/data -> /root/.hermes-web-ui Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: bundle server build and restructure service modules - Add build-server.mjs script for standalone server compilation - Add logger service with structured output - Restructure auth, gateway-manager, hermes-cli, hermes services - Update docker-compose volume mount path - Update tsconfig and entry point for bundled server Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: separate controllers from routes and centralize route registration - Extract business logic from route handlers into controllers/ - Add centralized route registry in routes/index.ts with public/auth/protected layers - Replace global auth whitelist with sequential middleware registration - Extract shared helpers to services/config-helpers.ts - Allow custom provider name to be user-editable in ProviderFormModal - Deduplicate custom providers by poolKey instead of base_url in getAvailable Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: auth bypass via path case, SPA serving, and provider improvements - Fix auth bypass: path case-insensitive check for /api, /v1, /upload - Fix SPA returning 401: skip auth for non-API paths (static files) - Fix profile switch: use local loading state instead of shared store ref - Auto-append /v1 to base_url when fetching models (frontend + backend) - Guard .env writing to built-in providers only - Add builtin field to provider presets, enable base_url input in form - Print auth token to console on startup (pino only writes to file) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Zhicheng Han <43314240+hanzckernel@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import * as hermesCli from '../services/hermes/hermes-cli'
|
|
import { getGatewayManagerInstance } from '../services/gateway-bootstrap'
|
|
import { config } from '../config'
|
|
|
|
declare const __APP_VERSION__: string
|
|
const LOCAL_VERSION = typeof __APP_VERSION__ !== 'undefined'
|
|
? __APP_VERSION__
|
|
: (() => { try { const { readFileSync } = require('fs'); const { resolve } = require('path'); return JSON.parse(readFileSync(resolve(__dirname, '../../package.json'), 'utf-8')).version } catch { return '0.0.0' } })()
|
|
|
|
let cachedLatestVersion = ''
|
|
|
|
export async function checkLatestVersion(): Promise<void> {
|
|
try {
|
|
const { readFileSync } = require('fs')
|
|
const pkg = JSON.parse(readFileSync(resolve(require('path').join(__dirname, '../../package.json')), 'utf-8'))
|
|
const name = pkg.name
|
|
const res = await fetch(`https://registry.npmjs.org/${name}/latest`, { signal: AbortSignal.timeout(10000) })
|
|
if (res.ok) {
|
|
const data = await res.json() as { version: string }
|
|
cachedLatestVersion = data.version
|
|
if (cachedLatestVersion !== LOCAL_VERSION) {
|
|
console.log(`Update available: ${LOCAL_VERSION} → ${cachedLatestVersion}`)
|
|
}
|
|
}
|
|
} catch { /* ignore */ }
|
|
}
|
|
|
|
export function startVersionCheck(): void {
|
|
setTimeout(checkLatestVersion, 5000)
|
|
setInterval(checkLatestVersion, 30 * 60 * 1000)
|
|
}
|
|
|
|
export async function healthCheck(ctx: any) {
|
|
const raw = await hermesCli.getVersion()
|
|
const hermesVersion = raw.split('\n')[0].replace('Hermes Agent ', '') || ''
|
|
let gatewayOk = false
|
|
try {
|
|
const mgr = getGatewayManagerInstance()
|
|
const upstream = mgr?.getUpstream() || config.upstream
|
|
const res = await fetch(`${upstream.replace(/\/$/, '')}/health`, { signal: AbortSignal.timeout(5000) })
|
|
gatewayOk = res.ok
|
|
} catch { }
|
|
ctx.body = {
|
|
status: gatewayOk ? 'ok' : 'error',
|
|
platform: 'hermes-agent',
|
|
version: hermesVersion,
|
|
gateway: gatewayOk ? 'running' : 'stopped',
|
|
webui_version: LOCAL_VERSION,
|
|
webui_latest: cachedLatestVersion,
|
|
webui_update_available: cachedLatestVersion && cachedLatestVersion !== LOCAL_VERSION,
|
|
}
|
|
}
|
|
|
|
function resolve(p: string) { return p }
|