feat: add client socket methods for LLM stats

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-10 13:26:03 +00:00
parent e5d3517416
commit d2fd013312
+13 -1
View File
@@ -1,5 +1,5 @@
import { io, Socket } from 'socket.io-client';
import type { ServerEvents, ClientEvents, WorldState, StateUpdate, PlayerJoined, PlayerLeft, PlayerInput, SuperlativesData, NarrationEvent, MemoryEvent, InventionSummary, StockpileLogEntry, TunableConstants, TunableKey, LogEntry } from '@dflike/shared';
import type { ServerEvents, ClientEvents, WorldState, StateUpdate, PlayerJoined, PlayerLeft, PlayerInput, SuperlativesData, NarrationEvent, MemoryEvent, InventionSummary, StockpileLogEntry, TunableConstants, TunableKey, LogEntry, LlmStatsData } from '@dflike/shared';
type TypedSocket = Socket<ServerEvents, ClientEvents>;
@@ -29,6 +29,8 @@ export class SocketClient {
// Admin callbacks
onAdminAuthResult: ((data: { success: boolean; constants?: TunableConstants }) => void) | null = null;
onAdminConstantsUpdated: ((data: TunableConstants) => void) | null = null;
onLlmStatsResult: ((data: LlmStatsData) => void) | null = null;
onLlmTrackingToggled: ((data: { enabled: boolean }) => void) | null = null;
// Log callbacks
onLogHistory: ((data: LogEntry[]) => void) | null = null;
@@ -92,6 +94,8 @@ export class SocketClient {
});
this.socket.on('admin-auth-result', (data) => this.onAdminAuthResult?.(data));
this.socket.on('admin-constants-updated', (data) => this.onAdminConstantsUpdated?.(data));
this.socket.on('admin-llm-stats-result', (data) => this.onLlmStatsResult?.(data));
this.socket.on('admin-llm-tracking-toggled', (data) => this.onLlmTrackingToggled?.(data));
this.socket.on('log-history', (data) => this.onLogHistory?.(data));
this.socket.on('log-entry', (data) => this.onLogEntry?.(data));
}
@@ -152,6 +156,14 @@ export class SocketClient {
this.socket.emit('admin-reset-defaults');
}
requestLlmStats(): void {
this.socket.emit('admin-llm-stats');
}
toggleLlmTracking(enabled: boolean): void {
this.socket.emit('admin-toggle-llm-tracking', { enabled });
}
subscribeLogs(): void {
this.socket.emit('log-subscribe');
}