@bitefoundry/outlook 0.3.0 → 0.3.2

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 CHANGED
@@ -53,6 +53,8 @@ For a company registration, use `outlook login --client-id YOUR_CLIENT_ID --tena
53
53
 
54
54
  > **Shared M365 Session & Token Brokers:** When `share_m365_auth = true` (default), `outlook` seamlessly reuses or upgrades an existing `@bitefoundry/teams` session without a second browser login. Also supports `--device-code`, `OUTLOOK_ACCESS_TOKEN`, `OUTLOOK_TOKEN_FILE`, `OUTLOOK_TOKEN_REFRESH_CMD` (`az account get-access-token`), and custom Entra ID apps. Run `outlook whoami` or `outlook doctor --online` for JWT scope diagnostics.
55
55
 
56
+ > **Corporate TLS proxies:** `outlook` trusts the bundled Mozilla roots and the OS trust store. If your network re-signs HTTPS with a private root CA, export it as PEM and set `OUTLOOK_EXTRA_CA_PEM` (`SSL_CERT_FILE` and `NODE_EXTRA_CA_CERTS` also work). `outlook doctor` shows which CA files were loaded. [Details](docs/NPM.md#corporate-tls-proxies-and-private-root-cas)
57
+
56
58
  Update a global npm install with `npm install -g @bitefoundry/outlook@latest`. For a standalone binary from [GitHub Releases](https://github.com/BiteFoundry/outlook/releases), use `outlook update`.
57
59
 
58
60
  ---
@@ -101,7 +103,7 @@ outlook add-task "Promote canary to 100%" --due 2026-11-20 --importance high
101
103
  outlook daemon start
102
104
  ```
103
105
 
104
- JSON output for `mail`, `read`, `move`, `archive`, `search --remote`, `calendar`, and `event` is compact by default. Pass `--full` with `--json` for full cached fields, HTML bodies, and attachment metadata (`content_bytes_b64` is never embedded in CLI/MCP JSON; fetch attachment bytes with `outlook download`, or `outlook download --offline` for cached bytes). `--compact` remains a compatibility alias and conflicts with `--full`. Paginated JSON listings (`mail`, `search --remote`, `folders`, `task-lists`) include `returned`, `has_more`, and `next_cursor`; continue with `--cursor <CURSOR>`. Cursors are bound to the originating command, folder, query, and filter, while `--limit` and `--full` may change between pages. In `mail --json`, `folder` is the canonical folder ID string, and the first online listing of an uncached folder syncs the full folder delta once. In `search --remote --json`, `hits` holds local cache matches while `remote` holds Graph results, so the same message ID can appear in both arrays.
106
+ JSON output for `mail`, `read`, `move`, `archive`, `search --remote`, `calendar`, and `event` is compact by default. Pass `--full` with `--json` for full cached fields, HTML bodies, and attachment metadata (`content_bytes_b64` is never embedded in CLI/MCP JSON; fetch attachment bytes with `outlook download`, or `outlook download --offline` for cached bytes). `--compact` remains a compatibility alias and conflicts with `--full`. Paginated JSON listings (`mail`, `search --remote`, `folders`, `task-lists`) include `returned`, `has_more`, and `next_cursor`; continue with `--cursor <CURSOR>`. Cursors are bound to the originating command, folder, query, and filter, while `--limit` and `--full` may change between pages. In `mail --json`, `folder` is the canonical folder ID string, and the first online listing of an uncached folder syncs the folder delta: up to 40 delta pages (about 2,000 messages) per call. A larger folder returns the newest messages right away with `"sync_complete": false` and continues the sync on the following listings (or in the TUI / `serve` background sync) until it is complete; the key is absent otherwise. In `search --remote --json`, `hits` holds local cache matches while `remote` holds Graph results, so the same message ID can appear in both arrays.
105
107
 
106
108
  For `read`, `message_id` is an exact message ID; subject and ID-prefix resolution apply only to CLI `read --offline` (online callers should locate IDs with `search` first). Runtime failures with `--json` emit a structured JSON error object on stdout (`{"ok": false, "error": {"code": ..., "message": ...}}`) with exit code `1`; exit code `2` indicates a CLI usage/parsing error printed as plain text on stderr. For `sync --json` (and `doctor --online --json`), check the `ok` field in the JSON output to determine overall success.
107
109
 
@@ -116,20 +118,26 @@ outlook update-task TASK_ID --list tasks --due 2026-11-25 --json
116
118
 
