Personal AI, On Personal Devices
Python
DGX Spark Fix (#231)
Tanvir Bhathal0e122cd7761d
diff --git a/.gitignore b/.gitignoreindex a993fcf3..889072d9 100644--- a/.gitignore+++ b/.gitignore@@ -90,4 +90,18 @@ CLAUDE.mdresearch_mining_*.python-versionsrc/openjarvis/channels/whatsapp_baileys_bridge/node_modules/++# SQLite in-memory artifacts+:memory:+MagicMock/++# Second Repos+Inline/scratch/++# SQLite in-memory artifacts+:memory:+MagicMock/++# Second Repos+Inline/diff --git a/src/openjarvis/server/auth_middleware.py b/src/openjarvis/server/auth_middleware.pyindex 52e79b59..fb7e05fd 100644--- a/src/openjarvis/server/auth_middleware.py+++ b/src/openjarvis/server/auth_middleware.py@@ -12,17 +12,9 @@ from starlette.responses import JSONResponselogger = logging.getLogger(__name__)-# Paths exempt from API key auth-_EXEMPT_PREFIXES = (- "/health",- "/webhooks/",- "/docs",- "/openapi.json",-)-class AuthMiddleware(BaseHTTPMiddleware):- """Validates ``Authorization: Bearer <key>`` on ``/v1/*`` routes.+ """Validates ``Authorization: Bearer <key>`` on ``/v1/*`` and ``/api/*`` routes.Webhook routes and health checks are exempt — they useper-channel signature verification instead.@@ -33,7 +25,7 @@ class AuthMiddleware(BaseHTTPMiddleware):self._api_key = api_key or os.environ.get("OPENJARVIS_API_KEY", "")async def dispatch(self, request: Request, call_next): # noqa: ANN001- if self._api_key and not self._is_exempt(request.url.path):+ if self._api_key and self._requires_auth(request.url.path):auth = request.headers.get("Authorization", "")if not auth:return JSONResponse(@@ -49,8 +41,10 @@ class AuthMiddleware(BaseHTTPMiddleware):return await call_next(request)@staticmethod- def _is_exempt(path: str) -> bool:- return any(path.startswith(p) for p in _EXEMPT_PREFIXES)+ def _requires_auth(path: str) -> bool:+ """Only protect API routes, not the frontend UI or static assets."""+ return path.startswith("/v1/") or path.startswith("/api/")+def generate_api_key() -> str:diff --git a/tests/agents/test_base_agent.py b/tests/agents/test_base_agent.pyindex f291020d..4235959c 100644--- a/tests/agents/test_base_agent.py+++ b/tests/agents/test_base_agent.py@@ -167,9 +167,7 @@ class TestBuildMessages:empty_cfg = JarvisConfig()empty_cfg.agent.default_system_prompt = ""- monkeypatch.setattr(- "openjarvis.agents._stubs.load_config", lambda: empty_cfg- )+ monkeypatch.setattr("openjarvis.agents._stubs.load_config", lambda: empty_cfg)engine = MagicMock()agent = _ConcreteAgent(engine, "m")diff --git a/tests/connectors/test_connector_health.py b/tests/connectors/test_connector_health.pyindex a56a386a..9269d20b 100644--- a/tests/connectors/test_connector_health.py+++ b/tests/connectors/test_connector_health.py@@ -120,7 +120,10 @@ def test_connector_has_metadata(def test_knowledge_store_has_data() -> None:- """KnowledgeStore at default path has data (if it exists)."""+ """Assert a populated default-path KnowledgeStore has chunks and sources.++ Skips if the DB is missing or has no indexed rows (fresh install / empty store).+ """from openjarvis.connectors.store import KnowledgeStorefrom openjarvis.core.config import DEFAULT_CONFIG_DIR@@ -129,20 +132,26 @@ def test_knowledge_store_has_data() -> None:pytest.skip("No knowledge.db found")store = KnowledgeStore(str(db_path))- count = store.count()- assert count > 0, "KnowledgeStore has no data"+ try:+ count = store.count()+ if count == 0:+ pytest.skip("KnowledgeStore exists but has no indexed data")- # Check sources exist- rows = store._conn.execute(- "SELECT DISTINCT source FROM knowledge_chunks"- ).fetchall()- sources = [r[0] for r in rows]- assert len(sources) > 0, "No sources in KnowledgeStore"- store.close()+ # Check sources exist+ rows = store._conn.execute(+ "SELECT DISTINCT source FROM knowledge_chunks"+ ).fetchall()+ sources = [r[0] for r in rows]+ assert len(sources) > 0, "No sources in KnowledgeStore"+ finally:+ store.close()def test_knowledge_store_sources_have_chunks() -> None:- """Each connected source has at least 1 chunk in the store."""+ """Each source row in a populated store has at least 1 chunk.++ Skips if the DB is missing or empty (same as test_knowledge_store_has_data).+ """from openjarvis.connectors.store import KnowledgeStorefrom openjarvis.core.config import DEFAULT_CONFIG_DIR@@ -151,12 +160,16 @@ def test_knowledge_store_sources_have_chunks() -> None:pytest.skip("No knowledge.db found")store = KnowledgeStore(str(db_path))- rows = store._conn.execute(- "SELECT source, COUNT(*) as n FROM knowledge_chunks "- "GROUP BY source ORDER BY n DESC"- ).fetchall()-- for source, count in rows:- assert count > 0, f"Source '{source}' has 0 chunks"-- store.close()+ try:+ if store.count() == 0:+ pytest.skip("KnowledgeStore exists but has no indexed data")++ rows = store._conn.execute(+ "SELECT source, COUNT(*) as n FROM knowledge_chunks "+ "GROUP BY source ORDER BY n DESC"+ ).fetchall()++ for source, count in rows:+ assert count > 0, f"Source '{source}' has 0 chunks"+ finally:+ store.close()diff --git a/uv.lock b/uv.lockindex d50a2c74..fc5fca60 100644--- a/uv.lock+++ b/uv.lock@@ -4776,7 +4776,7 @@ wheels = [][[package]]-name = "openjarvis"+name = "openjarvisai"version = "0.1.0"source = { editable = "." }dependencies = [