langmail-mcp 0.0.0 → 0.2.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 +1 -1
- package/README.md +89 -169
- package/dist/chunk-0fxfqny0.js +12642 -0
- package/dist/langmail-mcp.js +7 -0
- package/package.json +93 -98
- package/THIRD_PARTY_NOTICES.md +0 -388
- package/dist/attachments/download.js +0 -69
- package/dist/attachments/routes.js +0 -42
- package/dist/attachments/tickets.js +0 -45
- package/dist/attachments/upload-tickets.js +0 -43
- package/dist/attachments/upload.js +0 -136
- package/dist/caldav/account-settings.js +0 -92
- package/dist/caldav/agenda.js +0 -277
- package/dist/caldav/alarm.js +0 -97
- package/dist/caldav/client.js +0 -408
- package/dist/caldav/ical.js +0 -248
- package/dist/caldav/occurrence.js +0 -534
- package/dist/caldav/recurrence.js +0 -313
- package/dist/caldav/rsvp.js +0 -107
- package/dist/caldav/scheduling-handover.js +0 -22
- package/dist/caldav/timezone.js +0 -103
- package/dist/caldav/types.js +0 -5
- package/dist/config.js +0 -219
- package/dist/contacts/address-class.js +0 -79
- package/dist/contacts/birthdays.js +0 -81
- package/dist/contacts/card.js +0 -58
- package/dist/contacts/constants.js +0 -46
- package/dist/contacts/fold.js +0 -309
- package/dist/contacts/index.js +0 -10
- package/dist/contacts/merge.js +0 -388
- package/dist/contacts/observations.js +0 -115
- package/dist/contacts/profile.js +0 -402
- package/dist/contacts/scoring.js +0 -146
- package/dist/contacts/types.js +0 -7
- package/dist/contacts/upsert.js +0 -131
- package/dist/drafts/attachments.js +0 -254
- package/dist/drafts/idempotency.js +0 -60
- package/dist/drafts/send-guard.js +0 -184
- package/dist/email-render/email-viewer.html +0 -143
- package/dist/email-render/image-proxy.js +0 -389
- package/dist/email-render/meta.js +0 -48
- package/dist/email-render/sanitize.js +0 -93
- package/dist/email-render/viewer-resource.js +0 -104
- package/dist/http/bearer.js +0 -30
- package/dist/http/guard.js +0 -57
- package/dist/http/hosts.js +0 -10
- package/dist/http/listener.js +0 -170
- package/dist/http/routes.js +0 -72
- package/dist/ical/ical-parse.js +0 -357
- package/dist/ical/index.js +0 -4
- package/dist/ical/timezone.js +0 -22
- package/dist/ical/windows-zones.js +0 -155
- package/dist/index.js +0 -79
- package/dist/jmap/blob.js +0 -49
- package/dist/jmap/contacts.js +0 -226
- package/dist/jmap/drafts.js +0 -480
- package/dist/jmap/email.js +0 -668
- package/dist/jmap/index.js +0 -12
- package/dist/jmap/keywords.js +0 -22
- package/dist/jmap/live.js +0 -21
- package/dist/jmap/origin.js +0 -113
- package/dist/jmap/patch.js +0 -29
- package/dist/jmap/request.js +0 -37
- package/dist/jmap/session.js +0 -89
- package/dist/jmap/sieve.js +0 -71
- package/dist/jmap/submission.js +0 -107
- package/dist/jmap/timeout.js +0 -30
- package/dist/jmap/types.js +0 -6
- package/dist/logger.js +0 -48
- package/dist/mcp/handler.js +0 -255
- package/dist/mcp/http.js +0 -29
- package/dist/mcp/instructions.js +0 -44
- package/dist/mcp/links.js +0 -64
- package/dist/mcp/test-client.js +0 -43
- package/dist/mcp/tool-logging.js +0 -67
- package/dist/observability/errors.js +0 -41
- package/dist/rules/apply.js +0 -236
- package/dist/rules/rule.js +0 -280
- package/dist/rules/store.js +0 -92
- package/dist/tools/annotations.js +0 -71
- package/dist/tools/archive-emails.js +0 -40
- package/dist/tools/calendar-lookup.js +0 -64
- package/dist/tools/contact-common.js +0 -146
- package/dist/tools/contact-format.js +0 -72
- package/dist/tools/contact-write-through.js +0 -37
- package/dist/tools/create-calendar-event.js +0 -231
- package/dist/tools/create-calendar.js +0 -54
- package/dist/tools/create-contact.js +0 -172
- package/dist/tools/create-draft.js +0 -369
- package/dist/tools/create-mail-rule.js +0 -101
- package/dist/tools/delete-calendar-event.js +0 -165
- package/dist/tools/delete-contact.js +0 -60
- package/dist/tools/delete-draft.js +0 -129
- package/dist/tools/delete-mail-rule.js +0 -38
- package/dist/tools/download-attachment.js +0 -90
- package/dist/tools/download-email.js +0 -112
- package/dist/tools/draft-common.js +0 -600
- package/dist/tools/email-types.js +0 -58
- package/dist/tools/error-detail.js +0 -10
- package/dist/tools/file-emails-common.js +0 -75
- package/dist/tools/format.js +0 -131
- package/dist/tools/forward-message.js +0 -237
- package/dist/tools/forward-quote.js +0 -179
- package/dist/tools/get-draft.js +0 -61
- package/dist/tools/get-email.js +0 -164
- package/dist/tools/get-thread.js +0 -67
- package/dist/tools/keywords.js +0 -43
- package/dist/tools/list-calendar-events.js +0 -180
- package/dist/tools/list-calendars.js +0 -44
- package/dist/tools/list-drafts.js +0 -134
- package/dist/tools/list-mail-rules.js +0 -28
- package/dist/tools/list-unsubscribe.js +0 -152
- package/dist/tools/list-upcoming-birthdays.js +0 -165
- package/dist/tools/mail-rule-common.js +0 -43
- package/dist/tools/mail-rule-format.js +0 -79
- package/dist/tools/mailbox-lookup.js +0 -13
- package/dist/tools/mark-emails.js +0 -78
- package/dist/tools/merge-contacts.js +0 -145
- package/dist/tools/move-calendar-events.js +0 -340
- package/dist/tools/move-emails.js +0 -64
- package/dist/tools/one-click-post.js +0 -275
- package/dist/tools/preview-email.js +0 -204
- package/dist/tools/preview-mail-rule.js +0 -79
- package/dist/tools/reply-quote.js +0 -426
- package/dist/tools/reply-to-message.js +0 -292
- package/dist/tools/respond-to-event.js +0 -110
- package/dist/tools/result.js +0 -9
- package/dist/tools/search-contacts.js +0 -431
- package/dist/tools/search-emails.js +0 -570
- package/dist/tools/send-draft.js +0 -308
- package/dist/tools/trash-emails.js +0 -36
- package/dist/tools/unsubscribe-from-list.js +0 -249
- package/dist/tools/update-calendar-event.js +0 -973
- package/dist/tools/update-calendar.js +0 -100
- package/dist/tools/update-contact.js +0 -382
- package/dist/tools/update-draft.js +0 -714
- package/dist/tools/update-mail-rule.js +0 -103
- package/dist/tools/upload-attachments.js +0 -126
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// mark_emails tool — set and clear the user-facing flags on messages: read,
|
|
2
|
-
// to-do, starred. One targeted keyword patch over the whole batch, so nothing
|
|
3
|
-
// else about a message — its folders, its type, any flag left out — moves.
|
|
4
|
-
// One field per flag, holding the state the flag should end up in, so "add
|
|
5
|
-
// and remove the same flag" cannot be expressed. Reading a message with
|
|
6
|
-
// get_email never changes its read state; the agent decides, through this.
|
|
7
|
-
// System flags ($answered, $draft) and classification types are deliberately
|
|
8
|
-
// not fields: an agent must not fake what happened to a message.
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import { ACCOUNT_WRITE } from "./annotations.js";
|
|
11
|
-
import { dedupedIds, formatBatchResult, idsShape, } from "./file-emails-common.js";
|
|
12
|
-
import { FLAGGED_KEYWORD, keywordToJmapKeyword, SEEN_KEYWORD, } from "./keywords.js";
|
|
13
|
-
import { errorResult } from "./result.js";
|
|
14
|
-
// The same `$label:todo` keyword search_emails filters on with keywords: ["todo"].
|
|
15
|
-
const TODO_KEYWORD = keywordToJmapKeyword("todo");
|
|
16
|
-
const markEmailsShape = {
|
|
17
|
-
...idsShape,
|
|
18
|
-
read: z
|
|
19
|
-
.boolean()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe("true marks the messages read, false marks them unread. Leave out to keep read state."),
|
|
22
|
-
starred: z
|
|
23
|
-
.boolean()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("true stars the messages, false removes the star. Leave out to keep it."),
|
|
26
|
-
todo: z
|
|
27
|
-
.boolean()
|
|
28
|
-
.optional()
|
|
29
|
-
.describe("true flags the messages as a to-do for the user, false clears the to-do (e.g. once it is done). " +
|
|
30
|
-
"Leave out to keep it."),
|
|
31
|
-
};
|
|
32
|
-
export const markEmailsInput = z.object({
|
|
33
|
-
...markEmailsShape,
|
|
34
|
-
ids: dedupedIds,
|
|
35
|
-
});
|
|
36
|
-
// Field order here is the order the result line names the flags in.
|
|
37
|
-
const FLAGS = {
|
|
38
|
-
read: { keyword: SEEN_KEYWORD, off: "unread", on: "read" },
|
|
39
|
-
todo: { keyword: TODO_KEYWORD, off: "not to-do", on: "to-do" },
|
|
40
|
-
starred: { keyword: FLAGGED_KEYWORD, off: "unstarred", on: "starred" },
|
|
41
|
-
};
|
|
42
|
-
export const markEmails = async (deps, ctx) => {
|
|
43
|
-
const keywords = {};
|
|
44
|
-
const labels = [];
|
|
45
|
-
for (const [field, spec] of Object.entries(FLAGS)) {
|
|
46
|
-
const value = ctx.args[field];
|
|
47
|
-
if (value === undefined) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
keywords[spec.keyword] = value;
|
|
51
|
-
labels.push(value ? spec.on : spec.off);
|
|
52
|
-
}
|
|
53
|
-
if (labels.length === 0) {
|
|
54
|
-
const fields = Object.keys(FLAGS);
|
|
55
|
-
const choices = `${fields.slice(0, -1).join(", ")} or ${fields.at(-1)}`;
|
|
56
|
-
return errorResult(`No flag given, so nothing was changed. Pass at least one of ${choices}.`);
|
|
57
|
-
}
|
|
58
|
-
const result = await deps.updateEmails(ctx.token, ctx.args.ids, { keywords });
|
|
59
|
-
return formatBatchResult("Marked", result, ` as ${labels.join(", ")}`);
|
|
60
|
-
};
|
|
61
|
-
// --- MCP registration ----------------------------------------------------
|
|
62
|
-
export const registerMarkEmails = (server, deps, getToken) => {
|
|
63
|
-
server.registerTool("mark_emails", {
|
|
64
|
-
annotations: ACCOUNT_WRITE,
|
|
65
|
-
description: "Set or clear the flags on one or more messages: read / unread, to-do, and starred. " +
|
|
66
|
-
"Reading a message with get_email, get_thread or search_emails never changes its read state, so " +
|
|
67
|
-
'call this when the user wants what you read marked read or says "keep this unread"; set todo when ' +
|
|
68
|
-
'a message needs action from the user ("flag this for me", "add it to my to-dos"), clear it when ' +
|
|
69
|
-
'the to-do is done ("mark it done"), and set starred for "star this". Several flags go in one call; ' +
|
|
70
|
-
"a flag you leave out is untouched. To finish a to-do, call this tool with todo: false (plus " +
|
|
71
|
-
"read: true if it is still unread), then archive_emails. Takes message ids from search_emails or " +
|
|
72
|
-
"get_thread; folders are untouched, and re-running it on the same ids is harmless. To get a " +
|
|
73
|
-
"message out of the inbox use archive_emails or move_emails instead; to mark something as spam, " +
|
|
74
|
-
"use move_emails with Junk. Reports how many messages were marked and lists any id the server refused.",
|
|
75
|
-
inputSchema: z.object(markEmailsShape),
|
|
76
|
-
title: "Mark emails read, to-do or starred",
|
|
77
|
-
}, (args) => markEmails(deps, { args: markEmailsInput.parse(args), token: getToken() }));
|
|
78
|
-
};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
// merge_contacts tool — folds duplicate contact cards into the one to keep.
|
|
2
|
-
//
|
|
3
|
-
// Collection mints one card per sending address, so one organization (a gym
|
|
4
|
-
// writing from its own address and from its booking platform) can end up as
|
|
5
|
-
// several. Rebuilding that by hand — remove the address here, add it there,
|
|
6
|
-
// delete the rest — takes four calls, loses the history and can silently
|
|
7
|
-
// change which address mail goes to. This tool does it in one write.
|
|
8
|
-
//
|
|
9
|
-
// The merged addresses become addresses of the kept card. That is all the
|
|
10
|
-
// memory a merge needs: collection finds the card holding an address, so a
|
|
11
|
-
// later message from any of them updates the kept card. The update and the
|
|
12
|
-
// destroys go out in one ContactCard/set, so a CardDAV device syncs one
|
|
13
|
-
// change, never a half-merged book.
|
|
14
|
-
import { z } from "zod";
|
|
15
|
-
import { mergeCards } from "../contacts/index.js";
|
|
16
|
-
import { ACCOUNT_DESTRUCTIVE } from "./annotations.js";
|
|
17
|
-
import { collectedBookIdOf, contactCtx, contactIdSchema, readBack, } from "./contact-common.js";
|
|
18
|
-
import { renderContact } from "./contact-format.js";
|
|
19
|
-
import { errorResult, textResult } from "./result.js";
|
|
20
|
-
import { renderDetailedContact, } from "./search-contacts.js";
|
|
21
|
-
const mergeContactsShape = {
|
|
22
|
-
contactId: contactIdSchema.describe("The contact to keep, as printed by search_contacts under `contact_id`. Its name, organization and birthday win."),
|
|
23
|
-
mergeContactIds: z
|
|
24
|
-
.array(z.string().min(1))
|
|
25
|
-
.min(1)
|
|
26
|
-
.max(10)
|
|
27
|
-
.describe("The contacts to fold into it and then delete, as printed by search_contacts under `contact_id`. Up to 10."),
|
|
28
|
-
preferredEmail: z
|
|
29
|
-
.email()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe("The address mail to this contact should go to, from any of the merged contacts. " +
|
|
32
|
-
"Omit it to keep the preferred address the kept contact has now."),
|
|
33
|
-
};
|
|
34
|
-
export const mergeContactsInput = z.object(mergeContactsShape);
|
|
35
|
-
// SetError types worth a sentence; anything else is named as the server
|
|
36
|
-
// sent it.
|
|
37
|
-
const reasonFor = (type) => type === "forbidden"
|
|
38
|
-
? "its address book is read-only"
|
|
39
|
-
: `the server answered ${type}`;
|
|
40
|
-
const PREFERRED_NOTE = {
|
|
41
|
-
pinned: "kept from before the merge and now marked as preferred",
|
|
42
|
-
requested: "as requested",
|
|
43
|
-
unchanged: "unchanged",
|
|
44
|
-
};
|
|
45
|
-
export const mergeContacts = async (deps, cx) => {
|
|
46
|
-
const { args } = cx;
|
|
47
|
-
const mergeIds = [...new Set(args.mergeContactIds)];
|
|
48
|
-
if (mergeIds.includes(args.contactId)) {
|
|
49
|
-
return errorResult(`${args.contactId} is the contact to keep and cannot also be merged into itself. Nothing was changed. ` +
|
|
50
|
-
"List only the other contacts in mergeContactIds.");
|
|
51
|
-
}
|
|
52
|
-
const ctx = await contactCtx(deps, cx.token);
|
|
53
|
-
const cards = await deps.contactCardGet({
|
|
54
|
-
...ctx,
|
|
55
|
-
ids: [args.contactId, ...mergeIds],
|
|
56
|
-
});
|
|
57
|
-
const byId = new Map(cards.map((c) => [c.id, c]));
|
|
58
|
-
const missing = [args.contactId, ...mergeIds].filter((id) => !byId.has(id));
|
|
59
|
-
if (missing.length > 0) {
|
|
60
|
-
return errorResult(`No contact with id ${missing.join(", ")}. Nothing was changed. ` +
|
|
61
|
-
"Use search_contacts to find the people and read their contact_id.");
|
|
62
|
-
}
|
|
63
|
-
const kept = byId.get(args.contactId);
|
|
64
|
-
const merged = mergeIds.map((id) => byId.get(id));
|
|
65
|
-
const merge = mergeCards(kept, merged, args.preferredEmail);
|
|
66
|
-
if ("error" in merge) {
|
|
67
|
-
return errorResult(`${merge.error} Nothing was changed. Name one of those as preferredEmail, or omit it.`);
|
|
68
|
-
}
|
|
69
|
-
// Read before the write, so a failed lookup can never fail a merge that
|
|
70
|
-
// already landed.
|
|
71
|
-
const collectedBookId = await collectedBookIdOf(deps, ctx);
|
|
72
|
-
const details = (ids) => merged
|
|
73
|
-
.filter((card) => ids.includes(card.id))
|
|
74
|
-
.map((card) => renderContact(card, collectedBookId))
|
|
75
|
-
.join("\n\n");
|
|
76
|
-
const outcome = await deps.contactCardMerge({
|
|
77
|
-
...ctx,
|
|
78
|
-
cardId: kept.id,
|
|
79
|
-
destroy: mergeIds,
|
|
80
|
-
patch: merge.patch,
|
|
81
|
-
});
|
|
82
|
-
if (outcome.updateError !== undefined) {
|
|
83
|
-
if (outcome.destroyed.length === 0) {
|
|
84
|
-
return errorResult(`Could not update the contact to keep: ${reasonFor(outcome.updateError)}. Nothing was changed.`);
|
|
85
|
-
}
|
|
86
|
-
// A /set is not atomic: the destroys can land although the update did
|
|
87
|
-
// not. The details below are all that is left of those cards.
|
|
88
|
-
return errorResult(`Could not update the contact to keep (${reasonFor(outcome.updateError)}), but the server deleted ` +
|
|
89
|
-
`${outcome.destroyed.join(", ")}. Recreate them with create_contact from these details:\n\n${details(outcome.destroyed)}`);
|
|
90
|
-
}
|
|
91
|
-
// Best-effort: the merge already landed and the cards are gone, so a failed
|
|
92
|
-
// read must not swallow the recovery details below.
|
|
93
|
-
const stored = await readBack(deps, ctx, kept.id).catch(() => undefined);
|
|
94
|
-
const rendered = stored
|
|
95
|
-
? `into this one:\n\n${await renderDetailedContact(deps, { authorization: ctx.authorization, token: cx.token }, stored, collectedBookId)}`
|
|
96
|
-
: `into contact ${kept.id}; reading it back failed, so look it up with search_contacts.`;
|
|
97
|
-
// The addresses and history of every listed card landed, deleted or not.
|
|
98
|
-
const deleted = outcome.destroyed.length === mergeIds.length
|
|
99
|
-
? ""
|
|
100
|
-
: ` (${outcome.destroyed.length} deleted)`;
|
|
101
|
-
const sections = [
|
|
102
|
-
`Merged ${mergeIds.length} contact(s)${deleted} ${rendered}`,
|
|
103
|
-
];
|
|
104
|
-
if (merge.preferred) {
|
|
105
|
-
sections.push(`Preferred address: ${merge.preferred.address}, ${PREFERRED_NOTE[merge.preferred.how]}.`);
|
|
106
|
-
}
|
|
107
|
-
if (merge.conflicts.length > 0) {
|
|
108
|
-
sections.push(`Conflicts (the kept contact's value stays):\n${merge.conflicts.map((c) => `- ${c}`).join("\n")}`);
|
|
109
|
-
}
|
|
110
|
-
const failed = Object.entries(outcome.notDestroyed);
|
|
111
|
-
if (failed.length > 0) {
|
|
112
|
-
sections.push(`Not deleted: ${failed.map(([id, type]) => `${id} (${reasonFor(type)})`).join(", ")}. ` +
|
|
113
|
-
"Their addresses are now on the kept contact as well; to finish, run merge_contacts again with " +
|
|
114
|
-
`mergeContactIds: [${failed.map(([id]) => `"${id}"`).join(", ")}] only — their history is not counted twice.`);
|
|
115
|
-
}
|
|
116
|
-
if (outcome.destroyed.length > 0) {
|
|
117
|
-
sections.push(`Removed contacts:\n\n${details(outcome.destroyed)}`);
|
|
118
|
-
}
|
|
119
|
-
const moved = merge.movedEmails.length > 0 ? merge.movedEmails.join(", ") : "none";
|
|
120
|
-
sections.push(`Moved addresses: ${moved}. To undo the merge, remove those from the kept contact with update_contact ` +
|
|
121
|
-
"(`removedEmails`), then recreate each removed contact with create_contact from its details above. " +
|
|
122
|
-
"Later mail from any merged address updates the kept contact. " +
|
|
123
|
-
"The merge syncs to every device connected over CardDAV as one change.");
|
|
124
|
-
return textResult(sections.join("\n\n"));
|
|
125
|
-
};
|
|
126
|
-
// --- MCP registration ----------------------------------------------------
|
|
127
|
-
export const registerMergeContacts = (server, deps, getToken) => {
|
|
128
|
-
server.registerTool("merge_contacts", {
|
|
129
|
-
annotations: ACCOUNT_DESTRUCTIVE,
|
|
130
|
-
description: "Merge duplicate contacts — the same person or organization collected under several addresses — " +
|
|
131
|
-
"into the one to keep, and delete the others. The kept contact gains every email address, phone " +
|
|
132
|
-
"number, postal address and note of the merged ones and their interaction history; its name, " +
|
|
133
|
-
"organization, birthday and preferred address stay unless it has none, and every value that does " +
|
|
134
|
-
"not fit is listed as a conflict. Later mail from any merged address updates the kept contact. " +
|
|
135
|
-
"Returns the merged contact in the detailed search_contacts format plus the full details of the " +
|
|
136
|
-
"removed contacts, which is what undoing it by hand needs. Find the ids with search_contacts; to " +
|
|
137
|
-
"move a single address between two contacts that are different people, use update_contact instead, " +
|
|
138
|
-
"and to drop a contact without keeping anything, delete_contact.",
|
|
139
|
-
inputSchema: mergeContactsInput,
|
|
140
|
-
title: "Merge contacts",
|
|
141
|
-
}, (args) => mergeContacts(deps, {
|
|
142
|
-
args: mergeContactsInput.parse(args),
|
|
143
|
-
token: getToken(),
|
|
144
|
-
}));
|
|
145
|
-
};
|
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
// move_calendar_events tool — re-files events on another of the principal's
|
|
2
|
-
// calendars with one WebDAV MOVE per event (docs: caldav/client.ts moveEvent).
|
|
3
|
-
//
|
|
4
|
-
// A copy-and-delete would flatten changed occurrences, drop every property
|
|
5
|
-
// the tools never read (alarms, attachments, TRANSP…) and give the event a
|
|
6
|
-
// new UID, which re-invites every attendee. Stalwart's MOVE re-parents the
|
|
7
|
-
// stored event instead, so none of that happens and no iMIP leaves the
|
|
8
|
-
// server — which is why this is ACCOUNT_WRITE while update_calendar_event is
|
|
9
|
-
// OUTWARD_DESTRUCTIVE. If a MOVE is refused, nothing falls back to a copy.
|
|
10
|
-
//
|
|
11
|
-
// Each calendar involved is listed once, in parallel, into a UID → location
|
|
12
|
-
// index; the moves then run one at a time so the per-event outcomes come
|
|
13
|
-
// back in a deterministic order. Like the other CalDAV tools, the logic sits
|
|
14
|
-
// behind a `Deps` interface so it unit-tests without live Stalwart.
|
|
15
|
-
import { z } from "zod";
|
|
16
|
-
import { fetchCalendarList, fetchEvents, moveEvent, withTrailingSlash, } from "../caldav/client.js";
|
|
17
|
-
import { parseEvents } from "../ical/index.js";
|
|
18
|
-
import { logger } from "../logger.js";
|
|
19
|
-
import { describeError } from "../observability/errors.js";
|
|
20
|
-
import { ACCOUNT_WRITE } from "./annotations.js";
|
|
21
|
-
import { calendarLabel, resolveCalendar, sameCalendarUrl, } from "./calendar-lookup.js";
|
|
22
|
-
import { eventUidSchema } from "./create-calendar-event.js";
|
|
23
|
-
import { errorResult, textResult } from "./result.js";
|
|
24
|
-
const TOOL_NAME = "move_calendar_events";
|
|
25
|
-
const MAX_MOVE_UIDS = 50;
|
|
26
|
-
// CALDAV_TIMEOUT_MS bounds each request, not the call. No new MOVE starts
|
|
27
|
-
// once this much time has passed since the call began; the rest are reported
|
|
28
|
-
// as not attempted, and a re-run picks them up.
|
|
29
|
-
export const MOVE_BUDGET_MS = 45_000;
|
|
30
|
-
const NOTHING_MOVED = "Nothing was moved.";
|
|
31
|
-
const moveCalendarEventsShape = {
|
|
32
|
-
calendar: z
|
|
33
|
-
.string()
|
|
34
|
-
.trim()
|
|
35
|
-
.min(1)
|
|
36
|
-
.describe("Destination calendar: its name (matched ignoring case) or its URL, both as list_calendars " +
|
|
37
|
-
"shows them. It must already exist; calendars are never created here."),
|
|
38
|
-
fromCalendar: z
|
|
39
|
-
.string()
|
|
40
|
-
.trim()
|
|
41
|
-
.min(1)
|
|
42
|
-
.optional()
|
|
43
|
-
.describe("Only needed when a uid exists in more than one calendar: the calendar to move it out of, " +
|
|
44
|
-
"by name or URL. Omit otherwise; each event is found wherever it is."),
|
|
45
|
-
uids: z
|
|
46
|
-
.array(eventUidSchema)
|
|
47
|
-
.min(1)
|
|
48
|
-
.max(MAX_MOVE_UIDS)
|
|
49
|
-
.describe("Events to move, by the uid list_calendar_events shows. A recurring event moves as a whole " +
|
|
50
|
-
`series, including its changed occurrences. Up to ${MAX_MOVE_UIDS} per call.`),
|
|
51
|
-
};
|
|
52
|
-
// Duplicates are collapsed so one event is never reported twice (overrides of
|
|
53
|
-
// a series share its uid in list_calendar_events). The cap applies to the
|
|
54
|
-
// uids as given, before collapsing.
|
|
55
|
-
export const moveCalendarEventsInput = z.object({
|
|
56
|
-
...moveCalendarEventsShape,
|
|
57
|
-
uids: moveCalendarEventsShape.uids.transform((uids) => [...new Set(uids)]),
|
|
58
|
-
});
|
|
59
|
-
// Every uid a stored object carries, once — a series and its overrides are
|
|
60
|
-
// one object with one uid.
|
|
61
|
-
const uidsOf = (object) => [
|
|
62
|
-
...new Set(parseEvents(object.data).map((e) => e.uid)),
|
|
63
|
-
];
|
|
64
|
-
const indexByUid = (listings) => {
|
|
65
|
-
const index = new Map();
|
|
66
|
-
for (const { calendar, objects } of listings) {
|
|
67
|
-
for (const object of objects) {
|
|
68
|
-
for (const uid of uidsOf(object)) {
|
|
69
|
-
index.set(uid, [...(index.get(uid) ?? []), { calendar, object }]);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return index;
|
|
74
|
-
};
|
|
75
|
-
// The last path segment, copied verbatim from the href the listing returned.
|
|
76
|
-
// Never decoded or re-encoded: Stalwart treats `@` and `%40` in a resource
|
|
77
|
-
// name as two different resources, so a normalized spelling can move a
|
|
78
|
-
// different event.
|
|
79
|
-
const resourceName = (url) => url.slice(url.lastIndexOf("/") + 1);
|
|
80
|
-
const quotedNames = (calendars) => calendars.map((c) => `"${calendarLabel(c)}"`).join(" and ");
|
|
81
|
-
// With URLs, so the next call can pass fromCalendar even when two calendars share a name.
|
|
82
|
-
const namesWithUrls = (calendars) => calendars.map((c) => `"${calendarLabel(c)}" <${c.url}>`).join(" and ");
|
|
83
|
-
// An ATTENDEE the parser had to drop (a non-mailto cal-address) is still a
|
|
84
|
-
// person the server will mail a CANCEL to, so it counts — as it does in
|
|
85
|
-
// update_calendar_event's merge-safety check.
|
|
86
|
-
const hasAttendees = (object) => parseEvents(object.data).some((e) => e.attendees.length > 0 || (e.unparsedAttendeeCount ?? 0) > 0);
|
|
87
|
-
// A uid in both the destination and a source is two stored events, not one.
|
|
88
|
-
// delete_calendar_event looks in one calendar only (the default one unless
|
|
89
|
-
// given calendarUrl), so the remedy names both URLs and the argument. It is
|
|
90
|
-
// also outward-destructive: attendees resolve its CANCEL by uid, which both
|
|
91
|
-
// copies share, so deleting either one cancels the meeting for all of them.
|
|
92
|
-
// Either copy may be the organized meeting, so both sides are checked.
|
|
93
|
-
const duplicateRemedy = (dest, others, destCopies) => {
|
|
94
|
-
const cancels = [...others, ...destCopies].some((l) => hasAttendees(l.object))
|
|
95
|
-
? ". Warn the user first: the event has attendees and both copies share one uid, so deleting either " +
|
|
96
|
-
"copy cancels the meeting for all of them"
|
|
97
|
-
: "";
|
|
98
|
-
return (`"${calendarLabel(dest)}" <${dest.url}> already holds a separate copy of this event, and ` +
|
|
99
|
-
`${namesWithUrls(others.map((l) => l.calendar))} still ${others.length > 1 ? "hold" : "holds"} one; ask the ` +
|
|
100
|
-
`user which copy to keep and delete the other with delete_calendar_event, passing its calendar URL as calendarUrl${cancels}`);
|
|
101
|
-
};
|
|
102
|
-
const failedReason = (status) => {
|
|
103
|
-
if (status === 0) {
|
|
104
|
-
return "failed: the server gave no answer; re-run to retry";
|
|
105
|
-
}
|
|
106
|
-
// The destination came from the listing, so a 409 means it was deleted since.
|
|
107
|
-
if (status === 409) {
|
|
108
|
-
return "failed: the destination calendar no longer exists; check it with list_calendars";
|
|
109
|
-
}
|
|
110
|
-
return `failed: the server answered HTTP ${status}; re-run to retry`;
|
|
111
|
-
};
|
|
112
|
-
const refusalReason = (outcome, source, dest) => {
|
|
113
|
-
switch (outcome.kind) {
|
|
114
|
-
case "uidConflict":
|
|
115
|
-
// The destination held no copy when it was listed, so only the source is known.
|
|
116
|
-
return `uidConflict: ${duplicateRemedy(dest, [source], [])}`;
|
|
117
|
-
case "nameConflict":
|
|
118
|
-
return `nameConflict: "${calendarLabel(dest)}" already has an event stored under the same name; this cannot be resolved with these tools`;
|
|
119
|
-
case "forbidden":
|
|
120
|
-
return "forbidden: this account may not move events between these calendars";
|
|
121
|
-
default:
|
|
122
|
-
return failedReason(outcome.status);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const moveOne = async (deps, token, source, dest) => {
|
|
126
|
-
try {
|
|
127
|
-
const outcome = await deps.moveEvent({
|
|
128
|
-
destination: `${withTrailingSlash(dest.url)}${resourceName(source.object.url)}`,
|
|
129
|
-
token,
|
|
130
|
-
url: source.object.url,
|
|
131
|
-
});
|
|
132
|
-
return outcome.kind === "moved"
|
|
133
|
-
? outcome
|
|
134
|
-
: { kind: "notMoved", reason: refusalReason(outcome, source, dest) };
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
// davRequest never throws on an HTTP status, only when the exchange broke
|
|
138
|
-
// off (a timeout, a dropped connection) — possibly after Stalwart had
|
|
139
|
-
// already committed the move. So the outcome is unknown, never "not moved".
|
|
140
|
-
// Returned in-band, so log it here to keep it diagnosable.
|
|
141
|
-
logger.warn({ ...describeError(error), tool: TOOL_NAME }, "calendar event MOVE broke off; outcome unknown");
|
|
142
|
-
return { kind: "indeterminate" };
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const formatResult = (dest, outcomes, unreadable) => {
|
|
146
|
-
const name = calendarLabel(dest);
|
|
147
|
-
const of = (kind) => outcomes.filter((o) => o[1].kind === kind);
|
|
148
|
-
const moved = of("moved");
|
|
149
|
-
const already = of("alreadyThere");
|
|
150
|
-
const notMoved = of("notMoved");
|
|
151
|
-
const indeterminate = of("indeterminate");
|
|
152
|
-
const notAttempted = of("notAttempted");
|
|
153
|
-
const lines = [`Moved ${moved.length} event(s) to ${name}.`];
|
|
154
|
-
if (already.length > 0) {
|
|
155
|
-
// With a calendar unread, "nowhere else" was only checked where it could be.
|
|
156
|
-
const scope = unreadable.length > 0 ? " (no other readable calendar holds these)" : "";
|
|
157
|
-
lines.push(`Already in ${name} (${already.length}): ${already.map(([uid]) => uid).join(", ")}${scope}.`);
|
|
158
|
-
}
|
|
159
|
-
if (notMoved.length > 0) {
|
|
160
|
-
lines.push(`Not moved (${notMoved.length}): ${notMoved.map(([uid, o]) => `${uid} (${o.reason})`).join(", ")}.`);
|
|
161
|
-
}
|
|
162
|
-
if (indeterminate.length > 0) {
|
|
163
|
-
lines.push(`Outcome unknown (${indeterminate.length}): ${indeterminate.map(([uid]) => uid).join(", ")} — the connection ` +
|
|
164
|
-
"broke off before the server answered, so they may have moved. Re-run with these uids to find out.");
|
|
165
|
-
}
|
|
166
|
-
if (notAttempted.length > 0) {
|
|
167
|
-
lines.push(`Not attempted (${notAttempted.length}): ${notAttempted.map(([uid]) => uid).join(", ")} — out of time. ` +
|
|
168
|
-
"Re-run with these uids.");
|
|
169
|
-
}
|
|
170
|
-
if (unreadable.length > 0) {
|
|
171
|
-
lines.push(`Could not read ${quotedNames(unreadable)}, so events there were not found; re-run later, or pass ` +
|
|
172
|
-
"fromCalendar to look in one calendar only.");
|
|
173
|
-
}
|
|
174
|
-
const text = lines.join("\n");
|
|
175
|
-
// A partial batch is a normal result; only a call that certainly achieved
|
|
176
|
-
// nothing is an error — an unknown outcome may have been a move.
|
|
177
|
-
return moved.length + already.length + indeterminate.length === 0
|
|
178
|
-
? errorResult(text)
|
|
179
|
-
: textResult(text);
|
|
180
|
-
};
|
|
181
|
-
// The calendars to look in: only fromCalendar when given, else every calendar
|
|
182
|
-
// but the destination. fetchCalendarList reads the principal's own calendar
|
|
183
|
-
// home only, so every source and destination belongs to this account — the
|
|
184
|
-
// case the silent, copy-free MOVE is verified for.
|
|
185
|
-
const resolveSources = (calendars, dest, fromCalendar) => {
|
|
186
|
-
if (fromCalendar === undefined) {
|
|
187
|
-
return {
|
|
188
|
-
ok: true,
|
|
189
|
-
value: {
|
|
190
|
-
sources: calendars.filter((c) => !sameCalendarUrl(c.url, dest.url)),
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
const resolved = resolveCalendar(calendars, fromCalendar, {
|
|
195
|
-
argName: "fromCalendar",
|
|
196
|
-
nothingDone: NOTHING_MOVED,
|
|
197
|
-
});
|
|
198
|
-
if (!resolved.ok) {
|
|
199
|
-
return resolved;
|
|
200
|
-
}
|
|
201
|
-
if (sameCalendarUrl(resolved.calendar.url, dest.url)) {
|
|
202
|
-
return {
|
|
203
|
-
error: errorResult(`fromCalendar and calendar both name "${calendarLabel(dest)}". ${NOTHING_MOVED} ` +
|
|
204
|
-
"Pass the calendar the events are in now as fromCalendar, or omit it."),
|
|
205
|
-
ok: false,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
return {
|
|
209
|
-
ok: true,
|
|
210
|
-
value: { from: resolved.calendar, sources: [resolved.calendar] },
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
// Lists every calendar involved once, in parallel, in full. A calendar-query
|
|
214
|
-
// REPORT filtered on UID would fetch only the matching objects; the full
|
|
215
|
-
// listing reuses fetchEvents and is fine at the scale of one person's
|
|
216
|
-
// calendars, but its cost grows with every calendar's history, and on an
|
|
217
|
-
// account slow enough to spend the whole budget here, every uid is reported
|
|
218
|
-
// as not attempted on every re-run. Switch to the filtered REPORT if that
|
|
219
|
-
// shows up.
|
|
220
|
-
//
|
|
221
|
-
// The destination is always listed: an event already there is a success,
|
|
222
|
-
// which makes a repeated call a no-op. Without it nothing can be decided, but
|
|
223
|
-
// one unreadable source must not block moves out of the others.
|
|
224
|
-
const listCalendarsInvolved = async (deps, token, dest, sources) => {
|
|
225
|
-
const [destListing, ...sourceResults] = await Promise.allSettled([dest, ...sources].map((calendar) => deps.listEvents(token, calendar.url)));
|
|
226
|
-
if (destListing?.status !== "fulfilled") {
|
|
227
|
-
const reason = destListing?.reason instanceof Error
|
|
228
|
-
? destListing.reason.message
|
|
229
|
-
: String(destListing?.reason);
|
|
230
|
-
return {
|
|
231
|
-
error: errorResult(`Could not read "${calendarLabel(dest)}": ${reason}. ${NOTHING_MOVED} Re-run later.`),
|
|
232
|
-
ok: false,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
const readable = sources.flatMap((calendar, i) => {
|
|
236
|
-
const r = sourceResults[i];
|
|
237
|
-
return r?.status === "fulfilled" ? [{ calendar, objects: r.value }] : [];
|
|
238
|
-
});
|
|
239
|
-
return {
|
|
240
|
-
ok: true,
|
|
241
|
-
value: {
|
|
242
|
-
inDest: indexByUid([{ calendar: dest, objects: destListing.value }]),
|
|
243
|
-
index: indexByUid(readable),
|
|
244
|
-
unreadable: sources.filter((_, i) => sourceResults[i]?.status !== "fulfilled"),
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
// The outcome decided without touching the server, or the one location to
|
|
249
|
-
// move from. The first rule that applies wins, in this order.
|
|
250
|
-
const decide = (uid, listed, dest, from) => {
|
|
251
|
-
const locations = listed.index.get(uid) ?? [];
|
|
252
|
-
const destCopies = listed.inDest.get(uid);
|
|
253
|
-
if (destCopies) {
|
|
254
|
-
// Only a uid that has left every source is done; one still in a source
|
|
255
|
-
// is a duplicate, and calling it done would leave that copy behind.
|
|
256
|
-
return locations.length === 0
|
|
257
|
-
? { kind: "alreadyThere" }
|
|
258
|
-
: {
|
|
259
|
-
kind: "notMoved",
|
|
260
|
-
reason: `duplicate: ${duplicateRemedy(dest, locations, destCopies)}`,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
const [only] = locations;
|
|
264
|
-
if (!only) {
|
|
265
|
-
const where = from
|
|
266
|
-
? `not in "${calendarLabel(from)}"`
|
|
267
|
-
: "in none of your calendars";
|
|
268
|
-
return {
|
|
269
|
-
kind: "notMoved",
|
|
270
|
-
reason: `notFound: ${where}; check the uid with list_calendar_events`,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
if (locations.length > 1) {
|
|
274
|
-
const reason = `ambiguous: in ${namesWithUrls(locations.map((l) => l.calendar))}; pass one as fromCalendar`;
|
|
275
|
-
return { kind: "notMoved", reason };
|
|
276
|
-
}
|
|
277
|
-
return only;
|
|
278
|
-
};
|
|
279
|
-
export const moveCalendarEvents = async (deps, ctx) => {
|
|
280
|
-
const { args, token } = ctx;
|
|
281
|
-
const started = deps.now();
|
|
282
|
-
const calendars = await deps.listCalendars(token);
|
|
283
|
-
const destResolved = resolveCalendar(calendars, args.calendar, {
|
|
284
|
-
argName: "calendar",
|
|
285
|
-
nothingDone: NOTHING_MOVED,
|
|
286
|
-
});
|
|
287
|
-
if (!destResolved.ok) {
|
|
288
|
-
return destResolved.error;
|
|
289
|
-
}
|
|
290
|
-
const dest = destResolved.calendar;
|
|
291
|
-
const sources = resolveSources(calendars, dest, args.fromCalendar);
|
|
292
|
-
if (!sources.ok) {
|
|
293
|
-
return sources.error;
|
|
294
|
-
}
|
|
295
|
-
const listed = await listCalendarsInvolved(deps, token, dest, sources.value.sources);
|
|
296
|
-
if (!listed.ok) {
|
|
297
|
-
return listed.error;
|
|
298
|
-
}
|
|
299
|
-
const outcomes = [];
|
|
300
|
-
for (const uid of args.uids) {
|
|
301
|
-
const decided = decide(uid, listed.value, dest, sources.value.from);
|
|
302
|
-
if ("kind" in decided) {
|
|
303
|
-
outcomes.push([uid, decided]);
|
|
304
|
-
}
|
|
305
|
-
else if (deps.now() - started >= MOVE_BUDGET_MS) {
|
|
306
|
-
outcomes.push([uid, { kind: "notAttempted" }]);
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
outcomes.push([uid, await moveOne(deps, token, decided, dest)]);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return formatResult(dest, outcomes, listed.value.unreadable);
|
|
313
|
-
};
|
|
314
|
-
// --- live-deps wiring ----------------------------------------------------
|
|
315
|
-
export const makeLiveDeps = (cfg) => ({
|
|
316
|
-
listCalendars: (token) => fetchCalendarList(cfg, token),
|
|
317
|
-
listEvents: (token, calendarUrl) => fetchEvents(cfg, { calendarUrl, token }),
|
|
318
|
-
moveEvent: (params) => moveEvent(cfg, params),
|
|
319
|
-
now: () => Date.now(),
|
|
320
|
-
});
|
|
321
|
-
// --- MCP registration ----------------------------------------------------
|
|
322
|
-
export const registerMoveCalendarEvents = (server, deps,
|
|
323
|
-
// Bearer threaded per request — see mcp/handler.ts.
|
|
324
|
-
getToken) => {
|
|
325
|
-
server.registerTool(TOOL_NAME, {
|
|
326
|
-
annotations: ACCOUNT_WRITE,
|
|
327
|
-
description: 'Moves events from one of the user’s calendars to another — for example into a new "Private" ' +
|
|
328
|
-
"calendar — without changing their time or content. Use this when the user wants events filed " +
|
|
329
|
-
"on a different calendar; to change when an event happens (“move the meeting to 3 pm”), use " +
|
|
330
|
-
"update_calendar_event instead. Events keep their uid, attendees, reminders and every " +
|
|
331
|
-
"occurrence of a recurring series, and attendees are not notified. Returns how many events " +
|
|
332
|
-
"moved and names each one that did not, with the reason; the destination calendar must " +
|
|
333
|
-
"already exist (create one with create_calendar). Safe to re-run.",
|
|
334
|
-
inputSchema: z.object(moveCalendarEventsShape),
|
|
335
|
-
title: "Move calendar events",
|
|
336
|
-
}, (args) => moveCalendarEvents(deps, {
|
|
337
|
-
args: moveCalendarEventsInput.parse(args),
|
|
338
|
-
token: getToken(),
|
|
339
|
-
}));
|
|
340
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// move_emails tool — file messages into a named folder. A move is a wholesale
|
|
2
|
-
// replacement of the mailbox set (the whole RFC 8621 `mailboxIds` property,
|
|
3
|
-
// via emailSetMailboxes — a pointer patch can only add or drop the ids it
|
|
4
|
-
// names, never "and remove everything else"), which is what every JMAP
|
|
5
|
-
// client means by "move". Trash is refused here — by resolved id, so a
|
|
6
|
-
// localized trash-role folder cannot slip through, and by place name, so a
|
|
7
|
-
// role-less folder called "Trash" cannot either — so this tool can stay a
|
|
8
|
-
// non-destructive write; trash_emails carries that annotation.
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import { roleForPlaceName } from "../jmap/index.js";
|
|
11
|
-
import { ACCOUNT_WRITE } from "./annotations.js";
|
|
12
|
-
import { dedupedIds, formatBatchResult, idsShape, } from "./file-emails-common.js";
|
|
13
|
-
import { errorResult } from "./result.js";
|
|
14
|
-
const moveEmailsShape = {
|
|
15
|
-
...idsShape,
|
|
16
|
-
mailbox: z
|
|
17
|
-
.string()
|
|
18
|
-
.min(1)
|
|
19
|
-
.max(200)
|
|
20
|
-
.describe("Destination folder. The standard places — Inbox, Archive, Sent, Drafts, Junk — resolve to " +
|
|
21
|
-
"the folder holding that role whatever the server calls it; any other value must match an " +
|
|
22
|
-
"existing folder name exactly (case-insensitive). Folders are never created. Trash is not " +
|
|
23
|
-
"accepted here: use trash_emails."),
|
|
24
|
-
};
|
|
25
|
-
export const moveEmailsInput = z.object({
|
|
26
|
-
...moveEmailsShape,
|
|
27
|
-
ids: dedupedIds,
|
|
28
|
-
});
|
|
29
|
-
export const moveEmails = async (deps, ctx) => {
|
|
30
|
-
const { ids, mailbox } = ctx.args;
|
|
31
|
-
const trashRefusal = errorResult(`Moving to ${mailbox} is a delete. Use trash_emails instead. Nothing was moved.`);
|
|
32
|
-
if (roleForPlaceName(mailbox) === "trash") {
|
|
33
|
-
return trashRefusal;
|
|
34
|
-
}
|
|
35
|
-
const lookup = await deps.resolveMailbox(ctx.token, mailbox);
|
|
36
|
-
if (!lookup.id) {
|
|
37
|
-
const available = lookup.available.length > 0
|
|
38
|
-
? ` Available folders: ${lookup.available.join(", ")}.`
|
|
39
|
-
: "";
|
|
40
|
-
return errorResult(`Mailbox not found: ${mailbox}. Nothing was moved.${available}`);
|
|
41
|
-
}
|
|
42
|
-
const places = await deps.resolvePlaces(ctx.token);
|
|
43
|
-
if (lookup.id === places.trash) {
|
|
44
|
-
return trashRefusal;
|
|
45
|
-
}
|
|
46
|
-
const result = await deps.replaceMailboxes(ctx.token, ids, lookup.id);
|
|
47
|
-
return formatBatchResult("Moved", result, ` to ${mailbox}`);
|
|
48
|
-
};
|
|
49
|
-
// --- MCP registration ----------------------------------------------------
|
|
50
|
-
export const registerMoveEmails = (server, deps, getToken) => {
|
|
51
|
-
server.registerTool("move_emails", {
|
|
52
|
-
annotations: ACCOUNT_WRITE,
|
|
53
|
-
description: "Move one or more messages into a folder. They are removed from every folder they were in " +
|
|
54
|
-
'and end up only in the destination. Use this when the user names a destination ("put this ' +
|
|
55
|
-
'in Projects", "move it back to the inbox"). Takes message ids from search_emails or ' +
|
|
56
|
-
"get_thread. The mailbox is resolved the same way as the search_emails mailbox filter and is " +
|
|
57
|
-
"never created; an unknown name returns the folders that exist. Read state and flags (to-do, " +
|
|
58
|
-
"starred) are untouched; use mark_emails to change them. Re-running it on the same " +
|
|
59
|
-
"ids is harmless. To archive use archive_emails; to delete use trash_emails — this tool " +
|
|
60
|
-
"refuses Trash. Reports how many messages moved and lists any id the server refused.",
|
|
61
|
-
inputSchema: z.object(moveEmailsShape),
|
|
62
|
-
title: "Move emails",
|
|
63
|
-
}, (args) => moveEmails(deps, { args: moveEmailsInput.parse(args), token: getToken() }));
|
|
64
|
-
};
|