OpenTownie_jacksonuseThreads.tsx5 matches
10const [error, setError] = useState(null);
1112const fetchData = async () => {
13try {
14const res = await fetch(ENDPOINT, {
15headers: {
16"Authorization": "Bearer " + token,
18});
19const data = await res.json();
20console.log("useThreads fetchData", { res, data });
21if (!res.ok) {
22console.error(data);
3940useEffect(() => {
41fetchData();
42}, []);
4344return { data, loading, error, refetch: fetchData };
45}
OpenTownie_jacksonindex.ts1 match
2526// This is the entry point for HTTP vals
27export default app.fetch;
OpenTownie_jacksonsend-message.ts3 matches
100}
101102// If there are selected files, fetch their content and add them to the messages
103if (selectedFiles && selectedFiles.length > 0) {
104try {
118fileContents += `## File: ${filePath}\n\`\`\`\n${fileWithLinesNumbers(content)}\n\`\`\`\n\n`;
119} catch (error) {
120console.error(`Error fetching file ${filePath}:`, error);
121fileContents += `## File: ${filePath}\nError: Could not fetch file content\n\n`;
122}
123}
live-reloadutils.ts3 matches
93}
94/**
95* Creates a wrapper around a fetch handler that injects an HTML string
96* into the document. It first checks for a <body> tag; if missing,
97* it looks for an <html> tag. If neither are present, it appends to
98* the full text response.
99*
100* @param handler The original fetch handler function
101* @param html The HTML content to inject
102* @returns A new fetch handler with HTML rewriting
103*/
104export function injectHTML(
live-reloadclient.ts2 matches
6*/
7async function registerLongPoll({ pageLoadedAt }: { pageLoadedAt: number }) {
8const { lastUpdatedAt, status } = await (await fetch("/__lastUpdatedAt")).json();
9if (lastUpdatedAt > pageLoadedAt) {
10window.location.href = `https://reload.val.run?${new URLSearchParams({ url: window.location.href })}`;
28return;
29}
30const resp = await fetch(targetURL);
31if (resp.ok) {
32window.location.href = targetURL;
live-reload-demomain.tsx1 match
1516// Enable live reloading
17export default liveReload(app.fetch, import.meta.url);
4import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from "npm:node-html-markdown";
56const html = await fetch("https://github.com/trending").then(r => r.text());
78const { window: { document } } = new JSDOM(html);
2526try {
27const response = await fetch(window.location.href, {
28method: "POST",
29body: formData,
sqliteExplorerAppmain.tsx4 matches
1/** @jsxImportSource npm:hono/jsx **/
23import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
2// A more declarative and extensible multi-agent platform structure.
34import { fetch } from "https://esm.town/v/std/fetch"; // Assuming Val Town environment
56// --- Core Interfaces ---
296}
297298// Agent 2: Fetch External Data (modified for new signature)
299async function fetchAgent(
300input: AgentInput<{ url?: string }>, // Optionally allow URL via input
301context: AgentContext,
305const url = payload?.url || "https://jsonplaceholder.typicode.com/todos/1"; // Default URL
306307log('INFO', 'FetchAgent', `Start fetching data from ${url}`);
308try {
309const resp = await fetch(url);
310if (!resp.ok) {
311throw new Error(`Workspace failed: Server responded with status ${resp.status} ${resp.statusText}`);
313const data = await resp.json();
314315log('SUCCESS', 'FetchAgent', `Data fetched successfully`, { url, responseStatus: resp.status });
316return { mandateId, correlationId: taskId, payload: { data } };
317} catch (e: any) {
318log('ERROR', 'FetchAgent', `Workspaceing failed`, e);
319return { mandateId, correlationId: taskId, payload: { data: null }, error: e.message };
320}
325const analysisWorkflow: WorkflowDefinition = {
326id: "basicAnalysis",
327description: "Summarizes user text and fetches placeholder data.",
328steps: [
329{
335},
336{
337id: "step2_fetchData",
338agent: "fetcher",
339// No input mapping needed if the agent uses defaults or doesn't require specific input from workflow state
340input: {} // Explicitly empty
345outputMapping: { // Define the final output structure
346finalSummary: { source: "step1_summarize", field: "summary" },
347externalData: { source: "step2_fetchData", field: "data"},
348}
349};
358// Register agents
359agentRegistry.register("summarizer", summarizerAgent);
360agentRegistry.register("fetcher", fetchAgent);
361// Register more agents...
362// agentRegistry.register("sentimentAnalyzer", sentimentAgent);
410411try {
412const res = await fetch(window.location.pathname, {
413method: 'POST',
414headers: { 'Content-Type': 'application/json' },
430431} catch (err) {
432resultBox.textContent = 'Fetch Error: ' + err.message;
433resultBox.className = 'error';
434logBox.textContent = 'Failed to communicate with the backend.';