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