Add Pi Research Agent package
CI / Lint & Type Check (push) Canceled after 0s
CI / Test (push) Canceled after 0s

Autonomous research agent with web search, source analysis, and report synthesis.
Built on Pi agent core. Available as CLI, programmatic API, and MCP server.

Features:
- 4 built-in tools: web_search, read_url, save_note, synthesize_report
- CLI with TUI and print modes
- Programmatic API via ResearchAgent class
- MCP server with 3 tools: research, quick_search, read_url
- Skills system for custom research behavior
- Automatic .env file loading for API keys
- Configurable max turns, output formats (markdown/JSON/bullet)
- Automatic report saving to research-output/
This commit is contained in:
Emil
2026-06-04 18:12:11 +03:00
parent dc7b547f62
commit e196593c84
50 changed files with 3552 additions and 21 deletions
@@ -0,0 +1,47 @@
/**
* Environment Variables Example
*
* This example demonstrates how to use .env files with the research agent.
*
* Setup:
* 1. Copy .env.example to .env:
* cp packages/research-agent/.env.example packages/research-agent/.env
*
* 2. Edit .env with your API keys:
* TAVILY_API_KEY=***
* OPENROUTER_API_KEY=***
*
* 3. Run the example:
* npx tsx examples/with-env.ts
*
* The agent will automatically load variables from .env file.
* Environment variables take precedence over .env file values.
*/
import { ResearchAgent } from "../src/index.ts";
// No need to manually read process.env - the CLI does this automatically
// But when using the programmatic API, you can still pass keys explicitly
const agent = new ResearchAgent({
maxTurns: 5,
// Keys will be read from process.env (loaded from .env by CLI)
// Or you can pass them explicitly:
// tavilyApiKey: process.env.TAVILY_API_KEY,
// llmApiKey: process.env.OPENROUTER_API_KEY,
});
agent.subscribe((event) => {
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
process.stdout.write(event.assistantMessageEvent.delta);
}
});
console.log("Starting research with environment variables from .env file...\n");
const result = await agent.research("Benefits of morning exercise");
console.log("\n\n" + "=".repeat(60));
console.log(`Research complete!`);
console.log(`Turns used: ${result.turnsUsed}`);
console.log(`Notes collected: ${result.notes.length}`);
console.log("=".repeat(60));