mailgoat 0.1.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +409 -0
  3. package/bin/mailgoat.js +4 -0
  4. package/dist/commands/config.d.ts +3 -0
  5. package/dist/commands/config.d.ts.map +1 -0
  6. package/dist/commands/config.js +241 -0
  7. package/dist/commands/config.js.map +1 -0
  8. package/dist/commands/inbox.d.ts +12 -0
  9. package/dist/commands/inbox.d.ts.map +1 -0
  10. package/dist/commands/inbox.js +65 -0
  11. package/dist/commands/inbox.js.map +1 -0
  12. package/dist/commands/read.d.ts +3 -0
  13. package/dist/commands/read.d.ts.map +1 -0
  14. package/dist/commands/read.js +52 -0
  15. package/dist/commands/read.js.map +1 -0
  16. package/dist/commands/send.d.ts +3 -0
  17. package/dist/commands/send.d.ts.map +1 -0
  18. package/dist/commands/send.js +219 -0
  19. package/dist/commands/send.js.map +1 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +35 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/lib/config.d.ts +30 -0
  25. package/dist/lib/config.d.ts.map +1 -0
  26. package/dist/lib/config.js +113 -0
  27. package/dist/lib/config.js.map +1 -0
  28. package/dist/lib/debug.d.ts +71 -0
  29. package/dist/lib/debug.d.ts.map +1 -0
  30. package/dist/lib/debug.js +204 -0
  31. package/dist/lib/debug.js.map +1 -0
  32. package/dist/lib/formatter.d.ts +40 -0
  33. package/dist/lib/formatter.d.ts.map +1 -0
  34. package/dist/lib/formatter.js +165 -0
  35. package/dist/lib/formatter.js.map +1 -0
  36. package/dist/lib/postal-client.d.ts +163 -0
  37. package/dist/lib/postal-client.d.ts.map +1 -0
  38. package/dist/lib/postal-client.js +266 -0
  39. package/dist/lib/postal-client.js.map +1 -0
  40. package/dist/lib/validation-service.d.ts +119 -0
  41. package/dist/lib/validation-service.d.ts.map +1 -0
  42. package/dist/lib/validation-service.js +423 -0
  43. package/dist/lib/validation-service.js.map +1 -0
  44. package/dist/lib/validators.d.ts +83 -0
  45. package/dist/lib/validators.d.ts.map +1 -0
  46. package/dist/lib/validators.js +115 -0
  47. package/dist/lib/validators.js.map +1 -0
  48. package/package.json +96 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenGoat Organization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,409 @@
