25
26 try {
27 const response = await fetch('/api/jobs', {
28 method: 'POST',
29 headers: {
10 const [error, setError] = useState<string | null>(null);
11
12 const fetchJobs = async () => {
13 try {
14 setLoading(true);
15 const response = await fetch('/api/jobs');
16 const result: ApiResponse<Job[]> = await response.json();
17
20 setError(null);
21 } else {
22 setError(result.error || 'Failed to fetch jobs');
23 }
24 } catch (err) {
25 setError('Network error while fetching jobs');
26 } finally {
27 setLoading(false);
40
41 try {
42 const response = await fetch(`/api/jobs/${jobId}`, {
43 method: 'DELETE'
44 });
64
65 useEffect(() => {
66 fetchJobs();
67 }, []);
68
97 <p className="text-red-800">โ ๏ธ {error}</p>
98 <button
99 onClick={fetchJobs}
100 className="text-red-600 hover:text-red-800 underline mt-2"
101 >
17 const response: ApiResponse<ChatMessage[]> = {
18 success: false,
19 error: "Failed to fetch messages"
20 };
21 return c.json(response, 500);
17 const response: ApiResponse<Job[]> = {
18 success: false,
19 error: "Failed to fetch jobs"
20 };
21 return c.json(response, 500);
15
16 useEffect(() => {
17 fetchOrders();
18 }, []);
19
20 const fetchOrders = async () => {
21 try {
22 const response = await fetch('/api/orders');
23 const result = await response.json();
24 if (result.success) {
26 }
27 } catch (error) {
28 console.error('Error fetching orders:', error);
29 } finally {
30 setLoading(false);
29 const feedTypes = ['Fish Feed', 'Poultry Feed'] as const;
30
31 // Fetch products on component mount
32 useEffect(() => {
33 fetchProducts();
34 }, []);
35
39 }, [formData.productCategory, formData.fishType, formData.productForm, formData.poultryType, formData.eggType, formData.feedType]);
40
41 const fetchProducts = async () => {
42 try {
43 const response = await fetch('/api/products');
44 const result: ApiResponse<Product[]> = await response.json();
45 if (result.success && result.data) {
47 }
48 } catch (error) {
49 console.error('Failed to fetch products:', error);
50 }
51 };
110
111 try {
112 const response = await fetch('/api/orders', {
113 method: 'POST',
114 headers: {
137
138 // Refresh products to get updated stock
139 await fetchProducts();
140
141 // Scroll to top to show success message
1import { Hono, Context } from 'npm:hono';
2import { SSETransport } from 'npm:hono-mcp-server-sse-transport';
3import { toFetchResponse, toReqRes } from "npm:fetch-to-node";
4import { z } from "npm:zod";
5import lunr from "https://cdn.skypack.dev/lunr";
197
198 try {
199 console.log("Fetching site contents...");
200 const [searchData, proverbs] = await Promise.all([
201 fetch("https://www.joshbeckman.org/assets/js/SearchData.json").then((res) => res.json()),
202 fetch("https://www.joshbeckman.org/assets/js/proverbs.json").then((res) => res.json())
203 ]);
204 const db: Array<Post> = Object.values(searchData).filter(postFilter).map((post) => {
215 const index = buildIndex(searchData);
216 const tagsIndex = buildTagsIndex(tags);
217 console.log("Successfully fetched site contents");
218
219 console.log("Registering tools...");
403 });
404
405 return toFetchResponse(res);
406 } catch (e) {
407 console.error(e);
454 * This will be exposed as a Val.town HTTP endpoint
455 */
456export default app.fetch;
457
5import { AnthropicStreamEvent, MCPPrompt } from "../../shared/types.ts";
6import useAnthropicStream from "../hooks/useAnthropicStream.tsx";
7import { fetchMCPPromptsWithCache } from "../utils/mcpPrompts.ts";
8import { AppConfig, Message } from "./App.tsx";
9import CommandPalette from "./CommandPalette.tsx";
106 }, [input]);
107
108 /* fetch MCP prompts when config changes */
109 useEffect(() => {
110 const fetchPrompts = async () => {
111 try {
112 const result = await fetchMCPPromptsWithCache(config.mcpServers);
113
114 if (result.success) {
116 setPrompts(result.prompts);
117 } else {
118 console.warn("Failed to fetch MCP prompts:", result.error);
119 // Keep existing prompts on error
120 }
121 } catch (error) {
122 console.warn("Failed to fetch MCP prompts:", error);
123 // Keep existing prompts on error
124 }
126
127 if (config.mcpServers.some(s => s.enabled && s.url)) {
128 fetchPrompts();
129 } else {
130 // If no servers are enabled, just show the built-in test prompt
24- **Structured display of MCP tool calls and results** to prevent truncation
25- **Frontend MCP server testing** - test button for each MCP server with visual status indicators (โ
/โ)
26- **Frontend MCP prompt fetching** - prompts are fetched directly from MCP servers with caching support
27
28## Streaming Implementation
54โ โโโ utils/
55โ โ โโโ mcpTesting.ts # Frontend MCP server testing
56โ โ โโโ mcpPrompts.ts # Frontend MCP prompt fetching
57โ โโโ style.css # Custom styles with streaming animations
58โโโ shared/
75- `GET /shared/*` - Shared utility files
76
77**Note**: MCP server testing and prompt fetching are now handled directly on the frontend for improved performance and reduced server load.
78
79## Usage
64
65 try {
66 const response = await fetch(server.url, {
67 method: "POST",
68 headers,
97 };
98 }
99 } catch (fetchError: any) {
100 clearTimeout(timeoutId);
101
102 if (fetchError.name === "AbortError") {
103 return {
104 success: false,
107 }
108
109 throw fetchError;
110 }
111 } catch (error: any) {