@@ -14,6 +14,7 @@ use theater::config::actor_manifest::RuntimeHostConfig;
1414use theater:: config:: permissions:: RuntimePermissions ;
1515use theater:: events:: { runtime:: RuntimeEventData , ChainEventData , EventPayload } ;
1616use theater:: handler:: { Handler , HandlerContext , SharedActorInstance } ;
17+ use theater:: replay:: HostFunctionCall ;
1718use theater:: messages:: TheaterCommand ;
1819use theater:: shutdown:: ShutdownReceiver ;
1920use theater:: wasm:: { ActorComponent , ActorInstance } ;
@@ -47,7 +48,8 @@ impl<E> Handler<E> for RuntimeHandler
4748where
4849 E : EventPayload + Clone + From < RuntimeEventData >
4950 + From < theater:: events:: theater_runtime:: TheaterRuntimeEventData >
50- + From < theater:: events:: wasm:: WasmEventData > ,
51+ + From < theater:: events:: wasm:: WasmEventData >
52+ + From < theater:: replay:: HostFunctionCall > ,
5153{
5254 fn create_instance ( & self ) -> Box < dyn Handler < E > > {
5355 Box :: new ( self . clone ( ) )
@@ -106,7 +108,7 @@ where
106108 error : e. to_string ( ) ,
107109 step : "linker_instance" . to_string ( ) ,
108110 } . into ( ) ,
109- description : Some ( format ! ( "Failed to create linker instance: {}" , e) ) ,
111+ // description: Some(format!("Failed to create linker instance: {}", e)),
110112 } ) ;
111113 return Err ( anyhow:: anyhow!(
112114 "Could not instantiate theater:simple/runtime: {}" ,
@@ -122,14 +124,17 @@ where
122124 move |mut ctx : StoreContextMut < ' _ , ActorStore < E > > , ( msg, ) : ( String , ) | {
123125 let id = ctx. data ( ) . id . clone ( ) ;
124126
125- // Record log call event
127+ // Record host function call
128+ let input = serde_json:: to_vec ( & msg) . unwrap_or_default ( ) ;
126129 ctx. data_mut ( ) . record_event ( ChainEventData {
127130 event_type : "theater:simple/runtime/log" . to_string ( ) ,
128- data : RuntimeEventData :: Log {
129- level : "info" . to_string ( ) ,
130- message : msg. clone ( ) ,
131- } . into ( ) ,
132- description : Some ( format ! ( "Actor log: {}" , msg) ) ,
131+ data : HostFunctionCall :: new (
132+ "theater:simple/runtime" ,
133+ "log" ,
134+ input,
135+ vec ! [ ] , // log returns nothing
136+ ) . into ( ) ,
137+ // description removedformat!("Actor log: {}", msg)),
133138 } ) ;
134139
135140 info ! ( "[ACTOR] [{}] [{}] {}" , id, name1, msg) ;
@@ -144,7 +149,7 @@ where
144149 error : e. to_string ( ) ,
145150 step : "log_function_wrap" . to_string ( ) ,
146151 } . into ( ) ,
147- description : Some ( format ! ( "Failed to wrap log function: {}" , e) ) ,
152+ // description: Some(format!("Failed to wrap log function: {}", e)),
148153 } ) ;
149154 anyhow:: anyhow!( "Failed to wrap log function: {}" , e)
150155 } ) ?;
@@ -173,7 +178,7 @@ where
173178 old_state : "chain" . to_string ( ) ,
174179 new_state : "requested" . to_string ( ) ,
175180 } . into ( ) ,
176- description : Some ( "Get chain request" . to_string ( ) ) ,
181+ // description removed "Get chain request".to_string()),
177182 } ) ;
178183
179184 // Get all events from the chain
@@ -202,7 +207,7 @@ where
202207 data : RuntimeEventData :: StateChangeResult {
203208 success : true ,
204209 } . into ( ) ,
205- description : Some ( format ! ( "Chain retrieved: {} events" , event_count) ) ,
210+ // description removedformat !("Chain retrieved: {} events", event_count)),
206211 } ) ;
207212
208213 // Return as chain record: (events,)
@@ -217,7 +222,7 @@ where
217222 error : e. to_string ( ) ,
218223 step : "get_chain_function_wrap" . to_string ( ) ,
219224 } . into ( ) ,
220- description : Some ( format ! ( "Failed to wrap get-chain function: {}" , e) ) ,
225+ // description: Some(format!("Failed to wrap get-chain function: {}", e)),
221226 } ) ;
222227 anyhow:: anyhow!( "Failed to wrap get-chain function: {}" , e)
223228 } ) ?;
@@ -234,7 +239,7 @@ where
234239 data : RuntimeEventData :: ShutdownCall {
235240 data : data. clone ( ) ,
236241 } . into ( ) ,
237- description : Some ( format ! ( "Actor shutdown with data: {:?}" , data) ) ,
242+ // description removedformat !("Actor shutdown with data: {:?}", data)),
238243 } ) ;
239244
240245 info ! (
@@ -259,7 +264,6 @@ where
259264 data : RuntimeEventData :: ShutdownRequested {
260265 success : true ,
261266 } . into ( ) ,
262- description : Some ( "Shutdown command sent successfully" . to_string ( ) ) ,
263267 } ) ;
264268 Ok ( ( Ok ( ( ) ) , ) )
265269 }
@@ -271,10 +275,6 @@ where
271275 data : RuntimeEventData :: ShutdownRequested {
272276 success : false ,
273277 } . into ( ) ,
274- description : Some ( format ! (
275- "Failed to send shutdown command: {}" ,
276- err
277- ) ) ,
278278 } ) ;
279279 Ok ( ( Err ( err) , ) )
280280 }
@@ -290,7 +290,7 @@ where
290290 error : e. to_string ( ) ,
291291 step : "shutdown_function_wrap" . to_string ( ) ,
292292 } . into ( ) ,
293- description : Some ( format ! ( "Failed to wrap shutdown function: {}" , e) ) ,
293+ // description: Some(format!("Failed to wrap shutdown function: {}", e)),
294294 } ) ;
295295 anyhow:: anyhow!( "Failed to wrap shutdown function: {}" , e)
296296 } ) ?;
@@ -302,7 +302,9 @@ where
302302 & self ,
303303 actor_instance : & mut ActorInstance < E > ,
304304 ) -> anyhow:: Result < ( ) > {
305- actor_instance. register_function_no_result :: < ( String , ) > ( "theater:simple/actor" , "init" )
305+ // init: func(state: option<list<u8>>) -> result<tuple<option<list<u8>>>, string>
306+ // This is a state-only function - it takes only state and returns state
307+ actor_instance. register_function_state_only ( "theater:simple/actor" , "init" )
306308 }
307309
308310 fn name ( & self ) -> & str {
0 commit comments