stevennscronDailyBrief.ts1 match
1import { sendDailyBriefing } from "./sendDailyBrief.ts";
23export async function cronDailyBrief() {
4try {
5const chatId = Deno.env.get("TELEGRAM_CHAT_ID");
62};
6364export function App() {
65const [memories, setMemories] = useState<Memory[]>([]);
66const [loading, setLoading] = useState(true);
139const data = await response.json();
140141// Change the sorting function to show memories in chronological order
142const sortedMemories = [...data].sort((a, b) => {
143const dateA = a.createdDate || 0;
170}
171172// --- HTML Generation Function (Glassmorphism UI) ---
173function generateHtmlShell(initialUrl, initialText, sourceUrl, appConfig, analysisAgents, currentLocaleStrings) {
174const escapedUrl = initialUrl ? initialUrl.replace(/"/g, """) : "";
175const escapedText = initialText ? initialText.replace(/</g, "<").replace(/>/g, ">") : "";
416let currentLocale = APP_CONFIG.default_language || 'en';
417418// --- Localization Functions (largely unchanged, uses 'locales' object) ---
419function translate(key, replacements = {}) { /* ... original ... */ }
420function applyTranslations() { /* ... original ... */ }
421function setLocale(locale) { /* ... original ... */ }
422function updateLocaleButtons() {
423document.querySelectorAll('.lang-btn').forEach(btn => btn.classList.toggle('active', btn.dataset.lang === currentLocale));
424const linkHtml = \`<a href="\${APP_CONFIG.footer_powered_by_url}" target="_top">\${APP_CONFIG.footer_powered_by_link_text}</a>\`;
436const resultsContainer = document.getElementById('results-content-cards'); // Container for dynamic cards
437438// --- UI Update Functions ---
439function setLoadingState(isLoading) { /* ... original, use translate for button text ... */ }
440function displayError(messageKey, replacements = {}) { /* ... original, use translate for error messages ... */ }
441function clearResults() {
442ANALYSIS_AGENTS.forEach(agent => {
443if (agent.ui_display_info) {
459noResultsMessage.style.display = 'block';
460}
461function updateLoadingProgress(percentage, statusKey, agentName = '') {
462progressBar.style.width = \`\${percentage}%\`;
463let statusText = translate(statusKey);
468}
469470// --- Result Rendering Functions (DYNAMIC based on ANALYSIS_AGENTS) ---
471function renderAgentResult(agentId, agentResultData, agentConfig) {
472const card = document.getElementById(\`card-\${agentId}\`);
473const contentEl = document.getElementById(\`content-\${agentId}\`);
637638// --- Main Request Handler (Server Code) ---
639export default async function(req: Request) {
640// --- Dynamic Imports (Unchanged) ---
641const { OpenAI } = await import("https://esm.town/v/std/openai");
649650// --- Helper: Extract Text using pdf.js-extract (Unchanged) ---
651async function extractPdfTextNative(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> { /* ... original ... */ }
652653// --- Helper Function: Call OpenAI API (Uses APP_CONFIG for model) ---
654async function callOpenAI(
655openai: OpenAI,
656systemPrompt: string,
661/* ... original logic, but use modelFromConfig ... */
662const model = modelFromConfig;
663// ... rest of the original callOpenAI function
664try {
665const response = await openai.chat.completions.create({
678}
679680// --- Helper Function: Traverse References (Optional, could be an agent itself) ---
681// This function is specific. If reference traversal is a common need, keep it.
682// Otherwise, this logic could be part of a dedicated "Reference Traversal Agent".
683// For this template, we'll assume it's a potential fixed post-processing step for a reference agent.
684async function traverseReferences(references: Reference[], log: LogEntry[]): Promise<Reference[]> {
685const agent = "Reference Traversal Agent"; // Fixed name for this specialized step
686// ... original traverseReferences logic ...
697698// --- Main Agent Flow Logic (DYNAMIC based on ANALYSIS_AGENTS) ---
699async function runAgentFlow(
700input: { documentUrl?: string; documentText?: string; documentFile?: File },
701log: LogEntry[],
761if (extractedReferencesForTraversal && extractedReferencesForTraversal.length > 0) {
762log.push({ agent: "System", type: "step", message: "Attempting to verify reference URLs..." });
763// The traverseReferences function logs its own 'final' results for the 'Reference Traversal Agent'
764await traverseReferences(extractedReferencesForTraversal, log);
765} else {
848* Fill in `{{localization_strings_en_json}}` and `{{localization_strings_es_json}}` with all
849* UI text for English and Spanish respectively. Ensure keys match `data-translate` attributes in the HTML
850* and keys used in the JavaScript `translate()` function.
851* Card titles and table headers defined in `ui_display_info` for agents will also need corresponding
852* entries if you want them translated beyond the direct `card_title_en/es` provided (e.g. for dynamic labels within a key_value_pairs display).
862*
863* 6. Deployment:
864* This script is designed to be deployed as a single serverless function (e.g., on Val Town).
865* It serves both the HTML interface and the backend API endpoint.
866*
869* To implement agent chaining (where one agent's output is input to another), you would modify
870* `runAgentFlow` to pass `previousAgentOutput` and update agent prompts to accept/use it (e.g. `{{previous_output}}`).
871* - Advanced UI Rendering: The `renderAgentResult` function provides basic rendering for different data types.
872* For more complex visualizations or interactions, you'd expand this function or add new `display_type` handlers.
873* - Styling: The CSS is extensive. You can customize it directly or by templatizing CSS variables within the `<style>` block.
874* - Error Handling: Server-side and client-side error handling can be further enhanced.
35const app = new Hono();
3637// --- Helper Functions ---
38async function updateJobStatus(jobId: string, status: string, errorMessage?: string) {
39await sqlite.execute({
40sql: `UPDATE jobs SET status = ?, updated_at = ?, error_message = ? WHERE id = ?;`,
43}
4445async function updateLeadStatus(leadId: string, status: string, updates: Partial<Lead> = {}, errorMessage?: string) {
46let sql = `UPDATE leads SET status = ?, updated_at = ?`;
47const args: any[] = [status, new Date().toISOString()];
7778// WARNING: Scraping search engines like DuckDuckGo is fragile and might break.
79async function searchWebsites(searchQuery: string, jobId: string): Promise<{ name: string; url: string }[]> {
80const searchUrl = `https://html.duckduckgo.com/html/?q=${encodeURIComponent(searchQuery)}`;
81console.log(`Searching: ${searchUrl}`);
124}
125126async function extractEmailsFromWebsite(websiteUrl: string, leadId: string): Promise<string | null> {
127console.log(`Scraping ${websiteUrl} for lead ${leadId}`);
128try {
189}
190191async function draftColdEmail(
192openai: OpenAI,
193businessName: string | undefined,
284}
285286async function processJob(jobId: string, searchQuery: string) {
287await updateJobStatus(jobId, "processing_search");
288const openaiApiKey = Deno.env.get("openai");
1export default async function (interval: Interval) {
2
3}
untitled-4502code_attempt13.tsx3 matches
14];
1516function App() {
17const [noClicks, setNoClicks] = useState(0);
18const [isValentine, setIsValentine] = useState(false);
99}
100101function client() {
102createRoot(document.getElementById("root")).render(<App />);
103}
104if (typeof document !== "undefined") { client(); }
105106export default async function server(request: Request): Promise<Response> {
107return new Response(
108`
MiniAppStarterui.tsx8 matches
3import { useEffect, useState } from "https://esm.sh/react@19";
45export function Section({ children, ...props }: any) {
6const sectionClass = `p-5 rounded-3xl bg-neutral-400/15 ${props.className || ""}`;
7return <div class={sectionClass}>{children}</div>;
93};
9495// export function Input(props: any) {
96// const inputClass = "dark:bg-white dark:text-black bg-black text-white rounded-md px-3 py-1 ";
97// return <input class={inputClass} {...props} />;
98// }
99100// export function Button(props: any) {
101// const buttonClass = "dark:bg-white dark:text-black bg-black text-white rounded-md px-3 py-1 ";
102// return <button class={buttonClass} {...props} />;
103// }
104105export function MonoButton(props: any) {
106return (
107<Button {...props}>
111}
112113export function MonoButtonWithStatus(props: any) {
114const [status, setStatus] = useState<any>();
115const handleClick = async () => {
132}
133134export function formatJSON(json: any) {
135return JSON.stringify(json, null, 2);
136}
146};
147148export function BackButton({}) {
149return <ArrowLeft className="w-5 h-5 m-2 cursor-pointer opacity-50" onClick={() => window.location.href = "/"} />;
150}
151152export function ShareButton({ onClick }) {
153return <Share className="w-5 h-5 m-2 cursor-pointer opacity-50" onClick={onClick} />;
154}
MiniAppStarterneynar.ts7 matches
1const baseUrl = "https://api.neynar.com/v2/farcaster/";
23export async function fetchNeynarGet(path: string) {
4const res = await fetch(baseUrl + path, {
5method: "GET",
14}
1516export function fetchUser(username: string) {
17return fetchNeynarGet(`user/by_username?username=${username}`).then(r => r.user);
18}
19export function fetchUsersById(fids: string) {
20return fetchNeynarGet(`user/bulk?fids=${fids}`).then(r => r.users);
21}
2223export function fetchUserFeed(fid: number) {
24return fetchNeynarGet(
25`feed?feed_type=filter&filter_type=fids&fids=${fid}&with_recasts=false&with_replies=false&limit=100&cursor=`,
27}
2829export function fetchChannel(channelId: string) {
30return fetchNeynarGet(`channel?id=${channelId}`).then(r => r.channel);
31}
3233export function fetchChannelFeed(channelId: string) {
34return fetchNeynarGet(
35`feed/channels?channel_ids=${channelId}&with_recasts=false&limit=100`,
37}
3839export function fetchChannelsFeed(channelIds: array) {
40return fetchNeynarGet(
41`feed/channels?channel_ids=${channelIds.join(",")}&with_recasts=false&limit=100`,
MiniAppStarterindex.tsx1 match
35});
3637function generateHtml(baseUrl: string, path: string = "/"): any {
38return (
39<html>
MiniAppStarterimage.tsx4 matches
5import satori from "npm:satori";
67export function handleImageEndpoints(app: Hono) {
8const headers = {
9"Content-Type": "image/png",
18}
1920export async function homeImage() {
21return await ogImage(
22<div tw="w-full h-full flex justify-start items-end text-[100px] bg-black text-white p-[50px]">
31}
3233export async function iconImage() {
34return await ogImage(
35<div tw="w-full h-full flex justify-center items-center text-[100px] bg-black text-white p-[50px]">
45//////////
4647export async function ogImage(body, options = {}) {
48const svg = await satori(
49body,