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.
- package/README.md +233 -75
- package/dist/index.cjs +58 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# EngageLab Email CLI
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
47
|
+
Clear the saved configuration:
|
|
32
48
|
|
|
33
|
-
|
|
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
|
|
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
|
-
##
|
|
67
|
+
## Quick Start
|
|
46
68
|
|
|
47
|
-
|
|
69
|
+
List recent inbound messages:
|
|
48
70
|
|
|
49
71
|
```bash
|
|
50
|
-
engagelab-email-cli emails receiving
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
81
|
+
View the full thread around a message:
|
|
57
82
|
|
|
58
|
-
|
|
83
|
+
```bash
|
|
84
|
+
engagelab-email-cli threads messages <thread-id> --include-content
|
|
85
|
+
```
|
|
59
86
|
|
|
60
|
-
|
|
87
|
+
Reply to an inbound message:
|
|
61
88
|
|
|
62
89
|
```bash
|
|
63
|
-
engagelab-email-cli
|
|
90
|
+
engagelab-email-cli emails receiving reply <message-uid> --text "Thanks, we received your message."
|
|
64
91
|
```
|
|
65
92
|
|
|
66
|
-
|
|
93
|
+
Send a new email:
|
|
67
94
|
|
|
68
95
|
```bash
|
|
69
|
-
engagelab-email-cli
|
|
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
|
-
|
|
103
|
+
For scripts or agents, add `--json` to get machine-readable output:
|
|
73
104
|
|
|
74
105
|
```bash
|
|
75
|
-
engagelab-email-cli
|
|
106
|
+
engagelab-email-cli emails receiving list --page-size 20 --json
|
|
76
107
|
```
|
|
77
108
|
|
|
78
|
-
##
|
|
109
|
+
## Commands
|
|
110
|
+
|
|
111
|
+
### `config set`
|
|
112
|
+
|
|
113
|
+
Save local configuration.
|
|
79
114
|
|
|
80
|
-
|
|
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
|
|
123
|
+
engagelab-email-cli config set --base-url http://localhost:8087 --secret-key sk_xxx
|
|
84
124
|
```
|
|
85
125
|
|
|
86
|
-
|
|
126
|
+
### `config list`
|
|
127
|
+
|
|
128
|
+
Show saved configuration.
|
|
129
|
+
|
|
130
|
+
Example:
|
|
87
131
|
|
|
88
132
|
```bash
|
|
89
|
-
engagelab-email-cli
|
|
133
|
+
engagelab-email-cli config list
|
|
90
134
|
```
|
|
91
135
|
|
|
92
|
-
|
|
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
|
|
143
|
+
engagelab-email-cli config clear
|
|
96
144
|
```
|
|
97
145
|
|
|
98
|
-
|
|
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
|
|
164
|
+
engagelab-email-cli threads list --subject refund --page-no 1 --page-size 20
|
|
102
165
|
```
|
|
103
166
|
|
|
104
|
-
`
|
|
167
|
+
### `threads get <thread-id>`
|
|
105
168
|
|
|
106
|
-
|
|
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
|
-
|
|
171
|
+
| Argument/Option | Description |
|
|
172
|
+
| --- | --- |
|
|
173
|
+
| `<thread-id>` | Thread ID. |
|
|
174
|
+
| `--json` | Output raw JSON. |
|
|
113
175
|
|
|
114
|
-
|
|
176
|
+
Example:
|
|
115
177
|
|
|
116
178
|
```bash
|
|
117
|
-
engagelab-email-cli
|
|
179
|
+
engagelab-email-cli threads get b0d9d6a1-1d17-4df8-8245-c807d7e8cb50
|
|
118
180
|
```
|
|
119
181
|
|
|
120
|
-
|
|
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
|
|
196
|
+
engagelab-email-cli threads messages b0d9d6a1-1d17-4df8-8245-c807d7e8cb50 --include-content --json
|
|
124
197
|
```
|
|
125
198
|
|
|
126
|
-
`
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
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
|
-
|
|
226
|
+
Example:
|
|
141
227
|
|
|
142
228
|
```bash
|
|
143
|
-
engagelab-email-cli emails
|
|
229
|
+
engagelab-email-cli emails receiving get 7e2b2de6-14c5-4ef1-a1e2-f4337e4606e2 --json
|
|
144
230
|
```
|
|
145
231
|
|
|
146
|
-
|
|
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
|
|
246
|
+
engagelab-email-cli emails receiving listen --limit 10 --interval 5 --json
|
|
150
247
|
```
|
|
151
248
|
|
|
152
|
-
|
|
249
|
+
Continue from a known cursor:
|
|
153
250
|
|
|
154
251
|
```bash
|
|
155
|
-
engagelab-email-cli emails
|
|
252
|
+
engagelab-email-cli emails receiving listen --after 1500 --limit 10 --interval 5 --json
|
|
156
253
|
```
|
|
157
254
|
|
|
158
|
-
`
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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.
|