feat(kol): add SSE streaming for prompt assist

- Extract assist runtime (prompt building, response parsing, finalize)
  from the worker into kol_assist_runtime so the sync streaming path
  and the async task path share the same logic.
- Add POST /kol/manage/assist/stream as a Server-Sent Events endpoint
  emitting start/delta/completed/error events, and wire it to a
  streamAssist helper on kolManageApi that reports ApiClientError with
  the server's error envelope.
- Stream generated content live in KolPromptEditor and KolGenerateView,
  switching KolPromptEditArea to a boolean aiBusy flag and refining the
  generator page layout.
- Add KolAssistStreamEvent to shared types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-18 16:17:11 +08:00
parent 79c65c1da7
commit 4bbce5f083
13 changed files with 1062 additions and 234 deletions
+12
View File
@@ -1331,6 +1331,18 @@ export interface KolAssistTask {
error_message?: string;
}
export interface KolAssistStreamEvent {
type: "start" | "delta" | "completed" | "error";
mode?: "generate" | "optimize";
status?: "generating" | "completed" | "failed";
delta?: string;
content?: string;
schema?: KolSchemaJson;
error?: string;
model?: string;
done?: boolean;
}
export interface KolDashboardOverview {
total_subscriber_tenants: number;
month_new_subscriptions: number;