|
| 1 | +--- |
| 2 | +description: Implement Agentic Research Team |
| 3 | +--- |
| 4 | + |
| 5 | +# Workflow: |
| 6 | + |
| 7 | +## Phase 1: Infrastructure & MCP Layer |
| 8 | +1. **Wrangler Config**: |
| 9 | + * Edit `wrangler.jsonc` to add `[workflows]`, `[vectorize_indexes]`, and `[send_email]`. |
| 10 | + * Run `npx wrangler types` to update `worker-configuration.d.ts`. |
| 11 | +2. **Vectorize Setup**: |
| 12 | + * Run `npx wrangler vectorize create research-index --dimensions 1024 --metric cosine`. |
| 13 | +3. **MCP Adapter**: |
| 14 | + * Create `src/mcp/github-official-adapter.ts`. |
| 15 | + * Implement standard GitHub tools (`list_files`, `read_file`, `search_repositories`) using `src/octokit` logic but matching official tool names/schemas. |
| 16 | + * Import and register this in `src/tools/index.ts` to combine with custom tools. |
| 17 | + |
| 18 | +## Phase 2: The Research Workflow (The Muscle) |
| 19 | +1. **Scaffold Workflow**: |
| 20 | + * Create `src/workflows/DeepResearchWorkflow.ts` extending `WorkflowEntrypoint`. |
| 21 | +2. **Sandbox Integration**: |
| 22 | + * Implement `step.do('clone')`: |
| 23 | + ```typescript |
| 24 | + import { Sandbox } from '@cloudflare/sandbox-sdk'; |
| 25 | + // ... |
| 26 | + const sandbox = await Sandbox.create({ assets: env.BROWSER }); |
| 27 | + await sandbox.run(`git clone ${repoUrl}`); |
| 28 | + ``` |
| 29 | +3. **Analysis & RAG**: |
| 30 | + * Implement `step.do('process')`: |
| 31 | + * Read file tree. |
| 32 | + * Split code files. |
| 33 | + * `env.AI.run('@cf/baai/bge-large-en-v1.5')`. |
| 34 | + * `env.RESEARCH_INDEX.upsert()`. |
| 35 | + |
| 36 | +## Phase 3: The Orchestrator (The Brain) |
| 37 | +1. **Create Agent**: |
| 38 | + * Create `src/agents/ResearchAgent.ts` extending `Agent`. |
| 39 | +2. **Logic Implementation**: |
| 40 | + * **Plan**: `onMessage` -> LLM generates research plan. |
| 41 | + * **Execute**: Call `env.DEEP_RESEARCH_WORKFLOW.create()`. |
| 42 | + * **Monitor**: Expose a `reportProgress` RPC method that the Workflow calls to update the Agent. |
| 43 | + * **HITL**: If the plan involves "Create Issue" or "PR", pause and send `type: 'approval_request'` to WebSocket. |
| 44 | + |
| 45 | +## Phase 4: Daily Discovery & Email |
| 46 | +1. **Cron Handler**: |
| 47 | + * Update `src/index.ts` to export a `scheduled` handler. |
| 48 | + * Logic: Fetch "trending" -> Call `DeepResearchWorkflow` with `mode: 'discovery'` -> Aggregate Findings. |
| 49 | +2. **Email**: |
| 50 | + * Install `mimetext`. |
| 51 | + * Generate HTML report. |
| 52 | + * Send via `env.EMAIL_SENDER`. |
| 53 | + |
| 54 | +## Phase 5: Verification |
| 55 | +1. Deploy: `npx wrangler deploy`. |
| 56 | +2. Test MCP: Connect generic MCP client to the Agent. |
| 57 | +3. Test Full Loop: Trigger `ResearchAgent` via Chat UI. |
0 commit comments