@dudousxd/nestjs-agent-opencode 1.1.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 {
@@ -4117,11 +4130,11 @@ OpenCodeRunWorkflow = _ts_decorate4([
4117
4130
  version: "1"
4118
4131
  }),
4119
4132
  _ts_param4(1, (0, import_common7.Optional)()),
4120
- _ts_param4(1, (0, import_common7.Inject)(import_nestjs_durable.RUN_GATEWAY)),
4133
+ _ts_param4(1, (0, import_common7.Inject)(import_nestjs_durable_core.RunGateway)),
4121
4134
  _ts_metadata4("design:type", Function),
4122
4135
  _ts_metadata4("design:paramtypes", [
4123
4136
  typeof OpenCodeTurns === "undefined" ? Object : OpenCodeTurns,
4124
- typeof RunGateway === "undefined" ? Object : RunGateway
4137
+ typeof import_nestjs_durable_core.RunGateway === "undefined" ? Object : import_nestjs_durable_core.RunGateway
4125
4138
  ])
4126
4139
  ], OpenCodeRunWorkflow);
4127
4140
  function resultOf(outcome) {
@@ -4250,14 +4263,14 @@ var DurableOpenCodeAgentRunner = class _DurableOpenCodeAgentRunner {
4250
4263
  };
4251
4264
  DurableOpenCodeAgentRunner = _ts_decorate5([
4252
4265
  (0, import_common8.Injectable)(),
4253
- _ts_param5(1, (0, import_common8.Inject)(import_nestjs_durable2.RUN_GATEWAY)),
4266
+ _ts_param5(1, (0, import_common8.Inject)(import_nestjs_durable_core2.RunGateway)),
4254
4267
  _ts_param5(3, (0, import_common8.Inject)(OPENCODE_OPTIONS)),
4255
4268
  _ts_param5(4, (0, import_common8.Inject)(OPENCODE_HOST)),
4256
4269
  _ts_param5(5, (0, import_common8.Inject)(import_nestjs_agent_core7.AGENT_STORE)),
4257
4270
  _ts_metadata5("design:type", Function),
4258
4271
  _ts_metadata5("design:paramtypes", [
4259
4272
  typeof import_nestjs_durable2.WorkflowService === "undefined" ? Object : import_nestjs_durable2.WorkflowService,
4260
- typeof RunGateway === "undefined" ? Object : RunGateway,
4273
+ typeof import_nestjs_durable_core2.RunGateway === "undefined" ? Object : import_nestjs_durable_core2.RunGateway,
4261
4274
  typeof OpenCodeTurns === "undefined" ? Object : OpenCodeTurns,
4262
4275
  typeof OpenCodeEngineSettings === "undefined" ? Object : OpenCodeEngineSettings,
4263
4276
  typeof OpenCodeHost === "undefined" ? Object : OpenCodeHost,