Skip to content

Commit c2d38e6

Browse files
include frontmatter
1 parent 9a69c05 commit c2d38e6

34 files changed

+307
-19
lines changed

check-links.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import asyncio
2+
from playwright.async_api import async_playwright
3+
from urllib.parse import urljoin, urldefrag
4+
from collections import deque
5+
import aiofiles
6+
7+
BASE_URL = "http://localhost:8000"
8+
LOG_FILE = "visited.log"
9+
BROKEN_FILE = "broken-links.txt"
10+
CONTENTS_FILE = "contents.txt"
11+
12+
13+
async def check_page(page, source_url):
14+
url = page.url
15+
html = await page.content()
16+
17+
# Save page content
18+
async with aiofiles.open(CONTENTS_FILE, "a") as f:
19+
await f.write(html)
20+
21+
# Check for 404
22+
if "<h1>404 - Not found</h1>" in html:
23+
async with aiofiles.open(BROKEN_FILE, "a") as f:
24+
await f.write(f"[404] {url} (linked from {source_url})\n")
25+
26+
# Broken image sources
27+
bad_imgs = await page.eval_on_selector_all(
28+
"img[src]",
29+
"""els => els
30+
.map(e => ({ src: e.src, complete: e.complete, naturalWidth: e.naturalWidth }))
31+
.filter(e => !e.complete || e.naturalWidth === 0)
32+
.map(e => e.src)""",
33+
)
34+
if bad_imgs:
35+
async with aiofiles.open(BROKEN_FILE, "a") as f:
36+
for img in bad_imgs:
37+
await f.write(f"[Broken IMG] {img} on {url}\n")
38+
39+
# Check anchor hrefs
40+
anchors = await page.eval_on_selector_all("a[href]", "els => els.map(e => e.href)")
41+
for link in anchors:
42+
link_url, _ = urldefrag(urljoin(url, link))
43+
if not link_url.startswith(BASE_URL):
44+
continue
45+
try:
46+
res = await page.context.request.get(link_url)
47+
if res.status >= 400:
48+
async with aiofiles.open(BROKEN_FILE, "a") as f:
49+
await f.write(
50+
f"[Broken LINK] {link_url} on {url} (status {res.status})\n"
51+
)
52+
except Exception as e:
53+
async with aiofiles.open(BROKEN_FILE, "a") as f:
54+
await f.write(f"[Broken LINK] {link_url} on {url} (error {e})\n")
55+
56+
57+
async def crawl(base_url):
58+
visited = set()
59+
queue = deque([(base_url, "(start)")])
60+
61+
async with async_playwright() as p:
62+
browser = await p.chromium.launch()
63+
context = await browser.new_context()
64+
page = await context.new_page()
65+
66+
async with aiofiles.open(LOG_FILE, "w") as log_file:
67+
while queue:
68+
raw_url, source_url = queue.popleft()
69+
url, _ = urldefrag(raw_url)
70+
71+
if url in visited or not url.startswith(base_url):
72+
continue
73+
visited.add(url)
74+
75+
try:
76+
await page.goto(url)
77+
await check_page(page, source_url)
78+
await log_file.write(url + "\n")
79+
await log_file.flush()
80+
81+
links = await page.eval_on_selector_all(
82+
"a[href]", "els => els.map(e => e.href)"
83+
)
84+
for link in links:
85+
abs_link, _ = urldefrag(urljoin(url, link))
86+
if abs_link.startswith(base_url) and abs_link not in visited:
87+
queue.append((abs_link, url))
88+
89+
except Exception as e:
90+
print(f"Error visiting {url}: {e}")
91+
92+
await browser.close()
93+
94+
95+
if __name__ == "__main__":
96+
asyncio.run(crawl(BASE_URL))

docs/explorer/api/annotations.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Annotations
3+
description: Learn how to annotate traces in Explorer to add context and structure
4+
---
5+
16
# Annotations
27

