@dudousxd/nestjs-agent 0.5.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
  }
@@ -412,9 +415,9 @@ AgentDurableModule = _ts_decorate4([
412
415
  {
413
416
  provide: AGENT_DISPATCHED_STEPS,
414
417
  useFactory: /* @__PURE__ */ __name((options, sink) => {
415
- const enabled = options.dispatchedSteps ?? false;
418
+ const enabled = options.durable === true && options.dispatchedSteps !== false;
416
419
  if (enabled && sink instanceof InProcessTokenStreamSink) {
417
- logger.warn("dispatchedSteps is enabled 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.");
420
+ 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.");
418
421
  }
419
422
  return enabled;
420
423
  }, "useFactory"),
@@ -434,7 +437,7 @@ AgentDurableModule = _ts_decorate4([
434
437
  ], AgentDurableModule);
435
438
 
436
439
  // src/agent.module.ts
437
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, 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_SINK3, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
440
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, 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_SINK3, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
438
441
  import { Global as Global2, Module as Module2 } from "@nestjs/common";
439
442
  import { DiscoveryModule, RouterModule } from "@nestjs/core";
440
443
 
@@ -672,20 +675,32 @@ var AgentService = class {
672
675
  return this.deps.forAgent().sink.subscribe(runId);
673
676
  }
674
677
  async approve(actor, toolCallId) {
675
- const runId = await this.runForOwnedToolCall(actor, toolCallId);
676
- return this.runner.signal(runId, toolCallId, {
678
+ await this.assertOwnsToolCall(actor, toolCallId);
679
+ return this.signalToolCall(toolCallId, {
677
680
  approved: true
678
681
  });
679
682
  }
680
683
  async reject(actor, toolCallId, reason) {
681
- const runId = await this.runForOwnedToolCall(actor, toolCallId);
682
- return this.runner.signal(runId, toolCallId, {
684
+ await this.assertOwnsToolCall(actor, toolCallId);
685
+ return this.signalToolCall(toolCallId, {
683
686
  approved: false,
684
687
  ...reason !== void 0 ? {
685
688
  reason
686
689
  } : {}
687
690
  });
688
691
  }
692
+ /**
693
+ * The decision core behind approve/reject, WITHOUT an ownership check: resolves the run
694
+ * currently awaiting `toolCallId` and signals it. `approve`/`reject` above call this after their
695
+ * own `assertOwnsToolCall` gate; the console `AgentApprovalPort` adapter (bound by `AgentModule`)
696
+ * calls it directly — a console caller is already authorized by the dashboard's own guards, and
697
+ * re-deriving thread ownership here would reject a legitimate operator decision (an operator is
698
+ * not the thread's own actor).
699
+ */
700
+ async signalToolCall(toolCallId, decision) {
701
+ const runId = await this.resolveRunForToolCall(toolCallId);
702
+ return this.runner.signal(runId, toolCallId, decision);
703
+ }
689
704
  async cancel(actor, runId) {
690
705
  await this.assertOwnsActiveStream(actor, runId);
691
706
  return this.runner.cancel(runId);
@@ -833,12 +848,11 @@ var AgentService = class {
833
848
  }
834
849
  }
835
850
  /**
836
- * Authorization + routing seam for HITL approve/reject: assert the caller owns the tool call's
837
- * thread, then resolve the run currently awaiting that call (its thread's active stream). That run
838
- * is the sub-agent's own child run when the pending call belongs to a delegated agent — the client
839
- * never knows or supplies a runId; it is derived here from the tool call alone.
851
+ * Authorization seam for HITL approve/reject: the caller must own the tool call's thread. Split
852
+ * out from run resolution (see {@link resolveRunForToolCall}) so the console `AgentApprovalPort`
853
+ * adapter can resolve+signal a decision WITHOUT this check — it is authorized upstream instead.
840
854
  */
841
- async runForOwnedToolCall(actor, toolCallId) {
855
+ async assertOwnsToolCall(actor, toolCallId) {
842
856
  const owner = await this.store.ownerOfToolCall(toolCallId);
843
857
  if (owner === null) {
844
858
  throw new NotFoundException(`tool call ${toolCallId} not found`);
@@ -846,6 +860,13 @@ var AgentService = class {
846
860
  if (owner !== actor.id) {
847
861
  throw new ForbiddenException("tool call belongs to another actor");
848
862
  }
863
+ }
864
+ /**
865
+ * Resolve the run currently awaiting `toolCallId` (its thread's active stream). That run is the
866
+ * sub-agent's own child run when the pending call belongs to a delegated agent — the client never
867
+ * knows or supplies a runId; it is derived here from the tool call alone.
868
+ */
869
+ async resolveRunForToolCall(toolCallId) {
849
870
  const runId = await this.store.runForToolCall(toolCallId);
850
871
  if (runId === null) {
851
872
  throw new NotFoundException(`tool call ${toolCallId} has no active run to signal`);
@@ -878,9 +899,8 @@ AgentService = _ts_decorate6([
878
899
  ])
879
900
  ], AgentService);
880
901
 
881
- // src/controller/agents.controller.ts
882
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
883
- import { Controller, Get, Inject as Inject5 } from "@nestjs/common";
902
+ // src/approval-port.adapter.ts
903
+ import { Injectable as Injectable6 } from "@nestjs/common";
884
904
  function _ts_decorate7(decorators, target, key, desc) {
885
905
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
886
906
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -892,6 +912,56 @@ function _ts_metadata6(k, v) {
892
912
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
893
913
  }
894
914
  __name(_ts_metadata6, "_ts_metadata");
915
+ var AgentApprovalPortAdapter = class {
916
+ static {
917
+ __name(this, "AgentApprovalPortAdapter");
918
+ }
919
+ agent;
920
+ constructor(agent) {
921
+ this.agent = agent;
922
+ }
923
+ async approve(toolCallId, opts) {
924
+ await this.agent.signalToolCall(toolCallId, {
925
+ approved: true,
926
+ ...opts?.executedByRef !== void 0 ? {
927
+ executedByRef: opts.executedByRef
928
+ } : {}
929
+ });
930
+ }
931
+ async reject(toolCallId, opts) {
932
+ await this.agent.signalToolCall(toolCallId, {
933
+ approved: false,
934
+ ...opts?.executedByRef !== void 0 ? {
935
+ executedByRef: opts.executedByRef
936
+ } : {},
937
+ ...opts?.reason !== void 0 ? {
938
+ reason: opts.reason
939
+ } : {}
940
+ });
941
+ }
942
+ };
943
+ AgentApprovalPortAdapter = _ts_decorate7([
944
+ Injectable6(),
945
+ _ts_metadata6("design:type", Function),
946
+ _ts_metadata6("design:paramtypes", [
947
+ typeof AgentService === "undefined" ? Object : AgentService
948
+ ])
949
+ ], AgentApprovalPortAdapter);
950
+
951
+ // src/controller/agents.controller.ts
952
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
953
+ import { Controller, Get, Inject as Inject5 } from "@nestjs/common";
954
+ function _ts_decorate8(decorators, target, key, desc) {
955
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
956
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
957
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
958
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
959
+ }
960
+ __name(_ts_decorate8, "_ts_decorate");
961
+ function _ts_metadata7(k, v) {
962
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
963
+ }
964
+ __name(_ts_metadata7, "_ts_metadata");
895
965
  function _ts_param5(paramIndex, decorator) {
896
966
  return function(target, key) {
897
967
  decorator(target, key, paramIndex);
@@ -919,18 +989,18 @@ var AgentsController = class {
919
989
  }));
920
990
  }
921
991
  };
922
- _ts_decorate7([
992
+ _ts_decorate8([
923
993
  Get(),
924
- _ts_metadata6("design:type", Function),
925
- _ts_metadata6("design:paramtypes", []),
926
- _ts_metadata6("design:returntype", Array)
994
+ _ts_metadata7("design:type", Function),
995
+ _ts_metadata7("design:paramtypes", []),
996
+ _ts_metadata7("design:returntype", Array)
927
997
  ], AgentsController.prototype, "list", null);
928
- AgentsController = _ts_decorate7([
998
+ AgentsController = _ts_decorate8([
929
999
  Controller("agents"),
930
1000
  _ts_param5(0, Inject5(AGENT_REGISTRY2)),
931
1001
  _ts_param5(1, Inject5(AGENT_DEPS_FACTORY4)),
932
- _ts_metadata6("design:type", Function),
933
- _ts_metadata6("design:paramtypes", [
1002
+ _ts_metadata7("design:type", Function),
1003
+ _ts_metadata7("design:paramtypes", [
934
1004
  typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
935
1005
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
936
1006
  ])
@@ -940,17 +1010,17 @@ AgentsController = _ts_decorate7([
940
1010
  import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
941
1011
  import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as Inject6, NotImplementedException as NotImplementedException2, Optional as Optional2, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
942
1012
  import { FileInterceptor } from "@nestjs/platform-express";
943
- function _ts_decorate8(decorators, target, key, desc) {
1013
+ function _ts_decorate9(decorators, target, key, desc) {
944
1014
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
945
1015
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
946
1016
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
947
1017
  return c > 3 && r && Object.defineProperty(target, key, r), r;
948
1018
  }
949
- __name(_ts_decorate8, "_ts_decorate");
950
- function _ts_metadata7(k, v) {
1019
+ __name(_ts_decorate9, "_ts_decorate");
1020
+ function _ts_metadata8(k, v) {
951
1021
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
952
1022
  }
953
- __name(_ts_metadata7, "_ts_metadata");
1023
+ __name(_ts_metadata8, "_ts_metadata");
954
1024
  function _ts_param6(paramIndex, decorator) {
955
1025
  return function(target, key) {
956
1026
  decorator(target, key, paramIndex);
@@ -1015,26 +1085,26 @@ var AttachmentsController = class {
1015
1085
  });
1016
1086
  }
1017
1087
  };
1018
- _ts_decorate8([
1088
+ _ts_decorate9([
1019
1089
  Post(),
1020
1090
  UseInterceptors(FileInterceptor("file")),
1021
1091
  _ts_param6(0, Req()),
1022
1092
  _ts_param6(1, UploadedFile()),
1023
- _ts_metadata7("design:type", Function),
1024
- _ts_metadata7("design:paramtypes", [
1093
+ _ts_metadata8("design:type", Function),
1094
+ _ts_metadata8("design:paramtypes", [
1025
1095
  typeof Request === "undefined" ? Object : Request,
1026
1096
  Object
1027
1097
  ]),
1028
- _ts_metadata7("design:returntype", Promise)
1098
+ _ts_metadata8("design:returntype", Promise)
1029
1099
  ], AttachmentsController.prototype, "upload", null);
1030
- AttachmentsController = _ts_decorate8([
1100
+ AttachmentsController = _ts_decorate9([
1031
1101
  Controller2("attachments"),
1032
1102
  _ts_param6(0, Inject6(AGENT_OPTIONS3)),
1033
1103
  _ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER)),
1034
1104
  _ts_param6(2, Optional2()),
1035
1105
  _ts_param6(2, Inject6(AGENT_ATTACHMENT_STAGING)),
1036
- _ts_metadata7("design:type", Function),
1037
- _ts_metadata7("design:paramtypes", [
1106
+ _ts_metadata8("design:type", Function),
1107
+ _ts_metadata8("design:paramtypes", [
1038
1108
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
1039
1109
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
1040
1110
  Object
@@ -1044,17 +1114,17 @@ AttachmentsController = _ts_decorate8([
1044
1114
  // src/controller/chat.controller.ts
1045
1115
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2 } from "@dudousxd/nestjs-agent-core";
1046
1116
  import { Body, Controller as Controller3, Get as Get2, Inject as Inject7, Param, Post as Post2, Req as Req2, Res } from "@nestjs/common";
1047
- function _ts_decorate9(decorators, target, key, desc) {
1117
+ function _ts_decorate10(decorators, target, key, desc) {
1048
1118
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1049
1119
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1050
1120
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1051
1121
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1052
1122
  }
1053
- __name(_ts_decorate9, "_ts_decorate");
1054
- function _ts_metadata8(k, v) {
1123
+ __name(_ts_decorate10, "_ts_decorate");
1124
+ function _ts_metadata9(k, v) {
1055
1125
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1056
1126
  }
1057
- __name(_ts_metadata8, "_ts_metadata");
1127
+ __name(_ts_metadata9, "_ts_metadata");
1058
1128
  function _ts_param7(paramIndex, decorator) {
1059
1129
  return function(target, key) {
1060
1130
  decorator(target, key, paramIndex);
@@ -1163,46 +1233,46 @@ data: ${JSON.stringify(payload)}
1163
1233
  res.end();
1164
1234
  }
1165
1235
  };
1166
- _ts_decorate9([
1236
+ _ts_decorate10([
1167
1237
  Post2("chat"),
1168
1238
  _ts_param7(0, Req2()),
1169
1239
  _ts_param7(1, Res()),
1170
1240
  _ts_param7(2, Body()),
1171
- _ts_metadata8("design:type", Function),
1172
- _ts_metadata8("design:paramtypes", [
1241
+ _ts_metadata9("design:type", Function),
1242
+ _ts_metadata9("design:paramtypes", [
1173
1243
  typeof Request === "undefined" ? Object : Request,
1174
1244
  typeof Response === "undefined" ? Object : Response,
1175
1245
  typeof ChatBody === "undefined" ? Object : ChatBody
1176
1246
  ]),
1177
- _ts_metadata8("design:returntype", Promise)
1247
+ _ts_metadata9("design:returntype", Promise)
1178
1248
  ], ChatController.prototype, "chat", null);
1179
- _ts_decorate9([
1249
+ _ts_decorate10([
1180
1250
  Get2("chat/:runId/stream"),
1181
1251
  _ts_param7(0, Param("runId")),
1182
1252
  _ts_param7(1, Res()),
1183
- _ts_metadata8("design:type", Function),
1184
- _ts_metadata8("design:paramtypes", [
1253
+ _ts_metadata9("design:type", Function),
1254
+ _ts_metadata9("design:paramtypes", [
1185
1255
  String,
1186
1256
  typeof Response === "undefined" ? Object : Response
1187
1257
  ]),
1188
- _ts_metadata8("design:returntype", Promise)
1258
+ _ts_metadata9("design:returntype", Promise)
1189
1259
  ], ChatController.prototype, "stream", null);
1190
- _ts_decorate9([
1260
+ _ts_decorate10([
1191
1261
  Post2("chat/:runId/cancel"),
1192
1262
  _ts_param7(0, Req2()),
1193
1263
  _ts_param7(1, Param("runId")),
1194
- _ts_metadata8("design:type", Function),
1195
- _ts_metadata8("design:paramtypes", [
1264
+ _ts_metadata9("design:type", Function),
1265
+ _ts_metadata9("design:paramtypes", [
1196
1266
  typeof Request === "undefined" ? Object : Request,
1197
1267
  String
1198
1268
  ]),
1199
- _ts_metadata8("design:returntype", Promise)
1269
+ _ts_metadata9("design:returntype", Promise)
1200
1270
  ], ChatController.prototype, "cancel", null);
1201
- ChatController = _ts_decorate9([
1271
+ ChatController = _ts_decorate10([
1202
1272
  Controller3(),
1203
1273
  _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER2)),
1204
- _ts_metadata8("design:type", Function),
1205
- _ts_metadata8("design:paramtypes", [
1274
+ _ts_metadata9("design:type", Function),
1275
+ _ts_metadata9("design:paramtypes", [
1206
1276
  typeof AgentService === "undefined" ? Object : AgentService,
1207
1277
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1208
1278
  ])
@@ -1211,17 +1281,17 @@ ChatController = _ts_decorate9([
1211
1281
  // src/controller/quota.controller.ts
1212
1282
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3 } from "@dudousxd/nestjs-agent-core";
1213
1283
  import { Controller as Controller4, Get as Get3, Inject as Inject8, Req as Req3 } from "@nestjs/common";
1214
- function _ts_decorate10(decorators, target, key, desc) {
1284
+ function _ts_decorate11(decorators, target, key, desc) {
1215
1285
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1216
1286
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1217
1287
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1218
1288
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1219
1289
  }
1220
- __name(_ts_decorate10, "_ts_decorate");
1221
- function _ts_metadata9(k, v) {
1290
+ __name(_ts_decorate11, "_ts_decorate");
1291
+ function _ts_metadata10(k, v) {
1222
1292
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1223
1293
  }
1224
- __name(_ts_metadata9, "_ts_metadata");
1294
+ __name(_ts_metadata10, "_ts_metadata");
1225
1295
  function _ts_param8(paramIndex, decorator) {
1226
1296
  return function(target, key) {
1227
1297
  decorator(target, key, paramIndex);
@@ -1243,20 +1313,20 @@ var QuotaController = class {
1243
1313
  return this.agent.quotaToday(actor.id);
1244
1314
  }
1245
1315
  };
1246
- _ts_decorate10([
1316
+ _ts_decorate11([
1247
1317
  Get3("today"),
1248
1318
  _ts_param8(0, Req3()),
1249
- _ts_metadata9("design:type", Function),
1250
- _ts_metadata9("design:paramtypes", [
1319
+ _ts_metadata10("design:type", Function),
1320
+ _ts_metadata10("design:paramtypes", [
1251
1321
  typeof Request === "undefined" ? Object : Request
1252
1322
  ]),
1253
- _ts_metadata9("design:returntype", Promise)
1323
+ _ts_metadata10("design:returntype", Promise)
1254
1324
  ], QuotaController.prototype, "today", null);
1255
- QuotaController = _ts_decorate10([
1325
+ QuotaController = _ts_decorate11([
1256
1326
  Controller4("quota"),
1257
1327
  _ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER3)),
1258
- _ts_metadata9("design:type", Function),
1259
- _ts_metadata9("design:paramtypes", [
1328
+ _ts_metadata10("design:type", Function),
1329
+ _ts_metadata10("design:paramtypes", [
1260
1330
  typeof AgentService === "undefined" ? Object : AgentService,
1261
1331
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1262
1332
  ])
@@ -1265,17 +1335,17 @@ QuotaController = _ts_decorate10([
1265
1335
  // src/controller/threads.controller.ts
1266
1336
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4 } from "@dudousxd/nestjs-agent-core";
1267
1337
  import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as Inject9, Param as Param2, Patch, Post as Post3, Req as Req4 } from "@nestjs/common";
1268
- function _ts_decorate11(decorators, target, key, desc) {
1338
+ function _ts_decorate12(decorators, target, key, desc) {
1269
1339
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1270
1340
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1271
1341
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1272
1342
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1273
1343
  }
1274
- __name(_ts_decorate11, "_ts_decorate");
1275
- function _ts_metadata10(k, v) {
1344
+ __name(_ts_decorate12, "_ts_decorate");
1345
+ function _ts_metadata11(k, v) {
1276
1346
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1277
1347
  }
1278
- __name(_ts_metadata10, "_ts_metadata");
1348
+ __name(_ts_metadata11, "_ts_metadata");
1279
1349
  function _ts_param9(paramIndex, decorator) {
1280
1350
  return function(target, key) {
1281
1351
  decorator(target, key, paramIndex);
@@ -1345,92 +1415,92 @@ var ThreadsController = class {
1345
1415
  };
1346
1416
  }
1347
1417
  };
1348
- _ts_decorate11([
1418
+ _ts_decorate12([
1349
1419
  Get4(),
1350
1420
  _ts_param9(0, Req4()),
1351
- _ts_metadata10("design:type", Function),
1352
- _ts_metadata10("design:paramtypes", [
1421
+ _ts_metadata11("design:type", Function),
1422
+ _ts_metadata11("design:paramtypes", [
1353
1423
  typeof Request === "undefined" ? Object : Request
1354
1424
  ]),
1355
- _ts_metadata10("design:returntype", Promise)
1425
+ _ts_metadata11("design:returntype", Promise)
1356
1426
  ], ThreadsController.prototype, "list", null);
1357
- _ts_decorate11([
1427
+ _ts_decorate12([
1358
1428
  Get4(":id"),
1359
1429
  _ts_param9(0, Req4()),
1360
1430
  _ts_param9(1, Param2("id")),
1361
- _ts_metadata10("design:type", Function),
1362
- _ts_metadata10("design:paramtypes", [
1431
+ _ts_metadata11("design:type", Function),
1432
+ _ts_metadata11("design:paramtypes", [
1363
1433
  typeof Request === "undefined" ? Object : Request,
1364
1434
  String
1365
1435
  ]),
1366
- _ts_metadata10("design:returntype", Promise)
1436
+ _ts_metadata11("design:returntype", Promise)
1367
1437
  ], ThreadsController.prototype, "detail", null);
1368
- _ts_decorate11([
1438
+ _ts_decorate12([
1369
1439
  Delete(":id"),
1370
1440
  _ts_param9(0, Req4()),
1371
1441
  _ts_param9(1, Param2("id")),
1372
- _ts_metadata10("design:type", Function),
1373
- _ts_metadata10("design:paramtypes", [
1442
+ _ts_metadata11("design:type", Function),
1443
+ _ts_metadata11("design:paramtypes", [
1374
1444
  typeof Request === "undefined" ? Object : Request,
1375
1445
  String
1376
1446
  ]),
1377
- _ts_metadata10("design:returntype", Promise)
1447
+ _ts_metadata11("design:returntype", Promise)
1378
1448
  ], ThreadsController.prototype, "remove", null);
1379
- _ts_decorate11([
1449
+ _ts_decorate12([
1380
1450
  Post3(":id/fork-from/:messageId"),
1381
1451
  _ts_param9(0, Req4()),
1382
1452
  _ts_param9(1, Param2("id")),
1383
1453
  _ts_param9(2, Param2("messageId")),
1384
- _ts_metadata10("design:type", Function),
1385
- _ts_metadata10("design:paramtypes", [
1454
+ _ts_metadata11("design:type", Function),
1455
+ _ts_metadata11("design:paramtypes", [
1386
1456
  typeof Request === "undefined" ? Object : Request,
1387
1457
  String,
1388
1458
  String
1389
1459
  ]),
1390
- _ts_metadata10("design:returntype", Promise)
1460
+ _ts_metadata11("design:returntype", Promise)
1391
1461
  ], ThreadsController.prototype, "fork", null);
1392
- _ts_decorate11([
1462
+ _ts_decorate12([
1393
1463
  Patch(":id"),
1394
1464
  _ts_param9(0, Req4()),
1395
1465
  _ts_param9(1, Param2("id")),
1396
1466
  _ts_param9(2, Body2()),
1397
- _ts_metadata10("design:type", Function),
1398
- _ts_metadata10("design:paramtypes", [
1467
+ _ts_metadata11("design:type", Function),
1468
+ _ts_metadata11("design:paramtypes", [
1399
1469
  typeof Request === "undefined" ? Object : Request,
1400
1470
  String,
1401
1471
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
1402
1472
  ]),
1403
- _ts_metadata10("design:returntype", Promise)
1473
+ _ts_metadata11("design:returntype", Promise)
1404
1474
  ], ThreadsController.prototype, "update", null);
1405
- _ts_decorate11([
1475
+ _ts_decorate12([
1406
1476
  Post3(":id/promote"),
1407
1477
  _ts_param9(0, Req4()),
1408
1478
  _ts_param9(1, Param2("id")),
1409
- _ts_metadata10("design:type", Function),
1410
- _ts_metadata10("design:paramtypes", [
1479
+ _ts_metadata11("design:type", Function),
1480
+ _ts_metadata11("design:paramtypes", [
1411
1481
  typeof Request === "undefined" ? Object : Request,
1412
1482
  String
1413
1483
  ]),
1414
- _ts_metadata10("design:returntype", Promise)
1484
+ _ts_metadata11("design:returntype", Promise)
1415
1485
  ], ThreadsController.prototype, "promote", null);
1416
- _ts_decorate11([
1486
+ _ts_decorate12([
1417
1487
  Delete(":id/from/:messageId"),
1418
1488
  _ts_param9(0, Req4()),
1419
1489
  _ts_param9(1, Param2("id")),
1420
1490
  _ts_param9(2, Param2("messageId")),
1421
- _ts_metadata10("design:type", Function),
1422
- _ts_metadata10("design:paramtypes", [
1491
+ _ts_metadata11("design:type", Function),
1492
+ _ts_metadata11("design:paramtypes", [
1423
1493
  typeof Request === "undefined" ? Object : Request,
1424
1494
  String,
1425
1495
  String
1426
1496
  ]),
1427
- _ts_metadata10("design:returntype", Promise)
1497
+ _ts_metadata11("design:returntype", Promise)
1428
1498
  ], ThreadsController.prototype, "truncateFrom", null);
1429
- ThreadsController = _ts_decorate11([
1499
+ ThreadsController = _ts_decorate12([
1430
1500
  Controller5("threads"),
1431
1501
  _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER4)),
1432
- _ts_metadata10("design:type", Function),
1433
- _ts_metadata10("design:paramtypes", [
1502
+ _ts_metadata11("design:type", Function),
1503
+ _ts_metadata11("design:paramtypes", [
1434
1504
  typeof AgentService === "undefined" ? Object : AgentService,
1435
1505
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1436
1506
  ])
@@ -1439,17 +1509,17 @@ ThreadsController = _ts_decorate11([
1439
1509
  // src/controller/tool-call.controller.ts
1440
1510
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
1441
1511
  import { Body as Body3, Controller as Controller6, Inject as Inject10, Post as Post4, Req as Req5 } from "@nestjs/common";
1442
- function _ts_decorate12(decorators, target, key, desc) {
1512
+ function _ts_decorate13(decorators, target, key, desc) {
1443
1513
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1444
1514
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1445
1515
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1446
1516
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1447
1517
  }
1448
- __name(_ts_decorate12, "_ts_decorate");
1449
- function _ts_metadata11(k, v) {
1518
+ __name(_ts_decorate13, "_ts_decorate");
1519
+ function _ts_metadata12(k, v) {
1450
1520
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1451
1521
  }
1452
- __name(_ts_metadata11, "_ts_metadata");
1522
+ __name(_ts_metadata12, "_ts_metadata");
1453
1523
  function _ts_param10(paramIndex, decorator) {
1454
1524
  return function(target, key) {
1455
1525
  decorator(target, key, paramIndex);
@@ -1481,33 +1551,33 @@ var ToolCallController = class {
1481
1551
  };
1482
1552
  }
1483
1553
  };
1484
- _ts_decorate12([
1554
+ _ts_decorate13([
1485
1555
  Post4("approve"),
1486
1556
  _ts_param10(0, Req5()),
1487
1557
  _ts_param10(1, Body3()),
1488
- _ts_metadata11("design:type", Function),
1489
- _ts_metadata11("design:paramtypes", [
1558
+ _ts_metadata12("design:type", Function),
1559
+ _ts_metadata12("design:paramtypes", [
1490
1560
  typeof Request === "undefined" ? Object : Request,
1491
1561
  typeof ApproveBody === "undefined" ? Object : ApproveBody
1492
1562
  ]),
1493
- _ts_metadata11("design:returntype", Promise)
1563
+ _ts_metadata12("design:returntype", Promise)
1494
1564
  ], ToolCallController.prototype, "approve", null);
1495
- _ts_decorate12([
1565
+ _ts_decorate13([
1496
1566
  Post4("reject"),
1497
1567
  _ts_param10(0, Req5()),
1498
1568
  _ts_param10(1, Body3()),
1499
- _ts_metadata11("design:type", Function),
1500
- _ts_metadata11("design:paramtypes", [
1569
+ _ts_metadata12("design:type", Function),
1570
+ _ts_metadata12("design:paramtypes", [
1501
1571
  typeof Request === "undefined" ? Object : Request,
1502
1572
  typeof RejectBody === "undefined" ? Object : RejectBody
1503
1573
  ]),
1504
- _ts_metadata11("design:returntype", Promise)
1574
+ _ts_metadata12("design:returntype", Promise)
1505
1575
  ], ToolCallController.prototype, "reject", null);
1506
- ToolCallController = _ts_decorate12([
1576
+ ToolCallController = _ts_decorate13([
1507
1577
  Controller6("tool-call"),
1508
1578
  _ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER5)),
1509
- _ts_metadata11("design:type", Function),
1510
- _ts_metadata11("design:paramtypes", [
1579
+ _ts_metadata12("design:type", Function),
1580
+ _ts_metadata12("design:paramtypes", [
1511
1581
  typeof AgentService === "undefined" ? Object : AgentService,
1512
1582
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1513
1583
  ])
@@ -1515,7 +1585,7 @@ ToolCallController = _ts_decorate12([
1515
1585
 
1516
1586
  // src/discovery/agent-discovery.service.ts
1517
1587
  import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
1518
- import { Inject as Inject11, Injectable as Injectable6, Logger as Logger2 } from "@nestjs/common";
1588
+ import { Inject as Inject11, Injectable as Injectable7, Logger as Logger2 } from "@nestjs/common";
1519
1589
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
1520
1590
 
1521
1591
  // src/decorator/agent.decorator.ts
@@ -1532,17 +1602,17 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
1532
1602
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
1533
1603
 
1534
1604
  // src/discovery/agent-discovery.service.ts
1535
- function _ts_decorate13(decorators, target, key, desc) {
1605
+ function _ts_decorate14(decorators, target, key, desc) {
1536
1606
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1537
1607
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1538
1608
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1539
1609
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1540
1610
  }
1541
- __name(_ts_decorate13, "_ts_decorate");
1542
- function _ts_metadata12(k, v) {
1611
+ __name(_ts_decorate14, "_ts_decorate");
1612
+ function _ts_metadata13(k, v) {
1543
1613
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1544
1614
  }
1545
- __name(_ts_metadata12, "_ts_metadata");
1615
+ __name(_ts_metadata13, "_ts_metadata");
1546
1616
  function _ts_param11(paramIndex, decorator) {
1547
1617
  return function(target, key) {
1548
1618
  decorator(target, key, paramIndex);
@@ -1645,12 +1715,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
1645
1715
  return (ctx) => candidate.call(instance, ctx);
1646
1716
  }
1647
1717
  };
1648
- AgentDiscoveryService = _ts_decorate13([
1649
- Injectable6(),
1718
+ AgentDiscoveryService = _ts_decorate14([
1719
+ Injectable7(),
1650
1720
  _ts_param11(2, Inject11(AGENT_REGISTRY3)),
1651
1721
  _ts_param11(3, Inject11(AGENT_PROMPT_CONTRIBUTORS2)),
1652
- _ts_metadata12("design:type", Function),
1653
- _ts_metadata12("design:paramtypes", [
1722
+ _ts_metadata13("design:type", Function),
1723
+ _ts_metadata13("design:paramtypes", [
1654
1724
  typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
1655
1725
  typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
1656
1726
  typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4,
@@ -1660,7 +1730,7 @@ AgentDiscoveryService = _ts_decorate13([
1660
1730
 
1661
1731
  // src/discovery/ai-tool-discovery.service.ts
1662
1732
  import { AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
1663
- import { Inject as Inject12, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
1733
+ import { Inject as Inject12, Injectable as Injectable8, Logger as Logger3 } from "@nestjs/common";
1664
1734
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
1665
1735
  import { z } from "zod";
1666
1736
 
@@ -1680,17 +1750,17 @@ function isBrandedFunctionalTool(value) {
1680
1750
  __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
1681
1751
 
1682
1752
  // src/discovery/ai-tool-discovery.service.ts
1683
- function _ts_decorate14(decorators, target, key, desc) {
1753
+ function _ts_decorate15(decorators, target, key, desc) {
1684
1754
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1685
1755
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1686
1756
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1687
1757
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1688
1758
  }
1689
- __name(_ts_decorate14, "_ts_decorate");
1690
- function _ts_metadata13(k, v) {
1759
+ __name(_ts_decorate15, "_ts_decorate");
1760
+ function _ts_metadata14(k, v) {
1691
1761
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1692
1762
  }
1693
- __name(_ts_metadata13, "_ts_metadata");
1763
+ __name(_ts_metadata14, "_ts_metadata");
1694
1764
  function _ts_param12(paramIndex, decorator) {
1695
1765
  return function(target, key) {
1696
1766
  decorator(target, key, paramIndex);
@@ -1803,13 +1873,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
1803
1873
  return true;
1804
1874
  }
1805
1875
  };
1806
- AiToolDiscoveryService = _ts_decorate14([
1807
- Injectable7(),
1876
+ AiToolDiscoveryService = _ts_decorate15([
1877
+ Injectable8(),
1808
1878
  _ts_param12(1, Inject12(AGENT_TOOL_REGISTRY2)),
1809
1879
  _ts_param12(2, Inject12(AGENT_REGISTRY4)),
1810
1880
  _ts_param12(3, Inject12(AGENT_OPTIONS4)),
1811
- _ts_metadata13("design:type", Function),
1812
- _ts_metadata13("design:paramtypes", [
1881
+ _ts_metadata14("design:type", Function),
1882
+ _ts_metadata14("design:paramtypes", [
1813
1883
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
1814
1884
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
1815
1885
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -1842,18 +1912,18 @@ var LedgerQuotaStore = class {
1842
1912
 
1843
1913
  // src/runner/inline-agent-runner.ts
1844
1914
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_STORE as AGENT_STORE4, QuotaExceededError as QuotaExceededError2, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2 } from "@dudousxd/nestjs-agent-core";
1845
- import { Inject as Inject13, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
1846
- function _ts_decorate15(decorators, target, key, desc) {
1915
+ import { Inject as Inject13, Injectable as Injectable9, Logger as Logger4 } from "@nestjs/common";
1916
+ function _ts_decorate16(decorators, target, key, desc) {
1847
1917
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1848
1918
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1849
1919
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1850
1920
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1851
1921
  }
1852
- __name(_ts_decorate15, "_ts_decorate");
1853
- function _ts_metadata14(k, v) {
1922
+ __name(_ts_decorate16, "_ts_decorate");
1923
+ function _ts_metadata15(k, v) {
1854
1924
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1855
1925
  }
1856
- __name(_ts_metadata14, "_ts_metadata");
1926
+ __name(_ts_metadata15, "_ts_metadata");
1857
1927
  function _ts_param13(paramIndex, decorator) {
1858
1928
  return function(target, key) {
1859
1929
  decorator(target, key, paramIndex);
@@ -1971,25 +2041,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
1971
2041
  }
1972
2042
  }
1973
2043
  };
1974
- InlineAgentRunner = _ts_decorate15([
1975
- Injectable8(),
2044
+ InlineAgentRunner = _ts_decorate16([
2045
+ Injectable9(),
1976
2046
  _ts_param13(0, Inject13(AGENT_DEPS_FACTORY5)),
1977
2047
  _ts_param13(1, Inject13(AGENT_STORE4)),
1978
- _ts_metadata14("design:type", Function),
1979
- _ts_metadata14("design:paramtypes", [
2048
+ _ts_metadata15("design:type", Function),
2049
+ _ts_metadata15("design:paramtypes", [
1980
2050
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
1981
2051
  typeof AgentStore === "undefined" ? Object : AgentStore
1982
2052
  ])
1983
2053
  ], InlineAgentRunner);
1984
2054
 
1985
2055
  // src/agent.module.ts
1986
- function _ts_decorate16(decorators, target, key, desc) {
2056
+ function _ts_decorate17(decorators, target, key, desc) {
1987
2057
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1988
2058
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1989
2059
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1990
2060
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1991
2061
  }
1992
- __name(_ts_decorate16, "_ts_decorate");
2062
+ __name(_ts_decorate17, "_ts_decorate");
1993
2063
  var DEFAULT_PATH = "agent";
1994
2064
  function sharedProviders(durable, includeStore) {
1995
2065
  const providers = [
@@ -2056,7 +2126,14 @@ function sharedProviders(durable, includeStore) {
2056
2126
  AgentDiscoveryService,
2057
2127
  AiToolDiscoveryService,
2058
2128
  InlineAgentRunner,
2059
- AgentService
2129
+ AgentService,
2130
+ // Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
2131
+ // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
2132
+ AgentApprovalPortAdapter,
2133
+ {
2134
+ provide: AGENT_APPROVAL_PORT,
2135
+ useExisting: AgentApprovalPortAdapter
2136
+ }
2060
2137
  ];
2061
2138
  if (includeStore) {
2062
2139
  providers.push({
@@ -2109,7 +2186,8 @@ function exportsFor(includeStore) {
2109
2186
  AGENT_DEPS_FACTORY6,
2110
2187
  AgentDepsFactory2,
2111
2188
  AgentService,
2112
- InlineAgentRunner
2189
+ InlineAgentRunner,
2190
+ AGENT_APPROVAL_PORT
2113
2191
  ];
2114
2192
  }
2115
2193
  __name(exportsFor, "exportsFor");
@@ -2205,7 +2283,17 @@ var AgentModule = class _AgentModule {
2205
2283
  providers: [
2206
2284
  {
2207
2285
  provide: AGENT_OPTIONS5,
2208
- useFactory: options.useFactory,
2286
+ // Stamp the STATIC wiring flags onto the factory result: `durable`/`dispatchedSteps` are
2287
+ // authoritative on the async config object (they decided the actual wiring above), and
2288
+ // `AgentDurableModule` derives the effective dispatched-steps value from AGENT_OPTIONS —
2289
+ // without this stamp, an async host would get in-process localSteps despite durable: true.
2290
+ useFactory: /* @__PURE__ */ __name(async (...args) => ({
2291
+ ...await options.useFactory(...args),
2292
+ durable: options.durable ?? false,
2293
+ ...options.dispatchedSteps !== void 0 ? {
2294
+ dispatchedSteps: options.dispatchedSteps
2295
+ } : {}
2296
+ }), "useFactory"),
2209
2297
  inject: options.inject ?? []
2210
2298
  },
2211
2299
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -2215,7 +2303,7 @@ var AgentModule = class _AgentModule {
2215
2303
  };
2216
2304
  }
2217
2305
  };
2218
- AgentModule = _ts_decorate16([
2306
+ AgentModule = _ts_decorate17([
2219
2307
  Global2(),
2220
2308
  Module2({})
2221
2309
  ], AgentModule);