117
119
  Each edit sends the specified fields. A draft subject change preserves the original body and its markup. Use `--body-html` to supply replacement HTML directly. Calendar edits leave the body, attendees, and recurrence out of the request. To Do edits leave the body and checklist out of the request. [Message updates](https://learn.microsoft.com/en-us/graph/api/message-update?view=graph-rest-1.0) · [Event updates](https://learn.microsoft.com/en-us/graph/api/event-update?view=graph-rest-1.0) · [To Do updates](https://learn.microsoft.com/en-us/graph/api/todotask-update?view=graph-rest-1.0)
118
120
 
119
- Calendar wall-clock times such as `2026-11-23T09:00` use the event's original Graph time zone. Use date-only values with all-day events and give the exclusive end date. RFC3339 values such as `2026-11-23T09:00:00+09:00` are sent in UTC for timed events. Non-UTC recurring events require wall-clock times. To Do dates use midnight UTC, and RFC3339 To Do timestamps are converted to UTC. [Event time and recurrence](https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0)
121
+ For `create-event`, RFC3339 times are exact instants and wall-clock times such as `"2026-11-23 09:00"` are read in the machine's time zone, or in `--time-zone` when given. `--all-day` needs `YYYY-MM-DD` for both `--start` and `--end`, with an exclusive end date (`--start 2026-11-23 --end 2026-11-24` is one day).
122
+
123
+ For `update-event`, calendar wall-clock times such as `2026-11-23T09:00` use the event's original Graph time zone. Use date-only values with all-day events and give the exclusive end date. RFC3339 values such as `2026-11-23T09:00:00+09:00` are sent in UTC for timed events. Non-UTC recurring events require wall-clock times. To Do dates use midnight UTC, and RFC3339 To Do timestamps are converted to UTC. [Event time and recurrence](https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0)
120
124
 
121
125
  ### Local HTTP REST API (`outlook serve`)
122
126
 
123
- Start an Axum JSON server on `127.0.0.1:3939` (with live `/openapi.json` and optional `--api-key` auth):
127
+ Start an Axum JSON server on `127.0.0.1:3939` (with live `/openapi.json`). Requests need a Bearer key: pass your own with `--api-key`, or use the random token the server prints to stderr at startup.
124
128
 
125
129
  ```bash
126
- outlook serve --port 3939
127
- curl http://127.0.0.1:3939/v1/mail/messages?folder=inbox&unread=true
130
+ outlook serve --port 3939 --api-key "$OUTLOOK_API_KEY"
131
+ curl -H "Authorization: Bearer $OUTLOOK_API_KEY" \
132
+ "http://127.0.0.1:3939/v1/mail/messages?folder=inbox&unread=true"
128
133
  curl -X POST http://127.0.0.1:3939/v1/mail/send \
134
+ -H "Authorization: Bearer $OUTLOOK_API_KEY" \
129
135
  -H "Content-Type: application/json" \
130
136
  -d '{"to":["elena.park@acme.dev"],"subject":"Build green","markdown":"All checks passed!"}'
131
137
  ```
132
138
 
139
+ `--allow-keyless` serves loopback clients without a key. Browser apps are refused unless their origin is passed with `--cors-origin`; see [Security](docs/API.md#security).
140
+
133
141
  Full endpoint & schema docs: **[docs/API.md](docs/API.md)** · **[docs/openapi.yaml](docs/openapi.yaml)**
134
142
 
135
143
  ### MCP Server (`outlook mcp`)
package/docs/API.md CHANGED
@@ -5,17 +5,22 @@ Local HTTP/JSON server for AI agents, scripts, and integrations. Exposed by `out
5
5
  ## Starting the server
6
6
 
7
7
  ```bash
8
- outlook serve # http://127.0.0.1:3939
8
+ outlook serve # http://127.0.0.1:3939, prints a generated Bearer token to stderr
9
9
  outlook serve --port 9000 # custom port
10
10
  outlook serve --bind 127.0.0.1 --port 3939
11
11
  outlook serve --api-key secret123 # require Bearer secret123 or x-api-key: secret123
12
12
  outlook serve --token secret123 # --token is an alias for --api-key
13
+ outlook serve --allow-keyless # loopback only, no authentication
14
+ outlook serve --cors-origin http://localhost:5173 # let one browser app call the API
13
15
  outlook api # alias for `serve`
14
16
  ```
15
17
 
16
18
  - `--bind` defaults to `127.0.0.1` (loopback only). Binding to a non-loopback address (e.g. `0.0.0.0`) requires `--api-key <KEY>` (or `--token <KEY>`) unless `OUTLOOK_ALLOW_INSECURE_SERVE=1` is explicitly set.
17
19
  - `--port` defaults to `3939`.
18
- - `--api-key` (alias `--token`) is optional; when set, every endpoint except `GET /health` requires either `Authorization: Bearer <key>` or `x-api-key: <key>`.
20
+ - `--api-key` (alias `--token`) sets the key. Every endpoint except `GET /health` requires either `Authorization: Bearer <key>` or `x-api-key: <key>`.
21
+ - Without `--api-key`, a loopback server generates a random 32-byte token (64 hex characters) for that run and prints it once to stderr. It is not written to disk, and a new one is generated on every start; pass `--api-key` when clients need a stable key.
22
+ - `--allow-keyless` turns authentication off for a loopback server instead of generating a token. It cannot be combined with `--api-key`.
23
+ - `--cors-origin <ORIGIN>` (repeatable) allows one browser origin, written as `scheme://host[:port]`. No origin is allowed by default.
19
24
  - Requires an existing login (`outlook login`), `OUTLOOK_ACCESS_TOKEN`, `OUTLOOK_TOKEN_FILE`, or a shared M365 session (`teams-cli` / `TEAMS_TOKEN_FILE` when `OUTLOOK_SHARE_M365_AUTH=true`).
20
25
  - On startup, `outlook serve` spawns the background sync engine so the local SQLite cache stays warm while serving requests.
21
26
 
@@ -26,7 +31,16 @@ outlook api # alias for `serve`
26
31
  - `limit` is clamped to `1..=1000`.
27
32
  - Mail folder parameters accept a folder ID, display name/prefix, or well-known alias (`inbox`, `sent`, `drafts`, `archive`, `trash`, `junk`).
28
33
  - To Do list parameters default to `"tasks"` and accept a list ID, display name, or `"default"` / `"tasks"` / `"defaultList"`.
29
- - CORS is restricted to loopback (`localhost` / `127.0.0.1` / `[::1]`) origins when `--api-key` is unset, and permissive when `--api-key` is configured.
34
+ - The `curl` examples below leave out the key. Add `-H "Authorization: Bearer <key>"`, or start the server with `--allow-keyless`.
35
+
36
+ ## Security
37
+
38
+ The API can read and send mail as the signed-in user, so it refuses callers it cannot place:
39
+
40
+ - **Authentication** is on by default (see `--api-key` and the generated token above). `GET /health` stays public.
41
+ - **Browser origins**: a request with an `Origin` header is answered only when that origin was passed with `--cors-origin`, compared exactly. Every other origin gets `403`, preflight included, with or without a valid key. This applies to pages served from `localhost` too. Clients that send no `Origin` header (curl, scripts, agents) are unaffected.
42
+ - **`Host` header** (keyless servers only): the request must be addressed to `localhost`, a loopback address (`127.0.0.1`, `[::1]`), or a name listed in `OUTLOOK_SERVE_ALLOWED_HOSTS` (comma-separated). Any other host gets `403`, `/health` included. This stops a web page that points its own domain at `127.0.0.1` (DNS rebinding) from reaching the API. A server with a key skips this check, so a reverse proxy can forward its own host name.
43
+ - **Non-loopback binds** need `--api-key`. `OUTLOOK_ALLOW_INSECURE_SERVE=1` overrides that and serves without authentication; the bind address is then accepted as a `Host`, and `0.0.0.0` needs `OUTLOOK_SERVE_ALLOWED_HOSTS` for any non-loopback name.
30
44
 
31
45
  ## Endpoints
32
46
 
@@ -34,7 +48,7 @@ outlook api # alias for `serve`
34
48
 
35
49
  #### `GET /health`
36
50
 
37
- Always public, even when `--api-key` is configured.
51
+ No key needed. The `Origin` and `Host` checks in [Security](#security) still apply.
38
52
 
39
53
  ```bash
40
54
  curl http://127.0.0.1:3939/health
@@ -76,7 +90,7 @@ curl http://127.0.0.1:3939/v1/whoami -H "Authorization: Bearer secret123"
76
90
  "auth_source": "keyring",
77
91
  "expires_at": 1795023600,
78
92
  "expired": false,
79
- "scopes": ["Mail.ReadWrite", "Mail.Send", "Calendars.ReadWrite", "Tasks.ReadWrite", "Contacts.Read"],
93
+ "scopes": ["User.Read", "User.ReadBasic.All", "Mail.ReadWrite", "Mail.Send", "Calendars.ReadWrite", "Contacts.Read", "Tasks.ReadWrite"],
80
94
  "roles": []
81
95
  }
82
96
  ```
@@ -111,6 +125,11 @@ curl "http://127.0.0.1:3939/v1/mail/folders?refresh=true"
111
125
 
112
126
  Lists messages in a mail folder (`inbox`, `sent`, `drafts`, `archive`, `trash`, `junk`, folder name, or folder ID).
113
127
 
128
+ Live requests are bounded:
129
+
130
+ - With `unread`, `flagged` or `focused`, the scan reads at most 20 Graph pages. `has_more` is `true` or `false` when the scan could tell, and `null` when it stopped at the page cap (or the response came from the cache) and more matches may exist further back.
131
+ - Without a filter, the first sync of a folder reads at most 40 delta pages (about 2,000 messages) per request. A larger folder answers with the newest messages and `"sync_complete": false`; later requests and the background sync continue from where it stopped. The key is absent once the folder is fully synced.
132
+
114
133
  ```bash
115
134
  curl "http://127.0.0.1:3939/v1/mail/messages?folder=inbox&limit=20&unread=true"
116
135
  ```
@@ -134,7 +153,8 @@ curl "http://127.0.0.1:3939/v1/mail/messages?folder=inbox&limit=20&unread=true"
134
153
  "body_loaded": false,
135
154
  "preview": "Attached are the Q4 numbers..."
136
155
  }
137
- ]
156
+ ],
157
+ "has_more": false
138
158
  }
