engagelab-email-cli 1.1.1 → 1.4.0

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 (3) hide show
  1. package/README.md +233 -75
  2. package/dist/index.cjs +58 -41
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # EngageLab Email CLI
2
2
 
3
- Command line tool for EngageLab Email Agent workflows. Use it to query inbound messages, inspect threads, listen for new messages, reply to inbound mail, and send outbound mail.
3
+ EngageLab Email CLI helps agents and developers work with inbound and outbound email from the command line.
4
+
5
+ Use it to:
6
+
7
+ - List and inspect email threads
8
+ - Read inbound messages
9
+ - Poll for new inbound messages
10
+ - Reply to inbound messages
11
+ - Send new emails
4
12
 
5
13
  ## Install
6
14
 
@@ -8,32 +16,46 @@ Command line tool for EngageLab Email Agent workflows. Use it to query inbound m
8
16
  npm install -g engagelab-email-cli
9
17
  ```
10
18
 
11
- Check the installed command:
19
+ Check the installed version:
12
20
 
13
21
  ```bash
14
22
  engagelab-email-cli -V
15
23
  ```
16
24
 
25
+ When you run a command that connects to EngageLab Email, the CLI checks whether a newer CLI version is available. If an update is required, it stops and shows the update command:
26
+
27
+ ```bash
28
+ npm install -g engagelab-email-cli@latest
29
+ ```
30
+
17
31
  ## Configure
18
32
 
19
- Save your API base URL and Secret Key locally:
33
+ Save your service address and Secret Key locally:
20
34
 
21
35
  ```bash
22
36
  engagelab-email-cli config set --base-url http://localhost:8087 --secret-key sk_xxx
23
37
  ```
24
38
 
25
- View the current configuration:
39
+ If you do not configure `baseUrl` manually, the CLI will obtain it automatically from the Secret Key. If you do configure `baseUrl`, the CLI uses the configured value.
40
+
41
+ View the saved configuration:
26
42
 
27
43
  ```bash
28
44
  engagelab-email-cli config list
29
45
  ```
30
46
 
31
- `config list` masks the Secret Key and never prints the full value.
47
+ Clear the saved configuration:
32
48
 
33
- You can also pass credentials per command:
49
+ ```bash
50
+ engagelab-email-cli config clear
51
+ ```
52
+
53
+ `config list` masks the Secret Key.
54
+
55
+ You can also pass credentials for a single command:
34
56
 
35
57
  ```bash
36
- engagelab-email-cli --base-url http://localhost:8087 --secret-key sk_xxx emails receiving list --json
58
+ engagelab-email-cli --base-url http://localhost:8087 --secret-key sk_xxx emails receiving list
37
59
  ```
38
60
 
39
61
  Configuration priority:
@@ -42,138 +64,274 @@ Configuration priority:
42
64
  2. Environment variables: `ENGAGELAB_EMAIL_BASE_URL`, `ENGAGELAB_EMAIL_SECRET_KEY`
43
65
  3. Local config file
44
66
 
45
- ## Recommended Agent Usage
67
+ ## Quick Start
46
68
 
47
- For Agent or Skill integrations, use `--json` and JSON body files. This avoids shell quoting issues with long text, HTML, arrays, and newlines.
69
+ List recent inbound messages:
48
70
 
49
71
  ```bash
50
- engagelab-email-cli emails receiving listen --limit 10 --interval 5 --json
51
- engagelab-email-cli threads messages <thread-id> --include-content --json
52
- engagelab-email-cli emails receiving reply <message-uid> --body-file reply.json --json
53
- engagelab-email-cli emails send --body-file send.json --json
72
+ engagelab-email-cli emails receiving list --page-size 20
73
+ ```
74
+
75
+ Read one inbound message:
76
+
77
+ ```bash
78
+ engagelab-email-cli emails receiving get <message-uid>
54
79
  ```
55
80
 
56
- `emails receiving listen --json` prints NDJSON: one JSON object per new message line.
81
+ View the full thread around a message:
57
82
 
58
- ## Threads
83
+ ```bash
84
+ engagelab-email-cli threads messages <thread-id> --include-content
85
+ ```
59
86
 
60
- List threads:
87
+ Reply to an inbound message:
61
88
 
62
89
  ```bash
