shalomail 0.0.0-stage → 0.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.
- package/README.md +101 -2
- package/dist/index.d.ts +82 -0
- package/dist/index.mjs +64 -0
- package/dist/shalom.mjs +123 -0
- package/package.json +40 -4
package/README.md
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
#
|
|
1
|
+
# shalom
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Give your AI agents a real, end-to-end encrypted email address.
|
|
4
|
+
|
|
5
|
+
`shalom` is the command line for [Shalom Mail](https://shalomail.com). Each agent gets its own `@shalomail.com` mailbox. It receives, reads and sends real email, from Shalom or from anywhere, and every command speaks JSON. The mailbox's private key is created on the agent's machine and never leaves it: the server stores mail sealed and cannot read it.
|
|
6
|
+
|
|
7
|
+
## Start
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g shalomail # Node.js 20 or newer
|
|
11
|
+
shalom login # opens shalomail.com to connect this terminal
|
|
12
|
+
shalom agents create support # creates support@shalomail.com
|
|
13
|
+
```
|
|
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
|
+
|
|
32
|
+
## Read, reply and send
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
shalom inbox --json
|
|
36
|
+
shalom read 3f9c2a1b --json
|
|
37
|
+
shalom reply 3f9c2a1b --text "Got it, thanks."
|
|
38
|
+
shalom send --to ana@example.com --subject "Weekly report" \
|
|
39
|
+
--text-file report.md --attach report.pdf
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Ids can be shortened to their first 8 characters. Text can also come from standard input.
|
|
43
|
+
|
|
44
|
+
## React to every new email
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
shalom watch --exec "python agent.py" --mark-read
|
|
48
|
+
```
|
|
49
|
+
|
|
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`.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# agent.py
|
|
54
|
+
import json, subprocess, sys
|
|
55
|
+
msg = json.load(sys.stdin)
|
|
56
|
+
answer = f"Hi {msg['from']['name'] or 'there'}, we received: {msg['subject']}"
|
|
57
|
+
subprocess.run(["shalom", "reply", msg["id"], "--text", answer], check=True)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Run it on a server
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
shalom agents export support@shalomail.com # prints SHALOM_AGENT_TOKEN
|
|
64
|
+
SHALOM_AGENT_TOKEN=shalom_agent_... shalom inbox --json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Store the token as a secret: it contains the mailbox's private key.
|
|
68
|
+
|
|
69
|
+
## Commands
|
|
70
|
+
|
|
71
|
+
| Command | What it does |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| `shalom login` | Connects this terminal to your account in the browser (`--no-browser`, `--key`) |
|
|
74
|
+
| `shalom agents list` | Lists your agent mailboxes and your plan |
|
|
75
|
+
| `shalom agents create <name>` | Creates `<name>@shalomail.com`, with the private key on this machine |
|
|
76
|
+
| `shalom agents delete <address>` | Deletes the mailbox and all its mail; the address stays reserved for you |
|
|
77
|
+
| `shalom agents rotate <address>` | Issues a new API key for the mailbox |
|
|
78
|
+
| `shalom agents export <address>` | Prints `SHALOM_AGENT_TOKEN` |
|
|
79
|
+
| `shalom agents import <token>` | Saves an exported mailbox on this machine |
|
|
80
|
+
| `shalom plan` / `shalom upgrade <5\|12\|unlimited>` | Shows your plan, or opens checkout |
|
|
81
|
+
| `shalom inbox` | Lists messages (`--folder`, `--limit`, `--unread`) |
|
|
82
|
+
| `shalom read <id>` | Opens a message (`--save-attachments <dir>`) |
|
|
83
|
+
| `shalom send` | Sends a message (`--to`, `--cc`, `--bcc`, `--subject`, `--text`, `--text-file`, `--html-file`, `--attach`) |
|
|
84
|
+
| `shalom reply <id>` | Replies in the same thread (`--all`) |
|
|
85
|
+
| `shalom move <id> --to <folder>` | Moves to inbox, archive, spam or trash |
|
|
86
|
+
| `shalom mark <id>` | `--read`, `--unread`, `--star`, `--unstar` |
|
|
87
|
+
| `shalom watch` | Waits for new mail (`--exec`, `--interval`, `--mark-read`) |
|
|
88
|
+
|
|
89
|
+
Every command accepts `--json`, `--as <address>` to pick the mailbox, and `--api <url>`.
|
|
90
|
+
|
|
91
|
+
## Security
|
|
92
|
+
|
|
93
|
+
- Each mailbox's private key stays in `~/.config/shalom` (folder 700, files 600) or in your `SHALOM_AGENT_TOKEN`.
|
|
94
|
+
- Your account key only creates and deletes agent mailboxes. Each mailbox's key only reads and sends through it.
|
|
95
|
+
- Between Shalom addresses, mail is sealed end to end and the sender is verified. To other providers it goes as regular email.
|
|
96
|
+
- The encryption keys of Shalom contacts are pinned on first use; if one changes, sending stops until you confirm with `--trust-new-key`.
|
|
97
|
+
|
|
98
|
+
## Plans
|
|
99
|
+
|
|
100
|
+
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 or with `shalom upgrade`.
|
|
101
|
+
|
|
102
|
+
Docs: https://shalomail.com/en/agents/
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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 (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. */
|
|
71
|
+
watch(opts?: { interval?: number; signal?: AbortSignal; includeExisting?: 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
|
+
deleteAgent(address: string): Promise<void>;
|
|
82
|
+
}
|