molecule-core/workspace-template/tests
rabbitblood 376c9574a3 feat(hermes): Phase 1 — multi-provider registry (15 providers, back-compat preserved)
Ships the first half of the queued Hermes adapter expansion. PR 2 only
supported Nous Portal + OpenRouter; this adds 13 more providers reachable
via OpenAI-compat endpoints. Native SDK paths for Anthropic + Gemini are
Phase 2 (better tool-calling + vision fidelity).

## What's new

**`workspace-template/adapters/hermes/providers.py`** (new file, 220 LOC):
- ``ProviderConfig`` dataclass: name, env vars, base URL, default model, auth scheme, docs
- ``PROVIDERS`` dict with 15 entries across 4 groups:
  - PR 2 baseline: nous_portal, openrouter
  - Frontier commercial: openai, anthropic, xai, gemini
  - Chinese providers: qwen, glm, kimi, minimax, deepseek
  - OSS/alt: groq, together, fireworks, mistral
- ``RESOLUTION_ORDER`` tuple: priority for auto-detect (back-compat first,
  then commercial, then Chinese, then OSS/alt)
- ``resolve_provider(explicit=None)`` -> (ProviderConfig, api_key)
  - With explicit name: routes to that provider, raises if env var empty
  - Without: walks RESOLUTION_ORDER, first env-var-set provider wins

**`workspace-template/adapters/hermes/executor.py`** (refactored):
- `create_executor(hermes_api_key=None, provider=None, model=None)` now has
  three parameters:
  - `hermes_api_key`: PR 2 back-compat — routes to Nous Portal
  - `provider`: canonical short name from the registry (e.g. "anthropic")
  - `model`: optional override of the provider's default model
- Delegates all resolution to `providers.resolve_provider()` — no more
  hardcoded URLs or env var lookups in the executor itself
- `HermesA2AExecutor.__init__` no longer has Nous-specific defaults; callers
  pass base_url + model explicitly (which create_executor always does)

**`workspace-template/tests/test_hermes_providers.py`** (new file, 26 tests):
- Registry shape invariants (count >= 15, no duplicates, every config valid)
- PR 2 back-compat: HERMES_API_KEY / OPENROUTER_API_KEY still route correctly
- Auto-detect for every provider in the registry (parametrized — guards against
  typos in env var lists)
- Explicit `provider=` bypass of auto-detect
- Error cases: unknown provider, explicit-but-empty, auto-detect-with-no-env
- All 26 tests pass locally in 0.08s

## Back-compat guarantees

| Scenario | PR 2 behavior | This PR behavior |
|---|---|---|
| `create_executor(hermes_api_key="x")` | Nous Portal | Nous Portal (unchanged) |
| `HERMES_API_KEY=x` env, auto-detect | Nous Portal | Nous Portal (unchanged) |
| `OPENROUTER_API_KEY=x` env, auto-detect | OpenRouter | OpenRouter (unchanged) |
| Both env + explicit hermes_api_key param | Nous Portal (param wins) | Nous Portal (param wins, unchanged) |

Nothing existing can break. New callers gain access to 13 more providers.

## What's NOT in this PR (Phase 2)

- **Native Anthropic Messages API path** — better tool calling, vision, extended
  thinking. Requires pulling in `anthropic` SDK. ~50 LOC.
- **Native Gemini generateContent path** — for vision + google tools. Requires
  `google-genai` SDK. ~50 LOC.
- **Streaming support across all providers** — current executor is non-streaming
  (single chat.completions.create call). Streaming works with openai.AsyncOpenAI
  but hasn't been wired to the A2A event queue path. ~30 LOC.
- **Per-provider model overrides in config.yaml** — Phase 1 uses the registry's
  default_model. Phase 2 adds a `hermes: { provider: qwen, model: qwen3-coder-plus }`
  block in the workspace config.
- **`.env.example` updates** — not critical since the registry itself documents
  every env var via the `env_vars` field, but nice-to-have.

## Related
- Queued memory: `project_hermes_multi_provider.md`
- CEO directive 2026-04-15: *"once current works are cleared, I want you to
  focus on supporting hermes agent, right now it doesnt take too much providers"*
- `docs/ecosystem-watch.md` → `### Hermes Agent` — Research Lead's eco-watch
  entry listed "Nous Portal, OpenRouter, GLM, Kimi, MiniMax, OpenAI, …" which
  shaped this registry's initial set

## Test plan
- [x] Unit tests: 26/26 pass locally (pytest)
- [ ] CI will run on the self-hosted macOS arm64 runner
- [ ] Smoke test in a real workspace: set QWEN_API_KEY and verify Technical
      Researcher actually hits Alibaba DashScope successfully
- [ ] Integration test per provider with real API keys (gated on env, skip
      when not set — Phase 2 CI addition)
2026-04-15 11:14:35 -07:00
..
__init__.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
conftest.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_a2a_cli.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_a2a_client.py fix(security): complete Phase 30.6 auth headers in a2a_client get_peers and discover_peer 2026-04-14 13:23:44 +00:00
test_a2a_executor.py fix(a2a): cancel() event, stateTransitionHistory capability, wire push store (#173 #174 #175) 2026-04-15 17:58:10 +00:00
test_a2a_mcp_server.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_a2a_tools_impl.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_a2a_tools_module.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_adapters.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_agent_base_urls.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_agent.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_approval.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_audit.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_awareness_client_full.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_claude_sdk_executor.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_cli_executor.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_common_setup.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_compliance.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_config.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_consolidation.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_coordinator_parent.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_coordinator_routing.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_delegation.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_events.py fix(security): Cycle 5 — auth middleware, injection hardening, skill sandbox 2026-04-14 04:44:42 +00:00
test_executor_helpers.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_first_party_plugins.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_governance.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_heartbeat.py fix(security): Cycle 5 — auth middleware, injection hardening, skill sandbox 2026-04-14 04:44:42 +00:00
test_hermes_adapter.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_hermes_providers.py feat(hermes): Phase 1 — multi-provider registry (15 providers, back-compat preserved) 2026-04-15 11:14:35 -07:00
test_hermes_smoke.py feat: implement Hermes adapter create_executor() with OpenRouter fallback 2026-04-13 16:47:29 -07:00
test_hitl.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_main_initial_prompt.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_mcp_memory.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_medo.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_memory.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_molecule_ai_status.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_namespaces.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_openclaw_adapter.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_platform_auth.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_plugins_builtins_drift.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_plugins_builtins.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_plugins_registry.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_plugins.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_preflight.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_prompt.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_qianfan_provider.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_routing_policy.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_sandbox.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_security_scan.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_shared_runtime.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_skills_loader.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_skills_watcher.py fix(security): H1 — replace MD5 with SHA-256 in config/skill watchers 2026-04-14 07:52:07 +00:00
test_telemetry.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_temporal_workflow.py initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
test_watcher.py fix(gate-3): update watcher test to expect SHA-256 hash 2026-04-14 01:21:35 -07:00