@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.
@@ -1,5 +1,5 @@
1
1
  import { AgentEngine } from '@dudousxd/nestjs-agent';
2
- import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeTurnStop, d as OpenCodeEngineOptions } from '../engine-yFh3eD8j.cjs';
2
+ import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeTurnStop, d as OpenCodeEngineOptions } from '../engine-BSGFlWxG.cjs';
3
3
  import { AgentRunner, AgentStore, AgentRunInput, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
4
4
  import { WorkflowService } from '@dudousxd/nestjs-durable';
5
5
  import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
@@ -1,5 +1,5 @@
1
1
  import { AgentEngine } from '@dudousxd/nestjs-agent';
2
- import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeTurnStop, d as OpenCodeEngineOptions } from '../engine-yFh3eD8j.js';
2
+ import { O as OpenCodeTurns, a as OpenCodeEngineSettings, b as OpenCodeHost, c as OpenCodeTurnStop, d as OpenCodeEngineOptions } from '../engine-BSGFlWxG.js';
3
3
  import { AgentRunner, AgentStore, AgentRunInput, AgentRunStartOptions, HumanReply } from '@dudousxd/nestjs-agent-core';
4
4
  import { WorkflowService } from '@dudousxd/nestjs-durable';
5
5
  import { RunGateway, WorkflowCtx } from '@dudousxd/nestjs-durable-core';
@@ -2814,7 +2814,7 @@ ${body}
2814
2814
  return milestone;
2815
2815
  } finally {
2816
2816
  watch.observing = false;
2817
- if (wall !== void 0) clearTimeout(wall);
2817
+ wall?.();
2818
2818
  }
2819
2819
  }
2820
2820
  async observeLive(runId, input, handle, live) {
@@ -3431,18 +3431,31 @@ ${body}
3431
3431
  const result = await this.requestStop(runId, reason);
3432
3432
  if (result === "unconfirmed") this.logger.warn(`run ${runId}: passed its ${reason} limit, but its owner could not be read`);
3433
3433
  }
3434
- /** The wall-clock bound of an observation: a timer for what is left of it, if anything. */
3434
+ /**
3435
+ * The wall-clock bound of an observation: a timer for what is left of it, if anything, and how to
3436
+ * cancel it. A timer may fire a millisecond or so before `Date.now()` says the time is up (timers
3437
+ * run on a monotonic clock, rounded): one that fires early waits out the rest, so a turn is never
3438
+ * stopped before its limit and its `elapsedMs` never reads under it.
3439
+ */
3435
3440
  watchClock(watch) {
3436
3441
  const max = watch.limits.wallClockMs;
3437
3442
  if (max === void 0) return void 0;
3438
- const left = watch.startedAt + max - Date.now();
3439
- if (left <= 0) {
3443
+ const left = /* @__PURE__ */ __name(() => watch.startedAt + max - Date.now(), "left");
3444
+ if (left() <= 0) {
3440
3445
  watch.pending ??= "wall-clock";
3441
3446
  return void 0;
3442
3447
  }
3443
- const timer = setTimeout(() => void this.limitStop(watch.runId, "wall-clock"), left);
3444
- timer.unref?.();
3445
- return timer;
3448
+ let timer;
3449
+ const arm = /* @__PURE__ */ __name((ms) => {
3450
+ timer = setTimeout(() => {
3451
+ const rest = left();
3452
+ if (rest > 0) arm(rest);
3453
+ else void this.limitStop(watch.runId, "wall-clock");
3454
+ }, ms);
3455
+ timer.unref?.();
3456
+ }, "arm");
3457
+ arm(left());
3458
+ return () => clearTimeout(timer);
3446
3459
  }
3447
3460
  counts(watch) {
3448
3461
  return {