@dudousxd/nestjs-agent 1.6.0 → 1.8.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
@@ -40,9 +40,11 @@ __export(index_exports, {
40
40
  HeaderActorResolver: () => HeaderActorResolver,
41
41
  InProcessTokenStreamSink: () => InProcessTokenStreamSink,
42
42
  InlineAgentRunner: () => InlineAgentRunner,
43
+ LedgerQuotaProvider: () => LedgerQuotaProvider,
43
44
  LedgerQuotaStore: () => LedgerQuotaStore,
44
45
  MemoriesController: () => MemoriesController,
45
46
  MessagesController: () => MessagesController,
47
+ ModelsController: () => ModelsController,
46
48
  SKILL_METADATA: () => SKILL_METADATA,
47
49
  SYSTEM_PROMPT_CONTRIBUTOR_METADATA: () => SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
48
50
  SYSTEM_PROMPT_METADATA: () => SYSTEM_PROMPT_METADATA,
@@ -65,8 +67,8 @@ __export(index_exports, {
65
67
  module.exports = __toCommonJS(index_exports);
66
68
 
67
69
  // src/agent.module.ts
68
- var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
69
- var import_common18 = require("@nestjs/common");
70
+ var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
71
+ var import_common19 = require("@nestjs/common");
70
72
  var import_core4 = require("@nestjs/core");
71
73
 
72
74
  // src/agent-deps.factory.ts
@@ -390,15 +392,128 @@ var AgentService = class {
390
392
  deps;
391
393
  quota;
392
394
  staging;
393
- constructor(runner, store, deps, quota, staging) {
395
+ models;
396
+ quotaProvider;
397
+ options;
398
+ constructor(runner, store, deps, quota, staging, models, quotaProvider, options) {
394
399
  this.runner = runner;
395
400
  this.store = store;
396
401
  this.deps = deps;
397
402
  this.quota = quota;
398
403
  this.staging = staging;
404
+ this.models = models;
405
+ this.quotaProvider = quotaProvider;
406
+ this.options = options;
407
+ }
408
+ /**
409
+ * The actor's budget across windows (`GET <base>/quota`) — the bound {@link QuotaProvider}'s
410
+ * report. Without one (a service built outside the module), a day window from the ledger.
411
+ */
412
+ async quotaReport(actor) {
413
+ if (this.quotaProvider !== void 0) {
414
+ return this.quotaProvider.report({
415
+ actor
416
+ });
417
+ }
418
+ const today = await this.quotaToday(actor.id);
419
+ return {
420
+ windows: [
421
+ {
422
+ period: "day",
423
+ usedTokens: today.usedTokens,
424
+ ...today.limitTokens !== null ? {
425
+ limitTokens: today.limitTokens
426
+ } : {},
427
+ usedUsd: today.costUsd
428
+ }
429
+ ],
430
+ ...today.withinLimit ? {} : {
431
+ blocked: {
432
+ period: "day"
433
+ }
434
+ }
435
+ };
436
+ }
437
+ /**
438
+ * Refuse a turn the actor's budget no longer covers — only when the host configured one
439
+ * (`quotaProvider` or `quotaLimits`): the default report is informational, and the daily token
440
+ * quota the loop enforces keeps working as it always has.
441
+ */
442
+ async assertWithinQuota(actor) {
443
+ const gated = this.options?.quotaProvider !== void 0 || this.options?.quotaLimits !== void 0;
444
+ if (!gated || this.quotaProvider === void 0) {
445
+ return;
446
+ }
447
+ const { blocked } = await this.quotaProvider.report({
448
+ actor
449
+ });
450
+ if (blocked !== void 0) {
451
+ throw new import_common2.HttpException({
452
+ statusCode: import_common2.HttpStatus.TOO_MANY_REQUESTS,
453
+ code: "quota_exceeded",
454
+ period: blocked.period,
455
+ message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
456
+ }, import_common2.HttpStatus.TOO_MANY_REQUESTS);
457
+ }
458
+ }
459
+ /**
460
+ * The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
461
+ * bound, so a picker simply has nothing to offer.
462
+ */
463
+ async listModels(actor, agent) {
464
+ if (this.models === void 0) {
465
+ return {
466
+ providers: [],
467
+ default: null
468
+ };
469
+ }
470
+ return this.models.list({
471
+ actor,
472
+ ...agent !== void 0 ? {
473
+ agent
474
+ } : {}
475
+ });
476
+ }
477
+ /**
478
+ * `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
479
+ * one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
480
+ * pinned and again at every turn that runs on it (availability can change in between).
481
+ */
482
+ async assertModelAllowed(actor, agent, model) {
483
+ if (this.models === void 0) {
484
+ throw new import_common2.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
485
+ }
486
+ const entry = (0, import_nestjs_agent_core3.findCatalogModel)(await this.models.list({
487
+ actor,
488
+ agent
489
+ }), model);
490
+ if (entry === void 0) {
491
+ throw new import_common2.BadRequestException(`model "${model}" is not offered`);
492
+ }
493
+ if (!entry.available) {
494
+ throw new import_common2.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
495
+ }
496
+ return entry.id;
497
+ }
498
+ /** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
499
+ async resolveModel(actor, agent, requested, threadId) {
500
+ const model = requested ?? (threadId !== void 0 ? await this.threadModel(threadId) : null);
501
+ if (model === null || model === void 0) {
502
+ return void 0;
503
+ }
504
+ return this.assertModelAllowed(actor, agent, model);
505
+ }
506
+ async threadModel(threadId) {
507
+ const projecting = this.store;
508
+ if (typeof projecting.modelForThread === "function") {
509
+ return projecting.modelForThread(threadId);
510
+ }
511
+ return (await this.store.getThread(threadId))?.model ?? null;
399
512
  }
400
513
  async chat(params) {
514
+ await this.assertWithinQuota(params.actor);
401
515
  const agentName = await this.resolveAgentName(params.agentName, params.threadId);
516
+ const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
402
517
  const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
403
518
  let threadId = params.threadId;
404
519
  if (threadId === void 0) {
@@ -429,6 +544,9 @@ var AgentService = class {
429
544
  } : {},
430
545
  ...params.pageContext !== void 0 ? {
431
546
  pageContext: params.pageContext
547
+ } : {},
548
+ ...model !== void 0 ? {
549
+ model
432
550
  } : {}
433
551
  };
434
552
  const { runId } = await this.runner.start(input);
@@ -599,20 +717,26 @@ var AgentService = class {
599
717
  async updateThread(actor, threadId, patch) {
600
718
  const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
601
719
  await this.assertOwnsThread(actor, threadId);
602
- if (patch.defaultAgent === void 0) {
720
+ if (patch.defaultAgent === void 0 && patch.model === void 0) {
603
721
  if (title !== void 0) {
604
722
  await this.store.setTitle(threadId, title);
605
723
  }
606
724
  return;
607
725
  }
608
726
  if (this.store.updateThread === void 0) {
609
- throw new import_common2.NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
727
+ throw new import_common2.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
610
728
  }
729
+ 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);
611
730
  await this.store.updateThread(threadId, {
612
731
  ...title !== void 0 ? {
613
732
  title
614
733
  } : {},
615
- defaultAgent: patch.defaultAgent
734
+ ...patch.defaultAgent !== void 0 ? {
735
+ defaultAgent: patch.defaultAgent
736
+ } : {},
737
+ ...model !== void 0 ? {
738
+ model
739
+ } : {}
616
740
  });
617
741
  }
618
742
  validateTitle(title) {
@@ -659,6 +783,7 @@ var AgentService = class {
659
783
  return {
660
784
  ...thread,
661
785
  defaultAgent: thread.defaultAgent ?? null,
786
+ model: thread.model ?? null,
662
787
  activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
663
788
  };
664
789
  }
@@ -926,13 +1051,22 @@ AgentService = _ts_decorate2([
926
1051
  _ts_param2(3, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_QUOTA_STORE)),
927
1052
  _ts_param2(4, (0, import_common2.Optional)()),
928
1053
  _ts_param2(4, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_ATTACHMENT_STAGING)),
1054
+ _ts_param2(5, (0, import_common2.Optional)()),
1055
+ _ts_param2(5, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_MODEL_CATALOG)),
1056
+ _ts_param2(6, (0, import_common2.Optional)()),
1057
+ _ts_param2(6, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_QUOTA_PROVIDER)),
1058
+ _ts_param2(7, (0, import_common2.Optional)()),
1059
+ _ts_param2(7, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_OPTIONS)),
929
1060
  _ts_metadata2("design:type", Function),
930
1061
  _ts_metadata2("design:paramtypes", [
931
1062
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
932
1063
  typeof AgentStore === "undefined" ? Object : AgentStore,
933
1064
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
934
1065
  Object,
935
- typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
1066
+ typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
1067
+ typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
1068
+ typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
1069
+ typeof Pick === "undefined" ? Object : Pick
936
1070
  ])
937
1071
  ], AgentService);
938
1072
 
@@ -1304,6 +1438,9 @@ var ChatController = class {
1304
1438
  } : {},
1305
1439
  ...body.transient === true ? {
1306
1440
  transient: true
1441
+ } : {},
1442
+ ...typeof body.model === "string" && body.model.length > 0 ? {
1443
+ model: body.model
1307
1444
  } : {}
1308
1445
  });
1309
1446
  await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
@@ -1668,7 +1805,7 @@ MessagesController = _ts_decorate8([
1668
1805
  ])
1669
1806
  ], MessagesController);
1670
1807
 
1671
- // src/controller/quota.controller.ts
1808
+ // src/controller/models.controller.ts
1672
1809
  var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
1673
1810
  var import_common9 = require("@nestjs/common");
1674
1811
  function _ts_decorate9(decorators, target, key, desc) {
@@ -1697,9 +1834,9 @@ function _ts_param8(paramIndex, decorator) {
1697
1834
  };
1698
1835
  }
1699
1836
  __name(_ts_param8, "_ts_param");
1700
- var QuotaController = class {
1837
+ var ModelsController = class {
1701
1838
  static {
1702
- __name(this, "QuotaController");
1839
+ __name(this, "ModelsController");
1703
1840
  }
1704
1841
  agent;
1705
1842
  actorResolver;
@@ -1707,31 +1844,37 @@ var QuotaController = class {
1707
1844
  this.agent = agent;
1708
1845
  this.actorResolver = actorResolver;
1709
1846
  }
1710
- async today(req) {
1847
+ /**
1848
+ * The models the caller may pick for `agent` (the default agent when omitted), grouped by
1849
+ * provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
1850
+ */
1851
+ async list(req, agent) {
1711
1852
  const actor = await this.actorResolver.resolve(req);
1712
- return this.agent.quotaToday(actor.id);
1853
+ return this.agent.listModels(actor, agent);
1713
1854
  }
1714
1855
  };
1715
1856
  _ts_decorate9([
1716
- (0, import_common9.Get)("today"),
1857
+ (0, import_common9.Get)(),
1717
1858
  _ts_param8(0, (0, import_common9.Req)()),
1859
+ _ts_param8(1, (0, import_common9.Query)("agent")),
1718
1860
  _ts_metadata9("design:type", Function),
1719
1861
  _ts_metadata9("design:paramtypes", [
1720
- typeof Request === "undefined" ? Object : Request
1862
+ typeof Request === "undefined" ? Object : Request,
1863
+ String
1721
1864
  ]),
1722
1865
  _ts_metadata9("design:returntype", Promise)
1723
- ], QuotaController.prototype, "today", null);
1724
- QuotaController = _ts_decorate9([
1725
- (0, import_common9.Controller)("quota"),
1866
+ ], ModelsController.prototype, "list", null);
1867
+ ModelsController = _ts_decorate9([
1868
+ (0, import_common9.Controller)("models"),
1726
1869
  _ts_param8(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
1727
1870
  _ts_metadata9("design:type", Function),
1728
1871
  _ts_metadata9("design:paramtypes", [
1729
1872
  typeof AgentService === "undefined" ? Object : AgentService,
1730
1873
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1731
1874
  ])
1732
- ], QuotaController);
1875
+ ], ModelsController);
1733
1876
 
1734
- // src/controller/skills.controller.ts
1877
+ // src/controller/quota.controller.ts
1735
1878
  var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
1736
1879
  var import_common10 = require("@nestjs/common");
1737
1880
  function _ts_decorate10(decorators, target, key, desc) {
@@ -1760,6 +1903,86 @@ function _ts_param9(paramIndex, decorator) {
1760
1903
  };
1761
1904
  }
1762
1905
  __name(_ts_param9, "_ts_param");
1906
+ var QuotaController = class {
1907
+ static {
1908
+ __name(this, "QuotaController");
1909
+ }
1910
+ agent;
1911
+ actorResolver;
1912
+ constructor(agent, actorResolver) {
1913
+ this.agent = agent;
1914
+ this.actorResolver = actorResolver;
1915
+ }
1916
+ /**
1917
+ * The caller's budget across windows — `{ windows: [{ period, usedTokens, limitTokens?, usedUsd,
1918
+ * limitUsd?, resetsAt? }], blocked?: { period, reason? } }` — from the bound `QuotaProvider`.
1919
+ */
1920
+ async report(req) {
1921
+ const actor = await this.actorResolver.resolve(req);
1922
+ return this.agent.quotaReport(actor);
1923
+ }
1924
+ async today(req) {
1925
+ const actor = await this.actorResolver.resolve(req);
1926
+ return this.agent.quotaToday(actor.id);
1927
+ }
1928
+ };
1929
+ _ts_decorate10([
1930
+ (0, import_common10.Get)(),
1931
+ _ts_param9(0, (0, import_common10.Req)()),
1932
+ _ts_metadata10("design:type", Function),
1933
+ _ts_metadata10("design:paramtypes", [
1934
+ typeof Request === "undefined" ? Object : Request
1935
+ ]),
1936
+ _ts_metadata10("design:returntype", Promise)
1937
+ ], QuotaController.prototype, "report", null);
1938
+ _ts_decorate10([
1939
+ (0, import_common10.Get)("today"),
1940
+ _ts_param9(0, (0, import_common10.Req)()),
1941
+ _ts_metadata10("design:type", Function),
1942
+ _ts_metadata10("design:paramtypes", [
1943
+ typeof Request === "undefined" ? Object : Request
1944
+ ]),
1945
+ _ts_metadata10("design:returntype", Promise)
1946
+ ], QuotaController.prototype, "today", null);
1947
+ QuotaController = _ts_decorate10([
1948
+ (0, import_common10.Controller)("quota"),
1949
+ _ts_param9(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
1950
+ _ts_metadata10("design:type", Function),
1951
+ _ts_metadata10("design:paramtypes", [
1952
+ typeof AgentService === "undefined" ? Object : AgentService,
1953
+ typeof ActorResolver === "undefined" ? Object : ActorResolver
1954
+ ])
1955
+ ], QuotaController);
1956
+
1957
+ // src/controller/skills.controller.ts
1958
+ var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
1959
+ var import_common11 = require("@nestjs/common");
1960
+ function _ts_decorate11(decorators, target, key, desc) {
1961
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1962
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1963
+ r = Reflect.decorate(decorators, target, key, desc);
1964
+ } else {
1965
+ for (var i = decorators.length - 1; i >= 0; i--) {
1966
+ if (d = decorators[i]) {
1967
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1968
+ }
1969
+ }
1970
+ }
1971
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1972
+ }
1973
+ __name(_ts_decorate11, "_ts_decorate");
1974
+ function _ts_metadata11(metadataKey, metadataValue) {
1975
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1976
+ return Reflect.metadata(metadataKey, metadataValue);
1977
+ }
1978
+ }
1979
+ __name(_ts_metadata11, "_ts_metadata");
1980
+ function _ts_param10(paramIndex, decorator) {
1981
+ return function(target, key) {
1982
+ decorator(target, key, paramIndex);
1983
+ };
1984
+ }
1985
+ __name(_ts_param10, "_ts_param");
1763
1986
  var SkillsController = class {
1764
1987
  static {
1765
1988
  __name(this, "SkillsController");
@@ -1775,40 +1998,40 @@ var SkillsController = class {
1775
1998
  return [];
1776
1999
  }
1777
2000
  const actor = await this.actorResolver.resolve(req);
1778
- const offer = await (0, import_nestjs_agent_core10.offerSkills)(this.skills, {
2001
+ const offer = await (0, import_nestjs_agent_core11.offerSkills)(this.skills, {
1779
2002
  actor,
1780
2003
  threadId: threadId ?? ""
1781
2004
  });
1782
2005
  return offer.entries;
1783
2006
  }
1784
2007
  };
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", [
2008
+ _ts_decorate11([
2009
+ (0, import_common11.Get)(),
2010
+ _ts_param10(0, (0, import_common11.Req)()),
2011
+ _ts_param10(1, (0, import_common11.Query)("threadId")),
2012
+ _ts_metadata11("design:type", Function),
2013
+ _ts_metadata11("design:paramtypes", [
1791
2014
  typeof Request === "undefined" ? Object : Request,
1792
2015
  String
1793
2016
  ]),
1794
- _ts_metadata10("design:returntype", Promise)
2017
+ _ts_metadata11("design:returntype", Promise)
1795
2018
  ], SkillsController.prototype, "list", null);
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", [
2019
+ SkillsController = _ts_decorate11([
2020
+ (0, import_common11.Controller)("skills"),
2021
+ _ts_param10(0, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
2022
+ _ts_param10(1, (0, import_common11.Optional)()),
2023
+ _ts_param10(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_SKILLS)),
2024
+ _ts_metadata11("design:type", Function),
2025
+ _ts_metadata11("design:paramtypes", [
1803
2026
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
1804
2027
  Object
1805
2028
  ])
1806
2029
  ], SkillsController);
1807
2030
 
1808
2031
  // src/controller/threads.controller.ts
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) {
2032
+ var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2033
+ var import_common12 = require("@nestjs/common");
2034
+ function _ts_decorate12(decorators, target, key, desc) {
1812
2035
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1813
2036
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1814
2037
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1821,19 +2044,19 @@ function _ts_decorate11(decorators, target, key, desc) {
1821
2044
  }
1822
2045
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1823
2046
  }
1824
- __name(_ts_decorate11, "_ts_decorate");
1825
- function _ts_metadata11(metadataKey, metadataValue) {
2047
+ __name(_ts_decorate12, "_ts_decorate");
2048
+ function _ts_metadata12(metadataKey, metadataValue) {
1826
2049
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1827
2050
  return Reflect.metadata(metadataKey, metadataValue);
1828
2051
  }
1829
2052
  }
1830
- __name(_ts_metadata11, "_ts_metadata");
1831
- function _ts_param10(paramIndex, decorator) {
2053
+ __name(_ts_metadata12, "_ts_metadata");
2054
+ function _ts_param11(paramIndex, decorator) {
1832
2055
  return function(target, key) {
1833
2056
  decorator(target, key, paramIndex);
1834
2057
  };
1835
2058
  }
1836
- __name(_ts_param10, "_ts_param");
2059
+ __name(_ts_param11, "_ts_param");
1837
2060
  var ThreadsController = class {
1838
2061
  static {
1839
2062
  __name(this, "ThreadsController");
@@ -1876,6 +2099,9 @@ var ThreadsController = class {
1876
2099
  } : {},
1877
2100
  ..."defaultAgent" in body ? {
1878
2101
  defaultAgent: body.defaultAgent ?? null
2102
+ } : {},
2103
+ ..."model" in body ? {
2104
+ model: body.model ?? null
1879
2105
  } : {}
1880
2106
  });
1881
2107
  return {
@@ -1897,101 +2123,101 @@ var ThreadsController = class {
1897
2123
  };
1898
2124
  }
1899
2125
  };
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", [
2126
+ _ts_decorate12([
2127
+ (0, import_common12.Get)(),
2128
+ _ts_param11(0, (0, import_common12.Req)()),
2129
+ _ts_metadata12("design:type", Function),
2130
+ _ts_metadata12("design:paramtypes", [
1905
2131
  typeof Request === "undefined" ? Object : Request
1906
2132
  ]),
1907
- _ts_metadata11("design:returntype", Promise)
2133
+ _ts_metadata12("design:returntype", Promise)
1908
2134
  ], ThreadsController.prototype, "list", null);
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", [
2135
+ _ts_decorate12([
2136
+ (0, import_common12.Get)(":id"),
2137
+ _ts_param11(0, (0, import_common12.Req)()),
2138
+ _ts_param11(1, (0, import_common12.Param)("id")),
2139
+ _ts_metadata12("design:type", Function),
2140
+ _ts_metadata12("design:paramtypes", [
1915
2141
  typeof Request === "undefined" ? Object : Request,
1916
2142
  String
1917
2143
  ]),
1918
- _ts_metadata11("design:returntype", Promise)
2144
+ _ts_metadata12("design:returntype", Promise)
1919
2145
  ], ThreadsController.prototype, "detail", null);
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", [
2146
+ _ts_decorate12([
2147
+ (0, import_common12.Delete)(":id"),
2148
+ _ts_param11(0, (0, import_common12.Req)()),
2149
+ _ts_param11(1, (0, import_common12.Param)("id")),
2150
+ _ts_metadata12("design:type", Function),
2151
+ _ts_metadata12("design:paramtypes", [
1926
2152
  typeof Request === "undefined" ? Object : Request,
1927
2153
  String
1928
2154
  ]),
1929
- _ts_metadata11("design:returntype", Promise)
2155
+ _ts_metadata12("design:returntype", Promise)
1930
2156
  ], ThreadsController.prototype, "remove", null);
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", [
2157
+ _ts_decorate12([
2158
+ (0, import_common12.Post)(":id/fork-from/:messageId"),
2159
+ _ts_param11(0, (0, import_common12.Req)()),
2160
+ _ts_param11(1, (0, import_common12.Param)("id")),
2161
+ _ts_param11(2, (0, import_common12.Param)("messageId")),
2162
+ _ts_metadata12("design:type", Function),
2163
+ _ts_metadata12("design:paramtypes", [
1938
2164
  typeof Request === "undefined" ? Object : Request,
1939
2165
  String,
1940
2166
  String
1941
2167
  ]),
1942
- _ts_metadata11("design:returntype", Promise)
2168
+ _ts_metadata12("design:returntype", Promise)
1943
2169
  ], ThreadsController.prototype, "fork", null);
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", [
2170
+ _ts_decorate12([
2171
+ (0, import_common12.Patch)(":id"),
2172
+ _ts_param11(0, (0, import_common12.Req)()),
2173
+ _ts_param11(1, (0, import_common12.Param)("id")),
2174
+ _ts_param11(2, (0, import_common12.Body)()),
2175
+ _ts_metadata12("design:type", Function),
2176
+ _ts_metadata12("design:paramtypes", [
1951
2177
  typeof Request === "undefined" ? Object : Request,
1952
2178
  String,
1953
2179
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
1954
2180
  ]),
1955
- _ts_metadata11("design:returntype", Promise)
2181
+ _ts_metadata12("design:returntype", Promise)
1956
2182
  ], ThreadsController.prototype, "update", null);
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", [
2183
+ _ts_decorate12([
2184
+ (0, import_common12.Post)(":id/promote"),
2185
+ _ts_param11(0, (0, import_common12.Req)()),
2186
+ _ts_param11(1, (0, import_common12.Param)("id")),
2187
+ _ts_metadata12("design:type", Function),
2188
+ _ts_metadata12("design:paramtypes", [
1963
2189
  typeof Request === "undefined" ? Object : Request,
1964
2190
  String
1965
2191
  ]),
1966
- _ts_metadata11("design:returntype", Promise)
2192
+ _ts_metadata12("design:returntype", Promise)
1967
2193
  ], ThreadsController.prototype, "promote", null);
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", [
2194
+ _ts_decorate12([
2195
+ (0, import_common12.Delete)(":id/from/:messageId"),
2196
+ _ts_param11(0, (0, import_common12.Req)()),
2197
+ _ts_param11(1, (0, import_common12.Param)("id")),
2198
+ _ts_param11(2, (0, import_common12.Param)("messageId")),
2199
+ _ts_metadata12("design:type", Function),
2200
+ _ts_metadata12("design:paramtypes", [
1975
2201
  typeof Request === "undefined" ? Object : Request,
1976
2202
  String,
1977
2203
  String
1978
2204
  ]),
1979
- _ts_metadata11("design:returntype", Promise)
2205
+ _ts_metadata12("design:returntype", Promise)
1980
2206
  ], ThreadsController.prototype, "truncateFrom", null);
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", [
2207
+ ThreadsController = _ts_decorate12([
2208
+ (0, import_common12.Controller)("threads"),
2209
+ _ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
2210
+ _ts_metadata12("design:type", Function),
2211
+ _ts_metadata12("design:paramtypes", [
1986
2212
  typeof AgentService === "undefined" ? Object : AgentService,
1987
2213
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1988
2214
  ])
1989
2215
  ], ThreadsController);
1990
2216
 
1991
2217
  // src/controller/tool-call.controller.ts
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) {
2218
+ var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2219
+ var import_common13 = require("@nestjs/common");
2220
+ function _ts_decorate13(decorators, target, key, desc) {
1995
2221
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1996
2222
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1997
2223
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2004,19 +2230,19 @@ function _ts_decorate12(decorators, target, key, desc) {
2004
2230
  }
2005
2231
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2006
2232
  }
2007
- __name(_ts_decorate12, "_ts_decorate");
2008
- function _ts_metadata12(metadataKey, metadataValue) {
2233
+ __name(_ts_decorate13, "_ts_decorate");
2234
+ function _ts_metadata13(metadataKey, metadataValue) {
2009
2235
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2010
2236
  return Reflect.metadata(metadataKey, metadataValue);
2011
2237
  }
2012
2238
  }
2013
- __name(_ts_metadata12, "_ts_metadata");
2014
- function _ts_param11(paramIndex, decorator) {
2239
+ __name(_ts_metadata13, "_ts_metadata");
2240
+ function _ts_param12(paramIndex, decorator) {
2015
2241
  return function(target, key) {
2016
2242
  decorator(target, key, paramIndex);
2017
2243
  };
2018
2244
  }
2019
- __name(_ts_param11, "_ts_param");
2245
+ __name(_ts_param12, "_ts_param");
2020
2246
  var MAX_ANSWERED_QUESTIONS = 100;
2021
2247
  var MAX_VALUES_PER_QUESTION = 100;
2022
2248
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -2025,7 +2251,7 @@ var MAX_VIA_LENGTH = 64;
2025
2251
  var DEFAULT_VIA = "web";
2026
2252
  function toolCallId(claimed) {
2027
2253
  if (typeof claimed !== "string" || claimed.length === 0) {
2028
- throw new import_common12.BadRequestException("toolCallId must be a non-empty string");
2254
+ throw new import_common13.BadRequestException("toolCallId must be a non-empty string");
2029
2255
  }
2030
2256
  return claimed;
2031
2257
  }
@@ -2035,10 +2261,10 @@ function rejectReason(claimed) {
2035
2261
  return void 0;
2036
2262
  }
2037
2263
  if (typeof claimed !== "string") {
2038
- throw new import_common12.BadRequestException("reason must be a string");
2264
+ throw new import_common13.BadRequestException("reason must be a string");
2039
2265
  }
2040
2266
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
2041
- throw new import_common12.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
2267
+ throw new import_common13.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
2042
2268
  }
2043
2269
  return claimed;
2044
2270
  }
@@ -2048,7 +2274,7 @@ function remember(claimed) {
2048
2274
  return false;
2049
2275
  }
2050
2276
  if (typeof claimed !== "boolean") {
2051
- throw new import_common12.BadRequestException("remember must be a boolean");
2277
+ throw new import_common13.BadRequestException("remember must be a boolean");
2052
2278
  }
2053
2279
  return claimed;
2054
2280
  }
@@ -2058,7 +2284,7 @@ function via(claimed) {
2058
2284
  return DEFAULT_VIA;
2059
2285
  }
2060
2286
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
2061
- throw new import_common12.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
2287
+ throw new import_common13.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
2062
2288
  }
2063
2289
  return claimed;
2064
2290
  }
@@ -2068,26 +2294,26 @@ function answers(claimed) {
2068
2294
  return void 0;
2069
2295
  }
2070
2296
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
2071
- throw new import_common12.BadRequestException("answers must be an object of questionId \u2192 chosen values");
2297
+ throw new import_common13.BadRequestException("answers must be an object of questionId \u2192 chosen values");
2072
2298
  }