139
159
  ```
140
160
 
@@ -276,6 +296,15 @@ curl "http://127.0.0.1:3939/v1/calendar/events?days=14"
276
296
 
277
297
  Creates a new calendar event. `start_iso` / `end_iso` accept aliases `start` / `end`; `markdown` accepts alias `body`; `is_online_meeting` accepts alias `online`.
278
298
 
299
+ | Input | `time_zone` | Result |
300
+ |---|---|---|
301
+ | RFC3339 (`2026-11-20T14:00:00Z`, `...+09:00`) | any | Exact instant, stored in UTC. |
302
+ | Wall clock (`2026-11-20 14:00`) | omitted | Read in the server machine's time zone. |
303
+ | Wall clock (`2026-11-20 14:00`) | `Asia/Seoul` | Read in that zone (IANA or Windows name). |
304
+ | `is_all_day: true` | optional | `start_iso` and `end_iso` must be `YYYY-MM-DD`; the end date is exclusive. |
305
+
306
+ Invalid all-day input (a time of day, or an end date that is not after the start date) returns `400` without calling Microsoft Graph.
307
+
279
308
  ```bash
280
309
  curl -X POST http://127.0.0.1:3939/v1/calendar/events \
281
310
  -H "Content-Type: application/json" \
package/docs/MCP.md CHANGED
@@ -93,7 +93,7 @@ Mail `folder` arguments accept a canonical folder ID, display name/prefix, or we
93
93
  | --- | --- | --- | --- | --- |
