ofw-mcp 2.27.2 → 2.27.4
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 +5 -1
- package/dist/bundle.js +261 -148
- package/dist/sync.js +185 -33
- package/dist/tools/_shared.js +30 -10
- package/dist/tools/messages.js +30 -15
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/server.json +2 -2
- package/skills/ofw/SKILL.md +1 -1
- package/skills/ofw-fpx/references/requests.md +7 -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.27.
|
|
47855
|
+
var VERSION = "2.27.4";
|
|
47856
47856
|
|
|
47857
47857
|
// src/auth.ts
|
|
47858
47858
|
function fetchproxyDisabled() {
|
|
@@ -48497,17 +48497,18 @@ function reportsUnthreaded(detail) {
|
|
|
48497
48497
|
if (reportsThreaded(detail)) return false;
|
|
48498
48498
|
return detail.inReplyTo !== void 0 || detail.showContext !== void 0;
|
|
48499
48499
|
}
|
|
48500
|
-
function scrapeSaysRead(listData) {
|
|
48500
|
+
function scrapeSaysRead(folder, listData) {
|
|
48501
48501
|
if (typeof listData !== "object" || listData === null) return false;
|
|
48502
48502
|
const ld = listData;
|
|
48503
|
+
if (folder === "inbox") return ld.read === true;
|
|
48503
48504
|
return ld.read === true || ld.showNeverViewed === false;
|
|
48504
48505
|
}
|
|
48505
48506
|
function deriveRead(row) {
|
|
48506
48507
|
const viewedByAnyone = row.recipients.some((r) => r.viewedAt !== null);
|
|
48507
48508
|
if (row.folder === "inbox") {
|
|
48508
|
-
return viewedByAnyone || row.fetchedBodyAt !== null || scrapeSaysRead(row.listData);
|
|
48509
|
+
return viewedByAnyone || row.fetchedBodyAt !== null || scrapeSaysRead("inbox", row.listData);
|
|
48509
48510
|
}
|
|
48510
|
-
return viewedByAnyone || scrapeSaysRead(row.listData);
|
|
48511
|
+
return viewedByAnyone || scrapeSaysRead(row.folder, row.listData);
|
|
48511
48512
|
}
|
|
48512
48513
|
function withReadState(row) {
|
|
48513
48514
|
const read = deriveRead(row);
|
|
@@ -48713,6 +48714,101 @@ async function heldFilesFor(cache, draftIds) {
|
|
|
48713
48714
|
}
|
|
48714
48715
|
var HELD_NOTE = "OurFamilyWizard drafts do not store attachments, so these files are held with this draft by this server and attached when you send it with ofw_send_message (draftId). They are not visible on the draft in the OurFamilyWizard web app.";
|
|
48715
48716
|
|
|
48717
|
+
// src/tools/project.ts
|
|
48718
|
+
var MESSAGE_VIEWS = ["compact", "full"];
|
|
48719
|
+
var LABEL = "ofw-mcp";
|
|
48720
|
+
function asRecord(value) {
|
|
48721
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
48722
|
+
}
|
|
48723
|
+
function senderOf(row) {
|
|
48724
|
+
if (typeof row.fromUser === "string" && row.fromUser !== "") return row.fromUser;
|
|
48725
|
+
const author = asRecord(asRecord(row.listData)?.author);
|
|
48726
|
+
const name = author?.name;
|
|
48727
|
+
return typeof name === "string" && name !== "" ? name : null;
|
|
48728
|
+
}
|
|
48729
|
+
function fileCountOf(row) {
|
|
48730
|
+
const files = asRecord(row.listData)?.files;
|
|
48731
|
+
if (typeof files === "number") return files;
|
|
48732
|
+
if (Array.isArray(files)) return files.length;
|
|
48733
|
+
return void 0;
|
|
48734
|
+
}
|
|
48735
|
+
function repliedOf(row) {
|
|
48736
|
+
const replied = asRecord(row.listData)?.replied;
|
|
48737
|
+
return typeof replied === "boolean" ? replied : void 0;
|
|
48738
|
+
}
|
|
48739
|
+
function compactMessage(row) {
|
|
48740
|
+
const { listData: _drop, fromUser: _dropFrom, ...rest } = row;
|
|
48741
|
+
return pruneUndefined({
|
|
48742
|
+
id: rest.id,
|
|
48743
|
+
folder: rest.folder,
|
|
48744
|
+
subject: rest.subject,
|
|
48745
|
+
from: senderOf(row),
|
|
48746
|
+
sentAt: rest.sentAt,
|
|
48747
|
+
recipients: rest.recipients,
|
|
48748
|
+
read: rest.read,
|
|
48749
|
+
replied: repliedOf(row),
|
|
48750
|
+
files: fileCountOf(row),
|
|
48751
|
+
replyToId: rest.replyToId,
|
|
48752
|
+
chainRootId: rest.chainRootId,
|
|
48753
|
+
body: rest.body,
|
|
48754
|
+
fetchedBodyAt: rest.fetchedBodyAt,
|
|
48755
|
+
// Anything a TOOL added on top of the cache row — `attachments`,
|
|
48756
|
+
// `revision`, `cacheStatus`, `serverConfirmed`, `freshness` — is kept
|
|
48757
|
+
// wholesale. Those are this server's own answers, never OFW's echo, and a
|
|
48758
|
+
// projection that dropped one would be removing the thing the caller
|
|
48759
|
+
// asked for rather than the thing they got twice.
|
|
48760
|
+
...omitKnown(rest, MESSAGE_ROW_KEYS)
|
|
48761
|
+
});
|
|
48762
|
+
}
|
|
48763
|
+
var MESSAGE_ROW_KEYS = /* @__PURE__ */ new Set([
|
|
48764
|
+
"id",
|
|
48765
|
+
"folder",
|
|
48766
|
+
"subject",
|
|
48767
|
+
"sentAt",
|
|
48768
|
+
"recipients",
|
|
48769
|
+
"read",
|
|
48770
|
+
"replyToId",
|
|
48771
|
+
"chainRootId",
|
|
48772
|
+
"body",
|
|
48773
|
+
"fetchedBodyAt"
|
|
48774
|
+
]);
|
|
48775
|
+
var DRAFT_ROW_KEYS = /* @__PURE__ */ new Set(["id", "subject", "recipients", "replyToId", "modifiedAt", "body"]);
|
|
48776
|
+
function omitKnown(rest, own2) {
|
|
48777
|
+
const out = {};
|
|
48778
|
+
for (const [key2, value] of Object.entries(rest)) if (!own2.has(key2)) out[key2] = value;
|
|
48779
|
+
return out;
|
|
48780
|
+
}
|
|
48781
|
+
function compactDraft(row) {
|
|
48782
|
+
const { listData: _drop, ...rest } = row;
|
|
48783
|
+
return pruneUndefined({
|
|
48784
|
+
id: rest.id,
|
|
48785
|
+
subject: rest.subject,
|
|
48786
|
+
recipients: rest.recipients,
|
|
48787
|
+
replyToId: rest.replyToId,
|
|
48788
|
+
modifiedAt: rest.modifiedAt,
|
|
48789
|
+
body: rest.body,
|
|
48790
|
+
...omitKnown(rest, DRAFT_ROW_KEYS)
|
|
48791
|
+
});
|
|
48792
|
+
}
|
|
48793
|
+
function viewMessages(view, rows) {
|
|
48794
|
+
if (view !== "compact") return rows;
|
|
48795
|
+
return projectOrRaw(rows, (rs) => rs.map((r) => compactMessage(r)), {
|
|
48796
|
+
label: LABEL,
|
|
48797
|
+
context: "the cached message rows"
|
|
48798
|
+
});
|
|
48799
|
+
}
|
|
48800
|
+
function viewDrafts(view, rows) {
|
|
48801
|
+
if (view !== "compact") return rows;
|
|
48802
|
+
return projectOrRaw(rows, (rs) => rs.map((r) => compactDraft(r)), {
|
|
48803
|
+
label: LABEL,
|
|
48804
|
+
context: "the cached draft rows"
|
|
48805
|
+
});
|
|
48806
|
+
}
|
|
48807
|
+
function viewOne(view, row) {
|
|
48808
|
+
if (view !== "compact") return row;
|
|
48809
|
+
return projectOrRaw(row, (r) => compactMessage(r), { label: LABEL, context: "a cached message row" });
|
|
48810
|
+
}
|
|
48811
|
+
|
|
48716
48812
|
// src/read-days.ts
|
|
48717
48813
|
var WEEKDAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
|
|
48718
48814
|
var WEEKDAY_LABELS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
@@ -48877,6 +48973,7 @@ var ListItemSchema = external_exports.looseObject({
|
|
|
48877
48973
|
date: external_exports.looseObject({ dateTime: external_exports.string() }),
|
|
48878
48974
|
from: external_exports.looseObject({ name: external_exports.string().optional() }).optional(),
|
|
48879
48975
|
showNeverViewed: external_exports.boolean(),
|
|
48976
|
+
read: external_exports.boolean().optional(),
|
|
48880
48977
|
recipients: external_exports.array(ApiRecipientSchema).optional()
|
|
48881
48978
|
});
|
|
48882
48979
|
var ListResponseSchema = external_exports.looseObject({ data: external_exports.array(ListItemSchema).optional() });
|
|
@@ -48887,6 +48984,16 @@ var DetailResponseSchema = external_exports.looseObject({
|
|
|
48887
48984
|
// endpoint only has an epoch placeholder) — used by the view-status refresh.
|
|
48888
48985
|
recipients: external_exports.array(ApiRecipientSchema).optional()
|
|
48889
48986
|
});
|
|
48987
|
+
var STAMP_TOLERANCE_MS = 2e3;
|
|
48988
|
+
function stampedByFetch(viewedAt, startedAtMs) {
|
|
48989
|
+
if (viewedAt === null) return false;
|
|
48990
|
+
const at = parseTimestampValue("viewedAt", viewedAt, displayTimeZone());
|
|
48991
|
+
return at !== null && at.getTime() >= startedAtMs - STAMP_TOLERANCE_MS;
|
|
48992
|
+
}
|
|
48993
|
+
function latestViewedAt(recipients) {
|
|
48994
|
+
const times = mapRecipients(recipients).map((r) => r.viewedAt).filter((t) => t !== null);
|
|
48995
|
+
return times.length === 0 ? null : times.sort().at(-1);
|
|
48996
|
+
}
|
|
48890
48997
|
var maxId = (a, b) => a === null ? b : b === null ? a : Math.max(a, b);
|
|
48891
48998
|
async function walkPages(client2, folder, folderId, opts, store) {
|
|
48892
48999
|
const budget = opts.budget;
|
|
@@ -48895,9 +49002,34 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
48895
49002
|
let synced = 0;
|
|
48896
49003
|
let pagesFetched = 0;
|
|
48897
49004
|
const unread = [];
|
|
49005
|
+
const newMessages = [];
|
|
49006
|
+
const markedRead = [];
|
|
49007
|
+
const totals = () => ({ synced, unread, newMessages, markedRead, newestId, pagesFetched });
|
|
49008
|
+
const fetchDetail = async (item, row, context, deliberate) => {
|
|
49009
|
+
const startedAt = Date.now();
|
|
49010
|
+
const detail = parseLenient(
|
|
49011
|
+
DetailResponseSchema,
|
|
49012
|
+
await client2.request("GET", `/pub/v3/messages/${item.id}`),
|
|
49013
|
+
{ label: "ofw-mcp", context }
|
|
49014
|
+
);
|
|
49015
|
+
if (folder === "inbox") {
|
|
49016
|
+
const viewedAt = latestViewedAt(detail.recipients);
|
|
49017
|
+
if (deliberate || stampedByFetch(viewedAt, startedAt)) {
|
|
49018
|
+
markedRead.push({
|
|
49019
|
+
id: item.id,
|
|
49020
|
+
subject: row.subject,
|
|
49021
|
+
from: row.from,
|
|
49022
|
+
sentAt: row.sentAt,
|
|
49023
|
+
viewedAt,
|
|
49024
|
+
reason: deliberate ? "fetchUnreadBodies" : "unexpected"
|
|
49025
|
+
});
|
|
49026
|
+
}
|
|
49027
|
+
}
|
|
49028
|
+
return detail;
|
|
49029
|
+
};
|
|
48898
49030
|
while (true) {
|
|
48899
49031
|
if (!budget.take()) {
|
|
48900
|
-
return {
|
|
49032
|
+
return { ...totals(), done: false, nextPage: page };
|
|
48901
49033
|
}
|
|
48902
49034
|
const path = `/pub/v3/messages?folders=${encodeURIComponent(folderId)}&page=${page}&size=50&sort=date&sortDirection=desc`;
|
|
48903
49035
|
const list = parseLenient(
|
|
@@ -48908,7 +49040,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
48908
49040
|
pagesFetched++;
|
|
48909
49041
|
const items = list.data ?? [];
|
|
48910
49042
|
if (items.length === 0) {
|
|
48911
|
-
return {
|
|
49043
|
+
return { ...totals(), done: true, nextPage: null };
|
|
48912
49044
|
}
|
|
48913
49045
|
const existingById = new Map(
|
|
48914
49046
|
(await store.getMessages(items.map((it) => it.id))).map((row) => [row.id, row])
|
|
@@ -48919,17 +49051,19 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
48919
49051
|
for (const item of items) {
|
|
48920
49052
|
if (newestId === null || item.id > newestId) newestId = item.id;
|
|
48921
49053
|
const existing = existingById.get(item.id);
|
|
48922
|
-
const
|
|
49054
|
+
const listRead = scrapeSaysRead(folder, item);
|
|
49055
|
+
const isInboxUnread = folder === "inbox" && !listRead;
|
|
48923
49056
|
if (existing) {
|
|
48924
49057
|
if (opts.fetchBodies && existing.body === null && !isInboxUnread) {
|
|
48925
49058
|
if (!budget.take()) {
|
|
48926
49059
|
pageBudgetHit = true;
|
|
48927
49060
|
break;
|
|
48928
49061
|
}
|
|
48929
|
-
const detail =
|
|
48930
|
-
|
|
48931
|
-
|
|
48932
|
-
|
|
49062
|
+
const detail = await fetchDetail(
|
|
49063
|
+
item,
|
|
49064
|
+
{ subject: existing.subject, sentAt: existing.sentAt, from: senderOf(existing) },
|
|
49065
|
+
"GET /pub/v3/messages/{id} (body backfill)",
|
|
49066
|
+
false
|
|
48933
49067
|
);
|
|
48934
49068
|
toUpsert.push({
|
|
48935
49069
|
...existing,
|
|
@@ -48966,43 +49100,54 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
48966
49100
|
let fetchedBodyAt = null;
|
|
48967
49101
|
let detailFileIds = [];
|
|
48968
49102
|
let detailRecipients;
|
|
49103
|
+
const row = {
|
|
49104
|
+
id: item.id,
|
|
49105
|
+
folder,
|
|
49106
|
+
subject: item.subject ?? "(no subject)",
|
|
49107
|
+
fromUser: item.from?.name ?? "",
|
|
49108
|
+
sentAt: item.date?.dateTime ?? nowNaiveWallClock(),
|
|
49109
|
+
recipients: mapRecipients(item.recipients),
|
|
49110
|
+
body: null,
|
|
49111
|
+
fetchedBodyAt: null,
|
|
49112
|
+
replyToId: null,
|
|
49113
|
+
chainRootId: null,
|
|
49114
|
+
listData: item
|
|
49115
|
+
};
|
|
49116
|
+
const from = senderOf(row);
|
|
48969
49117
|
if (shouldFetchBody) {
|
|
48970
49118
|
if (!budget.take()) {
|
|
48971
49119
|
pageBudgetHit = true;
|
|
48972
49120
|
break;
|
|
48973
49121
|
}
|
|
48974
|
-
const detail =
|
|
48975
|
-
DetailResponseSchema,
|
|
48976
|
-
await client2.request("GET", `/pub/v3/messages/${item.id}`),
|
|
48977
|
-
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (sync)" }
|
|
48978
|
-
);
|
|
49122
|
+
const detail = await fetchDetail(item, { subject: row.subject, sentAt: row.sentAt, from }, "GET /pub/v3/messages/{id} (sync)", isInboxUnread);
|
|
48979
49123
|
body = detail.body ?? "";
|
|
48980
49124
|
fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
48981
49125
|
detailRecipients = detail.recipients;
|
|
48982
49126
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
48983
49127
|
detailFileIds = detail.files;
|
|
48984
49128
|
}
|
|
48985
|
-
}
|
|
49129
|
+
}
|
|
49130
|
+
if (isInboxUnread) {
|
|
48986
49131
|
unread.push({
|
|
48987
49132
|
id: item.id,
|
|
48988
49133
|
subject: item.subject,
|
|
48989
|
-
from:
|
|
48990
|
-
sentAt: item.date.dateTime
|
|
49134
|
+
from: from ?? "",
|
|
49135
|
+
sentAt: item.date.dateTime,
|
|
49136
|
+
bodyFetched: shouldFetchBody
|
|
48991
49137
|
});
|
|
48992
49138
|
}
|
|
48993
|
-
|
|
49139
|
+
newMessages.push({
|
|
48994
49140
|
id: item.id,
|
|
48995
49141
|
folder,
|
|
48996
|
-
|
|
48997
|
-
|
|
48998
|
-
sentAt:
|
|
48999
|
-
|
|
49000
|
-
|
|
49001
|
-
|
|
49002
|
-
|
|
49003
|
-
|
|
49004
|
-
|
|
49005
|
-
};
|
|
49142
|
+
from,
|
|
49143
|
+
subject: row.subject,
|
|
49144
|
+
sentAt: row.sentAt,
|
|
49145
|
+
read: listRead,
|
|
49146
|
+
bodyFetched: shouldFetchBody
|
|
49147
|
+
});
|
|
49148
|
+
row.body = body;
|
|
49149
|
+
row.fetchedBodyAt = fetchedBodyAt;
|
|
49150
|
+
if (detailRecipients) row.recipients = mapRecipients(detailRecipients);
|
|
49006
49151
|
toUpsert.push(row);
|
|
49007
49152
|
synced++;
|
|
49008
49153
|
if (detailFileIds.length > 0) {
|
|
@@ -49011,10 +49156,10 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49011
49156
|
}
|
|
49012
49157
|
if (toUpsert.length > 0) await store.upsertMessages(toUpsert);
|
|
49013
49158
|
if (pageBudgetHit) {
|
|
49014
|
-
return {
|
|
49159
|
+
return { ...totals(), done: false, nextPage: page };
|
|
49015
49160
|
}
|
|
49016
49161
|
if (opts.stopAtCachedPage && !pageHadNewItem) {
|
|
49017
|
-
return {
|
|
49162
|
+
return { ...totals(), done: true, nextPage: page };
|
|
49018
49163
|
}
|
|
49019
49164
|
page++;
|
|
49020
49165
|
}
|
|
@@ -49033,6 +49178,8 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
|
|
|
49033
49178
|
}, store);
|
|
49034
49179
|
let synced = fwd.synced;
|
|
49035
49180
|
const unread = [...fwd.unread];
|
|
49181
|
+
const newMessages = [...fwd.newMessages];
|
|
49182
|
+
const markedRead = [...fwd.markedRead];
|
|
49036
49183
|
let newestId = maxId(saved?.newestId ?? null, fwd.newestId);
|
|
49037
49184
|
let done;
|
|
49038
49185
|
let resumePage;
|
|
@@ -49059,6 +49206,8 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
|
|
|
49059
49206
|
}, store);
|
|
49060
49207
|
synced += bf.synced;
|
|
49061
49208
|
unread.push(...bf.unread);
|
|
49209
|
+
newMessages.push(...bf.newMessages);
|
|
49210
|
+
markedRead.push(...bf.markedRead);
|
|
49062
49211
|
newestId = maxId(newestId, bf.newestId);
|
|
49063
49212
|
done = bf.done;
|
|
49064
49213
|
resumePage = bf.done ? null : bf.nextPage;
|
|
@@ -49066,7 +49215,7 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
|
|
|
49066
49215
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
49067
49216
|
await store.setSyncState(folder, { lastSyncAt: now, newestId, resumePage });
|
|
49068
49217
|
if (fwd.done) await markFolderVerified(store, folder, now);
|
|
49069
|
-
return { synced, unread, done, verified: fwd.done };
|
|
49218
|
+
return { synced, unread, newMessages, markedRead, done, verified: fwd.done };
|
|
49070
49219
|
}
|
|
49071
49220
|
var DraftListItemSchema = external_exports.looseObject({
|
|
49072
49221
|
id: external_exports.number(),
|
|
@@ -49189,9 +49338,40 @@ async function syncDrafts(client2, draftsFolderId, store, budget) {
|
|
|
49189
49338
|
await markFolderVerified(store, "drafts", now);
|
|
49190
49339
|
return { synced, done: true };
|
|
49191
49340
|
}
|
|
49341
|
+
var NEW_MESSAGES_CAP = 50;
|
|
49342
|
+
function newestFirst(a, b) {
|
|
49343
|
+
if (a.sentAt !== b.sentAt) return a.sentAt < b.sentAt ? 1 : -1;
|
|
49344
|
+
return b.id - a.id;
|
|
49345
|
+
}
|
|
49192
49346
|
function unreadInboxNote(count) {
|
|
49193
49347
|
return `${count} unread inbox messages cached without bodies. Call ofw_get_message(id) to read them \u2014 this will mark them as read on OFW.`;
|
|
49194
49348
|
}
|
|
49349
|
+
var MARKED_READ_LEAD = "MARKED READ on OurFamilyWizard by this sync:";
|
|
49350
|
+
function markedReadNote(markedRead) {
|
|
49351
|
+
const unexpected = markedRead.filter((m) => m.reason === "unexpected").length;
|
|
49352
|
+
return `${MARKED_READ_LEAD} ${markedRead.length} inbox message${markedRead.length === 1 ? "" : "s"} (ids ${markedRead.map((m) => m.id).join(", ")}). Each now carries a "First Viewed" time your co-parent can see; it cannot be undone.${unexpected > 0 ? ` ${unexpected} of them ${unexpected === 1 ? "was" : "were"} NOT requested (reason "unexpected").` : ""}`;
|
|
49353
|
+
}
|
|
49354
|
+
function markedReadWarning(markedRead) {
|
|
49355
|
+
const unexpected = markedRead.filter((m) => m.reason === "unexpected").length;
|
|
49356
|
+
return `WARNING: this sync marked ${markedRead.length} inbox message${markedRead.length === 1 ? "" : "s"} READ on OurFamilyWizard (see markedRead). Your co-parent can see the "First Viewed" time, and it cannot be undone.${unexpected > 0 ? ` ${unexpected} of them ${unexpected === 1 ? "was" : "were"} NOT requested: the list reported ${unexpected === 1 ? "it" : "them"} as already read, but the fetch stamped ${unexpected === 1 ? "it" : "them"}. Tell the user, and report this as a bug.` : ""}`;
|
|
49357
|
+
}
|
|
49358
|
+
function refreshReadReporting(result) {
|
|
49359
|
+
const markedRead = result.markedRead ?? [];
|
|
49360
|
+
const notes = (result.note === void 0 ? [] : result.note.split("\n\n")).filter((n) => !n.startsWith(MARKED_READ_LEAD) && !/^\d+ unread inbox messages cached without bodies\./.test(n));
|
|
49361
|
+
const bodiless = result.unreadInbox.filter((h) => !h.bodyFetched).length;
|
|
49362
|
+
if (bodiless > 0) notes.push(unreadInboxNote(bodiless));
|
|
49363
|
+
if (markedRead.length > 0) notes.unshift(markedReadNote(markedRead));
|
|
49364
|
+
result.note = notes.length > 0 ? notes.join("\n\n") : void 0;
|
|
49365
|
+
if (result.note === void 0) delete result.note;
|
|
49366
|
+
result.markedReadCount = markedRead.length;
|
|
49367
|
+
if (markedRead.length > 0) {
|
|
49368
|
+
result.warning = markedReadWarning(markedRead);
|
|
49369
|
+
result.markedRead = markedRead;
|
|
49370
|
+
} else {
|
|
49371
|
+
delete result.warning;
|
|
49372
|
+
delete result.markedRead;
|
|
49373
|
+
}
|
|
49374
|
+
}
|
|
49195
49375
|
async function syncAll(client2, opts, store) {
|
|
49196
49376
|
const requested = opts.folders ?? ["inbox", "sent", "drafts"];
|
|
49197
49377
|
const folders = [
|
|
@@ -49204,6 +49384,8 @@ async function syncAll(client2, opts, store) {
|
|
|
49204
49384
|
const ids = await resolveFolderIds(client2, store);
|
|
49205
49385
|
const synced = {};
|
|
49206
49386
|
let unreadInbox = [];
|
|
49387
|
+
const newMessages = [];
|
|
49388
|
+
const markedRead = [];
|
|
49207
49389
|
let done = true;
|
|
49208
49390
|
let draftsUnverified = false;
|
|
49209
49391
|
const refreshed = [];
|
|
@@ -49226,6 +49408,8 @@ async function syncAll(client2, opts, store) {
|
|
|
49226
49408
|
}, store);
|
|
49227
49409
|
record2("inbox", r.verified, r.synced);
|
|
49228
49410
|
unreadInbox = r.unread;
|
|
49411
|
+
newMessages.push(...r.newMessages);
|
|
49412
|
+
markedRead.push(...r.markedRead);
|
|
49229
49413
|
if (!r.done) done = false;
|
|
49230
49414
|
} else if (folder === "sent") {
|
|
49231
49415
|
const r = await syncMessageFolder(client2, "sent", ids.sent, {
|
|
@@ -49235,6 +49419,7 @@ async function syncAll(client2, opts, store) {
|
|
|
49235
49419
|
budget
|
|
49236
49420
|
}, store);
|
|
49237
49421
|
record2("sent", r.verified, r.synced);
|
|
49422
|
+
newMessages.push(...r.newMessages);
|
|
49238
49423
|
if (!r.done) done = false;
|
|
49239
49424
|
} else if (folder === "drafts") {
|
|
49240
49425
|
const r = await syncDrafts(client2, ids.drafts, store, budget);
|
|
@@ -49252,9 +49437,6 @@ async function syncAll(client2, opts, store) {
|
|
|
49252
49437
|
if (draftsUnverified) {
|
|
49253
49438
|
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.');
|
|
49254
49439
|
}
|
|
49255
|
-
if (unreadInbox.length > 0) {
|
|
49256
|
-
notes.push(unreadInboxNote(unreadInbox.length));
|
|
49257
|
-
}
|
|
49258
49440
|
if (notRefreshed.length > 0) {
|
|
49259
49441
|
notes.push(`NOT checked against OurFamilyWizard on this call: ${notRefreshed.join(", ")}. No count is reported for ${notRefreshed.length > 1 ? "those folders" : "that folder"} \u2014 absence of a count means "not looked at", not "no changes". Cached contents may be behind the server; call ofw_sync_messages again to finish, or ofw_check_freshness for a cheap live confirmation.`);
|
|
49260
49442
|
}
|
|
@@ -49262,16 +49444,25 @@ async function syncAll(client2, opts, store) {
|
|
|
49262
49444
|
notes.push("Paused after the request budget to stay within the hosting limit; more pages remain \u2014 call ofw_sync_messages again with the same arguments to resume where it left off and continue the backfill.");
|
|
49263
49445
|
}
|
|
49264
49446
|
const note = notes.length > 0 ? notes.join("\n\n") : void 0;
|
|
49265
|
-
|
|
49447
|
+
newMessages.sort(newestFirst);
|
|
49448
|
+
const result = {
|
|
49449
|
+
warning: void 0,
|
|
49266
49450
|
synced,
|
|
49451
|
+
markedReadCount: 0,
|
|
49452
|
+
newMessagesTotal: newMessages.length,
|
|
49453
|
+
newMessagesTruncated: newMessages.length > NEW_MESSAGES_CAP,
|
|
49267
49454
|
unreadInbox,
|
|
49268
49455
|
done,
|
|
49269
49456
|
syncComplete: done,
|
|
49270
49457
|
refreshed,
|
|
49271
49458
|
notRefreshed,
|
|
49272
49459
|
...readingBlocked ? { bodiesWithheld: true } : {},
|
|
49273
|
-
|
|
49460
|
+
note,
|
|
49461
|
+
markedRead,
|
|
49462
|
+
newMessages: newMessages.slice(0, NEW_MESSAGES_CAP)
|
|
49274
49463
|
};
|
|
49464
|
+
refreshReadReporting(result);
|
|
49465
|
+
return result;
|
|
49275
49466
|
}
|
|
49276
49467
|
|
|
49277
49468
|
// src/config.ts
|
|
@@ -50083,7 +50274,7 @@ function toArrayBuffer(view) {
|
|
|
50083
50274
|
const buf = view.buffer;
|
|
50084
50275
|
if (buf instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === buf.byteLength)
|
|
50085
50276
|
return buf;
|
|
50086
|
-
return
|
|
50277
|
+
return Uint8Array.prototype.slice.call(view).buffer;
|
|
50087
50278
|
}
|
|
50088
50279
|
function createBlobStore(opts) {
|
|
50089
50280
|
const { base, prefix } = parseBase(opts.baseUrl);
|
|
@@ -50355,6 +50546,10 @@ function uploadFileNameFromKey(key2, opts = {}) {
|
|
|
50355
50546
|
return sanitizeUploadFilename(Buffer.from(match[1], "base64url").toString("utf8"));
|
|
50356
50547
|
}
|
|
50357
50548
|
|
|
50549
|
+
// node_modules/@chrischall/mcp-utils/dist/export/deliver.js
|
|
50550
|
+
var INLINE_DELIVERY_MAX_BYTES = 10 * 1024 * 1024;
|
|
50551
|
+
var DELIVERY_LINK_DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
50552
|
+
|
|
50358
50553
|
// src/tools/uploads.ts
|
|
50359
50554
|
import { createHash as createHash6 } from "node:crypto";
|
|
50360
50555
|
var MAX_FILES_PER_CALL = MAX_UPLOAD_FILES;
|
|
@@ -51496,7 +51691,7 @@ function pageState(input2) {
|
|
|
51496
51691
|
const hasMore = input2.page * input2.size < input2.total;
|
|
51497
51692
|
return { hasMore, nextPage: hasMore ? input2.page + 1 : null };
|
|
51498
51693
|
}
|
|
51499
|
-
function
|
|
51694
|
+
function asRecord2(value) {
|
|
51500
51695
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
51501
51696
|
}
|
|
51502
51697
|
function recordArray(root) {
|
|
@@ -51507,9 +51702,9 @@ function recordArray(root) {
|
|
|
51507
51702
|
return null;
|
|
51508
51703
|
}
|
|
51509
51704
|
function readUpstreamPaging(payload) {
|
|
51510
|
-
const root =
|
|
51705
|
+
const root = asRecord2(payload);
|
|
51511
51706
|
const rows = root === null ? null : recordArray(root);
|
|
51512
|
-
const meta3 = root === null ? null :
|
|
51707
|
+
const meta3 = root === null ? null : asRecord2(root.metadata);
|
|
51513
51708
|
const total = meta3 !== null && typeof meta3.totalElements === "number" && Number.isFinite(meta3.totalElements) ? meta3.totalElements : null;
|
|
51514
51709
|
const last = meta3 !== null && typeof meta3.last === "boolean" ? meta3.last : null;
|
|
51515
51710
|
return { returned: rows?.length ?? 0, total, last };
|
|
@@ -51521,7 +51716,7 @@ function offsetState(input2) {
|
|
|
51521
51716
|
return { hasMore, nextStart: hasMore ? input2.start + input2.max : null };
|
|
51522
51717
|
}
|
|
51523
51718
|
function withPaginationFirst(input2) {
|
|
51524
|
-
const body =
|
|
51719
|
+
const body = asRecord2(input2.payload);
|
|
51525
51720
|
if (body === null) return null;
|
|
51526
51721
|
const scope = input2.total !== null ? ` of ${input2.total}` : "";
|
|
51527
51722
|
const head = {
|
|
@@ -51536,101 +51731,6 @@ function withPaginationFirst(input2) {
|
|
|
51536
51731
|
return { ...head, ...body, ...head };
|
|
51537
51732
|
}
|
|
51538
51733
|
|
|
51539
|
-
// src/tools/project.ts
|
|
51540
|
-
var MESSAGE_VIEWS = ["compact", "full"];
|
|
51541
|
-
var LABEL = "ofw-mcp";
|
|
51542
|
-
function asRecord2(value) {
|
|
51543
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
51544
|
-
}
|
|
51545
|
-
function senderOf(row) {
|
|
51546
|
-
if (typeof row.fromUser === "string" && row.fromUser !== "") return row.fromUser;
|
|
51547
|
-
const author = asRecord2(asRecord2(row.listData)?.author);
|
|
51548
|
-
const name = author?.name;
|
|
51549
|
-
return typeof name === "string" && name !== "" ? name : null;
|
|
51550
|
-
}
|
|
51551
|
-
function fileCountOf(row) {
|
|
51552
|
-
const files = asRecord2(row.listData)?.files;
|
|
51553
|
-
if (typeof files === "number") return files;
|
|
51554
|
-
if (Array.isArray(files)) return files.length;
|
|
51555
|
-
return void 0;
|
|
51556
|
-
}
|
|
51557
|
-
function repliedOf(row) {
|
|
51558
|
-
const replied = asRecord2(row.listData)?.replied;
|
|
51559
|
-
return typeof replied === "boolean" ? replied : void 0;
|
|
51560
|
-
}
|
|
51561
|
-
function compactMessage(row) {
|
|
51562
|
-
const { listData: _drop, fromUser: _dropFrom, ...rest } = row;
|
|
51563
|
-
return pruneUndefined({
|
|
51564
|
-
id: rest.id,
|
|
51565
|
-
folder: rest.folder,
|
|
51566
|
-
subject: rest.subject,
|
|
51567
|
-
from: senderOf(row),
|
|
51568
|
-
sentAt: rest.sentAt,
|
|
51569
|
-
recipients: rest.recipients,
|
|
51570
|
-
read: rest.read,
|
|
51571
|
-
replied: repliedOf(row),
|
|
51572
|
-
files: fileCountOf(row),
|
|
51573
|
-
replyToId: rest.replyToId,
|
|
51574
|
-
chainRootId: rest.chainRootId,
|
|
51575
|
-
body: rest.body,
|
|
51576
|
-
fetchedBodyAt: rest.fetchedBodyAt,
|
|
51577
|
-
// Anything a TOOL added on top of the cache row — `attachments`,
|
|
51578
|
-
// `revision`, `cacheStatus`, `serverConfirmed`, `freshness` — is kept
|
|
51579
|
-
// wholesale. Those are this server's own answers, never OFW's echo, and a
|
|
51580
|
-
// projection that dropped one would be removing the thing the caller
|
|
51581
|
-
// asked for rather than the thing they got twice.
|
|
51582
|
-
...omitKnown(rest, MESSAGE_ROW_KEYS)
|
|
51583
|
-
});
|
|
51584
|
-
}
|
|
51585
|
-
var MESSAGE_ROW_KEYS = /* @__PURE__ */ new Set([
|
|
51586
|
-
"id",
|
|
51587
|
-
"folder",
|
|
51588
|
-
"subject",
|
|
51589
|
-
"sentAt",
|
|
51590
|
-
"recipients",
|
|
51591
|
-
"read",
|
|
51592
|
-
"replyToId",
|
|
51593
|
-
"chainRootId",
|
|
51594
|
-
"body",
|
|
51595
|
-
"fetchedBodyAt"
|
|
51596
|
-
]);
|
|
51597
|
-
var DRAFT_ROW_KEYS = /* @__PURE__ */ new Set(["id", "subject", "recipients", "replyToId", "modifiedAt", "body"]);
|
|
51598
|
-
function omitKnown(rest, own2) {
|
|
51599
|
-
const out = {};
|
|
51600
|
-
for (const [key2, value] of Object.entries(rest)) if (!own2.has(key2)) out[key2] = value;
|
|
51601
|
-
return out;
|
|
51602
|
-
}
|
|
51603
|
-
function compactDraft(row) {
|
|
51604
|
-
const { listData: _drop, ...rest } = row;
|
|
51605
|
-
return pruneUndefined({
|
|
51606
|
-
id: rest.id,
|
|
51607
|
-
subject: rest.subject,
|
|
51608
|
-
recipients: rest.recipients,
|
|
51609
|
-
replyToId: rest.replyToId,
|
|
51610
|
-
modifiedAt: rest.modifiedAt,
|
|
51611
|
-
body: rest.body,
|
|
51612
|
-
...omitKnown(rest, DRAFT_ROW_KEYS)
|
|
51613
|
-
});
|
|
51614
|
-
}
|
|
51615
|
-
function viewMessages(view, rows) {
|
|
51616
|
-
if (view !== "compact") return rows;
|
|
51617
|
-
return projectOrRaw(rows, (rs) => rs.map((r) => compactMessage(r)), {
|
|
51618
|
-
label: LABEL,
|
|
51619
|
-
context: "the cached message rows"
|
|
51620
|
-
});
|
|
51621
|
-
}
|
|
51622
|
-
function viewDrafts(view, rows) {
|
|
51623
|
-
if (view !== "compact") return rows;
|
|
51624
|
-
return projectOrRaw(rows, (rs) => rs.map((r) => compactDraft(r)), {
|
|
51625
|
-
label: LABEL,
|
|
51626
|
-
context: "the cached draft rows"
|
|
51627
|
-
});
|
|
51628
|
-
}
|
|
51629
|
-
function viewOne(view, row) {
|
|
51630
|
-
if (view !== "compact") return row;
|
|
51631
|
-
return projectOrRaw(row, (r) => compactMessage(r), { label: LABEL, context: "a cached message row" });
|
|
51632
|
-
}
|
|
51633
|
-
|
|
51634
51734
|
// src/tools/messages.ts
|
|
51635
51735
|
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.";
|
|
51636
51736
|
async function describeDraftKey(cache, id2) {
|
|
@@ -51798,6 +51898,14 @@ async function openUnreadBody(client2, cache, cached2) {
|
|
|
51798
51898
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
51799
51899
|
await fetchAttachmentMetaForMessage(client2, cached2.id, detail.files, cache);
|
|
51800
51900
|
}
|
|
51901
|
+
return {
|
|
51902
|
+
id: cached2.id,
|
|
51903
|
+
subject: cached2.subject,
|
|
51904
|
+
from: senderOf(cached2),
|
|
51905
|
+
sentAt: cached2.sentAt,
|
|
51906
|
+
viewedAt: latestViewedAt(detail.recipients),
|
|
51907
|
+
reason: "fetchUnreadBodies"
|
|
51908
|
+
};
|
|
51801
51909
|
}
|
|
51802
51910
|
async function confirmMarkRead(ctx, cached2, args) {
|
|
51803
51911
|
if (!getConfirmMarkRead()) return void 0;
|
|
@@ -53200,7 +53308,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53200
53308
|
_meta: familyMeta("other"),
|
|
53201
53309
|
// Destructive: fetchUnreadBodies:true stamps a co-parent-visible "First
|
|
53202
53310
|
// Viewed" time on every unread inbox message it touches — irreversible.
|
|
53203
|
-
description:
|
|
53311
|
+
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) no inbox or sent message body is downloaded at all \u2014 new messages are cached from the list (sender, date, subject) and the response carries bodiesWithheld:true; the first sync on a reading day fills in those bodies, except unread inbox ones.',
|
|
53204
53312
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
53205
53313
|
inputSchema: external_exports.object({
|
|
53206
53314
|
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(),
|
|
@@ -53257,23 +53365,28 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53257
53365
|
confirmToken: args.confirmToken
|
|
53258
53366
|
});
|
|
53259
53367
|
if (gate) return gate;
|
|
53260
|
-
|
|
53368
|
+
const markedRead = result.markedRead ?? [];
|
|
53369
|
+
for (const row of rows) markedRead.push(await openUnreadBody(client2, cache, row));
|
|
53370
|
+
result.markedRead = markedRead;
|
|
53261
53371
|
}
|
|
53262
53372
|
const opened = new Set(rows.map((row) => row.id));
|
|
53263
|
-
|
|
53264
|
-
result.
|
|
53265
|
-
|
|
53266
|
-
const notes = result.note.split("\n\n").filter((n) => n !== unreadInboxNote(before));
|
|
53267
|
-
if (result.unreadInbox.length > 0) notes.push(unreadInboxNote(result.unreadInbox.length));
|
|
53268
|
-
result.note = notes.length > 0 ? notes.join("\n\n") : void 0;
|
|
53269
|
-
}
|
|
53373
|
+
result.unreadInbox = result.unreadInbox.map((hint) => opened.has(hint.id) ? { ...hint, bodyFetched: true } : hint);
|
|
53374
|
+
result.newMessages = result.newMessages.map((m) => opened.has(m.id) ? { ...m, bodyFetched: true } : m);
|
|
53375
|
+
refreshReadReporting(result);
|
|
53270
53376
|
unreadBodies = { requested: true, fetched: true, opened: [...opened], ...remaining > 0 ? { remaining } : {} };
|
|
53271
53377
|
}
|
|
53272
53378
|
const freshness = await buildFreshness(cache, {
|
|
53273
53379
|
source: "cache",
|
|
53274
53380
|
folders: args.folders ?? ["inbox", "sent", "drafts"]
|
|
53275
53381
|
});
|
|
53276
|
-
|
|
53382
|
+
const { warning, newMessages, ...rest } = result;
|
|
53383
|
+
return jsonResponse({
|
|
53384
|
+
...warning ? { warning } : {},
|
|
53385
|
+
...rest,
|
|
53386
|
+
...unreadBodies ? { unreadBodies } : {},
|
|
53387
|
+
freshness,
|
|
53388
|
+
newMessages
|
|
53389
|
+
});
|
|
53277
53390
|
});
|
|
53278
53391
|
server.registerTool("ofw_check_freshness", {
|
|
53279
53392
|
_meta: familyMeta("other"),
|