6 * @returns Promise resolving to complete buffer of stdin data
7 */
8export async function readStdinToBuffer(): Promise<Uint8Array> {
9 try {
10 const buf = new Uint8Array(1024);
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
6const LOCAL_TIMEZONE = "America/New_York";
7
8async function deleteExistingCalendarEvents() {
9 await sqlite.execute(
10 `
15}
16
17// Helper function to extract time from ISO string without timezone conversion
18function extractTimeFromISO(isoString) {
19 // Match the time portion of the ISO string
20 const timeMatch = isoString.match(/T(\d{2}):(\d{2}):/);
31}
32
33function formatEventToNaturalLanguage(event) {
34 const summary = event.summary || "Untitled event";
35
83}
84
85async function insertCalendarEvent(date, eventText) {
86 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
87
97}
98
99export default async function getCalendarEvents() {
100 try {
101 const events = await getEvents(
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [svgUrl, setSvgUrl] = useState("");
7 const [svgContent, setSvgContent] = useState("");
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<App />);
107}
111}
112
113export default async function server(request: Request): Promise<Response> {
114 return new Response(`
115 <!DOCTYPE html>
12
13// enrichit un record chiffré depuis la BDD en objet Memory
14function unwrap(record: any): Memory {
15 const { id, date, createdBy, createdDate, owner } = record;
16 const { text, tags } = decrypt(record.text, record.tags);
2
3// Helper pour convertir hex ↔ bytes
4function hexToBytes(hex: string): Uint8Array {
5 const bytes = new Uint8Array(hex.length / 2);
6 for (let i = 0; i < bytes.length; i++) {
9 return bytes;
10}
11function bytesToBase64(bytes: Uint8Array): string {
12 let s = "";
13 for (const b of bytes) s += String.fromCharCode(b);
14 return btoa(s);
15}
16function base64ToBytes(b64: string): Uint8Array {
17 const str = atob(b64);
18 const bytes = new Uint8Array(str.length);
38
39// Encrypt & Decrypt
40export async function encrypt(input: {
41 text: string;
42 tags: string[];
71}
72
73export function decrypt(
74 cipherText: string,
75 cipherTags: string,
82}
83
84export async function decryptAsync(
85 cipherText: string,
86 cipherTags: string,
12`.trim();
13
14function generateWeekDays(today: DateTime): string {
15 const lines = [];
16 lines.push(`* Today: ${today.toFormat("EEEE, MMMM d")}`);
22}
23
24async function generateBriefingContent(
25 openai: OpenAI,
26 memories: unknown[],
62}
63
64export async function sendDailyBriefing(
65 chatId?: string,
66 overrideToday?: DateTime,
3import { sendDailyBriefing } from "./sendDailyBrief.ts";
4
5async function testDailyBrief() {
6 const chatId = Deno.env.get("TELEGRAM_CHAT_ID");
7 if (!chatId) {
11 * @returns Array of previous fun facts
12 */
13async function getPreviousFunFacts() {
14 try {
15 const result = await sqlite.execute(
32 * @param dates Array of date strings in ISO format
33 */
34async function deleteExistingFunFacts(dates) {
35 try {
36 for (const date of dates) {
51 * @param factText The fun fact text
52 */
53async function insertFunFact(date, factText) {
54 try {
55 await sqlite.execute(
75 * @returns Array of generated fun facts
76 */
77async function generateFunFacts(previousFacts) {
78 try {
79 // Get API key from environment
197 * @returns Array of parsed facts
198 */
199function parseFallbackFacts(responseText, expectedDates) {
200 // Try to extract facts using regex
201 const factPattern = /(\d{4}-\d{2}-\d{2})["']?[,:]?\s*["']?(.*?)["']?[,}]/gs;
260
261/**
262 * Main function to generate and store fun facts for the next 7 days
263 */
264export async function generateAndStoreFunFacts() {
265 try {
266 // Get previous fun facts
301 * Intended to be used as a Val Town cron job
302 */
303export default async function() {
304 console.log("Running fun facts generation cron job...");
305 return await generateAndStoreFunFacts();
6const LOCAL_TIMEZONE = "America/New_York";
7
8async function deleteExistingCalendarEvents() {
9 await sqlite.execute(
10 `
15}
16
17// Helper function to extract time from ISO string without timezone conversion
18function extractTimeFromISO(isoString) {
19 // Match the time portion of the ISO string
20 const timeMatch = isoString.match(/T(\d{2}):(\d{2}):/);
31}
32
33function formatEventToNaturalLanguage(event) {
34 const summary = event.summary || "Untitled event";
35
83}
84
85async function insertCalendarEvent(date, eventText) {
86 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
87
97}
98
99export default async function getCalendarEvents() {
100 try {
101 const events = await getEvents(
A helper function to build a file's email
Simple functional CSS library for Val Town
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": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.