Skip to content

feat: runtime provider configuration API (BYOK setup) - #12

Open
amos-aios wants to merge 1 commit into
mofa-org:mainfrom
amos-aios:feat/provider-config-api
Open

feat: runtime provider configuration API (BYOK setup)#12
amos-aios wants to merge 1 commit into
mofa-org:mainfrom
amos-aios:feat/provider-config-api

Conversation

@amos-aios

Copy link
Copy Markdown

What

Setup UIs (BYOK key wizards) can now add providers without editing config files or restarting:

  • Engine.add_provider_config — registers a provider at runtime (RwLock-guarded list next to the startup registrations); find_provider / routing_providers / discover_all consult both, so a runtime provider is routable and discoverable immediately. Engine.build_provider is extracted from startup assembly and shared.
  • SDK endpoints:
    • POST /v1/config/providers — validates (kind resolvable, name non-empty, api_key present for openai_compatible), appends a [[providers]] TOML entry to the resolved config file (restart survival), registers + refreshes capabilities
    • GET /v1/config/providers — masked listing derived from live capability cards; keys never leave the engine
  • EngineConfig::resolved_pathMOFA_ENGINE_CONFIG env > ./config.toml > ~/.config/mofa-engine/config.toml

Testing

runtime_provider_registration_serves_requests — registers an OpenAI-compatible provider against a live mock endpoint at runtime, asserts capabilities pick it up and invoke routes to it. Full suite 102 green.

Stacked on #11; will rebase on landing.

🤖 Generated with Claude Code

amos-aios added a commit to aios-pub/mofa-studio that referenced this pull request Aug 25, 2026
…RD-02)

On top of the engine's runtime provider-config API (upstream PR
mofa-org/mofa-engine#12):

- gateway: GET/POST /v1/config/providers proxied to the engine; the key
  crosses the gateway once and persists engine-side (config.toml) — the
  frontend never stores it
- engineConfig service: vendor→engine registration mapping, 国内可达优先
  vendor ordering, curated default model names (deepseek/qwen/glm/kimi…),
  paste-time key validation (prefix/whitespace/length with specific
  reasons); 10 unit tests
- KeyWizard (/onboarding/key, linked from the welcome flow's 开始配置 CTA):
  vendor picker with apply-page deep link, masked key input with inline
  validation feedback, editable default model, register + connectivity
  test (engine model list must expose the vendor), success screen; the
  onboarded flag flips on completion
- 98 frontend tests green

Co-Authored-By: Claude <noreply@anthropic.com>
@amos-aios
amos-aios force-pushed the feat/provider-config-api branch from 44ad8f3 to 1d28d6b Compare August 25, 2026 17:18
Rebased onto upstream main (post cloud-video-gen merge) as a single clean
commit; adapts to the new provider-kind matrix (LiterLLM, LocalAsr,
LocalImageGen, LocalVideoGen, CloudVideoGen dialect) and the
associated-function server style.

- Engine::build_provider extracted from startup assembly; shared with
  Engine::add_provider_config, which registers a provider at runtime behind
  an RwLock (replacing same-name entries); find_provider, routing_providers,
  and discover_all all consult the runtime list, so a registered provider
  is routable and discoverable immediately
- SDK: GET/POST /v1/config/providers with masked listing derived from live
  capability cards; add validates (name/kind/api_key), appends a
  [[providers]] entry to the resolved config file for restart survival,
  then registers + refreshes. ProviderConfig::provider_kind made pub so
  external API layers can validate before calling into the engine.
- EngineConfig::resolved_path: MOFA_ENGINE_CONFIG env > ./config.toml >
  ~/.config/mofa-engine/config.toml.
- Tests: factory smoke over the full kind matrix + full runtime registration
  (discoverability, invoke routing, disabled rejection) against a live mock
  endpoint.

Co-Authored-By: Claude <noreply@anthropic.com>
@amos-aios
amos-aios force-pushed the feat/provider-config-api branch from 1d28d6b to d853ddb Compare August 25, 2026 17:21
@amos-aios

Copy link
Copy Markdown
Author

Rebased onto current main as a single clean commit (d853ddb): the runtime provider-config API now covers the full provider-kind matrix merged from the engine branch (LiterLLM, LocalAsr, LocalImageGen, LocalVideoGen, CloudVideoGen) and follows the associated-function server style. Tests: full workspace suite green (11 test binaries), including a live-mock runtime registration round trip (discoverability + invoke routing + disabled rejection). Note: the sibling PRs (#9/#10/#11/#13) were closed as their capabilities landed on main separately; this PR's runtime config API remains novel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant