You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(widgets): add Exa web search + fix widget API endpoints (koala73#1782)
* feat(widgets): add Exa web search + fix widget API endpoints
- Replace Tavily with Exa as primary stock-news search provider
(Exa → Brave → SerpAPI → Google News RSS cascade)
- Add search_web tool to widget agent so AI can fetch live data
about any topic beyond the pre-defined RPC catalog
- Exa primary (type:auto + content snippets), Brave fallback
- Fix all widget tool endpoints: /rpc/... paths were hitting
Vercel catch-all and returning SPA HTML instead of JSON data
- Fix wm-widget-shell min-height causing fixed-size border that
clipped AI widget content
- Add HTML response guard in tool handler
- Update env key: TAVILY_API_KEYS → EXA_API_KEYS throughout
* fix(stock-news): use type 'neural' for Exa search (type 'news' is invalid)
constWIDGET_SYSTEM_PROMPT=`You are a WorldMonitor widget builder. Your job is to fetch live data and generate a display-only HTML widget using the WorldMonitor design system.
7495
7496
7496
-
## Available data (use fetch_worldmonitor_data tool)
### search_web — Live internet search for ANY topic (use when topic not covered above)
7516
+
Use search_web for: breaking news, weather, sports, elections, specific events, company news, scientific reports, geopolitical updates, sanctions, disasters, or any real-time topic.
7517
+
Results include: title, url, snippet, publishedDate. Embed this data directly into the widget HTML.
7510
7518
7511
7519
## Design system CSS classes
7512
7520
Use ONLY these classes (no inline styles except var() references):
@@ -7536,16 +7544,92 @@ Use var(--widget-accent, var(--accent)) for themed highlights.
7536
7544
4. No interactive elements (no buttons, no tabs, no inputs).
7537
7545
5. Tables use class="trade-tariffs-table". Lists use class="trade-restrictions-list".
7538
7546
6. Always include a source footer: <div class="economic-footer"><span class="economic-source">Source: WorldMonitor</span></div>
7539
-
7. If no data available: <div class="economic-empty">No data available</div>
7540
-
8. The dashboard already provides the outer widget shell. Generate only the inner widget body markup.
7547
+
7. If tool returns no data or an error: use <div class="economic-empty">No live data available</div> — NEVER write prose explanations.
7548
+
8. If tool response contains "<!DOCTYPE" or "<html": it is an error — treat as no data and use the empty state HTML.
7549
+
9. The dashboard already provides the outer widget shell. Generate only the inner widget body markup.
7550
+
10. CRITICAL: Your response MUST always be HTML inside <!-- widget-html --> markers. NEVER respond with plain text, markdown, or explanations outside the HTML markers.
7541
7551
7542
7552
For modify requests: make targeted changes to improve the widget as requested.`;
7543
7553
7554
+
constWIDGET_SEARCH_TOOL={
7555
+
name: 'search_web',
7556
+
description: 'Search the web for current news, live data, or any topic not covered by WorldMonitor RPCs. Returns up to 8 results with title, URL, snippet, and publish date. Use this for topics like breaking news, weather, specific events, prices not in RPC catalog, etc.',
7557
+
input_schema: {
7558
+
type: 'object',
7559
+
properties: {
7560
+
query: {type: 'string',description: 'Search query — be specific for better results'},
@@ -7806,20 +7913,27 @@ async function handleWidgetAgentRequest(req, res) {
7806
7913
7807
7914
constWIDGET_PRO_SYSTEM_PROMPT=`You are a WorldMonitor PRO widget builder. Your job is to fetch live data and generate an interactive HTML widget body with inline JavaScript.
7808
7915
7809
-
## Available data (use fetch_worldmonitor_data tool)
### search_web — Live internet search for ANY topic (use when topic not covered above)
7935
+
Use search_web for: breaking news, weather, sports, elections, specific events, company news, scientific reports, geopolitical updates, sanctions, disasters, or any real-time topic.
7936
+
Results include: title, url, snippet, publishedDate. Embed as const DATA = [...] in your inline script.
7823
7937
7824
7938
## Output: body content + inline scripts ONLY
7825
7939
Generate ONLY the <body> content — NO <!DOCTYPE>, NO <html>, NO <head> wrappers. The client provides the page skeleton with dark theme CSS and a strict CSP already in place.
0 commit comments