94
94
  | 1 | `whoami` | Auth | *(none)* | `{ "authenticated": bool, "user_id": ..., "email": ..., "auth_mode": ..., "auth_source": ..., "scopes": [...] }` |
95
95
  | 2 | `list_mail_folders` | Mail | `limit?` (1..200, default 50), `cursor?`, `refresh?` (bool), `offline?` (bool) | `{ "folders": [...], "returned": n, "has_more": bool, "next_cursor": string\|null }` |
96
- | 3 | `list_messages` | Mail | `folder?` (default `'inbox'`), `limit?` (1..200), `cursor?`, `unread?`, `flagged?`, `focused?`, `offline?`, `compact?` (default `true`) | `{ "folder": {...}, "messages": [...], "returned": n, "has_more": bool\|null, "next_cursor": string\|null }` |
96
+ | 3 | `list_messages` | Mail | `folder?` (default `'inbox'`), `limit?` (1..200), `cursor?`, `unread?`, `flagged?`, `focused?`, `offline?`, `compact?` (default `true`) | `{ "folder": {...}, "messages": [...], "returned": n, "has_more": bool\|null, "next_cursor": string\|null }`, plus `"sync_complete": false` while a large folder's first sync is still in progress |
97
97
  | 4 | `get_message` | Mail | `message_id` (exact ID, req), `mark_read?`, `offline?`, `compact?` (default `true`) | `{ "message": {...} }` (compact includes `omitted`, `hint`) |
