ofw-mcp 2.29.1 → 2.30.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 +2 -2
- package/dist/bundle.js +628 -79
- package/dist/sync.js +9 -1
- package/dist/tools/folder-messages.js +198 -0
- package/dist/tools/messages.js +193 -29
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/ofw/SKILL.md +3 -3
package/dist/sync.js
CHANGED
|
@@ -77,8 +77,16 @@ async function fetchAttachmentMetaBudgeted(client, messageId, fileIds, store, bu
|
|
|
77
77
|
await fetchAttachmentMetaForMessage(client, messageId, affordable, store);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* A folder id as OFW sends it, normalised to the string every comparison in
|
|
82
|
+
* this server uses. The live /pub/v1/messageFolders payload carries NUMBERS
|
|
83
|
+
* (verified 2026-11-19); a string-only schema warned on every sync and passed
|
|
84
|
+
* the numbers through typed as strings, so `String(detail.folder.id) ===
|
|
85
|
+
* map.sent` in lifecycle.ts could never match a live-resolved map.
|
|
86
|
+
*/
|
|
87
|
+
export const FolderIdSchema = z.union([z.string(), z.number()]).transform(String);
|
|
80
88
|
const FoldersSchema = z.looseObject({
|
|
81
|
-
systemFolders: z.array(z.looseObject({ id:
|
|
89
|
+
systemFolders: z.array(z.looseObject({ id: FolderIdSchema, folderType: z.string() })).optional(),
|
|
82
90
|
});
|
|
83
91
|
export async function resolveFolderIds(client, store) {
|
|
84
92
|
const data = parseLenient(FoldersSchema, await client.request('GET', '/pub/v1/messageFolders?includeFolderCounts=true'), { label: 'ofw-mcp', context: 'GET /pub/v1/messageFolders' });
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseLenient, pruneUndefined } from '@chrischall/mcp-utils';
|
|
3
|
+
import { ApiRecipientSchema, mapRecipients } from './_shared.js';
|
|
4
|
+
import { briefDate, briefLine } from './hints.js';
|
|
5
|
+
import { offsetState, readUpstreamPaging } from './pagination.js';
|
|
6
|
+
/**
|
|
7
|
+
* Messages in folders the cache does not hold (issue #453).
|
|
8
|
+
*
|
|
9
|
+
* The cache syncs three folders: inbox, sent and drafts. OurFamilyWizard has
|
|
10
|
+
* more — user-created folders, plus system folders such as Archived and Action
|
|
11
|
+
* Items — and a message the account holder files into one of them leaves the
|
|
12
|
+
* inbox, so before this it was unreachable from every tool. And
|
|
13
|
+
* `ofw_list_message_folders` advertised "folder IDs needed to call
|
|
14
|
+
* ofw_list_messages", which then refused every one of them.
|
|
15
|
+
*
|
|
16
|
+
* These are read LIVE, one list page per call, and never cached. The list
|
|
17
|
+
* endpoint is what the sync already walks: it carries no body and stamps
|
|
18
|
+
* nothing, so reading a folder this way can never mark a message read. Bodies
|
|
19
|
+
* stay behind `ofw_get_message`, with every gate it applies.
|
|
20
|
+
*/
|
|
21
|
+
const FolderEntrySchema = z.looseObject({
|
|
22
|
+
// Numeric on the live payload (verified 2026-11-19), strings in older fixtures.
|
|
23
|
+
id: z.union([z.number(), z.string()]).optional(),
|
|
24
|
+
name: z.string().optional(),
|
|
25
|
+
folderType: z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
const FoldersSchema = z.looseObject({
|
|
28
|
+
systemFolders: z.array(FolderEntrySchema).optional(),
|
|
29
|
+
userFolders: z.array(FolderEntrySchema).optional(),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a caller's folder (an OFW id or a folder name) against OFW's live
|
|
33
|
+
* folder list. One request. An id or name that matches nothing is UNKNOWN,
|
|
34
|
+
* never an empty folder: OFW answers a list request for a folder that does not
|
|
35
|
+
* exist with an empty page, which would read as "no messages".
|
|
36
|
+
*/
|
|
37
|
+
export async function resolveMessageFolder(client, arg) {
|
|
38
|
+
const data = parseLenient(FoldersSchema, await client.request('GET', '/pub/v1/messageFolders?includeFolderCounts=true'), { label: 'ofw-mcp', context: 'GET /pub/v1/messageFolders (ofw_list_messages folder)' });
|
|
39
|
+
const toFolder = (user) => (f) => f.id === undefined ? null : { id: String(f.id), name: f.name ?? null, folderType: f.folderType ?? null, user };
|
|
40
|
+
const all = [
|
|
41
|
+
...(data?.systemFolders ?? []).map(toFolder(false)),
|
|
42
|
+
...(data?.userFolders ?? []).map(toFolder(true)),
|
|
43
|
+
].filter((f) => f !== null);
|
|
44
|
+
const wanted = arg.trim();
|
|
45
|
+
let matches = all.filter((f) => f.id === wanted);
|
|
46
|
+
if (matches.length === 0) {
|
|
47
|
+
const lower = wanted.toLowerCase();
|
|
48
|
+
matches = all.filter((f) => f.name !== null && f.name.trim().toLowerCase() === lower);
|
|
49
|
+
}
|
|
50
|
+
if (matches.length !== 1) {
|
|
51
|
+
return { kind: 'unknown', available: matches.length > 1 ? matches : all, ambiguous: matches.length > 1 };
|
|
52
|
+
}
|
|
53
|
+
const [folder] = matches;
|
|
54
|
+
if (folder.folderType === 'INBOX')
|
|
55
|
+
return { kind: 'cached', folder: 'inbox' };
|
|
56
|
+
if (folder.folderType === 'SENT_MESSAGES')
|
|
57
|
+
return { kind: 'cached', folder: 'sent' };
|
|
58
|
+
if (folder.folderType === 'DRAFTS')
|
|
59
|
+
return { kind: 'drafts' };
|
|
60
|
+
return { kind: 'live', folder };
|
|
61
|
+
}
|
|
62
|
+
const ListItemSchema = z.looseObject({
|
|
63
|
+
id: z.number(),
|
|
64
|
+
subject: z.string(),
|
|
65
|
+
date: z.looseObject({ dateTime: z.string() }).optional(),
|
|
66
|
+
recipients: z.array(ApiRecipientSchema).optional(),
|
|
67
|
+
});
|
|
68
|
+
const ListResponseSchema = z.looseObject({ data: z.array(ListItemSchema).optional() });
|
|
69
|
+
function asRecord(value) {
|
|
70
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
71
|
+
}
|
|
72
|
+
function nameOf(value) {
|
|
73
|
+
const name = asRecord(value)?.name;
|
|
74
|
+
return typeof name === 'string' && name !== '' ? name : null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Fetch ONE list page of a folder, newest (or oldest) first. One request, no
|
|
78
|
+
* detail GETs: the list carries no body, so nothing is marked read.
|
|
79
|
+
*/
|
|
80
|
+
export async function fetchFolderPage(client, folder, opts) {
|
|
81
|
+
const direction = opts.sort === 'oldest' ? 'asc' : 'desc';
|
|
82
|
+
const raw = await client.request('GET', `/pub/v3/messages?folders=${encodeURIComponent(folder.id)}&page=${opts.page}&size=${opts.size}&sort=date&sortDirection=${direction}`);
|
|
83
|
+
// Lenient: a mismatch warns on stderr and the raw payload flows on, so each
|
|
84
|
+
// item is read defensively below rather than trusted to the schema.
|
|
85
|
+
parseLenient(ListResponseSchema, raw, { label: 'ofw-mcp', context: 'GET /pub/v3/messages?folders={folder}' });
|
|
86
|
+
const items = asRecord(raw)?.data ?? [];
|
|
87
|
+
const upstream = readUpstreamPaging(raw);
|
|
88
|
+
const messages = [];
|
|
89
|
+
for (const entry of items) {
|
|
90
|
+
const it = asRecord(entry);
|
|
91
|
+
if (it === null || typeof it.id !== 'number')
|
|
92
|
+
continue;
|
|
93
|
+
const files = it.files;
|
|
94
|
+
const dateTime = asRecord(it.date)?.dateTime;
|
|
95
|
+
const message = pruneUndefined({
|
|
96
|
+
id: it.id,
|
|
97
|
+
folderId: folder.id,
|
|
98
|
+
folderName: folder.name,
|
|
99
|
+
subject: typeof it.subject === 'string' ? it.subject : '',
|
|
100
|
+
from: nameOf(it.author) ?? nameOf(it.from),
|
|
101
|
+
sentAt: typeof dateTime === 'string' ? dateTime : null,
|
|
102
|
+
recipients: mapRecipients(Array.isArray(it.recipients) ? it.recipients : [], { source: 'list', checkedAt: opts.checkedAt }),
|
|
103
|
+
read: typeof it.read === 'boolean' ? it.read : null,
|
|
104
|
+
replied: typeof it.replied === 'boolean' ? it.replied : undefined,
|
|
105
|
+
files: typeof files === 'number' ? files : Array.isArray(files) ? files.length : undefined,
|
|
106
|
+
});
|
|
107
|
+
if (opts.full) {
|
|
108
|
+
const { preview: _preview, body: _body, ...listData } = it;
|
|
109
|
+
message.listData = listData;
|
|
110
|
+
}
|
|
111
|
+
messages.push(message);
|
|
112
|
+
}
|
|
113
|
+
const { hasMore } = offsetState({
|
|
114
|
+
start: (opts.page - 1) * opts.size,
|
|
115
|
+
max: opts.size,
|
|
116
|
+
returned: items.length,
|
|
117
|
+
total: upstream.total,
|
|
118
|
+
last: upstream.last,
|
|
119
|
+
base: 0,
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
messages,
|
|
123
|
+
returned: messages.length,
|
|
124
|
+
skipped: items.length - messages.length,
|
|
125
|
+
total: upstream.total,
|
|
126
|
+
hasMore,
|
|
127
|
+
nextPage: hasMore ? opts.page + 1 : null,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** One folder message as a brief line: `<sender>: <subject> — <sent> — read|unread`. */
|
|
131
|
+
export function folderMessageBrief(m, tz) {
|
|
132
|
+
const status = m.read === null ? 'read state unknown' : m.read ? 'read' : 'unread';
|
|
133
|
+
return briefLine(m.from ? `${m.from}: ${m.subject}` : m.subject, briefDate(m.sentAt, tz), status);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The largest page a live folder read asks OFW for: the size the sync walks
|
|
137
|
+
* with, so it is known to be honoured. A bigger request OFW silently capped
|
|
138
|
+
* would come back short and read as the last page.
|
|
139
|
+
*/
|
|
140
|
+
export const LIVE_FOLDER_MAX_PAGE = 50;
|
|
141
|
+
const sightingKey = (id) => `folder_sighting:${id}`;
|
|
142
|
+
export async function recordFolderSightings(store, messages, seenAt) {
|
|
143
|
+
for (const m of messages) {
|
|
144
|
+
const sighting = {
|
|
145
|
+
folderId: m.folderId, folderName: m.folderName, subject: m.subject, from: m.from, sentAt: m.sentAt, read: m.read, seenAt,
|
|
146
|
+
};
|
|
147
|
+
await store.setMeta(sightingKey(m.id), JSON.stringify(sighting));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** The recorded sighting for an id, or null — including for a record that does not parse. */
|
|
151
|
+
export async function getFolderSighting(store, id) {
|
|
152
|
+
const raw = await store.getMeta(sightingKey(id));
|
|
153
|
+
if (raw === null)
|
|
154
|
+
return null;
|
|
155
|
+
let value;
|
|
156
|
+
try {
|
|
157
|
+
value = JSON.parse(raw);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const r = asRecord(value);
|
|
163
|
+
if (r === null || typeof r.folderId !== 'string' || typeof r.subject !== 'string')
|
|
164
|
+
return null;
|
|
165
|
+
const str = (v) => (typeof v === 'string' ? v : null);
|
|
166
|
+
return {
|
|
167
|
+
folderId: r.folderId,
|
|
168
|
+
folderName: str(r.folderName),
|
|
169
|
+
subject: r.subject,
|
|
170
|
+
from: str(r.from),
|
|
171
|
+
sentAt: str(r.sentAt),
|
|
172
|
+
read: typeof r.read === 'boolean' ? r.read : null,
|
|
173
|
+
seenAt: str(r.seenAt),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A sighting as a row the mark-read gates can judge — NEVER stored. It is
|
|
178
|
+
* shaped as an inbox row because that is the conservative reading: only OFW's
|
|
179
|
+
* explicit `read: true` counts as read (scrapeSaysRead), so a missing flag, or
|
|
180
|
+
* a sent message whose list flag means something else, fails closed to
|
|
181
|
+
* "would stamp" — a false unread costs a confirmation, a false read stamps
|
|
182
|
+
* the record.
|
|
183
|
+
*/
|
|
184
|
+
export function sightingGateRow(id, s) {
|
|
185
|
+
return {
|
|
186
|
+
id,
|
|
187
|
+
folder: 'inbox',
|
|
188
|
+
subject: s.subject,
|
|
189
|
+
fromUser: s.from ?? '',
|
|
190
|
+
sentAt: s.sentAt ?? '(time unknown)',
|
|
191
|
+
recipients: [],
|
|
192
|
+
body: null,
|
|
193
|
+
fetchedBodyAt: null,
|
|
194
|
+
replyToId: null,
|
|
195
|
+
chainRootId: null,
|
|
196
|
+
listData: { read: s.read === true, sightedInFolder: s.folderName ?? s.folderId },
|
|
197
|
+
};
|
|
198
|
+
}
|
package/dist/tools/messages.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { syncAll, fetchAttachmentMeta, fetchAttachmentMetaForMessage, getDraftsCacheStatus, latestViewedAt, NEW_MESSAGES_CAP, refreshReadReporting } from '../sync.js';
|
|
2
|
+
import { FolderIdSchema, syncAll, fetchAttachmentMeta, fetchAttachmentMetaForMessage, getDraftsCacheStatus, latestViewedAt, NEW_MESSAGES_CAP, refreshReadReporting } from '../sync.js';
|
|
3
3
|
import { buildFreshness } from './freshness.js';
|
|
4
4
|
import { briefDate, briefLine, briefPage, briefResult, familyMeta } from './hints.js';
|
|
5
5
|
import { checkDraftFreshness, draftRevision, fetchServerDraft, staleDraftPayload, } from './draft-freshness.js';
|
|
6
|
-
import { FOLDER_TYPE, newDraftKey, persistFolderIds, probeIds, resolveDraftKey } from './lifecycle.js';
|
|
6
|
+
import { FOLDER_TYPE, newDraftKey, persistFolderIds, probeIds, readFolderIdMap, resolveDraftKey } from './lifecycle.js';
|
|
7
7
|
import { CONFIRM_NOTE, confirmTokenParam, confirmWrite } from './_confirm.js';
|
|
8
8
|
import { getFolderVerifiedAt } from '../sync.js';
|
|
9
9
|
import { MAX_UPLOAD_BYTES } from './attachments.js';
|
|
@@ -19,6 +19,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
19
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
|
+
import { fetchFolderPage, folderMessageBrief, getFolderSighting, LIVE_FOLDER_MAX_PAGE, recordFolderSightings, resolveMessageFolder, sightingGateRow } from './folder-messages.js';
|
|
22
23
|
import { compactSentMessage, compactWrittenDraft, MESSAGE_VIEWS, senderOf, viewDrafts, viewMessages, viewOne } from './project.js';
|
|
23
24
|
// The `view` note on the two write tools. Their echo is what the caller just
|
|
24
25
|
// wrote, so compact replaces the body with its length + hash rather than
|
|
@@ -120,7 +121,7 @@ const DetailFilesSchema = z.looseObject({ files: z.array(z.number()).optional()
|
|
|
120
121
|
// guessing, since a wrong count would manufacture a false out-of-sync verdict.
|
|
121
122
|
const FolderCountsSchema = z.looseObject({
|
|
122
123
|
systemFolders: z.array(z.looseObject({
|
|
123
|
-
id:
|
|
124
|
+
id: FolderIdSchema,
|
|
124
125
|
folderType: z.string(),
|
|
125
126
|
totalCount: z.number().optional(),
|
|
126
127
|
messageCount: z.number().optional(),
|
|
@@ -319,6 +320,12 @@ async function openUnreadBody(client, cache, cached) {
|
|
|
319
320
|
viewedAt: latestViewedAt(detail.recipients), reason: 'fetchUnreadBodies',
|
|
320
321
|
};
|
|
321
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* What to do about an id the cache has never seen. A sync covers inbox, sent
|
|
325
|
+
* and drafts; a message in any other folder is only ever seen by listing that
|
|
326
|
+
* folder, which records a sighting the mark-read gates can judge.
|
|
327
|
+
*/
|
|
328
|
+
const UNSEEN_ID_HINT = 'Run ofw_sync_messages first: it walks list pages, not bodies, so it learns an inbox or sent message\'s subject, sender and read state without marking anything read. If the message is in another folder (Archived, Action Items, a folder you created), list that folder instead with ofw_list_messages(folderId: <its id or name>) — that reads its list page without opening anything. Then call ofw_get_message again.';
|
|
322
329
|
/**
|
|
323
330
|
* OFW_CONFIRM_MARK_READ: before `ofw_get_message` fetches a body that would
|
|
324
331
|
* mark an unread inbox message read, show the user which message it is and
|
|
@@ -341,7 +348,7 @@ async function confirmMarkRead(ctx, cached, args, overriding) {
|
|
|
341
348
|
error: 'MARK_READ_CONFIRMATION_UNAVAILABLE',
|
|
342
349
|
messageId: Number(args.messageId),
|
|
343
350
|
reason: 'This server asks before opening an unread message (OFW_CONFIRM_MARK_READ), but this id is not in the cache, so there is no subject or time to show — and fetching them is the request that would mark it read.',
|
|
344
|
-
hint:
|
|
351
|
+
hint: UNSEEN_ID_HINT,
|
|
345
352
|
});
|
|
346
353
|
}
|
|
347
354
|
// The preview never passes through jsonResponse, so normalize here: sentAt
|
|
@@ -411,6 +418,11 @@ function withholdBody(row) {
|
|
|
411
418
|
* we cannot know without making the request that stamps it. Syncing first
|
|
412
419
|
* (which reads list pages, not bodies) resolves it.
|
|
413
420
|
*/
|
|
421
|
+
/** The folder a gate row was SIGHTED in (sightingGateRow), or null for a cached row. */
|
|
422
|
+
function sightedIn(row) {
|
|
423
|
+
const where = row.listData?.sightedInFolder;
|
|
424
|
+
return typeof where === 'string' ? where : null;
|
|
425
|
+
}
|
|
414
426
|
export function markReadVerdict(cached, requested) {
|
|
415
427
|
const ceiling = getAllowMarkRead();
|
|
416
428
|
if (ceiling && (requested ?? true))
|
|
@@ -427,10 +439,12 @@ export function markReadVerdict(cached, requested) {
|
|
|
427
439
|
messageId: cached?.id ?? null,
|
|
428
440
|
reason: cached === null
|
|
429
441
|
? 'This id is not in the cache, so whether reading it would mark it read is unknowable without making the request that would.'
|
|
430
|
-
:
|
|
442
|
+
: sightedIn(cached) !== null
|
|
443
|
+
? `This is an unread message in the "${sightedIn(cached)}" folder (per OurFamilyWizard's folder listing); fetching its body would mark it read on OurFamilyWizard.`
|
|
444
|
+
: 'This is an unread inbox message; fetching its body would mark it read on OurFamilyWizard.',
|
|
431
445
|
note: `Refused because ${because}. Reading a message for the first time stamps a "First Viewed" timestamp that your co-parent can see and that forms part of the record — it cannot be undone. To read it anyway, call again with allowMarkRead:true${ceiling ? '' : ' (which this deployment does not permit — clear OFW_ALLOW_MARK_READ to re-enable)'}.`,
|
|
432
446
|
...(cached === null
|
|
433
|
-
? { hint:
|
|
447
|
+
? { hint: UNSEEN_ID_HINT }
|
|
434
448
|
: { subject: cached.subject, fromUser: cached.fromUser, sentAt: cached.sentAt }),
|
|
435
449
|
});
|
|
436
450
|
}
|
|
@@ -480,7 +494,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
480
494
|
const allowDrafts = writeMode !== 'none';
|
|
481
495
|
server.registerTool('ofw_list_message_folders', {
|
|
482
496
|
_meta: familyMeta('lookup'),
|
|
483
|
-
description: 'List OurFamilyWizard message folders (
|
|
497
|
+
description: 'List OurFamilyWizard message folders — system folders (Inbox, Sent, Archived, Action Items, …) and folders the user created — with their unread counts. Fetched LIVE from OFW, so the counts are current. Pass a folder\'s id or name to ofw_list_messages(folderId) to list the messages in it. Does NOT return message content.',
|
|
484
498
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
485
499
|
}, async () => {
|
|
486
500
|
const data = await client.request('GET', '/pub/v1/messageFolders?includeFolderCounts=true');
|
|
@@ -493,12 +507,12 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
493
507
|
when: { start: 'since', end: 'until' },
|
|
494
508
|
aliases: ['messages', 'inbox', 'co-parent', 'ofw', 'ourfamilywizard', 'new messages'],
|
|
495
509
|
}),
|
|
496
|
-
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 — 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" — 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,
|
|
510
|
+
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 — 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" — 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. folderId may also name any other OurFamilyWizard folder (a user-created folder, Archived, Action Items, …) by id or name: that folder is not cached, so it is read live, one list page per call (at most 50), returning `folder` and each message\'s subject, sender, sentAt, recipients and OurFamilyWizard\'s own `read` flag — never a body, so it marks nothing read. since/until/q are refused there (UNSUPPORTED_FILTER); a folder id or name OurFamilyWizard does not have is refused as INVALID_FOLDER with `availableFolders`. Read a body with ofw_get_message(messageId).' + OVERRIDE_DESCRIPTION,
|
|
497
511
|
// Read-only even with autoRefresh: guardedCacheRead's sync never fetches
|
|
498
512
|
// unread inbox bodies, so a list call cannot stamp "First Viewed".
|
|
499
513
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
500
514
|
inputSchema: z.object({
|
|
501
|
-
folderId: z.string().describe('
|
|
515
|
+
folderId: z.string().describe('"inbox", "sent", or "both" (default "both") read the local cache. Any other OurFamilyWizard folder — one the user created, or Archived, Action Items, etc. — by its id or name from ofw_list_message_folders: read LIVE, one page at a time, with subjects/senders/dates but no bodies, and without since/until/q.').optional(),
|
|
502
516
|
page: z.number().int().min(1).describe('Page number (default 1)').optional(),
|
|
503
517
|
size: z.number().int().min(1).describe('Messages per page (default 50)').optional(),
|
|
504
518
|
since: z.string().describe('ISO date or datetime — only messages with sent_at >= since (inclusive). A value with an offset or Z is compared as that instant; a naive value is read as the account\'s local time (DISPLAY_TZ)').optional(),
|
|
@@ -520,6 +534,79 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
520
534
|
const brief = args.view === 'brief';
|
|
521
535
|
const view = resolveView(brief ? undefined : args.view, MESSAGE_VIEWS);
|
|
522
536
|
const folderArg = args.folderId ?? 'both';
|
|
537
|
+
/**
|
|
538
|
+
* A folder the cache does not hold, read LIVE (issue #453). One list page,
|
|
539
|
+
* no detail GETs: the list carries no body, so this marks nothing read and
|
|
540
|
+
* a no-read day has nothing to withhold. Nothing is cached.
|
|
541
|
+
*/
|
|
542
|
+
const listLiveFolder = async (liveFolder) => {
|
|
543
|
+
// The cache filters run in SQL over cached rows; OFW's list endpoint has
|
|
544
|
+
// no equivalent, so a filter here would be silently ignored — and an
|
|
545
|
+
// unfiltered page read as a filtered one is a wrong answer, not a slow one.
|
|
546
|
+
const unsupported = ['since', 'until', 'q'].filter((k) => args[k] !== undefined);
|
|
547
|
+
if (unsupported.length > 0) {
|
|
548
|
+
return jsonErrorResponse({
|
|
549
|
+
result: 'UNSUPPORTED_FILTER',
|
|
550
|
+
reason: `${unsupported.join(', ')} ${unsupported.length === 1 ? 'is' : 'are'} not supported for the "${liveFolder.name ?? liveFolder.id}" folder: it is read live from OurFamilyWizard, not from the cache, and OurFamilyWizard's folder listing cannot filter.`,
|
|
551
|
+
remedy: 'Re-call without since/until/q and page through the folder (newest first, or sort:"oldest").',
|
|
552
|
+
complete: false,
|
|
553
|
+
note: 'No messages were looked up.',
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
// 50 is the page size the sync walks with, so OFW is known to honour it.
|
|
557
|
+
// A larger request that OFW silently capped would come back short and
|
|
558
|
+
// read as the LAST page, hiding every page after it.
|
|
559
|
+
const liveSize = Math.min(size, LIVE_FOLDER_MAX_PAGE);
|
|
560
|
+
const result = await fetchFolderPage(client, liveFolder, {
|
|
561
|
+
page, size: liveSize, sort, checkedAt: new Date(callStartedAt).toISOString(), full: args.view === 'full',
|
|
562
|
+
});
|
|
563
|
+
// Remember what the listing showed (subject, sender, time, OFW's read
|
|
564
|
+
// flag) so ofw_get_message's mark-read gates can judge these ids — the
|
|
565
|
+
// sync never walks this folder, so nothing else ever would.
|
|
566
|
+
await recordFolderSightings(cacheProvider(), result.messages, new Date(callStartedAt).toISOString());
|
|
567
|
+
const freshness = await buildFreshness(cacheProvider(), { source: 'live', folders: [] });
|
|
568
|
+
if (brief) {
|
|
569
|
+
const lines = result.messages.map((m) => folderMessageBrief(m, displayTimeZone()));
|
|
570
|
+
// OFW rarely reports a folder total, so "-- N of M shown" is not
|
|
571
|
+
// always available; a slice still has to say it is one.
|
|
572
|
+
return briefResult(result.hasMore && result.total === null
|
|
573
|
+
? [...lines, `-- ${result.returned} shown, more on page ${result.nextPage}`]
|
|
574
|
+
: briefPage(lines, result.hasMore ? { shown: result.returned, total: result.total } : undefined), 'Message subjects and sender names are written by your co-parent and other OurFamilyWizard users.');
|
|
575
|
+
}
|
|
576
|
+
const complete = page === 1 && !result.hasMore && result.skipped === 0;
|
|
577
|
+
const label = liveFolder.name ?? liveFolder.id;
|
|
578
|
+
// Same key order as the cached path: paging state, notes and freshness
|
|
579
|
+
// ahead of `messages`, so a reader that stops early still learns it holds
|
|
580
|
+
// a slice.
|
|
581
|
+
const payload = {
|
|
582
|
+
complete,
|
|
583
|
+
hasMore: result.hasMore,
|
|
584
|
+
nextPage: result.nextPage,
|
|
585
|
+
returned: result.returned,
|
|
586
|
+
...(result.total !== null ? { total: result.total } : {}),
|
|
587
|
+
page,
|
|
588
|
+
size: liveSize,
|
|
589
|
+
sort,
|
|
590
|
+
folder: liveFolder,
|
|
591
|
+
};
|
|
592
|
+
if (result.skipped > 0)
|
|
593
|
+
payload.skipped = result.skipped;
|
|
594
|
+
if (!complete) {
|
|
595
|
+
payload.completeNote = [
|
|
596
|
+
page !== 1 ? `this is page ${page}; earlier pages are not in this response` : null,
|
|
597
|
+
result.hasMore ? `more messages remain in "${label}" — call again with page:${result.nextPage}` : null,
|
|
598
|
+
result.skipped > 0 ? `${result.skipped} list item${result.skipped === 1 ? '' : 's'} carried no message id and ${result.skipped === 1 ? 'was' : 'were'} left out` : null,
|
|
599
|
+
].filter((r) => r !== null)
|
|
600
|
+
.join('; ')
|
|
601
|
+
.concat('. Do not state a total or an absence from this result without resolving that first.');
|
|
602
|
+
}
|
|
603
|
+
payload.note = result.returned === 0 && complete
|
|
604
|
+
? `The "${label}" folder holds no messages on OurFamilyWizard (read live just now).`
|
|
605
|
+
: `Read live from the "${label}" folder on OurFamilyWizard: subjects, senders and dates only — this folder is not cached, so no body is included and since/until/q do not apply. Fetch one with ofw_get_message(messageId); like any first read, that marks an unread message read on OurFamilyWizard. \`read\` is OurFamilyWizard's own list flag (null when it sent none).`;
|
|
606
|
+
payload.freshness = freshness;
|
|
607
|
+
payload.messages = result.messages;
|
|
608
|
+
return jsonResponse(payload);
|
|
609
|
+
};
|
|
523
610
|
let folder;
|
|
524
611
|
if (folderArg === 'inbox')
|
|
525
612
|
folder = 'inbox';
|
|
@@ -528,16 +615,40 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
528
615
|
else if (folderArg === 'both')
|
|
529
616
|
folder = undefined;
|
|
530
617
|
else {
|
|
531
|
-
//
|
|
532
|
-
//
|
|
533
|
-
//
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
618
|
+
// Any other value names an OurFamilyWizard folder by id or name (issue
|
|
619
|
+
// #453). Inbox and sent still answer from the cache; anything else is
|
|
620
|
+
// read live, one list page at a time.
|
|
621
|
+
const resolved = await resolveMessageFolder(client, folderArg);
|
|
622
|
+
if (resolved.kind === 'cached')
|
|
623
|
+
folder = resolved.folder;
|
|
624
|
+
else if (resolved.kind === 'drafts') {
|
|
625
|
+
return jsonErrorResponse({
|
|
626
|
+
result: 'INVALID_FOLDER',
|
|
627
|
+
reason: `${JSON.stringify(folderArg)} is the Drafts folder, which ofw_list_messages does not list.`,
|
|
628
|
+
remedy: 'Call ofw_list_drafts instead: it verifies drafts against OurFamilyWizard and carries each draft\'s revision and draftKey.',
|
|
629
|
+
complete: false,
|
|
630
|
+
note: 'No messages were looked up. This says NOTHING about what is in the folder.',
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
else if (resolved.kind === 'unknown') {
|
|
634
|
+
// A rejected argument is an ERROR, not a result. Returning
|
|
635
|
+
// `messages: []` here — even with a note attached — hands back the one
|
|
636
|
+
// shape this whole mechanism exists to eliminate: an empty list that
|
|
637
|
+
// looks like an answer.
|
|
638
|
+
return jsonErrorResponse({
|
|
639
|
+
result: 'INVALID_FOLDER',
|
|
640
|
+
reason: resolved.ambiguous
|
|
641
|
+
? `${resolved.available.length} folders are named ${JSON.stringify(folderArg.trim())}; pass one of their ids instead.`
|
|
642
|
+
: `There is no OurFamilyWizard folder with the id or name ${JSON.stringify(folderArg)}.`,
|
|
643
|
+
remedy: 'Re-call with folderId "inbox", "sent", "both", or the id or name of one of availableFolders (ofw_list_message_folders lists them with counts).',
|
|
644
|
+
availableFolders: resolved.available,
|
|
645
|
+
complete: false,
|
|
646
|
+
note: 'No messages were looked up. This says NOTHING about what is in any folder — do not read it as "no messages".',
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
return listLiveFolder(resolved.folder);
|
|
651
|
+
}
|
|
541
652
|
}
|
|
542
653
|
// sent_at is stored as OFW's naive local wall clock, so the bounds are
|
|
543
654
|
// compared as strings. Convert an offset/Z bound to that same form first —
|
|
@@ -689,7 +800,7 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
689
800
|
});
|
|
690
801
|
server.registerTool('ofw_get_message', {
|
|
691
802
|
_meta: familyMeta('lookup'),
|
|
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,
|
|
803
|
+
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. A message in any other folder (Archived, Action Items, a folder the user created) comes back with folder:"other", folderId and folderName, no `read` verdict (received vs sent cannot be told from the folder; see recipients[].viewedAt), and is not cached (each read is live); after ofw_list_messages(folderId) has listed that folder, the mark-read safeguards below judge such a message by that listing\'s read flag, so it can be opened, confirmed or withheld like an inbox message instead of being refused as unknown. 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,
|
|
693
804
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
694
805
|
inputSchema: z.object({
|
|
695
806
|
messageId: z.string().describe('Message ID (also accepts draft IDs — drafts are routed via the drafts cache)'),
|
|
@@ -767,22 +878,41 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
767
878
|
});
|
|
768
879
|
}
|
|
769
880
|
const cached = await cache.getMessage(id);
|
|
881
|
+
// A message in a folder the cache does not hold (Archived, a user folder)
|
|
882
|
+
// is known only from a live folder listing's sighting. It stands in for
|
|
883
|
+
// the cached row in every mark-read gate below — never stored, and never
|
|
884
|
+
// used as content: its body still comes from the live fetch.
|
|
885
|
+
const sighting = cached === null ? await getFolderSighting(cache, id) : null;
|
|
886
|
+
const gateRow = cached ?? (sighting === null ? null : sightingGateRow(id, sighting));
|
|
770
887
|
// No-read day: protect an UNREAD INBOX message — answer from the cache
|
|
771
888
|
// with its body withheld and never touch OFW, since its detail GET would
|
|
772
889
|
// mark it read. An uncached id is refused: whether it is one is exactly
|
|
773
890
|
// what cannot be known without that GET. Sent and already-read messages
|
|
774
891
|
// fall through and are served as on any other day.
|
|
775
892
|
const noReadDay = readingBlockedToday();
|
|
776
|
-
const protectedToday = noReadDay !== null && (
|
|
893
|
+
const protectedToday = noReadDay !== null && (gateRow === null || isUnreadInbox(gateRow));
|
|
777
894
|
// The override is "used" only when it lifts the day for THIS message.
|
|
778
895
|
const overriding = protectedToday && args.overrideNoReadDay === true;
|
|
779
896
|
const blocked = protectedToday && !overriding ? noReadDay : null;
|
|
780
897
|
if (blocked !== null) {
|
|
781
898
|
if (cached === null) {
|
|
899
|
+
if (sighting !== null) {
|
|
900
|
+
// Seen in a folder listing as unread: say which message is being
|
|
901
|
+
// held back, as the cached path does, without a request.
|
|
902
|
+
return jsonErrorResponse({
|
|
903
|
+
...blocked,
|
|
904
|
+
messageId: id,
|
|
905
|
+
subject: sighting.subject,
|
|
906
|
+
from: sighting.from,
|
|
907
|
+
sentAt: sighting.sentAt,
|
|
908
|
+
folderName: sighting.folderName,
|
|
909
|
+
hint: `OurFamilyWizard's listing of the "${sighting.folderName ?? sighting.folderId}" folder shows this message unread, and opening it would mark it read. Its body is withheld until reading resumes (or overrideNoReadDay:true, if the user explicitly asks).`,
|
|
910
|
+
});
|
|
911
|
+
}
|
|
782
912
|
return jsonErrorResponse({
|
|
783
913
|
...blocked,
|
|
784
914
|
messageId: id,
|
|
785
|
-
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 — and, if it is sent or already read, its body.',
|
|
915
|
+
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 — and, if it is sent or already read, its body. If it is in another folder (Archived, Action Items, a folder you created), list that folder with ofw_list_messages(folderId: <its id or name>) instead.',
|
|
786
916
|
});
|
|
787
917
|
}
|
|
788
918
|
const attachments = await cache.listAttachmentsForMessage(id);
|
|
@@ -857,10 +987,10 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
857
987
|
// unread INBOX message marks it read on OFW, stamping a "First Viewed"
|
|
858
988
|
// time the co-parent can see. That is a court-visible, irreversible change
|
|
859
989
|
// made as a side effect of an ordinary read, so it gets an explicit gate.
|
|
860
|
-
const markReadCheck = markReadVerdict(
|
|
990
|
+
const markReadCheck = markReadVerdict(gateRow, args.allowMarkRead);
|
|
861
991
|
if (markReadCheck !== null)
|
|
862
992
|
return markReadCheck;
|
|
863
|
-
const confirmGate = await confirmMarkRead(ctx,
|
|
993
|
+
const confirmGate = await confirmMarkRead(ctx, gateRow, args, overriding);
|
|
864
994
|
if (confirmGate)
|
|
865
995
|
return confirmGate;
|
|
866
996
|
const detail = parseLenient(MessageDetailSchema, await client.request('GET', `/pub/v3/messages/${encodeURIComponent(args.messageId)}`), { label: 'ofw-mcp', context: 'GET /pub/v3/messages/{id} (ofw_get_message)' });
|
|
@@ -872,11 +1002,27 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
872
1002
|
// a sent-scoped ofw_list_messages). When that mapping isn't known yet (no
|
|
873
1003
|
// sync has run in this cache), fall back to 'inbox' as before.
|
|
874
1004
|
let folder = cached?.folder ?? 'inbox';
|
|
1005
|
+
// Set when the detail places the message in a folder the cache does not
|
|
1006
|
+
// hold. Such a message is NOT cached: as 'inbox' it would appear in inbox
|
|
1007
|
+
// listings and counts it is not in, and no sync would ever correct it.
|
|
1008
|
+
let otherFolder = null;
|
|
875
1009
|
if (!cached) {
|
|
876
|
-
const
|
|
877
|
-
|
|
1010
|
+
const map = await readFolderIdMap(cache);
|
|
1011
|
+
const detailFolderId = detail.folder?.id == null ? null : String(detail.folder.id);
|
|
1012
|
+
if (map.sent !== null && detailFolderId === map.sent) {
|
|
878
1013
|
folder = 'sent';
|
|
879
1014
|
}
|
|
1015
|
+
else if (detailFolderId !== null && map.inbox !== null && map.sent !== null && detailFolderId !== map.inbox) {
|
|
1016
|
+
// Only when BOTH ids are known: with a partial map, "not the sent id"
|
|
1017
|
+
// cannot tell the inbox from anything else, so the old labelling stands.
|
|
1018
|
+
const detailName = detail.folder.name;
|
|
1019
|
+
otherFolder = {
|
|
1020
|
+
id: detailFolderId,
|
|
1021
|
+
name: typeof detailName === 'string' && detailName !== ''
|
|
1022
|
+
? detailName
|
|
1023
|
+
: sighting !== null && sighting.folderId === detailFolderId ? sighting.folderName : null,
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
880
1026
|
}
|
|
881
1027
|
const fetchedBodyAt = new Date().toISOString();
|
|
882
1028
|
const row = {
|
|
@@ -892,16 +1038,34 @@ export function registerMessageTools(server, client, cacheProvider, attachmentIO
|
|
|
892
1038
|
chainRootId: cached?.chainRootId ?? null,
|
|
893
1039
|
listData: cached?.listData ?? detail,
|
|
894
1040
|
};
|
|
895
|
-
|
|
1041
|
+
if (otherFolder === null)
|
|
1042
|
+
await cache.upsertMessage(row);
|
|
896
1043
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
897
1044
|
await fetchAttachmentMetaForMessage(client, detail.id, detail.files, cache);
|
|
898
1045
|
}
|
|
899
1046
|
const attachments = await cache.listAttachmentsForMessage(detail.id);
|
|
900
1047
|
// Fetched live from OFW in this call — current by construction.
|
|
901
|
-
const freshness = await buildFreshness(cache, { source: 'live', folders: [folder] });
|
|
1048
|
+
const freshness = await buildFreshness(cache, { source: 'live', folders: otherFolder === null ? [folder] : [] });
|
|
1049
|
+
// A copy: on the full rung viewOne hands back the row object itself.
|
|
1050
|
+
const shown = { ...viewOne(view, withViewOrigin(withReadState(row), callStartedAt)) };
|
|
1051
|
+
if (otherFolder !== null) {
|
|
1052
|
+
// The read derivation is folder-aware (received vs sent), and a message
|
|
1053
|
+
// in another folder could be either — so there is no verdict to give.
|
|
1054
|
+
// `read` is OMITTED rather than null, as on the drafts route (the other
|
|
1055
|
+
// folder this tool reports that is not inbox/sent): a caller already has
|
|
1056
|
+
// to handle its absence, and a new null type would be one more contract.
|
|
1057
|
+
// The recipients' viewedAt, read from the detail just now, is the evidence.
|
|
1058
|
+
delete shown.read;
|
|
1059
|
+
}
|
|
902
1060
|
return jsonResponse({
|
|
903
1061
|
...(overriding ? readOverrideFields('ofw_get_message', [row.id]) : {}),
|
|
904
|
-
...
|
|
1062
|
+
...shown,
|
|
1063
|
+
...(otherFolder === null ? {} : {
|
|
1064
|
+
folder: 'other',
|
|
1065
|
+
folderId: otherFolder.id,
|
|
1066
|
+
folderName: otherFolder.name,
|
|
1067
|
+
otherFolderNote: `This message is in the "${otherFolder.name ?? otherFolder.id}" folder, which this server does not sync, so it is not cached: every read of it is a live fetch. There is no \`read\` verdict, because whether it was received or sent cannot be told from the folder; recipients[].viewedAt is OurFamilyWizard's own record.`,
|
|
1068
|
+
}),
|
|
905
1069
|
attachments,
|
|
906
1070
|
freshness,
|
|
907
1071
|
});
|
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.
|
|
7
|
+
export const VERSION = '2.30.0'; // 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.
|
|
9
|
+
"version": "2.30.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "ofw-mcp",
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.30.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|