38
<div class='subtitle'>Learn how to annotate traces in Explorer to add context and structure</div>
@@ -8,7 +13,7 @@ Annotations provide additional context, facilitating collaboration and agent err
813

914
<figure class='wide'>
1015

11-
<img src="site:assets/annotated-trace.png" alt="An annotated trace" style="width: 100%;">
16+
<img src="site:explorer/assets/annotated-trace.png" alt="An annotated trace" style="width: 100%;">
1217

1318
<figcaption>An annotated trace in Explorer</figcaption>
1419

docs/explorer/api/sdk-installation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: SDK Installation
3+
description: Installing the Invariant SDK for Python
4+
---
5+
16
# SDK Installation
27

38
<div class='subtitle'>Installing the Invariant SDK for Python</div>

docs/explorer/api/uploading-traces/file-uploads.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: File Uploads
3+
description: Upload datasets to Explorer via the browser
4+
---
5+
16
# File Uploads
27

38
<div class='subtitle'>Upload datasets to Explorer via the browser</div>
@@ -8,7 +13,7 @@ Apart from API-based uploads, you can also upload datasets to Explorer using the
813

914
To upload a dataset to Explorer, navigate to the [home page](https://explorer.invariantlabs.ai) and click on the `New Dataset` button. This will open the file upload dialog.
1015

11-
![File Upload Dialog](site:assets/explorer-create-dataset.png)
16+
![File Upload Dialog](site:explorer/assets/explorer-create-dataset.png)
1217

1318
Click on the `Choose a File` button and select the dataset file from your local machine. Once the file is selected, click on the `Create` button to start the upload process.
1419

docs/explorer/benchmarks.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Benchmarks
3+
description: Submit your own AI agent to be included in a benchmark comparison
4+
---
5+
16
# Benchmarks
27

38
<div class='subtitle'>Submit your own AI agent to be included in a benchmark comparison</div>
@@ -10,7 +15,7 @@ This document outlines the datasets and benchmarks that are currently available,
1015

1116
A benchmark is a collection of tasks and environment of a particular domain, that can be used to evaluate the performance of an AI agent system. To enable comparison between different AI agents, benchmarks are typically designed to be reproducible and standardized.
1217

13-
To facilitate the comparison of AI agents, Invariant hosts a number of popular benchmarks and respective AI agent results on the <img class='inline-invariant' src="/assets/logo.svg"/> [Invariant Explorer](https://explorer.invariantlabs.ai).
18+
To facilitate the comparison of AI agents, Invariant hosts a number of popular benchmarks and respective AI agent results on the <img class='inline-invariant' src="site:/assets/logo.svg"/> [Invariant Explorer](https://explorer.invariantlabs.ai).
1419

1520
<figure>
1621

docs/explorer/search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Search
3+
description: Use Explorer Search to quickly find and filter traces
4+
---
5+
16
# Search
27

38
<div class='subtitle'>Use Explorer Search to quickly find and filter traces</div>

docs/explorer/self-hosted.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Self-Host Explorer
3+
description: Use the self-hosted version of Explorer for local use
4+
---
5+
16
# Self-Host Explorer
27

38
<div class='subtitle'>Use the self-hosted version of Explorer for local use</div>

docs/gateway/agent-integrations/browser-use.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Browser Use Integration
3+
description: Use Gateway with <code>browser-use</code>
4+
---
5+
16
# Browser Use Integration
27

38
<div class='subtitle'>Use Gateway with <code>browser-use</code></div>

docs/gateway/agent-integrations/microsoft-autogen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: Microsoft AutoGen Integration
3+
description: Integrate Gateway with AutoGen
4+
---
5+
16
# Microsoft AutoGen Integration
27

38
<div class='subtitle'>Integrate Gateway with AutoGen</div>

docs/gateway/agent-integrations/openai-agents-sdk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: OpenAI Agents SDK
3+
description: Use Gateway with the Agents SDK
4+
---
5+
16
# OpenAI Agents SDK
27

38
<div class='subtitle'>Use Gateway with the Agents SDK</div>

0 commit comments

Comments
 (0)