@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.
@@ -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 {
@@ -3970,13 +3983,13 @@ __name(openCodeProviders, "openCodeProviders");
3970
3983
  // src/durable/runner.ts
3971
3984
  import { randomUUID as randomUUID2 } from "crypto";
3972
3985
  import { AGENT_STORE as AGENT_STORE2 } from "@dudousxd/nestjs-agent-core";
3973
- import { RUN_GATEWAY as RUN_GATEWAY2, WorkflowService } from "@dudousxd/nestjs-durable";
3974
- import { isWorkflowControlFlowSignal as isWorkflowControlFlowSignal2 } from "@dudousxd/nestjs-durable-core";
3986
+ import { WorkflowService } from "@dudousxd/nestjs-durable";
3987
+ import { RunGateway as RunGateway2, isWorkflowControlFlowSignal as isWorkflowControlFlowSignal2 } from "@dudousxd/nestjs-durable-core";
3975
3988
  import { Inject as Inject5, Injectable as Injectable4, Logger as Logger4 } from "@nestjs/common";
3976
3989
 
3977
3990
  // src/durable/workflow.ts
3978
- import { RUN_GATEWAY, Workflow } from "@dudousxd/nestjs-durable";
3979
- import { SignalTimeoutError, isWorkflowControlFlowSignal } from "@dudousxd/nestjs-durable-core";
3991
+ import { Workflow } from "@dudousxd/nestjs-durable";
3992
+ import { RunGateway, SignalTimeoutError, isWorkflowControlFlowSignal } from "@dudousxd/nestjs-durable-core";
3980
3993
  import { Inject as Inject4, Injectable as Injectable3, Optional as Optional2 } from "@nestjs/common";
3981
3994
  function _ts_decorate4(decorators, target, key, desc) {
3982
3995
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4089,7 +4102,7 @@ OpenCodeRunWorkflow = _ts_decorate4([
4089
4102
  version: "1"
4090
4103
  }),
4091
4104
  _ts_param4(1, Optional2()),
4092
- _ts_param4(1, Inject4(RUN_GATEWAY)),
4105
+ _ts_param4(1, Inject4(RunGateway)),
4093
4106
  _ts_metadata4("design:type", Function),
4094
4107
  _ts_metadata4("design:paramtypes", [
4095
4108
  typeof OpenCodeTurns === "undefined" ? Object : OpenCodeTurns,
@@ -4222,14 +4235,14 @@ var DurableOpenCodeAgentRunner = class _DurableOpenCodeAgentRunner {
4222
4235
  };
4223
4236
  DurableOpenCodeAgentRunner = _ts_decorate5([
4224
4237
  Injectable4(),
4225
- _ts_param5(1, Inject5(RUN_GATEWAY2)),
4238
+ _ts_param5(1, Inject5(RunGateway2)),
4226
4239
  _ts_param5(3, Inject5(OPENCODE_OPTIONS)),
4227
4240
  _ts_param5(4, Inject5(OPENCODE_HOST)),
4228
4241
  _ts_param5(5, Inject5(AGENT_STORE2)),
4229
4242
  _ts_metadata5("design:type", Function),
4230
4243
  _ts_metadata5("design:paramtypes", [
4231
4244
  typeof WorkflowService === "undefined" ? Object : WorkflowService,
4232
- typeof RunGateway === "undefined" ? Object : RunGateway,
4245
+ typeof RunGateway2 === "undefined" ? Object : RunGateway2,
4233
4246
  typeof OpenCodeTurns === "undefined" ? Object : OpenCodeTurns,
4234
4247
  typeof OpenCodeEngineSettings === "undefined" ? Object : OpenCodeEngineSettings,
4235
4248
  typeof OpenCodeHost === "undefined" ? Object : OpenCodeHost,