getShadowOption converted the shadow blur from px to pt but left the offset
in px. pptxgenjs expects both in points (ratioPx2Pt = 96/72 × viewportSize/960),
so shadows exported ~33% too far from their element at the default viewport
while the blur radius was correct. Divide the offset by ratioPx2Pt like blur.
Closes#678
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>
parse.js used `textContainerNames.includes[arr[level].name]`, which reads a
property of the includes function (always undefined) instead of calling it,
so the "trailing text node" branch never ran and trailing text inside a
MathML text container (mtext/mi/mn/mo/ms) was dropped from the OMML. Line 48
of the same file already uses the correct `includes(...)` form.
dist/ is gitignored and rebuilt by postinstall, so the runtime bundle picks
up the fix on install.
Closes#680
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>
Promote the Action contract (Action union + variants, ActionType, the action-category lists, PercentageGeometry) into @openmaic/dsl/src/action.ts, zero-runtime-dep. Widget interaction actions graduate into the contract; Scene<TAction> defaults to the standard Action union; lib/types/action.ts becomes a re-export shim. Part A of #787 (Phase 2 under #720).
Interactive-webpage scenes (SceneType 'interactive') emit four widget_*
action types — widget_highlight, widget_setState, widget_annotation,
widget_reveal — each typically followed by a speech action. These execute
correctly on stage during playback but were dropped from the Lecture Notes
timeline due to two compounding gaps:
1. chat-area.tsx built lectureNotes with an allowlist that only admitted
speech/spotlight/laser/play_video/discussion, filtering out all widget_*
types so they never entered the notes data.
2. lecture-notes-view.tsx ACTION_ICON_ONLY had no entries for widget_*, and
unknown types render as null, so even with data they would be invisible.
Add the four widget_* types to the allowlist and extend ACTION_ICON_ONLY with
icon/style entries (Highlighter/SlidersHorizontal/StickyNote/Eye), reusing the
existing inline icon-only badge pattern already used by spotlight/laser.
* feat(agent-edit): multi-session conversation history for the AI editor
The "Edit with AI" panel kept only one thread per stage in localStorage, and
"New conversation" deleted it, so previous conversations were unrecoverable.
Add a per-stage session list backed by IndexedDB (Dexie v12 `agentEditSessions`):
- "New conversation" now archives the current session and starts a fresh one
instead of deleting it; a history popover in the panel header lists past
sessions (auto-titled from the first user message) to switch back to or delete.
- One-time migration of the existing single-thread localStorage entry.
- The active session id is remembered per stage so a refresh restores it,
including a just-cleared empty session (clean slate survives reload).
- saveSession preserves the original createdAt and tombstones deleted ids so an
in-flight save can't resurrect a deleted session; switching stages drops the
previous thread synchronously so it can't leak into the new stage.
- Sessions are pruned to a soft cap per stage and removed when a course is
deleted.
- i18n for all 8 locales; unit tests for title derivation and the store.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(types): drop redundant Window.SpeechRecognition augmentation conflicting with @assistant-ui/core
@assistant-ui/core's speech adapter declares Window.SpeechRecognition and
webkitSpeechRecognition globally as SpeechRecognitionConstructor. Three files
(prompt-input, use-audio-recorder, use-browser-asr) re-declared them as `any`,
which conflicts (TS2717) once that adapter's types are pulled into the program,
and the constructed instance then lacks the event handlers the code sets
(TS2339/2551). Rely on the global declaration and cast the instance to the local
rich shape. Takes `tsc --noEmit` back to zero.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* 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.
Add an append-only 'Add discussion' control + inline editor (topic/prompt/initiating agent) to the script timeline, respecting the action-parser invariant that a discussion is the scene's last action and at most one per scene. Yellow terminal-anchor styling; agent picker (with avatars) sourced from the selected agents the playback engine gates on. Runtime unchanged.
Key-point chips in the pre-generation outline editor used a single-line
`truncate`, so longer points were cut off with an ellipsis and users could
not read the full text while reviewing the outline. Let the text wrap within
the chip's max width and add a native title tooltip as a fallback.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A failed tool card rendered the tool result's full text inline. For
framework schema-validation failures that text is a large blob — the
validation message plus the entire received-arguments JSON, including
the full interactive-page HTML — which floods the Edit-with-AI panel.
Remove the inline failure body. The card is non-expandable by design (a
single status row), so failure surfaces through the amber ✗ status mark
and its hover tooltip; the model also restates the actionable reason in
its own reply. Drops the now-unused `failText` prop from ToolCard and its
wiring at the three call sites, and refreshes the stale "surfaced inline"
doc comments.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(packages): publish the @openmaic/* SDK family to npm (#778)
Prepares the @openmaic/{dsl,renderer,importer} family for its first npm
publish, and moves the SDK packages onto the @openmaic scope.
Why the scope move: the @maic org name is unavailable on npm (an unscoped
`maic` package already holds the name), so @maic/* is not claimable. @openmaic
matches the project name, the scope is free, and the repo already ships an
@openmaic/docs package — so the SDK family now lines up with that convention.
- rename @maic/{dsl,renderer,importer} -> @openmaic/* across packages, the
workspace glob, the package dir, and all import sites; lockfile regenerated
- renderer: add publishConfig (public, registry.npmjs.org) — was missing, so
a scoped publish would default to the wrong registry / restricted access
- importer: add a files allowlist (dist, README, LICENSE) and drop the
fragile .npmignore blacklist that shipped src; add an exports map so ESM
consumers resolve dist/index.js instead of falling back to the .cjs main
- all three: add a prepublishOnly build (+ test/typecheck) guard so a publish
can never ship a stale or empty dist
- add a tag-triggered publish workflow with npm provenance, pinned by name to
the three @openmaic packages so the vendored forks (mathml2omml, pptxgenjs)
are never published
Refs #778, #720 (Phase 1).
* fix(packages): address cross-review on the @openmaic publish prep
Cross-review (Claude /code-review + codex) on this PR surfaced:
- renderer's advertised CJS entry was broken: it keeps @openmaic/dsl external
and imports a runtime enum from it, but dsl is ESM-only (no `require`
condition), so `require('@openmaic/renderer')` would throw
ERR_PACKAGE_PATH_NOT_EXPORTED. Make renderer ESM-only: drop the `.cjs`
rollup output, `main` now points at the ESM build, and the `require`
conditions are removed from `exports`. (importer is unaffected — it bundles
dsl, so its CJS build still works.)
- prepublishOnly re-ran the test suite during `pnpm -r publish`, so a flaky
test after dsl had already published gave a non-atomic partial release.
Reduce prepublishOnly to a build-only guard (never ship stale/empty dist)
and move the real test/typecheck gate into the workflow, before any publish.
- document that an @openmaic/* tag publishes the whole family via `pnpm -r`
(pnpm skips already-published versions); the tag is a release marker, not a
per-package gate.
Verified: dsl + renderer + importer build; renderer emits ESM only (0 .cjs),
all exports entries resolve; `npm pack` ships dist + README + LICENSE with no
src leak; frozen-lockfile passes.
Refs #778.
* style: reflow @openmaic/dsl type imports past print-width after rename
The @maic -> @openmaic rename lengthened two single-line type imports past
prettier's 100-col width; prettier --check flagged them. Pure formatting.
Refs #778.
* docs(importer): mark @openmaic/importer browser-only (cr-loop accepted limitation)
codex cross-review flagged that the published @openmaic/importer throws
`XMLHttpRequest is not a constructor` when loaded in a pure Node process —
its rollup build is browser-targeted (`nodeResolve({browser:true})` + a
browser pdf.js build). The app only consumes it client-side ('use client'),
so this is by design. Document it as an accepted limitation: prominent
browser-only note in the README and a `browser` field in the manifest.
Refs #778.
* fix(agent): mark pi-ai/pi-agent-core server-external to fix#619 e2e
The editor-agent packages `@earendil-works/pi-ai` and `pi-agent-core` lazily
load node builtins via a computed `import(specifier)` (deliberately, to avoid
breaking browser/Vite builds). webpack cannot statically analyze that, so once
these run on the server (the Pro-mode "Edit with AI" path) the bundled form
throws `Cannot find module as expression is too dynamic` as an unhandled
rejection. That broke the #619 interactive-iframe keep-alive e2e: entering Pro
mode no longer settled, so the keep-alive iframe stayed visible
(`interactive-iframe-keepalive-619.spec.ts:189` expected hidden).
Add both packages to `serverExternalPackages` so Next loads them natively and
their dynamic import resolves as a real Node call.
Refs #619, #777.
* test(619): interactive iframe stays visible in edit mode since #777#777 intentionally dropped the `mode !== 'edit'` guard in InteractiveIframeHost
so the interactive iframe stays visible during Pro-mode editing — the editor
agent ("Edit with AI") fixes interactive HTML, so the teacher must see the live
page while editing. The keep-alive e2e was still asserting the old "hidden in
edit mode" behavior (toBeHidden at line 189) and so failed on every run since
#777 landed.
Update Trigger A to the new contract: after the Pro-mode toggle the iframe is
visible and its in-iframe counter state is preserved (the real keep-alive
proof — neither unmounted nor reloaded). Trigger B (scene switch to a slide)
still hides it via ownership release, unchanged.
Refs #619, #777.
* feat(generation): changeOutlineType total constructor for valid type switches
Switching a scene outline's type in the editor only flipped `type` and left
the new type without its required config, so applyOutlineFallbacks silently
downgraded interactive/pbl back to slide. changeOutlineType returns a new
outline that strips foreign per-type config and seeds the target type's
required config from the shared fields, valid by construction.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* i18n(generation): keys for interactive widget kind and PBL project config
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(editor): make outline type changes take effect with config forms
TypePill now builds a valid outline via changeOutlineType (replace, not
partial-merge) so a type switch drops stale config and seeds the new type's
required config — no longer silently downgraded to slide by applyOutlineFallbacks.
Adds InteractiveConfigDisclosure (widget kind + concept) and PblConfigDisclosure
(topic / description / target skills), mirroring QuizConfigDisclosure, so users
can configure interactive and PBL scenes that previously had no input UI.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): move type-specific config under the type pill
The quiz/interactive/PBL config disclosure rendered as a detached chip at the
bottom-left of the card, reading like a stray key point. Pin it to the
bottom-right of the key-points row instead, so it sits directly under the
TypePill it configures (type top-right -> its config bottom-right, same edge),
with key points flowing on the left.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): cascade type config as a connected segment left of the type pill
Replace the standalone config chip with a cascading control in the header: the
type-specific config (quiz count / interactive widget kind / PBL project) renders
as a themed segment joined to the left of the TypePill, the two clipped into one
rounded pill split by a hairline divider. Reads as a single 'config › type'
cascade and groups the config with the selector it refines.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): address cross-review — preserve widget config, drop stale fields
- changeOutlineType: preserve an existing procedural-skill widget config
instead of replacing it with a seeded simulation (codex P2 — task-engine
fields were silently dropped on Interactive re-select).
- InteractiveConfigDisclosure.setWidgetType: reset widgetOutline to the shared
concept only, so switching widget kind drops the previous kind's fields
(claude P2 — language/gameType/etc. leaked across kinds).
- i18n locale-coverage test now also checks ko-KR and pt-BR.
- Drop a redundant WidgetType cast; add tests for procedural-skill preservation
and pbl targetSkills dedupe/cap.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(editor): round 2 cross-review nits — procedural-skill label + skill a11y
- InteractiveConfigDisclosure: when an outline carries a preserved
procedural-skill widget, surface it as the current (selected) kind with its
own label instead of mislabeling it 'Simulation', and make a same-kind
re-select a no-op so its task-engine fields are never silently clobbered.
- PBL target-skill remove button uses a dedicated removeSkill aria-label.
- Add widgetProceduralSkill / removeSkill i18n keys (8 locales) + test coverage.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(generation): make re-selecting the current outline type a no-op
changeOutlineType rebuilt the outline on every type-menu click, so re-selecting
the already-current type dropped fields it doesn't re-seed — legacy
interactiveConfig, or a partial pblConfig whose projectTopic is empty — turning a
harmless click into data loss. Short-circuit same-type selections to return the
outline untouched (codex P2).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* chore(format): prettier --write files left unformatted on main
These 14 agent/edit files (not part of this PR's feature) fail the repo-wide
`prettier . --check` in the required Lint job — they landed on main unformatted,
turning main's CI (and therefore this PR after a branch update) red. Formatting
them here unblocks the required check; pure formatting, no logic changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(lint): suppress intentional set-state-in-effect in reasoning timer
The reasoning timer does a deliberate one-shot setState in its effect to show
the right elapsed value before the first 1s interval tick. main's CI fails the
required Lint job on the new react-hooks/set-state-in-effect rule here; suppress
it with a justification (no behavior change). Unblocks the required check.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Deleting a slide in Pro/Edit mode removed it from `scenes` but left its
entry in the persisted `outlines` plan. On the next classroom mount the
resume-generation pass treats the now-missing `order` as a pending
outline and regenerates the slide, appending it as the last page.
Rather than prune outlines by `order` (which is rebalanced by Pro-mode
insert/duplicate/reorder, so it is not a stable key and would mis-target
or break delete-undo), gate resume on a persisted `generationComplete`
flag:
- The flag is recorded (alongside outlines, in the stageOutlines record)
when generation finishes — both generateRemaining completion paths, the
retry-to-completion path (markGenerationCompleteIfDone), and the
already-materialized-at-mount path — and restored on load. It is written
only after a verified scene flush, so it never outruns the deck's scenes.
- A finished deck is frozen for editing: loadFromStorage no longer derives
pending placeholders from orphaned outlines, the classroom resume effect
skips generateRemaining, media resume is filtered to materialized
outlines, and isCourseComplete honours the flag — so a deleted slide
neither regenerates nor leaves a phantom pending page.
- Decks generated before the flag existed self-heal on load (every outline
has a scene ⇒ inferred complete). deleteScene additionally records
completion when deleting from a deck that is complete right now, so the
"Course complete" end page and resume-suppression survive even when the
flag was never persisted (e.g. edited without a reload).
`outlines` are never pruned, so order-rebalancing and delete-undo are
unaffected. Genuinely interrupted generations (not complete) still resume.
Fixes#768
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(generation): infer concise courseTitle from outlines for readable course names
Generated courses were named after the raw user prompt (truncated to 500 chars
client-side, or 50 chars / first outline title server-side), which is long and
unreadable. The outline-generation step already understands the full course
semantics, so have it emit a concise `courseTitle` alongside `languageDirective`
and `outlines`, and use it as the stage name.
- Prompts (requirements-to-outlines, interactive-outlines): top-level JSON gains
a required `courseTitle` (≤30 chars, in the teaching language, noun phrase).
- Streaming route: extract `courseTitle` head-bound like `languageDirective`,
emit a `courseTitle` SSE event, and include it in the `done` event.
- Non-streaming outline-generator: parse and return optional `courseTitle`
(defensive trim + 120-char cap).
- Naming: stage.name = courseTitle || outlines[0]?.title || requirement fallback
(client preview path backfills stage.name after outlines resolve; server
classroom-generation uses it directly).
- Session: persist `courseTitle` on GenerationSessionState for reload safety.
- Tests: add courseTitle parsing coverage; e2e mock done event carries it.
Fully optional in the pipeline — every consumer falls back to the previous
behavior when the field is absent, so legacy/LLM-skipped cases are unaffected.
* fix(generation): make courseTitle propagation robust across all outline paths
Address review feedback on the courseTitle threading.
Prompts — align every outline-prompt schema statement to the 3-key shape.
The user-prompt "final reminder" / top-level shape blocks for
requirements-to-outlines, interactive-outlines, and task-engine-outlines still
demanded the old two-key {languageDirective, outlines} object; as the last
instruction the model reads, that caused it to omit courseTitle and the stage
name to fall back to the raw requirement. Task Engine prompts now emit
courseTitle as well.
Streaming route — normalize the streamed courseTitle (trim, ignore
whitespace-only, cap length) to match the non-streaming parser, and add a
full-buffer fallback so a title emitted after the outlines array or beyond the
head-scan window is still recovered before the done event.
Client — reset latched languageDirective/title on outline retry so a
succeeding attempt that omits them falls back instead of inheriting a failed
attempt's stale value; also carry courseTitle in the stream-end resolve path
that fires when the stream closes without an explicit done event.
courseTitle remains optional on every consumer path.
---------
Co-authored-by: wyuc <zdq1204@gmail.com>
* 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>
Adds the Qwen3.7 series to the built-in qwen provider, mirroring the
existing Qwen3.6 model-card shape:
- qwen3.7-plus: 1M context, 64K output, vision, tools, toggleable
thinking + budget (default on)
- qwen3.7-max: 1M context, 64K output, text-only, tools, toggleable
thinking + budget (default on)
Both run over the already-configured DashScope OpenAI-compatible
endpoint; no transport changes. Thinking is wired through the existing
qwen request adapter (qwenBudgetEnabled, 0-81920 budget). Output ceiling
and thinking-budget max reuse the Qwen3.6 conventions, since the public
docs don't spell these out per-model.
Closes#752
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch the OpenMAIC root and the in-house @maic/* SDK packages
(@maic/dsl, @maic/importer, @maic/renderer) from AGPL-3.0 to the MIT
License. Updates LICENSE files, package.json license fields, README
badges and license sections (EN/ZH), CONTRIBUTING, and renderer FONTS
note.
Third-party vendored packages are left untouched: packages/mathml2omml
remains LGPL-3.0, packages/pptxgenjs remains MIT.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
On first render animStates was an empty Map, populated only via a
setTimeout(0) effect. Every CodeLineRow therefore mounted with
animState undefined, latched mounted=true from its initial props, and
took the non-animated branch. When the states arrived one tick later,
every already-mounted row fired setTyping(true) in the same tick, so
all lines typed simultaneously - the delayed-mount stagger path was
unreachable on first paint.
Compute the first-render typing states synchronously in the useState
initializer so rows see their animState and typingDelay on the very
first render: line 0 types immediately, each later row stays unmounted
until its cumulative delay. The effect now only handles subsequent
line edits (inserted/replaced), with prevLinesRef seeded to the
initial lines.
Behavior note: previously, toggling animate from false to true marked
every line "inserted" (prevLinesRef started empty); now the ref is
seeded so a toggle does not replay the entrance - arguably the less
surprising behavior.
Fixes#531
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
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(dsl): promote Stage/Scene lesson skeleton into @maic/dsl (#740)
Phase 2 of the @maic SDK consumption epic (#720): move the universal lesson
skeleton into the contract package, with Scene generic so app-side feature
surfaces (Action, widgets, PBL) plug in via type parameters.
DSL (packages/@maic/dsl):
- New src/stage.ts: Stage, SceneType, StageMode, Whiteboard, VideoManifest,
GeneratedAgentConfig, MultiAgentConfig, SlideContent, QuizContent, and a
narrowed SceneContent (SlideContent | QuizContent).
- Scene<TAction = never, TContent extends { type: SceneType } = SlideContent |
QuizContent> — the contract owns only the structure + universal content
kinds; TContent is constrained structurally so an app can pass a wider
content union. Defaults give renderers/importers a feature-free skeleton.
- Pure guards isSlideContent / isQuizContent.
- Registered in index.ts barrel; README roadmap item checked off + 'Stage /
Scene split' section added.
- Added vitest config + test script + stage.test.ts (9 contract tests).
App (lib/types/stage.ts):
- Rewritten as a shim: re-exports the skeleton types from @maic/dsl, keeps
InteractiveContent / PBLContent (app feature surfaces), and aliases Scene =
Scene<Action, AppSceneContent> so all ~55 existing import sites keep their
semantics. The generation re-export block is dropped (verified zero
consumers import those five types via @/lib/types/stage).
Scope B from #740 (lesson container in DSL, features plug in). Decision:
generic Scene<TAction, TContent> over a registry/extension seam — explicit,
isolatedModules-friendly, no declaration-merge pitfalls.
* fix(dsl): address review — guard genericity, standalone tests, type pin
1. isSlideContent / isQuizContent: relax <T extends SceneContent> to
<T extends { type: SceneType }> so the guards accept an app-widened
content union (interactive / pbl) — the generic case Scene<TAction,
TContent> is meant to support. Add a regression test exercising the
widened union.
2. tests: resolve @maic/dsl to ./src/index.ts via resolve.alias in
vitest.config.ts, so 'pnpm --filter @maic/dsl test' is standalone on a
clean checkout (no dist build required). Verified by deleting dist and
re-running.
3. Pin the TAction-defaults-to-never type test to .toEqualTypeOf<never[] |
undefined> instead of the trivially-true .toMatchTypeOf<unknown[] | …>.
* style: prettier-format lib/types/stage.ts (CI prettier --check)
* fix(stage): value-export isSlideContent/isQuizContent from the compat shim
The two discriminant guards are runtime functions but were sitting inside the
shim's `export type { … }` block, which erases them: `import { isSlideContent }
from '@/lib/types/stage'` would resolve to `undefined` at runtime and TS-error
'cannot be used as a value'. No call sites import the guards through the shim
today (latent), but the shim's job is back-compat re-export, so move them to a
plain `export { … }`.
---------
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
* test(orchestration): add answer-content eval for agent first-reply answering
The existing director question-answering eval only checks that the director
ROUTES to the teacher; it never generates the dispatched agent's reply, so it
cannot catch the case where routing is correct but the agent's first sentence
drifts (greets / opens a lecture / pivots) and only a later turn answers.
This adds an answer-content eval that runs the real agent-generate inputs
(buildStructuredPrompt + convertMessagesToOpenAI), parses the structured output
with the app's runtime parser, and uses an LLM judge for two signals:
leads_with_answer (first sentence addresses the literal ask) and
answered_anywhere (addressed at all). Their gap quantifies "drift-then-answer".
A/B mirrors the answering-runner rule-13 strip: baseline removes the
"Answering the User's Question" section from agent-system, with_rule is as-shipped.
Scenarios are synthetic/anonymized (opening-lecture override, ignored
format/capability/navigation request, ignored correction, frustration re-ask,
adjacent pivot, vague-clarify) plus clean controls; no real user data.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(orchestration): give answer-content scenarios live-shaped classroom context
The minimal store state (empty scenes, null stage, no profile) made the
assembled agent prompt far thinner than the live agent-generate path and
suppressed the slide-narration "lecture reflex" that drives opener drift.
Each scenario now carries a topical slide scene (title + body + latex elements
with ids), a stage (name/description/languageDirective), and a student profile,
so buildStructuredPrompt emits a "# Current State", "# Student Profile" and
"# Language" of the same shape and bulk as production. The runner reads this
context from the scenario instead of a hardcoded empty state.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(agent): respond to the user's turn before continuing the lecture
Generalize the agent-system "Answering the User's Question" section into
"Responding to the User's Turn": the user's latest message always takes priority
over continuing the planned lecture. Beyond factual questions it now explicitly
covers the interaction requests agents were ignoring — navigation/pacing
("skip to next page"), format/language ("explain in Chinese"), capability
requests it cannot fulfill ("make a video" -> say so + offer an alternative),
corrections, frustration re-asks, and vague asks (ask one clarifying question).
Strengthen the answer-content eval that measures this:
- the navigation case now uses a 3-slide deck so "skip to next page" is well-posed;
runner supports multi-scene state and strips the renamed section for the A/B;
- judge is fairer to legitimate behavior: explaining primarily in the requested
language while keeping technical terms standard counts; a verbal transition to
the next slide counts as honoring navigation (no page-turn action exists).
Result (gemini-3-flash-preview, n=10): mean leads-with-answer rises from 42%
(section stripped) to 93% (as-shipped); all 12 scenarios pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(agent): don't over-respond to bare acknowledgements; guard empty eval set
Code-review follow-ups on the "Responding to the User's Turn" change:
- Prompt: the absolute "every user message needs a direct response / treat
continuing the lecture as a failure" wording had no carve-out for bare
acknowledgements ("ok" / "嗯" / "good" / "thanks"), risking the agent halting
the lesson to manufacture a reply, and conflicted with agent-initiated
discussions where no user turn exists. Add a bare-acknowledgement carve-out,
allow a brief "好的"/"Sure" before the answer, and scope the override to actual
requests (and to "if there is a user turn to respond to").
- Eval: answer-content-runner exited 0 with a PASS verdict and NaN% aggregates
when the scenario set was empty (e.g. an EVAL_SCENARIO typo). Guard it: error
and exit 1 when no scenario matches.
Re-run unchanged otherwise (gemini-3-flash-preview, n=10): mean leads-with-answer
42% (stripped) -> 94% (as-shipped), 11/12 scenarios pass; the chem opener is
variance-prone around the 70% bar and not over-tuned.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(eval): cr-loop cleanups on answer-content-runner
- ScenarioAgentSpec extends the shared ScenarioAgent (./types) instead of
re-declaring id/name/role/priority.
- Drop the dead expectedPreFix plumbing from ScenarioResult (it was copied in
but never read; it stays as an informational annotation in the scenarios).
- extractTexts: replace the hand-rolled JSON fallback with the app's
finalizeParser, which recovers plain-prose / unclosed-array output the same
way the runtime does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: tighten acknowledgement carve-out; don't surface action-JSON as text (cr round 2)
Round-2 review follow-ups.
Prompt: the bare-acknowledgement carve-out was too loose — it could swallow
ack+request hybrids ("嗯,那为什么X?") as acks (re-introducing drift), double-listed
"好的" as both an allowed lead-in and a no-response ack, and listed pacing words
("继续"/"go on") that collide with the navigation bullet. Restrict it to a
STANDALONE acknowledgement with nothing else attached; route an embedded
question/request to that request; route pacing words to the navigation bullet.
Eval: extractTexts gated finalizeParser recovery on !state.jsonStarted, so an
actions-only / unclosed array yields "no text" (the judge's intended empty case)
instead of finalizeParser's raw-buffer fallback surfacing action JSON as fake speech.
Re-run (gemini-3-flash-preview, n=5): no regression — 11/12 pass, meta-requests
100/100/80/100; the chem opener remains variance-prone around the 70% bar.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix: address review — honest slide-nav, strict judge booleans, errors fail (cr)
Review follow-ups from @cosarah:
- Navigation (P2): agents have no slide-navigation action, so "do it" + a verbal
transition let "skip to next page" pass the eval while the UI stayed on the
same slide. Reframe prompt, judge, and scenario so a correct reply ACKNOWLEDGES
the request and is HONEST that it cannot change the slide itself (continue
verbally / tell the user how to navigate); pretending it flipped the slide no
longer counts.
- Judge booleans (P2): answer-content-judge coerced fields with Boolean(...), so a
string "false" became true. Parse strictly (real bool or "true"/"false");
malformed output is flagged as an error.
- Error accounting (P3): aggregate excluded errored samples from the denominator,
letting a scenario pass on one good sample. Errors now count as failures
(denominator = all requested samples).
Re-run (gemini-3-flash-preview, n=10): navigation 0% -> 100% under the honest
framing; aggregate leads-with-answer ~93%, no regression. Opener scenarios
(math/chem) remain variance-prone near the 70% bar.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(eval): judge first-sentence lead; use canonical teacher actions (cr round 2)
Second review round from @cosarah:
- leads_with_answer was judged against texts[0] (the whole first JSON text
block), so "Today we'll discuss parabolas. The formula is x=-b/(2a)." counted
as leading even though the first sentence drifted. Now extract the first ~2
sentences as the "opening" and have the judge make the call: a brief
acknowledgement of the user before the answer counts as leading, but a greeting
/ self-intro / topic preamble before the answer does not. (Two sentences +
semantic judge handles "Sorry, let me clarify. m is inertial mass." vs
"Welcome! …" without a brittle keyword list.)
- The runner hardcoded TEACHER_ACTIONS, omitting canonical teacher actions
(play_video, wb_draw_chart). Use getActionsForRole('teacher') so the available-
actions section matches production.
Re-run (gemini-3-flash-preview agent, n=10): 11/12 pass, aggregate leads ~90%.
The chem opener now correctly fails (~10%): its "Welcome! Today we…" persona
greets first, so at sentence granularity it is genuine first-sentence drift
(answered-anywhere ~90%) — exactly what the stricter lead measurement should
catch.
Note: the judge model is deepseek-v4-pro in this run because the anthropic
gateway is currently returning Bad Request in our environment; the eval is
judge-model-agnostic via EVAL_JUDGE_MODEL.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(eval): judge the opening across all text blocks, not just texts[0] (cr round 3)
Review follow-up from @cosarah: leadFromTexts only looked inside the first
text block, so a valid multi-block reply like
[{"type":"text","content":"Sure."},{"type":"text","content":"The derivative is 2x."}]
was judged on "Sure." alone and failed leads_with_answer despite following the
allowed acknowledgement-then-answer pattern. Build the opening from the first ~2
speech sentences across ALL ordered text chunks.
Re-run (gemini-3-flash-preview, n=10, deepseek judge): 11/12 pass, aggregate
leads ~93%. The chem opener stays sub-threshold (~50%) — its "Welcome! Today
we…" persona greets before answering about half the time, a genuine
first-sentence drift.
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>
Combining allow-scripts with allow-same-origin on a srcDoc iframe negates the sandbox; since the embedded HTML can come from LLM output or imported data, the iframe now runs in a null origin. postMessage control (targetOrigin='*') is unaffected. Adds a regression test. Fixes#725.
#707 left lib/types/slides.ts as a thin `export * from '@maic/dsl'` shim so the
~100 existing `@/lib/types/slides` import sites kept working unchanged. Point
them at `@maic/dsl` directly and delete the shim, so the app consumes the
package contract with no indirection and the legacy module path is gone.
Pure module-specifier migration — every symbol imported from
`@/lib/types/slides` was already a re-export of the same `@maic/dsl` symbol, so
behavior is identical. Also redirects the two `lib/types` relative importers
(`./slides`), the e2e fixture's relative import, and the dynamic
`import('../types/slides').Slide` type alias in stage-storage; merges the now
same-module import pair in slide-edit-elements.
Verified: tsc --noEmit clean, eslint clean, vitest 804/804, next build OK,
e2e (Playwright) 19/19.
Part of #720 (Phase 1).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(slide-renderer): remove dead legacy ThumbnailSlide/ThumbnailElement
These were the in-app read-only thumbnail renderers replaced by SlideThumbnail
(→ @maic/renderer) in #707. They have zero importers now — the editor nav rail
renders through SceneThumbnailContent → SlideThumbnail; the only remaining
"ThumbnailSlide" mentions are an unrelated local type alias / util name and
historical doc comments. Delete the dead code (~215 LOC).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(dsl): emit explicit .js extensions so @maic/dsl resolves under Node ESM
The build used `moduleResolution: bundler` + extensionless re-exports, so the
emitted `dist/index.js` did `export * from './slides'` — which fails bare-node
ESM resolution (`ERR_MODULE_NOT_FOUND`), even though Next's bundler tolerated
it. Switch the package tsconfig to `NodeNext` and add `.js` extensions to the
relative specifiers so tsc emits resolvable ESM. `node -e import('@maic/dsl')`
now loads; NodeNext also enforces extensions going forward.
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>
* fix(importer): correct hanging-indent bullet slot rendering
Size the bullet slot to the hanging-indent amount (|indent|) instead of
marL so wide marL paragraphs no longer push body text past the bullet.
Reset text-indent on the inline-block slot to stop symbol bullets from
drifting left onto adjacent shapes, and only pad synthesized-marL symbol
bullets. Add vitest setup and serializer tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
* style(importer): apply prettier formatting to serializer tests
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(importer): wire up package-local vitest config and CI
Add packages/@maic/importer/vitest.config.ts so the package tests in
test/ are discovered (the root config only globs tests/), and add a CI
step that runs them. Align vitest to a single 4.1.8 in the lockfile and
move the tableSerializer setup into beforeAll so parse failures surface
as test failures instead of collection errors.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
* refactor(app): consume @maic/dsl + @maic/renderer for slide types and read-only thumbnails
The app extracted @maic/{dsl,renderer,importer} (#668) but kept rendering its
own duplicated copies. Start dogfooding the packages back into the app:
1. lib/types/slides.ts is now a thin re-export of @maic/dsl. The hand-kept
copy was the seed for @maic/dsl, so consuming the package stops the three
former copies (app / renderer / importer) from drifting again. All
`from '@/lib/types/slides'` import sites keep working unchanged.
(ShapePathFormulasKeys / ElementTypes move from local `const enum` to the
package's regular `enum` — required across a package boundary; runtime
value usage is identical.)
2. Read-only slide thumbnails now render via @maic/renderer's SlideCanvas
through a small SlideThumbnail wrapper, replacing the in-app ThumbnailSlide
element renderers at the three read-only surfaces: playback scene sidebar,
scene thumbnail content (editor rail), and home recent-course cards. The
wrapper preserves the legacy thumbnail video treatment (muted play-badged
<video>, placeholder filtering) via the renderer's renderVideo slot. The
full-size editing canvas is untouched (renderer v1 is read-only).
Verified: tsc --noEmit clean, next build OK, e2e 19/19 green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(thumbnail): resolve gen_* media placeholders so retries reflect in thumbnails
SlideThumbnail rendered slides through @maic/renderer with only a renderVideo
slot, so image (and video) `gen_img_*`/`gen_vid_*` placeholders were painted
as-is. @maic/renderer is a pure package and does not know about this app's
async media-generation store; the store also never mutates the slide's
`element.src` (it keeps the placeholder ref and tracks the generated objectUrl
in a task). Net effect inside a classroom: a thumbnail showed the broken
placeholder on first paint and — the reported bug — did NOT update when a
failed image's retry finally succeeded, because nothing re-resolved the src.
Add `useResolvedSlide`: resolve each placeholder element's `src` to its task
`objectUrl` (video `poster` too) against the media-generation store,
reactively. Unresolved (pending/failed) placeholders are blanked so the
renderer paints nothing instead of a broken-media icon. Off-classroom (no
stage context, e.g. home recent-course cards) renders raw, matching the legacy
thumbnail's behavior. Mirrors the app's existing `useResolvedImageSrc` resolver
that the full-size canvas already uses — restoring the reactive sync the
in-app ThumbnailElement had before the @maic/renderer migration.
The store subscription is a primitive signature of just this slide's
placeholder resolutions (src → done objectUrl), so unrelated task churn —
other slides' media generating or retrying — neither re-renders the thumbnail
nor invalidates the resolved-slide memo.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(thumbnail): key video tasks by mediaRef; use a visible signature delimiter
Review follow-ups (#707):
- Videos' media-generation tasks are keyed by mediaRef (with gen_vid_* src as
the legacy fallback), not by element src — resolve them through
getVideoMediaRefForElement, matching BaseVideoElement's subscription, so a
mediaRef-keyed video thumbnail updates when generation or a retry completes.
A mediaRef-keyed video that already carries a real playable src keeps it
while the task is unresolved; only placeholder srcs are blanked.
- The resolution-signature delimiter was a literal NUL byte, which made git
treat the source file as binary (degrading diffs and review tooling). Use a
visible '|' delimiter instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
Add a full Korean locale (lib/i18n/locales/ko-KR.json, all 1018 keys translated
from en-US.json) and register it in lib/i18n/locales.ts per TRANSLATION_GUIDE.md.
i18next {{interpolation}} preserved; AI provider/model brand names kept per the
existing ja-JP convention.
Signed-off-by: moduvoice <moduvoicr77@gmail.com>
Two streaming generation paths do super-linear work on the model output and can
block the Node event loop (and balloon the heap) on large or pathological
responses:
1. app/api/generate/scene-outlines-stream re-parses the ENTIRE accumulated
buffer on every streamed chunk — extractLanguageDirective (full-buffer regex)
and extractNewOutlines (char-walk from the array start). That is O(n²) over
the stream; a ~300 KB response blocks the event loop for ~20 s.
2. lib/generation/interactive-post-processor convertLatexDelimiters restores
<script> placeholders by rebuilding the whole HTML string once per block —
O(blocks × length). A widget with many <script> tags blocks for tens of
seconds and allocates GBs.
Fixes:
- extractNewOutlines: parse incrementally, resuming from a cursor so the buffer
is scanned once across the stream (O(n)). Behaviour-equivalent — verified
across chunk sizes, markdown fences, flat arrays, prose preambles, and
braces/escapes inside string values.
- extractLanguageDirective: bound the regex to the buffer head (the directive is
the first wrapper key), O(1) per chunk.
- Restore <script> blocks in a single pass with a function replacer ($-safe).
- Stream-loop hardening: honor request abort and propagate the AbortSignal to
the LLM call so upstream generation stops on disconnect; cap the accumulated
buffer; guard controller.close() against double-close.
Standalone repro (copied functions): 300 KB outline stream 20.8 s -> 1.3 s;
45 MB widget HTML >30 s + OOM -> 45 ms.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(audio): let resolveAgentVoice honor per-agent voice overrides
* feat(settings): persist per-agent voice overrides
* fix(agents): persist AgentBar voice picks via settings overrides
* fix(classroom): keep user's agent mode and selection across loads
* fix(agents): only carry user-set agent selection across classrooms
Review follow-ups: stage-derived defaults written by a classroom load were
re-read as a user choice on the next load, so visiting a preset classroom
permanently downgraded auto classrooms to preset agents. Track the origin
with a persisted agentSelectionIsUserSet flag (set by AgentBar interactions,
cleared by fallback writes). Also: voice overrides are now clearable
(undefined deletes), the override type is single-sourced in voice-resolver,
and persist rehydration of the new fields is pinned by tests.
* fix(agents): don't mark stage-derived selections as user choices
Round-2 review: clicking the already-active mode tab no longer flags the
selection as user-set (a visual no-op must not promote stage defaults to a
choice), generation-preview clears the flag when it writes the generated
roster, and tests now pin that setter writes actually reach storage.
* fix(agents): restore generated agent selection when switching back to Auto
Review follow-up (#723): handleModeChange('auto') left the preset ids
selected, so the UI said Auto while discussion playback kept using preset
agents, and the persisted user-set auto pair could never validate on
restore. Switching to Auto now selects the loaded classroom's generated
agents (empty when none are loaded, falling back to stage defaults on the
next classroom load).
* fix(audio): gate SpeechButton on ASR availability
SpeechButton only honored the `disabled` prop and never read ASR state, so
each call site had to wire it and the home page passed nothing — the mic
button stayed clickable even when ASR was turned off.
Add a `useASRAvailable()` hook as the single source of truth (the
`asrEnabled` toggle + whether the selected provider is usable + Web Speech
API support for browser-native) and consume it inside SpeechButton, so every
call site is gated uniformly. The external `disabled` prop still composes on
top, so existing call-site conditions keep working.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(audio): address review — trim API key, require custom-provider models
- Treat whitespace-only API keys as unconfigured: the recorder only sends
keys after trim(), so an untrimmed check enabled the button and then
failed server-side as missing credentials (review P3).
- Custom ASR providers now count as unavailable until at least one model
is configured, mirroring the media-popover rule that hides model-less
custom providers (review P2).
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>
* feat(import): add pptxtojson-pro workspace package and stage-1 PPTX import
Vendor the TypeScript pptxtojson-pro parser as a workspace package, sync its
bundle to public/vendor at install time (avoids Turbopack dynamic require
issues), and wire a home-page import hook that parses files for inspection.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(import): extend pptxtojson-pro with PPTX → Slide[] pipeline
`importPptx` now turns a .pptx file directly into canvas `Slide[]`,
optionally uploading every base64 image and blob-backed media via a
caller-supplied OSS callback before resolving.
- Vendor OpenMAIC slide types and shapes config into `src/openmaic/`
so the bundled dist is self-contained and loadable via `/vendor/`
URL under Turbopack; add stubs for `resolveFont`, `getSvgPathRange`
and `parseVideoCodec` until the real PPTist helpers are ported.
- Move `import-pipeline/` under `src/` and re-export `importPptx`,
`parsedToSlides`, `OssUpload`, `ImportPptxOptions` and `CanvasSlide`
from the package main entry.
- Add `nanoid`, `katex` and `pptxtojson` as runtime deps of the package.
- Update `useImportPptx` to accept `upload` / `onImported` and return
the converted `Slide[]`.
- Document the new API surface, error semantics and Turbopack workaround
in the package README.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(slide-renderer): package skeleton (rollup + tsc + empty index)
Workspace package scaffolding: package.json with peer deps (react/react-dom/motion/tailwindcss),
rollup ESM+CJS config, tsconfig (strict, jsx react-jsx), and empty entrypoints under src/.
Verified: pnpm --filter slide-renderer build produces dist/{index,elements/index,types/index}.{js,cjs,d.ts}
(empty chunks are expected at this stage).
* docs(slide-renderer): DESIGN.md + README.md
* feat(slide-renderer): copy Slide/Element types + add effects types
* feat(slide-renderer): add utils (geometry simplified to elements API, element ranges, cn)
* feat(slide-renderer): shared element hooks (fill/outline/shadow/flip) + ElementOutline
* feat(slide-renderer): BaseTextElement
* feat(slide-renderer): BaseShapeElement + GradientDefs + PatternDefs
* feat(slide-renderer): pure <img> BaseImageElement, decouple OpenMAIC media business
The base component drops:
- useMediaGenerationStore / isMediaPlaceholder (AI media generation polling)
- useSettingsStore (imageGenerationEnabled toggle)
- useMediaStageId / retryMediaTask (classroom-scoped retry orchestration)
- useI18n (placeholder/error/disabled copy)
- skeleton / error / disabled render branches
Retains: clip / filter / outline / shadow / colorMask, output <img src={elementInfo.src}>.
Adds a `renderImage` slot so consumers can re-inject business behavior (placeholders,
retry buttons, custom src resolvers) without modifying the package.
* feat(slide-renderer): Line / Table / Latex / Code base elements
- Line + LinePointMarker: copied with stroke-draw animation intact
- Table + StaticTable + tableUtils: copied with getTableSubThemeColor moved to package utils
- Latex: katex HTML + legacy SVG fallback, no business deps
- Code: shiki-based syntax highlighting (dynamic import); shiki added as optional peer
dependency so consumers without code slides pay zero install cost
* feat(slide-renderer): BaseChartElement + Chart + chartOption (echarts as optional peer)
* feat(slide-renderer): pure <video> BaseVideoElement, decouple OpenMAIC media business
Drops:
- useCanvasStore (playingVideoElementId / pauseVideo)
- useMediaGenerationStore / useMediaStageId / retryMediaTask / getVideoMediaRefForElement
- useSettingsStore (videoGenerationEnabled)
- useI18n, motion/react animate scope
- skeleton / error / disabled / placeholder branches
Retains <video src controls preload=metadata>. Adds a `renderVideo` slot so
consumers can re-inject orchestrator-driven playback or placeholders.
* feat(slide-renderer): canvas hooks (useSlideBackgroundStyle, useViewportSize simplified)
- useSlideBackgroundStyle: copied as-is (no business deps)
- useViewportSize: rewritten to take viewportSize/Ratio/canvasPercentage as args,
drop useCanvasStore, drop editor-only canvasDragged/dragViewport, return fitScale
instead of writing to a store
* feat(slide-renderer): 4 effect overlays (Highlight/Spotlight/Laser/Zoom), props-driven
All overlays now receive element/geometry/options through props instead of reading
useCanvasStore. SpotlightOverlay uses a configurable element-id prefix
(default 'slide-element-') to locate DOM nodes for measurement, matching the
convention SlideElement will set in T14.
HighlightEffectOptions extended with color/opacity/borderWidth/animated to surface
the original visual knobs through the public API.
* feat(slide-renderer): SlideElement dispatcher with renderImage/renderVideo slots
* feat(slide-renderer): SlideCanvas v1 main entry (props-driven, auto-fit viewport)
Mirrors ScreenCanvas structure but reads from props: slide.elements, slide.theme,
props.background ?? slide.background, props.scale ?? autoFit, props.effects.
Auto-fits viewport into container by default via useViewportSize+ResizeObserver;
pass scale=1 to opt out and render at slide-native dimensions.
* feat(slide-renderer): SlideRendererProvider + useSlideContext (props or context)
SlideCanvas now reads from context as a fallback when props are omitted. Allows
the wrap-then-compose pattern from spec §3.2: provider holds shared data,
sibling overlays read via useSlideContext.
* feat(slide-renderer): aggregate public exports
Main entry exposes SlideCanvas, SlideElement, Provider/hooks, effects, hooks,
utils. `slide-renderer/elements` re-exports all 9 Base*Element + shared
ElementOutline/useElementXxx for granular composition. `slide-renderer/types`
already lived in src/types/index.ts.
* docs(slide-renderer): complete README (install / quickstart / API / effects / Tailwind setup)
* feat(demo): /slide-renderer-demo route exercising the workspace package
Hand-written single Slide with shapes + text demonstrates the v1 API end-to-end:
- props-driven SlideCanvas
- auto-fit viewport via parent container
- gradient background, shape outline + text fill
Wires slide-renderer as a workspace dep and registers its dist as a Tailwind
@source so utility classes inside the package get picked up by the host PostCSS
pipeline.
* feat(pptxtojson-pro): align imported Slide JSON with renderer contract
- Drive `viewportWidth` from the deck's actual pixel width (json.size.width
× ratio) instead of the legacy 960 default, so 16:9 widescreen decks no
longer get text element widths clamped to 4:3 dimensions (e.g. titles
truncated to 842px and forced to wrap). Per-slide `viewportSize` now
reports the same value, keeping transform-time and render-time aligned.
- Replace the pass-through font STUB with real resolution: 22-font
self-hosted whitelist + alias map (微软雅黑/等线/宋体/楷体/仿宋/Arial/etc.)
→ 5-category primary font mapping, so unknown PPT fonts fall back to a
rendered open-source equivalent and the pipeline can surface the
replacement via `replacedFonts.fallback`.
- Translate cell `vAlign` from PPT-native (`up`/`mid`/`down`) to CSS-native
(`top`/`middle`/`bottom`) at the importer boundary, so the renderer can
transparently pass it through to `vertical-align` / `justify-content`
without per-component conversion.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(slide-renderer): drop Tailwind defaults, data-drive styles, ship fonts
Three intertwined changes that together make the package self-contained
and align it with the "slide JSON is the single source of visual truth"
contract.
1. Remove Tailwind utility classes from every element renderer.
- Replace `className="absolute ..."` / `className="rounded ..."` etc.
with inline `style={{ position: 'absolute', borderRadius: ... }}`.
- The few rules that can't be expressed inline (descendant selectors,
keyframes, browser-default <p> margin reset) move to a new
`src/styles.ts` injected once by `<SlideCanvas>` via `<style>`.
Named animation classes (`slide-renderer-pulse` / `-ping`) replace
`animate-pulse` / `animate-ping` so consumers don't need Tailwind.
2. Strip renderer-level positive defaults; surface them as data fields.
- `BaseTextElement`: drop hardcoded `overflowWrap: 'break-word'` and
the `paragraphSpace ?? 5` fallback. `--paragraphSpace` is only set
when defined in data; CSS `var()` fallback is 0.
- `StaticTable`: drop hardcoded `padding: '5px'`, `verticalAlign:
'middle'`, `wordBreak: 'break-word'`. Extend `TableCell` with
`padding?: string` and `vAlign?: 'top' | 'middle' | 'bottom'` so
PPT-extracted padding / vertical alignment flow through unchanged.
- `PPTTableElement` gets `rowHeights?: number[]` (per-row min-height;
content can still grow rows).
- Reshape `<td>` to match the classroom Vue layout: outer `<td>` carries
only border + textStyle; inner `slide-renderer-cell-text` <div> is
a flex column with `min-height = rowHeight - 4`, `padding =
cell.padding`, `line-height: 1`, `justify-content` from `cell.vAlign`.
Add `.slide-renderer-cell-text p + p { margin-top: 0.4em }` to give
adjacent paragraphs breathing room without breaking the reset.
3. Self-contained font shipping.
- Move the 22 woff2 files into `packages/slide-renderer/fonts/`.
- Ship a sibling `fonts.css` with @font-face declarations using
relative `./fonts/<name>.woff2` URLs.
- Expose both via `package.json` exports (`./fonts.css`, `./fonts/*`)
and the `files` array.
- Consumer adds one import (`import 'slide-renderer/fonts.css'`); the
bundler resolves the relative URLs against the package and emits
each woff2 as a static asset. Removes the dependency on consumer-
owned `app/globals.css` @font-face blocks and `public/font/` copies.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(demo): wire slide-renderer fonts and swap demo to a table-heavy slide
- Import `slide-renderer/fonts.css` in the root layout so consumer apps
pull the package's self-hosted @font-face declarations and woff2 assets
through Next.js' static-asset pipeline.
- Replace the hardcoded `demoSlides` array (24 mixed-element slides) in
`/slide-renderer-demo` with a single 5×7 table-heavy slide so the demo
exercises the new `TableCell.padding` / `TableCell.vAlign` /
`PPTTableElement.rowHeights` fields and the flex-based cell layout.
Convert the legacy `vAlign: 'up' | 'mid' | 'down'` values to the
CSS-native `'top' | 'middle' | 'bottom'` form the renderer now expects.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(slide-renderer): add slideToPng standalone snapshot util
Exposes a new `slide-renderer/snapshot` sub-export with `slideToPng(slide,
options)`, the foundation for the AI-driven visual diff loop (snapshot
the rendered slide, compare against PowerPoint's own PNG export, decide
whether a discrepancy belongs to the import algorithm or the renderer).
Implementation notes
- Mounts `<SlideCanvas>` into an off-screen container sized exactly to
the slide's native pixels, so `useViewportSize` collapses to a 1:1
render (no scale offset).
- `flushSync` for the initial commit so the snapshot doesn't fire on an
empty container; `requestAnimationFrame` × 2 to let the ResizeObserver
settle; then waits for `document.fonts.ready` and every `<img>` in the
container (with a configurable `timeoutMs`, default 5s).
- Snapshots the SlideCanvas root (`container.firstElementChild`) rather
than the outer wrapper — html2canvas-pro's bounding-box math otherwise
leaves white edges or drops absolutely-positioned children.
- Uses `html2canvas-pro` instead of `html-to-image`: the latter's SVG
`<foreignObject>` path loads embedded woff2 asynchronously, so the
drawImage fires before fonts decode and text re-wraps in the fallback
font. html2canvas-pro walks the DOM and inherits the parent document's
font registry, keeping wrap positions identical to the on-screen render.
- `onclone` hook injects a small CSS reset (`font-kerning: none`,
`font-feature-settings: normal`, `font-variant-east-asian: normal`,
`text-rendering: geometricPrecision`) scoped to the slide tree, to
prevent html2canvas-pro's CJK text measurement from clipping
full-width punctuation (e.g. `(` / `)`) past cell boundaries.
- Default `pixelRatio` follows `window.devicePixelRatio` for retina-sharp
output; consumers can override.
- Optional `debugVisibleMs` briefly shows the off-screen container after
snapshot so callers can compare what was captured vs the live render.
Wiring
- Sub-export added to `package.json` (`./snapshot`) and Rollup `entries`
for tree-shaking — apps that don't use snapshot don't pay the
`html2canvas-pro` bundle cost.
- Demo route adds an "导出 PNG" button that calls `slideToPng` on the
active slide and triggers a browser download.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: build slide-renderer in root postinstall
Without this, fresh installs leave packages/slide-renderer/dist
missing and Next.js fails to resolve the `slide-renderer` import.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(parser+renderer): iteration-0601-002 fidelity fixes
Parser (pptxtojson-pro):
- shapeSerializer: stop painting parent fill on grpFill children; honor
explicit <a:ln><a:noFill/></a:ln> over theme lnRef (master logo dots
were rendering as visible green rings).
- imageSerializer: detect custGeom ellipses and 8-vertex chamfered-rect
photo frames; resolve to 'ellipse'/'octagon' instead of falling back
to 'rect'.
- textSerializer: emit text-shadow from rPr effectLst > outerShdw, and
compensate the half-leading PowerPoint puts above the first line for
unitless lnSpc > 1 (cover-title gap regression).
- border/tableSerializer: pass rgba()/hsla() colors through ensureHex
untouched so '#rgba(...)' never reaches the DOM.
- transformParsedToSlides: drop the 1.1 SAFE_PADDING wrap-fudge and
thread bodyPr@anchor through as vAlign.
- font config: add 思源黑体/思源宋体 + Source Han aliases and a trailing
region/weight suffix stripper so 'SourceHanSerif CN Light' resolves.
Renderer (slide-renderer):
- SlideCanvas: new chrome prop (default true) to opt out of the
preview-only card shadow + rounded corners; snapshot pipeline passes
false so html2canvas output matches PPT edges.
- BaseTextElement: flex-column + justifyContent driven by the new
vAlign field; width/height stay 100% so the box anchors correctly.
- BaseImageElement: maxWidth/maxHeight 'none' to prevent host CSS from
shrinking absolutely-positioned <img>.
- snapshot: render with chrome=false.
Docs: SKILL.md expanded with the iteration workflow + OOXML traps.
* fix(parser+renderer): iteration-0605-001 fidelity fixes
slide-renderer:
- PPTImageElement: add `softEdge` field (feather radius that fades image
alpha to transparent at every edge, per a:softEdge@rad).
- TableCell: add per-side `borders` so cells with partial dividers render
each side independently instead of falling back to the table-level
uniform outline.
- BaseTextElement: hoist `fill`/`opacity` to the outer wrapper so the
background covers the full shape rectangle, matching PowerPoint behavior
for short text inside tall shapes.
- Misc tweaks across image/latex/shape/video base elements, StaticTable
and the standalone snapshot util.
pptxtojson-pro:
- Parser/serializer fidelity improvements for text, math, image, shape
and table (notably ~500 lines in textSerializer and ~127 in
mathSerializer).
- Refinements in GroupNode, MathNode and ShapeNode models; richer Theme,
StyleResolver and RenderContext plumbing.
- Expanded shape presets and customGeometry utilities, plus adapter and
import-pipeline updates to surface the new fields.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: stop tracking local slide-renderer-demo sandbox
`app/slide-renderer-demo/page.tsx` is a personal scratchpad used for
ad-hoc rendering tests; it shouldn't ship with the package. Remove it
from the index (file stays on disk locally) and ignore the directory so
future tweaks don't show up in `git status`.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rename packages pptxtojson-pro→maic-import and slide-renderer→maic-renderer
Align workspace package names with the MAIC product family:
packages/pptxtojson-pro → packages/maic-import
packages/slide-renderer → packages/maic-renderer
Functional references updated end to end:
- Root package.json: workspace deps + postinstall/sync scripts
- next.config.ts: transpilePackages
- app/globals.css: Tailwind `@source` for renderer dist
- app/layout.tsx: `maic-renderer/fonts.css` import
- lib/import/use-import-pptx.ts: imports + runtime URL
(`/vendor/maic-import/index.js`) + script comment
- scripts/sync-maic-import.mjs: renamed and pointed at the new dist
- .gitignore: vendor path and sync-script comment
- Package package.json `name` fields and cross-link in READMEs
Also re-include the gitignored `app/slide-renderer-demo/` in Tailwind's
source detection via an explicit `@source` so its classes (e.g.
`bg-violet-600`) keep getting generated — Tailwind v4 skips gitignored
paths by default, which was making the demo's import button render
white-on-white after the demo was excluded from version control.
CSS class names (`slide-renderer-prose` / `slide-renderer-cell-text` /
`slide-renderer-pulse` / `slide-renderer-ping` / `slide-renderer-code-
cursor-blink`) and internal source comments that still reference the old
package names are intentionally left untouched to keep the rename
diff minimal; they can be updated separately as the codebase evolves.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(dsl): extract @maic/dsl contract package and adopt @maic/* scope
Establish the SDK family's contract keystone and align package naming with
the planned @maic/* scope, per PR #668 review.
1. New @maic/dsl package (packages/maic-dsl)
- Pure, zero-runtime-dependency spec: the canonical slide object model,
pure type-guards, and DSL version/migration scaffolding.
- Seeded from lib/types/slides.ts but reconciled into a *superset* of the
three previously-drifted copies (app / renderer / importer); merged
fields are annotated @since-merge. README documents the divergence and
the acyclic dependency arrows (renderer/importer -> dsl -> nothing).
- Enums are regular (not const) so consumers compiling with
isolatedModules can import them across the package boundary (TS2748).
2. Wire @maic/importer to @maic/dsl
- Import all slide types from @maic/dsl; delete the vendored
openmaic/types/slides.ts copy.
- Eliminate the Slide drift at the root: transformParsedToSlides now fills
viewportSize/viewportRatio/theme at construction and emits a complete
DSL Slide, removing the partial "draft slide" + post-fill step in
parsedToSlides (no DraftSlide type needed).
- Add @maic/dsl to the root postinstall build chain before the importer.
3. Adopt @maic/* scope (agent-noun names)
- maic-import -> @maic/importer
- maic-renderer -> @maic/renderer
- Update all package-name references (deps, app imports, transpilePackages,
fonts.css subpath import, Tailwind @source node_modules path, READMEs).
- Directory names and /vendor paths are intentionally left unchanged.
Note: @maic/renderer still vendors its own slide types; wiring it to
@maic/dsl is the next step.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(renderer): consume slide types from @maic/dsl, drop vendored copy
Wire @maic/renderer to the @maic/dsl contract keystone, completing the
de-duplication of the slide object model across the SDK family.
- Delete packages/maic-renderer/src/types/slides.ts (the vendored copy) and
repoint all ~30 internal imports at @maic/dsl. SlideElement's runtime
`ElementTypes` value import now resolves to the DSL enum.
- Re-export the DSL types from src/types/index.ts so the public
`@maic/renderer/types` entry keeps exporting the full slide contract
(alongside the renderer-only effect types).
- Add @maic/dsl as a regular dependency and mark it external in the rollup
build so consumers share a single copy (enum not inlined); the emitted
.d.ts references @maic/dsl directly.
@maic/dsl is a superset of the renderer's former types, so this is
non-breaking; the renderer additionally gains `script` and the
importer-origin fields it didn't previously declare.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(renderer): serve fonts from OSS, drop the 43.6MB bundled woff2
Move the 22 CJK fonts off the repo and onto object storage to fix the
PR #668 blocking repo-weight concern.
- fonts.css now points every @font-face src at
https://file.maic.chat/fonts/<name>.woff2 instead of bundled local files.
- Extract the CDN origin + font whitelist into fonts.config.mjs (single
source of truth) and generate fonts.css from it via
scripts/generate-fonts-css.mjs. `genfonts` runs first in the build, so the
CSS always reflects the config; changing the domain is now a one-liner.
- Delete packages/maic-renderer/fonts/*.woff2 (22 files, ~43.6MB) and drop
the now-unused "./fonts/*" export and "fonts" files entry from package.json
(fonts.css is kept).
Font names are unchanged, so consumers and the importer font whitelist are
unaffected. Note: this removes the files going forward only; purging them
from git history (LFS / filter-repo) is a separate follow-up.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(home): gate the unwired PPTX import button behind a feature flag
The PPTX import flow is still scaffolding — `useImportPptx` has no
`onImported` consumer, so clicking it only logs the parsed slides. Hide both
PPTX import entry points (and the hidden file input) behind
NEXT_PUBLIC_ENABLE_PPTX_IMPORT (default off) so the UI doesn't expose a
no-op. The classroom import button is unaffected.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(import): harden the runtime URL-loaded PPTX parser
The PPTX parser is loaded at runtime from /vendor/maic-import/index.js — a
gitignored artifact synced into public/vendor during postinstall. If a deploy
skips that step the URL 404s and import() fails with an opaque SyntaxError
(404 HTML parsed as JS). Add guards on both ends plus docs.
- Build-time assertion: scripts/assert-vendor-maic-import.mjs verifies the
bundle exists and is non-empty; wired into `build` so a misconfigured deploy
fails early with an actionable message instead of shipping a broken runtime.
- Runtime guard: use-import-pptx.ts HEAD-probes the URL before import() and,
on a non-ok response, throws a clear error surfaced to the user via the new
import.error.parserUnavailable string (added to all 6 locales).
- Docs: document the postinstall deploy dependency and the pull-without-install
type/runtime drift in @maic/importer's README.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: unify the @maic/* license policy to AGPL-3.0
Pick one license for the SDK family and apply it uniformly, matching the
OpenMAIC root, per PR #668 review.
- @maic/dsl and @maic/importer: relicense MIT -> AGPL-3.0 (package.json +
full AGPL-3.0 LICENSE text).
- @maic/renderer: already AGPL-3.0; add the LICENSE file its package.json
`files` already referenced.
@maic/importer is derived from pptxtojson (MIT); MIT permits relicensing a
derivative under AGPL, and the upstream MIT attribution is retained in the
package README/index.html, so this is compliant.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rename packages/maic-import dir to maic-importer
Align the importer's directory with its @maic/importer package name and the
maic-* sibling dirs (maic-dsl, maic-renderer). Package name is unchanged, so
imports/transpilePackages/node_modules resolution are unaffected.
- git mv packages/maic-import -> packages/maic-importer (history preserved).
- Rename the vendor sync/assert scripts and the runtime vendor path to match:
scripts/{sync,assert-vendor}-maic-importer.mjs, public/vendor/maic-importer,
URL /vendor/maic-importer/index.js.
- Update all path references: root postinstall/build/sync scripts, .gitignore,
use-import-pptx.ts, and doc links in the dsl/renderer/importer READMEs.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: nest the @maic packages under packages/@maic/
Mirror the @maic/* npm scope in the directory layout: move the three family
packages into packages/@maic/{dsl,importer,renderer}. Package names are
unchanged, so imports / transpilePackages / node_modules resolution are
unaffected.
- git mv packages/maic-{dsl,importer,renderer} -> packages/@maic/* (history
preserved).
- pnpm-workspace.yaml: add packages/@maic/* glob.
- Recompute the root postinstall cd chain for the nested layout.
- Update dir-path references: sync script srcDir, .gitignore comment, the dsl
source comment, and the renderer/importer README/SKILL cross-links.
Unchanged: the @maic/* package names, the runtime vendor path
(public/vendor/maic-importer) and its sync/assert scripts.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore(renderer): clear font licenses, drop non-redistributable faces, remove importer font remapping
Address the PR #668 blocking font-license-clearance review.
Font licensing (renderer):
- Reduce the self-hosted whitelist to 6 clearly-redistributable faces:
SourceHanSans/SourceHanSerif/LXGWWenKai/ZhuQueFangSong (SIL OFL 1.1),
ZcoolHappy (ZCOOL free-use), WenDingPLKaiTi = AR PL KaitiM GB (Arphic PL 1999).
- Drop AlibabaPuHuiTi: free to *use* commercially but its license grants no
explicit redistribution/re-host right, unlike OFL — dropped to keep public
CDN serving unambiguous.
- Add FONTS.md (per-face attribution/clearance record, separate from the
package's AGPL LICENSE) and bundle the verbatim license texts under
font-licenses/ (OFL.txt, ZcoolHappy-LICENSE.txt, ARPHIC-PL.txt); ship both via
package.json `files`. Regenerate fonts.css from the trimmed config.
Importer font remapping removed:
- The importer no longer rewrites font-family names (alias -> category ->
primary). It passes each slide's original font-family through unchanged, so
it can never target a face the renderer doesn't ship. Delete configs/font.ts,
the resolveFont/replaceFontFamilyInHtml helpers, and the now-unused
FontReplacementBucket / ImportContext.replacedFonts plumbing.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(renderer): document the CDN font runtime dependency
Add a "Fonts" section to the renderer README per PR #668: the optional
`@maic/renderer/fonts.css` loads woff2 from an external host
(https://file.maic.chat), which must be reachable + CORS-enabled or the
browser silently falls back to system fonts. Note that the import is optional
and that the origin is configurable via fonts.config.mjs + `pnpm run genfonts`.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(renderer): verify WenDingPLKaiTi == AR PL KaitiM GB from the font name table
Record the embedded-name-table evidence (Family/Copyright/Trademark/Designer =
Arphic, nameID 13 = the full Arphic Public License) so the
WenDingPLKaiTi ⇄ AR PL KaitiM GB correspondence is provable, and correct the
copyright year to 1994–1999 to match the font metadata.
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: fix `pnpm check` (prettier) after merging main
main added a `prettier . --check` CI step that flagged 180 files. Resolve it
consistently with the existing convention (vendored/workspace packages are
excluded from root Prettier):
- .prettierignore: exclude `packages/@maic/` (own rollup/tsc/eslint toolchains;
dist is generated, importer/src1 is a vendored oracle), matching how
pptxgenjs / mathml2omml / docs are already handled.
- Format the three root-level files we added/edited that root Prettier does
cover: lib/import/use-import-pptx.ts and the two scripts/*-maic-importer.mjs.
`pnpm check` now passes.
Co-authored-by: Cursor <cursoragent@cursor.com>
* style: align @maic/{dsl,renderer,importer} source to root Prettier
Per review preference, the @maic packages are our own code and should follow
the repo style rather than be ignored wholesale. Narrow .prettierignore to only
the generated build output (packages/@maic/*/dist/) and the vendored legacy
reference (packages/@maic/importer/src1/), then `prettier --write` the package
sources. Formatting-only; all three packages still build.
`pnpm check` passes.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(lint): scope ESLint to @maic source and clear all errors
- eslint.config.mjs: replace blanket packages/** ignore with precise
rules so @maic/{dsl,importer,renderer} source is linted, while skipping
third-party packages, dist output, importer/src1 and public/vendor
(the generated bundle was producing thousands of false errors in CI).
- importer: replace `any` with concrete narrowings/types, fix prefer-const.
- renderer: drop manual useMemo that React Compiler could not preserve.
- remove leftover debug console.log + stale eslint-disable in use-import-pptx.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(i18n): add missing PPTX import keys to pt-BR
pt-BR.json was missing import.{pptx,parsingPptx,pptxSuccess} and
import.error.{invalidPptx,parserUnavailable}, failing the i18n key
alignment check against en-US.json.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* 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>