@diskd-ai/email-mcp 0.3.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/LICENSE +155 -0
- package/README.md +820 -0
- package/dist/cli/account-commands.d.ts +10 -0
- package/dist/cli/account-commands.d.ts.map +1 -0
- package/dist/cli/account-commands.js +703 -0
- package/dist/cli/account-commands.js.map +1 -0
- package/dist/cli/config-commands.d.ts +9 -0
- package/dist/cli/config-commands.d.ts.map +1 -0
- package/dist/cli/config-commands.js +156 -0
- package/dist/cli/config-commands.js.map +1 -0
- package/dist/cli/guard.d.ts +11 -0
- package/dist/cli/guard.d.ts.map +1 -0
- package/dist/cli/guard.js +18 -0
- package/dist/cli/guard.js.map +1 -0
- package/dist/cli/install-commands.d.ts +12 -0
- package/dist/cli/install-commands.d.ts.map +1 -0
- package/dist/cli/install-commands.js +320 -0
- package/dist/cli/install-commands.js.map +1 -0
- package/dist/cli/notify.d.ts +8 -0
- package/dist/cli/notify.d.ts.map +1 -0
- package/dist/cli/notify.js +143 -0
- package/dist/cli/notify.js.map +1 -0
- package/dist/cli/providers.d.ts +13 -0
- package/dist/cli/providers.d.ts.map +1 -0
- package/dist/cli/providers.js +180 -0
- package/dist/cli/providers.js.map +1 -0
- package/dist/cli/scheduler.d.ts +8 -0
- package/dist/cli/scheduler.d.ts.map +1 -0
- package/dist/cli/scheduler.js +268 -0
- package/dist/cli/scheduler.js.map +1 -0
- package/dist/cli/setup.d.ts +12 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +15 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/test.d.ts +7 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +67 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/config/loader.d.ts +34 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +339 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +351 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +165 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/xdg.d.ts +27 -0
- package/dist/config/xdg.d.ts.map +1 -0
- package/dist/config/xdg.js +30 -0
- package/dist/config/xdg.js.map +1 -0
- package/dist/connections/manager.d.ts +42 -0
- package/dist/connections/manager.d.ts.map +1 -0
- package/dist/connections/manager.js +266 -0
- package/dist/connections/manager.js.map +1 -0
- package/dist/connections/types.d.ts +13 -0
- package/dist/connections/types.d.ts.map +1 -0
- package/dist/connections/types.js +2 -0
- package/dist/connections/types.js.map +1 -0
- package/dist/logging.d.ts +46 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +63 -0
- package/dist/logging.js.map +1 -0
- package/dist/main.d.ts +13 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +206 -0
- package/dist/main.js.map +1 -0
- package/dist/prompts/actions.prompt.d.ts +9 -0
- package/dist/prompts/actions.prompt.d.ts.map +1 -0
- package/dist/prompts/actions.prompt.js +64 -0
- package/dist/prompts/actions.prompt.js.map +1 -0
- package/dist/prompts/calendar.prompt.d.ts +9 -0
- package/dist/prompts/calendar.prompt.d.ts.map +1 -0
- package/dist/prompts/calendar.prompt.js +55 -0
- package/dist/prompts/calendar.prompt.js.map +1 -0
- package/dist/prompts/cleanup.prompt.d.ts +9 -0
- package/dist/prompts/cleanup.prompt.d.ts.map +1 -0
- package/dist/prompts/cleanup.prompt.js +78 -0
- package/dist/prompts/cleanup.prompt.js.map +1 -0
- package/dist/prompts/compose.prompt.d.ts +8 -0
- package/dist/prompts/compose.prompt.d.ts.map +1 -0
- package/dist/prompts/compose.prompt.js +116 -0
- package/dist/prompts/compose.prompt.js.map +1 -0
- package/dist/prompts/register.d.ts +8 -0
- package/dist/prompts/register.d.ts.map +1 -0
- package/dist/prompts/register.js +20 -0
- package/dist/prompts/register.js.map +1 -0
- package/dist/prompts/thread.prompt.d.ts +9 -0
- package/dist/prompts/thread.prompt.d.ts.map +1 -0
- package/dist/prompts/thread.prompt.js +58 -0
- package/dist/prompts/thread.prompt.js.map +1 -0
- package/dist/prompts/triage.prompt.d.ts +9 -0
- package/dist/prompts/triage.prompt.d.ts.map +1 -0
- package/dist/prompts/triage.prompt.js +64 -0
- package/dist/prompts/triage.prompt.js.map +1 -0
- package/dist/resources/accounts.resource.d.ts +9 -0
- package/dist/resources/accounts.resource.d.ts.map +1 -0
- package/dist/resources/accounts.resource.js +26 -0
- package/dist/resources/accounts.resource.js.map +1 -0
- package/dist/resources/mailboxes.resource.d.ts +10 -0
- package/dist/resources/mailboxes.resource.d.ts.map +1 -0
- package/dist/resources/mailboxes.resource.js +33 -0
- package/dist/resources/mailboxes.resource.js.map +1 -0
- package/dist/resources/register.d.ts +12 -0
- package/dist/resources/register.d.ts.map +1 -0
- package/dist/resources/register.js +20 -0
- package/dist/resources/register.js.map +1 -0
- package/dist/resources/scheduled.resource.d.ts +9 -0
- package/dist/resources/scheduled.resource.d.ts.map +1 -0
- package/dist/resources/scheduled.resource.js +31 -0
- package/dist/resources/scheduled.resource.js.map +1 -0
- package/dist/resources/stats.resource.d.ts +10 -0
- package/dist/resources/stats.resource.d.ts.map +1 -0
- package/dist/resources/stats.resource.js +45 -0
- package/dist/resources/stats.resource.js.map +1 -0
- package/dist/resources/templates.resource.d.ts +9 -0
- package/dist/resources/templates.resource.d.ts.map +1 -0
- package/dist/resources/templates.resource.js +34 -0
- package/dist/resources/templates.resource.js.map +1 -0
- package/dist/resources/unread.resource.d.ts +11 -0
- package/dist/resources/unread.resource.d.ts.map +1 -0
- package/dist/resources/unread.resource.js +46 -0
- package/dist/resources/unread.resource.js.map +1 -0
- package/dist/safety/audit.d.ts +17 -0
- package/dist/safety/audit.d.ts.map +1 -0
- package/dist/safety/audit.js +50 -0
- package/dist/safety/audit.js.map +1 -0
- package/dist/safety/rate-limiter.d.ts +22 -0
- package/dist/safety/rate-limiter.d.ts.map +1 -0
- package/dist/safety/rate-limiter.js +52 -0
- package/dist/safety/rate-limiter.js.map +1 -0
- package/dist/safety/validation.d.ts +44 -0
- package/dist/safety/validation.d.ts.map +1 -0
- package/dist/safety/validation.js +113 -0
- package/dist/safety/validation.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +25 -0
- package/dist/server.js.map +1 -0
- package/dist/services/calendar.service.d.ts +22 -0
- package/dist/services/calendar.service.d.ts.map +1 -0
- package/dist/services/calendar.service.js +115 -0
- package/dist/services/calendar.service.js.map +1 -0
- package/dist/services/event-bus.d.ts +28 -0
- package/dist/services/event-bus.d.ts.map +1 -0
- package/dist/services/event-bus.js +16 -0
- package/dist/services/event-bus.js.map +1 -0
- package/dist/services/hooks.service.d.ts +77 -0
- package/dist/services/hooks.service.d.ts.map +1 -0
- package/dist/services/hooks.service.js +498 -0
- package/dist/services/hooks.service.js.map +1 -0
- package/dist/services/imap.service.d.ts +133 -0
- package/dist/services/imap.service.d.ts.map +1 -0
- package/dist/services/imap.service.js +1393 -0
- package/dist/services/imap.service.js.map +1 -0
- package/dist/services/label-strategy.d.ts +20 -0
- package/dist/services/label-strategy.d.ts.map +1 -0
- package/dist/services/label-strategy.js +237 -0
- package/dist/services/label-strategy.js.map +1 -0
- package/dist/services/local-calendar.service.d.ts +126 -0
- package/dist/services/local-calendar.service.d.ts.map +1 -0
- package/dist/services/local-calendar.service.js +428 -0
- package/dist/services/local-calendar.service.js.map +1 -0
- package/dist/services/notifier.service.d.ts +69 -0
- package/dist/services/notifier.service.d.ts.map +1 -0
- package/dist/services/notifier.service.js +319 -0
- package/dist/services/notifier.service.js.map +1 -0
- package/dist/services/oauth.service.d.ts +47 -0
- package/dist/services/oauth.service.d.ts.map +1 -0
- package/dist/services/oauth.service.js +140 -0
- package/dist/services/oauth.service.js.map +1 -0
- package/dist/services/presets.d.ts +36 -0
- package/dist/services/presets.d.ts.map +1 -0
- package/dist/services/presets.js +173 -0
- package/dist/services/presets.js.map +1 -0
- package/dist/services/reminders.service.d.ts +63 -0
- package/dist/services/reminders.service.d.ts.map +1 -0
- package/dist/services/reminders.service.js +281 -0
- package/dist/services/reminders.service.js.map +1 -0
- package/dist/services/scheduler.service.d.ts +42 -0
- package/dist/services/scheduler.service.d.ts.map +1 -0
- package/dist/services/scheduler.service.js +260 -0
- package/dist/services/scheduler.service.js.map +1 -0
- package/dist/services/smtp.service.d.ts +40 -0
- package/dist/services/smtp.service.d.ts.map +1 -0
- package/dist/services/smtp.service.js +151 -0
- package/dist/services/smtp.service.js.map +1 -0
- package/dist/services/template.service.d.ts +33 -0
- package/dist/services/template.service.d.ts.map +1 -0
- package/dist/services/template.service.js +123 -0
- package/dist/services/template.service.js.map +1 -0
- package/dist/services/watcher.service.d.ts +36 -0
- package/dist/services/watcher.service.d.ts.map +1 -0
- package/dist/services/watcher.service.js +241 -0
- package/dist/services/watcher.service.js.map +1 -0
- package/dist/tools/accounts.tool.d.ts +7 -0
- package/dist/tools/accounts.tool.d.ts.map +1 -0
- package/dist/tools/accounts.tool.js +29 -0
- package/dist/tools/accounts.tool.js.map +1 -0
- package/dist/tools/analytics.tool.d.ts +9 -0
- package/dist/tools/analytics.tool.d.ts.map +1 -0
- package/dist/tools/analytics.tool.js +27 -0
- package/dist/tools/analytics.tool.js.map +1 -0
- package/dist/tools/attachments.tool.d.ts +7 -0
- package/dist/tools/attachments.tool.d.ts.map +1 -0
- package/dist/tools/attachments.tool.js +45 -0
- package/dist/tools/attachments.tool.js.map +1 -0
- package/dist/tools/bulk.tool.d.ts +7 -0
- package/dist/tools/bulk.tool.d.ts.map +1 -0
- package/dist/tools/bulk.tool.js +75 -0
- package/dist/tools/bulk.tool.js.map +1 -0
- package/dist/tools/calendar.tool.d.ts +19 -0
- package/dist/tools/calendar.tool.d.ts.map +1 -0
- package/dist/tools/calendar.tool.js +538 -0
- package/dist/tools/calendar.tool.js.map +1 -0
- package/dist/tools/contacts.tool.d.ts +7 -0
- package/dist/tools/contacts.tool.d.ts.map +1 -0
- package/dist/tools/contacts.tool.js +44 -0
- package/dist/tools/contacts.tool.js.map +1 -0
- package/dist/tools/drafts.tool.d.ts +8 -0
- package/dist/tools/drafts.tool.d.ts.map +1 -0
- package/dist/tools/drafts.tool.js +92 -0
- package/dist/tools/drafts.tool.js.map +1 -0
- package/dist/tools/emails.tool.d.ts +7 -0
- package/dist/tools/emails.tool.d.ts.map +1 -0
- package/dist/tools/emails.tool.js +400 -0
- package/dist/tools/emails.tool.js.map +1 -0
- package/dist/tools/folders.tool.d.ts +7 -0
- package/dist/tools/folders.tool.d.ts.map +1 -0
- package/dist/tools/folders.tool.js +111 -0
- package/dist/tools/folders.tool.js.map +1 -0
- package/dist/tools/health.tool.d.ts +10 -0
- package/dist/tools/health.tool.d.ts.map +1 -0
- package/dist/tools/health.tool.js +78 -0
- package/dist/tools/health.tool.js.map +1 -0
- package/dist/tools/label.tool.d.ts +11 -0
- package/dist/tools/label.tool.d.ts.map +1 -0
- package/dist/tools/label.tool.js +165 -0
- package/dist/tools/label.tool.js.map +1 -0
- package/dist/tools/locate.tool.d.ts +11 -0
- package/dist/tools/locate.tool.d.ts.map +1 -0
- package/dist/tools/locate.tool.js +59 -0
- package/dist/tools/locate.tool.js.map +1 -0
- package/dist/tools/mailboxes.tool.d.ts +7 -0
- package/dist/tools/mailboxes.tool.d.ts.map +1 -0
- package/dist/tools/mailboxes.tool.js +38 -0
- package/dist/tools/mailboxes.tool.js.map +1 -0
- package/dist/tools/manage.tool.d.ts +7 -0
- package/dist/tools/manage.tool.d.ts.map +1 -0
- package/dist/tools/manage.tool.js +125 -0
- package/dist/tools/manage.tool.js.map +1 -0
- package/dist/tools/register.d.ts +20 -0
- package/dist/tools/register.d.ts.map +1 -0
- package/dist/tools/register.js +53 -0
- package/dist/tools/register.js.map +1 -0
- package/dist/tools/scheduler.tool.d.ts +9 -0
- package/dist/tools/scheduler.tool.d.ts.map +1 -0
- package/dist/tools/scheduler.tool.js +104 -0
- package/dist/tools/scheduler.tool.js.map +1 -0
- package/dist/tools/send.tool.d.ts +7 -0
- package/dist/tools/send.tool.d.ts.map +1 -0
- package/dist/tools/send.tool.js +123 -0
- package/dist/tools/send.tool.js.map +1 -0
- package/dist/tools/templates.tool.d.ts +12 -0
- package/dist/tools/templates.tool.d.ts.map +1 -0
- package/dist/tools/templates.tool.js +140 -0
- package/dist/tools/templates.tool.js.map +1 -0
- package/dist/tools/thread.tool.d.ts +10 -0
- package/dist/tools/thread.tool.d.ts.map +1 -0
- package/dist/tools/thread.tool.js +146 -0
- package/dist/tools/thread.tool.js.map +1 -0
- package/dist/tools/watcher.tool.d.ts +9 -0
- package/dist/tools/watcher.tool.d.ts.map +1 -0
- package/dist/tools/watcher.tool.js +282 -0
- package/dist/tools/watcher.tool.js.map +1 -0
- package/dist/types/index.d.ts +271 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/calendar-notes.d.ts +31 -0
- package/dist/utils/calendar-notes.d.ts.map +1 -0
- package/dist/utils/calendar-notes.js +99 -0
- package/dist/utils/calendar-notes.js.map +1 -0
- package/dist/utils/calendar-state.d.ts +27 -0
- package/dist/utils/calendar-state.d.ts.map +1 -0
- package/dist/utils/calendar-state.js +85 -0
- package/dist/utils/calendar-state.js.map +1 -0
- package/dist/utils/conference-details.d.ts +12 -0
- package/dist/utils/conference-details.d.ts.map +1 -0
- package/dist/utils/conference-details.js +71 -0
- package/dist/utils/conference-details.js.map +1 -0
- package/dist/utils/meeting-url.d.ts +10 -0
- package/dist/utils/meeting-url.d.ts.map +1 -0
- package/dist/utils/meeting-url.js +30 -0
- package/dist/utils/meeting-url.js.map +1 -0
- package/package.json +108 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tools: list_templates, apply_template
|
|
3
|
+
*
|
|
4
|
+
* User-defined email templates with {{variable}} substitution.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import audit from '../safety/audit.js';
|
|
8
|
+
export function registerTemplateReadTools(server, templateService) {
|
|
9
|
+
server.tool('list_templates', 'List all available email templates. Templates are TOML files in ~/.config/email-mcp/templates/ with {{variable}} placeholders for subject and body.', {}, { readOnlyHint: true, destructiveHint: false }, async () => {
|
|
10
|
+
try {
|
|
11
|
+
const templates = await templateService.listTemplates();
|
|
12
|
+
if (templates.length === 0) {
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: 'text',
|
|
17
|
+
text: `No templates found. Create .toml files in ${templateService.directory}/ to add templates.\n\nExample template:\n name = "meeting-followup"\n description = "Follow-up after a meeting"\n subject = "Follow-up: {{topic}}"\n body = "Hi {{name}},\\n\\nThank you for..."\n variables = ["topic", "name"]`,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const lines = templates.map((t) => {
|
|
23
|
+
const vars = t.variables.length > 0 ? ` (variables: ${t.variables.join(', ')})` : '';
|
|
24
|
+
const desc = t.description ? ` ā ${t.description}` : '';
|
|
25
|
+
return `š ${t.name}${desc}${vars}`;
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: 'text',
|
|
31
|
+
text: `š ${templates.length} template${templates.length === 1 ? '' : 's'} available:\n\n${lines.join('\n')}`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
return {
|
|
38
|
+
isError: true,
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: `Failed to list templates: ${err instanceof Error ? err.message : String(err)}`,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function registerTemplateWriteTools(server, templateService, imapService, smtpService) {
|
|
50
|
+
server.tool('apply_template', 'Apply an email template with variable substitution. Use action "preview" to see the result, "draft" to save as draft, or "send" to send immediately.', {
|
|
51
|
+
account: z.string().describe('Account name from list_accounts'),
|
|
52
|
+
template: z.string().describe('Template name from list_templates'),
|
|
53
|
+
variables: z
|
|
54
|
+
.record(z.string(), z.string())
|
|
55
|
+
.describe("Variable values as key-value pairs, e.g. { topic: 'Q1 Review' }"),
|
|
56
|
+
action: z
|
|
57
|
+
.enum(['preview', 'draft', 'send'])
|
|
58
|
+
.default('preview')
|
|
59
|
+
.describe('What to do with the composed email'),
|
|
60
|
+
to: z
|
|
61
|
+
.array(z.string())
|
|
62
|
+
.optional()
|
|
63
|
+
.describe('Recipient addresses (required for send, optional for draft)'),
|
|
64
|
+
}, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, async ({ account, template, variables, action, to }) => {
|
|
65
|
+
try {
|
|
66
|
+
const composed = await templateService.applyTemplate(template, variables);
|
|
67
|
+
if (action === 'preview') {
|
|
68
|
+
return {
|
|
69
|
+
content: [
|
|
70
|
+
{
|
|
71
|
+
type: 'text',
|
|
72
|
+
text: `š Template preview ā "${template}"\n\nSubject: ${composed.subject}\n\n${composed.body}`,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (action === 'draft') {
|
|
78
|
+
const draftResult = await imapService.saveDraft(account, {
|
|
79
|
+
to: to ?? [],
|
|
80
|
+
subject: composed.subject,
|
|
81
|
+
body: composed.body,
|
|
82
|
+
});
|
|
83
|
+
audit.log('apply_template', account, {
|
|
84
|
+
template,
|
|
85
|
+
action: 'draft',
|
|
86
|
+
}, 'ok');
|
|
87
|
+
return {
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: `ā
Draft saved from template "${template}" (ID: ${draftResult.id} in ${draftResult.mailbox})`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// action === "send"
|
|
97
|
+
if (!to || to.length === 0) {
|
|
98
|
+
return {
|
|
99
|
+
isError: true,
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'text',
|
|
103
|
+
text: 'Recipients ("to") are required when action is "send".',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const sendResult = await smtpService.sendEmail(account, {
|
|
109
|
+
to,
|
|
110
|
+
subject: composed.subject,
|
|
111
|
+
body: composed.body,
|
|
112
|
+
});
|
|
113
|
+
audit.log('apply_template', account, {
|
|
114
|
+
template,
|
|
115
|
+
action: 'send',
|
|
116
|
+
to,
|
|
117
|
+
}, 'ok');
|
|
118
|
+
return {
|
|
119
|
+
content: [
|
|
120
|
+
{
|
|
121
|
+
type: 'text',
|
|
122
|
+
text: `ā
Email sent from template "${template}" (Message-ID: ${sendResult.messageId})`,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
return {
|
|
129
|
+
isError: true,
|
|
130
|
+
content: [
|
|
131
|
+
{
|
|
132
|
+
type: 'text',
|
|
133
|
+
text: `Failed to apply template: ${err instanceof Error ? err.message : String(err)}`,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=templates.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.tool.js","sourceRoot":"","sources":["../../src/tools/templates.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAMvC,MAAM,UAAU,yBAAyB,CACvC,MAAiB,EACjB,eAAgC;IAEhC,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,qJAAqJ,EACrJ,EAAE,EACF,EAAE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M;gBACd,EAAE;aACH,EACD,IAAI,CACL,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,+BAA+B,QAAQ,kBAAkB,UAAU,CAAC,SAAS,GAAG;qBACvF;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;qBACtF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: get_thread
|
|
3
|
+
*
|
|
4
|
+
* Reconstructs an email conversation thread using References / In-Reply-To
|
|
5
|
+
* header chains. Returns messages in chronological order (or newest-first).
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import type ImapService from '../services/imap.service.js';
|
|
9
|
+
export default function registerThreadTools(server: McpServer, imapService: ImapService): void;
|
|
10
|
+
//# sourceMappingURL=thread.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.tool.d.ts","sourceRoot":"","sources":["../../src/tools/thread.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AA0D3D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CA6G7F"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool: get_thread
|
|
3
|
+
*
|
|
4
|
+
* Reconstructs an email conversation thread using References / In-Reply-To
|
|
5
|
+
* header chains. Returns messages in chronological order (or newest-first).
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Inline body helpers (avoids cross-tool import)
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
function stripHtml(html) {
|
|
12
|
+
return html
|
|
13
|
+
.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
|
|
14
|
+
.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, '')
|
|
15
|
+
.replace(/<br\s*\/?>/gi, '\n')
|
|
16
|
+
.replace(/<\/p>/gi, '\n\n')
|
|
17
|
+
.replace(/<\/div>/gi, '\n')
|
|
18
|
+
.replace(/<li\b[^>]*>/gi, '\n⢠')
|
|
19
|
+
.replace(/<[^>]+>/g, '')
|
|
20
|
+
.replace(/ /g, ' ')
|
|
21
|
+
.replace(/</g, '<')
|
|
22
|
+
.replace(/>/g, '>')
|
|
23
|
+
.replace(/&/g, '&')
|
|
24
|
+
.replace(/"/g, '"')
|
|
25
|
+
.replace(/'/g, "'")
|
|
26
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
27
|
+
.trim();
|
|
28
|
+
}
|
|
29
|
+
function stripReplyChain(text) {
|
|
30
|
+
const lines = text.split('\n');
|
|
31
|
+
const stopIdx = lines.findIndex((l) => /^--\s*$/.test(l) || /^_{3,}\s*$/.test(l));
|
|
32
|
+
const relevant = stopIdx === -1 ? lines : lines.slice(0, stopIdx);
|
|
33
|
+
return relevant
|
|
34
|
+
.filter((l) => !l.startsWith('>'))
|
|
35
|
+
.join('\n')
|
|
36
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
37
|
+
.trim();
|
|
38
|
+
}
|
|
39
|
+
function applyBodyFormat(bodyText, bodyHtml, format, maxLength) {
|
|
40
|
+
let body;
|
|
41
|
+
if (format === 'full') {
|
|
42
|
+
body = bodyText ?? bodyHtml ?? '(no content)';
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const base = bodyText ?? (bodyHtml ? stripHtml(bodyHtml) : undefined) ?? '(no content)';
|
|
46
|
+
body = format === 'stripped' ? stripReplyChain(base) : base;
|
|
47
|
+
}
|
|
48
|
+
if (maxLength !== undefined && maxLength > 0 && body.length > maxLength) {
|
|
49
|
+
const remaining = body.length - maxLength;
|
|
50
|
+
body = `${body.slice(0, maxLength)}\n\n⦠(${remaining} more characters ā increase maxLength to read the full body)`;
|
|
51
|
+
}
|
|
52
|
+
return body;
|
|
53
|
+
}
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
export default function registerThreadTools(server, imapService) {
|
|
56
|
+
server.tool('get_thread', 'Reconstruct a full email conversation thread by following References and In-Reply-To headers. ' +
|
|
57
|
+
'Returns all related messages. Does NOT mark emails as seen. ' +
|
|
58
|
+
'Use format="text" to strip HTML, or format="stripped" to also remove quoted replies. ' +
|
|
59
|
+
'Use newestFirst=true to show the most recent message in full and older messages as header-only summaries. ' +
|
|
60
|
+
'Use get_email first to obtain the message_id.', {
|
|
61
|
+
account: z.string().describe('Account name from list_accounts'),
|
|
62
|
+
message_id: z.string().describe('Message-ID header value (from get_email)'),
|
|
63
|
+
mailbox: z.string().default('INBOX').describe('Mailbox to search (default: INBOX)'),
|
|
64
|
+
format: z
|
|
65
|
+
.enum(['full', 'text', 'stripped'])
|
|
66
|
+
.default('full')
|
|
67
|
+
.describe('Body format: full=raw (default), text=plain text (strips HTML), stripped=plain text without quoted replies or signatures'),
|
|
68
|
+
maxLength: z
|
|
69
|
+
.number()
|
|
70
|
+
.int()
|
|
71
|
+
.min(100)
|
|
72
|
+
.optional()
|
|
73
|
+
.describe('Truncate each message body at this many characters. A hint shows how many characters remain.'),
|
|
74
|
+
newestFirst: z
|
|
75
|
+
.boolean()
|
|
76
|
+
.default(false)
|
|
77
|
+
.describe('When true, shows the newest message in full and older messages as header-only summaries. ' +
|
|
78
|
+
'Ideal for AI triage of long threads where only the latest reply matters.'),
|
|
79
|
+
}, { readOnlyHint: true, destructiveHint: false }, async ({ account, message_id: messageId, mailbox, format, maxLength, newestFirst }) => {
|
|
80
|
+
try {
|
|
81
|
+
const thread = await imapService.getThread(account, messageId, mailbox);
|
|
82
|
+
if (thread.messageCount === 0) {
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: `No thread found for Message-ID: ${messageId}`,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const ordered = newestFirst ? [...thread.messages].reverse() : thread.messages;
|
|
93
|
+
const total = thread.messageCount;
|
|
94
|
+
const parts = [
|
|
95
|
+
`š§µ Thread: ${total} message${total === 1 ? '' : 's'}`,
|
|
96
|
+
`Thread-ID: ${thread.threadId}`,
|
|
97
|
+
`Participants: ${thread.participants.map((p) => (p.name ? `${p.name} <${p.address}>` : p.address)).join(', ')}`,
|
|
98
|
+
'',
|
|
99
|
+
];
|
|
100
|
+
ordered.forEach((email, idx) => {
|
|
101
|
+
let label;
|
|
102
|
+
if (newestFirst) {
|
|
103
|
+
label = idx === 0 ? 'Latest message' : `Message ${total - idx} of ${total} (older)`;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
label = `Message ${idx + 1} of ${total}`;
|
|
107
|
+
}
|
|
108
|
+
const from = email.from.name
|
|
109
|
+
? `${email.from.name} <${email.from.address}>`
|
|
110
|
+
: email.from.address;
|
|
111
|
+
parts.push(`--- ${label} ---`);
|
|
112
|
+
parts.push(`From: ${from}`);
|
|
113
|
+
parts.push(`To: ${email.to.map((a) => a.address).join(', ')}`);
|
|
114
|
+
parts.push(`Date: ${email.date}`);
|
|
115
|
+
parts.push(`Subject: ${email.subject}`);
|
|
116
|
+
if (email.attachments.length > 0) {
|
|
117
|
+
parts.push(`š ${email.attachments.map((a) => a.filename).join(', ')}`);
|
|
118
|
+
}
|
|
119
|
+
// In newestFirst mode, only render body for the newest (first) message
|
|
120
|
+
if (newestFirst && idx > 0) {
|
|
121
|
+
parts.push('(body omitted ā use get_email to read this message)');
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
parts.push('');
|
|
125
|
+
parts.push(applyBodyFormat(email.bodyText, email.bodyHtml, format, maxLength));
|
|
126
|
+
}
|
|
127
|
+
parts.push('');
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
content: [{ type: 'text', text: parts.join('\n') }],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
return {
|
|
135
|
+
isError: true,
|
|
136
|
+
content: [
|
|
137
|
+
{
|
|
138
|
+
type: 'text',
|
|
139
|
+
text: `Failed to get thread: ${err instanceof Error ? err.message : String(err)}`,
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=thread.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.tool.js","sourceRoot":"","sources":["../../src/tools/thread.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,8EAA8E;AAC9E,iDAAiD;AACjD,8EAA8E;AAE9E,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI;SACR,OAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC;SAC9C,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC;SAChD,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC;SAC7B,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;SAC1B,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;S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,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC1E,CAAC;gBAED,uEAAuE;gBACvE,IAAI,WAAW,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;oBAC3B,KAAK,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;gBACpE,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACf,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;gBACjF,CAAC;gBAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;aAC7D,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yBAAyB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;qBAClF;iBACF;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watcher & Hooks tools ā inspect watcher status, list presets, view hooks config,
|
|
3
|
+
* check notification setup, test notifications, configure alerts.
|
|
4
|
+
*/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import type HooksService from '../services/hooks.service.js';
|
|
7
|
+
import type WatcherService from '../services/watcher.service.js';
|
|
8
|
+
export default function registerWatcherTools(server: McpServer, watcherService: WatcherService, hooksService: HooksService): void;
|
|
9
|
+
//# sourceMappingURL=watcher.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.tool.d.ts","sourceRoot":"","sources":["../../src/tools/watcher.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAG7D,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AAGjE,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,GACzB,IAAI,CAoWN"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watcher & Hooks tools ā inspect watcher status, list presets, view hooks config,
|
|
3
|
+
* check notification setup, test notifications, configure alerts.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { loadRawConfig, saveConfig } from '../config/loader.js';
|
|
7
|
+
import NotifierService from '../services/notifier.service.js';
|
|
8
|
+
import { listPresets as listAllPresets } from '../services/presets.js';
|
|
9
|
+
export default function registerWatcherTools(server, watcherService, hooksService) {
|
|
10
|
+
const hooksConfig = hooksService.getHooksConfig();
|
|
11
|
+
// -------------------------------------------------------------------------
|
|
12
|
+
// get_watcher_status ā read
|
|
13
|
+
// -------------------------------------------------------------------------
|
|
14
|
+
server.tool('get_watcher_status', 'Get the status of IMAP IDLE watcher connections and recent activity.', {}, { readOnlyHint: true, destructiveHint: false }, async () => {
|
|
15
|
+
const status = watcherService.getStatus();
|
|
16
|
+
if (status.length === 0) {
|
|
17
|
+
return {
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: 'text',
|
|
21
|
+
text: 'Watcher is not active. Enable it in config: [settings.watcher] enabled = true',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const lines = status.map((s) => {
|
|
27
|
+
const icon = s.connected ? 'š¢ connected' : 'š“ disconnected';
|
|
28
|
+
return `⢠${s.account}/${s.folder}: ${icon} (last UID: ${s.lastSeenUid})`;
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: 'text',
|
|
34
|
+
text: `š” Watcher Status (${status.length} connection(s)):\n${lines.join('\n')}`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
// -------------------------------------------------------------------------
|
|
40
|
+
// list_presets ā read
|
|
41
|
+
// -------------------------------------------------------------------------
|
|
42
|
+
server.tool('list_presets', 'List all available AI triage presets with their descriptions and suggested labels.', {}, { readOnlyHint: true, destructiveHint: false }, async () => {
|
|
43
|
+
const presets = listAllPresets();
|
|
44
|
+
const activePreset = hooksConfig.preset;
|
|
45
|
+
const lines = presets.map((p) => {
|
|
46
|
+
const active = p.id === activePreset ? ' ā
(active)' : '';
|
|
47
|
+
const labels = p.suggestedLabels.length > 0 ? `\n Labels: ${p.suggestedLabels.join(', ')}` : '';
|
|
48
|
+
return `⢠${p.name} [${p.id}]${active}\n ${p.description}${labels}`;
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: `šÆ Available Hook Presets:\n\n${lines.join('\n\n')}` +
|
|
55
|
+
`\n\nTo change preset, set \`preset = "${activePreset}"\` in [settings.hooks] of your config.toml.`,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
// -------------------------------------------------------------------------
|
|
61
|
+
// get_hooks_config ā read
|
|
62
|
+
// -------------------------------------------------------------------------
|
|
63
|
+
server.tool('get_hooks_config', 'Get the current AI hooks configuration including preset, rules, and custom instructions.', {}, { readOnlyHint: true, destructiveHint: false }, async () => {
|
|
64
|
+
const sections = [
|
|
65
|
+
`āļø Hooks Configuration:`,
|
|
66
|
+
` Mode: ${hooksConfig.onNewEmail}`,
|
|
67
|
+
` Preset: ${hooksConfig.preset}`,
|
|
68
|
+
` Labels: ${hooksConfig.autoLabel ? 'auto-apply' : 'disabled'}`,
|
|
69
|
+
` Flags: ${hooksConfig.autoFlag ? 'auto-flag' : 'disabled'}`,
|
|
70
|
+
` Batch: ${hooksConfig.batchDelay}s delay`,
|
|
71
|
+
];
|
|
72
|
+
if (hooksConfig.customInstructions) {
|
|
73
|
+
sections.push(`\nš Custom Instructions:\n ${hooksConfig.customInstructions.replace(/\n/g, '\n ')}`);
|
|
74
|
+
}
|
|
75
|
+
if (hooksConfig.rules.length > 0) {
|
|
76
|
+
sections.push(`\nš Static Rules (${hooksConfig.rules.length}):`);
|
|
77
|
+
hooksConfig.rules.forEach((rule) => {
|
|
78
|
+
const matchParts = [];
|
|
79
|
+
if (rule.match.from)
|
|
80
|
+
matchParts.push(`from=${rule.match.from}`);
|
|
81
|
+
if (rule.match.to)
|
|
82
|
+
matchParts.push(`to=${rule.match.to}`);
|
|
83
|
+
if (rule.match.subject)
|
|
84
|
+
matchParts.push(`subject=${rule.match.subject}`);
|
|
85
|
+
const actionParts = [];
|
|
86
|
+
if (rule.actions.labels?.length) {
|
|
87
|
+
actionParts.push(`labels=[${rule.actions.labels.join(', ')}]`);
|
|
88
|
+
}
|
|
89
|
+
if (rule.actions.flag)
|
|
90
|
+
actionParts.push('flag');
|
|
91
|
+
if (rule.actions.markRead)
|
|
92
|
+
actionParts.push('mark_read');
|
|
93
|
+
if (rule.actions.alert)
|
|
94
|
+
actionParts.push('š alert');
|
|
95
|
+
sections.push(` ⢠"${rule.name}": ${matchParts.join(' & ')} ā ${actionParts.join(', ')}`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
sections.push('\nš Static Rules: none configured');
|
|
100
|
+
}
|
|
101
|
+
// Alerts config
|
|
102
|
+
const { alerts } = hooksConfig;
|
|
103
|
+
sections.push(`\nš Alerts:`);
|
|
104
|
+
sections.push(` Desktop: ${alerts.desktop ? 'ā
enabled' : 'ā disabled'}`);
|
|
105
|
+
sections.push(` Sound: ${alerts.sound ? 'ā
enabled' : 'ā disabled'}`);
|
|
106
|
+
sections.push(` Threshold: ${alerts.urgencyThreshold}`);
|
|
107
|
+
if (alerts.webhookUrl) {
|
|
108
|
+
sections.push(` Webhook: ${alerts.webhookUrl}`);
|
|
109
|
+
sections.push(` Events: ${alerts.webhookEvents.join(', ')}`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
sections.push(` Webhook: not configured`);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: 'text', text: sections.join('\n') }],
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
// -------------------------------------------------------------------------
|
|
119
|
+
// check_notification_setup ā diagnose platform support
|
|
120
|
+
// -------------------------------------------------------------------------
|
|
121
|
+
server.tool('check_notification_setup', 'Diagnose desktop notification support on this platform. ' +
|
|
122
|
+
'Checks if required OS tools are available and provides setup instructions ' +
|
|
123
|
+
'to enable notification permissions (macOS, Linux, Windows).', {}, { readOnlyHint: true, destructiveHint: false }, async () => {
|
|
124
|
+
const diag = await NotifierService.checkPlatformSupport();
|
|
125
|
+
const notifier = hooksService.getNotifier();
|
|
126
|
+
const alertsCfg = notifier.getConfig();
|
|
127
|
+
const lines = [
|
|
128
|
+
`š Notification Setup Diagnostics`,
|
|
129
|
+
``,
|
|
130
|
+
`Platform: ${diag.platform}`,
|
|
131
|
+
`Desktop: ${diag.desktopTool.name} ā ${diag.desktopTool.available ? 'ā
available' : 'ā not found'}`,
|
|
132
|
+
`Sound: ${diag.soundTool.name} ā ${diag.soundTool.available ? 'ā
available' : 'ā not found'}`,
|
|
133
|
+
`Supported: ${diag.supported ? 'ā
yes' : 'ā no'}`,
|
|
134
|
+
];
|
|
135
|
+
if (diag.issues.length > 0) {
|
|
136
|
+
lines.push('', 'ā ļø Issues:');
|
|
137
|
+
diag.issues.forEach((issue) => {
|
|
138
|
+
lines.push(` ⢠${issue}`);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
lines.push('', 'š Setup Instructions:');
|
|
142
|
+
diag.setupInstructions.forEach((instr) => {
|
|
143
|
+
lines.push(` ${instr}`);
|
|
144
|
+
});
|
|
145
|
+
lines.push('', 'āļø Current Config:', ` Desktop: ${alertsCfg.desktop ? 'ā
enabled' : 'ā disabled'}`, ` Sound: ${alertsCfg.sound ? 'ā
enabled' : 'ā disabled'}`, ` Threshold: ${alertsCfg.urgencyThreshold}`, alertsCfg.webhookUrl
|
|
146
|
+
? ` Webhook: ${alertsCfg.webhookUrl}`
|
|
147
|
+
: ' Webhook: not configured');
|
|
148
|
+
if (!alertsCfg.desktop && diag.supported) {
|
|
149
|
+
lines.push('', 'š” Tip: Desktop notifications are supported but disabled.', ' Use configure_alerts to enable them, or set desktop = true in config.toml.');
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
// -------------------------------------------------------------------------
|
|
156
|
+
// test_notification ā send a test notification
|
|
157
|
+
// -------------------------------------------------------------------------
|
|
158
|
+
server.tool('test_notification', 'Send a test desktop notification to verify that OS permissions are correctly configured. ' +
|
|
159
|
+
'Use check_notification_setup first to diagnose any issues.', {
|
|
160
|
+
sound: z.boolean().default(false).describe('Include a sound alert in the test notification'),
|
|
161
|
+
}, { readOnlyHint: false, destructiveHint: false }, async ({ sound }) => {
|
|
162
|
+
const notifier = hooksService.getNotifier();
|
|
163
|
+
const result = await notifier.sendTestNotification(sound);
|
|
164
|
+
const icon = result.success ? 'ā
' : 'ā';
|
|
165
|
+
const lines = [`${icon} ${result.message}`];
|
|
166
|
+
if (!result.success) {
|
|
167
|
+
const diag = await NotifierService.checkPlatformSupport();
|
|
168
|
+
lines.push('', 'š§ Troubleshooting:');
|
|
169
|
+
diag.setupInstructions.forEach((instr) => {
|
|
170
|
+
lines.push(` ${instr}`);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
// -------------------------------------------------------------------------
|
|
178
|
+
// configure_alerts ā runtime alert configuration
|
|
179
|
+
// -------------------------------------------------------------------------
|
|
180
|
+
server.tool('configure_alerts', 'Update alert/notification settings at runtime. Changes take effect immediately. ' +
|
|
181
|
+
'Use save=true to persist changes to the config file. ' +
|
|
182
|
+
'Omit any field to leave it unchanged.', {
|
|
183
|
+
desktop: z.boolean().optional().describe('Enable/disable desktop notifications'),
|
|
184
|
+
sound: z.boolean().optional().describe('Enable/disable sound alerts for urgent emails'),
|
|
185
|
+
urgency_threshold: z
|
|
186
|
+
.enum(['urgent', 'high', 'normal', 'low'])
|
|
187
|
+
.optional()
|
|
188
|
+
.describe('Minimum urgency level to trigger desktop notifications'),
|
|
189
|
+
webhook_url: z
|
|
190
|
+
.string()
|
|
191
|
+
.optional()
|
|
192
|
+
.describe('Webhook URL for external notifications (empty string to disable)'),
|
|
193
|
+
webhook_events: z
|
|
194
|
+
.array(z.enum(['urgent', 'high', 'normal', 'low']))
|
|
195
|
+
.optional()
|
|
196
|
+
.describe('Which urgency levels trigger webhook dispatch'),
|
|
197
|
+
save: z
|
|
198
|
+
.boolean()
|
|
199
|
+
.default(false)
|
|
200
|
+
.describe('Persist changes to config.toml (default: runtime only)'),
|
|
201
|
+
}, { readOnlyHint: false, destructiveHint: false }, async ({ desktop, sound, urgency_threshold: urgencyThreshold, webhook_url: webhookUrl, webhook_events: webhookEvents, save, }) => {
|
|
202
|
+
try {
|
|
203
|
+
const notifier = hooksService.getNotifier();
|
|
204
|
+
// Build partial update from provided fields
|
|
205
|
+
const partial = {};
|
|
206
|
+
if (desktop !== undefined)
|
|
207
|
+
partial.desktop = desktop;
|
|
208
|
+
if (sound !== undefined)
|
|
209
|
+
partial.sound = sound;
|
|
210
|
+
if (urgencyThreshold !== undefined)
|
|
211
|
+
partial.urgencyThreshold = urgencyThreshold;
|
|
212
|
+
if (webhookUrl !== undefined)
|
|
213
|
+
partial.webhookUrl = webhookUrl;
|
|
214
|
+
if (webhookEvents !== undefined)
|
|
215
|
+
partial.webhookEvents = webhookEvents;
|
|
216
|
+
if (Object.keys(partial).length === 0) {
|
|
217
|
+
const current = notifier.getConfig();
|
|
218
|
+
return {
|
|
219
|
+
content: [
|
|
220
|
+
{
|
|
221
|
+
type: 'text',
|
|
222
|
+
text: `No changes specified. Current config:\n` +
|
|
223
|
+
` Desktop: ${current.desktop ? 'ā
' : 'ā'}\n` +
|
|
224
|
+
` Sound: ${current.sound ? 'ā
' : 'ā'}\n` +
|
|
225
|
+
` Threshold: ${current.urgencyThreshold}\n` +
|
|
226
|
+
` Webhook: ${current.webhookUrl || '(none)'}\n` +
|
|
227
|
+
` Events: ${current.webhookEvents.join(', ')}`,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
// Apply runtime update
|
|
233
|
+
const updated = notifier.updateConfig(partial);
|
|
234
|
+
// Also update the in-memory hooks config alerts reference
|
|
235
|
+
hooksConfig.alerts = { ...updated };
|
|
236
|
+
// Persist to file if requested
|
|
237
|
+
let persistMsg = '';
|
|
238
|
+
if (save) {
|
|
239
|
+
try {
|
|
240
|
+
const rawConfig = await loadRawConfig();
|
|
241
|
+
rawConfig.settings.hooks.alerts = {
|
|
242
|
+
desktop: updated.desktop,
|
|
243
|
+
sound: updated.sound,
|
|
244
|
+
urgency_threshold: updated.urgencyThreshold,
|
|
245
|
+
webhook_url: updated.webhookUrl,
|
|
246
|
+
webhook_events: updated.webhookEvents,
|
|
247
|
+
};
|
|
248
|
+
await saveConfig(rawConfig);
|
|
249
|
+
persistMsg = '\n\nš¾ Changes saved to config file.';
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
253
|
+
persistMsg = `\n\nā ļø Could not save to config file: ${errMsg}\n Changes are active for this session only.`;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const lines = [
|
|
257
|
+
'ā
Alerts configuration updated:',
|
|
258
|
+
` Desktop: ${updated.desktop ? 'ā
enabled' : 'ā disabled'}`,
|
|
259
|
+
` Sound: ${updated.sound ? 'ā
enabled' : 'ā disabled'}`,
|
|
260
|
+
` Threshold: ${updated.urgencyThreshold}`,
|
|
261
|
+
` Webhook: ${updated.webhookUrl || '(none)'}`,
|
|
262
|
+
` Events: ${updated.webhookEvents.join(', ')}`,
|
|
263
|
+
persistMsg,
|
|
264
|
+
];
|
|
265
|
+
return {
|
|
266
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
return {
|
|
271
|
+
isError: true,
|
|
272
|
+
content: [
|
|
273
|
+
{
|
|
274
|
+
type: 'text',
|
|
275
|
+
text: `Failed to update alerts config: ${err instanceof Error ? err.message : String(err)}`,
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=watcher.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.tool.js","sourceRoot":"","sources":["../../src/tools/watcher.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,eAAe,MAAM,iCAAiC,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