2073
2299
  const entries = Object.entries(claimed);
2074
2300
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
2075
- throw new import_common12.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
2301
+ throw new import_common13.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
2076
2302
  }
2077
2303
  const validated = /* @__PURE__ */ Object.create(null);
2078
2304
  for (const [questionId, values] of entries) {
2079
2305
  if (!Array.isArray(values)) {
2080
- throw new import_common12.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
2306
+ throw new import_common13.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
2081
2307
  }
2082
2308
  if (values.length > MAX_VALUES_PER_QUESTION) {
2083
- throw new import_common12.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
2309
+ throw new import_common13.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
2084
2310
  }
2085
2311
  for (const value of values) {
2086
2312
  if (typeof value !== "string") {
2087
- throw new import_common12.BadRequestException(`answers["${questionId}"] must contain only strings`);
2313
+ throw new import_common13.BadRequestException(`answers["${questionId}"] must contain only strings`);
2088
2314
  }
2089
2315
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
2090
- throw new import_common12.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
2316
+ throw new import_common13.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
2091
2317
  }
2092
2318
  }
2093
2319
  validated[questionId] = values;
@@ -2145,64 +2371,64 @@ var ToolCallController = class {
2145
2371
  };
2146
2372
  }
2147
2373
  };
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", [
2374
+ _ts_decorate13([
2375
+ (0, import_common13.Post)("approve"),
2376
+ _ts_param12(0, (0, import_common13.Req)()),
2377
+ _ts_param12(1, (0, import_common13.Body)()),
2378
+ _ts_metadata13("design:type", Function),
2379
+ _ts_metadata13("design:paramtypes", [
2154
2380
  typeof Request === "undefined" ? Object : Request,
2155
2381
  typeof ApproveBody === "undefined" ? Object : ApproveBody
2156
2382
  ]),
2157
- _ts_metadata12("design:returntype", Promise)
2383
+ _ts_metadata13("design:returntype", Promise)
2158
2384
  ], ToolCallController.prototype, "approve", null);
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", [
2385
+ _ts_decorate13([
2386
+ (0, import_common13.Post)("reject"),
2387
+ _ts_param12(0, (0, import_common13.Req)()),
2388
+ _ts_param12(1, (0, import_common13.Body)()),
2389
+ _ts_metadata13("design:type", Function),
2390
+ _ts_metadata13("design:paramtypes", [
2165
2391
  typeof Request === "undefined" ? Object : Request,
2166
2392
  typeof RejectBody === "undefined" ? Object : RejectBody
2167
2393
  ]),
2168
- _ts_metadata12("design:returntype", Promise)
2394
+ _ts_metadata13("design:returntype", Promise)
2169
2395
  ], ToolCallController.prototype, "reject", null);
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", [
2396
+ _ts_decorate13([
2397
+ (0, import_common13.Post)("answer"),
2398
+ _ts_param12(0, (0, import_common13.Req)()),
2399
+ _ts_param12(1, (0, import_common13.Body)()),
2400
+ _ts_metadata13("design:type", Function),
2401
+ _ts_metadata13("design:paramtypes", [
2176
2402
  typeof Request === "undefined" ? Object : Request,
2177
2403
  typeof AnswerBody === "undefined" ? Object : AnswerBody
2178
2404
  ]),
2179
- _ts_metadata12("design:returntype", Promise)
2405
+ _ts_metadata13("design:returntype", Promise)
2180
2406
  ], ToolCallController.prototype, "answer", null);
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", [
2407
+ _ts_decorate13([
2408
+ (0, import_common13.Post)("skip"),
2409
+ _ts_param12(0, (0, import_common13.Req)()),
2410
+ _ts_param12(1, (0, import_common13.Body)()),
2411
+ _ts_metadata13("design:type", Function),
2412
+ _ts_metadata13("design:paramtypes", [
2187
2413
  typeof Request === "undefined" ? Object : Request,
2188
2414
  Object
2189
2415
  ]),
2190
- _ts_metadata12("design:returntype", Promise)
2416
+ _ts_metadata13("design:returntype", Promise)
2191
2417
  ], ToolCallController.prototype, "skip", null);
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", [
2418
+ ToolCallController = _ts_decorate13([
2419
+ (0, import_common13.Controller)("tool-call"),
2420
+ _ts_param12(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
2421
+ _ts_metadata13("design:type", Function),
2422
+ _ts_metadata13("design:paramtypes", [
2197
2423
  typeof AgentService === "undefined" ? Object : AgentService,
2198
2424
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2199
2425
  ])
2200
2426
  ], ToolCallController);
2201
2427
 
2202
2428
  // src/controller/tools.controller.ts
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) {
2429
+ var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2430
+ var import_common14 = require("@nestjs/common");
2431
+ function _ts_decorate14(decorators, target, key, desc) {
2206
2432
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2207
2433
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2208
2434
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2215,19 +2441,19 @@ function _ts_decorate13(decorators, target, key, desc) {
2215
2441
  }
2216
2442
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2217
2443
  }
2218
- __name(_ts_decorate13, "_ts_decorate");
2219
- function _ts_metadata13(metadataKey, metadataValue) {
2444
+ __name(_ts_decorate14, "_ts_decorate");
2445
+ function _ts_metadata14(metadataKey, metadataValue) {
2220
2446
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2221
2447
  return Reflect.metadata(metadataKey, metadataValue);
2222
2448
  }
2223
2449
  }
2224
- __name(_ts_metadata13, "_ts_metadata");
2225
- function _ts_param12(paramIndex, decorator) {
2450
+ __name(_ts_metadata14, "_ts_metadata");
2451
+ function _ts_param13(paramIndex, decorator) {
2226
2452
  return function(target, key) {
2227
2453
  decorator(target, key, paramIndex);
2228
2454
  };
2229
2455
  }
2230
- __name(_ts_param12, "_ts_param");
2456
+ __name(_ts_param13, "_ts_param");
2231
2457
  var ToolsController = class {
2232
2458
  static {
2233
2459
  __name(this, "ToolsController");
@@ -2242,7 +2468,7 @@ var ToolsController = class {
2242
2468
  }
2243
2469
  async list(req, agent) {
2244
2470
  if (agent !== void 0 && this.agents.get(agent) === void 0) {
2245
- throw new import_common13.NotFoundException(`No agent named "${agent}"`);
2471
+ throw new import_common14.NotFoundException(`No agent named "${agent}"`);
2246
2472
  }
2247
2473
  const actor = await this.actorResolver.resolve(req);
2248
2474
  const deps = this.depsFactory.forAgent(agent);
@@ -2256,33 +2482,33 @@ var ToolsController = class {
2256
2482
  }));
2257
2483
  }
2258
2484
  };
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", [
2485
+ _ts_decorate14([
2486
+ (0, import_common14.Get)(),
2487
+ _ts_param13(0, (0, import_common14.Req)()),
2488
+ _ts_param13(1, (0, import_common14.Query)("agent")),
2489
+ _ts_metadata14("design:type", Function),
2490
+ _ts_metadata14("design:paramtypes", [
2265
2491
  typeof Request === "undefined" ? Object : Request,
2266
2492
  String
2267
2493
  ]),
2268
- _ts_metadata13("design:returntype", Promise)
2494
+ _ts_metadata14("design:returntype", Promise)
2269
2495
  ], ToolsController.prototype, "list", null);
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", [
2496
+ ToolsController = _ts_decorate14([
2497
+ (0, import_common14.Controller)("tools"),
2498
+ _ts_param13(0, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
2499
+ _ts_param13(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_DEPS_FACTORY)),
2500
+ _ts_param13(2, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
2501
+ _ts_metadata14("design:type", Function),
2502
+ _ts_metadata14("design:paramtypes", [
2277
2503
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2278
2504
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
2279
- typeof import_nestjs_agent_core13.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core13.AgentRegistry
2505
+ typeof import_nestjs_agent_core14.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core14.AgentRegistry
2280
2506
  ])
2281
2507
  ], ToolsController);
2282
2508
 
2283
2509
  // src/discovery/agent-discovery.service.ts
2284
- var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2285
- var import_common14 = require("@nestjs/common");
2510
+ var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2511
+ var import_common15 = require("@nestjs/common");
2286
2512
  var import_core = require("@nestjs/core");
2287
2513
 
2288
2514
  // src/decorator/agent.decorator.ts
@@ -2317,7 +2543,7 @@ function SystemPromptContributor() {
2317
2543
  __name(SystemPromptContributor, "SystemPromptContributor");
2318
2544
 
2319
2545
  // src/discovery/agent-discovery.service.ts
2320
- function _ts_decorate14(decorators, target, key, desc) {
2546
+ function _ts_decorate15(decorators, target, key, desc) {
2321
2547
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2322
2548
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2323
2549
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2330,19 +2556,19 @@ function _ts_decorate14(decorators, target, key, desc) {
2330
2556
  }
2331
2557
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2332
2558
  }
2333
- __name(_ts_decorate14, "_ts_decorate");
2334
- function _ts_metadata14(metadataKey, metadataValue) {
2559
+ __name(_ts_decorate15, "_ts_decorate");
2560
+ function _ts_metadata15(metadataKey, metadataValue) {
2335
2561
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2336
2562
  return Reflect.metadata(metadataKey, metadataValue);
2337
2563
  }
2338
2564
  }
2339
- __name(_ts_metadata14, "_ts_metadata");
2340
- function _ts_param13(paramIndex, decorator) {
2565
+ __name(_ts_metadata15, "_ts_metadata");
2566
+ function _ts_param14(paramIndex, decorator) {
2341
2567
  return function(target, key) {
2342
2568
  decorator(target, key, paramIndex);
2343
2569
  };
2344
2570
  }
2345
- __name(_ts_param13, "_ts_param");
2571
+ __name(_ts_param14, "_ts_param");
2346
2572
  var AgentDiscoveryService = class _AgentDiscoveryService {
2347
2573
  static {
2348
2574
  __name(this, "AgentDiscoveryService");
@@ -2351,7 +2577,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
2351
2577
  scanner;
2352
2578
  registry;
2353
2579
  contributors;
2354
- logger = new import_common14.Logger(_AgentDiscoveryService.name);
2580
+ logger = new import_common15.Logger(_AgentDiscoveryService.name);
2355
2581
  constructor(discovery, scanner, registry, contributors) {
2356
2582
  this.discovery = discovery;
2357
2583
  this.scanner = scanner;
@@ -2469,22 +2695,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
2469
2695
  return (ctx) => candidate.call(instance, ctx);
2470
2696
  }
2471
2697
  };
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", [
2698
+ AgentDiscoveryService = _ts_decorate15([
2699
+ (0, import_common15.Injectable)(),
2700
+ _ts_param14(2, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_REGISTRY)),
2701
+ _ts_param14(3, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_PROMPT_CONTRIBUTORS)),
2702
+ _ts_metadata15("design:type", Function),
2703
+ _ts_metadata15("design:paramtypes", [
2478
2704
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
2479
2705
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
2480
- typeof import_nestjs_agent_core14.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core14.AgentRegistry,
2706
+ typeof import_nestjs_agent_core15.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core15.AgentRegistry,
2481
2707
  Array
2482
2708
  ])
2483
2709
  ], AgentDiscoveryService);
2484
2710
 
2485
2711
  // src/discovery/ai-tool-discovery.service.ts
2486
- var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2487
- var import_common15 = require("@nestjs/common");
2712
+ var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2713
+ var import_common16 = require("@nestjs/common");
2488
2714
  var import_core2 = require("@nestjs/core");
2489
2715
  var import_zod = require("zod");
2490
2716
 
@@ -2533,7 +2759,7 @@ function provideAgentTool(factoryOrTool, inject) {
2533
2759
  __name(provideAgentTool, "provideAgentTool");
2534
2760
 
2535
2761
  // src/discovery/ai-tool-discovery.service.ts
2536
- function _ts_decorate15(decorators, target, key, desc) {
2762
+ function _ts_decorate16(decorators, target, key, desc) {
2537
2763
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2538
2764
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2539
2765
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2546,19 +2772,19 @@ function _ts_decorate15(decorators, target, key, desc) {
2546
2772
  }
2547
2773
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2548
2774
  }
2549
- __name(_ts_decorate15, "_ts_decorate");
2550
- function _ts_metadata15(metadataKey, metadataValue) {
2775
+ __name(_ts_decorate16, "_ts_decorate");
2776
+ function _ts_metadata16(metadataKey, metadataValue) {
2551
2777
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2552
2778
  return Reflect.metadata(metadataKey, metadataValue);
2553
2779
  }
2554
2780
  }
2555
- __name(_ts_metadata15, "_ts_metadata");
2556
- function _ts_param14(paramIndex, decorator) {
2781
+ __name(_ts_metadata16, "_ts_metadata");
2782
+ function _ts_param15(paramIndex, decorator) {
2557
2783
  return function(target, key) {
2558
2784
  decorator(target, key, paramIndex);
2559
2785
  };
2560
2786
  }
2561
- __name(_ts_param14, "_ts_param");
2787
+ __name(_ts_param15, "_ts_param");
2562
2788
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
2563
2789
  static {
2564
2790
  __name(this, "AiToolDiscoveryService");
@@ -2567,7 +2793,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2567
2793
  registry;
2568
2794
  agents;
2569
2795
  options;
2570
- logger = new import_common15.Logger(_AiToolDiscoveryService.name);
2796
+ logger = new import_common16.Logger(_AiToolDiscoveryService.name);
2571
2797
  constructor(discovery, registry, agents, options) {
2572
2798
  this.discovery = discovery;
2573
2799
  this.registry = registry;
@@ -2641,7 +2867,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2641
2867
  let delegates = 0;
2642
2868
  for (const definition of this.agents.list()) {
2643
2869
  for (const edge of definition.delegatesTo ?? []) {
2644
- const { agent: target, detached } = (0, import_nestjs_agent_core15.normalizeDelegation)(edge);
2870
+ const { agent: target, detached } = (0, import_nestjs_agent_core16.normalizeDelegation)(edge);
2645
2871
  const targetDefinition = this.agents.get(target);
2646
2872
  if (targetDefinition === void 0) {
2647
2873
  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.`);
@@ -2691,13 +2917,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
2691
2917
  return true;
2692
2918
  }
2693
2919
  };
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", [
2920
+ AiToolDiscoveryService = _ts_decorate16([
2921
+ (0, import_common16.Injectable)(),
2922
+ _ts_param15(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_TOOL_REGISTRY)),
2923
+ _ts_param15(2, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_REGISTRY)),
2924
+ _ts_param15(3, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_OPTIONS)),
2925
+ _ts_metadata16("design:type", Function),
2926
+ _ts_metadata16("design:paramtypes", [
2701
2927
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
2702
2928
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
2703
2929
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -2706,13 +2932,13 @@ AiToolDiscoveryService = _ts_decorate15([
2706
2932
  ], AiToolDiscoveryService);
2707
2933
 
2708
2934
  // src/discovery/skill-discovery.service.ts
2709
- var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2710
- var import_common16 = require("@nestjs/common");
2935
+ var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2936
+ var import_common17 = require("@nestjs/common");
2711
2937
  var import_core3 = require("@nestjs/core");
2712
2938
 
2713
2939
  // src/decorator/skill.decorator.ts
2714
2940
  var import_reflect_metadata4 = require("reflect-metadata");
2715
- var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2941
+ var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2716
2942
  var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
2717
2943
  function Skill(options) {
2718
2944
  return (target) => {
@@ -2725,12 +2951,12 @@ function readSkillMetadata(target) {
2725
2951
  }
2726
2952
  __name(readSkillMetadata, "readSkillMetadata");
2727
2953
  function skillScope(options) {
2728
- return options.scope ?? import_nestjs_agent_core16.GLOBAL_SCOPE;
2954
+ return options.scope ?? import_nestjs_agent_core17.GLOBAL_SCOPE;
2729
2955
  }
2730
2956
  __name(skillScope, "skillScope");
2731
2957
 
2732
2958
  // src/discovery/skill-discovery.service.ts
2733
- function _ts_decorate16(decorators, target, key, desc) {
2959
+ function _ts_decorate17(decorators, target, key, desc) {
2734
2960
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2735
2961
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2736
2962
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2743,26 +2969,26 @@ function _ts_decorate16(decorators, target, key, desc) {
2743
2969
  }
2744
2970
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2745
2971
  }
2746
- __name(_ts_decorate16, "_ts_decorate");
2747
- function _ts_metadata16(metadataKey, metadataValue) {
2972
+ __name(_ts_decorate17, "_ts_decorate");
2973
+ function _ts_metadata17(metadataKey, metadataValue) {
2748
2974
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2749
2975
  return Reflect.metadata(metadataKey, metadataValue);
2750
2976
  }
2751
2977
  }
2752
- __name(_ts_metadata16, "_ts_metadata");
2753
- function _ts_param15(paramIndex, decorator) {
2978
+ __name(_ts_metadata17, "_ts_metadata");
2979
+ function _ts_param16(paramIndex, decorator) {
2754
2980
  return function(target, key) {
2755
2981
  decorator(target, key, paramIndex);
2756
2982
  };
2757
2983
  }
2758
- __name(_ts_param15, "_ts_param");
2984
+ __name(_ts_param16, "_ts_param");
2759
2985
  var SkillDiscoveryService = class _SkillDiscoveryService {
2760
2986
  static {
2761
2987
  __name(this, "SkillDiscoveryService");
2762
2988
  }
2763
2989
  discovery;
2764
2990
  declared;
2765
- logger = new import_common16.Logger(_SkillDiscoveryService.name);
2991
+ logger = new import_common17.Logger(_SkillDiscoveryService.name);
2766
2992
  constructor(discovery, declared) {
2767
2993
  this.discovery = discovery;
2768
2994
  this.declared = declared;
@@ -2799,18 +3025,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
2799
3025
  return flat === void 0 ? void 0 : () => flat;
2800
3026
  }
2801
3027
  };
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", [
3028
+ SkillDiscoveryService = _ts_decorate17([
3029
+ (0, import_common17.Injectable)(),
3030
+ _ts_param16(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_SKILL_SOURCES)),
3031
+ _ts_metadata17("design:type", Function),
3032
+ _ts_metadata17("design:paramtypes", [
2807
3033
  typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
2808
3034
  Array
2809
3035
  ])
2810
3036
  ], SkillDiscoveryService);
2811
3037
 
2812
3038
  // src/in-process-sink.ts
2813
- var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
3039
+ var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
2814
3040
  var InProcessTokenStreamSink = class {
2815
3041
  static {
2816
3042
  __name(this, "InProcessTokenStreamSink");
@@ -2865,7 +3091,7 @@ var InProcessTokenStreamSink = class {
2865
3091
  }
2866
3092
  if (buf.ended) {
2867
3093
  if (buf.failure !== void 0) {
2868
- throw new import_nestjs_agent_core18.AgentStreamError(buf.failure);
3094
+ throw new import_nestjs_agent_core19.AgentStreamError(buf.failure);
2869
3095
  }
2870
3096
  return;
2871
3097
  }
@@ -2877,6 +3103,69 @@ var InProcessTokenStreamSink = class {
2877
3103
  }
2878
3104
  };
2879
3105
 
3106
+ // src/ledger-quota-provider.ts
3107
+ var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3108
+ var LedgerQuotaProvider = class {
3109
+ static {
3110
+ __name(this, "LedgerQuotaProvider");
3111
+ }
3112
+ store;
3113
+ quota;
3114
+ limits;
3115
+ constructor(store, quota, limits = {}) {
3116
+ this.store = store;
3117
+ this.quota = quota;
3118
+ this.limits = limits;
3119
+ }
3120
+ async report(query) {
3121
+ const now = query.now ?? /* @__PURE__ */ new Date();
3122
+ const actorRef = query.actor.id;
3123
+ const windows = [
3124
+ await this.dayWindow(actorRef, now)
3125
+ ];
3126
+ if (this.store.usageBetween !== void 0) {
3127
+ const range = (0, import_nestjs_agent_core20.quotaPeriodRange)("month", now);
3128
+ const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
3129
+ windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
3130
+ }
3131
+ const blocked = (0, import_nestjs_agent_core20.exhaustedWindow)(windows);
3132
+ return {
3133
+ windows,
3134
+ ...blocked !== void 0 ? {
3135
+ blocked
3136
+ } : {}
3137
+ };
3138
+ }
3139
+ async dayWindow(actorRef, now) {
3140
+ const range = (0, import_nestjs_agent_core20.quotaPeriodRange)("day", now);
3141
+ const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
3142
+ if (this.quota === void 0) {
3143
+ return this.window("day", usedTokens, costUsd, range.resetsAt);
3144
+ }
3145
+ const state = await this.quota.check(actorRef, range.fromDay);
3146
+ const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
3147
+ if (window.limitTokens === void 0) {
3148
+ window.limitTokens = state.limitTokens;
3149
+ }
3150
+ return window;
3151
+ }
3152
+ window(period, usedTokens, usedUsd, resetsAt) {
3153
+ const limits = this.limits[period] ?? {};
3154
+ return {
3155
+ period,
3156
+ usedTokens,
3157
+ ...limits.tokens !== void 0 ? {
3158
+ limitTokens: limits.tokens
3159
+ } : {},
3160
+ usedUsd,
3161
+ ...limits.usd !== void 0 ? {
3162
+ limitUsd: limits.usd
3163
+ } : {},
3164
+ resetsAt
3165
+ };
3166
+ }
3167
+ };
3168
+
2880
3169
  // src/ledger-quota-store.ts
2881
3170
  var LedgerQuotaStore = class {
2882
3171
  static {
@@ -2901,9 +3190,9 @@ var LedgerQuotaStore = class {
2901
3190
  };
2902
3191
 
2903
3192
  // src/runner/inline-agent-runner.ts
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) {
3193
+ var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
3194
+ var import_common18 = require("@nestjs/common");
3195
+ function _ts_decorate18(decorators, target, key, desc) {
2907
3196
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2908
3197
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2909
3198
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2916,26 +3205,26 @@ function _ts_decorate17(decorators, target, key, desc) {
2916
3205
  }
2917
3206
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2918
3207
  }
2919
- __name(_ts_decorate17, "_ts_decorate");
2920
- function _ts_metadata17(metadataKey, metadataValue) {
3208
+ __name(_ts_decorate18, "_ts_decorate");
3209
+ function _ts_metadata18(metadataKey, metadataValue) {
2921
3210
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2922
3211
  return Reflect.metadata(metadataKey, metadataValue);
2923
3212
  }
2924
3213
  }
2925
- __name(_ts_metadata17, "_ts_metadata");
2926
- function _ts_param16(paramIndex, decorator) {
3214
+ __name(_ts_metadata18, "_ts_metadata");
3215
+ function _ts_param17(paramIndex, decorator) {
2927
3216
  return function(target, key) {
2928
3217
  decorator(target, key, paramIndex);
2929
3218
  };
2930
3219
  }
2931
- __name(_ts_param16, "_ts_param");
3220
+ __name(_ts_param17, "_ts_param");
2932
3221
  var InlineAgentRunner = class _InlineAgentRunner {
2933
3222
  static {
2934
3223
  __name(this, "InlineAgentRunner");
2935
3224
  }
2936
3225
  factory;
2937
3226
  store;
2938
- logger = new import_common17.Logger(_InlineAgentRunner.name);
3227
+ logger = new import_common18.Logger(_InlineAgentRunner.name);
2939
3228
  pending = /* @__PURE__ */ new Map();
2940
3229
  /**
2941
3230
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -2964,18 +3253,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
2964
3253
  ] : []
2965
3254
  ]
2966
3255
  });
2967
- void (0, import_nestjs_agent_core19.runAgentLoop)({
3256
+ void (0, import_nestjs_agent_core21.runAgentLoop)({
2968
3257
  ...deps,
2969
3258
  day
2970
3259
  }, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
2971
- if (error instanceof import_nestjs_agent_core19.RunCancelledError) {
3260
+ if (error instanceof import_nestjs_agent_core21.RunCancelledError) {
2972
3261
  await this.settleCancelled(runId, input.threadId, deps);
2973
3262
  return;
2974
3263
  }
2975
3264
  const message = error instanceof Error ? error.message : String(error);
2976
- const code = (0, import_nestjs_agent_core19.agentFailureCode)(error);
3265
+ const code = (0, import_nestjs_agent_core21.agentFailureCode)(error);
2977
3266
  this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
2978
- (0, import_nestjs_agent_core19.publishAgentRunFailed)({
3267
+ (0, import_nestjs_agent_core21.publishAgentRunFailed)({
2979
3268
  runId,
2980
3269
  code,
2981
3270
  message
@@ -3024,7 +3313,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3024
3313
  for (const [key, waiter] of this.pending) {
3025
3314
  if (key.startsWith(`${runId}:`)) {
3026
3315
  this.pending.delete(key);
3027
- waiter.reject(new import_nestjs_agent_core19.RunCancelledError());
3316
+ waiter.reject(new import_nestjs_agent_core21.RunCancelledError());
3028
3317
  }
3029
3318
  }
3030
3319
  await Promise.resolve();
@@ -3039,7 +3328,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3039
3328
  this.logger.log(`agent run ${runId} cancelled`);
3040
3329
  await this.store.setActiveStream(threadId, null);
3041
3330
  const writer = await deps.sink.open(runId);
3042
- await writer.write((0, import_nestjs_agent_core19.encodeStreamEvent)({
3331
+ await writer.write((0, import_nestjs_agent_core21.encodeStreamEvent)({
3043
3332
  kind: "cancelled"
3044
3333
  }));
3045
3334
  await writer.end();
@@ -3100,7 +3389,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3100
3389
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3101
3390
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3102
3391
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3103
- parallel: import_nestjs_agent_core19.settleAll,
3392
+ parallel: import_nestjs_agent_core21.settleAll,
3104
3393
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
3105
3394
  runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
3106
3395
  agentName,
@@ -3151,7 +3440,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3151
3440
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3152
3441
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3153
3442
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3154
- parallel: import_nestjs_agent_core19.settleAll,
3443
+ parallel: import_nestjs_agent_core21.settleAll,
3155
3444
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
3156
3445
  runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
3157
3446
  agentName: childName,
@@ -3184,7 +3473,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3184
3473
  }
3185
3474
  }), "startAgent")
3186
3475
  };
3187
- void (0, import_nestjs_agent_core19.runAgentLoop)({
3476
+ void (0, import_nestjs_agent_core21.runAgentLoop)({
3188
3477
  ...deps,
3189
3478
  day
3190
3479
  }, {
@@ -3198,13 +3487,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
3198
3487
  parentRunId,
3199
3488
  deliverTo
3200
3489
  }, hooks).catch(async (error) => {
3201
- const cancelled = error instanceof import_nestjs_agent_core19.RunCancelledError;
3490
+ const cancelled = error instanceof import_nestjs_agent_core21.RunCancelledError;
3202
3491
  const message = error instanceof Error ? error.message : String(error);
3203
3492
  if (!cancelled) {
3204
3493
  this.logger.error(`detached agent run ${runId} failed: ${message}`);
3205
- (0, import_nestjs_agent_core19.publishAgentRunFailed)({
3494
+ (0, import_nestjs_agent_core21.publishAgentRunFailed)({
3206
3495
  runId,
3207
- code: (0, import_nestjs_agent_core19.agentFailureCode)(error),
3496
+ code: (0, import_nestjs_agent_core21.agentFailureCode)(error),
3208
3497
  message
3209
3498
  });
3210
3499
  }
@@ -3212,11 +3501,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
3212
3501
  runId,
3213
3502
  status: cancelled ? "cancelled" : "failed",
3214
3503
  ...cancelled ? {} : {
3215
- errorCode: (0, import_nestjs_agent_core19.agentFailureCode)(error),
3504
+ errorCode: (0, import_nestjs_agent_core21.agentFailureCode)(error),
3216
3505
  errorMessage: message
3217
3506
  }
3218
3507
  });
3219
- await (0, import_nestjs_agent_core19.settleUnsettledDelegation)({
3508
+ await (0, import_nestjs_agent_core21.settleUnsettledDelegation)({
3220
3509
  store: this.store,
3221
3510
  delivery: deliverTo,
3222
3511
  agent: agentName,
@@ -3255,7 +3544,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3255
3544
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3256
3545
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3257
3546
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3258
- parallel: import_nestjs_agent_core19.settleAll,
3547
+ parallel: import_nestjs_agent_core21.settleAll,
3259
3548
  // A child stops when it is cancelled OR when the run a human is actually watching is: the
3260
3549
  // canceller names the top-level run, which is the only id that ever left the server.
3261
3550
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
@@ -3290,7 +3579,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3290
3579
  }), "startAgent")
3291
3580
  };
3292
3581
  try {
3293
- return await (0, import_nestjs_agent_core19.runAgentLoop)({
3582
+ return await (0, import_nestjs_agent_core21.runAgentLoop)({
3294
3583
  ...deps,
3295
3584
  day
3296
3585
  }, {
@@ -3309,19 +3598,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
3309
3598
  }
3310
3599
  }
3311
3600
  };
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", [
3601
+ InlineAgentRunner = _ts_decorate18([
3602
+ (0, import_common18.Injectable)(),
3603
+ _ts_param17(0, (0, import_common18.Inject)(import_nestjs_agent_core21.AGENT_DEPS_FACTORY)),
3604
+ _ts_param17(1, (0, import_common18.Inject)(import_nestjs_agent_core21.AGENT_STORE)),
3605
+ _ts_metadata18("design:type", Function),
3606
+ _ts_metadata18("design:paramtypes", [
3318
3607
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
3319
3608
  typeof AgentStore === "undefined" ? Object : AgentStore
3320
3609
  ])
3321
3610
  ], InlineAgentRunner);
3322
3611
 
3323
3612
  // src/skills-config.ts
3324
- var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3613
+ var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
3325
3614
  function declaredSkillProvider(declared) {
3326
3615
  return {
3327
3616
  list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
@@ -3347,7 +3636,7 @@ function resolveSkillsConfig(options, declared) {
3347
3636
  declaredSkillProvider(declared)
3348
3637
  ];
3349
3638
  return {
3350
- provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core20.compositeSkillProvider)(providers),
3639
+ provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core22.compositeSkillProvider)(providers),
3351
3640
  ...options.scopes !== void 0 ? {
3352
3641
  scopes: options.scopes
3353
3642
  } : {},
@@ -3359,7 +3648,7 @@ function resolveSkillsConfig(options, declared) {
3359
3648
  __name(resolveSkillsConfig, "resolveSkillsConfig");
3360
3649
 
3361
3650
  // src/agent.module.ts
3362
- function _ts_decorate18(decorators, target, key, desc) {
3651
+ function _ts_decorate19(decorators, target, key, desc) {
3363
3652
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3364
3653
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3365
3654
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3372,92 +3661,108 @@ function _ts_decorate18(decorators, target, key, desc) {
3372
3661
  }
3373
3662
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3374
3663
  }
3375
- __name(_ts_decorate18, "_ts_decorate");
3664
+ __name(_ts_decorate19, "_ts_decorate");
3376
3665
  var DEFAULT_PATH = "agent";
3377
3666
  function sharedProviders(durable, includeStore) {
3378
3667
  const providers = [
3379
3668
  {
3380
- provide: import_nestjs_agent_core21.AGENT_TOOL_REGISTRY,
3381
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core21.ToolRegistry(), "useFactory")
3669
+ provide: import_nestjs_agent_core23.AGENT_TOOL_REGISTRY,
3670
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core23.ToolRegistry(), "useFactory")
3382
3671
  },
3383
3672
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
3384
3673
  {
3385
- provide: import_nestjs_agent_core21.AGENT_REGISTRY,
3386
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core21.AgentRegistry(), "useFactory")
3674
+ provide: import_nestjs_agent_core23.AGENT_REGISTRY,
3675
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core23.AgentRegistry(), "useFactory")
3387
3676
  },
3388
3677
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
3389
3678
  {
3390
- provide: import_nestjs_agent_core21.AGENT_PROMPT_CONTRIBUTORS,
3679
+ provide: import_nestjs_agent_core23.AGENT_PROMPT_CONTRIBUTORS,
3391
3680
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
3392
3681
  },
3393
3682
  // Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
3394
3683
  // read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
3395
3684
  {
3396
- provide: import_nestjs_agent_core21.AGENT_SKILL_SOURCES,
3685
+ provide: import_nestjs_agent_core23.AGENT_SKILL_SOURCES,
3397
3686
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
3398
3687
  },
3399
3688
  {
3400
3689
  // One resolution, shared by the loop's deps and the listing endpoint: a second one would
3401
3690
  // drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
3402
3691
  // host configured none — which is what keeps the turn's checkpoint sequence unchanged.
3403
- provide: import_nestjs_agent_core21.AGENT_SKILLS,
3692
+ provide: import_nestjs_agent_core23.AGENT_SKILLS,
3404
3693
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
3405
3694
  inject: [
3406
- import_nestjs_agent_core21.AGENT_OPTIONS,
3407
- import_nestjs_agent_core21.AGENT_SKILL_SOURCES
3695
+ import_nestjs_agent_core23.AGENT_OPTIONS,
3696
+ import_nestjs_agent_core23.AGENT_SKILL_SOURCES
3408
3697
  ]
3409
3698
  },
3410
3699
  {
3411
3700
  // One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
3412
3701
  // shown what the model was shown, and two resolutions would eventually disagree about that.
3413
- provide: import_nestjs_agent_core21.AGENT_MEMORY,
3702
+ provide: import_nestjs_agent_core23.AGENT_MEMORY,
3414
3703
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
3415
3704
  inject: [
3416
- import_nestjs_agent_core21.AGENT_OPTIONS
3705
+ import_nestjs_agent_core23.AGENT_OPTIONS
3417
3706
  ]
3418
3707
  },
3419
3708
  {
3420
- provide: import_nestjs_agent_core21.AGENT_SINK,
3709
+ provide: import_nestjs_agent_core23.AGENT_SINK,
3421
3710
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
3422
3711
  inject: [
3423
- import_nestjs_agent_core21.AGENT_OPTIONS
3712
+ import_nestjs_agent_core23.AGENT_OPTIONS
3424
3713
  ]
3425
3714
  },
3426
3715
  {
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"),
3716
+ provide: import_nestjs_agent_core23.AGENT_ROLES_POLICY,
3717
+ useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core23.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
3429
3718
  inject: [
3430
- import_nestjs_agent_core21.AGENT_OPTIONS
3719
+ import_nestjs_agent_core23.AGENT_OPTIONS
3431
3720
  ]
3432
3721
  },
3433
3722
  {
3434
- provide: import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER,
3723
+ provide: import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER,
3435
3724
  useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
3436
3725
  inject: [
3437
- import_nestjs_agent_core21.AGENT_OPTIONS
3726
+ import_nestjs_agent_core23.AGENT_OPTIONS
3438
3727
  ]
3439
3728
  },
3440
3729
  {
3441
- provide: import_nestjs_agent_core21.AGENT_MODEL,
3730
+ provide: import_nestjs_agent_core23.AGENT_MODEL,
3442
3731
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
3443
3732
  inject: [
3444
- import_nestjs_agent_core21.AGENT_OPTIONS
3733
+ import_nestjs_agent_core23.AGENT_OPTIONS
3445
3734
  ]
3446
3735
  },
3447
3736
  {
3448
3737
  // An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
3449
3738
  // store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
3450
3739
  // the loop already writes, so enforcement needs no extra shared state across replicas.
3451
- provide: import_nestjs_agent_core21.AGENT_QUOTA_STORE,
3740
+ provide: import_nestjs_agent_core23.AGENT_QUOTA_STORE,
3452
3741
  useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
3453
3742
  inject: [
3454
- import_nestjs_agent_core21.AGENT_OPTIONS,
3455
- import_nestjs_agent_core21.AGENT_STORE
3743
+ import_nestjs_agent_core23.AGENT_OPTIONS,
3744
+ import_nestjs_agent_core23.AGENT_STORE
3745
+ ]
3746
+ },
3747
+ {
3748
+ provide: import_nestjs_agent_core23.AGENT_QUOTA_PROVIDER,
3749
+ useFactory: /* @__PURE__ */ __name((o, store, quota) => o.quotaProvider ?? new LedgerQuotaProvider(store, quota, o.quotaLimits), "useFactory"),
3750
+ inject: [
3751
+ import_nestjs_agent_core23.AGENT_OPTIONS,
3752
+ import_nestjs_agent_core23.AGENT_STORE,
3753
+ import_nestjs_agent_core23.AGENT_QUOTA_STORE
3754
+ ]
3755
+ },
3756
+ {
3757
+ provide: import_nestjs_agent_core23.AGENT_MODEL_CATALOG,
3758
+ useFactory: /* @__PURE__ */ __name((o) => o.models, "useFactory"),
3759
+ inject: [
3760
+ import_nestjs_agent_core23.AGENT_OPTIONS
3456
3761
  ]
3457
3762
  },
3458
3763
  AgentDepsFactory2,
3459
3764
  {
3460
- provide: import_nestjs_agent_core21.AGENT_DEPS_FACTORY,
3765
+ provide: import_nestjs_agent_core23.AGENT_DEPS_FACTORY,
3461
3766
  useExisting: AgentDepsFactory2
3462
3767
  },
3463
3768
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -3471,22 +3776,22 @@ function sharedProviders(durable, includeStore) {
3471
3776
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
3472
3777
  AgentApprovalPortAdapter,
3473
3778
  {
3474
- provide: import_nestjs_agent_core21.AGENT_APPROVAL_PORT,
3779
+ provide: import_nestjs_agent_core23.AGENT_APPROVAL_PORT,
3475
3780
  useExisting: AgentApprovalPortAdapter
3476
3781
  }
3477
3782
  ];
3478
3783
  if (includeStore) {
3479
3784
  providers.push({
3480
- provide: import_nestjs_agent_core21.AGENT_STORE,
3785
+ provide: import_nestjs_agent_core23.AGENT_STORE,
3481
3786
  useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
3482
3787
  inject: [
3483
- import_nestjs_agent_core21.AGENT_OPTIONS
3788
+ import_nestjs_agent_core23.AGENT_OPTIONS
3484
3789
  ]
3485
3790
  });
3486
3791
  }
3487
3792
  if (durable) {
3488
3793
  providers.push({
3489
- provide: import_nestjs_agent_core21.AGENT_RUNNER,
3794
+ provide: import_nestjs_agent_core23.AGENT_RUNNER,
3490
3795
  useFactory: /* @__PURE__ */ __name((durableRunner) => {
3491
3796
  if (durableRunner === void 0) {
3492
3797
  throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
@@ -3495,14 +3800,14 @@ function sharedProviders(durable, includeStore) {
3495
3800
  }, "useFactory"),
3496
3801
  inject: [
3497
3802
  {
3498
- token: import_nestjs_agent_core21.AGENT_DURABLE_RUNNER,
3803
+ token: import_nestjs_agent_core23.AGENT_DURABLE_RUNNER,
3499
3804
  optional: true
3500
3805
  }
3501
3806
  ]
3502
3807
  });
3503
3808
  } else {
3504
3809
  providers.push({
3505
- provide: import_nestjs_agent_core21.AGENT_RUNNER,
3810
+ provide: import_nestjs_agent_core23.AGENT_RUNNER,
3506
3811
  useExisting: InlineAgentRunner
3507
3812
  });
3508
3813
  }
@@ -3511,25 +3816,27 @@ function sharedProviders(durable, includeStore) {
3511
3816
  __name(sharedProviders, "sharedProviders");
3512
3817
  function exportsFor(includeStore) {
3513
3818
  return [
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,
3819
+ import_nestjs_agent_core23.AGENT_OPTIONS,
3820
+ import_nestjs_agent_core23.AGENT_TOOL_REGISTRY,
3821
+ import_nestjs_agent_core23.AGENT_REGISTRY,
3822
+ import_nestjs_agent_core23.AGENT_SINK,
3823
+ import_nestjs_agent_core23.AGENT_ROLES_POLICY,
3824
+ import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER,
3825
+ import_nestjs_agent_core23.AGENT_MODEL,
3521
3826
  ...includeStore ? [
3522
- import_nestjs_agent_core21.AGENT_STORE
3827
+ import_nestjs_agent_core23.AGENT_STORE
3523
3828
  ] : [],
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,
3829
+ import_nestjs_agent_core23.AGENT_QUOTA_STORE,
3830
+ import_nestjs_agent_core23.AGENT_MODEL_CATALOG,
3831
+ import_nestjs_agent_core23.AGENT_QUOTA_PROVIDER,
3832
+ import_nestjs_agent_core23.AGENT_PROMPT_CONTRIBUTORS,
3833
+ import_nestjs_agent_core23.AGENT_SKILLS,
3834
+ import_nestjs_agent_core23.AGENT_MEMORY,
3835
+ import_nestjs_agent_core23.AGENT_DEPS_FACTORY,
3529
3836
  AgentDepsFactory2,
3530
3837
  AgentService,
3531
3838
  InlineAgentRunner,
3532
- import_nestjs_agent_core21.AGENT_APPROVAL_PORT
3839
+ import_nestjs_agent_core23.AGENT_APPROVAL_PORT
3533
3840
  ];
3534
3841
  }
3535
3842
  __name(exportsFor, "exportsFor");
@@ -3542,7 +3849,8 @@ var BASE_CONTROLLERS = [
3542
3849
  SkillsController,
3543
3850
  MemoriesController,
3544
3851
  ToolsController,
3545
- MessagesController
3852
+ MessagesController,
3853
+ ModelsController
3546
3854
  ];
3547
3855
  var GUARDABLE_CONTROLLERS = [
3548
3856
  ...BASE_CONTROLLERS,
@@ -3600,7 +3908,7 @@ var AgentModule = class _AgentModule {
3600
3908
  controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
3601
3909
  providers: [
3602
3910
  {
3603
- provide: import_nestjs_agent_core21.AGENT_OPTIONS,
3911
+ provide: import_nestjs_agent_core23.AGENT_OPTIONS,
3604
3912
  useValue: options
3605
3913
  },
3606
3914
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -3624,7 +3932,7 @@ var AgentModule = class _AgentModule {
3624
3932
  controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
3625
3933
  providers: [
3626
3934
  {
3627
- provide: import_nestjs_agent_core21.AGENT_OPTIONS,
3935
+ provide: import_nestjs_agent_core23.AGENT_OPTIONS,
3628
3936
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
3629
3937
  // authoritative on the async config object (they decided the actual wiring above), and
3630
3938
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -3645,13 +3953,13 @@ var AgentModule = class _AgentModule {
3645
3953
  };
3646
3954
  }
3647
3955
  };
3648
- AgentModule = _ts_decorate18([
3649
- (0, import_common18.Global)(),
3650
- (0, import_common18.Module)({})
3956
+ AgentModule = _ts_decorate19([
3957
+ (0, import_common19.Global)(),
3958
+ (0, import_common19.Module)({})
3651
3959
  ], AgentModule);
3652
3960
 
3653
3961
  // src/resolver/header-actor-resolver.ts
3654
- var import_common19 = require("@nestjs/common");
3962
+ var import_common20 = require("@nestjs/common");
3655
3963
  function readHeader(req, name) {
3656
3964
  if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
3657
3965
  const { headers } = req;
@@ -3667,7 +3975,7 @@ var HeaderActorResolver = class {
3667
3975
  resolve(req) {
3668
3976
  const id = readHeader(req, "x-actor-id");
3669
3977
  if (id === void 0 || id.length === 0) {
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.");
3978
+ throw new import_common20.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.");
3671
3979
  }
3672
3980
  const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
3673
3981
  const tenantRef = readHeader(req, "x-tenant-ref");
@@ -3703,9 +4011,11 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
3703
4011
  HeaderActorResolver,
3704
4012
  InProcessTokenStreamSink,
3705
4013
  InlineAgentRunner,
4014
+ LedgerQuotaProvider,
3706
4015
  LedgerQuotaStore,
3707
4016
  MemoriesController,
3708
4017
  MessagesController,
4018
+ ModelsController,
3709
4019
  SKILL_METADATA,
3710
4020
  SYSTEM_PROMPT_CONTRIBUTOR_METADATA,
3711
4021
  SYSTEM_PROMPT_METADATA,