ofw-mcp 2.28.0 → 2.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/dist/bundle.js +254 -54
- package/dist/cache/store.js +6 -3
- package/dist/read-days.js +11 -6
- package/dist/sync.js +26 -24
- package/dist/tools/messages.js +98 -41
- package/dist/tools/plain-text.js +211 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/server.json +4 -4
- package/skills/ofw/SKILL.md +5 -3
package/dist/bundle.js
CHANGED
|
@@ -47852,7 +47852,7 @@ function describeTokenlessLogin(record2) {
|
|
|
47852
47852
|
|
|
47853
47853
|
// src/version.ts
|
|
47854
47854
|
var SERVER_NAME = "ofw-mcp";
|
|
47855
|
-
var VERSION = "2.
|
|
47855
|
+
var VERSION = "2.29.0";
|
|
47856
47856
|
|
|
47857
47857
|
// src/auth.ts
|
|
47858
47858
|
function fetchproxyDisabled() {
|
|
@@ -48923,6 +48923,7 @@ function addDays(date5, n) {
|
|
|
48923
48923
|
const dt = new Date(Date.UTC(y, m - 1, d + n));
|
|
48924
48924
|
return { date: dt.toISOString().slice(0, 10), weekday: dt.getUTCDay() };
|
|
48925
48925
|
}
|
|
48926
|
+
var UNREAD_ON_NO_READ_DAY = "UNREAD_ON_NO_READ_DAY";
|
|
48926
48927
|
function readingBlockedToday(now = /* @__PURE__ */ new Date()) {
|
|
48927
48928
|
const policy = getReadDayPolicy();
|
|
48928
48929
|
if (policy === null) return null;
|
|
@@ -48943,7 +48944,7 @@ function readingBlockedToday(now = /* @__PURE__ */ new Date()) {
|
|
|
48943
48944
|
today: today.date,
|
|
48944
48945
|
weekday: WEEKDAY_LABELS[today.weekday],
|
|
48945
48946
|
timeZone,
|
|
48946
|
-
reason: `${reason}
|
|
48947
|
+
reason: `${reason} A no-read day only protects UNREAD inbox messages: their sender, subject and time are shown, but their bodies and attachments are withheld and nothing may mark them read on OurFamilyWizard. Sent messages, inbox messages already read, and drafts stay fully readable. This is a deployment setting: respect it. Only if the user has explicitly asked to read an unread message anyway today, pass overrideNoReadDay:true to ofw_get_message, ofw_list_messages or ofw_sync_messages. Attachments of unread messages stay withheld either way.`,
|
|
48947
48948
|
nextReadableDay
|
|
48948
48949
|
};
|
|
48949
48950
|
}
|
|
@@ -49117,7 +49118,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49117
49118
|
const listRead = scrapeSaysRead(folder, item);
|
|
49118
49119
|
const isInboxUnread = folder === "inbox" && !listRead;
|
|
49119
49120
|
if (existing) {
|
|
49120
|
-
if (
|
|
49121
|
+
if (existing.body === null && !isInboxUnread) {
|
|
49121
49122
|
if (!budget.take()) {
|
|
49122
49123
|
pageBudgetHit = true;
|
|
49123
49124
|
break;
|
|
@@ -49128,7 +49129,6 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49128
49129
|
"GET /pub/v3/messages/{id} (body backfill)",
|
|
49129
49130
|
false
|
|
49130
49131
|
);
|
|
49131
|
-
opts.onBodyFetched?.(item.id);
|
|
49132
49132
|
toUpsert.push({
|
|
49133
49133
|
...existing,
|
|
49134
49134
|
body: detail.body ?? "",
|
|
@@ -49143,7 +49143,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49143
49143
|
}
|
|
49144
49144
|
continue;
|
|
49145
49145
|
}
|
|
49146
|
-
if (
|
|
49146
|
+
if (folder === "sent" && item.showNeverViewed === false && !hasRealView(existing.recipients)) {
|
|
49147
49147
|
if (!budget.take()) {
|
|
49148
49148
|
pageBudgetHit = true;
|
|
49149
49149
|
break;
|
|
@@ -49159,7 +49159,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49159
49159
|
continue;
|
|
49160
49160
|
}
|
|
49161
49161
|
pageHadNewItem = true;
|
|
49162
|
-
const shouldFetchBody =
|
|
49162
|
+
const shouldFetchBody = !isInboxUnread || opts.fetchUnreadBodies;
|
|
49163
49163
|
let body = null;
|
|
49164
49164
|
let fetchedBodyAt = null;
|
|
49165
49165
|
let detailFileIds = [];
|
|
@@ -49184,7 +49184,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49184
49184
|
break;
|
|
49185
49185
|
}
|
|
49186
49186
|
const detail = await fetchDetail(item, { subject: row.subject, sentAt: row.sentAt, from }, "GET /pub/v3/messages/{id} (sync)", isInboxUnread);
|
|
49187
|
-
opts.
|
|
49187
|
+
if (isInboxUnread) opts.onUnreadBodyFetched?.(item.id);
|
|
49188
49188
|
body = detail.body ?? "";
|
|
49189
49189
|
fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
49190
49190
|
detailRecipients = detail.recipients;
|
|
@@ -49230,7 +49230,6 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49230
49230
|
}
|
|
49231
49231
|
}
|
|
49232
49232
|
async function syncMessageFolder(client2, folder, folderId, opts, store) {
|
|
49233
|
-
const fetchBodies = opts.fetchBodies ?? true;
|
|
49234
49233
|
const budget = opts.budget ?? makeBudget(Number.POSITIVE_INFINITY);
|
|
49235
49234
|
const saved = await store.getSyncState(folder);
|
|
49236
49235
|
const savedResume = saved?.resumePage ?? null;
|
|
@@ -49238,8 +49237,7 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
|
|
|
49238
49237
|
startPage: 1,
|
|
49239
49238
|
stopAtCachedPage: true,
|
|
49240
49239
|
fetchUnreadBodies: opts.fetchUnreadBodies,
|
|
49241
|
-
|
|
49242
|
-
onBodyFetched: opts.onBodyFetched,
|
|
49240
|
+
onUnreadBodyFetched: opts.onUnreadBodyFetched,
|
|
49243
49241
|
budget
|
|
49244
49242
|
}, store);
|
|
49245
49243
|
let synced = fwd.synced;
|
|
@@ -49267,8 +49265,7 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
|
|
|
49267
49265
|
startPage: savedResume ?? fwd.nextPage,
|
|
49268
49266
|
stopAtCachedPage: false,
|
|
49269
49267
|
fetchUnreadBodies: opts.fetchUnreadBodies,
|
|
49270
|
-
|
|
49271
|
-
onBodyFetched: opts.onBodyFetched,
|
|
49268
|
+
onUnreadBodyFetched: opts.onUnreadBodyFetched,
|
|
49272
49269
|
budget
|
|
49273
49270
|
}, store);
|
|
49274
49271
|
synced += bf.synced;
|
|
@@ -49464,9 +49461,9 @@ async function syncAll(client2, opts, store) {
|
|
|
49464
49461
|
const noReadDay = readingBlockedToday() !== null;
|
|
49465
49462
|
const overriding = noReadDay && opts.overrideNoReadDay === true;
|
|
49466
49463
|
const readingBlocked = noReadDay && !overriding;
|
|
49467
|
-
const
|
|
49468
|
-
const
|
|
49469
|
-
|
|
49464
|
+
const openedUnreadIds = [];
|
|
49465
|
+
const onUnreadBodyFetched = (id2) => {
|
|
49466
|
+
openedUnreadIds.push(id2);
|
|
49470
49467
|
};
|
|
49471
49468
|
budget.take();
|
|
49472
49469
|
const ids = await resolveFolderIds(client2, store);
|
|
@@ -49490,8 +49487,7 @@ async function syncAll(client2, opts, store) {
|
|
|
49490
49487
|
if (folder === "inbox") {
|
|
49491
49488
|
const r = await syncMessageFolder(client2, "inbox", ids.inbox, {
|
|
49492
49489
|
fetchUnreadBodies: !readingBlocked && (opts.fetchUnreadBodies ?? false),
|
|
49493
|
-
|
|
49494
|
-
onBodyFetched,
|
|
49490
|
+
onUnreadBodyFetched,
|
|
49495
49491
|
deep: opts.deep ?? false,
|
|
49496
49492
|
budget
|
|
49497
49493
|
}, store);
|
|
@@ -49503,8 +49499,6 @@ async function syncAll(client2, opts, store) {
|
|
|
49503
49499
|
} else if (folder === "sent") {
|
|
49504
49500
|
const r = await syncMessageFolder(client2, "sent", ids.sent, {
|
|
49505
49501
|
fetchUnreadBodies: false,
|
|
49506
|
-
fetchBodies: !readingBlocked,
|
|
49507
|
-
onBodyFetched,
|
|
49508
49502
|
deep: opts.deep ?? false,
|
|
49509
49503
|
budget
|
|
49510
49504
|
}, store);
|
|
@@ -49521,8 +49515,8 @@ async function syncAll(client2, opts, store) {
|
|
|
49521
49515
|
}
|
|
49522
49516
|
}
|
|
49523
49517
|
const notes = [];
|
|
49524
|
-
if (readingBlocked) {
|
|
49525
|
-
notes.push("Today is a no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS):
|
|
49518
|
+
if (readingBlocked && opts.fetchUnreadBodies === true) {
|
|
49519
|
+
notes.push("Today is a no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS), so fetchUnreadBodies was not honoured: unread inbox messages were cached from the list only \u2014 sender, date and subject \u2014 and none was marked read. Sent and already-read messages synced as usual.");
|
|
49526
49520
|
}
|
|
49527
49521
|
if (draftsUnverified) {
|
|
49528
49522
|
notes.push('The drafts folder was NOT checked against OurFamilyWizard on this call (the request budget ran out first), so no drafts count is reported and the cached drafts are marked "unverified". Cached draft bodies may be behind the server. Call ofw_sync_messages again \u2014 or ofw_sync_messages with folders:["drafts"] \u2014 before editing or deleting a draft.');
|
|
@@ -49546,8 +49540,10 @@ async function syncAll(client2, opts, store) {
|
|
|
49546
49540
|
syncComplete: done,
|
|
49547
49541
|
refreshed,
|
|
49548
49542
|
notRefreshed,
|
|
49549
|
-
|
|
49550
|
-
|
|
49543
|
+
// Claimed only when the override released something: like ofw_get_message
|
|
49544
|
+
// and ofw_list_messages, a sync whose read/sent bodies needed no override
|
|
49545
|
+
// reports none and leaves nothing to audit.
|
|
49546
|
+
...overriding && openedUnreadIds.length > 0 ? { readOverride: true, readOverrideNote: READ_OVERRIDE_NOTE, readOverrideMessageIds: openedUnreadIds } : {},
|
|
49551
49547
|
note,
|
|
49552
49548
|
markedRead,
|
|
49553
49549
|
newMessages: newMessages.slice(0, NEW_MESSAGES_CAP)
|
|
@@ -51825,6 +51821,174 @@ function withPaginationFirst(input2) {
|
|
|
51825
51821
|
return { ...head, ...body, ...head };
|
|
51826
51822
|
}
|
|
51827
51823
|
|
|
51824
|
+
// src/tools/plain-text.ts
|
|
51825
|
+
var CHANGE_ORDER = [
|
|
51826
|
+
"headings",
|
|
51827
|
+
"bold/italic",
|
|
51828
|
+
"links",
|
|
51829
|
+
"list markers",
|
|
51830
|
+
"list numbering",
|
|
51831
|
+
"list indentation"
|
|
51832
|
+
];
|
|
51833
|
+
var PH_OPEN = "\uE000";
|
|
51834
|
+
var PH_CLOSE = "\uE001";
|
|
51835
|
+
var PLACEHOLDER = /(\d+)/g;
|
|
51836
|
+
function convertInline(line, changes) {
|
|
51837
|
+
if (line.includes(PH_OPEN) || line.includes(PH_CLOSE)) return line;
|
|
51838
|
+
const kept = [];
|
|
51839
|
+
const protect = (s2) => `${PH_OPEN}${kept.push(s2) - 1}${PH_CLOSE}`;
|
|
51840
|
+
let s = line.replace(/(`+)[^`]+?\1(?!`)/g, protect);
|
|
51841
|
+
const beforeLinks = s;
|
|
51842
|
+
s = s.replace(/<(https?:\/\/[^\s<>]+)>/g, (_m, url2) => protect(url2));
|
|
51843
|
+
s = s.replace(/!?\[([^\]\n]+)\]\(([^)\s]+)\)/g, (_m, text, url2) => {
|
|
51844
|
+
const bare = (u) => u.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
51845
|
+
return bare(text) === bare(url2) ? protect(url2) : `${text} (${protect(url2)})`;
|
|
51846
|
+
});
|
|
51847
|
+
if (s !== beforeLinks) changes.add("links");
|
|
51848
|
+
s = s.replace(/https?:\/\/\S+/g, protect);
|
|
51849
|
+
const beforeEmphasis = s;
|
|
51850
|
+
s = s.replace(/\*\*(?=\S)(.+?)(?<=\S)\*\*/g, "$1");
|
|
51851
|
+
s = s.replace(/(?<![\w_])__(?=\S)(.+?)(?<=\S)__(?![\w_])/g, "$1");
|
|
51852
|
+
s = s.replace(/(?<![\w*])\*(?![\s*])(.+?)(?<![\s*])\*(?![\w*])/g, "$1");
|
|
51853
|
+
s = s.replace(/(?<![\w_])_(?![\s_])(.+?)(?<![\s_])_(?![\w_])/g, "$1");
|
|
51854
|
+
if (s !== beforeEmphasis) changes.add("bold/italic");
|
|
51855
|
+
while (s.includes(PH_OPEN)) {
|
|
51856
|
+
s = s.replace(PLACEHOLDER, (_m, i) => kept[Number(i)]);
|
|
51857
|
+
}
|
|
51858
|
+
return s;
|
|
51859
|
+
}
|
|
51860
|
+
var HEADING = /^ {0,3}#{1,6}[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/;
|
|
51861
|
+
var FENCE = /^ {0,3}(`{3,}|~{3,})/;
|
|
51862
|
+
var ITEM = /^([ \t]*)([-*+]|\d{1,9}[.)]|[a-z]{1,2}[.)])([ \t]+)(\S.*)$/;
|
|
51863
|
+
function indentWidth(ws) {
|
|
51864
|
+
let n = 0;
|
|
51865
|
+
for (const ch of ws) n += ch === " " ? 4 : 1;
|
|
51866
|
+
return n;
|
|
51867
|
+
}
|
|
51868
|
+
function alphaIndex(token) {
|
|
51869
|
+
let n = 0;
|
|
51870
|
+
for (const ch of token) n = n * 26 + (ch.charCodeAt(0) - 96);
|
|
51871
|
+
return n;
|
|
51872
|
+
}
|
|
51873
|
+
function toAlpha(n) {
|
|
51874
|
+
let s = "";
|
|
51875
|
+
for (let k = Math.max(1, n); k > 0; k = Math.floor((k - 1) / 26)) {
|
|
51876
|
+
s = String.fromCharCode(97 + (k - 1) % 26) + s;
|
|
51877
|
+
}
|
|
51878
|
+
return s;
|
|
51879
|
+
}
|
|
51880
|
+
function markdownToPlainText(input2) {
|
|
51881
|
+
const eol = input2.includes("\r\n") ? "\r\n" : "\n";
|
|
51882
|
+
const lines = input2.split(/\r?\n/);
|
|
51883
|
+
const out = [...lines];
|
|
51884
|
+
const changes = /* @__PURE__ */ new Set();
|
|
51885
|
+
const runs = [];
|
|
51886
|
+
let fence = null;
|
|
51887
|
+
let stack = [];
|
|
51888
|
+
let prevBlank = true;
|
|
51889
|
+
const endList = () => {
|
|
51890
|
+
stack = [];
|
|
51891
|
+
};
|
|
51892
|
+
lines.forEach((line, i) => {
|
|
51893
|
+
if (fence !== null) {
|
|
51894
|
+
if (line.trimStart().startsWith(fence)) fence = null;
|
|
51895
|
+
return;
|
|
51896
|
+
}
|
|
51897
|
+
const fenceOpen = FENCE.exec(line);
|
|
51898
|
+
if (fenceOpen) {
|
|
51899
|
+
fence = fenceOpen[1];
|
|
51900
|
+
endList();
|
|
51901
|
+
prevBlank = false;
|
|
51902
|
+
return;
|
|
51903
|
+
}
|
|
51904
|
+
if (line.trim() === "") {
|
|
51905
|
+
prevBlank = true;
|
|
51906
|
+
return;
|
|
51907
|
+
}
|
|
51908
|
+
const m = ITEM.exec(line);
|
|
51909
|
+
if (m) {
|
|
51910
|
+
const [, ws, marker, sep3, content] = m;
|
|
51911
|
+
const indent = indentWidth(ws);
|
|
51912
|
+
const bullet = /^[-*+]$/.test(marker);
|
|
51913
|
+
const letter = /^[a-z]/.test(marker);
|
|
51914
|
+
const token = bullet ? "" : marker.slice(0, -1);
|
|
51915
|
+
const accepted = letter ? stack.length > 0 && indent >= stack[0].indent + 2 : stack.length > 0 || prevBlank || bullet || token === "1";
|
|
51916
|
+
if (accepted) {
|
|
51917
|
+
const kind = bullet ? "bullet" : "ordered";
|
|
51918
|
+
const start = bullet ? 0 : letter ? alphaIndex(token) : Number(token);
|
|
51919
|
+
const item = { line: i, indent: ws, marker, sep: sep3, content };
|
|
51920
|
+
const newRun = (level) => {
|
|
51921
|
+
const run = { kind, level, start, items: [item] };
|
|
51922
|
+
runs.push(run);
|
|
51923
|
+
return run;
|
|
51924
|
+
};
|
|
51925
|
+
if (stack.length === 0) {
|
|
51926
|
+
stack.push({ indent, run: newRun(0) });
|
|
51927
|
+
} else {
|
|
51928
|
+
while (stack.length > 1 && indent <= stack[stack.length - 1].indent - 2) stack.pop();
|
|
51929
|
+
const top = stack[stack.length - 1];
|
|
51930
|
+
if (indent >= top.indent + 2) {
|
|
51931
|
+
stack.push({ indent, run: newRun(stack.length) });
|
|
51932
|
+
} else if (top.run.kind !== kind) {
|
|
51933
|
+
top.run = newRun(stack.length - 1);
|
|
51934
|
+
} else {
|
|
51935
|
+
top.run.items.push(item);
|
|
51936
|
+
}
|
|
51937
|
+
}
|
|
51938
|
+
prevBlank = false;
|
|
51939
|
+
return;
|
|
51940
|
+
}
|
|
51941
|
+
}
|
|
51942
|
+
if (stack.length > 0 && /^[ \t]/.test(line)) {
|
|
51943
|
+
out[i] = convertInline(line, changes);
|
|
51944
|
+
prevBlank = false;
|
|
51945
|
+
return;
|
|
51946
|
+
}
|
|
51947
|
+
endList();
|
|
51948
|
+
const heading = HEADING.exec(line);
|
|
51949
|
+
if (heading) {
|
|
51950
|
+
out[i] = convertInline(heading[1], changes);
|
|
51951
|
+
changes.add("headings");
|
|
51952
|
+
} else {
|
|
51953
|
+
out[i] = convertInline(line, changes);
|
|
51954
|
+
}
|
|
51955
|
+
prevBlank = false;
|
|
51956
|
+
});
|
|
51957
|
+
for (const run of runs) {
|
|
51958
|
+
const lettered = run.kind === "ordered" && run.level % 2 === 1;
|
|
51959
|
+
const markers = run.items.map((_, k) => {
|
|
51960
|
+
if (run.kind === "bullet") return "-";
|
|
51961
|
+
return `${lettered ? toAlpha(run.start + k) : run.start + k}.`;
|
|
51962
|
+
});
|
|
51963
|
+
const width = Math.max(...markers.map((mk) => mk.length));
|
|
51964
|
+
run.items.forEach((item, k) => {
|
|
51965
|
+
const indent = " ".repeat(4 * run.level);
|
|
51966
|
+
const sep3 = " ".repeat(width - markers[k].length + 1);
|
|
51967
|
+
if (indent !== item.indent) changes.add("list indentation");
|
|
51968
|
+
const origToken = item.marker.replace(/[.)]$/, "");
|
|
51969
|
+
const newToken = markers[k].replace(/\.$/, "");
|
|
51970
|
+
if (run.kind === "bullet" ? item.marker !== "-" : item.marker.endsWith(")")) changes.add("list markers");
|
|
51971
|
+
if (run.kind === "ordered" && origToken !== newToken) changes.add("list numbering");
|
|
51972
|
+
if (sep3 !== item.sep) changes.add(run.kind === "ordered" && width > 2 ? "list numbering" : "list markers");
|
|
51973
|
+
out[item.line] = `${indent}${markers[k]}${sep3}${convertInline(item.content, changes)}`;
|
|
51974
|
+
});
|
|
51975
|
+
}
|
|
51976
|
+
if (changes.size === 0) return { text: input2, changes: [] };
|
|
51977
|
+
return { text: out.join(eol), changes: CHANGE_ORDER.filter((c) => changes.has(c)) };
|
|
51978
|
+
}
|
|
51979
|
+
var BODY_FORMAT_DESCRIPTION = 'How to treat `body`. OurFamilyWizard shows message bodies as PLAIN TEXT \u2014 Markdown is never rendered, so **bold** would reach the co-parent with its asterisks. Default "markdown": Markdown is converted to plain text before anything is saved or sent (bold/italic markers and # heading markers dropped; [text](url) \u2192 "text (url)"; lists normalized to "-" bullets and renumbered 1., 2., \u2026 with a., b. for the second level, 4 spaces per nesting level; code, URLs and ~~strikethrough~~ left as written), and the response reports what changed under bodyConversion. "plain": send the body byte-for-byte. Line breaks, blank lines and leading spaces always survive; full https:// URLs, email addresses and phone numbers become links for the reader.';
|
|
51980
|
+
function prepareBody(body, format) {
|
|
51981
|
+
if (format === "plain") return { body, conversion: null, noteLine: null };
|
|
51982
|
+
const { text, changes } = markdownToPlainText(body);
|
|
51983
|
+
if (changes.length === 0) return { body, conversion: null, noteLine: null };
|
|
51984
|
+
const note = `OurFamilyWizard shows bodies as plain text, so Markdown was converted (${changes.join(", ")}). What was saved/sent is the converted text; pass bodyFormat:"plain" to send a body exactly as written.`;
|
|
51985
|
+
return {
|
|
51986
|
+
body: text,
|
|
51987
|
+
conversion: { changes, note },
|
|
51988
|
+
noteLine: `NOTE: the body was converted from Markdown to plain text (${changes.join(", ")}).`
|
|
51989
|
+
};
|
|
51990
|
+
}
|
|
51991
|
+
|
|
51828
51992
|
// src/tools/messages.ts
|
|
51829
51993
|
var WRITE_VIEW_NOTE = 'compact omits OurFamilyWizard\'s raw `listData` echo (which repeats the body, subject, recipients and a date block) and replaces the body you just wrote with `bodyLength` + `bodySha256` (the first 16 hex characters of its SHA-256) to confirm what landed. Pass "full" for both.';
|
|
51830
51994
|
var DRAFT_KEY_NULL_REASON = "No draftKey: this draft was not saved through this server's cache \u2014 it may have been created in the OurFamilyWizard web app or replaced from another session \u2014 so its lineage is unknown. The next ofw_save_draft on it starts a new key.";
|
|
@@ -51967,7 +52131,7 @@ function markReadCeiling(overrideDay) {
|
|
|
51967
52131
|
if (blocked !== null && !overrideDay) {
|
|
51968
52132
|
return {
|
|
51969
52133
|
gate: "OFW_READ_DAYS",
|
|
51970
|
-
reason: "Today is a no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS), so no
|
|
52134
|
+
reason: "Today is a no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS), so no unread inbox body was fetched; sent and already-read messages synced as usual. readingBlocked says when reading resumes.",
|
|
51971
52135
|
readingBlocked: blocked
|
|
51972
52136
|
};
|
|
51973
52137
|
}
|
|
@@ -52041,13 +52205,16 @@ async function confirmMarkRead(ctx, cached2, args, overriding) {
|
|
|
52041
52205
|
confirmToken: args.confirmToken
|
|
52042
52206
|
});
|
|
52043
52207
|
}
|
|
52208
|
+
function isUnreadInbox(row) {
|
|
52209
|
+
return row.folder === "inbox" && !deriveRead(row);
|
|
52210
|
+
}
|
|
52044
52211
|
function withholdBody(row) {
|
|
52045
52212
|
let listData = row.listData;
|
|
52046
52213
|
if (listData !== null && typeof listData === "object" && !Array.isArray(listData)) {
|
|
52047
52214
|
const { preview: _preview, body: _body, ...rest } = listData;
|
|
52048
52215
|
listData = rest;
|
|
52049
52216
|
}
|
|
52050
|
-
return { ...row, body: null, listData, bodyWithheld: true };
|
|
52217
|
+
return { ...row, body: null, listData, bodyWithheld: true, withheldReason: UNREAD_ON_NO_READ_DAY };
|
|
52051
52218
|
}
|
|
52052
52219
|
function markReadVerdict(cached2, requested) {
|
|
52053
52220
|
const ceiling = getAllowMarkRead();
|
|
@@ -52105,7 +52272,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52105
52272
|
when: { start: "since", end: "until" },
|
|
52106
52273
|
aliases: ["messages", "inbox", "co-parent", "ofw", "ourfamilywizard", "new messages"]
|
|
52107
52274
|
}),
|
|
52108
|
-
description: 'List messages from the local OurFamilyWizard cache. Supports filtering by folder, date range, and a substring query on subject+body. Pagination is offset-based (1-based `page`) but if you know what you want (a date range, a topic), prefer the filters over walking pages \u2014 the cache may have 1000+ messages. Results are newest-first by default; `sort:"oldest"` starts at the old end of a range instead of paging to it. Returns an explicit `complete` boolean describing the RESULT SET: true means "this is every message on OurFamilyWizard matching these filters as of freshness.asOf" \u2014 check it before asserting a count. An empty result from a cache that is not verified-fresh is REFUSED (result:"UNVERIFIED_EMPTY") rather than reported as an absence; pass autoRefresh:true to sync and answer instead. On a server-configured no-read day
|
|
52275
|
+
description: 'List messages from the local OurFamilyWizard cache. Supports filtering by folder, date range, and a substring query on subject+body. Pagination is offset-based (1-based `page`) but if you know what you want (a date range, a topic), prefer the filters over walking pages \u2014 the cache may have 1000+ messages. Results are newest-first by default; `sort:"oldest"` starts at the old end of a range instead of paging to it. Returns an explicit `complete` boolean describing the RESULT SET: true means "this is every message on OurFamilyWizard matching these filters as of freshness.asOf" \u2014 check it before asserting a count. An empty result from a cache that is not verified-fresh is REFUSED (result:"UNVERIFIED_EMPTY") rather than reported as an absence; pass autoRefresh:true to sync and answer instead. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) only unread inbox messages are protected: each keeps its sender, subject and time but carries body:null, bodyWithheld:true, withheldReason:"UNREAD_ON_NO_READ_DAY", and q matches it by subject only (bodySearchSkipped counts those); readingBlocked, ahead of the messages, appears only when something was withheld and says when reading resumes. Sent messages and inbox messages already read are returned and searched in full, exactly as on a reading day.' + OVERRIDE_DESCRIPTION,
|
|
52109
52276
|
// Read-only even with autoRefresh: guardedCacheRead's sync never fetches
|
|
52110
52277
|
// unread inbox bodies, so a list call cannot stamp "First Viewed".
|
|
52111
52278
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
@@ -52162,7 +52329,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52162
52329
|
const noReadDay = readingBlockedToday();
|
|
52163
52330
|
const overriding = noReadDay !== null && args.overrideNoReadDay === true;
|
|
52164
52331
|
const blocked = overriding ? null : noReadDay;
|
|
52165
|
-
const filter = { folder, since: bounds.since, until: bounds.until, q: args.q,
|
|
52332
|
+
const filter = { folder, since: bounds.since, until: bounds.until, q: args.q, qBodyReadOnly: blocked !== null };
|
|
52166
52333
|
const { value, refreshed, unverifiedEmpty } = await guardedCacheRead({
|
|
52167
52334
|
client: client2,
|
|
52168
52335
|
cache,
|
|
@@ -52222,19 +52389,37 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52222
52389
|
if (refreshed) {
|
|
52223
52390
|
payload.autoRefreshed = true;
|
|
52224
52391
|
}
|
|
52225
|
-
|
|
52226
|
-
|
|
52392
|
+
const withheld = blocked === null ? 0 : messages.filter(isUnreadInbox).length;
|
|
52393
|
+
let bodySearchSkipped = 0;
|
|
52394
|
+
if (blocked !== null && args.q !== void 0 && args.q.length > 0 && folder !== "sent") {
|
|
52395
|
+
const unopened = await cache.listMessages({
|
|
52396
|
+
folder: "inbox",
|
|
52397
|
+
since: bounds.since,
|
|
52398
|
+
until: bounds.until,
|
|
52399
|
+
unopenedInboxOnly: true,
|
|
52400
|
+
page: 1,
|
|
52401
|
+
size: 1e5
|
|
52402
|
+
});
|
|
52403
|
+
bodySearchSkipped = unopened.filter(isUnreadInbox).length;
|
|
52404
|
+
}
|
|
52405
|
+
if (bodySearchSkipped > 0) {
|
|
52406
|
+
payload.bodySearchSkipped = bodySearchSkipped;
|
|
52407
|
+
payload.bodySearchSkippedNote = `Today is a no-read day: ${bodySearchSkipped} unread inbox message${bodySearchSkipped === 1 ? " was" : "s were"} matched against the subject only, never the body. Sent and already-read messages were searched in full.`;
|
|
52227
52408
|
}
|
|
52228
|
-
if (
|
|
52229
|
-
|
|
52409
|
+
if (blocked !== null && (withheld > 0 || bodySearchSkipped > 0)) {
|
|
52410
|
+
payload.readingBlocked = { ...blocked, withheld };
|
|
52411
|
+
}
|
|
52412
|
+
const released = overriding ? messages.filter((m) => m.body !== null && isUnreadInbox(m)).map((m) => m.id) : [];
|
|
52413
|
+
if (released.length > 0) {
|
|
52414
|
+
Object.assign(payload, readOverrideFields("ofw_list_messages", released));
|
|
52230
52415
|
}
|
|
52231
52416
|
payload.freshness = freshness;
|
|
52232
|
-
payload.messages = viewMessages(view, blocked === null ? messages : messages.map(withholdBody));
|
|
52417
|
+
payload.messages = viewMessages(view, blocked === null ? messages : messages.map((m) => isUnreadInbox(m) ? withholdBody(m) : m));
|
|
52233
52418
|
return jsonResponse(payload);
|
|
52234
52419
|
});
|
|
52235
52420
|
server.registerTool("ofw_get_message", {
|
|
52236
52421
|
_meta: familyMeta("lookup"),
|
|
52237
|
-
description: 'Get a single OurFamilyWizard message OR draft by ID. Reads from local cache when available; otherwise fetches from OFW \u2014 and for an UNREAD INBOX message that fetch marks it read and stamps a "First Viewed" time the co-parent can see, which is part of the record and cannot be undone. Pass allowMarkRead:false to refuse such a fetch instead (cached bodies, sent messages and already-read messages are unaffected, because none of them stamp anything). For ids that match a draft (in the drafts cache), the response carries folder="drafts" and the body/subject/recipients reflect the drafts cache (which ofw_sync_messages keeps fresh) \u2014 drafts have no `fromUser`, and `sentAt`/`fetchedBodyAt` mirror the draft\'s `modifiedAt`. For inbox/sent messages, folder is "inbox" or "sent" as before. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) inbox
|
|
52422
|
+
description: 'Get a single OurFamilyWizard message OR draft by ID. Reads from local cache when available; otherwise fetches from OFW \u2014 and for an UNREAD INBOX message that fetch marks it read and stamps a "First Viewed" time the co-parent can see, which is part of the record and cannot be undone. Pass allowMarkRead:false to refuse such a fetch instead (cached bodies, sent messages and already-read messages are unaffected, because none of them stamp anything). For ids that match a draft (in the drafts cache), the response carries folder="drafts" and the body/subject/recipients reflect the drafts cache (which ofw_sync_messages keeps fresh) \u2014 drafts have no `fromUser`, and `sentAt`/`fetchedBodyAt` mirror the draft\'s `modifiedAt`. For inbox/sent messages, folder is "inbox" or "sent" as before. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) only an UNREAD inbox message is protected: its body is withheld (body:null, bodyWithheld:true, withheldReason:"UNREAD_ON_NO_READ_DAY", readingBlocked says when reading resumes) and OFW is never contacted for it; an id not in the cache is refused, since fetching it could mark it read. Sent messages and inbox messages already read are returned exactly as on a reading day. When the server runs with OFW_CONFIRM_MARK_READ=true, opening an unread inbox message first shows its subject, sender and sent time and asks the user to confirm marking it read: a confirmation prompt where the client supports one; otherwise the first call fetches NOTHING and returns that preview plus a confirmToken, and only a repeat call with that token opens the message (see MCP_CONFIRM_MODE). Show the user the preview and wait for their yes before repeating the call.' + OVERRIDE_DESCRIPTION,
|
|
52238
52423
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
52239
52424
|
inputSchema: external_exports.object({
|
|
52240
52425
|
messageId: external_exports.string().describe("Message ID (also accepts draft IDs \u2014 drafts are routed via the drafts cache)"),
|
|
@@ -52303,14 +52488,15 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52303
52488
|
}
|
|
52304
52489
|
const cached2 = await cache.getMessage(id2);
|
|
52305
52490
|
const noReadDay = readingBlockedToday();
|
|
52306
|
-
const
|
|
52307
|
-
const
|
|
52491
|
+
const protectedToday = noReadDay !== null && (cached2 === null || isUnreadInbox(cached2));
|
|
52492
|
+
const overriding = protectedToday && args.overrideNoReadDay === true;
|
|
52493
|
+
const blocked = protectedToday && !overriding ? noReadDay : null;
|
|
52308
52494
|
if (blocked !== null) {
|
|
52309
52495
|
if (cached2 === null) {
|
|
52310
52496
|
return jsonErrorResponse({
|
|
52311
52497
|
...blocked,
|
|
52312
52498
|
messageId: id2,
|
|
52313
|
-
hint: "This id is not in the cache. Run ofw_sync_messages (it
|
|
52499
|
+
hint: "This id is not in the cache, so whether it is an unread inbox message cannot be told without the request that would mark it read. Run ofw_sync_messages (it never opens an unread inbox message) to see its subject, sender and date \u2014 and, if it is sent or already read, its body."
|
|
52314
52500
|
});
|
|
52315
52501
|
}
|
|
52316
52502
|
const attachments2 = await cache.listAttachmentsForMessage(id2);
|
|
@@ -52413,6 +52599,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52413
52599
|
inputSchema: external_exports.object({
|
|
52414
52600
|
subject: external_exports.string().describe("Message subject. Required unless draftId/messageId is given (then it overrides the server draft's subject).").optional(),
|
|
52415
52601
|
body: external_exports.string().describe("Message body text. Required unless draftId/messageId is given (then it overrides the server draft's body \u2014 omit it to send exactly what is on OurFamilyWizard).").optional(),
|
|
52602
|
+
bodyFormat: external_exports.enum(["markdown", "plain"]).describe(`${BODY_FORMAT_DESCRIPTION} Applies only to a body passed here: a draft sent by id goes out exactly as it is on OurFamilyWizard.`).optional(),
|
|
52416
52603
|
recipientIds: external_exports.array(external_exports.number()).describe("Array of recipient user IDs (get from ofw_get_profile). Usually required even when sending a draft: OurFamilyWizard does not persist recipients on drafts.").optional(),
|
|
52417
52604
|
replyToId: external_exports.number().describe("ID of the message being replied to. Defaults to the draft's stored reply target when sending by draftId.").optional(),
|
|
52418
52605
|
draftId: external_exports.number().describe("ID of an existing draft to send. The draft is re-read from OurFamilyWizard and its SERVER content is sent; missing subject/body default from it. Guarded: a draft that changed since you read it, or that was already sent/deleted, refuses rather than sending blind.").optional(),
|
|
@@ -52439,7 +52626,8 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52439
52626
|
{ store: blobStore, readBlobs: true }
|
|
52440
52627
|
);
|
|
52441
52628
|
let subject = args.subject;
|
|
52442
|
-
|
|
52629
|
+
const prepared = args.body === void 0 ? null : prepareBody(args.body, args.bodyFormat);
|
|
52630
|
+
let body = prepared?.body;
|
|
52443
52631
|
let recipientIds = args.recipientIds;
|
|
52444
52632
|
let draftReplyToId = null;
|
|
52445
52633
|
let guardNote = null;
|
|
@@ -52516,6 +52704,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52516
52704
|
...unresolved.length > 0 ? { recipientNote: `No name on file for user id(s) ${unresolved.join(", ")} \u2014 verify the recipient before approving.` } : {},
|
|
52517
52705
|
subject,
|
|
52518
52706
|
body,
|
|
52707
|
+
...prepared?.conversion ? { bodyConversion: prepared.conversion } : {},
|
|
52519
52708
|
replyTo: resolvedReplyTo === null ? null : { messageId: resolvedReplyTo, subject: replyParent?.subject ?? null, from: replyParent?.fromUser || null },
|
|
52520
52709
|
attachments,
|
|
52521
52710
|
...pending.length > 0 ? { newAttachments: describePending(pending) } : {},
|
|
@@ -52704,10 +52893,11 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52704
52893
|
...resolveView(args.view, MESSAGE_VIEWS) === "full" ? persisted : compactSentMessage(persisted),
|
|
52705
52894
|
...attachmentCheck !== null ? { attachments: attachmentCheck } : {},
|
|
52706
52895
|
...newFiles.length > 0 ? { attachmentsUploaded: newFiles } : {},
|
|
52707
|
-
...uploadWarnings.length > 0 ? { warnings: uploadWarnings } : {}
|
|
52896
|
+
...uploadWarnings.length > 0 ? { warnings: uploadWarnings } : {},
|
|
52897
|
+
...prepared?.conversion ? { bodyConversion: prepared.conversion } : {}
|
|
52708
52898
|
};
|
|
52709
52899
|
return notedJsonResponse(
|
|
52710
|
-
[guardNote, rewriteNote, verifyNote, threadNote, attachmentNote, unconfirmedNote, retainNote],
|
|
52900
|
+
[guardNote, rewriteNote, prepared?.noteLine ?? null, verifyNote, threadNote, attachmentNote, unconfirmedNote, retainNote],
|
|
52711
52901
|
responseObj,
|
|
52712
52902
|
"Message sent successfully."
|
|
52713
52903
|
);
|
|
@@ -52885,6 +53075,7 @@ ${jsonText(
|
|
|
52885
53075
|
inputSchema: external_exports.object({
|
|
52886
53076
|
subject: external_exports.string().describe("Message subject"),
|
|
52887
53077
|
body: external_exports.string().describe("Message body text"),
|
|
53078
|
+
bodyFormat: external_exports.enum(["markdown", "plain"]).describe(BODY_FORMAT_DESCRIPTION).optional(),
|
|
52888
53079
|
recipientIds: external_exports.array(external_exports.number()).describe("Array of recipient user IDs (optional for drafts)").optional(),
|
|
52889
53080
|
messageId: external_exports.number().describe("ID of an existing draft to replace (the new draft will have a new id; the old is deleted)").optional(),
|
|
52890
53081
|
replyToId: external_exports.number().nullable().describe("ID of the message this draft replies to. When replacing a draft (messageId), omit it to keep the draft's own reply target, or pass null to make the draft a new top-level message.").optional(),
|
|
@@ -52899,6 +53090,7 @@ ${jsonText(
|
|
|
52899
53090
|
}, async (args) => {
|
|
52900
53091
|
const cache = cacheProvider();
|
|
52901
53092
|
const view = resolveView(args.view, MESSAGE_VIEWS);
|
|
53093
|
+
const prepared = prepareBody(args.body, args.bodyFormat);
|
|
52902
53094
|
const blobStore = args.blobKeys?.length ? blobStoreFromEnv() : void 0;
|
|
52903
53095
|
const pending = await planAttachments(
|
|
52904
53096
|
{ inline: args.inlineAttachments, blobKeys: args.blobKeys },
|
|
@@ -52950,7 +53142,7 @@ ${jsonText(
|
|
|
52950
53142
|
]).filter((id2) => !removed.has(id2));
|
|
52951
53143
|
const payload = {
|
|
52952
53144
|
subject: args.subject,
|
|
52953
|
-
body:
|
|
53145
|
+
body: prepared.body,
|
|
52954
53146
|
recipientIds: args.recipientIds ?? serverRecipientIds ?? [],
|
|
52955
53147
|
attachments: { myFileIDs },
|
|
52956
53148
|
draft: true,
|
|
@@ -52974,7 +53166,7 @@ ${jsonText(
|
|
|
52974
53166
|
let draftKey = null;
|
|
52975
53167
|
const warnings = [...uploadWarnings];
|
|
52976
53168
|
if (newId !== null) {
|
|
52977
|
-
verifyNote = verifyWriteLanded("draft", { subject: args.subject, body:
|
|
53169
|
+
verifyNote = verifyWriteLanded("draft", { subject: args.subject, body: prepared.body }, detail);
|
|
52978
53170
|
const reply = draftReplyTarget([detail], resolvedReplyTo);
|
|
52979
53171
|
const effectiveReplyTo = reply.replyToId;
|
|
52980
53172
|
replyToSource = reply.replyToSource;
|
|
@@ -53067,11 +53259,12 @@ ${jsonText(
|
|
|
53067
53259
|
},
|
|
53068
53260
|
...newFiles.length > 0 ? { attachmentsUploaded: newFiles } : {},
|
|
53069
53261
|
...warnings.length > 0 ? { warnings } : {},
|
|
53070
|
-
...recipientsNote !== null ? { recipientsNote } : {}
|
|
53262
|
+
...recipientsNote !== null ? { recipientsNote } : {},
|
|
53263
|
+
...prepared.conversion !== null ? { bodyConversion: prepared.conversion } : {}
|
|
53071
53264
|
} : raw;
|
|
53072
53265
|
const warnNote = warnings.length > 0 ? `WARNING: ${warnings.join("\n\n")}` : null;
|
|
53073
53266
|
return notedJsonResponse(
|
|
53074
|
-
[forceNote, rewriteNote, verifyNote, warnNote, recipientsNote, replaceNote],
|
|
53267
|
+
[forceNote, rewriteNote, prepared.noteLine, verifyNote, warnNote, recipientsNote, replaceNote],
|
|
53075
53268
|
responseObj,
|
|
53076
53269
|
"Draft saved."
|
|
53077
53270
|
);
|
|
@@ -53314,7 +53507,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53314
53507
|
// Destructive: force:true replaces an existing file in the attachments
|
|
53315
53508
|
// directory (which is also the default upload directory), and nothing
|
|
53316
53509
|
// here restores what it replaced. The default refuses to overwrite.
|
|
53317
|
-
description: "Download an OFW message attachment by fileId and return content you can actually read. Inline delivery walks a ladder and returns the first rung that works: (1) host-renderable images (PNG/JPEG/GIF/WEBP) come back as ImageContent; (2) .xlsx/.csv/.tsv, .pdf, .docx, .pptx and text files come back as EXTRACTED CONTENT \u2014 per-sheet CSV, per-page/slide text, document text \u2014 in the response JSON under `extracted`; (3) anything else comes back as an EmbeddedResource blob of the raw bytes. Images and raw bytes are only returned inline up to 10 MiB; a larger file fails with a tool error that says how to get it instead (extracted text is unaffected \u2014 it is bounded by maxChars). The meta block names the rung as `deliveredVia` and, when it falls through to bytes, lists what was tried in `deliveryAttempts`. Reported mime types are always normalized to a bare media type (no charset/name parameters). In disk mode the bytes are saved to ~/Downloads/ofw-mcp/ and the response carries the absolute path; pass extract:true to ALSO get the extracted content in that response. The default for `inline` can be flipped server-side via the OFW_INLINE_ATTACHMENTS env var. On a hosted deployment with no filesystem, disk mode is unavailable, so inline is forced (forcedInline:true) rather than failing \u2014 a saveTo path never costs you the content. fileId comes from attachments[].fileId on ofw_get_message. Override disk destination with OFW_ATTACHMENTS_DIR or saveTo; saveTo must stay inside the attachments directory, and an existing file is never overwritten unless force:true. Re-downloading to the same path is a no-op (disk mode only).",
|
|
53510
|
+
description: "Download an OFW message attachment by fileId and return content you can actually read. Inline delivery walks a ladder and returns the first rung that works: (1) host-renderable images (PNG/JPEG/GIF/WEBP) come back as ImageContent; (2) .xlsx/.csv/.tsv, .pdf, .docx, .pptx and text files come back as EXTRACTED CONTENT \u2014 per-sheet CSV, per-page/slide text, document text \u2014 in the response JSON under `extracted`; (3) anything else comes back as an EmbeddedResource blob of the raw bytes. Images and raw bytes are only returned inline up to 10 MiB; a larger file fails with a tool error that says how to get it instead (extracted text is unaffected \u2014 it is bounded by maxChars). The meta block names the rung as `deliveredVia` and, when it falls through to bytes, lists what was tried in `deliveryAttempts`. Reported mime types are always normalized to a bare media type (no charset/name parameters). In disk mode the bytes are saved to ~/Downloads/ofw-mcp/ and the response carries the absolute path; pass extract:true to ALSO get the extracted content in that response. The default for `inline` can be flipped server-side via the OFW_INLINE_ATTACHMENTS env var. On a hosted deployment with no filesystem, disk mode is unavailable, so inline is forced (forcedInline:true) rather than failing \u2014 a saveTo path never costs you the content. fileId comes from attachments[].fileId on ofw_get_message. Override disk destination with OFW_ATTACHMENTS_DIR or saveTo; saveTo must stay inside the attachments directory, and an existing file is never overwritten unless force:true. Re-downloading to the same path is a no-op (disk mode only). On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) only attachments of unread inbox messages are withheld (READING_BLOCKED, with nextReadableDay), along with files the cache cannot place; attachments of sent, already-read and draft messages download as on any day.",
|
|
53318
53511
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
53319
53512
|
inputSchema: external_exports.object({
|
|
53320
53513
|
fileId: external_exports.number().describe("Attachment file id (from ofw_get_message \u2192 attachments[].fileId)"),
|
|
@@ -53343,16 +53536,18 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53343
53536
|
const blocked = readingBlockedToday();
|
|
53344
53537
|
if (blocked !== null) {
|
|
53345
53538
|
const linked = (cached2?.messageIds ?? []).filter((mid) => mid !== 0);
|
|
53346
|
-
let
|
|
53539
|
+
let readable = linked.length > 0;
|
|
53347
53540
|
for (const mid of linked) {
|
|
53348
|
-
if (await cache.getDraft(mid)
|
|
53541
|
+
if (await cache.getDraft(mid) !== null) continue;
|
|
53542
|
+
const message = await cache.getMessage(mid);
|
|
53543
|
+
if (message === null || isUnreadInbox(message)) readable = false;
|
|
53349
53544
|
}
|
|
53350
|
-
if (!
|
|
53545
|
+
if (!readable) {
|
|
53351
53546
|
return jsonErrorResponse({
|
|
53352
53547
|
...blocked,
|
|
53353
53548
|
fileId,
|
|
53354
53549
|
...cached2 ? { fileName: cached2.fileName } : {},
|
|
53355
|
-
hint: "Attachments
|
|
53550
|
+
hint: "Attachments of unread inbox messages (and files this cache cannot place) are withheld on a no-read day. Attachments of sent, already-read and draft messages are not. Download it on the next reading day."
|
|
53356
53551
|
});
|
|
53357
53552
|
}
|
|
53358
53553
|
}
|
|
@@ -53450,7 +53645,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53450
53645
|
_meta: familyMeta("other"),
|
|
53451
53646
|
// Destructive: fetchUnreadBodies:true stamps a co-parent-visible "First
|
|
53452
53647
|
// Viewed" time on every unread inbox message it touches — irreversible.
|
|
53453
|
-
description: 'Sync messages from OurFamilyWizard into the local cache. A sync NEVER marks a message read unless fetchUnreadBodies is set: a new inbox message that OFW does not list as read is cached from the list (sender, date, subject) WITHOUT its body, because fetching the body is what stamps a co-parent-visible "First Viewed" time. Every response says what arrived: newMessages lists each message first cached by THIS call \u2014 inbox and sent, newest first, with read (its state before the sync) and bodyFetched; newMessagesTotal and newMessagesTruncated give the full count when more than ' + NEW_MESSAGES_CAP + ' arrived (ofw_list_messages pages through the rest). unreadInbox lists the new inbox messages that were unread when the sync began; bodyFetched:false means still unread on OFW \u2014 call ofw_get_message(id) to read one, which marks it read. If this call DID mark anything read (fetchUnreadBodies, or a stamp it detected but did not intend), the response LEADS with a warning and lists each in markedRead with reason "fetchUnreadBodies" or "unexpected"; markedRead is omitted when nothing was marked, and markedReadCount is always present. Returns counts per folder too. EVERY call re-checks the newest page first, so new messages are picked up promptly even while an old-history backfill is still running; only then does it spend what is left of its budget advancing that backfill. Pass deep:true to walk all OFW pages instead of stopping at the first all-cached page (use to backfill suspected gaps). Sync is BOUNDED and RESUMABLE: on hosted deployments a per-call OFW-request budget (env OFW_SYNC_MAX_REQUESTS, or the maxRequests argument) caps how far one call walks; when the budget is hit the response reports done:false with a note \u2014 call again with the SAME arguments to resume. done:false means older history is still being backfilled; it does NOT mean recent messages are missing. Local installs are unbounded by default (done is always true). On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS)
|
|
53648
|
+
description: 'Sync messages from OurFamilyWizard into the local cache. A sync NEVER marks a message read unless fetchUnreadBodies is set: a new inbox message that OFW does not list as read is cached from the list (sender, date, subject) WITHOUT its body, because fetching the body is what stamps a co-parent-visible "First Viewed" time. Every response says what arrived: newMessages lists each message first cached by THIS call \u2014 inbox and sent, newest first, with read (its state before the sync) and bodyFetched; newMessagesTotal and newMessagesTruncated give the full count when more than ' + NEW_MESSAGES_CAP + ' arrived (ofw_list_messages pages through the rest). unreadInbox lists the new inbox messages that were unread when the sync began; bodyFetched:false means still unread on OFW \u2014 call ofw_get_message(id) to read one, which marks it read. If this call DID mark anything read (fetchUnreadBodies, or a stamp it detected but did not intend), the response LEADS with a warning and lists each in markedRead with reason "fetchUnreadBodies" or "unexpected"; markedRead is omitted when nothing was marked, and markedReadCount is always present. Returns counts per folder too. EVERY call re-checks the newest page first, so new messages are picked up promptly even while an old-history backfill is still running; only then does it spend what is left of its budget advancing that backfill. Pass deep:true to walk all OFW pages instead of stopping at the first all-cached page (use to backfill suspected gaps). Sync is BOUNDED and RESUMABLE: on hosted deployments a per-call OFW-request budget (env OFW_SYNC_MAX_REQUESTS, or the maxRequests argument) caps how far one call walks; when the budget is hit the response reports done:false with a note \u2014 call again with the SAME arguments to resume. done:false means older history is still being backfilled; it does NOT mean recent messages are missing. Local installs are unbounded by default (done is always true). On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) a sync only protects unread inbox messages: it keeps syncing and fetching bodies for sent and already-read messages as on any day, and fetchUnreadBodies (argument or OFW_FETCH_UNREAD_BODIES) is refused, reported in unreadBodies.gate. Under overrideNoReadDay, fetchUnreadBodies:true on this call opens unread inbox messages as on a reading day; the env default alone does not.' + OVERRIDE_DESCRIPTION,
|
|
53454
53649
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
53455
53650
|
inputSchema: external_exports.object({
|
|
53456
53651
|
folders: external_exports.array(external_exports.enum(["inbox", "sent", "drafts"])).min(1).describe("Folders to sync (default: all three). Must be non-empty if given \u2014 an empty list would sync nothing while reporting success.").optional(),
|
|
@@ -53519,9 +53714,11 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53519
53714
|
const markedRead = result.markedRead ?? [];
|
|
53520
53715
|
for (const row of rows) markedRead.push(await openUnreadBody(client2, cache, row));
|
|
53521
53716
|
result.markedRead = markedRead;
|
|
53522
|
-
if (
|
|
53717
|
+
if (overriding) {
|
|
53523
53718
|
const openedIds = rows.map((row) => row.id);
|
|
53524
|
-
result.
|
|
53719
|
+
result.readOverride = true;
|
|
53720
|
+
result.readOverrideNote = READ_OVERRIDE_NOTE;
|
|
53721
|
+
result.readOverrideMessageIds = [...result.readOverrideMessageIds ?? [], ...openedIds];
|
|
53525
53722
|
auditReadOverride("ofw_sync_messages", openedIds);
|
|
53526
53723
|
}
|
|
53527
53724
|
}
|
|
@@ -55203,11 +55400,14 @@ function buildMessageFilter(opts) {
|
|
|
55203
55400
|
wheres.push("sent_at < ?");
|
|
55204
55401
|
params.push(opts.until);
|
|
55205
55402
|
}
|
|
55403
|
+
if (opts.unopenedInboxOnly) {
|
|
55404
|
+
wheres.push("folder = 'inbox' AND fetched_body_at IS NULL");
|
|
55405
|
+
}
|
|
55206
55406
|
if (opts.q !== void 0 && opts.q.length > 0) {
|
|
55207
55407
|
const pattern = `%${opts.q}%`;
|
|
55208
|
-
if (opts.
|
|
55209
|
-
wheres.push("subject LIKE ?");
|
|
55210
|
-
params.push(pattern);
|
|
55408
|
+
if (opts.qBodyReadOnly) {
|
|
55409
|
+
wheres.push("(subject LIKE ? OR (body LIKE ? AND (folder <> 'inbox' OR fetched_body_at IS NOT NULL)))");
|
|
55410
|
+
params.push(pattern, pattern);
|
|
55211
55411
|
} else {
|
|
55212
55412
|
wheres.push("(subject LIKE ? OR body LIKE ?)");
|
|
55213
55413
|
params.push(pattern, pattern);
|
package/dist/cache/store.js
CHANGED
|
@@ -156,11 +156,14 @@ function buildMessageFilter(opts) {
|
|
|
156
156
|
wheres.push('sent_at < ?');
|
|
157
157
|
params.push(opts.until);
|
|
158
158
|
}
|
|
159
|
+
if (opts.unopenedInboxOnly) {
|
|
160
|
+
wheres.push("folder = 'inbox' AND fetched_body_at IS NULL");
|
|
161
|
+
}
|
|
159
162
|
if (opts.q !== undefined && opts.q.length > 0) {
|
|
160
163
|
const pattern = `%${opts.q}%`;
|
|
161
|
-
if (opts.
|
|
162
|
-
wheres.push(
|
|
163
|
-
params.push(pattern);
|
|
164
|
+
if (opts.qBodyReadOnly) {
|
|
165
|
+
wheres.push("(subject LIKE ? OR (body LIKE ? AND (folder <> 'inbox' OR fetched_body_at IS NOT NULL)))");
|
|
166
|
+
params.push(pattern, pattern);
|
|
164
167
|
}
|
|
165
168
|
else {
|
|
166
169
|
wheres.push('(subject LIKE ? OR body LIKE ?)');
|