1import { LoaderFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { getTopicById, getMessageById, getMessagesByTopicId } from "../backend/database/queries.ts";
3
4export async function loader({ params }: LoaderFunctionArgs) {
5 const topicId = parseInt(params.topicId!, 10);
6 const messageId = parseInt(params.messageId!, 10);
4import { LoadingSpinner } from "./LoadingSpinner.tsx";
5
6export function SearchForm() {
7 const navigation = useNavigation();
8 const [searchParams] = useSearchParams();
1import { ActionFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { createMessage } from "../backend/database/queries.ts";
3
4export async function action({ request }: ActionFunctionArgs) {
5 console.log("HERE!");
6 const formData = await request.formData();
5import { SearchForm } from "../frontend/components/SearchForm.tsx";
6
7export function Search() {
8 const { topics, messages, query } = useLoaderData() as SearchResultsType;
9 const hasResults = topics.length > 0 || messages.length > 0;
10}
11
12export function MessageList({ messages, topicId, highlightedMessageId }: MessageListProps) {
13 const location = useLocation();
14
5import { SearchForm } from "./SearchForm.tsx";
6
7export function SearchResults() {
8 const { topics, messages, query } = useLoaderData() as SearchResultsType;
9 const hasResults = topics.length > 0 || messages.length > 0;
6}
7
8export function LoadingSpinner({ size = "medium" }: LoadingSpinnerProps) {
9 const sizeClasses = {
10 small: "w-4 h-4 border-2",
12}
13
14export function MessageForm({ topicId }: MessageFormProps) {
15 const navigation = useNavigation();
16 const isSubmitting = navigation.state === "submitting";
18
19 // reset the form on success
20 React.useEffect(function() {
21 if (navigation.state === "idle" && $form.current) {
22 $form.current.reset();
22 * Uses a cached instance if available
23 */
24export async function setupMcpServer(): Promise<McpServer> {
25 // Return cached instance if available
26 if (mcpServerInstance) {
72 * Registers a GET endpoint as an MCP Resource
73 */
74function registerResource(
75 server: McpServer,
76 operationId: string,
162 * Registers a POST, PUT, or DELETE endpoint as an MCP Tool
163 */
164function registerTool(
165 server: McpServer,
166 operationId: string,
275 * Creates a parameter schema from an OpenAPI parameter
276 */
277function createParameterSchema(param: any): any {
278 const schema: any = {
279 type: param.schema?.type || 'string',
321
322/**
323 * Overrides the default handlePostMessage function to add the Authorization header to the request body
324 */
325export async function handlePostMessage(transport: SSETransport, context: Context): Promise<Response> {
326 try {
327 const contentType = context.req.header('content-type') || '';
55
56/**
57 * Val.town handler function for HTTP requests
58 * This will be exposed as a Val.town HTTP endpoint
59 */
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.