@morphllm/subagents
Advanced tools
+1
-1
| { | ||
| "name": "@morphllm/subagents", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "Modular AI subagents for document processing - DOCX editing, PDF filling, and more", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
+50
-24
@@ -5,2 +5,35 @@ # @morphllm/subagents | ||
| ## How It Works | ||
| Subagents follow the **"Agents as Tools"** pattern—specialized secondary agents that your main agent delegates to for domain-specific tasks: | ||
| ``` | ||
| ┌─────────────────────┐ | ||
| │ MAIN AGENT │ | ||
| │ │ | ||
| │ • Orchestrates │ | ||
| │ • Plans │ | ||
| │ • Delegates │ | ||
| └──────────┬──────────┘ | ||
| │ | ||
| ┌────────────────────────────┼────────────────────────────┐ | ||
| │ │ │ | ||
| ▼ ▼ ▼ | ||
| ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ | ||
| │ DOCX AGENT │ │ PDF AGENT │ │ YOUR AGENT │ | ||
| │ │ │ │ │ │ | ||
| │ "Review this │ │ "Fill out │ │ Domain-specific│ | ||
| │ contract" │ │ this form" │ │ capabilities │ | ||
| └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ | ||
| │ │ │ | ||
| ▼ ▼ ▼ | ||
| ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ | ||
| │ Track changes │ │ Form filling │ │ Custom tools │ | ||
| │ Comments │ │ Annotations │ │ & APIs │ | ||
| │ Document edits │ │ (Coming soon) │ │ │ | ||
| └─────────────────┘ └─────────────────┘ └─────────────────┘ | ||
| ``` | ||
| The main agent handles orchestration and planning. When it encounters a specialized task (editing a Word doc, filling a PDF form), it delegates to the appropriate subagent which handles all the domain complexity—file formats, APIs, and tool execution. | ||
| ## Installation | ||
@@ -48,11 +81,15 @@ | ||
| import OpenAI from 'openai'; | ||
| import { DocxAgent } from '@morphllm/subagents/docx'; | ||
| import { DocxClient, DocxAgent } from '@morphllm/subagents/docx'; | ||
| const openai = new OpenAI({ | ||
| apiKey: process.env.OPENAI_API_KEY, | ||
| }); | ||
| const openai = new OpenAI(); | ||
| const client = new DocxClient(); | ||
| // Upload a document first | ||
| const file = new File([documentBuffer], 'contract.docx'); | ||
| const { doc_id } = await client.upload(file); | ||
| // Create agent with the document | ||
| const agent = new DocxAgent({ | ||
| openai, | ||
| documentId: 'your-doc-id', | ||
| documentId: doc_id, | ||
| }); | ||
@@ -65,3 +102,9 @@ | ||
| // Or stream for real-time UI | ||
| // Download the edited document | ||
| const editedDoc = await client.download(doc_id); | ||
| ``` | ||
| ### Streaming Responses | ||
| ```typescript | ||
| for await (const event of agent.runStream('Add comments to unclear sections')) { | ||
@@ -76,19 +119,2 @@ if (event.type === 'content_delta') { | ||
| ### Using with Kimi/Moonshot API | ||
| ```typescript | ||
| import OpenAI from 'openai'; | ||
| import { DocxAgent } from '@morphllm/subagents/docx'; | ||
| const openai = new OpenAI({ | ||
| apiKey: process.env.KIMI_API_KEY, | ||
| baseURL: 'https://api.moonshot.cn/v1', | ||
| }); | ||
| const agent = new DocxAgent({ | ||
| openai, | ||
| model: 'moonshot-v1-32k', | ||
| }); | ||
| ``` | ||
| ## Module Imports | ||
@@ -146,3 +172,3 @@ | ||
| |----------|-------------|---------| | ||
| | `DOCX_API_URL` | DOCX service URL | Railway deployment | | ||
| | `DOCX_API_URL` | DOCX service URL | https://docx.morphllm.com | | ||
@@ -149,0 +175,0 @@ ## License |
316400
0.91%173
17.69%