Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Agent Configuration
AGENT_BASE_URL=http://127.0.0.1:3500
AGENT_ID=agent_9ccc5545e93644bd9d7954e632a55a61

# Alternative: You can also set the full URL instead of BASE_URL + ID
# AGENT_FULL_URL=http://127.0.0.1:3500/agent_9ccc5545e93644bd9d7954e632a55a61
# KV-store is hitting Agentuity Service API, this can be found in `agent-docs` after running `agentuity dev`
AGENTUITY_API_KEY=
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ next-env.d.ts
.dev.vars

# this is generated by the build process
content/docs.json
content/docs.json
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@ To make the search feature work, you must set up `.env.local` with the following
cd agent-docs
```

2. **Start the Agent:**
2. **Generate Agent Environment:**
```bash
agentuity dev
```
This will generate a `.env` file in the `agent-docs` directory with your SDK key. The key is required for the next steps.



3. **Copy Environment Configuration:**
For local development, copy the `.env.example` file to `.env.local`:
For local development, copy the `.env.example` file to `.env.local` in the root directory of the docs project:
```bash
# Make sure you are in the root directory, not in agent-docs
cd ../
cp .env.example .env.local
```

4. **Update `AGENT_ID`:**
If you are a contributor from outside the Agentuity organization, ensure that you update the `AGENT_ID` in your `.env.local` file with your specific agent ID from the `agentuity dev` run.
4. **Update `AGENTUITY_API_KEY`:**
If you are a contributor from outside the Agentuity organization, ensure that you update the `AGENTUITY_API_KEY` in your `.env.local` file with your specific SDK key from the `agentuity dev` run.

## Running Docs Application

Expand Down
18 changes: 17 additions & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { v4 as uuidv4 } from 'uuid';

const TYPE_MAP: Record<string, string> = {
agent: 'agents',
Expand All @@ -11,9 +12,22 @@ const TYPE_MAP: Record<string, string> = {
sys: 'system',
};

const COOKIE_NAME = 'chat_user_id';
const COOKIE_MAX_AGE = 24 * 60 * 60 * 14; // 14 days

export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;

let userId = request.cookies.get(COOKIE_NAME)?.value;
const response = NextResponse.next();
if (!userId) {
userId = uuidv4();
response.cookies.set(COOKIE_NAME, userId, {
maxAge: COOKIE_MAX_AGE,
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
});
}
// Match error code URLs
const errorMatch = pathname.match(
/^\/errors\/((?:CLI|AUTH|PROJ|AGENT|DATA|INT|SYS)-\d+)$/
Expand All @@ -31,4 +45,6 @@ export function middleware(request: NextRequest) {

return NextResponse.redirect(url);
}

return response;
}