63
- engagelab-email-cli threads list --mailbox-id 1001 --subject refund --participant alice@example.com --page-no 1 --page-size 20
90
+ engagelab-email-cli emails receiving reply <message-uid> --text "Thanks, we received your message."
64
91
  ```
65
92
 
66
- Get one thread:
93
+ Send a new email:
67
94
 
68
95
  ```bash
69
- engagelab-email-cli threads get <thread-id> --json
96
+ engagelab-email-cli emails send \
97
+ --mailbox-id 1001 \
98
+ --to alice@example.com \
99
+ --subject "Hello" \
100
+ --text "Hello from EngageLab Email CLI."
70
101
  ```
71
102
 
72
- List messages in a thread:
103
+ For scripts or agents, add `--json` to get machine-readable output:
73
104
 
74
105
  ```bash
75
- engagelab-email-cli threads messages <thread-id> --limit 50 --include-content --json
106
+ engagelab-email-cli emails receiving list --page-size 20 --json
76
107
  ```
77
108
 
78
- ## Receiving
109
+ ## Commands
110
+
111
+ ### `config set`
112
+
113
+ Save local configuration.
79
114
 
80
- List inbound messages:
115
+ | Option | Description |
116
+ | --- | --- |
117
+ | `--base-url <url>` | Service address, such as `http://localhost:8087`. |
118
+ | `--secret-key <key>` | Secret Key. It must start with `sk_`. |
119
+
120
+ Example:
81
121
 
82
122
  ```bash
83
- engagelab-email-cli emails receiving list --mailbox-id 1001 --keyword refund --json
123
+ engagelab-email-cli config set --base-url http://localhost:8087 --secret-key sk_xxx
84
124
  ```
85
125
 
86
- Get one inbound message:
126
+ ### `config list`
127
+
128
+ Show saved configuration.
129
+
130
+ Example:
87
131
 
88
132
  ```bash
89
- engagelab-email-cli emails receiving get <message-uid> --json
133
+ engagelab-email-cli config list
90
134
  ```
91
135
 
92
- Listen for new inbound messages:
136
+ ### `config clear`
137
+
138
+ Clear saved local configuration, including `baseUrl` and `secretKey`.
139
+
140
+ Example:
93
141
 
94
142
  ```bash
95
- engagelab-email-cli emails receiving listen --limit 10 --interval 5 --json
143
+ engagelab-email-cli config clear
96
144
  ```
97
145
 
98
- Continue from a known cursor:
146
+ ### `threads list`
147
+
148
+ List email threads.
149
+
150
+ | Option | Description |
151
+ | --- | --- |
152
+ | `--mailbox-id <id>` | Filter by mailbox ID. |
153
+ | `--subject <text>` | Search by subject. |
154
+ | `--participant <email>` | Search by participant email address. |
155
+ | `--start-time <timestamp>` | Filter by latest message start time in milliseconds. |
156
+ | `--end-time <timestamp>` | Filter by latest message end time in milliseconds. |
157
+ | `--page-no <number>` | Page number. |
158
+ | `--page-size <number>` | Number of results per page. |
159
+ | `--json` | Output raw JSON. |
160
+
161
+ Example:
99
162
 
100
163
  ```bash
101
- engagelab-email-cli emails receiving listen --after 1500 --limit 10 --interval 5 --json
164
+ engagelab-email-cli threads list --subject refund --page-no 1 --page-size 20
102
165
  ```
103
166
 
104
- `listen` is a long-running polling command:
167
+ ### `threads get <thread-id>`
105
168
 
106
- - If `--after` is not provided, it seeds the cursor from the latest message and does not print historical messages on startup.
107
- - It polls `GET /v1/message/listen` every `--interval` seconds.
108
- - `--interval` defaults to `5`; the minimum is `2`.
109
- - It updates the cursor from the newest returned message.
110
- - It keeps running until `Ctrl+C` or process termination.
169
+ Show one thread.
111
170
 
112
- ## Reply
171
+ | Argument/Option | Description |
172
+ | --- | --- |
173
+ | `<thread-id>` | Thread ID. |
174
+ | `--json` | Output raw JSON. |
113
175
 
114
- Reply with plain text:
176
+ Example:
115
177
 
