@dudousxd/nestjs-agent 0.12.0 → 1.0.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.
@@ -161,9 +161,6 @@ AgentRunSteps = _ts_decorate([
161
161
  ])
162
162
  ], AgentRunSteps);
163
163
 
164
- // src/durable/dispatched-steps.token.ts
165
- var AGENT_DISPATCHED_STEPS = Symbol.for("@dudousxd/nestjs-agent:dispatched-steps");
166
-
167
164
  // src/durable/agent-run.workflow.ts
168
165
  function _ts_decorate2(decorators, target, key, desc) {
169
166
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -188,12 +185,10 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
188
185
  }
189
186
  factory;
190
187
  store;
191
- dispatchedSteps;
192
188
  runs;
193
- constructor(factory, store, dispatchedSteps, runs) {
189
+ constructor(factory, store, runs) {
194
190
  this.factory = factory;
195
191
  this.store = store;
196
- this.dispatchedSteps = dispatchedSteps;
197
192
  this.runs = runs;
198
193
  }
199
194
  /**
@@ -246,7 +241,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
246
241
  async run(ctx, input) {
247
242
  const day = input.day ?? utcDay();
248
243
  const deps = this.factory.forAgent(input.agentName);
249
- const dispatchSteps = this.dispatchedSteps && await ctx.patched("agent:dispatched-steps");
244
+ const dispatchSteps = await ctx.patched("agent:dispatched-steps");
250
245
  if (input.sinkRunId !== void 0 || input.deliverTo !== void 0) {
251
246
  await ctx.localStep("activate", () => this.store.setActiveStream(input.threadId, ctx.runId));
252
247
  }
@@ -336,10 +331,11 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
336
331
  runId: childRunId
337
332
  };
338
333
  }, "startAgent"),
339
- // Routes the two long steps through AgentRunSteps as engine-dispatched `ctx.step`s instead of
340
- // `ctx.localStep`s, so a turn isn't pinned to this workflow worker for the model call or a tool
341
- // execution. `sinkRunId`/`childSink` are sink routing this workflow already resolved above —
342
- // core's dispatchLlm signature stays sink-topology-agnostic, so we add them here, not in core.
334
+ // The two long steps as engine-dispatched `ctx.step`s, so a turn isn't pinned to this
335
+ // workflow worker for the model call or a tool execution. `sinkRunId`/`childSink` are sink
336
+ // routing this workflow already resolved above — core's dispatchLlm signature stays
337
+ // sink-topology-agnostic, so we add them here, not in core. Omitted only for a run whose
338
+ // journal predates dispatch (`dispatchSteps` above), which leaves the loop on `hooks.step`.
343
339
  ...dispatchSteps ? {
344
340
  dispatchLlm: /* @__PURE__ */ __name((index, envelope) => ctx.step(AgentRunSteps.prototype.llm, {
345
341
  ...envelope,
@@ -425,14 +421,12 @@ AgentRunWorkflow = _ts_decorate2([
425
421
  }),
426
422
  _ts_param2(0, Inject2(AGENT_DEPS_FACTORY2)),
427
423
  _ts_param2(1, Inject2(AGENT_STORE)),
428
- _ts_param2(2, Inject2(AGENT_DISPATCHED_STEPS)),
429
- _ts_param2(3, Optional()),
430
- _ts_param2(3, Inject2(RUN_GATEWAY)),
424
+ _ts_param2(2, Optional()),
425
+ _ts_param2(2, Inject2(RUN_GATEWAY)),
431
426
  _ts_metadata2("design:type", Function),
432
427
  _ts_metadata2("design:paramtypes", [
433
428
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
434
429
  typeof AgentStore === "undefined" ? Object : AgentStore,
435
- Boolean,
436
430
  typeof RunGateway === "undefined" ? Object : RunGateway
437
431
  ])
438
432
  ], AgentRunWorkflow);
@@ -443,6 +437,76 @@ import { AGENT_SINK, AGENT_STORE as AGENT_STORE2, encodeStreamEvent } from "@dud
443
437
  import { RUN_GATEWAY as RUN_GATEWAY2, WorkflowService } from "@dudousxd/nestjs-durable";
444
438
  import { isWorkflowControlFlowSignal as isWorkflowControlFlowSignal2 } from "@dudousxd/nestjs-durable-core";
445
439
  import { Inject as Inject3, Injectable as Injectable3, Logger } from "@nestjs/common";
440
+
441
+ // src/in-process-sink.ts
442
+ import { AgentStreamError } from "@dudousxd/nestjs-agent-core";
443
+ var InProcessTokenStreamSink = class {
444
+ static {
445
+ __name(this, "InProcessTokenStreamSink");
446
+ }
447
+ runs = /* @__PURE__ */ new Map();
448
+ buffer(runId) {
449
+ let buf = this.runs.get(runId);
450
+ if (buf === void 0) {
451
+ buf = {
452
+ chunks: [],
453
+ ended: false,
454
+ notify: /* @__PURE__ */ new Set()
455
+ };
456
+ this.runs.set(runId, buf);
457
+ }
458
+ return buf;
459
+ }
460
+ wake(buf) {
461
+ for (const resolve of buf.notify) {
462
+ resolve();
463
+ }
464
+ buf.notify.clear();
465
+ }
466
+ open(runId) {
467
+ const buf = this.buffer(runId);
468
+ return {
469
+ write: /* @__PURE__ */ __name((chunk) => {
470
+ buf.chunks.push(chunk);
471
+ this.wake(buf);
472
+ }, "write"),
473
+ end: /* @__PURE__ */ __name(() => {
474
+ buf.ended = true;
475
+ this.wake(buf);
476
+ }, "end"),
477
+ fail: /* @__PURE__ */ __name((error) => {
478
+ buf.failure = error;
479
+ buf.ended = true;
480
+ this.wake(buf);
481
+ }, "fail")
482
+ };
483
+ }
484
+ async *subscribe(runId) {
485
+ const buf = this.buffer(runId);
486
+ let index = 0;
487
+ while (true) {
488
+ while (index < buf.chunks.length) {
489
+ const chunk = buf.chunks[index];
490
+ index += 1;
491
+ if (chunk !== void 0) {
492
+ yield chunk;
493
+ }
494
+ }
495
+ if (buf.ended) {
496
+ if (buf.failure !== void 0) {
497
+ throw new AgentStreamError(buf.failure);
498
+ }
499
+ return;
500
+ }
501
+ await new Promise((resolve) => buf.notify.add(resolve));
502
+ }
503
+ }
504
+ close(runId) {
505
+ this.runs.delete(runId);
506
+ }
507
+ };
508
+
509
+ // src/durable/durable-agent-runner.ts
446
510
  function _ts_decorate3(decorators, target, key, desc) {
447
511
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
448
512
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -460,6 +524,13 @@ function _ts_param3(paramIndex, decorator) {
460
524
  };
461
525
  }
462
526
  __name(_ts_param3, "_ts_param");
527
+ function threadOfRun(input) {
528
+ if (typeof input !== "object" || input === null || !("threadId" in input)) {
529
+ return void 0;
530
+ }
531
+ return typeof input.threadId === "string" ? input.threadId : void 0;
532
+ }
533
+ __name(threadOfRun, "threadOfRun");
463
534
  var DurableAgentRunner = class _DurableAgentRunner {
464
535
  static {
465
536
  __name(this, "DurableAgentRunner");
@@ -474,6 +545,9 @@ var DurableAgentRunner = class _DurableAgentRunner {
474
545
  this.runs = runs;
475
546
  this.store = store;
476
547
  this.sink = sink;
548
+ if (this.sink instanceof InProcessTokenStreamSink) {
549
+ this.logger.warn("durable: true with the default InProcessTokenStreamSink, which only buffers tokens in this process. The worker that runs the turn \u2014 and the one that serves its dispatched `llm` step \u2014 cannot stream into this buffer. Wire a cross-process TokenStreamSink (e.g. a Redis pub/sub sink) via AgentModule.forRoot({ sink }) before running multi-pod.");
550
+ }
477
551
  }
478
552
  async start(input) {
479
553
  const stamped = {
@@ -506,17 +580,28 @@ var DurableAgentRunner = class _DurableAgentRunner {
506
580
  * settles the run `cancelled` regardless. The cascade to child runs comes with it.
507
581
  *
508
582
  * Neither of those settles the agent's own state, so this does: the run row gets its own terminal,
509
- * and the subscriber gets a `cancelled` frame followed by a normal end. Both are keyed by runId
510
- * alone, which is why they belong here rather than in the body — the body is the only place that
511
- * knows which THREAD was streaming, so releasing that stays there (see `AgentRunWorkflow`).
583
+ * the thread stops reporting a live stream, and the subscriber gets a `cancelled` frame followed
584
+ * by a normal end.
585
+ *
586
+ * The thread is released HERE rather than left to the body, because a cancelled turn is usually
587
+ * suspended — parked on a human, or on one of the dispatched steps a turn spends most of its life
588
+ * in — and a suspended body never reaches its own catch: the runtime settles the run from outside
589
+ * it. The body still releases the thread on the paths where it does unwind (see
590
+ * `AgentRunWorkflow`); both write the same `null`, and whichever gets there first is right. The
591
+ * thread id comes off the run's own recorded input, so this holds for a sub-agent's subthread too
592
+ * — read best-effort, because a gateway that cannot name the thread must not stop the cancel.
512
593
  *
513
594
  * A tool already executing is not interrupted, here or anywhere: see `haltIfCancelled` in core.
514
595
  */
515
596
  async cancel(runId) {
516
597
  this.logger.log(`cancelling agent run ${runId}`);
598
+ const threadId = await this.threadOf(runId);
517
599
  await this.runs.cancel(runId, {
518
600
  compensate: true
519
601
  });
602
+ if (threadId !== void 0) {
603
+ await this.store.setActiveStream(threadId, null);
604
+ }
520
605
  const writer = await this.sink.open(runId);
521
606
  await writer.write(encodeStreamEvent({
522
607
  kind: "cancelled"
@@ -527,6 +612,23 @@ var DurableAgentRunner = class _DurableAgentRunner {
527
612
  status: "cancelled"
528
613
  });
529
614
  }
615
+ /**
616
+ * Which thread a run was streaming, or `undefined` where the gateway cannot say.
617
+ *
618
+ * A read failure answers `undefined` instead of propagating, the same posture `AgentRunWorkflow`
619
+ * takes for its own cancel observation: failing to ask is not an answer worth failing a cancel
620
+ * over. This id is only needed to clear the thread's active stream, and a stream still marked live
621
+ * is a far smaller fault than the one a throw here would cause — a run nobody ever told to stop,
622
+ * with a subscriber holding a stream that never settles, from the one call whose entire job is to
623
+ * make a run stop.
624
+ */
625
+ async threadOf(runId) {
626
+ try {
627
+ return threadOfRun((await this.runs.getRunDetail(runId))?.run.input);
628
+ } catch {
629
+ return void 0;
630
+ }
631
+ }
530
632
  };
531
633
  DurableAgentRunner = _ts_decorate3([
532
634
  Injectable3(),
@@ -543,78 +645,8 @@ DurableAgentRunner = _ts_decorate3([
543
645
  ], DurableAgentRunner);
544
646
 
545
647
  // src/durable/agent-durable.module.ts
546
- import { AGENT_DURABLE_RUNNER, AGENT_OPTIONS, AGENT_SINK as AGENT_SINK2 } from "@dudousxd/nestjs-agent-core";
547
- import { Global, Logger as Logger2, Module } from "@nestjs/common";
548
-
549
- // src/in-process-sink.ts
550
- import { AgentStreamError } from "@dudousxd/nestjs-agent-core";
551
- var InProcessTokenStreamSink = class {
552
- static {
553
- __name(this, "InProcessTokenStreamSink");
554
- }
555
- runs = /* @__PURE__ */ new Map();
556
- buffer(runId) {
557
- let buf = this.runs.get(runId);
558
- if (buf === void 0) {
559
- buf = {
560
- chunks: [],
561
- ended: false,
562
- notify: /* @__PURE__ */ new Set()
563
- };
564
- this.runs.set(runId, buf);
565
- }
566
- return buf;
567
- }
568
- wake(buf) {
569
- for (const resolve of buf.notify) {
570
- resolve();
571
- }
572
- buf.notify.clear();
573
- }
574
- open(runId) {
575
- const buf = this.buffer(runId);
576
- return {
577
- write: /* @__PURE__ */ __name((chunk) => {
578
- buf.chunks.push(chunk);
579
- this.wake(buf);
580
- }, "write"),
581
- end: /* @__PURE__ */ __name(() => {
582
- buf.ended = true;
583
- this.wake(buf);
584
- }, "end"),
585
- fail: /* @__PURE__ */ __name((error) => {
586
- buf.failure = error;
587
- buf.ended = true;
588
- this.wake(buf);
589
- }, "fail")
590
- };
591
- }
592
- async *subscribe(runId) {
593
- const buf = this.buffer(runId);
594
- let index = 0;
595
- while (true) {
596
- while (index < buf.chunks.length) {
597
- const chunk = buf.chunks[index];
598
- index += 1;
599
- if (chunk !== void 0) {
600
- yield chunk;
601
- }
602
- }
603
- if (buf.ended) {
604
- if (buf.failure !== void 0) {
605
- throw new AgentStreamError(buf.failure);
606
- }
607
- return;
608
- }
609
- await new Promise((resolve) => buf.notify.add(resolve));
610
- }
611
- }
612
- close(runId) {
613
- this.runs.delete(runId);
614
- }
615
- };
616
-
617
- // src/durable/agent-durable.module.ts
648
+ import { AGENT_DURABLE_RUNNER } from "@dudousxd/nestjs-agent-core";
649
+ import { Global, Module } from "@nestjs/common";
618
650
  function _ts_decorate4(decorators, target, key, desc) {
619
651
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
620
652
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -622,27 +654,12 @@ function _ts_decorate4(decorators, target, key, desc) {
622
654
  return c > 3 && r && Object.defineProperty(target, key, r), r;
623
655
  }
624
656
  __name(_ts_decorate4, "_ts_decorate");
625
- var logger = new Logger2("AgentDurableModule");
626
657
  function runnerProviders() {
627
658
  return [
628
659
  DurableAgentRunner,
629
660
  {
630
661
  provide: AGENT_DURABLE_RUNNER,
631
662
  useExisting: DurableAgentRunner
632
- },
633
- {
634
- provide: AGENT_DISPATCHED_STEPS,
635
- useFactory: /* @__PURE__ */ __name((options, sink) => {
636
- const enabled = options.durable === true && options.dispatchedSteps !== false;
637
- if (enabled && sink instanceof InProcessTokenStreamSink) {
638
- logger.warn("Dispatched steps are active (the default under durable: true) with the default InProcessTokenStreamSink, which only buffers tokens in-process. A dispatched `llm` step served by a different worker cannot stream into this buffer. Wire a cross-process TokenStreamSink (e.g. a Redis pub/sub sink) via AgentModule.forRoot({ sink }) before running multi-pod, or set dispatchedSteps: false to keep the turn in-process localSteps.");
639
- }
640
- return enabled;
641
- }, "useFactory"),
642
- inject: [
643
- AGENT_OPTIONS,
644
- AGENT_SINK2
645
- ]
646
663
  }
647
664
  ];
648
665
  }
@@ -661,8 +678,7 @@ AgentDurableHttpModule = _ts_decorate4([
661
678
  ],
662
679
  exports: [
663
680
  AGENT_DURABLE_RUNNER,
664
- AgentRunWorkflow,
665
- AGENT_DISPATCHED_STEPS
681
+ AgentRunWorkflow
666
682
  ]
667
683
  })
668
684
  ], AgentDurableHttpModule);
@@ -702,20 +718,19 @@ AgentDurableModule = _ts_decorate4([
702
718
  exports: [
703
719
  AGENT_DURABLE_RUNNER,
704
720
  AgentRunWorkflow,
705
- AgentRunSteps,
706
- AGENT_DISPATCHED_STEPS
721
+ AgentRunSteps
707
722
  ]
708
723
  })
709
724
  ], AgentDurableModule);
710
725
 
711
726
  // src/agent.module.ts
712
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK4, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE6, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
727
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE6, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
713
728
  import { Global as Global2, Module as Module2 } from "@nestjs/common";
714
729
  import { DiscoveryModule, RouterModule } from "@nestjs/core";
715
730
 
716
731
  // src/agent-deps.factory.ts
717
- import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS, AGENT_STORE as AGENT_STORE3, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, normalizeDelegation, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
718
- import { AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
732
+ import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK2, AGENT_SKILLS, AGENT_STORE as AGENT_STORE3, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, normalizeDelegation, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
733
+ import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
719
734
  import { Inject as Inject4, Injectable as Injectable4, Optional as Optional2 } from "@nestjs/common";
720
735
  function _ts_decorate5(decorators, target, key, desc) {
721
736
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -934,10 +949,10 @@ var AgentDepsFactory2 = class {
934
949
  };
935
950
  AgentDepsFactory2 = _ts_decorate5([
936
951
  Injectable4(),
937
- _ts_param4(0, Inject4(AGENT_OPTIONS2)),
952
+ _ts_param4(0, Inject4(AGENT_OPTIONS)),
938
953
  _ts_param4(1, Inject4(AGENT_MODEL)),
939
954
  _ts_param4(2, Inject4(AGENT_STORE3)),
940
- _ts_param4(3, Inject4(AGENT_SINK3)),
955
+ _ts_param4(3, Inject4(AGENT_SINK2)),
941
956
  _ts_param4(4, Inject4(AGENT_ROLES_POLICY)),
942
957
  _ts_param4(5, Inject4(AGENT_TOOL_REGISTRY)),
943
958
  _ts_param4(6, Inject4(AGENT_REGISTRY)),
@@ -1534,7 +1549,7 @@ AgentsController = _ts_decorate8([
1534
1549
  ], AgentsController);
1535
1550
 
1536
1551
  // src/controller/attachments.controller.ts
1537
- import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
1552
+ import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
1538
1553
  import { BadRequestException as BadRequestException2, Controller as Controller2, Get as Get2, Inject as Inject7, NotImplementedException as NotImplementedException2, Optional as Optional4, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
1539
1554
  import { FileInterceptor } from "@nestjs/platform-express";
1540
1555
  function _ts_decorate9(decorators, target, key, desc) {
@@ -1658,7 +1673,7 @@ _ts_decorate9([
1658
1673
  ], AttachmentsController.prototype, "upload", null);
1659
1674
  AttachmentsController = _ts_decorate9([
1660
1675
  Controller2("attachments"),
1661
- _ts_param7(0, Inject7(AGENT_OPTIONS3)),
1676
+ _ts_param7(0, Inject7(AGENT_OPTIONS2)),
1662
1677
  _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER)),
1663
1678
  _ts_param7(3, Optional4()),
1664
1679
  _ts_param7(3, Inject7(AGENT_ATTACHMENT_STAGING2)),
@@ -2463,7 +2478,7 @@ ToolCallController = _ts_decorate15([
2463
2478
 
2464
2479
  // src/discovery/agent-discovery.service.ts
2465
2480
  import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
2466
- import { Inject as Inject14, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
2481
+ import { Inject as Inject14, Injectable as Injectable7, Logger as Logger2 } from "@nestjs/common";
2467
2482
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
2468
2483
 
2469
2484
  // src/decorator/agent.decorator.ts
@@ -2505,7 +2520,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
2505
2520
  scanner;
2506
2521
  registry;
2507
2522
  contributors;
2508
- logger = new Logger3(_AgentDiscoveryService.name);
2523
+ logger = new Logger2(_AgentDiscoveryService.name);
2509
2524
  constructor(discovery, scanner, registry, contributors) {
2510
2525
  this.discovery = discovery;
2511
2526
  this.scanner = scanner;
@@ -2637,8 +2652,8 @@ AgentDiscoveryService = _ts_decorate16([
2637
2652
  ], AgentDiscoveryService);
2638
2653
 
2639
2654
  // src/discovery/ai-tool-discovery.service.ts
2640
- import { AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
2641
- import { Inject as Inject15, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
2655
+ import { AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
2656
+ import { Inject as Inject15, Injectable as Injectable8, Logger as Logger3 } from "@nestjs/common";
2642
2657
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
2643
2658
  import { z } from "zod";
2644
2659
 
@@ -2683,7 +2698,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2683
2698
  registry;
2684
2699
  agents;
2685
2700
  options;
2686
- logger = new Logger4(_AiToolDiscoveryService.name);
2701
+ logger = new Logger3(_AiToolDiscoveryService.name);
2687
2702
  constructor(discovery, registry, agents, options) {
2688
2703
  this.discovery = discovery;
2689
2704
  this.registry = registry;
@@ -2805,7 +2820,7 @@ AiToolDiscoveryService = _ts_decorate17([
2805
2820
  Injectable8(),
2806
2821
  _ts_param15(1, Inject15(AGENT_TOOL_REGISTRY2)),
2807
2822
  _ts_param15(2, Inject15(AGENT_REGISTRY4)),
2808
- _ts_param15(3, Inject15(AGENT_OPTIONS4)),
2823
+ _ts_param15(3, Inject15(AGENT_OPTIONS3)),
2809
2824
  _ts_metadata16("design:type", Function),
2810
2825
  _ts_metadata16("design:paramtypes", [
2811
2826
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
@@ -2817,7 +2832,7 @@ AiToolDiscoveryService = _ts_decorate17([
2817
2832
 
2818
2833
  // src/discovery/skill-discovery.service.ts
2819
2834
  import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
2820
- import { Inject as Inject16, Injectable as Injectable9, Logger as Logger5 } from "@nestjs/common";
2835
+ import { Inject as Inject16, Injectable as Injectable9, Logger as Logger4 } from "@nestjs/common";
2821
2836
  import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
2822
2837
 
2823
2838
  // src/decorator/skill.decorator.ts
@@ -2857,7 +2872,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
2857
2872
  }
2858
2873
  discovery;
2859
2874
  declared;
2860
- logger = new Logger5(_SkillDiscoveryService.name);
2875
+ logger = new Logger4(_SkillDiscoveryService.name);
2861
2876
  constructor(discovery, declared) {
2862
2877
  this.discovery = discovery;
2863
2878
  this.declared = declared;
@@ -2929,7 +2944,7 @@ var LedgerQuotaStore = class {
2929
2944
 
2930
2945
  // src/runner/inline-agent-runner.ts
2931
2946
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_STORE as AGENT_STORE5, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent2, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation2 } from "@dudousxd/nestjs-agent-core";
2932
- import { Inject as Inject17, Injectable as Injectable10, Logger as Logger6 } from "@nestjs/common";
2947
+ import { Inject as Inject17, Injectable as Injectable10, Logger as Logger5 } from "@nestjs/common";
2933
2948
  function _ts_decorate19(decorators, target, key, desc) {
2934
2949
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2935
2950
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2953,7 +2968,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
2953
2968
  }
2954
2969
  factory;
2955
2970
  store;
2956
- logger = new Logger6(_InlineAgentRunner.name);
2971
+ logger = new Logger5(_InlineAgentRunner.name);
2957
2972
  pending = /* @__PURE__ */ new Map();
2958
2973
  /**
2959
2974
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -3384,7 +3399,7 @@ function sharedProviders(durable, includeStore) {
3384
3399
  provide: AGENT_SKILLS3,
3385
3400
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
3386
3401
  inject: [
3387
- AGENT_OPTIONS5,
3402
+ AGENT_OPTIONS4,
3388
3403
  AGENT_SKILL_SOURCES2
3389
3404
  ]
3390
3405
  },
@@ -3394,35 +3409,35 @@ function sharedProviders(durable, includeStore) {
3394
3409
  provide: AGENT_MEMORY3,
3395
3410
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
3396
3411
  inject: [
3397
- AGENT_OPTIONS5
3412
+ AGENT_OPTIONS4
3398
3413
  ]
3399
3414
  },
3400
3415
  {
3401
- provide: AGENT_SINK4,
3416
+ provide: AGENT_SINK3,
3402
3417
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
3403
3418
  inject: [
3404
- AGENT_OPTIONS5
3419
+ AGENT_OPTIONS4
3405
3420
  ]
3406
3421
  },
3407
3422
  {
3408
3423
  provide: AGENT_ROLES_POLICY2,
3409
3424
  useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
3410
3425
  inject: [
3411
- AGENT_OPTIONS5
3426
+ AGENT_OPTIONS4
3412
3427
  ]
3413
3428
  },
3414
3429
  {
3415
3430
  provide: AGENT_ACTOR_RESOLVER8,
3416
3431
  useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
3417
3432
  inject: [
3418
- AGENT_OPTIONS5
3433
+ AGENT_OPTIONS4
3419
3434
  ]
3420
3435
  },
3421
3436
  {
3422
3437
  provide: AGENT_MODEL2,
3423
3438
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
3424
3439
  inject: [
3425
- AGENT_OPTIONS5
3440
+ AGENT_OPTIONS4
3426
3441
  ]
3427
3442
  },
3428
3443
  {
@@ -3432,7 +3447,7 @@ function sharedProviders(durable, includeStore) {
3432
3447
  provide: AGENT_QUOTA_STORE3,
3433
3448
  useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
3434
3449
  inject: [
3435
- AGENT_OPTIONS5,
3450
+ AGENT_OPTIONS4,
3436
3451
  AGENT_STORE6
3437
3452
  ]
3438
3453
  },
@@ -3461,7 +3476,7 @@ function sharedProviders(durable, includeStore) {
3461
3476
  provide: AGENT_STORE6,
3462
3477
  useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
3463
3478
  inject: [
3464
- AGENT_OPTIONS5
3479
+ AGENT_OPTIONS4
3465
3480
  ]
3466
3481
  });
3467
3482
  }
@@ -3492,10 +3507,10 @@ function sharedProviders(durable, includeStore) {
3492
3507
  __name(sharedProviders, "sharedProviders");
3493
3508
  function exportsFor(includeStore) {
3494
3509
  return [
3495
- AGENT_OPTIONS5,
3510
+ AGENT_OPTIONS4,
3496
3511
  AGENT_TOOL_REGISTRY3,
3497
3512
  AGENT_REGISTRY5,
3498
- AGENT_SINK4,
3513
+ AGENT_SINK3,
3499
3514
  AGENT_ROLES_POLICY2,
3500
3515
  AGENT_ACTOR_RESOLVER8,
3501
3516
  AGENT_MODEL2,
@@ -3561,18 +3576,11 @@ function routerFor(path) {
3561
3576
  ]);
3562
3577
  }
3563
3578
  __name(routerFor, "routerFor");
3564
- function assertDispatchedStepsRequiresDurable(dispatchedSteps, durable) {
3565
- if (dispatchedSteps && !durable) {
3566
- throw new Error("AgentModule dispatchedSteps: true requires durable: true \u2014 dispatched steps are routed durable steps (AgentRunSteps.llm/tool) with no in-process equivalent.");
3567
- }
3568
- }
3569
- __name(assertDispatchedStepsRequiresDurable, "assertDispatchedStepsRequiresDurable");
3570
3579
  var AgentModule = class _AgentModule {
3571
3580
  static {
3572
3581
  __name(this, "AgentModule");
3573
3582
  }
3574
3583
  static forRoot(options) {
3575
- assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
3576
3584
  const path = options.path ?? DEFAULT_PATH;
3577
3585
  const includeStore = options.store !== void 0;
3578
3586
  applyGuards(options.guards);
@@ -3586,7 +3594,7 @@ var AgentModule = class _AgentModule {
3586
3594
  controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
3587
3595
  providers: [
3588
3596
  {
3589
- provide: AGENT_OPTIONS5,
3597
+ provide: AGENT_OPTIONS4,
3590
3598
  useValue: options
3591
3599
  },
3592
3600
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -3596,7 +3604,6 @@ var AgentModule = class _AgentModule {
3596
3604
  };
3597
3605
  }
3598
3606
  static forRootAsync(options) {
3599
- assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
3600
3607
  const path = options.path ?? DEFAULT_PATH;
3601
3608
  const includeStore = options.externalStore !== true;
3602
3609
  applyGuards(options.guards);
@@ -3611,21 +3618,17 @@ var AgentModule = class _AgentModule {
3611
3618
  controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
3612
3619
  providers: [
3613
3620
  {
3614
- provide: AGENT_OPTIONS5,
3615
- // Stamp the STATIC wiring flags onto the factory result: `durable`/`dispatchedSteps`/
3616
- // `surface` are authoritative on the async config object (they decided the actual wiring
3617
- // above), and `AgentDurableModule` derives the effective dispatched-steps value from
3618
- // AGENT_OPTIONS — without this stamp, an async host would get in-process localSteps
3619
- // despite durable: true. `surface` isn't read back by anything today (AgentDurableModule
3620
- // takes its own mirror option — see its doc for why), but it's stamped here too so the
3621
- // EFFECTIVE value is always observable off AGENT_OPTIONS, sync or async alike.
3621
+ provide: AGENT_OPTIONS4,
3622
+ // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
3623
+ // authoritative on the async config object (they decided the actual wiring above), and
3624
+ // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
3625
+ // anything today (AgentDurableModule takes its own mirror option — see its doc for why),
3626
+ // but it's stamped here too so the EFFECTIVE value is always observable off
3627
+ // AGENT_OPTIONS, sync or async alike.
3622
3628
  useFactory: /* @__PURE__ */ __name(async (...args) => ({
3623
3629
  ...await options.useFactory(...args),
3624
3630
  durable: options.durable ?? false,
3625
- surface: options.surface ?? "both",
3626
- ...options.dispatchedSteps !== void 0 ? {
3627
- dispatchedSteps: options.dispatchedSteps
3628
- } : {}
3631
+ surface: options.surface ?? "both"
3629
3632
  }), "useFactory"),
3630
3633
  inject: options.inject ?? []
3631
3634
  },
@@ -3655,7 +3658,6 @@ function agentDurable(options) {
3655
3658
  }
3656
3659
  __name(agentDurable, "agentDurable");
3657
3660
  export {
3658
- AGENT_DISPATCHED_STEPS,
3659
3661
  AgentDurableModule,
3660
3662
  AgentRunSteps,
3661
3663
  AgentRunWorkflow,