feat(gateway,cli,types): wire token usage, model info, and thinking levels
Gateway: - Emit session:info on session creation with provider, model, thinking level - Include SessionUsagePayload in agent:end with token stats, cost, context usage - Handle set:thinking client event to cycle thinking levels - Respond with updated session:info after thinking level change Types (@mosaic/types): - Add SessionUsagePayload (tokens, cost, context) to AgentEndPayload - Add SessionInfoPayload (provider, model, thinking level, available levels) - Add SetThinkingPayload and set:thinking to ClientToServerEvents - Add session:info to ServerToClientEvents CLI TUI: - useSocket now tracks tokenUsage, modelName, providerName, thinkingLevel - Updates from both session:info and agent:end usage payload - Ctrl+T cycles thinking level via set:thinking socket event - Footer shows thinking level next to model (e.g. 'claude-opus-4-6 • medium') - Token stats populate with real ↑in ↓out Rcache Wcache $cost ctx%
This commit is contained in:
@@ -9,6 +9,26 @@ export interface AgentStartPayload {
|
||||
|
||||
export interface AgentEndPayload {
|
||||
conversationId: string;
|
||||
usage?: SessionUsagePayload;
|
||||
}
|
||||
|
||||
/** Session metadata emitted with agent:end and on session:info */
|
||||
export interface SessionUsagePayload {
|
||||
provider: string;
|
||||
modelId: string;
|
||||
thinkingLevel: string;
|
||||
tokens: {
|
||||
input: number;
|
||||
output: number;
|
||||
cacheRead: number;
|
||||
cacheWrite: number;
|
||||
total: number;
|
||||
};
|
||||
cost: number;
|
||||
context: {
|
||||
percent: number | null;
|
||||
window: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AgentTextPayload {
|
||||
@@ -44,6 +64,21 @@ export interface ChatMessagePayload {
|
||||
content: string;
|
||||
}
|
||||
|
||||
/** Session info pushed when session is created or model changes */
|
||||
export interface SessionInfoPayload {
|
||||
conversationId: string;
|
||||
provider: string;
|
||||
modelId: string;
|
||||
thinkingLevel: string;
|
||||
availableThinkingLevels: string[];
|
||||
}
|
||||
|
||||
/** Client request to change thinking level */
|
||||
export interface SetThinkingPayload {
|
||||
conversationId: string;
|
||||
level: string;
|
||||
}
|
||||
|
||||
/** Socket.IO typed event map: server → client */
|
||||
export interface ServerToClientEvents {
|
||||
'message:ack': (payload: MessageAckPayload) => void;
|
||||
@@ -53,10 +88,12 @@ export interface ServerToClientEvents {
|
||||
'agent:thinking': (payload: AgentThinkingPayload) => void;
|
||||
'agent:tool:start': (payload: ToolStartPayload) => void;
|
||||
'agent:tool:end': (payload: ToolEndPayload) => void;
|
||||
'session:info': (payload: SessionInfoPayload) => void;
|
||||
error: (payload: ErrorPayload) => void;
|
||||
}
|
||||
|
||||
/** Socket.IO typed event map: client → server */
|
||||
export interface ClientToServerEvents {
|
||||
message: (data: ChatMessagePayload) => void;
|
||||
'set:thinking': (data: SetThinkingPayload) => void;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ export type {
|
||||
AgentThinkingPayload,
|
||||
ToolStartPayload,
|
||||
ToolEndPayload,
|
||||
SessionUsagePayload,
|
||||
SessionInfoPayload,
|
||||
SetThinkingPayload,
|
||||
ErrorPayload,
|
||||
ChatMessagePayload,
|
||||
ServerToClientEvents,
|
||||
|
||||
Reference in New Issue
Block a user