@hyperwindmill/caretaker-cli 0.21.0 → 0.22.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email_tools.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/email_tools.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"email_tools.d.ts","sourceRoot":"","sources":["../../../../src/harness/tools/builtin/email_tools.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;AAmCpD,eAAO,MAAM,qBAAqB,EAAE,IAqBnC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IAiE5B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,IAwG3B,CAAC"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// ctx.callerAgent — a scoped account is invisible, not refused);
|
|
10
10
|
// - who an account may send to (`allowedRecipients`, checked before connecting);
|
|
11
11
|
// - whose mail it may read (`allowedSenders`, checked on the envelope pass).
|
|
12
|
-
import { listEmailAccounts, findAccount, matchesAllowlist, bareAddress, sendEmail, fetchInbox, canSend, canRead, clampLimit, MAX_FETCH, } from '../../../lib/email.js';
|
|
12
|
+
import { listEmailAccounts, findAccount, matchesAllowlist, bareAddress, sendEmail, fetchInbox, canSend, canRead, clampLimit, markdownToHtml, MAX_FETCH, } from '../../../lib/email.js';
|
|
13
13
|
function err(msg) {
|
|
14
14
|
return { content: JSON.stringify({ error: msg }) };
|
|
15
15
|
}
|
|
@@ -114,7 +114,7 @@ export const emailFetchTool = {
|
|
|
114
114
|
};
|
|
115
115
|
export const emailSendTool = {
|
|
116
116
|
name: 'mcp__email__email_send',
|
|
117
|
-
description: 'Send
|
|
117
|
+
description: 'Send an email through one of the configured accounts. Pick the account by its name from email_list_accounts. `body` is the plain-text version and is always required; for a formatted message write `body` in markdown and set `markdown: true` (converted for you, so you write the content once), or pass your own `html`. No attachments. Recipients outside the account allowlist are refused and nothing is sent.',
|
|
118
118
|
parameters: {
|
|
119
119
|
type: 'object',
|
|
120
120
|
properties: {
|
|
@@ -127,7 +127,18 @@ export const emailSendTool = {
|
|
|
127
127
|
cc: { type: 'array', items: { type: 'string' } },
|
|
128
128
|
bcc: { type: 'array', items: { type: 'string' } },
|
|
129
129
|
subject: { type: 'string' },
|
|
130
|
-
body: {
|
|
130
|
+
body: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'Plain-text body. Required even when sending HTML — it is the fallback part for clients that do not render HTML, and mail without one is treated as spam by many filters.',
|
|
133
|
+
},
|
|
134
|
+
markdown: {
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
description: 'Default false. Set true when `body` is markdown: it is converted to a formatted HTML part for you and also sent as-is as the text part. Prefer this over writing the message twice. Cannot be combined with `html`.',
|
|
137
|
+
},
|
|
138
|
+
html: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'Optional HTML body, sent as an alternative part alongside `body` — for full control over the markup. Usually `markdown: true` is enough and costs half as much to write. A full document or a fragment both work; inline the CSS as style attributes, because mail clients drop <style> blocks and never fetch external assets.',
|
|
141
|
+
},
|
|
131
142
|
},
|
|
132
143
|
required: ['account', 'to', 'subject', 'body'],
|
|
133
144
|
},
|
|
@@ -142,6 +153,15 @@ export const emailSendTool = {
|
|
|
142
153
|
return err('subject must be a non-empty string');
|
|
143
154
|
if (typeof args?.body !== 'string')
|
|
144
155
|
return err('body must be a string');
|
|
156
|
+
if (args?.html !== undefined && typeof args.html !== 'string')
|
|
157
|
+
return err('html must be a string');
|
|
158
|
+
if (args?.markdown === true && typeof args?.html === 'string' && args.html.trim())
|
|
159
|
+
return err('pass either html or markdown: true, not both — they set the same message part');
|
|
160
|
+
const html = typeof args?.html === 'string' && args.html.trim()
|
|
161
|
+
? args.html
|
|
162
|
+
: args?.markdown === true && body.trim()
|
|
163
|
+
? markdownToHtml(body)
|
|
164
|
+
: undefined;
|
|
145
165
|
const to = toList(args?.to);
|
|
146
166
|
const cc = toList(args?.cc);
|
|
147
167
|
const bcc = toList(args?.bcc);
|
|
@@ -170,9 +190,17 @@ export const emailSendTool = {
|
|
|
170
190
|
return err(`Recipient(s) not allowed by account "${account.name}": ${refused.join(', ')}. Allowed patterns: ${account.allowedRecipients.join(', ')}`);
|
|
171
191
|
}
|
|
172
192
|
try {
|
|
173
|
-
const messageId = await sendEmail(account, { to, cc, bcc, subject, body }, ctx.signal);
|
|
193
|
+
const messageId = await sendEmail(account, { to, cc, bcc, subject, body, html }, ctx.signal);
|
|
174
194
|
return {
|
|
175
|
-
content: JSON.stringify({
|
|
195
|
+
content: JSON.stringify({
|
|
196
|
+
ok: true,
|
|
197
|
+
messageId,
|
|
198
|
+
from: account.from,
|
|
199
|
+
to,
|
|
200
|
+
cc,
|
|
201
|
+
bcc,
|
|
202
|
+
html: !!html,
|
|
203
|
+
}),
|
|
176
204
|
};
|
|
177
205
|
}
|
|
178
206
|
catch (e) {
|
package/dist/lib/email.d.ts
CHANGED
|
@@ -71,14 +71,30 @@ export declare function visibleAccounts(accounts: EmailAccount[], agentId?: stri
|
|
|
71
71
|
export declare function listEmailAccounts(agentId?: string): Promise<EmailAccount[]>;
|
|
72
72
|
/** Look an account up by service name, case-insensitively. */
|
|
73
73
|
export declare function findAccount(accounts: EmailAccount[], name: string): EmailAccount | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Render the markdown an agent already wrote as `body` into the HTML part, so a
|
|
76
|
+
* formatted mail costs one copy of the content instead of two. The wrapper is
|
|
77
|
+
* the whole styling story: `marked` emits bare `<p>`/`<h2>`, and mail clients
|
|
78
|
+
* have no sensible default for those. Inline styles only — clients strip
|
|
79
|
+
* `<style>` blocks and never fetch anything external.
|
|
80
|
+
*
|
|
81
|
+
* ponytail: no sanitizer. This is outbound mail written by the agent, which can
|
|
82
|
+
* already send arbitrary HTML through `email_send`'s `html` argument; the
|
|
83
|
+
* recipient's client is what sanitizes on render.
|
|
84
|
+
*/
|
|
85
|
+
export declare function markdownToHtml(markdown: string): string;
|
|
74
86
|
export type OutgoingMail = {
|
|
75
87
|
to: string[];
|
|
76
88
|
cc?: string[];
|
|
77
89
|
bcc?: string[];
|
|
78
90
|
subject: string;
|
|
91
|
+
/** Plain-text part. Always sent — the fallback when `html` is set. */
|
|
79
92
|
body: string;
|
|
93
|
+
/** Optional HTML part. Set together with `body` it makes a multipart/alternative. */
|
|
94
|
+
html?: string;
|
|
80
95
|
};
|
|
81
|
-
/** Send one plain
|
|
96
|
+
/** Send one message (plain text, plus an HTML alternative when given).
|
|
97
|
+
* Returns the SMTP message id. */
|
|
82
98
|
export declare function sendEmail(account: EmailAccount, mail: OutgoingMail, signal?: AbortSignal): Promise<string>;
|
|
83
99
|
/** Hard ceiling on messages per call, whatever the caller asks for. */
|
|
84
100
|
export declare const MAX_FETCH = 50;
|
package/dist/lib/email.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAAS,CAAC;AAarC,4EAA4E;AAC5E,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAA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WAAW,CAAC,MAAM,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,GAAG,MAAM,CAIpF;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,oDAAoD;AACpD,wBAAsB,UAAU,CAC9B,OAAO,EAAE,YAAY,EACrB,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC;IAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA0FnF"}
|
package/dist/lib/email.js
CHANGED
|
@@ -15,6 +15,7 @@ import nodemailer from 'nodemailer';
|
|
|
15
15
|
import { ImapFlow } from 'imapflow';
|
|
16
16
|
import { simpleParser } from 'mailparser';
|
|
17
17
|
import TurndownService from 'turndown';
|
|
18
|
+
import { marked } from 'marked';
|
|
18
19
|
import { loadConfig } from '../store/json.js';
|
|
19
20
|
import { decrypt, isEncrypted } from './encryption.js';
|
|
20
21
|
/**
|
|
@@ -140,7 +141,26 @@ export function findAccount(accounts, name) {
|
|
|
140
141
|
const wanted = name.trim().toLowerCase();
|
|
141
142
|
return accounts.find((a) => a.name.trim().toLowerCase() === wanted);
|
|
142
143
|
}
|
|
143
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* Render the markdown an agent already wrote as `body` into the HTML part, so a
|
|
146
|
+
* formatted mail costs one copy of the content instead of two. The wrapper is
|
|
147
|
+
* the whole styling story: `marked` emits bare `<p>`/`<h2>`, and mail clients
|
|
148
|
+
* have no sensible default for those. Inline styles only — clients strip
|
|
149
|
+
* `<style>` blocks and never fetch anything external.
|
|
150
|
+
*
|
|
151
|
+
* ponytail: no sanitizer. This is outbound mail written by the agent, which can
|
|
152
|
+
* already send arbitrary HTML through `email_send`'s `html` argument; the
|
|
153
|
+
* recipient's client is what sanitizes on render.
|
|
154
|
+
*/
|
|
155
|
+
export function markdownToHtml(markdown) {
|
|
156
|
+
const body = marked.parse(markdown, { async: false, gfm: true });
|
|
157
|
+
return ('<div style="font-family:-apple-system,Segoe UI,Helvetica,Arial,sans-serif;' +
|
|
158
|
+
'font-size:14px;line-height:1.5;color:#1a1a1a;max-width:40em">' +
|
|
159
|
+
body +
|
|
160
|
+
'</div>');
|
|
161
|
+
}
|
|
162
|
+
/** Send one message (plain text, plus an HTML alternative when given).
|
|
163
|
+
* Returns the SMTP message id. */
|
|
144
164
|
export async function sendEmail(account, mail, signal) {
|
|
145
165
|
if (signal?.aborted)
|
|
146
166
|
throw new Error('aborted before connecting');
|
|
@@ -161,6 +181,8 @@ export async function sendEmail(account, mail, signal) {
|
|
|
161
181
|
bcc: mail.bcc,
|
|
162
182
|
subject: mail.subject,
|
|
163
183
|
text: mail.body,
|
|
184
|
+
// Both parts → nodemailer builds multipart/alternative on its own.
|
|
185
|
+
...(mail.html ? { html: mail.html } : {}),
|
|
164
186
|
});
|
|
165
187
|
return info.messageId;
|
|
166
188
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperwindmill/caretaker-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Caretaker — in-process agent harness, TUI, file-based state.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"typescript": "^5.9.3",
|
|
86
86
|
"typescript-eslint": "^8.59.2",
|
|
87
87
|
"zod": "^4.4.3",
|
|
88
|
-
"caretaker-types": "0.
|
|
89
|
-
"webview-ui": "0.
|
|
88
|
+
"caretaker-types": "0.22.0",
|
|
89
|
+
"webview-ui": "0.22.0"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"@hono/node-server": "^2.0.4",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"isomorphic-git": "^1.37.6",
|
|
104
104
|
"mailparser": "^3.9.14",
|
|
105
105
|
"mammoth": "^1.12.0",
|
|
106
|
+
"marked": "^15.0.12",
|
|
106
107
|
"nodemailer": "^9.0.4",
|
|
107
108
|
"react": "^19.2.6",
|
|
108
109
|
"turndown": "^7.2.4",
|