1// ui.tsx
23export function generateHtmlShellV2(): string {
4return `<!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
1011// Your provided summarizerAgent
12export async function summarizerAgent(
13input: AgentInput<{ textToSummarize: string }>,
14context: AgentContext,
5758// Your provided fetchAgent (Note: "Workspaceing" seems like a typo, changed to "Fetching")
59export async function fetchAgent(
60input: AgentInput<{ url_from_input?: string; maxHeadlines?: number }>,
61context: AgentContext,
199200// 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) ...
203input: AgentInput<{
329330// 1. ConfigurationAgent
331export async function configurationAgent(
332input: AgentInput<{ userQuery: string }>,
333context: AgentContext,
393394// 2. SourceValidationAgent (was SourceSuggestionAgent - focuses on validating/using config's suggestions)
395export async function sourceValidationAgent(
396input: AgentInput<{ config: AnalysisConfig }>,
397context: AgentContext,
407408// 3. ParallelFetchAgent (This agent will call the user-provided fetchAgent for each feed)
409export async function parallelFetchAgent(
410input: AgentInput<{ feedsToFetch: { name: string; url: string }[]; maxHeadlinesPerFeed: number }>,
411context: AgentContext, // This context will be passed to the individual fetchAgent calls
460461// 4. ArticleCleaningAgent
462export async function articleCleaningAgent(
463input: AgentInput<{ articles: FetchedArticle[] }>,
464context: AgentContext,
477478// 5. RelevanceAssessmentAgent
479export async function relevanceAssessmentAgent(
480input: AgentInput<{ articles: FetchedArticle[]; topic: string; keywords: string[] }>,
481context: AgentContext,
535536// 6. ContentExtractionAgent (Simplified: mainly uses cleaned summary, conceptual for full text)
537export async function contentExtractionAgent(
538input: AgentInput<{ articles: FetchedArticle[]; analysisDepth: "cursory" | "standard" | "deep" }>,
539context: AgentContext,
554555// 7. SentimentAnalysisAgent
556export async function sentimentAnalysisAgent(
557input: AgentInput<{ articles: FetchedArticle[] }>,
558context: AgentContext,
602603// 8. KeyThemeExtractionAgent
604export async function keyThemeExtractionAgent(
605input: AgentInput<{ articles: FetchedArticle[]; topic: string }>,
606context: AgentContext,
647648// 9. TrendAndAnomalyDetectionAgent
649export async function trendAndAnomalyDetectionAgent(
650input: AgentInput<{ articlesWithThemes: FetchedArticle[]; topic: string; historicalContextSummary?: string }>, // historicalContext is optional
651context: AgentContext,
718719// 10. InsightGenerationAgent
720export async function insightGenerationAgent(
721input: AgentInput<{ trendReport: any; anomalyReport: any; config: AnalysisConfig; articlesCount: number }>,
722context: AgentContext,
825826// 11. ReportCompilationAgent
827export async function reportCompilationAgent(
828input: AgentInput<ReportCompilationAgentPayload>, // Use the new flat payload type
829context: 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(
909input: AgentInput<{ anomalyReport: any; insights: string[]; config: AnalysisConfig }>,
910context: AgentContext,
947948// --- Orchestrator Agent ---
949export async function analysisWorkflowOrchestrator(
950initialUserQuery: string,
951baseContext?: Partial<AgentContext>, // Allow passing a base context, e.g., for top-level config/secrets
mandateinterfaces.ts4 matches
20mandateId: string;
21taskId: string;
22log: LogFunction;
23config?: Record<string, any>;
24}
2526/** Defines the function signature for any agent. */
27export type AgentFunction<InputPayload = any, OutputPayload = any> = (
28input: AgentInput<InputPayload>,
29context: AgentContext,
6768// --- 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
67// Initialize database schema
8export async function initializeDatabase() {
9// Create locations table
10await sqlite.execute(`
4546// Save location data from ChirpStack payload
47export async function saveLocationData(payload: any) {
48console.log("[DB] Starting to save location data");
49
188189// Get all location data for a device
190export async function getLocationHistory(deviceId?: string) {
191let query = `
192SELECT
218219// Get a specific location by ID with its gateway data
220export async function getLocationById(id: number) {
221const location = await sqlite.execute(
222`SELECT * FROM ${LOCATIONS_TABLE} WHERE id = ?`,
240241// Get list of all devices
242export async function getDevices() {
243return await sqlite.execute(
244`SELECT DISTINCT device_id, device_name FROM ${LOCATIONS_TABLE}`
jsDelivr-as-iifemain.ts1 match
1export default async function (req: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
getGoogleCalendarEventsmain.tsx3 matches
4const accountId = "apn_Dph5j3E"; // frome pipedream integrations app id
56export async function getCalendars(accountId: string) {
7const calendarAPI = await pipeDreamGoogle("calendar", accountId);
8const calendars = await calendarAPI.calendarList.list();
11}
1213async function printCalendars(accountId: string) {
14const calendars = await getCalendars(accountId);
15for (let i = 0; i < calendars.data.items.length; i++) {
2223// 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
4import { DateTime } from "https://esm.sh/luxon@3.4.4";
56export async function testDailyBrief() {
7try {
8const testChatId = Deno.env.get("TEST_TELEGRAM_CHAT_ID");
2// Run this script manually to create the database table
34export default async function setupTelegramChatDb() {
5try {
6// Import SQLite module
stevennssendDailyBrief.ts6 matches
13} from "../memoryUtils.ts";
1415async function generateBriefingContent(anthropic, memories, today, isSunday) {
16try {
17const weekdaysHelp = generateWeekDays(today);
96}
9798export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99// Get API keys from environment
100const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
135const lastSunday = today.startOf("week").minus({ days: 1 });
136137// Fetch relevant memories using the utility function
138const memories = await getRelevantMemories();
139216}
217218function generateWeekDays(today) {
219let output = [];
220239// console.log(weekDays);
240241// Export a function that calls sendDailyBriefing with no parameters
242// This maintains backward compatibility with existing cron jobs
243export default async function (overrideToday?: DateTime) {
244return await sendDailyBriefing(undefined, overrideToday);
245}
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.
1718However 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.
1920### `index.html`
26## CRUD API Routes
2728This 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.
2930## Errors