@dudousxd/nestjs-agent 0.6.0 → 0.7.0

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.
@@ -4,7 +4,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
4
4
  // src/durable/agent-run.workflow.ts
5
5
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
6
6
  import { Workflow } from "@dudousxd/nestjs-durable";
7
- import { ContinueAsNew, WorkflowSuspended } from "@dudousxd/nestjs-durable-core";
7
+ import { isWorkflowControlFlowSignal } from "@dudousxd/nestjs-durable-core";
8
8
  import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
9
9
 
10
10
  // src/agent-deps.ts
@@ -159,8 +159,11 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
159
159
  openSink: /* @__PURE__ */ __name(async () => input.sinkRunId !== void 0 ? childSinkWriter(await deps.sink.open(sinkRunId)) : deps.sink.open(ctx.runId), "openSink"),
160
160
  awaitApproval: /* @__PURE__ */ __name((call) => ctx.waitForSignal(`tool:${ctx.runId}:${call.id}`), "awaitApproval"),
161
161
  step: /* @__PURE__ */ __name((name, fn) => ctx.localStep(name, fn), "step"),
162
- // Dispatched-step suspends must escape the loop's tool catch — control flow, not a tool failure.
163
- isControlFlowError: /* @__PURE__ */ __name((error) => error instanceof WorkflowSuspended || error instanceof ContinueAsNew, "isControlFlowError"),
162
+ // Dispatched-step suspends must escape the loop's tool catch — control flow, not a tool
163
+ // failure. Marker-based predicate, NOT instanceof: the signal's CLASS differs by runtime
164
+ // (engine in-process throws durable-core's WorkflowSuspended/ContinueAsNew; the BullMQ thin
165
+ // worker throws durable-worker's own Suspend), so only the Symbol.for marker is reliable.
166
+ isControlFlowError: /* @__PURE__ */ __name((error) => isWorkflowControlFlowSignal(error), "isControlFlowError"),
164
167
  runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
165
168
  const subThreadId = await ctx.localStep(`subthread:${agentName}`, async () => {
166
169
  const thread = await this.store.createThread({
@@ -201,7 +204,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
201
204
  await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
202
205
  return result;
203
206
  } catch (error) {
204
- if (error instanceof WorkflowSuspended || error instanceof ContinueAsNew) {
207
+ if (isWorkflowControlFlowSignal(error)) {
205
208
  throw error;
206
209
  }
207
210
  const message = error instanceof Error ? error.message : String(error);
@@ -248,7 +251,7 @@ AgentRunWorkflow = _ts_decorate2([
248
251
  // src/durable/durable-agent-runner.ts
249
252
  import { randomUUID } from "node:crypto";
250
253
  import { WorkflowService } from "@dudousxd/nestjs-durable";
251
- import { WorkflowSuspended as WorkflowSuspended2 } from "@dudousxd/nestjs-durable-core";
254
+ import { isWorkflowControlFlowSignal as isWorkflowControlFlowSignal2 } from "@dudousxd/nestjs-durable-core";
252
255
  import { Injectable as Injectable3 } from "@nestjs/common";
253
256
  function _ts_decorate3(decorators, target, key, desc) {
254
257
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -278,7 +281,7 @@ var DurableAgentRunner = class {
278
281
  try {
279
282
  await this.workflows.start(AgentRunWorkflow, stamped, runId);
280
283
  } catch (error) {
281
- if (!(error instanceof WorkflowSuspended2)) {
284
+ if (!isWorkflowControlFlowSignal2(error)) {
282
285
  throw error;
283
286
  }
284
287
  }