Stream live server logs over SSE
This commit is contained in:
@@ -55,6 +55,7 @@ import type {
|
||||
LlmConfigSuggestionRequest,
|
||||
LlmConfigSuggestionResponse,
|
||||
LogBackfillRequest,
|
||||
LogStreamEventOptions,
|
||||
LogStreamCursorRequest,
|
||||
LogStreamCursorResponse,
|
||||
LogStreamListResponse,
|
||||
@@ -446,6 +447,17 @@ export class PlatformApiClient {
|
||||
return this.request<LogStreamListResponse>(`/server-instances/${encodeURIComponent(id)}/logs/live`);
|
||||
}
|
||||
|
||||
openServerLogEvents(id: string, options: LogStreamEventOptions = {}): EventSource {
|
||||
return new EventSource(this.serverLogEventsUrl(id, options), { withCredentials: true });
|
||||
}
|
||||
|
||||
serverLogEventsUrl(id: string, options: LogStreamEventOptions = {}): string {
|
||||
const params = new URLSearchParams();
|
||||
if (options.historyLimit !== undefined) params.set("historyLimit", String(options.historyLimit));
|
||||
const query = params.toString();
|
||||
return `${this.baseUrl}/server-instances/${encodeURIComponent(id)}/logs/events${query ? `?${query}` : ""}`;
|
||||
}
|
||||
|
||||
async requestLogBackfill(id: string, request: LogBackfillRequest): Promise<JobResponse> {
|
||||
return this.request<JobResponse>(`/server-instances/${encodeURIComponent(id)}/logs/backfill`, {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user