@dudousxd/nestjs-agent 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  InlineAgentRunner: () => InlineAgentRunner,
43
43
  LedgerQuotaStore: () => LedgerQuotaStore,
44
44
  MemoriesController: () => MemoriesController,
45
+ MessagesController: () => MessagesController,
45
46
  SKILL_METADATA: () => SKILL_METADATA,
46
47
  SYSTEM_PROMPT_CONTRIBUTOR_METADATA: () => SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
47
48
  SYSTEM_PROMPT_METADATA: () => SYSTEM_PROMPT_METADATA,
@@ -64,8 +65,8 @@ __export(index_exports, {
64
65
  module.exports = __toCommonJS(index_exports);
65
66
 
66
67
  // src/agent.module.ts
67
- var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
68
- var import_common17 = require("@nestjs/common");
68
+ var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
69
+ var import_common18 = require("@nestjs/common");
69
70
  var import_core4 = require("@nestjs/core");
70
71
 
71
72
  // src/agent-deps.factory.ts
@@ -685,6 +686,40 @@ var AgentService = class {
685
686
  return this.store.truncateFrom(threadId, messageId);
686
687
  }
687
688
  /**
689
+ * Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
690
+ * to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
691
+ * on a store without `threadOfMessage` + `setMessageFeedback`.
692
+ */
693
+ async setMessageFeedback(actor, messageId, input) {
694
+ if (input.value !== null && input.value !== "up" && input.value !== "down") {
695
+ throw new import_common2.BadRequestException("value must be 'up', 'down' or null");
696
+ }
697
+ if (input.comment !== void 0 && typeof input.comment !== "string") {
698
+ throw new import_common2.BadRequestException("comment must be a string");
699
+ }
700
+ const comment = input.comment?.trim();
701
+ if (comment !== void 0 && comment.length > 2e3) {
702
+ throw new import_common2.BadRequestException("comment must be at most 2000 characters");
703
+ }
704
+ if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
705
+ throw new import_common2.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
706
+ }
707
+ const threadId = await this.store.threadOfMessage(messageId);
708
+ if (threadId === null) {
709
+ throw new import_common2.NotFoundException(`message ${messageId} not found`);
710
+ }
711
+ await this.assertOwnsThread(actor, threadId);
712
+ const feedback = input.value === null ? null : {
713
+ value: input.value,
714
+ ...comment !== void 0 && comment.length > 0 ? {
715
+ comment
716
+ } : {},
717
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
718
+ };
719
+ await this.store.setMessageFeedback(messageId, feedback);
720
+ return feedback;
721
+ }
722
+ /**
688
723
  * Every file this actor has staged, newest first — across threads, including uploads that were
689
724
  * never sent, which nothing else on this surface can see.
690
725
  *
@@ -1273,9 +1308,15 @@ var ChatController = class {
1273
1308
  });
1274
1309
  await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
1275
1310
  }
1276
- async stream(req, runId, res) {
1311
+ /**
1312
+ * Attach to a run's stream: every buffered frame, then live ones. `?after=<seq>` (or the SSE
1313
+ * `Last-Event-ID` header a browser `EventSource` sends on its own) skips the frames a reconnecting
1314
+ * client already has — see {@link pipe} for how frames are numbered.
1315
+ */
1316
+ async stream(req, runId, res, after) {
1277
1317
  const actor = await this.actorResolver.resolve(req);
1278
- await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId));
1318
+ const cursor = parseCursor(after) ?? parseCursor(req.headers["last-event-id"]) ?? 0;
1319
+ await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId), void 0, cursor);
1279
1320
  }
1280
1321
  async cancel(req, runId) {
1281
1322
  const actor = await this.actorResolver.resolve(req);
@@ -1284,7 +1325,15 @@ var ChatController = class {
1284
1325
  aborted: true
1285
1326
  };
1286
1327
  }
