@workover/cli 0.27.0 → 0.29.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/bin/workover.mjs +2244 -4
- package/contacts.mjs +1561 -0
- package/domains.mjs +417 -0
- package/email-studio.mjs +829 -0
- package/feedback-board.mjs +321 -0
- package/journeys.mjs +409 -0
- package/package.json +20 -1
- package/support-agent-tests.mjs +424 -0
- package/support-config.mjs +302 -0
- package/support-email.mjs +458 -0
- package/support-fields.mjs +294 -0
- package/support-freshdesk.mjs +176 -0
- package/support-inbox.mjs +313 -0
- package/support-label-rules.mjs +136 -0
- package/support-labels.mjs +244 -0
- package/support-outcomes.mjs +276 -0
- package/support-outside-bot.mjs +145 -0
- package/support-setup.mjs +660 -0
- package/support-signatures.mjs +156 -0
- package/support-sources.mjs +233 -0
- package/support-walter.mjs +310 -0
package/domains.mjs
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
// Sending domains from a terminal (WO-1752): `workover domains ...` and the MCP server's
|
|
2
|
+
// `workover_domains_*` tools.
|
|
3
|
+
//
|
|
4
|
+
// THE SAME FILE ships in @workover/cli (apps/cli/domains.mjs) and @workover/mcp
|
|
5
|
+
// (apps/mcp/domains.mjs), because the two packages are published separately and neither may depend
|
|
6
|
+
// on the other. `apps/mcp/domains.test.mjs` fails when the copies differ.
|
|
7
|
+
//
|
|
8
|
+
// A sending domain is a domain a workspace sends email from (Contacts journeys, Support email). The
|
|
9
|
+
// whole setup, end to end:
|
|
10
|
+
// 1. add it: the answer carries every DNS record the domain needs (type, full name, the name
|
|
11
|
+
// relative to its zone, value, MX priority), each already looked up once;
|
|
12
|
+
// 2. apply the records at the DNS host (through its API, or hand them to whoever runs the DNS:
|
|
13
|
+
// `records --format bind|text`, or `share` for a read-only page they can open without an
|
|
14
|
+
// account);
|
|
15
|
+
// 3. check: verified once the provider agrees and every required record resolves. DNS can take up
|
|
16
|
+
// to an hour; a pending domain is also checked by itself every 15 minutes for 72 hours, then
|
|
17
|
+
// hourly, and is failed after 7 days. Check again later rather than in a tight loop.
|
|
18
|
+
// Then add the addresses it sends from (`addresses add hello@acme.com --name "Acme"`); the first is
|
|
19
|
+
// the workspace's default. Nothing here sends email.
|
|
20
|
+
//
|
|
21
|
+
// Every call goes to a route opened to tokens holding the `contacts` scope (`workover login
|
|
22
|
+
// --contacts`). Reading is any teammate's; adding, checking, sharing and removing are the owners'
|
|
23
|
+
// and admins'. Adding a domain the workspace already has answers it again (`created: false`), and
|
|
24
|
+
// adding an address it already has does the same, so each step is safe to repeat.
|
|
25
|
+
|
|
26
|
+
import { apiError, resolveWorkspace } from './site-setup.mjs';
|
|
27
|
+
|
|
28
|
+
export const DOMAINS_LOGIN = 'workover login --contacts';
|
|
29
|
+
export const RECORD_FORMATS = ['bind', 'text', 'json'];
|
|
30
|
+
|
|
31
|
+
const base = (ws) => `/workspace/${encodeURIComponent(ws.id)}`;
|
|
32
|
+
const ref = (v, what = 'domain') => {
|
|
33
|
+
const s = String(v ?? '').trim();
|
|
34
|
+
if (!s) throw apiError(400, `Name the ${what}, like ${what === 'domain' ? 'acme.com' : 'hello@acme.com'}.`);
|
|
35
|
+
return encodeURIComponent(s);
|
|
36
|
+
};
|
|
37
|
+
/** The MCP server says so (`?via=mcp`), so the audit log names mcp rather than cli. */
|
|
38
|
+
const via = (v, joiner = '?') => (v === 'mcp' ? `${joiner}via=mcp` : '');
|
|
39
|
+
|
|
40
|
+
// ── Calls ─────────────────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
export async function listDomains(call, { workspace } = {}) {
|
|
43
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
44
|
+
return { workspace: ws, ...(await call(`${base(ws)}/sending-domains`)) };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Add a domain. `mailFrom`: the bounce subdomain (default bounce), or false for none. `dkim`: branded or easy. */
|
|
48
|
+
export async function addDomain(call, { workspace, domain, mailFrom, dkim, via: v } = {}) {
|
|
49
|
+
if (!String(domain ?? '').trim()) throw apiError(400, 'Give the domain to send from, like acme.com.');
|
|
50
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
51
|
+
const body = { domain: String(domain).trim() };
|
|
52
|
+
if (mailFrom !== undefined) body.mailFrom = mailFrom;
|
|
53
|
+
if (dkim !== undefined) body.dkim = dkim;
|
|
54
|
+
const res = await call(`${base(ws)}/sending-domains${via(v)}`, { method: 'POST', body });
|
|
55
|
+
return { workspace: ws, ...res };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function getDomain(call, { workspace, domain } = {}) {
|
|
59
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
60
|
+
return { workspace: ws, domain: await call(`${base(ws)}/sending-domains/${ref(domain)}`) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function checkDomain(call, { workspace, domain, via: v } = {}) {
|
|
64
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
65
|
+
const res = await call(`${base(ws)}/sending-domains/${ref(domain)}/check${via(v)}`, { method: 'POST' });
|
|
66
|
+
return { workspace: ws, domain: res };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function domainRecords(call, { workspace, domain, format = 'text' } = {}) {
|
|
70
|
+
if (!RECORD_FORMATS.includes(format)) throw apiError(400, 'format is bind, text or json.');
|
|
71
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
72
|
+
const res = await call(`${base(ws)}/sending-domains/${ref(domain)}/records?format=${format}`);
|
|
73
|
+
return { workspace: ws, ...res };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function shareDomain(call, { workspace, domain, reset = false, via: v } = {}) {
|
|
77
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
78
|
+
const res = await call(`${base(ws)}/sending-domains/${ref(domain)}/share${via(v)}`, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: reset ? { reset: true } : {},
|
|
81
|
+
});
|
|
82
|
+
return { workspace: ws, ...res };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function removeDomain(call, { workspace, domain, via: v } = {}) {
|
|
86
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
87
|
+
const res = await call(`${base(ws)}/sending-domains/${ref(domain)}${via(v)}`, { method: 'DELETE' });
|
|
88
|
+
return { workspace: ws, ...res };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function listAddresses(call, { workspace } = {}) {
|
|
92
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
93
|
+
return { workspace: ws, ...(await call(`${base(ws)}/sending-addresses`)) };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function addAddress(call, { workspace, email, name, replyTo, isDefault, via: v } = {}) {
|
|
97
|
+
if (!String(email ?? '').trim()) throw apiError(400, 'Give the address, like hello@acme.com.');
|
|
98
|
+
if (!String(name ?? '').trim()) throw apiError(400, 'Give the From name people see, like "Acme".');
|
|
99
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
100
|
+
const body = { email: String(email).trim(), fromName: String(name).trim() };
|
|
101
|
+
if (replyTo) body.replyTo = String(replyTo).trim();
|
|
102
|
+
if (isDefault === true) body.default = true;
|
|
103
|
+
const res = await call(`${base(ws)}/sending-addresses${via(v)}`, { method: 'POST', body });
|
|
104
|
+
return { workspace: ws, ...res };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function updateAddress(call, { workspace, email, name, replyTo, via: v } = {}) {
|
|
108
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
109
|
+
const body = {};
|
|
110
|
+
if (name !== undefined) body.fromName = name;
|
|
111
|
+
if (replyTo !== undefined) body.replyTo = replyTo;
|
|
112
|
+
const res = await call(`${base(ws)}/sending-addresses/${ref(email, 'address')}${via(v)}`, {
|
|
113
|
+
method: 'PATCH',
|
|
114
|
+
body,
|
|
115
|
+
});
|
|
116
|
+
return { workspace: ws, ...res };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function defaultAddress(call, { workspace, email, via: v } = {}) {
|
|
120
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
121
|
+
const res = await call(`${base(ws)}/sending-addresses/${ref(email, 'address')}/default${via(v)}`, {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
});
|
|
124
|
+
return { workspace: ws, ...res };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function removeAddress(call, { workspace, email, via: v } = {}) {
|
|
128
|
+
const ws = await resolveWorkspace(call, workspace);
|
|
129
|
+
const res = await call(`${base(ws)}/sending-addresses/${ref(email, 'address')}${via(v)}`, {
|
|
130
|
+
method: 'DELETE',
|
|
131
|
+
});
|
|
132
|
+
return { workspace: ws, ...res };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ── Rendering ─────────────────────────────────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
const STATUS = {
|
|
138
|
+
verified: 'verified',
|
|
139
|
+
pending: 'pending',
|
|
140
|
+
failed: 'failed',
|
|
141
|
+
temporary_failure: 'temporary failure',
|
|
142
|
+
};
|
|
143
|
+
const MARK = { ok: '✓', missing: '·', mismatch: '✗', unknown: '?' };
|
|
144
|
+
|
|
145
|
+
export function renderDomainLine(d) {
|
|
146
|
+
const addrs = (d.addresses ?? []).map((a) => a.email).join(', ');
|
|
147
|
+
return ` ${d.domain} ${STATUS[d.status] ?? d.status} ${d.requiredOk ?? 0}/${d.requiredRecords ?? 0} required records${addrs ? ` (${addrs})` : ''}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function renderDomains(res) {
|
|
151
|
+
const list = res.domains ?? [];
|
|
152
|
+
const out = [''];
|
|
153
|
+
if (!list.length) out.push(' No sending domains yet. `workover domains add acme.com` adds one and prints its DNS records.');
|
|
154
|
+
else out.push(` Sending domains (${list.length} of ${res.max ?? 10}):`, ...list.map(renderDomainLine));
|
|
155
|
+
if (res.canManage === false) out.push('', ' Only workspace owners and admins add, check or remove domains.');
|
|
156
|
+
out.push('');
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const minutesUntil = (iso) => Math.max(1, Math.round((Date.parse(iso) - Date.now()) / 60000));
|
|
161
|
+
|
|
162
|
+
/** One domain: its status, each record with both names, and what to do next. */
|
|
163
|
+
export function renderDomain(d, { created } = {}) {
|
|
164
|
+
const out = [''];
|
|
165
|
+
if (created === true) out.push(` ✓ Added ${d.domain}. Add these records at its DNS host, then check.`);
|
|
166
|
+
if (created === false) out.push(` ${d.domain} was already added.`);
|
|
167
|
+
out.push(
|
|
168
|
+
` ${d.domain} ${STATUS[d.status] ?? d.status} (${d.requiredOk}/${d.requiredRecords} required records found${d.lastCheckedAt ? `, checked ${d.lastCheckedAt}` : ''})`,
|
|
169
|
+
);
|
|
170
|
+
if (d.failureReason) out.push(` ${d.failureReason}`);
|
|
171
|
+
if (d.lastError) out.push(` ${d.lastError}`);
|
|
172
|
+
out.push('');
|
|
173
|
+
for (const r of d.records ?? []) {
|
|
174
|
+
out.push(
|
|
175
|
+
` ${MARK[r.status] ?? '?'} ${r.type.padEnd(5)} ${r.name} (${r.host})${r.required ? '' : ' recommended'}`,
|
|
176
|
+
` ${r.type === 'MX' ? `${r.priority ?? 10} ` : ''}${r.value}`,
|
|
177
|
+
` ${r.message}`,
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
if (d.spf?.note) out.push('', ` ${d.spf.note}`);
|
|
181
|
+
if (d.status === 'verified') out.push('', ' Verified: it can send. Add an address with `workover domains addresses add hello@' + d.domain + ' --name "..."`.');
|
|
182
|
+
else if (d.nextCheckAt)
|
|
183
|
+
out.push(
|
|
184
|
+
'',
|
|
185
|
+
` Workover checks again by itself in about ${minutesUntil(d.nextCheckAt)} minute(s); \`workover domains check ${d.domain}\` checks now.`,
|
|
186
|
+
);
|
|
187
|
+
const addrs = d.addresses ?? [];
|
|
188
|
+
if (addrs.length) out.push('', ' Addresses:', ...addrs.map(renderAddressLine));
|
|
189
|
+
out.push('');
|
|
190
|
+
return out;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function renderRemoved(res) {
|
|
194
|
+
return ['', ` ✓ Removed ${res.domain}.`, ''];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function renderShared(res) {
|
|
198
|
+
return [
|
|
199
|
+
'',
|
|
200
|
+
` Records page for ${res.domain} (no sign-in needed; \`--reset\` replaces the link):`,
|
|
201
|
+
` ${res.url}`,
|
|
202
|
+
'',
|
|
203
|
+
' To send to whoever runs the DNS:',
|
|
204
|
+
'',
|
|
205
|
+
...String(res.text ?? '')
|
|
206
|
+
.split('\n')
|
|
207
|
+
.map((l) => ` ${l}`),
|
|
208
|
+
'',
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function renderAddressLine(a) {
|
|
213
|
+
return ` ${a.email} "${a.fromName}"${a.replyTo ? ` reply-to ${a.replyTo}` : ''}${a.isDefault ? ' default' : ''}${a.verified ? '' : ' (domain not verified yet)'}`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function renderAddresses(res) {
|
|
217
|
+
const list = res.addresses ?? [];
|
|
218
|
+
if (!list.length)
|
|
219
|
+
return ['', ' No sending addresses yet. `workover domains addresses add hello@acme.com --name "Acme"` adds one.', ''];
|
|
220
|
+
return ['', ` Sending addresses (${list.length}):`, ...list.map(renderAddressLine), ''];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function renderAddressSaved(res) {
|
|
224
|
+
const verb = res.created === false ? 'Already there' : res.created ? 'Added' : 'Saved';
|
|
225
|
+
return ['', ` ✓ ${verb}:`, renderAddressLine(res.address), ''];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ── MCP tools ─────────────────────────────────────────────────────────────────────────────────────
|
|
229
|
+
|
|
230
|
+
const WORKSPACE = {
|
|
231
|
+
type: 'string',
|
|
232
|
+
description: 'The workspace, by slug or id. Needed only when the account has more than one.',
|
|
233
|
+
};
|
|
234
|
+
const DOMAIN = { type: 'string', description: 'The domain by name (acme.com) or id.' };
|
|
235
|
+
const ADDRESS = { type: 'string', description: 'The address (hello@acme.com) or its id.' };
|
|
236
|
+
const SCOPE =
|
|
237
|
+
' Needs a token from `workover login --contacts`; without it this returns a permission error naming that command.';
|
|
238
|
+
const FLOW =
|
|
239
|
+
' The setup end to end: workover_domains_add, apply every required record at the DNS host (or hand them on with workover_domains_records or workover_domains_share), then workover_domains_check. DNS can take up to an hour: when it is still pending, tell the person and check again later rather than in a loop (Workover also checks by itself every 15 minutes for 72 hours, then hourly, and fails it after 7 days).';
|
|
240
|
+
|
|
241
|
+
export const DOMAINS_TOOL_DEFS = [
|
|
242
|
+
{
|
|
243
|
+
name: 'workover_domains_list',
|
|
244
|
+
description:
|
|
245
|
+
"The workspace's sending domains: each one's status (pending, verified, failed, temporary_failure), how many required DNS records are found, and its addresses." +
|
|
246
|
+
SCOPE,
|
|
247
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE } },
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'workover_domains_add',
|
|
251
|
+
description:
|
|
252
|
+
'Add a domain the workspace sends email from, such as acme.com or mail.acme.com, and answer every DNS record it needs (type, full name, the name relative to its zone, value, MX priority), each already looked up once. Safe to repeat: a domain already added is answered again. Owners and admins. Up to 10 per workspace; public mailbox domains (gmail.com) are refused.' +
|
|
253
|
+
FLOW +
|
|
254
|
+
SCOPE,
|
|
255
|
+
inputSchema: {
|
|
256
|
+
type: 'object',
|
|
257
|
+
properties: {
|
|
258
|
+
workspace: WORKSPACE,
|
|
259
|
+
domain: { type: 'string', description: 'The domain, like acme.com.' },
|
|
260
|
+
mailFrom: {
|
|
261
|
+
type: ['string', 'boolean'],
|
|
262
|
+
description: 'The bounce subdomain (custom MAIL FROM), default "bounce"; false for none.',
|
|
263
|
+
},
|
|
264
|
+
dkim: {
|
|
265
|
+
type: 'string',
|
|
266
|
+
enum: ['branded', 'easy'],
|
|
267
|
+
description:
|
|
268
|
+
"branded (default where available): one DKIM TXT record with Workover's own key. easy: three DKIM CNAMEs at the mail provider.",
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
required: ['domain'],
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'workover_domains_get',
|
|
276
|
+
description:
|
|
277
|
+
'One sending domain: its status, every record with what the last check found and a sentence about it, when Workover checks next, and its addresses.' +
|
|
278
|
+
SCOPE,
|
|
279
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE, domain: DOMAIN }, required: ['domain'] },
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
name: 'workover_domains_check',
|
|
283
|
+
description:
|
|
284
|
+
'Check a sending domain now: the provider and every DNS record looked up, kept and answered. Verified once every required record resolves. Owners and admins.' +
|
|
285
|
+
FLOW +
|
|
286
|
+
SCOPE,
|
|
287
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE, domain: DOMAIN }, required: ['domain'] },
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'workover_domains_records',
|
|
291
|
+
description:
|
|
292
|
+
"A domain's records to hand on: bind (a zone-file snippet many DNS hosts import), text (for whoever runs the DNS), or json (for a DNS provider's API)." +
|
|
293
|
+
SCOPE,
|
|
294
|
+
inputSchema: {
|
|
295
|
+
type: 'object',
|
|
296
|
+
properties: {
|
|
297
|
+
workspace: WORKSPACE,
|
|
298
|
+
domain: DOMAIN,
|
|
299
|
+
format: { type: 'string', enum: RECORD_FORMATS, description: 'Default text.' },
|
|
300
|
+
},
|
|
301
|
+
required: ['domain'],
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: 'workover_domains_share',
|
|
306
|
+
description:
|
|
307
|
+
'A link to a read-only page with the domain\'s records, for a DNS admin without a Workover account, and the same records as text to send them. `reset: true` replaces the link and breaks the old one: ask first. Owners and admins.' +
|
|
308
|
+
SCOPE,
|
|
309
|
+
inputSchema: {
|
|
310
|
+
type: 'object',
|
|
311
|
+
properties: { workspace: WORKSPACE, domain: DOMAIN, reset: { type: 'boolean' } },
|
|
312
|
+
required: ['domain'],
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: 'workover_domains_remove',
|
|
317
|
+
description:
|
|
318
|
+
'Remove a sending domain, its signing key and its addresses. Mail can no longer go from it: ask the person first. Owners and admins.' +
|
|
319
|
+
SCOPE,
|
|
320
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE, domain: DOMAIN }, required: ['domain'] },
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: 'workover_domains_addresses',
|
|
324
|
+
description:
|
|
325
|
+
"The workspace's sending addresses: email, From name, Reply-To, which is the default, and whether its domain is verified." +
|
|
326
|
+
SCOPE,
|
|
327
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE } },
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: 'workover_domains_address_add',
|
|
331
|
+
description:
|
|
332
|
+
"Add an address at one of the workspace's sending domains, with the From name people see and an optional Reply-To. The first address is the default. Safe to repeat. Owners and admins." +
|
|
333
|
+
SCOPE,
|
|
334
|
+
inputSchema: {
|
|
335
|
+
type: 'object',
|
|
336
|
+
properties: {
|
|
337
|
+
workspace: WORKSPACE,
|
|
338
|
+
email: { type: 'string', description: 'Like hello@acme.com.' },
|
|
339
|
+
name: { type: 'string', description: 'The From name, like "Acme".' },
|
|
340
|
+
replyTo: { type: 'string' },
|
|
341
|
+
default: { type: 'boolean', description: "Make it the workspace's default address." },
|
|
342
|
+
},
|
|
343
|
+
required: ['email', 'name'],
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: 'workover_domains_address_update',
|
|
348
|
+
description: "Change an address's From name or Reply-To (null clears the Reply-To). Owners and admins." + SCOPE,
|
|
349
|
+
inputSchema: {
|
|
350
|
+
type: 'object',
|
|
351
|
+
properties: {
|
|
352
|
+
workspace: WORKSPACE,
|
|
353
|
+
email: ADDRESS,
|
|
354
|
+
name: { type: 'string' },
|
|
355
|
+
replyTo: { type: ['string', 'null'] },
|
|
356
|
+
},
|
|
357
|
+
required: ['email'],
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: 'workover_domains_address_default',
|
|
362
|
+
description: "Make an address the workspace's default sending address. Owners and admins." + SCOPE,
|
|
363
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE, email: ADDRESS }, required: ['email'] },
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
name: 'workover_domains_address_remove',
|
|
367
|
+
description:
|
|
368
|
+
'Remove a sending address; if it was the default, the oldest remaining one takes over. Owners and admins.' +
|
|
369
|
+
SCOPE,
|
|
370
|
+
inputSchema: { type: 'object', properties: { workspace: WORKSPACE, email: ADDRESS }, required: ['email'] },
|
|
371
|
+
},
|
|
372
|
+
];
|
|
373
|
+
|
|
374
|
+
/** The domains tools' names, for the MCP dispatcher. */
|
|
375
|
+
export const DOMAINS_TOOLS = new Set(DOMAINS_TOOL_DEFS.map((t) => t.name));
|
|
376
|
+
|
|
377
|
+
/** One domains tool, run: the lines to answer with. Throws as `call` does. */
|
|
378
|
+
export async function runDomainsTool(call, name, args = {}) {
|
|
379
|
+
const workspace = args.workspace === undefined || args.workspace === null ? undefined : String(args.workspace);
|
|
380
|
+
const v = 'mcp';
|
|
381
|
+
if (name === 'workover_domains_list') return renderDomains(await listDomains(call, { workspace }));
|
|
382
|
+
if (name === 'workover_domains_add') {
|
|
383
|
+
const res = await addDomain(call, { workspace, domain: args.domain, mailFrom: args.mailFrom, dkim: args.dkim, via: v });
|
|
384
|
+
return renderDomain(res.domain, { created: res.created });
|
|
385
|
+
}
|
|
386
|
+
if (name === 'workover_domains_get') return renderDomain((await getDomain(call, { workspace, domain: args.domain })).domain);
|
|
387
|
+
if (name === 'workover_domains_check')
|
|
388
|
+
return renderDomain((await checkDomain(call, { workspace, domain: args.domain, via: v })).domain);
|
|
389
|
+
if (name === 'workover_domains_records') {
|
|
390
|
+
const res = await domainRecords(call, { workspace, domain: args.domain, format: args.format ?? 'text' });
|
|
391
|
+
return res.format === 'json' ? [JSON.stringify(res.records, null, 2)] : [res.text];
|
|
392
|
+
}
|
|
393
|
+
if (name === 'workover_domains_share')
|
|
394
|
+
return renderShared(await shareDomain(call, { workspace, domain: args.domain, reset: args.reset === true, via: v }));
|
|
395
|
+
if (name === 'workover_domains_remove') return renderRemoved(await removeDomain(call, { workspace, domain: args.domain, via: v }));
|
|
396
|
+
if (name === 'workover_domains_addresses') return renderAddresses(await listAddresses(call, { workspace }));
|
|
397
|
+
if (name === 'workover_domains_address_add')
|
|
398
|
+
return renderAddressSaved(
|
|
399
|
+
await addAddress(call, {
|
|
400
|
+
workspace,
|
|
401
|
+
email: args.email,
|
|
402
|
+
name: args.name,
|
|
403
|
+
replyTo: args.replyTo,
|
|
404
|
+
isDefault: args.default === true,
|
|
405
|
+
via: v,
|
|
406
|
+
}),
|
|
407
|
+
);
|
|
408
|
+
if (name === 'workover_domains_address_update')
|
|
409
|
+
return renderAddressSaved(
|
|
410
|
+
await updateAddress(call, { workspace, email: args.email, name: args.name, replyTo: args.replyTo, via: v }),
|
|
411
|
+
);
|
|
412
|
+
if (name === 'workover_domains_address_default')
|
|
413
|
+
return renderAddresses(await defaultAddress(call, { workspace, email: args.email, via: v }));
|
|
414
|
+
if (name === 'workover_domains_address_remove')
|
|
415
|
+
return renderAddresses(await removeAddress(call, { workspace, email: args.email, via: v }));
|
|
416
|
+
throw apiError(400, `Unknown tool: ${name}`);
|
|
417
|
+
}
|