@clawos-dev/clawd 0.2.226 → 0.2.227

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/cli.cjs +22 -9
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -48364,6 +48364,12 @@ function computeNextRunAtMs(schedule, fromMs) {
48364
48364
  }
48365
48365
 
48366
48366
  // src/shift/store.ts
48367
+ function normalizeSchedule(schedule, nowMs) {
48368
+ if (schedule.kind === "every" && schedule.anchorMs === void 0) {
48369
+ return { ...schedule, anchorMs: nowMs };
48370
+ }
48371
+ return schedule;
48372
+ }
48367
48373
  function createShiftStore(deps) {
48368
48374
  let shifts = [];
48369
48375
  let flushTimer = null;
@@ -48382,7 +48388,15 @@ function createShiftStore(deps) {
48382
48388
  if (parsed.version !== 1) {
48383
48389
  throw new Error(`shift.json: unsupported version ${parsed.version}`);
48384
48390
  }
48385
- shifts = parsed.shifts ?? [];
48391
+ const now = deps.now();
48392
+ shifts = (parsed.shifts ?? []).map((s) => {
48393
+ const schedule = normalizeSchedule(s.schedule, s.createdAtMs);
48394
+ if (schedule === s.schedule) return s;
48395
+ const gridNext = computeNextRunAtMs(schedule, now) ?? void 0;
48396
+ const oldNext = s.state.nextRunAtMs;
48397
+ const nextRunAtMs = gridNext !== void 0 && (oldNext === void 0 || gridNext < oldNext) ? gridNext : oldNext;
48398
+ return { ...s, schedule, state: { ...s.state, nextRunAtMs } };
48399
+ });
48386
48400
  }
48387
48401
  async function flushNow() {
48388
48402
  if (flushTimer) {
@@ -48415,9 +48429,11 @@ function createShiftStore(deps) {
48415
48429
  }
48416
48430
  function add(input) {
48417
48431
  const now = deps.now();
48418
- const nextRunAtMs = computeNextRunAtMs(input.schedule, now) ?? void 0;
48432
+ const schedule = normalizeSchedule(input.schedule, now);
48433
+ const nextRunAtMs = computeNextRunAtMs(schedule, now) ?? void 0;
48419
48434
  const shift = {
48420
48435
  ...input,
48436
+ schedule,
48421
48437
  id: (0, import_node_crypto6.randomUUID)(),
48422
48438
  createdAtMs: now,
48423
48439
  updatedAtMs: now,
@@ -48432,8 +48448,8 @@ function createShiftStore(deps) {
48432
48448
  const idx = shifts.findIndex((s) => s.id === id);
48433
48449
  if (idx < 0) throw new Error(`shift not found: ${id}`);
48434
48450
  const now = deps.now();
48435
- const newSchedule = patch.schedule ?? shifts[idx].schedule;
48436
- const nextRunAtMs = patch.schedule ? computeNextRunAtMs(patch.schedule, now) ?? void 0 : shifts[idx].state.nextRunAtMs;
48451
+ const newSchedule = patch.schedule ? normalizeSchedule(patch.schedule, now) : shifts[idx].schedule;
48452
+ const nextRunAtMs = patch.schedule ? computeNextRunAtMs(newSchedule, now) ?? void 0 : shifts[idx].state.nextRunAtMs;
48437
48453
  const merged = {
48438
48454
  ...shifts[idx],
48439
48455
  ...patch,
@@ -48529,13 +48545,10 @@ function createShiftScheduler(deps) {
48529
48545
  async function tickNow() {
48530
48546
  const now = deps.now();
48531
48547
  if (now < lastTickAtMs || now - lastTickAtMs > CLOCK_JUMP_THRESHOLD_MS) {
48532
- for (const shift of deps.store.list()) {
48533
- const next = computeNextRunAtMs(shift.schedule, now) ?? void 0;
48534
- deps.store.patchState(shift.id, { nextRunAtMs: next });
48535
- }
48536
48548
  deps.logger?.warn("shift.scheduler.clock_jump", {
48537
48549
  lastTickAtMs,
48538
- now
48550
+ now,
48551
+ gapMs: now - lastTickAtMs
48539
48552
  });
48540
48553
  }
48541
48554
  lastTickAtMs = now;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.226",
3
+ "version": "0.2.227",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",