shalomail 0.1.0 → 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 +30 -12
- package/dist/index.d.ts +83 -0
- package/dist/index.mjs +64 -0
- package/dist/shalom.mjs +69 -62
- package/package.json +35 -7
package/README.md
CHANGED
|
@@ -8,10 +8,27 @@ Give your AI agents a real, end-to-end encrypted email address.
|
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
npm install -g shalomail # Node.js 20 or newer
|
|
11
|
-
shalom login #
|
|
12
|
-
shalom agents create
|
|
11
|
+
shalom login # opens shalomail.com to connect this terminal
|
|
12
|
+
shalom agents create yourname-bot # creates yourname-bot@shalomail.com
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
No global install? `npx shalomail <command>` works anywhere, for example `npx shalomail login`. The command answers to both `shalom` and `shalomail`.
|
|
16
|
+
|
|
17
|
+
On a machine without a browser (SSH, server), `shalom login --no-browser` prints the link and the code: open it on any device where you are signed in to Shalom and confirm. For CI, `shalom login --key shalom_sk_...` uses an API key created on the AI agents page.
|
|
18
|
+
|
|
19
|
+
## Use it from code
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { Agent } from 'shalomail';
|
|
23
|
+
|
|
24
|
+
const agent = Agent.fromToken(process.env.SHALOM_AGENT_TOKEN);
|
|
25
|
+
for await (const msg of agent.watch()) {
|
|
26
|
+
await agent.reply(msg.id, { text: `Got it: ${msg.subject}` });
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Full SDK and HTTP API reference: https://shalomail.com/developers/
|
|
31
|
+
|
|
15
32
|
## Read, reply and send
|
|
16
33
|
|
|
17
34
|
```sh
|
|
@@ -30,7 +47,7 @@ Ids can be shortened to their first 8 characters. Text can also come from standa
|
|
|
30
47
|
shalom watch --exec "python agent.py" --mark-read
|
|
31
48
|
```
|
|
32
49
|
|
|
33
|
-
`watch` waits for new mail and runs your program once per message, with the message as JSON on standard input: `id`, `from`, `to`, `cc`, `subject`, `date`, `text`, `html`, `messageId`, `verifiedSender` and `attachments`. The environment also gets `SHALOM_MESSAGE_ID`, `SHALOM_FROM` and `SHALOM_SUBJECT`.
|
|
50
|
+
`watch` waits for new mail and runs your program once per message, with the message as JSON on standard input: `id`, `from`, `to`, `cc`, `subject`, `date`, `text`, `html`, `messageId`, `verifiedSender` and `attachments`. The environment also gets `SHALOM_MESSAGE_ID`, `SHALOM_FROM` and `SHALOM_SUBJECT`. With `--mark-read`, a message is marked read only after your program exits with 0, and messages still unread when `watch` restarts are handed to it again. In the SDK, `agent.watch({ includeUnread: true })` does the same.
|
|
34
51
|
|
|
35
52
|
```python
|
|
36
53
|
# agent.py
|
|
@@ -43,24 +60,24 @@ subprocess.run(["shalom", "reply", msg["id"], "--text", answer], check=True)
|
|
|
43
60
|
## Run it on a server
|
|
44
61
|
|
|
45
62
|
```sh
|
|
46
|
-
shalom agents export
|
|
63
|
+
shalom agents export yourname-bot@shalomail.com # prints SHALOM_AGENT_TOKEN
|
|
47
64
|
SHALOM_AGENT_TOKEN=shalom_agent_... shalom inbox --json
|
|
48
65
|
```
|
|
49
66
|
|
|
50
|
-
Store the token as a secret: it contains the mailbox's private key.
|
|
67
|
+
Store the token as a secret: it contains the mailbox's private key. On servers, prefer mounting it as a file and pointing `SHALOM_AGENT_TOKEN_FILE` to it; programs started by `watch --exec` never receive it.
|
|
51
68
|
|
|
52
69
|
## Commands
|
|
53
70
|
|
|
54
71
|
| Command | What it does |
|
|
55
72
|
| --- | --- |
|
|
56
|
-
| `shalom login` |
|
|
73
|
+
| `shalom login` | Connects this terminal to your account in the browser (`--no-browser`, `--key`) |
|
|
57
74
|
| `shalom agents list` | Lists your agent mailboxes and your plan |
|
|
58
75
|
| `shalom agents create <name>` | Creates `<name>@shalomail.com`, with the private key on this machine |
|
|
59
|
-
| `shalom agents delete <address>` | Deletes the mailbox and all its mail; the address stays reserved for you |
|
|
60
|
-
| `shalom agents rotate <address>` | Issues a new API key for the mailbox |
|
|
76
|
+
| `shalom agents delete <address>` | Deletes the mailbox and all its mail (needs the mailbox saved on this machine); the address stays reserved for you |
|
|
77
|
+
| `shalom agents rotate <address>` | Issues a new API key for the mailbox, sealed to its private key |
|
|
61
78
|
| `shalom agents export <address>` | Prints `SHALOM_AGENT_TOKEN` |
|
|
62
|
-
| `shalom agents import <token>` | Saves an exported mailbox on this machine |
|
|
63
|
-
| `shalom plan` / `shalom upgrade
|
|
79
|
+
| `shalom agents import <token>` | Saves an exported mailbox on this machine (`--yes` to replace one with other keys) |
|
|
80
|
+
| `shalom plan` / `shalom upgrade` | Shows your plan, or opens the plans page in the app |
|
|
64
81
|
| `shalom inbox` | Lists messages (`--folder`, `--limit`, `--unread`) |
|
|
65
82
|
| `shalom read <id>` | Opens a message (`--save-attachments <dir>`) |
|
|
66
83
|
| `shalom send` | Sends a message (`--to`, `--cc`, `--bcc`, `--subject`, `--text`, `--text-file`, `--html-file`, `--attach`) |
|
|
@@ -74,12 +91,13 @@ Every command accepts `--json`, `--as <address>` to pick the mailbox, and `--api
|
|
|
74
91
|
## Security
|
|
75
92
|
|
|
76
93
|
- Each mailbox's private key stays in `~/.config/shalom` (folder 700, files 600) or in your `SHALOM_AGENT_TOKEN`.
|
|
77
|
-
- Your account key
|
|
94
|
+
- Your account key creates agent mailboxes and shows your plan. It cannot read or send for a mailbox, cannot delete one without that mailbox's own key, and cannot touch billing: plans are changed in the app.
|
|
95
|
+
- The keys of shalomail.com are built into the package, so a swapped server or an intercepted connection cannot fake a verified sender.
|
|
78
96
|
- Between Shalom addresses, mail is sealed end to end and the sender is verified. To other providers it goes as regular email.
|
|
79
97
|
- The encryption keys of Shalom contacts are pinned on first use; if one changes, sending stops until you confirm with `--trust-new-key`.
|
|
80
98
|
|
|
81
99
|
## Plans
|
|
82
100
|
|
|
83
|
-
Free: 2 agent mailboxes. Agents 5: up to 5 for US$ 4.99 a month. Agents 12: up to 12 for US$ 9.99 a month. Subscribe
|
|
101
|
+
Free: 2 agent mailboxes. Agents 5: up to 5 for US$ 4.99 a month. Agents 12: up to 12 for US$ 9.99 a month. Unlimited: no mailbox limit, up to 250 new mailboxes a day, for US$ 49.90 a month. Subscribe on the AI agents page of the app (`shalom upgrade` opens it).
|
|
84
102
|
|
|
85
103
|
Docs: https://shalomail.com/en/agents/
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Types for the shalomail Node SDK: import { Agent, Account } from 'shalomail'.
|
|
2
|
+
|
|
3
|
+
export type Folder = 'inbox' | 'starred' | 'sent' | 'drafts' | 'archive' | 'spam' | 'trash';
|
|
4
|
+
export type Person = { name: string; address: string };
|
|
5
|
+
|
|
6
|
+
export type Summary = {
|
|
7
|
+
id: string;
|
|
8
|
+
folder: string;
|
|
9
|
+
from: Person | null;
|
|
10
|
+
to: Person[];
|
|
11
|
+
subject: string;
|
|
12
|
+
date: string;
|
|
13
|
+
receivedAt: number;
|
|
14
|
+
snippet: string;
|
|
15
|
+
attachments: number;
|
|
16
|
+
unread: boolean;
|
|
17
|
+
starred: boolean;
|
|
18
|
+
/** Shalom to Shalom: sender verified by the server certificate and sealed end to end. */
|
|
19
|
+
verifiedSender: boolean;
|
|
20
|
+
/** Mail from other providers: DMARC result seen on arrival. */
|
|
21
|
+
auth: 'pass' | 'fail' | 'unknown';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type Message = Omit<Summary, 'attachments'> & {
|
|
25
|
+
messageId: string | null;
|
|
26
|
+
inReplyTo: string | null;
|
|
27
|
+
references: string | null;
|
|
28
|
+
replyTo: Person[];
|
|
29
|
+
cc: Person[];
|
|
30
|
+
text: string;
|
|
31
|
+
html: string | null;
|
|
32
|
+
attachments: { filename: string; mimeType: string; size: number; content: Uint8Array }[];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type Attachment = { filename: string; content: Uint8Array; type?: string };
|
|
36
|
+
|
|
37
|
+
export type SendInput = {
|
|
38
|
+
to: string | string[];
|
|
39
|
+
cc?: string | string[];
|
|
40
|
+
bcc?: string | string[];
|
|
41
|
+
subject: string;
|
|
42
|
+
text: string;
|
|
43
|
+
html?: string;
|
|
44
|
+
attachments?: Attachment[];
|
|
45
|
+
inReplyTo?: string;
|
|
46
|
+
references?: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type SendResult = { id: string; external: number; internal: number };
|
|
50
|
+
|
|
51
|
+
export declare class ApiError extends Error {
|
|
52
|
+
status: number;
|
|
53
|
+
code: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One agent mailbox. Opening, sealing and sending happen on your machine. */
|
|
57
|
+
export declare class Agent {
|
|
58
|
+
/** From SHALOM_AGENT_TOKEN or the file in SHALOM_AGENT_TOKEN_FILE (see `shalom agents export`). */
|
|
59
|
+
static fromToken(token?: string, opts?: { api?: string }): Agent;
|
|
60
|
+
/** From the file the CLI saved in ~/.config/shalom/agents. */
|
|
61
|
+
static fromFile(address: string, opts?: { api?: string }): Agent;
|
|
62
|
+
readonly address: string;
|
|
63
|
+
inbox(opts?: { folder?: Folder; limit?: number; unread?: boolean }): Promise<Summary[]>;
|
|
64
|
+
/** Marks the message as read unless markRead is false. Ids can be shortened to 8 characters. */
|
|
65
|
+
read(id: string, opts?: { markRead?: boolean }): Promise<Message>;
|
|
66
|
+
send(msg: SendInput, opts?: { trustNewKey?: boolean }): Promise<SendResult>;
|
|
67
|
+
reply(id: string, msg: { text: string; html?: string; all?: boolean; quote?: boolean; attachments?: Attachment[] }, opts?: { trustNewKey?: boolean }): Promise<SendResult>;
|
|
68
|
+
move(ids: string | string[], folder: 'inbox' | 'archive' | 'spam' | 'trash'): Promise<void>;
|
|
69
|
+
mark(ids: string | string[], change: { read?: boolean; starred?: boolean }): Promise<void>;
|
|
70
|
+
/** New inbox messages, one at a time, until the loop breaks or the signal aborts. includeUnread also yields the unread ones already there, to resume after a restart. */
|
|
71
|
+
watch(opts?: { interval?: number; signal?: AbortSignal; includeExisting?: boolean; includeUnread?: boolean }): AsyncGenerator<Message>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Your account: creates and deletes agent mailboxes with the account API key. */
|
|
75
|
+
export declare class Account {
|
|
76
|
+
constructor(apiKey?: string, opts?: { api?: string });
|
|
77
|
+
/** plan.limit is null on the Unlimited plan. */
|
|
78
|
+
listAgents(): Promise<{ agents: { id: string; address: string; name: string; createdAt: number; paused: boolean }[]; plan: { plan: string; limit: number | null; used: number } }>;
|
|
79
|
+
/** The mailbox private key is created here. The returned token is the full credential: store it as a secret. */
|
|
80
|
+
createAgent(name: string, opts?: { displayName?: string; save?: boolean }): Promise<{ id: string; address: string; name: string; token: string }>;
|
|
81
|
+
/** Needs the mailbox's own credential: { token }, or the file the CLI saved. Or delete it in the app. */
|
|
82
|
+
deleteAgent(address: string, opts?: { token?: string }): Promise<void>;
|
|
83
|
+
}
|