Rewrite SocketController (#634)

* WIP

* Working

* Working

* Cleanup
This commit is contained in:
Max Goedjen
2025-08-26 23:44:16 -07:00
committed by GitHub
parent 8ad2d60082
commit e8fcb95db0
6 changed files with 196 additions and 177 deletions

View File

@@ -33,9 +33,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
logger.debug("SecretAgent finished launching")
Task { @MainActor in
socketController.handler = { [agent] reader, writer in
await agent.handle(reader: reader, writer: writer)
Task {
for await session in socketController.sessions {
Task {
do {
for await message in session.messages {
let agentResponse = try await agent.handle(data: message, provenance: session.provenance)
try await session.write(agentResponse)
}
} catch {
try session.close()
}
}
}
}
Task {