2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function createMemoriesTable() {
5 console.log("Creating memories table...");
6
31}
32
33// Run the function immediately
34createMemoriesTable();
1## Get An Email File's Email
2
3This helper function will construct your file's email if you pass it the file's `import.meta.url`.
4
5### Example Usage
7import { getFileEmail } from "https://esm.town/v/shouser/getFileEmail/main.tsx"
8
9export default async function(e: Email) {
10 const email = await getFileEmail(import.meta.url);
11}
4const vt = new ValTown();
5
6async function getFileId(author: string, name: string, filePath: string) {
7 const project = await vt.alias.username.projectName.retrieve(author, name);
8 const file = await vt.projects.files.retrieve(project.id, { path: filePath });
10}
11
12function extractFilePath(url: string) {
13 const regex = /[^/]+@[^/]+\/(.+)$/;
14 const match = url.match(regex);
22
23// Pass in import.meta.url here
24export async function getFileEmail(url: string) {
25 const { author, name } = extractValInfo(url);
26 const filePath = extractFilePath(url);
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3export default async function checkMemoriesTable() {
4 try {
5 // Query to check if the table exists in SQLite
1export default async function() {
2 const token = process.env.TELEGRAM_TOKEN;
3 const response = await fetch(`https://api.telegram.org/bot${token}/getWebhookInfo`);
1export default async function() {
2 const token = process.env.TELEGRAM_TOKEN; // Make sure this environment variable exists
3 const webhookUrl = "https://greasegum--72ebd4b2582846bf9261128d453e441c.web.val.run";
36 * Store a chat message in the database
37 */
38export async function storeChatMessage(
39 chatId,
40 senderId,
69 * Retrieve chat history for a specific chat
70 */
71export async function getChatHistory(chatId, limit = 50) {
72 try {
73 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
94 * Format chat history for Anthropic API
95 */
96function formatChatHistoryForAI(history) {
97 const messages = [];
98
118 * Analyze a Telegram message and extract memories from it
119 */
120async function analyzeMessageContent(
121 anthropic,
122 username,
499
500// Handle webhook requests
501export default async function (req: Request): Promise<Response> {
502 // Set webhook if it is not set yet
503 if (!isEndpointSet) {
5const TABLE_NAME = `memories`;
6
7function summarizeWeather(weather: WeatherResponse) {
8 const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
9 date: day.date,
21}
22
23async function generateConciseWeatherSummary(weatherDay) {
24 try {
25 // Get API key from environment
79}
80
81async function deleteExistingForecast(date: string) {
82 await sqlite.execute(
83 `
89}
90
91async function insertForecast(date: string, forecast: string) {
92 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
93
108}
109
110export default async function getWeatherForecast(interval: number) {
111 const weather = await getWeather("Copake Falls, NY");
112 console.log({ weather });
10}
11
12function Tooltip({ children, content }: TooltipProps) {
13 const [isVisible, setIsVisible] = useState(false);
14 const tooltipRef = useRef<HTMLDivElement>(null);
49}
50
51function formatBytes(bytes: number, decimals = 2) {
52 if (bytes === 0) return "0 Bytes";
53 const k = 1024;
58}
59
60function copyToClipboard(text: string) {
61 navigator.clipboard.writeText(text).then(() => {
62 console.log("Text copied to clipboard");
66}
67
68function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
69 const [isOpen, setIsOpen] = useState(false);
70 const menuRef = useRef(null);
73
74 useEffect(() => {
75 function handleClickOutside(event) {
76 if (menuRef.current && !menuRef.current.contains(event.target)) {
77 event.stopPropagation();
155}
156
157function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
158 const [isLoading, setIsLoading] = useState(false);
159 const decodedKey = decodeURIComponent(blob.key);
216}
217
218function App({ initialEmail, initialProfile, sourceURL }) {
219 const encodeKey = (key: string) => encodeURIComponent(key);
220 const decodeKey = (key: string) => decodeURIComponent(key);
4
5// Simplified UI components
6function Card({ children, onClick, className }) {
7 return (
8
12}
13
14function Button({ children, onClick, variant, disabled }) {
15 const variantStyles = {
16 "destructive": "bg-red-500 text-white",
29}
30
31function Input({ value, onChange, placeholder }) {
32 return (
33 <input
41}
42
43function Badge({ children, color = "blue" }) {
44 const colorVariants = {
45 blue: "bg-blue-100 text-blue-800",
106};
107
108function App() {
109 const [selectedSenior, setSelectedSenior] = useState(null);
110 const [chat, setChat] = useState("");
396}
397
398function client() {
399 createRoot(document.getElementById("root")).render(<App />);
400}
401if (typeof document !== "undefined") { client(); }
402
403export default async function server(request: Request): Promise<Response> {
404 // Dynamic import for blob to ensure server-side only
405 const { blob } = await import("https://esm.town/v/std/blob");