ofw-mcp 2.29.0 → 2.29.1
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/dist/bundle.js +75 -22
- package/dist/sync.js +14 -9
- package/dist/timestamps.js +4 -0
- package/dist/tools/_shared.js +71 -15
- package/dist/tools/messages.js +22 -12
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/ofw/SKILL.md +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "OurFamilyWizard tools for Claude Code",
|
|
9
|
-
"version": "2.29.
|
|
9
|
+
"version": "2.29.1"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"displayName": "OurFamilyWizard",
|
|
15
15
|
"source": "./",
|
|
16
16
|
"description": "OurFamilyWizard co-parenting tools for Claude — messages, calendar, expenses, and journal via MCP",
|
|
17
|
-
"version": "2.29.
|
|
17
|
+
"version": "2.29.1",
|
|
18
18
|
"author": {
|
|
19
19
|
"name": "Chris Chall"
|
|
20
20
|
},
|
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.29.
|
|
47855
|
+
var VERSION = "2.29.1";
|
|
47856
47856
|
|
|
47857
47857
|
// src/auth.ts
|
|
47858
47858
|
function fetchproxyDisabled() {
|
|
@@ -48325,6 +48325,10 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
|
48325
48325
|
// OFW: UTC instants we stamp ourselves.
|
|
48326
48326
|
"fetchedBodyAt",
|
|
48327
48327
|
"fetchedAt",
|
|
48328
|
+
// When the detail behind a recipient's `viewedAt` was read (issue #448).
|
|
48329
|
+
// NOT `viewedPlaceholder`: that is OFW's raw epoch-zero placeholder, kept
|
|
48330
|
+
// verbatim precisely so it can never be rendered as a real time.
|
|
48331
|
+
"viewedAtCheckedAt",
|
|
48328
48332
|
"syncedAt",
|
|
48329
48333
|
"downloadedAt",
|
|
48330
48334
|
"recordedAt",
|
|
@@ -48477,12 +48481,52 @@ var ApiRecipientSchema = external_exports.looseObject({
|
|
|
48477
48481
|
}).optional(),
|
|
48478
48482
|
viewed: external_exports.looseObject({ dateTime: external_exports.string() }).nullable().optional()
|
|
48479
48483
|
});
|
|
48480
|
-
function mapRecipients(items) {
|
|
48484
|
+
function mapRecipients(items, origin) {
|
|
48481
48485
|
return (items ?? []).map((r) => {
|
|
48482
48486
|
const dt = r.viewed?.dateTime;
|
|
48483
|
-
const
|
|
48484
|
-
|
|
48487
|
+
const placeholder = typeof dt === "string" && dt.startsWith("1970-01-01");
|
|
48488
|
+
const viewedAt = typeof dt === "string" && !placeholder ? dt : null;
|
|
48489
|
+
const out = { userId: r.user?.userId ?? r.user?.id ?? 0, name: r.user?.name ?? "", viewedAt };
|
|
48490
|
+
if (origin) {
|
|
48491
|
+
out.viewedAtSource = origin.source;
|
|
48492
|
+
if (origin.source === "detail" && origin.checkedAt !== void 0) out.viewedAtCheckedAt = origin.checkedAt;
|
|
48493
|
+
if (placeholder) out.viewedPlaceholder = dt;
|
|
48494
|
+
}
|
|
48495
|
+
return out;
|
|
48496
|
+
});
|
|
48497
|
+
}
|
|
48498
|
+
function detailRecipients(items, checkedAt) {
|
|
48499
|
+
return items && items.length > 0 ? mapRecipients(items, { source: "detail", checkedAt }) : null;
|
|
48500
|
+
}
|
|
48501
|
+
function sameRecipient(a, b) {
|
|
48502
|
+
if (a.userId !== 0 && b.userId !== 0) return a.userId === b.userId;
|
|
48503
|
+
return a.name !== "" && a.name === b.name;
|
|
48504
|
+
}
|
|
48505
|
+
function mergeRecipients(prior, fresh) {
|
|
48506
|
+
if (fresh === null || fresh.length === 0) return prior ?? [];
|
|
48507
|
+
const priorList = prior ?? [];
|
|
48508
|
+
return fresh.map((r) => {
|
|
48509
|
+
if (hasRealView([r])) return r;
|
|
48510
|
+
const match = priorList.find((p) => sameRecipient(p, r) && hasRealView([p]));
|
|
48511
|
+
if (!match) return r;
|
|
48512
|
+
const carried = { userId: r.userId, name: r.name, viewedAt: match.viewedAt };
|
|
48513
|
+
if (match.viewedAtSource !== void 0) carried.viewedAtSource = match.viewedAtSource;
|
|
48514
|
+
if (match.viewedAtCheckedAt !== void 0) carried.viewedAtCheckedAt = match.viewedAtCheckedAt;
|
|
48515
|
+
return carried;
|
|
48516
|
+
});
|
|
48517
|
+
}
|
|
48518
|
+
function withViewOrigin(row, callStartedAtMs) {
|
|
48519
|
+
const recipients = row.recipients.map((r) => {
|
|
48520
|
+
let viewedAtOrigin;
|
|
48521
|
+
if (r.viewedAtSource === "detail") {
|
|
48522
|
+
const at = r.viewedAtCheckedAt === void 0 ? NaN : Date.parse(r.viewedAtCheckedAt);
|
|
48523
|
+
viewedAtOrigin = at >= callStartedAtMs ? "detail-this-call" : "detail-cached";
|
|
48524
|
+
} else {
|
|
48525
|
+
viewedAtOrigin = r.viewedAtSource ?? "unrecorded";
|
|
48526
|
+
}
|
|
48527
|
+
return { ...r, viewedAtOrigin };
|
|
48485
48528
|
});
|
|
48529
|
+
return { ...row, recipients };
|
|
48486
48530
|
}
|
|
48487
48531
|
function hasRealView(recipients) {
|
|
48488
48532
|
return recipients.some((r) => r.viewedAt !== null && !r.viewedAt.startsWith("1970-01-01"));
|
|
@@ -49129,11 +49173,15 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49129
49173
|
"GET /pub/v3/messages/{id} (body backfill)",
|
|
49130
49174
|
false
|
|
49131
49175
|
);
|
|
49176
|
+
const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
49132
49177
|
toUpsert.push({
|
|
49133
49178
|
...existing,
|
|
49134
49179
|
body: detail.body ?? "",
|
|
49135
|
-
fetchedBodyAt:
|
|
49136
|
-
|
|
49180
|
+
fetchedBodyAt: checkedAt,
|
|
49181
|
+
// A detail that omits recipients (or a view time) must not erase
|
|
49182
|
+
// what the cache already recorded — and the LIST's recipients
|
|
49183
|
+
// carry only a placeholder, so they are never a substitute.
|
|
49184
|
+
recipients: mergeRecipients(existing.recipients, detailRecipients(detail.recipients, checkedAt)),
|
|
49137
49185
|
listData: item
|
|
49138
49186
|
});
|
|
49139
49187
|
synced++;
|
|
@@ -49153,7 +49201,8 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49153
49201
|
await client2.request("GET", `/pub/v3/messages/${item.id}`),
|
|
49154
49202
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (view-status refresh)" }
|
|
49155
49203
|
);
|
|
49156
|
-
|
|
49204
|
+
const recipients = mergeRecipients(existing.recipients, detailRecipients(detail.recipients, (/* @__PURE__ */ new Date()).toISOString()));
|
|
49205
|
+
toUpsert.push({ ...existing, recipients, listData: item });
|
|
49157
49206
|
synced++;
|
|
49158
49207
|
}
|
|
49159
49208
|
continue;
|
|
@@ -49163,14 +49212,14 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49163
49212
|
let body = null;
|
|
49164
49213
|
let fetchedBodyAt = null;
|
|
49165
49214
|
let detailFileIds = [];
|
|
49166
|
-
let
|
|
49215
|
+
let detailRecipientsRaw;
|
|
49167
49216
|
const row = {
|
|
49168
49217
|
id: item.id,
|
|
49169
49218
|
folder,
|
|
49170
49219
|
subject: item.subject ?? "(no subject)",
|
|
49171
49220
|
fromUser: item.from?.name ?? "",
|
|
49172
49221
|
sentAt: item.date?.dateTime ?? nowNaiveWallClock(),
|
|
49173
|
-
recipients: mapRecipients(item.recipients),
|
|
49222
|
+
recipients: mapRecipients(item.recipients, { source: "list" }),
|
|
49174
49223
|
body: null,
|
|
49175
49224
|
fetchedBodyAt: null,
|
|
49176
49225
|
replyToId: null,
|
|
@@ -49187,7 +49236,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49187
49236
|
if (isInboxUnread) opts.onUnreadBodyFetched?.(item.id);
|
|
49188
49237
|
body = detail.body ?? "";
|
|
49189
49238
|
fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
49190
|
-
|
|
49239
|
+
detailRecipientsRaw = detail.recipients;
|
|
49191
49240
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
49192
49241
|
detailFileIds = detail.files;
|
|
49193
49242
|
}
|
|
@@ -49212,7 +49261,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49212
49261
|
});
|
|
49213
49262
|
row.body = body;
|
|
49214
49263
|
row.fetchedBodyAt = fetchedBodyAt;
|
|
49215
|
-
if (
|
|
49264
|
+
if (detailRecipientsRaw) row.recipients = mergeRecipients(row.recipients, detailRecipients(detailRecipientsRaw, fetchedBodyAt));
|
|
49216
49265
|
toUpsert.push(row);
|
|
49217
49266
|
synced++;
|
|
49218
49267
|
if (detailFileIds.length > 0) {
|
|
@@ -52154,11 +52203,12 @@ async function openUnreadBody(client2, cache, cached2) {
|
|
|
52154
52203
|
await client2.request("GET", `/pub/v3/messages/${cached2.id}`),
|
|
52155
52204
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (sync, confirmed mark-read)" }
|
|
52156
52205
|
);
|
|
52206
|
+
const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52157
52207
|
await cache.upsertMessage({
|
|
52158
52208
|
...cached2,
|
|
52159
|
-
recipients:
|
|
52209
|
+
recipients: mergeRecipients(cached2.recipients, detailRecipients(detail.recipients, checkedAt)),
|
|
52160
52210
|
body: detail.body ?? "",
|
|
52161
|
-
fetchedBodyAt:
|
|
52211
|
+
fetchedBodyAt: checkedAt
|
|
52162
52212
|
});
|
|
52163
52213
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
52164
52214
|
await fetchAttachmentMetaForMessage(client2, cached2.id, detail.files, cache);
|
|
@@ -52289,6 +52339,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52289
52339
|
view: LIST_MESSAGES_VIEW
|
|
52290
52340
|
})
|
|
52291
52341
|
}, async (args) => {
|
|
52342
|
+
const callStartedAt = Date.now();
|
|
52292
52343
|
const page = args.page ?? 1;
|
|
52293
52344
|
const size = args.size ?? 50;
|
|
52294
52345
|
const sort = args.sort ?? "newest";
|
|
@@ -52338,7 +52389,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52338
52389
|
isEmpty: (v) => v.total === 0,
|
|
52339
52390
|
read: async () => {
|
|
52340
52391
|
const total2 = await cache.countMessages(filter);
|
|
52341
|
-
const messages2 = (await cache.listMessages({ ...filter, page, size, sort })).map((m) => withReadState(m));
|
|
52392
|
+
const messages2 = (await cache.listMessages({ ...filter, page, size, sort })).map((m) => withViewOrigin(withReadState(m), callStartedAt));
|
|
52342
52393
|
const freshness2 = await buildFreshness(cache, { source: "cache", folders });
|
|
52343
52394
|
return { messages: messages2, total: total2, freshness: freshness2 };
|
|
52344
52395
|
}
|
|
@@ -52419,7 +52470,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52419
52470
|
});
|
|
52420
52471
|
server.registerTool("ofw_get_message", {
|
|
52421
52472
|
_meta: familyMeta("lookup"),
|
|
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,
|
|
52473
|
+
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. Each recipient\'s `viewedAt` carries its provenance: `viewedAtOrigin` is "detail-this-call" (read from OurFamilyWizard during this call), "detail-cached" (from an earlier read \u2014 see `viewedAtCheckedAt`), "list" (only the list was seen, so a null `viewedAt` means UNKNOWN, not unviewed) or "unrecorded". `viewedPlaceholder` is OurFamilyWizard\'s raw 1970 placeholder, kept as source data \u2014 it is never a view time.' + OVERRIDE_DESCRIPTION,
|
|
52423
52474
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
52424
52475
|
inputSchema: external_exports.object({
|
|
52425
52476
|
messageId: external_exports.string().describe("Message ID (also accepts draft IDs \u2014 drafts are routed via the drafts cache)"),
|
|
@@ -52431,6 +52482,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52431
52482
|
confirmToken: confirmTokenParam
|
|
52432
52483
|
})
|
|
52433
52484
|
}, async (args, ctx) => {
|
|
52485
|
+
const callStartedAt = Date.now();
|
|
52434
52486
|
const id2 = Number(args.messageId);
|
|
52435
52487
|
const view = resolveView(args.view, MESSAGE_VIEWS);
|
|
52436
52488
|
const cache = cacheProvider();
|
|
@@ -52503,7 +52555,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52503
52555
|
const freshness2 = await buildFreshness(cache, { source: "cache", folders: [cached2.folder] });
|
|
52504
52556
|
return jsonResponse({
|
|
52505
52557
|
readingBlocked: blocked,
|
|
52506
|
-
...viewOne(view, withholdBody(withReadState(cached2))),
|
|
52558
|
+
...viewOne(view, withholdBody(withViewOrigin(withReadState(cached2), callStartedAt))),
|
|
52507
52559
|
attachments: attachments2,
|
|
52508
52560
|
freshness: freshness2
|
|
52509
52561
|
});
|
|
@@ -52517,7 +52569,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52517
52569
|
await client2.request("GET", `/pub/v3/messages/${id2}`),
|
|
52518
52570
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (view-status refresh)" }
|
|
52519
52571
|
);
|
|
52520
|
-
const recipients =
|
|
52572
|
+
const recipients = mergeRecipients(cached2.recipients, detailRecipients(detail2.recipients, (/* @__PURE__ */ new Date()).toISOString()));
|
|
52521
52573
|
row2 = {
|
|
52522
52574
|
...cached2,
|
|
52523
52575
|
recipients,
|
|
@@ -52545,7 +52597,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52545
52597
|
const freshness2 = await buildFreshness(cache, { source: "cache", folders: [row2.folder] });
|
|
52546
52598
|
return jsonResponse({
|
|
52547
52599
|
...overriding ? readOverrideFields("ofw_get_message", [row2.id]) : {},
|
|
52548
|
-
...viewOne(view, withReadState(row2)),
|
|
52600
|
+
...viewOne(view, withViewOrigin(withReadState(row2), callStartedAt)),
|
|
52549
52601
|
attachments: attachments2,
|
|
52550
52602
|
freshness: freshness2
|
|
52551
52603
|
});
|
|
@@ -52566,15 +52618,16 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52566
52618
|
folder = "sent";
|
|
52567
52619
|
}
|
|
52568
52620
|
}
|
|
52621
|
+
const fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52569
52622
|
const row = {
|
|
52570
52623
|
id: detail.id,
|
|
52571
52624
|
folder,
|
|
52572
52625
|
subject: detail.subject,
|
|
52573
52626
|
fromUser: detail.from?.name ?? "",
|
|
52574
52627
|
sentAt: detail.date?.dateTime ?? nowNaiveWallClock(),
|
|
52575
|
-
recipients:
|
|
52628
|
+
recipients: mergeRecipients(cached2?.recipients, detailRecipients(detail.recipients, fetchedBodyAt)),
|
|
52576
52629
|
body: detail.body ?? "",
|
|
52577
|
-
fetchedBodyAt
|
|
52630
|
+
fetchedBodyAt,
|
|
52578
52631
|
replyToId: cached2?.replyToId ?? null,
|
|
52579
52632
|
chainRootId: cached2?.chainRootId ?? null,
|
|
52580
52633
|
listData: cached2?.listData ?? detail
|
|
@@ -52587,7 +52640,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52587
52640
|
const freshness = await buildFreshness(cache, { source: "live", folders: [folder] });
|
|
52588
52641
|
return jsonResponse({
|
|
52589
52642
|
...overriding ? readOverrideFields("ofw_get_message", [row.id]) : {},
|
|
52590
|
-
...viewOne(view, withReadState(row)),
|
|
52643
|
+
...viewOne(view, withViewOrigin(withReadState(row), callStartedAt)),
|
|
52591
52644
|
attachments,
|
|
52592
52645
|
freshness
|
|
52593
52646
|
});
|
|
@@ -52803,7 +52856,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52803
52856
|
} else {
|
|
52804
52857
|
threaded = true;
|
|
52805
52858
|
}
|
|
52806
|
-
const storedRecipients = mapRecipients(detail.recipients);
|
|
52859
|
+
const storedRecipients = mapRecipients(detail.recipients, { source: "detail", checkedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
52807
52860
|
if (Array.isArray(detail.recipients) && detail.recipients.length > 0) {
|
|
52808
52861
|
const landed = new Set(storedRecipients.map((r) => r.userId));
|
|
52809
52862
|
const missingRecipients = recipientIds.filter((rid) => !landed.has(rid));
|
package/dist/sync.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clearHeldFiles, getHeldFiles, setHeldFiles } from './tools/held-attachments.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { ApiRecipientSchema, draftReplyTarget, hasRealView, mapRecipients, scrapeSaysRead } from './tools/_shared.js';
|
|
3
|
+
import { ApiRecipientSchema, detailRecipients, draftReplyTarget, hasRealView, mapRecipients, mergeRecipients, scrapeSaysRead } from './tools/_shared.js';
|
|
4
4
|
import { clearReplyToSource, setReplyToSource } from './tools/reply-source.js';
|
|
5
5
|
import { senderOf } from './tools/project.js';
|
|
6
6
|
import { parseLenient } from '@chrischall/mcp-utils';
|
|
@@ -233,11 +233,15 @@ async function walkPages(client, folder, folderId, opts, store) {
|
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
const detail = await fetchDetail(item, { subject: existing.subject, sentAt: existing.sentAt, from: senderOf(existing) }, 'GET /pub/v3/messages/{id} (body backfill)', false);
|
|
236
|
+
const checkedAt = new Date().toISOString();
|
|
236
237
|
toUpsert.push({
|
|
237
238
|
...existing,
|
|
238
239
|
body: detail.body ?? '',
|
|
239
|
-
fetchedBodyAt:
|
|
240
|
-
|
|
240
|
+
fetchedBodyAt: checkedAt,
|
|
241
|
+
// A detail that omits recipients (or a view time) must not erase
|
|
242
|
+
// what the cache already recorded — and the LIST's recipients
|
|
243
|
+
// carry only a placeholder, so they are never a substitute.
|
|
244
|
+
recipients: mergeRecipients(existing.recipients, detailRecipients(detail.recipients, checkedAt)),
|
|
241
245
|
listData: item,
|
|
242
246
|
});
|
|
243
247
|
synced++;
|
|
@@ -262,7 +266,8 @@ async function walkPages(client, folder, folderId, opts, store) {
|
|
|
262
266
|
break;
|
|
263
267
|
}
|
|
264
268
|
const detail = parseLenient(DetailResponseSchema, await client.request('GET', `/pub/v3/messages/${item.id}`), { label: 'ofw-mcp', context: 'GET /pub/v3/messages/{id} (view-status refresh)' });
|
|
265
|
-
|
|
269
|
+
const recipients = mergeRecipients(existing.recipients, detailRecipients(detail.recipients, new Date().toISOString()));
|
|
270
|
+
toUpsert.push({ ...existing, recipients, listData: item });
|
|
266
271
|
synced++;
|
|
267
272
|
}
|
|
268
273
|
continue;
|
|
@@ -278,7 +283,7 @@ async function walkPages(client, folder, folderId, opts, store) {
|
|
|
278
283
|
// the row from the list would cache viewedAt:null for a message that was
|
|
279
284
|
// already read by the time we first saw it — reporting "never viewed" for
|
|
280
285
|
// a message OFW shows as read, until a later sync's refresh healed it.
|
|
281
|
-
let
|
|
286
|
+
let detailRecipientsRaw;
|
|
282
287
|
// The row as the list describes it; the detail (if fetched) fills in
|
|
283
288
|
// body and real view times below.
|
|
284
289
|
const row = {
|
|
@@ -287,7 +292,7 @@ async function walkPages(client, folder, folderId, opts, store) {
|
|
|
287
292
|
subject: item.subject ?? '(no subject)',
|
|
288
293
|
fromUser: item.from?.name ?? '',
|
|
289
294
|
sentAt: item.date?.dateTime ?? nowNaiveWallClock(),
|
|
290
|
-
recipients: mapRecipients(item.recipients),
|
|
295
|
+
recipients: mapRecipients(item.recipients, { source: 'list' }),
|
|
291
296
|
body: null,
|
|
292
297
|
fetchedBodyAt: null,
|
|
293
298
|
replyToId: null,
|
|
@@ -306,7 +311,7 @@ async function walkPages(client, folder, folderId, opts, store) {
|
|
|
306
311
|
opts.onUnreadBodyFetched?.(item.id);
|
|
307
312
|
body = detail.body ?? '';
|
|
308
313
|
fetchedBodyAt = new Date().toISOString();
|
|
309
|
-
|
|
314
|
+
detailRecipientsRaw = detail.recipients;
|
|
310
315
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
311
316
|
detailFileIds = detail.files;
|
|
312
317
|
}
|
|
@@ -327,8 +332,8 @@ async function walkPages(client, folder, folderId, opts, store) {
|
|
|
327
332
|
});
|
|
328
333
|
row.body = body;
|
|
329
334
|
row.fetchedBodyAt = fetchedBodyAt;
|
|
330
|
-
if (
|
|
331
|
-
row.recipients =
|
|
335
|
+
if (detailRecipientsRaw)
|
|
336
|
+
row.recipients = mergeRecipients(row.recipients, detailRecipients(detailRecipientsRaw, fetchedBodyAt));
|
|
332
337
|
toUpsert.push(row);
|
|
333
338
|
synced++;
|
|
334
339
|
if (detailFileIds.length > 0) {
|
package/dist/timestamps.js
CHANGED
|
@@ -173,6 +173,10 @@ const TIMESTAMP_KEYS = new Set([
|
|
|
173
173
|
// OFW: UTC instants we stamp ourselves.
|
|
174
174
|
'fetchedBodyAt',
|
|
175
175
|
'fetchedAt',
|
|
176
|
+
// When the detail behind a recipient's `viewedAt` was read (issue #448).
|
|
177
|
+
// NOT `viewedPlaceholder`: that is OFW's raw epoch-zero placeholder, kept
|
|
178
|
+
// verbatim precisely so it can never be rendered as a real time.
|
|
179
|
+
'viewedAtCheckedAt',
|
|
176
180
|
'syncedAt',
|
|
177
181
|
'downloadedAt',
|
|
178
182
|
'recordedAt',
|
package/dist/tools/_shared.js
CHANGED
|
@@ -70,24 +70,80 @@ export const ApiRecipientSchema = z.looseObject({
|
|
|
70
70
|
}).optional(),
|
|
71
71
|
viewed: z.looseObject({ dateTime: z.string() }).nullable().optional(),
|
|
72
72
|
});
|
|
73
|
-
|
|
74
|
-
// Used wherever we surface or persist recipients (sync, get_message, send,
|
|
75
|
-
// save_draft).
|
|
76
|
-
//
|
|
77
|
-
// `viewedAt` is the recipient's true "First Viewed" time, or null if not yet
|
|
78
|
-
// viewed. Only the DETAIL endpoint (/pub/v3/messages/{id}) carries a real
|
|
79
|
-
// timestamp; the LIST endpoint returns an epoch-zero PLACEHOLDER
|
|
80
|
-
// ("1970-01-01T00:00:00") in the SAME field even for read messages (on the
|
|
81
|
-
// list, read status lives in the flags — `read` for inbox, `showNeverViewed`
|
|
82
|
-
// for sent; see scrapeSaysRead — not the timestamp). So treat
|
|
83
|
-
// the epoch placeholder as "no real view time" — otherwise a list-sourced row
|
|
84
|
-
// reports a bogus 1970 read time. A detail re-fetch is what fills in the truth.
|
|
85
|
-
export function mapRecipients(items) {
|
|
73
|
+
export function mapRecipients(items, origin) {
|
|
86
74
|
return (items ?? []).map((r) => {
|
|
87
75
|
const dt = r.viewed?.dateTime;
|
|
88
|
-
const
|
|
89
|
-
|
|
76
|
+
const placeholder = typeof dt === 'string' && dt.startsWith('1970-01-01');
|
|
77
|
+
const viewedAt = typeof dt === 'string' && !placeholder ? dt : null;
|
|
78
|
+
const out = { userId: r.user?.userId ?? r.user?.id ?? 0, name: r.user?.name ?? '', viewedAt };
|
|
79
|
+
if (origin) {
|
|
80
|
+
out.viewedAtSource = origin.source;
|
|
81
|
+
if (origin.source === 'detail' && origin.checkedAt !== undefined)
|
|
82
|
+
out.viewedAtCheckedAt = origin.checkedAt;
|
|
83
|
+
if (placeholder)
|
|
84
|
+
out.viewedPlaceholder = dt;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A detail payload's recipients, labelled as read from the detail at
|
|
91
|
+
* `checkedAt` — or null when the payload reported none (absent or empty), so
|
|
92
|
+
* {@link mergeRecipients} keeps what the cache already knew.
|
|
93
|
+
*/
|
|
94
|
+
export function detailRecipients(items, checkedAt) {
|
|
95
|
+
return items && items.length > 0 ? mapRecipients(items, { source: 'detail', checkedAt }) : null;
|
|
96
|
+
}
|
|
97
|
+
function sameRecipient(a, b) {
|
|
98
|
+
if (a.userId !== 0 && b.userId !== 0)
|
|
99
|
+
return a.userId === b.userId;
|
|
100
|
+
return a.name !== '' && a.name === b.name;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Combine freshly fetched recipients with what the cache already held, so an
|
|
104
|
+
* INCOMPLETE OFW response can never erase evidence (issue #448).
|
|
105
|
+
*
|
|
106
|
+
* - No recipients reported (absent or `[]`) → the cached set stands; a message
|
|
107
|
+
* always has recipients, so an empty array is "not echoed", not "none".
|
|
108
|
+
* - A recipient the fresh payload gives no real view time, where the cache
|
|
109
|
+
* holds one → the cached time is carried forward WITH its original
|
|
110
|
+
* provenance (`viewedAtSource`/`viewedAtCheckedAt`), so a reader can tell it
|
|
111
|
+
* was not re-observed by this fetch. "First Viewed" cannot be withdrawn, so
|
|
112
|
+
* a payload that omits it is incomplete, not a correction.
|
|
113
|
+
*
|
|
114
|
+
* Membership otherwise follows the fresh payload.
|
|
115
|
+
*/
|
|
116
|
+
export function mergeRecipients(prior, fresh) {
|
|
117
|
+
if (fresh === null || fresh.length === 0)
|
|
118
|
+
return prior ?? [];
|
|
119
|
+
const priorList = prior ?? [];
|
|
120
|
+
return fresh.map((r) => {
|
|
121
|
+
if (hasRealView([r]))
|
|
122
|
+
return r;
|
|
123
|
+
const match = priorList.find((p) => sameRecipient(p, r) && hasRealView([p]));
|
|
124
|
+
if (!match)
|
|
125
|
+
return r;
|
|
126
|
+
const carried = { userId: r.userId, name: r.name, viewedAt: match.viewedAt };
|
|
127
|
+
if (match.viewedAtSource !== undefined)
|
|
128
|
+
carried.viewedAtSource = match.viewedAtSource;
|
|
129
|
+
if (match.viewedAtCheckedAt !== undefined)
|
|
130
|
+
carried.viewedAtCheckedAt = match.viewedAtCheckedAt;
|
|
131
|
+
return carried;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export function withViewOrigin(row, callStartedAtMs) {
|
|
135
|
+
const recipients = row.recipients.map((r) => {
|
|
136
|
+
let viewedAtOrigin;
|
|
137
|
+
if (r.viewedAtSource === 'detail') {
|
|
138
|
+
const at = r.viewedAtCheckedAt === undefined ? NaN : Date.parse(r.viewedAtCheckedAt);
|
|
139
|
+
viewedAtOrigin = at >= callStartedAtMs ? 'detail-this-call' : 'detail-cached';
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
viewedAtOrigin = r.viewedAtSource ?? 'unrecorded';
|
|
143
|
+
}
|
|
144
|
+
return { ...r, viewedAtOrigin };
|
|
90
145
|
});
|
|
146
|
+
return { ...row, recipients };
|
|
91
147
|
}
|
|
92
148
|
// True if any recipient has a *real* "First Viewed" time — i.e. present and
|
|
93
149
|
// not the epoch-zero placeholder. After mapRecipients a fresh `viewedAt` is
|
package/dist/tools/messages.js
CHANGED
|
@@ -16,7 +16,7 @@ import { resolveDownloadMime, resolveSaveDest } from './attachments.js';
|
|
|
16
16
|
import { getAllowMarkRead, getConfirmMarkRead, getAttachmentsDir, getAutoRefreshStaleReads, getDefaultInlineAttachments, getFetchUnreadBodies, getSyncMaxRequests, getWriteMode, } from '../config.js';
|
|
17
17
|
import { basename, resolve } from 'node:path';
|
|
18
18
|
import { randomUUID } from 'node:crypto';
|
|
19
|
-
import { ApiRecipientSchema, deriveRead, draftReplyTarget, hasRealView, jsonErrorResponse, jsonResponse, jsonText, mapRecipients, notedJsonResponse, postMessageAndRefetch, reportsThreaded, UnconfirmedWriteError, reportsUnthreaded, threadedReplyTo, verifyWriteLanded, withReadState } from './_shared.js';
|
|
19
|
+
import { ApiRecipientSchema, deriveRead, detailRecipients, mergeRecipients, withViewOrigin, draftReplyTarget, hasRealView, jsonErrorResponse, jsonResponse, jsonText, mapRecipients, notedJsonResponse, postMessageAndRefetch, reportsThreaded, UnconfirmedWriteError, reportsUnthreaded, threadedReplyTo, verifyWriteLanded, withReadState } from './_shared.js';
|
|
20
20
|
import { parseLenient } from '@chrischall/mcp-utils';
|
|
21
21
|
import { pageState } from './pagination.js';
|
|
22
22
|
import { compactSentMessage, compactWrittenDraft, MESSAGE_VIEWS, senderOf, viewDrafts, viewMessages, viewOne } from './project.js';
|
|
@@ -304,11 +304,12 @@ async function unreadCandidates(cache) {
|
|
|
304
304
|
*/
|
|
305
305
|
async function openUnreadBody(client, cache, cached) {
|
|
306
306
|
const detail = parseLenient(MessageDetailSchema, await client.request('GET', `/pub/v3/messages/${cached.id}`), { label: 'ofw-mcp', context: 'GET /pub/v3/messages/{id} (sync, confirmed mark-read)' });
|
|
307
|
+
const checkedAt = new Date().toISOString();
|
|
307
308
|
await cache.upsertMessage({
|
|
308
309
|
...cached,
|
|
309
|
-
recipients:
|
|
310
|
+
recipients: mergeRecipients(cached.recipients, detailRecipients(detail.recipients, checkedAt)),
|
|
310
311
|
body: detail.body ?? '',
|
|
311
|
-
fetchedBodyAt:
|
|
312
|
+
fetchedBodyAt: checkedAt,
|
|
312
313
|
});
|
|
313
314
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
314
315
|
await fetchAttachmentMetaForMessage(client, cached.id, detail.files, cache);
|
|
@@ -509,6 +510,10 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
509
510
|
view: LIST_MESSAGES_VIEW,
|
|
510
511
|
}),
|
|
511
512
|
}, async (args) => {
|
|
513
|
+
// The instant this call began: a recipient view time read from OFW's detail
|
|
514
|
+
// at or after it is labelled `detail-this-call`, anything older came from
|
|
515
|
+
// the cache (withViewOrigin, issue #448).
|
|
516
|
+
const callStartedAt = Date.now();
|
|
512
517
|
const page = args.page ?? 1;
|
|
513
518
|
const size = args.size ?? 50;
|
|
514
519
|
const sort = args.sort ?? 'newest';
|
|
@@ -578,7 +583,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
578
583
|
// can be stale (a message read after it was first scraped), so `read`
|
|
579
584
|
// is derived from the record's own `viewedAt`/`fetchedBodyAt` and
|
|
580
585
|
// `listData` is forced to agree — see withReadState.
|
|
581
|
-
const messages = (await cache.listMessages({ ...filter, page, size, sort })).map((m) => withReadState(m));
|
|
586
|
+
const messages = (await cache.listMessages({ ...filter, page, size, sort })).map((m) => withViewOrigin(withReadState(m), callStartedAt));
|
|
582
587
|
// Served from the local cache, so the result must say how old it is and
|
|
583
588
|
// whether anything vouches for it — a caller cannot state current state
|
|
584
589
|
// from this payload without either re-reading or surfacing the caveat.
|
|
@@ -684,7 +689,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
684
689
|
});
|
|
685
690
|
server.registerTool('ofw_get_message', {
|
|
686
691
|
_meta: familyMeta('lookup'),
|
|
687
|
-
description: 'Get a single OurFamilyWizard message OR draft by ID. Reads from local cache when available; otherwise fetches from OFW — 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) — 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,
|
|
692
|
+
description: 'Get a single OurFamilyWizard message OR draft by ID. Reads from local cache when available; otherwise fetches from OFW — 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) — 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. Each recipient\'s `viewedAt` carries its provenance: `viewedAtOrigin` is "detail-this-call" (read from OurFamilyWizard during this call), "detail-cached" (from an earlier read — see `viewedAtCheckedAt`), "list" (only the list was seen, so a null `viewedAt` means UNKNOWN, not unviewed) or "unrecorded". `viewedPlaceholder` is OurFamilyWizard\'s raw 1970 placeholder, kept as source data — it is never a view time.' + OVERRIDE_DESCRIPTION,
|
|
688
693
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
689
694
|
inputSchema: z.object({
|
|
690
695
|
messageId: z.string().describe('Message ID (also accepts draft IDs — drafts are routed via the drafts cache)'),
|
|
@@ -696,6 +701,10 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
696
701
|
confirmToken: confirmTokenParam,
|
|
697
702
|
}),
|
|
698
703
|
}, async (args, ctx) => {
|
|
704
|
+
// The instant this call began: a recipient view time read from OFW's detail
|
|
705
|
+
// at or after it is labelled `detail-this-call`, anything older came from
|
|
706
|
+
// the cache (withViewOrigin, issue #448).
|
|
707
|
+
const callStartedAt = Date.now();
|
|
699
708
|
const id = Number(args.messageId);
|
|
700
709
|
const view = resolveView(args.view, MESSAGE_VIEWS);
|
|
701
710
|
const cache = cacheProvider();
|
|
@@ -780,7 +789,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
780
789
|
const freshness = await buildFreshness(cache, { source: 'cache', folders: [cached.folder] });
|
|
781
790
|
return jsonResponse({
|
|
782
791
|
readingBlocked: blocked,
|
|
783
|
-
...viewOne(view, withholdBody(withReadState(cached))),
|
|
792
|
+
...viewOne(view, withholdBody(withViewOrigin(withReadState(cached), callStartedAt))),
|
|
784
793
|
attachments,
|
|
785
794
|
freshness,
|
|
786
795
|
});
|
|
@@ -797,7 +806,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
797
806
|
if (cached.folder === 'sent' && !hasRealView(cached.recipients)) {
|
|
798
807
|
try {
|
|
799
808
|
const detail = parseLenient(MessageDetailSchema, await client.request('GET', `/pub/v3/messages/${id}`), { label: 'ofw-mcp', context: 'GET /pub/v3/messages/{id} (view-status refresh)' });
|
|
800
|
-
const recipients =
|
|
809
|
+
const recipients = mergeRecipients(cached.recipients, detailRecipients(detail.recipients, new Date().toISOString()));
|
|
801
810
|
// Keep the raw listData read-flag in step with the refreshed
|
|
802
811
|
// recipients so `showNeverViewed` can't contradict `viewedAt`.
|
|
803
812
|
// (Spreading a null/absent listData is a no-op, so no guard needed.)
|
|
@@ -838,7 +847,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
838
847
|
const freshness = await buildFreshness(cache, { source: 'cache', folders: [row.folder] });
|
|
839
848
|
return jsonResponse({
|
|
840
849
|
...(overriding ? readOverrideFields('ofw_get_message', [row.id]) : {}),
|
|
841
|
-
...viewOne(view, withReadState(row)),
|
|
850
|
+
...viewOne(view, withViewOrigin(withReadState(row), callStartedAt)),
|
|
842
851
|
attachments,
|
|
843
852
|
freshness,
|
|
844
853
|
});
|
|
@@ -869,15 +878,16 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
869
878
|
folder = 'sent';
|
|
870
879
|
}
|
|
871
880
|
}
|
|
881
|
+
const fetchedBodyAt = new Date().toISOString();
|
|
872
882
|
const row = {
|
|
873
883
|
id: detail.id,
|
|
874
884
|
folder,
|
|
875
885
|
subject: detail.subject,
|
|
876
886
|
fromUser: detail.from?.name ?? '',
|
|
877
887
|
sentAt: detail.date?.dateTime ?? nowNaiveWallClock(),
|
|
878
|
-
recipients:
|
|
888
|
+
recipients: mergeRecipients(cached?.recipients, detailRecipients(detail.recipients, fetchedBodyAt)),
|
|
879
889
|
body: detail.body ?? '',
|
|
880
|
-
fetchedBodyAt
|
|
890
|
+
fetchedBodyAt,
|
|
881
891
|
replyToId: cached?.replyToId ?? null,
|
|
882
892
|
chainRootId: cached?.chainRootId ?? null,
|
|
883
893
|
listData: cached?.listData ?? detail,
|
|
@@ -891,7 +901,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
891
901
|
const freshness = await buildFreshness(cache, { source: 'live', folders: [folder] });
|
|
892
902
|
return jsonResponse({
|
|
893
903
|
...(overriding ? readOverrideFields('ofw_get_message', [row.id]) : {}),
|
|
894
|
-
...viewOne(view, withReadState(row)),
|
|
904
|
+
...viewOne(view, withViewOrigin(withReadState(row), callStartedAt)),
|
|
895
905
|
attachments,
|
|
896
906
|
freshness,
|
|
897
907
|
});
|
|
@@ -1174,7 +1184,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
1174
1184
|
// omitted or empty recipients array is "not echoed" (OFW routinely
|
|
1175
1185
|
// echoes [] the way it does on drafts), and crying wolf on it would
|
|
1176
1186
|
// retain the draft after every ordinary send.
|
|
1177
|
-
const storedRecipients = mapRecipients(detail.recipients);
|
|
1187
|
+
const storedRecipients = mapRecipients(detail.recipients, { source: 'detail', checkedAt: new Date().toISOString() });
|
|
1178
1188
|
if (Array.isArray(detail.recipients) && detail.recipients.length > 0) {
|
|
1179
1189
|
const landed = new Set(storedRecipients.map((r) => r.userId));
|
|
1180
1190
|
const missingRecipients = recipientIds.filter((rid) => !landed.has(rid));
|
package/dist/version.js
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// package.json drift. Importing these instead of package.json keeps the whole
|
|
5
5
|
// manifest — npm scripts included — out of dist/bundle.js.
|
|
6
6
|
export const SERVER_NAME = 'ofw-mcp';
|
|
7
|
-
export const VERSION = '2.29.
|
|
7
|
+
export const VERSION = '2.29.1'; // x-release-please-version
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/ofw-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "2.29.
|
|
9
|
+
"version": "2.29.1",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "ofw-mcp",
|
|
14
|
-
"version": "2.29.
|
|
14
|
+
"version": "2.29.1",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|
package/skills/ofw/SKILL.md
CHANGED
|
@@ -93,7 +93,7 @@ Always pass `--config ~/.mcporter/mcporter.json` unless a local `config/mcporter
|
|
|
93
93
|
| `ofw_sync_messages(folders?, deep?, fetchUnreadBodies?)` | Sync OFW → local cache. **Call first if the cache might be stale.** Never marks anything read unless `fetchUnreadBodies` is set. `newMessages` lists every message this call cached for the first time (newest first, with `read` and `bodyFetched`; `newMessagesTotal`/`newMessagesTruncated` when more than 50 arrived), so tell the user what arrived from that list. `unreadInbox` lists the new inbox messages that were unread when the sync began (`bodyFetched:false` = still unread). If the response leads with a `warning` and a `markedRead` list, the sync marked those messages read on OFW; tell the user, and stress any with `reason: "unexpected"`. With `fetchUnreadBodies` it may instead return a confirmation preview listing the unread messages it would open (server `OFW_CONFIRM_MARK_READ`): show the user that list and repeat with the `confirmToken` only on their yes. `unreadBodies.gate` names a server ceiling that refused. |
|
|
94
94
|
| `ofw_list_message_folders` | List OFW folders with unread counts. Most reads use the cache; this is mainly for folder IDs and live unread counts. |
|
|
95
95
|
| `ofw_list_messages(folderId?, since?, until?, q?, sort?, page?, size?, autoRefresh?, view?)` | Cache-backed list. Supports folder ("inbox"/"sent"/"both"), date range, and substring search. `sort:"oldest"` starts at the old end of a range instead of paging to it (default `"newest"`). Returns `complete` for the RESULT SET plus **`nextPage`** (null when done) — and the paging keys come FIRST in the JSON, before `messages`. `returned` carries the record count as a scalar, beside `total`. An **empty** result from a non-fresh cache is refused (`UNVERIFIED_EMPTY`) — pass `autoRefresh:true` to sync and answer instead. |
|
|
96
|
-
| `ofw_get_message(messageId, allowMarkRead?, view?)` | Read a message OR draft body. Cache-first. Ids in the drafts cache return `folder: "drafts"`. ⚠️ Falls through to OFW for unread inbox messages, which marks them read AND stamps a "First Viewed" time the co-parent can see — irreversible. Pass `allowMarkRead:false` to refuse that fetch instead; cached, sent and already-read messages are unaffected. If the server runs with `OFW_CONFIRM_MARK_READ`, the first call returns a preview (subject, sender, sent time) instead of the body: show it to the user and repeat the call with its `confirmToken` only after they say yes. On a server-configured no-read day (`readingBlocked` / `READING_BLOCKED` in the response) the body is withheld (`bodyWithheld: true`) — report the sender, date and subject, say when `nextReadableDay` is, and do not try to work around it. |
|
|
96
|
+
| `ofw_get_message(messageId, allowMarkRead?, view?)` | Read a message OR draft body. Cache-first. Ids in the drafts cache return `folder: "drafts"`. ⚠️ Falls through to OFW for unread inbox messages, which marks them read AND stamps a "First Viewed" time the co-parent can see — irreversible. Pass `allowMarkRead:false` to refuse that fetch instead; cached, sent and already-read messages are unaffected. If the server runs with `OFW_CONFIRM_MARK_READ`, the first call returns a preview (subject, sender, sent time) instead of the body: show it to the user and repeat the call with its `confirmToken` only after they say yes. On a server-configured no-read day (`readingBlocked` / `READING_BLOCKED` in the response) the body is withheld (`bodyWithheld: true`) — report the sender, date and subject, say when `nextReadableDay` is, and do not try to work around it. When citing a "First Viewed" time, check the recipient's `viewedAtOrigin`: `detail-this-call` was read from OFW just now, `detail-cached` is carried forward from an earlier read (`viewedAtCheckedAt`), `list` means unknown. Never cite `viewedPlaceholder` (OFW's 1970 placeholder) as a view time. |
|
|
97
97
|
| `ofw_send_message(draftId?, subject?, body?, bodyFormat?, recipientIds?, replyToId?, expectedRevision?, deleteDraftOnSuccess?, myFileIDs?, inlineAttachments?, blobKeys?, force?)` | Send a message — **the one irreversible operation**. Preferred path: pass `draftId` (+ `expectedRevision`) to send an existing draft **as it exists on the server** — the tool re-reads it from OFW first and refuses if it changed since you read it (or was already sent/deleted); `subject`/`body` become optional overrides. `recipientIds` is usually still required: OFW does not store recipients on drafts. After a **confirmed** send the draft is auto-deleted (`deleteDraftOnSuccess:false` to keep it); on any failure or ambiguity it is retained and the response says why (`draftRetained`). Response leads with `sentMessageId`, `draftKey`, `threaded`, `draftDeleted`. Compose from scratch by passing `subject`/`body`/`recipientIds` with no `draftId`. Sending a draft attaches its held files as they are (PRIVATE files attach fine); new files upload PRIVATE only after approval, and the response's `attachments.verified`/`missing` says what OFW actually attached. A replace without `recipientIds` keeps the draft's recipients. A draft with no `draftKey` says why (`draftKeyReason`). |
|
|
98
98
|
| `ofw_get_unread_sent(page?, size?, autoRefresh?)` | Sent messages your co-parent hasn't read yet (from cache). Leads with `complete`/`hasMore`/`nextPage`, then `scanned`/`total`, then `unread`; an empty sent cache that is not fresh is refused rather than reported as "nothing sent". |
|
|
99
99
|
| `ofw_list_drafts(page?, size?, verify?, autoRefresh?, view?)` | Leads with `complete`/`hasMore`/`nextPage`; `drafts` comes last. List saved drafts, **auto-verified**: when the cache is not verified-fresh a cheap drafts sync runs first (default `verify:true`), so one call answers server-confirmed. `verify:false` serves straight from cache. Each draft carries `serverConfirmed`, `revision` and `draftKey`. Returns `complete` — **check it before saying "you have N drafts"**. See [Freshness](#freshness). |
|