@dudousxd/nestjs-agent 1.11.0 → 1.12.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.
@@ -828,8 +828,8 @@ AgentDurableModule = _ts_decorate4([
828
828
  ], AgentDurableModule);
829
829
 
830
830
  // src/agent.module.ts
831
- var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
832
- var import_common23 = require("@nestjs/common");
831
+ var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
832
+ var import_common24 = require("@nestjs/common");
833
833
  var import_core4 = require("@nestjs/core");
834
834
 
835
835
  // src/agent-deps.factory.ts
@@ -879,11 +879,10 @@ var AgentDepsFactory2 = class {
879
879
  registry;
880
880
  agents;
881
881
  promptContributors;
882
- quota;
883
882
  pricingStore;
884
883
  skills;
885
884
  memory;
886
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, quota, pricingStore, skills, memory) {
885
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory) {
887
886
  this.options = options;
888
887
  this.model = model;
889
888
  this.store = store;
@@ -892,7 +891,6 @@ var AgentDepsFactory2 = class {
892
891
  this.registry = registry;
893
892
  this.agents = agents;
894
893
  this.promptContributors = promptContributors;
895
- this.quota = quota;
896
894
  this.pricingStore = pricingStore;
897
895
  this.skills = skills;
898
896
  this.memory = memory;
@@ -964,9 +962,6 @@ var AgentDepsFactory2 = class {
964
962
  ...definition?.modelId !== void 0 ? {
965
963
  modelId: definition.modelId
966
964
  } : {},
967
- ...this.quota !== void 0 ? {
968
- quota: this.quota
969
- } : {},
970
965
  ...this.pricingStore !== void 0 ? {
971
966
  pricingStore: this.pricingStore
972
967
  } : {},
@@ -1073,13 +1068,12 @@ AgentDepsFactory2 = _ts_decorate5([
1073
1068
  _ts_param4(5, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_TOOL_REGISTRY)),
1074
1069
  _ts_param4(6, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_REGISTRY)),
1075
1070
  _ts_param4(7, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_PROMPT_CONTRIBUTORS)),
1076
- _ts_param4(8, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_QUOTA_STORE)),
1071
+ _ts_param4(8, (0, import_common5.Optional)()),
1072
+ _ts_param4(8, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_PRICING_STORE)),
1077
1073
  _ts_param4(9, (0, import_common5.Optional)()),
1078
- _ts_param4(9, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_PRICING_STORE)),
1074
+ _ts_param4(9, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_SKILLS)),
1079
1075
  _ts_param4(10, (0, import_common5.Optional)()),
1080
- _ts_param4(10, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_SKILLS)),
1081
- _ts_param4(11, (0, import_common5.Optional)()),
1082
- _ts_param4(11, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_MEMORY)),
1076
+ _ts_param4(10, (0, import_common5.Inject)(import_nestjs_agent_core6.AGENT_MEMORY)),
1083
1077
  _ts_metadata4("design:type", Function),
1084
1078
  _ts_metadata4("design:paramtypes", [
1085
1079
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -1092,7 +1086,6 @@ AgentDepsFactory2 = _ts_decorate5([
1092
1086
  Array,
1093
1087
  Object,
1094
1088
  Object,
1095
- Object,
1096
1089
  Object
1097
1090
  ])
1098
1091
  ], AgentDepsFactory2);
@@ -1133,16 +1126,14 @@ var AgentService = class {
1133
1126
  runner;
1134
1127
  store;
1135
1128
  deps;
1136
- quota;
1137
1129
  staging;
1138
1130
  models;
1139
1131
  quotaProvider;
1140
1132
  options;
1141
- constructor(runner, store, deps, quota, staging, models, quotaProvider, options) {
1133
+ constructor(runner, store, deps, staging, models, quotaProvider, options) {
1142
1134
  this.runner = runner;
1143
1135
  this.store = store;
1144
1136
  this.deps = deps;
1145
- this.quota = quota;
1146
1137
  this.staging = staging;
1147
1138
  this.models = models;
1148
1139
  this.quotaProvider = quotaProvider;
@@ -1158,33 +1149,23 @@ var AgentService = class {
1158
1149
  actor
1159
1150
  });
1160
1151
  }
1161
- const today = await this.quotaToday(actor.id);
1152
+ const { usedTokens, costUsd } = await this.store.quotaToday(actor.id, utcDay());
1162
1153
  return {
1163
1154
  windows: [
1164
1155
  {
1165
1156
  period: "day",
1166
- usedTokens: today.usedTokens,
1167
- ...today.limitTokens !== null ? {
1168
- limitTokens: today.limitTokens
1169
- } : {},
1170
- usedUsd: today.costUsd
1157
+ usedTokens,
1158
+ usedUsd: costUsd
1171
1159
  }
1172
- ],
1173
- ...today.withinLimit ? {} : {
1174
- blocked: {
1175
- period: "day"
1176
- }
1177
- }
1160
+ ]
1178
1161
  };
1179
1162
  }
1180
1163
  /**
1181
1164
  * Refuse a turn the actor's budget no longer covers — only when the host configured one
1182
- * (`quotaProvider` or `quotaLimits`): the default report is informational, and the daily token
1183
- * quota the loop enforces keeps working as it always has.
1165
+ * (`quota`): the default report is informational.
1184
1166
  */
1185
1167
  async assertWithinQuota(actor) {
1186
- const gated = this.options?.quotaProvider !== void 0 || this.options?.quotaLimits !== void 0;
1187
- if (!gated || this.quotaProvider === void 0) {
1168
+ if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
1188
1169
  return;
1189
1170
  }
1190
1171
  const { blocked } = await this.quotaProvider.report({
@@ -1435,7 +1416,7 @@ var AgentService = class {
1435
1416
  async getThread(actor, threadId) {
1436
1417
  await this.assertOwnsThread(actor, threadId);
1437
1418
  const thread = await this.store.getThread(threadId);
1438
- return thread === null ? null : this.toDetailView(thread);
1419
+ return thread === null ? null : this.toDetailView(thread, actor);
1439
1420
  }
1440
1421
  async deleteThread(actor, threadId) {
1441
1422
  await this.assertOwnsThread(actor, threadId);
@@ -1527,19 +1508,46 @@ var AgentService = class {
1527
1508
  ...thread,
1528
1509
  defaultAgent: thread.defaultAgent ?? null,
1529
1510
  model: thread.model ?? null,
1530
- activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
1511
+ activeRunId: await this.store.activeRunForThread?.(thread.id) ?? thread.activeRunId ?? null
1531
1512
  };
1532
1513
  }
1533
- async toDetailView(thread) {
1514
+ async toDetailView(thread, actor) {
1534
1515
  const summary = await this.toSummaryView(thread);
1535
1516
  return {
1536
1517
  ...summary,
1537
- messages: thread.messages,
1538
- ...thread.activeStreamId !== void 0 ? {
1539
- activeStreamId: thread.activeStreamId
1540
- } : {}
1518
+ messages: await this.freshAttachmentUrls(thread.messages, actor)
1541
1519
  };
1542
1520
  }
1521
+ /**
1522
+ * Re-mint each replayed attachment's url from the staging store, by `mediaId`: the url persisted
1523
+ * with the message was minted for THAT turn (a presigned url with an expiry), so an old turn would
1524
+ * otherwise show a dead link. The store's own access check applies — an attachment it will not
1525
+ * resolve for this actor keeps the url it was stored with.
1526
+ */
1527
+ async freshAttachmentUrls(messages, actor) {
1528
+ const staging = this.staging;
1529
+ if (staging === void 0 || !messages.some((message) => message.attachments?.length)) {
1530
+ return messages;
1531
+ }
1532
+ return Promise.all(messages.map(async (message) => {
1533
+ if (message.attachments === void 0 || message.attachments.length === 0) return message;
1534
+ const attachments = await Promise.all(message.attachments.map(async (attachment) => {
1535
+ try {
1536
+ const fresh = await staging.resolve({
1537
+ mediaId: attachment.mediaId,
1538
+ actor
1539
+ });
1540
+ return fresh ?? attachment;
1541
+ } catch {
1542
+ return attachment;
1543
+ }
1544
+ }));
1545
+ return {
1546
+ ...message,
1547
+ attachments
1548
+ };
1549
+ }));
1550
+ }
1543
1551
  async promoteThread(actor, threadId) {
1544
1552
  await this.assertOwnsThread(actor, threadId);
1545
1553
  return this.store.promoteThread(threadId);
@@ -1649,30 +1657,6 @@ var AgentService = class {
1649
1657
  return list;
1650
1658
  }
1651
1659
  /**
1652
- * The day's usage for the badge: tokens + summed USD cost from the store, and the configured
1653
- * limit from the quota store (null → unlimited). `withinLimit` comes from the quota store so it
1654
- * can never drift from what enforcement uses.
1655
- */
1656
- async quotaToday(actorRef) {
1657
- const day = utcDay();
1658
- const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, day);
1659
- if (this.quota === void 0) {
1660
- return {
1661
- usedTokens,
1662
- costUsd,
1663
- limitTokens: null,
1664
- withinLimit: true
1665
- };
1666
- }
1667
- const state = await this.quota.check(actorRef, day);
1668
- return {
1669
- usedTokens: state.usedTokens,
1670
- costUsd,
1671
- limitTokens: state.limitTokens,
1672
- withinLimit: state.withinLimit
1673
- };
1674
- }
1675
- /**
1676
1660
  * Authorization seam for thread-scoped endpoints: the caller must own the thread. A missing
1677
1661
  * thread is a 404; someone else's thread is a 403 — one actor never touches another's thread.
1678
1662
  */
@@ -1791,21 +1775,19 @@ AgentService = _ts_decorate6([
1791
1775
  _ts_param5(0, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_RUNNER)),
1792
1776
  _ts_param5(1, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_STORE)),
1793
1777
  _ts_param5(2, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_DEPS_FACTORY)),
1794
- _ts_param5(3, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_QUOTA_STORE)),
1778
+ _ts_param5(3, (0, import_common6.Optional)()),
1779
+ _ts_param5(3, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_ATTACHMENT_STAGING)),
1795
1780
  _ts_param5(4, (0, import_common6.Optional)()),
1796
- _ts_param5(4, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_ATTACHMENT_STAGING)),
1781
+ _ts_param5(4, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_MODEL_CATALOG)),
1797
1782
  _ts_param5(5, (0, import_common6.Optional)()),
1798
- _ts_param5(5, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_MODEL_CATALOG)),
1783
+ _ts_param5(5, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_QUOTA_PROVIDER)),
1799
1784
  _ts_param5(6, (0, import_common6.Optional)()),
1800
- _ts_param5(6, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_QUOTA_PROVIDER)),
1801
- _ts_param5(7, (0, import_common6.Optional)()),
1802
- _ts_param5(7, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_OPTIONS)),
1785
+ _ts_param5(6, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_OPTIONS)),
1803
1786
  _ts_metadata5("design:type", Function),
