Add community node protocol spec, Agent Skills, and make the failing tests hermetic
DevPlace CI / test (push) Failing after 31m42s

Community nodes (Phase 1 of plan.md): the protocol specification in
services/nodes/spec.py as the single source of truth, GET /nodes/spec.json,
a generated protocol docs page, the Community nodes API docs group, and the
implementation plan plus the residential proxy research. The no-open-proxy rule
is enforced in the spec (open_proxy cannot be set).

Agent Skills: register the Skills API docs group, cascade skills on account
deletion, add the nested CLAUDE.md, README and routes docs, and cover the
parser, the fetcher (end to end against a mock origin), the data layer and the
routes with 73 unit and 16 api tests.

Tests made hermetic with the repo's existing patterns instead of ambient
environment: embeddings tests set OPENROUTER_API_KEY via monkeypatch, the
workspace tests install FakeBackend via runtime.set_backend, and the skills
install tests use run_async. DockerCliBackend now returns 127 (command not
found) when the CLI is missing instead of raising FileNotFoundError, so a host
without docker answers with a clean error rather than a 500. The Providers tab
empty state no longer names the Model routes tab.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 07:13:25 +02:00
co-authored by Claude Sonnet 5.5
parent cae139ead9
commit f55c7ee5f4
102 changed files with 7414 additions and 65 deletions
+95 -20
View File
@@ -36,6 +36,14 @@ CLIENT_PROFILES: dict = {
"opencode": opencode_zen.opencode_impersonation_headers,
}
# Upstream wire protocol a provider speaks. `chat_completions` is the
# classic OpenAI shape (base_url ends in /chat/completions, forwarded
# verbatim). `responses` is the Responses API shape (base_url ends in
# /responses); the gateway transpiles inbound Chat requests to it and
# converts Response objects / SSE events back to the normal OpenAI surface.
PROVIDER_PROTOCOLS = ("chat_completions", "responses")
PROTOCOL_DEFAULT = "chat_completions"
_ROUTING_CACHE: dict = {}
@@ -78,6 +86,20 @@ def _models_url_from_base(base_url: str) -> str:
return base_url.rstrip("/") + "/models"
def _responses_models_urls(base_url: str) -> list:
# A Responses-protocol provider's model listing is vendor-specific:
# OpenAI serves /models next to /responses, Meta serves
# /muse-code/models. Probe both, first success wins.
base_url = (base_url or "").strip()
if not base_url:
return []
if base_url.endswith("/responses"):
root = base_url[: -len("/responses")].rstrip("/")
else:
root = base_url.rstrip("/")
return [root + "/models", root + "/muse-code/models"]
PROVIDER_MODELS_PROBE_TIMEOUT = 8.0
@@ -89,6 +111,14 @@ def _default_provider_credentials() -> tuple[str, str]:
return cfg.get("gateway_upstream_url", ""), cfg.get("gateway_api_key", "")
def _default_provider_protocol() -> str:
from devplacepy.services.manager import service_manager
svc = service_manager.get_service("openai")
cfg = svc.get_config() if svc is not None else {}
return cfg.get("gateway_upstream_protocol", PROTOCOL_DEFAULT) or PROTOCOL_DEFAULT
async def fetch_provider_models(
provider_name: str, timeout: float = PROVIDER_MODELS_PROBE_TIMEOUT
) -> Optional[list[str]]:
@@ -97,33 +127,53 @@ async def fetch_provider_models(
provider = provider_store.get(provider_name)
if provider is None:
return None
base_url, api_key = provider.get("base_url", ""), provider.get("api_key", "")
base_url = provider.get("base_url", "")
api_key = provider.get("api_key", "")
protocol = provider.get("protocol", PROTOCOL_DEFAULT) or PROTOCOL_DEFAULT
else:
base_url, api_key = _default_provider_credentials()
models_url = _models_url_from_base(base_url)
if not models_url:
protocol = _default_provider_protocol()
if protocol == "responses":
models_urls = _responses_models_urls(base_url)
else:
single = _models_url_from_base(base_url)
models_urls = [single] if single else []
if not models_urls:
return None
from devplacepy import stealth
headers = {"authorization": f"Bearer {api_key}"} if api_key else {}
try:
async with stealth.stealth_async_client(timeout=timeout, headers=headers) as client:
response = await client.get(models_url)
except Exception as exc:
logger.info("gateway provider model listing failed for %s: %s", models_url, exc)
return None
if response.status_code != 200:
return None
try:
payload = response.json()
except Exception:
return None
rows = payload.get("data") if isinstance(payload, dict) else None
if not isinstance(rows, list):
return None
ids = [str(row["id"]) for row in rows if isinstance(row, dict) and row.get("id")]
return ids or None
for models_url in models_urls:
try:
async with stealth.stealth_async_client(
timeout=timeout, headers=headers
) as client:
response = await client.get(models_url)
except Exception as exc:
logger.info(
"gateway provider model listing failed for %s: %s",
models_url,
exc,
)
continue
if response.status_code != 200:
continue
try:
payload = response.json()
except Exception:
continue
rows = payload.get("data") if isinstance(payload, dict) else None
if not isinstance(rows, list):
continue
ids = [
str(row["id"])
for row in rows
if isinstance(row, dict) and row.get("id")
]
if ids:
return ids
return None
MODEL_TIER2_COLUMNS = (
@@ -144,11 +194,16 @@ def ensure_tables() -> None:
+ PROVIDERS_TABLE
+ " (id INTEGER PRIMARY KEY, name TEXT, base_url TEXT, api_key TEXT, "
"is_active INTEGER DEFAULT 1, client_profile TEXT DEFAULT '', "
"protocol TEXT DEFAULT 'chat_completions', "
"created_at TEXT, updated_at TEXT)"
)
providers_table = get_table(PROVIDERS_TABLE)
if not providers_table.has_column("client_profile"):
providers_table.create_column_by_example("client_profile", "")
if not providers_table.has_column("protocol"):
providers_table.create_column_by_example(
"protocol", PROTOCOL_DEFAULT
)
db.query(
"CREATE TABLE IF NOT EXISTS "
+ MODELS_TABLE
@@ -196,6 +251,7 @@ class ProviderIn(BaseModel):
api_key: str = Field(default="", max_length=400)
is_active: bool = True
client_profile: str = Field(default="", max_length=32)
protocol: str = Field(default=PROTOCOL_DEFAULT, max_length=32)
@field_validator("name")
@classmethod
@@ -225,6 +281,16 @@ class ProviderIn(BaseModel):
)
return value
@field_validator("protocol")
@classmethod
def _clean_protocol(cls, value: str) -> str:
value = (value or PROTOCOL_DEFAULT).strip().lower()
if value not in PROVIDER_PROTOCOLS:
raise ValueError(
f"protocol must be one of: {', '.join(PROVIDER_PROTOCOLS)}"
)
return value
class ModelRouteIn(BaseModel):
source_model: str = Field(min_length=1, max_length=128)
@@ -366,6 +432,9 @@ def _load() -> dict:
"api_key": str(row.get("api_key") or ""),
"is_active": _as_bool(row.get("is_active", 1)),
"client_profile": str(row.get("client_profile") or ""),
"protocol": str(
row.get("protocol") or PROTOCOL_DEFAULT
),
}
if MODELS_TABLE in db.tables:
for row in get_table(MODELS_TABLE).all():
@@ -404,6 +473,7 @@ class ProviderStore:
"api_key": payload.api_key,
"is_active": 1 if payload.is_active else 0,
"client_profile": payload.client_profile,
"protocol": payload.protocol,
"updated_at": _now(),
}
if existing:
@@ -632,6 +702,11 @@ def chat_overlay(requested_model: Optional[str], base_cfg: dict) -> Optional[dic
header_hook = _header_hook_for(route.provider)
if header_hook is not None:
overlay["gateway_extra_request_headers"] = header_hook()
provider = provider_store.get(route.provider)
if provider is not None:
overlay["gateway_upstream_protocol"] = (
provider.get("protocol") or PROTOCOL_DEFAULT
)
if route.context_window:
from devplacepy.services.openai_gateway.usage import parse_context_map