@bitefoundry/outlook 0.2.0 → 0.3.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/docs/NPM.md CHANGED
@@ -1,236 +1,269 @@
1
- # npm distribution
2
-
3
- `@bitefoundry/outlook` is distributed on npm as a small JavaScript launcher plus one
4
- optional dependency per platform. The launcher resolves the prebuilt Rust binary
5
- and execs it directly (with `scripts/postinstall.mjs` linking the native binary
6
- into `bin/` and Windows shims for zero-Node-startup execution), so there is no
7
- compiler, Node native addon, or network download during install.
8
-
9
- The Rust crate is named `outlook-cli` and produces the pure **Microsoft Outlook**
10
- binary (`outlook` / `outlook.exe`). The npm package is scoped as `@bitefoundry/outlook`
11
- and installs the **`outlook`** command.
12
-
13
- ## Install and run
14
-
15
- ```sh
16
- # one-off
17
- npx @bitefoundry/outlook --version
18
-
19
- # global install (installs `outlook`)
20
- npm install -g @bitefoundry/outlook
21
- outlook --version
22
-
23
- # project-local
24
- npm install @bitefoundry/outlook
25
- npx outlook mail --folder inbox
26
- ```
27
-
28
- All workflows share the same Microsoft Entra ID login (or automatic M365 shared-session
29
- bootstrap with `teams-cli`), SQLite WAL + FTS5 cache (`cache.db`), background sync
30
- daemon (`outlook daemon start | status | stop | restart`), HTTP API (`outlook serve`,
31
- default `127.0.0.1:3939`), MCP server (`outlook mcp`), and multi-protocol terminal image
32
- preview (`Kitty` / `iTerm2` / `Sixel` / `Halfblock` via `outlook preview` and the TUI).
33
- Read commands also support `--cached` / `--fast` for instant local cache reads, or run
34
- with zero Graph round-trips while the daemon is warm:
35
-
36
- - `outlook login`, `outlook whoami`, `outlook doctor --online`
37
- - `outlook folders`, `outlook mail --folder inbox --limit 30`, `outlook read <message_id>`
38
- - `outlook send`, `outlook reply`, `outlook forward`, `outlook mark`, `outlook move`, `outlook archive`, `outlook delete`
39
- - `outlook calendar --days 7`, `outlook event <id>`, `outlook create-event`, `outlook rsvp`, `outlook delete-event`
40
- - `outlook contacts --query <q>`, `outlook task-lists`, `outlook tasks`, `outlook add-task`, `outlook done`, `outlook delete-task`
41
- - `outlook search`, `outlook download`, `outlook preview`, `outlook sync`, `outlook daemon <start|status|stop|restart>`, `outlook tui`, `outlook serve`, `outlook mcp`, `outlook update`
42
-
43
- ## Supported platforms
44
-
45
- | npm package | OS | CPU | Rust target |
46
- | ------------------------------- | ------- | ----- | ----------------------------------- |
47
- | `@bitefoundry/outlook-win32-x64` | Windows | x64 | `x86_64-pc-windows-msvc` |
48
- | `@bitefoundry/outlook-win32-arm64` | Windows | arm64 | `aarch64-pc-windows-msvc` |
49
- | `@bitefoundry/outlook-darwin-x64` | macOS | x64 | `x86_64-apple-darwin` |
50
- | `@bitefoundry/outlook-darwin-arm64` | macOS | arm64 | `aarch64-apple-darwin` |
51
- | `@bitefoundry/outlook-linux-x64` | Linux | x64 | `x86_64-unknown-linux-gnu` (2.28) |
52
- | `@bitefoundry/outlook-linux-arm64` | Linux | arm64 | `aarch64-unknown-linux-gnu` (2.28) |
53
-
54
- Linux packages are cross-compiled in CI with `cargo-zigbuild` against **GLIBC 2.28** (`*.2.28`) and verified with `scripts/verify-glibc.mjs` plus an `almalinux:8` container smoke test, so prebuilt binaries run out of the box on **AlmaLinux 8 / RHEL 8+ / Rocky Linux 8+ / Ubuntu 20.04+ / Debian 10+**. Older glibc distributions (e.g., CentOS 7 with `GLIBC < 2.28`) and Alpine/musl Linux should build from source with Cargo (`cargo build --release`).
55
-
56
- ## How resolution works
57
-
58
- `bin/outlook.js` looks up `@bitefoundry/outlook-<platform>-<arch>` through
59
- `require.resolve`, then executes
60
- `node_modules/@bitefoundry/outlook-<platform>-<arch>/bin/outlook` (or `outlook.exe` on
61
- Windows) with `stdio: 'inherit'`. On `npm install`, `scripts/postinstall.mjs`
62
- additionally replaces `bin/outlook.js` (Unix) or rewrites `.bin/outlook[.cmd|.ps1]`
63
- (Windows) to invoke the native Rust executable directly without spawning Node.
64
- Signals (`SIGINT`, `SIGTERM`, `SIGHUP`) are forwarded and the launcher exits
65
- with the child's exit code. If the platform package is missing (for example
66
- because optional dependencies were skipped), the launcher prints the supported
67
- platforms and the `--include=optional` hint instead of a stack trace.
68
-
69
- ## Layout
70
-
71
- ```
72
- package.json # @bitefoundry/outlook launcher package (bin: outlook)
73
- bin/outlook.js # outlook launcher
74
- scripts/postinstall.mjs # zero-Node native binary linker on npm install
75
- outlook / outlook.cmd # repo-local Outlook launchers
76
- npm/outlook-<platform>/ # one package per platform
77
- package.json # os/cpu/files, same version as root
78
- bin/outlook[.exe] # added by scripts/build-npm.mjs, never committed
79
- scripts/build-npm.mjs # copy target/<triple>/release/outlook[.exe]
80
- scripts/sync-version.mjs # Cargo.toml version -> all package.json files
81
- scripts/verify-glibc.mjs # verify Linux ELF GLIBC <= 2.28 symbol ceiling
82
- .github/workflows/release.yml # tag-triggered build, publish, GitHub Release
83
- ```
84
-
85
- Binaries are gitignored (`npm/*/bin/outlook*`). A clean checkout has empty
86
- platform `bin/` directories until a build or `npm run build:npm` runs.
87
-
88
- ## Versioning
89
-
90
- `Cargo.toml` (`[package].version`) is the single source of truth. To bump:
91
-
92
- ```sh
93
- # edit Cargo.toml [package].version
94
- node scripts/sync-version.mjs
95
- ```
96
-
97
- The script updates the root `package.json`, every `npm/outlook-*/package.json`,
98
- and the root `optionalDependencies` pins. It is idempotent; `--check` exits
99
- non-zero if anything is stale. All packages must be published at the same
100
- version because the root package pins its platform packages exactly.
101
-
102
- Tag the release with a matching `v` prefix:
103
-
104
- ```sh
105
- git tag v0.1.0
106
- git push origin v0.1.0
107
- ```
108
-
109
- ## Publishing
110
-
111
- Publishing is automated by `.github/workflows/release.yml`, which is triggered
112
- by pushing a `v*` tag (or manually via `workflow_dispatch`).
113
-
114
- 1. Add a repository secret `NPM_TOKEN` (an npm automation token with publish
115
- rights for the `@bitefoundry/outlook` packages).
116
- 2. Bump the version in `Cargo.toml`, run `node scripts/sync-version.mjs`,
117
- commit, and push `v<version>`.
118
- 3. The workflow builds six targets, stages binaries into the platform
119
- packages, uploads artifacts, publishes each platform package, publishes the
120
- root package, and creates a GitHub Release with the archives, `outlook.exe`,
121
- and `SHA256SUMS.txt`.
122
-
123
- The publish job verifies that the tag matches the package version and that all
124
- six platform packages contain a binary before publishing anything. Platform
125
- packages are published first so the root package's `optionalDependencies` can
126
- resolve immediately.
127
-
128
- Manual publish (matching order):
129
-
130
- ```sh
131
- node scripts/sync-version.mjs --check
132
- for dir in npm/outlook-*; do npm publish "$dir" --access public; done
133
- npm publish --access public
134
- ```
135
-
136
- ## Local validation
137
-
138
- ```sh
139
- # stage the current host binary (Windows example)
140
- node scripts/build-npm.mjs --target x86_64-pc-windows-msvc
141
- node bin/outlook.js --version
142
-
143
- npm pack --dry-run
144
- npm pack --dry-run ./npm/outlook-win32-x64
145
- ```
146
-
147
- `node scripts/build-npm.mjs` with no arguments uses the host target and falls
148
- back to `target/release/` when a plain `cargo build --release` was used.
149
- `--all` attempts every supported target and warns about the ones not built on
150
- the current host.
151
-
152
- ## External token brokers, M365 bootstrap & token scopes
153
-
154
- When using an external Microsoft Graph token broker (`tc-auth`, `az account get-access-token`, Vault CLI, etc.), configure `token_file` / `token_refresh_cmd` instead of shell wrappers (avoids `cmd.exe` 1023-char `set /p` truncation and `.ps1`/`.cmd` shim issues). Setting `OUTLOOK_TOKEN_FILE` (`token_file`) or `OUTLOOK_ACCESS_TOKEN` automatically skips OS keyring reads.
155
-
156
- When `share_m365_auth = true` (default; `OUTLOOK_SHARE_M365_AUTH=true`), `outlook` can also bootstrap from an existing `TEAMS_TOKEN_FILE` or `teams-cli` stored session if no `outlook-cli` token is configured yet.
157
-
158
- ### Required Microsoft Graph delegated scopes
159
-
160
- Pure Outlook requests only Microsoft Outlook & Graph core scopes:
161
-
162
- `offline_access`, `User.Read`, `User.ReadBasic.All`, `Mail.ReadWrite`, `Mail.Send`, `Calendars.ReadWrite`, `Contacts.ReadWrite`, `Tasks.ReadWrite`
163
-
164
- Run `outlook whoami` or `outlook doctor` to inspect JWT `scp`/`roles` claims automatically.
165
-
166
- ### 1. `config.toml` (recommended persistent setup)
167
-
168
- ```toml
169
- # Windows: %APPDATA%\outlook-cli\config.toml
170
- # Linux/macOS: ~/.config/outlook-cli/config.toml
171
- token_file = "~/.cursor/tc-auth/access_token"
172
- token_refresh_cmd = "python ~/.cursor/tc-auth/graph-auth.py refresh"
173
- token_refresh_mins = 5
174
- ```
175
-
176
- ### 2. Environment variables
177
-
178
- ```sh
179
- export OUTLOOK_TOKEN_FILE="$HOME/.cursor/tc-auth/access_token"
180
- export OUTLOOK_TOKEN_REFRESH_CMD="python $HOME/.cursor/tc-auth/graph-auth.py refresh"
181
- export OUTLOOK_TOKEN_REFRESH_MINS=5
182
- ```
183
-
184
- ### 3. Azure CLI (`az account get-access-token`) JSON/stdout integration
185
-
186
- If `token_file` is omitted, `token_refresh_cmd` stdout (raw JWT or Azure CLI camelCase JSON `accessToken` / `expiresOn`) is parsed and cached in memory:
187
-
188
- ```toml
189
- token_refresh_cmd = "az account get-access-token --resource https://graph.microsoft.com --output json"
190
- token_refresh_mins = 5
191
- ```
192
-
193
- ### Key environment variables
194
-
195
- | Variable | Summary |
196
- | --- | --- |
197
- | `OUTLOOK_ACCESS_TOKEN` | Static Bearer token override (automatically skips OS keyring) |
198
- | `OUTLOOK_TOKEN_FILE` | External token file path (raw JWT or JSON; skips OS keyring) |
199
- | `OUTLOOK_TOKEN_REFRESH_CMD` | Shell command run to refresh expiring/`401` tokens |
200
- | `OUTLOOK_TOKEN_REFRESH_MINS` | Refresh lead window in minutes before expiry (default `5`) |
201
- | `OUTLOOK_SHARE_M365_AUTH` | Share/bootstrap M365 token session from `TEAMS_TOKEN_FILE` or `teams-cli` (default `true`) |
202
- | `OUTLOOK_DISABLE_KEYRING=1` | Disable OS keyring and use `credentials.json` only |
203
- | `OUTLOOK_CLIENT_ID` | Override Entra ID application client ID (falls back to `TEAMS_CLIENT_ID`, `AZURE_CLIENT_ID`) |
204
- | `OUTLOOK_TENANT_ID` | Override Entra ID tenant ID (default `common`; falls back to `TEAMS_TENANT_ID`, `AZURE_TENANT_ID`) |
205
- | `OUTLOOK_CONFIG_DIR` | Override config/credentials directory |
206
- | `OUTLOOK_DATA_DIR` | Override SQLite cache (`cache.db`) directory |
207
- | `OUTLOOK_NO_BROWSER` | Disable automatic browser launch during login (`1` / `true`) |
208
- | `OUTLOOK_CLI_CACHE_SECS` | CLI read cache TTL in seconds (default `0`; `--cached` / `--fast` forces cache-first reads) |
209
- | `OUTLOOK_AUTO_DAEMON` | Auto-start/attach to the background sync daemon (`1` / `true`, or `config.toml`: `auto_daemon = true`, default `false`) |
210
- | `OUTLOOK_IMAGE_PROTOCOL` | Terminal image protocol override (`auto`, `kitty`, `iterm2`, `sixel`, `halfblock`) |
211
- | `OUTLOOK_GITHUB_REPO` | Override GitHub `owner/repo` used by `outlook update` (default `BiteFoundry/outlook`) |
212
- | `OUTLOOK_GITHUB_TOKEN` | GitHub token for private release checks in `outlook update` |
213
-
214
- ## Troubleshooting
215
-
216
- - **`no prebuilt binary found for <platform>-<arch>`** — the optional
217
- dependency was skipped. Reinstall with
218
- `npm install -g @bitefoundry/outlook --include=optional` or
219
- `npm install @bitefoundry/outlook --include=optional`. Check that your npm config
220
- does not set `omit=optional`.
221
- - **`EBADPLATFORM` / package skipped** — npm installs only the matching
222
- `os`/`cpu` package. Cross-installing (for example x64 Node on ARM Windows via
223
- emulation) still reports the Node architecture, so install under the native
224
- Node build.
225
- - **Older Linux (`GLIBC < 2.28`, e.g. CentOS 7) or Alpine/musl Linux** — prebuilt Linux binaries require **GLIBC >= 2.28** (AlmaLinux 8 / RHEL 8+ / Rocky Linux 8+ / Ubuntu 20.04+ / Debian 10+). On older glibc or musl systems, build from source with Cargo (`cargo build --release`).
226
- - **macOS Gatekeeper** — npm-installed binaries are not notarized. If macOS
227
- blocks execution, allow the binary in System Settings → Privacy & Security, or
228
- build from source.
229
- - **Corporate proxy/firewall** — `npx @bitefoundry/outlook` performs a registry
230
- download each time unless cached; use a global install for offline-friendly
231
- use.
232
- - **Verify the binary** —
233
- `node -p "require.resolve('@bitefoundry/outlook-win32-x64/package.json')"`
234
- (adjust for your platform) shows which platform package npm selected.
235
- - **Tag push did not publish** — check the publish job log; a tag/version
236
- mismatch or a missing `NPM_TOKEN` fails the job before any publish.
1
+ # npm distribution
2
+
3
+ `@bitefoundry/outlook` is distributed on npm as a small JavaScript launcher plus one
4
+ optional dependency per platform. The launcher resolves the prebuilt Rust binary
5
+ and execs it directly (with `scripts/postinstall.mjs` linking the native binary
6
+ into `bin/` and Windows shims for zero-Node-startup execution), so there is no
7
+ compiler, Node native addon, or network download during install.
8
+
9
+ The Rust crate is named `outlook-cli` and produces the pure **Microsoft Outlook**
10
+ binary (`outlook` / `outlook.exe`). The npm package is scoped as `@bitefoundry/outlook`
11
+ and installs the **`outlook`** command.
12
+
13
+ ## Install and run
14
+
15
+ ```sh
16
+ # one-off
17
+ npx @bitefoundry/outlook --version
18
+
19
+ # global install (installs `outlook`)
20
+ npm install -g @bitefoundry/outlook
21
+ outlook --version
22
+
23
+ # project-local
24
+ npm install @bitefoundry/outlook
25
+ npx outlook mail --folder inbox
26
+ ```
27
+
28
+ All workflows share the same Microsoft Entra ID login (or automatic M365 shared-session
29
+ bootstrap with `teams-cli`), SQLite WAL + FTS5 cache (`cache.db`), background sync
30
+ daemon (`outlook daemon start | status | stop | restart`), HTTP API (`outlook serve`,
31
+ default `127.0.0.1:3939`), MCP server (`outlook mcp`), and multi-protocol terminal image
32
+ preview (`Kitty` / `iTerm2` / `Sixel` / `Halfblock` via `outlook preview` and the TUI).
33
+ Read commands also support `--cached` / `--fast` for instant local cache reads, or run
34
+ with zero Graph round-trips while the daemon is warm:
35
+
36
+ - `outlook login`, `outlook whoami`, `outlook doctor --online`
37
+ - `outlook folders`, `outlook mail --folder inbox --limit 30`, `outlook read <message_id>`
38
+ - `outlook send`, `outlook reply`, `outlook forward`, `outlook mark`, `outlook move`, `outlook archive`, `outlook delete`
39
+ - `outlook calendar --days 7`, `outlook event <id>`, `outlook create-event`, `outlook rsvp`, `outlook delete-event`
40
+ - `outlook contacts --query <q>`, `outlook task-lists`, `outlook tasks`, `outlook add-task`, `outlook done`, `outlook delete-task`
41
+ - `outlook search`, `outlook download`, `outlook preview`, `outlook sync`, `outlook daemon <start|status|stop|restart>`, `outlook tui`, `outlook serve`, `outlook mcp`, `outlook update`
42
+
43
+ ## Supported platforms
44
+
45
+ | npm package | OS | CPU | Rust target |
46
+ | ------------------------------- | ------- | ----- | ----------------------------------- |
47
+ | `@bitefoundry/outlook-win32-x64` | Windows | x64 | `x86_64-pc-windows-msvc` |
48
+ | `@bitefoundry/outlook-win32-arm64` | Windows | arm64 | `aarch64-pc-windows-msvc` |
49
+ | `@bitefoundry/outlook-darwin-x64` | macOS | x64 | `x86_64-apple-darwin` |
50
+ | `@bitefoundry/outlook-darwin-arm64` | macOS | arm64 | `aarch64-apple-darwin` |
51
+ | `@bitefoundry/outlook-linux-x64` | Linux | x64 | `x86_64-unknown-linux-gnu` (2.28) |
52
+ | `@bitefoundry/outlook-linux-arm64` | Linux | arm64 | `aarch64-unknown-linux-gnu` (2.28) |
53
+
54
+ Linux packages are cross-compiled in CI with `cargo-zigbuild` against **GLIBC 2.28** (`*.2.28`) and verified with `scripts/verify-glibc.mjs` plus an `almalinux:8` container smoke test, so prebuilt binaries run out of the box on **AlmaLinux 8 / RHEL 8+ / Rocky Linux 8+ / Ubuntu 20.04+ / Debian 10+**. Older glibc distributions (e.g., CentOS 7 with `GLIBC < 2.28`) and Alpine/musl Linux should build from source with Cargo (`cargo build --release`).
55
+
56
+ ## How resolution works
57
+
58
+ `bin/outlook.js` looks up `@bitefoundry/outlook-<platform>-<arch>` through
59
+ `require.resolve`, then executes
60
+ `node_modules/@bitefoundry/outlook-<platform>-<arch>/bin/outlook` (or `outlook.exe` on
61
+ Windows) with `stdio: 'inherit'`. On `npm install`, `scripts/postinstall.mjs`
62
+ additionally replaces `bin/outlook.js` (Unix) or rewrites `.bin/outlook[.cmd|.ps1]`
63
+ (Windows) to invoke the native Rust executable directly without spawning Node.
64
+ Signals (`SIGINT`, `SIGTERM`, `SIGHUP`) are forwarded and the launcher exits
65
+ with the child's exit code. If the platform package is missing (for example
66
+ because optional dependencies were skipped), the launcher prints the supported
67
+ platforms and the `--include=optional` hint instead of a stack trace.
68
+
69
+ ## Layout
70
+
71
+ ```
72
+ package.json # @bitefoundry/outlook launcher package (bin: outlook)
73
+ bin/outlook.js # outlook launcher
74
+ scripts/postinstall.mjs # zero-Node native binary linker on npm install
75
+ outlook / outlook.cmd # repo-local Outlook launchers
76
+ npm/outlook-<platform>/ # one package per platform
77
+ package.json # os/cpu/files, same version as root
78
+ bin/outlook[.exe] # added by scripts/build-npm.mjs, never committed
79
+ scripts/build-npm.mjs # copy target/<triple>/release/outlook[.exe]
80
+ scripts/sync-version.mjs # Cargo.toml version -> all package.json files
81
+ scripts/verify-glibc.mjs # verify Linux ELF GLIBC <= 2.28 symbol ceiling
82
+ .github/workflows/release.yml # tag-triggered build, publish, GitHub Release
83
+ ```
84
+
85
+ Binaries are gitignored (`npm/*/bin/outlook*`). A clean checkout has empty
86
+ platform `bin/` directories until a build or `npm run build:npm` runs.
87
+
88
+ ## Versioning
89
+
90
+ `Cargo.toml` (`[package].version`) is the single source of truth. To bump:
91
+
92
+ ```sh
93
+ # edit Cargo.toml [package].version
94
+ node scripts/sync-version.mjs
95
+ ```
96
+
97
+ The script updates the root `package.json`, every `npm/outlook-*/package.json`,
98
+ and the root `optionalDependencies` pins. It is idempotent; `--check` exits
99
+ non-zero if anything is stale. All packages must be published at the same
100
+ version because the root package pins its platform packages exactly.
101
+
102
+ Tag the release with a matching `v` prefix:
103
+
104
+ ```sh
105
+ git tag v0.1.0
106
+ git push origin v0.1.0
107
+ ```
108
+
109
+ ## Publishing
110
+
111
+ Publishing is automated by `.github/workflows/release.yml`, which is triggered
112
+ by pushing a `v*` tag (or manually via `workflow_dispatch`).
113
+
114
+ 1. Add a repository secret `NPM_TOKEN` (an npm automation token with publish
115
+ rights for the `@bitefoundry/outlook` packages).
116
+ 2. Bump the version in `Cargo.toml`, run `node scripts/sync-version.mjs`,
117
+ commit, and push `v<version>`.
118
+ 3. The workflow builds six targets, stages binaries into the platform
119
+ packages, uploads artifacts, publishes each platform package, publishes the
120
+ root package, and creates a GitHub Release with the archives, `outlook.exe`,
121
+ and `SHA256SUMS.txt`.
122
+
123
+ The publish job verifies that the tag matches the package version and that all
124
+ six platform packages contain a binary before publishing anything. Platform
125
+ packages are published first so the root package's `optionalDependencies` can
126
+ resolve immediately.
127
+
128
+ Manual publish (matching order):
129
+
130
+ ```sh
131
+ node scripts/sync-version.mjs --check
132
+ for dir in npm/outlook-*; do npm publish "$dir" --access public; done
133
+ npm publish --access public
134
+ ```
135
+
136
+ ## Local validation
137
+
138
+ ```sh
139
+ # stage the current host binary (Windows example)
140
+ node scripts/build-npm.mjs --target x86_64-pc-windows-msvc
141
+ node bin/outlook.js --version
142
+
143
+ npm pack --dry-run
144
+ npm pack --dry-run ./npm/outlook-win32-x64
145
+ ```
146
+
147
+ `node scripts/build-npm.mjs` with no arguments uses the host target and falls
148
+ back to `target/release/` when a plain `cargo build --release` was used.
149
+ `--all` attempts every supported target and warns about the ones not built on
150
+ the current host.
151
+
152
+ ## External token brokers, M365 bootstrap & token scopes
153
+
154
+ When using an external Microsoft Graph token broker (`tc-auth`, `az account get-access-token`, Vault CLI, etc.), configure `token_file` / `token_refresh_cmd` instead of shell wrappers (avoids `cmd.exe` 1023-char `set /p` truncation and `.ps1`/`.cmd` shim issues). Setting `OUTLOOK_TOKEN_FILE` (`token_file`) or `OUTLOOK_ACCESS_TOKEN` automatically skips OS keyring reads.
155
+
156
+ When `share_m365_auth = true` (default; `OUTLOOK_SHARE_M365_AUTH=true`), `outlook` can also bootstrap from an existing `TEAMS_TOKEN_FILE` or `teams-cli` stored session if no `outlook-cli` token is configured yet.
157
+
158
+ ### Required Microsoft Graph delegated scopes
159
+
160
+ Pure Outlook requests only Microsoft Outlook & Graph core scopes:
161
+
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.
165
+
166
+ Run `outlook whoami` or `outlook doctor` to inspect JWT `scp`/`roles` claims automatically.
167
+
168
+ ### 1. `config.toml` (recommended persistent setup)
169
+
170
+ ```toml
171
+ # Windows: %APPDATA%\outlook-cli\config.toml
172
+ # Linux/macOS: ~/.config/outlook-cli/config.toml
173
+ token_file = "~/.cursor/tc-auth/access_token"
174
+ token_refresh_cmd = "python ~/.cursor/tc-auth/graph-auth.py refresh"
175
+ token_refresh_mins = 5
176
+ ```
177
+
178
+ ### 2. Environment variables
179
+
180
+ ```sh
181
+ export OUTLOOK_TOKEN_FILE="$HOME/.cursor/tc-auth/access_token"
182
+ export OUTLOOK_TOKEN_REFRESH_CMD="python $HOME/.cursor/tc-auth/graph-auth.py refresh"
183
+ export OUTLOOK_TOKEN_REFRESH_MINS=5
184
+ ```
185
+
186
+ ### 3. Azure CLI (`az account get-access-token`) JSON/stdout integration
187
+
188
+ If `token_file` is omitted, `token_refresh_cmd` stdout (raw JWT or Azure CLI camelCase JSON `accessToken` / `expiresOn`) is parsed and cached in memory:
189
+
190
+ ```toml
191
+ token_refresh_cmd = "az account get-access-token --resource https://graph.microsoft.com --output json"
192
+ token_refresh_mins = 5
193
+ ```
194
+
195
+ ### Key environment variables
196
+
197
+ | Variable | Summary |
198
+ | --- | --- |
199
+ | `OUTLOOK_ACCESS_TOKEN` | Static Bearer token override (automatically skips OS keyring) |
200
+ | `OUTLOOK_TOKEN_FILE` | External token file path (raw JWT or JSON; skips OS keyring) |
201
+ | `OUTLOOK_TOKEN_REFRESH_CMD` | Shell command run to refresh expiring/`401` tokens |
202
+ | `OUTLOOK_TOKEN_REFRESH_MINS` | Refresh lead window in minutes before expiry (default `5`) |
203
+ | `OUTLOOK_SHARE_M365_AUTH` | Share/bootstrap M365 token session from `TEAMS_TOKEN_FILE` or `teams-cli` (default `true`) |
204
+ | `OUTLOOK_DISABLE_KEYRING=1` | Disable OS keyring and use `credentials.json` only |
205
+ | `OUTLOOK_CLIENT_ID` | Override Entra ID application client ID (falls back to `TEAMS_CLIENT_ID`, `AZURE_CLIENT_ID`) |
206
+ | `OUTLOOK_TENANT_ID` | Override Entra ID tenant ID (default `common`; falls back to `TEAMS_TENANT_ID`, `AZURE_TENANT_ID`) |
207
+ | `OUTLOOK_CONFIG_DIR` | Override config/credentials directory |
208
+ | `OUTLOOK_DATA_DIR` | Override SQLite cache (`cache.db`) directory |
209
+ | `OUTLOOK_NO_BROWSER` | Disable automatic browser launch during login (`1` / `true`) |
210
+ | `OUTLOOK_CLI_CACHE_SECS` | CLI read cache TTL in seconds (default `0`; `--cached` / `--fast` forces cache-first reads) |
211
+ | `OUTLOOK_AUTO_DAEMON` | Auto-start/attach to the background sync daemon (`1` / `true`, or `config.toml`: `auto_daemon = true`, default `false`) |
212
+ | `OUTLOOK_IMAGE_PROTOCOL` | Terminal image protocol override (`auto`, `kitty`, `iterm2`, `sixel`, `halfblock`) |
213
+ | `OUTLOOK_GITHUB_REPO` | Override GitHub `owner/repo` used by `outlook update` (default `BiteFoundry/outlook`) |
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" }`.
246
+
247
+ ## Troubleshooting
248
+
249
+ - **`no prebuilt binary found for <platform>-<arch>`** — the optional
250
+ dependency was skipped. Reinstall with
251
+ `npm install -g @bitefoundry/outlook --include=optional` or
252
+ `npm install @bitefoundry/outlook --include=optional`. Check that your npm config
253
+ does not set `omit=optional`.
254
+ - **`EBADPLATFORM` / package skipped** — npm installs only the matching
255
+ `os`/`cpu` package. Cross-installing (for example x64 Node on ARM Windows via
256
+ emulation) still reports the Node architecture, so install under the native
257
+ Node build.
258
+ - **Older Linux (`GLIBC < 2.28`, e.g. CentOS 7) or Alpine/musl Linux** — prebuilt Linux binaries require **GLIBC >= 2.28** (AlmaLinux 8 / RHEL 8+ / Rocky Linux 8+ / Ubuntu 20.04+ / Debian 10+). On older glibc or musl systems, build from source with Cargo (`cargo build --release`).
259
+ - **macOS Gatekeeper** — npm-installed binaries are not notarized. If macOS
260
+ blocks execution, allow the binary in System Settings → Privacy & Security, or
261
+ build from source.
262
+ - **Corporate proxy/firewall** — `npx @bitefoundry/outlook` performs a registry
263
+ download each time unless cached; use a global install for offline-friendly
264
+ use.
265
+ - **Verify the binary** —
266
+ `node -p "require.resolve('@bitefoundry/outlook-win32-x64/package.json')"`
267
+ (adjust for your platform) shows which platform package npm selected.
268
+ - **Tag push did not publish** — check the publish job log; a tag/version
269
+ mismatch or a missing `NPM_TOKEN` fails the job before any publish.