mirror of
https://github.com/volcengine/OpenViking.git
synced 2026-09-30 17:28:07 +08:00
Every harness memory plugin sent OpenViking requests under Node's default `user-agent: node`, so server-side and gateway logs could not attribute traffic to a harness or a plugin version. Send `openviking-memory-<harness>/<version>` from all six harnesses (claude-code, codex, opencode, pi, cursor, trae) on both the data plane and the MCP proxy. Versions come from each harness's own manifest, or from OPENVIKING_INTEGRATION_VERSION for cursor/trae; an unreadable manifest degrades to 0.0.0 rather than throwing inside a short-lived hook. The header is purely informational — neither the open-source server nor the commercial gateway consumes it, and no auth or identity header changes.
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import { log, makeToast, normalizeEndpoint } from "./utils.mjs"
|
|
|
|
export async function checkServiceHealth(config, timeoutMs = 3000) {
|
|
const controller = new AbortController()
|
|
const timeout = setTimeout(() => controller.abort(), timeoutMs)
|
|
try {
|
|
const response = await fetch(`${normalizeEndpoint(config.endpoint)}/health`, {
|
|
method: "GET",
|
|
headers: config.userAgent ? { "User-Agent": config.userAgent } : undefined,
|
|
signal: controller.signal,
|
|
})
|
|
return response.ok
|
|
} catch (error) {
|
|
log("WARN", "health", "OpenViking health check failed", {
|
|
endpoint: config.endpoint,
|
|
error: error?.message,
|
|
})
|
|
return false
|
|
} finally {
|
|
clearTimeout(timeout)
|
|
}
|
|
}
|
|
|
|
export async function initializeRuntime(config, client) {
|
|
const toast = makeToast(client)
|
|
|
|
if (await checkServiceHealth(config)) {
|
|
log("INFO", "runtime", "OpenViking service is healthy", { endpoint: config.endpoint })
|
|
return true
|
|
}
|
|
|
|
await toast(`OpenViking service is not reachable at ${config.endpoint}. Start openviking-server before using memory tools.`, "warning")
|
|
return false
|
|
}
|