untitled-2444scriptTypeDetector.ts5 matches
21technical: {
22patterns: [
23/\b(function|class|method|algorithm|implementation|interface|API|SDK)\b/i,
24/\b(code|syntax|compiler|runtime|debug|exception|error|bug|fix)\b/i,
25/\b(database|query|schema|table|index|key|value|record)\b/i,
68* Detect the most likely script type from text
69*/
70export function detectScriptType(text: string): string {
71// Sample the text if it's very long
72const sampleText = text.length > 5000
120* Check if text has screenplay formatting
121*/
122function hasScreenplayFormatting(text: string): boolean {
123// Look for character name pattern (all caps, centered on line)
124const lines = text.split("\n");
140* Check if text has code blocks
141*/
142function hasCodeBlocks(text: string): boolean {
143// Look for code block markers or indented code
144return (
145text.includes("```") ||
146text.includes(" ") ||
147/\b(function|class|const|let|var|import|export)\s+\w+/.test(text)
148);
149}
untitled-2444tokenizer.ts1 match
20"ANGLE ON": 1, "POV": 1, "CLOSE UP": 1, "WIDE SHOT": 1, "MONTAGE": 1,
21// Common programming tokens
22"function": 1, "return": 1, "if": 1, "else": 1, "for": 1, "while": 1, "class": 1,
23"const": 1, "let": 1, "var": 1, "import": 1, "export": 1, "from": 1, "async": 1, "await": 1,
24};
42const openai = new OpenAI();
4344// Helper function to get session from cookies
45async function getSessionFromRequest(c: any) {
46const sessionId = c.req.cookie("session_id");
47if (!sessionId) {
52}
5354// Helper function to set session cookie
55function setSessionCookie(c: any, sessionId: string) {
56c.header("Set-Cookie", `session_id=${sessionId}; Path=/; HttpOnly; SameSite=Lax; Max-Age=2592000`);
57}
Assistantindex.html11 matches
211
212// Initialize the app
213function initApp() {
214if (initialData.isLoggedIn) {
215showMainApp();
274}
275
276function showLoginScreen() {
277loginScreen.classList.remove('hidden');
278mainApp.classList.add('hidden');
279}
280
281function showMainApp() {
282loginScreen.classList.add('hidden');
283mainApp.classList.remove('hidden');
285
286// Load events from the API
287async function loadEvents() {
288try {
289const response = await fetch('/api/events');
307
308// Display events in the UI
309function displayEvents(events) {
310if (events.length === 0) {
311eventsContainer.innerHTML = '<p class="text-center py-8 text-gray-500">No upcoming events</p>';
399
400// Show event details in modal
401function showEventDetails(event) {
402currentEvent = event;
403
479
480// Show reschedule modal
481function showRescheduleModal() {
482eventModal.classList.add('hidden');
483rescheduleModal.classList.remove('hidden');
485
486// Handle event deletion
487async function handleDeleteEvent() {
488if (!currentEvent) return;
489
517
518// Handle event rescheduling
519async function handleRescheduleEvent() {
520if (!currentEvent) return;
521
564
565// Handle assistant request
566async function handleAssistantRequest() {
567const message = assistantInput.value.trim();
568
668
669// Show notification
670function showNotification(message, isError = false) {
671const notification = document.createElement('div');
672notification.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg ${isError ? 'bg-red-500' : 'bg-green-500'} text-white`;
Assistantcalendar.ts10 matches
4const CALENDAR_API_BASE = "https://www.googleapis.com/calendar/v3";
56// Helper function to make authenticated requests to Google Calendar API
7async function makeCalendarRequest(
8session: UserSession,
9endpoint: string,
3637// Get upcoming events from the user's primary calendar
38export async function getUpcomingEvents(
39session: UserSession,
40maxResults = 10,
6869// Get a specific event by ID
70export async function getEvent(
71session: UserSession,
72eventId: string
8182// Create a new calendar event
83export async function createEvent(
84session: UserSession,
85event: Partial<CalendarEvent>
9697// Update an existing calendar event
98export async function updateEvent(
99session: UserSession,
100eventId: string,
112113// Move an event to a new time
114export async function rescheduleEvent(
115session: UserSession,
116eventId: string,
129130// Delete a calendar event
131export async function deleteEvent(
132session: UserSession,
133eventId: string
141142// Search for events matching a query
143export async function searchEvents(
144session: UserSession,
145query: string,
163164// Get available time slots for a given day
165export async function getAvailableTimeSlots(
166session: UserSession,
167date: string, // YYYY-MM-DD
1213// Generate a random state for OAuth security
14export function generateState(): string {
15const array = new Uint8Array(16);
16crypto.getRandomValues(array);
1920// Create the OAuth authorization URL
21export function getAuthUrl(state: string): string {
22if (!GOOGLE_CLIENT_ID) {
23throw new Error("GOOGLE_CLIENT_ID environment variable is not set");
3839// Get the redirect URI based on the current environment
40function getRedirectUri(): string {
41// This will be your Val Town URL
42return `https://${Deno.env.get("VAL_HOSTNAME") || "your-username.val.run"}/auth/callback`;
4445// Exchange authorization code for tokens
46export async function exchangeCodeForTokens(code: string): Promise<UserSession> {
47if (!GOOGLE_CLIENT_ID || !GOOGLE_CLIENT_SECRET) {
48throw new Error("Google OAuth credentials are not set");
9596// Save user session to blob storage
97export async function saveSession(sessionId: string, session: UserSession): Promise<void> {
98await blob.setJSON(`session_${sessionId}`, session);
99}
100101// Get user session from blob storage
102export async function getSession(sessionId: string): Promise<UserSession | null> {
103try {
104return await blob.getJSON(`session_${sessionId}`);
109110// Refresh access token if expired
111export async function refreshAccessToken(session: UserSession): Promise<UserSession> {
112if (!GOOGLE_CLIENT_ID || !GOOGLE_CLIENT_SECRET) {
113throw new Error("Google OAuth credentials are not set");
149150// Generate a session ID cookie
151export function generateSessionId(): string {
152const array = new Uint8Array(16);
153crypto.getRandomValues(array);
156157// Clear user session
158export async function clearSession(sessionId: string): Promise<void> {
159await blob.delete(`session_${sessionId}`);
160}
base_user_codeindex.tsx1 match
4const baseUserCode = baseX("123456789BCDFGHJKLMNPQRSTVWXZ");
56function testCode(userCode = baseUserCode.encode(randomBytes(8))) {
7console.log(userCode, userCode.length);
8}
11* @returns Response with the logs or error message
12*/
13export default async function(req: Request): Promise<Response> {
14try {
15// Get URL parameters
stevensDemogetWeather.ts5 matches
5const TABLE_NAME = `memories`;
67function summarizeWeather(weather: WeatherResponse) {
8const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
9date: day.date,
21}
2223async function generateConciseWeatherSummary(weatherDay) {
24try {
25// Get API key from environment
79}
8081async function deleteExistingForecast(date: string) {
82await sqlite.execute(
83`
89}
9091async function insertForecast(date: string, forecast: string) {
92const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
93108}
109110export default async function getWeatherForecast(interval: number) {
111const weather = await getWeather("New York City, NY");
112console.log({ weather });
untitled-6906Main.tsx6 matches
4const openai = new OpenAI();
56// This function will be the main entry point for the Val
7export default async function handler(req: Request): Promise<Response> {
8const url = new URL(req.url);
9if (req.method === "POST") {
35}
3637// Function to generate the HTML dashboard
38function generateHtml(initialText = "") {
39return `
40<!DOCTYPE html>
189});
190191function appendMessage(text, sender) {
192const message = document.createElement('p');
193message.classList.add('mud-text');
205}
206207async function getOpenAIResponse(command: string): Promise<string> {
208try {
209const completion = await openai.chat.completions.create({