98
98
  | 5 | `send_mail` | Mail | `to` (`string[]`, req), `subject` (req), `body` (Markdown, req), `cc?`, `bcc?`, `importance?` (`low\|normal\|high`), `attachments?`, `save_to_sent_items?` | `{ "ok": true, "to": [...], "subject": "..." }` |
99
99
  | 6 | `reply_mail` | Mail | `message_id` (req), `body` (req), `reply_all?` | `{ "ok": true, "message_id": "...", "reply_all": bool }` |
@@ -103,7 +103,7 @@ Mail `folder` arguments accept a canonical folder ID, display name/prefix, or we
103
103
  | 10 | `download_attachment` | Mail | `message_id` (req), `attachment_index?` (>=0), `attachment?` (ID/name/index), `output_dir?`, `offline?` | `{ "ok": true, "message_id": "...", "attachment_id": "...", "path": "...", "file_name": "...", "mime_type": "...", "size_bytes": n, "is_image": bool }` |
104
104
  | 11 | `search_mail` | Mail | `query` (req), `folder?`, `limit?` (1..200), `cursor?`, `compact?` (default `true`), `offline?` | `{ "query": "...", "hits": [...] }` (offline) or `{ "query": "...", "messages": [...], "returned": n, "has_more": bool, "next_cursor": string\|null }` (online, compact by default, no 100-item cap) |
105
105
  | 12 | `list_events` | Calendar | `from?` (`ISO-8601\|YYYY-MM-DD`), `to?`, `days?` (1..365), `limit?` (1..200), `compact?` (default `true`), `offline?` | `{ "start": "...", "end": "...", "events": [...], "returned": n, "has_more": bool }` (compact omits `body_html`) |
106
- | 13 | `create_event` | Calendar | `subject` (req), `start` (req), `end` (req), `time_zone?`, `is_all_day?`, `location?`, `body?`, `attendees?`, `is_online_meeting?` | `{ "ok": true, "event": {...} }` |
106
+ | 13 | `create_event` | Calendar | `subject` (req), `start` (req), `end` (req), `time_zone?`, `is_all_day?`, `location?`, `body?`, `attendees?`, `is_online_meeting?`. RFC3339 `start`/`end` are exact instants; wall-clock values are read in `time_zone` (machine zone when omitted). With `is_all_day`, both must be `YYYY-MM-DD` and `end` is exclusive. | `{ "ok": true, "event": {...} }` |
107
107
  | 14 | `respond_event` | Calendar | `event_id` (req), `response` (`accept\|tentative\|decline`, req), `comment?` | `{ "ok": true, "event_id": "...", "response": "..." }` |
108
108
  | 15 | `delete_event` | Calendar | `event_id` (req), `confirm` (must be literal `true`) | `{ "ok": true, "event_id": "..." }` |
109
109
  | 16 | `list_todo_lists` | To Do | `limit?` (1..200, default 50), `cursor?`, `refresh?`, `offline?` | `{ "lists": [...], "returned": n, "has_more": bool, "next_cursor": string\|null }` |
@@ -115,6 +115,22 @@ Mail `folder` arguments accept a canonical folder ID, display name/prefix, or we
115
115
  | 22 | `update_event` | Calendar | `event_id` (req), `subject?`, `start?`, `end?` | `{ "ok": true, "event": {...} }` |
116
116
  | 23 | `update_task` | To Do | `task_id` (req), `list?` (default `'tasks'`), `title?`, `due?` | `{ "ok": true, "task": {...} }` |
117
117
 
