315 };
316 try {
317 const res = await fetch('/api/email',
318 {
319 method: 'POST',
419
420 try {
421 const response = await fetch(\`\${API_BASE_URL}/start\`, {
422 method: 'POST',
423 headers: { 'Content-Type': 'application/json' },
442 const pollJobStatus = async () => {
443 try {
444 const response = await fetch(\`\${API_BASE_URL}/status?jobId=\${jobId}\`);
445 if (!response.ok) throw new Error('Polling failed');
446
144
145#### **Agent Data Integration**
146- **Real-time Agent Updates**: Fetches agent data every 5 seconds when user is authorized
147- **Conditional Display**: Remote support section only appears when agents array has at least one item
148- **Complete Agent Information**: Shows all blob contents including pageId, agents array, lastUpdated, and assignedAt timestamps
149- **Authorization-based**: Only fetches agent data for authorized users (matching email addresses)
150- **Error Handling**: Silent console logging for missing agent data without disrupting user experience
151
196```javascript
197// Internal call from within Val (no authentication needed)
198const response = await fetch('/api/demo/page-id/properties');
199const data = await response.json();
200
2765. **STEP 1: Clear Current Demo Blob** - Immediately clears the agent blob for this demo
2776. **STEP 2: Find New Agents** - Queries agents database by Assigned property
2787. **STEP 3: Collect Agent Data** - Fetches complete agent information and validates
2798. **STEP 4: Clear Agents from Other Demo Blobs** - Removes agents from any other demo blobs to prevent double-assignment
2809. **STEP 5: Update Current Demo Blob** - Stores new agent assignments in the current demo's blob
295**Error Handling & Reliability:**
296- **Transactional Approach**: Collects all required data before making any changes
297- **Early Validation**: Aborts assignment if any agent data cannot be fetched
298- **Atomic Updates**: Critical Notion updates happen together or not at all
299- **Non-Blocking Blob Operations**: Both blob updates and blob clearing are non-blocking
151
152app.onError((err) => Promise.reject(err));
153export default liveReload(lastlogin(app.fetch), import.meta.url);
299 // Make API request
300 async function makeApiRequest(requestData, apiKey) {
301 const response = await fetch('https://integrate.api.nvidia.com/v1/chat/completions', {
302 method: 'POST',
303 headers: {
12 };
13
14 const response = await fetch(`${BASE_URL}/chat/completions`, {
15 method: "POST",
16 headers: {
540 if (version) queryParams.version = version;
541
542 // Fetch servers from the MCP Registry
543 const response = await client.listServers(queryParams);
544
592 );
593 } catch (error) {
594 console.error("Error fetching servers:", error);
595 return c.html(<ErrorPage error={error.message} />, 500);
596 }
627 }
628
629 const response = await fetch(officialUrl.toString(), {
630 headers: {
631 "Accept": "application/json, application/problem+json",
659 }
660
661 const response = await fetch(officialUrl.toString(), {
662 headers: {
663 "Accept": "application/json, application/problem+json",
682app.get("/v0/health", async (c) => {
683 try {
684 const response = await fetch(`${OFFICIAL_REGISTRY}/v0/health`, {
685 headers: {
686 "Accept": "application/json, application/problem+json",
705app.get("/v0/ping", async (c) => {
706 try {
707 const response = await fetch(`${OFFICIAL_REGISTRY}/v0/ping`, {
708 headers: {
709 "Accept": "application/json, application/problem+json",
730 const body = await c.req.json();
731
732 const response = await fetch(`${OFFICIAL_REGISTRY}/v0/publish`, {
733 method: "POST",
734 headers: {
766});
767
768export default app.fetch;
20 }
21
22 const res = await fetch(url);
23 const html = await res.text();
24 const result = await parseAIP(html, url);
27 }
28
29 // 2) Fetch & parse the RSS feed
30 const parser = new Parser();
31 const res = await fetch(RSS_URL, { redirect: "follow" });
32 if (!res.ok) {
33 throw new Error(`RSS fetch failed: ${res.status} ${res.statusText}`);
34 }
35 const xml = await res.text();
22
23async function getAirportsAvinor(cycleStart: string): string {
24 const response = await fetch("https://aim-prod.avinor.no/no/AIP/");
25 const path = new URL(
26 `${cycleStart}-AIRAC/html/eAIP/EN-AD-0.6-en-GB.html`,
43
44async function getAirports(aip) {
45 const respose = await fetch(aip);
46 const html = await respose.text();
47 const doc = (new JSDOM(html)).window.document;