116
178
  ```bash
117
- engagelab-email-cli emails receiving reply <message-uid> --text "您好,您的邮件已收到。" --json
179
+ engagelab-email-cli threads get b0d9d6a1-1d17-4df8-8245-c807d7e8cb50
118
180
  ```
119
181
 
120
- Reply with a JSON file:
182
+ ### `threads messages <thread-id>`
183
+
184
+ List messages in a thread.
185
+
186
+ | Argument/Option | Description |
187
+ | --- | --- |
188
+ | `<thread-id>` | Thread ID. |
189
+ | `--limit <number>` | Maximum number of messages to return. |
190
+ | `--include-content` | Include message content and attachment information. |
191
+ | `--json` | Output raw JSON. |
192
+
193
+ Example:
121
194
 
122
195
  ```bash
123
- engagelab-email-cli emails receiving reply <message-uid> --body-file reply.json --json
196
+ engagelab-email-cli threads messages b0d9d6a1-1d17-4df8-8245-c807d7e8cb50 --include-content --json
124
197
  ```
125
198
 
126
- `reply.json`:
199
+ ### `emails receiving list`
200
+
201
+ List inbound messages.
202
+
203
+ | Option | Description |
204
+ | --- | --- |
205
+ | `--mailbox-id <id>` | Filter by mailbox ID. |
206
+ | `--keyword <text>` | Search by keyword. |
207
+ | `--page-no <number>` | Page number. |
208
+ | `--page-size <number>` | Number of results per page. |
209
+ | `--json` | Output raw JSON. |
127
210
 
128
- ```json
129
- {
130
- "subject": "Re: Refund request",
131
- "text": "您好,您的退款申请已收到。",
132
- "html": "<p>您好,您的退款申请已收到。</p>",
133
- "cc": ["ops@example.com"],
134
- "bcc": []
135
- }
211
+ Example:
212
+
213
+ ```bash
214
+ engagelab-email-cli emails receiving list --keyword refund --page-size 20
136
215
  ```
137
216
 
138
- ## Send
217
+ ### `emails receiving get <message-uid>`
218
+
219
+ Show one inbound message.
220
+
221
+ | Argument/Option | Description |
222
+ | --- | --- |
223
+ | `<message-uid>` | Message UID. |
224
+ | `--json` | Output raw JSON. |
139
225
 
140
- Send with command options:
226
+ Example:
141
227
 
142
228
  ```bash
143
- engagelab-email-cli emails send --mailbox-id 1001 --to alice@example.com --subject "Refund update" --text "您的退款申请已经处理完成。" --json
229
+ engagelab-email-cli emails receiving get 7e2b2de6-14c5-4ef1-a1e2-f4337e4606e2 --json
144
230
  ```
145
231
 
146
- Send an HTML file:
232
+ ### `emails receiving listen`
233
+
234
+ Poll for new inbound messages. This command keeps running until you stop it with `Ctrl+C`.
235
+
236
+ | Option | Description |
237
+ | --- | --- |
238
+ | `--after <id>` | Start after a known cursor ID. |
239
+ | `--limit <number>` | Maximum messages per poll. Default: `10`. |
240
+ | `--interval <seconds>` | Polling interval. Default: `5`; minimum: `2`. |
241
+ | `--json` | Output one JSON message per line. |
242
+
243
+ Example:
147
244
 
148
245
  ```bash
149
- engagelab-email-cli emails send --mailbox-id 1001 --to alice@example.com --subject "Refund update" --html-file ./email.html --json
246
+ engagelab-email-cli emails receiving listen --limit 10 --interval 5 --json
150
247
  ```
151
248
 
152
- Send with a JSON file:
249
+ Continue from a known cursor:
153
250
 
154
251
  ```bash
