Compare commits
3 Commits
addSeconda
...
sec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31be44a3b9 | ||
|
|
4192bb9dee | ||
|
|
5c29eec50b |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,4 +9,4 @@ accounts.json
|
|||||||
|
|
||||||
# Runtime output
|
# Runtime output
|
||||||
summary.json
|
summary.json
|
||||||
token-secondary.json
|
summary-secondary.json
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Infinitely mod-able. Dead simple. Privacy centric.
|
|||||||
|
|
||||||
# Scope
|
# Scope
|
||||||
|
|
||||||
## Current implementation contemplates: Claude Desktop + Local Model Context Protocol Server + Commercial SMTP Server (MX'config’d properly) + your DNS-config’d XXX.YYY
|
## Current implementation contemplates: Claude Desktop + Custom, Local Model Context Protocol Server + Commercial SMTP Server (MX'config’d properly) + your DNS-config’d XXX.YYY
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
34
src/index.ts
34
src/index.ts
@@ -54,11 +54,13 @@ function getSummaryPath(account: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const VALID_ACCOUNTS = ["work", "secondary"] as const;
|
const VALID_ACCOUNTS = ["work", "secondary"] as const;
|
||||||
|
const accounts = loadAccounts();
|
||||||
|
const accountDescription = VALID_ACCOUNTS
|
||||||
|
.map((key) => `"${key}" (${accounts[key]?.label ?? key})`)
|
||||||
|
.join(" or ");
|
||||||
const accountSchema = z
|
const accountSchema = z
|
||||||
.enum(VALID_ACCOUNTS)
|
.enum(VALID_ACCOUNTS)
|
||||||
.describe(
|
.describe(`Which email account to use: ${accountDescription}`);
|
||||||
"Which email account to use: \"work\" (sj@sjdev.co) or \"secondary\" (ken.jannette@gmail.com)"
|
|
||||||
);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Load classification prompt
|
// Load classification prompt
|
||||||
@@ -169,7 +171,7 @@ server.registerPrompt(
|
|||||||
"review_emails",
|
"review_emails",
|
||||||
{
|
{
|
||||||
description:
|
description:
|
||||||
"Review WORK inbox (sj@sjdev.co): classify job application emails (A/B/C/D), delete A+C, summarize B+D.",
|
`Review WORK inbox (${accounts.work?.label ?? "work"}): classify job application emails (A/B/C/D), delete A+C, summarize B+D.`,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const instructions = loadClassificationPrompt();
|
const instructions = loadClassificationPrompt();
|
||||||
@@ -197,7 +199,7 @@ server.registerPrompt(
|
|||||||
"review_secondary_emails",
|
"review_secondary_emails",
|
||||||
{
|
{
|
||||||
description:
|
description:
|
||||||
"Review SECONDARY inbox (ken.jannette@gmail.com): classify job application emails (A/B/C/D), delete A+C, summarize B+D.",
|
`Review SECONDARY inbox (${accounts.secondary?.label ?? "secondary"}): classify job application emails (A/B/C/D), delete A+C, summarize B+D.`,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const instructions = loadClassificationPrompt();
|
const instructions = loadClassificationPrompt();
|
||||||
@@ -423,15 +425,30 @@ server.registerTool(
|
|||||||
summary = JSON.parse(fs.readFileSync(summaryPath, "utf-8"));
|
summary = JSON.parse(fs.readFileSync(summaryPath, "utf-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Date().toISOString();
|
const now = new Date();
|
||||||
|
const nowIso = now.toISOString();
|
||||||
const newEntries: SummaryEntry[] = entries.map((e) => ({
|
const newEntries: SummaryEntry[] = entries.map((e) => ({
|
||||||
...e,
|
...e,
|
||||||
addedAt: now,
|
addedAt: nowIso,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
summary.push(...newEntries);
|
summary.push(...newEntries);
|
||||||
|
|
||||||
|
// Purge entries older than 30 days
|
||||||
|
const RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
||||||
|
const cutoff = now.getTime() - RETENTION_MS;
|
||||||
|
const beforePurge = summary.length;
|
||||||
|
summary = summary.filter(
|
||||||
|
(entry) => new Date(entry.addedAt).getTime() >= cutoff
|
||||||
|
);
|
||||||
|
const purged = beforePurge - summary.length;
|
||||||
|
|
||||||
fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2));
|
fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2));
|
||||||
|
|
||||||
|
const purgeNote = purged > 0
|
||||||
|
? `\nPurged ${purged} entry/entries older than 30 days.`
|
||||||
|
: "";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
@@ -439,7 +456,8 @@ server.registerTool(
|
|||||||
text:
|
text:
|
||||||
`Appended ${newEntries.length} entry/entries to summary.\n` +
|
`Appended ${newEntries.length} entry/entries to summary.\n` +
|
||||||
`Total entries in summary: ${summary.length}\n` +
|
`Total entries in summary: ${summary.length}\n` +
|
||||||
`Summary file: ${summaryPath}`,
|
`Summary file: ${summaryPath}` +
|
||||||
|
purgeNote,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user