1804
1787
  _ts_metadata5("design:paramtypes", [
1805
1788
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
1806
1789
  typeof AgentStore === "undefined" ? Object : AgentStore,
1807
1790
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
1808
- Object,
1809
1791
  typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
1810
1792
  typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
1811
1793
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
@@ -1951,6 +1933,33 @@ AgentsController = _ts_decorate8([
1951
1933
  var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
1952
1934
  var import_common9 = require("@nestjs/common");
1953
1935
  var import_platform_express = require("@nestjs/platform-express");
1936
+
1937
+ // src/attachment-limits.ts
1938
+ var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
1939
+ var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
1940
+ "image/png",
1941
+ "image/jpeg",
1942
+ "image/gif",
1943
+ "image/webp",
1944
+ "application/pdf",
1945
+ "text/plain",
1946
+ "text/csv"
1947
+ ];
1948
+ var MAX_ATTACHMENTS_PER_MESSAGE = 10;
1949
+ function attachmentLimits(options, staging) {
1950
+ const declared = staging?.describe?.();
1951
+ const own = options?.attachments;
1952
+ return {
1953
+ enabled: staging !== void 0,
1954
+ upload: staging === void 0 ? null : declared?.upload ?? "multipart",
1955
+ maxBytes: declared?.maxBytes ?? own?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,
1956
+ allowedContentTypes: declared?.allowedContentTypes ?? own?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES,
1957
+ maxPerMessage: MAX_ATTACHMENTS_PER_MESSAGE
1958
+ };
1959
+ }
1960
+ __name(attachmentLimits, "attachmentLimits");
1961
+
1962
+ // src/controller/attachments.controller.ts
1954
1963
  function _ts_decorate9(decorators, target, key, desc) {
1955
1964
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1956
1965
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1977,18 +1986,8 @@ function _ts_param7(paramIndex, decorator) {
1977
1986
  };
1978
1987
  }
1979
1988
  __name(_ts_param7, "_ts_param");
1980
- var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
1981
1989
  var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
1982
1990
  var ATTACHMENT_PAGE_SIZE = 50;
1983
- var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
1984
- "image/png",
1985
- "image/jpeg",
1986
- "image/gif",
1987
- "image/webp",
1988
- "application/pdf",
1989
- "text/plain",
1990
- "text/csv"
1991
- ];
1992
1991
  var AttachmentsController = class {
1993
1992
  static {
1994
1993
  __name(this, "AttachmentsController");
@@ -2004,17 +2003,6 @@ var AttachmentsController = class {
2004
2003
  this.staging = staging;
2005
2004
  }
2006
2005
  /**
2007
- * `attachments.upload: true` is what mounts this controller at all (see `agent.module.ts`), so by
2008
- * the time an instance exists the host clearly intends uploads to work. Fail boot loudly rather
2009
- * than mounting a controller that would 501 on every single request because nobody bound
2010
- * `AGENT_ATTACHMENT_STAGING`.
2011
- */
2012
- onModuleInit() {
2013
- if (this.options.attachments?.upload === true && this.staging === void 0) {
2014
- throw new Error("AgentModule: attachments.upload is true but no AGENT_ATTACHMENT_STAGING provider is bound. Bind one (e.g. `{ provide: AGENT_ATTACHMENT_STAGING, useClass: MyStagingStore }`) in a module imported alongside AgentModule, or set attachments.upload to false.");
2015
- }
2016
- }
2017
- /**
2018
2006
  * The caller's own staged files, newest first — the one question `GET /agent/threads/:id` cannot
2019
2007
  * answer, since an upload that was never sent belongs to no thread.
2020
2008
  *
@@ -2031,16 +2019,15 @@ var AttachmentsController = class {
2031
2019
  }
2032
2020
  async upload(req, file) {
2033
2021
  if (this.staging === void 0) {
2034
- throw new import_common9.NotImplementedException("Attachment upload is not configured on this server.");
2022
+ throw new import_common9.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2035
2023
  }
2036
2024
  if (file === void 0) {
2037
2025
  throw new import_common9.BadRequestException('multipart field "file" is required');
2038
2026
  }
2039
- const allowedContentTypes = this.options.attachments?.allowedContentTypes ?? DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES;
2027
+ const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
2040
2028
  if (!allowedContentTypes.includes(file.mimetype)) {
2041
2029
  throw new import_common9.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
2042
2030
  }
2043
- const maxBytes = this.options.attachments?.maxBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES;
2044
2031
  if (file.size > maxBytes) {
2045
2032
  throw new import_common9.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
2046
2033
  }
@@ -2123,7 +2110,6 @@ function _ts_param8(paramIndex, decorator) {
2123
2110
  };
2124
2111
  }
2125
2112
  __name(_ts_param8, "_ts_param");
2126
- var MAX_ATTACHMENTS_PER_MESSAGE = 10;
2127
2113
  function attachmentRefs(claimed) {
2128
2114
  if (claimed === void 0) {
2129
2115
  return [];
@@ -2138,6 +2124,9 @@ function attachmentRefs(claimed) {
2138
2124
  if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
2139
2125
  throw new import_common10.BadRequestException("each attachment must be an object with a mediaId");
2140
2126
  }
2127
+ if (Object.keys(entry).some((key) => key !== "mediaId")) {
2128
+ throw new import_common10.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
2129
+ }
2141
2130
  const { mediaId } = entry;
2142
2131
  if (typeof mediaId !== "string" || mediaId.length === 0) {
2143
2132
  throw new import_common10.BadRequestException("each attachment must carry a non-empty string mediaId");
@@ -2333,9 +2322,98 @@ function parseCursor(raw) {
2333
2322
  }
2334
2323
  __name(parseCursor, "parseCursor");
2335
2324
 
2336
- // src/controller/memories.controller.ts
2325
+ // src/controller/config.controller.ts
2337
2326
  var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2338
2327
  var import_common11 = require("@nestjs/common");
2328
+
2329
+ // src/resolver/anonymous-actor-resolver.ts
2330
+ var import_node_crypto2 = require("crypto");
2331
+ var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
2332
+ var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
2333
+ function readCookie(req, name) {
2334
+ const header = req.headers?.cookie;
2335
+ const raw = Array.isArray(header) ? header.join("; ") : header;
2336
+ if (raw === void 0) return void 0;
2337
+ for (const pair of raw.split(";")) {
2338
+ const index = pair.indexOf("=");
2339
+ if (index === -1) continue;
2340
+ if (pair.slice(0, index).trim() === name) {
2341
+ try {
2342
+ return decodeURIComponent(pair.slice(index + 1).trim());
2343
+ } catch {
2344
+ return void 0;
2345
+ }
2346
+ }
2347
+ }
2348
+ return void 0;
2349
+ }
2350
+ __name(readCookie, "readCookie");
2351
+ function isHttps(req) {
2352
+ if (req.secure === true) return true;
2353
+ const forwarded = req.headers?.["x-forwarded-proto"];
2354
+ const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
2355
+ return proto?.split(",")[0]?.trim() === "https";
2356
+ }
2357
+ __name(isHttps, "isHttps");
2358
+ var AnonymousActorResolver = class {
2359
+ static {
2360
+ __name(this, "AnonymousActorResolver");
2361
+ }
2362
+ options;
2363
+ cookieName;
2364
+ roles;
2365
+ constructor(options = {}) {
2366
+ this.options = options;
2367
+ this.cookieName = options.cookieName ?? "agent_anon";
2368
+ this.roles = options.roles ?? [
2369
+ "anonymous"
2370
+ ];
2371
+ }
2372
+ resolve(request) {
2373
+ const req = typeof request === "object" && request !== null ? request : {};
2374
+ let token = req[MINTED] ?? readCookie(req, this.cookieName);
2375
+ if (token === void 0 || !TOKEN_PATTERN.test(token)) {
2376
+ token = (0, import_node_crypto2.randomBytes)(32).toString("base64url");
2377
+ req[MINTED] = token;
2378
+ this.setCookie(req, token);
2379
+ }
2380
+ const digest = (0, import_node_crypto2.createHash)("sha256").update(token).digest("base64url").slice(0, 32);
2381
+ return {
2382
+ id: `anon:${digest}`,
2383
+ roles: [
2384
+ ...this.roles
2385
+ ]
2386
+ };
2387
+ }
2388
+ setCookie(req, token) {
2389
+ const res = req.res;
2390
+ if (res?.setHeader === void 0 || res.headersSent === true) return;
2391
+ const sameSite = this.options.sameSite ?? "lax";
2392
+ const secureOption = this.options.secure ?? "auto";
2393
+ const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
2394
+ const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
2395
+ const cookie = [
2396
+ `${this.cookieName}=${token}`,
2397
+ `Path=${this.options.path ?? "/"}`,
2398
+ `Max-Age=${maxAge}`,
2399
+ "HttpOnly",
2400
+ `SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
2401
+ ...secure ? [
2402
+ "Secure"
2403
+ ] : []
2404
+ ].join("; ");
2405
+ const existing = res.getHeader?.("Set-Cookie");
2406
+ const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
2407
+ String(existing)
2408
+ ] : [];
2409
+ res.setHeader("Set-Cookie", [
2410
+ ...list,
2411
+ cookie
2412
+ ]);
2413
+ }
2414
+ };
2415
+
2416
+ // src/controller/config.controller.ts
2339
2417
  function _ts_decorate11(decorators, target, key, desc) {
2340
2418
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2341
2419
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2362,6 +2440,91 @@ function _ts_param9(paramIndex, decorator) {
2362
2440
  };
2363
2441
  }
2364
2442
  __name(_ts_param9, "_ts_param");
2443
+ var ConfigController = class {
2444
+ static {
2445
+ __name(this, "ConfigController");
2446
+ }
2447
+ options;
2448
+ actorResolver;
2449
+ staging;
2450
+ models;
2451
+ constructor(options, actorResolver, staging, models) {
2452
+ this.options = options;
2453
+ this.actorResolver = actorResolver;
2454
+ this.staging = staging;
2455
+ this.models = models;
2456
+ }
2457
+ async config(req) {
2458
+ await this.actorResolver.resolve(req);
2459
+ return {
2460
+ attachments: attachmentLimits(this.options, this.staging),
2461
+ models: {
2462
+ enabled: this.models !== void 0
2463
+ },
2464
+ quota: {
2465
+ enforced: this.options.quota !== void 0
2466
+ },
2467
+ identity: {
2468
+ anonymous: this.actorResolver instanceof AnonymousActorResolver
2469
+ }
2470
+ };
2471
+ }
2472
+ };
2473
+ _ts_decorate11([
2474
+ (0, import_common11.Get)(),
2475
+ _ts_param9(0, (0, import_common11.Req)()),
2476
+ _ts_metadata10("design:type", Function),
2477
+ _ts_metadata10("design:paramtypes", [
2478
+ typeof Request === "undefined" ? Object : Request
2479
+ ]),
2480
+ _ts_metadata10("design:returntype", Promise)
2481
+ ], ConfigController.prototype, "config", null);
2482
+ ConfigController = _ts_decorate11([
2483
+ (0, import_common11.Controller)("config"),
2484
+ _ts_param9(0, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
2485
+ _ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
2486
+ _ts_param9(2, (0, import_common11.Optional)()),
2487
+ _ts_param9(2, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ATTACHMENT_STAGING)),
2488
+ _ts_param9(3, (0, import_common11.Optional)()),
2489
+ _ts_param9(3, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_MODEL_CATALOG)),
2490
+ _ts_metadata10("design:type", Function),
2491
+ _ts_metadata10("design:paramtypes", [
2492
+ typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
2493
+ typeof ActorResolver === "undefined" ? Object : ActorResolver,
2494
+ Object,
2495
+ Object
2496
+ ])
2497
+ ], ConfigController);
2498
+
2499
+ // src/controller/memories.controller.ts
2500
+ var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2501
+ var import_common12 = require("@nestjs/common");
2502
+ function _ts_decorate12(decorators, target, key, desc) {
2503
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2504
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2505
+ r = Reflect.decorate(decorators, target, key, desc);
2506
+ } else {
2507
+ for (var i = decorators.length - 1; i >= 0; i--) {
2508
+ if (d = decorators[i]) {
2509
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2510
+ }
2511
+ }
2512
+ }
2513
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2514
+ }
2515
+ __name(_ts_decorate12, "_ts_decorate");
2516
+ function _ts_metadata11(metadataKey, metadataValue) {
2517
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2518
+ return Reflect.metadata(metadataKey, metadataValue);
2519
+ }
2520
+ }
2521
+ __name(_ts_metadata11, "_ts_metadata");
2522
+ function _ts_param10(paramIndex, decorator) {
2523
+ return function(target, key) {
2524
+ decorator(target, key, paramIndex);
2525
+ };
2526
+ }
2527
+ __name(_ts_param10, "_ts_param");
2365
2528
  var MemoriesController = class {
2366
2529
  static {
2367
2530
  __name(this, "MemoriesController");
@@ -2395,20 +2558,20 @@ var MemoriesController = class {
2395
2558
  */
2396
2559
  async forget(req, id) {
2397
2560
  if (this.memory === void 0) {
2398
- throw new import_common11.NotFoundException("No memory is configured in this deployment.");
2561
+ throw new import_common12.NotFoundException("No memory is configured in this deployment.");
2399
2562
  }
2400
2563
  const actor = await this.actorResolver.resolve(req);
2401
2564
  const digest = await this.unbounded("", actor);
2402
2565
  const entry = digest.entries.find((candidate) => candidate.id === id);
2403
2566
  if (entry === void 0) {
2404
- throw new import_common11.NotFoundException(`No memory with id "${id}".`);
2567
+ throw new import_common12.NotFoundException(`No memory with id "${id}".`);
2405
2568
  }
2406
- const verdict = (0, import_nestjs_agent_core12.memoryForgetVerdict)({
2569
+ const verdict = (0, import_nestjs_agent_core13.memoryForgetVerdict)({
2407
2570
  record: entry,
2408
2571
  actor
2409
2572
  });
2410
2573
  if (!verdict.allowed) {
2411
- throw new import_common11.ForbiddenException(verdict.reason);
2574
+ throw new import_common12.ForbiddenException(verdict.reason);
2412
2575
  }
2413
2576
  return {
2414
2577
  forgotten: await this.memory.provider.forget({
@@ -2422,7 +2585,7 @@ var MemoriesController = class {
2422
2585
  }
2423
2586
  async unbounded(threadId, actor) {
2424
2587
  const config = this.memory;
2425
- return await (0, import_nestjs_agent_core12.offerMemories)({
2588
+ return await (0, import_nestjs_agent_core13.offerMemories)({
2426
2589
  config: {
2427
2590
  ...config,
2428
2591
  maxMemories: Number.POSITIVE_INFINITY
@@ -2434,44 +2597,44 @@ var MemoriesController = class {
2434
2597
  });
2435
2598
  }
2436
2599
  };
2437
- _ts_decorate11([
2438
- (0, import_common11.Get)(),
2439
- _ts_param9(0, (0, import_common11.Req)()),
2440
- _ts_param9(1, (0, import_common11.Query)("threadId")),
2441
- _ts_metadata10("design:type", Function),
2442
- _ts_metadata10("design:paramtypes", [
2600
+ _ts_decorate12([
2601
+ (0, import_common12.Get)(),
2602
+ _ts_param10(0, (0, import_common12.Req)()),
2603
+ _ts_param10(1, (0, import_common12.Query)("threadId")),
2604
+ _ts_metadata11("design:type", Function),
2605
+ _ts_metadata11("design:paramtypes", [
2443
2606
  typeof Request === "undefined" ? Object : Request,
2444
2607
  String
2445
2608
  ]),
2446
- _ts_metadata10("design:returntype", Promise)
2609
+ _ts_metadata11("design:returntype", Promise)
2447
2610
  ], MemoriesController.prototype, "list", null);
2448
- _ts_decorate11([
2449
- (0, import_common11.Delete)(":id"),
2450
- _ts_param9(0, (0, import_common11.Req)()),
2451
- _ts_param9(1, (0, import_common11.Param)("id")),
2452
- _ts_metadata10("design:type", Function),
2453
- _ts_metadata10("design:paramtypes", [
2611
+ _ts_decorate12([
2612
+ (0, import_common12.Delete)(":id"),
2613
+ _ts_param10(0, (0, import_common12.Req)()),
2614
+ _ts_param10(1, (0, import_common12.Param)("id")),
2615
+ _ts_metadata11("design:type", Function),
2616
+ _ts_metadata11("design:paramtypes", [
2454
2617
  typeof Request === "undefined" ? Object : Request,
2455
2618
  String
2456
2619
  ]),
2457
- _ts_metadata10("design:returntype", Promise)
2620
+ _ts_metadata11("design:returntype", Promise)
2458
2621
  ], MemoriesController.prototype, "forget", null);
2459
- MemoriesController = _ts_decorate11([
2460
- (0, import_common11.Controller)("memories"),
2461
- _ts_param9(0, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
2462
- _ts_param9(1, (0, import_common11.Optional)()),
2463
- _ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_MEMORY)),
2464
- _ts_metadata10("design:type", Function),
2465
- _ts_metadata10("design:paramtypes", [
2622
+ MemoriesController = _ts_decorate12([
2623
+ (0, import_common12.Controller)("memories"),
2624
+ _ts_param10(0, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
2625
+ _ts_param10(1, (0, import_common12.Optional)()),
2626
+ _ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_MEMORY)),
2627
+ _ts_metadata11("design:type", Function),
2628
+ _ts_metadata11("design:paramtypes", [
2466
2629
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2467
2630
  Object
2468
2631
  ])
2469
2632
  ], MemoriesController);
2470
2633
 
2471
2634
  // src/controller/messages.controller.ts
2472
- var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2473
- var import_common12 = require("@nestjs/common");
2474
- function _ts_decorate12(decorators, target, key, desc) {
2635
+ var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2636
+ var import_common13 = require("@nestjs/common");
2637
+ function _ts_decorate13(decorators, target, key, desc) {
2475
2638
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2476
2639
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2477
2640
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2484,19 +2647,19 @@ function _ts_decorate12(decorators, target, key, desc) {
2484
2647
  }
2485
2648
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2486
2649
  }
2487
- __name(_ts_decorate12, "_ts_decorate");
2488
- function _ts_metadata11(metadataKey, metadataValue) {
2650
+ __name(_ts_decorate13, "_ts_decorate");
2651
+ function _ts_metadata12(metadataKey, metadataValue) {
2489
2652
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2490
2653
  return Reflect.metadata(metadataKey, metadataValue);
2491
2654
  }
2492
2655
  }
2493
- __name(_ts_metadata11, "_ts_metadata");
2494
- function _ts_param10(paramIndex, decorator) {
2656
+ __name(_ts_metadata12, "_ts_metadata");
2657
+ function _ts_param11(paramIndex, decorator) {
2495
2658
  return function(target, key) {
2496
2659
  decorator(target, key, paramIndex);
2497
2660
  };
2498
2661
  }
2499
- __name(_ts_param10, "_ts_param");
2662
+ __name(_ts_param11, "_ts_param");
2500
2663
  var MessagesController = class {
2501
2664
  static {
2502
2665
  __name(this, "MessagesController");
@@ -2524,34 +2687,34 @@ var MessagesController = class {
2524
2687
  };
2525
2688
  }
2526
2689
  };
2527
- _ts_decorate12([
2528
- (0, import_common12.Post)(":id/feedback"),
2529
- (0, import_common12.HttpCode)(200),
2530
- _ts_param10(0, (0, import_common12.Req)()),
2531
- _ts_param10(1, (0, import_common12.Param)("id")),
2532
- _ts_param10(2, (0, import_common12.Body)()),
2533
- _ts_metadata11("design:type", Function),
2534
- _ts_metadata11("design:paramtypes", [
2690
+ _ts_decorate13([
2691
+ (0, import_common13.Post)(":id/feedback"),
2692
+ (0, import_common13.HttpCode)(200),
2693
+ _ts_param11(0, (0, import_common13.Req)()),
2694
+ _ts_param11(1, (0, import_common13.Param)("id")),
2695
+ _ts_param11(2, (0, import_common13.Body)()),
2696
+ _ts_metadata12("design:type", Function),
2697
+ _ts_metadata12("design:paramtypes", [
2535
2698
  typeof Request === "undefined" ? Object : Request,
2536
2699
  String,
2537
2700
  typeof FeedbackBody === "undefined" ? Object : FeedbackBody
2538
2701
  ]),
2539
- _ts_metadata11("design:returntype", Promise)
2702
+ _ts_metadata12("design:returntype", Promise)
2540
2703
  ], MessagesController.prototype, "feedback", null);
2541
- MessagesController = _ts_decorate12([
2542
- (0, import_common12.Controller)("messages"),
2543
- _ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
2544
- _ts_metadata11("design:type", Function),
2545
- _ts_metadata11("design:paramtypes", [
2704
+ MessagesController = _ts_decorate13([
2705
+ (0, import_common13.Controller)("messages"),
2706
+ _ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
2707
+ _ts_metadata12("design:type", Function),
2708
+ _ts_metadata12("design:paramtypes", [
2546
2709
  typeof AgentService === "undefined" ? Object : AgentService,
2547
2710
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2548
2711
  ])
2549
2712
  ], MessagesController);
2550
2713
 
2551
2714
  // src/controller/models.controller.ts
2552
- var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2553
- var import_common13 = require("@nestjs/common");
2554
- function _ts_decorate13(decorators, target, key, desc) {
2715
+ var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2716
+ var import_common14 = require("@nestjs/common");
2717
+ function _ts_decorate14(decorators, target, key, desc) {
2555
2718
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2556
2719
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2557
2720
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2564,19 +2727,19 @@ function _ts_decorate13(decorators, target, key, desc) {
2564
2727
  }
2565
2728
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2566
2729
  }
2567
- __name(_ts_decorate13, "_ts_decorate");
2568
- function _ts_metadata12(metadataKey, metadataValue) {
2730
+ __name(_ts_decorate14, "_ts_decorate");
2731
+ function _ts_metadata13(metadataKey, metadataValue) {
2569
2732
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2570
2733
  return Reflect.metadata(metadataKey, metadataValue);
2571
2734
  }
2572
2735
  }
2573
- __name(_ts_metadata12, "_ts_metadata");
2574
- function _ts_param11(paramIndex, decorator) {
2736
+ __name(_ts_metadata13, "_ts_metadata");
2737
+ function _ts_param12(paramIndex, decorator) {
2575
2738
  return function(target, key) {
2576
2739
  decorator(target, key, paramIndex);
2577
2740
  };
2578
2741
  }
2579
- __name(_ts_param11, "_ts_param");
2742
+ __name(_ts_param12, "_ts_param");
2580
2743
  var ModelsController = class {
2581
2744
  static {
2582
2745
  __name(this, "ModelsController");
@@ -2596,31 +2759,31 @@ var ModelsController = class {
2596
2759
  return this.agent.listModels(actor, agent);
2597
2760
  }
2598
2761
  };
2599
- _ts_decorate13([
2600
- (0, import_common13.Get)(),
2601
- _ts_param11(0, (0, import_common13.Req)()),
2602
- _ts_param11(1, (0, import_common13.Query)("agent")),
2603
- _ts_metadata12("design:type", Function),
2604
- _ts_metadata12("design:paramtypes", [
2762
+ _ts_decorate14([
2763
+ (0, import_common14.Get)(),
2764
+ _ts_param12(0, (0, import_common14.Req)()),
2765
+ _ts_param12(1, (0, import_common14.Query)("agent")),
2766
+ _ts_metadata13("design:type", Function),
2767
+ _ts_metadata13("design:paramtypes", [
2605
2768
  typeof Request === "undefined" ? Object : Request,
2606
2769
  String
2607
2770
  ]),
2608
- _ts_metadata12("design:returntype", Promise)
2771
+ _ts_metadata13("design:returntype", Promise)
2609
2772
  ], ModelsController.prototype, "list", null);
2610
- ModelsController = _ts_decorate13([
2611
- (0, import_common13.Controller)("models"),
2612
- _ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
2613
- _ts_metadata12("design:type", Function),
2614
- _ts_metadata12("design:paramtypes", [
2773
+ ModelsController = _ts_decorate14([
2774
+ (0, import_common14.Controller)("models"),
2775
+ _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
2776
+ _ts_metadata13("design:type", Function),
2777
+ _ts_metadata13("design:paramtypes", [
2615
2778
  typeof AgentService === "undefined" ? Object : AgentService,
2616
2779
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2617
2780
  ])
2618
2781
  ], ModelsController);
2619
2782
 
2620
2783
  // src/controller/quota.controller.ts
2621
- var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2622
- var import_common14 = require("@nestjs/common");
2623
- function _ts_decorate14(decorators, target, key, desc) {
2784
+ var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2785
+ var import_common15 = require("@nestjs/common");
2786
+ function _ts_decorate15(decorators, target, key, desc) {
2624
2787
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2625
2788
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2626
2789
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2633,19 +2796,19 @@ function _ts_decorate14(decorators, target, key, desc) {
2633
2796
  }
2634
2797
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2635
2798
  }
2636
- __name(_ts_decorate14, "_ts_decorate");
2637
- function _ts_metadata13(metadataKey, metadataValue) {
2799
+ __name(_ts_decorate15, "_ts_decorate");
2800
+ function _ts_metadata14(metadataKey, metadataValue) {
2638
2801
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2639
2802
  return Reflect.metadata(metadataKey, metadataValue);
2640
2803
  }
2641
2804
  }
2642
- __name(_ts_metadata13, "_ts_metadata");
2643
- function _ts_param12(paramIndex, decorator) {
2805
+ __name(_ts_metadata14, "_ts_metadata");
2806
+ function _ts_param13(paramIndex, decorator) {
2644
2807
  return function(target, key) {
2645
2808
  decorator(target, key, paramIndex);
2646
2809
  };
2647
2810
  }
2648
- __name(_ts_param12, "_ts_param");
2811
+ __name(_ts_param13, "_ts_param");
2649
2812
  var QuotaController = class {
2650
2813
  static {
2651
2814
  __name(this, "QuotaController");
@@ -2664,43 +2827,30 @@ var QuotaController = class {
2664
2827
  const actor = await this.actorResolver.resolve(req);
2665
2828
  return this.agent.quotaReport(actor);
2666
2829
  }
2667
- async today(req) {
2668
- const actor = await this.actorResolver.resolve(req);
2669
- return this.agent.quotaToday(actor.id);
2670
- }
2671
2830
  };
2672
- _ts_decorate14([
2673
- (0, import_common14.Get)(),
2674
- _ts_param12(0, (0, import_common14.Req)()),
2675
- _ts_metadata13("design:type", Function),
2676
- _ts_metadata13("design:paramtypes", [
2831
+ _ts_decorate15([
2832
+ (0, import_common15.Get)(),
2833
+ _ts_param13(0, (0, import_common15.Req)()),
2834
+ _ts_metadata14("design:type", Function),
2835
+ _ts_metadata14("design:paramtypes", [
2677
2836
  typeof Request === "undefined" ? Object : Request
2678
2837
  ]),
2679
- _ts_metadata13("design:returntype", Promise)
2838
+ _ts_metadata14("design:returntype", Promise)
2680
2839
  ], QuotaController.prototype, "report", null);
2681
- _ts_decorate14([
2682
- (0, import_common14.Get)("today"),
2683
- _ts_param12(0, (0, import_common14.Req)()),
2684
- _ts_metadata13("design:type", Function),
2685
- _ts_metadata13("design:paramtypes", [
2686
- typeof Request === "undefined" ? Object : Request
2687
- ]),
2688
- _ts_metadata13("design:returntype", Promise)
2689
- ], QuotaController.prototype, "today", null);
2690
- QuotaController = _ts_decorate14([
2691
- (0, import_common14.Controller)("quota"),
2692
- _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
2693
- _ts_metadata13("design:type", Function),
2694
- _ts_metadata13("design:paramtypes", [
2840
+ QuotaController = _ts_decorate15([
2841
+ (0, import_common15.Controller)("quota"),
2842
+ _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
2843
+ _ts_metadata14("design:type", Function),
2844
+ _ts_metadata14("design:paramtypes", [
2695
2845
  typeof AgentService === "undefined" ? Object : AgentService,
2696
2846
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2697
2847
  ])
2698
2848
  ], QuotaController);
2699
2849
 
2700
2850
  // src/controller/skills.controller.ts
2701
- var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2702
- var import_common15 = require("@nestjs/common");
2703
- function _ts_decorate15(decorators, target, key, desc) {
2851
+ var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2852
+ var import_common16 = require("@nestjs/common");
2853
+ function _ts_decorate16(decorators, target, key, desc) {
2704
2854
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2705
2855
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2706
2856
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2713,19 +2863,19 @@ function _ts_decorate15(decorators, target, key, desc) {
2713
2863
  }
2714
2864
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2715
2865
  }
2716
- __name(_ts_decorate15, "_ts_decorate");
2717
- function _ts_metadata14(metadataKey, metadataValue) {
2866
+ __name(_ts_decorate16, "_ts_decorate");
2867
+ function _ts_metadata15(metadataKey, metadataValue) {
2718
2868
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2719
2869
  return Reflect.metadata(metadataKey, metadataValue);
2720
2870
  }
2721
2871
  }
2722
- __name(_ts_metadata14, "_ts_metadata");
2723
- function _ts_param13(paramIndex, decorator) {
2872
+ __name(_ts_metadata15, "_ts_metadata");
2873
+ function _ts_param14(paramIndex, decorator) {
2724
2874
  return function(target, key) {
2725
2875
  decorator(target, key, paramIndex);
2726
2876
  };
2727
2877
  }
2728
- __name(_ts_param13, "_ts_param");
2878
+ __name(_ts_param14, "_ts_param");
2729
2879
  var SkillsController = class {
2730
2880
  static {
2731
2881
  __name(this, "SkillsController");
@@ -2741,40 +2891,40 @@ var SkillsController = class {
2741
2891
  return [];
2742
2892
  }
2743
2893
  const actor = await this.actorResolver.resolve(req);
2744
- const offer = await (0, import_nestjs_agent_core16.offerSkills)(this.skills, {
2894
+ const offer = await (0, import_nestjs_agent_core17.offerSkills)(this.skills, {
2745
2895
  actor,
2746
2896
  threadId: threadId ?? ""
2747
2897
  });
2748
2898
  return offer.entries;
2749
2899
  }
2750
2900
  };
2751
- _ts_decorate15([
2752
- (0, import_common15.Get)(),
2753
- _ts_param13(0, (0, import_common15.Req)()),
2754
- _ts_param13(1, (0, import_common15.Query)("threadId")),
2755
- _ts_metadata14("design:type", Function),
2756
- _ts_metadata14("design:paramtypes", [
2901
+ _ts_decorate16([
2902
+ (0, import_common16.Get)(),
2903
+ _ts_param14(0, (0, import_common16.Req)()),
2904
+ _ts_param14(1, (0, import_common16.Query)("threadId")),
2905
+ _ts_metadata15("design:type", Function),
2906
+ _ts_metadata15("design:paramtypes", [
2757
2907
  typeof Request === "undefined" ? Object : Request,
2758
2908
  String
2759
2909
  ]),
2760
- _ts_metadata14("design:returntype", Promise)
2910
+ _ts_metadata15("design:returntype", Promise)
2761
2911
  ], SkillsController.prototype, "list", null);
2762
- SkillsController = _ts_decorate15([
2763
- (0, import_common15.Controller)("skills"),
2764
- _ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
2765
- _ts_param13(1, (0, import_common15.Optional)()),
2766
- _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_SKILLS)),
2767
- _ts_metadata14("design:type", Function),
2768
- _ts_metadata14("design:paramtypes", [
2912
+ SkillsController = _ts_decorate16([
2913
+ (0, import_common16.Controller)("skills"),
2914
+ _ts_param14(0, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
2915
+ _ts_param14(1, (0, import_common16.Optional)()),
2916
+ _ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_SKILLS)),
2917
+ _ts_metadata15("design:type", Function),
2918
+ _ts_metadata15("design:paramtypes", [
2769
2919
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2770
2920
  Object
2771
2921
  ])
2772
2922
  ], SkillsController);
2773
2923
 
2774
2924
  // src/controller/threads.controller.ts
2775
- var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2776
- var import_common16 = require("@nestjs/common");
2777
- function _ts_decorate16(decorators, target, key, desc) {
2925
+ var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2926
+ var import_common17 = require("@nestjs/common");
2927
+ function _ts_decorate17(decorators, target, key, desc) {
2778
2928
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2779
2929
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2780
2930
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2787,19 +2937,19 @@ function _ts_decorate16(decorators, target, key, desc) {
2787
2937
  }
2788
2938
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2789
2939
  }
2790
- __name(_ts_decorate16, "_ts_decorate");
2791
- function _ts_metadata15(metadataKey, metadataValue) {
2940
+ __name(_ts_decorate17, "_ts_decorate");
2941
+ function _ts_metadata16(metadataKey, metadataValue) {
2792
2942
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2793
2943
  return Reflect.metadata(metadataKey, metadataValue);
2794
2944
  }
2795
2945
  }
2796
- __name(_ts_metadata15, "_ts_metadata");
2797
- function _ts_param14(paramIndex, decorator) {
2946
+ __name(_ts_metadata16, "_ts_metadata");
2947
+ function _ts_param15(paramIndex, decorator) {
2798
2948
  return function(target, key) {
2799
2949
  decorator(target, key, paramIndex);
2800
2950
  };
2801
2951
  }
2802
- __name(_ts_param14, "_ts_param");
2952
+ __name(_ts_param15, "_ts_param");
2803
2953
  var ThreadsController = class {
2804
2954
  static {
2805
2955
  __name(this, "ThreadsController");
@@ -2866,101 +3016,101 @@ var ThreadsController = class {
2866
3016
  };
2867
3017
  }
2868
3018
  };
2869
- _ts_decorate16([
2870
- (0, import_common16.Get)(),
2871
- _ts_param14(0, (0, import_common16.Req)()),
2872
- _ts_metadata15("design:type", Function),
2873
- _ts_metadata15("design:paramtypes", [
3019
+ _ts_decorate17([
3020
+ (0, import_common17.Get)(),
3021
+ _ts_param15(0, (0, import_common17.Req)()),
3022
+ _ts_metadata16("design:type", Function),
3023
+ _ts_metadata16("design:paramtypes", [
2874
3024
  typeof Request === "undefined" ? Object : Request
2875
3025
  ]),
2876
- _ts_metadata15("design:returntype", Promise)
3026
+ _ts_metadata16("design:returntype", Promise)
2877
3027
  ], ThreadsController.prototype, "list", null);
2878
- _ts_decorate16([
2879
- (0, import_common16.Get)(":id"),
2880
- _ts_param14(0, (0, import_common16.Req)()),
2881
- _ts_param14(1, (0, import_common16.Param)("id")),
2882
- _ts_metadata15("design:type", Function),
2883
- _ts_metadata15("design:paramtypes", [
3028
+ _ts_decorate17([
3029
+ (0, import_common17.Get)(":id"),
3030
+ _ts_param15(0, (0, import_common17.Req)()),
3031
+ _ts_param15(1, (0, import_common17.Param)("id")),
3032
+ _ts_metadata16("design:type", Function),
3033
+ _ts_metadata16("design:paramtypes", [
2884
3034
  typeof Request === "undefined" ? Object : Request,
2885
3035
  String
2886
3036
  ]),
2887
- _ts_metadata15("design:returntype", Promise)
3037
+ _ts_metadata16("design:returntype", Promise)
2888
3038
  ], ThreadsController.prototype, "detail", null);
2889
- _ts_decorate16([
2890
- (0, import_common16.Delete)(":id"),
2891
- _ts_param14(0, (0, import_common16.Req)()),
2892
- _ts_param14(1, (0, import_common16.Param)("id")),
2893
- _ts_metadata15("design:type", Function),
2894
- _ts_metadata15("design:paramtypes", [
3039
+ _ts_decorate17([
3040
+ (0, import_common17.Delete)(":id"),
3041
+ _ts_param15(0, (0, import_common17.Req)()),
3042
+ _ts_param15(1, (0, import_common17.Param)("id")),
3043
+ _ts_metadata16("design:type", Function),
3044
+ _ts_metadata16("design:paramtypes", [
2895
3045
  typeof Request === "undefined" ? Object : Request,
2896
3046
  String
2897
3047
  ]),
2898
- _ts_metadata15("design:returntype", Promise)
3048
+ _ts_metadata16("design:returntype", Promise)
2899
3049
  ], ThreadsController.prototype, "remove", null);
2900
- _ts_decorate16([
2901
- (0, import_common16.Post)(":id/fork-from/:messageId"),
2902
- _ts_param14(0, (0, import_common16.Req)()),
2903
- _ts_param14(1, (0, import_common16.Param)("id")),
2904
- _ts_param14(2, (0, import_common16.Param)("messageId")),
2905
- _ts_metadata15("design:type", Function),
2906
- _ts_metadata15("design:paramtypes", [
3050
+ _ts_decorate17([
3051
+ (0, import_common17.Post)(":id/fork-from/:messageId"),
3052
+ _ts_param15(0, (0, import_common17.Req)()),
3053
+ _ts_param15(1, (0, import_common17.Param)("id")),
3054
+ _ts_param15(2, (0, import_common17.Param)("messageId")),
3055
+ _ts_metadata16("design:type", Function),
3056
+ _ts_metadata16("design:paramtypes", [
2907
3057
  typeof Request === "undefined" ? Object : Request,
2908
3058
  String,
2909
3059
  String
2910
3060
  ]),
2911
- _ts_metadata15("design:returntype", Promise)
3061
+ _ts_metadata16("design:returntype", Promise)
2912
3062
  ], ThreadsController.prototype, "fork", null);
2913
- _ts_decorate16([
2914
- (0, import_common16.Patch)(":id"),
2915
- _ts_param14(0, (0, import_common16.Req)()),
2916
- _ts_param14(1, (0, import_common16.Param)("id")),
2917
- _ts_param14(2, (0, import_common16.Body)()),
2918
- _ts_metadata15("design:type", Function),
2919
- _ts_metadata15("design:paramtypes", [
3063
+ _ts_decorate17([
3064
+ (0, import_common17.Patch)(":id"),
3065
+ _ts_param15(0, (0, import_common17.Req)()),
3066
+ _ts_param15(1, (0, import_common17.Param)("id")),
3067
+ _ts_param15(2, (0, import_common17.Body)()),
3068
+ _ts_metadata16("design:type", Function),
3069
+ _ts_metadata16("design:paramtypes", [
2920
3070
  typeof Request === "undefined" ? Object : Request,
2921
3071
  String,
2922
3072
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
2923
3073
  ]),
2924
- _ts_metadata15("design:returntype", Promise)
3074
+ _ts_metadata16("design:returntype", Promise)
2925
3075
  ], ThreadsController.prototype, "update", null);
2926
- _ts_decorate16([
2927
- (0, import_common16.Post)(":id/promote"),
2928
- _ts_param14(0, (0, import_common16.Req)()),
2929
- _ts_param14(1, (0, import_common16.Param)("id")),
2930
- _ts_metadata15("design:type", Function),
2931
- _ts_metadata15("design:paramtypes", [
3076
+ _ts_decorate17([
3077
+ (0, import_common17.Post)(":id/promote"),
3078
+ _ts_param15(0, (0, import_common17.Req)()),
3079
+ _ts_param15(1, (0, import_common17.Param)("id")),
3080
+ _ts_metadata16("design:type", Function),
3081
+ _ts_metadata16("design:paramtypes", [
2932
3082
  typeof Request === "undefined" ? Object : Request,
2933
3083
  String
2934
3084
  ]),
2935
- _ts_metadata15("design:returntype", Promise)
3085
+ _ts_metadata16("design:returntype", Promise)
2936
3086
  ], ThreadsController.prototype, "promote", null);
2937
- _ts_decorate16([
2938
- (0, import_common16.Delete)(":id/from/:messageId"),
2939
- _ts_param14(0, (0, import_common16.Req)()),
2940
- _ts_param14(1, (0, import_common16.Param)("id")),
2941
- _ts_param14(2, (0, import_common16.Param)("messageId")),
2942
- _ts_metadata15("design:type", Function),
2943
- _ts_metadata15("design:paramtypes", [
3087
+ _ts_decorate17([
3088
+ (0, import_common17.Delete)(":id/from/:messageId"),
3089
+ _ts_param15(0, (0, import_common17.Req)()),
3090
+ _ts_param15(1, (0, import_common17.Param)("id")),
3091
+ _ts_param15(2, (0, import_common17.Param)("messageId")),
3092
+ _ts_metadata16("design:type", Function),
3093
+ _ts_metadata16("design:paramtypes", [
2944
3094
  typeof Request === "undefined" ? Object : Request,
2945
3095
  String,
2946
3096
  String
2947
3097
  ]),
2948
- _ts_metadata15("design:returntype", Promise)
3098
+ _ts_metadata16("design:returntype", Promise)
2949
3099
  ], ThreadsController.prototype, "truncateFrom", null);
2950
- ThreadsController = _ts_decorate16([
2951
- (0, import_common16.Controller)("threads"),
2952
- _ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
2953
- _ts_metadata15("design:type", Function),
2954
- _ts_metadata15("design:paramtypes", [
3100
+ ThreadsController = _ts_decorate17([
3101
+ (0, import_common17.Controller)("threads"),
3102
+ _ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
3103
+ _ts_metadata16("design:type", Function),
3104
+ _ts_metadata16("design:paramtypes", [
2955
3105
  typeof AgentService === "undefined" ? Object : AgentService,
2956
3106
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2957
3107
  ])
2958
3108
  ], ThreadsController);
2959
3109
 
2960
3110
  // src/controller/tool-call.controller.ts
2961
- var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2962
- var import_common17 = require("@nestjs/common");
2963
- function _ts_decorate17(decorators, target, key, desc) {
3111
+ var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3112
+ var import_common18 = require("@nestjs/common");
3113
+ function _ts_decorate18(decorators, target, key, desc) {
2964
3114
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2965
3115
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2966
3116
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2973,19 +3123,19 @@ function _ts_decorate17(decorators, target, key, desc) {
2973
3123
  }
2974
3124
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2975
3125
  }
2976
- __name(_ts_decorate17, "_ts_decorate");
2977
- function _ts_metadata16(metadataKey, metadataValue) {
3126
+ __name(_ts_decorate18, "_ts_decorate");
3127
+ function _ts_metadata17(metadataKey, metadataValue) {
2978
3128
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2979
3129
  return Reflect.metadata(metadataKey, metadataValue);
2980
3130
  }
2981
3131
  }
2982
- __name(_ts_metadata16, "_ts_metadata");
2983
- function _ts_param15(paramIndex, decorator) {
3132
+ __name(_ts_metadata17, "_ts_metadata");
3133
+ function _ts_param16(paramIndex, decorator) {
2984
3134
  return function(target, key) {
2985
3135
  decorator(target, key, paramIndex);
2986
3136
  };
2987
3137
  }
2988
- __name(_ts_param15, "_ts_param");
3138
+ __name(_ts_param16, "_ts_param");
2989
3139
  var MAX_ANSWERED_QUESTIONS = 100;
2990
3140
  var MAX_VALUES_PER_QUESTION = 100;
2991
3141
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -2994,7 +3144,7 @@ var MAX_VIA_LENGTH = 64;
2994
3144
  var DEFAULT_VIA = "web";
2995
3145
  function toolCallId(claimed) {
2996
3146
  if (typeof claimed !== "string" || claimed.length === 0) {
2997
- throw new import_common17.BadRequestException("toolCallId must be a non-empty string");
3147
+ throw new import_common18.BadRequestException("toolCallId must be a non-empty string");
2998
3148
  }
2999
3149
  return claimed;
3000
3150
  }
@@ -3004,10 +3154,10 @@ function rejectReason(claimed) {
3004
3154
  return void 0;
3005
3155
  }
3006
3156
  if (typeof claimed !== "string") {
3007
- throw new import_common17.BadRequestException("reason must be a string");
3157
+ throw new import_common18.BadRequestException("reason must be a string");
3008
3158
  }
3009
3159
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
3010
- throw new import_common17.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
3160
+ throw new import_common18.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
3011
3161
  }
3012
3162
  return claimed;
3013
3163
  }
@@ -3017,7 +3167,7 @@ function remember(claimed) {
3017
3167
  return false;
3018
3168
  }
3019
3169
  if (typeof claimed !== "boolean") {
3020
- throw new import_common17.BadRequestException("remember must be a boolean");
3170
+ throw new import_common18.BadRequestException("remember must be a boolean");
3021
3171
  }
3022
3172
  return claimed;
3023
3173
  }
@@ -3027,7 +3177,7 @@ function via(claimed) {
3027
3177
  return DEFAULT_VIA;
3028
3178
  }
3029
3179
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
3030
- throw new import_common17.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
3180
+ throw new import_common18.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
3031
3181
  }
3032
3182
  return claimed;
3033
3183
  }
@@ -3037,26 +3187,26 @@ function answers(claimed) {
3037
3187
  return void 0;
3038
3188
  }
3039
3189
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
3040
- throw new import_common17.BadRequestException("answers must be an object of questionId \u2192 chosen values");
3190
+ throw new import_common18.BadRequestException("answers must be an object of questionId \u2192 chosen values");
3041
3191
  }
3042
3192
  const entries = Object.entries(claimed);
3043
3193
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
3044
- throw new import_common17.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
3194
+ throw new import_common18.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
3045
3195
  }
3046
3196
  const validated = /* @__PURE__ */ Object.create(null);
3047
3197
  for (const [questionId, values] of entries) {
3048
3198
  if (!Array.isArray(values)) {
3049
- throw new import_common17.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
3199
+ throw new import_common18.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
3050
3200
  }
3051
3201
  if (values.length > MAX_VALUES_PER_QUESTION) {
3052
- throw new import_common17.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
3202
+ throw new import_common18.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
3053
3203
  }
3054
3204
  for (const value of values) {
3055
3205
  if (typeof value !== "string") {
3056
- throw new import_common17.BadRequestException(`answers["${questionId}"] must contain only strings`);
3206
+ throw new import_common18.BadRequestException(`answers["${questionId}"] must contain only strings`);
3057
3207
  }
3058
3208
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
3059
- throw new import_common17.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
3209
+ throw new import_common18.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
3060
3210
  }
3061
3211
  }
3062
3212
  validated[questionId] = values;
@@ -3114,64 +3264,64 @@ var ToolCallController = class {
3114
3264
  };
3115
3265
  }
3116
3266
  };
3117
- _ts_decorate17([
3118
- (0, import_common17.Post)("approve"),
3119
- _ts_param15(0, (0, import_common17.Req)()),
3120
- _ts_param15(1, (0, import_common17.Body)()),
3121
- _ts_metadata16("design:type", Function),
3122
- _ts_metadata16("design:paramtypes", [
3267
+ _ts_decorate18([
3268
+ (0, import_common18.Post)("approve"),
3269
+ _ts_param16(0, (0, import_common18.Req)()),
3270
+ _ts_param16(1, (0, import_common18.Body)()),
3271
+ _ts_metadata17("design:type", Function),
3272
+ _ts_metadata17("design:paramtypes", [
3123
3273
  typeof Request === "undefined" ? Object : Request,
3124
3274
  typeof ApproveBody === "undefined" ? Object : ApproveBody
3125
3275
  ]),
3126
- _ts_metadata16("design:returntype", Promise)
3276
+ _ts_metadata17("design:returntype", Promise)
3127
3277
  ], ToolCallController.prototype, "approve", null);
3128
- _ts_decorate17([
3129
- (0, import_common17.Post)("reject"),
3130
- _ts_param15(0, (0, import_common17.Req)()),
3131
- _ts_param15(1, (0, import_common17.Body)()),
3132
- _ts_metadata16("design:type", Function),
3133
- _ts_metadata16("design:paramtypes", [
3278
+ _ts_decorate18([
3279
+ (0, import_common18.Post)("reject"),
3280
+ _ts_param16(0, (0, import_common18.Req)()),
3281
+ _ts_param16(1, (0, import_common18.Body)()),
3282
+ _ts_metadata17("design:type", Function),
3283
+ _ts_metadata17("design:paramtypes", [
3134
3284
  typeof Request === "undefined" ? Object : Request,
3135
3285
  typeof RejectBody === "undefined" ? Object : RejectBody
3136
3286
  ]),
3137
- _ts_metadata16("design:returntype", Promise)
3287
+ _ts_metadata17("design:returntype", Promise)
3138
3288
  ], ToolCallController.prototype, "reject", null);
3139
- _ts_decorate17([
3140
- (0, import_common17.Post)("answer"),
3141
- _ts_param15(0, (0, import_common17.Req)()),
3142
- _ts_param15(1, (0, import_common17.Body)()),
3143
- _ts_metadata16("design:type", Function),
3144
- _ts_metadata16("design:paramtypes", [
3289
+ _ts_decorate18([
3290
+ (0, import_common18.Post)("answer"),
3291
+ _ts_param16(0, (0, import_common18.Req)()),
3292
+ _ts_param16(1, (0, import_common18.Body)()),
3293
+ _ts_metadata17("design:type", Function),
3294
+ _ts_metadata17("design:paramtypes", [
3145
3295
  typeof Request === "undefined" ? Object : Request,
3146
3296
  typeof AnswerBody === "undefined" ? Object : AnswerBody
3147
3297
  ]),
3148
- _ts_metadata16("design:returntype", Promise)
3298
+ _ts_metadata17("design:returntype", Promise)
3149
3299
  ], ToolCallController.prototype, "answer", null);
3150
- _ts_decorate17([
3151
- (0, import_common17.Post)("skip"),
3152
- _ts_param15(0, (0, import_common17.Req)()),
3153
- _ts_param15(1, (0, import_common17.Body)()),
3154
- _ts_metadata16("design:type", Function),
3155
- _ts_metadata16("design:paramtypes", [
3300
+ _ts_decorate18([
3301
+ (0, import_common18.Post)("skip"),
3302
+ _ts_param16(0, (0, import_common18.Req)()),
3303
+ _ts_param16(1, (0, import_common18.Body)()),
3304
+ _ts_metadata17("design:type", Function),
3305
+ _ts_metadata17("design:paramtypes", [
3156
3306
  typeof Request === "undefined" ? Object : Request,
3157
3307
  Object
3158
3308
  ]),
3159
- _ts_metadata16("design:returntype", Promise)
3309
+ _ts_metadata17("design:returntype", Promise)
3160
3310
  ], ToolCallController.prototype, "skip", null);
3161
- ToolCallController = _ts_decorate17([
3162
- (0, import_common17.Controller)("tool-call"),
3163
- _ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
3164
- _ts_metadata16("design:type", Function),
3165
- _ts_metadata16("design:paramtypes", [
3311
+ ToolCallController = _ts_decorate18([
3312
+ (0, import_common18.Controller)("tool-call"),
3313
+ _ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
3314
+ _ts_metadata17("design:type", Function),
3315
+ _ts_metadata17("design:paramtypes", [
3166
3316
  typeof AgentService === "undefined" ? Object : AgentService,
3167
3317
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3168
3318
  ])
3169
3319
  ], ToolCallController);
3170
3320
 
3171
3321
  // src/controller/tools.controller.ts
3172
- var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3173
- var import_common18 = require("@nestjs/common");
3174
- function _ts_decorate18(decorators, target, key, desc) {
3322
+ var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3323
+ var import_common19 = require("@nestjs/common");
3324
+ function _ts_decorate19(decorators, target, key, desc) {
3175
3325
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3176
3326
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3177
3327
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3184,19 +3334,19 @@ function _ts_decorate18(decorators, target, key, desc) {
3184
3334
  }
3185
3335
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3186
3336
  }
3187
- __name(_ts_decorate18, "_ts_decorate");
3188
- function _ts_metadata17(metadataKey, metadataValue) {
3337
+ __name(_ts_decorate19, "_ts_decorate");
3338
+ function _ts_metadata18(metadataKey, metadataValue) {
3189
3339
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3190
3340
  return Reflect.metadata(metadataKey, metadataValue);
3191
3341
  }
3192
3342
  }
3193
- __name(_ts_metadata17, "_ts_metadata");
3194
- function _ts_param16(paramIndex, decorator) {
3343
+ __name(_ts_metadata18, "_ts_metadata");
3344
+ function _ts_param17(paramIndex, decorator) {
3195
3345
  return function(target, key) {
3196
3346
  decorator(target, key, paramIndex);
3197
3347
  };
3198
3348
  }
3199
- __name(_ts_param16, "_ts_param");
3349
+ __name(_ts_param17, "_ts_param");
3200
3350
  var ToolsController = class {
3201
3351
  static {
3202
3352
  __name(this, "ToolsController");
@@ -3211,7 +3361,7 @@ var ToolsController = class {
3211
3361
  }
3212
3362
  async list(req, agent) {
3213
3363
  if (agent !== void 0 && this.agents.get(agent) === void 0) {
3214
- throw new import_common18.NotFoundException(`No agent named "${agent}"`);
3364
+ throw new import_common19.NotFoundException(`No agent named "${agent}"`);
3215
3365
  }
3216
3366
  const actor = await this.actorResolver.resolve(req);
3217
3367
  const deps = this.depsFactory.forAgent(agent);
@@ -3225,33 +3375,33 @@ var ToolsController = class {
3225
3375
  }));
3226
3376
  }
3227
3377
  };
3228
- _ts_decorate18([
3229
- (0, import_common18.Get)(),
3230
- _ts_param16(0, (0, import_common18.Req)()),
3231
- _ts_param16(1, (0, import_common18.Query)("agent")),
3232
- _ts_metadata17("design:type", Function),
3233
- _ts_metadata17("design:paramtypes", [
3378
+ _ts_decorate19([
3379
+ (0, import_common19.Get)(),
3380
+ _ts_param17(0, (0, import_common19.Req)()),
3381
+ _ts_param17(1, (0, import_common19.Query)("agent")),
3382
+ _ts_metadata18("design:type", Function),
3383
+ _ts_metadata18("design:paramtypes", [
3234
3384
  typeof Request === "undefined" ? Object : Request,
3235
3385
  String
3236
3386
  ]),
3237
- _ts_metadata17("design:returntype", Promise)
3387
+ _ts_metadata18("design:returntype", Promise)
3238
3388
  ], ToolsController.prototype, "list", null);
3239
- ToolsController = _ts_decorate18([
3240
- (0, import_common18.Controller)("tools"),
3241
- _ts_param16(0, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
3242
- _ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_DEPS_FACTORY)),
3243
- _ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
3244
- _ts_metadata17("design:type", Function),
3245
- _ts_metadata17("design:paramtypes", [
3389
+ ToolsController = _ts_decorate19([
3390
+ (0, import_common19.Controller)("tools"),
3391
+ _ts_param17(0, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
3392
+ _ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_DEPS_FACTORY)),
3393
+ _ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
3394
+ _ts_metadata18("design:type", Function),
3395
+ _ts_metadata18("design:paramtypes", [
3246
3396
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3247
3397
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
3248
- typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry
3398
+ typeof import_nestjs_agent_core20.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core20.AgentRegistry
3249
3399
  ])
3250
3400
  ], ToolsController);
3251
3401
 
3252
3402
  // src/discovery/agent-discovery.service.ts
3253
- var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3254
- var import_common19 = require("@nestjs/common");
3403
+ var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
3404
+ var import_common20 = require("@nestjs/common");
3255
3405
  var import_core = require("@nestjs/core");
3256
3406
 
3257
3407
  // src/decorator/agent.decorator.ts
@@ -3268,7 +3418,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
3268
3418
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
3269
3419
 
3270
3420
  // src/discovery/agent-discovery.service.ts
3271
- function _ts_decorate19(decorators, target, key, desc) {
3421
+ function _ts_decorate20(decorators, target, key, desc) {
3272
3422
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3273
3423
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3274
3424
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3281,19 +3431,19 @@ function _ts_decorate19(decorators, target, key, desc) {
3281
3431
  }
3282
3432
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3283
3433
  }
3284
- __name(_ts_decorate19, "_ts_decorate");
3285
- function _ts_metadata18(metadataKey, metadataValue) {
3434
+ __name(_ts_decorate20, "_ts_decorate");
3435
+ function _ts_metadata19(metadataKey, metadataValue) {
3286
3436
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3287
3437
  return Reflect.metadata(metadataKey, metadataValue);
3288
3438
  }
3289
3439
  }
3290
- __name(_ts_metadata18, "_ts_metadata");
3291
- function _ts_param17(paramIndex, decorator) {
3440
+ __name(_ts_metadata19, "_ts_metadata");
3441
+ function _ts_param18(paramIndex, decorator) {
3292
3442
  return function(target, key) {
3293
3443
  decorator(target, key, paramIndex);
3294
3444
  };
3295
3445
  }
3296
- __name(_ts_param17, "_ts_param");
3446
+ __name(_ts_param18, "_ts_param");
3297
3447
  var AgentDiscoveryService = class _AgentDiscoveryService {
3298
3448
  static {
3299
3449
  __name(this, "AgentDiscoveryService");
@@ -3302,7 +3452,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
3302
3452
  scanner;
3303
3453
  registry;
3304
3454
  contributors;
3305
- logger = new import_common19.Logger(_AgentDiscoveryService.name);
3455
+ logger = new import_common20.Logger(_AgentDiscoveryService.name);
3306
3456
  constructor(discovery, scanner, registry, contributors) {
3307
3457
  this.discovery = discovery;
3308
3458
  this.scanner = scanner;
@@ -3420,22 +3570,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
3420
3570
  return (ctx) => candidate.call(instance, ctx);
3421
3571
  }
3422
3572
  };
3423
- AgentDiscoveryService = _ts_decorate19([
3424
- (0, import_common19.Injectable)(),
3425
- _ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
3426
- _ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS)),
3427
- _ts_metadata18("design:type", Function),
3428
- _ts_metadata18("design:paramtypes", [
3573
+ AgentDiscoveryService = _ts_decorate20([
3574
+ (0, import_common20.Injectable)(),
3575
+ _ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_REGISTRY)),
3576
+ _ts_param18(3, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_PROMPT_CONTRIBUTORS)),
3577
+ _ts_metadata19("design:type", Function),
3578
+ _ts_metadata19("design:paramtypes", [
3429
3579
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
3430
3580
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
3431
- typeof import_nestjs_agent_core20.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core20.AgentRegistry,
3581
+ typeof import_nestjs_agent_core21.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core21.AgentRegistry,
3432
3582
  Array
3433
3583
  ])
3434
3584
  ], AgentDiscoveryService);
3435
3585
 
3436
3586
  // src/discovery/ai-tool-discovery.service.ts
3437
- var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
3438
- var import_common20 = require("@nestjs/common");
3587
+ var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
3588
+ var import_common21 = require("@nestjs/common");
3439
3589
  var import_core2 = require("@nestjs/core");
3440
3590
  var import_zod = require("zod");
3441
3591
 
@@ -3455,7 +3605,7 @@ function isBrandedFunctionalTool(value) {
3455
3605
  __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
3456
3606
 
3457
3607
  // src/discovery/ai-tool-discovery.service.ts
3458
- function _ts_decorate20(decorators, target, key, desc) {
3608
+ function _ts_decorate21(decorators, target, key, desc) {
3459
3609
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3460
3610
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3461
3611
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3468,19 +3618,19 @@ function _ts_decorate20(decorators, target, key, desc) {
3468
3618
  }
3469
3619
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3470
3620
  }
3471
- __name(_ts_decorate20, "_ts_decorate");
3472
- function _ts_metadata19(metadataKey, metadataValue) {
3621
+ __name(_ts_decorate21, "_ts_decorate");
3622
+ function _ts_metadata20(metadataKey, metadataValue) {
3473
3623
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3474
3624
  return Reflect.metadata(metadataKey, metadataValue);
3475
3625
  }
3476
3626
  }
3477
- __name(_ts_metadata19, "_ts_metadata");
3478
- function _ts_param18(paramIndex, decorator) {
3627
+ __name(_ts_metadata20, "_ts_metadata");
3628
+ function _ts_param19(paramIndex, decorator) {
3479
3629
  return function(target, key) {
3480
3630
  decorator(target, key, paramIndex);
3481
3631
  };
3482
3632
  }
3483
- __name(_ts_param18, "_ts_param");
3633
+ __name(_ts_param19, "_ts_param");
3484
3634
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
3485
3635
  static {
3486
3636
  __name(this, "AiToolDiscoveryService");
@@ -3489,7 +3639,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3489
3639
  registry;
3490
3640
  agents;
3491
3641
  options;
3492
- logger = new import_common20.Logger(_AiToolDiscoveryService.name);
3642
+ logger = new import_common21.Logger(_AiToolDiscoveryService.name);
3493
3643
  constructor(discovery, registry, agents, options) {
3494
3644
  this.discovery = discovery;
3495
3645
  this.registry = registry;
@@ -3574,7 +3724,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3574
3724
  let delegates = 0;
3575
3725
  for (const definition of this.agents.list()) {
3576
3726
  for (const edge of definition.delegatesTo ?? []) {
3577
- const { agent: target, detached } = (0, import_nestjs_agent_core21.normalizeDelegation)(edge);
3727
+ const { agent: target, detached } = (0, import_nestjs_agent_core22.normalizeDelegation)(edge);
3578
3728
  const targetDefinition = this.agents.get(target);
3579
3729
  if (targetDefinition === void 0) {
3580
3730
  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.`);
@@ -3624,13 +3774,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3624
3774
  return true;
3625
3775
  }
3626
3776
  };
3627
- AiToolDiscoveryService = _ts_decorate20([
3628
- (0, import_common20.Injectable)(),
3629
- _ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_TOOL_REGISTRY)),
3630
- _ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_REGISTRY)),
3631
- _ts_param18(3, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_OPTIONS)),
3632
- _ts_metadata19("design:type", Function),
3633
- _ts_metadata19("design:paramtypes", [
3777
+ AiToolDiscoveryService = _ts_decorate21([
3778
+ (0, import_common21.Injectable)(),
3779
+ _ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_TOOL_REGISTRY)),
3780
+ _ts_param19(2, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_REGISTRY)),
3781
+ _ts_param19(3, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_OPTIONS)),
3782
+ _ts_metadata20("design:type", Function),
3783
+ _ts_metadata20("design:paramtypes", [
3634
3784
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
3635
3785
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
3636
3786
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -3639,25 +3789,25 @@ AiToolDiscoveryService = _ts_decorate20([
3639
3789
  ], AiToolDiscoveryService);
3640
3790
 
3641
3791
  // src/discovery/skill-discovery.service.ts
3642
- var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
3643
- var import_common21 = require("@nestjs/common");
3792
+ var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
3793
+ var import_common22 = require("@nestjs/common");
3644
3794
  var import_core3 = require("@nestjs/core");
3645
3795
 
3646
3796
  // src/decorator/skill.decorator.ts
3647
3797
  var import_reflect_metadata4 = require("reflect-metadata");
3648
- var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
3798
+ var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
3649
3799
  var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
3650
3800
  function readSkillMetadata(target) {
3651
3801
  return Reflect.getMetadata(SKILL_METADATA, target);
3652
3802
  }
3653
3803
  __name(readSkillMetadata, "readSkillMetadata");
3654
3804
  function skillScope(options) {
3655
- return options.scope ?? import_nestjs_agent_core22.GLOBAL_SCOPE;
3805
+ return options.scope ?? import_nestjs_agent_core23.GLOBAL_SCOPE;
3656
3806
  }
3657
3807
  __name(skillScope, "skillScope");
3658
3808
 
3659
3809
  // src/discovery/skill-discovery.service.ts
3660
- function _ts_decorate21(decorators, target, key, desc) {
3810
+ function _ts_decorate22(decorators, target, key, desc) {
3661
3811
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3662
3812
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3663
3813
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3670,26 +3820,26 @@ function _ts_decorate21(decorators, target, key, desc) {
3670
3820
  }
3671
3821
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3672
3822
  }
3673
- __name(_ts_decorate21, "_ts_decorate");
3674
- function _ts_metadata20(metadataKey, metadataValue) {
3823
+ __name(_ts_decorate22, "_ts_decorate");
3824
+ function _ts_metadata21(metadataKey, metadataValue) {
3675
3825
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3676
3826
  return Reflect.metadata(metadataKey, metadataValue);
3677
3827
  }
3678
3828
  }
3679
- __name(_ts_metadata20, "_ts_metadata");
3680
- function _ts_param19(paramIndex, decorator) {
3829
+ __name(_ts_metadata21, "_ts_metadata");
3830
+ function _ts_param20(paramIndex, decorator) {
3681
3831
  return function(target, key) {
3682
3832
  decorator(target, key, paramIndex);
3683
3833
  };
3684
3834
  }
3685
- __name(_ts_param19, "_ts_param");
3835
+ __name(_ts_param20, "_ts_param");
3686
3836
  var SkillDiscoveryService = class _SkillDiscoveryService {
3687
3837
  static {
3688
3838
  __name(this, "SkillDiscoveryService");
3689
3839
  }
3690
3840
  discovery;
3691
3841
  declared;
3692
- logger = new import_common21.Logger(_SkillDiscoveryService.name);
3842
+ logger = new import_common22.Logger(_SkillDiscoveryService.name);
3693
3843
  constructor(discovery, declared) {
3694
3844
  this.discovery = discovery;
3695
3845
  this.declared = declared;
@@ -3726,28 +3876,26 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
3726
3876
  return flat === void 0 ? void 0 : () => flat;
3727
3877
  }
3728
3878
  };
3729
- SkillDiscoveryService = _ts_decorate21([
3730
- (0, import_common21.Injectable)(),
3731
- _ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_SKILL_SOURCES)),
3732
- _ts_metadata20("design:type", Function),
3733
- _ts_metadata20("design:paramtypes", [
3879
+ SkillDiscoveryService = _ts_decorate22([
3880
+ (0, import_common22.Injectable)(),
3881
+ _ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_SKILL_SOURCES)),
3882
+ _ts_metadata21("design:type", Function),
3883
+ _ts_metadata21("design:paramtypes", [
3734
3884
  typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
3735
3885
  Array
3736
3886
  ])
3737
3887
  ], SkillDiscoveryService);
3738
3888
 
3739
3889
  // src/ledger-quota-provider.ts
3740
- var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
3890
+ var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
3741
3891
  var LedgerQuotaProvider = class {
3742
3892
  static {
3743
3893
  __name(this, "LedgerQuotaProvider");
3744
3894
  }
3745
3895
  store;
3746
- quota;
3747
3896
  limits;
3748
- constructor(store, quota, limits = {}) {
3897
+ constructor(store, limits = {}) {
3749
3898
  this.store = store;
3750
- this.quota = quota;
3751
3899
  this.limits = limits;
3752
3900
  }
3753
3901
  async report(query) {
@@ -3757,11 +3905,11 @@ var LedgerQuotaProvider = class {
3757
3905
  await this.dayWindow(actorRef, now)
3758
3906
  ];
3759
3907
  if (this.store.usageBetween !== void 0) {
3760
- const range = (0, import_nestjs_agent_core24.quotaPeriodRange)("month", now);
3908
+ const range = (0, import_nestjs_agent_core25.quotaPeriodRange)("month", now);
3761
3909
  const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
3762
3910
  windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
3763
3911
  }
3764
- const blocked = (0, import_nestjs_agent_core24.exhaustedWindow)(windows);
3912
+ const blocked = (0, import_nestjs_agent_core25.exhaustedWindow)(windows);
3765
3913
  return {
3766
3914
  windows,
3767
3915
  ...blocked !== void 0 ? {
@@ -3770,17 +3918,9 @@ var LedgerQuotaProvider = class {
3770
3918
  };
3771
3919
  }
3772
3920
  async dayWindow(actorRef, now) {
3773
- const range = (0, import_nestjs_agent_core24.quotaPeriodRange)("day", now);
3921
+ const range = (0, import_nestjs_agent_core25.quotaPeriodRange)("day", now);
3774
3922
  const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
3775
- if (this.quota === void 0) {
3776
- return this.window("day", usedTokens, costUsd, range.resetsAt);
3777
- }
3778
- const state = await this.quota.check(actorRef, range.fromDay);
3779
- const window = this.window("day", state.usedTokens, costUsd, range.resetsAt);
3780
- if (window.limitTokens === void 0) {
3781
- window.limitTokens = state.limitTokens;
3782
- }
3783
- return window;
3923
+ return this.window("day", usedTokens, costUsd, range.resetsAt);
3784
3924
  }
3785
3925
  window(period, usedTokens, usedUsd, resetsAt) {
3786
3926
  const limits = this.limits[period] ?? {};
@@ -3799,120 +3939,10 @@ var LedgerQuotaProvider = class {
3799
3939
  }
3800
3940
  };
3801
3941
 
3802
- // src/ledger-quota-store.ts
3803
- var LedgerQuotaStore = class {
3804
- static {
3805
- __name(this, "LedgerQuotaStore");
3806
- }
3807
- store;
3808
- limitTokens;
3809
- constructor(store, limitTokens) {
3810
- this.store = store;
3811
- this.limitTokens = limitTokens;
3812
- }
3813
- async check(actorRef, day) {
3814
- const { usedTokens } = await this.store.quotaToday(actorRef, day);
3815
- return {
3816
- usedTokens,
3817
- limitTokens: this.limitTokens,
3818
- withinLimit: usedTokens < this.limitTokens
3819
- };
3820
- }
3821
- async bump(_actorRef, _day, _tokens) {
3822
- }
3823
- };
3824
-
3825
- // src/resolver/anonymous-actor-resolver.ts
3826
- var import_node_crypto2 = require("crypto");
3827
- var TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
3828
- var MINTED = /* @__PURE__ */ Symbol("nestjs-agent:anonymous-token");
3829
- function readCookie(req, name) {
3830
- const header = req.headers?.cookie;
3831
- const raw = Array.isArray(header) ? header.join("; ") : header;
3832
- if (raw === void 0) return void 0;
3833
- for (const pair of raw.split(";")) {
3834
- const index = pair.indexOf("=");
3835
- if (index === -1) continue;
3836
- if (pair.slice(0, index).trim() === name) {
3837
- try {
3838
- return decodeURIComponent(pair.slice(index + 1).trim());
3839
- } catch {
3840
- return void 0;
3841
- }
3842
- }
3843
- }
3844
- return void 0;
3845
- }
3846
- __name(readCookie, "readCookie");
3847
- function isHttps(req) {
3848
- if (req.secure === true) return true;
3849
- const forwarded = req.headers?.["x-forwarded-proto"];
3850
- const proto = Array.isArray(forwarded) ? forwarded[0] : forwarded;
3851
- return proto?.split(",")[0]?.trim() === "https";
3852
- }
3853
- __name(isHttps, "isHttps");
3854
- var AnonymousActorResolver = class {
3855
- static {
3856
- __name(this, "AnonymousActorResolver");
3857
- }
3858
- options;
3859
- cookieName;
3860
- roles;
3861
- constructor(options = {}) {
3862
- this.options = options;
3863
- this.cookieName = options.cookieName ?? "agent_anon";
3864
- this.roles = options.roles ?? [
3865
- "anonymous"
3866
- ];
3867
- }
3868
- resolve(request) {
3869
- const req = typeof request === "object" && request !== null ? request : {};
3870
- let token = req[MINTED] ?? readCookie(req, this.cookieName);
3871
- if (token === void 0 || !TOKEN_PATTERN.test(token)) {
3872
- token = (0, import_node_crypto2.randomBytes)(32).toString("base64url");
3873
- req[MINTED] = token;
3874
- this.setCookie(req, token);
3875
- }
3876
- const digest = (0, import_node_crypto2.createHash)("sha256").update(token).digest("base64url").slice(0, 32);
3877
- return {
3878
- id: `anon:${digest}`,
3879
- roles: [
3880
- ...this.roles
3881
- ]
3882
- };
3883
- }
3884
- setCookie(req, token) {
3885
- const res = req.res;
3886
- if (res?.setHeader === void 0 || res.headersSent === true) return;
3887
- const sameSite = this.options.sameSite ?? "lax";
3888
- const secureOption = this.options.secure ?? "auto";
3889
- const secure = sameSite === "none" || (secureOption === "auto" ? isHttps(req) : secureOption);
3890
- const maxAge = Math.round((this.options.maxAgeDays ?? 365) * 24 * 60 * 60);
3891
- const cookie = [
3892
- `${this.cookieName}=${token}`,
3893
- `Path=${this.options.path ?? "/"}`,
3894
- `Max-Age=${maxAge}`,
3895
- "HttpOnly",
3896
- `SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`,
3897
- ...secure ? [
3898
- "Secure"
3899
- ] : []
3900
- ].join("; ");
3901
- const existing = res.getHeader?.("Set-Cookie");
3902
- const list = Array.isArray(existing) ? existing.map(String) : existing !== void 0 ? [
3903
- String(existing)
3904
- ] : [];
3905
- res.setHeader("Set-Cookie", [
3906
- ...list,
3907
- cookie
3908
- ]);
3909
- }
3910
- };
3911
-
3912
3942
  // src/runner/inline-agent-runner.ts
3913
- var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
3914
- var import_common22 = require("@nestjs/common");
3915
- function _ts_decorate22(decorators, target, key, desc) {
3943
+ var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
3944
+ var import_common23 = require("@nestjs/common");
3945
+ function _ts_decorate23(decorators, target, key, desc) {
3916
3946
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3917
3947
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3918
3948
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3925,26 +3955,26 @@ function _ts_decorate22(decorators, target, key, desc) {
3925
3955
  }
3926
3956
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3927
3957
  }
3928
- __name(_ts_decorate22, "_ts_decorate");
3929
- function _ts_metadata21(metadataKey, metadataValue) {
3958
+ __name(_ts_decorate23, "_ts_decorate");
3959
+ function _ts_metadata22(metadataKey, metadataValue) {
3930
3960
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3931
3961
  return Reflect.metadata(metadataKey, metadataValue);
3932
3962
  }
3933
3963
  }
3934
- __name(_ts_metadata21, "_ts_metadata");
3935
- function _ts_param20(paramIndex, decorator) {
3964
+ __name(_ts_metadata22, "_ts_metadata");
3965
+ function _ts_param21(paramIndex, decorator) {
3936
3966
  return function(target, key) {
3937
3967
  decorator(target, key, paramIndex);
3938
3968
  };
3939
3969
  }
3940
- __name(_ts_param20, "_ts_param");
3970
+ __name(_ts_param21, "_ts_param");
3941
3971
  var InlineAgentRunner = class _InlineAgentRunner {
3942
3972
  static {
3943
3973
  __name(this, "InlineAgentRunner");
3944
3974
  }
3945
3975
  factory;
3946
3976
  store;
3947
- logger = new import_common22.Logger(_InlineAgentRunner.name);
3977
+ logger = new import_common23.Logger(_InlineAgentRunner.name);
3948
3978
  pending = /* @__PURE__ */ new Map();
3949
3979
  /**
3950
3980
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -3973,18 +4003,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
3973
4003
  ] : []
3974
4004
  ]
3975
4005
  });
3976
- void (0, import_nestjs_agent_core25.runAgentLoop)({
4006
+ void (0, import_nestjs_agent_core26.runAgentLoop)({
3977
4007
  ...deps,
3978
4008
  day
3979
4009
  }, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
3980
- if (error instanceof import_nestjs_agent_core25.RunCancelledError) {
4010
+ if (error instanceof import_nestjs_agent_core26.RunCancelledError) {
3981
4011
  await this.settleCancelled(runId, input.threadId, deps);
3982
4012
  return;
3983
4013
  }
3984
4014
  const message = error instanceof Error ? error.message : String(error);
3985
- const code = (0, import_nestjs_agent_core25.agentFailureCode)(error);
4015
+ const code = (0, import_nestjs_agent_core26.agentFailureCode)(error);
3986
4016
  this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
3987
- (0, import_nestjs_agent_core25.publishAgentRunFailed)({
4017
+ (0, import_nestjs_agent_core26.publishAgentRunFailed)({
3988
4018
  runId,
3989
4019
  code,
3990
4020
  message
@@ -4033,7 +4063,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4033
4063
  for (const [key, waiter] of this.pending) {
4034
4064
  if (key.startsWith(`${runId}:`)) {
4035
4065
  this.pending.delete(key);
4036
- waiter.reject(new import_nestjs_agent_core25.RunCancelledError());
4066
+ waiter.reject(new import_nestjs_agent_core26.RunCancelledError());
4037
4067
  }
4038
4068
  }
4039
4069
  await Promise.resolve();
@@ -4048,7 +4078,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4048
4078
  this.logger.log(`agent run ${runId} cancelled`);
4049
4079
  await this.store.setActiveStream(threadId, null);
4050
4080
  const writer = await deps.sink.open(runId);
4051
- await writer.write((0, import_nestjs_agent_core25.encodeStreamEvent)({
4081
+ await writer.write((0, import_nestjs_agent_core26.encodeStreamEvent)({
4052
4082
  kind: "cancelled"
4053
4083
  }));
4054
4084
  await writer.end();
@@ -4109,7 +4139,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4109
4139
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
4110
4140
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
4111
4141
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
4112
- parallel: import_nestjs_agent_core25.settleAll,
4142
+ parallel: import_nestjs_agent_core26.settleAll,
4113
4143
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
4114
4144
  runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
4115
4145
  agentName,
@@ -4160,7 +4190,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4160
4190
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
4161
4191
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
4162
4192
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
4163
- parallel: import_nestjs_agent_core25.settleAll,
4193
+ parallel: import_nestjs_agent_core26.settleAll,
4164
4194
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
4165
4195
  runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
4166
4196
  agentName: childName,
@@ -4193,7 +4223,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4193
4223
  }
4194
4224
  }), "startAgent")
4195
4225
  };
4196
- void (0, import_nestjs_agent_core25.runAgentLoop)({
4226
+ void (0, import_nestjs_agent_core26.runAgentLoop)({
4197
4227
  ...deps,
4198
4228
  day
4199
4229
  }, {
@@ -4207,13 +4237,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
4207
4237
  parentRunId,
4208
4238
  deliverTo
4209
4239
  }, hooks).catch(async (error) => {
4210
- const cancelled = error instanceof import_nestjs_agent_core25.RunCancelledError;
4240
+ const cancelled = error instanceof import_nestjs_agent_core26.RunCancelledError;
4211
4241
  const message = error instanceof Error ? error.message : String(error);
4212
4242
  if (!cancelled) {
4213
4243
  this.logger.error(`detached agent run ${runId} failed: ${message}`);
4214
- (0, import_nestjs_agent_core25.publishAgentRunFailed)({
4244
+ (0, import_nestjs_agent_core26.publishAgentRunFailed)({
4215
4245
  runId,
4216
- code: (0, import_nestjs_agent_core25.agentFailureCode)(error),
4246
+ code: (0, import_nestjs_agent_core26.agentFailureCode)(error),
4217
4247
  message
4218
4248
  });
4219
4249
  }
@@ -4221,11 +4251,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
4221
4251
  runId,
4222
4252
  status: cancelled ? "cancelled" : "failed",
4223
4253
  ...cancelled ? {} : {
4224
- errorCode: (0, import_nestjs_agent_core25.agentFailureCode)(error),
4254
+ errorCode: (0, import_nestjs_agent_core26.agentFailureCode)(error),
4225
4255
  errorMessage: message
4226
4256
  }
4227
4257
  });
4228
- await (0, import_nestjs_agent_core25.settleUnsettledDelegation)({
4258
+ await (0, import_nestjs_agent_core26.settleUnsettledDelegation)({
4229
4259
  store: this.store,
4230
4260
  delivery: deliverTo,
4231
4261
  agent: agentName,
@@ -4264,7 +4294,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4264
4294
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
4265
4295
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
4266
4296
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
4267
- parallel: import_nestjs_agent_core25.settleAll,
4297
+ parallel: import_nestjs_agent_core26.settleAll,
4268
4298
  // A child stops when it is cancelled OR when the run a human is actually watching is: the
4269
4299
  // canceller names the top-level run, which is the only id that ever left the server.
4270
4300
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
@@ -4299,7 +4329,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4299
4329
  }), "startAgent")
4300
4330
  };
4301
4331
  try {
4302
- return await (0, import_nestjs_agent_core25.runAgentLoop)({
4332
+ return await (0, import_nestjs_agent_core26.runAgentLoop)({
4303
4333
  ...deps,
4304
4334
  day
4305
4335
  }, {
@@ -4318,19 +4348,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
4318
4348
  }
4319
4349
  }
4320
4350
  };
4321
- InlineAgentRunner = _ts_decorate22([
4322
- (0, import_common22.Injectable)(),
4323
- _ts_param20(0, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_DEPS_FACTORY)),
4324
- _ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core25.AGENT_STORE)),
4325
- _ts_metadata21("design:type", Function),
4326
- _ts_metadata21("design:paramtypes", [
4351
+ InlineAgentRunner = _ts_decorate23([
4352
+ (0, import_common23.Injectable)(),
4353
+ _ts_param21(0, (0, import_common23.Inject)(import_nestjs_agent_core26.AGENT_DEPS_FACTORY)),
4354
+ _ts_param21(1, (0, import_common23.Inject)(import_nestjs_agent_core26.AGENT_STORE)),
4355
+ _ts_metadata22("design:type", Function),
4356
+ _ts_metadata22("design:paramtypes", [
4327
4357
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
4328
4358
  typeof AgentStore === "undefined" ? Object : AgentStore
4329
4359
  ])
4330
4360
  ], InlineAgentRunner);
4331
4361
 
4332
4362
  // src/skills-config.ts
4333
- var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
4363
+ var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
4334
4364
  function declaredSkillProvider(declared) {
4335
4365
  return {
4336
4366
  list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
@@ -4356,7 +4386,7 @@ function resolveSkillsConfig(options, declared) {
4356
4386
  declaredSkillProvider(declared)
4357
4387
  ];
4358
4388
  return {
4359
- provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core26.compositeSkillProvider)(providers),
4389
+ provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core27.compositeSkillProvider)(providers),
4360
4390
  ...options.scopes !== void 0 ? {
4361
4391
  scopes: options.scopes
4362
4392
  } : {},
@@ -4368,7 +4398,7 @@ function resolveSkillsConfig(options, declared) {
4368
4398
  __name(resolveSkillsConfig, "resolveSkillsConfig");
4369
4399
 
4370
4400
  // src/agent.module.ts
4371
- function _ts_decorate23(decorators, target, key, desc) {
4401
+ function _ts_decorate24(decorators, target, key, desc) {
4372
4402
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4373
4403
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4374
4404
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4381,13 +4411,13 @@ function _ts_decorate23(decorators, target, key, desc) {
4381
4411
  }
4382
4412
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4383
4413
  }
4384
- __name(_ts_decorate23, "_ts_decorate");
4414
+ __name(_ts_decorate24, "_ts_decorate");
4385
4415
  var DEFAULT_PATH = "agent";
4386
- var logger = new import_common23.Logger("AgentModule");
4416
+ var logger = new import_common24.Logger("AgentModule");
4387
4417
  function externalStoreWrapper(modules) {
4388
4418
  for (const module2 of modules.values()) {
4389
4419
  if (module2.metatype === AgentModule) continue;
4390
- const wrapper = module2.providers.get(import_nestjs_agent_core27.AGENT_STORE);
4420
+ const wrapper = module2.providers.get(import_nestjs_agent_core28.AGENT_STORE);
4391
4421
  if (wrapper !== void 0) return wrapper;
4392
4422
  }
4393
4423
  return void 0;
@@ -4418,9 +4448,13 @@ function resolveStore(options, modules) {
4418
4448
  const external = externalStoreWrapper(modules);
4419
4449
  if (external !== void 0) return forwardingStore(external);
4420
4450
  logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
4421
- return new import_nestjs_agent_core27.InMemoryAgentStore();
4451
+ return new import_nestjs_agent_core28.InMemoryAgentStore();
4422
4452
  }
4423
4453
  __name(resolveStore, "resolveStore");
4454
+ function isQuotaProvider(quota) {
4455
+ return quota !== void 0 && typeof quota.report === "function";
4456
+ }
4457
+ __name(isQuotaProvider, "isQuotaProvider");
4424
4458
  function resolveCatalog(options) {
4425
4459
  if (options.models !== void 0) return options.models;
4426
4460
  const carried = options.model.catalog;
@@ -4430,107 +4464,97 @@ __name(resolveCatalog, "resolveCatalog");
4430
4464
  function sharedProviders(durable) {
4431
4465
  const providers = [
4432
4466
  {
4433
- provide: import_nestjs_agent_core27.AGENT_TOOL_REGISTRY,
4434
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core27.ToolRegistry(), "useFactory")
4467
+ provide: import_nestjs_agent_core28.AGENT_TOOL_REGISTRY,
4468
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core28.ToolRegistry(), "useFactory")
4435
4469
  },
4436
4470
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
4437
4471
  {
4438
- provide: import_nestjs_agent_core27.AGENT_REGISTRY,
4439
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core27.AgentRegistry(), "useFactory")
4472
+ provide: import_nestjs_agent_core28.AGENT_REGISTRY,
4473
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core28.AgentRegistry(), "useFactory")
4440
4474
  },
4441
4475
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
4442
4476
  {
4443
- provide: import_nestjs_agent_core27.AGENT_PROMPT_CONTRIBUTORS,
4477
+ provide: import_nestjs_agent_core28.AGENT_PROMPT_CONTRIBUTORS,
4444
4478
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
4445
4479
  },
4446
4480
  // Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
4447
4481
  // read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
4448
4482
  {
4449
- provide: import_nestjs_agent_core27.AGENT_SKILL_SOURCES,
4483
+ provide: import_nestjs_agent_core28.AGENT_SKILL_SOURCES,
4450
4484
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
4451
4485
  },
4452
4486
  {
4453
4487
  // One resolution, shared by the loop's deps and the listing endpoint: a second one would
4454
4488
  // drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
4455
4489
  // host configured none — which is what keeps the turn's checkpoint sequence unchanged.
4456
- provide: import_nestjs_agent_core27.AGENT_SKILLS,
4490
+ provide: import_nestjs_agent_core28.AGENT_SKILLS,
4457
4491
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
4458
4492
  inject: [
4459
- import_nestjs_agent_core27.AGENT_OPTIONS,
4460
- import_nestjs_agent_core27.AGENT_SKILL_SOURCES
4493
+ import_nestjs_agent_core28.AGENT_OPTIONS,
4494
+ import_nestjs_agent_core28.AGENT_SKILL_SOURCES
4461
4495
  ]
4462
4496
  },
4463
4497
  {
4464
4498
  // One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
4465
4499
  // shown what the model was shown, and two resolutions would eventually disagree about that.
4466
- provide: import_nestjs_agent_core27.AGENT_MEMORY,
4500
+ provide: import_nestjs_agent_core28.AGENT_MEMORY,
4467
4501
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
4468
4502
  inject: [
4469
- import_nestjs_agent_core27.AGENT_OPTIONS
4503
+ import_nestjs_agent_core28.AGENT_OPTIONS
4470
4504
  ]
4471
4505
  },
4472
4506
  {
4473
- provide: import_nestjs_agent_core27.AGENT_SINK,
4507
+ provide: import_nestjs_agent_core28.AGENT_SINK,
4474
4508
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
4475
4509
  inject: [
4476
- import_nestjs_agent_core27.AGENT_OPTIONS
4510
+ import_nestjs_agent_core28.AGENT_OPTIONS
4477
4511
  ]
4478
4512
  },
4479
4513
  {
4480
- provide: import_nestjs_agent_core27.AGENT_ROLES_POLICY,
4481
- useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core27.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
4514
+ provide: import_nestjs_agent_core28.AGENT_ROLES_POLICY,
4515
+ useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core28.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
4482
4516
  inject: [
4483
- import_nestjs_agent_core27.AGENT_OPTIONS
4517
+ import_nestjs_agent_core28.AGENT_OPTIONS
4484
4518
  ]
4485
4519
  },
4486
4520
  {
4487
- provide: import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER,
4521
+ provide: import_nestjs_agent_core28.AGENT_ACTOR_RESOLVER,
4488
4522
  useFactory: /* @__PURE__ */ __name((options) => {
4489
4523
  if (options.actorResolver !== void 0) return options.actorResolver;
4490
4524
  logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
4491
4525
  return new AnonymousActorResolver();
4492
4526
  }, "useFactory"),
4493
4527
  inject: [
4494
- import_nestjs_agent_core27.AGENT_OPTIONS
4528
+ import_nestjs_agent_core28.AGENT_OPTIONS
4495
4529
  ]
4496
4530
  },
4497
4531
  {
4498
- provide: import_nestjs_agent_core27.AGENT_MODEL,
4532
+ provide: import_nestjs_agent_core28.AGENT_MODEL,
4499
4533
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
4500
4534
  inject: [
4501
- import_nestjs_agent_core27.AGENT_OPTIONS
4535
+ import_nestjs_agent_core28.AGENT_OPTIONS
4502
4536
  ]
4503
4537
  },
4504
4538
  {
4505
- // An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
4506
- // store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
4507
- // the loop already writes, so enforcement needs no extra shared state across replicas.
4508
- provide: import_nestjs_agent_core27.AGENT_QUOTA_STORE,
4509
- useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
4539
+ // `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
4540
+ // omitted, the ledger provider still reports usage, with no ceiling to block on.
4541
+ provide: import_nestjs_agent_core28.AGENT_QUOTA_PROVIDER,
4542
+ useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits), "useFactory"),
4510
4543
  inject: [
4511
- import_nestjs_agent_core27.AGENT_OPTIONS,
4512
- import_nestjs_agent_core27.AGENT_STORE
4544
+ import_nestjs_agent_core28.AGENT_OPTIONS,
4545
+ import_nestjs_agent_core28.AGENT_STORE
4513
4546
  ]
4514
4547
  },
4515
4548
  {
4516
- provide: import_nestjs_agent_core27.AGENT_QUOTA_PROVIDER,
4517
- useFactory: /* @__PURE__ */ __name((o, store, quota) => o.quotaProvider ?? new LedgerQuotaProvider(store, quota, o.quotaLimits), "useFactory"),
4518
- inject: [
4519
- import_nestjs_agent_core27.AGENT_OPTIONS,
4520
- import_nestjs_agent_core27.AGENT_STORE,
4521
- import_nestjs_agent_core27.AGENT_QUOTA_STORE
4522
- ]
4523
- },
4524
- {
4525
- provide: import_nestjs_agent_core27.AGENT_MODEL_CATALOG,
4549
+ provide: import_nestjs_agent_core28.AGENT_MODEL_CATALOG,
4526
4550
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
4527
4551
  inject: [
4528
- import_nestjs_agent_core27.AGENT_OPTIONS
4552
+ import_nestjs_agent_core28.AGENT_OPTIONS
4529
4553
  ]
4530
4554
  },
4531
4555
  AgentDepsFactory2,
4532
4556
  {
4533
- provide: import_nestjs_agent_core27.AGENT_DEPS_FACTORY,
4557
+ provide: import_nestjs_agent_core28.AGENT_DEPS_FACTORY,
4534
4558
  useExisting: AgentDepsFactory2
4535
4559
  },
4536
4560
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -4544,21 +4568,21 @@ function sharedProviders(durable) {
4544
4568
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
4545
4569
  AgentApprovalPortAdapter,
4546
4570
  {
4547
- provide: import_nestjs_agent_core27.AGENT_APPROVAL_PORT,
4571
+ provide: import_nestjs_agent_core28.AGENT_APPROVAL_PORT,
4548
4572
  useExisting: AgentApprovalPortAdapter
4549
4573
  }
4550
4574
  ];
4551
4575
  providers.push({
4552
- provide: import_nestjs_agent_core27.AGENT_STORE,
4576
+ provide: import_nestjs_agent_core28.AGENT_STORE,
4553
4577
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
4554
4578
  inject: [
4555
- import_nestjs_agent_core27.AGENT_OPTIONS,
4579
+ import_nestjs_agent_core28.AGENT_OPTIONS,
4556
4580
  import_core4.ModulesContainer
4557
4581
  ]
4558
4582
  });
4559
4583
  if (durable) {
4560
4584
  providers.push({
4561
- provide: import_nestjs_agent_core27.AGENT_RUNNER,
4585
+ provide: import_nestjs_agent_core28.AGENT_RUNNER,
4562
4586
  useFactory: /* @__PURE__ */ __name((durableRunner) => {
4563
4587
  if (durableRunner === void 0) {
4564
4588
  throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
@@ -4567,14 +4591,14 @@ function sharedProviders(durable) {
4567
4591
  }, "useFactory"),
4568
4592
  inject: [
4569
4593
  {
4570
- token: import_nestjs_agent_core27.AGENT_DURABLE_RUNNER,
4594
+ token: import_nestjs_agent_core28.AGENT_DURABLE_RUNNER,
4571
4595
  optional: true
4572
4596
  }
4573
4597
  ]
4574
4598
  });
4575
4599
  } else {
4576
4600
  providers.push({
4577
- provide: import_nestjs_agent_core27.AGENT_RUNNER,
4601
+ provide: import_nestjs_agent_core28.AGENT_RUNNER,
4578
4602
  useExisting: InlineAgentRunner
4579
4603
  });
4580
4604
  }
@@ -4583,25 +4607,24 @@ function sharedProviders(durable) {
4583
4607
  __name(sharedProviders, "sharedProviders");
4584
4608
  function exportsFor() {
4585
4609
  return [
4586
- import_nestjs_agent_core27.AGENT_OPTIONS,
4587
- import_nestjs_agent_core27.AGENT_TOOL_REGISTRY,
4588
- import_nestjs_agent_core27.AGENT_REGISTRY,
4589
- import_nestjs_agent_core27.AGENT_SINK,
4590
- import_nestjs_agent_core27.AGENT_ROLES_POLICY,
4591
- import_nestjs_agent_core27.AGENT_ACTOR_RESOLVER,
4592
- import_nestjs_agent_core27.AGENT_MODEL,
4593
- import_nestjs_agent_core27.AGENT_STORE,
4594
- import_nestjs_agent_core27.AGENT_QUOTA_STORE,
4595
- import_nestjs_agent_core27.AGENT_MODEL_CATALOG,
4596
- import_nestjs_agent_core27.AGENT_QUOTA_PROVIDER,
4597
- import_nestjs_agent_core27.AGENT_PROMPT_CONTRIBUTORS,
4598
- import_nestjs_agent_core27.AGENT_SKILLS,
4599
- import_nestjs_agent_core27.AGENT_MEMORY,
4600
- import_nestjs_agent_core27.AGENT_DEPS_FACTORY,
4610
+ import_nestjs_agent_core28.AGENT_OPTIONS,
4611
+ import_nestjs_agent_core28.AGENT_TOOL_REGISTRY,
4612
+ import_nestjs_agent_core28.AGENT_REGISTRY,
4613
+ import_nestjs_agent_core28.AGENT_SINK,
4614
+ import_nestjs_agent_core28.AGENT_ROLES_POLICY,
4615
+ import_nestjs_agent_core28.AGENT_ACTOR_RESOLVER,
4616
+ import_nestjs_agent_core28.AGENT_MODEL,
4617
+ import_nestjs_agent_core28.AGENT_STORE,
4618
+ import_nestjs_agent_core28.AGENT_MODEL_CATALOG,
4619
+ import_nestjs_agent_core28.AGENT_QUOTA_PROVIDER,
4620
+ import_nestjs_agent_core28.AGENT_PROMPT_CONTRIBUTORS,
4621
+ import_nestjs_agent_core28.AGENT_SKILLS,
4622
+ import_nestjs_agent_core28.AGENT_MEMORY,
4623
+ import_nestjs_agent_core28.AGENT_DEPS_FACTORY,
4601
4624
  AgentDepsFactory2,
4602
4625
  AgentService,
4603
4626
  InlineAgentRunner,
4604
- import_nestjs_agent_core27.AGENT_APPROVAL_PORT
4627
+ import_nestjs_agent_core28.AGENT_APPROVAL_PORT
4605
4628
  ];
4606
4629
  }
4607
4630
  __name(exportsFor, "exportsFor");
@@ -4615,21 +4638,13 @@ var BASE_CONTROLLERS = [
4615
4638
  MemoriesController,
4616
4639
  ToolsController,
4617
4640
  MessagesController,
4618
- ModelsController
4619
- ];
4620
- var GUARDABLE_CONTROLLERS = [
4621
- ...BASE_CONTROLLERS,
4641
+ ModelsController,
4642
+ ConfigController,
4622
4643
  AttachmentsController
4623
4644
  ];
4624
- function controllersFor(mountAttachments) {
4625
- return mountAttachments ? [
4626
- ...BASE_CONTROLLERS,
4627
- AttachmentsController
4628
- ] : BASE_CONTROLLERS;
4629
- }
4630
- __name(controllersFor, "controllersFor");
4631
- function controllersForSurface(surface, mountAttachments) {
4632
- return surface === "engine" ? [] : controllersFor(mountAttachments);
4645
+ var GUARDABLE_CONTROLLERS = BASE_CONTROLLERS;
4646
+ function controllersForSurface(surface) {
4647
+ return surface === "engine" ? [] : BASE_CONTROLLERS;
4633
4648
  }
4634
4649
  __name(controllersForSurface, "controllersForSurface");
4635
4650
  var GUARDS_METADATA = "__guards__";
@@ -4669,10 +4684,10 @@ var AgentModule = class _AgentModule {
4669
4684
  import_core4.DiscoveryModule,
4670
4685
  routerFor(path)
4671
4686
  ],
4672
- controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
4687
+ controllers: controllersForSurface(options.surface),
4673
4688
  providers: [
4674
4689
  {
4675
- provide: import_nestjs_agent_core27.AGENT_OPTIONS,
4690
+ provide: import_nestjs_agent_core28.AGENT_OPTIONS,
4676
4691
  useValue: options
4677
4692
  },
4678
4693
  ...sharedProviders(options.durable ?? false),
@@ -4692,10 +4707,10 @@ var AgentModule = class _AgentModule {
4692
4707
  routerFor(path),
4693
4708
  ...options.imports ?? []
4694
4709
  ],
4695
- controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
4710
+ controllers: controllersForSurface(options.surface),
4696
4711
  providers: [
4697
4712
  {
4698
- provide: import_nestjs_agent_core27.AGENT_OPTIONS,
4713
+ provide: import_nestjs_agent_core28.AGENT_OPTIONS,
4699
4714
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
4700
4715
  // authoritative on the async config object (they decided the actual wiring above), and
4701
4716
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -4716,9 +4731,9 @@ var AgentModule = class _AgentModule {
4716
4731
  };
4717
4732
  }
4718
4733
  };
4719
- AgentModule = _ts_decorate23([
4720
- (0, import_common23.Global)(),
4721
- (0, import_common23.Module)({})
4734
+ AgentModule = _ts_decorate24([
4735
+ (0, import_common24.Global)(),
4736
+ (0, import_common24.Module)({})
4722
4737
  ], AgentModule);
4723
4738
 
4724
4739
  // src/durable/agent-durable.ts