@@ -16,8 +16,12 @@ This guide provides comprehensive instructions for developing AI agents using th
1616``` typescript
1717import type { AgentRequest , AgentResponse , AgentContext } from " @agentuity/sdk" ;
1818
19- export default async function Agent(req : AgentRequest , resp : AgentResponse , ctx : AgentContext ) {
20- return resp .json ({hello: ' world' });
19+ export default async function Agent(
20+ req : AgentRequest ,
21+ resp : AgentResponse ,
22+ ctx : AgentContext ,
23+ ) {
24+ return resp .json ({ hello: " world" });
2125}
2226```
2327
@@ -31,7 +35,7 @@ The main handler function type for an agent:
3135type AgentHandler = (
3236 request : AgentRequest ,
3337 response : AgentResponse ,
34- context : AgentContext
38+ context : AgentContext ,
3539) => Promise <AgentResponseType >;
3640```
3741
@@ -107,4 +111,152 @@ Access through `context.logger`:
107111- Use the storage APIs for persisting data
108112- Consider agent communication for complex workflows
109113
110- For complete documentation, visit: https://agentuity.dev/SDKs/javascript/api-reference
114+ ## 6. How to use the documentation site, its APIs, etc.
115+
116+ The Agentuity documentation site provides API endpoints that AI agents can use to search and read documentation programmatically.
117+
118+ For the complete docs: https://agentuity.dev
119+ The public repo markdown files are here: https://github.com/agentuity/docs/tree/main/content
120+ For complete JS SDK documentation, visit: https://agentuity.dev/SDKs/javascript/api-reference
121+
122+ With that in mind, here are some helpful things you can do to find the right doc information:
123+
124+ ** Base URL:** ` https://agentuity.dev `
125+
126+ ### Quick Reference
127+
128+ ``` bash
129+ # Set base URL once per session
130+ BASE=" https://agentuity.dev"
131+
132+ # Ask a question (AI-powered with RAG)
133+ curl -sG " $BASE /api/rag-search" --data-urlencode " query=How do I create an agent?"
134+
135+ # Search documentation (keyword search)
136+ curl -sG " $BASE /api/search" --data-urlencode " query=environment variables"
137+
138+ # Read full page content
139+ curl -sG " $BASE /api/page-content" --data-urlencode " path=Introduction/getting-started"
140+ ```
141+
142+ ### API Endpoints
143+
144+ #### 1. RAG Search (Recommended for Questions)
145+
146+ ** Use when:** You have a natural-language question and want an AI-generated answer with supporting documentation.
147+
148+ ``` bash
149+ curl -sG " https://agentuity.dev/api/rag-search" \
150+ --data-urlencode " query=How do I use KV?"
151+ ```
152+
153+ ** Response Format:**
154+
155+ ``` json
156+ [
157+ {
158+ "id" : " ai-answer-..." ,
159+ "url" : " #ai-answer" ,
160+ "title" : " AI Answer" ,
161+ "content" : " AI-generated answer to your question..." ,
162+ "type" : " ai-answer"
163+ },
164+ {
165+ "id" : " doc-..." ,
166+ "url" : " /getting-started/installation" ,
167+ "title" : " Installation Guide" ,
168+ "content" : " Brief snippet of the document..." ,
169+ "type" : " document"
170+ }
171+ ]
172+ ```
173+
174+ ** Workflow:**
175+
176+ 1 . Get the ` ai-answer ` item for a quick response
177+ 2 . Extract ` document ` items for supporting documentation
178+ 3 . Use the ` url ` field to read full page content (see Page Content API)
179+
180+ #### 2. Keyword Search (Deterministic)
181+
182+ ** Use when:** You need exact keyword matches or when RAG is unavailable.
183+
184+ ``` bash
185+ curl -sG " https://agentuity.dev/api/search" \
186+ --data-urlencode " query=agent create"
187+ ```
188+
189+ ** Response Format:**
190+
191+ ``` json
192+ [
193+ {
194+ "id" : " /guide/agents" ,
195+ "type" : " page" ,
196+ "content" : " Creating Agents" ,
197+ "url" : " /guide/agents"
198+ },
199+ {
200+ "id" : " /guide/agents-12" ,
201+ "type" : " text" ,
202+ "content" : " Use the CLI to create a new agent..." ,
203+ "url" : " /guide/agents#create"
204+ }
205+ ]
206+ ```
207+
208+ #### 3. Page Content (Full Markdown)
209+
210+ ** Use when:** You need the complete markdown content of a specific documentation page.
211+
212+ ``` bash
213+ curl -sG " https://agentuity.dev/api/page-content" \
214+ --data-urlencode " path=getting-started/quickstart"
215+ ```
216+
217+ ** Path Format:**
218+
219+ - Remove leading slash: ` /getting-started/quickstart ` → ` getting-started/quickstart `
220+ - Remove trailing slashes
221+ - Remove URL fragments: ` guide/install#linux ` → ` guide/install `
222+ - For index pages, use just the folder name: ` getting-started ` resolves to ` getting-started/index.mdx `
223+
224+ ** Convert URL to Path (one-liner):**
225+
226+ ``` bash
227+ PATH=" $( echo " $URL " | sed -E ' s#^/##; s#/+$##; s/#.*$//' ) "
228+ ```
229+
230+ ** Response Format:**
231+
232+ ``` json
233+ {
234+ "content" : " # Quickstart\n\n Full markdown content here..." ,
235+ "title" : " Quickstart Guide" ,
236+ "description" : " Get started quickly with Agentuity" ,
237+ "path" : " getting-started/quickstart"
238+ }
239+ ```
240+
241+ ** Path Validation:**
242+
243+ - Paths cannot contain ` .. ` , ` \ ` , or start with ` / `
244+ - Returns 404 if page not found
245+
246+ ### When to Use Which API
247+
248+ | Scenario | Recommended API | Reason |
249+ | ----------------------- | ------------------------------------------ | ------------------------------------- |
250+ | "How do I..." questions | ` /api/rag-search ` | AI-generated answer + supporting docs |
251+ | Exact term search | ` /api/search ` | Fast, deterministic keyword matching |
252+ | Reading specific page | ` /api/page-content ` | Full markdown with proper formatting |
253+ | Error message lookup | ` /api/search ` | Exact text matching |
254+ | Multi-step tutorials | ` /api/rag-search ` then ` /api/page-content ` | Get overview, then deep dive |
255+
256+ ### Best Practices
257+
258+ 1 . ** Start with RAG for questions:** It provides both answers and relevant documentation links
259+ 2 . ** Use keyword search for known terms:** When you know exactly what you're looking for
260+ 3 . ** Fetch full content for citations:** Always read the complete page when citing documentation
261+ 4 . ** Cache results:** Avoid repeated API calls for the same content
262+ 5 . ** Handle fallbacks:** If RAG fails, fall back to keyword search
0 commit comments