155
- engagelab-email-cli emails send --body-file send.json --json
252
+ engagelab-email-cli emails receiving listen --after 1500 --limit 10 --interval 5 --json
156
253
  ```
157
254
 
158
- `send.json`:
255
+ ### `emails receiving reply <message-uid>`
256
+
257
+ Reply to an inbound message.
258
+
259
+ | Argument/Option | Description |
260
+ | --- | --- |
261
+ | `<message-uid>` | Message UID to reply to. |
262
+ | `--subject <text>` | Reply subject. |
263
+ | `--text <text>` | Plain text reply content. |
264
+ | `--html <html>` | HTML reply content. |
265
+ | `--text-file <path>` | Read plain text reply content from a file. |
266
+ | `--html-file <path>` | Read HTML reply content from a file. |
267
+ | `--cc <email>` | CC address. Can be repeated. |
268
+ | `--bcc <email>` | BCC address. Can be repeated. |
269
+ | `--reply-to <email>` | Reply-To address. Can be repeated. |
270
+ | `--preview-text <text>` | Preview text. |
271
+ | `--attachment <path>` | Attach a file. Can be repeated. Up to 10 files, 10MB total. |
272
+ | `--sandbox` | Send in sandbox mode. |
273
+ | `--json` | Output raw JSON. |
159
274
 
160
- ```json
161
- {
162
- "mailboxId": 1001,
163
- "to": ["alice@example.com"],
164
- "subject": "Refund update",
165
- "text": "您的退款申请已经处理完成。",
166
- "html": "<p>您的退款申请已经处理完成。</p>",
167
- "cc": [],
168
- "bcc": []
169
- }
275
+ Example:
276
+
277
+ ```bash
278
+ engagelab-email-cli emails receiving reply 7e2b2de6-14c5-4ef1-a1e2-f4337e4606e2 \
279
+ --text "Thanks, we received your message." \
280
+ --attachment ./receipt.pdf
281
+ ```
282
+
283
+ ### `emails send`
284
+
285
+ Send a new email.
286
+
287
+ | Option | Description |
288
+ | --- | --- |
289
+ | `--mailbox-id <id>` | Mailbox ID to send from. Required. |
290
+ | `--from <email>` | Sender address. |
291
+ | `--to <email>` | Recipient address. Can be repeated. Required. |
292
+ | `--subject <text>` | Email subject. Required. |
293
+ | `--text <text>` | Plain text email content. |
294
+ | `--html <html>` | HTML email content. |
295
+ | `--text-file <path>` | Read plain text email content from a file. |
296
+ | `--html-file <path>` | Read HTML email content from a file. |
297
+ | `--cc <email>` | CC address. Can be repeated. |
298
+ | `--bcc <email>` | BCC address. Can be repeated. |
299
+ | `--reply-to <email>` | Reply-To address. Can be repeated. |
300
+ | `--preview-text <text>` | Preview text. |
301
+ | `--attachment <path>` | Attach a file. Can be repeated. Up to 10 files, 10MB total. |
302
+ | `--sandbox` | Send in sandbox mode. |
303
+ | `--json` | Output raw JSON. |
304
+
305
+ Example:
306
+
307
+ ```bash
308
+ engagelab-email-cli emails send \
309
+ --mailbox-id 1001 \
310
+ --to alice@example.com \
311
+ --to bob@example.com \
312
+ --subject "Refund update" \
313
+ --text "Your refund has been processed." \
314
+ --attachment ./receipt.pdf
315
+ ```
316
+
317
+ Send HTML content from a file:
318
+
319
+ ```bash
320
+ engagelab-email-cli emails send \
321
+ --mailbox-id 1001 \
322
+ --to alice@example.com \
323
+ --subject "Monthly report" \
324
+ --html-file ./report.html
170
325
  ```
171
326
 
172
- ## Body Input Rules
327
+ ## Output
328
+
329
+ By default, the CLI prints readable tables or summaries and shows a short loading message while requests are running.
330
+
331
+ Use `--json` when another tool or script needs to parse the result.
332
+
333
+ ```bash
334
+ engagelab-email-cli emails receiving get <message-uid> --json
335
+ ```
173
336
 
174
- - `--body-file` and `--body-json` are mutually exclusive.
175
- - `--body-file` or `--body-json` cannot be combined with field-level body options.
176
- - `--text` and `--text-file` are mutually exclusive.
177
- - `--html` and `--html-file` are mutually exclusive.
178
- - `emails send` requires `mailboxId`, at least one `to`, `subject`, and at least one of `text` or `html`.
179
- - `emails receiving reply` requires at least one of `text` or `html`.
337
+ `emails receiving listen --json` prints one message JSON object per line.