Val Town Code SearchReturn to Val Town

API Access

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)

myApi1 file match

@sujeetUpdated 1 year ago

twitterAPIDownAlert2 file matches

@stevekrouseUpdated 1 year ago

myApi1 file match

@tangshengnanUpdated 1 year ago

myApi1 file match

@factoriUpdated 1 year ago

myApi1 file match

@jonsibleyUpdated 1 year ago

myApi1 file match

@silversteezUpdated 1 year ago

myApi1 file match

@rykiUpdated 1 year ago

myApi1 file match

@fksUpdated 1 year ago

openapi2TS1 file match

@pomdtrUpdated 1 year ago

myApi1 file match

@abdulamiteUpdated 1 year ago

ChatHTMLRenderer.tsx23 matches

@c15rUpdated 48 mins ago
9}
10
11interface MCPContextAPI {
12 // Tool operations
13 listTools: () => 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 */
46 const [isLoading, setIsLoading] = useState(true);
47
48 // Create MCP context API that will be exposed to iframe
49 const createMCPContext = useCallback((): MCPContextAPI => {
50 const findClientByName = (serverName: string) => {
51 console.log("[MCP/Browser Renderer] Finding client by name:", serverName, mcpClients);
210 const { type, id, method, args } = event.data;
211
212 if (type !== "mcp-api-call") {
213 return;
214 }
219
220 if (typeof methodFunc !== "function") {
221 throw new Error(`Unknown MCP API method: ${method}`);
222 }
223
225
226 iframe.contentWindow?.postMessage({
227 type: "mcp-api-response",
228 id,
229 success: true,
232 } catch (error) {
233 iframe.contentWindow?.postMessage({
234 type: "mcp-api-response",
235 id,
236 success: false,
252 </script>
253 <script>
254 // MCP Context API for iframe content
255 window.mcpContext = {
256 // Async wrapper for postMessage communication
257 async callAPI(method, ...args) {
258 return new Promise((resolve, reject) => {
259 const id = Math.random().toString(36).substr(2, 9);
260
261 const handleResponse = (event) => {
262 if (event.data.type === 'mcp-api-response' && event.data.id === id) {
263 window.removeEventListener('message', handleResponse);
264 if (event.data.success) {
273
274 window.parent.postMessage({
275 type: 'mcp-api-call',
276 id,
277 method,
282 setTimeout(() => {
283 window.removeEventListener('message', handleResponse);
284 reject(new Error('MCP API call timeout'));
285 }, 30000);
286 });
288
289 // Convenience methods
290 async listTools() { return this.callAPI('listTools'); },
291 async callTool(serverName, toolName, args) { return this.callAPI('callTool', serverName, toolName, args); },
292 async listPrompts() { return this.callAPI('listPrompts'); },
293 async getPrompt(serverName, promptName, args) { return this.callAPI('getPrompt', serverName, promptName, args); },
294 async listResources() { return this.callAPI('listResources'); },
295 async readResource(serverName, uri) { return this.callAPI('readResource', serverName, uri); },
296 log(level, message, data) { this.callAPI('log', level, message, data); },
297 requestFullscreen() { this.callAPI('requestFullscreen'); },
298 exitFullscreen() { this.callAPI('exitFullscreen'); },
299 async isFullscreen() { return this.callAPI('isFullscreen'); }
300 };
301

Louai_team_performance_review.tsx46 matches

@jeffvincentUpdated 1 hour ago
7 TeamPerformanceStats,
8 WaiverWirePlayer,
9 YahooFantasyAPIClient,
10} from "./daily_lineup_scheduler.ts";
11import {
135 review?: AITeamPerformanceReview;
136 error?: {
137 type: "AUTH_ERROR" | "API_ERROR" | "ANALYSIS_ERROR" | "VALIDATION_ERROR" | "UNKNOWN_ERROR";
138 message: string;
139 details?: any;
141 execution_stats: {
142 duration_ms: number;
143 api_calls_made: number;
144 tokens_used?: number;
145 rate_limited: boolean;
213 ): Promise<ReviewExecutionResult> {
214 const startTime = Date.now();
215 let apiCallsCounter = 0;
216 let rateLimited = false;
217
226 "No valid authentication tokens found",
227 startTime,
228 apiCallsCounter,
229 rateLimited,
230 );
231 }
232
233 // Step 2: Initialize Yahoo API client
234 const yahooAPI = new YahooFantasyAPIClient(tokenData, this.tokenStorage, userId);
235
236 // Step 3: Get team key if not provided
237 if (!teamKey) {
238 teamKey = await yahooAPI.getTeamKey(userId, leagueId);
239 apiCallsCounter++;
240
241 if (!teamKey) {
242 return this.createErrorResult(
243 "API_ERROR",
244 "Could not determine team key for user in league",
245 startTime,
246 apiCallsCounter,
247 rateLimited,
248 );
254 // Step 4: Gather comprehensive performance data
255 console.log("📊 Gathering performance data...");
256 const performanceData = await this.gatherPerformanceData(yahooAPI, teamKey, leagueId);
257 apiCallsCounter += performanceData.apiCalls;
258 rateLimited = rateLimited || performanceData.rateLimited;
259
260 if (!performanceData.success) {
261 return this.createErrorResult(
262 "API_ERROR",
263 "Failed to gather performance data",
264 startTime,
265 apiCallsCounter,
266 rateLimited,
267 performanceData.error,
277 `Data validation failed: ${validationResult.errors.join(", ")}`,
278 startTime,
279 apiCallsCounter,
280 rateLimited,
281 );
296 "Failed to generate performance analysis report",
297 startTime,
298 apiCallsCounter,
299 rateLimited,
300 );
309 "AI analysis failed",
310 startTime,
311 apiCallsCounter,
312 rateLimited,
313 aiAnalysisResult.error,
326 "Waiver analysis failed",
327 startTime,
328 apiCallsCounter,
329 rateLimited,
330 waiverAnalysisResult.error,
349 execution_stats: {
350 duration_ms: duration,
351 api_calls_made: apiCallsCounter,
352 rate_limited: rateLimited,
353 },
359 error instanceof Error ? error.message : "Unknown error occurred",
360 startTime,
361 apiCallsCounter,
362 rateLimited,
363 error,
419 results: {
420 authentication: boolean;
421 yahooAPI: boolean;
422 openAI: boolean;
423 performanceAnalyzer: boolean;
429 const results = {
430 authentication: false,
431 yahooAPI: false,
432 openAI: false,
433 performanceAnalyzer: false,
445 }
446
447 // Test 2: OpenAI API
448 try {
449 const openAITest = await this.openaiClient.testConnection();
468 }
469
470 // Test 4: Yahoo API (requires valid tokens, so just test instantiation)
471 try {
472 const testTokens = { access_token: "test", refresh_token: "test", expires_at: Date.now() + 3600000 };
473 const yahooAPI = new YahooFantasyAPIClient(testTokens, this.tokenStorage, "test_user");
474 results.yahooAPI = true; // If instantiation succeeds
475 console.log("✅ Yahoo API test passed");
476 } catch (error) {
477 errors.push(`Yahoo API test failed: ${error}`);
478 console.log("❌ Yahoo API test failed");
479 }
480
497 */
498 private async gatherPerformanceData(
499 yahooAPI: YahooFantasyAPIClient,
500 teamKey: string,
501 leagueId: string,
508 leagueContext?: any;
509 };
510 apiCalls: number;
511 rateLimited: boolean;
512 error?: any;
513 }> {
514 let apiCalls = 0;
515 let rateLimited = false;
516
517 try {
518 // Get team performance stats
519 const teamStats = await yahooAPI.getTeamPerformanceStats(teamKey, leagueId);
520 apiCalls++;
521
522 if (!teamStats) {
525
526 // Get team roster
527 const roster = await yahooAPI.getTeamRoster(teamKey);
528 apiCalls++;
529
530 // Get detailed player performance (batch process to avoid rate limits)
534 for (let i = 0; i < roster.length; i += batchSize) {
535 const batch = roster.slice(i, i + batchSize);
536 const batchPromises = batch.map(player => yahooAPI.getPlayerPerformanceStats(player.player_id, leagueId));
537
538 try {
539 const batchResults = await Promise.allSettled(batchPromises);
540 apiCalls += batch.length;
541
542 for (const result of batchResults) {
557
558 // Get waiver wire players
559 const waiverPlayers = await yahooAPI.getWaiverWirePlayers(
560 leagueId,
561 undefined, // No position filter
562 undefined, // No ownership threshold
563 );
564 apiCalls++;
565
566 // Limit waiver candidates to avoid token overflow
578 teamKey,
579 );
580 // Note: This doesn't count as additional API calls since it uses cached data
581 } catch (error) {
582 console.log("⚠️ Could not gather league context:", error);
592 leagueContext,
593 },
594 apiCalls,
595 rateLimited,
596 };
598 return {
599 success: false,
600 apiCalls,
601 rateLimited,
602 error,
832 message: string,
833 startTime: number,
834 apiCalls: number,
835 rateLimited: boolean,
836 details?: any,
841 execution_stats: {
842 duration_ms: Date.now() - startTime,
843 api_calls_made: apiCalls,
844 rate_limited: rateLimited,
845 },
apiry
snartapi