118
+ ### Graph request cost
119
+
120
+ Tool descriptions state what a call costs, so an agent can prefer the cache:
121
+
122
+ - Every `offline` flag: read the local cache only; no Graph request.
123
+ - `list_mail_folders`: 1 request plus 1 batch per folder nesting level, skipped while the cache is younger than `OUTLOOK_CLI_CACHE_SECS` (default 0). `refresh`: force a full folder-tree fetch even when the cache is fresh; use only when a folder is missing.
124
+ - `list_messages`: usually 1-2 requests. The first call on a large folder syncs at most 40 pages (`sync_complete: false` until done); `unread`/`flagged`/`focused` filters scan at most 20 pages.
125
+ - `get_message`: 1 request unless `offline` (plus 1 when `mark_read` changes the state); `compact: false` can be large.
126
+ - `send_mail`: attachments over 3 MiB are uploaded in chunks before sending, which takes several requests.
127
+ - `download_attachment`: fetches the full attachment bytes unless `offline` reads them from the cache; time grows with file size.
128
+ - `search_mail`: remote search is 1 request per page and is rate-limited by Exchange; prefer `offline: true` (local FTS, no request) for mail that is already synced.
129
+ - `list_events`: 1 request per 100 events in the window.
130
+ - `list_todo_lists`: 1 request per page of lists, skipped while the cache is younger than `OUTLOOK_CLI_CACHE_SECS`. `refresh`: force a refetch even when the cache is fresh.
131
+ - `list_tasks`: 1 request per 100 tasks unless `offline`.
132
+ - `search_contacts`: a query reads personal contacts and the organization directory: 2-3 requests.
133
+
118
134
  ### Destructive tool guard (`confirm: true`)
119
135
 
120
136
  `delete_message` and `delete_event` require `"confirm": true` as a literal JSON boolean. Omitting `confirm`, passing `false`, `"true"`, or `1` is rejected during argument validation before any Graph API call is made.
@@ -137,6 +153,7 @@ Mail `folder` arguments accept a canonical folder ID, display name/prefix, or we
137
153
  - Pass `"offline": true` on read/search tools (`list_mail_folders`, `list_messages`, `get_message`, `search_mail`, `list_events`, `list_todo_lists`, `list_tasks`, `search_contacts`) to query the local SQLite cache (`cache.db`) without network calls.
138
154
  - `list_messages`, `get_message`, `search_mail` (online), and `list_events` default to `"compact": true` and reject unknown arguments. Pass `"compact": false` to return full cached fields, HTML bodies, and attachment metadata (`content_bytes_b64` is never included; use `download_attachment` to retrieve attachment bytes). `get_message` requires an exact `message_id`; subject and ID-prefix resolution are available only in CLI `outlook read --offline` (online callers should find IDs with `search_mail` first). Compact `get_message` responses include `omitted` (`attachments` is the known count, `0` when the message has no attachments, or `null` when attachment metadata has not been fetched yet; `fields` lists omitted scalar fields) and a follow-up `hint`.
139
155
  - `next_cursor` is an opaque pagination token valid only for the same tool, `folder`, `query`, and filter combination (`limit` and `compact` may change between pages). Reusing a cursor with a different tool, folder, query, or filter fails before any network call with `invalid cursor: issued for a different command, folder, query or filter`.
156
+ - `list_messages` bounds the first sync of a folder to 40 delta pages (about 2,000 messages) per call. When a folder is larger, the response carries `"sync_complete": false`, `messages` still holds the newest messages, and each later call continues the sync where the previous one stopped. The key is absent once the folder is fully synced.
140
157
  - `update_message` accepts read and flag changes or a destination folder. An unsupported argument such as `subject` fails validation before any write. Use `update_draft` for a draft's subject or body.
141
158
 
142
159
  ## Partial edits
