101 lines
3.5 KiB
TypeScript
101 lines
3.5 KiB
TypeScript
import { isOpsWorkbenchEnabled } from '@/lib/config/deployment-role';
|
|
|
|
/**
|
|
* Feature flags. Public flags come from `NEXT_PUBLIC_*` env vars, which
|
|
* Next.js inlines at build time so they are safe to read from client
|
|
* components. Server-only flags must not use the `NEXT_PUBLIC_` prefix.
|
|
*
|
|
* Truthy values: `'true'` or `'1'`. Anything else (including unset) is
|
|
* treated as disabled.
|
|
*/
|
|
|
|
function readBoolean(envValue: string | undefined): boolean {
|
|
return envValue === 'true' || envValue === '1';
|
|
}
|
|
|
|
/**
|
|
* MAIC Editor (Pro mode) gate. Default OFF — gates only the Pro toggle
|
|
* affordance in `Header`. The `StageMode` type union is unaffected so
|
|
* existing code paths typecheck identically with the flag in either
|
|
* state.
|
|
*/
|
|
export function isMaicEditorEnabled(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_MAIC_EDITOR_ENABLED);
|
|
}
|
|
|
|
/**
|
|
* Experimental playback canvas renderer. Default OFF so classroom playback uses
|
|
* the legacy in-app renderer unless explicitly enabled in `.env.local`.
|
|
*/
|
|
export function isPlaybackRendererEnabled(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_MAIC_PLAYBACK_RENDERER_ENABLED);
|
|
}
|
|
|
|
/**
|
|
* Experimental Pro-mode slide editor renderer. Default OFF so professional
|
|
* editing keeps using the legacy in-app editor canvas unless explicitly enabled
|
|
* in `.env.local`.
|
|
*/
|
|
export function isEditorRendererEnabled(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_MAIC_EDITOR_RENDERER_ENABLED);
|
|
}
|
|
|
|
/**
|
|
* Experimental Pi-based classroom chat runtime. Default OFF. The same public
|
|
* flag selects the client runtime and gates the corresponding server route.
|
|
*/
|
|
export function isPiChatEnabled(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_PI_CHAT_ENABLED);
|
|
}
|
|
|
|
/**
|
|
* Server-only gate for the Pi Director web-search tool. Default OFF. Enabling
|
|
* Pi chat alone must not implicitly grant the Director external network access.
|
|
*/
|
|
export function isPiWebSearchEnabled(): boolean {
|
|
return readBoolean(process.env.OPENMAIC_ENABLE_PI_WEB_SEARCH);
|
|
}
|
|
|
|
/**
|
|
* Server-authoritative gate for the vocational task-engine generation path.
|
|
* Default OFF. When disabled, requests that include taskEngineMode must
|
|
* silently fall back to the ordinary standard / interactive generation paths.
|
|
*/
|
|
export function isVocationalTaskEngineEnabled(): boolean {
|
|
return readBoolean(process.env.OPENMAIC_ENABLE_VOCATIONAL);
|
|
}
|
|
|
|
export function resolveVocationalActive(
|
|
requirements?: { taskEngineMode?: boolean } | null,
|
|
): boolean {
|
|
return Boolean(requirements?.taskEngineMode) && isVocationalTaskEngineEnabled();
|
|
}
|
|
|
|
/**
|
|
* Optional client-only affordance for exposing the experimental vocational
|
|
* test toggle. This is not a security or routing gate.
|
|
*/
|
|
export function shouldShowVocationalTestUi(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_SHOW_VOCATIONAL_TEST_UI);
|
|
}
|
|
|
|
/**
|
|
* Experimental classroom video export (Hyperframes composition ZIP, #865).
|
|
* Default OFF — gates only the "Export Video" affordance in the export menu.
|
|
* The emitter/compiler code paths are unaffected; this hides the UI entry
|
|
* point until the render pipeline (#866) lands.
|
|
*/
|
|
export function isVideoExportEnabled(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_ENABLE_VIDEO_EXPORT);
|
|
}
|
|
|
|
/** Experimental PPTX import entry point. Default OFF. */
|
|
export function isPptxImportEnabled(): boolean {
|
|
return readBoolean(process.env.NEXT_PUBLIC_ENABLE_PPTX_IMPORT);
|
|
}
|
|
|
|
/** Courseware publishing is an ops affordance; server routes enforce it again. */
|
|
export function isCoursewarePublishEnabled(): boolean {
|
|
return isOpsWorkbenchEnabled();
|
|
}
|