@wahooks/channel 2.3.0 → 2.3.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.
Files changed (2) hide show
  1. package/dist/index.js +0 -81
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -164,35 +164,6 @@ let claudeConnected = false;
164
164
  const WAHOOKS_DIR = path.join(os.homedir(), ".wahooks");
165
165
  const REMINDERS_FILE = path.join(WAHOOKS_DIR, "reminders.json");
166
166
  const PENDING_FILE = path.join(WAHOOKS_DIR, "pending.json");
167
- const LOCK_FILE = path.join(WAHOOKS_DIR, ".pending.lock");
168
- function acquireLock() {
169
- try {
170
- fs.writeFileSync(LOCK_FILE, String(process.pid), { flag: "wx" });
171
- return true;
172
- }
173
- catch {
174
- try {
175
- const pid = parseInt(fs.readFileSync(LOCK_FILE, "utf-8"));
176
- try {
177
- process.kill(pid, 0);
178
- return false;
179
- }
180
- catch {
181
- fs.writeFileSync(LOCK_FILE, String(process.pid));
182
- return true;
183
- }
184
- }
185
- catch {
186
- return false;
187
- }
188
- }
189
- }
190
- function releaseLock() {
191
- try {
192
- fs.unlinkSync(LOCK_FILE);
193
- }
194
- catch { }
195
- }
196
167
  function readReminders() {
197
168
  try {
198
169
  return JSON.parse(fs.readFileSync(REMINDERS_FILE, "utf-8"));
@@ -205,58 +176,6 @@ function writeReminders(reminders) {
205
176
  fs.mkdirSync(WAHOOKS_DIR, { recursive: true });
206
177
  fs.writeFileSync(REMINDERS_FILE, JSON.stringify(reminders, null, 2) + "\n", { mode: 0o600 });
207
178
  }
208
- function readPending() {
209
- try {
210
- return JSON.parse(fs.readFileSync(PENDING_FILE, "utf-8"));
211
- }
212
- catch {
213
- return [];
214
- }
215
- }
216
- function writePending(items) {
217
- fs.mkdirSync(WAHOOKS_DIR, { recursive: true });
218
- fs.writeFileSync(PENDING_FILE, JSON.stringify(items, null, 2) + "\n", { mode: 0o600 });
219
- }
220
- async function processPendingQueue() {
221
- if (!claudeConnected)
222
- return;
223
- if (!acquireLock())
224
- return;
225
- try {
226
- const pending = readPending();
227
- if (pending.length === 0)
228
- return;
229
- // Prune stale items (>24h)
230
- const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000);
231
- const active = pending.filter((p) => new Date(p.addedAt) > cutoff);
232
- for (const item of active) {
233
- try {
234
- console.error(`[wahooks-channel] Sending reminder ${item.reminderId} to Claude...`);
235
- await mcp.notification({
236
- method: "notifications/claude/channel",
237
- params: {
238
- content: `[Scheduled Reminder] ${item.task}\n\nTarget chat: ${item.chatId}\nScheduled for: ${item.scheduledFor}\n\nPlease execute this task now and send the results to the target chat using wahooks_reply.`,
239
- meta: {
240
- from: item.chatId,
241
- reminder_id: item.reminderId,
242
- },
243
- },
244
- });
245
- console.error(`[wahooks-channel] Delivered reminder ${item.reminderId}`);
246
- }
247
- catch (err) {
248
- claudeConnected = false;
249
- console.error(`[wahooks-channel] Claude disconnected during reminder delivery: ${err}`);
250
- return; // stop processing, items stay in queue
251
- }
252
- }
253
- // All delivered — clear the queue
254
- writePending([]);
255
- }
256
- finally {
257
- releaseLock();
258
- }
259
- }
260
179
  // ─── MCP Server ─────────────────────────────────────────────────────────
261
180
  const mcp = new Server({ name: "wahooks-channel", version: "0.1.0" }, {
262
181
  capabilities: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wahooks/channel",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "WhatsApp channel for Claude Code — chat with Claude via WhatsApp",
5
5
  "type": "module",
6
6
  "bin": {