@@ -35,6 +35,7 @@ const TTY_ENV: &str = "AGENTOS_EXEC_TTY";
3535const TTY_COLS_ENV : & str = "AGENTOS_EXEC_TTY_COLS" ;
3636const TTY_ROWS_ENV : & str = "AGENTOS_EXEC_TTY_ROWS" ;
3737const RETAIN_LANGUAGE_CONTEXT_ENV : & str = "AGENTOS_RETAIN_LANGUAGE_CONTEXT" ;
38+ const GUEST_ENTRYPOINT_MODULE_MODE_ENV : & str = "AGENTOS_GUEST_ENTRYPOINT_MODULE_MODE" ;
3839const INLINE_FILE_PATH_ENV : & str = "AGENTOS_INLINE_FILE_PATH" ;
3940const USE_BUNDLED_TYPESCRIPT_ENV : & str = "AGENTOS_USE_BUNDLED_TYPESCRIPT" ;
4041const SEMANTIC_RESULT_PATH_PREFIX : & str = "/tmp/.agentos-semantic-result-" ;
@@ -336,14 +337,6 @@ fn transpile_typescript(
336337 transform_source ( source, file_path, true , common_js)
337338}
338339
339- fn transform_retained_javascript_module (
340- source : & str ,
341- file_path : & str ,
342- ) -> Result < String , SidecarError > {
343- let source = rewrite_static_imports ( source, file_path, false ) ?;
344- transform_source ( & source, file_path, false , true )
345- }
346-
347340fn transform_retained_typescript_module (
348341 source : & str ,
349342 file_path : & str ,
@@ -528,16 +521,19 @@ fn lower_operation(payload: RequestPayload) -> Result<LoweredOperation, SidecarE
528521 let module = payload. format == Some ( JavaScriptModuleFormat :: Module ) ;
529522 let mut source = inline_inputs_prefix ( payload. inputs , false ) ;
530523 source. push_str ( & payload. source ) ;
531- if module {
532- source = transform_retained_javascript_module ( & source, & file_path) ?;
533- }
534524 let retained_source = source. clone ( ) ;
535525 let mut operation =
536526 lowered_process ( payload. process , "node" , vec ! [ String :: from( "-e" ) , source] ) ;
537527 operation. retained_language = Some ( RetainedExecutionLanguage :: JavaScript ) ;
538528 operation. retained_source = Some ( retained_source) ;
539529 operation. retained_file_path = Some ( file_path. clone ( ) ) ;
540- operation. retained_module = false ;
530+ operation. retained_module = module;
531+ if module {
532+ operation. env . insert (
533+ String :: from ( GUEST_ENTRYPOINT_MODULE_MODE_ENV ) ,
534+ String :: from ( "1" ) ,
535+ ) ;
536+ }
541537 operation
542538 . env
543539 . insert ( String :: from ( INLINE_FILE_PATH_ENV ) , file_path) ;
@@ -556,15 +552,18 @@ fn lower_operation(payload: RequestPayload) -> Result<LoweredOperation, SidecarE
556552 serde_json:: to_string( & result_path)
557553 . expect( "semantic result path serialization cannot fail" )
558554 ) ) ;
559- if module {
560- source = transform_retained_javascript_module ( & source, & file_path) ?;
561- }
562555 let mut operation =
563556 lowered_process ( payload. process , "node" , vec ! [ String :: from( "-e" ) , source] ) ;
564557 operation. retained_language = Some ( RetainedExecutionLanguage :: JavaScript ) ;
565558 operation. retained_source = operation. args . get ( 1 ) . cloned ( ) ;
566559 operation. retained_file_path = Some ( file_path. clone ( ) ) ;
567- operation. retained_module = false ;
560+ operation. retained_module = module;
561+ if module {
562+ operation. env . insert (
563+ String :: from ( GUEST_ENTRYPOINT_MODULE_MODE_ENV ) ,
564+ String :: from ( "1" ) ,
565+ ) ;
566+ }
568567 operation
569568 . env
570569 . insert ( String :: from ( INLINE_FILE_PATH_ENV ) , file_path) ;
0 commit comments