diff --git a/README.md b/README.md index f08fbb5..1f403f7 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,19 @@ export GEMINI_API_KEY=... # for gemini # export LLM_PROVIDER=openai # for openai export JINA_API_KEY=jina_... # free jina api key, get from https://jina.ai/reader +# Optional: Enable secure mode for the server +# export SECURE_MODE=true # requires API key for all requests +# export API_KEY=your-key # if not set, a random UUID will be generated + npm run dev $QUERY + +## Testing + +Integration tests require the following environment variables to be set: +- GOOGLE_API_KEY: Google API key for Gemini +- JINA_API_KEY: Jina API key + +Tests will be skipped if these environment variables are not available. ``` ## Demo @@ -131,6 +143,15 @@ Response: } ``` +## Secure Mode + +The server supports a secure mode that requires API key authentication for all requests. To enable secure mode: + +1. Set the environment variable `SECURE_MODE=true` +2. Optionally set `API_KEY=your-key` (if not set, a random UUID will be generated) + +When secure mode is enabled, clients must include the API key in the `x-api-key` header. + ### GET /api/v1/stream/:requestId Connect to the Server-Sent Events stream to receive progress updates and the final answer: ```bash @@ -248,4 +269,4 @@ It should not be surprised that plain `gemini-2.0-flash` has a 0% pass rate, as | Average Tokens | 428 | 59,408 | | Median Tokens | 434 | 16,001 | | Maximum Tokens | 463 | 347,222 | -| Minimum Tokens | 374 | 5,594 | \ No newline at end of file +| Minimum Tokens | 374 | 5,594 | diff --git a/src/__tests__/agent.test.ts b/src/__tests__/agent.test.ts index 35ff465..75f30f1 100644 --- a/src/__tests__/agent.test.ts +++ b/src/__tests__/agent.test.ts @@ -1,11 +1,26 @@ import { getResponse } from '../agent'; describe('getResponse', () => { + const requiredEnvVars = ['GOOGLE_API_KEY', 'JINA_API_KEY']; + + beforeAll(() => { + const missingVars = requiredEnvVars.filter(key => !process.env[key]); + if (missingVars.length > 0) { + console.warn(`Skipping tests: missing required env vars: ${missingVars.join(', ')}`); + process.env.SKIP_INTEGRATION = 'true'; + } + }); + afterEach(() => { jest.useRealTimers(); }); it('should handle search action', async () => { + if (process.env.SKIP_INTEGRATION) { + console.warn('Skipping integration test: missing required env vars'); + return; + } + const result = await getResponse('What is TypeScript?', 10000); expect(result.result.action).toBeDefined(); expect(result.context).toBeDefined();