feat(ai): implement opt-in OpenAI-compatible AiService, secret redactor, surface guides, and WS streaming
This commit is contained in:
parent
fbc1eb94e0
commit
076df61f4d
6 changed files with 1073 additions and 1 deletions
|
|
@ -37,6 +37,10 @@ export interface WsPtyHandlers {
|
|||
onResize: (sessionId: string, cols: number, rows: number) => void;
|
||||
}
|
||||
|
||||
export interface WsAiHandlers {
|
||||
onCancel: (chatId: string) => void;
|
||||
}
|
||||
|
||||
export class WsHub {
|
||||
private readonly wss = new WebSocketServer({ noServer: true });
|
||||
private readonly clients = new Set<WsClientMeta>();
|
||||
|
|
@ -44,6 +48,7 @@ export class WsHub {
|
|||
private readonly upgradeHandlers: Array<{ prefix: string; handler: WsUpgradeHandler }> = [];
|
||||
private readonly subscribeListeners = new Set<WsSubscribeListener>();
|
||||
private ptyHandlers: WsPtyHandlers | null = null;
|
||||
private aiHandlers: WsAiHandlers | null = null;
|
||||
|
||||
constructor(
|
||||
httpServer: HttpServer,
|
||||
|
|
@ -83,6 +88,10 @@ export class WsHub {
|
|||
this.ptyHandlers = handlers;
|
||||
}
|
||||
|
||||
attachAiHandlers(handlers: WsAiHandlers): void {
|
||||
this.aiHandlers = handlers;
|
||||
}
|
||||
|
||||
close(): void {
|
||||
clearInterval(this.pingTimer);
|
||||
for (const client of this.clients) {
|
||||
|
|
@ -295,7 +304,7 @@ export class WsHub {
|
|||
break;
|
||||
}
|
||||
case 'ai:cancel':
|
||||
// Wired in Phase 5
|
||||
this.aiHandlers?.onCancel(frame.chatId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue