@@ -89,7 +89,8 @@ import {
8989 workspacePlanBackingPath ,
9090 workspacePlansBackingFolderPath ,
9191} from '@/lib/copilot/vfs/workflow-aliases'
92- import { isE2BDocEnabled , isMothershipBetaFeaturesEnabled } from '@/lib/core/config/env-flags'
92+ import { isE2BDocEnabled } from '@/lib/core/config/env-flags'
93+ import { isFeatureEnabled } from '@/lib/core/config/feature-flags'
9394import {
9495 getAccessibleEnvCredentials ,
9596 getAccessibleOAuthCredentials ,
@@ -379,6 +380,7 @@ function getStaticComponentFiles(): Map<string, string> {
379380export class WorkspaceVFS {
380381 private files : Map < string , string > = new Map ( )
381382 private _workspaceId = ''
383+ private _betaEnabled = false
382384
383385 get workspaceId ( ) : string {
384386 return this . _workspaceId
@@ -393,6 +395,7 @@ export class WorkspaceVFS {
393395 const start = Date . now ( )
394396 this . files = new Map ( )
395397 this . _workspaceId = workspaceId
398+ this . _betaEnabled = await isFeatureEnabled ( 'mothership-beta' , { userId } )
396399
397400 // Per-phase wall-clock, stamped on the span so a slow materialize in a
398401 // trace names its bottleneck instead of showing up as unattributed dead
@@ -591,7 +594,7 @@ export class WorkspaceVFS {
591594 path : string ,
592595 suffix : 'style' | 'compiled-check' | 'compiled' | 'render' | 'extract'
593596 ) : Promise < WorkspaceFileRecord | null > {
594- if ( ! isMothershipBetaFeaturesEnabled && isWorkflowAliasBackingPath ( path ) ) {
597+ if ( ! this . _betaEnabled && isWorkflowAliasBackingPath ( path ) ) {
595598 return null
596599 }
597600 const canonicalMatch = path . match ( new RegExp ( `^files/(.+)/${ suffix } $` ) )
@@ -642,7 +645,7 @@ export class WorkspaceVFS {
642645 totalLines : 1 ,
643646 }
644647 }
645- if ( isE2BDocEnabled && getE2BDocFormat ( record . name ) ) {
648+ if ( isE2BDocEnabled && ( await getE2BDocFormat ( record . name ) ) ) {
646649 bin = (
647650 await compileDoc ( { source : code , fileName : record . name , workspaceId : this . _workspaceId } )
648651 ) . buffer
@@ -695,7 +698,7 @@ export class WorkspaceVFS {
695698 record = await this . resolveWorkspaceFileForDynamicRead ( path , 'compiled' )
696699 if ( ! record ) return null
697700 const ext = record . name . split ( '.' ) . pop ( ) ?. toLowerCase ( ) ?? ''
698- const e2bFmt = isE2BDocEnabled ? getE2BDocFormat ( record . name ) : null
701+ const e2bFmt = isE2BDocEnabled ? await getE2BDocFormat ( record . name ) : null
699702 const taskId = BINARY_DOC_TASKS [ ext ]
700703 if ( ! e2bFmt && ! taskId ) return null
701704
@@ -890,7 +893,7 @@ export class WorkspaceVFS {
890893 record = await this . resolveWorkspaceFileForDynamicRead ( path , 'compiled-check' )
891894 if ( ! record ) return null
892895 const ext = record . name . split ( '.' ) . pop ( ) ?. toLowerCase ( ) ?? ''
893- const e2bFmt = isE2BDocEnabled ? getE2BDocFormat ( record . name ) : null
896+ const e2bFmt = isE2BDocEnabled ? await getE2BDocFormat ( record . name ) : null
894897 const taskId = BINARY_DOC_TASKS [ ext ]
895898 const isMermaidFile = ext === 'mmd' || ext === 'mermaid'
896899 if ( ! e2bFmt && ! taskId && ! isMermaidFile ) return null
@@ -978,7 +981,7 @@ export class WorkspaceVFS {
978981 . replace ( / \/ c o n t e n t $ / , '' )
979982 . replace ( / ^ \/ + / , '' )
980983
981- if ( ! isMothershipBetaFeaturesEnabled && isWorkflowAliasBackingPath ( fileReference ) ) {
984+ if ( ! this . _betaEnabled && isWorkflowAliasBackingPath ( fileReference ) ) {
982985 return null
983986 }
984987 if ( fileReference . endsWith ( '/meta.json' ) || path . endsWith ( '/meta.json' ) ) return null
@@ -988,7 +991,7 @@ export class WorkspaceVFS {
988991 try {
989992 const files = await listWorkspaceFiles ( this . _workspaceId , {
990993 scope,
991- includeReservedSystemFiles : isMothershipBetaFeaturesEnabled ,
994+ includeReservedSystemFiles : this . _betaEnabled ,
992995 } )
993996 const record = findWorkspaceFileRecord ( files , fileReference )
994997 if ( ! record ) return null
@@ -1021,7 +1024,7 @@ export class WorkspaceVFS {
10211024 * Returns a summary for WORKSPACE.md generation.
10221025 */
10231026 private async materializeWorkflows ( workspaceId : string ) : Promise < WorkspaceMdData [ 'workflows' ] > {
1024- const workflowArtifactsEnabled = isMothershipBetaFeaturesEnabled
1027+ const workflowArtifactsEnabled = this . _betaEnabled
10251028 const [ workflowRows , folderRows ] = await Promise . all ( [
10261029 listWorkflows ( workspaceId ) ,
10271030 listFolders ( workspaceId ) ,
@@ -1404,7 +1407,7 @@ export class WorkspaceVFS {
14041407 */
14051408 private async materializeFiles ( workspaceId : string ) : Promise < WorkspaceMdData [ 'files' ] > {
14061409 try {
1407- const workflowArtifactsEnabled = isMothershipBetaFeaturesEnabled
1410+ const workflowArtifactsEnabled = this . _betaEnabled
14081411 const folders = await listWorkspaceFileFolders ( workspaceId , {
14091412 includeReservedSystemFolders : true ,
14101413 } )
0 commit comments