( msg: AgentServerMessage, blobStore: Map<string, Uint8Array>, mcpTools: McpToolDefinition[], sendFrame: (data: Uint8Array) => void, state: StreamState, onText: (text: string, isThinking?: boolean) => void, onMcpExec: (exec: PendingExec) => void, onCheckpoint?: (checkpointBytes: Uint8Array) => void, )
| 836 | } |
| 837 | |
| 838 | function processServerMessage( |
| 839 | msg: AgentServerMessage, |
| 840 | blobStore: Map<string, Uint8Array>, |
| 841 | mcpTools: McpToolDefinition[], |
| 842 | sendFrame: (data: Uint8Array) => void, |
| 843 | state: StreamState, |
| 844 | onText: (text: string, isThinking?: boolean) => void, |
| 845 | onMcpExec: (exec: PendingExec) => void, |
| 846 | onCheckpoint?: (checkpointBytes: Uint8Array) => void, |
| 847 | ): void { |
| 848 | const msgCase = msg.message.case; |
| 849 | |
| 850 | if (msgCase === "interactionUpdate") { |
| 851 | handleInteractionUpdate(msg.message.value, state, onText); |
| 852 | } else if (msgCase === "kvServerMessage") { |
| 853 | handleKvMessage(msg.message.value as KvServerMessage, blobStore, sendFrame); |
| 854 | } else if (msgCase === "execServerMessage") { |
| 855 | handleExecMessage( |
| 856 | msg.message.value as ExecServerMessage, |
| 857 | mcpTools, |
| 858 | sendFrame, |
| 859 | onMcpExec, |
| 860 | ); |
| 861 | } else if (msgCase === "conversationCheckpointUpdate") { |
| 862 | const stateStructure = msg.message.value as ConversationStateStructure; |
| 863 | if (stateStructure.tokenDetails) { |
| 864 | state.totalTokens = stateStructure.tokenDetails.usedTokens; |
| 865 | } |
| 866 | if (onCheckpoint) { |
| 867 | onCheckpoint(toBinary(ConversationStateStructureSchema, stateStructure)); |
| 868 | } |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | function handleInteractionUpdate( |
| 873 | update: any, |
no test coverage detected