@dudousxd/nestjs-agent 0.5.0 → 0.6.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.
@@ -441,9 +441,9 @@ AgentDurableModule = _ts_decorate4([
441
441
  {
442
442
  provide: AGENT_DISPATCHED_STEPS,
443
443
  useFactory: /* @__PURE__ */ __name((options, sink) => {
444
- const enabled = options.dispatchedSteps ?? false;
444
+ const enabled = options.durable === true && options.dispatchedSteps !== false;
445
445
  if (enabled && sink instanceof InProcessTokenStreamSink) {
446
- 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.");
446
+ 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.");
447
447
  }
448
448
  return enabled;
449
449
  }, "useFactory"),
@@ -464,7 +464,7 @@ AgentDurableModule = _ts_decorate4([
464
464
 
465
465
  // src/agent.module.ts
466
466
  var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
467
- var import_common16 = require("@nestjs/common");
467
+ var import_common17 = require("@nestjs/common");
468
468
  var import_core3 = require("@nestjs/core");
469
469
 
470
470
  // src/agent-deps.factory.ts
@@ -701,20 +701,32 @@ var AgentService = class {
701
701
  return this.deps.forAgent().sink.subscribe(runId);
702
702
  }
703
703
  async approve(actor, toolCallId) {
704
- const runId = await this.runForOwnedToolCall(actor, toolCallId);
705
- return this.runner.signal(runId, toolCallId, {
704
+ await this.assertOwnsToolCall(actor, toolCallId);
705
+ return this.signalToolCall(toolCallId, {
706
706
  approved: true
707
707
  });
708
708
  }
709
709
  async reject(actor, toolCallId, reason) {
710
- const runId = await this.runForOwnedToolCall(actor, toolCallId);
711
- return this.runner.signal(runId, toolCallId, {
710
+ await this.assertOwnsToolCall(actor, toolCallId);
711
+ return this.signalToolCall(toolCallId, {
712
712
  approved: false,
713
713
  ...reason !== void 0 ? {
714
714
  reason
715
715
  } : {}
716
716
  });
717
717
  }
718
+ /**
719
+ * The decision core behind approve/reject, WITHOUT an ownership check: resolves the run
720
+ * currently awaiting `toolCallId` and signals it. `approve`/`reject` above call this after their
721
+ * own `assertOwnsToolCall` gate; the console `AgentApprovalPort` adapter (bound by `AgentModule`)
722
+ * calls it directly — a console caller is already authorized by the dashboard's own guards, and
723
+ * re-deriving thread ownership here would reject a legitimate operator decision (an operator is
724
+ * not the thread's own actor).
725
+ */
726
+ async signalToolCall(toolCallId, decision) {
727
+ const runId = await this.resolveRunForToolCall(toolCallId);
728
+ return this.runner.signal(runId, toolCallId, decision);
729
+ }
718
730
  async cancel(actor, runId) {
719
731
  await this.assertOwnsActiveStream(actor, runId);
720
732
  return this.runner.cancel(runId);
@@ -862,12 +874,11 @@ var AgentService = class {
862
874
  }
863
875
  }
864
876
  /**
865
- * Authorization + routing seam for HITL approve/reject: assert the caller owns the tool call's
866
- * thread, then resolve the run currently awaiting that call (its thread's active stream). That run
867
- * is the sub-agent's own child run when the pending call belongs to a delegated agent — the client
868
- * never knows or supplies a runId; it is derived here from the tool call alone.
877
+ * Authorization seam for HITL approve/reject: the caller must own the tool call's thread. Split
878
+ * out from run resolution (see {@link resolveRunForToolCall}) so the console `AgentApprovalPort`
879
+ * adapter can resolve+signal a decision WITHOUT this check — it is authorized upstream instead.
869
880
  */
870
- async runForOwnedToolCall(actor, toolCallId) {
881
+ async assertOwnsToolCall(actor, toolCallId) {
871
882
  const owner = await this.store.ownerOfToolCall(toolCallId);
872
883
  if (owner === null) {
873
884
  throw new import_common6.NotFoundException(`tool call ${toolCallId} not found`);
@@ -875,6 +886,13 @@ var AgentService = class {
875
886
  if (owner !== actor.id) {
876
887
  throw new import_common6.ForbiddenException("tool call belongs to another actor");
877
888
  }
889
+ }
890
+ /**
891
+ * Resolve the run currently awaiting `toolCallId` (its thread's active stream). That run is the
892
+ * sub-agent's own child run when the pending call belongs to a delegated agent — the client never
893
+ * knows or supplies a runId; it is derived here from the tool call alone.
894
+ */
895
+ async resolveRunForToolCall(toolCallId) {
878
896
  const runId = await this.store.runForToolCall(toolCallId);
879
897
  if (runId === null) {
880
898
  throw new import_common6.NotFoundException(`tool call ${toolCallId} has no active run to signal`);
@@ -907,8 +925,7 @@ AgentService = _ts_decorate6([
907
925
  ])
908
926
  ], AgentService);
909
927
 
910
- // src/controller/agents.controller.ts
911
- var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
928
+ // src/approval-port.adapter.ts
912
929
  var import_common7 = require("@nestjs/common");
913
930
  function _ts_decorate7(decorators, target, key, desc) {
914
931
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -921,6 +938,56 @@ function _ts_metadata6(k, v) {
921
938
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
922
939
  }
923
940
  __name(_ts_metadata6, "_ts_metadata");
941
+ var AgentApprovalPortAdapter = class {
942
+ static {
943
+ __name(this, "AgentApprovalPortAdapter");
944
+ }
945
+ agent;
946
+ constructor(agent) {
947
+ this.agent = agent;
948
+ }
949
+ async approve(toolCallId, opts) {
950
+ await this.agent.signalToolCall(toolCallId, {
951
+ approved: true,
952
+ ...opts?.executedByRef !== void 0 ? {
953
+ executedByRef: opts.executedByRef
954
+ } : {}
955
+ });
956
+ }
957
+ async reject(toolCallId, opts) {
958
+ await this.agent.signalToolCall(toolCallId, {
959
+ approved: false,
960
+ ...opts?.executedByRef !== void 0 ? {
961
+ executedByRef: opts.executedByRef
962
+ } : {},
963
+ ...opts?.reason !== void 0 ? {
964
+ reason: opts.reason
965
+ } : {}
966
+ });
967
+ }
968
+ };
969
+ AgentApprovalPortAdapter = _ts_decorate7([
970
+ (0, import_common7.Injectable)(),
971
+ _ts_metadata6("design:type", Function),
972
+ _ts_metadata6("design:paramtypes", [
973
+ typeof AgentService === "undefined" ? Object : AgentService
974
+ ])
975
+ ], AgentApprovalPortAdapter);
976
+
977
+ // src/controller/agents.controller.ts
978
+ var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
979
+ var import_common8 = require("@nestjs/common");
980
+ function _ts_decorate8(decorators, target, key, desc) {
981
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
982
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
983
+ 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;
984
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
985
+ }
986
+ __name(_ts_decorate8, "_ts_decorate");
987
+ function _ts_metadata7(k, v) {
988
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
989
+ }
990
+ __name(_ts_metadata7, "_ts_metadata");
924
991
  function _ts_param5(paramIndex, decorator) {
925
992
  return function(target, key) {
926
993
  decorator(target, key, paramIndex);
@@ -948,18 +1015,18 @@ var AgentsController = class {
948
1015
  }));
949
1016
  }
950
1017
  };
951
- _ts_decorate7([
952
- (0, import_common7.Get)(),
953
- _ts_metadata6("design:type", Function),
954
- _ts_metadata6("design:paramtypes", []),
955
- _ts_metadata6("design:returntype", Array)
1018
+ _ts_decorate8([
1019
+ (0, import_common8.Get)(),
1020
+ _ts_metadata7("design:type", Function),
1021
+ _ts_metadata7("design:paramtypes", []),
1022
+ _ts_metadata7("design:returntype", Array)
956
1023
  ], AgentsController.prototype, "list", null);
957
- AgentsController = _ts_decorate7([
958
- (0, import_common7.Controller)("agents"),
959
- _ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_REGISTRY)),
960
- _ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core8.AGENT_DEPS_FACTORY)),
961
- _ts_metadata6("design:type", Function),
962
- _ts_metadata6("design:paramtypes", [
1024
+ AgentsController = _ts_decorate8([
1025
+ (0, import_common8.Controller)("agents"),
1026
+ _ts_param5(0, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_REGISTRY)),
1027
+ _ts_param5(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_DEPS_FACTORY)),
1028
+ _ts_metadata7("design:type", Function),
1029
+ _ts_metadata7("design:paramtypes", [
963
1030
  typeof import_nestjs_agent_core8.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core8.AgentRegistry,
964
1031
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
965
1032
  ])
@@ -967,19 +1034,19 @@ AgentsController = _ts_decorate7([
967
1034
 
968
1035
  // src/controller/attachments.controller.ts
969
1036
  var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
970
- var import_common8 = require("@nestjs/common");
1037
+ var import_common9 = require("@nestjs/common");
971
1038
  var import_platform_express = require("@nestjs/platform-express");
972
- function _ts_decorate8(decorators, target, key, desc) {
1039
+ function _ts_decorate9(decorators, target, key, desc) {
973
1040
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
974
1041
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
975
1042
  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;
976
1043
  return c > 3 && r && Object.defineProperty(target, key, r), r;
977
1044
  }
978
- __name(_ts_decorate8, "_ts_decorate");
979
- function _ts_metadata7(k, v) {
1045
+ __name(_ts_decorate9, "_ts_decorate");
1046
+ function _ts_metadata8(k, v) {
980
1047
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
981
1048
  }
982
- __name(_ts_metadata7, "_ts_metadata");
1049
+ __name(_ts_metadata8, "_ts_metadata");
983
1050
  function _ts_param6(paramIndex, decorator) {
984
1051
  return function(target, key) {
985
1052
  decorator(target, key, paramIndex);
@@ -1021,18 +1088,18 @@ var AttachmentsController = class {
1021
1088
  }
1022
1089
  async upload(req, file) {
1023
1090
  if (this.staging === void 0) {
1024
- throw new import_common8.NotImplementedException("Attachment upload is not configured on this server.");
1091
+ throw new import_common9.NotImplementedException("Attachment upload is not configured on this server.");
1025
1092
  }
1026
1093
  if (file === void 0) {
1027
- throw new import_common8.BadRequestException('multipart field "file" is required');
1094
+ throw new import_common9.BadRequestException('multipart field "file" is required');
1028
1095
  }
1029
1096
  const allowedContentTypes = this.options.attachments?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES;
1030
1097
  if (!allowedContentTypes.includes(file.mimetype)) {
1031
- throw new import_common8.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
1098
+ throw new import_common9.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
1032
1099
  }
1033
1100
  const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
1034
1101
  if (file.size > maxBytes) {
1035
- throw new import_common8.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
1102
+ throw new import_common9.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
1036
1103
  }
1037
1104
  const actor = await this.actorResolver.resolve(req);
1038
1105
  return this.staging.stage({
@@ -1044,26 +1111,26 @@ var AttachmentsController = class {
1044
1111
  });
1045
1112
  }
1046
1113
  };
1047
- _ts_decorate8([
1048
- (0, import_common8.Post)(),
1049
- (0, import_common8.UseInterceptors)((0, import_platform_express.FileInterceptor)("file")),
1050
- _ts_param6(0, (0, import_common8.Req)()),
1051
- _ts_param6(1, (0, import_common8.UploadedFile)()),
1052
- _ts_metadata7("design:type", Function),
1053
- _ts_metadata7("design:paramtypes", [
1114
+ _ts_decorate9([
1115
+ (0, import_common9.Post)(),
1116
+ (0, import_common9.UseInterceptors)((0, import_platform_express.FileInterceptor)("file")),
1117
+ _ts_param6(0, (0, import_common9.Req)()),
1118
+ _ts_param6(1, (0, import_common9.UploadedFile)()),
1119
+ _ts_metadata8("design:type", Function),
1120
+ _ts_metadata8("design:paramtypes", [
1054
1121
  typeof Request === "undefined" ? Object : Request,
1055
1122
  Object
1056
1123
  ]),
1057
- _ts_metadata7("design:returntype", Promise)
1124
+ _ts_metadata8("design:returntype", Promise)
1058
1125
  ], AttachmentsController.prototype, "upload", null);
1059
- AttachmentsController = _ts_decorate8([
1060
- (0, import_common8.Controller)("attachments"),
1061
- _ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
1062
- _ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
1063
- _ts_param6(2, (0, import_common8.Optional)()),
1064
- _ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
1065
- _ts_metadata7("design:type", Function),
1066
- _ts_metadata7("design:paramtypes", [
1126
+ AttachmentsController = _ts_decorate9([
1127
+ (0, import_common9.Controller)("attachments"),
1128
+ _ts_param6(0, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
1129
+ _ts_param6(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
1130
+ _ts_param6(2, (0, import_common9.Optional)()),
1131
+ _ts_param6(2, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
1132
+ _ts_metadata8("design:type", Function),
1133
+ _ts_metadata8("design:paramtypes", [
1067
1134
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
1068
1135
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
1069
1136
  Object
@@ -1072,18 +1139,18 @@ AttachmentsController = _ts_decorate8([
1072
1139
 
1073
1140
  // src/controller/chat.controller.ts
1074
1141
  var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
1075
- var import_common9 = require("@nestjs/common");
1076
- function _ts_decorate9(decorators, target, key, desc) {
1142
+ var import_common10 = require("@nestjs/common");
1143
+ function _ts_decorate10(decorators, target, key, desc) {
1077
1144
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1078
1145
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1079
1146
  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;
1080
1147
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1081
1148
  }
1082
- __name(_ts_decorate9, "_ts_decorate");
1083
- function _ts_metadata8(k, v) {
1149
+ __name(_ts_decorate10, "_ts_decorate");
1150
+ function _ts_metadata9(k, v) {
1084
1151
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1085
1152
  }
1086
- __name(_ts_metadata8, "_ts_metadata");
1153
+ __name(_ts_metadata9, "_ts_metadata");
1087
1154
  function _ts_param7(paramIndex, decorator) {
1088
1155
  return function(target, key) {
1089
1156
  decorator(target, key, paramIndex);
@@ -1192,46 +1259,46 @@ data: ${JSON.stringify(payload)}
1192
1259
  res.end();
1193
1260
  }
1194
1261
  };
1195
- _ts_decorate9([
1196
- (0, import_common9.Post)("chat"),
1197
- _ts_param7(0, (0, import_common9.Req)()),
1198
- _ts_param7(1, (0, import_common9.Res)()),
1199
- _ts_param7(2, (0, import_common9.Body)()),
1200
- _ts_metadata8("design:type", Function),
1201
- _ts_metadata8("design:paramtypes", [
1262
+ _ts_decorate10([
1263
+ (0, import_common10.Post)("chat"),
1264
+ _ts_param7(0, (0, import_common10.Req)()),
1265
+ _ts_param7(1, (0, import_common10.Res)()),
1266
+ _ts_param7(2, (0, import_common10.Body)()),
1267
+ _ts_metadata9("design:type", Function),
1268
+ _ts_metadata9("design:paramtypes", [
1202
1269
  typeof Request === "undefined" ? Object : Request,
1203
1270
  typeof Response === "undefined" ? Object : Response,
1204
1271
  typeof ChatBody === "undefined" ? Object : ChatBody
1205
1272
  ]),
1206
- _ts_metadata8("design:returntype", Promise)
1273
+ _ts_metadata9("design:returntype", Promise)
1207
1274
  ], ChatController.prototype, "chat", null);
1208
- _ts_decorate9([
1209
- (0, import_common9.Get)("chat/:runId/stream"),
1210
- _ts_param7(0, (0, import_common9.Param)("runId")),
1211
- _ts_param7(1, (0, import_common9.Res)()),
1212
- _ts_metadata8("design:type", Function),
1213
- _ts_metadata8("design:paramtypes", [
1275
+ _ts_decorate10([
1276
+ (0, import_common10.Get)("chat/:runId/stream"),
1277
+ _ts_param7(0, (0, import_common10.Param)("runId")),
1278
+ _ts_param7(1, (0, import_common10.Res)()),
1279
+ _ts_metadata9("design:type", Function),
1280
+ _ts_metadata9("design:paramtypes", [
1214
1281
  String,
1215
1282
  typeof Response === "undefined" ? Object : Response
1216
1283
  ]),
1217
- _ts_metadata8("design:returntype", Promise)
1284
+ _ts_metadata9("design:returntype", Promise)
1218
1285
  ], ChatController.prototype, "stream", null);
1219
- _ts_decorate9([
1220
- (0, import_common9.Post)("chat/:runId/cancel"),
1221
- _ts_param7(0, (0, import_common9.Req)()),
1222
- _ts_param7(1, (0, import_common9.Param)("runId")),
1223
- _ts_metadata8("design:type", Function),
1224
- _ts_metadata8("design:paramtypes", [
1286
+ _ts_decorate10([
1287
+ (0, import_common10.Post)("chat/:runId/cancel"),
1288
+ _ts_param7(0, (0, import_common10.Req)()),
1289
+ _ts_param7(1, (0, import_common10.Param)("runId")),
1290
+ _ts_metadata9("design:type", Function),
1291
+ _ts_metadata9("design:paramtypes", [
1225
1292
  typeof Request === "undefined" ? Object : Request,
1226
1293
  String
1227
1294
  ]),
1228
- _ts_metadata8("design:returntype", Promise)
1295
+ _ts_metadata9("design:returntype", Promise)
1229
1296
  ], ChatController.prototype, "cancel", null);
1230
- ChatController = _ts_decorate9([
1231
- (0, import_common9.Controller)(),
1232
- _ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
1233
- _ts_metadata8("design:type", Function),
1234
- _ts_metadata8("design:paramtypes", [
1297
+ ChatController = _ts_decorate10([
1298
+ (0, import_common10.Controller)(),
1299
+ _ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
1300
+ _ts_metadata9("design:type", Function),
1301
+ _ts_metadata9("design:paramtypes", [
1235
1302
  typeof AgentService === "undefined" ? Object : AgentService,
1236
1303
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1237
1304
  ])
@@ -1239,18 +1306,18 @@ ChatController = _ts_decorate9([
1239
1306
 
1240
1307
  // src/controller/quota.controller.ts
1241
1308
  var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
1242
- var import_common10 = require("@nestjs/common");
1243
- function _ts_decorate10(decorators, target, key, desc) {
1309
+ var import_common11 = require("@nestjs/common");
1310
+ function _ts_decorate11(decorators, target, key, desc) {
1244
1311
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1245
1312
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1246
1313
  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;
1247
1314
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1248
1315
  }
1249
- __name(_ts_decorate10, "_ts_decorate");
1250
- function _ts_metadata9(k, v) {
1316
+ __name(_ts_decorate11, "_ts_decorate");
1317
+ function _ts_metadata10(k, v) {
1251
1318
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1252
1319
  }
1253
- __name(_ts_metadata9, "_ts_metadata");
1320
+ __name(_ts_metadata10, "_ts_metadata");
1254
1321
  function _ts_param8(paramIndex, decorator) {
1255
1322
  return function(target, key) {
1256
1323
  decorator(target, key, paramIndex);
@@ -1272,20 +1339,20 @@ var QuotaController = class {
1272
1339
  return this.agent.quotaToday(actor.id);
1273
1340
  }
1274
1341
  };
1275
- _ts_decorate10([
1276
- (0, import_common10.Get)("today"),
1277
- _ts_param8(0, (0, import_common10.Req)()),
1278
- _ts_metadata9("design:type", Function),
1279
- _ts_metadata9("design:paramtypes", [
1342
+ _ts_decorate11([
1343
+ (0, import_common11.Get)("today"),
1344
+ _ts_param8(0, (0, import_common11.Req)()),
1345
+ _ts_metadata10("design:type", Function),
1346
+ _ts_metadata10("design:paramtypes", [
1280
1347
  typeof Request === "undefined" ? Object : Request
1281
1348
  ]),
1282
- _ts_metadata9("design:returntype", Promise)
1349
+ _ts_metadata10("design:returntype", Promise)
1283
1350
  ], QuotaController.prototype, "today", null);
1284
- QuotaController = _ts_decorate10([
1285
- (0, import_common10.Controller)("quota"),
1286
- _ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
1287
- _ts_metadata9("design:type", Function),
1288
- _ts_metadata9("design:paramtypes", [
1351
+ QuotaController = _ts_decorate11([
1352
+ (0, import_common11.Controller)("quota"),
1353
+ _ts_param8(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
1354
+ _ts_metadata10("design:type", Function),
1355
+ _ts_metadata10("design:paramtypes", [
1289
1356
  typeof AgentService === "undefined" ? Object : AgentService,
1290
1357
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1291
1358
  ])
@@ -1293,18 +1360,18 @@ QuotaController = _ts_decorate10([
1293
1360
 
1294
1361
  // src/controller/threads.controller.ts
1295
1362
  var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
1296
- var import_common11 = require("@nestjs/common");
1297
- function _ts_decorate11(decorators, target, key, desc) {
1363
+ var import_common12 = require("@nestjs/common");
1364
+ function _ts_decorate12(decorators, target, key, desc) {
1298
1365
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1299
1366
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1300
1367
  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;
1301
1368
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1302
1369
  }
1303
- __name(_ts_decorate11, "_ts_decorate");
1304
- function _ts_metadata10(k, v) {
1370
+ __name(_ts_decorate12, "_ts_decorate");
1371
+ function _ts_metadata11(k, v) {
1305
1372
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1306
1373
  }
1307
- __name(_ts_metadata10, "_ts_metadata");
1374
+ __name(_ts_metadata11, "_ts_metadata");
1308
1375
  function _ts_param9(paramIndex, decorator) {
1309
1376
  return function(target, key) {
1310
1377
  decorator(target, key, paramIndex);
@@ -1374,92 +1441,92 @@ var ThreadsController = class {
1374
1441
  };
1375
1442
  }
1376
1443
  };
1377
- _ts_decorate11([
1378
- (0, import_common11.Get)(),
1379
- _ts_param9(0, (0, import_common11.Req)()),
1380
- _ts_metadata10("design:type", Function),
1381
- _ts_metadata10("design:paramtypes", [
1444
+ _ts_decorate12([
1445
+ (0, import_common12.Get)(),
1446
+ _ts_param9(0, (0, import_common12.Req)()),
1447
+ _ts_metadata11("design:type", Function),
1448
+ _ts_metadata11("design:paramtypes", [
1382
1449
  typeof Request === "undefined" ? Object : Request
1383
1450
  ]),
1384
- _ts_metadata10("design:returntype", Promise)
1451
+ _ts_metadata11("design:returntype", Promise)
1385
1452
  ], ThreadsController.prototype, "list", null);
1386
- _ts_decorate11([
1387
- (0, import_common11.Get)(":id"),
1388
- _ts_param9(0, (0, import_common11.Req)()),
1389
- _ts_param9(1, (0, import_common11.Param)("id")),
1390
- _ts_metadata10("design:type", Function),
1391
- _ts_metadata10("design:paramtypes", [
1453
+ _ts_decorate12([
1454
+ (0, import_common12.Get)(":id"),
1455
+ _ts_param9(0, (0, import_common12.Req)()),
1456
+ _ts_param9(1, (0, import_common12.Param)("id")),
1457
+ _ts_metadata11("design:type", Function),
1458
+ _ts_metadata11("design:paramtypes", [
1392
1459
  typeof Request === "undefined" ? Object : Request,
1393
1460
  String
1394
1461
  ]),
1395
- _ts_metadata10("design:returntype", Promise)
1462
+ _ts_metadata11("design:returntype", Promise)
1396
1463
  ], ThreadsController.prototype, "detail", null);
1397
- _ts_decorate11([
1398
- (0, import_common11.Delete)(":id"),
1399
- _ts_param9(0, (0, import_common11.Req)()),
1400
- _ts_param9(1, (0, import_common11.Param)("id")),
1401
- _ts_metadata10("design:type", Function),
1402
- _ts_metadata10("design:paramtypes", [
1464
+ _ts_decorate12([
1465
+ (0, import_common12.Delete)(":id"),
1466
+ _ts_param9(0, (0, import_common12.Req)()),
1467
+ _ts_param9(1, (0, import_common12.Param)("id")),
1468
+ _ts_metadata11("design:type", Function),
1469
+ _ts_metadata11("design:paramtypes", [
1403
1470
  typeof Request === "undefined" ? Object : Request,
1404
1471
  String
1405
1472
  ]),
1406
- _ts_metadata10("design:returntype", Promise)
1473
+ _ts_metadata11("design:returntype", Promise)
1407
1474
  ], ThreadsController.prototype, "remove", null);
1408
- _ts_decorate11([
1409
- (0, import_common11.Post)(":id/fork-from/:messageId"),
1410
- _ts_param9(0, (0, import_common11.Req)()),
1411
- _ts_param9(1, (0, import_common11.Param)("id")),
1412
- _ts_param9(2, (0, import_common11.Param)("messageId")),
1413
- _ts_metadata10("design:type", Function),
1414
- _ts_metadata10("design:paramtypes", [
1475
+ _ts_decorate12([
1476
+ (0, import_common12.Post)(":id/fork-from/:messageId"),
1477
+ _ts_param9(0, (0, import_common12.Req)()),
1478
+ _ts_param9(1, (0, import_common12.Param)("id")),
1479
+ _ts_param9(2, (0, import_common12.Param)("messageId")),
1480
+ _ts_metadata11("design:type", Function),
1481
+ _ts_metadata11("design:paramtypes", [
1415
1482
  typeof Request === "undefined" ? Object : Request,
1416
1483
  String,
1417
1484
  String
1418
1485
  ]),
1419
- _ts_metadata10("design:returntype", Promise)
1486
+ _ts_metadata11("design:returntype", Promise)
1420
1487
  ], ThreadsController.prototype, "fork", null);
1421
- _ts_decorate11([
1422
- (0, import_common11.Patch)(":id"),
1423
- _ts_param9(0, (0, import_common11.Req)()),
1424
- _ts_param9(1, (0, import_common11.Param)("id")),
1425
- _ts_param9(2, (0, import_common11.Body)()),
1426
- _ts_metadata10("design:type", Function),
1427
- _ts_metadata10("design:paramtypes", [
1488
+ _ts_decorate12([
1489
+ (0, import_common12.Patch)(":id"),
1490
+ _ts_param9(0, (0, import_common12.Req)()),
1491
+ _ts_param9(1, (0, import_common12.Param)("id")),
1492
+ _ts_param9(2, (0, import_common12.Body)()),
1493
+ _ts_metadata11("design:type", Function),
1494
+ _ts_metadata11("design:paramtypes", [
1428
1495
  typeof Request === "undefined" ? Object : Request,
1429
1496
  String,
1430
1497
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
1431
1498
  ]),
1432
- _ts_metadata10("design:returntype", Promise)
1499
+ _ts_metadata11("design:returntype", Promise)
1433
1500
  ], ThreadsController.prototype, "update", null);
1434
- _ts_decorate11([
1435
- (0, import_common11.Post)(":id/promote"),
1436
- _ts_param9(0, (0, import_common11.Req)()),
1437
- _ts_param9(1, (0, import_common11.Param)("id")),
1438
- _ts_metadata10("design:type", Function),
1439
- _ts_metadata10("design:paramtypes", [
1501
+ _ts_decorate12([
1502
+ (0, import_common12.Post)(":id/promote"),
1503
+ _ts_param9(0, (0, import_common12.Req)()),
1504
+ _ts_param9(1, (0, import_common12.Param)("id")),
1505
+ _ts_metadata11("design:type", Function),
1506
+ _ts_metadata11("design:paramtypes", [
1440
1507
  typeof Request === "undefined" ? Object : Request,
1441
1508
  String
1442
1509
  ]),
1443
- _ts_metadata10("design:returntype", Promise)
1510
+ _ts_metadata11("design:returntype", Promise)
1444
1511
  ], ThreadsController.prototype, "promote", null);
1445
- _ts_decorate11([
1446
- (0, import_common11.Delete)(":id/from/:messageId"),
1447
- _ts_param9(0, (0, import_common11.Req)()),
1448
- _ts_param9(1, (0, import_common11.Param)("id")),
1449
- _ts_param9(2, (0, import_common11.Param)("messageId")),
1450
- _ts_metadata10("design:type", Function),
1451
- _ts_metadata10("design:paramtypes", [
1512
+ _ts_decorate12([
1513
+ (0, import_common12.Delete)(":id/from/:messageId"),
1514
+ _ts_param9(0, (0, import_common12.Req)()),
1515
+ _ts_param9(1, (0, import_common12.Param)("id")),
1516
+ _ts_param9(2, (0, import_common12.Param)("messageId")),
1517
+ _ts_metadata11("design:type", Function),
1518
+ _ts_metadata11("design:paramtypes", [
1452
1519
  typeof Request === "undefined" ? Object : Request,
1453
1520
  String,
1454
1521
  String
1455
1522
  ]),
1456
- _ts_metadata10("design:returntype", Promise)
1523
+ _ts_metadata11("design:returntype", Promise)
1457
1524
  ], ThreadsController.prototype, "truncateFrom", null);
1458
- ThreadsController = _ts_decorate11([
1459
- (0, import_common11.Controller)("threads"),
1460
- _ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
1461
- _ts_metadata10("design:type", Function),
1462
- _ts_metadata10("design:paramtypes", [
1525
+ ThreadsController = _ts_decorate12([
1526
+ (0, import_common12.Controller)("threads"),
1527
+ _ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
1528
+ _ts_metadata11("design:type", Function),
1529
+ _ts_metadata11("design:paramtypes", [
1463
1530
  typeof AgentService === "undefined" ? Object : AgentService,
1464
1531
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1465
1532
  ])
@@ -1467,18 +1534,18 @@ ThreadsController = _ts_decorate11([
1467
1534
 
1468
1535
  // src/controller/tool-call.controller.ts
1469
1536
  var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
1470
- var import_common12 = require("@nestjs/common");
1471
- function _ts_decorate12(decorators, target, key, desc) {
1537
+ var import_common13 = require("@nestjs/common");
1538
+ function _ts_decorate13(decorators, target, key, desc) {
1472
1539
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1473
1540
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1474
1541
  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;
1475
1542
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1476
1543
  }
1477
- __name(_ts_decorate12, "_ts_decorate");
1478
- function _ts_metadata11(k, v) {
1544
+ __name(_ts_decorate13, "_ts_decorate");
1545
+ function _ts_metadata12(k, v) {
1479
1546
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1480
1547
  }
1481
- __name(_ts_metadata11, "_ts_metadata");
1548
+ __name(_ts_metadata12, "_ts_metadata");
1482
1549
  function _ts_param10(paramIndex, decorator) {
1483
1550
  return function(target, key) {
1484
1551
  decorator(target, key, paramIndex);
@@ -1510,33 +1577,33 @@ var ToolCallController = class {
1510
1577
  };
1511
1578
  }
1512
1579
  };
1513
- _ts_decorate12([
1514
- (0, import_common12.Post)("approve"),
1515
- _ts_param10(0, (0, import_common12.Req)()),
1516
- _ts_param10(1, (0, import_common12.Body)()),
1517
- _ts_metadata11("design:type", Function),
1518
- _ts_metadata11("design:paramtypes", [
1580
+ _ts_decorate13([
1581
+ (0, import_common13.Post)("approve"),
1582
+ _ts_param10(0, (0, import_common13.Req)()),
1583
+ _ts_param10(1, (0, import_common13.Body)()),
1584
+ _ts_metadata12("design:type", Function),
1585
+ _ts_metadata12("design:paramtypes", [
1519
1586
  typeof Request === "undefined" ? Object : Request,
1520
1587
  typeof ApproveBody === "undefined" ? Object : ApproveBody
1521
1588
  ]),
1522
- _ts_metadata11("design:returntype", Promise)
1589
+ _ts_metadata12("design:returntype", Promise)
1523
1590
  ], ToolCallController.prototype, "approve", null);
1524
- _ts_decorate12([
1525
- (0, import_common12.Post)("reject"),
1526
- _ts_param10(0, (0, import_common12.Req)()),
1527
- _ts_param10(1, (0, import_common12.Body)()),
1528
- _ts_metadata11("design:type", Function),
1529
- _ts_metadata11("design:paramtypes", [
1591
+ _ts_decorate13([
1592
+ (0, import_common13.Post)("reject"),
1593
+ _ts_param10(0, (0, import_common13.Req)()),
1594
+ _ts_param10(1, (0, import_common13.Body)()),
1595
+ _ts_metadata12("design:type", Function),
1596
+ _ts_metadata12("design:paramtypes", [
1530
1597
  typeof Request === "undefined" ? Object : Request,
1531
1598
  typeof RejectBody === "undefined" ? Object : RejectBody
1532
1599
  ]),
1533
- _ts_metadata11("design:returntype", Promise)
1600
+ _ts_metadata12("design:returntype", Promise)
1534
1601
  ], ToolCallController.prototype, "reject", null);
1535
- ToolCallController = _ts_decorate12([
1536
- (0, import_common12.Controller)("tool-call"),
1537
- _ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
1538
- _ts_metadata11("design:type", Function),
1539
- _ts_metadata11("design:paramtypes", [
1602
+ ToolCallController = _ts_decorate13([
1603
+ (0, import_common13.Controller)("tool-call"),
1604
+ _ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
1605
+ _ts_metadata12("design:type", Function),
1606
+ _ts_metadata12("design:paramtypes", [
1540
1607
  typeof AgentService === "undefined" ? Object : AgentService,
1541
1608
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1542
1609
  ])
@@ -1544,7 +1611,7 @@ ToolCallController = _ts_decorate12([
1544
1611
 
1545
1612
  // src/discovery/agent-discovery.service.ts
1546
1613
  var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
1547
- var import_common13 = require("@nestjs/common");
1614
+ var import_common14 = require("@nestjs/common");
1548
1615
  var import_core = require("@nestjs/core");
1549
1616
 
1550
1617
  // src/decorator/agent.decorator.ts
@@ -1561,17 +1628,17 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
1561
1628
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
1562
1629
 
1563
1630
  // src/discovery/agent-discovery.service.ts
1564
- function _ts_decorate13(decorators, target, key, desc) {
1631
+ function _ts_decorate14(decorators, target, key, desc) {
1565
1632
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1566
1633
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1567
1634
  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;
1568
1635
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1569
1636
  }
1570
- __name(_ts_decorate13, "_ts_decorate");
1571
- function _ts_metadata12(k, v) {
1637
+ __name(_ts_decorate14, "_ts_decorate");
1638
+ function _ts_metadata13(k, v) {
1572
1639
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1573
1640
  }
1574
- __name(_ts_metadata12, "_ts_metadata");
1641
+ __name(_ts_metadata13, "_ts_metadata");
1575
1642
  function _ts_param11(paramIndex, decorator) {
1576
1643
  return function(target, key) {
1577
1644
  decorator(target, key, paramIndex);
@@ -1586,7 +1653,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
1586
1653
  scanner;
1587
1654
  registry;
1588
1655
  contributors;
1589
- logger = new import_common13.Logger(_AgentDiscoveryService.name);
1656
+ logger = new import_common14.Logger(_AgentDiscoveryService.name);
1590
1657
  constructor(discovery, scanner, registry, contributors) {
1591
1658
  this.discovery = discovery;
1592
1659
  this.scanner = scanner;
@@ -1674,12 +1741,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
1674
1741
  return (ctx) => candidate.call(instance, ctx);
1675
1742
  }
1676
1743
  };
1677
- AgentDiscoveryService = _ts_decorate13([
1678
- (0, import_common13.Injectable)(),
1679
- _ts_param11(2, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
1680
- _ts_param11(3, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_PROMPT_CONTRIBUTORS)),
1681
- _ts_metadata12("design:type", Function),
1682
- _ts_metadata12("design:paramtypes", [
1744
+ AgentDiscoveryService = _ts_decorate14([
1745
+ (0, import_common14.Injectable)(),
1746
+ _ts_param11(2, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
1747
+ _ts_param11(3, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_PROMPT_CONTRIBUTORS)),
1748
+ _ts_metadata13("design:type", Function),
1749
+ _ts_metadata13("design:paramtypes", [
1683
1750
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
1684
1751
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
1685
1752
  typeof import_nestjs_agent_core14.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core14.AgentRegistry,
@@ -1689,7 +1756,7 @@ AgentDiscoveryService = _ts_decorate13([
1689
1756
 
1690
1757
  // src/discovery/ai-tool-discovery.service.ts
1691
1758
  var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
1692
- var import_common14 = require("@nestjs/common");
1759
+ var import_common15 = require("@nestjs/common");
1693
1760
  var import_core2 = require("@nestjs/core");
1694
1761
  var import_zod = require("zod");
1695
1762
 
@@ -1709,17 +1776,17 @@ function isBrandedFunctionalTool(value) {
1709
1776
  __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
1710
1777
 
1711
1778
  // src/discovery/ai-tool-discovery.service.ts
1712
- function _ts_decorate14(decorators, target, key, desc) {
1779
+ function _ts_decorate15(decorators, target, key, desc) {
1713
1780
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1714
1781
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1715
1782
  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;
1716
1783
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1717
1784
  }
1718
- __name(_ts_decorate14, "_ts_decorate");
1719
- function _ts_metadata13(k, v) {
1785
+ __name(_ts_decorate15, "_ts_decorate");
1786
+ function _ts_metadata14(k, v) {
1720
1787
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1721
1788
  }
1722
- __name(_ts_metadata13, "_ts_metadata");
1789
+ __name(_ts_metadata14, "_ts_metadata");
1723
1790
  function _ts_param12(paramIndex, decorator) {
1724
1791
  return function(target, key) {
1725
1792
  decorator(target, key, paramIndex);
@@ -1734,7 +1801,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
1734
1801
  registry;
1735
1802
  agents;
1736
1803
  options;
1737
- logger = new import_common14.Logger(_AiToolDiscoveryService.name);
1804
+ logger = new import_common15.Logger(_AiToolDiscoveryService.name);
1738
1805
  constructor(discovery, registry, agents, options) {
1739
1806
  this.discovery = discovery;
1740
1807
  this.registry = registry;
@@ -1832,13 +1899,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
1832
1899
  return true;
1833
1900
  }
1834
1901
  };
1835
- AiToolDiscoveryService = _ts_decorate14([
1836
- (0, import_common14.Injectable)(),
1837
- _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_TOOL_REGISTRY)),
1838
- _ts_param12(2, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
1839
- _ts_param12(3, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_OPTIONS)),
1840
- _ts_metadata13("design:type", Function),
1841
- _ts_metadata13("design:paramtypes", [
1902
+ AiToolDiscoveryService = _ts_decorate15([
1903
+ (0, import_common15.Injectable)(),
1904
+ _ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_TOOL_REGISTRY)),
1905
+ _ts_param12(2, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
1906
+ _ts_param12(3, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_OPTIONS)),
1907
+ _ts_metadata14("design:type", Function),
1908
+ _ts_metadata14("design:paramtypes", [
1842
1909
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
1843
1910
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
1844
1911
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -1871,18 +1938,18 @@ var LedgerQuotaStore = class {
1871
1938
 
1872
1939
  // src/runner/inline-agent-runner.ts
1873
1940
  var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
1874
- var import_common15 = require("@nestjs/common");
1875
- function _ts_decorate15(decorators, target, key, desc) {
1941
+ var import_common16 = require("@nestjs/common");
1942
+ function _ts_decorate16(decorators, target, key, desc) {
1876
1943
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1877
1944
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1878
1945
  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;
1879
1946
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1880
1947
  }
1881
- __name(_ts_decorate15, "_ts_decorate");
1882
- function _ts_metadata14(k, v) {
1948
+ __name(_ts_decorate16, "_ts_decorate");
1949
+ function _ts_metadata15(k, v) {
1883
1950
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1884
1951
  }
1885
- __name(_ts_metadata14, "_ts_metadata");
1952
+ __name(_ts_metadata15, "_ts_metadata");
1886
1953
  function _ts_param13(paramIndex, decorator) {
1887
1954
  return function(target, key) {
1888
1955
  decorator(target, key, paramIndex);
@@ -1895,7 +1962,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
1895
1962
  }
1896
1963
  factory;
1897
1964
  store;
1898
- logger = new import_common15.Logger(_InlineAgentRunner.name);
1965
+ logger = new import_common16.Logger(_InlineAgentRunner.name);
1899
1966
  pending = /* @__PURE__ */ new Map();
1900
1967
  constructor(factory, store) {
1901
1968
  this.factory = factory;
@@ -2000,25 +2067,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
2000
2067
  }
2001
2068
  }
2002
2069
  };
2003
- InlineAgentRunner = _ts_decorate15([
2004
- (0, import_common15.Injectable)(),
2005
- _ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_DEPS_FACTORY)),
2006
- _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_STORE)),
2007
- _ts_metadata14("design:type", Function),
2008
- _ts_metadata14("design:paramtypes", [
2070
+ InlineAgentRunner = _ts_decorate16([
2071
+ (0, import_common16.Injectable)(),
2072
+ _ts_param13(0, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_DEPS_FACTORY)),
2073
+ _ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_STORE)),
2074
+ _ts_metadata15("design:type", Function),
2075
+ _ts_metadata15("design:paramtypes", [
2009
2076
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
2010
2077
  typeof AgentStore === "undefined" ? Object : AgentStore
2011
2078
  ])
2012
2079
  ], InlineAgentRunner);
2013
2080
 
2014
2081
  // src/agent.module.ts
2015
- function _ts_decorate16(decorators, target, key, desc) {
2082
+ function _ts_decorate17(decorators, target, key, desc) {
2016
2083
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2017
2084
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2018
2085
  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;
2019
2086
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2020
2087
  }
2021
- __name(_ts_decorate16, "_ts_decorate");
2088
+ __name(_ts_decorate17, "_ts_decorate");
2022
2089
  var DEFAULT_PATH = "agent";
2023
2090
  function sharedProviders(durable, includeStore) {
2024
2091
  const providers = [
@@ -2085,7 +2152,14 @@ function sharedProviders(durable, includeStore) {
2085
2152
  AgentDiscoveryService,
2086
2153
  AiToolDiscoveryService,
2087
2154
  InlineAgentRunner,
2088
- AgentService
2155
+ AgentService,
2156
+ // Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
2157
+ // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
2158
+ AgentApprovalPortAdapter,
2159
+ {
2160
+ provide: import_nestjs_agent_core17.AGENT_APPROVAL_PORT,
2161
+ useExisting: AgentApprovalPortAdapter
2162
+ }
2089
2163
  ];
2090
2164
  if (includeStore) {
2091
2165
  providers.push({
@@ -2138,7 +2212,8 @@ function exportsFor(includeStore) {
2138
2212
  import_nestjs_agent_core17.AGENT_DEPS_FACTORY,
2139
2213
  AgentDepsFactory2,
2140
2214
  AgentService,
2141
- InlineAgentRunner
2215
+ InlineAgentRunner,
2216
+ import_nestjs_agent_core17.AGENT_APPROVAL_PORT
2142
2217
  ];
2143
2218
  }
2144
2219
  __name(exportsFor, "exportsFor");
@@ -2234,7 +2309,17 @@ var AgentModule = class _AgentModule {
2234
2309
  providers: [
2235
2310
  {
2236
2311
  provide: import_nestjs_agent_core17.AGENT_OPTIONS,
2237
- useFactory: options.useFactory,
2312
+ // Stamp the STATIC wiring flags onto the factory result: `durable`/`dispatchedSteps` are
2313
+ // authoritative on the async config object (they decided the actual wiring above), and
2314
+ // `AgentDurableModule` derives the effective dispatched-steps value from AGENT_OPTIONS —
2315
+ // without this stamp, an async host would get in-process localSteps despite durable: true.
2316
+ useFactory: /* @__PURE__ */ __name(async (...args) => ({
2317
+ ...await options.useFactory(...args),
2318
+ durable: options.durable ?? false,
2319
+ ...options.dispatchedSteps !== void 0 ? {
2320
+ dispatchedSteps: options.dispatchedSteps
2321
+ } : {}
2322
+ }), "useFactory"),
2238
2323
  inject: options.inject ?? []
2239
2324
  },
2240
2325
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -2244,9 +2329,9 @@ var AgentModule = class _AgentModule {
2244
2329
  };
2245
2330
  }
2246
2331
  };
2247
- AgentModule = _ts_decorate16([
2248
- (0, import_common16.Global)(),
2249
- (0, import_common16.Module)({})
2332
+ AgentModule = _ts_decorate17([
2333
+ (0, import_common17.Global)(),
2334
+ (0, import_common17.Module)({})
2250
2335
  ], AgentModule);
2251
2336
 
2252
2337
  // src/durable/agent-durable.ts