@morphllm/subagents 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +50 -24
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  Modular AI subagents for document processing. Built for use with OpenAI-compatible APIs.
4
4
 
5
+ ## How It Works
6
+
7
+ Subagents follow the **"Agents as Tools"** pattern—specialized secondary agents that your main agent delegates to for domain-specific tasks:
8
+
9
+ ```
10
+ ┌─────────────────────┐
11
+ │ MAIN AGENT │
12
+ │ │
13
+ │ • Orchestrates │
14
+ │ • Plans │
15
+ │ • Delegates │
16
+ └──────────┬──────────┘
17
+
18
+ ┌────────────────────────────┼────────────────────────────┐
19
+ │ │ │
20
+ ▼ ▼ ▼
21
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
22
+ │ DOCX AGENT │ │ PDF AGENT │ │ YOUR AGENT │
23
+ │ │ │ │ │ │
24
+ │ "Review this │ │ "Fill out │ │ Domain-specific│
25
+ │ contract" │ │ this form" │ │ capabilities │
26
+ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘
27
+ │ │ │
28
+ ▼ ▼ ▼
29
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
30
+ │ Track changes │ │ Form filling │ │ Custom tools │
31
+ │ Comments │ │ Annotations │ │ & APIs │
32
+ │ Document edits │ │ (Coming soon) │ │ │
33
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
34
+ ```
35
+
36
+ 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.
37
+
5
38
  ## Installation
6
39
 
7
40
  ```bash
@@ -44,15 +77,19 @@ const blob = await client.download(doc.doc_id);
44
77
 
45
78
  ```typescript
46
79
  import OpenAI from 'openai';
47
- import { DocxAgent } from '@morphllm/subagents/docx';
80
+ import { DocxClient, DocxAgent } from '@morphllm/subagents/docx';
48
81
 
49
- const openai = new OpenAI({
50
- apiKey: process.env.OPENAI_API_KEY,
51
- });
82
+ const openai = new OpenAI();
83
+ const client = new DocxClient();
84
+
85
+ // Upload a document first
86
+ const file = new File([documentBuffer], 'contract.docx');
87
+ const { doc_id } = await client.upload(file);
52
88
 
89
+ // Create agent with the document
53
90
  const agent = new DocxAgent({
54
91
  openai,
55
- documentId: 'your-doc-id',
92
+ documentId: doc_id,
56
93
  });
57
94
 
58
95
  // Run with natural language
@@ -60,7 +97,13 @@ const result = await agent.run('Review this contract and flag any issues');
60
97
  console.log(result.response);
61
98
  console.log(result.toolCalls);
62
99
 
63
- // Or stream for real-time UI
100
+ // Download the edited document
101
+ const editedDoc = await client.download(doc_id);
102
+ ```
103
+
104
+ ### Streaming Responses
105
+
106
+ ```typescript
64
107
  for await (const event of agent.runStream('Add comments to unclear sections')) {
65
108
  if (event.type === 'content_delta') {
66
109
  process.stdout.write(event.delta.text);
@@ -70,23 +113,6 @@ for await (const event of agent.runStream('Add comments to unclear sections')) {
70
113
  }
71
114
  ```
72
115
 
73
- ### Using with Kimi/Moonshot API
74
-
75
- ```typescript
76
- import OpenAI from 'openai';
77
- import { DocxAgent } from '@morphllm/subagents/docx';
78
-
79
- const openai = new OpenAI({
80
- apiKey: process.env.KIMI_API_KEY,
81
- baseURL: 'https://api.moonshot.cn/v1',
82
- });
83
-
84
- const agent = new DocxAgent({
85
- openai,
86
- model: 'moonshot-v1-32k',
87
- });
88
- ```
89
-
90
116
  ## Module Imports
91
117
 
92
118
  ```typescript
@@ -139,7 +165,7 @@ class MyAgent extends BaseAgent<MyClient> {
139
165
 
140
166
  | Variable | Description | Default |
141
167
  |----------|-------------|---------|
142
- | `DOCX_API_URL` | DOCX service URL | Railway deployment |
168
+ | `DOCX_API_URL` | DOCX service URL | https://docx.morphllm.com |
143
169
 
144
170
  ## License
145
171
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morphllm/subagents",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Modular AI subagents for document processing - DOCX editing, PDF filling, and more",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",