@dudousxd/nestjs-agent-opencode 2.0.0 → 2.0.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.
@@ -2842,7 +2842,7 @@ ${body}
2842
2842
  return milestone;
2843
2843
  } finally {
2844
2844
  watch.observing = false;
2845
- if (wall !== void 0) clearTimeout(wall);
2845
+ wall?.();
2846
2846
  }
2847
2847
  }
2848
2848
  async observeLive(runId, input, handle, live) {
@@ -3459,18 +3459,31 @@ ${body}
3459
3459
  const result = await this.requestStop(runId, reason);
3460
3460
  if (result === "unconfirmed") this.logger.warn(`run ${runId}: passed its ${reason} limit, but its owner could not be read`);
3461
3461
  }
3462
- /** The wall-clock bound of an observation: a timer for what is left of it, if anything. */
3462
+ /**
3463
+ * The wall-clock bound of an observation: a timer for what is left of it, if anything, and how to
3464
+ * cancel it. A timer may fire a millisecond or so before `Date.now()` says the time is up (timers
3465
+ * run on a monotonic clock, rounded): one that fires early waits out the rest, so a turn is never
3466
+ * stopped before its limit and its `elapsedMs` never reads under it.
3467
+ */
3463
3468
  watchClock(watch) {
3464
3469
  const max = watch.limits.wallClockMs;
3465
3470
  if (max === void 0) return void 0;
3466
- const left = watch.startedAt + max - Date.now();
3467
- if (left <= 0) {
3471
+ const left = /* @__PURE__ */ __name(() => watch.startedAt + max - Date.now(), "left");
3472
+ if (left() <= 0) {
3468
3473
  watch.pending ??= "wall-clock";
3469
3474
  return void 0;
3470
3475
  }
3471
- const timer = setTimeout(() => void this.limitStop(watch.runId, "wall-clock"), left);
3472
- timer.unref?.();
3473
- return timer;
3476
+ let timer;
3477
+ const arm = /* @__PURE__ */ __name((ms) => {
3478
+ timer = setTimeout(() => {
3479
+ const rest = left();
3480
+ if (rest > 0) arm(rest);
3481
+ else void this.limitStop(watch.runId, "wall-clock");
3482
+ }, ms);
3483
+ timer.unref?.();
3484
+ }, "arm");
3485
+ arm(left());
3486
+ return () => clearTimeout(timer);
3474
3487
  }
3475
3488
  counts(watch) {
3476
3489
  return {