@@ -3,7 +3,10 @@ import GRPC
33extension MutagenDaemon {
44typealias PromptStream = GRPCAsyncBidirectionalStreamingCall < Prompting_HostRequest , Prompting_HostResponse >
55
6- func host( allowPrompts: Bool = true ) async throws ( DaemonError) -> ( PromptStream , identifier: String ) {
6+ func host(
7+ allowPrompts: Bool = true ,
8+ promptCallback: ( @MainActor ( String ) -> Void ) ? = nil
9+ ) async throws ( DaemonError) -> ( PromptStream , identifier: String ) {
710let stream = client!. prompt. makeHostCall ( )
811
912do {
@@ -28,7 +31,6 @@ extension MutagenDaemon {
2831try initResp. ensureValid ( first: true , allowPrompts: allowPrompts)
2932
3033Task . detached ( priority: . background) {
31- defer { Task { @MainActor in self . lastPromptMessage= nil } }
3234do {
3335while let msg= try await iter. next ( ) {
3436try msg. ensureValid ( first: false , allowPrompts: allowPrompts)
@@ -41,7 +43,7 @@ extension MutagenDaemon {
4143 // Any other messages that require a non-empty response will
4244 // cause the create op to fail, showing an error. This is ok for now.
4345} else {
44- Task { @MainActor in self . lastPromptMessage = msg. message}
46+ Task { @MainActor in promptCallback ? ( msg. message) }
4547}
4648try await stream. requestStream. send ( reply)
4749}