1287
- async pipe(res, runId, events, threadId) {
1328
+ /**
1329
+ * Every `data:` frame carries an SSE `id:` — its 1-based sequence number within the run. The
1330
+ * number is a pure function of the run's buffered stream (every sink replays a run from its first
1331
+ * chunk, in write order), so the same frame gets the same number on the POST that started the run
1332
+ * and on any later `GET …/stream`, whichever replica serves it. A reconnecting client passes the
1333
+ * last one it saw as `?after=`; frames at or below it are read off the sink but not re-sent.
1334
+ * `meta`, `done` and `error` carry no id: `meta` is re-sent on every attach, the terminals once.
1335
+ */
1336
+ async pipe(res, runId, events, threadId, after = 0) {
1288
1337
  res.setHeader("Content-Type", "text/event-stream");
1289
1338
  res.setHeader("Cache-Control", "no-cache");
1290
1339
  res.setHeader("Connection", "keep-alive");
@@ -1301,6 +1350,16 @@ data: ${JSON.stringify({
1301
1350
  `);
1302
1351
  const decoder = new TextDecoder();
1303
1352
  let buffer = "";
1353
+ let seq = 0;
1354
+ const forward = /* @__PURE__ */ __name((line) => {
1355
+ seq += 1;
1356
+ if (seq > after) {
1357
+ res.write(`id: ${seq}
1358
+ data: ${line}
1359
+
1360
+ `);
1361
+ }
1362
+ }, "forward");
1304
1363
  try {
1305
1364
  for await (const chunk of events) {
1306
1365
  buffer += decoder.decode(chunk, {
@@ -1311,17 +1370,13 @@ data: ${JSON.stringify({
1311
1370
  const line = buffer.slice(0, newline);
1312
1371
  buffer = buffer.slice(newline + 1);
1313
1372
  if (line.length > 0) {
1314
- res.write(`data: ${line}
1315
-
1316
- `);
1373
+ forward(line);
1317
1374
  }
1318
1375
  newline = buffer.indexOf("\n");
1319
1376
  }
1320
1377
  }
1321
1378
  if (buffer.length > 0) {
1322
- res.write(`data: ${buffer}
1323
-
1324
- `);
1379
+ forward(buffer);
1325
1380
  }
1326
1381
  res.write("event: done\ndata: {}\n\n");
1327
1382
  } catch (error) {
@@ -1358,11 +1413,13 @@ _ts_decorate6([
1358
1413
  _ts_param5(0, (0, import_common6.Req)()),
1359
1414
  _ts_param5(1, (0, import_common6.Param)("runId")),
1360
1415
  _ts_param5(2, (0, import_common6.Res)()),
1416
+ _ts_param5(3, (0, import_common6.Query)("after")),
1361
1417
  _ts_metadata6("design:type", Function),
1362
1418
  _ts_metadata6("design:paramtypes", [
1363
1419
  typeof Request === "undefined" ? Object : Request,
1364
1420
  String,
1365
- typeof Response === "undefined" ? Object : Response
1421
+ typeof Response === "undefined" ? Object : Response,
1422
+ String
1366
1423
  ]),
1367
1424
  _ts_metadata6("design:returntype", Promise)
1368
1425
  ], ChatController.prototype, "stream", null);
@@ -1386,6 +1443,15 @@ ChatController = _ts_decorate6([
1386
1443
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1387
1444
  ])
1388
1445
  ], ChatController);
1446
+ function parseCursor(raw) {
1447
+ const value = Array.isArray(raw) ? raw[0] : raw;
1448
+ if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
1449
+ return void 0;
1450
+ }
1451
+ const parsed = Number(value.trim());
1452
+ return Number.isSafeInteger(parsed) ? parsed : void 0;
1453
+ }
1454
+ __name(parseCursor, "parseCursor");
1389
1455
 
1390
1456
  // src/controller/memories.controller.ts
1391
1457
  var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
@@ -1522,7 +1588,7 @@ MemoriesController = _ts_decorate7([
1522
1588
  ])
1523
1589
  ], MemoriesController);
1524
1590
 
1525
- // src/controller/quota.controller.ts
1591
+ // src/controller/messages.controller.ts
1526
1592
  var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
1527
1593
  var import_common8 = require("@nestjs/common");
1528
1594
  function _ts_decorate8(decorators, target, key, desc) {
@@ -1551,9 +1617,9 @@ function _ts_param7(paramIndex, decorator) {
1551
1617
  };
1552
1618
  }
1553
1619
  __name(_ts_param7, "_ts_param");
1554
- var QuotaController = class {
1620
+ var MessagesController = class {
1555
1621
  static {
1556
- __name(this, "QuotaController");
1622
+ __name(this, "MessagesController");
1557
1623
  }
1558
1624
  agent;
1559
1625
  actorResolver;
@@ -1561,31 +1627,48 @@ var QuotaController = class {
1561
1627
  this.agent = agent;
1562
1628
  this.actorResolver = actorResolver;
1563
1629
  }
1564
- async today(req) {
1630
+ /**
1631
+ * Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
1632
+ * (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
1633
+ */
1634
+ async feedback(req, id, body) {
1565
1635
  const actor = await this.actorResolver.resolve(req);
1566
- return this.agent.quotaToday(actor.id);
1636
+ const feedback = await this.agent.setMessageFeedback(actor, id, {
1637
+ value: body?.value ?? null,
1638
+ ...body?.comment !== void 0 ? {
1639
+ comment: body.comment
1640
+ } : {}
1641
+ });
1642
+ return {
1643
+ feedback
1644
+ };
1567
1645
  }
1568
1646
  };
1569
1647
  _ts_decorate8([
1570
- (0, import_common8.Get)("today"),
1648
+ (0, import_common8.Post)(":id/feedback"),
1649
+ (0, import_common8.HttpCode)(200),
1571
1650
  _ts_param7(0, (0, import_common8.Req)()),
1651
+ _ts_param7(1, (0, import_common8.Param)("id")),
1652
+ _ts_param7(2, (0, import_common8.Body)()),
1572
1653
  _ts_metadata8("design:type", Function),
1573
1654
  _ts_metadata8("design:paramtypes", [
1574
- typeof Request === "undefined" ? Object : Request
1655
+ typeof Request === "undefined" ? Object : Request,
1656
+ String,
1657
+ typeof FeedbackBody === "undefined" ? Object : FeedbackBody
1575
1658
  ]),
1576
1659
  _ts_metadata8("design:returntype", Promise)
1577
- ], QuotaController.prototype, "today", null);
1578
- QuotaController = _ts_decorate8([
1579
- (0, import_common8.Controller)("quota"),
1660
+ ], MessagesController.prototype, "feedback", null);
1661
+ MessagesController = _ts_decorate8([
1662
+ (0, import_common8.Controller)("messages"),
1580
1663
  _ts_param7(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_ACTOR_RESOLVER)),
1581
1664
  _ts_metadata8("design:type", Function),
1582
1665
  _ts_metadata8("design:paramtypes", [
1583
1666
  typeof AgentService === "undefined" ? Object : AgentService,
1584
1667
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1585
1668
  ])
1586
- ], QuotaController);
1669
+ ], MessagesController);
1587
1670
 
1588
- // src/controller/skills.controller.ts
1671
+ // src/controller/quota.controller.ts
1589
1672
  var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
1590
1673
  var import_common9 = require("@nestjs/common");
1591
1674
  function _ts_decorate9(decorators, target, key, desc) {
@@ -1614,6 +1697,69 @@ function _ts_param8(paramIndex, decorator) {
1614
1697
  };
1615
1698
  }
1616
1699
  __name(_ts_param8, "_ts_param");
1700
+ var QuotaController = class {
1701
+ static {
1702
+ __name(this, "QuotaController");
1703
+ }
1704
+ agent;
1705
+ actorResolver;
1706
+ constructor(agent, actorResolver) {
1707
+ this.agent = agent;
1708
+ this.actorResolver = actorResolver;
1709
+ }
1710
+ async today(req) {
1711
+ const actor = await this.actorResolver.resolve(req);
1712
+ return this.agent.quotaToday(actor.id);
1713
+ }
1714
+ };
1715
+ _ts_decorate9([
1716
+ (0, import_common9.Get)("today"),
1717
+ _ts_param8(0, (0, import_common9.Req)()),
1718
+ _ts_metadata9("design:type", Function),
1719
+ _ts_metadata9("design:paramtypes", [
1720
+ typeof Request === "undefined" ? Object : Request
1721
+ ]),
1722
+ _ts_metadata9("design:returntype", Promise)
1723
+ ], QuotaController.prototype, "today", null);
1724
+ QuotaController = _ts_decorate9([
1725
+ (0, import_common9.Controller)("quota"),
1726
+ _ts_param8(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
1727
+ _ts_metadata9("design:type", Function),
1728
+ _ts_metadata9("design:paramtypes", [
1729
+ typeof AgentService === "undefined" ? Object : AgentService,
1730
+ typeof ActorResolver === "undefined" ? Object : ActorResolver
1731
+ ])
1732
+ ], QuotaController);
1733
+
1734
+ // src/controller/skills.controller.ts
1735
+ var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
1736
+ var import_common10 = require("@nestjs/common");
1737
+ function _ts_decorate10(decorators, target, key, desc) {
1738
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1739
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1740
+ r = Reflect.decorate(decorators, target, key, desc);
1741
+ } else {
1742
+ for (var i = decorators.length - 1; i >= 0; i--) {
1743
+ if (d = decorators[i]) {
1744
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1745
+ }
1746
+ }
1747
+ }
1748
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1749
+ }
1750
+ __name(_ts_decorate10, "_ts_decorate");
1751
+ function _ts_metadata10(metadataKey, metadataValue) {
1752
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1753
+ return Reflect.metadata(metadataKey, metadataValue);
1754
+ }
1755
+ }
1756
+ __name(_ts_metadata10, "_ts_metadata");
1757
+ function _ts_param9(paramIndex, decorator) {
1758
+ return function(target, key) {
1759
+ decorator(target, key, paramIndex);
1760
+ };
1761
+ }
1762
+ __name(_ts_param9, "_ts_param");
1617
1763
  var SkillsController = class {
1618
1764
  static {
1619
1765
  __name(this, "SkillsController");
@@ -1629,40 +1775,40 @@ var SkillsController = class {
1629
1775
  return [];
1630
1776
  }
1631
1777
  const actor = await this.actorResolver.resolve(req);
1632
- const offer = await (0, import_nestjs_agent_core9.offerSkills)(this.skills, {
1778
+ const offer = await (0, import_nestjs_agent_core10.offerSkills)(this.skills, {
1633
1779
  actor,
1634
1780
  threadId: threadId ?? ""
1635
1781
  });
1636
1782
  return offer.entries;
1637
1783
  }
1638
1784
  };
1639
- _ts_decorate9([
1640
- (0, import_common9.Get)(),
1641
- _ts_param8(0, (0, import_common9.Req)()),
1642
- _ts_param8(1, (0, import_common9.Query)("threadId")),
1643
- _ts_metadata9("design:type", Function),
1644
- _ts_metadata9("design:paramtypes", [
1785
+ _ts_decorate10([
1786
+ (0, import_common10.Get)(),
1787
+ _ts_param9(0, (0, import_common10.Req)()),
1788
+ _ts_param9(1, (0, import_common10.Query)("threadId")),
1789
+ _ts_metadata10("design:type", Function),
1790
+ _ts_metadata10("design:paramtypes", [
1645
1791
  typeof Request === "undefined" ? Object : Request,
1646
1792
  String
1647
1793
  ]),
1648
- _ts_metadata9("design:returntype", Promise)
1794
+ _ts_metadata10("design:returntype", Promise)
1649
1795
  ], SkillsController.prototype, "list", null);
1650
- SkillsController = _ts_decorate9([
1651
- (0, import_common9.Controller)("skills"),
1652
- _ts_param8(0, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
1653
- _ts_param8(1, (0, import_common9.Optional)()),
1654
- _ts_param8(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_SKILLS)),
1655
- _ts_metadata9("design:type", Function),
1656
- _ts_metadata9("design:paramtypes", [
1796
+ SkillsController = _ts_decorate10([
1797
+ (0, import_common10.Controller)("skills"),
1798
+ _ts_param9(0, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
1799
+ _ts_param9(1, (0, import_common10.Optional)()),
1800
+ _ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_SKILLS)),
1801
+ _ts_metadata10("design:type", Function),
1802
+ _ts_metadata10("design:paramtypes", [
1657
1803
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
1658
1804
  Object
1659
1805
  ])
1660
1806
  ], SkillsController);
1661
1807
 
1662
1808
  // src/controller/threads.controller.ts
1663
- var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
1664
- var import_common10 = require("@nestjs/common");
1665
- function _ts_decorate10(decorators, target, key, desc) {
1809
+ var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
1810
+ var import_common11 = require("@nestjs/common");
1811
+ function _ts_decorate11(decorators, target, key, desc) {
1666
1812
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1667
1813
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1668
1814
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1675,19 +1821,19 @@ function _ts_decorate10(decorators, target, key, desc) {
1675
1821
  }
1676
1822
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1677
1823
  }
1678
- __name(_ts_decorate10, "_ts_decorate");
1679
- function _ts_metadata10(metadataKey, metadataValue) {
1824
+ __name(_ts_decorate11, "_ts_decorate");
1825
+ function _ts_metadata11(metadataKey, metadataValue) {
1680
1826
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1681
1827
  return Reflect.metadata(metadataKey, metadataValue);
1682
1828
  }
1683
1829
  }
1684
- __name(_ts_metadata10, "_ts_metadata");
1685
- function _ts_param9(paramIndex, decorator) {
1830
+ __name(_ts_metadata11, "_ts_metadata");
1831
+ function _ts_param10(paramIndex, decorator) {
1686
1832
  return function(target, key) {
1687
1833
  decorator(target, key, paramIndex);
1688
1834
  };
1689
1835
  }
1690
- __name(_ts_param9, "_ts_param");
1836
+ __name(_ts_param10, "_ts_param");
1691
1837
  var ThreadsController = class {
1692
1838
  static {
1693
1839
  __name(this, "ThreadsController");
@@ -1751,101 +1897,101 @@ var ThreadsController = class {
1751
1897
  };
1752
1898
  }
1753
1899
  };
1754
- _ts_decorate10([
1755
- (0, import_common10.Get)(),
1756
- _ts_param9(0, (0, import_common10.Req)()),
1757
- _ts_metadata10("design:type", Function),
1758
- _ts_metadata10("design:paramtypes", [
1900
+ _ts_decorate11([
1901
+ (0, import_common11.Get)(),
1902
+ _ts_param10(0, (0, import_common11.Req)()),
1903
+ _ts_metadata11("design:type", Function),
1904
+ _ts_metadata11("design:paramtypes", [
1759
1905
  typeof Request === "undefined" ? Object : Request
1760
1906
  ]),
1761
- _ts_metadata10("design:returntype", Promise)
1907
+ _ts_metadata11("design:returntype", Promise)
1762
1908
  ], ThreadsController.prototype, "list", null);
1763
- _ts_decorate10([
1764
- (0, import_common10.Get)(":id"),
1765
- _ts_param9(0, (0, import_common10.Req)()),
1766
- _ts_param9(1, (0, import_common10.Param)("id")),
1767
- _ts_metadata10("design:type", Function),
1768
- _ts_metadata10("design:paramtypes", [
1909
+ _ts_decorate11([
1910
+ (0, import_common11.Get)(":id"),
1911
+ _ts_param10(0, (0, import_common11.Req)()),
1912
+ _ts_param10(1, (0, import_common11.Param)("id")),
1913
+ _ts_metadata11("design:type", Function),
1914
+ _ts_metadata11("design:paramtypes", [
1769
1915
  typeof Request === "undefined" ? Object : Request,
1770
1916
  String
1771
1917
  ]),
1772
- _ts_metadata10("design:returntype", Promise)
1918
+ _ts_metadata11("design:returntype", Promise)
1773
1919
  ], ThreadsController.prototype, "detail", null);
1774
- _ts_decorate10([
1775
- (0, import_common10.Delete)(":id"),
1776
- _ts_param9(0, (0, import_common10.Req)()),
1777
- _ts_param9(1, (0, import_common10.Param)("id")),
1778
- _ts_metadata10("design:type", Function),
1779
- _ts_metadata10("design:paramtypes", [
1920
+ _ts_decorate11([
1921
+ (0, import_common11.Delete)(":id"),
1922
+ _ts_param10(0, (0, import_common11.Req)()),
1923
+ _ts_param10(1, (0, import_common11.Param)("id")),
1924
+ _ts_metadata11("design:type", Function),
1925
+ _ts_metadata11("design:paramtypes", [
1780
1926
  typeof Request === "undefined" ? Object : Request,
1781
1927
  String
1782
1928
  ]),
1783
- _ts_metadata10("design:returntype", Promise)
1929
+ _ts_metadata11("design:returntype", Promise)
1784
1930
  ], ThreadsController.prototype, "remove", null);
1785
- _ts_decorate10([
1786
- (0, import_common10.Post)(":id/fork-from/:messageId"),
1787
- _ts_param9(0, (0, import_common10.Req)()),
1788
- _ts_param9(1, (0, import_common10.Param)("id")),
1789
- _ts_param9(2, (0, import_common10.Param)("messageId")),
1790
- _ts_metadata10("design:type", Function),
1791
- _ts_metadata10("design:paramtypes", [
1931
+ _ts_decorate11([
1932
+ (0, import_common11.Post)(":id/fork-from/:messageId"),
1933
+ _ts_param10(0, (0, import_common11.Req)()),
1934
+ _ts_param10(1, (0, import_common11.Param)("id")),
1935
+ _ts_param10(2, (0, import_common11.Param)("messageId")),
1936
+ _ts_metadata11("design:type", Function),
1937
+ _ts_metadata11("design:paramtypes", [
1792
1938
  typeof Request === "undefined" ? Object : Request,
1793
1939
  String,
1794
1940
  String
1795
1941
  ]),
1796
- _ts_metadata10("design:returntype", Promise)
1942
+ _ts_metadata11("design:returntype", Promise)
1797
1943
  ], ThreadsController.prototype, "fork", null);
1798
- _ts_decorate10([
1799
- (0, import_common10.Patch)(":id"),
1800
- _ts_param9(0, (0, import_common10.Req)()),
1801
- _ts_param9(1, (0, import_common10.Param)("id")),
1802
- _ts_param9(2, (0, import_common10.Body)()),
1803
- _ts_metadata10("design:type", Function),
1804
- _ts_metadata10("design:paramtypes", [
1944
+ _ts_decorate11([
1945
+ (0, import_common11.Patch)(":id"),
1946
+ _ts_param10(0, (0, import_common11.Req)()),
1947
+ _ts_param10(1, (0, import_common11.Param)("id")),
1948
+ _ts_param10(2, (0, import_common11.Body)()),
1949
+ _ts_metadata11("design:type", Function),
1950
+ _ts_metadata11("design:paramtypes", [
1805
1951
  typeof Request === "undefined" ? Object : Request,
1806
1952
  String,
1807
1953
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
1808
1954
  ]),
1809
- _ts_metadata10("design:returntype", Promise)
1955
+ _ts_metadata11("design:returntype", Promise)
1810
1956
  ], ThreadsController.prototype, "update", null);
1811
- _ts_decorate10([
1812
- (0, import_common10.Post)(":id/promote"),
1813
- _ts_param9(0, (0, import_common10.Req)()),
1814
- _ts_param9(1, (0, import_common10.Param)("id")),
1815
- _ts_metadata10("design:type", Function),
1816
- _ts_metadata10("design:paramtypes", [
1957
+ _ts_decorate11([
1958
+ (0, import_common11.Post)(":id/promote"),
1959
+ _ts_param10(0, (0, import_common11.Req)()),
1960
+ _ts_param10(1, (0, import_common11.Param)("id")),
1961
+ _ts_metadata11("design:type", Function),
1962
+ _ts_metadata11("design:paramtypes", [
1817
1963
  typeof Request === "undefined" ? Object : Request,
1818
1964
  String
1819
1965
  ]),
1820
- _ts_metadata10("design:returntype", Promise)
1966
+ _ts_metadata11("design:returntype", Promise)
1821
1967
  ], ThreadsController.prototype, "promote", null);
1822
- _ts_decorate10([
1823
- (0, import_common10.Delete)(":id/from/:messageId"),
1824
- _ts_param9(0, (0, import_common10.Req)()),
1825
- _ts_param9(1, (0, import_common10.Param)("id")),
1826
- _ts_param9(2, (0, import_common10.Param)("messageId")),
1827
- _ts_metadata10("design:type", Function),
1828
- _ts_metadata10("design:paramtypes", [
1968
+ _ts_decorate11([
1969
+ (0, import_common11.Delete)(":id/from/:messageId"),
1970
+ _ts_param10(0, (0, import_common11.Req)()),
1971
+ _ts_param10(1, (0, import_common11.Param)("id")),
1972
+ _ts_param10(2, (0, import_common11.Param)("messageId")),
1973
+ _ts_metadata11("design:type", Function),
1974
+ _ts_metadata11("design:paramtypes", [
1829
1975
  typeof Request === "undefined" ? Object : Request,
1830
1976
  String,
1831
1977
  String
1832
1978
  ]),
1833
- _ts_metadata10("design:returntype", Promise)
1979
+ _ts_metadata11("design:returntype", Promise)
1834
1980
  ], ThreadsController.prototype, "truncateFrom", null);
1835
- ThreadsController = _ts_decorate10([
1836
- (0, import_common10.Controller)("threads"),
1837
- _ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
1838
- _ts_metadata10("design:type", Function),
1839
- _ts_metadata10("design:paramtypes", [
1981
+ ThreadsController = _ts_decorate11([
1982
+ (0, import_common11.Controller)("threads"),
1983
+ _ts_param10(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
1984
+ _ts_metadata11("design:type", Function),
1985
+ _ts_metadata11("design:paramtypes", [
1840
1986
  typeof AgentService === "undefined" ? Object : AgentService,
1841
1987
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1842
1988
  ])
1843
1989
  ], ThreadsController);
1844
1990
 
1845
1991
  // src/controller/tool-call.controller.ts
1846
- var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
1847
- var import_common11 = require("@nestjs/common");
1848
- function _ts_decorate11(decorators, target, key, desc) {
1992
+ var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
1993
+ var import_common12 = require("@nestjs/common");
1994
+ function _ts_decorate12(decorators, target, key, desc) {
1849
1995
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1850
1996
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1851
1997
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1858,19 +2004,19 @@ function _ts_decorate11(decorators, target, key, desc) {
1858
2004
  }
1859
2005
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1860
2006
  }
1861
- __name(_ts_decorate11, "_ts_decorate");
1862
- function _ts_metadata11(metadataKey, metadataValue) {
2007
+ __name(_ts_decorate12, "_ts_decorate");
2008
+ function _ts_metadata12(metadataKey, metadataValue) {
1863
2009
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1864
2010
  return Reflect.metadata(metadataKey, metadataValue);
1865
2011
  }
1866
2012
  }
1867
- __name(_ts_metadata11, "_ts_metadata");
1868
- function _ts_param10(paramIndex, decorator) {
2013
+ __name(_ts_metadata12, "_ts_metadata");
2014
+ function _ts_param11(paramIndex, decorator) {
1869
2015
  return function(target, key) {
1870
2016
  decorator(target, key, paramIndex);
1871
2017
  };
1872
2018
  }
1873
- __name(_ts_param10, "_ts_param");
2019
+ __name(_ts_param11, "_ts_param");
1874
2020
  var MAX_ANSWERED_QUESTIONS = 100;
1875
2021
  var MAX_VALUES_PER_QUESTION = 100;
1876
2022
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -1879,7 +2025,7 @@ var MAX_VIA_LENGTH = 64;
1879
2025
  var DEFAULT_VIA = "web";
1880
2026
  function toolCallId(claimed) {
1881
2027
  if (typeof claimed !== "string" || claimed.length === 0) {
1882
- throw new import_common11.BadRequestException("toolCallId must be a non-empty string");
2028
+ throw new import_common12.BadRequestException("toolCallId must be a non-empty string");
1883
2029
  }
1884
2030
  return claimed;
1885
2031
  }
@@ -1889,10 +2035,10 @@ function rejectReason(claimed) {
1889
2035
  return void 0;
1890
2036
  }
1891
2037
  if (typeof claimed !== "string") {
1892
- throw new import_common11.BadRequestException("reason must be a string");
2038
+ throw new import_common12.BadRequestException("reason must be a string");
1893
2039
  }
1894
2040
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
1895
- throw new import_common11.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
2041
+ throw new import_common12.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
1896
2042
  }
1897
2043
  return claimed;
1898
2044
  }
@@ -1902,7 +2048,7 @@ function remember(claimed) {
1902
2048
  return false;
1903
2049
  }
1904
2050
  if (typeof claimed !== "boolean") {
1905
- throw new import_common11.BadRequestException("remember must be a boolean");
2051
+ throw new import_common12.BadRequestException("remember must be a boolean");
1906
2052
  }
1907
2053
  return claimed;
1908
2054
  }
@@ -1912,7 +2058,7 @@ function via(claimed) {
1912
2058
  return DEFAULT_VIA;
1913
2059
  }
1914
2060
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
1915
- throw new import_common11.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
2061
+ throw new import_common12.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
1916
2062
  }
1917
2063
  return claimed;
1918
2064
  }
@@ -1922,26 +2068,26 @@ function answers(claimed) {
1922
2068
  return void 0;
1923
2069
  }
1924
2070
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
1925
- throw new import_common11.BadRequestException("answers must be an object of questionId \u2192 chosen values");
2071
+ throw new import_common12.BadRequestException("answers must be an object of questionId \u2192 chosen values");
1926
2072
  }
1927
2073
  const entries = Object.entries(claimed);
1928
2074
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
1929
- throw new import_common11.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
2075
+ throw new import_common12.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
1930
2076
  }
1931
2077
  const validated = /* @__PURE__ */ Object.create(null);
1932
2078
  for (const [questionId, values] of entries) {
1933
2079
  if (!Array.isArray(values)) {
1934
- throw new import_common11.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
2080
+ throw new import_common12.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
1935
2081
  }
1936
2082
  if (values.length > MAX_VALUES_PER_QUESTION) {
1937
- throw new import_common11.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
2083
+ throw new import_common12.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
1938
2084
  }
1939
2085
  for (const value of values) {
1940
2086
  if (typeof value !== "string") {
1941
- throw new import_common11.BadRequestException(`answers["${questionId}"] must contain only strings`);
2087
+ throw new import_common12.BadRequestException(`answers["${questionId}"] must contain only strings`);
1942
2088
  }
1943
2089
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
1944
- throw new import_common11.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
2090
+ throw new import_common12.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
1945
2091
  }
1946
2092
  }
1947
2093
  validated[questionId] = values;
@@ -1999,64 +2145,64 @@ var ToolCallController = class {
1999
2145
  };
2000
2146
  }
2001
2147
  };
2002
- _ts_decorate11([
2003
- (0, import_common11.Post)("approve"),
2004
- _ts_param10(0, (0, import_common11.Req)()),
2005
- _ts_param10(1, (0, import_common11.Body)()),
2006
- _ts_metadata11("design:type", Function),
2007
- _ts_metadata11("design:paramtypes", [
2148
+ _ts_decorate12([
2149
+ (0, import_common12.Post)("approve"),
2150
+ _ts_param11(0, (0, import_common12.Req)()),
2151
+ _ts_param11(1, (0, import_common12.Body)()),
2152
+ _ts_metadata12("design:type", Function),
2153
+ _ts_metadata12("design:paramtypes", [
2008
2154
  typeof Request === "undefined" ? Object : Request,
2009
2155
  typeof ApproveBody === "undefined" ? Object : ApproveBody
2010
2156
  ]),
2011
- _ts_metadata11("design:returntype", Promise)
2157
+ _ts_metadata12("design:returntype", Promise)
2012
2158
  ], ToolCallController.prototype, "approve", null);
2013
- _ts_decorate11([
2014
- (0, import_common11.Post)("reject"),
2015
- _ts_param10(0, (0, import_common11.Req)()),
2016
- _ts_param10(1, (0, import_common11.Body)()),
2017
- _ts_metadata11("design:type", Function),
2018
- _ts_metadata11("design:paramtypes", [
2159
+ _ts_decorate12([
2160
+ (0, import_common12.Post)("reject"),
2161
+ _ts_param11(0, (0, import_common12.Req)()),
2162
+ _ts_param11(1, (0, import_common12.Body)()),
2163
+ _ts_metadata12("design:type", Function),
2164
+ _ts_metadata12("design:paramtypes", [
2019
2165
  typeof Request === "undefined" ? Object : Request,
2020
2166
  typeof RejectBody === "undefined" ? Object : RejectBody
2021
2167
  ]),
2022
- _ts_metadata11("design:returntype", Promise)
2168
+ _ts_metadata12("design:returntype", Promise)
2023
2169
  ], ToolCallController.prototype, "reject", null);
2024
- _ts_decorate11([
2025
- (0, import_common11.Post)("answer"),
2026
- _ts_param10(0, (0, import_common11.Req)()),
2027
- _ts_param10(1, (0, import_common11.Body)()),
2028
- _ts_metadata11("design:type", Function),
2029
- _ts_metadata11("design:paramtypes", [
2170
+ _ts_decorate12([
2171
+ (0, import_common12.Post)("answer"),
2172
+ _ts_param11(0, (0, import_common12.Req)()),
2173
+ _ts_param11(1, (0, import_common12.Body)()),
2174
+ _ts_metadata12("design:type", Function),
2175
+ _ts_metadata12("design:paramtypes", [
2030
2176
  typeof Request === "undefined" ? Object : Request,
2031
2177
  typeof AnswerBody === "undefined" ? Object : AnswerBody
2032
2178
  ]),
2033
- _ts_metadata11("design:returntype", Promise)
2179
+ _ts_metadata12("design:returntype", Promise)
2034
2180
  ], ToolCallController.prototype, "answer", null);
2035
- _ts_decorate11([
2036
- (0, import_common11.Post)("skip"),
2037
- _ts_param10(0, (0, import_common11.Req)()),
2038
- _ts_param10(1, (0, import_common11.Body)()),
2039
- _ts_metadata11("design:type", Function),
2040
- _ts_metadata11("design:paramtypes", [
2181
+ _ts_decorate12([
2182
+ (0, import_common12.Post)("skip"),
2183
+ _ts_param11(0, (0, import_common12.Req)()),
2184
+ _ts_param11(1, (0, import_common12.Body)()),
2185
+ _ts_metadata12("design:type", Function),
2186
+ _ts_metadata12("design:paramtypes", [
2041
2187
  typeof Request === "undefined" ? Object : Request,
2042
2188
  Object
2043
2189
  ]),
2044
- _ts_metadata11("design:returntype", Promise)
2190
+ _ts_metadata12("design:returntype", Promise)
2045
2191
  ], ToolCallController.prototype, "skip", null);
2046
- ToolCallController = _ts_decorate11([
2047
- (0, import_common11.Controller)("tool-call"),
2048
- _ts_param10(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
2049
- _ts_metadata11("design:type", Function),
2050
- _ts_metadata11("design:paramtypes", [
2192
+ ToolCallController = _ts_decorate12([
2193
+ (0, import_common12.Controller)("tool-call"),
2194
+ _ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
2195
+ _ts_metadata12("design:type", Function),
2196
+ _ts_metadata12("design:paramtypes", [
2051
2197
  typeof AgentService === "undefined" ? Object : AgentService,
2052
2198
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2053
2199
  ])
2054
2200
  ], ToolCallController);
2055
2201
 
2056
2202
  // src/controller/tools.controller.ts
2057
- var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2058
- var import_common12 = require("@nestjs/common");
2059
- function _ts_decorate12(decorators, target, key, desc) {
2203
+ var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2204
+ var import_common13 = require("@nestjs/common");
2205
+ function _ts_decorate13(decorators, target, key, desc) {
2060
2206
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2061
2207
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2062
2208
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2069,19 +2215,19 @@ function _ts_decorate12(decorators, target, key, desc) {
2069
2215
  }
2070
2216
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2071
2217
  }
2072
- __name(_ts_decorate12, "_ts_decorate");
2073
- function _ts_metadata12(metadataKey, metadataValue) {
2218
+ __name(_ts_decorate13, "_ts_decorate");
2219
+ function _ts_metadata13(metadataKey, metadataValue) {
2074
2220
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2075
2221
  return Reflect.metadata(metadataKey, metadataValue);
2076
2222
  }
2077
2223
  }
2078
- __name(_ts_metadata12, "_ts_metadata");
2079
- function _ts_param11(paramIndex, decorator) {
2224
+ __name(_ts_metadata13, "_ts_metadata");
2225
+ function _ts_param12(paramIndex, decorator) {
2080
2226
  return function(target, key) {
2081
2227
  decorator(target, key, paramIndex);
2082
2228
  };
2083
2229
  }
2084
- __name(_ts_param11, "_ts_param");
2230
+ __name(_ts_param12, "_ts_param");
2085
2231
  var ToolsController = class {
2086
2232
  static {
2087
2233
  __name(this, "ToolsController");
@@ -2096,7 +2242,7 @@ var ToolsController = class {
2096
2242
  }
2097
2243
  async list(req, agent) {
2098
2244
  if (agent !== void 0 && this.agents.get(agent) === void 0) {
2099
- throw new import_common12.NotFoundException(`No agent named "${agent}"`);
2245
+ throw new import_common13.NotFoundException(`No agent named "${agent}"`);
2100
2246
  }
2101
2247
  const actor = await this.actorResolver.resolve(req);
2102
2248
  const deps = this.depsFactory.forAgent(agent);
@@ -2110,33 +2256,33 @@ var ToolsController = class {
2110
2256
  }));
2111
2257
  }
2112
2258
  };
2113
- _ts_decorate12([
2114
- (0, import_common12.Get)(),
2115
- _ts_param11(0, (0, import_common12.Req)()),
2116
- _ts_param11(1, (0, import_common12.Query)("agent")),
2117
- _ts_metadata12("design:type", Function),
2118
- _ts_metadata12("design:paramtypes", [
2259
+ _ts_decorate13([
2260
+ (0, import_common13.Get)(),
2261
+ _ts_param12(0, (0, import_common13.Req)()),
2262
+ _ts_param12(1, (0, import_common13.Query)("agent")),
2263
+ _ts_metadata13("design:type", Function),
2264
+ _ts_metadata13("design:paramtypes", [
2119
2265
  typeof Request === "undefined" ? Object : Request,
2120
2266
  String
2121
2267
  ]),
2122
- _ts_metadata12("design:returntype", Promise)
2268
+ _ts_metadata13("design:returntype", Promise)
2123
2269
  ], ToolsController.prototype, "list", null);
2124
- ToolsController = _ts_decorate12([
2125
- (0, import_common12.Controller)("tools"),
2126
- _ts_param11(0, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
2127
- _ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_DEPS_FACTORY)),
2128
- _ts_param11(2, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_REGISTRY)),
2129
- _ts_metadata12("design:type", Function),
2130
- _ts_metadata12("design:paramtypes", [
2270
+ ToolsController = _ts_decorate13([
2271
+ (0, import_common13.Controller)("tools"),
2272
+ _ts_param12(0, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
2273
+ _ts_param12(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_DEPS_FACTORY)),
2274
+ _ts_param12(2, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_REGISTRY)),
2275
+ _ts_metadata13("design:type", Function),
2276
+ _ts_metadata13("design:paramtypes", [
2131
2277
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2132
2278
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
2133
- typeof import_nestjs_agent_core12.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core12.AgentRegistry
2279
+ typeof import_nestjs_agent_core13.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core13.AgentRegistry
2134
2280
  ])
2135
2281
  ], ToolsController);
2136
2282
 
2137
2283
  // src/discovery/agent-discovery.service.ts
2138
- var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2139
- var import_common13 = require("@nestjs/common");
2284
+ var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2285
+ var import_common14 = require("@nestjs/common");
2140
2286
  var import_core = require("@nestjs/core");
2141
2287
 
2142
2288
  // src/decorator/agent.decorator.ts
@@ -2171,7 +2317,7 @@ function SystemPromptContributor() {
2171
2317
  __name(SystemPromptContributor, "SystemPromptContributor");
2172
2318
 
2173
2319
  // src/discovery/agent-discovery.service.ts
2174
- function _ts_decorate13(decorators, target, key, desc) {
2320
+ function _ts_decorate14(decorators, target, key, desc) {
2175
2321
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2176
2322
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2177
2323
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2184,19 +2330,19 @@ function _ts_decorate13(decorators, target, key, desc) {
2184
2330
  }
2185
2331
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2186
2332
  }
2187
- __name(_ts_decorate13, "_ts_decorate");
2188
- function _ts_metadata13(metadataKey, metadataValue) {
2333
+ __name(_ts_decorate14, "_ts_decorate");
2334
+ function _ts_metadata14(metadataKey, metadataValue) {
2189
2335
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2190
2336
  return Reflect.metadata(metadataKey, metadataValue);
2191
2337
  }
2192
2338
  }
2193
- __name(_ts_metadata13, "_ts_metadata");
2194
- function _ts_param12(paramIndex, decorator) {
2339
+ __name(_ts_metadata14, "_ts_metadata");
2340
+ function _ts_param13(paramIndex, decorator) {
2195
2341
  return function(target, key) {
2196
2342
  decorator(target, key, paramIndex);
2197
2343
  };
2198
2344
  }
2199
- __name(_ts_param12, "_ts_param");
2345
+ __name(_ts_param13, "_ts_param");
2200
2346
  var AgentDiscoveryService = class _AgentDiscoveryService {
2201
2347
  static {
2202
2348
  __name(this, "AgentDiscoveryService");
@@ -2205,7 +2351,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
2205
2351
  scanner;
2206
2352
  registry;
2207
2353
  contributors;
2208
- logger = new import_common13.Logger(_AgentDiscoveryService.name);
2354
+ logger = new import_common14.Logger(_AgentDiscoveryService.name);
2209
2355
  constructor(discovery, scanner, registry, contributors) {
2210
2356
  this.discovery = discovery;
2211
2357
  this.scanner = scanner;
@@ -2323,22 +2469,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
2323
2469
  return (ctx) => candidate.call(instance, ctx);
2324
2470
  }
2325
2471
  };
2326
- AgentDiscoveryService = _ts_decorate13([
2327
- (0, import_common13.Injectable)(),
2328
- _ts_param12(2, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_REGISTRY)),
2329
- _ts_param12(3, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_PROMPT_CONTRIBUTORS)),
2330
- _ts_metadata13("design:type", Function),
2331
- _ts_metadata13("design:paramtypes", [
2472
+ AgentDiscoveryService = _ts_decorate14([
2473
+ (0, import_common14.Injectable)(),
2474
+ _ts_param13(2, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
2475
+ _ts_param13(3, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_PROMPT_CONTRIBUTORS)),
2476
+ _ts_metadata14("design:type", Function),
2477
+ _ts_metadata14("design:paramtypes", [
2332
2478
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
2333
2479
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
2334
- typeof import_nestjs_agent_core13.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core13.AgentRegistry,
2480
+ typeof import_nestjs_agent_core14.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core14.AgentRegistry,
2335
2481
  Array
2336
2482
  ])
2337
2483
  ], AgentDiscoveryService);
2338
2484
 
2339
2485
  // src/discovery/ai-tool-discovery.service.ts
2340
- var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2341
- var import_common14 = require("@nestjs/common");
2486
+ var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2487
+ var import_common15 = require("@nestjs/common");
2342
2488
  var import_core2 = require("@nestjs/core");
2343
2489
  var import_zod = require("zod");
2344
2490
 
@@ -2387,7 +2533,7 @@ function provideAgentTool(factoryOrTool, inject) {
2387
2533
  __name(provideAgentTool, "provideAgentTool");
2388
2534
 
2389
2535
  // src/discovery/ai-tool-discovery.service.ts
2390
- function _ts_decorate14(decorators, target, key, desc) {
2536
+ function _ts_decorate15(decorators, target, key, desc) {
2391
2537
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2392
2538
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2393
2539
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2400,19 +2546,19 @@ function _ts_decorate14(decorators, target, key, desc) {
2400
2546
  }
2401
2547
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2402
2548
  }
2403
- __name(_ts_decorate14, "_ts_decorate");
2404
- function _ts_metadata14(metadataKey, metadataValue) {
2549
+ __name(_ts_decorate15, "_ts_decorate");
2550
+ function _ts_metadata15(metadataKey, metadataValue) {
2405
2551
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2406
2552
  return Reflect.metadata(metadataKey, metadataValue);
2407
2553
  }
2408
2554
  }
2409
- __name(_ts_metadata14, "_ts_metadata");
2410
- function _ts_param13(paramIndex, decorator) {
2555
+ __name(_ts_metadata15, "_ts_metadata");
2556
+ function _ts_param14(paramIndex, decorator) {
2411
2557
  return function(target, key) {
2412
2558
  decorator(target, key, paramIndex);
2413
2559
  };
2414
2560
  }
2415
- __name(_ts_param13, "_ts_param");
2561
+ __name(_ts_param14, "_ts_param");
2416
2562
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
2417
2563
  static {
2418
2564
  __name(this, "AiToolDiscoveryService");
@@ -2421,7 +2567,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2421
2567
  registry;
2422
2568
  agents;
2423
2569
  options;
2424
- logger = new import_common14.Logger(_AiToolDiscoveryService.name);
2570
+ logger = new import_common15.Logger(_AiToolDiscoveryService.name);
2425
2571
  constructor(discovery, registry, agents, options) {
2426
2572
  this.discovery = discovery;
2427
2573
  this.registry = registry;
@@ -2495,7 +2641,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2495
2641
  let delegates = 0;
2496
2642
  for (const definition of this.agents.list()) {
2497
2643
  for (const edge of definition.delegatesTo ?? []) {
2498
- const { agent: target, detached } = (0, import_nestjs_agent_core14.normalizeDelegation)(edge);
2644
+ const { agent: target, detached } = (0, import_nestjs_agent_core15.normalizeDelegation)(edge);
2499
2645
  const targetDefinition = this.agents.get(target);
2500
2646
  if (targetDefinition === void 0) {
2501
2647
  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.`);
@@ -2545,13 +2691,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2545
2691
  return true;
2546
2692
  }
2547
2693
  };
2548
- AiToolDiscoveryService = _ts_decorate14([
2549
- (0, import_common14.Injectable)(),
2550
- _ts_param13(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_TOOL_REGISTRY)),
2551
- _ts_param13(2, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
2552
- _ts_param13(3, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
2553
- _ts_metadata14("design:type", Function),
2554
- _ts_metadata14("design:paramtypes", [
2694
+ AiToolDiscoveryService = _ts_decorate15([
2695
+ (0, import_common15.Injectable)(),
2696
+ _ts_param14(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_TOOL_REGISTRY)),
2697
+ _ts_param14(2, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
2698
+ _ts_param14(3, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_OPTIONS)),
2699
+ _ts_metadata15("design:type", Function),
2700
+ _ts_metadata15("design:paramtypes", [
2555
2701
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
2556
2702
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
2557
2703
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -2560,13 +2706,13 @@ AiToolDiscoveryService = _ts_decorate14([
2560
2706
  ], AiToolDiscoveryService);
2561
2707
 
2562
2708
  // src/discovery/skill-discovery.service.ts
2563
- var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2564
- var import_common15 = require("@nestjs/common");
2709
+ var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2710
+ var import_common16 = require("@nestjs/common");
2565
2711
  var import_core3 = require("@nestjs/core");
2566
2712
 
2567
2713
  // src/decorator/skill.decorator.ts
2568
2714
  var import_reflect_metadata4 = require("reflect-metadata");
2569
- var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2715
+ var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2570
2716
  var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
2571
2717
  function Skill(options) {
2572
2718
  return (target) => {
@@ -2579,12 +2725,12 @@ function readSkillMetadata(target) {
2579
2725
  }
2580
2726
  __name(readSkillMetadata, "readSkillMetadata");
2581
2727
  function skillScope(options) {
2582
- return options.scope ?? import_nestjs_agent_core15.GLOBAL_SCOPE;
2728
+ return options.scope ?? import_nestjs_agent_core16.GLOBAL_SCOPE;
2583
2729
  }
2584
2730
  __name(skillScope, "skillScope");
2585
2731
 
2586
2732
  // src/discovery/skill-discovery.service.ts
2587
- function _ts_decorate15(decorators, target, key, desc) {
2733
+ function _ts_decorate16(decorators, target, key, desc) {
2588
2734
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2589
2735
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2590
2736
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2597,26 +2743,26 @@ function _ts_decorate15(decorators, target, key, desc) {
2597
2743
  }
2598
2744
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2599
2745
  }
2600
- __name(_ts_decorate15, "_ts_decorate");
2601
- function _ts_metadata15(metadataKey, metadataValue) {
2746
+ __name(_ts_decorate16, "_ts_decorate");
2747
+ function _ts_metadata16(metadataKey, metadataValue) {
2602
2748
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2603
2749
  return Reflect.metadata(metadataKey, metadataValue);
2604
2750
  }
2605
2751
  }
2606
- __name(_ts_metadata15, "_ts_metadata");
2607
- function _ts_param14(paramIndex, decorator) {
2752
+ __name(_ts_metadata16, "_ts_metadata");
2753
+ function _ts_param15(paramIndex, decorator) {
2608
2754
  return function(target, key) {
2609
2755
  decorator(target, key, paramIndex);
2610
2756
  };
2611
2757
  }
2612
- __name(_ts_param14, "_ts_param");
2758
+ __name(_ts_param15, "_ts_param");
2613
2759
  var SkillDiscoveryService = class _SkillDiscoveryService {
2614
2760
  static {
2615
2761
  __name(this, "SkillDiscoveryService");
2616
2762
  }
2617
2763
  discovery;
2618
2764
  declared;
2619
- logger = new import_common15.Logger(_SkillDiscoveryService.name);
2765
+ logger = new import_common16.Logger(_SkillDiscoveryService.name);
2620
2766
  constructor(discovery, declared) {
2621
2767
  this.discovery = discovery;
2622
2768
  this.declared = declared;
@@ -2653,18 +2799,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
2653
2799
  return flat === void 0 ? void 0 : () => flat;
2654
2800
  }
2655
2801
  };
2656
- SkillDiscoveryService = _ts_decorate15([
2657
- (0, import_common15.Injectable)(),
2658
- _ts_param14(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_SKILL_SOURCES)),
2659
- _ts_metadata15("design:type", Function),
2660
- _ts_metadata15("design:paramtypes", [
2802
+ SkillDiscoveryService = _ts_decorate16([
2803
+ (0, import_common16.Injectable)(),
2804
+ _ts_param15(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_SKILL_SOURCES)),
2805
+ _ts_metadata16("design:type", Function),
2806
+ _ts_metadata16("design:paramtypes", [
2661
2807
  typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
2662
2808
  Array
2663
2809
  ])
2664
2810
  ], SkillDiscoveryService);
2665
2811
 
2666
2812
  // src/in-process-sink.ts
2667
- var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2813
+ var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2668
2814
  var InProcessTokenStreamSink = class {
2669
2815
  static {
2670
2816
  __name(this, "InProcessTokenStreamSink");
@@ -2719,7 +2865,7 @@ var InProcessTokenStreamSink = class {
2719
2865
  }
2720
2866
  if (buf.ended) {
2721
2867
  if (buf.failure !== void 0) {
2722
- throw new import_nestjs_agent_core17.AgentStreamError(buf.failure);
2868
+ throw new import_nestjs_agent_core18.AgentStreamError(buf.failure);
2723
2869
  }
2724
2870
  return;
2725
2871
  }
@@ -2755,9 +2901,9 @@ var LedgerQuotaStore = class {
2755
2901
  };
2756
2902
 
2757
2903
  // src/runner/inline-agent-runner.ts
2758
- var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2759
- var import_common16 = require("@nestjs/common");
2760
- function _ts_decorate16(decorators, target, key, desc) {
2904
+ var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
2905
+ var import_common17 = require("@nestjs/common");
2906
+ function _ts_decorate17(decorators, target, key, desc) {
2761
2907
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2762
2908
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2763
2909
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2770,26 +2916,26 @@ function _ts_decorate16(decorators, target, key, desc) {
2770
2916
  }
2771
2917
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2772
2918
  }
2773
- __name(_ts_decorate16, "_ts_decorate");
2774
- function _ts_metadata16(metadataKey, metadataValue) {
2919
+ __name(_ts_decorate17, "_ts_decorate");
2920
+ function _ts_metadata17(metadataKey, metadataValue) {
2775
2921
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2776
2922
  return Reflect.metadata(metadataKey, metadataValue);
2777
2923
  }
2778
2924
  }
2779
- __name(_ts_metadata16, "_ts_metadata");
2780
- function _ts_param15(paramIndex, decorator) {
2925
+ __name(_ts_metadata17, "_ts_metadata");
2926
+ function _ts_param16(paramIndex, decorator) {
2781
2927
  return function(target, key) {
2782
2928
  decorator(target, key, paramIndex);
2783
2929
  };
2784
2930
  }
2785
- __name(_ts_param15, "_ts_param");
2931
+ __name(_ts_param16, "_ts_param");
2786
2932
  var InlineAgentRunner = class _InlineAgentRunner {
2787
2933
  static {
2788
2934
  __name(this, "InlineAgentRunner");
2789
2935
  }
2790
2936
  factory;
2791
2937
  store;
2792
- logger = new import_common16.Logger(_InlineAgentRunner.name);
2938
+ logger = new import_common17.Logger(_InlineAgentRunner.name);
2793
2939
  pending = /* @__PURE__ */ new Map();
2794
2940
  /**
2795
2941
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -2818,18 +2964,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
2818
2964
  ] : []
2819
2965
  ]
2820
2966
  });
2821
- void (0, import_nestjs_agent_core18.runAgentLoop)({
2967
+ void (0, import_nestjs_agent_core19.runAgentLoop)({
2822
2968
  ...deps,
2823
2969
  day
2824
2970
  }, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
2825
- if (error instanceof import_nestjs_agent_core18.RunCancelledError) {
2971
+ if (error instanceof import_nestjs_agent_core19.RunCancelledError) {
2826
2972
  await this.settleCancelled(runId, input.threadId, deps);
2827
2973
  return;
2828
2974
  }
2829
2975
  const message = error instanceof Error ? error.message : String(error);
2830
- const code = (0, import_nestjs_agent_core18.agentFailureCode)(error);
2976
+ const code = (0, import_nestjs_agent_core19.agentFailureCode)(error);
2831
2977
  this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
2832
- (0, import_nestjs_agent_core18.publishAgentRunFailed)({
2978
+ (0, import_nestjs_agent_core19.publishAgentRunFailed)({
2833
2979
  runId,
2834
2980
  code,
2835
2981
  message
@@ -2878,7 +3024,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
2878
3024
  for (const [key, waiter] of this.pending) {
2879
3025
  if (key.startsWith(`${runId}:`)) {
2880
3026
  this.pending.delete(key);
2881
- waiter.reject(new import_nestjs_agent_core18.RunCancelledError());
3027
+ waiter.reject(new import_nestjs_agent_core19.RunCancelledError());
2882
3028
  }
2883
3029
  }
2884
3030
  await Promise.resolve();
@@ -2893,7 +3039,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
2893
3039
  this.logger.log(`agent run ${runId} cancelled`);
2894
3040
  await this.store.setActiveStream(threadId, null);
2895
3041
  const writer = await deps.sink.open(runId);
2896
- await writer.write((0, import_nestjs_agent_core18.encodeStreamEvent)({
3042
+ await writer.write((0, import_nestjs_agent_core19.encodeStreamEvent)({
2897
3043
  kind: "cancelled"
2898
3044
  }));
2899
3045
  await writer.end();
@@ -2954,7 +3100,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
2954
3100
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
2955
3101
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
2956
3102
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
2957
- parallel: import_nestjs_agent_core18.settleAll,
3103
+ parallel: import_nestjs_agent_core19.settleAll,
2958
3104
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
2959
3105
  runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
2960
3106
  agentName,
@@ -3005,7 +3151,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3005
3151
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3006
3152
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3007
3153
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3008
- parallel: import_nestjs_agent_core18.settleAll,
3154
+ parallel: import_nestjs_agent_core19.settleAll,
3009
3155
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
3010
3156
  runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
3011
3157
  agentName: childName,
@@ -3038,7 +3184,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3038
3184
  }
3039
3185
  }), "startAgent")
3040
3186
  };
3041
- void (0, import_nestjs_agent_core18.runAgentLoop)({
3187
+ void (0, import_nestjs_agent_core19.runAgentLoop)({
3042
3188
  ...deps,
3043
3189
  day
3044
3190
  }, {
@@ -3052,13 +3198,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
3052
3198
  parentRunId,
3053
3199
  deliverTo
3054
3200
  }, hooks).catch(async (error) => {
3055
- const cancelled = error instanceof import_nestjs_agent_core18.RunCancelledError;
3201
+ const cancelled = error instanceof import_nestjs_agent_core19.RunCancelledError;
3056
3202
  const message = error instanceof Error ? error.message : String(error);
3057
3203
  if (!cancelled) {
3058
3204
  this.logger.error(`detached agent run ${runId} failed: ${message}`);
3059
- (0, import_nestjs_agent_core18.publishAgentRunFailed)({
3205
+ (0, import_nestjs_agent_core19.publishAgentRunFailed)({
3060
3206
  runId,
3061
- code: (0, import_nestjs_agent_core18.agentFailureCode)(error),
3207
+ code: (0, import_nestjs_agent_core19.agentFailureCode)(error),
3062
3208
  message
3063
3209
  });
3064
3210
  }
@@ -3066,11 +3212,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
3066
3212
  runId,
3067
3213
  status: cancelled ? "cancelled" : "failed",
3068
3214
  ...cancelled ? {} : {
3069
- errorCode: (0, import_nestjs_agent_core18.agentFailureCode)(error),
3215
+ errorCode: (0, import_nestjs_agent_core19.agentFailureCode)(error),
3070
3216
  errorMessage: message
3071
3217
  }
3072
3218
  });
3073
- await (0, import_nestjs_agent_core18.settleUnsettledDelegation)({
3219
+ await (0, import_nestjs_agent_core19.settleUnsettledDelegation)({
3074
3220
  store: this.store,
3075
3221
  delivery: deliverTo,
3076
3222
  agent: agentName,
@@ -3109,7 +3255,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3109
3255
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3110
3256
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3111
3257
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3112
- parallel: import_nestjs_agent_core18.settleAll,
3258
+ parallel: import_nestjs_agent_core19.settleAll,
3113
3259
  // A child stops when it is cancelled OR when the run a human is actually watching is: the
3114
3260
  // canceller names the top-level run, which is the only id that ever left the server.
3115
3261
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
@@ -3144,7 +3290,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3144
3290
  }), "startAgent")
3145
3291
  };
3146
3292
  try {
3147
- return await (0, import_nestjs_agent_core18.runAgentLoop)({
3293
+ return await (0, import_nestjs_agent_core19.runAgentLoop)({
3148
3294
  ...deps,
3149
3295
  day
3150
3296
  }, {
@@ -3163,19 +3309,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
3163
3309
  }
3164
3310
  }
3165
3311
  };
3166
- InlineAgentRunner = _ts_decorate16([
3167
- (0, import_common16.Injectable)(),
3168
- _ts_param15(0, (0, import_common16.Inject)(import_nestjs_agent_core18.AGENT_DEPS_FACTORY)),
3169
- _ts_param15(1, (0, import_common16.Inject)(import_nestjs_agent_core18.AGENT_STORE)),
3170
- _ts_metadata16("design:type", Function),
3171
- _ts_metadata16("design:paramtypes", [
3312
+ InlineAgentRunner = _ts_decorate17([
3313
+ (0, import_common17.Injectable)(),
3314
+ _ts_param16(0, (0, import_common17.Inject)(import_nestjs_agent_core19.AGENT_DEPS_FACTORY)),
3315
+ _ts_param16(1, (0, import_common17.Inject)(import_nestjs_agent_core19.AGENT_STORE)),
3316
+ _ts_metadata17("design:type", Function),
3317
+ _ts_metadata17("design:paramtypes", [
3172
3318
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
3173
3319
  typeof AgentStore === "undefined" ? Object : AgentStore
3174
3320
  ])
3175
3321
  ], InlineAgentRunner);
3176
3322
 
3177
3323
  // src/skills-config.ts
3178
- var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3324
+ var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3179
3325
  function declaredSkillProvider(declared) {
3180
3326
  return {
3181
3327
  list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
@@ -3201,7 +3347,7 @@ function resolveSkillsConfig(options, declared) {
3201
3347
  declaredSkillProvider(declared)
3202
3348
  ];
3203
3349
  return {
3204
- provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core19.compositeSkillProvider)(providers),
3350
+ provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core20.compositeSkillProvider)(providers),
3205
3351
  ...options.scopes !== void 0 ? {
3206
3352
  scopes: options.scopes
3207
3353
  } : {},
@@ -3213,7 +3359,7 @@ function resolveSkillsConfig(options, declared) {
3213
3359
  __name(resolveSkillsConfig, "resolveSkillsConfig");
3214
3360
 
3215
3361
  // src/agent.module.ts
3216
- function _ts_decorate17(decorators, target, key, desc) {
3362
+ function _ts_decorate18(decorators, target, key, desc) {
3217
3363
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3218
3364
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3219
3365
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3226,92 +3372,92 @@ function _ts_decorate17(decorators, target, key, desc) {
3226
3372
  }
3227
3373
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3228
3374
  }
3229
- __name(_ts_decorate17, "_ts_decorate");
3375
+ __name(_ts_decorate18, "_ts_decorate");
3230
3376
  var DEFAULT_PATH = "agent";
3231
3377
  function sharedProviders(durable, includeStore) {
3232
3378
  const providers = [
3233
3379
  {
3234
- provide: import_nestjs_agent_core20.AGENT_TOOL_REGISTRY,
3235
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core20.ToolRegistry(), "useFactory")
3380
+ provide: import_nestjs_agent_core21.AGENT_TOOL_REGISTRY,
3381
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core21.ToolRegistry(), "useFactory")
3236
3382
  },
3237
3383
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
3238
3384
  {
3239
- provide: import_nestjs_agent_core20.AGENT_REGISTRY,
3240
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core20.AgentRegistry(), "useFactory")
3385
+ provide: import_nestjs_agent_core21.AGENT_REGISTRY,
3386
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core21.AgentRegistry(), "useFactory")
3241
3387
  },
3242
3388
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
3243
3389
  {
3244
- provide: import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS,
3390
+ provide: import_nestjs_agent_core21.AGENT_PROMPT_CONTRIBUTORS,
3245
3391
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
3246
3392
  },
3247
3393
  // Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
3248
3394
  // read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
3249
3395
  {
3250
- provide: import_nestjs_agent_core20.AGENT_SKILL_SOURCES,
3396
+ provide: import_nestjs_agent_core21.AGENT_SKILL_SOURCES,
3251
3397
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
3252
3398
  },
3253
3399
  {
3254
3400
  // One resolution, shared by the loop's deps and the listing endpoint: a second one would
3255
3401
  // drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
3256
3402
  // host configured none — which is what keeps the turn's checkpoint sequence unchanged.
3257
- provide: import_nestjs_agent_core20.AGENT_SKILLS,
3403
+ provide: import_nestjs_agent_core21.AGENT_SKILLS,
3258
3404
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
3259
3405
  inject: [
3260
- import_nestjs_agent_core20.AGENT_OPTIONS,
3261
- import_nestjs_agent_core20.AGENT_SKILL_SOURCES
3406
+ import_nestjs_agent_core21.AGENT_OPTIONS,
3407
+ import_nestjs_agent_core21.AGENT_SKILL_SOURCES
3262
3408
  ]
3263
3409
  },
3264
3410
  {
3265
3411
  // One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
3266
3412
  // shown what the model was shown, and two resolutions would eventually disagree about that.
3267
- provide: import_nestjs_agent_core20.AGENT_MEMORY,
3413
+ provide: import_nestjs_agent_core21.AGENT_MEMORY,
3268
3414
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
3269
3415
  inject: [
3270
- import_nestjs_agent_core20.AGENT_OPTIONS
3416
+ import_nestjs_agent_core21.AGENT_OPTIONS
3271
3417
  ]
3272
3418
  },
3273
3419
  {
3274
- provide: import_nestjs_agent_core20.AGENT_SINK,
3420
+ provide: import_nestjs_agent_core21.AGENT_SINK,
3275
3421
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
3276
3422
  inject: [
3277
- import_nestjs_agent_core20.AGENT_OPTIONS
3423
+ import_nestjs_agent_core21.AGENT_OPTIONS
3278
3424
  ]
3279
3425
  },
3280
3426
  {
3281
- provide: import_nestjs_agent_core20.AGENT_ROLES_POLICY,
3282
- useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core20.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
3427
+ provide: import_nestjs_agent_core21.AGENT_ROLES_POLICY,
3428
+ useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core21.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
3283
3429
  inject: [
3284
- import_nestjs_agent_core20.AGENT_OPTIONS
3430
+ import_nestjs_agent_core21.AGENT_OPTIONS
3285
3431
  ]
3286
3432
  },
3287
3433
  {
3288
- provide: import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER,
3434
+ provide: import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER,
3289
3435
  useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
3290
3436
  inject: [
3291
- import_nestjs_agent_core20.AGENT_OPTIONS
3437
+ import_nestjs_agent_core21.AGENT_OPTIONS
3292
3438
  ]
3293
3439
  },
3294
3440
  {
3295
- provide: import_nestjs_agent_core20.AGENT_MODEL,
3441
+ provide: import_nestjs_agent_core21.AGENT_MODEL,
3296
3442
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
3297
3443
  inject: [
3298
- import_nestjs_agent_core20.AGENT_OPTIONS
3444
+ import_nestjs_agent_core21.AGENT_OPTIONS
3299
3445
  ]
3300
3446
  },
3301
3447
  {
3302
3448
  // An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
3303
3449
  // store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
3304
3450
  // the loop already writes, so enforcement needs no extra shared state across replicas.
3305
- provide: import_nestjs_agent_core20.AGENT_QUOTA_STORE,
3451
+ provide: import_nestjs_agent_core21.AGENT_QUOTA_STORE,
3306
3452
  useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
3307
3453
  inject: [
3308
- import_nestjs_agent_core20.AGENT_OPTIONS,
3309
- import_nestjs_agent_core20.AGENT_STORE
3454
+ import_nestjs_agent_core21.AGENT_OPTIONS,
3455
+ import_nestjs_agent_core21.AGENT_STORE
3310
3456
  ]
3311
3457
  },
3312
3458
  AgentDepsFactory2,
3313
3459
  {
3314
- provide: import_nestjs_agent_core20.AGENT_DEPS_FACTORY,
3460
+ provide: import_nestjs_agent_core21.AGENT_DEPS_FACTORY,
3315
3461
  useExisting: AgentDepsFactory2
3316
3462
  },
3317
3463
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -3325,22 +3471,22 @@ function sharedProviders(durable, includeStore) {
3325
3471
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
3326
3472
  AgentApprovalPortAdapter,
3327
3473
  {
3328
- provide: import_nestjs_agent_core20.AGENT_APPROVAL_PORT,
3474
+ provide: import_nestjs_agent_core21.AGENT_APPROVAL_PORT,
3329
3475
  useExisting: AgentApprovalPortAdapter
3330
3476
  }
3331
3477
  ];
3332
3478
  if (includeStore) {
3333
3479
  providers.push({
3334
- provide: import_nestjs_agent_core20.AGENT_STORE,
3480
+ provide: import_nestjs_agent_core21.AGENT_STORE,
3335
3481
  useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
3336
3482
  inject: [
3337
- import_nestjs_agent_core20.AGENT_OPTIONS
3483
+ import_nestjs_agent_core21.AGENT_OPTIONS
3338
3484
  ]
3339
3485
  });
3340
3486
  }
3341
3487
  if (durable) {
3342
3488
  providers.push({
3343
- provide: import_nestjs_agent_core20.AGENT_RUNNER,
3489
+ provide: import_nestjs_agent_core21.AGENT_RUNNER,
3344
3490
  useFactory: /* @__PURE__ */ __name((durableRunner) => {
3345
3491
  if (durableRunner === void 0) {
3346
3492
  throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
@@ -3349,14 +3495,14 @@ function sharedProviders(durable, includeStore) {
3349
3495
  }, "useFactory"),
3350
3496
  inject: [
3351
3497
  {
3352
- token: import_nestjs_agent_core20.AGENT_DURABLE_RUNNER,
3498
+ token: import_nestjs_agent_core21.AGENT_DURABLE_RUNNER,
3353
3499
  optional: true
3354
3500
  }
3355
3501
  ]
3356
3502
  });
3357
3503
  } else {
3358
3504
  providers.push({
3359
- provide: import_nestjs_agent_core20.AGENT_RUNNER,
3505
+ provide: import_nestjs_agent_core21.AGENT_RUNNER,
3360
3506
  useExisting: InlineAgentRunner
3361
3507
  });
3362
3508
  }
@@ -3365,25 +3511,25 @@ function sharedProviders(durable, includeStore) {
3365
3511
  __name(sharedProviders, "sharedProviders");
3366
3512
  function exportsFor(includeStore) {
3367
3513
  return [
3368
- import_nestjs_agent_core20.AGENT_OPTIONS,
3369
- import_nestjs_agent_core20.AGENT_TOOL_REGISTRY,
3370
- import_nestjs_agent_core20.AGENT_REGISTRY,
3371
- import_nestjs_agent_core20.AGENT_SINK,
3372
- import_nestjs_agent_core20.AGENT_ROLES_POLICY,
3373
- import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER,
3374
- import_nestjs_agent_core20.AGENT_MODEL,
3514
+ import_nestjs_agent_core21.AGENT_OPTIONS,
3515
+ import_nestjs_agent_core21.AGENT_TOOL_REGISTRY,
3516
+ import_nestjs_agent_core21.AGENT_REGISTRY,
3517
+ import_nestjs_agent_core21.AGENT_SINK,
3518
+ import_nestjs_agent_core21.AGENT_ROLES_POLICY,
3519
+ import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER,
3520
+ import_nestjs_agent_core21.AGENT_MODEL,
3375
3521
  ...includeStore ? [
3376
- import_nestjs_agent_core20.AGENT_STORE
3522
+ import_nestjs_agent_core21.AGENT_STORE
3377
3523
  ] : [],
3378
- import_nestjs_agent_core20.AGENT_QUOTA_STORE,
3379
- import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS,
3380
- import_nestjs_agent_core20.AGENT_SKILLS,
3381
- import_nestjs_agent_core20.AGENT_MEMORY,
3382
- import_nestjs_agent_core20.AGENT_DEPS_FACTORY,
3524
+ import_nestjs_agent_core21.AGENT_QUOTA_STORE,
3525
+ import_nestjs_agent_core21.AGENT_PROMPT_CONTRIBUTORS,
3526
+ import_nestjs_agent_core21.AGENT_SKILLS,
3527
+ import_nestjs_agent_core21.AGENT_MEMORY,
3528
+ import_nestjs_agent_core21.AGENT_DEPS_FACTORY,
3383
3529
  AgentDepsFactory2,
3384
3530
  AgentService,
3385
3531
  InlineAgentRunner,
3386
- import_nestjs_agent_core20.AGENT_APPROVAL_PORT
3532
+ import_nestjs_agent_core21.AGENT_APPROVAL_PORT
3387
3533
  ];
3388
3534
  }
3389
3535
  __name(exportsFor, "exportsFor");
@@ -3395,7 +3541,8 @@ var BASE_CONTROLLERS = [
3395
3541
  AgentsController,
3396
3542
  SkillsController,
3397
3543
  MemoriesController,
3398
- ToolsController
3544
+ ToolsController,
3545
+ MessagesController
3399
3546
  ];
3400
3547
  var GUARDABLE_CONTROLLERS = [
3401
3548
  ...BASE_CONTROLLERS,
@@ -3453,7 +3600,7 @@ var AgentModule = class _AgentModule {
3453
3600
  controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
3454
3601
  providers: [
3455
3602
  {
3456
- provide: import_nestjs_agent_core20.AGENT_OPTIONS,
3603
+ provide: import_nestjs_agent_core21.AGENT_OPTIONS,
3457
3604
  useValue: options
3458
3605
  },
3459
3606
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -3477,7 +3624,7 @@ var AgentModule = class _AgentModule {
3477
3624
  controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
3478
3625
  providers: [
3479
3626
  {
3480
- provide: import_nestjs_agent_core20.AGENT_OPTIONS,
3627
+ provide: import_nestjs_agent_core21.AGENT_OPTIONS,
3481
3628
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
3482
3629
  // authoritative on the async config object (they decided the actual wiring above), and
3483
3630
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -3498,13 +3645,13 @@ var AgentModule = class _AgentModule {
3498
3645
  };
3499
3646
  }
3500
3647
  };
3501
- AgentModule = _ts_decorate17([
3502
- (0, import_common17.Global)(),
3503
- (0, import_common17.Module)({})
3648
+ AgentModule = _ts_decorate18([
3649
+ (0, import_common18.Global)(),
3650
+ (0, import_common18.Module)({})
3504
3651
  ], AgentModule);
3505
3652
 
3506
3653
  // src/resolver/header-actor-resolver.ts
3507
- var import_common18 = require("@nestjs/common");
3654
+ var import_common19 = require("@nestjs/common");
3508
3655
  function readHeader(req, name) {
3509
3656
  if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
3510
3657
  const { headers } = req;
@@ -3520,7 +3667,7 @@ var HeaderActorResolver = class {
3520
3667
  resolve(req) {
3521
3668
  const id = readHeader(req, "x-actor-id");
3522
3669
  if (id === void 0 || id.length === 0) {
3523
- throw new import_common18.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.");
3670
+ throw new import_common19.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.");
3524
3671
  }
3525
3672
  const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
3526
3673
  const tenantRef = readHeader(req, "x-tenant-ref");
@@ -3558,6 +3705,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
3558
3705
  InlineAgentRunner,
3559
3706
  LedgerQuotaStore,
3560
3707
  MemoriesController,
3708
+ MessagesController,
3561
3709
  SKILL_METADATA,
3562
3710
  SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
3563
3711
  SYSTEM_PROMPT_METADATA,