replywizard-whatsapp-mcp 0.4.0 → 0.5.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/README.md CHANGED
@@ -35,6 +35,14 @@ lifted into its own repository without touching the extension.
35
35
  | `summarize_chat` | value | Bulleted summary of a chat's recent messages (uses your configured AI provider). |
36
36
  | `suggest_reply` | value | Drafts a reply as you, returns text only, **never sends**. |
37
37
  | `transcribe_voice_note` | value | Transcribes a voice note via your configured **cloud** speech-to-text provider. |
38
+ | `draft_message` | write | Puts text in one chat's message box under a "Drafted by" bar. Refuses a box that already holds text. **Never sends**: you read it and press Send. |
39
+ | `create_reminder` | write | Saves a Reply Wizard reminder for a chat (`dueAt` in ISO 8601 with a time zone, optional repeat). Chrome notifies you at that time; nothing is sent. |
40
+ | `save_template` | write | Saves a message template to Reply Wizard's Templates. |
41
+
42
+ **Write tools (0.5.0) are off until you allow them.** They need Reply Wizard 3.5.9 or later and the
43
+ switch "Let AI assistants save and draft" on the extension's WhatsApp MCP tab. Until then every call
44
+ answers with a sentence saying so and changes nothing. Every attempt, allowed or refused, is listed on
45
+ that tab, and none of the three can send a message.
38
46
 
39
47
  Value tools reuse the extension's existing AI/STT configuration; **your API keys never leave the
40
48
  extension** (the hub only sees tool arguments and results).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replywizard-whatsapp-mcp",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Local MCP server and command line that expose WhatsApp Web (read + value tools) to AI clients via the Reply Wizard Chrome extension.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -33,7 +33,7 @@
33
33
  import { realpathSync } from 'node:fs';
34
34
  import { fileURLToPath } from 'node:url';
35
35
  import { TOOLS } from './tools.js';
36
- import { ACTIONS, VALUE_ACTIONS } from './protocol.js';
36
+ import { ACTIONS, VALUE_ACTIONS, WRITE_ACTIONS } from './protocol.js';
37
37
  import { DEFAULT_HTTP_PORT } from './daemon.js';
38
38
  import { ensureDaemon, spawnDetachedDaemon } from './connector.js';
39
39
  import { readToken } from './daemonAuth.js';
@@ -61,6 +61,9 @@ const POSITIONAL = {
61
61
  [ACTIONS.SUMMARIZE_CHAT]: ['chatId'],
62
62
  [ACTIONS.SUGGEST_REPLY]: ['chatId', 'guidance'],
63
63
  [ACTIONS.TRANSCRIBE_VOICE_NOTE]: ['messageId'],
64
+ [ACTIONS.DRAFT_MESSAGE]: ['chatId', 'text'],
65
+ [ACTIONS.CREATE_REMINDER]: ['chatId', 'text', 'dueAt'],
66
+ [ACTIONS.SAVE_TEMPLATE]: ['body'],
64
67
  };
65
68
 
66
69
  /** Shorter names for the two longest tools. The tool name always works as well. */
@@ -72,6 +75,9 @@ const ALIASES = {
72
75
  summarize: ACTIONS.SUMMARIZE_CHAT,
73
76
  suggest: ACTIONS.SUGGEST_REPLY,
74
77
  transcribe: ACTIONS.TRANSCRIBE_VOICE_NOTE,
78
+ draft: ACTIONS.DRAFT_MESSAGE,
79
+ remind: ACTIONS.CREATE_REMINDER,
80
+ template: ACTIONS.SAVE_TEMPLATE,
75
81
  };
76
82
 
77
83
  const toolByName = new Map(TOOLS.map((t) => [t.name, t]));
@@ -296,7 +302,8 @@ export function helpText() {
296
302
  const req = ((t.inputSchema && t.inputSchema.required) || []).includes(p);
297
303
  return req ? `<${p}>` : `[${p}]`;
298
304
  }).join(' ');
299
- const value = VALUE_ACTIONS.includes(t.name) ? ' (uses your AI provider)' : '';
305
+ const value = VALUE_ACTIONS.includes(t.name) ? ' (uses your AI provider)'
306
+ : WRITE_ACTIONS.includes(t.name) ? ' (off until you allow it; never sends)' : '';
300
307
  return ` replywizard ${[name, positional].filter(Boolean).join(' ')}${value}`;
301
308
  });
302
309
  return [
package/src/mcpServer.js CHANGED
@@ -30,7 +30,10 @@ export function createMcpServer(bridge) {
30
30
  };
31
31
  }
