mirror of
https://github.com/ruvnet/RuView
synced 2026-07-21 17:13:19 +00:00
3f462a254d
Adds two new npm packages that expose RuView's WiFi-DensePose sensing capabilities outside the Cognitum appliance ecosystem: - tools/ruview-mcp/ (@ruv/ruview-mcp) — MCP server with 6 tools: ruview_csi_latest, ruview_pose_infer, ruview_count_infer, ruview_registry_list, ruview_train_count, ruview_job_status. Uses @modelcontextprotocol/sdk with stdio transport. 6/6 smoke tests pass. TypeScript strict mode, Node 20. - tools/ruview-cli/ (@ruv/ruview-cli) — Yargs CLI with matching subcommands: csi tail, pose infer, count infer, cogs list, train count, job status. Same fail-open pattern as the cog binaries (WARN to stderr, exit 0 on unavailable sensing-server). - docs/adr/ADR-104-ruview-mcp-cli-distribution.md — design rationale, 6-row threat table, packaging plan, acceptance gates, failure modes. - docs/research/sota-2026-05-22/HORIZON.md — 12-hour horizon plan with 7 milestones tracked (M1 complete in this commit). Both packages are private:true pending the user's publish decision. Inference is via subprocess to the signed cog binaries (ADR-100/101/103) — no JS/WASM ML engine bundled.
68 lines
2.3 KiB
TypeScript
68 lines
2.3 KiB
TypeScript
/**
|
|
* Configuration loader for the RuView MCP server.
|
|
*
|
|
* All settings can be overridden via environment variables. No config file is
|
|
* required — the server is designed to work out of the box with a locally-running
|
|
* sensing-server on the default port.
|
|
*/
|
|
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import type { RuviewConfig } from "./types.js";
|
|
|
|
function env(key: string): string | undefined {
|
|
return process.env[key];
|
|
}
|
|
|
|
function envOrDefault(key: string, fallback: string): string {
|
|
return env(key) ?? fallback;
|
|
}
|
|
|
|
/**
|
|
* Load the effective RuviewConfig from environment variables.
|
|
*
|
|
* Environment variables:
|
|
* RUVIEW_SENSING_SERVER_URL — base URL of the sensing-server (default: http://localhost:3000)
|
|
* RUVIEW_API_TOKEN — Bearer token for /api/v1/* routes (no default; auth disabled when absent)
|
|
* RUVIEW_POSE_COG_BINARY — path to cog-pose-estimation binary
|
|
* RUVIEW_COUNT_COG_BINARY — path to cog-person-count binary
|
|
* RUVIEW_JOBS_DIR — directory for job logs (default: ~/.ruview/jobs)
|
|
*/
|
|
export function loadConfig(): RuviewConfig {
|
|
return {
|
|
sensingServerUrl: envOrDefault(
|
|
"RUVIEW_SENSING_SERVER_URL",
|
|
"http://localhost:3000"
|
|
),
|
|
apiToken: env("RUVIEW_API_TOKEN"),
|
|
poseCogBinary: envOrDefault(
|
|
"RUVIEW_POSE_COG_BINARY",
|
|
detectCogBinary("cog-pose-estimation")
|
|
),
|
|
countCogBinary: envOrDefault(
|
|
"RUVIEW_COUNT_COG_BINARY",
|
|
detectCogBinary("cog-person-count")
|
|
),
|
|
jobsDir: envOrDefault(
|
|
"RUVIEW_JOBS_DIR",
|
|
path.join(os.homedir(), ".ruview", "jobs")
|
|
),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Attempt to locate a cog binary on PATH or in common install locations.
|
|
* Returns the bare binary name if not found (will fail gracefully at invocation).
|
|
*/
|
|
function detectCogBinary(name: string): string {
|
|
// Common install paths for Cognitum cog binaries on Linux/macOS appliances.
|
|
const candidates = [
|
|
`/var/lib/cognitum/apps/${name.replace("cog-", "")}/cog-${name.replace("cog-", "")}-arm`,
|
|
`/var/lib/cognitum/apps/${name.replace("cog-", "")}/cog-${name.replace("cog-", "")}-x86_64`,
|
|
`/usr/local/bin/${name}`,
|
|
name, // bare name — rely on PATH
|
|
];
|
|
// Return the first candidate that might exist; actual existence is checked at call time.
|
|
return candidates[candidates.length - 1] ?? name;
|
|
}
|