* refactor: align widget actions with scene pipeline
* feat(edit): migrate legacy teacherActions off interactive content on load
The widget-actions pipeline no longer persists a teacherActions authoring
layer; playback reads only scene.actions. Add migrateInteractiveContent to
strip the dead field from existing documents as they load through migrateScene
(wired into all store/classroom load paths). Satisfies the #794 forward-migration
acceptance item.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(generation): default widget_setState.state to {} when the LLM omits it
The removed TeacherAction->Action converter always defaulted state to {}.
Restore that guard in the structured-output parser so an action missing
state can't forward state: undefined into the widget iframe, where
SET_WIDGET_STATE handlers dereference it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(edit): also strip nested widgetConfig.teacherActions in migration
Legacy WidgetConfig variants each declared their own teacherActions, so existing
documents can carry the dead field nested inside content.widgetConfig as well as
at the top level. Extend migrateInteractiveContent to drop both, preserving all
other widgetConfig fields.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(prompts): document stable widget-action selectors for diagram/game/viz3d
The interactive-actions prompt documented stable target selectors only for
procedural-skill and simulation widgets. Add the canonical selectors the
diagram / game / visualization3d content prompts actually emit (node IDs via
revealOrder; #zoom-in-btn / #canvas-container / #speed-slider / ...; #start-btn),
plus a rule to use widget_setState or a speech-only beat instead of guessing a
target when no stable selector is known (e.g. free-form code widgets). Hardens
against widget actions silently no-oping on non-existent selectors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
Adds automatic retry with exponential backoff for scene generation (content/actions/TTS): shared withGenerationRetry helper at the fetch boundary, smart error classification (retries 429/5xx/timeouts/network, fails fast on 401/403/404), AI SDK RetryError unwrapping, abort-aware backoff, per-route thinking config preserved, and upstream HTTP status surfaced for client retry classification. Fixes#755.
Promote the editor-agent line to main: read-then-act editor agent (read_scene_content, regenerate_scene, regenerate_scene_actions, edit_interactive_html), a routable maic-agent model stage, the agent sidebar UI, interactive-scene runtime-error capture, and the timeline/script editor. Cross-reviewed and smoke-verified; see #777.
* feat(model): optional per-stage LLM model routing (#745)
Add a config-only stage -> model map consulted during model resolution,
falling back to DEFAULT_MODEL when unset (zero behavior change unless opted in).
- lib/server/model-routes.ts: parse/validate/cache MODEL_ROUTES env JSON;
LLM_STAGES registry of routable stages; getStageModel(stage).
- resolveModel: resolution order x-model > stage route > DEFAULT_MODEL > builtin;
thread optional `stage` through resolveModelFromHeaders/FromRequest.
- Wire each route's resolveModel call site to its stage; classroom-generation
resolves generate-classroom and web-search-query-rewrite independently.
- .env.example: document MODEL_ROUTES; unit tests for both modules.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): address cross-review findings for per-stage routing (#745)
- classroom-generation: resolve the web-search-query-rewrite model lazily,
only when explicitly routed and inside the web-search branch, with try/catch
fallback to the classroom model. Fixes a regression where a misconfigured
optional route (keyless/invalid provider) threw and aborted ALL classroom
generation even with web search disabled; also avoids wasted resolution on the
common no-search path and preserves classroom-model inheritance when unrouted.
- resolve-model: type the stage param as LlmStage across resolveModel/
resolveModelFromHeaders/resolveModelFromRequest so a mistyped stage literal is
a compile error instead of silently falling through to DEFAULT_MODEL.
- model-routes: simplify the cache to a process singleton (matching
provider-config), dropping the raw-string-keyed cache and redundant STAGE_SET.
- .env.example: clarify x-model precedence and that a route to an unconfigured
provider fails at request time (no startup validation), like a bad DEFAULT_MODEL.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): stage route takes precedence over client x-model (#745)
Cross-review (codex P2 + Claude tracer) found that the browser UI always sends
its saved model as x-model, so the previous x-model > stage order made
MODEL_ROUTES inert for normal UI traffic on exactly the heavy stages the RFC
targets (scene-content, quiz, pbl-chat, chat). Flip resolution to
stage route > x-model > DEFAULT_MODEL: a configured route is the operator's
deliberate per-stage choice and wins, while unrouted stages still honor the
client's x-model. Update docs and tests accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* style(model): prettier-format changed files for #745 CI
Run the repo formatter (pnpm check / prettier) on the changed routes, the new
model-routes module, and the new tests so `prettier . --check` (CI) passes;
also correct a stale precedence comment in the resolve-model test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): isolate routed model from client connection params (#745)
When a stage route overrides the client's x-model and points at a different
provider, the client-sent apiKey/baseUrl/providerType (for the client's model)
must not bleed onto the routed provider — otherwise a routed Anthropic model
would be constructed with the client's OpenAI providerType/key and fail. A
routed model now resolves its connection params purely from server config, as
if no x-model was sent. Unrouted stages still honor the client params. Adds
tests covering both the drop (routed) and keep (unrouted) cases.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(model): correct graceful-degradation comment in classroom (#745)
resolveModel does not throw on a missing key; clarify that a keyless route
surfaces later in callLLM (degraded by the outer try/catch), while only a
resolution-time failure is caught at the rewrite re-resolve. Comment-only.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(model): route scene-content per scene type (#745)
Extend MODEL_ROUTES with composite keys scene-content:<type> for the four core
scene types (slide/quiz/interactive/pbl). getStageModel now resolves composite
`a:b` stages most-specific-first, trimming `:` segments, so scene-content:<type>
falls back to the base scene-content route, then x-model, then DEFAULT_MODEL.
The scene-content route derives its stage from outline.type. Backward
compatible: with no composite key configured, behavior is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(model): per-stage thinking effort + drop hardcoded gpt fallback (#745)
MODEL_ROUTES values may now be {model, effort} (not just a model string) to pin
the thinking effort per stage. Arbitration mirrors model routing: a routed stage
with effort set wins over the client's thinking (effort "none" disables); routed
with no effort uses the model's default and drops client thinking; unrouted
stages keep the client thinking. resolveModel is the single arbiter — body
thinking is threaded in via resolveModelFromRequest. classroom-generation passes
the resolved thinking into its callLLM calls so generate-classroom and
web-search-query-rewrite honor route effort too.
Also: removed the hardcoded `|| 'gpt-5.4-mini'` fallback in resolveModel — if no
model resolves (no route / x-model / DEFAULT_MODEL) it now throws instead of
silently picking a vendor default.
model-routes: getStageRoute returns {model, effort?}; getStageModel delegates to
it. Docs + tests updated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(model): route value carries full ThinkingConfig (#745)
Per-stage routing accepts the full unified ThinkingConfig in the route value
({model, thinking:{mode,effort,level,enabled,budgetTokens,excludeReasoningOutput}})
instead of just an effort string. The route's thinking is passed through
resolveModel and normalized per the model's capability by callLLM, so
budgetTokens (qwen), level (Gemini), enabled/mode, etc. all work.
(qwen3.7-plus/max thinking capability now comes from upstream #753, so this no
longer registers them.)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(model): honor routed thinking for chat-adapter; doc fixes (#745)
Cross-review (codex P2 + Claude) found chat-adapter was the only routable stage
that ignored the route's thinking: it took the routed model but built its own
thinkingConfig from the request body, so operator-pinned thinking never applied
and client thinking still leaked onto a routed model. Now pass the client
thinking into resolveModel and use the resolved thinkingConfig (route-pinned for
a routed stage, client otherwise; defaults to disabled for low-latency chat).
Also: clarify DEFAULT_MODEL is now required for server-side stages (the
hardcoded gpt-5.4-mini fallback was removed → resolveModel throws if nothing
resolves), and fix a stale {model,effort}→{model,thinking} doc comment.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
proxyFetch routed every request through the configured HTTP(S) proxy,
including loopback targets. A deployment with HTTP_PROXY set would send
a http://localhost:8888 SearXNG (or any self-hosted service) request to
the external proxy, where localhost resolves to the proxy machine and
the request fails.
- Always bypass loopback hosts (localhost, *.localhost, 127.0.0.0/8, ::1).
- Honor the standard no_proxy / NO_PROXY env var: comma-separated hosts,
`*` wildcard, optional `:port` (with protocol-default ports), and
curl-style domain-suffix matching (`example.com` matches
`api.example.com`; a leading dot is equivalent).
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* feat(generation): opt-in parallel scene-content generation
Scene generation was strictly serial — content -> actions -> TTS, one
outline at a time — so an N-scene classroom paid N x (content + actions
+ TTS) of wall-clock latency, which dominates the post-outline wait.
Add an opt-in hybrid two-phase path (#572):
- Phase 1 fetches scene *content* concurrently (bounded). Content is the
only per-scene step independent of cross-scene state, so it is safe to
parallelise; a content failure marks just that outline and does not
pause the batch.
- Phase 2 keeps the existing in-order actions + TTS loop, so
previousSpeeches threading, ordered addScene, the abort/epoch guards,
and the pause-on-failure UX are all unchanged.
Gated by a server-side PARALLEL_SCENE_CONCURRENCY (default 0 = off,
clamped to 10), surfaced to the client through the existing
/api/server-providers response. With it unset the content map is null
and the loop is byte-for-byte the original serial path, so out-of-box
behaviour is unchanged.
The bounded worker pool is extracted to lib/utils/concurrency.ts
(mapWithConcurrency, with an early-stop hook for abort/epoch) and
unit-tested; getParallelSceneConcurrency env parsing/clamping is tested
too.
Closes#572
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(generation): pipeline content fetches instead of a barrier
Address @wyuc's review on #660. The previous version awaited the whole
bounded content pool before Phase 2, so for N > C scenes the user saw the
first scene, then a stall on a single page for the entire content phase,
then a burst — perceived as worse than serial despite the wall-clock win
(the gap scales with ceil((N-1)/C)).
Pipeline instead: lazyBoundedMap starts the content fetches (<= C in
flight) and returns one promise per outline immediately; the serial loop
awaits them in order, so each resolves as soon as its own content is ready
(usually already done, hidden behind the previous scene's actions/TTS). The
first scene now paints after content(1)+actions(1)+TTS(1) — same as serial
— with the full concurrency benefit and no stall.
Also from the review:
- a content fetch can no longer take its siblings down: an unexpected throw
is caught and returned as a failure result, routed through the same
mark-failed path as the serial loop (symmetric);
- drop the cosmetic Phase-1 setCurrentGeneratingOrder — the loop already
sets it per outline;
- note the intentional belt-and-suspenders clamp;
- concurrency.test.ts asserts <= limit (not == limit), and gains
lazyBoundedMap tests including the no-barrier property.
mapWithConcurrency is kept as a thin await-all wrapper over lazyBoundedMap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* feat(tts): voxcpm voice-design types + deterministic voice id helpers (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): emit + persist per-agent voiceDesign descriptor (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): voxcpm voice registration backend client (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): voxcpm-voice ensure/register endpoint (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): client auto-voice registration + reference-clip cache (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): reference registered voice id in vLLM-Omni speech (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): thread voiceDesign + backend through tts call sites (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): match vLLM-Omni voice registration contract (#670)
Live e2e against the real backend revealed the assumed multipart contract was
wrong: POST /v1/audio/voices needs name + consent + audio_sample (not
voice_id/file), and there is no per-name GET (405) — existence must list
/v1/audio/voices and check membership.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(tts): make auto-voice register-once pattern provider-neutral (#670)
The descriptor + register-once/reference-by-id pattern is not VoxCPM-specific.
De-couple it into a provider-neutral seam so other registration-capable
providers (ElevenLabs/MiniMax/Doubao voice cloning, …) can plug in:
- lib/audio/voice-design.ts: VoiceDesign + buildVoiceDesignPrompt /
normalizeVoiceDesign / getDeterministicVoiceId (neutral 'auto-<hash>' id,
namespaced by providerId).
- lib/audio/voice-registration.ts: VoiceRegistrationAdapter interface +
providerId->adapter registry + supportsVoiceRegistration.
- lib/audio/voice-registration-client.ts: neutral ensureRegisteredVoice() +
IndexedDB clip cache.
- app/api/generate/voice (replaces .../voxcpm-voice): dispatches by providerId.
- voxcpm-registration.ts becomes the VoxCPM adapter (sole registered provider).
- AgentConfig.voiceDesign + DB cache table renamed neutral.
Behavior-preserving; VoxCPM-specific bits (inline (prompt)text, backend kinds,
capability gate) stay in the voxcpm modules. Full suite green (674).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): build the voice clip Blob from an inline Uint8Array (#670)
A factored-out helper returning Uint8Array widened to Uint8Array<ArrayBufferLike>,
which next build (stricter than bare tsc) rejects as a BlobPart. Inline the
buffer like the rest of the repo does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): managed TTS providers resolve model server-side (#670)
A server-managed TTS provider's model was still client-driven, but the
managed-provider settings UI hides the model field — so a backend whose model
id isn't the client default (e.g. VoxCPM/vLLM-Omni serving the full model path)
always 500'd. resolveTTSModel() makes the model authoritative from server
config (${PREFIX}_MODELS, first entry) for managed providers, like key/baseUrl;
unmanaged/unconfigured providers keep the client model unchanged. Used by the
tts and voice routes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): single agent-voice resolver + stable teacher narration voice (#670)
Route all TTS voice resolution (narration, discussion, preview) through one
resolveAgentVoiceOptions(agent, ...) that reads the agent profile and registers
+ references the voice by id. Eagerly warm up generated agents' voices on save.
Critically fixes the teacher narration drifting (male/female jumps): the registry
is always seeded with DEFAULT_AGENTS, so the old narration lookup
find(role==='teacher') returned the default teacher (no voiceDesign) instead of
the generated one — so narration never registered a voice and fell back to the
inline prompt. pickNarratorAgent() now prefers the teacher carrying a voiceDesign.
Also: drop language from the deterministic voice id (descriptor already encodes
it) so narration (directive) and discussion (locale) resolve the same id; log
the effective registeredVoiceId. Regression tests for pickNarratorAgent.
Verified e2e: agent-profiles -> 1 voice registration -> 16 narration TTS all
referencing the same registeredVoiceId; voice present on the backend.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(tts): fall back to persona as the voice seed for agents without a voiceDesign (#670)
Preset/default agents carry no LLM voiceDesign. Rather than add a static field,
derive the bootstrap descriptor from the agent's persona when voiceDesign is
absent, so they still register one stable reference voice (stable-but-generic;
persona is not a vocal spec). Generated agents keep their LLM voiceDesign.
Also hardens replay: stage snapshots drop voiceDesign but keep persona.
Unit-tested: resolveAgentVoiceOptions uses real voiceDesign when present, persona
otherwise.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): match Auto Voice by its localized label in the agent voice picker (#670)
The picker filtered on voice.name ('Auto Voice'), but Auto Voice is shown via
its localized label (自动音色). Searching '自动' returned '没有匹配音色'. Match
the localized label for the Auto Voice option so it's findable in any language.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): address code-review round 1 (#670)
- strip parentheses in the voice-design prompt so a paren in the descriptor/
persona can't corrupt the (prompt)text bootstrap delimiter
- gate POST /api/generate/voice on isServerTTSProviderDisabled (#665): a
force-disabled provider was off for the tts route but not this sibling
- check voiceExists before re-registering a client-cached clip, so a cached
voice that's still live isn't needlessly re-uploaded every session
- dedup concurrent ensureRegisteredVoice calls via an in-flight promise map
(eager warm-up + first utterance no longer double bootstrap/register)
- warm up only the narrator (teacher), not every generated agent, to avoid
synthesizing voices at save time for agents that may never speak
- collapse the duplicated vLLM-Omni speech payload into one object
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(tts): prettier formatting (#670)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): key auto-voice memo by (voiceId, backend) so a base-URL change re-registers (#670)
Addresses review (cosarah): registeredThisSession/inFlight were keyed by voiceId
alone, so switching the VoxCPM base URL mid-session made ensureRegisteredVoice
short-circuit and return an id registered only on the old backend — TTS then sent
that stale registeredVoiceId and skipped the inline fallback, failing with
voice-not-found on the new backend. Memo key now includes the base URL; the
IndexedDB clip cache stays keyed by voiceId (the reference clip is
backend-independent and reused to re-register elsewhere). Regression test added.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(tts): include API key in the auto-voice memo key (#670)
Addresses review (cosarah, round 2): memoKeyFor was keyed by (voiceId, baseUrl)
but not the API key. Registration/existence checks and speech calls are
auth-scoped, so switching account/key on the same base URL could reuse a
registeredVoiceId from the old credentials and skip re-validation. Memo key now
includes the API key (in-memory only, never persisted/logged). Regression test
covers the key-switch case.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
A single TTS provider-enablement model honored everywhere (picker,
auto-assignment, fallback, lecture/playback, server).
Model
- lib/audio/provider-enablement.ts: isTTSProviderConfigured /
isTTSProviderEnabled / listEnabledTTSProviderIds. Availability drops the
registry defaultBaseUrl fallback (fixes Lemonade's always-shown voices),
honors the per-provider `enabled` flag, server-disable overrides (server
precedence).
- voice-resolver: getEnabledProvidersWithVoices (enabled server/custom
providers) and getSelectableProvidersWithVoices (the ONE client source of
truth = enabled providers + opt-in browser-native when the browser exposes
voices). resolveAgentVoice picks deterministically among the given providers,
honors a voiceConfig only while its provider is present.
- Picker + discussion build their list from getSelectableProvidersWithVoices, so
the AgentBar and the live discussion agree on selectable voices (fixes
student agents going silent in auto mode). Students resolve via
resolveAgentVoice; the teacher uses the global lecture voice verbatim (same
voice the pre-generated lecture sends), so lecture and discussion never
diverge.
- Voice assignment vs fallback: an agent's voice is bound at generation (the
agent-profile LLM picks from availableVoices; preset uses the user's pick).
The fallback for a missing/invalid/unavailable voice is applied only at the
live TTS calls, not baked into the saved agent — so it reflects current
provider availability.
Defaults / opt-in
- Browser-native: first-class, default OFF, opt-in. Built-in providers default
enabled:true (only surface once configured).
- TTS master toggle defaults OFF; first server-sync auto-enables it when a
provider is configured (mirrors image/video).
- Persist v3->v4 migration normalizes the never-user-editable flags.
Server/admin disable (server precedence): server-providers.yml `enabled:false`
and env `TTS_<P>_ENABLED=false` (incl. browser-native). Surfaced as a per-provider
`disabled` flag on /api/server-providers; merged as serverDisabled; enforced at
the /api/generate/tts trust boundary, classroom media generation, and /api/health.
UI
- Settings TTS panel: per-provider enable toggle, disabled (with a hint) when the
provider is unavailable, locked off (with a note) when server-disabled.
- AgentBar voice pills render disabled with a "No voice" placeholder when no
provider is enabled. The toolbar media-popover TTS tab keeps its existing
on/off toggle (no picker/CTA).
Tests: predicates, resolver determinism + unified selectable list, server
force-disable, store merge + migration + TTS auto-enable, i18n parity. Verified
in a real browser (Playwright): settings toggle states + a full Gemini classroom
generation whose TTS requests used the picked voice.
Found on main @ 2586cb5.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* refactor(providers): make server-configured providers admin-managed, not client-overridable
A server-configured provider is now authoritative: the operator owns its API
key and base URL, and the client cannot override either. This collapses the
tri-state (server key / client base URL / client key) that was the root of a
recurring "missing API key" bug class — when the settings UI echoed a base URL
with an empty key, routes that treated "any base URL ⇒ fully client-configured"
dropped the server key. #533 patched that per-route via canUseServerApiKeyForBaseUrl;
this removes the guard entirely by fixing the design.
Server:
- resolve*ApiKey/BaseUrl ignore client values when the provider is server-
configured; add isServerConfiguredProvider(section, id); drop
canUseServerApiKeyForBaseUrl + normalizeProviderBaseUrl.
- getServer*Providers() no longer return base URLs — only allowed models
(LLM/image) and the managed flag (presence) — so an internal gateway/proxy
endpoint is never exposed to the client.
- routes (chat/image/video/tts/asr/pdf + verify-*) resolve managed providers
purely server-side; SSRF validation now applies only to unmanaged (client)
base URLs.
Client:
- drop serverBaseUrl from ProviderSettings, the settings store, request-building
(TTS base URL no longer echoes the server URL) and voice resolution.
- settings UI renders managed providers read-only: the key/base-URL override
inputs and region toggles are hidden, leaving the "managed by server" notice.
Tradeoff: overriding a server provider's key with your own for the same provider
is removed; add a separate custom provider instead. Closes#620.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore(providers): refresh managed-provider copy, drop dead audio-settings, add #620 e2e
- serverConfiguredNotice now says the provider is managed and not editable here,
pointing users to add a separate provider for their own credentials (7 locales).
- delete components/settings/audio-settings.tsx — unreferenced dead code.
- add e2e/tests/managed-provider-620.spec.ts: managed provider hides the
key/base-URL inputs; unmanaged provider keeps them.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* feat(providers): lock the model catalog for managed providers with a pinned list
When the operator pins an allowed model list (MODELS env/yaml ⇒ serverModels),
the model catalog is admin-managed too: the LLM provider panel shows the pinned
models read-only with a "Server" badge and no add / reset / edit / delete
affordances. Without a pinned list the server manages only credentials and the
user keeps curating models.
This removes the prior inconsistency where the settings panel let you add models
to a pinned managed provider that the generation toolbar then filtered out.
e2e: the managed-openai case now also asserts the catalog is locked.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(providers): ignore (not reject) client overrides for managed web-search; clear legacy serverBaseUrl
Addresses review feedback on #624:
1. Managed web-search providers now ignore a client-sent key/baseUrl instead of
validating and rejecting it. A server-configured provider is admin-owned, so
the server config is authoritative and a stale client base URL is dropped
rather than 400-ing the request. The allowlist validation still runs for
unmanaged providers, where the client base URL is actually used.
2. Drop the removed `serverBaseUrl` field from persisted localStorage on
rehydrate (settings version 2 -> 3, stripped in both migrate and merge), so
old clients don't keep a stale server URL in client state.
Tests: web-search route test split into unmanaged-rejects-allowlist and
managed-ignores-client-baseUrl; settings rehydrate test asserts a legacy
serverBaseUrl is stripped. Full suite 381 pass; e2e 2 pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
Summary:
- Enable the OpenAI image provider from standard OpenAI server env vars when image-specific env vars are absent.
- Add provider-config coverage for resolving the fallback API key and base URL.
Rationale:
- Allows gpt-image-2 image generation to work with common OpenAI proxy configuration.
Tests:
- pnpm vitest run tests/media/openai-image-adapter.test.ts tests/server/provider-config.test.ts
- pnpm prettier lib/server/provider-config.ts tests/server/provider-config.test.ts --check
- pnpm lint -- lib/server/provider-config.ts tests/server/provider-config.test.ts
Co-authored-by: Codex <codex@openai.com>
* fix(#353,#354): conditionally set generatedAgentConfigs based on agentMode
#353: Only embed generatedAgentConfigs in the Stage when agentMode is
'generate'. For default mode, set agentIds instead. This prevents
default agents from being incorrectly marked as isGenerated on the
client-side registry.
Also reset agentMode to 'default' in the catch block when LLM agent
generation fails and falls back to defaults.
#354: Remove redundant setSelectedAgentIds call from Path 1 (server
hydration). Path 2 handles agent restoration uniformly for both
IndexedDB and server-loaded classrooms.
Includes unit tests covering all three scenarios (default, generate,
and LLM fallback).
* fix: replace `as any` with typed interfaces to satisfy eslint no-explicit-any
---------
- Make validateUrlForSSRF async; resolve hostnames via dns.promises.lookup
with { all: true, verbatim: true } and reject if any address is private
- Add isPrivateIP helper covering IPv4 private ranges, IPv6 loopback/ULA/
link-local, IPv4-mapped IPv6, deprecated fec0::/10 site-local, 6to4
tunnel (2002::/16), and Teredo tunnel (2001:0000::/32)
- Detect IP literals via net.isIP() and validate directly without DNS
- Fail closed on DNS resolution errors
- Propagate async to resolveModel, resolveModelFromHeaders, and all 20+
route-level callers; preserve existing production-only gating
- Add 14 unit tests covering public pass-through, private literals, DNS
rebinding, mixed DNS answers, tunnel addresses, and DNS failure
Closes#378
* test: add failing unit tests for isProviderUsable, validateProvider, validateModel
* test: add failing integration tests for all provider stale selection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: implement isProviderUsable, validateProvider, validateModel
* feat: validate all provider selections after server sync (#263)
Replace inline LLM-only validation from PR #232 with unified validation
for all provider types (LLM, TTS, ASR, PDF, Image, Video).
- Extract isProviderUsable, validateProvider, validateModel into
lib/store/settings-validation.ts
- Usability checks server config and client API key, not requiresApiKey
- Auto-select fallback to usable providers instead of clearing to empty
- TTS/ASR/PDF fall back to local defaults (browser-native, unpdf)
- Image/Video clear to empty when no server provider available
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: remove setup-needed prompt from header
Server-configured providers auto-select on first load, making the
manual configuration prompt unnecessary.
* fix: disable image/video generation when no provider is usable
Auto-close imageGenerationEnabled/videoGenerationEnabled when server
removes all providers. Prevent re-enabling until a provider becomes
available.
* fix: auto-recover image/video provider and enable on server restore
When server adds image/video providers after empty state, auto-select
the first available provider+model and enable generation. When server
removes all providers, disable generation and prevent re-enabling.
* fix: auto-enable image/video and select model when server has provider
Fix cases where provider matches default but generation stays disabled,
and where model is empty after provider recovery. Split provider and
model spreads so model updates independently of provider changes.
* fix: allow baseUrl-only server config for PDF providers (e.g. mineru)
loadEnvSection now accepts allowBaseUrlOnly option. PDF providers like
mineru that only need a baseUrl (no API key) are now correctly included
in the server provider response.
* fix: remove auto-enable logic, clean up dead CSS
Only auto-disable image/video generation when no provider is usable.
Never auto-enable — user controls when to turn it on. First-run
auto-enable via autoConfigApplied guard is preserved.
Also remove dead setup-needed CSS animations from globals.css.
* style: fix prettier formatting
* fix: unify fallback strategy to include client-key providers for all types
All provider types now fall back to client-key-only providers (not just
server-configured ones), matching the LLM fallback strategy. Extracted
buildFallback helper to reduce duplication. Added spread precedence
comment per review feedback.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: set up Vitest testing infrastructure
- Add vitest as devDependency
- Create vitest.config.ts with @/ path alias and tests/ directory
- Add "test" script to package.json
- Add Unit Tests step to CI pipeline
Ref: #79
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add action-parser tests covering parsing, fault tolerance, and post-processing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: fix describe block names and add nanoid ID assertion
- Rename misleading "all layers/strategies fail" to "edge cases"
- Add assertion for generated action ID from nanoid mock
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add provider config and model string parsing tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: replace low-value tests with server-sync store tests
Remove parse-model-string, action-parser, and json-repair tests.
Add settings-server-sync tests verifying fetchServerProviders()
correctly updates provider availability and model filtering.
Include 3 it.fails() cases documenting stale selection bug:
when server removes a model/provider, the store's modelId/providerId
should be cleared but currently persists as a stale value.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add ASR_PROVIDERS to audio constants mock
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: format settings-server-sync test with Prettier
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address PR #144 review feedback
- Remove unrelated `release` script from package.json
- Narrow `vi.mock('fs')` to only intercept server-providers.yml reads
- Add positive test for `resolveProxy` with YAML config
- Add error-path tests for `fetchServerProviders()` (HTTP error, network error)
- Track stale-selection bugs as GitHub issue #226
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>