@inkbox/cli 0.2.1
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 +246 -0
- package/dist/client.js +21 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/email.js +187 -0
- package/dist/commands/email.js.map +1 -0
- package/dist/commands/identity.js +315 -0
- package/dist/commands/identity.js.map +1 -0
- package/dist/commands/mailbox.js +91 -0
- package/dist/commands/mailbox.js.map +1 -0
- package/dist/commands/number.js +93 -0
- package/dist/commands/number.js.map +1 -0
- package/dist/commands/phone.js +95 -0
- package/dist/commands/phone.js.map +1 -0
- package/dist/commands/signing-key.js +22 -0
- package/dist/commands/signing-key.js.map +1 -0
- package/dist/commands/vault.js +276 -0
- package/dist/commands/vault.js.map +1 -0
- package/dist/commands/webhook.js +48 -0
- package/dist/commands/webhook.js.map +1 -0
- package/dist/errors.js +31 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/output.js +53 -0
- package/dist/output.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# @inkbox/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for the [Inkbox API](https://inkbox.ai/docs) — email, phone, identities, and encrypted vault for AI agents.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @inkbox/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run directly with npx:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @inkbox/cli <command>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Node.js >= 18.
|
|
18
|
+
|
|
19
|
+
## Authentication
|
|
20
|
+
|
|
21
|
+
Set your API key as an environment variable or pass it as a flag:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
export INKBOX_API_KEY="ApiKey_..."
|
|
25
|
+
export INKBOX_VAULT_KEY="my-vault-key" # only needed for vault decrypt/create
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Get your API key at [console.inkbox.ai](https://console.inkbox.ai/).
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Create an agent identity
|
|
34
|
+
inkbox identity create support-bot
|
|
35
|
+
|
|
36
|
+
# Create a mailbox for the identity
|
|
37
|
+
inkbox mailbox create --handle support-bot
|
|
38
|
+
|
|
39
|
+
# Send an email
|
|
40
|
+
inkbox email send -i support-bot \
|
|
41
|
+
--to customer@example.com \
|
|
42
|
+
--subject "Your order has shipped" \
|
|
43
|
+
--body-text "Tracking number: 1Z999AA10123456784"
|
|
44
|
+
|
|
45
|
+
# List recent emails
|
|
46
|
+
inkbox email list -i support-bot --limit 10
|
|
47
|
+
|
|
48
|
+
# List all identities (JSON output)
|
|
49
|
+
inkbox --json identity list
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Commands
|
|
53
|
+
|
|
54
|
+
### identity
|
|
55
|
+
|
|
56
|
+
Manage agent identities.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
inkbox identity list # List all identities
|
|
60
|
+
inkbox identity get <handle> # Get identity details
|
|
61
|
+
inkbox identity create <handle> # Create a new identity
|
|
62
|
+
inkbox identity delete <handle> # Delete an identity
|
|
63
|
+
inkbox identity update <handle> # Update an identity
|
|
64
|
+
--new-handle <handle> # New handle
|
|
65
|
+
--status <status> # active or paused
|
|
66
|
+
inkbox identity refresh <handle> # Re-fetch identity from API
|
|
67
|
+
|
|
68
|
+
inkbox identity create-secret <handle> # Create a secret scoped to identity (vault key)
|
|
69
|
+
--name <name> # Secret name (required)
|
|
70
|
+
--type <type> # Secret type (required)
|
|
71
|
+
--description <desc> # Optional description
|
|
72
|
+
(same secret type flags as vault create)
|
|
73
|
+
|
|
74
|
+
inkbox identity get-secret <handle> <secret-id> # Decrypt a secret (vault key)
|
|
75
|
+
inkbox identity delete-secret <handle> <secret-id> # Delete a secret (vault key)
|
|
76
|
+
inkbox identity revoke-access <handle> <secret-id> # Revoke credential access
|
|
77
|
+
|
|
78
|
+
inkbox identity set-totp <handle> <secret-id> # Add TOTP to login (vault key)
|
|
79
|
+
--uri <otpauth-uri> # otpauth:// URI (required)
|
|
80
|
+
inkbox identity remove-totp <handle> <secret-id> # Remove TOTP (vault key)
|
|
81
|
+
inkbox identity totp-code <handle> <secret-id> # Generate TOTP code (vault key)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### email
|
|
85
|
+
|
|
86
|
+
Email operations, scoped to an identity. Requires `-i <handle>`.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
inkbox email send -i <handle> # Send an email
|
|
90
|
+
--to <addresses> # Comma-separated recipients (required)
|
|
91
|
+
--subject <subject> # Email subject (required)
|
|
92
|
+
--body-text <text> # Plain text body
|
|
93
|
+
--body-html <html> # HTML body
|
|
94
|
+
--cc <addresses> # Comma-separated CC
|
|
95
|
+
--bcc <addresses> # Comma-separated BCC
|
|
96
|
+
--in-reply-to <message-id> # Message ID to reply to
|
|
97
|
+
|
|
98
|
+
inkbox email list -i <handle> # List emails
|
|
99
|
+
--direction <dir> # Filter: inbound or outbound
|
|
100
|
+
--limit <n> # Max messages (default: 50)
|
|
101
|
+
|
|
102
|
+
inkbox email get <message-id> -i <handle> # Get full message with body
|
|
103
|
+
|
|
104
|
+
inkbox email search -i <handle> # Search emails
|
|
105
|
+
-q, --query <query> # Search query (required)
|
|
106
|
+
--limit <n> # Max results (default: 50)
|
|
107
|
+
|
|
108
|
+
inkbox email unread -i <handle> # List unread emails
|
|
109
|
+
--direction <dir> # Filter: inbound or outbound
|
|
110
|
+
--limit <n> # Max messages (default: 50)
|
|
111
|
+
|
|
112
|
+
inkbox email mark-read <ids...> -i <handle> # Mark messages as read
|
|
113
|
+
inkbox email thread <thread-id> -i <handle> # Get thread with all messages
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### phone
|
|
117
|
+
|
|
118
|
+
Phone operations, scoped to an identity. Requires `-i <handle>`.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
inkbox phone call -i <handle> # Place an outbound call
|
|
122
|
+
--to <number> # E.164 phone number (required)
|
|
123
|
+
--ws-url <url> # WebSocket URL (wss://) for audio bridging
|
|
124
|
+
|
|
125
|
+
inkbox phone calls -i <handle> # List calls
|
|
126
|
+
--limit <n> # Max results (default: 50)
|
|
127
|
+
--offset <n> # Pagination offset (default: 0)
|
|
128
|
+
|
|
129
|
+
inkbox phone transcripts <call-id> -i <handle> # Get call transcripts
|
|
130
|
+
|
|
131
|
+
inkbox phone search-transcripts -i <handle> # Search transcripts
|
|
132
|
+
-q, --query <query> # Search query (required)
|
|
133
|
+
--party <party> # Filter: local or remote
|
|
134
|
+
--limit <n> # Max results (default: 50)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### vault
|
|
138
|
+
|
|
139
|
+
Encrypted vault operations. `get`, `create`, and credential listing require a vault key.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
inkbox vault info # Show vault info
|
|
143
|
+
inkbox vault secrets # List secrets (metadata only)
|
|
144
|
+
--type <type> # Filter: login, api_key, ssh_key, key_pair, other
|
|
145
|
+
|
|
146
|
+
inkbox vault get <secret-id> # Decrypt a secret (requires vault key)
|
|
147
|
+
inkbox vault delete <secret-id> # Delete a secret
|
|
148
|
+
|
|
149
|
+
inkbox vault create # Create a secret (requires vault key)
|
|
150
|
+
--name <name> # Secret name (required)
|
|
151
|
+
--type <type> # Secret type (required)
|
|
152
|
+
--description <desc> # Optional description
|
|
153
|
+
|
|
154
|
+
inkbox vault keys # List vault keys
|
|
155
|
+
--type <type> # Filter: primary or recovery
|
|
156
|
+
|
|
157
|
+
inkbox vault logins -i <handle> # List login credentials (vault key)
|
|
158
|
+
inkbox vault api-keys -i <handle> # List API key credentials (vault key)
|
|
159
|
+
inkbox vault ssh-keys -i <handle> # List SSH key credentials (vault key)
|
|
160
|
+
inkbox vault key-pairs -i <handle> # List key pair credentials (vault key)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Secret type flags:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# login
|
|
167
|
+
--password <pass> [--username <user>] [--email <email>] [--url <url>] [--totp-uri <uri>] [--notes <text>]
|
|
168
|
+
|
|
169
|
+
# api_key
|
|
170
|
+
--key <key> [--endpoint <url>] [--notes <text>]
|
|
171
|
+
|
|
172
|
+
# key_pair
|
|
173
|
+
--access-key <key> --secret-key <key> [--endpoint <url>] [--notes <text>]
|
|
174
|
+
|
|
175
|
+
# ssh_key
|
|
176
|
+
--private-key <key> [--public-key <key>] [--fingerprint <fp>] [--passphrase <pass>] [--notes <text>]
|
|
177
|
+
|
|
178
|
+
# other
|
|
179
|
+
--data <json> [--notes <text>]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### mailbox
|
|
183
|
+
|
|
184
|
+
Org-level mailbox management.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
inkbox mailbox list # List all mailboxes
|
|
188
|
+
inkbox mailbox get <email-address> # Get mailbox details
|
|
189
|
+
inkbox mailbox create # Create a mailbox
|
|
190
|
+
--handle <handle> # Agent handle (required)
|
|
191
|
+
--display-name <name> # Display name
|
|
192
|
+
inkbox mailbox update <email-address> # Update a mailbox
|
|
193
|
+
--display-name <name> # New display name
|
|
194
|
+
--webhook-url <url> # Webhook URL ("" to clear)
|
|
195
|
+
inkbox mailbox delete <email-address> # Delete a mailbox
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### number
|
|
199
|
+
|
|
200
|
+
Org-level phone number management.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
inkbox number list # List all phone numbers
|
|
204
|
+
inkbox number get <id> # Get phone number details
|
|
205
|
+
inkbox number provision # Provision a new number
|
|
206
|
+
--handle <handle> # Agent handle (required)
|
|
207
|
+
--type <type> # toll_free or local (default: toll_free)
|
|
208
|
+
--state <state> # US state abbreviation (for local)
|
|
209
|
+
inkbox number update <id> # Update phone number config
|
|
210
|
+
--incoming-call-action <action> # auto_accept, auto_reject, or webhook
|
|
211
|
+
--client-websocket-url <url> # WebSocket URL for audio bridging
|
|
212
|
+
--incoming-call-webhook-url <url> # Webhook URL for incoming calls
|
|
213
|
+
inkbox number release <number-id> # Release a phone number
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### signing-key
|
|
217
|
+
|
|
218
|
+
Webhook signing key management.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
inkbox signing-key create # Create or rotate signing key
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### webhook
|
|
225
|
+
|
|
226
|
+
Webhook utilities.
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
inkbox webhook verify # Verify a webhook signature (local)
|
|
230
|
+
--payload <payload> # Raw request body (required)
|
|
231
|
+
--secret <secret> # Signing key (required)
|
|
232
|
+
-H, --header <header> # Header in Key: Value format (repeatable)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Global options
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
--api-key <key> Inkbox API key (or set INKBOX_API_KEY)
|
|
239
|
+
--vault-key <key> Vault key for decrypt operations (or set INKBOX_VAULT_KEY)
|
|
240
|
+
--base-url <url> Override API base URL
|
|
241
|
+
--json Output as JSON (default: formatted tables)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
MIT
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Inkbox } from "@inkbox/sdk";
|
|
2
|
+
export function getGlobalOpts(cmd) {
|
|
3
|
+
let root = cmd;
|
|
4
|
+
while (root.parent)
|
|
5
|
+
root = root.parent;
|
|
6
|
+
return root.opts();
|
|
7
|
+
}
|
|
8
|
+
export function createClient(opts) {
|
|
9
|
+
const apiKey = opts.apiKey ?? process.env.INKBOX_API_KEY;
|
|
10
|
+
if (!apiKey) {
|
|
11
|
+
console.error("Error: API key required. Set INKBOX_API_KEY or pass --api-key.");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const vaultKey = opts.vaultKey ?? process.env.INKBOX_VAULT_KEY;
|
|
15
|
+
return new Inkbox({
|
|
16
|
+
apiKey,
|
|
17
|
+
vaultKey: vaultKey || undefined,
|
|
18
|
+
baseUrl: opts.baseUrl,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,IAAI,GAAG,GAAG,CAAC;IACf,OAAO,IAAI,CAAC,MAAM;QAAE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACvC,OAAO,IAAI,CAAC,IAAI,EAAgB,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CACX,gEAAgE,CACjE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC/D,OAAO,IAAI,MAAM,CAAC;QAChB,MAAM;QACN,QAAQ,EAAE,QAAQ,IAAI,SAAS;QAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createClient, getGlobalOpts } from "../client.js";
|
|
2
|
+
import { output } from "../output.js";
|
|
3
|
+
import { withErrorHandler } from "../errors.js";
|
|
4
|
+
export function registerEmailCommands(program) {
|
|
5
|
+
const email = program
|
|
6
|
+
.command("email")
|
|
7
|
+
.description("Email operations (identity-scoped)");
|
|
8
|
+
email
|
|
9
|
+
.command("send")
|
|
10
|
+
.description("Send an email")
|
|
11
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
12
|
+
.requiredOption("--to <addresses>", "Comma-separated recipient addresses")
|
|
13
|
+
.requiredOption("--subject <subject>", "Email subject")
|
|
14
|
+
.option("--body-text <text>", "Plain text body")
|
|
15
|
+
.option("--body-html <html>", "HTML body")
|
|
16
|
+
.option("--cc <addresses>", "Comma-separated CC addresses")
|
|
17
|
+
.option("--bcc <addresses>", "Comma-separated BCC addresses")
|
|
18
|
+
.option("--in-reply-to <message-id>", "Message ID to reply to")
|
|
19
|
+
.action(withErrorHandler(async function (cmdOpts) {
|
|
20
|
+
const opts = getGlobalOpts(this);
|
|
21
|
+
const inkbox = createClient(opts);
|
|
22
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
23
|
+
const msg = await identity.sendEmail({
|
|
24
|
+
to: cmdOpts.to.split(",").map((s) => s.trim()),
|
|
25
|
+
subject: cmdOpts.subject,
|
|
26
|
+
bodyText: cmdOpts.bodyText,
|
|
27
|
+
bodyHtml: cmdOpts.bodyHtml,
|
|
28
|
+
cc: cmdOpts.cc?.split(",").map((s) => s.trim()),
|
|
29
|
+
bcc: cmdOpts.bcc?.split(",").map((s) => s.trim()),
|
|
30
|
+
inReplyToMessageId: cmdOpts.inReplyTo,
|
|
31
|
+
});
|
|
32
|
+
output({
|
|
33
|
+
id: msg.id,
|
|
34
|
+
subject: msg.subject,
|
|
35
|
+
to: msg.toAddresses.join(", "),
|
|
36
|
+
status: msg.status,
|
|
37
|
+
}, { json: !!opts.json });
|
|
38
|
+
}));
|
|
39
|
+
email
|
|
40
|
+
.command("list")
|
|
41
|
+
.description("List emails")
|
|
42
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
43
|
+
.option("--direction <dir>", "Filter: inbound or outbound")
|
|
44
|
+
.option("--limit <n>", "Max messages to show", "50")
|
|
45
|
+
.action(withErrorHandler(async function (cmdOpts) {
|
|
46
|
+
const opts = getGlobalOpts(this);
|
|
47
|
+
const inkbox = createClient(opts);
|
|
48
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
49
|
+
const limit = parseInt(cmdOpts.limit, 10);
|
|
50
|
+
const messages = [];
|
|
51
|
+
for await (const msg of identity.iterEmails({
|
|
52
|
+
direction: cmdOpts.direction,
|
|
53
|
+
})) {
|
|
54
|
+
messages.push(msg);
|
|
55
|
+
if (messages.length >= limit)
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
output(messages, {
|
|
59
|
+
json: !!opts.json,
|
|
60
|
+
columns: [
|
|
61
|
+
"id",
|
|
62
|
+
"direction",
|
|
63
|
+
"fromAddress",
|
|
64
|
+
"subject",
|
|
65
|
+
"isRead",
|
|
66
|
+
"createdAt",
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
}));
|
|
70
|
+
email
|
|
71
|
+
.command("get <message-id>")
|
|
72
|
+
.description("Get a message with full body")
|
|
73
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
74
|
+
.action(withErrorHandler(async function (messageId, cmdOpts) {
|
|
75
|
+
const opts = getGlobalOpts(this);
|
|
76
|
+
const inkbox = createClient(opts);
|
|
77
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
78
|
+
const msg = await identity.getMessage(messageId);
|
|
79
|
+
output({
|
|
80
|
+
id: msg.id,
|
|
81
|
+
threadId: msg.threadId,
|
|
82
|
+
from: msg.fromAddress,
|
|
83
|
+
to: msg.toAddresses.join(", "),
|
|
84
|
+
subject: msg.subject,
|
|
85
|
+
direction: msg.direction,
|
|
86
|
+
isRead: msg.isRead,
|
|
87
|
+
createdAt: msg.createdAt,
|
|
88
|
+
bodyText: msg.bodyText,
|
|
89
|
+
}, { json: !!opts.json });
|
|
90
|
+
}));
|
|
91
|
+
email
|
|
92
|
+
.command("search")
|
|
93
|
+
.description("Search emails")
|
|
94
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
95
|
+
.requiredOption("-q, --query <query>", "Search query")
|
|
96
|
+
.option("--limit <n>", "Max results", "50")
|
|
97
|
+
.action(withErrorHandler(async function (cmdOpts) {
|
|
98
|
+
const opts = getGlobalOpts(this);
|
|
99
|
+
const inkbox = createClient(opts);
|
|
100
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
101
|
+
if (!identity.mailbox) {
|
|
102
|
+
console.error(`Identity '${cmdOpts.identity}' has no mailbox assigned.`);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
const messages = await inkbox.mailboxes.search(identity.mailbox.emailAddress, { q: cmdOpts.query, limit: parseInt(cmdOpts.limit, 10) });
|
|
106
|
+
output(messages, {
|
|
107
|
+
json: !!opts.json,
|
|
108
|
+
columns: [
|
|
109
|
+
"id",
|
|
110
|
+
"direction",
|
|
111
|
+
"fromAddress",
|
|
112
|
+
"subject",
|
|
113
|
+
"createdAt",
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
}));
|
|
117
|
+
email
|
|
118
|
+
.command("unread")
|
|
119
|
+
.description("List unread emails")
|
|
120
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
121
|
+
.option("--direction <dir>", "Filter: inbound or outbound")
|
|
122
|
+
.option("--limit <n>", "Max messages to show", "50")
|
|
123
|
+
.action(withErrorHandler(async function (cmdOpts) {
|
|
124
|
+
const opts = getGlobalOpts(this);
|
|
125
|
+
const inkbox = createClient(opts);
|
|
126
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
127
|
+
const limit = parseInt(cmdOpts.limit, 10);
|
|
128
|
+
const messages = [];
|
|
129
|
+
for await (const msg of identity.iterUnreadEmails({
|
|
130
|
+
direction: cmdOpts.direction,
|
|
131
|
+
})) {
|
|
132
|
+
messages.push(msg);
|
|
133
|
+
if (messages.length >= limit)
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
output(messages, {
|
|
137
|
+
json: !!opts.json,
|
|
138
|
+
columns: [
|
|
139
|
+
"id",
|
|
140
|
+
"direction",
|
|
141
|
+
"fromAddress",
|
|
142
|
+
"subject",
|
|
143
|
+
"createdAt",
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
}));
|
|
147
|
+
email
|
|
148
|
+
.command("mark-read <message-ids...>")
|
|
149
|
+
.description("Mark messages as read")
|
|
150
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
151
|
+
.action(withErrorHandler(async function (messageIds, cmdOpts) {
|
|
152
|
+
const opts = getGlobalOpts(this);
|
|
153
|
+
const inkbox = createClient(opts);
|
|
154
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
155
|
+
await identity.markEmailsRead(messageIds);
|
|
156
|
+
console.log(`Marked ${messageIds.length} message(s) as read.`);
|
|
157
|
+
}));
|
|
158
|
+
email
|
|
159
|
+
.command("thread <thread-id>")
|
|
160
|
+
.description("Get an email thread with all messages")
|
|
161
|
+
.requiredOption("-i, --identity <handle>", "Agent identity handle")
|
|
162
|
+
.action(withErrorHandler(async function (threadId, cmdOpts) {
|
|
163
|
+
const opts = getGlobalOpts(this);
|
|
164
|
+
const inkbox = createClient(opts);
|
|
165
|
+
const identity = await inkbox.getIdentity(cmdOpts.identity);
|
|
166
|
+
const thread = await identity.getThread(threadId);
|
|
167
|
+
if (opts.json) {
|
|
168
|
+
output(thread, { json: true });
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
output({ id: thread.id, subject: thread.subject, messageCount: thread.messages.length }, { json: false });
|
|
172
|
+
console.log("");
|
|
173
|
+
output(thread.messages, {
|
|
174
|
+
json: false,
|
|
175
|
+
columns: [
|
|
176
|
+
"id",
|
|
177
|
+
"direction",
|
|
178
|
+
"fromAddress",
|
|
179
|
+
"subject",
|
|
180
|
+
"isRead",
|
|
181
|
+
"createdAt",
|
|
182
|
+
],
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../src/commands/email.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,MAAM,KAAK,GAAG,OAAO;SAClB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,oCAAoC,CAAC,CAAC;IAErD,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,eAAe,CAAC;SAC5B,cAAc,CAAC,yBAAyB,EAAE,uBAAuB,CAAC;SAClE,cAAc,CAAC,kBAAkB,EAAE,qCAAqC,CAAC;SACzE,cAAc,CAAC,qBAAqB,EAAE,eAAe,CAAC;SACtD,MAAM,CAAC,oBAAoB,EAAE,iBAAiB,CAAC;SAC/C,MAAM,CAAC,oBAAoB,EAAE,WAAW,CAAC;SACzC,MAAM,CAAC,kBAAkB,EAAE,8BAA8B,CAAC;SAC1D,MAAM,CAAC,mBAAmB,EAAE,+BAA+B,CAAC;SAC5D,MAAM,CAAC,4BAA4B,EAAE,wBAAwB,CAAC;SAC9D,MAAM,CACL,gBAAgB,CAAC,KAAK,WAEpB,OASC;QAED,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAA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