mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat: add assistant mode, SSE streaming, and OpenCode server integration (#214)
This commit is contained in:
1 parent
3cc24288a6
commit
c3d6549f01
133 files changed
+7284
-6293
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import type { EventStreamConnection, EventStreamTransport, EventStreamTransportHandlers } from './types'
|
||||
|
||||
export class TestEventStreamTransport implements EventStreamTransport {
|
||||
readonly posts: Array<{ path: string; body: unknown }> = []
|
||||
closeCount = 0
|
||||
private handlers: EventStreamTransportHandlers | null = null
|
||||
private connection: EventStreamConnection | null = null
|
||||
|
||||
open(_url: string, handlers: EventStreamTransportHandlers): EventStreamConnection {
|
||||
this.handlers = handlers
|
||||
this.connection = {
|
||||
close: () => {
|
||||
if (this.connection) {
|
||||
this.connection = null
|
||||
this.closeCount += 1
|
||||
}
|
||||
},
|
||||
}
|
||||
return this.connection
|
||||
}
|
||||
|
||||
async post(path: string, body: unknown): Promise<boolean> {
|
||||
this.posts.push({ path, body })
|
||||
return true
|
||||
}
|
||||
|
||||
openConnection(): void {
|
||||
this.handlers?.onOpen()
|
||||
}
|
||||
|
||||
connected(clientId = 'test-client'): void {
|
||||
this.handlers?.onConnected(JSON.stringify({ clientId }))
|
||||
}
|
||||
|
||||
message(data: unknown): void {
|
||||
this.handlers?.onMessage(JSON.stringify(data))
|
||||
}
|
||||
|
||||
heartbeat(): void {
|
||||
this.handlers?.onHeartbeat()
|
||||
}
|
||||
|
||||
fail(): void {
|
||||
this.handlers?.onError()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user