feat: merge schedule_reminder + send_later, add subtype reminder
Some checks failed
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled

- Merge send_later into schedule_reminder (optional `to` param — omit for self-reminder)
- Add subtype?: "reminder" to WSPushMessage, WSScheduleMessage, ScheduledEntry, InboundPush
- Broker handleSend now accepts optional subtype and injects into push envelope
- deliver closure passes sm.subtype so reminders surface correctly
- MCP channel meta includes subtype field; formatPush tags [REMINDER] in check_messages
- MCP server instructions document subtype and schedule_reminder/list_scheduled/cancel_scheduled
- client.scheduleMessage accepts isReminder flag, sends subtype: "reminder" on wire

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-07 22:38:41 +01:00
parent 3ff7a61e3f
commit 0bb9d71a26
5 changed files with 62 additions and 45 deletions

View File

@@ -51,6 +51,8 @@ export interface InboundPush {
/** Hint for UI: "direct" (crypto_box), "channel"/"broadcast"
* (plaintext for now). */
kind: "direct" | "broadcast" | "channel" | "unknown";
/** Optional semantic tag — "reminder" when fired by the scheduler. */
subtype?: "reminder";
}
type PushHandler = (msg: InboundPush) => void;
@@ -406,6 +408,7 @@ export class BrokerClient {
to: string,
message: string,
deliverAt: number,
isReminder = false,
): Promise<{ scheduledId: string; deliverAt: number } | null> {
if (!this.ws || this.ws.readyState !== this.ws.OPEN) return null;
return new Promise((resolve) => {
@@ -413,7 +416,14 @@ export class BrokerClient {
this.scheduledAckResolvers.set(reqId, { resolve, timer: setTimeout(() => {
if (this.scheduledAckResolvers.delete(reqId)) resolve(null);
}, 8_000) });
this.ws!.send(JSON.stringify({ type: "schedule", to, message, deliverAt, _reqId: reqId }));
this.ws!.send(JSON.stringify({
type: "schedule",
to,
message,
deliverAt,
...(isReminder ? { subtype: "reminder" } : {}),
_reqId: reqId,
}));
});
}
@@ -927,6 +937,7 @@ export class BrokerClient {
receivedAt: new Date().toISOString(),
plaintext,
kind,
...(msg.subtype ? { subtype: msg.subtype as "reminder" } : {}),
};
this.pushBuffer.push(push);
if (this.pushBuffer.length > 500) this.pushBuffer.shift();