32
32
  try {
33
- const result = await bridge.callAction(action, args || {});
33
+ // The client's own name from its `initialize`, so a draft can say who wrote it
34
+ // ("Drafted by Claude"). Display text only; the extension bounds and cleans it.
35
+ const client = (server.getClientVersion && server.getClientVersion() && server.getClientVersion().name) || null;
36
+ const result = await bridge.callAction(action, args || {}, { client });
34
37
  // Compact, not pretty-printed (2026-10-02): every result is read by a model, and the
35
38
  // indentation was paid for in tokens on every call. The remote relay answers the same way.
36
39
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
package/src/protocol.js CHANGED
@@ -22,6 +22,10 @@ export const ACTIONS = Object.freeze({
22
22
  TRANSCRIBE_VOICE_NOTE: 'transcribe_voice_note',
23
23
  SUMMARIZE_CHAT: 'summarize_chat',
24
24
  SUGGEST_REPLY: 'suggest_reply',
25
+ // write, off until the person allows it (W0: our own storage; W1: a draft, never a send)
26
+ CREATE_REMINDER: 'create_reminder',
27
+ SAVE_TEMPLATE: 'save_template',
28
+ DRAFT_MESSAGE: 'draft_message',
25
29
  });
26
30
 
27
31
  export const READ_ACTIONS = Object.freeze([
@@ -30,6 +34,9 @@ export const READ_ACTIONS = Object.freeze([
30
34
  export const VALUE_ACTIONS = Object.freeze([
31
35
  ACTIONS.TRANSCRIBE_VOICE_NOTE, ACTIONS.SUMMARIZE_CHAT, ACTIONS.SUGGEST_REPLY,
32
36
  ]);
37
+ export const WRITE_ACTIONS = Object.freeze([
38
+ ACTIONS.CREATE_REMINDER, ACTIONS.SAVE_TEMPLATE, ACTIONS.DRAFT_MESSAGE,
39
+ ]);
33
40
 
34
41
  export const STATUS = Object.freeze({
35
42
  DISCONNECTED: 'disconnected',
package/src/tools.js CHANGED
@@ -18,6 +18,14 @@ import { ACTIONS } from './protocol.js';
18
18
  */
19
19
  const READ = Object.freeze({ readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false });
20
20
  const VALUE = Object.freeze({ readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: true });
21
+ /*
22
+ * The write tools (row 20 Phase 4, tiers W0 and W1). `readOnlyHint: false` on purpose, so ChatGPT
23
+ * and Claude ask the person before each call. None of them sends: two save to Reply Wizard's own
24
+ * storage and the third puts text in a message box for the person to send. They are refused by the
25
+ * extension until the person turns on "Let AI assistants save and draft" in Reply Wizard.
26
+ */
27
+ const WRITE = Object.freeze({ readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false });
28
+ const OFF_UNTIL_ALLOWED = ' Refused until the user turns on "Let AI assistants save and draft" in Reply Wizard\'s WhatsApp MCP settings.';
21
29
 
22
30
  export const TOOLS = [
23
31
  {
@@ -159,6 +167,62 @@ export const TOOLS = [
159
167
  additionalProperties: false,
160
168
  },
161
169
  },
170
+ {
171
+ name: ACTIONS.DRAFT_MESSAGE,
172
+ title: 'Put a draft in a chat\'s message box (does not send)',
173
+ annotations: { title: 'Put a draft in a chat\'s message box (does not send)', ...WRITE },
174
+ description:
175
+ 'Open a chat in the user\'s WhatsApp Web and put text in its message box, with a bar saying ' +
176
+ 'who drafted it. It does NOT send: the user reads it and presses Send. Refused if that chat ' +
177
+ 'already has unsent text in its box, so nothing the user typed is overwritten.' + OFF_UNTIL_ALLOWED,
178
+ inputSchema: {
179
+ type: 'object',
180
+ properties: {
181
+ chatId: { type: 'string', description: 'Chat id from list_chats, or a phone number in digits.' },
182
+ text: { type: 'string', maxLength: 2000, description: 'The message text, at most 2,000 characters.' },
183
+ },
184
+ required: ['chatId', 'text'],
185
+ additionalProperties: false,
186
+ },
187
+ },
188
+ {
189
+ name: ACTIONS.CREATE_REMINDER,
190
+ title: 'Set a reminder for a chat',
191
+ annotations: { title: 'Set a reminder for a chat', ...WRITE },
192
+ description:
193
+ 'Save a Reply Wizard reminder: at the time given, Chrome shows the user a notification with ' +
194
+ 'the note, and clicking it opens the chat with the note in the message box. Nothing is sent.' +
195
+ OFF_UNTIL_ALLOWED,
196
+ inputSchema: {
197
+ type: 'object',
198
+ properties: {
199
+ chatId: { type: 'string', description: 'Chat id from list_chats, or a phone number in digits.' },
200
+ text: { type: 'string', maxLength: 1000, description: 'The note, written as the message the user wants to send.' },
201
+ dueAt: { type: 'string', description: 'When, as ISO 8601 with a time zone offset, e.g. "2026-10-03T09:00:00+05:30". Must be in the future.' },
202
+ repeat: { type: 'string', description: 'Optional: "daily", "weekly", "monthly" or "weekdays". Omit for once.' },
203
+ },
204
+ required: ['chatId', 'text', 'dueAt'],
205
+ additionalProperties: false,
206
+ },
207
+ },
208
+ {
209
+ name: ACTIONS.SAVE_TEMPLATE,
210
+ title: 'Save a message template',
211
+ annotations: { title: 'Save a message template', ...WRITE },
212
+ description:
213
+ 'Save a reusable message template to Reply Wizard. Square brackets mark a part to fill in ' +
214
+ 'each time, e.g. "Running about [15] minutes late". The user inserts templates from the reply bar.' +
215
+ OFF_UNTIL_ALLOWED,
216
+ inputSchema: {
217
+ type: 'object',
218
+ properties: {
219
+ body: { type: 'string', maxLength: 2000, description: 'The template text, at most 2,000 characters.' },
220
+ title: { type: 'string', maxLength: 80, description: 'Optional short name; derived from the text if omitted.' },
221
+ },
222
+ required: ['body'],
223
+ additionalProperties: false,
224
+ },
225
+ },
162
226
  ];
163
227
 
164
228
  // name → extension action. (Identity for now; kept explicit so a tool name can
package/src/wsServer.js CHANGED
@@ -27,7 +27,7 @@ import { platform } from 'node:os';
27
27
  import { join } from 'node:path';
28
28
  import { mkdirSync, writeFileSync, rmSync } from 'node:fs';
29
29
  import { spawn } from 'node:child_process';
30
- import { CONTROL, DEFAULT_PORT, PROTOCOL_VERSION, VALUE_ACTIONS } from './protocol.js';
30
+ import { CONTROL, DEFAULT_PORT, PROTOCOL_VERSION, VALUE_ACTIONS, WRITE_ACTIONS } from './protocol.js';
31
31
  import { hostVersion } from './hostVersion.js';
32
32
  import { readJson, stateDir, writeJsonVerified } from './stateStore.js';
33
33
 
@@ -478,7 +478,7 @@ export class ExtensionBridge {
478
478
  * (read vs value) with bounded concurrency + per-lane backpressure; the per-action
479
479
  * timeout covers queue wait + round-trip.
480
480
  */
481
- callAction(action, params = {}) {
481
+ callAction(action, params = {}, { client = null } = {}) {
482
482
  if (this.portConflict) {
483
483
  return Promise.reject(new Error(`Another Reply Wizard hub is already using port ${this.port}. Close the duplicate MCP host (or set RW_MCP_PORT to a free port) and reconnect.`));
484
484
  }
@@ -493,7 +493,7 @@ export class ExtensionBridge {
493
493
  return Promise.reject(new Error(`Reply Wizard is busy (${lane.name} queue full). Try again shortly.`));
494
494
  }
495
495
  return new Promise((resolve, reject) => {
496
- const entry = { action, params, resolve, reject, settled: false, id: null, timer: null };
496
+ const entry = { action, params, client, resolve, reject, settled: false, id: null, timer: null };
497
497
  entry.timer = setTimeout(() => this._timeout(entry, lane), this.requestTimeoutMs);
498
498
  lane.queue.push(entry);
499
499
  this._drainLane(lane);
@@ -501,7 +501,8 @@ export class ExtensionBridge {
501
501
  }
502
502
 
503
503
  _laneFor(action) {
504
- return VALUE_ACTIONS.includes(action) ? this.lanes.value : this.lanes.read;
504
+ // Writes share the one-at-a-time value lane, so two drafts can never race for one composer.
505
+ return VALUE_ACTIONS.includes(action) || WRITE_ACTIONS.includes(action) ? this.lanes.value : this.lanes.read;
505
506
  }
506
507
 
507
508
  // Dispatch as many queued entries as the lane's concurrency limit allows.
@@ -529,7 +530,7 @@ export class ExtensionBridge {
529
530
  const id = randomUUID();
530
531
  entry.id = id;
531
532
  this.pending.set(id, { entry, lane });
532
- this._send({ id, method: 'action', action: entry.action, params: entry.params });
533
+ this._send({ id, method: 'action', action: entry.action, params: entry.params, ...(entry.client ? { client: String(entry.client).slice(0, 60) } : {}) });
533
534
  }
534
535
 
535
536
  // Settle an in-flight action, free its lane slot, and pump the lane.