You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/$1?q=api&page=45&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=api
Returns an array of strings in format "username" or "username/projectName"
Found 18993 results for "api"(1246ms)
9}
1011interface MCPContextAPI {
12// Tool operations
13listTools: () => Promise<any[]>;
37* - Renders HTML in a secure iframe
38* - Provides fullscreen enter/exit affordances
39* - Exposes MCP context API to iframe content
40* - Handles iframe communication via postMessage
41*/
46const [isLoading, setIsLoading] = useState(true);
4748// Create MCP context API that will be exposed to iframe
49const createMCPContext = useCallback((): MCPContextAPI => {
50const findClientByName = (serverName: string) => {
51console.log("[MCP/Browser Renderer] Finding client by name:", serverName, mcpClients);
210const { type, id, method, args } = event.data;
211212if (type !== "mcp-api-call") {
213return;
214}
219220if (typeof methodFunc !== "function") {
221throw new Error(`Unknown MCP API method: ${method}`);
222}
223225226iframe.contentWindow?.postMessage({
227type: "mcp-api-response",
228id,
229success: true,
232} catch (error) {
233iframe.contentWindow?.postMessage({
234type: "mcp-api-response",
235id,
236success: false,
252</script>
253<script>
254// MCP Context API for iframe content
255window.mcpContext = {
256// Async wrapper for postMessage communication
257async callAPI(method, ...args) {
258return new Promise((resolve, reject) => {
259const id = Math.random().toString(36).substr(2, 9);
260
261const handleResponse = (event) => {
262if (event.data.type === 'mcp-api-response' && event.data.id === id) {
263window.removeEventListener('message', handleResponse);
264if (event.data.success) {
273
274window.parent.postMessage({
275type: 'mcp-api-call',
276id,
277method,
282setTimeout(() => {
283window.removeEventListener('message', handleResponse);
284reject(new Error('MCP API call timeout'));
285}, 30000);
286});
288
289// Convenience methods
290async listTools() { return this.callAPI('listTools'); },
291async callTool(serverName, toolName, args) { return this.callAPI('callTool', serverName, toolName, args); },
292async listPrompts() { return this.callAPI('listPrompts'); },
293async getPrompt(serverName, promptName, args) { return this.callAPI('getPrompt', serverName, promptName, args); },
294async listResources() { return this.callAPI('listResources'); },
295async readResource(serverName, uri) { return this.callAPI('readResource', serverName, uri); },
296log(level, message, data) { this.callAPI('log', level, message, data); },
297requestFullscreen() { this.callAPI('requestFullscreen'); },
298exitFullscreen() { this.callAPI('exitFullscreen'); },
299async isFullscreen() { return this.callAPI('isFullscreen'); }
300};
301
7TeamPerformanceStats,
8WaiverWirePlayer,
9YahooFantasyAPIClient,
10} from "./daily_lineup_scheduler.ts";
11import {
135review?: AITeamPerformanceReview;
136error?: {
137type: "AUTH_ERROR" | "API_ERROR" | "ANALYSIS_ERROR" | "VALIDATION_ERROR" | "UNKNOWN_ERROR";
138message: string;
139details?: any;
141execution_stats: {
142duration_ms: number;
143api_calls_made: number;
144tokens_used?: number;
145rate_limited: boolean;
213): Promise<ReviewExecutionResult> {
214const startTime = Date.now();
215let apiCallsCounter = 0;
216let rateLimited = false;
217226"No valid authentication tokens found",
227startTime,
228apiCallsCounter,
229rateLimited,
230);
231}
232233// Step 2: Initialize Yahoo API client
234const yahooAPI = new YahooFantasyAPIClient(tokenData, this.tokenStorage, userId);
235236// Step 3: Get team key if not provided
237if (!teamKey) {
238teamKey = await yahooAPI.getTeamKey(userId, leagueId);
239apiCallsCounter++;
240241if (!teamKey) {
242return this.createErrorResult(
243"API_ERROR",
244"Could not determine team key for user in league",
245startTime,
246apiCallsCounter,
247rateLimited,
248);
254// Step 4: Gather comprehensive performance data
255console.log("📊 Gathering performance data...");
256const performanceData = await this.gatherPerformanceData(yahooAPI, teamKey, leagueId);
257apiCallsCounter += performanceData.apiCalls;
258rateLimited = rateLimited || performanceData.rateLimited;
259260if (!performanceData.success) {
261return this.createErrorResult(
262"API_ERROR",
263"Failed to gather performance data",
264startTime,
265apiCallsCounter,
266rateLimited,
267performanceData.error,
277`Data validation failed: ${validationResult.errors.join(", ")}`,
278startTime,
279apiCallsCounter,
280rateLimited,
281);
296"Failed to generate performance analysis report",
297startTime,
298apiCallsCounter,
299rateLimited,
300);
309"AI analysis failed",
310startTime,
311apiCallsCounter,
312rateLimited,
313aiAnalysisResult.error,
326"Waiver analysis failed",
327startTime,
328apiCallsCounter,
329rateLimited,
330waiverAnalysisResult.error,
349execution_stats: {
350duration_ms: duration,
351api_calls_made: apiCallsCounter,
352rate_limited: rateLimited,
353},
359error instanceof Error ? error.message : "Unknown error occurred",
360startTime,
361apiCallsCounter,
362rateLimited,
363error,
419results: {
420authentication: boolean;
421yahooAPI: boolean;
422openAI: boolean;
423performanceAnalyzer: boolean;
429const results = {
430authentication: false,
431yahooAPI: false,
432openAI: false,
433performanceAnalyzer: false,
445}
446447// Test 2: OpenAI API
448try {
449const openAITest = await this.openaiClient.testConnection();
468}
469470// Test 4: Yahoo API (requires valid tokens, so just test instantiation)
471try {
472const testTokens = { access_token: "test", refresh_token: "test", expires_at: Date.now() + 3600000 };
473const yahooAPI = new YahooFantasyAPIClient(testTokens, this.tokenStorage, "test_user");
474results.yahooAPI = true; // If instantiation succeeds
475console.log("✅ Yahoo API test passed");
476} catch (error) {
477errors.push(`Yahoo API test failed: ${error}`);
478console.log("❌ Yahoo API test failed");
479}
480497*/
498private async gatherPerformanceData(
499yahooAPI: YahooFantasyAPIClient,
500teamKey: string,
501leagueId: string,
508leagueContext?: any;
509};
510apiCalls: number;
511rateLimited: boolean;
512error?: any;
513}> {
514let apiCalls = 0;
515let rateLimited = false;
516517try {
518// Get team performance stats
519const teamStats = await yahooAPI.getTeamPerformanceStats(teamKey, leagueId);
520apiCalls++;
521522if (!teamStats) {
525526// Get team roster
527const roster = await yahooAPI.getTeamRoster(teamKey);
528apiCalls++;
529530// Get detailed player performance (batch process to avoid rate limits)
534for (let i = 0; i < roster.length; i += batchSize) {
535const batch = roster.slice(i, i + batchSize);
536const batchPromises = batch.map(player => yahooAPI.getPlayerPerformanceStats(player.player_id, leagueId));
537538try {
539const batchResults = await Promise.allSettled(batchPromises);
540apiCalls += batch.length;
541542for (const result of batchResults) {
557558// Get waiver wire players
559const waiverPlayers = await yahooAPI.getWaiverWirePlayers(
560leagueId,
561undefined, // No position filter
562undefined, // No ownership threshold
563);
564apiCalls++;
565566// Limit waiver candidates to avoid token overflow
578teamKey,
579);
580// Note: This doesn't count as additional API calls since it uses cached data
581} catch (error) {
582console.log("⚠️ Could not gather league context:", error);
592leagueContext,
593},
594apiCalls,
595rateLimited,
596};
598return {
599success: false,
600apiCalls,
601rateLimited,
602error,
832message: string,
833startTime: number,
834apiCalls: number,
835rateLimited: boolean,
836details?: any,
841execution_stats: {
842duration_ms: Date.now() - startTime,
843api_calls_made: apiCalls,
844rate_limited: rateLimited,
845},