From d2fd013312dd0c75758292b642fb325d041a1247 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 13:26:03 +0000 Subject: [PATCH] feat: add client socket methods for LLM stats Co-Authored-By: Claude Opus 4.6 --- client/src/network/SocketClient.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/network/SocketClient.ts b/client/src/network/SocketClient.ts index a90d53c..f26a760 100644 --- a/client/src/network/SocketClient.ts +++ b/client/src/network/SocketClient.ts @@ -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; @@ -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'); }