package/docs/NPM.md CHANGED
@@ -159,7 +159,9 @@ When `share_m365_auth = true` (default; `OUTLOOK_SHARE_M365_AUTH=true`), `outloo
159
159
 
160
160
  Pure Outlook requests only Microsoft Outlook & Graph core scopes:
161
161
 
162
- `offline_access`, `User.Read`, `User.ReadBasic.All`, `Mail.ReadWrite`, `Mail.Send`, `Calendars.ReadWrite`, `Contacts.ReadWrite`, `Tasks.ReadWrite`
162
+ `offline_access`, `User.Read`, `User.ReadBasic.All`, `Mail.ReadWrite`, `Mail.Send`, `Calendars.ReadWrite`, `Contacts.Read`, `Tasks.ReadWrite`
163
+
164
+ Login, token refresh, and `outlook doctor` all use this one list (override it with `scopes = [...]` in `config.toml`). `User.ReadBasic.All` enables organization directory search in `outlook contacts`. Sessions created before v0.3.1 keep working without it; `outlook doctor` lists it under `missing_scopes` until you run `outlook login` again. If your tenant restricts user consent for that scope, either ask an administrator to approve it or set `scopes` without it; contact search then returns personal contacts only.
163
165
 
164
166
  Run `outlook whoami` or `outlook doctor` to inspect JWT `scp`/`roles` claims automatically.
165
167
 
@@ -210,6 +212,37 @@ token_refresh_mins = 5
210
212
  | `OUTLOOK_IMAGE_PROTOCOL` | Terminal image protocol override (`auto`, `kitty`, `iterm2`, `sixel`, `halfblock`) |
211
213
  | `OUTLOOK_GITHUB_REPO` | Override GitHub `owner/repo` used by `outlook update` (default `BiteFoundry/outlook`) |
212
214
  | `OUTLOOK_GITHUB_TOKEN` | GitHub token for private release checks in `outlook update` |
215
+ | `OUTLOOK_EXTRA_CA_PEM` | PEM file with extra root CAs to trust (also read: `SSL_CERT_FILE`, `NODE_EXTRA_CA_CERTS`) |
216
+
217
+ ### Corporate TLS proxies and private root CAs
218
+
219
+ `outlook` trusts the Mozilla roots bundled into the binary plus the OS trust store (Windows certificate store, macOS keychain, the Linux system bundle). A CA installed in the OS store therefore works without configuration.
220
+
221
+ To trust a root CA that is not in the OS store, export it (and any intermediates you want to pin) as PEM and point one of these variables at the file:
222
+
223
+ | Variable | Notes |
224
+ | --- | --- |
225
+ | `OUTLOOK_EXTRA_CA_PEM` | Read by `outlook` only |
226
+ | `SSL_CERT_FILE` | Shared with OpenSSL tools. While it is set, the OS store is not read: this file replaces it |
227
+ | `NODE_EXTRA_CA_CERTS` | Shared with Node.js, so an existing Node setup carries over |
228
+
229
+ All of them are additive and can be combined; a path named twice is read once. A file may hold several `-----BEGIN CERTIFICATE-----` blocks. A missing or invalid file prints a warning to stderr and is skipped, so it never breaks `--json` or MCP output. Certificate verification cannot be turned off.
230
+
231
+ ```powershell
232
+ # Windows PowerShell
233
+ $env:OUTLOOK_EXTRA_CA_PEM = "C:\certs\corp-root.pem"
234
+ outlook doctor
235
+ ```
236
+
237
+ ```bash
238
+ # macOS / Linux
239
+ export OUTLOOK_EXTRA_CA_PEM="$HOME/certs/corp-root.pem"
240
+ outlook doctor
241
+ ```
242
+
243
+ `outlook doctor` prints `tls_roots` and one `tls_extra_ca` line per file (`--json`: `tls.roots`, `tls.extra_ca[]` with `source`, `path`, `loaded`, `certs`, `error`). A request that fails with an untrusted certificate (`UnknownIssuer`) ends with a hint pointing to these variables.
244
+
245
+ For MCP clients, put the variable in the server's `env` block, e.g. `"env": { "OUTLOOK_EXTRA_CA_PEM": "C:\\certs\\corp-root.pem" }`.
213
246
 
214
247
  ## Troubleshooting
215
248
 
package/docs/openapi.yaml CHANGED
@@ -8,9 +8,15 @@ info:
8
8
  Backed by Microsoft Graph v1.0, local SQLite WAL/FTS5 caching, and the
9
9
  background sync engine. Binds to `127.0.0.1:3939` by default (non-loopback
10
10
  binds require `--api-key <KEY>` / `--token <KEY>` or
11
- `OUTLOOK_ALLOW_INSECURE_SERVE=1`). When an API key is configured, every
12
- endpoint except `GET /health` requires `Authorization: Bearer <key>` or
13
- `x-api-key: <key>`.
11
+ `OUTLOOK_ALLOW_INSECURE_SERVE=1`). Every endpoint except `GET /health`
12
+ requires `Authorization: Bearer <key>` or `x-api-key: <key>`, where the key
13
+ is `--api-key` or, without one, the random token a loopback server prints
14
+ to stderr at startup. `--allow-keyless` turns authentication off.
15
+
16
+ Requests with an `Origin` header get `403` unless the origin was allowed
17
+ with `--cors-origin`. A keyless server also answers `403` to a `Host`
18
+ header that is not a loopback name or listed in
19
+ `OUTLOOK_SERVE_ALLOWED_HOSTS`.
14
20
 
15
21
  All errors return `{"error": "<message>"}` with an appropriate HTTP status.
16
22
  servers:
@@ -31,7 +37,7 @@ paths:
31
37
  get:
32
38
  tags: [system]
33
39
  summary: Health check (public)
34
- description: Always public, even when `--api-key` is set.
40
+ description: No key needed; the `Origin` and keyless `Host` checks still apply.
35
41
  security: []
36
42
  responses:
37
43
  "200":
@@ -126,7 +132,31 @@ paths:
126
132
  default: false
127
133
  responses:
128
134
  "200":
129
- description: Folder metadata and matching messages
135
+ description: >-
136
+ Folder metadata and matching messages. A live filtered scan reads at most 20 Graph pages and
137
+ a first folder sync at most 40 delta pages per request.
138
+ content:
139
+ application/json:
140
+ schema:
141
+ type: object
142
+ required: [folder, messages, has_more]
143
+ properties:
144
+ folder:
145
+ type: object
146
+ messages:
147
+ type: array
148
+ items:
149
+ type: object
150
+ has_more:
151
+ type: [boolean, "null"]
152
+ description: >-
153
+ Whether more matching messages exist. Null when unknown: the filtered scan
154
+ stopped at its page cap, or the response was served from the cache.
155
+ sync_complete:
156
+ type: boolean
157
+ description: >-
158
+ Present (and false) only while the first sync of a large folder is still in
159
+ progress; messages then holds the newest messages.
130
160
  "401":
131
161
  $ref: "#/components/responses/Unauthorized"
132
162
  "403":
@@ -670,13 +700,17 @@ components:
670
700
  type: string
671
701
  start_iso:
672
702
  type: string
703
+ description: RFC3339 instant, wall clock "YYYY-MM-DD HH:MM" (machine zone, or time_zone when given), or "YYYY-MM-DD" when is_all_day is true.
673
704
  end_iso:
674
705
  type: string
706
+ description: Same form as start_iso. For all-day events the end date is exclusive.
675
707
  time_zone:
676
708
  type: string
709
+ description: IANA or Windows time zone. Wall-clock values are read in this zone; RFC3339 values stay exact instants in UTC.
677
710
  is_all_day:
678
711
  type: boolean
679
712
  default: false
713
+ description: All-day event. start_iso and end_iso must be YYYY-MM-DD.
680
714
  location:
681
715
  type: string
682
716
  markdown:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitefoundry/outlook",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Microsoft Outlook terminal client & AI agent toolkit — Mail, Calendar, Tasks & Contacts (CLI, TUI, HTTP API, MCP)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,11 +39,11 @@
39
39
  "build:npm": "node scripts/build-npm.mjs"
40
40
  },
41
41
  "optionalDependencies": {
42
- "@bitefoundry/outlook-win32-x64": "0.3.0",
43
- "@bitefoundry/outlook-win32-arm64": "0.3.0",
44
- "@bitefoundry/outlook-darwin-x64": "0.3.0",
45
- "@bitefoundry/outlook-darwin-arm64": "0.3.0",
46
- "@bitefoundry/outlook-linux-x64": "0.3.0",
47
- "@bitefoundry/outlook-linux-arm64": "0.3.0"
42
+ "@bitefoundry/outlook-win32-x64": "0.3.2",
43
+ "@bitefoundry/outlook-win32-arm64": "0.3.2",
44
+ "@bitefoundry/outlook-darwin-x64": "0.3.2",
45
+ "@bitefoundry/outlook-darwin-arm64": "0.3.2",
46
+ "@bitefoundry/outlook-linux-x64": "0.3.2",
47
+ "@bitefoundry/outlook-linux-arm64": "0.3.2"
48
48
  }
49
49
  }
@@ -256,7 +256,17 @@ export function runPostinstall(options = {}) {
256
256
  return { skipped: false, platform, linked };
257
257
  }
258
258
 
259
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
259
+ function isMainModule() {
260
+ if (!process.argv[1]) return false;
261
+ const selfPath = fileURLToPath(import.meta.url);
262
+ try {
263
+ return fs.realpathSync(process.argv[1]) === fs.realpathSync(selfPath);
264
+ } catch {
265
+ return path.resolve(process.argv[1]) === path.resolve(selfPath);
266
+ }
267
+ }
268
+
269
+ if (isMainModule()) {
260
270
  try {
261
271
  runPostinstall();
262
272
  } catch {