Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
feat(gateway): the Gateway card is on by default
trohitg208710b58341
diff --git a/.env.template b/.env.templateindex e3ee8371..f198c443 100644--- a/.env.template+++ b/.env.template@@ -339,11 +339,12 @@ WEBSOCKET_API_KEY=# Default port for AI proxy servers (e.g., Ollama, Claude Code CLI proxy)AI_PROXY_DEFAULT_PORT=11434-# OpenCompany Gateway (docs-internal/llm_gateway.md). When enabled, the-# Connectors panel offers the "Gateway" card: with a gateway key there, LLM+# OpenCompany Gateway (docs-internal/llm_gateway.md). On by default: the+# Connectors panel offers the "Gateway" card, and with a gateway key there, LLM# calls for a provider this install has no key of its own for go through the-# gateway, billed to the key owner's monthly allowance.-OPENCOMPANY_GATEWAY_ENABLED=false+# gateway, billed to the key owner's monthly allowance. false hides the card+# and turns the routing off.+OPENCOMPANY_GATEWAY_ENABLED=trueOPENCOMPANY_GATEWAY_URL=https://api.gw.opencompany.shdiff --git a/docs-internal/llm_gateway.md b/docs-internal/llm_gateway.mdindex c8e5a8ef..0f518ee3 100644--- a/docs-internal/llm_gateway.md+++ b/docs-internal/llm_gateway.md@@ -6,11 +6,11 @@ OpenCompany's hosted LLM gateway is the stock open-source LiteLLM Proxy, deploye## OpenCompany's side-**Turning it on.**-- `OPENCOMPANY_GATEWAY_ENABLED=true` (`gateway_enabled`, default off) lists the **Gateway** card, by OpenCompany, under AI models in Connectors. It is gated by `requires_setting` in `server/config/credential_providers.json`, honoured by `CredentialRegistry.get_all_providers`.+**On by default.**+- `OPENCOMPANY_GATEWAY_ENABLED` (`gateway_enabled`, default `true`) lists the **Gateway** card, by OpenCompany, under AI models in Connectors. It is gated by `requires_setting` in `server/config/credential_providers.json`, honoured by `CredentialRegistry.get_all_providers`.- **Where it appears:** in normal mode, the Get Started guide's Connect an AI model step and Connectors; in dev mode, API Credentials. Both shells use the same `CredentialsBrowser`.- `OPENCOMPANY_GATEWAY_URL` (`gateway_url`) points at the gateway.-- Off, behaviour is exactly as before.+- `false` hides the card and turns the routing off, so behaviour is exactly as without the gateway.- **No 1Password:** the router reads the key on every call, which a 1Password lookup can't serve. So the card offers no 1Password source (`catalogue_extras`), and distributed mode keeps the gateway off.**The key.** One gateway key per install, saved like any API key (`OpenCompanyGatewayCredential`, `services/gateway/credential.py`, default `validate`). Its probe calls the gateway's `/user/info` with the key: 401 means a wrong key; 403 means an LLM-API key, and the person is told to create a Default one. The card's `ws.status` hook (`gateway_status`, `services/gateway/handlers.py`) returns the allowance as one line, which the API-key panel shows under the key (`statusSummary` in `useCredentialPanel`).diff --git a/server/config/credential_providers.json b/server/config/credential_providers.jsonindex 8f9d0ee8..4c86cc80 100644--- a/server/config/credential_providers.json+++ b/server/config/credential_providers.json@@ -114,7 +114,7 @@]},"opencompany_gateway": {- "_description": "The hosted OpenCompany Gateway (gateway/, docs-internal/llm_gateway.md). One key per install, stored like any API key; LLM calls for a provider the install has no key of its own for go through the gateway on the key owner's monthly allowance (services/gateway). Not an LLM provider itself: no llm_defaults.json block, so it never appears in model pickers. Listed only while OPENCOMPANY_GATEWAY_ENABLED is on (requires_setting). ws.status feeds the card's allowance line.",+ "_description": "The hosted OpenCompany Gateway (gateway/, docs-internal/llm_gateway.md). One key per install, stored like any API key; LLM calls for a provider the install has no key of its own for go through the gateway on the key owner's monthly allowance (services/gateway). Not an LLM provider itself: no llm_defaults.json block, so it never appears in model pickers. Listed while OPENCOMPANY_GATEWAY_ENABLED is on, the default (requires_setting). ws.status feeds the card's allowance line.","name": "Gateway","publisher": "OpenCompany","verified": true,diff --git a/server/core/config.py b/server/core/config.pyindex 0f08f336..5dc17410 100644--- a/server/core/config.py+++ b/server/core/config.py@@ -359,8 +359,9 @@ class Settings(BaseSettings):# OpenCompany Gateway (hosted LiteLLM, gateway/): with a gateway key in# Connectors, LLM calls for a provider this install has no key of its- # own for go through the gateway on the person's allowance.- gateway_enabled: bool = Field(default=False, validation_alias="OPENCOMPANY_GATEWAY_ENABLED")+ # own for go through the gateway on the person's allowance. On by+ # default; false hides the card and turns the routing off.+ gateway_enabled: bool = Field(default=True, validation_alias="OPENCOMPANY_GATEWAY_ENABLED")gateway_url: str = Field(default="https://api.gw.opencompany.sh", validation_alias="OPENCOMPANY_GATEWAY_URL")# Residential Proxy Configurationdiff --git a/server/tests/conftest.py b/server/tests/conftest.pyindex efb45f73..c97977fc 100644--- a/server/tests/conftest.py+++ b/server/tests/conftest.py@@ -5,6 +5,7 @@ before any handler/service is loaded so node tests don't pay the cost ofreal DI or Temporal runtimes during collection."""+import osimport sysimport typesfrom pathlib import Path@@ -21,6 +22,13 @@ SERVER_DIR = Path(__file__).parent.parentif str(SERVER_DIR) not in sys.path:sys.path.insert(0, str(SERVER_DIR))+# The OpenCompany Gateway is on by default (core/config.py). Under test it is+# off, as on an install with no gateway key: once the real core.container is+# imported (middleware.auth does), its router would read the credentials+# database, which most tests never set up. Gateway tests build their router+# with explicit settings.+os.environ["OPENCOMPANY_GATEWAY_ENABLED"] = "false"+def _make_package(name: str) -> types.ModuleType:"""Force a fresh stub package, replacing whatever is in sys.modules."""diff --git a/server/tests/gateway/test_routing.py b/server/tests/gateway/test_routing.pyindex d38cf49a..b2cbee72 100644--- a/server/tests/gateway/test_routing.py+++ b/server/tests/gateway/test_routing.py@@ -100,9 +100,12 @@ def test_llm_defaults_serves_exactly_the_priced_providers():}-async def test_gateway_covers_trusts_only_a_real_router():- # tests/conftest.py stubs core.container with a MagicMock, whose router- # would claim to cover every provider.+async def test_gateway_covers_trusts_only_a_real_router(monkeypatch):+ # Under test the container can be a MagicMock (tests/conftest.py), whose+ # router would claim to cover every provider.+ from core.container import container++ monkeypatch.setattr(container, "gateway_router", MagicMock(), raising=False)assert await gateway_covers("openai") is False