@wirecat/mail-cli 0.28.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/CHANGELOG.md +19 -0
- package/dist/bin/mail.js +2 -2
- package/dist/bundle/{app-server-XS7ABUNU.js → app-server-E44CAPPI.js} +8 -8
- package/dist/bundle/{chunk-54ZEOOL7.js → chunk-7AO73MJZ.js} +2 -2
- package/dist/bundle/{chunk-EVO4FGYJ.js → chunk-BPHLFSUO.js} +3 -3
- package/dist/bundle/{chunk-TVMBGHUW.js → chunk-DIOHJT2W.js} +2 -2
- package/dist/bundle/{chunk-LY2QIBFL.js → chunk-FDGCTY6J.js} +1 -1
- package/dist/bundle/{chunk-TV6OJBK6.js → chunk-KTLJ6F2B.js} +1 -1
- package/dist/bundle/{chunk-HFROBAHY.js → chunk-NWA7JS74.js} +1 -1
- package/dist/bundle/{chunk-YE464BDT.js → chunk-RFM3AAK5.js} +3 -3
- package/dist/bundle/{chunk-D6VV655V.js → chunk-RGIEG4XK.js} +2 -1
- package/dist/bundle/{chunk-IUIL6OQY.js → chunk-UH7FYLFL.js} +2 -2
- package/dist/bundle/{chunk-4CRO7EHW.js → chunk-VERUQQZS.js} +2 -2
- package/dist/bundle/{chunk-DZYGVA6V.js → chunk-W32UQL5I.js} +4 -4
- package/dist/bundle/{chunk-HYMSFNTS.js → chunk-WSHPLO4Q.js} +1 -0
- package/dist/bundle/{chunk-P7TVXYJZ.js → chunk-YRER6N3Y.js} +7 -7
- package/dist/bundle/{command-contract-4PTK23CK.js → command-contract-TMLXLGVT.js} +2 -2
- package/dist/bundle/{command-server-entry-KSAHRZOO.js → command-server-entry-PFUR2W7X.js} +3 -3
- package/dist/bundle/{first-run-4XEWECC3.js → first-run-LU2MAK2B.js} +1 -1
- package/dist/bundle/{first-screen-YI2YNTYY.js → first-screen-KZNLKRRQ.js} +3 -3
- package/dist/bundle/mail.js +2 -2
- package/dist/bundle/{program-UXFXSGIW.js → program-OE7MFRMJ.js} +166 -56
- package/dist/bundle/{server-DF2SECWB.js → server-D5OTVERP.js} +8 -8
- package/dist/bundle/{server-OQV2MVCA.js → server-DBS4WC6T.js} +4 -4
- package/dist/bundle/{store-maintenance-command-4TW6FABJ.js → store-maintenance-command-SH6IB7S6.js} +4 -4
- package/dist/commands/rules.d.ts.map +1 -1
- package/dist/commands/rules.js +78 -20
- package/dist/commands/rules.js.map +1 -1
- package/dist/commands/words.d.ts.map +1 -1
- package/dist/commands/words.js +2 -0
- package/dist/commands/words.js.map +1 -1
- package/dist/mail/imap/connection.d.ts.map +1 -1
- package/dist/mail/imap/connection.js +10 -2
- package/dist/mail/imap/connection.js.map +1 -1
- package/dist/mail/rules/apply.d.ts +10 -2
- package/dist/mail/rules/apply.d.ts.map +1 -1
- package/dist/mail/rules/apply.js +110 -30
- package/dist/mail/rules/apply.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +1 -0
- package/dist/reasons.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
enterCommandServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-DIOHJT2W.js";
|
|
6
6
|
import "./chunk-KSFPMRH6.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_LINK_CONFIG,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
syncsFirst,
|
|
60
60
|
taskStatsAnswer,
|
|
61
61
|
waitingAnswer
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-W32UQL5I.js";
|
|
63
63
|
import {
|
|
64
64
|
readsStdin
|
|
65
65
|
} from "./chunk-ODPYXNHI.js";
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
skillStatus,
|
|
74
74
|
skillVersion,
|
|
75
75
|
withVersion
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-FDGCTY6J.js";
|
|
77
77
|
import {
|
|
78
78
|
INPUT_FIELD_REASONS,
|
|
79
79
|
failureContext
|
|
@@ -138,7 +138,7 @@ import {
|
|
|
138
138
|
writeRepliesFile,
|
|
139
139
|
writeRepliesState,
|
|
140
140
|
writeReplyConsent
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-RFM3AAK5.js";
|
|
142
142
|
import {
|
|
143
143
|
renderMessages
|
|
144
144
|
} from "./chunk-3AH7UEM6.js";
|
|
@@ -156,7 +156,7 @@ import {
|
|
|
156
156
|
refuseUnknownPermissionKeys,
|
|
157
157
|
terminalAsker,
|
|
158
158
|
unknownPermissionIssues
|
|
159
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-7AO73MJZ.js";
|
|
160
160
|
import {
|
|
161
161
|
ADMIN_RIGHTS,
|
|
162
162
|
AGENDA_DEFAULTS,
|
|
@@ -372,7 +372,7 @@ import {
|
|
|
372
372
|
writeHarderSetting,
|
|
373
373
|
writeHarderTimeout,
|
|
374
374
|
writePictureReading
|
|
375
|
-
} from "./chunk-
|
|
375
|
+
} from "./chunk-NWA7JS74.js";
|
|
376
376
|
import {
|
|
377
377
|
acquireLock,
|
|
378
378
|
readBoundedUtf8File,
|
|
@@ -407,13 +407,13 @@ import {
|
|
|
407
407
|
} from "./chunk-FHQ32JKS.js";
|
|
408
408
|
import {
|
|
409
409
|
installHelp
|
|
410
|
-
} from "./chunk-
|
|
410
|
+
} from "./chunk-UH7FYLFL.js";
|
|
411
411
|
import {
|
|
412
412
|
SCHEMA_DIALECT,
|
|
413
413
|
commandContract,
|
|
414
414
|
commandPathOf,
|
|
415
415
|
findCommand
|
|
416
|
-
} from "./chunk-
|
|
416
|
+
} from "./chunk-KTLJ6F2B.js";
|
|
417
417
|
import "./chunk-HTQTIKWP.js";
|
|
418
418
|
import {
|
|
419
419
|
Argument,
|
|
@@ -570,6 +570,7 @@ import {
|
|
|
570
570
|
repairConfigText,
|
|
571
571
|
rootOf,
|
|
572
572
|
rootOf2,
|
|
573
|
+
runBudget,
|
|
573
574
|
runBudgetOf,
|
|
574
575
|
runnable,
|
|
575
576
|
sampleCommand,
|
|
@@ -608,7 +609,7 @@ import {
|
|
|
608
609
|
withLines,
|
|
609
610
|
withoutPath,
|
|
610
611
|
withoutProviderRefs
|
|
611
|
-
} from "./chunk-
|
|
612
|
+
} from "./chunk-WSHPLO4Q.js";
|
|
612
613
|
import {
|
|
613
614
|
AUTHORITY_KEY,
|
|
614
615
|
BOT_API_KEY,
|
|
@@ -635,7 +636,7 @@ import {
|
|
|
635
636
|
} from "./chunk-7ESXP4TG.js";
|
|
636
637
|
import {
|
|
637
638
|
setupAtStart
|
|
638
|
-
} from "./chunk-
|
|
639
|
+
} from "./chunk-VERUQQZS.js";
|
|
639
640
|
import {
|
|
640
641
|
isNewer,
|
|
641
642
|
latestVersion,
|
|
@@ -826,7 +827,7 @@ import {
|
|
|
826
827
|
IDENTITY,
|
|
827
828
|
PACKAGE,
|
|
828
829
|
SKILL
|
|
829
|
-
} from "./chunk-
|
|
830
|
+
} from "./chunk-RGIEG4XK.js";
|
|
830
831
|
import {
|
|
831
832
|
installerOf
|
|
832
833
|
} from "./chunk-M4OP5ASJ.js";
|
|
@@ -8090,11 +8091,11 @@ var messengerHost = /* @__PURE__ */ __name((messenger) => ({
|
|
|
8090
8091
|
context: /* @__PURE__ */ __name((self, options) => messengerContext(self, messenger, options), "context"),
|
|
8091
8092
|
permissionExample: "messages.send=deny",
|
|
8092
8093
|
serveStdio: /* @__PURE__ */ __name(async (self, context) => {
|
|
8093
|
-
const { serveOverStdio } = await import("./server-
|
|
8094
|
+
const { serveOverStdio } = await import("./server-D5OTVERP.js");
|
|
8094
8095
|
await serveOverStdio(self, context, messenger, {});
|
|
8095
8096
|
}, "serveStdio"),
|
|
8096
8097
|
serveHttp: /* @__PURE__ */ __name(async (self, context, http2) => {
|
|
8097
|
-
const { serveOverHttpUntilStopped } = await import("./server-
|
|
8098
|
+
const { serveOverHttpUntilStopped } = await import("./server-D5OTVERP.js");
|
|
8098
8099
|
await serveOverHttpUntilStopped(self, context, messenger, {}, http2);
|
|
8099
8100
|
}, "serveHttp"),
|
|
8100
8101
|
instructions: /* @__PURE__ */ __name(async (profiles) => {
|
|
@@ -13808,12 +13809,12 @@ var appMcpCommand = /* @__PURE__ */ __name((app2, configuration2, options) => {
|
|
|
13808
13809
|
permissionExample: options.permissionExample,
|
|
13809
13810
|
serveStdio: /* @__PURE__ */ __name(async (self, context) => {
|
|
13810
13811
|
checked3(self, context);
|
|
13811
|
-
const { serveAppOverStdio } = await import("./app-server-
|
|
13812
|
+
const { serveAppOverStdio } = await import("./app-server-E44CAPPI.js");
|
|
13812
13813
|
await serveAppOverStdio(self, context, server());
|
|
13813
13814
|
}, "serveStdio"),
|
|
13814
13815
|
serveHttp: /* @__PURE__ */ __name(async (self, context, http2) => {
|
|
13815
13816
|
checked3(self, context);
|
|
13816
|
-
const { serveAppOverHttp } = await import("./app-server-
|
|
13817
|
+
const { serveAppOverHttp } = await import("./app-server-E44CAPPI.js");
|
|
13817
13818
|
await serveAppOverHttp(self, context, server(), http2);
|
|
13818
13819
|
}, "serveHttp"),
|
|
13819
13820
|
instructions: /* @__PURE__ */ __name(async (profiles) => {
|
|
@@ -14401,7 +14402,7 @@ var botMcpCommand = /* @__PURE__ */ __name((bot) => {
|
|
|
14401
14402
|
const mcp = bot.mcp;
|
|
14402
14403
|
if (!mcp)
|
|
14403
14404
|
throw new Error("bot mcp is mounted only with BotMessenger.mcp");
|
|
14404
|
-
const [{ serveBotOverStdio }, run4] = await Promise.all([import("./server-
|
|
14405
|
+
const [{ serveBotOverStdio }, run4] = await Promise.all([import("./server-DBS4WC6T.js"), mcp.program()]);
|
|
14405
14406
|
await serveBotOverStdio({
|
|
14406
14407
|
bot,
|
|
14407
14408
|
program: { run: run4, commands: describeProgram(rootOf2(this)) },
|
|
@@ -37377,12 +37378,16 @@ var imapConnections = /* @__PURE__ */ __name((endpoint2, credential, tuning = {}
|
|
|
37377
37378
|
const limited = /* @__PURE__ */ __name(async (slot, work) => {
|
|
37378
37379
|
const left = timeLeftMs?.();
|
|
37379
37380
|
const ms = left === void 0 ? requestTimeoutMs : Math.max(1, Math.min(requestTimeoutMs, left));
|
|
37381
|
+
const ranOut = left !== void 0 && left < requestTimeoutMs;
|
|
37380
37382
|
let cancel = /* @__PURE__ */ __name(() => {
|
|
37381
37383
|
}, "cancel");
|
|
37382
37384
|
const expired = new Promise((_2, reject) => {
|
|
37383
37385
|
cancel = expireAfter(ms, () => {
|
|
37384
37386
|
drop(slot);
|
|
37385
|
-
reject(
|
|
37387
|
+
reject(ranOut ? new CliError("timeout", "the command reached its time limit before the mail server finished", {
|
|
37388
|
+
reason: "command.timed-out",
|
|
37389
|
+
retryable: false
|
|
37390
|
+
}) : Object.assign(new Error("request timed out"), { code: "RequestTimeout" }));
|
|
37386
37391
|
});
|
|
37387
37392
|
});
|
|
37388
37393
|
work.catch(() => {
|
|
@@ -37421,7 +37426,7 @@ var imapConnections = /* @__PURE__ */ __name((endpoint2, credential, tuning = {}
|
|
|
37421
37426
|
return await command();
|
|
37422
37427
|
} catch (raw) {
|
|
37423
37428
|
const error2 = mapImapError(raw);
|
|
37424
|
-
const transient = error2.code === "network_error" || error2.code === "timeout" || error2.code === "provider_unavailable";
|
|
37429
|
+
const transient = (error2.code === "network_error" || error2.code === "timeout" || error2.code === "provider_unavailable") && error2.details.retryable !== false;
|
|
37425
37430
|
if (transient)
|
|
37426
37431
|
drop(slot);
|
|
37427
37432
|
if (!transient || closed || attempt >= maxAttempts || signal?.aborted)
|
|
@@ -37940,6 +37945,8 @@ var WORDS = {
|
|
|
37940
37945
|
"mail.profile-exists": /* @__PURE__ */ __name((message2) => `${message2}; pass --replace to overwrite it`, "mail.profile-exists"),
|
|
37941
37946
|
"download.exists": /* @__PURE__ */ __name((message2) => `${message2}; pass --replace to overwrite it`, "download.exists"),
|
|
37942
37947
|
"mail.server-unknown": /* @__PURE__ */ __name((message2) => `${message2}; pass --provider (${PROVIDER_NAMES.join(", ")}), or --host, --port and --security yourself`, "mail.server-unknown"),
|
|
37948
|
+
"mail.cursor-foreign": /* @__PURE__ */ __name((message2) => `--cursor: ${message2}; run it again without --cursor`, "mail.cursor-foreign"),
|
|
37949
|
+
"command.timed-out": /* @__PURE__ */ __name((message2) => `${message2}; run it again with a longer --timeout, such as --timeout 30m`, "command.timed-out"),
|
|
37943
37950
|
"mail.export-other": /* @__PURE__ */ __name((message2) => `${message2}; resume it with the same --format and profile`, "mail.export-other"),
|
|
37944
37951
|
"mail.export-destination-exists": /* @__PURE__ */ __name((message2, _profile, error2) => error2.details.resumable === true ? `${message2}; --resume goes on with it, --replace starts over in it` : `${message2}; --replace writes into it anyway, over files of the same name`, "mail.export-destination-exists")
|
|
37945
37952
|
};
|
|
@@ -47764,12 +47771,42 @@ var readCommands = /* @__PURE__ */ __name(() => {
|
|
|
47764
47771
|
import { readFileSync as readFileSync30 } from "node:fs";
|
|
47765
47772
|
|
|
47766
47773
|
// dist/mail/rules/apply.js
|
|
47774
|
+
var cursorOf3 = /* @__PURE__ */ __name((position) => Buffer.from(JSON.stringify(position)).toString("base64url"), "cursorOf");
|
|
47775
|
+
var positionOf = /* @__PURE__ */ __name((cursor, folders, apply) => {
|
|
47776
|
+
const refuse = /* @__PURE__ */ __name(() => new CliError("validation_error", "this cursor is not one a stopped run gave for these folders and this mode", {
|
|
47777
|
+
param: "cursor",
|
|
47778
|
+
reason: "mail.cursor-foreign"
|
|
47779
|
+
}), "refuse");
|
|
47780
|
+
let position;
|
|
47781
|
+
try {
|
|
47782
|
+
position = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
47783
|
+
} catch {
|
|
47784
|
+
throw refuse();
|
|
47785
|
+
}
|
|
47786
|
+
if (typeof position?.folder !== "string" || typeof position.below !== "number" || typeof position.totals !== "object" || position.applied !== apply || !folders.includes(position.folder))
|
|
47787
|
+
throw refuse();
|
|
47788
|
+
return position;
|
|
47789
|
+
}, "positionOf");
|
|
47790
|
+
var storedAggregates = /* @__PURE__ */ __name(async (store, accountId, rules, since) => {
|
|
47791
|
+
const from = since.toISOString();
|
|
47792
|
+
const stored2 = (await store.mail.emailFacts({ accountId })).map((email) => {
|
|
47793
|
+
const item = listedOf(email);
|
|
47794
|
+
return email.outgoing && !item.labels?.includes("Sent") ? { ...item, labels: [...item.labels ?? [], "Sent"] } : item;
|
|
47795
|
+
}).filter((item) => item.receivedAt >= from);
|
|
47796
|
+
const known = new Map(stored2.map((item) => [item.messageId, item]));
|
|
47797
|
+
const factsFor = factsOf(stored2, rules);
|
|
47798
|
+
return (item) => {
|
|
47799
|
+
const { score, replied } = factsFor(known.get(item.messageId) ?? item);
|
|
47800
|
+
return { ...item, ...score === void 0 ? {} : { score }, ...replied === void 0 ? {} : { replied } };
|
|
47801
|
+
};
|
|
47802
|
+
}, "storedAggregates");
|
|
47767
47803
|
var textBytes = /* @__PURE__ */ __name((text6) => text6 ? Buffer.byteLength(text6) : 0, "textBytes");
|
|
47768
|
-
var applyRules = /* @__PURE__ */ __name(async ({ store, source, account, folders, since, apply, now = Date.now }) => {
|
|
47804
|
+
var applyRules = /* @__PURE__ */ __name(async ({ store, source, account, folders, since, apply, cursor, take = /* @__PURE__ */ __name(() => null, "take"), now = Date.now }) => {
|
|
47769
47805
|
const startedAt = now();
|
|
47770
47806
|
const key = { provider: "email", account: account.address.toLowerCase() };
|
|
47771
47807
|
const rules = account.rules ?? [];
|
|
47772
47808
|
const effects = rules.filter(({ action, protected: kept }) => action === ENVELOPE && !kept).map((rule2) => ({ rule: rule2, emails: 0, bytes: 0 }));
|
|
47809
|
+
const from = cursor === void 0 ? void 0 : positionOf(cursor, folders, apply);
|
|
47773
47810
|
const result = {
|
|
47774
47811
|
account: key.account,
|
|
47775
47812
|
applied: apply,
|
|
@@ -47779,45 +47816,24 @@ var applyRules = /* @__PURE__ */ __name(async ({ store, source, account, folders
|
|
|
47779
47816
|
skipMatched: 0,
|
|
47780
47817
|
protectedKept: 0,
|
|
47781
47818
|
tagged: 0,
|
|
47819
|
+
...from?.totals,
|
|
47782
47820
|
rules: effects
|
|
47783
47821
|
};
|
|
47822
|
+
const listedBefore = result.listed;
|
|
47784
47823
|
if (effects.length === 0 && !rules.some(({ tags, protected: kept }) => tags?.length || kept))
|
|
47785
47824
|
return result;
|
|
47786
47825
|
const stored2 = await store.accounts.storedAccount(key).catch(() => null);
|
|
47787
47826
|
if (stored2 === null)
|
|
47788
47827
|
return result;
|
|
47789
|
-
const listed6 = /* @__PURE__ */ new Map();
|
|
47790
|
-
for (const folder2 of folders)
|
|
47791
|
-
for (const item of await source.list(since, folder2, { headers: true }))
|
|
47792
|
-
listed6.set(item.messageId, item);
|
|
47793
|
-
result.listed = listed6.size;
|
|
47794
47828
|
const full = new Set((await store.mail.emailRefs({ accountId: stored2.id })).filter(({ deleted, mailboxes }) => !deleted && !mailboxes.some(({ kind: kind3 }) => kind3 === ENVELOPE)).map(({ externalId }) => externalId));
|
|
47795
47829
|
const all = new Set((await store.mail.emailRefs({ accountId: stored2.id })).map(({ externalId }) => externalId));
|
|
47796
|
-
const factsFor = factsOf([...listed6.values()], rules);
|
|
47797
47830
|
const tagger = ruleTagger(store, key);
|
|
47798
|
-
const
|
|
47799
|
-
|
|
47800
|
-
|
|
47801
|
-
const tags = all.has(item.messageId) ? tagsOf(rules, facts) : [];
|
|
47802
|
-
if (tags.length) {
|
|
47803
|
-
result.tagged++;
|
|
47804
|
-
if (apply)
|
|
47805
|
-
await tagger.tag({ type: "message", chatId: item.threadId, messageId: item.messageId }, tags);
|
|
47806
|
-
}
|
|
47807
|
-
if (!full.has(item.messageId))
|
|
47808
|
-
continue;
|
|
47809
|
-
const rule2 = decide(rules, facts);
|
|
47810
|
-
if (rule2?.protected)
|
|
47811
|
-
result.protectedKept++;
|
|
47812
|
-
if (rule2?.action === "skip")
|
|
47813
|
-
result.skipMatched++;
|
|
47814
|
-
if (rule2?.action === ENVELOPE)
|
|
47815
|
-
chosen2.push({ item, rule: rule2 });
|
|
47816
|
-
}
|
|
47817
|
-
for (const { item, rule: rule2 } of chosen2) {
|
|
47831
|
+
const listed6 = /* @__PURE__ */ new Map();
|
|
47832
|
+
const aggregatesOf = await storedAggregates(store, stored2.id, rules, since);
|
|
47833
|
+
const envelope = /* @__PURE__ */ __name(async (item, rule2) => {
|
|
47818
47834
|
const email = await store.mail.email(stored2.id, item.messageId);
|
|
47819
47835
|
if (email === null)
|
|
47820
|
-
|
|
47836
|
+
return;
|
|
47821
47837
|
const bytes = textBytes(email.bodyText) + textBytes(email.bodyHtml) + email.attachments.reduce((sum, { text: text6 }) => sum + textBytes(text6), 0);
|
|
47822
47838
|
const effect = effects.find((one) => sameMatch(one.rule.match, rule2.match));
|
|
47823
47839
|
if (effect) {
|
|
@@ -47827,7 +47843,7 @@ var applyRules = /* @__PURE__ */ __name(async ({ store, source, account, folders
|
|
|
47827
47843
|
result.envelopes++;
|
|
47828
47844
|
result.bytes += bytes;
|
|
47829
47845
|
if (!apply)
|
|
47830
|
-
|
|
47846
|
+
return;
|
|
47831
47847
|
const [placed] = await store.mail.inThreads(stored2.id, [item.messageId]);
|
|
47832
47848
|
const subject = email.subject ?? item.headers?.subject;
|
|
47833
47849
|
const listId = item.headers?.listId;
|
|
@@ -47857,7 +47873,58 @@ var applyRules = /* @__PURE__ */ __name(async ({ store, source, account, folders
|
|
|
47857
47873
|
}
|
|
47858
47874
|
]
|
|
47859
47875
|
});
|
|
47876
|
+
}, "envelope");
|
|
47877
|
+
const settle2 = /* @__PURE__ */ __name(async (batch) => {
|
|
47878
|
+
const fresh = batch.filter(({ messageId }) => !listed6.has(messageId));
|
|
47879
|
+
for (const item of fresh)
|
|
47880
|
+
listed6.set(item.messageId, item);
|
|
47881
|
+
for (const item of fresh) {
|
|
47882
|
+
const facts = aggregatesOf(item);
|
|
47883
|
+
const tags = all.has(item.messageId) ? tagsOf(rules, facts) : [];
|
|
47884
|
+
if (tags.length) {
|
|
47885
|
+
result.tagged++;
|
|
47886
|
+
if (apply)
|
|
47887
|
+
await tagger.tag({ type: "message", chatId: item.threadId, messageId: item.messageId }, tags);
|
|
47888
|
+
}
|
|
47889
|
+
if (!full.has(item.messageId))
|
|
47890
|
+
continue;
|
|
47891
|
+
const rule2 = decide(rules, facts);
|
|
47892
|
+
if (rule2?.protected)
|
|
47893
|
+
result.protectedKept++;
|
|
47894
|
+
if (rule2?.action === "skip")
|
|
47895
|
+
result.skipMatched++;
|
|
47896
|
+
if (rule2?.action === ENVELOPE)
|
|
47897
|
+
await envelope(item, rule2);
|
|
47898
|
+
}
|
|
47899
|
+
}, "settle");
|
|
47900
|
+
const slice = source.listBatch ?? 200;
|
|
47901
|
+
walk: for (const folder2 of folders.slice(from === void 0 ? 0 : folders.indexOf(from.folder))) {
|
|
47902
|
+
if (source.search === void 0) {
|
|
47903
|
+
await settle2(await source.list(since, folder2, { headers: true }));
|
|
47904
|
+
continue;
|
|
47905
|
+
}
|
|
47906
|
+
const searched = await source.search(since, folder2);
|
|
47907
|
+
const below = from?.folder === folder2 && from.validity !== void 0 && from.validity === searched.validity ? from.below : Number.POSITIVE_INFINITY;
|
|
47908
|
+
const uids = searched.uids.filter((uid) => Number(uid) < below).sort((a2, b) => Number(b) - Number(a2));
|
|
47909
|
+
for (let start = 0; start < uids.length; start += slice) {
|
|
47910
|
+
const stop = take();
|
|
47911
|
+
if (stop !== null) {
|
|
47912
|
+
result.stopped = stop;
|
|
47913
|
+
const { envelopes, bytes, skipMatched, protectedKept, tagged } = result;
|
|
47914
|
+
result.cursor = cursorOf3({
|
|
47915
|
+
folder: folder2,
|
|
47916
|
+
...searched.validity === void 0 ? {} : { validity: searched.validity },
|
|
47917
|
+
below: Number(uids[start]) + 1,
|
|
47918
|
+
applied: apply,
|
|
47919
|
+
totals: { listed: listedBefore + listed6.size, envelopes, bytes, skipMatched, protectedKept, tagged }
|
|
47920
|
+
});
|
|
47921
|
+
break walk;
|
|
47922
|
+
}
|
|
47923
|
+
const part = uids.slice(start, start + slice);
|
|
47924
|
+
await settle2(await source.list(since, folder2, { headers: true, searched: { ...searched, uids: part } }));
|
|
47925
|
+
}
|
|
47860
47926
|
}
|
|
47927
|
+
result.listed = listedBefore + listed6.size;
|
|
47861
47928
|
const tagging = tagger.outcome();
|
|
47862
47929
|
if (apply)
|
|
47863
47930
|
await settleRuleTags(store, stored2.id, rules, tagging);
|
|
@@ -48225,6 +48292,9 @@ var mailRulesApply = looseObject({
|
|
|
48225
48292
|
skip_matched: number(),
|
|
48226
48293
|
protected_kept: number(),
|
|
48227
48294
|
tagged: number(),
|
|
48295
|
+
state: picklist(["partial", "complete"]),
|
|
48296
|
+
stopped: optional(picklist(["requests", "deadline", "cancelled"])),
|
|
48297
|
+
cursor: optional(string()),
|
|
48228
48298
|
rules: array(looseObject({})),
|
|
48229
48299
|
meeting_notes: optional(record(string(), looseObject({ meetings: number() })))
|
|
48230
48300
|
});
|
|
@@ -48276,10 +48346,11 @@ var ruleLine = /* @__PURE__ */ __name((rule2) => [
|
|
|
48276
48346
|
rule2.recorded === void 0 ? "" : `${rule2.recorded.emails} emails, ${megabytes3(rule2.recorded.bytes)} MB`,
|
|
48277
48347
|
rule2.reason ?? ""
|
|
48278
48348
|
].filter(Boolean).join(" ").trimEnd(), "ruleLine");
|
|
48279
|
-
var applyText2 = /* @__PURE__ */ __name((result) => [
|
|
48349
|
+
var applyText2 = /* @__PURE__ */ __name((result, goOn) => [
|
|
48280
48350
|
...result.rules.filter(({ emails }) => emails > 0).map(({ rule: rule2, emails, bytes }) => `${describeMatch(rule2.match)} ${emails} emails, ${megabytes3(bytes)} MB of text`),
|
|
48281
48351
|
`${result.applied ? "cut" : "would cut"} ${result.envelopes} emails to envelopes, ${megabytes3(result.bytes)} MB of text, of ${result.listed} listed; ${result.skipMatched} match only a skip rule and stay as stored; ${result.protectedKept} are protected and stay whole; ${result.applied ? "tagged" : "would tag"} ${result.tagged}`,
|
|
48282
|
-
...Object.entries(result.meetingNotes ?? {}).map(([provider, { meetings }]) => `${result.applied ? "saved" : "would save"} ${meetings} ${provider} meetings from notes`)
|
|
48352
|
+
...Object.entries(result.meetingNotes ?? {}).map(([provider, { meetings }]) => `${result.applied ? "saved" : "would save"} ${meetings} ${provider} meetings from notes`),
|
|
48353
|
+
...goOn === void 0 ? [] : [`the run stopped before its time limit and kept what it did; to go on: ${goOn}`]
|
|
48283
48354
|
].join("\n"), "applyText");
|
|
48284
48355
|
var meetingNotesOf = /* @__PURE__ */ __name(async (store, address, rules, since, apply) => {
|
|
48285
48356
|
const providers = [...new Set(rules.flatMap(({ meeting_notes }) => meeting_notes ? [meeting_notes] : []))];
|
|
@@ -48382,23 +48453,31 @@ var removeCommand2 = /* @__PURE__ */ __name(() => answerEntity(matchOptions(gran
|
|
|
48382
48453
|
throw new CliError("not_found", `no rule for ${describeMatch(match)}; \`${IDENTITY.command} ${profile} rules list\` shows them`, { reason: "mail.rule-not-found" });
|
|
48383
48454
|
renderAnswer(this, outputFor(this), itemOf({ removed: match }), () => `removed the rule for ${describeMatch(match)}`);
|
|
48384
48455
|
}), "removeCommand");
|
|
48456
|
+
var STOP_CODES = { requests: "rate_limited", deadline: "timeout", cancelled: "cancelled" };
|
|
48385
48457
|
var applyCommand = /* @__PURE__ */ __name(() => answerEntity(annotate(new Command("apply"), {
|
|
48386
48458
|
effects: LOCAL_WRITE,
|
|
48459
|
+
// A large mailbox takes minutes to list; the run stops before its deadline, keeps what it did and gives a
|
|
48460
|
+
// --cursor to go on (WC-LIFE-10, WC-LIFE-16), so an MCP call answers before the client gives up.
|
|
48461
|
+
cooperative: true,
|
|
48462
|
+
partial: true,
|
|
48387
48463
|
examples: [
|
|
48388
48464
|
`${IDENTITY.command} personal rules apply`,
|
|
48389
48465
|
`${IDENTITY.command} personal rules apply --since-time 2026-01-01 --yes`
|
|
48390
48466
|
]
|
|
48391
|
-
}), "mail_rules_apply", mailRulesApply).description("cut stored mail an envelope rule matches to its envelope; dry run unless --yes").option("--since-time <time>", "only mail from this time, ISO 8601 or 30d ago (default: all mail)").option("--dry-run", "only say what would change, even with --yes; the read-only lock lets this through").addHelpText("after", "\nWithout --yes it only says what would change. Reads the mailbox's headers from the server, from the folders sync reads (List-Id is not stored), then drops the text, attachments and search entries of each matching stored email and keeps its sender, date, size, labels and subject in metadata. Mail a skip rule matches is left as stored. Nothing changes in the mailbox. Changing a rule to keep, or removing it, reads those emails in full on the next sync. A meeting-notes rule saves the stored emails it matches as meetings.").action(async function(options) {
|
|
48467
|
+
}), "mail_rules_apply", mailRulesApply).description("cut stored mail an envelope rule matches to its envelope; dry run unless --yes").option("--since-time <time>", "only mail from this time, ISO 8601 or 30d ago (default: all mail)").option("--yes", "cut them; without it, only say what would change").option("--dry-run", "only say what would change, even with --yes; the read-only lock lets this through").option("--cursor <cursor>", "go on from where a stopped run ended; its next step gives it, with the same options").addHelpText("after", "\nWithout --yes it only says what would change. Reads the mailbox's headers from the server, newest first, from the folders sync reads (List-Id is not stored), then drops the text, attachments and search entries of each matching stored email and keeps its sender, date, size, labels and subject in metadata. Mail a skip rule matches is left as stored. Nothing changes in the mailbox. Changing a rule to keep, or removing it, reads those emails in full on the next sync. A meeting-notes rule saves the stored emails it matches as meetings.\n\nA large mailbox takes minutes: 17,000 emails took about 4 minutes on one server. The run stops before its time limit (15 minutes, 45 seconds over MCP; --timeout changes it), keeps what it did and answers state partial with a --cursor to go on.").action(async function(options) {
|
|
48392
48468
|
const context = contextOf(this);
|
|
48393
48469
|
refuseOffline2(context.flags);
|
|
48394
48470
|
const address = addressOf3(context);
|
|
48395
48471
|
const window2 = dateWindow({ sinceTime: options.sinceTime });
|
|
48396
48472
|
const since = new Date(window2.since ?? 0);
|
|
48397
48473
|
const apply = this.optsWithGlobals().yes === true && options.dryRun !== true;
|
|
48474
|
+
const { deadline, signal } = environmentOf(this);
|
|
48475
|
+
const ends = deadline?.();
|
|
48476
|
+
const budget = runBudget({ requestMs: 1, ...ends ? { deadline: ends } : {}, ...signal ? { signal } : {} });
|
|
48398
48477
|
const { backend } = await openMail(context);
|
|
48399
48478
|
let result;
|
|
48400
48479
|
try {
|
|
48401
|
-
result = await withRules2(this, async (store) => {
|
|
48480
|
+
result = await worded(context.profile, () => withRules2(this, async (store) => {
|
|
48402
48481
|
const rules = await storedMailRules(store, { address });
|
|
48403
48482
|
const applied = await applyRules({
|
|
48404
48483
|
store,
|
|
@@ -48406,25 +48485,56 @@ var applyCommand = /* @__PURE__ */ __name(() => answerEntity(annotate(new Comman
|
|
|
48406
48485
|
account: { address, rules },
|
|
48407
48486
|
folders: await syncFoldersOf(context.settings.mailbox, backend),
|
|
48408
48487
|
since,
|
|
48409
|
-
apply
|
|
48488
|
+
apply,
|
|
48489
|
+
...options.cursor === void 0 ? {} : { cursor: options.cursor },
|
|
48490
|
+
take: /* @__PURE__ */ __name(() => budget.take(), "take")
|
|
48410
48491
|
});
|
|
48492
|
+
if (applied.stopped)
|
|
48493
|
+
return applied;
|
|
48411
48494
|
const meetingNotes = await meetingNotesOf(store, address, rules, since, apply);
|
|
48412
48495
|
return meetingNotes === void 0 ? applied : { ...applied, meetingNotes };
|
|
48413
|
-
});
|
|
48496
|
+
}));
|
|
48414
48497
|
} finally {
|
|
48415
48498
|
await backend.close();
|
|
48416
48499
|
}
|
|
48417
|
-
const
|
|
48500
|
+
const timeout = this.optsWithGlobals().timeout;
|
|
48501
|
+
const same = {
|
|
48502
|
+
...options.sinceTime === void 0 ? {} : { since_time: options.sinceTime },
|
|
48503
|
+
...timeout === void 0 ? {} : { timeout }
|
|
48504
|
+
};
|
|
48505
|
+
const changes = result.envelopes + result.tagged + Object.values(result.meetingNotes ?? {}).reduce((n2, { meetings }) => n2 + meetings, 0);
|
|
48506
|
+
const next = result.cursor !== void 0 ? [
|
|
48507
|
+
{
|
|
48508
|
+
kind: "command",
|
|
48509
|
+
step: "mail.rules-apply",
|
|
48510
|
+
command: "rules apply",
|
|
48511
|
+
args: { ...same, ...apply ? { yes: true } : {}, cursor: result.cursor },
|
|
48512
|
+
why: result.listed === 0 ? "the run read nothing before its time limit; run it again with a longer --timeout" : "the run stopped before its time limit to answer in time; this goes on from where it stopped",
|
|
48513
|
+
// The same decision, already made: only the stored copy changes, and the mailbox stays as it is.
|
|
48514
|
+
safe_to_auto_execute: true
|
|
48515
|
+
}
|
|
48516
|
+
] : result.applied || changes === 0 ? [] : [
|
|
48418
48517
|
{
|
|
48419
48518
|
kind: "command",
|
|
48420
48519
|
step: "mail.rules-apply",
|
|
48421
48520
|
command: "rules apply",
|
|
48422
|
-
args: { yes: true, ...
|
|
48521
|
+
args: { yes: true, ...same },
|
|
48423
48522
|
why: "this was a dry run; --yes cuts them",
|
|
48424
48523
|
safe_to_auto_execute: false
|
|
48425
48524
|
}
|
|
48426
48525
|
];
|
|
48427
|
-
|
|
48526
|
+
const issues = result.stopped ? [{ code: STOP_CODES[result.stopped], reason: `budget.${result.stopped}`, source: "rules apply" }] : [];
|
|
48527
|
+
const state3 = result.stopped ? "partial" : "complete";
|
|
48528
|
+
renderAnswer(this, outputFor(this), itemOf(snakeKeys({ ...result, state: state3 }), {
|
|
48529
|
+
next,
|
|
48530
|
+
meta: { ...window2.meta, ...issues.length ? { complete: false, issues } : {} }
|
|
48531
|
+
}), () => applyText2(result, result.cursor === void 0 ? void 0 : [
|
|
48532
|
+
`${IDENTITY.command} ${context.profile} rules apply`,
|
|
48533
|
+
...apply ? ["--yes"] : [],
|
|
48534
|
+
...options.sinceTime === void 0 ? [] : [`--since-time ${options.sinceTime}`],
|
|
48535
|
+
...timeout === void 0 ? [] : [`--timeout ${timeout}`],
|
|
48536
|
+
`--cursor ${result.cursor}`
|
|
48537
|
+
].join(" ")));
|
|
48428
48538
|
}), "applyCommand");
|
|
48429
48539
|
var exportCommand2 = /* @__PURE__ */ __name(() => annotate(new Command("export"), {
|
|
48430
48540
|
effects: LOCAL_READ,
|
|
@@ -6,26 +6,26 @@ import {
|
|
|
6
6
|
envelope,
|
|
7
7
|
serveOverHttpUntilStopped,
|
|
8
8
|
serveOverStdio
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-YRER6N3Y.js";
|
|
10
|
+
import "./chunk-W32UQL5I.js";
|
|
11
11
|
import "./chunk-ODPYXNHI.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-BPHLFSUO.js";
|
|
13
|
+
import "./chunk-FDGCTY6J.js";
|
|
14
14
|
import "./chunk-IZEK7JI7.js";
|
|
15
15
|
import "./chunk-7E4KECG4.js";
|
|
16
16
|
import "./chunk-VFRI6RF7.js";
|
|
17
17
|
import "./chunk-VXHL3XI6.js";
|
|
18
18
|
import "./chunk-5D4AEUVA.js";
|
|
19
19
|
import "./chunk-PIKOQWTL.js";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-7AO73MJZ.js";
|
|
21
|
+
import "./chunk-NWA7JS74.js";
|
|
22
22
|
import "./chunk-KBTVVHFP.js";
|
|
23
23
|
import "./chunk-YAQGWHMH.js";
|
|
24
24
|
import "./chunk-UUM7AF32.js";
|
|
25
25
|
import "./chunk-MVGFB7IS.js";
|
|
26
26
|
import "./chunk-FHQ32JKS.js";
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-KTLJ6F2B.js";
|
|
28
|
+
import "./chunk-WSHPLO4Q.js";
|
|
29
29
|
import "./chunk-2MTIGJHQ.js";
|
|
30
30
|
import "./chunk-XEMARUGS.js";
|
|
31
31
|
import "./chunk-7ESXP4TG.js";
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
registerCommands,
|
|
10
10
|
runCommandForAgent,
|
|
11
11
|
toolsFromCommands
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-BPHLFSUO.js";
|
|
13
13
|
import {
|
|
14
14
|
agentJson,
|
|
15
15
|
skillResource
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FDGCTY6J.js";
|
|
17
17
|
import "./chunk-IZEK7JI7.js";
|
|
18
18
|
import {
|
|
19
19
|
callerOf,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./chunk-5D4AEUVA.js";
|
|
25
25
|
import {
|
|
26
26
|
wholeList
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-NWA7JS74.js";
|
|
28
28
|
import "./chunk-KBTVVHFP.js";
|
|
29
29
|
import "./chunk-YAQGWHMH.js";
|
|
30
30
|
import "./chunk-UUM7AF32.js";
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
itemOf,
|
|
37
37
|
readOnlyLockOf,
|
|
38
38
|
readOnlyRefusal
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-WSHPLO4Q.js";
|
|
40
40
|
import "./chunk-2MTIGJHQ.js";
|
|
41
41
|
import "./chunk-XEMARUGS.js";
|
|
42
42
|
import "./chunk-7ESXP4TG.js";
|
package/dist/bundle/{store-maintenance-command-4TW6FABJ.js → store-maintenance-command-SH6IB7S6.js}
RENAMED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
buildStems,
|
|
6
6
|
storeMaintenanceCommands,
|
|
7
7
|
storeSummary
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RFM3AAK5.js";
|
|
9
9
|
import "./chunk-3AH7UEM6.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-7AO73MJZ.js";
|
|
11
|
+
import "./chunk-NWA7JS74.js";
|
|
12
12
|
import "./chunk-KBTVVHFP.js";
|
|
13
13
|
import "./chunk-YAQGWHMH.js";
|
|
14
14
|
import "./chunk-UUM7AF32.js";
|
|
@@ -16,7 +16,7 @@ import "./chunk-MVGFB7IS.js";
|
|
|
16
16
|
import "./chunk-PYOM4J73.js";
|
|
17
17
|
import "./chunk-FHQ32JKS.js";
|
|
18
18
|
import "./chunk-HTQTIKWP.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-WSHPLO4Q.js";
|
|
20
20
|
import "./chunk-2MTIGJHQ.js";
|
|
21
21
|
import "./chunk-XEMARUGS.js";
|
|
22
22
|
import "./chunk-7ESXP4TG.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/commands/rules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/commands/rules.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAwjB3C,eAAO,MAAM,YAAY,QAAO,OAQA,CAAA"}
|