@dudousxd/nestjs-agent 1.16.1 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  // src/index.ts
23
23
  var index_exports = {};
24
24
  __export(index_exports, {
25
+ AGENT_CHAT_QUEUE: () => AGENT_CHAT_QUEUE,
25
26
  AGENT_METADATA: () => AGENT_METADATA,
26
27
  AGENT_TOOL_BRAND: () => AGENT_TOOL_BRAND,
27
28
  AI_TOOL_METADATA: () => AI_TOOL_METADATA,
@@ -49,6 +50,7 @@ __export(index_exports, {
49
50
  MessagesController: () => MessagesController,
50
51
  ModelsController: () => ModelsController,
51
52
  QueueController: () => QueueController,
53
+ RunNotActiveException: () => RunNotActiveException,
52
54
  SKILL_METADATA: () => SKILL_METADATA,
53
55
  SYSTEM_PROMPT_CONTRIBUTOR_METADATA: () => SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
54
56
  SYSTEM_PROMPT_METADATA: () => SYSTEM_PROMPT_METADATA,
@@ -76,8 +78,8 @@ __export(index_exports, {
76
78
  module.exports = __toCommonJS(index_exports);
77
79
 
78
80
  // src/agent.module.ts
79
- var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
80
- var import_common22 = require("@nestjs/common");
81
+ var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
82
+ var import_common23 = require("@nestjs/common");
81
83
  var import_core4 = require("@nestjs/core");
82
84
 
83
85
  // src/agent-deps.factory.ts
@@ -339,8 +341,8 @@ AgentDepsFactory2 = _ts_decorate([
339
341
  ], AgentDepsFactory2);
340
342
 
341
343
  // src/agent.service.ts
342
- var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
343
- var import_common3 = require("@nestjs/common");
344
+ var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
345
+ var import_common4 = require("@nestjs/common");
344
346
 
345
347
  // src/agent-deps.ts
346
348
  function utcDay(date = /* @__PURE__ */ new Date()) {
@@ -785,6 +787,24 @@ function queueFrame(items, paused, started) {
785
787
  }
786
788
  __name(queueFrame, "queueFrame");
787
789
 
790
+ // src/run-not-active.exception.ts
791
+ var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
792
+ var import_common3 = require("@nestjs/common");
793
+ var RunNotActiveException = class extends import_common3.ConflictException {
794
+ static {
795
+ __name(this, "RunNotActiveException");
796
+ }
797
+ runId;
798
+ code = import_nestjs_agent_core4.RUN_NOT_ACTIVE_CODE;
799
+ constructor(runId) {
800
+ super({
801
+ statusCode: 409,
802
+ code: import_nestjs_agent_core4.RUN_NOT_ACTIVE_CODE,
803
+ message: import_nestjs_agent_core4.RUN_NOT_ACTIVE_MESSAGE
804
+ }), this.runId = runId;
805
+ }
806
+ };
807
+
788
808
  // src/agent.service.ts
789
809
  function _ts_decorate3(decorators, target, key, desc) {
790
810
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -842,7 +862,7 @@ var AgentService = class {
842
862
  requireQueue() {
843
863
  const queue = this.queueing();
844
864
  if (queue === void 0) {
845
- throw new import_common3.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
865
+ throw new import_common4.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
846
866
  }
847
867
  return queue;
848
868
  }
@@ -879,12 +899,12 @@ var AgentService = class {
879
899
  actor
880
900
  });
881
901
  if (blocked !== void 0) {
882
- throw new import_common3.HttpException({
883
- statusCode: import_common3.HttpStatus.TOO_MANY_REQUESTS,
902
+ throw new import_common4.HttpException({
903
+ statusCode: import_common4.HttpStatus.TOO_MANY_REQUESTS,
884
904
  code: "quota_exceeded",
885
905
  period: blocked.period,
886
906
  message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
887
- }, import_common3.HttpStatus.TOO_MANY_REQUESTS);
907
+ }, import_common4.HttpStatus.TOO_MANY_REQUESTS);
888
908
  }
889
909
  }
890
910
  /**
@@ -912,17 +932,17 @@ var AgentService = class {
912
932
  */
913
933
  async assertModelAllowed(actor, agent, model) {
914
934
  if (this.models === void 0) {
915
- throw new import_common3.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
935
+ throw new import_common4.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
916
936
  }
917
- const entry = (0, import_nestjs_agent_core4.findCatalogModel)(await this.models.list({
937
+ const entry = (0, import_nestjs_agent_core5.findCatalogModel)(await this.models.list({
918
938
  actor,
919
939
  agent
920
940
  }), model);
921
941
  if (entry === void 0) {
922
- throw new import_common3.BadRequestException(`model "${model}" is not offered`);
942
+ throw new import_common4.BadRequestException(`model "${model}" is not offered`);
923
943
  }
924
944
  if (!entry.available) {
925
- throw new import_common3.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
945
+ throw new import_common4.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
926
946
  }
927
947
  return entry.id;
928
948
  }
@@ -938,7 +958,7 @@ var AgentService = class {
938
958
  })).locked : void 0;
939
959
  if (locked !== void 0) {
940
960
  if (requested !== void 0 && requested !== locked.model) {
941
- throw new import_common3.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
961
+ throw new import_common4.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
942
962
  }
943
963
  return locked.model;
944
964
  }
@@ -982,7 +1002,7 @@ var AgentService = class {
982
1002
  };
983
1003
  }
984
1004
  await this.requireQueue().publish(result.threadId);
985
- throw new import_common3.ConflictException({
1005
+ throw new import_common4.ConflictException({
986
1006
  statusCode: 409,
987
1007
  code: "run_active",
988
1008
  message: `thread ${result.threadId} already has a turn running`
@@ -1000,7 +1020,7 @@ var AgentService = class {
1000
1020
  let threadId = params.threadId;
1001
1021
  if (threadId === void 0) {
1002
1022
  if (params.regenerate === true) {
1003
- throw new import_common3.BadRequestException("regenerate requires an existing threadId");
1023
+ throw new import_common4.BadRequestException("regenerate requires an existing threadId");
1004
1024
  }
1005
1025
  const created = await this.store.createThread({
1006
1026
  actor: params.actor,
@@ -1042,6 +1062,11 @@ var AgentService = class {
1042
1062
  }
1043
1063
  const mode = params.mode ?? "auto";
1044
1064
  const { live, stale } = await queue.holder(threadId, this.runner);
1065
+ if (stale !== null) {
1066
+ await (0, import_nestjs_agent_core5.settleDeadRun)(this.store, {
1067
+ runId: stale
1068
+ });
1069
+ }
1045
1070
  if (live === null && mode !== "queue") {
1046
1071
  const runId = crypto.randomUUID();
1047
1072
  if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
@@ -1054,7 +1079,7 @@ var AgentService = class {
1054
1079
  }
1055
1080
  }
1056
1081
  if (params.regenerate === true) {
1057
- throw new import_common3.ConflictException({
1082
+ throw new import_common4.ConflictException({
1058
1083
  statusCode: 409,
1059
1084
  code: "run_active",
1060
1085
  message: "cannot regenerate while a turn is running on this thread"
@@ -1151,7 +1176,7 @@ var AgentService = class {
1151
1176
  const store = queue.queueStore();
1152
1177
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
1153
1178
  if (patch.message !== void 0 && patch.message.trim().length === 0) {
1154
- throw new import_common3.BadRequestException("message must not be empty");
1179
+ throw new import_common4.BadRequestException("message must not be empty");
1155
1180
  }
1156
1181
  const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
1157
1182
  if (patch.message !== void 0 || attachments !== void 0) {
@@ -1164,15 +1189,15 @@ var AgentService = class {
1164
1189
  } : {}
1165
1190
  });
1166
1191
  if (updated === null) {
1167
- throw new import_common3.GoneException(`queued message ${messageId} already started or was removed`);
1192
+ throw new import_common4.GoneException(`queued message ${messageId} already started or was removed`);
1168
1193
  }
1169
1194
  }
1170
1195
  if (patch.position !== void 0) {
1171
1196
  if (!Number.isInteger(patch.position) || patch.position < 0) {
1172
- throw new import_common3.BadRequestException("position must be a non-negative integer");
1197
+ throw new import_common4.BadRequestException("position must be a non-negative integer");
1173
1198
  }
1174
1199
  if (!await store.moveQueuedMessage(messageId, patch.position)) {
1175
- throw new import_common3.GoneException(`queued message ${messageId} already started or was removed`);
1200
+ throw new import_common4.GoneException(`queued message ${messageId} already started or was removed`);
1176
1201
  }
1177
1202
  }
1178
1203
  return queue.publish(threadId);
@@ -1182,7 +1207,7 @@ var AgentService = class {
1182
1207
  const queue = this.requireQueue();
1183
1208
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
1184
1209
  if (!await queue.queueStore().removeQueuedMessage(messageId)) {
1185
- throw new import_common3.GoneException(`queued message ${messageId} already started or was removed`);
1210
+ throw new import_common4.GoneException(`queued message ${messageId} already started or was removed`);
1186
1211
  }
1187
1212
  return queue.publish(threadId);
1188
1213
  }
@@ -1201,7 +1226,7 @@ var AgentService = class {
1201
1226
  const queue = this.requireQueue();
1202
1227
  const store = queue.queueStore();
1203
1228
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
1204
- const gone = /* @__PURE__ */ __name(() => new import_common3.GoneException(`queued message ${messageId} already started or was removed`), "gone");
1229
+ const gone = /* @__PURE__ */ __name(() => new import_common4.GoneException(`queued message ${messageId} already started or was removed`), "gone");
1205
1230
  const marked = await store.updateQueuedMessage(messageId, {
1206
1231
  interrupt: true
1207
1232
  });
@@ -1209,7 +1234,7 @@ var AgentService = class {
1209
1234
  throw gone();
1210
1235
  }
1211
1236
  if (marked.interrupt !== true) {
1212
- throw new import_common3.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
1237
+ throw new import_common4.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
1213
1238
  }
1214
1239
  if (!await store.moveQueuedMessage(messageId, 0)) {
1215
1240
  throw gone();
@@ -1268,7 +1293,7 @@ var AgentService = class {
1268
1293
  async assertOwnsQueuedMessage(actor, messageId) {
1269
1294
  const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
1270
1295
  if (message === null) {
1271
- throw new import_common3.NotFoundException(`queued message ${messageId} not found`);
1296
+ throw new import_common4.NotFoundException(`queued message ${messageId} not found`);
1272
1297
  }
1273
1298
  await this.assertOwnsThread(actor, message.threadId);
1274
1299
  return message.threadId;
@@ -1289,7 +1314,7 @@ var AgentService = class {
1289
1314
  }
1290
1315
  const staging = this.staging;
1291
1316
  if (staging === void 0 || typeof staging.resolve !== "function") {
1292
- throw new import_common3.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
1317
+ throw new import_common4.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
1293
1318
  }
1294
1319
  const resolved = [];
1295
1320
  for (const ref of refs) {
@@ -1298,7 +1323,7 @@ var AgentService = class {
1298
1323
  actor
1299
1324
  });
1300
1325
  if (attachment === null) {
1301
- throw new import_common3.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
1326
+ throw new import_common4.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
1302
1327
  }
1303
1328
  resolved.push(attachment);
1304
1329
  }
@@ -1402,8 +1427,29 @@ var AgentService = class {
1402
1427
  async signalToolCall(toolCallId2, reply) {
1403
1428
  await this.assertNotExpired(toolCallId2);
1404
1429
  const runId = await this.resolveRunForToolCall(toolCallId2);
1430
+ await this.assertRunWaiting(runId);
1405
1431
  return this.runner.signal(runId, toolCallId2, reply);
1406
1432
  }
1433
+ /**
1434
+ * Refuse a decision addressed at a run that is over (`409 run_not_active`). The runtime would take
1435
+ * the signal and buffer it for a run that never comes back — the person's "yes" is accepted, the
1436
+ * card says so, and nothing runs. Settles the calls the dead run left awaiting a decision on the
1437
+ * way out, so the card stops asking. A runner that cannot say whether a run is alive is taken at
1438
+ * its word that it is, and so is one that fails to answer.
1439
+ */
1440
+ async assertRunWaiting(runId) {
1441
+ if (typeof this.runner.isRunActive !== "function") {
1442
+ return;
1443
+ }
1444
+ const active = await this.runner.isRunActive(runId).catch(() => true);
1445
+ if (active) {
1446
+ return;
1447
+ }
1448
+ await (0, import_nestjs_agent_core5.settleDeadRun)(this.store, {
1449
+ runId
1450
+ });
1451
+ throw new RunNotActiveException(runId);
1452
+ }
1407
1453
  async cancel(actor, runId) {
1408
1454
  await this.assertOwnsActiveStream(actor, runId);
1409
1455
  return this.runner.cancel(runId);
@@ -1447,7 +1493,7 @@ var AgentService = class {
1447
1493
  return;
1448
1494
  }
1449
1495
  if (this.store.updateThread === void 0) {
1450
- throw new import_common3.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
1496
+ throw new import_common4.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
1451
1497
  }
1452
1498
  const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
1453
1499
  await this.store.updateThread(threadId, {
@@ -1465,10 +1511,10 @@ var AgentService = class {
1465
1511
  validateTitle(title) {
1466
1512
  const trimmed = title.trim();
1467
1513
  if (trimmed.length === 0) {
1468
- throw new import_common3.BadRequestException("title must not be empty");
1514
+ throw new import_common4.BadRequestException("title must not be empty");
1469
1515
  }
1470
1516
  if (trimmed.length > 200) {
1471
- throw new import_common3.BadRequestException("title must be at most 200 characters");
1517
+ throw new import_common4.BadRequestException("title must be at most 200 characters");
1472
1518
  }
1473
1519
  return trimmed;
1474
1520
  }
@@ -1571,21 +1617,21 @@ var AgentService = class {
1571
1617
  */
1572
1618
  async setMessageFeedback(actor, messageId, input) {
1573
1619
  if (input.value !== null && input.value !== "up" && input.value !== "down") {
1574
- throw new import_common3.BadRequestException("value must be 'up', 'down' or null");
1620
+ throw new import_common4.BadRequestException("value must be 'up', 'down' or null");
1575
1621
  }
1576
1622
  if (input.comment !== void 0 && typeof input.comment !== "string") {
1577
- throw new import_common3.BadRequestException("comment must be a string");
1623
+ throw new import_common4.BadRequestException("comment must be a string");
1578
1624
  }
1579
1625
  const comment = input.comment?.trim();
1580
1626
  if (comment !== void 0 && comment.length > 2e3) {
1581
- throw new import_common3.BadRequestException("comment must be at most 2000 characters");
1627
+ throw new import_common4.BadRequestException("comment must be at most 2000 characters");
1582
1628
  }
1583
1629
  if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
1584
- throw new import_common3.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
1630
+ throw new import_common4.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
1585
1631
  }
1586
1632
  const threadId = await this.store.threadOfMessage(messageId);
1587
1633
  if (threadId === null) {
1588
- throw new import_common3.NotFoundException(`message ${messageId} not found`);
1634
+ throw new import_common4.NotFoundException(`message ${messageId} not found`);
1589
1635
  }
1590
1636
  await this.assertOwnsThread(actor, threadId);
1591
1637
  const feedback = input.value === null ? null : {
@@ -1633,7 +1679,7 @@ var AgentService = class {
1633
1679
  const list = this.attachmentInventory();
1634
1680
  const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
1635
1681
  if (referencedMediaIds === void 0) {
1636
- throw new import_common3.NotImplementedException("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
1682
+ throw new import_common4.NotImplementedException("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
1637
1683
  }
1638
1684
  const stagedBefore = options.olderThan.toISOString();
1639
1685
  const inventory = await list({
@@ -1655,7 +1701,7 @@ var AgentService = class {
1655
1701
  attachmentInventory() {
1656
1702
  const list = this.staging?.list?.bind(this.staging);
1657
1703
  if (list === void 0) {
1658
- throw new import_common3.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
1704
+ throw new import_common4.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
1659
1705
  }
1660
1706
  return list;
1661
1707
  }
@@ -1666,10 +1712,10 @@ var AgentService = class {
1666
1712
  async assertOwnsThread(actor, threadId) {
1667
1713
  const owner = await this.store.ownerOfThread(threadId);
1668
1714
  if (owner === null) {
1669
- throw new import_common3.NotFoundException(`thread ${threadId} not found`);
1715
+ throw new import_common4.NotFoundException(`thread ${threadId} not found`);
1670
1716
  }
1671
1717
  if (owner !== actor.id) {
1672
- throw new import_common3.ForbiddenException("thread belongs to another actor");
1718
+ throw new import_common4.ForbiddenException("thread belongs to another actor");
1673
1719
  }
1674
1720
  }
1675
1721
  /**
@@ -1680,10 +1726,10 @@ var AgentService = class {
1680
1726
  async assertOwnsToolCall(actor, toolCallId2) {
1681
1727
  const owner = await this.store.ownerOfToolCall(toolCallId2);
1682
1728
  if (owner === null) {
1683
- throw new import_common3.NotFoundException(`tool call ${toolCallId2} not found`);
1729
+ throw new import_common4.NotFoundException(`tool call ${toolCallId2} not found`);
1684
1730
  }
1685
1731
  if (owner !== actor.id) {
1686
- throw new import_common3.ForbiddenException("tool call belongs to another actor");
1732
+ throw new import_common4.ForbiddenException("tool call belongs to another actor");
1687
1733
  }
1688
1734
  }
1689
1735
  /**
@@ -1698,12 +1744,12 @@ var AgentService = class {
1698
1744
  if (this.store.toolCallInput === void 0) {
1699
1745
  return;
1700
1746
  }
1701
- const questions = (0, import_nestjs_agent_core4.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
1747
+ const questions = (0, import_nestjs_agent_core5.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
1702
1748
  for (const question of questions) {
1703
1749
  const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
1704
- const problem = (0, import_nestjs_agent_core4.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
1750
+ const problem = (0, import_nestjs_agent_core5.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
1705
1751
  if (problem !== null) {
1706
- throw new import_common3.BadRequestException(`answers["${question.id}"] ${problem}`);
1752
+ throw new import_common4.BadRequestException(`answers["${question.id}"] ${problem}`);
1707
1753
  }
1708
1754
  }
1709
1755
  }
@@ -1715,21 +1761,21 @@ var AgentService = class {
1715
1761
  */
1716
1762
  async assertMayDecide(actor, toolCallId2) {
1717
1763
  const approval = await this.store.toolCallApproval?.(toolCallId2);
1718
- const approver = approval?.approver ?? import_nestjs_agent_core4.REQUESTER_APPROVER;
1719
- if (approver === import_nestjs_agent_core4.REQUESTER_APPROVER) {
1764
+ const approver = approval?.approver ?? import_nestjs_agent_core5.REQUESTER_APPROVER;
1765
+ if (approver === import_nestjs_agent_core5.REQUESTER_APPROVER) {
1720
1766
  return this.assertOwnsToolCall(actor, toolCallId2);
1721
1767
  }
1722
1768
  const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
1723
1769
  if (requesterRef === null) {
1724
- throw new import_common3.NotFoundException(`tool call ${toolCallId2} not found`);
1770
+ throw new import_common4.NotFoundException(`tool call ${toolCallId2} not found`);
1725
1771
  }
1726
- const allowed = await (0, import_nestjs_agent_core4.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
1772
+ const allowed = await (0, import_nestjs_agent_core5.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
1727
1773
  toolCallId: toolCallId2,
1728
1774
  approver,
1729
1775
  requesterRef
1730
1776
  });
1731
1777
  if (!allowed) {
1732
- throw new import_common3.ForbiddenException(`this approval is for ${approver}`);
1778
+ throw new import_common4.ForbiddenException(`this approval is for ${approver}`);
1733
1779
  }
1734
1780
  }
1735
1781
  /**
@@ -1745,7 +1791,7 @@ var AgentService = class {
1745
1791
  }
1746
1792
  const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
1747
1793
  if (lapsed) {
1748
- throw new import_common3.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
1794
+ throw new import_common4.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
1749
1795
  }
1750
1796
  }
1751
1797
  /**
@@ -1758,7 +1804,7 @@ var AgentService = class {
1758
1804
  async resolveRunForToolCall(toolCallId2) {
1759
1805
  const runId = await this.store.runForToolCall(toolCallId2);
1760
1806
  if (runId === null) {
1761
- throw new import_common3.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
1807
+ throw new import_common4.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
1762
1808
  }
1763
1809
  return runId;
1764
1810
  }
@@ -1766,27 +1812,27 @@ var AgentService = class {
1766
1812
  async assertOwnsActiveStream(actor, runId) {
1767
1813
  const owner = await this.store.ownerOfActiveStream(runId);
1768
1814
  if (owner === null) {
1769
- throw new import_common3.NotFoundException(`no active run ${runId}`);
1815
+ throw new import_common4.NotFoundException(`no active run ${runId}`);
1770
1816
  }
1771
1817
  if (owner !== actor.id) {
1772
- throw new import_common3.ForbiddenException("run belongs to another actor");
1818
+ throw new import_common4.ForbiddenException("run belongs to another actor");
1773
1819
  }
1774
1820
  }
1775
1821
  };
1776
1822
  AgentService = _ts_decorate3([
1777
- (0, import_common3.Injectable)(),
1778
- _ts_param3(0, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_RUNNER)),
1779
- _ts_param3(1, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_STORE)),
1780
- _ts_param3(2, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_DEPS_FACTORY)),
1781
- _ts_param3(3, (0, import_common3.Optional)()),
1782
- _ts_param3(3, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_ATTACHMENT_STAGING)),
1783
- _ts_param3(4, (0, import_common3.Optional)()),
1784
- _ts_param3(4, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_MODEL_CATALOG)),
1785
- _ts_param3(5, (0, import_common3.Optional)()),
1786
- _ts_param3(5, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_QUOTA_PROVIDER)),
1787
- _ts_param3(6, (0, import_common3.Optional)()),
1788
- _ts_param3(6, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_OPTIONS)),
1789
- _ts_param3(7, (0, import_common3.Optional)()),
1823
+ (0, import_common4.Injectable)(),
1824
+ _ts_param3(0, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_RUNNER)),
1825
+ _ts_param3(1, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_STORE)),
1826
+ _ts_param3(2, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_DEPS_FACTORY)),
1827
+ _ts_param3(3, (0, import_common4.Optional)()),
1828
+ _ts_param3(3, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_ATTACHMENT_STAGING)),
1829
+ _ts_param3(4, (0, import_common4.Optional)()),
1830
+ _ts_param3(4, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_MODEL_CATALOG)),
1831
+ _ts_param3(5, (0, import_common4.Optional)()),
1832
+ _ts_param3(5, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_QUOTA_PROVIDER)),
1833
+ _ts_param3(6, (0, import_common4.Optional)()),
1834
+ _ts_param3(6, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_OPTIONS)),
1835
+ _ts_param3(7, (0, import_common4.Optional)()),
1790
1836
  _ts_metadata3("design:type", Function),
1791
1837
  _ts_metadata3("design:paramtypes", [
1792
1838
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
@@ -1801,7 +1847,7 @@ AgentService = _ts_decorate3([
1801
1847
  ], AgentService);
1802
1848
 
1803
1849
  // src/approval-port.adapter.ts
1804
- var import_common4 = require("@nestjs/common");
1850
+ var import_common5 = require("@nestjs/common");
1805
1851
  function _ts_decorate4(decorators, target, key, desc) {
1806
1852
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1807
1853
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1860,7 +1906,7 @@ var AgentApprovalPortAdapter = class {
1860
1906
  }
1861
1907
  };
1862
1908
  AgentApprovalPortAdapter = _ts_decorate4([
1863
- (0, import_common4.Injectable)(),
1909
+ (0, import_common5.Injectable)(),
1864
1910
  _ts_metadata4("design:type", Function),
1865
1911
  _ts_metadata4("design:paramtypes", [
1866
1912
  typeof AgentService === "undefined" ? Object : AgentService
@@ -1868,8 +1914,8 @@ AgentApprovalPortAdapter = _ts_decorate4([
1868
1914
  ], AgentApprovalPortAdapter);
1869
1915
 
1870
1916
  // src/controller/agents.controller.ts
1871
- var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
1872
- var import_common5 = require("@nestjs/common");
1917
+ var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
1918
+ var import_common6 = require("@nestjs/common");
1873
1919
  function _ts_decorate5(decorators, target, key, desc) {
1874
1920
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1875
1921
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1918,25 +1964,25 @@ var AgentsController = class {
1918
1964
  }
1919
1965
  };
1920
1966
  _ts_decorate5([
1921
- (0, import_common5.Get)(),
1967
+ (0, import_common6.Get)(),
1922
1968
  _ts_metadata5("design:type", Function),
1923
1969
  _ts_metadata5("design:paramtypes", []),
1924
1970
  _ts_metadata5("design:returntype", Array)
1925
1971
  ], AgentsController.prototype, "list", null);
1926
1972
  AgentsController = _ts_decorate5([
1927
- (0, import_common5.Controller)("agents"),
1928
- _ts_param4(0, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_REGISTRY)),
1929
- _ts_param4(1, (0, import_common5.Inject)(import_nestjs_agent_core5.AGENT_DEPS_FACTORY)),
1973
+ (0, import_common6.Controller)("agents"),
1974
+ _ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_REGISTRY)),
1975
+ _ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_DEPS_FACTORY)),
1930
1976
  _ts_metadata5("design:type", Function),
1931
1977
  _ts_metadata5("design:paramtypes", [
1932
- typeof import_nestjs_agent_core5.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core5.AgentRegistry,
1978
+ typeof import_nestjs_agent_core6.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core6.AgentRegistry,
1933
1979
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
1934
1980
  ])
1935
1981
  ], AgentsController);
1936
1982
 
1937
1983
  // src/controller/attachments.controller.ts
1938
- var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
1939
- var import_common6 = require("@nestjs/common");
1984
+ var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
1985
+ var import_common7 = require("@nestjs/common");
1940
1986
  var import_platform_express = require("@nestjs/platform-express");
1941
1987
 
1942
1988
  // src/attachment-limits.ts
@@ -2024,17 +2070,17 @@ var AttachmentsController = class {
2024
2070
  }
2025
2071
  async upload(req, file) {
2026
2072
  if (this.staging === void 0) {
2027
- throw new import_common6.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2073
+ throw new import_common7.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2028
2074
  }
2029
2075
  if (file === void 0) {
2030
- throw new import_common6.BadRequestException('multipart field "file" is required');
2076
+ throw new import_common7.BadRequestException('multipart field "file" is required');
2031
2077
  }
2032
2078
  const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
2033
2079
  if (!allowedContentTypes.includes(file.mimetype)) {
2034
- throw new import_common6.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
2080
+ throw new import_common7.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
2035
2081
  }
2036
2082
  if (file.size > maxBytes) {
2037
- throw new import_common6.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
2083
+ throw new import_common7.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
2038
2084
  }
2039
2085
  const actor = await this.actorResolver.resolve(req);
2040
2086
  return this.staging.stage({
@@ -2047,8 +2093,8 @@ var AttachmentsController = class {
2047
2093
  }
2048
2094
  };
2049
2095
  _ts_decorate6([
2050
- (0, import_common6.Get)(),
2051
- _ts_param5(0, (0, import_common6.Req)()),
2096
+ (0, import_common7.Get)(),
2097
+ _ts_param5(0, (0, import_common7.Req)()),
2052
2098
  _ts_metadata6("design:type", Function),
2053
2099
  _ts_metadata6("design:paramtypes", [
2054
2100
  typeof Request === "undefined" ? Object : Request
@@ -2056,14 +2102,14 @@ _ts_decorate6([
2056
2102
  _ts_metadata6("design:returntype", Promise)
2057
2103
  ], AttachmentsController.prototype, "list", null);
2058
2104
  _ts_decorate6([
2059
- (0, import_common6.Post)(),
2060
- (0, import_common6.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
2105
+ (0, import_common7.Post)(),
2106
+ (0, import_common7.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
2061
2107
  limits: {
2062
2108
  fileSize: HARD_MAX_ATTACHMENT_BYTES
2063
2109
  }
2064
2110
  })),
2065
- _ts_param5(0, (0, import_common6.Req)()),
2066
- _ts_param5(1, (0, import_common6.UploadedFile)()),
2111
+ _ts_param5(0, (0, import_common7.Req)()),
2112
+ _ts_param5(1, (0, import_common7.UploadedFile)()),
2067
2113
  _ts_metadata6("design:type", Function),
2068
2114
  _ts_metadata6("design:paramtypes", [
2069
2115
  typeof Request === "undefined" ? Object : Request,
@@ -2072,11 +2118,11 @@ _ts_decorate6([
2072
2118
  _ts_metadata6("design:returntype", Promise)
2073
2119
  ], AttachmentsController.prototype, "upload", null);
2074
2120
  AttachmentsController = _ts_decorate6([
2075
- (0, import_common6.Controller)("attachments"),
2076
- _ts_param5(0, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_OPTIONS)),
2077
- _ts_param5(1, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_ACTOR_RESOLVER)),
2078
- _ts_param5(3, (0, import_common6.Optional)()),
2079
- _ts_param5(3, (0, import_common6.Inject)(import_nestjs_agent_core6.AGENT_ATTACHMENT_STAGING)),
2121
+ (0, import_common7.Controller)("attachments"),
2122
+ _ts_param5(0, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_OPTIONS)),
2123
+ _ts_param5(1, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ACTOR_RESOLVER)),
2124
+ _ts_param5(3, (0, import_common7.Optional)()),
2125
+ _ts_param5(3, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ATTACHMENT_STAGING)),
2080
2126
  _ts_metadata6("design:type", Function),
2081
2127
  _ts_metadata6("design:paramtypes", [
2082
2128
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -2087,8 +2133,8 @@ AttachmentsController = _ts_decorate6([
2087
2133
  ], AttachmentsController);
2088
2134
 
2089
2135
  // src/controller/chat.controller.ts
2090
- var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
2091
- var import_common7 = require("@nestjs/common");
2136
+ var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
2137
+ var import_common8 = require("@nestjs/common");
2092
2138
  function _ts_decorate7(decorators, target, key, desc) {
2093
2139
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2094
2140
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2125,7 +2171,7 @@ function sendMode(body) {
2125
2171
  if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
2126
2172
  return body.mode;
2127
2173
  }
2128
- throw new import_common7.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
2174
+ throw new import_common8.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
2129
2175
  }
2130
2176
  __name(sendMode, "sendMode");
2131
2177
  function attachmentRefs(claimed) {
@@ -2133,21 +2179,21 @@ function attachmentRefs(claimed) {
2133
2179
  return [];
2134
2180
  }
2135
2181
  if (!Array.isArray(claimed)) {
2136
- throw new import_common7.BadRequestException("attachments must be an array of { mediaId }");
2182
+ throw new import_common8.BadRequestException("attachments must be an array of { mediaId }");
2137
2183
  }
2138
2184
  if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
2139
- throw new import_common7.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
2185
+ throw new import_common8.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
2140
2186
  }
2141
2187
  return claimed.map((entry) => {
2142
2188
  if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
2143
- throw new import_common7.BadRequestException("each attachment must be an object with a mediaId");
2189
+ throw new import_common8.BadRequestException("each attachment must be an object with a mediaId");
2144
2190
  }
2145
2191
  if (Object.keys(entry).some((key) => key !== "mediaId")) {
2146
- throw new import_common7.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
2192
+ throw new import_common8.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
2147
2193
  }
2148
2194
  const { mediaId } = entry;
2149
2195
  if (typeof mediaId !== "string" || mediaId.length === 0) {
2150
- throw new import_common7.BadRequestException("each attachment must carry a non-empty string mediaId");
2196
+ throw new import_common8.BadRequestException("each attachment must carry a non-empty string mediaId");
2151
2197
  }
2152
2198
  return {
2153
2199
  mediaId
@@ -2280,13 +2326,10 @@ data: ${line}
2280
2326
  }
2281
2327
  res.write("event: done\ndata: {}\n\n");
2282
2328
  } catch (error) {
2283
- const payload = error instanceof import_nestjs_agent_core7.AgentStreamError ? {
2329
+ const payload = error instanceof import_nestjs_agent_core8.AgentStreamError ? {
2284
2330
  code: error.code,
2285
2331
  message: error.message
2286
- } : {
2287
- code: "run_failed",
2288
- message: error instanceof Error ? error.message : "stream error"
2289
- };
2332
+ } : (0, import_nestjs_agent_core8.streamFailure)(error);
2290
2333
  res.write(`event: error
2291
2334
  data: ${JSON.stringify(payload)}
2292
2335
 
@@ -2296,10 +2339,10 @@ data: ${JSON.stringify(payload)}
2296
2339
  }
2297
2340
  };
2298
2341
  _ts_decorate7([
2299
- (0, import_common7.Post)("chat"),
2300
- _ts_param6(0, (0, import_common7.Req)()),
2301
- _ts_param6(1, (0, import_common7.Res)()),
2302
- _ts_param6(2, (0, import_common7.Body)()),
2342
+ (0, import_common8.Post)("chat"),
2343
+ _ts_param6(0, (0, import_common8.Req)()),
2344
+ _ts_param6(1, (0, import_common8.Res)()),
2345
+ _ts_param6(2, (0, import_common8.Body)()),
2303
2346
  _ts_metadata7("design:type", Function),
2304
2347
  _ts_metadata7("design:paramtypes", [
2305
2348
  typeof Request === "undefined" ? Object : Request,
@@ -2309,11 +2352,11 @@ _ts_decorate7([
2309
2352
  _ts_metadata7("design:returntype", Promise)
2310
2353
  ], ChatController.prototype, "chat", null);
2311
2354
  _ts_decorate7([
2312
- (0, import_common7.Get)("chat/:runId/stream"),
2313
- _ts_param6(0, (0, import_common7.Req)()),
2314
- _ts_param6(1, (0, import_common7.Param)("runId")),
2315
- _ts_param6(2, (0, import_common7.Res)()),
2316
- _ts_param6(3, (0, import_common7.Query)("after")),
2355
+ (0, import_common8.Get)("chat/:runId/stream"),
2356
+ _ts_param6(0, (0, import_common8.Req)()),
2357
+ _ts_param6(1, (0, import_common8.Param)("runId")),
2358
+ _ts_param6(2, (0, import_common8.Res)()),
2359
+ _ts_param6(3, (0, import_common8.Query)("after")),
2317
2360
  _ts_metadata7("design:type", Function),
2318
2361
  _ts_metadata7("design:paramtypes", [
2319
2362
  typeof Request === "undefined" ? Object : Request,
@@ -2324,9 +2367,9 @@ _ts_decorate7([
2324
2367
  _ts_metadata7("design:returntype", Promise)
2325
2368
  ], ChatController.prototype, "stream", null);
2326
2369
  _ts_decorate7([
2327
- (0, import_common7.Post)("chat/:runId/cancel"),
2328
- _ts_param6(0, (0, import_common7.Req)()),
2329
- _ts_param6(1, (0, import_common7.Param)("runId")),
2370
+ (0, import_common8.Post)("chat/:runId/cancel"),
2371
+ _ts_param6(0, (0, import_common8.Req)()),
2372
+ _ts_param6(1, (0, import_common8.Param)("runId")),
2330
2373
  _ts_metadata7("design:type", Function),
2331
2374
  _ts_metadata7("design:paramtypes", [
2332
2375
  typeof Request === "undefined" ? Object : Request,
@@ -2335,8 +2378,8 @@ _ts_decorate7([
2335
2378
  _ts_metadata7("design:returntype", Promise)
2336
2379
  ], ChatController.prototype, "cancel", null);
2337
2380
  ChatController = _ts_decorate7([
2338
- (0, import_common7.Controller)(),
2339
- _ts_param6(1, (0, import_common7.Inject)(import_nestjs_agent_core7.AGENT_ACTOR_RESOLVER)),
2381
+ (0, import_common8.Controller)(),
2382
+ _ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
2340
2383
  _ts_metadata7("design:type", Function),
2341
2384
  _ts_metadata7("design:paramtypes", [
2342
2385
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -2354,8 +2397,8 @@ function parseCursor(raw) {
2354
2397
  __name(parseCursor, "parseCursor");
2355
2398
 
2356
2399
  // src/controller/config.controller.ts
2357
- var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
2358
- var import_common8 = require("@nestjs/common");
2400
+ var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
2401
+ var import_common9 = require("@nestjs/common");
2359
2402
 
2360
2403
  // src/resolver/anonymous-actor-resolver.ts
2361
2404
  var import_node_crypto = require("crypto");
@@ -2502,8 +2545,8 @@ var ConfigController = class {
2502
2545
  }
2503
2546
  };
2504
2547
  _ts_decorate8([
2505
- (0, import_common8.Get)(),
2506
- _ts_param7(0, (0, import_common8.Req)()),
2548
+ (0, import_common9.Get)(),
2549
+ _ts_param7(0, (0, import_common9.Req)()),
2507
2550
  _ts_metadata8("design:type", Function),
2508
2551
  _ts_metadata8("design:paramtypes", [
2509
2552
  typeof Request === "undefined" ? Object : Request
@@ -2511,13 +2554,13 @@ _ts_decorate8([
2511
2554
  _ts_metadata8("design:returntype", Promise)
2512
2555
  ], ConfigController.prototype, "config", null);
2513
2556
  ConfigController = _ts_decorate8([
2514
- (0, import_common8.Controller)("config"),
2515
- _ts_param7(0, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_OPTIONS)),
2516
- _ts_param7(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
2517
- _ts_param7(2, (0, import_common8.Optional)()),
2518
- _ts_param7(2, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ATTACHMENT_STAGING)),
2519
- _ts_param7(3, (0, import_common8.Optional)()),
2520
- _ts_param7(3, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_MODEL_CATALOG)),
2557
+ (0, import_common9.Controller)("config"),
2558
+ _ts_param7(0, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
2559
+ _ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
2560
+ _ts_param7(2, (0, import_common9.Optional)()),
2561
+ _ts_param7(2, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
2562
+ _ts_param7(3, (0, import_common9.Optional)()),
2563
+ _ts_param7(3, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_MODEL_CATALOG)),
2521
2564
  _ts_metadata8("design:type", Function),
2522
2565
  _ts_metadata8("design:paramtypes", [
2523
2566
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -2528,8 +2571,8 @@ ConfigController = _ts_decorate8([
2528
2571
  ], ConfigController);
2529
2572
 
2530
2573
  // src/controller/memories.controller.ts
2531
- var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
2532
- var import_common9 = require("@nestjs/common");
2574
+ var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
2575
+ var import_common10 = require("@nestjs/common");
2533
2576
  function _ts_decorate9(decorators, target, key, desc) {
2534
2577
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2535
2578
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2589,20 +2632,20 @@ var MemoriesController = class {
2589
2632
  */
2590
2633
  async forget(req, id) {
2591
2634
  if (this.memory === void 0) {
2592
- throw new import_common9.NotFoundException("No memory is configured in this deployment.");
2635
+ throw new import_common10.NotFoundException("No memory is configured in this deployment.");
2593
2636
  }
2594
2637
  const actor = await this.actorResolver.resolve(req);
2595
2638
  const digest = await this.unbounded("", actor);
2596
2639
  const entry = digest.entries.find((candidate) => candidate.id === id);
2597
2640
  if (entry === void 0) {
2598
- throw new import_common9.NotFoundException(`No memory with id "${id}".`);
2641
+ throw new import_common10.NotFoundException(`No memory with id "${id}".`);
2599
2642
  }
2600
- const verdict = (0, import_nestjs_agent_core9.memoryForgetVerdict)({
2643
+ const verdict = (0, import_nestjs_agent_core10.memoryForgetVerdict)({
2601
2644
  record: entry,
2602
2645
  actor
2603
2646
  });
2604
2647
  if (!verdict.allowed) {
2605
- throw new import_common9.ForbiddenException(verdict.reason);
2648
+ throw new import_common10.ForbiddenException(verdict.reason);
2606
2649
  }
2607
2650
  return {
2608
2651
  forgotten: await this.memory.provider.forget({
@@ -2616,7 +2659,7 @@ var MemoriesController = class {
2616
2659
  }
2617
2660
  async unbounded(threadId, actor) {
2618
2661
  const config = this.memory;
2619
- return await (0, import_nestjs_agent_core9.offerMemories)({
2662
+ return await (0, import_nestjs_agent_core10.offerMemories)({
2620
2663
  config: {
2621
2664
  ...config,
2622
2665
  maxMemories: Number.POSITIVE_INFINITY
@@ -2629,9 +2672,9 @@ var MemoriesController = class {
2629
2672
  }
2630
2673
  };
2631
2674
  _ts_decorate9([
2632
- (0, import_common9.Get)(),
2633
- _ts_param8(0, (0, import_common9.Req)()),
2634
- _ts_param8(1, (0, import_common9.Query)("threadId")),
2675
+ (0, import_common10.Get)(),
2676
+ _ts_param8(0, (0, import_common10.Req)()),
2677
+ _ts_param8(1, (0, import_common10.Query)("threadId")),
2635
2678
  _ts_metadata9("design:type", Function),
2636
2679
  _ts_metadata9("design:paramtypes", [
2637
2680
  typeof Request === "undefined" ? Object : Request,
@@ -2640,9 +2683,9 @@ _ts_decorate9([
2640
2683
  _ts_metadata9("design:returntype", Promise)
2641
2684
  ], MemoriesController.prototype, "list", null);
2642
2685
  _ts_decorate9([
2643
- (0, import_common9.Delete)(":id"),
2644
- _ts_param8(0, (0, import_common9.Req)()),
2645
- _ts_param8(1, (0, import_common9.Param)("id")),
2686
+ (0, import_common10.Delete)(":id"),
2687
+ _ts_param8(0, (0, import_common10.Req)()),
2688
+ _ts_param8(1, (0, import_common10.Param)("id")),
2646
2689
  _ts_metadata9("design:type", Function),
2647
2690
  _ts_metadata9("design:paramtypes", [
2648
2691
  typeof Request === "undefined" ? Object : Request,
@@ -2651,10 +2694,10 @@ _ts_decorate9([
2651
2694
  _ts_metadata9("design:returntype", Promise)
2652
2695
  ], MemoriesController.prototype, "forget", null);
2653
2696
  MemoriesController = _ts_decorate9([
2654
- (0, import_common9.Controller)("memories"),
2655
- _ts_param8(0, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
2656
- _ts_param8(1, (0, import_common9.Optional)()),
2657
- _ts_param8(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_MEMORY)),
2697
+ (0, import_common10.Controller)("memories"),
2698
+ _ts_param8(0, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
2699
+ _ts_param8(1, (0, import_common10.Optional)()),
2700
+ _ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_MEMORY)),
2658
2701
  _ts_metadata9("design:type", Function),
2659
2702
  _ts_metadata9("design:paramtypes", [
2660
2703
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
@@ -2663,8 +2706,8 @@ MemoriesController = _ts_decorate9([
2663
2706
  ], MemoriesController);
2664
2707
 
2665
2708
  // src/controller/messages.controller.ts
2666
- var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
2667
- var import_common10 = require("@nestjs/common");
2709
+ var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
2710
+ var import_common11 = require("@nestjs/common");
2668
2711
  function _ts_decorate10(decorators, target, key, desc) {
2669
2712
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2670
2713
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2719,11 +2762,11 @@ var MessagesController = class {
2719
2762
  }
2720
2763
  };
2721
2764
  _ts_decorate10([
2722
- (0, import_common10.Post)(":id/feedback"),
2723
- (0, import_common10.HttpCode)(200),
2724
- _ts_param9(0, (0, import_common10.Req)()),
2725
- _ts_param9(1, (0, import_common10.Param)("id")),
2726
- _ts_param9(2, (0, import_common10.Body)()),
2765
+ (0, import_common11.Post)(":id/feedback"),
2766
+ (0, import_common11.HttpCode)(200),
2767
+ _ts_param9(0, (0, import_common11.Req)()),
2768
+ _ts_param9(1, (0, import_common11.Param)("id")),
2769
+ _ts_param9(2, (0, import_common11.Body)()),
2727
2770
  _ts_metadata10("design:type", Function),
2728
2771
  _ts_metadata10("design:paramtypes", [
2729
2772
  typeof Request === "undefined" ? Object : Request,
@@ -2733,8 +2776,8 @@ _ts_decorate10([
2733
2776
  _ts_metadata10("design:returntype", Promise)
2734
2777
  ], MessagesController.prototype, "feedback", null);
2735
2778
  MessagesController = _ts_decorate10([
2736
- (0, import_common10.Controller)("messages"),
2737
- _ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
2779
+ (0, import_common11.Controller)("messages"),
2780
+ _ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
2738
2781
  _ts_metadata10("design:type", Function),
2739
2782
  _ts_metadata10("design:paramtypes", [
2740
2783
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -2743,8 +2786,8 @@ MessagesController = _ts_decorate10([
2743
2786
  ], MessagesController);
2744
2787
 
2745
2788
  // src/controller/models.controller.ts
2746
- var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
2747
- var import_common11 = require("@nestjs/common");
2789
+ var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2790
+ var import_common12 = require("@nestjs/common");
2748
2791
  function _ts_decorate11(decorators, target, key, desc) {
2749
2792
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2750
2793
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2791,9 +2834,9 @@ var ModelsController = class {
2791
2834
  }
2792
2835
  };
2793
2836
  _ts_decorate11([
2794
- (0, import_common11.Get)(),
2795
- _ts_param10(0, (0, import_common11.Req)()),
2796
- _ts_param10(1, (0, import_common11.Query)("agent")),
2837
+ (0, import_common12.Get)(),
2838
+ _ts_param10(0, (0, import_common12.Req)()),
2839
+ _ts_param10(1, (0, import_common12.Query)("agent")),
2797
2840
  _ts_metadata11("design:type", Function),
2798
2841
  _ts_metadata11("design:paramtypes", [
2799
2842
  typeof Request === "undefined" ? Object : Request,
@@ -2802,8 +2845,8 @@ _ts_decorate11([
2802
2845
  _ts_metadata11("design:returntype", Promise)
2803
2846
  ], ModelsController.prototype, "list", null);
2804
2847
  ModelsController = _ts_decorate11([
2805
- (0, import_common11.Controller)("models"),
2806
- _ts_param10(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
2848
+ (0, import_common12.Controller)("models"),
2849
+ _ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
2807
2850
  _ts_metadata11("design:type", Function),
2808
2851
  _ts_metadata11("design:paramtypes", [
2809
2852
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -2812,8 +2855,8 @@ ModelsController = _ts_decorate11([
2812
2855
  ], ModelsController);
2813
2856
 
2814
2857
  // src/controller/queue.controller.ts
2815
- var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2816
- var import_common12 = require("@nestjs/common");
2858
+ var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2859
+ var import_common13 = require("@nestjs/common");
2817
2860
  function _ts_decorate12(decorators, target, key, desc) {
2818
2861
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2819
2862
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2863,10 +2906,10 @@ var QueueController = class {
2863
2906
  async update(req, messageId, body) {
2864
2907
  const actor = await this.actorResolver.resolve(req);
2865
2908
  if (body.message !== void 0 && typeof body.message !== "string") {
2866
- throw new import_common12.BadRequestException("message must be a string");
2909
+ throw new import_common13.BadRequestException("message must be a string");
2867
2910
  }
2868
2911
  if (body.position !== void 0 && typeof body.position !== "number") {
2869
- throw new import_common12.BadRequestException("position must be a number");
2912
+ throw new import_common13.BadRequestException("position must be a number");
2870
2913
  }
2871
2914
  const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
2872
2915
  return this.agent.updateQueuedMessage(actor, messageId, {
@@ -2894,9 +2937,9 @@ var QueueController = class {
2894
2937
  }
2895
2938
  };
2896
2939
  _ts_decorate12([
2897
- (0, import_common12.Get)("threads/:id/queue"),
2898
- _ts_param11(0, (0, import_common12.Req)()),
2899
- _ts_param11(1, (0, import_common12.Param)("id")),
2940
+ (0, import_common13.Get)("threads/:id/queue"),
2941
+ _ts_param11(0, (0, import_common13.Req)()),
2942
+ _ts_param11(1, (0, import_common13.Param)("id")),
2900
2943
  _ts_metadata12("design:type", Function),
2901
2944
  _ts_metadata12("design:paramtypes", [
2902
2945
  typeof Request === "undefined" ? Object : Request,
@@ -2905,9 +2948,9 @@ _ts_decorate12([
2905
2948
  _ts_metadata12("design:returntype", Promise)
2906
2949
  ], QueueController.prototype, "list", null);
2907
2950
  _ts_decorate12([
2908
- (0, import_common12.Delete)("threads/:id/queue"),
2909
- _ts_param11(0, (0, import_common12.Req)()),
2910
- _ts_param11(1, (0, import_common12.Param)("id")),
2951
+ (0, import_common13.Delete)("threads/:id/queue"),
2952
+ _ts_param11(0, (0, import_common13.Req)()),
2953
+ _ts_param11(1, (0, import_common13.Param)("id")),
2911
2954
  _ts_metadata12("design:type", Function),
2912
2955
  _ts_metadata12("design:paramtypes", [
2913
2956
  typeof Request === "undefined" ? Object : Request,
@@ -2916,9 +2959,9 @@ _ts_decorate12([
2916
2959
  _ts_metadata12("design:returntype", Promise)
2917
2960
  ], QueueController.prototype, "clear", null);
2918
2961
  _ts_decorate12([
2919
- (0, import_common12.Post)("threads/:id/queue/resume"),
2920
- _ts_param11(0, (0, import_common12.Req)()),
2921
- _ts_param11(1, (0, import_common12.Param)("id")),
2962
+ (0, import_common13.Post)("threads/:id/queue/resume"),
2963
+ _ts_param11(0, (0, import_common13.Req)()),
2964
+ _ts_param11(1, (0, import_common13.Param)("id")),
2922
2965
  _ts_metadata12("design:type", Function),
2923
2966
  _ts_metadata12("design:paramtypes", [
2924
2967
  typeof Request === "undefined" ? Object : Request,
@@ -2927,10 +2970,10 @@ _ts_decorate12([
2927
2970
  _ts_metadata12("design:returntype", Promise)
2928
2971
  ], QueueController.prototype, "resume", null);
2929
2972
  _ts_decorate12([
2930
- (0, import_common12.Patch)("queue/:messageId"),
2931
- _ts_param11(0, (0, import_common12.Req)()),
2932
- _ts_param11(1, (0, import_common12.Param)("messageId")),
2933
- _ts_param11(2, (0, import_common12.Body)()),
2973
+ (0, import_common13.Patch)("queue/:messageId"),
2974
+ _ts_param11(0, (0, import_common13.Req)()),
2975
+ _ts_param11(1, (0, import_common13.Param)("messageId")),
2976
+ _ts_param11(2, (0, import_common13.Body)()),
2934
2977
  _ts_metadata12("design:type", Function),
2935
2978
  _ts_metadata12("design:paramtypes", [
2936
2979
  typeof Request === "undefined" ? Object : Request,
@@ -2940,9 +2983,9 @@ _ts_decorate12([
2940
2983
  _ts_metadata12("design:returntype", Promise)
2941
2984
  ], QueueController.prototype, "update", null);
2942
2985
  _ts_decorate12([
2943
- (0, import_common12.Post)("queue/:messageId/interrupt"),
2944
- _ts_param11(0, (0, import_common12.Req)()),
2945
- _ts_param11(1, (0, import_common12.Param)("messageId")),
2986
+ (0, import_common13.Post)("queue/:messageId/interrupt"),
2987
+ _ts_param11(0, (0, import_common13.Req)()),
2988
+ _ts_param11(1, (0, import_common13.Param)("messageId")),
2946
2989
  _ts_metadata12("design:type", Function),
2947
2990
  _ts_metadata12("design:paramtypes", [
2948
2991
  typeof Request === "undefined" ? Object : Request,
@@ -2951,9 +2994,9 @@ _ts_decorate12([
2951
2994
  _ts_metadata12("design:returntype", Promise)
2952
2995
  ], QueueController.prototype, "interrupt", null);
2953
2996
  _ts_decorate12([
2954
- (0, import_common12.Delete)("queue/:messageId"),
2955
- _ts_param11(0, (0, import_common12.Req)()),
2956
- _ts_param11(1, (0, import_common12.Param)("messageId")),
2997
+ (0, import_common13.Delete)("queue/:messageId"),
2998
+ _ts_param11(0, (0, import_common13.Req)()),
2999
+ _ts_param11(1, (0, import_common13.Param)("messageId")),
2957
3000
  _ts_metadata12("design:type", Function),
2958
3001
  _ts_metadata12("design:paramtypes", [
2959
3002
  typeof Request === "undefined" ? Object : Request,
@@ -2962,8 +3005,8 @@ _ts_decorate12([
2962
3005
  _ts_metadata12("design:returntype", Promise)
2963
3006
  ], QueueController.prototype, "remove", null);
2964
3007
  QueueController = _ts_decorate12([
2965
- (0, import_common12.Controller)(),
2966
- _ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
3008
+ (0, import_common13.Controller)(),
3009
+ _ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
2967
3010
  _ts_metadata12("design:type", Function),
2968
3011
  _ts_metadata12("design:paramtypes", [
2969
3012
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -2972,8 +3015,8 @@ QueueController = _ts_decorate12([
2972
3015
  ], QueueController);
2973
3016
 
2974
3017
  // src/controller/quota.controller.ts
2975
- var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2976
- var import_common13 = require("@nestjs/common");
3018
+ var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
3019
+ var import_common14 = require("@nestjs/common");
2977
3020
  function _ts_decorate13(decorators, target, key, desc) {
2978
3021
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2979
3022
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3020,8 +3063,8 @@ var QuotaController = class {
3020
3063
  }
3021
3064
  };
3022
3065
  _ts_decorate13([
3023
- (0, import_common13.Get)(),
3024
- _ts_param12(0, (0, import_common13.Req)()),
3066
+ (0, import_common14.Get)(),
3067
+ _ts_param12(0, (0, import_common14.Req)()),
3025
3068
  _ts_metadata13("design:type", Function),
3026
3069
  _ts_metadata13("design:paramtypes", [
3027
3070
  typeof Request === "undefined" ? Object : Request
@@ -3029,8 +3072,8 @@ _ts_decorate13([
3029
3072
  _ts_metadata13("design:returntype", Promise)
3030
3073
  ], QuotaController.prototype, "report", null);
3031
3074
  QuotaController = _ts_decorate13([
3032
- (0, import_common13.Controller)("quota"),
3033
- _ts_param12(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
3075
+ (0, import_common14.Controller)("quota"),
3076
+ _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
3034
3077
  _ts_metadata13("design:type", Function),
3035
3078
  _ts_metadata13("design:paramtypes", [
3036
3079
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3039,8 +3082,8 @@ QuotaController = _ts_decorate13([
3039
3082
  ], QuotaController);
3040
3083
 
3041
3084
  // src/controller/skills.controller.ts
3042
- var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
3043
- var import_common14 = require("@nestjs/common");
3085
+ var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
3086
+ var import_common15 = require("@nestjs/common");
3044
3087
  function _ts_decorate14(decorators, target, key, desc) {
3045
3088
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3046
3089
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3082,7 +3125,7 @@ var SkillsController = class {
3082
3125
  return [];
3083
3126
  }
3084
3127
  const actor = await this.actorResolver.resolve(req);
3085
- const offer = await (0, import_nestjs_agent_core14.offerSkills)(this.skills, {
3128
+ const offer = await (0, import_nestjs_agent_core15.offerSkills)(this.skills, {
3086
3129
  actor,
3087
3130
  threadId: threadId ?? ""
3088
3131
  });
@@ -3090,9 +3133,9 @@ var SkillsController = class {
3090
3133
  }
3091
3134
  };
3092
3135
  _ts_decorate14([
3093
- (0, import_common14.Get)(),
3094
- _ts_param13(0, (0, import_common14.Req)()),
3095
- _ts_param13(1, (0, import_common14.Query)("threadId")),
3136
+ (0, import_common15.Get)(),
3137
+ _ts_param13(0, (0, import_common15.Req)()),
3138
+ _ts_param13(1, (0, import_common15.Query)("threadId")),
3096
3139
  _ts_metadata14("design:type", Function),
3097
3140
  _ts_metadata14("design:paramtypes", [
3098
3141
  typeof Request === "undefined" ? Object : Request,
@@ -3101,10 +3144,10 @@ _ts_decorate14([
3101
3144
  _ts_metadata14("design:returntype", Promise)
3102
3145
  ], SkillsController.prototype, "list", null);
3103
3146
  SkillsController = _ts_decorate14([
3104
- (0, import_common14.Controller)("skills"),
3105
- _ts_param13(0, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
3106
- _ts_param13(1, (0, import_common14.Optional)()),
3107
- _ts_param13(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_SKILLS)),
3147
+ (0, import_common15.Controller)("skills"),
3148
+ _ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
3149
+ _ts_param13(1, (0, import_common15.Optional)()),
3150
+ _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_SKILLS)),
3108
3151
  _ts_metadata14("design:type", Function),
3109
3152
  _ts_metadata14("design:paramtypes", [
3110
3153
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
@@ -3113,8 +3156,8 @@ SkillsController = _ts_decorate14([
3113
3156
  ], SkillsController);
3114
3157
 
3115
3158
  // src/controller/threads.controller.ts
3116
- var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
3117
- var import_common15 = require("@nestjs/common");
3159
+ var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
3160
+ var import_common16 = require("@nestjs/common");
3118
3161
  function _ts_decorate15(decorators, target, key, desc) {
3119
3162
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3120
3163
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3208,8 +3251,8 @@ var ThreadsController = class {
3208
3251
  }
3209
3252
  };
3210
3253
  _ts_decorate15([
3211
- (0, import_common15.Get)(),
3212
- _ts_param14(0, (0, import_common15.Req)()),
3254
+ (0, import_common16.Get)(),
3255
+ _ts_param14(0, (0, import_common16.Req)()),
3213
3256
  _ts_metadata15("design:type", Function),
3214
3257
  _ts_metadata15("design:paramtypes", [
3215
3258
  typeof Request === "undefined" ? Object : Request
@@ -3217,9 +3260,9 @@ _ts_decorate15([
3217
3260
  _ts_metadata15("design:returntype", Promise)
3218
3261
  ], ThreadsController.prototype, "list", null);
3219
3262
  _ts_decorate15([
3220
- (0, import_common15.Get)(":id"),
3221
- _ts_param14(0, (0, import_common15.Req)()),
3222
- _ts_param14(1, (0, import_common15.Param)("id")),
3263
+ (0, import_common16.Get)(":id"),
3264
+ _ts_param14(0, (0, import_common16.Req)()),
3265
+ _ts_param14(1, (0, import_common16.Param)("id")),
3223
3266
  _ts_metadata15("design:type", Function),
3224
3267
  _ts_metadata15("design:paramtypes", [
3225
3268
  typeof Request === "undefined" ? Object : Request,
@@ -3228,9 +3271,9 @@ _ts_decorate15([
3228
3271
  _ts_metadata15("design:returntype", Promise)
3229
3272
  ], ThreadsController.prototype, "detail", null);
3230
3273
  _ts_decorate15([
3231
- (0, import_common15.Delete)(":id"),
3232
- _ts_param14(0, (0, import_common15.Req)()),
3233
- _ts_param14(1, (0, import_common15.Param)("id")),
3274
+ (0, import_common16.Delete)(":id"),
3275
+ _ts_param14(0, (0, import_common16.Req)()),
3276
+ _ts_param14(1, (0, import_common16.Param)("id")),
3234
3277
  _ts_metadata15("design:type", Function),
3235
3278
  _ts_metadata15("design:paramtypes", [
3236
3279
  typeof Request === "undefined" ? Object : Request,
@@ -3239,10 +3282,10 @@ _ts_decorate15([
3239
3282
  _ts_metadata15("design:returntype", Promise)
3240
3283
  ], ThreadsController.prototype, "remove", null);
3241
3284
  _ts_decorate15([
3242
- (0, import_common15.Post)(":id/fork-from/:messageId"),
3243
- _ts_param14(0, (0, import_common15.Req)()),
3244
- _ts_param14(1, (0, import_common15.Param)("id")),
3245
- _ts_param14(2, (0, import_common15.Param)("messageId")),
3285
+ (0, import_common16.Post)(":id/fork-from/:messageId"),
3286
+ _ts_param14(0, (0, import_common16.Req)()),
3287
+ _ts_param14(1, (0, import_common16.Param)("id")),
3288
+ _ts_param14(2, (0, import_common16.Param)("messageId")),
3246
3289
  _ts_metadata15("design:type", Function),
3247
3290
  _ts_metadata15("design:paramtypes", [
3248
3291
  typeof Request === "undefined" ? Object : Request,
@@ -3252,10 +3295,10 @@ _ts_decorate15([
3252
3295
  _ts_metadata15("design:returntype", Promise)
3253
3296
  ], ThreadsController.prototype, "fork", null);
3254
3297
  _ts_decorate15([
3255
- (0, import_common15.Patch)(":id"),
3256
- _ts_param14(0, (0, import_common15.Req)()),
3257
- _ts_param14(1, (0, import_common15.Param)("id")),
3258
- _ts_param14(2, (0, import_common15.Body)()),
3298
+ (0, import_common16.Patch)(":id"),
3299
+ _ts_param14(0, (0, import_common16.Req)()),
3300
+ _ts_param14(1, (0, import_common16.Param)("id")),
3301
+ _ts_param14(2, (0, import_common16.Body)()),
3259
3302
  _ts_metadata15("design:type", Function),
3260
3303
  _ts_metadata15("design:paramtypes", [
3261
3304
  typeof Request === "undefined" ? Object : Request,
@@ -3265,9 +3308,9 @@ _ts_decorate15([
3265
3308
  _ts_metadata15("design:returntype", Promise)
3266
3309
  ], ThreadsController.prototype, "update", null);
3267
3310
  _ts_decorate15([
3268
- (0, import_common15.Post)(":id/promote"),
3269
- _ts_param14(0, (0, import_common15.Req)()),
3270
- _ts_param14(1, (0, import_common15.Param)("id")),
3311
+ (0, import_common16.Post)(":id/promote"),
3312
+ _ts_param14(0, (0, import_common16.Req)()),
3313
+ _ts_param14(1, (0, import_common16.Param)("id")),
3271
3314
  _ts_metadata15("design:type", Function),
3272
3315
  _ts_metadata15("design:paramtypes", [
3273
3316
  typeof Request === "undefined" ? Object : Request,
@@ -3276,10 +3319,10 @@ _ts_decorate15([
3276
3319
  _ts_metadata15("design:returntype", Promise)
3277
3320
  ], ThreadsController.prototype, "promote", null);
3278
3321
  _ts_decorate15([
3279
- (0, import_common15.Delete)(":id/from/:messageId"),
3280
- _ts_param14(0, (0, import_common15.Req)()),
3281
- _ts_param14(1, (0, import_common15.Param)("id")),
3282
- _ts_param14(2, (0, import_common15.Param)("messageId")),
3322
+ (0, import_common16.Delete)(":id/from/:messageId"),
3323
+ _ts_param14(0, (0, import_common16.Req)()),
3324
+ _ts_param14(1, (0, import_common16.Param)("id")),
3325
+ _ts_param14(2, (0, import_common16.Param)("messageId")),
3283
3326
  _ts_metadata15("design:type", Function),
3284
3327
  _ts_metadata15("design:paramtypes", [
3285
3328
  typeof Request === "undefined" ? Object : Request,
@@ -3289,8 +3332,8 @@ _ts_decorate15([
3289
3332
  _ts_metadata15("design:returntype", Promise)
3290
3333
  ], ThreadsController.prototype, "truncateFrom", null);
3291
3334
  ThreadsController = _ts_decorate15([
3292
- (0, import_common15.Controller)("threads"),
3293
- _ts_param14(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
3335
+ (0, import_common16.Controller)("threads"),
3336
+ _ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
3294
3337
  _ts_metadata15("design:type", Function),
3295
3338
  _ts_metadata15("design:paramtypes", [
3296
3339
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3299,8 +3342,8 @@ ThreadsController = _ts_decorate15([
3299
3342
  ], ThreadsController);
3300
3343
 
3301
3344
  // src/controller/tool-call.controller.ts
3302
- var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
3303
- var import_common16 = require("@nestjs/common");
3345
+ var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
3346
+ var import_common17 = require("@nestjs/common");
3304
3347
  function _ts_decorate16(decorators, target, key, desc) {
3305
3348
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3306
3349
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3335,7 +3378,7 @@ var MAX_VIA_LENGTH = 64;
3335
3378
  var DEFAULT_VIA = "web";
3336
3379
  function toolCallId(claimed) {
3337
3380
  if (typeof claimed !== "string" || claimed.length === 0) {
3338
- throw new import_common16.BadRequestException("toolCallId must be a non-empty string");
3381
+ throw new import_common17.BadRequestException("toolCallId must be a non-empty string");
3339
3382
  }
3340
3383
  return claimed;
3341
3384
  }
@@ -3345,10 +3388,10 @@ function rejectReason(claimed) {
3345
3388
  return void 0;
3346
3389
  }
3347
3390
  if (typeof claimed !== "string") {
3348
- throw new import_common16.BadRequestException("reason must be a string");
3391
+ throw new import_common17.BadRequestException("reason must be a string");
3349
3392
  }
3350
3393
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
3351
- throw new import_common16.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
3394
+ throw new import_common17.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
3352
3395
  }
3353
3396
  return claimed;
3354
3397
  }
@@ -3358,7 +3401,7 @@ function remember(claimed) {
3358
3401
  return false;
3359
3402
  }
3360
3403
  if (typeof claimed !== "boolean") {
3361
- throw new import_common16.BadRequestException("remember must be a boolean");
3404
+ throw new import_common17.BadRequestException("remember must be a boolean");
3362
3405
  }
3363
3406
  return claimed;
3364
3407
  }
@@ -3368,7 +3411,7 @@ function via(claimed) {
3368
3411
  return DEFAULT_VIA;
3369
3412
  }
3370
3413
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
3371
- throw new import_common16.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
3414
+ throw new import_common17.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
3372
3415
  }
3373
3416
  return claimed;
3374
3417
  }
@@ -3378,26 +3421,26 @@ function answers(claimed) {
3378
3421
  return void 0;
3379
3422
  }
3380
3423
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
3381
- throw new import_common16.BadRequestException("answers must be an object of questionId \u2192 chosen values");
3424
+ throw new import_common17.BadRequestException("answers must be an object of questionId \u2192 chosen values");
3382
3425
  }
3383
3426
  const entries = Object.entries(claimed);
3384
3427
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
3385
- throw new import_common16.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
3428
+ throw new import_common17.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
3386
3429
  }
3387
3430
  const validated = /* @__PURE__ */ Object.create(null);
3388
3431
  for (const [questionId, values] of entries) {
3389
3432
  if (!Array.isArray(values)) {
3390
- throw new import_common16.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
3433
+ throw new import_common17.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
3391
3434
  }
3392
3435
  if (values.length > MAX_VALUES_PER_QUESTION) {
3393
- throw new import_common16.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
3436
+ throw new import_common17.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
3394
3437
  }
3395
3438
  for (const value of values) {
3396
3439
  if (typeof value !== "string") {
3397
- throw new import_common16.BadRequestException(`answers["${questionId}"] must contain only strings`);
3440
+ throw new import_common17.BadRequestException(`answers["${questionId}"] must contain only strings`);
3398
3441
  }
3399
3442
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
3400
- throw new import_common16.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
3443
+ throw new import_common17.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
3401
3444
  }
3402
3445
  }
3403
3446
  validated[questionId] = values;
@@ -3460,9 +3503,9 @@ var ToolCallController = class {
3460
3503
  }
3461
3504
  };
3462
3505
  _ts_decorate16([
3463
- (0, import_common16.Post)("approve"),
3464
- _ts_param15(0, (0, import_common16.Req)()),
3465
- _ts_param15(1, (0, import_common16.Body)()),
3506
+ (0, import_common17.Post)("approve"),
3507
+ _ts_param15(0, (0, import_common17.Req)()),
3508
+ _ts_param15(1, (0, import_common17.Body)()),
3466
3509
  _ts_metadata16("design:type", Function),
3467
3510
  _ts_metadata16("design:paramtypes", [
3468
3511
  typeof Request === "undefined" ? Object : Request,
@@ -3471,9 +3514,9 @@ _ts_decorate16([
3471
3514
  _ts_metadata16("design:returntype", Promise)
3472
3515
  ], ToolCallController.prototype, "approve", null);
3473
3516
  _ts_decorate16([
3474
- (0, import_common16.Post)("reject"),
3475
- _ts_param15(0, (0, import_common16.Req)()),
3476
- _ts_param15(1, (0, import_common16.Body)()),
3517
+ (0, import_common17.Post)("reject"),
3518
+ _ts_param15(0, (0, import_common17.Req)()),
3519
+ _ts_param15(1, (0, import_common17.Body)()),
3477
3520
  _ts_metadata16("design:type", Function),
3478
3521
  _ts_metadata16("design:paramtypes", [
3479
3522
  typeof Request === "undefined" ? Object : Request,
@@ -3482,9 +3525,9 @@ _ts_decorate16([
3482
3525
  _ts_metadata16("design:returntype", Promise)
3483
3526
  ], ToolCallController.prototype, "reject", null);
3484
3527
  _ts_decorate16([
3485
- (0, import_common16.Post)("answer"),
3486
- _ts_param15(0, (0, import_common16.Req)()),
3487
- _ts_param15(1, (0, import_common16.Body)()),
3528
+ (0, import_common17.Post)("answer"),
3529
+ _ts_param15(0, (0, import_common17.Req)()),
3530
+ _ts_param15(1, (0, import_common17.Body)()),
3488
3531
  _ts_metadata16("design:type", Function),
3489
3532
  _ts_metadata16("design:paramtypes", [
3490
3533
  typeof Request === "undefined" ? Object : Request,
@@ -3493,9 +3536,9 @@ _ts_decorate16([
3493
3536
  _ts_metadata16("design:returntype", Promise)
3494
3537
  ], ToolCallController.prototype, "answer", null);
3495
3538
  _ts_decorate16([
3496
- (0, import_common16.Post)("skip"),
3497
- _ts_param15(0, (0, import_common16.Req)()),
3498
- _ts_param15(1, (0, import_common16.Body)()),
3539
+ (0, import_common17.Post)("skip"),
3540
+ _ts_param15(0, (0, import_common17.Req)()),
3541
+ _ts_param15(1, (0, import_common17.Body)()),
3499
3542
  _ts_metadata16("design:type", Function),
3500
3543
  _ts_metadata16("design:paramtypes", [
3501
3544
  typeof Request === "undefined" ? Object : Request,
@@ -3504,8 +3547,8 @@ _ts_decorate16([
3504
3547
  _ts_metadata16("design:returntype", Promise)
3505
3548
  ], ToolCallController.prototype, "skip", null);
3506
3549
  ToolCallController = _ts_decorate16([
3507
- (0, import_common16.Controller)("tool-call"),
3508
- _ts_param15(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
3550
+ (0, import_common17.Controller)("tool-call"),
3551
+ _ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
3509
3552
  _ts_metadata16("design:type", Function),
3510
3553
  _ts_metadata16("design:paramtypes", [
3511
3554
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3514,8 +3557,8 @@ ToolCallController = _ts_decorate16([
3514
3557
  ], ToolCallController);
3515
3558
 
3516
3559
  // src/controller/tools.controller.ts
3517
- var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
3518
- var import_common17 = require("@nestjs/common");
3560
+ var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
3561
+ var import_common18 = require("@nestjs/common");
3519
3562
  function _ts_decorate17(decorators, target, key, desc) {
3520
3563
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3521
3564
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3555,11 +3598,11 @@ var ToolsController = class {
3555
3598
  this.agents = agents;
3556
3599
  }
3557
3600
  async list(req, agent) {
3558
- if (agent !== void 0 && agent !== import_nestjs_agent_core17.ALL_AGENTS && this.agents.get(agent) === void 0) {
3559
- throw new import_common17.NotFoundException(`No agent named "${agent}"`);
3601
+ if (agent !== void 0 && agent !== import_nestjs_agent_core18.ALL_AGENTS && this.agents.get(agent) === void 0) {
3602
+ throw new import_common18.NotFoundException(`No agent named "${agent}"`);
3560
3603
  }
3561
3604
  const actor = await this.actorResolver.resolve(req);
3562
- const names = agent === import_nestjs_agent_core17.ALL_AGENTS ? [
3605
+ const names = agent === import_nestjs_agent_core18.ALL_AGENTS ? [
3563
3606
  void 0,
3564
3607
  ...this.agents.list().map((definition) => definition.name)
3565
3608
  ] : [
@@ -3586,9 +3629,9 @@ var ToolsController = class {
3586
3629
  }
3587
3630
  };
3588
3631
  _ts_decorate17([
3589
- (0, import_common17.Get)(),
3590
- _ts_param16(0, (0, import_common17.Req)()),
3591
- _ts_param16(1, (0, import_common17.Query)("agent")),
3632
+ (0, import_common18.Get)(),
3633
+ _ts_param16(0, (0, import_common18.Req)()),
3634
+ _ts_param16(1, (0, import_common18.Query)("agent")),
3592
3635
  _ts_metadata17("design:type", Function),
3593
3636
  _ts_metadata17("design:paramtypes", [
3594
3637
  typeof Request === "undefined" ? Object : Request,
@@ -3597,21 +3640,21 @@ _ts_decorate17([
3597
3640
  _ts_metadata17("design:returntype", Promise)
3598
3641
  ], ToolsController.prototype, "list", null);
3599
3642
  ToolsController = _ts_decorate17([
3600
- (0, import_common17.Controller)("tools"),
3601
- _ts_param16(0, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
3602
- _ts_param16(1, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_DEPS_FACTORY)),
3603
- _ts_param16(2, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_REGISTRY)),
3643
+ (0, import_common18.Controller)("tools"),
3644
+ _ts_param16(0, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
3645
+ _ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_DEPS_FACTORY)),
3646
+ _ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_REGISTRY)),
3604
3647
  _ts_metadata17("design:type", Function),
3605
3648
  _ts_metadata17("design:paramtypes", [
3606
3649
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3607
3650
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
3608
- typeof import_nestjs_agent_core17.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core17.AgentRegistry
3651
+ typeof import_nestjs_agent_core18.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core18.AgentRegistry
3609
3652
  ])
3610
3653
  ], ToolsController);
3611
3654
 
3612
3655
  // src/discovery/agent-discovery.service.ts
3613
- var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
3614
- var import_common18 = require("@nestjs/common");
3656
+ var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3657
+ var import_common19 = require("@nestjs/common");
3615
3658
  var import_core = require("@nestjs/core");
3616
3659
 
3617
3660
  // src/decorator/agent.decorator.ts
@@ -3680,7 +3723,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
3680
3723
  scanner;
3681
3724
  registry;
3682
3725
  contributors;
3683
- logger = new import_common18.Logger(_AgentDiscoveryService.name);
3726
+ logger = new import_common19.Logger(_AgentDiscoveryService.name);
3684
3727
  constructor(discovery, scanner, registry, contributors) {
3685
3728
  this.discovery = discovery;
3686
3729
  this.scanner = scanner;
@@ -3799,21 +3842,21 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
3799
3842
  }
3800
3843
  };
3801
3844
  AgentDiscoveryService = _ts_decorate18([
3802
- (0, import_common18.Injectable)(),
3803
- _ts_param17(2, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_REGISTRY)),
3804
- _ts_param17(3, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_PROMPT_CONTRIBUTORS)),
3845
+ (0, import_common19.Injectable)(),
3846
+ _ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
3847
+ _ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_PROMPT_CONTRIBUTORS)),
3805
3848
  _ts_metadata18("design:type", Function),
3806
3849
  _ts_metadata18("design:paramtypes", [
3807
3850
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
3808
3851
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
3809
- typeof import_nestjs_agent_core18.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core18.AgentRegistry,
3852
+ typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry,
3810
3853
  Array
3811
3854
  ])
3812
3855
  ], AgentDiscoveryService);
3813
3856
 
3814
3857
  // src/discovery/ai-tool-discovery.service.ts
3815
- var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3816
- var import_common19 = require("@nestjs/common");
3858
+ var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3859
+ var import_common20 = require("@nestjs/common");
3817
3860
  var import_core2 = require("@nestjs/core");
3818
3861
  var import_zod = require("zod");
3819
3862
 
@@ -3918,7 +3961,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3918
3961
  registry;
3919
3962
  agents;
3920
3963
  options;
3921
- logger = new import_common19.Logger(_AiToolDiscoveryService.name);
3964
+ logger = new import_common20.Logger(_AiToolDiscoveryService.name);
3922
3965
  constructor(discovery, registry, agents, options) {
3923
3966
  this.discovery = discovery;
3924
3967
  this.registry = registry;
@@ -4003,7 +4046,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4003
4046
  let delegates = 0;
4004
4047
  for (const definition of this.agents.list()) {
4005
4048
  for (const edge of definition.delegatesTo ?? []) {
4006
- const { agent: target, detached } = (0, import_nestjs_agent_core19.normalizeDelegation)(edge);
4049
+ const { agent: target, detached } = (0, import_nestjs_agent_core20.normalizeDelegation)(edge);
4007
4050
  const targetDefinition = this.agents.get(target);
4008
4051
  if (targetDefinition === void 0) {
4009
4052
  throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
@@ -4054,10 +4097,10 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4054
4097
  }
4055
4098
  };
4056
4099
  AiToolDiscoveryService = _ts_decorate19([
4057
- (0, import_common19.Injectable)(),
4058
- _ts_param18(1, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_TOOL_REGISTRY)),
4059
- _ts_param18(2, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
4060
- _ts_param18(3, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_OPTIONS)),
4100
+ (0, import_common20.Injectable)(),
4101
+ _ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_TOOL_REGISTRY)),
4102
+ _ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
4103
+ _ts_param18(3, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
4061
4104
  _ts_metadata19("design:type", Function),
4062
4105
  _ts_metadata19("design:paramtypes", [
4063
4106
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
@@ -4068,13 +4111,13 @@ AiToolDiscoveryService = _ts_decorate19([
4068
4111
  ], AiToolDiscoveryService);
4069
4112
 
4070
4113
  // src/discovery/skill-discovery.service.ts
4071
- var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
4072
- var import_common20 = require("@nestjs/common");
4114
+ var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
4115
+ var import_common21 = require("@nestjs/common");
4073
4116
  var import_core3 = require("@nestjs/core");
4074
4117
 
4075
4118
  // src/decorator/skill.decorator.ts
4076
4119
  var import_reflect_metadata4 = require("reflect-metadata");
4077
- var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
4120
+ var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
4078
4121
  var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
4079
4122
  function Skill(options) {
4080
4123
  return (target) => {
@@ -4087,7 +4130,7 @@ function readSkillMetadata(target) {
4087
4130
  }
4088
4131
  __name(readSkillMetadata, "readSkillMetadata");
4089
4132
  function skillScope(options) {
4090
- return options.scope ?? import_nestjs_agent_core20.GLOBAL_SCOPE;
4133
+ return options.scope ?? import_nestjs_agent_core21.GLOBAL_SCOPE;
4091
4134
  }
4092
4135
  __name(skillScope, "skillScope");
4093
4136
 
@@ -4124,7 +4167,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
4124
4167
  }
4125
4168
  discovery;
4126
4169
  declared;
4127
- logger = new import_common20.Logger(_SkillDiscoveryService.name);
4170
+ logger = new import_common21.Logger(_SkillDiscoveryService.name);
4128
4171
  constructor(discovery, declared) {
4129
4172
  this.discovery = discovery;
4130
4173
  this.declared = declared;
@@ -4162,8 +4205,8 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
4162
4205
  }
4163
4206
  };
4164
4207
  SkillDiscoveryService = _ts_decorate20([
4165
- (0, import_common20.Injectable)(),
4166
- _ts_param19(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_SKILL_SOURCES)),
4208
+ (0, import_common21.Injectable)(),
4209
+ _ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_SKILL_SOURCES)),
4167
4210
  _ts_metadata20("design:type", Function),
4168
4211
  _ts_metadata20("design:paramtypes", [
4169
4212
  typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
@@ -4172,7 +4215,7 @@ SkillDiscoveryService = _ts_decorate20([
4172
4215
  ], SkillDiscoveryService);
4173
4216
 
4174
4217
  // src/in-process-sink.ts
4175
- var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
4218
+ var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
4176
4219
  var InProcessTokenStreamSink = class {
4177
4220
  static {
4178
4221
  __name(this, "InProcessTokenStreamSink");
@@ -4227,7 +4270,7 @@ var InProcessTokenStreamSink = class {
4227
4270
  }
4228
4271
  if (buf.ended) {
4229
4272
  if (buf.failure !== void 0) {
4230
- throw new import_nestjs_agent_core22.AgentStreamError(buf.failure);
4273
+ throw new import_nestjs_agent_core23.AgentStreamError(buf.failure);
4231
4274
  }
4232
4275
  return;
4233
4276
  }
@@ -4240,7 +4283,7 @@ var InProcessTokenStreamSink = class {
4240
4283
  };
4241
4284
 
4242
4285
  // src/ledger-quota-provider.ts
4243
- var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
4286
+ var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
4244
4287
  var LedgerQuotaProvider = class {
4245
4288
  static {
4246
4289
  __name(this, "LedgerQuotaProvider");
@@ -4260,12 +4303,12 @@ var LedgerQuotaProvider = class {
4260
4303
  await this.dayWindow(actorRef, now)
4261
4304
  ];
4262
4305
  if (this.store.usageBetween !== void 0) {
4263
- const range = (0, import_nestjs_agent_core23.quotaPeriodRange)("month", now);
4306
+ const range = (0, import_nestjs_agent_core24.quotaPeriodRange)("month", now);
4264
4307
  const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
4265
4308
  windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
4266
4309
  }
4267
- const blocked = (0, import_nestjs_agent_core23.exhaustedWindow)(windows);
4268
- const warning = (0, import_nestjs_agent_core23.quotaWarning)(windows);
4310
+ const blocked = (0, import_nestjs_agent_core24.exhaustedWindow)(windows);
4311
+ const warning = (0, import_nestjs_agent_core24.quotaWarning)(windows);
4269
4312
  return {
4270
4313
  windows,
4271
4314
  ...blocked !== void 0 ? {
@@ -4277,7 +4320,7 @@ var LedgerQuotaProvider = class {
4277
4320
  };
4278
4321
  }
4279
4322
  async dayWindow(actorRef, now) {
4280
- const range = (0, import_nestjs_agent_core23.quotaPeriodRange)("day", now);
4323
+ const range = (0, import_nestjs_agent_core24.quotaPeriodRange)("day", now);
4281
4324
  const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
4282
4325
  return this.window("day", usedTokens, costUsd, range.resetsAt);
4283
4326
  }
@@ -4301,9 +4344,12 @@ var LedgerQuotaProvider = class {
4301
4344
  }
4302
4345
  };
4303
4346
 
4347
+ // src/queue/chat-queue.token.ts
4348
+ var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
4349
+
4304
4350
  // src/runner/inline-agent-runner.ts
4305
- var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
4306
- var import_common21 = require("@nestjs/common");
4351
+ var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
4352
+ var import_common22 = require("@nestjs/common");
4307
4353
  function _ts_decorate21(decorators, target, key, desc) {
4308
4354
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4309
4355
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -4337,7 +4383,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4337
4383
  factory;
4338
4384
  store;
4339
4385
  queue;
4340
- logger = new import_common21.Logger(_InlineAgentRunner.name);
4386
+ logger = new import_common22.Logger(_InlineAgentRunner.name);
4341
4387
  pending = /* @__PURE__ */ new Map();
4342
4388
  /**
4343
4389
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -4357,7 +4403,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
4357
4403
  * that was running it is gone (a restart), and a thread it still holds is a stale claim.
4358
4404
  */
4359
4405
  async isRunActive(runId) {
4360
- return this.live.has(runId);
4406
+ if (this.live.has(runId)) {
4407
+ return true;
4408
+ }
4409
+ for (const key of this.pending.keys()) {
4410
+ if (key.startsWith(`${runId}:`)) {
4411
+ return true;
4412
+ }
4413
+ }
4414
+ return false;
4361
4415
  }
4362
4416
  async start(input, options = {}) {
4363
4417
  const runId = options.runId ?? crypto.randomUUID();
@@ -4378,18 +4432,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
4378
4432
  ],
4379
4433
  input
4380
4434
  });
4381
- void (0, import_nestjs_agent_core24.runAgentLoop)({
4435
+ void (0, import_nestjs_agent_core25.runAgentLoop)({
4382
4436
  ...deps,
4383
4437
  day
4384
- }, input, hooks).then(() => (0, import_nestjs_agent_core24.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
4385
- if (error instanceof import_nestjs_agent_core24.RunCancelledError) {
4438
+ }, input, hooks).then(() => (0, import_nestjs_agent_core25.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
4439
+ if (error instanceof import_nestjs_agent_core25.RunCancelledError) {
4386
4440
  await this.settleCancelled(runId, input, deps);
4387
4441
  return;
4388
4442
  }
4389
4443
  const message = error instanceof Error ? error.message : String(error);
4390
- const code = (0, import_nestjs_agent_core24.agentFailureCode)(error);
4444
+ const code = (0, import_nestjs_agent_core25.agentFailureCode)(error);
4391
4445
  this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
4392
- (0, import_nestjs_agent_core24.publishAgentRunFailed)({
4446
+ (0, import_nestjs_agent_core25.publishAgentRunFailed)({
4393
4447
  runId,
4394
4448
  code,
4395
4449
  message
@@ -4400,13 +4454,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
4400
4454
  errorCode: code,
4401
4455
  errorMessage: message
4402
4456
  });
4457
+ await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core25.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
4403
4458
  const writer = await deps.sink.open(runId);
4404
4459
  await this.settleQueue(writer, input, runId, "failed", message);
4405
- await (0, import_nestjs_agent_core24.releaseThreadRun)(this.store, input.threadId, runId);
4406
- await writer.fail({
4407
- code,
4408
- message
4409
- });
4460
+ await (0, import_nestjs_agent_core25.releaseThreadRun)(this.store, input.threadId, runId);
4461
+ await writer.fail((0, import_nestjs_agent_core25.streamFailure)(error));
4410
4462
  }).finally(() => {
4411
4463
  this.cancelled.delete(runId);
4412
4464
  this.live.delete(runId);
@@ -4442,7 +4494,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4442
4494
  for (const [key, waiter] of this.pending) {
4443
4495
  if (key.startsWith(`${runId}:`)) {
4444
4496
  this.pending.delete(key);
4445
- waiter.reject(new import_nestjs_agent_core24.RunCancelledError());
4497
+ waiter.reject(new import_nestjs_agent_core25.RunCancelledError());
4446
4498
  }
4447
4499
  }
4448
4500
  await Promise.resolve();
@@ -4457,8 +4509,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
4457
4509
  this.logger.log(`agent run ${runId} cancelled`);
4458
4510
  const writer = await deps.sink.open(runId);
4459
4511
  await this.settleQueue(writer, input, runId, "cancelled");
4460
- await (0, import_nestjs_agent_core24.releaseThreadRun)(this.store, input.threadId, runId);
4461
- await writer.write((0, import_nestjs_agent_core24.encodeStreamEvent)({
4512
+ await (0, import_nestjs_agent_core25.releaseThreadRun)(this.store, input.threadId, runId);
4513
+ await writer.write((0, import_nestjs_agent_core25.encodeStreamEvent)({
4462
4514
  kind: "cancelled"
4463
4515
  }));
4464
4516
  await writer.end();
@@ -4493,7 +4545,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4493
4545
  runId: nextRunId
4494
4546
  }));
4495
4547
  if (frame !== void 0) {
4496
- await writer.write((0, import_nestjs_agent_core24.encodeStreamEvent)(frame));
4548
+ await writer.write((0, import_nestjs_agent_core25.encodeStreamEvent)(frame));
4497
4549
  }
4498
4550
  } catch (failure) {
4499
4551
  this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
@@ -4564,7 +4616,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4564
4616
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
4565
4617
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
4566
4618
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
4567
- parallel: import_nestjs_agent_core24.settleAll,
4619
+ parallel: import_nestjs_agent_core25.settleAll,
4568
4620
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
4569
4621
  runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
4570
4622
  agentName,
@@ -4615,7 +4667,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4615
4667
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
4616
4668
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
4617
4669
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
4618
- parallel: import_nestjs_agent_core24.settleAll,
4670
+ parallel: import_nestjs_agent_core25.settleAll,
4619
4671
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
4620
4672
  runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
4621
4673
  agentName: childName,
@@ -4648,7 +4700,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4648
4700
  }
4649
4701
  }), "startAgent")
4650
4702
  };
4651
- void (0, import_nestjs_agent_core24.runAgentLoop)({
4703
+ void (0, import_nestjs_agent_core25.runAgentLoop)({
4652
4704
  ...deps,
4653
4705
  day
4654
4706
  }, {
@@ -4662,13 +4714,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
4662
4714
  parentRunId,
4663
4715
  deliverTo
4664
4716
  }, hooks).catch(async (error) => {
4665
- const cancelled = error instanceof import_nestjs_agent_core24.RunCancelledError;
4717
+ const cancelled = error instanceof import_nestjs_agent_core25.RunCancelledError;
4666
4718
  const message = error instanceof Error ? error.message : String(error);
4667
4719
  if (!cancelled) {
4668
4720
  this.logger.error(`detached agent run ${runId} failed: ${message}`);
4669
- (0, import_nestjs_agent_core24.publishAgentRunFailed)({
4721
+ (0, import_nestjs_agent_core25.publishAgentRunFailed)({
4670
4722
  runId,
4671
- code: (0, import_nestjs_agent_core24.agentFailureCode)(error),
4723
+ code: (0, import_nestjs_agent_core25.agentFailureCode)(error),
4672
4724
  message
4673
4725
  });
4674
4726
  }
@@ -4676,11 +4728,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
4676
4728
  runId,
4677
4729
  status: cancelled ? "cancelled" : "failed",
4678
4730
  ...cancelled ? {} : {
4679
- errorCode: (0, import_nestjs_agent_core24.agentFailureCode)(error),
4731
+ errorCode: (0, import_nestjs_agent_core25.agentFailureCode)(error),
4680
4732
  errorMessage: message
4681
4733
  }
4682
4734
  });
4683
- await (0, import_nestjs_agent_core24.settleUnsettledDelegation)({
4735
+ await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core25.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
4736
+ await (0, import_nestjs_agent_core25.settleUnsettledDelegation)({
4684
4737
  store: this.store,
4685
4738
  delivery: deliverTo,
4686
4739
  agent: agentName,
@@ -4719,7 +4772,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4719
4772
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
4720
4773
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
4721
4774
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
4722
- parallel: import_nestjs_agent_core24.settleAll,
4775
+ parallel: import_nestjs_agent_core25.settleAll,
4723
4776
  // A child stops when it is cancelled OR when the run a human is actually watching is: the
4724
4777
  // canceller names the top-level run, which is the only id that ever left the server.
4725
4778
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
@@ -4754,7 +4807,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4754
4807
  }), "startAgent")
4755
4808
  };
4756
4809
  try {
4757
- return await (0, import_nestjs_agent_core24.runAgentLoop)({
4810
+ return await (0, import_nestjs_agent_core25.runAgentLoop)({
4758
4811
  ...deps,
4759
4812
  day
4760
4813
  }, {
@@ -4774,10 +4827,10 @@ var InlineAgentRunner = class _InlineAgentRunner {
4774
4827
  }
4775
4828
  };
4776
4829
  InlineAgentRunner = _ts_decorate21([
4777
- (0, import_common21.Injectable)(),
4778
- _ts_param20(0, (0, import_common21.Inject)(import_nestjs_agent_core24.AGENT_DEPS_FACTORY)),
4779
- _ts_param20(1, (0, import_common21.Inject)(import_nestjs_agent_core24.AGENT_STORE)),
4780
- _ts_param20(2, (0, import_common21.Optional)()),
4830
+ (0, import_common22.Injectable)(),
4831
+ _ts_param20(0, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_DEPS_FACTORY)),
4832
+ _ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_STORE)),
4833
+ _ts_param20(2, (0, import_common22.Optional)()),
4781
4834
  _ts_metadata21("design:type", Function),
4782
4835
  _ts_metadata21("design:paramtypes", [
4783
4836
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
@@ -4791,7 +4844,7 @@ function isThreadTurn(input) {
4791
4844
  __name(isThreadTurn, "isThreadTurn");
4792
4845
 
4793
4846
  // src/skills-config.ts
4794
- var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
4847
+ var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
4795
4848
  function declaredSkillProvider(declared) {
4796
4849
  return {
4797
4850
  list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
@@ -4817,7 +4870,7 @@ function resolveSkillsConfig(options, declared) {
4817
4870
  declaredSkillProvider(declared)
4818
4871
  ];
4819
4872
  return {
4820
- provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core25.compositeSkillProvider)(providers),
4873
+ provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core26.compositeSkillProvider)(providers),
4821
4874
  ...options.scopes !== void 0 ? {
4822
4875
  scopes: options.scopes
4823
4876
  } : {},
@@ -4844,11 +4897,11 @@ function _ts_decorate22(decorators, target, key, desc) {
4844
4897
  }
4845
4898
  __name(_ts_decorate22, "_ts_decorate");
4846
4899
  var DEFAULT_PATH = "agent";
4847
- var logger = new import_common22.Logger("AgentModule");
4900
+ var logger = new import_common23.Logger("AgentModule");
4848
4901
  function externalStoreWrapper(modules) {
4849
4902
  for (const module2 of modules.values()) {
4850
4903
  if (module2.metatype === AgentModule) continue;
4851
- const wrapper = module2.providers.get(import_nestjs_agent_core26.AGENT_STORE);
4904
+ const wrapper = module2.providers.get(import_nestjs_agent_core27.AGENT_STORE);
4852
4905
  if (wrapper !== void 0) return wrapper;
4853
4906
  }
4854
4907
  return void 0;
@@ -4879,7 +4932,7 @@ function resolveStore(options, modules) {
4879
4932
  const external = externalStoreWrapper(modules);
4880
4933
  if (external !== void 0) return forwardingStore(external);
4881
4934
  logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
4882
- return new import_nestjs_agent_core26.InMemoryAgentStore();
4935
+ return new import_nestjs_agent_core27.InMemoryAgentStore();
4883
4936
  }
4884
4937
  __name(resolveStore, "resolveStore");
4885
4938
  function isQuotaProvider(quota) {
@@ -4895,99 +4948,99 @@ __name(resolveCatalog, "resolveCatalog");
4895
4948
  function sharedProviders(durable) {
4896
4949
  const providers = [
4897
4950
  {
4898
- provide: import_nestjs_agent_core26.AGENT_TOOL_REGISTRY,
4899
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core26.ToolRegistry(), "useFactory")
4951
+ provide: import_nestjs_agent_core27.AGENT_TOOL_REGISTRY,
4952
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core27.ToolRegistry(), "useFactory")
4900
4953
  },
4901
4954
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
4902
4955
  {
4903
- provide: import_nestjs_agent_core26.AGENT_REGISTRY,
4904
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core26.AgentRegistry(), "useFactory")
4956
+ provide: import_nestjs_agent_core27.AGENT_REGISTRY,
4957
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core27.AgentRegistry(), "useFactory")
4905
4958
  },
4906
4959
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
4907
4960
  {
4908
- provide: import_nestjs_agent_core26.AGENT_PROMPT_CONTRIBUTORS,
4961
+ provide: import_nestjs_agent_core27.AGENT_PROMPT_CONTRIBUTORS,
4909
4962
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
4910
4963
  },
4911
4964
  // Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
4912
4965
  // read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
4913
4966
  {
4914
- provide: import_nestjs_agent_core26.AGENT_SKILL_SOURCES,
4967
+ provide: import_nestjs_agent_core27.AGENT_SKILL_SOURCES,
4915
4968
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
4916
4969
  },
4917
4970
  {
4918
4971
  // One resolution, shared by the loop's deps and the listing endpoint: a second one would
4919
4972
  // drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
4920
4973
  // host configured none — which is what keeps the turn's checkpoint sequence unchanged.
4921
- provide: import_nestjs_agent_core26.AGENT_SKILLS,
4974
+ provide: import_nestjs_agent_core27.AGENT_SKILLS,
4922
4975
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
4923
4976
  inject: [
4924
- import_nestjs_agent_core26.AGENT_OPTIONS,
4925
- import_nestjs_agent_core26.AGENT_SKILL_SOURCES
4977
+ import_nestjs_agent_core27.AGENT_OPTIONS,
4978
+ import_nestjs_agent_core27.AGENT_SKILL_SOURCES
4926
4979
  ]
4927
4980
  },
4928
4981
  {
4929
4982
  // One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
4930
4983
  // shown what the model was shown, and two resolutions would eventually disagree about that.
4931
- provide: import_nestjs_agent_core26.AGENT_MEMORY,
4984
+ provide: import_nestjs_agent_core27.AGENT_MEMORY,
4932
4985
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
4933
4986
  inject: [
4934
- import_nestjs_agent_core26.AGENT_OPTIONS
4987
+ import_nestjs_agent_core27.AGENT_OPTIONS
4935
4988
  ]
4936
4989
  },
4937
4990
  {
4938
- provide: import_nestjs_agent_core26.AGENT_SINK,
4991
+ provide: import_nestjs_agent_core27.AGENT_SINK,
4939
4992
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
4940
4993
  inject: [
4941
- import_nestjs_agent_core26.AGENT_OPTIONS
4994
+ import_nestjs_agent_core27.AGENT_OPTIONS
4942
4995
  ]
4943
4996
  },
4944
4997
  {
4945
- provide: import_nestjs_agent_core26.AGENT_ROLES_POLICY,
4946
- useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core26.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
4998
+ provide: import_nestjs_agent_core27.AGENT_ROLES_POLICY,
4999
+ useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core27.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
4947
5000
  inject: [
4948
- import_nestjs_agent_core26.AGENT_OPTIONS
5001
+ import_nestjs_agent_core27.AGENT_OPTIONS
4949
5002
  ]
4950
5003
  },
4951
5004
  {
4952
- provide: import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER,
5005
+ provide: import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER,
4953
5006
  useFactory: /* @__PURE__ */ __name((options) => {
4954
5007
  if (options.actorResolver !== void 0) return options.actorResolver;
4955
5008
  logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
4956
5009
  return new AnonymousActorResolver();
4957
5010
  }, "useFactory"),
4958
5011
  inject: [
4959
- import_nestjs_agent_core26.AGENT_OPTIONS
5012
+ import_nestjs_agent_core27.AGENT_OPTIONS
4960
5013
  ]
4961
5014
  },
4962
5015
  {
4963
- provide: import_nestjs_agent_core26.AGENT_MODEL,
5016
+ provide: import_nestjs_agent_core27.AGENT_MODEL,
4964
5017
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
4965
5018
  inject: [
4966
- import_nestjs_agent_core26.AGENT_OPTIONS
5019
+ import_nestjs_agent_core27.AGENT_OPTIONS
4967
5020
  ]
4968
5021
  },
4969
5022
  {
4970
5023
  // `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
4971
5024
  // omitted, the ledger provider still reports usage, with no ceiling to block on.
4972
- provide: import_nestjs_agent_core26.AGENT_QUOTA_PROVIDER,
5025
+ provide: import_nestjs_agent_core27.AGENT_QUOTA_PROVIDER,
4973
5026
  useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
4974
5027
  warnAt: o.quota.warnAt
4975
5028
  } : {}), "useFactory"),
4976
5029
  inject: [
4977
- import_nestjs_agent_core26.AGENT_OPTIONS,
4978
- import_nestjs_agent_core26.AGENT_STORE
5030
+ import_nestjs_agent_core27.AGENT_OPTIONS,
5031
+ import_nestjs_agent_core27.AGENT_STORE
4979
5032
  ]
4980
5033
  },
4981
5034
  {
4982
- provide: import_nestjs_agent_core26.AGENT_MODEL_CATALOG,
5035
+ provide: import_nestjs_agent_core27.AGENT_MODEL_CATALOG,
4983
5036
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
4984
5037
  inject: [
4985
- import_nestjs_agent_core26.AGENT_OPTIONS
5038
+ import_nestjs_agent_core27.AGENT_OPTIONS
4986
5039
  ]
4987
5040
  },
4988
5041
  AgentDepsFactory2,
4989
5042
  {
4990
- provide: import_nestjs_agent_core26.AGENT_DEPS_FACTORY,
5043
+ provide: import_nestjs_agent_core27.AGENT_DEPS_FACTORY,
4991
5044
  useExisting: AgentDepsFactory2
4992
5045
  },
4993
5046
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -4998,27 +5051,31 @@ function sharedProviders(durable) {
4998
5051
  // The thread message queue — every surface, since both runners and the durable workflow settle
4999
5052
  // into it, and the chat routes enqueue into it.
5000
5053
  ChatQueueService,
5054
+ {
5055
+ provide: AGENT_CHAT_QUEUE,
5056
+ useExisting: ChatQueueService
5057
+ },
5001
5058
  InlineAgentRunner,
5002
5059
  AgentService,
5003
5060
  // Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
5004
5061
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
5005
5062
  AgentApprovalPortAdapter,
5006
5063
  {
5007
- provide: import_nestjs_agent_core26.AGENT_APPROVAL_PORT,
5064
+ provide: import_nestjs_agent_core27.AGENT_APPROVAL_PORT,
5008
5065
  useExisting: AgentApprovalPortAdapter
5009
5066
  }
5010
5067
  ];
5011
5068
  providers.push({
5012
- provide: import_nestjs_agent_core26.AGENT_STORE,
5069
+ provide: import_nestjs_agent_core27.AGENT_STORE,
5013
5070
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
5014
5071
  inject: [
5015
- import_nestjs_agent_core26.AGENT_OPTIONS,
5072
+ import_nestjs_agent_core27.AGENT_OPTIONS,
5016
5073
  import_core4.ModulesContainer
5017
5074
  ]
5018
5075
  });
5019
5076
  if (durable) {
5020
5077
  providers.push({
5021
- provide: import_nestjs_agent_core26.AGENT_RUNNER,
5078
+ provide: import_nestjs_agent_core27.AGENT_RUNNER,
5022
5079
  useFactory: /* @__PURE__ */ __name((durableRunner) => {
5023
5080
  if (durableRunner === void 0) {
5024
5081
  throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
@@ -5027,14 +5084,14 @@ function sharedProviders(durable) {
5027
5084
  }, "useFactory"),
5028
5085
  inject: [
5029
5086
  {
5030
- token: import_nestjs_agent_core26.AGENT_DURABLE_RUNNER,
5087
+ token: import_nestjs_agent_core27.AGENT_DURABLE_RUNNER,
5031
5088
  optional: true
5032
5089
  }
5033
5090
  ]
5034
5091
  });
5035
5092
  } else {
5036
5093
  providers.push({
5037
- provide: import_nestjs_agent_core26.AGENT_RUNNER,
5094
+ provide: import_nestjs_agent_core27.AGENT_RUNNER,
5038
5095
  useExisting: InlineAgentRunner
5039
5096
  });
5040
5097
  }
@@ -5043,25 +5100,26 @@ function sharedProviders(durable) {
5043
5100
  __name(sharedProviders, "sharedProviders");
5044
5101
  function exportsFor() {
5045
5102
  return [
5046
- import_nestjs_agent_core26.AGENT_OPTIONS,
5047
- import_nestjs_agent_core26.AGENT_TOOL_REGISTRY,
5048
- import_nestjs_agent_core26.AGENT_REGISTRY,
5049
- import_nestjs_agent_core26.AGENT_SINK,
5050
- import_nestjs_agent_core26.AGENT_ROLES_POLICY,
5051
- import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER,
5052
- import_nestjs_agent_core26.AGENT_MODEL,
5053
- import_nestjs_agent_core26.AGENT_STORE,
5054
- import_nestjs_agent_core26.AGENT_MODEL_CATALOG,
5055
- import_nestjs_agent_core26.AGENT_QUOTA_PROVIDER,
5056
- import_nestjs_agent_core26.AGENT_PROMPT_CONTRIBUTORS,
5057
- import_nestjs_agent_core26.AGENT_SKILLS,
5058
- import_nestjs_agent_core26.AGENT_MEMORY,
5059
- import_nestjs_agent_core26.AGENT_DEPS_FACTORY,
5103
+ import_nestjs_agent_core27.AGENT_OPTIONS,
5104
+ import_nestjs_agent_core27.AGENT_TOOL_REGISTRY,
5105
+ import_nestjs_agent_core27.AGENT_REGISTRY,
5106
+ import_nestjs_agent_core27.AGENT_SINK,
5107
+ import_nestjs_agent_core27.AGENT_ROLES_POLICY,
5108
+ import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER,
5109
+ import_nestjs_agent_core27.AGENT_MODEL,
5110
+ import_nestjs_agent_core27.AGENT_STORE,
5111
+ import_nestjs_agent_core27.AGENT_MODEL_CATALOG,
5112
+ import_nestjs_agent_core27.AGENT_QUOTA_PROVIDER,
5113
+ import_nestjs_agent_core27.AGENT_PROMPT_CONTRIBUTORS,
5114
+ import_nestjs_agent_core27.AGENT_SKILLS,
5115
+ import_nestjs_agent_core27.AGENT_MEMORY,
5116
+ import_nestjs_agent_core27.AGENT_DEPS_FACTORY,
5060
5117
  AgentDepsFactory2,
5061
5118
  AgentService,
5062
5119
  ChatQueueService,
5120
+ AGENT_CHAT_QUEUE,
5063
5121
  InlineAgentRunner,
5064
- import_nestjs_agent_core26.AGENT_APPROVAL_PORT
5122
+ import_nestjs_agent_core27.AGENT_APPROVAL_PORT
5065
5123
  ];
5066
5124
  }
5067
5125
  __name(exportsFor, "exportsFor");
@@ -5125,7 +5183,7 @@ var AgentModule = class _AgentModule {
5125
5183
  controllers: controllersForSurface(options.surface),
5126
5184
  providers: [
5127
5185
  {
5128
- provide: import_nestjs_agent_core26.AGENT_OPTIONS,
5186
+ provide: import_nestjs_agent_core27.AGENT_OPTIONS,
5129
5187
  useValue: options
5130
5188
  },
5131
5189
  ...sharedProviders(options.durable ?? false),
@@ -5148,7 +5206,7 @@ var AgentModule = class _AgentModule {
5148
5206
  controllers: controllersForSurface(options.surface),
5149
5207
  providers: [
5150
5208
  {
5151
- provide: import_nestjs_agent_core26.AGENT_OPTIONS,
5209
+ provide: import_nestjs_agent_core27.AGENT_OPTIONS,
5152
5210
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
5153
5211
  // authoritative on the async config object (they decided the actual wiring above), and
5154
5212
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -5170,12 +5228,12 @@ var AgentModule = class _AgentModule {
5170
5228
  }
5171
5229
  };
5172
5230
  AgentModule = _ts_decorate22([
5173
- (0, import_common22.Global)(),
5174
- (0, import_common22.Module)({})
5231
+ (0, import_common23.Global)(),
5232
+ (0, import_common23.Module)({})
5175
5233
  ], AgentModule);
5176
5234
 
5177
5235
  // src/resolver/header-actor-resolver.ts
5178
- var import_common23 = require("@nestjs/common");
5236
+ var import_common24 = require("@nestjs/common");
5179
5237
  function readHeader(req, name) {
5180
5238
  if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
5181
5239
  const { headers } = req;
@@ -5191,7 +5249,7 @@ var HeaderActorResolver = class {
5191
5249
  resolve(req) {
5192
5250
  const id = readHeader(req, "x-actor-id");
5193
5251
  if (id === void 0 || id.length === 0) {
5194
- throw new import_common23.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
5252
+ throw new import_common24.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
5195
5253
  }
5196
5254
  const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
5197
5255
  const tenantRef = readHeader(req, "x-tenant-ref");
@@ -5206,7 +5264,7 @@ var HeaderActorResolver = class {
5206
5264
  };
5207
5265
 
5208
5266
  // src/resolver/request-user-actor-resolver.ts
5209
- var import_common24 = require("@nestjs/common");
5267
+ var import_common25 = require("@nestjs/common");
5210
5268
  function field(user, ...names) {
5211
5269
  for (const name of names) {
5212
5270
  const value = user[name];
@@ -5218,7 +5276,7 @@ __name(field, "field");
5218
5276
  function defaultRequestUserMapper(user) {
5219
5277
  const id = field(user, "id", "sub", "_id", "userId");
5220
5278
  if (id === void 0) {
5221
- throw new import_common24.UnauthorizedException("requestUserActorResolver: req.user has no id/sub/_id/userId \u2014 pass a mapper: requestUserActorResolver((user) => ({ id: \u2026, roles: \u2026 }))");
5279
+ throw new import_common25.UnauthorizedException("requestUserActorResolver: req.user has no id/sub/_id/userId \u2014 pass a mapper: requestUserActorResolver((user) => ({ id: \u2026, roles: \u2026 }))");
5222
5280
  }
5223
5281
  const rawRoles = field(user, "roles", "role");
5224
5282
  const roles = Array.isArray(rawRoles) ? rawRoles.map(String) : typeof rawRoles === "string" ? [
@@ -5239,7 +5297,7 @@ function requestUserActorResolver(map) {
5239
5297
  async resolve(req) {
5240
5298
  const user = typeof req === "object" && req !== null ? req.user : void 0;
5241
5299
  if (user === void 0 || user === null || user === false) {
5242
- throw new import_common24.UnauthorizedException("Sign in to use the agent.");
5300
+ throw new import_common25.UnauthorizedException("Sign in to use the agent.");
5243
5301
  }
5244
5302
  if (map !== void 0) return map(user, req);
5245
5303
  return defaultRequestUserMapper(user);
@@ -5252,6 +5310,7 @@ __name(requestUserActorResolver, "requestUserActorResolver");
5252
5310
  __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports);
5253
5311
  // Annotate the CommonJS export names for ESM import in node:
5254
5312
  0 && (module.exports = {
5313
+ AGENT_CHAT_QUEUE,
5255
5314
  AGENT_METADATA,
5256
5315
  AGENT_TOOL_BRAND,
5257
5316
  AI_TOOL_METADATA,
@@ -5279,6 +5338,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
5279
5338
  MessagesController,
5280
5339
  ModelsController,
5281
5340
  QueueController,
5341
+ RunNotActiveException,
5282
5342
  SKILL_METADATA,
5283
5343
  SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
5284
5344
  SYSTEM_PROMPT_METADATA,