@@ -42,6 +42,8 @@ import { promiseWithResolvers } from "@/utils";
4242import type { Config } from "./config" ;
4343import { KEYS } from "./kv" ;
4444import { logger } from "./log" ;
45+ import { Hono , MiddlewareHandler } from "hono" ;
46+ import { streamSSE } from "hono/streaming" ;
4547
4648interface ActorHandler {
4749 actor ?: AnyActorInstance ;
@@ -63,6 +65,9 @@ export class EngineActorDriver implements ActorDriver {
6365 #actorRouter: ActorRouter ;
6466 #version: number = 1 ; // Version for the runner protocol
6567
68+ #runnerStarted: PromiseWithResolvers < undefined > = Promise . withResolvers ( ) ;
69+ #runnerStopped: PromiseWithResolvers < undefined > = Promise . withResolvers ( ) ;
70+
6671 constructor (
6772 registryConfig : RegistryConfig ,
6873 runConfig : RunConfig ,
@@ -111,6 +116,8 @@ export class EngineActorDriver implements ActorDriver {
111116 runnerName : this . #config. runnerName ,
112117 } ) ;
113118 }
119+
120+ this . #runnerStarted. resolve ( undefined ) ;
114121 } ,
115122 onDisconnected : ( ) => {
116123 logger ( ) . warn ( {
@@ -120,7 +127,9 @@ export class EngineActorDriver implements ActorDriver {
120127 } ) ;
121128 hasDisconnected = true ;
122129 } ,
123- onShutdown : ( ) => { } ,
130+ onShutdown : ( ) => {
131+ this . #runnerStopped. resolve ( undefined ) ;
132+ } ,
124133 fetch : this . #runnerFetch. bind ( this ) ,
125134 websocket : this . #runnerWebSocket. bind ( this ) ,
126135 onActorStart : this . #runnerOnActorStart. bind ( this ) ,
@@ -381,4 +390,16 @@ export class EngineActorDriver implements ActorDriver {
381390 logger ( ) . info ( { msg : "stopping engine actor driver" } ) ;
382391 await this . #runner. shutdown ( immediate ) ;
383392 }
393+
394+ awaitStarted ( ) : Promise < void > {
395+ return this . #runnerStarted. promise ;
396+ }
397+
398+ awaitStopped ( ) : Promise < void > {
399+ return this . #runnerStopped. promise ;
400+ }
401+
402+ runnerId ( ) : string | undefined {
403+ return this . #runner. runnerId ;
404+ }
384405}
0 commit comments