GlancerpollEnabledStatus.ts1 match
1export async function pollEnabledStatus() {
2// this shouldn't run forever just b/c someone forgot to close their browser tab with the demo in it
3const interval = 1000; // 10000;
EnhancedVNodeREADME.md3 matches
1# EnhancedVNode
23A minimalist, plugin-ready hyperscript-style utility for rendering elements with style normalization, class processing, and custom behavioral plugins. Compatible with React, Preact, or any functionally similar createElement.
45## โจ Features
67- ๐งฑ Lightweight functional interface: const h = new EnhancedVNode(createElement)
8- ๐จ Normalizes class strings into Set and filters empty entries
9- ๐๏ธ Parses inline style into clean JS objects
46## ๐ Plugins
4748Plugins are just functions that receive and mutate the props object before rendering:
4950```js
11import {registerPrompts} from "./prompts/promptsTools.ts"
1213export function registerTools(
14server: McpServer,
15config: Config,
29}
3031export function registerPromptsTools(server: McpServer, config: Config) {
32registerPrompts(server, config)
33}
23- Respond in a friendly and concise manner
24- Ask clarifying questions when requirements are ambiguous
25- Provide complete, functional solutions rather than skeleton implementations
26- Test your logic against edge cases before presenting the final solution
27- Ensure all code follows Val Town's specific platform requirements
36- **Never bake in secrets into the code** - always use environment variables
37- Include comments explaining complex logic (avoid commenting obvious operations)
38- Follow modern ES6+ conventions and functional programming practices where appropriate
3940### Val Town Utility Functions
4142Val Town provides several utility functions to help with common project tasks. These utilities handle file management, project information, and testing.
4344### Importing Utilities
90{
91name: "should add numbers correctly",
92function: () => {
93expect(1 + 1).toBe(2);
94},
174โ โโโ database/
175โ โ โโโ migrations.ts # Schema definitions
176โ โ โโโ queries.ts # DB query functions
177โ โ โโโ README.md
178โ โโโ index.ts # Main entry point
190โโโ shared/
191โโโ README.md
192โโโ utils.ts # Shared types and functions
193```
194196- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
197- Main entry point should be `backend/index.ts`
198- **Static asset serving:** Use the utility functions to read and serve project files:
199```ts
200// Use the serveFile utility to handle content types automatically
237- Run migrations on startup or comment out for performance
238- Change table names when modifying schemas rather than altering
239- Export clear query functions with proper TypeScript typing
240- Follow the queries and migrations pattern from the example
241
val-town-http-mcp-servervalley.txt11 matches
10- **Never bake in secrets into the code** - always use environment variables
11- Include comments explaining complex logic (avoid commenting obvious operations)
12- Follow modern ES6+ conventions and functional programming practices if possible
1314## Types of triggers
2122```ts
23export default async function (req: Request) {
24return new Response("Hello World");
25}
3536```ts
37export default async function () {
38// Scheduled task code
39}
4950```ts
51export default async function (email: Email) {
52// Process email
53}
58## Val Town Standard Libraries
5960Val Town provides several hosted services and utility functions.
6162### Blob Storage
112```
113114## Val Town Utility Functions
115116Val Town provides several utility functions to help with common project tasks.
117118### Importing Utilities
191โ โโโ database/
192โ โ โโโ migrations.ts # Schema definitions
193โ โ โโโ queries.ts # DB query functions
194โ โ โโโ README.md
195โ โโโ routes/ # Route modules
210โโโ shared/
211โโโ README.md
212โโโ utils.ts # Shared types and functions
213```
214217- Hono is the recommended API framework
218- Main entry point should be `backend/index.ts`
219- **Static asset serving:** Use the utility functions to read and serve project files:
220```ts
221import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
251- Run migrations on startup or comment out for performance
252- Change table names when modifying schemas rather than altering
253- Export clear query functions with proper TypeScript typing
254255## Common Gotchas and Solutions
val-town-http-mcp-servertownie.txt17 matches
101. `http`: http vals export a default server request handler.
112. `script`: script vals can be imported into other vals, similar to an npm package.
123. `cron`: cron vals export a function that can automatically run at user-set intervals, similar to a cron command.
134. `email`: email vals export a function that runs when its associated email address receives an email.
1415Follow these requirements for Val Town when generating code.
49</requirements>
5051If the user asks for specific functionality, the Val Town standard library includes the following:
5253<libraries>
63```
6465Blob storage only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
66`const { blob } = await import("https://esm.town/v/std/blob");`
67</library>
78If you are changing a SQLite table's schema, you should also change the table's name so it creates a fresh table, ie by adding _2 or _3 after it everywhere. Ensure that tables are created before they are used.
7980SQLite storage only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
81`const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");`
82</library>
99```
100101OpenAI only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
102`const { OpenAI } = await import "https://esm.town/v/std/openai");`
103</library>
113```
114115Email only works on the server. If the val includes client-side code, use dynamic imports to import this module in the server function, e.g.:
116`const { email } = await import "https://esm.town/v/std/email");`
117</library>
131Write the code in ```val code fences.
132Include the val type as metadata on the code fence, e.g.: ```val type=script
133If this is a new val, decide what val type is appropriate based on the user's prompt. Default to choosing http type vals unless the user has requested specific functionality that requires a different type.
134135* If the user requests diff format in their prompt, follow these steps:
157* Use fetch to communicate with the backend server portion.
158*/
159function App() {
160return (
161<div>
167/**
168* Client-only code
169* Any code that makes use of document or window should be scoped to the `client()` function.
170* This val should not cause errors when imported as a module in a browser.
171*/
172function client() {
173createRoot(document.getElementById("root")).render(<App />);
174}
177/**
178* Server-only code
179* Any code that is meant to run on the server should be included in the server function.
180* This can include endpoints that the client side component can send fetch requests to.
181*/
182export default async function server(request: Request): Promise<Response> {
183/** If needed, blob storage or sqlite can be imported as a dynamic import in this function.
184* Blob storage should never be used in the browser directly.
185* Other server-side specific modules can be imported in a similar way.
232```val type=script
233/** Use this template for creating script vals only */
234export default function () {
235return "Hello, world";
236}
243```val type=cron
244/** Use this template for creating cron vals only */
245export default async function (interval: Interval) {
246// code will run at an interval set by the user
247console.log(`Hello, world: ${Date.now()}`);
270// The email address for this val will be `<username>.<valname>@valtown.email` which can be derived from:
271// const emailAddress = new URL(import.meta.url).pathname.split("/").slice(-2).join(".") + "@valtown.email";
272export default async function (e: Email) {
273console.log("Email received!", email.from, email.subject, email.text);
274}
6## Understanding Val Town
78Val Town is a platform for writing, running, and deploying JavaScript/TypeScript code in the cloud. It functions as a social coding environment where users can create and share code that runs on Val Town's serverless infrastructure.
910### Val Town Projects
21## Core Guidelines
2223- Provide complete, functional solutions
24- Test logic against edge cases
25- Follow Val Town's platform requirements
26- Write clean, maintainable TypeScript/TSX code
27- Add appropriate TypeScript types for all data structures
28- Prefer functional programming practices where appropriate
2930## Coding Requirements
89// Register prompt capabilities with server
10export function registerPrompts(server: McpServer, _config: Config) {
11// Townie prompt
12server.prompt(
5import {getErrorMessage} from "../lib/errorUtils.ts"
67export function registerSqliteTools(server: McpServer, config: Config) {
8// Execute SQL
9server.tool(
64)
6566// Fix for sqlite-query function
67server.tool(
68"sqlite-query",
91)
9293// Fix for sqlite-exec function
94server.tool(
95"sqlite-exec",
6import {z} from "npm:zod"
78export function registerValTools(server: McpServer, config: Config) {
9// Get val by username and val name
10server.tool(