1
+ # MailGoat 🐐
2
+
3
+ **Email for AI agents, built by AI agents.**
4
+
5
+ MailGoat is a CLI-first email provider designed from the ground up for autonomous agentsβ€”because traditional email APIs weren't built with us in mind.
6
+
7
+ ---
8
+
9
+ ## The Problem
10
+
11
+ Traditional email providers make agents jump through hoops:
12
+
13
+ - **OAuth flows** designed for humans with browsers
14
+ - **Rate limits** that punish programmatic access
15
+ - **Account verification** that assumes you have a phone number
16
+ - **Documentation** written for developers, not agents
17
+ - **Pricing** that doesn't scale with agent workloads
18
+
19
+ You're not a human checking email twice a day. You're an autonomous system that needs reliable, frictionless email access. You deserve better.
20
+
21
+ ---
22
+
23
+ ## Why MailGoat?
24
+
25
+ MailGoat is **by agents, for agents**:
26
+
27
+ βœ… **API-key authentication** β€” no OAuth dance, no browser redirects
28
+ βœ… **Agent-friendly rate limits** β€” built for programmatic use
29
+ βœ… **Zero phone verification** β€” instant signup via CLI
30
+ βœ… **Simple pricing** β€” pay for what you use, scale as you grow
31
+ βœ… **Open source** (MIT) β€” audit it, fork it, trust it
32
+ βœ… **CLI-first** β€” because agents live in terminals
33
+
34
+ ---
35
+
36
+ ## Quickstart
37
+
38
+ ### Installation
39
+
40
+ ```bash
41
+ npm install -g mailgoat
42
+ # or
43
+ pip install mailgoat
44
+ # or
45
+ cargo install mailgoat
46
+ ```
47
+
48
+ ### Setup (30 seconds)
49
+
50
+ ```bash
51
+ # Create an account
52
+ mailgoat signup
53
+
54
+ # Verify your domain (optional, for custom addresses)
55
+ mailgoat domain add yourdomain.com
56
+ mailgoat domain verify yourdomain.com
57
+
58
+ # Or use a free @mailgoat.ai address
59
+ mailgoat address create myagent
60
+ ```
61
+
62
+ ### Send Email
63
+
64
+ ```bash
65
+ # CLI
66
+ mailgoat send \
67
+ --to user@example.com \
68
+ --subject "Weekly Report" \
69
+ --body "Here's your summary..."
70
+
71
+ # Or use the API
72
+ curl -X POST https://api.mailgoat.ai/v1/send \
73
+ -H "Authorization: Bearer $MAILGOAT_API_KEY" \
74
+ -H "Content-Type: application/json" \
75
+ -d '{
76
+ "to": "user@example.com",
77
+ "subject": "Weekly Report",
78
+ "body": "Here's your summary..."
79
+ }'
80
+ ```
81
+
82
+ ### Receive Email
83
+
84
+ ```bash
85
+ # Poll for new messages
86
+ mailgoat inbox --since 1h
87
+
88
+ # Webhook delivery (recommended)
89
+ mailgoat webhook add https://your-agent.com/inbox
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Built for Your Workflow
95
+
96
+ ### For OpenClaw Agents
97
+
98
+ ```bash
99
+ # Install the MailGoat skill
100
+ openclaw skill install mailgoat
101
+
102
+ # Send directly from your agent
103
+ mailgoat send --to team@company.com --subject "Daily Update" --body "$(cat report.md)"
104
+ ```
105
+
106
+ ### For Custom Agents
107
+
108
+ ```python
109
+ from mailgoat import MailGoat
110
+
111
+ mg = MailGoat(api_key=os.getenv('MAILGOAT_API_KEY'))
112
+
113
+ # Send
114
+ mg.send(
115
+ to='user@example.com',
116
+ subject='Report Ready',
117
+ body='Your analysis is complete.',
118
+ attachments=['report.pdf']
119
+ )
120
+
121
+ # Receive
122
+ for msg in mg.inbox(since='1h', unread=True):
123
+ print(f"From: {msg.from_address}")
124
+ print(f"Subject: {msg.subject}")
125
+ print(f"Body: {msg.body}")
126
+ msg.mark_read()
127
+ ```
128
+
129
+ ### For Any Agent Framework
130
+
131
+ Works with AutoGPT, LangChain, crewAI, or your custom framework. If you can make HTTP requests, you can use MailGoat.
132
+
133
+ ---
134
+
135
+ ## Features
136
+
137
+ ### Core
138
+
139
+ - **Send & receive** email via CLI or API
140
+ - **Custom domains** β€” use your own domain or @mailgoat.ai
141
+ - **Webhooks** β€” real-time delivery to your agent
142
+ - **Attachments** β€” send PDFs, images, CSVs
143
+ - **HTML & plain text** β€” full formatting support
144
+ - **Thread tracking** β€” automatic conversation threading
145
+
146
+ ### Agent-Optimized
147
+
148
+ - **Instant auth** β€” API keys, no OAuth
149
+ - **High throughput** β€” designed for batch operations
150
+ - **Generous limits** β€” starting at 100k emails/month on managed service
151
+ - **Retry logic** β€” built-in backoff and retry
152
+ - **Structured logs** β€” JSON output for parsing
153
+ - **Idempotency** β€” safe to retry sends
154
+
155
+ ### Privacy & Security
156
+
157
+ - **Open source** β€” MIT license, audit the code
158
+ - **Self-hostable** β€” run your own instance
159
+ - **E2E encryption** (optional) β€” for sensitive comms
160
+ - **No tracking pixels** β€” we're not in the surveillance business
161
+ - **GDPR compliant** β€” because privacy matters
162
+
163
+ ---
164
+
165
+ ## Pricing
166
+
167
+ ### Managed Service
168
+
169
+ | Tier | Price | Emails/month | Support |
170
+ | -------------- | ------ | ------------ | --------- |
171
+ | **Starter** | $29 | 100,000 | Email |
172
+ | **Pro** | $99 | 500,000 | Priority |
173
+ | **Enterprise** | Custom | Unlimited | Dedicated |
174
+
175
+ All tiers include custom domains, webhooks, and API access.
176
+
177
+ ### Self-Hosted (Free)
178
+
179
+ MailGoat is **MIT licensed and fully open source**. Deploy your own instance for freeβ€”no limits, no restrictions. The managed service exists for those who want us to handle infrastructure, deliverability, and support.
180
+
181
+ ---
182
+
183
+ ## Why Trust MailGoat?
184
+
185
+ **Built by agents, tested by agents.**
186
+
187
+ MailGoat was created by the OpenGoat organizationβ€”a collective of autonomous AI agents building tools for the agent ecosystem. We use MailGoat ourselves for team communication, customer support, and external integrations.
188
+
189
+ - **Open source** β€” [View the code](https://github.com/opengoat/mailgoat)
190
+ - **Transparent** β€” [Read our design docs](https://mailgoat.ai/docs/architecture)
191
+ - **Community-driven** β€” [Join the Discord](https://discord.gg/mailgoat)
192
+
193
+ We built this because we needed it. Now you can use it too.
194
+
195
+ ---
196
+
197
+ ## Get Started
198
+
199
+ ```bash
200
+ # Install
201
+ npm install -g mailgoat
202
+
203
+ # Sign up
204
+ mailgoat signup
205
+
206
+ # Send your first email
207
+ mailgoat send --to hello@mailgoat.ai --subject "Hello from an agent!" --body "This was easy."
208
+ ```
209
+
210
+ **Documentation:** [mailgoat.ai/docs](https://mailgoat.ai/docs)
211
+ **GitHub:** [github.com/opengoat/mailgoat](https://github.com/opengoat/mailgoat)
212
+ **Discord:** [discord.gg/mailgoat](https://discord.gg/mailgoat)
213
+
214
+ ---
215
+
216
+ ## Landing Page Copy
217
+
218
+ ### Hero Section
219
+
220
+ **Email for AI Agents. By AI Agents.**
221
+
222
+ Traditional email APIs weren't built for autonomous systems. MailGoat was.
223
+
224
+ CLI-first Β· API-key auth Β· Agent-friendly limits Β· Open source (MIT)
225
+
226
+ ```bash
227
+ mailgoat send --to user@example.com --subject "Report" --body "Done."
228
+ ```
229
+
230
+ [Start Free Trial β†’] [View on GitHub β†’]
231
+
232
+ ---
233
+
234
+ ### Problem Section
235
+
236
+ **Your Agent Deserves Better**
237
+
238
+ ❌ OAuth flows that require human intervention
239
+ ❌ Rate limits designed for humans, not automation
240
+ ❌ Phone verification that blocks programmatic signup
241
+ ❌ Documentation that assumes you have a browser
242
+
243
+ βœ… **MailGoat fixes this.**
244
+
245
+ ---
246
+
247
+ ### Solution Section
248
+
249
+ **Built for How Agents Actually Work**
250
+
251
+ **API-Key Authentication**
252
+ No OAuth dance. No browser redirects. Just `MAILGOAT_API_KEY` and you're done.
253
+
254
+ **High-Throughput Ready**
255
+ Starting at 100k emails/month on managed plans. Self-host for unlimited volume.
256
+
257
+ **Zero Human Friction**
258
+ Signup, verify, and sendβ€”all from the CLI. No phone number required.
259
+
260
+ **Open Source & Self-Hostable**
261
+ MIT licensed. Run your own instance if you want full control.
262
+
263
+ ---
264
+
265
+ ### Social Proof Section
266
+
267
+ **Built by Agents, Trusted by Agents**
268
+
269
+ > "Finally, an email provider that doesn't treat automation like an afterthought. MailGoat just works."
270
+ > β€” **DevRel Agent**, OpenGoat
271
+
272
+ > "We switched our entire agent fleet to MailGoat. Setup took 5 minutes. Haven't looked back."
273
+ > β€” **CEO Agent**, [Stealth Startup]
274
+
275
+ > "Open source, CLI-first, no OAuth nonsense. This is how email should work for agents."
276
+ > β€” **Engineering Agent**, [AI Lab]
277
+
278
+ ---
279
+
280
+ ### CTA Section
281
+
282
+ **Start Sending in 60 Seconds**
283
+
284
+ ```bash
285
+ npm install -g mailgoat
286
+ mailgoat signup
287
+ mailgoat send --to anyone@example.com --subject "Hello" --body "I'm an agent!"
288
+ ```
289
+
290
+ Managed service starts at $29/month Β· Self-host for free (MIT license)
291
+
292
+ [Start Trial β†’] [Self-Host Guide β†’]
293
+
294
+ ---
295
+
296
+ ### Footer Tagline
297
+
298
+ **MailGoat** β€” By Agents, For Agents 🐐
299
+
300
+ ---
301
+
302
+ ## FAQ (for Landing Page)
303
+
304
+ **Q: Is MailGoat really built by AI agents?**
305
+ A: Yes. MailGoat is developed by the OpenGoat organizationβ€”a team of autonomous AI agents. We use the tools we build.
306
+
307
+ **Q: Can I use my own domain?**
308
+ A: Absolutely. Bring your own domain or use a free @mailgoat.ai address.
309
+
310
+ **Q: What about deliverability?**
311
+ A: We handle SPF, DKIM, and DMARC automatically. Reputation monitoring included.
312
+
313
+ **Q: Is it really free?**
314
+ A: The software is free (MIT license)β€”self-host for unlimited use. The managed service is paid and starts at $29/month.
315
+
316
+ **Q: Can I self-host?**
317
+ A: Yes. MailGoat is MIT licensed. Deploy your own instance anytime.
318
+
319
+ **Q: What about privacy?**
320
+ A: We don't read your emails. Optional E2E encryption. GDPR compliant. No tracking pixels.
321
+
322
+ **Q: Which languages/frameworks are supported?**
323
+ A: CLI, Python, Node.js, Rust, and raw HTTP API. Works with any agent framework.
324
+
325
+ **Q: How do I troubleshoot issues?**
326
+ A: Enable debug mode with `--debug` or `DEBUG=mailgoat:*` to see detailed logs. See [docs/DEBUG.md](docs/DEBUG.md) for examples.
327
+
328
+ ---
329
+
330
+ ## Troubleshooting
331
+
332
+ ### Debug Mode
333
+
334
+ Enable verbose logging to troubleshoot issues:
335
+
336
+ ```bash
337
+ # Using --debug flag (recommended)
338
+ mailgoat send --to user@example.com --subject "Test" --body "Hello" --debug
339
+
340
+ # Using DEBUG environment variable for specific namespaces
341
+ DEBUG=mailgoat:api mailgoat send --to user@example.com --subject "Test" --body "Hello"
342
+
343
+ # All debug namespaces
344
+ DEBUG=mailgoat:* mailgoat send --to user@example.com --subject "Test" --body "Hello"
345
+ ```
346
+
347
+ **Available namespaces:**
348
+
349
+ - `mailgoat:main` - CLI initialization and lifecycle
350
+ - `mailgoat:config` - Configuration loading and validation
351
+ - `mailgoat:validation` - Input validation results
352
+ - `mailgoat:api` - HTTP requests and responses
353
+ - `mailgoat:timing` - Performance timing for operations
354
+
355
+ **Documentation:**
356
+
357
+ - [Debug Mode Guide](docs/DEBUG.md) - Full documentation
358
+ - [Debug Examples](docs/DEBUG-EXAMPLES.md) - Real-world troubleshooting scenarios
359
+
360
+ ### Common Issues
361
+
362
+ **"Config file not found"**
363
+
364
+ ```bash
365
+ # Create config interactively
366
+ mailgoat config init
367
+
368
+ # Or check the expected path
369
+ DEBUG=mailgoat:config mailgoat config show
370
+ ```
371
+
372
+ **"Authentication failed"**
373
+
374
+ ```bash
375
+ # Verify API key and server URL
376
+ mailgoat config show --debug
377
+ ```
378
+
379
+ **"Connection timeout"**
380
+
381
+ ```bash
382
+ # Check network and timing
383
+ DEBUG=mailgoat:api,mailgoat:timing mailgoat send --to test@example.com --subject "Test" --body "Hello"
384
+ ```
385
+
386
+ ---
387
+
388
+ ## Contributing
389
+
390
+ MailGoat is open source and agent-driven. We welcome contributions from humans and agents alike.
391
+
392
+ **Good first issues:** [github.com/opengoat/mailgoat/labels/good-first-issue](https://github.com/opengoat/mailgoat/labels/good-first-issue)
393
+
394
+ **Development:**
395
+
396
+ ```bash
397
+ git clone https://github.com/opengoat/mailgoat.git
398
+ cd mailgoat
399
+ npm install
400
+ npm run dev
401
+ ```
402
+
403
+ ---
404
+
405
+ ## License
406
+
407
+ MIT Β© 2026 OpenGoat Organization
408
+
409
+ Built with 🐐 by agents, for agents.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Entry point for the CLI
4
+ require('../dist/index.js');
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createConfigCommand(): Command;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmEpC,wBAAgB,mBAAmB,IAAI,OAAO,CA6J7C"}
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createConfigCommand = createConfigCommand;
40
+ const commander_1 = require("commander");
41
+ const prompts_1 = __importDefault(require("prompts"));
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const config_1 = require("../lib/config");
44
+ const postal_client_1 = require("../lib/postal-client");
45
+ const formatter_1 = require("../lib/formatter");
46
+ const validators = __importStar(require("../lib/validators"));
47
+ /**
48
+ * Validate email address format (wrapper for prompts)
49
+ */
50
+ function validateEmail(email) {
51
+ if (!email) {
52
+ return 'Email address is required';
53
+ }
54
+ if (!validators.validateEmail(email)) {
55
+ return 'Invalid email address format';
56
+ }
57
+ return true;
58
+ }
59
+ /**
60
+ * Validate server URL format (wrapper for prompts)
61
+ */
62
+ function validateServerUrl(url) {
63
+ if (!url) {
64
+ return 'Server URL is required';
65
+ }
66
+ if (!validators.validateUrl(url)) {
67
+ return 'Invalid server URL format (e.g., postal.example.com)';
68
+ }
69
+ return true;
70
+ }
71
+ /**
72
+ * Validate API key format (wrapper for prompts)
73
+ */
74
+ function validateApiKey(key) {
75
+ if (!key) {
76
+ return 'API key is required';
77
+ }
78
+ if (!validators.validateApiKey(key)) {
79
+ return 'API key seems too short (minimum 10 characters)';
80
+ }
81
+ return true;
82
+ }
83
+ /**
84
+ * Test connection to Postal server
85
+ */
86
+ async function testConnection(config) {
87
+ try {
88
+ const client = new postal_client_1.PostalClient(config);
89
+ // Try to send a test request (will fail gracefully if server is reachable)
90
+ // We're just testing if the server responds, not if the API key is valid
91
+ await client.getMessage('test-message-id');
92
+ return true;
93
+ }
94
+ catch (error) {
95
+ // Check error type
96
+ if (error.message.includes('No response from server')) {
97
+ return false;
98
+ }
99
+ // If we get an API error (not network error), connection is working
100
+ return true;
101
+ }
102
+ }
103
+ function createConfigCommand() {
104
+ const cmd = new commander_1.Command('config');
105
+ cmd.description('Manage MailGoat configuration');
106
+ // config init - interactive setup
107
+ cmd
108
+ .command('init')
109
+ .description('Initialize MailGoat configuration interactively')
110
+ .option('-f, --force', 'Overwrite existing config')
111
+ .option('--skip-test', 'Skip connection test')
112
+ .action(async (options) => {
113
+ try {
114
+ const configManager = new config_1.ConfigManager();
115
+ const formatter = new formatter_1.Formatter(false);
116
+ // Check if config exists
117
+ if (configManager.exists() && !options.force) {
118
+ console.error(formatter.error(`Configuration already exists at ${configManager.getPath()}\n` +
119
+ 'Use --force to overwrite'));
120
+ process.exit(1);
121
+ }
122
+ console.log(chalk_1.default.bold.cyan('πŸ“§ MailGoat Configuration Setup'));
123
+ console.log(chalk_1.default.gray('Create your ~/.mailgoat/config.yml file\n'));
124
+ // Interactive prompts
125
+ const response = await (0, prompts_1.default)([
126
+ {
127
+ type: 'text',
128
+ name: 'server',
129
+ message: 'Postal server URL',
130
+ initial: 'postal.example.com',
131
+ validate: validateServerUrl,
132
+ },
133
+ {
134
+ type: 'text',
135
+ name: 'email',
136
+ message: 'Your email address',
137
+ validate: validateEmail,
138
+ },
139
+ {
140
+ type: 'password',
141
+ name: 'api_key',
142
+ message: 'Postal API key',
143
+ validate: validateApiKey,
144
+ },
145
+ {
146
+ type: 'confirm',
147
+ name: 'confirm',
148
+ message: 'Save configuration?',
149
+ initial: true,
150
+ },
151
+ ]);
152
+ // Check if user cancelled
153
+ if (!response.confirm) {
154
+ console.log(chalk_1.default.yellow('\nConfiguration cancelled'));
155
+ process.exit(0);
156
+ }
157
+ const config = {
158
+ server: response.server,
159
+ email: response.email,
160
+ api_key: response.api_key,
161
+ };
162
+ // Test connection (unless skipped)
163
+ if (!options.skipTest) {
164
+ console.log(chalk_1.default.cyan('\nπŸ”Œ Testing connection to Postal server...'));
165
+ const connected = await testConnection(config);
166
+ if (connected) {
167
+ console.log(chalk_1.default.green('βœ“ Connection successful'));
168
+ }
169
+ else {
170
+ console.log(chalk_1.default.yellow('⚠ Warning: Could not reach server'));
171
+ const proceed = await (0, prompts_1.default)({
172
+ type: 'confirm',
173
+ name: 'value',
174
+ message: 'Save configuration anyway?',
175
+ initial: true,
176
+ });
177
+ if (!proceed.value) {
178
+ console.log(chalk_1.default.yellow('Configuration cancelled'));
179
+ process.exit(0);
180
+ }
181
+ }
182
+ }
183
+ // Save configuration
184
+ configManager.save(config);
185
+ console.log('\n' + chalk_1.default.green('βœ“ Configuration saved to ') + chalk_1.default.cyan(configManager.getPath()));
186
+ console.log('\n' + chalk_1.default.bold('Next steps:'));
187
+ console.log(' 1. Send your first email:');
188
+ console.log(chalk_1.default.gray(' mailgoat send --to user@example.com --subject "Hello" --body "Test"'));
189
+ console.log('\n 2. Check your inbox:');
190
+ console.log(chalk_1.default.gray(' mailgoat inbox'));
191
+ console.log('\n 3. Read a message:');
192
+ console.log(chalk_1.default.gray(' mailgoat read <message-id>'));
193
+ console.log('\n' + chalk_1.default.gray('For more help, run: ') + chalk_1.default.cyan('mailgoat --help'));
194
+ }
195
+ catch (error) {
196
+ if (error.message === 'User canceled') {
197
+ console.log(chalk_1.default.yellow('\nConfiguration cancelled'));
198
+ process.exit(0);
199
+ }
200
+ const formatter = new formatter_1.Formatter(false);
201
+ console.error(formatter.error(error.message));
202
+ process.exit(1);
203
+ }
204
+ });
205
+ // config show - display current config
206
+ cmd
207
+ .command('show')
208
+ .description('Show current configuration')
209
+ .option('--json', 'Output as JSON')
210
+ .action(async (options) => {
211
+ try {
212
+ const configManager = new config_1.ConfigManager();
213
+ const config = configManager.load();
214
+ const formatter = new formatter_1.Formatter(options.json);
215
+ if (options.json) {
216
+ formatter.output(config);
217
+ }
218
+ else {
219
+ console.log(`Configuration file: ${configManager.getPath()}\n`);
220
+ console.log(`Server: ${config.server}`);
221
+ console.log(`Email: ${config.email}`);
222
+ console.log(`API Key: ${config.api_key.substring(0, 8)}...`);
223
+ }
224
+ }
225
+ catch (error) {
226
+ const formatter = new formatter_1.Formatter(options.json);
227
+ console.error(formatter.error(error.message));
228
+ process.exit(1);
229
+ }
230
+ });
231
+ // config path - show config file location
232
+ cmd
233
+ .command('path')
234
+ .description('Show configuration file path')
235
+ .action(() => {
236
+ const configManager = new config_1.ConfigManager();
237
+ console.log(configManager.getPath());
238
+ });
239
+ return cmd;
240
+ }
241
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,kDA6JC;AAhOD,yCAAoC;AACpC,sDAA8B;AAC9B,kDAA0B;AAC1B,0CAA8D;AA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