@@ -228,8 +228,10 @@ func WaveAIPostMessageWrap(ctx context.Context, sseHandler *sse.SSEHandlerCh, ai
228228
229229// PostMessageRequest represents the request body for posting a message
230230type PostMessageRequest struct {
231- Msg uctypes.AIMessage `json:"msg"`
232- ChatID string `json:"chatid"`
231+ TabId string `json:"tabid"`
232+ ChatID string `json:"chatid"`
233+ Msg uctypes.AIMessage `json:"msg"`
234+ WidgetAccess bool `json:"widgetaccess,omitempty"`
233235}
234236
235237func WaveAIPostMessageHandler (w http.ResponseWriter , r * http.Request ) {
@@ -256,6 +258,16 @@ func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request) {
256258 return
257259 }
258260
261+ // Validate tabid is present and is a UUID
262+ if req .TabId == "" {
263+ http .Error (w , "tabid is required in request body" , http .StatusBadRequest )
264+ return
265+ }
266+ if _ , err := uuid .Parse (req .TabId ); err != nil {
267+ http .Error (w , "tabid must be a valid UUID" , http .StatusBadRequest )
268+ return
269+ }
270+
259271 // Validate the message
260272 if err := req .Msg .Validate (); err != nil {
261273 http .Error (w , fmt .Sprintf ("Message validation failed: %v" , err ), http .StatusInternalServerError )
@@ -277,6 +289,8 @@ func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request) {
277289 tools := []uctypes.ToolDefinition {
278290 GetAdderToolDefinition (),
279291 }
292+ tabTools := MakeToolsForTab (req .TabId , req .WidgetAccess )
293+ tools = append (tools , tabTools ... )
280294
281295 // Call the core WaveAIPostMessage function
282296 if err := WaveAIPostMessageWrap (r .Context (), sseHandler , aiOpts , req .ChatID , & req .Msg , tools ); err != nil {
0 commit comments