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/$%7Bsuccess?q=function&page=44&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 19409 results for "function"(1761ms)

mandateui.ts2 matches

@salon•Updated 2 days ago
1// ui.tsx
2
3export function generateHtmlShellV2(): string {
4 return `<!DOCTYPE html>
5<html>
26<form id="demoForm">
27 <label for="userText">Enter text for summarization (Required):</label>
28 <textarea id="userText" name="userText" required>The quick brown fox jumps over the lazy dog. This is a longer sentence to ensure the summarizer has enough text to work with and demonstrate its functionality properly. This workflow will summarize this text and optionally fetch data from jsonplaceholder based on the checkbox below. The final step combines the results.</textarea>
29 <label class="checkbox-label">
30 <input type="checkbox" id="enableFetch" name="enableExternalFetch" value="true" checked>

mandateagent_ecosystem.ts17 matches

@salon•Updated 2 days ago
10
11// Your provided summarizerAgent
12export async function summarizerAgent(
13 input: AgentInput<{ textToSummarize: string }>,
14 context: AgentContext,
57
58// Your provided fetchAgent (Note: "Workspaceing" seems like a typo, changed to "Fetching")
59export async function fetchAgent(
60 input: AgentInput<{ url_from_input?: string; maxHeadlines?: number }>,
61 context: AgentContext,
199
200// Your provided combinerAgent (not directly used in the 12-step orchestrator, but kept for reference)
201export async function combinerAgent(
202 // ... (combinerAgent code as you provided, also updating its OpenAI call) ...
203 input: AgentInput<{
329
330// 1. ConfigurationAgent
331export async function configurationAgent(
332 input: AgentInput<{ userQuery: string }>,
333 context: AgentContext,
393
394// 2. SourceValidationAgent (was SourceSuggestionAgent - focuses on validating/using config's suggestions)
395export async function sourceValidationAgent(
396 input: AgentInput<{ config: AnalysisConfig }>,
397 context: AgentContext,
407
408// 3. ParallelFetchAgent (This agent will call the user-provided fetchAgent for each feed)
409export async function parallelFetchAgent(
410 input: AgentInput<{ feedsToFetch: { name: string; url: string }[]; maxHeadlinesPerFeed: number }>,
411 context: AgentContext, // This context will be passed to the individual fetchAgent calls
460
461// 4. ArticleCleaningAgent
462export async function articleCleaningAgent(
463 input: AgentInput<{ articles: FetchedArticle[] }>,
464 context: AgentContext,
477
478// 5. RelevanceAssessmentAgent
479export async function relevanceAssessmentAgent(
480 input: AgentInput<{ articles: FetchedArticle[]; topic: string; keywords: string[] }>,
481 context: AgentContext,
535
536// 6. ContentExtractionAgent (Simplified: mainly uses cleaned summary, conceptual for full text)
537export async function contentExtractionAgent(
538 input: AgentInput<{ articles: FetchedArticle[]; analysisDepth: "cursory" | "standard" | "deep" }>,
539 context: AgentContext,
554
555// 7. SentimentAnalysisAgent
556export async function sentimentAnalysisAgent(
557 input: AgentInput<{ articles: FetchedArticle[] }>,
558 context: AgentContext,
602
603// 8. KeyThemeExtractionAgent
604export async function keyThemeExtractionAgent(
605 input: AgentInput<{ articles: FetchedArticle[]; topic: string }>,
606 context: AgentContext,
647
648// 9. TrendAndAnomalyDetectionAgent
649export async function trendAndAnomalyDetectionAgent(
650 input: AgentInput<{ articlesWithThemes: FetchedArticle[]; topic: string; historicalContextSummary?: string }>, // historicalContext is optional
651 context: AgentContext,
718
719// 10. InsightGenerationAgent
720export async function insightGenerationAgent(
721 input: AgentInput<{ trendReport: any; anomalyReport: any; config: AnalysisConfig; articlesCount: number }>,
722 context: AgentContext,
825
826// 11. ReportCompilationAgent
827export async function reportCompilationAgent(
828 input: AgentInput<ReportCompilationAgentPayload>, // Use the new flat payload type
829 context: AgentContext,
902// Ensure the insightGenerationAgent is also consistent with its input expectations
903// The insightGenerationAgent seems fine as it destructures its expected inputs directly from input.payload.
904// export async function insightGenerationAgent(
905//   input: AgentInput<{ trendReport: any, anomalyReport: any, config: AnalysisConfig, articlesCount: number }>,
906// ...)
907// 12. AlertFormattingAgent
908export async function alertFormattingAgent(
909 input: AgentInput<{ anomalyReport: any; insights: string[]; config: AnalysisConfig }>,
910 context: AgentContext,
947
948// --- Orchestrator Agent ---
949export async function analysisWorkflowOrchestrator(
950 initialUserQuery: string,
951 baseContext?: Partial<AgentContext>, // Allow passing a base context, e.g., for top-level config/secrets

mandateinterfaces.ts4 matches

@salon•Updated 2 days ago
20 mandateId: string;
21 taskId: string;
22 log: LogFunction;
23 config?: Record<string, any>;
24}
25
26/** Defines the function signature for any agent. */
27export type AgentFunction<InputPayload = any, OutputPayload = any> = (
28 input: AgentInput<InputPayload>,
29 context: AgentContext,
67
68// --- Logging Types ---
69export type LogFunction = (level: LogLevel, component: string, message: string, details?: any) => void;
70export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR" | "SUCCESS";
71

ValTown-Package-Trackerschema.ts5 matches

@jhiller•Updated 2 days ago
6
7// Initialize database schema
8export async function initializeDatabase() {
9 // Create locations table
10 await sqlite.execute(`
45
46// Save location data from ChirpStack payload
47export async function saveLocationData(payload: any) {
48 console.log("[DB] Starting to save location data");
49
188
189// Get all location data for a device
190export async function getLocationHistory(deviceId?: string) {
191 let query = `
192 SELECT
218
219// Get a specific location by ID with its gateway data
220export async function getLocationById(id: number) {
221 const location = await sqlite.execute(
222 `SELECT * FROM ${LOCATIONS_TABLE} WHERE id = ?`,
240
241// Get list of all devices
242export async function getDevices() {
243 return await sqlite.execute(
244 `SELECT DISTINCT device_id, device_name FROM ${LOCATIONS_TABLE}`

jsDelivr-as-iifemain.ts1 match

@netux•Updated 2 days ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

getGoogleCalendarEventsmain.tsx3 matches

@pugio•Updated 2 days ago
4const accountId = "apn_Dph5j3E"; // frome pipedream integrations app id
5
6export async function getCalendars(accountId: string) {
7 const calendarAPI = await pipeDreamGoogle("calendar", accountId);
8 const calendars = await calendarAPI.calendarList.list();
11}
12
13async function printCalendars(accountId: string) {
14 const calendars = await getCalendars(accountId);
15 for (let i = 0; i < calendars.data.items.length; i++) {
22
23// list out the events on a calendar
24// export async function getEvents(accountId: string, calendarId: string) {
25// const calendar = await pipeDreamGoogle("calendar", accountId);
26

stevennstestDailyBrief.ts1 match

@pugio•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");

stevennssetupTelegramChatDb.ts1 match

@pugio•Updated 2 days ago
2// Run this script manually to create the database table
3
4export default async function setupTelegramChatDb() {
5 try {
6 // Import SQLite module

stevennssendDailyBrief.ts6 matches

@pugio•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}

stevennsREADME.md2 matches

@pugio•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

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 weeks ago
Simple functional CSS library for Val Town
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.