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/$2?q=function&page=41&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 31490 results for "function"(4045ms)

GlancerApp.tsx3 matches

@lightweight•Updated 2 days ago
14}
15// Simple hook for mobile menu toggle
16function useMobileMenu() {
17 const [isOpen, setIsOpen] = useState(false);
18 const toggleMenu = () => setIsOpen(!isOpen);
22
23// Simple hook for tracking current hash for active nav styling
24function useCurrentHash() {
25 const [currentHash, setCurrentHash] = useState(() => window.location.hash.slice(1));
26
37}
38
39export function App({ initialData }: AppProps) {
40 // initialData
41 const { demoData, loading, error } = initialData;

GlancerpollEnabledStatus.ts1 match

@lightweight•Updated 2 days ago
1export async function pollEnabledStatus() {
2 // this shouldn't run forever just b/c someone forgot to close their browser tab with the demo in it
3 const interval = 1000; // 10000;

openai_enrichmentindex.ts5 matches

@stevekrouse•Updated 2 days ago
26}
27
28export default async function (req: Request): Promise<Response> {
29 // Only allow POST requests with form data
30 if (req.method !== "POST") {
161}
162
163// Helper function to extract sections from the response
164function extractSection(content: string, sectionName: string): string {
165 const regex = new RegExp(
166 `${sectionName}:?\\s*([\\s\\S]*?)(?=\\n\\d+\\.|\\n[A-Z_]+:|$)`,
171}
172
173// Helper function to extract sources
174function extractSources(content: string): string[] {
175 const sourcesSection = extractSection(content, "SOURCES");
176 if (sourcesSection === "No information found") {

GetDustAgentsmain.tsx1 match

@gilles•Updated 2 days ago
1// File: syncDustAgents.ts
2export default async function syncDustAgents(req: Request): Promise<Response> {
3 // Only allow POST
4 if (req.method !== "POST") {

untitled-4158main.tsx14 matches

@legal•Updated 2 days ago
33 * Utility to create a standardized ACP object.
34 */
35function createAcp(
36 source_step_id: string,
37 status: ACPStatus,
56 * Simulated Tool: Searches application logs for errors.
57 */
58async function logSearchTool(serviceName: string, timeWindow: string): Promise<any> {
59 console.log(`TOOL: Searching logs for service "${serviceName}" in the last ${timeWindow}...`);
60 await new Promise(res => setTimeout(res, 250)); // Simulate network delay
72 * Simulated Tool: Checks the current status of a system component.
73 */
74async function systemStatusTool(serviceName: string): Promise<any> {
75 console.log(`TOOL: Checking current status of "${serviceName}"...`);
76 await new Promise(res => setTimeout(res, 250));
87 * Agent 1: Parses and normalizes the initial alert.
88 */
89async function triageAgent(inputAcp: ACP): Promise<ACP> {
90 console.log("AGENT: Triage Agent running...");
91 const alert = inputAcp.payload.content;
102 * Agent 2: Gathers additional context using tools.
103 */
104async function dataEnrichmentAgent(inputAcp: ACP): Promise<ACP> {
105 console.log("AGENT: Data Enrichment Agent running...");
106 const { service_name } = inputAcp.payload.content;
123 * Agent 3: Analyzes data and proposes a remediation plan. (REAL OpenAI Call)
124 */
125async function rootCauseAnalysisAgent(
126 enrichedData: any,
127 safetyFeedback?: string,
174 * Agent 4: The Safety Gate. Checks the plan for dangerous operations.
175 */
176async function safetyCheckerAgent(inputAcp: ACP): Promise<ACP> {
177 console.log(`AGENT: Safety Checker Agent running...`);
178 await new Promise(res => setTimeout(res, 200));
195 * Agent 5: Formats the final approved plan into an executable script.
196 */
197async function remediationFormatterAgent(inputAcp: ACP): Promise<ACP> {
198 console.log("AGENT: Remediation Formatter Agent running...");
199 const { remediation_plan } = inputAcp.payload.content;
214// --- Workflow Orchestrator --- //
215
216async function runIncidentResponseWorkflow(
217 alertPayload: object,
218 safetyFeedback?: string,
257// --- HTML Front-End --- //
258
259function generateHtmlShell() {
260 return `
261<!DOCTYPE html>
327 let originalAlertPayload = '';
328
329 function logStatus(message, type) {
330 statusLogEl.innerHTML += \`<div class="log-entry \${type}">\${message.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</div>\`;
331 }
332
333 function setLoading(isLoading) {
334 startBtn.disabled = isLoading;
335 approveBtn.disabled = isLoading;
380 approveBtn.addEventListener('click', () => continueWorkflow('approved'));
381
382 async function continueWorkflow(decision) {
383 setLoading(true);
384 humanApprovalEl.style.display = 'none';
429// --- Main HTTP Request Handler --- //
430
431export default async function(req: Request) {
432 const url = new URL(req.url);
433 const action = url.searchParams.get("action");

stevensDemoRY65O7ZtestDailyBrief.ts1 match

@ZOZYkOR45aid•Updated 2 days ago
4import { DateTime } from "https://esm.sh/luxon@3.4.4";
5
6export async function testDailyBrief() {
7 try {
8 const testChatId = Deno.env.get("TEST_TELEGRAM_CHAT_ID");
2// Run this script manually to create the database table
3
4export default async function setupTelegramChatDb() {
5 try {
6 // Import SQLite module

stevensDemoRY65O7ZsendDailyBrief.ts6 matches

@ZOZYkOR45aid•Updated 2 days ago
13} from "../memoryUtils.ts";
14
15async function generateBriefingContent(anthropic, memories, today, isSunday) {
16 try {
17 const weekdaysHelp = generateWeekDays(today);
96}
97
98export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99 // Get API keys from environment
100 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
135 const lastSunday = today.startOf("week").minus({ days: 1 });
136
137 // Fetch relevant memories using the utility function
138 const memories = await getRelevantMemories();
139
216}
217
218function generateWeekDays(today) {
219 let output = [];
220
239// console.log(weekDays);
240
241// Export a function that calls sendDailyBriefing with no parameters
242// This maintains backward compatibility with existing cron jobs
243export default async function (overrideToday?: DateTime) {
244 return await sendDailyBriefing(undefined, overrideToday);
245}

stevensDemoRY65O7ZREADME.md2 matches

@ZOZYkOR45aid•Updated 2 days ago
16In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
17
18However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md), which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and assigns content-types based on the file's extension.
19
20### `index.html`
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

stevensDemoRY65O7ZREADME.md2 matches

@ZOZYkOR45aid•Updated 2 days ago
4
5* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
7
8## Migrations
18The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
19
20The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.