@@ -13,33 +13,28 @@ export type ReplayScriptSourceRequest = {
1313 env ?: Readonly < Record < string , string > > ;
1414} ;
1515
16- export async function loadReplayScriptSourceBundle (
16+ export function loadReplayScriptSourceBundle (
1717 params : ReplayScriptSourceRequest ,
18- ) : Promise < ReplayScriptSourceBundle > {
19- const entry = resolveUserPath ( params . inputPath , { cwd : params . cwd } ) ;
20- const entrySource = readReplayEntryScript ( entry , params . inputPath ) ;
21- if ( resolveReplayFormat ( entry , params . replayBackend ) !== 'maestro' ) {
22- return finishBundle ( entry , { [ entry ] : entrySource } , params . inputPath ) ;
18+ ) : ReplayScriptSourceBundle | Promise < ReplayScriptSourceBundle > {
19+ try {
20+ const entry = resolveUserPath ( params . inputPath , { cwd : params . cwd } ) ;
21+ const entrySource = readReplayEntryScript ( entry , params . inputPath ) ;
22+ if ( resolveReplayFormat ( entry , params . replayBackend ) !== 'maestro' ) {
23+ return finishBundle ( entry , { [ entry ] : entrySource } , params . inputPath ) ;
24+ }
25+ return ( async ( ) => {
26+ const { collectMaestroFlowSources } = await import ( '@agent-device/maestro' ) ;
27+ const files = collectMaestroFlowSources ( {
28+ entryPath : entry ,
29+ entrySource,
30+ env : params . env ,
31+ readSource : tryReadScriptFile ,
32+ } ) ;
33+ return finishBundle ( entry , files , params . inputPath ) ;
34+ } ) ( ) ;
35+ } catch ( error ) {
36+ return Promise . reject ( error ) ;
2337 }
24- const { collectMaestroFlowSources } = await import ( '@agent-device/maestro' ) ;
25- const files = collectMaestroFlowSources ( {
26- entryPath : entry ,
27- entrySource,
28- env : params . env ,
29- readSource : tryReadScriptFile ,
30- } ) ;
31- return finishBundle ( entry , files , params . inputPath ) ;
32- }
33-
34- export function readAdScriptSourceBundle (
35- params : Pick < ReplayScriptSourceRequest , 'inputPath' | 'cwd' > ,
36- ) : ReplayScriptSourceBundle {
37- const entry = resolveUserPath ( params . inputPath , { cwd : params . cwd } ) ;
38- return finishBundle (
39- entry ,
40- { [ entry ] : readReplayEntryScript ( entry , params . inputPath ) } ,
41- params . inputPath ,
42- ) ;
4338}
4439
4540function finishBundle (
0 commit comments