You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/$2?q=api&page=55&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 17842 results for "api"(2754ms)
845log.push({agent,type:"info",message:`Successfully extracted ~${text.length} characters from PDF.`});return text;}catch(error){const errorMessage=`Failed to extract text from PDF: ${error.message}`;log.push({agent,type:"error",message:errorMessage});console.error(agent,errorMessage,error);return null;}}
846async function callOpenAI(openaiInstance:OpenAI,systemPrompt:string,userMessage:string,model="gpt-4o",expectJson=true,log:LogEntry[],agentName:string,):Promise<object|string>{log.push({agent:agentName,type:"step",message:`Calling OpenAI model ${model}...`});try{const response=await openaiInstance.chat.completions.create({model:model,messages:[{role:"system",content:systemPrompt},{role:"user",content:userMessage}],temperature:expectJson?0.2:0.5,...(expectJson&&{response_format:{type:"json_object"}}),});const content=response.choices?.[0]?.message?.content;if(!content){log.push({agent:agentName,type:"error",message:"Received empty content from AI model."});throw new Error("Received empty content from AI model.");}
847log.push({agent:agentName,type:"info",message:`Received response from AI model (${content.length} chars).`});if(expectJson){try{return JSON.parse(content);}catch(parseError){console.error(`${agentName} JSON Parse Error:`,parseError,"Raw Content (first 500 chars):",content.substring(0,500));log.push({agent:agentName,type:"error",message:`AI response was not valid JSON. Raw (truncated): ${content.substring(0,100)}...`,});return{error:"AI_JSON_PARSE_ERROR",message:`AI response was not valid JSON. Raw (truncated for log): ${content.substring(0,250)}...`,rawContent:content};}}else{return content;}}catch(error){console.error(`${agentName} API call failed. Error:`,error);let errorMessage="Error communicating with AI model.";if(error.message){errorMessage+=` Details: ${error.message}`;}
848if(error.response&&error.response.data){errorMessage+=` Server Response: ${JSON.stringify(error.response.data)}`;}else if(error.cause){errorMessage+=` Cause: ${error.cause}`;}
849log.push({agent:agentName,type:"error",message:errorMessage});return{error:"AI_API_ERROR",message:errorMessage,details:error.toString()};}}
850async function ingestDocumentInput(input:{documentUrl?:string;documentText?:string;documentFile?:File;clientInputSourceDescription:string},log:LogEntry[],):Promise<{documentText:string|null;derivedInputSourceDescription:string;log:LogEntry[]}>{let documentText:string|null=null;let derivedInputSourceDescription=input.clientInputSourceDescription;const ingestionAgent="Ingestion Agent (Val Server)";if(input.documentFile){try{const fileBuffer=await input.documentFile.arrayBuffer();documentText=await extractPdfTextNative(fileBuffer,input.documentFile.name,log);derivedInputSourceDescription=`File: ${input.documentFile.name}`;}catch(bufferError){log.push({agent:ingestionAgent,type:"error",message:`Error reading PDF file buffer: ${bufferError.message}`});}}else if(input.documentText){log.push({agent:ingestionAgent,type:"info",message:"Using provided document text."});documentText=input.documentText;derivedInputSourceDescription="Pasted Text";}else if(input.documentUrl){log.push({agent:ingestionAgent,type:"step",message:`Fetching from URL: ${input.documentUrl}`});derivedInputSourceDescription=`URL: ${input.documentUrl}`;try{const response=await fetch(input.documentUrl,{headers:{"Accept":"text/plain, text/html, application/pdf"}});if(!response.ok)throw new Error(`HTTP error! status: ${response.status} ${response.statusText}`);const contentType=response.headers.get("content-type")||"";if(contentType.includes("application/pdf")){log.push({agent:ingestionAgent,type:"info",message:"Fetched PDF from URL. Extracting text..."});const pdfBuffer=await response.arrayBuffer();documentText=await extractPdfTextNative(pdfBuffer,input.documentUrl.split("/").pop()||"downloaded.pdf",log);}else{const text=await response.text();if(!text||text.trim().length===0)throw new Error("Fetched content is empty or not text.");log.push({agent:ingestionAgent,type:"info",message:`Fetched ~${text.length} characters from URL.`});documentText=text;}}catch(error){log.push({agent:ingestionAgent,type:"error",message:`Failed to fetch/process URL ${input.documentUrl}: ${error.message}`});}}
851return{documentText,derivedInputSourceDescription,log};}
53## Getting Started
5455The website is fully functional and ready to use. The main entry point is `/backend/index.ts` which serves the React application and handles API endpoints.
5657## Key Features