macroclaw 0.19.0 → 0.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "macroclaw",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Telegram-to-Claude-Code bridge",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/cron.test.ts CHANGED
@@ -254,7 +254,7 @@ describe("CronScheduler", () => {
254
254
 
255
255
  it("does not write file when no non-recurring jobs fired", () => {
256
256
  writeScheduleConfig({
257
- jobs: [{ name: "recurring", cron: nonMatchingCron(), prompt: "nope", recurring: false }],
257
+ jobs: [{ name: "recurring", cron: nonMatchingCron(), prompt: "nope" }],
258
258
  });
259
259
 
260
260
  const onJob = makeOnJob();
@@ -318,9 +318,9 @@ describe("missed non-recurring events", () => {
318
318
  expect(onJob).not.toHaveBeenCalled();
319
319
  });
320
320
 
321
- it("does not fire non-recurring jobs older than threshold", () => {
321
+ it("fires non-recurring job missed by more than 5 minutes", () => {
322
322
  writeScheduleConfig({
323
- jobs: [{ name: "old", cron: minutesAgoCron(10), prompt: "too late", recurring: false }],
323
+ jobs: [{ name: "old", cron: minutesAgoCron(10), prompt: "still fires", recurring: false }],
324
324
  });
325
325
 
326
326
  const onJob = makeOnJob();
@@ -328,8 +328,13 @@ describe("missed non-recurring events", () => {
328
328
  cron.start();
329
329
  cron.stop();
330
330
 
331
- expect(onJob).not.toHaveBeenCalled();
331
+ expect(onJob).toHaveBeenCalledTimes(1);
332
+ const call = onJob.mock.calls[0];
333
+ expect(call[0]).toBe("old");
334
+ expect(call[1]).toContain("[missed event, should have fired");
335
+ expect(call[1]).toContain("still fires");
336
+
332
337
  const updated = readScheduleConfig();
333
- expect(updated.jobs).toHaveLength(1);
338
+ expect(updated.jobs).toHaveLength(0);
334
339
  });
335
340
  });
package/src/cron.ts CHANGED
@@ -25,7 +25,6 @@ export interface CronSchedulerConfig {
25
25
  }
26
26
 
27
27
  const TICK_INTERVAL = 10_000; // 10 seconds
28
- const MISSED_THRESHOLD = 300_000; // 5 minutes
29
28
 
30
29
  export class CronScheduler {
31
30
  #lastMinute = -1;
@@ -88,8 +87,8 @@ export class CronScheduler {
88
87
  if (job.recurring === false) {
89
88
  firedNonRecurring.push(i);
90
89
  }
91
- } else if (job.recurring === false && diff < MISSED_THRESHOLD) {
92
- // Non-recurring job missed (service was down) — fire with missed prefix
90
+ } else if (job.recurring === false && diff >= 60_000) {
91
+ // Non-recurring job in the past — fire regardless of how late
93
92
  const missedMinutes = Math.round(diff / 60_000);
94
93
  const firedAt = prev.toISOString();
95
94
  const missedPrompt = `[missed event, should have fired ${missedMinutes} min ago at ${firedAt}] ${job.prompt}`;