203 prompts.push({
204 name: "server-test",
205 description: "Test system functionality",
206 arguments: [
207 {
7 * 默认 lang=en, format=json
8 */
9export default async function server(request: Request): Promise<Response> {
10 const { searchParams } = new URL(request.url);
11
60/* ---------- 工具函数 ---------- */
61
62function txt(msg: string, status = 200) {
63 return new Response(msg, {
64 status,
68
69/** 提取 11 位 videoId(与你之前的逻辑一致) */
70function extractVideoId(url: string): string | null {
71 const regex =
72 /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
76
77/** 把 transcript 数组转成 SRT 字符串 */
78function toSRT(items: { text: string; offset: number; duration: number }[]) {
79 const pad = (n: number, z = 2) => String(n).padStart(z, "0");
80
21 )`);
22
23// Function to parse a single post div and extract review data
24function parsePostDiv(postHtml: string, songIndex: number) {
25 const reviews: Array<{
26 song_index: number;
104}
105
106// Function to find all post divs in the HTML
107function findPostDivs(html: string): string[] {
108 const postDivs: string[] = [];
109
1export default async function (e: Email) {
2
3}
1// export default async function(req: Request): Promise<Response> {
2// return Response.json({ ok1: Deno.cwd() });
3// }
5// import { serveDir } from "jsr:@std/http/file-server";
6
7// export default async function(req: Request): Promise<Response> {
8// return serveDir(req, {
9// fsRoot: "public",
7// export const ogImageUrl = "https://imgur.com/xKVOVUE.png";
8
9export function embedMetadata(baseUrl: string, path: string = "/") {
10 return {
11 version: "next",
24}
25
26export function handleFarcasterEndpoints(app: Hono) {
27 app.get("/.well-known/farcaster.json", (c) => {
28 const baseUrl = c.req.url.replace(c.req.path, "");
91const decodeBase64Json = (str: string) => JSON.parse(Buffer.from(str, "base64").toString("utf-8"));
92
93async function sendWelcomeNotification(fid: number, baseUrl: string) {
94 return await sendNotificationToUser(fid, {
95 title: name + " installed!",
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function ValTownLogo () {
4 return (
5 <svg
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;
7 *
8 * @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9 * @returns {Object} An object containing containerRef and scrollToBottom function
10 */
11export function useScrollToBottomContainer(dependencies = []) {
12 const containerRef = useRef(null);
13
28
29// body scroll version
30export function useScrollToBottom(dependencies = []) {
31 const bottomRef = useRef(null);
32
Simple functional CSS library for Val Town
A helper function to build a file's email
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.