surface-cli 0.3.4 → 0.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 +74 -15
- package/dist/cli.js +67 -5
- package/dist/cli.js.map +1 -1
- package/dist/contracts/account.js +1 -1
- package/dist/contracts/account.js.map +1 -1
- package/dist/lib/skill-install.js +55 -0
- package/dist/lib/skill-install.js.map +1 -0
- package/dist/providers/imap/adapter.js +1627 -0
- package/dist/providers/imap/adapter.js.map +1 -0
- package/dist/providers/imap/adapter.test.js +295 -0
- package/dist/providers/imap/adapter.test.js.map +1 -0
- package/dist/providers/imap/auth.js +159 -0
- package/dist/providers/imap/auth.js.map +1 -0
- package/dist/providers/imap/auth.test.js +36 -0
- package/dist/providers/imap/auth.test.js.map +1 -0
- package/dist/providers/index.js +6 -1
- package/dist/providers/index.js.map +1 -1
- package/package.json +12 -4
- package/skills/surface-cli/SKILL.md +338 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { imapAuthTestHooks } from "./auth.js";
|
|
4
|
+
function account() {
|
|
5
|
+
return {
|
|
6
|
+
account_id: "acc_imap",
|
|
7
|
+
name: "imap",
|
|
8
|
+
provider: "imap",
|
|
9
|
+
transport: "imap-smtp",
|
|
10
|
+
email: "surface@example.com",
|
|
11
|
+
created_at: "2026-06-03T12:00:00.000Z",
|
|
12
|
+
updated_at: "2026-06-03T12:00:00.000Z",
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
test("failing password-command errors are redacted", () => {
|
|
16
|
+
const command = `${process.execPath} -e "console.error('DO_NOT_LEAK_SECRET'); process.exit(7)"`;
|
|
17
|
+
let thrown;
|
|
18
|
+
try {
|
|
19
|
+
imapAuthTestHooks.resolvePassword({ passwordCommand: command }, account());
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
thrown = error;
|
|
23
|
+
}
|
|
24
|
+
assert.ok(thrown instanceof Error);
|
|
25
|
+
assert.equal(thrown.message, "IMAP/SMTP password command failed.");
|
|
26
|
+
assert.doesNotMatch(thrown.message, /DO_NOT_LEAK_SECRET/);
|
|
27
|
+
assert.doesNotMatch(thrown.message, /process\.exit/);
|
|
28
|
+
assert.doesNotMatch(thrown.message, new RegExp(process.execPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")));
|
|
29
|
+
});
|
|
30
|
+
test("direct password source returns the password flag value", () => {
|
|
31
|
+
assert.equal(imapAuthTestHooks.resolvePassword({ password: "mailbox-secret" }, account()), "mailbox-secret");
|
|
32
|
+
});
|
|
33
|
+
test("password sources are mutually exclusive", () => {
|
|
34
|
+
assert.throws(() => imapAuthTestHooks.resolvePassword({ password: "mailbox-secret", passwordEnv: "SURFACE_GMX_PASSWORD" }, account()), /exactly one of --password, --password-env, --password-file, or --password-command/);
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=auth.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.test.js","sourceRoot":"","sources":["../../../src/providers/imap/auth.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,SAAS,OAAO;IACd,OAAO;QACL,UAAU,EAAE,UAAU;QACtB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,WAAW;QACtB,KAAK,EAAE,qBAAqB;QAC5B,UAAU,EAAE,0BAA0B;QACtC,UAAU,EAAE,0BAA0B;KACvC,CAAC;AACJ,CAAC;AAED,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACxD,MAAM,OAAO,GAAG,GAAG,OAAO,CAAC,QAAQ,4DAA4D,CAAC;IAEhG,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,iBAAiB,CAAC,eAAe,CAAC,EAAE,eAAe,EAAE,OAAO,EAAsB,EAAE,OAAO,EAAE,CAAC,CAAC;IACjG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;IACnC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,oCAAoC,CAAC,CAAC;IACnE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAC1D,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACrD,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;AAC3G,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wDAAwD,EAAE,GAAG,EAAE;IAClE,MAAM,CAAC,KAAK,CACV,iBAAiB,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAsB,EAAE,OAAO,EAAE,CAAC,EAChG,gBAAgB,CACjB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACnD,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,CAAC,iBAAiB,CAAC,eAAe,CACrC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB,EAAsB,EACvF,OAAO,EAAE,CACV,EACD,mFAAmF,CACpF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/providers/index.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { SurfaceError } from "../lib/errors.js";
|
|
2
2
|
import { GmailApiAdapter } from "./gmail/adapter.js";
|
|
3
|
+
import { ImapSmtpAdapter } from "./imap/adapter.js";
|
|
3
4
|
import { OutlookWebPlaywrightAdapter } from "./outlook/adapter.js";
|
|
4
|
-
const providers = [
|
|
5
|
+
const providers = [
|
|
6
|
+
new GmailApiAdapter(),
|
|
7
|
+
new OutlookWebPlaywrightAdapter(),
|
|
8
|
+
new ImapSmtpAdapter(),
|
|
9
|
+
];
|
|
5
10
|
export function resolveProviderAdapter(account) {
|
|
6
11
|
const adapter = providers.find((candidate) => candidate.provider === account.provider && candidate.transport === account.transport);
|
|
7
12
|
if (!adapter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE,MAAM,SAAS,GAA0B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE,MAAM,SAAS,GAA0B;IACvC,IAAI,eAAe,EAAE;IACrB,IAAI,2BAA2B,EAAE;IACjC,IAAI,eAAe,EAAE;CACtB,CAAC;AAEF,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAC5B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,IAAI,SAAS,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,CACpG,CAAC;IAEF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,YAAY,CACpB,uBAAuB,EACvB,yCAAyC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,SAAS,GAAG,EACjF,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAC1B,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "surface-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A lean, local-first mail CLI for Gmail and
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A lean, local-first mail CLI for Gmail, Outlook, and generic IMAP with a JSON-first contract for automation.",
|
|
5
5
|
"homepage": "https://github.com/VishalJ99/surface-cli",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -16,17 +16,20 @@
|
|
|
16
16
|
"gmail",
|
|
17
17
|
"outlook",
|
|
18
18
|
"automation",
|
|
19
|
-
"openclaw"
|
|
19
|
+
"openclaw",
|
|
20
|
+
"codex",
|
|
21
|
+
"claude-code"
|
|
20
22
|
],
|
|
21
23
|
"type": "module",
|
|
22
24
|
"bin": {
|
|
23
25
|
"surface": "dist/cli.js"
|
|
24
26
|
},
|
|
25
27
|
"engines": {
|
|
26
|
-
"node": ">=20"
|
|
28
|
+
"node": ">=20.19.0"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
29
31
|
"dist",
|
|
32
|
+
"skills",
|
|
30
33
|
"README.md"
|
|
31
34
|
],
|
|
32
35
|
"scripts": {
|
|
@@ -41,6 +44,9 @@
|
|
|
41
44
|
"dependencies": {
|
|
42
45
|
"better-sqlite3": "^12.8.0",
|
|
43
46
|
"commander": "^14.0.3",
|
|
47
|
+
"imapflow": "^1.3.5",
|
|
48
|
+
"mailparser": "^3.9.9",
|
|
49
|
+
"nodemailer": "^8.0.10",
|
|
44
50
|
"playwright-core": "^1.55.0",
|
|
45
51
|
"smol-toml": "^1.6.1",
|
|
46
52
|
"ulid": "^3.0.2",
|
|
@@ -48,7 +54,9 @@
|
|
|
48
54
|
},
|
|
49
55
|
"devDependencies": {
|
|
50
56
|
"@types/better-sqlite3": "^7.6.13",
|
|
57
|
+
"@types/mailparser": "^3.4.6",
|
|
51
58
|
"@types/node": "^25.5.2",
|
|
59
|
+
"@types/nodemailer": "^8.0.0",
|
|
52
60
|
"tsx": "^4.21.0",
|
|
53
61
|
"typescript": "^6.0.2"
|
|
54
62
|
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: surface-cli
|
|
3
|
+
description: "Use the Surface mail CLI to read and act on Gmail, Outlook, and generic IMAP/SMTP mail through one JSON-first contract. Prefer this skill when you need Outlook access for school or work accounts that do not expose IMAP, or generic IMAP for providers such as GMX, plus stable refs for unread fetch, sent-message lookup, structured search, thread refresh, message read, attachments, send or draft, archive, mark read or unread, and provider-supported RSVP."
|
|
4
|
+
metadata:
|
|
5
|
+
{
|
|
6
|
+
"openclaw":
|
|
7
|
+
{
|
|
8
|
+
"emoji": "📬",
|
|
9
|
+
"homepage": "https://github.com/VishalJ99/surface-cli",
|
|
10
|
+
"requires": { "bins": ["surface"] },
|
|
11
|
+
"install":
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
"id": "node",
|
|
15
|
+
"kind": "node",
|
|
16
|
+
"package": "surface-cli",
|
|
17
|
+
"bins": ["surface"],
|
|
18
|
+
"label": "Install Surface CLI (npm)",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# Surface CLI
|
|
26
|
+
|
|
27
|
+
Surface is a local-first mail CLI for Gmail, Outlook, and generic IMAP/SMTP. It is especially
|
|
28
|
+
useful for Outlook school or work accounts that only work through the web UI, and for mail
|
|
29
|
+
providers such as GMX that expose standard IMAP and SMTP settings. Surface prints
|
|
30
|
+
machine-readable JSON to stdout and stores local state in `~/.surface-cli`.
|
|
31
|
+
|
|
32
|
+
## Use This Skill When
|
|
33
|
+
|
|
34
|
+
- the user wants to read or triage email from Gmail, Outlook, or an IMAP mailbox
|
|
35
|
+
- the user needs a provider-neutral CLI for search, unread fetch, read, attachments, or actions
|
|
36
|
+
- you need stable `thread_ref` / `message_ref` values for follow-up commands or thread watching
|
|
37
|
+
|
|
38
|
+
## Prerequisites
|
|
39
|
+
|
|
40
|
+
1. Surface CLI installed (`surface --help` should work)
|
|
41
|
+
2. At least one configured account
|
|
42
|
+
3. Valid auth for the target account
|
|
43
|
+
|
|
44
|
+
Check setup:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
surface account list
|
|
48
|
+
surface auth status
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If the user asks to install the Surface skill for another agent on the same machine, use:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
surface skill install codex
|
|
55
|
+
surface skill install claude-code
|
|
56
|
+
surface skill install all
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Account Setup
|
|
60
|
+
|
|
61
|
+
Add an account:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
surface account add personal_2 --provider gmail --email you@example.com
|
|
65
|
+
surface account add uni --provider outlook --email you@example.com
|
|
66
|
+
surface account add gmx --provider imap --email you@gmx.com
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For reliable `summary.needs_action`, Surface should know who the account owner is. Gmail auth can
|
|
70
|
+
verify the mailbox email automatically; Outlook may need explicit human identifiers:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
surface account identity set uni --email you@example.com --name "Your Name" --name-alias "FirstName"
|
|
74
|
+
surface account identity show uni
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Log in:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
surface auth login personal_2
|
|
81
|
+
surface auth login uni
|
|
82
|
+
surface auth login gmx \
|
|
83
|
+
--imap-host imap.gmx.com --imap-port 993 --imap-security tls \
|
|
84
|
+
--smtp-host mail.gmx.com --smtp-port 587 --smtp-security starttls \
|
|
85
|
+
--username you@gmx.com \
|
|
86
|
+
--password-env SURFACE_GMX_PASSWORD
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For GMX and similar providers, make sure IMAP/POP3 access is enabled in the
|
|
90
|
+
provider web settings before logging in. Generic IMAP login does not need a
|
|
91
|
+
Google Cloud project, OAuth client JSON, Microsoft Graph app registration, or a
|
|
92
|
+
browser session. It does need the provider's IMAP/SMTP settings and a mailbox or
|
|
93
|
+
app password. `--password <password>` is supported and treats the flag value as
|
|
94
|
+
the password directly, but prefer `--password-env`, `--password-file`, or
|
|
95
|
+
`--password-command` because direct CLI passwords can leak through shell
|
|
96
|
+
history, process listings, terminal logs, or agent transcripts. Do not ask the
|
|
97
|
+
user to paste mailbox passwords into chat or store them in the repo.
|
|
98
|
+
|
|
99
|
+
Local policy lives in:
|
|
100
|
+
|
|
101
|
+
```text
|
|
102
|
+
~/.surface-cli/config.toml
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Important local knobs:
|
|
106
|
+
|
|
107
|
+
- `summarizer_backend`
|
|
108
|
+
- `summarizer_model`
|
|
109
|
+
- `writes_enabled`
|
|
110
|
+
- `send_mode`
|
|
111
|
+
- `test_recipients`
|
|
112
|
+
- `test_account_allowlist`
|
|
113
|
+
|
|
114
|
+
Summarization is opt-in and controlled by the user's local config. Do not change
|
|
115
|
+
`summarizer_backend`, `summarizer_model`, or related environment variables unless the user
|
|
116
|
+
explicitly asks. If an external summarizer backend is enabled, email thread content may be sent to
|
|
117
|
+
the configured model provider; confirm the user accepts that privacy tradeoff before enabling or
|
|
118
|
+
changing summarization.
|
|
119
|
+
|
|
120
|
+
## Common Operations
|
|
121
|
+
|
|
122
|
+
### List Accounts
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
surface account list
|
|
126
|
+
surface auth status
|
|
127
|
+
surface auth status personal_2
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Fetch Unread Threads
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
surface mail fetch-unread --account uni --limit 10
|
|
134
|
+
surface mail fetch-unread --account personal_2 --limit 20
|
|
135
|
+
surface mail fetch-unread --account uni --session sess_01... --limit 10
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Search Mail
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
surface mail search --account uni --text "invoice" --limit 10
|
|
142
|
+
surface mail search --account uni --from registrar@school.edu --subject "waitlist" --limit 10
|
|
143
|
+
surface mail search --account uni --session sess_01... --from registrar@school.edu --limit 10
|
|
144
|
+
surface mail search --account personal_2 --mailbox inbox --label unread --text "sale" --limit 10
|
|
145
|
+
surface mail search --account personal_2 --text "has:attachment newer_than:30d" --limit 5
|
|
146
|
+
surface mail search --account gmx --mailbox inbox --limit 10
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### List Sent Messages
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
surface mail sent --account uni
|
|
153
|
+
surface mail sent --account uni --recipient person@example.com --limit 10
|
|
154
|
+
surface mail sent --account uni --thread thr_01... --limit 10
|
|
155
|
+
surface mail sent --account uni --session sess_01... --recipient person@example.com --limit 10
|
|
156
|
+
surface mail sent --account personal_2 --limit 10
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`sent` is message-first. Its default limit is the last 10 sent messages, not threads. Each returned
|
|
160
|
+
message includes `message_ref` and `thread_ref`; use `surface mail thread get <thread_ref>
|
|
161
|
+
--refresh` when you need the full conversation around a sent message.
|
|
162
|
+
|
|
163
|
+
Use `--thread <thread_ref>` when you already know the conversation and need only the user's sent
|
|
164
|
+
messages in that thread for style or consistency. `--thread` may be combined with `--recipient`.
|
|
165
|
+
|
|
166
|
+
### Watching Threads And Topics
|
|
167
|
+
|
|
168
|
+
Surface is the polling primitive, not the scheduler or delivery transport. If the user asks to
|
|
169
|
+
watch mail, use the surrounding automation system to rerun Surface commands and surface updates to
|
|
170
|
+
the user-requested destination.
|
|
171
|
+
|
|
172
|
+
- For a specific thread watch, persist the `account`, `thread_ref`, and the newest known
|
|
173
|
+
message/timestamp. On each check, rerun `surface mail thread get <thread_ref> --refresh` and
|
|
174
|
+
notify only when the newest message state changes.
|
|
175
|
+
- For a topic watch, establish a baseline with `search`, then use periodic `fetch-unread` checks
|
|
176
|
+
to catch new inbox arrivals and targeted `search` checks when the topic has clear `--from`,
|
|
177
|
+
`--subject`, `--mailbox`, `--label`, or `--text` filters.
|
|
178
|
+
- Do not assume a delivery target. Return updates through the current agent conversation or the
|
|
179
|
+
explicit destination the user asked for.
|
|
180
|
+
- Reasonable starting cadences are: 5-10 minutes for one active thread, 30-60 minutes for a
|
|
181
|
+
narrow topic watch, and 2-4 hours for inbox digests. Avoid sub-5-minute polling unless the user
|
|
182
|
+
explicitly asks for it.
|
|
183
|
+
- For Outlook-heavy polling, keep concurrency modest and prefer one warm session per parallel
|
|
184
|
+
worker if several live checks will run close together.
|
|
185
|
+
|
|
186
|
+
### Warm Sessions
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
surface session start --account uni
|
|
190
|
+
surface session list
|
|
191
|
+
surface session stop sess_01...
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Parallel Read Guidance
|
|
195
|
+
|
|
196
|
+
Read-only commands may be run in parallel. Live probes passed for:
|
|
197
|
+
|
|
198
|
+
- two Gmail searches on the same account
|
|
199
|
+
- two cold Outlook searches on the same account
|
|
200
|
+
- Gmail and Outlook searches at the same time
|
|
201
|
+
- two separate Outlook warm sessions searched at the same time
|
|
202
|
+
- two searches sharing one Outlook warm session
|
|
203
|
+
|
|
204
|
+
For Outlook, keep concurrency modest because each cold command or warm session uses browser
|
|
205
|
+
resources. If planning multiple concurrent Outlook operations, prefer one warm session per
|
|
206
|
+
parallel worker. Reusing the same `--session` concurrently works in the tested case but can be
|
|
207
|
+
slower due to contention.
|
|
208
|
+
|
|
209
|
+
### Read One Thread
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
surface mail thread get thr_01...
|
|
213
|
+
surface mail thread get thr_01... --refresh
|
|
214
|
+
surface mail thread get thr_01... --refresh --session sess_01...
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Read One Message
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
surface mail read msg_01...
|
|
221
|
+
surface mail read msg_01... --refresh
|
|
222
|
+
surface mail read msg_01... --refresh --session sess_01...
|
|
223
|
+
surface mail read msg_01... --mark-read
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Attachments
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
surface attachment list msg_01...
|
|
230
|
+
surface attachment download msg_01... att_01...
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Compose And Send
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
surface mail send --account personal_2 --to recipient@example.com --subject "Hello" --body "Test"
|
|
237
|
+
surface mail send --account personal_2 --to recipient@example.com --subject "Hello" --body "Test" --draft
|
|
238
|
+
surface mail reply msg_01... --body "Thanks"
|
|
239
|
+
surface mail reply msg_01... --body "Thanks" --draft
|
|
240
|
+
surface mail reply-all msg_01... --body "Thanks everyone"
|
|
241
|
+
surface mail forward msg_01... --to recipient@example.com --body "FYI"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Mailbox Actions
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
surface mail archive msg_01... # IMAP requires an Archive/All Mail mailbox
|
|
248
|
+
surface mail mark-read msg_01...
|
|
249
|
+
surface mail mark-unread msg_01...
|
|
250
|
+
surface mail rsvp msg_01... --response accept # Gmail/Outlook only; IMAP returns unsupported
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Workflow
|
|
254
|
+
|
|
255
|
+
1. Start with `surface account list` if the target account is unclear.
|
|
256
|
+
2. Use `surface auth status` before assuming a provider is ready.
|
|
257
|
+
3. Use `surface account identity show <account>` if `summary.needs_action` looks wrong; add
|
|
258
|
+
`--name-alias` or `--email-alias` with `surface account identity set` when the mailbox address
|
|
259
|
+
alone is not enough to identify the user in message bodies.
|
|
260
|
+
4. For triage, prefer `fetch-unread` or `search` and inspect the returned thread/message refs.
|
|
261
|
+
5. For style matching before drafting, run
|
|
262
|
+
`surface mail sent --account <account> --recipient <email> --limit 3` and use the returned sent
|
|
263
|
+
messages as tone/context. When replying in an existing thread, prefer
|
|
264
|
+
`surface mail sent --account <account> --thread <thread_ref> --limit 3`; use recipient matching
|
|
265
|
+
as fallback if the thread has no sent examples.
|
|
266
|
+
6. If you expect several live Outlook reads in a row, start a warm session first and reuse its `session_id`.
|
|
267
|
+
7. For a thread watch, use `surface mail thread get <thread_ref> --refresh` and compare the newest
|
|
268
|
+
message state against the stored prior observation before notifying.
|
|
269
|
+
8. For a topic watch, start with `search` to set the baseline, then use `fetch-unread` for new
|
|
270
|
+
inbox arrivals plus targeted `search` when the watch has narrow filters.
|
|
271
|
+
9. Read only the messages you need with `surface mail read <message_ref>`.
|
|
272
|
+
10. For passive watching, do not mutate read state. If the user explicitly asks you to triage unread
|
|
273
|
+
mail and write safety is enabled, marking handled messages read after reporting is acceptable
|
|
274
|
+
unless the user asks to keep them unread.
|
|
275
|
+
11. Act using refs from Surface output. Do not rely on array positions from previous JSON.
|
|
276
|
+
|
|
277
|
+
## Important Rules
|
|
278
|
+
|
|
279
|
+
- Surface outputs JSON on stdout. Parse it instead of scraping terminal text.
|
|
280
|
+
- Use `message_ref` and `thread_ref` for follow-up commands.
|
|
281
|
+
- `search` accepts structured filters for sender, subject, mailbox, and labels in addition to raw `--text`.
|
|
282
|
+
- `session start` is the explicit opt-in path for warm Outlook read sessions. In v1, `--session` is supported on `search`, `fetch-unread`, `thread get --refresh`, and `read`.
|
|
283
|
+
- `thread get --refresh` is the thread-level live refresh path for automations that watch a specific conversation.
|
|
284
|
+
- `read` is cache-first by default. Use `--refresh` when you need live provider state.
|
|
285
|
+
- the first session-backed Outlook query still pays mailbox setup cost; the main win is faster follow-on live reads in the same mailbox session
|
|
286
|
+
- `read` does not download attachments. Use `surface attachment download`.
|
|
287
|
+
- Generic IMAP reads raw MIME directly and does not need webmail "show images" or "trust sender"
|
|
288
|
+
UI. Remote images are not fetched; message body text, links, and MIME attachments still work.
|
|
289
|
+
- `fetch-unread` and `search` do not mutate mailbox state.
|
|
290
|
+
- passive watching should stay read-only; do not mark watched mail read unless the user explicitly asks
|
|
291
|
+
- if the user asks for unread triage rather than passive watching, `mark-read` or `read --mark-read`
|
|
292
|
+
is acceptable only after reporting and only when local write safety allows it
|
|
293
|
+
- watcher notifications should go to the user-requested destination; do not invent a session,
|
|
294
|
+
channel, or DM target
|
|
295
|
+
- `--draft` is the safe compose path when you do not need to send immediately.
|
|
296
|
+
|
|
297
|
+
## Provider Notes
|
|
298
|
+
|
|
299
|
+
- Gmail and Outlook both support read, search, unread fetch, attachments, send/reply/forward,
|
|
300
|
+
archive, mark-read, mark-unread, RSVP, and `--draft`.
|
|
301
|
+
- Generic IMAP/SMTP supports read, search, unread fetch, attachments, sent lookup,
|
|
302
|
+
send/reply/reply-all/forward, drafts, mark-read, and mark-unread. Archive works only when the
|
|
303
|
+
account exposes an Archive or All Mail style mailbox. RSVP is not supported for generic IMAP.
|
|
304
|
+
- Public CLI send-with-attachment/upload flags are not supported yet. Receive-side attachment
|
|
305
|
+
list/download is supported.
|
|
306
|
+
- Generic IMAP does not expose a reliable cross-folder conversation ID. Replies return the created
|
|
307
|
+
Sent or Draft refs and include `in_reply_to_message_ref`; use `sent --recipient` or `sent
|
|
308
|
+
--thread` for sent-message lookup.
|
|
309
|
+
- Gmail RSVP requires Google Calendar API access on the authenticated account. If RSVP returns a
|
|
310
|
+
reauth error, re-run `surface auth login <account>`.
|
|
311
|
+
|
|
312
|
+
## Safety
|
|
313
|
+
|
|
314
|
+
- Respect local write-safety policy from `~/.surface-cli/config.toml` and any `SURFACE_*` env vars.
|
|
315
|
+
- Do not send mail unless write safety is enabled locally.
|
|
316
|
+
- Prefer the configured sink recipients from local config; do not invent recipients.
|
|
317
|
+
- For send-like tests, use `--draft` unless the task explicitly requires a live send.
|
|
318
|
+
- When testing live sends, only send to recipients already configured locally for safe testing.
|
|
319
|
+
|
|
320
|
+
## Examples
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
surface account list
|
|
324
|
+
surface auth status
|
|
325
|
+
surface auth status gmx
|
|
326
|
+
surface session start --account uni
|
|
327
|
+
surface mail fetch-unread --account uni --limit 10
|
|
328
|
+
surface mail search --account gmx --mailbox inbox --limit 5
|
|
329
|
+
surface mail fetch-unread --account uni --session sess_01... --limit 10
|
|
330
|
+
surface mail search --account personal_2 --from alerts@example.com --subject 'discount' --mailbox inbox --label unread --limit 5
|
|
331
|
+
surface mail thread get thr_01... --refresh --session sess_01...
|
|
332
|
+
surface mail read msg_01... --refresh --session sess_01...
|
|
333
|
+
surface mail read msg_01... --mark-read
|
|
334
|
+
surface attachment list msg_01...
|
|
335
|
+
surface attachment download msg_01... att_01...
|
|
336
|
+
surface mail reply msg_01... --body 'Thanks' --draft
|
|
337
|
+
surface mail archive msg_01...
|
|
338
|
+
```
|