@dudousxd/nestjs-agent 1.16.1 → 1.17.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.
@@ -606,7 +606,7 @@ var AgentRunSteps = class {
606
606
  await (await opened).write((0, import_nestjs_agent_core2.encodeStreamEvent)(event));
607
607
  });
608
608
  const ctx = {
609
- ...input.ctx,
609
+ ...(0, import_nestjs_agent_core2.toolCallContext)(input.ctx, input.toolCallId),
610
610
  emitUi: ui.emit
611
611
  };
612
612
  const localClassify = deps.toolTransientRetry !== false ? deps.toolTransientRetry?.classify : void 0;
@@ -700,6 +700,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
700
700
  store;
701
701
  runs;
702
702
  queue;
703
+ logger = new import_common3.Logger(_AgentRunWorkflow.name);
703
704
  constructor(factory, store, runs, queue) {
704
705
  this.factory = factory;
705
706
  this.store = store;
@@ -978,30 +979,42 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
978
979
  throw error;
979
980
  }
980
981
  if ((0, import_nestjs_agent_core3.isReplayIntegrityError)(error)) {
981
- const failure = {
982
- code: "run_failed",
983
- message: error.message
984
- };
982
+ const detail = error.message;
983
+ const code2 = (0, import_nestjs_agent_core3.agentFailureCode)(error);
984
+ this.logger.error(`agent run ${ctx.runId} failed (${code2}): ${detail}`);
985
985
  (0, import_nestjs_agent_core3.publishAgentRunFailed)({
986
986
  runId: ctx.runId,
987
- ...failure
987
+ code: code2,
988
+ message: detail
989
+ });
990
+ await (0, import_nestjs_agent_core3.settleDeadRun)(this.store, {
991
+ runId: ctx.runId,
992
+ threadId: input.threadId,
993
+ failure: {
994
+ code: code2,
995
+ message: detail
996
+ }
988
997
  });
989
- await (await hooks.openSink()).fail(failure);
998
+ await (await hooks.openSink()).fail((0, import_nestjs_agent_core3.streamFailure)(error));
990
999
  throw error;
991
1000
  }
992
1001
  const message = error instanceof Error ? error.message : String(error);
993
1002
  const code = (0, import_nestjs_agent_core3.agentFailureCode)(error);
1003
+ this.logger.error(`agent run ${ctx.runId} failed (${code}): ${message}`);
994
1004
  (0, import_nestjs_agent_core3.publishAgentRunFailed)({
995
1005
  runId: ctx.runId,
996
1006
  code,
997
1007
  message
998
1008
  });
999
- await stepOf(ctx)("persist:run:fail", () => this.store.recordRunEnd?.({
1000
- runId: ctx.runId,
1001
- status: "failed",
1002
- errorCode: code,
1003
- errorMessage: message
1004
- }) ?? Promise.resolve());
1009
+ await stepOf(ctx)("persist:run:fail", async () => {
1010
+ await this.store.recordRunEnd?.({
1011
+ runId: ctx.runId,
1012
+ status: "failed",
1013
+ errorCode: code,
1014
+ errorMessage: message
1015
+ });
1016
+ await Promise.resolve(this.store.failUnsettledToolCalls?.(ctx.runId, import_nestjs_agent_core3.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
1017
+ });
1005
1018
  const queueFrame2 = await this.advanceQueue(ctx, input, "failed", message);
1006
1019
  await stepOf(ctx)("deactivate", () => (0, import_nestjs_agent_core3.releaseThreadRun)(this.store, input.threadId, ctx.runId));
1007
1020
  await this.settleDetachedParent(ctx, input, {
@@ -1012,10 +1025,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
1012
1025
  if (queueFrame2 !== void 0) {
1013
1026
  await writer.write((0, import_nestjs_agent_core3.encodeStreamEvent)(queueFrame2));
1014
1027
  }
1015
- await writer.fail({
1016
- code,
1017
- message
1018
- });
1028
+ await writer.fail((0, import_nestjs_agent_core3.streamFailure)(error));
1019
1029
  throw error;
1020
1030
  }
1021
1031
  }
@@ -1391,8 +1401,8 @@ AgentDurableModule = _ts_decorate5([
1391
1401
  ], AgentDurableModule);
1392
1402
 
1393
1403
  // src/agent.module.ts
1394
- var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
1395
- var import_common26 = require("@nestjs/common");
1404
+ var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
1405
+ var import_common27 = require("@nestjs/common");
1396
1406
  var import_core4 = require("@nestjs/core");
1397
1407
 
1398
1408
  // src/agent-deps.factory.ts
@@ -1654,8 +1664,28 @@ AgentDepsFactory2 = _ts_decorate6([
1654
1664
  ], AgentDepsFactory2);
1655
1665
 
1656
1666
  // src/agent.service.ts
1667
+ var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
1668
+ var import_common8 = require("@nestjs/common");
1669
+
1670
+ // src/run-not-active.exception.ts
1657
1671
  var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
1658
1672
  var import_common7 = require("@nestjs/common");
1673
+ var RunNotActiveException = class extends import_common7.ConflictException {
1674
+ static {
1675
+ __name(this, "RunNotActiveException");
1676
+ }
1677
+ runId;
1678
+ code = import_nestjs_agent_core9.RUN_NOT_ACTIVE_CODE;
1679
+ constructor(runId) {
1680
+ super({
1681
+ statusCode: 409,
1682
+ code: import_nestjs_agent_core9.RUN_NOT_ACTIVE_CODE,
1683
+ message: import_nestjs_agent_core9.RUN_NOT_ACTIVE_MESSAGE
1684
+ }), this.runId = runId;
1685
+ }
1686
+ };
1687
+
1688
+ // src/agent.service.ts
1659
1689
  function _ts_decorate7(decorators, target, key, desc) {
1660
1690
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1661
1691
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1712,7 +1742,7 @@ var AgentService = class {
1712
1742
  requireQueue() {
1713
1743
  const queue = this.queueing();
1714
1744
  if (queue === void 0) {
1715
- throw new import_common7.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
1745
+ throw new import_common8.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
1716
1746
  }
1717
1747
  return queue;
1718
1748
  }
@@ -1749,12 +1779,12 @@ var AgentService = class {
1749
1779
  actor
1750
1780
  });
1751
1781
  if (blocked !== void 0) {
1752
- throw new import_common7.HttpException({
1753
- statusCode: import_common7.HttpStatus.TOO_MANY_REQUESTS,
1782
+ throw new import_common8.HttpException({
1783
+ statusCode: import_common8.HttpStatus.TOO_MANY_REQUESTS,
1754
1784
  code: "quota_exceeded",
1755
1785
  period: blocked.period,
1756
1786
  message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
1757
- }, import_common7.HttpStatus.TOO_MANY_REQUESTS);
1787
+ }, import_common8.HttpStatus.TOO_MANY_REQUESTS);
1758
1788
  }
1759
1789
  }
1760
1790
  /**
@@ -1782,17 +1812,17 @@ var AgentService = class {
1782
1812
  */
1783
1813
  async assertModelAllowed(actor, agent, model) {
1784
1814
  if (this.models === void 0) {
1785
- throw new import_common7.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
1815
+ throw new import_common8.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
1786
1816
  }
1787
- const entry = (0, import_nestjs_agent_core9.findCatalogModel)(await this.models.list({
1817
+ const entry = (0, import_nestjs_agent_core10.findCatalogModel)(await this.models.list({
1788
1818
  actor,
1789
1819
  agent
1790
1820
  }), model);
1791
1821
  if (entry === void 0) {
1792
- throw new import_common7.BadRequestException(`model "${model}" is not offered`);
1822
+ throw new import_common8.BadRequestException(`model "${model}" is not offered`);
1793
1823
  }
1794
1824
  if (!entry.available) {
1795
- throw new import_common7.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
1825
+ throw new import_common8.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
1796
1826
  }
1797
1827
  return entry.id;
1798
1828
  }
@@ -1808,7 +1838,7 @@ var AgentService = class {
1808
1838
  })).locked : void 0;
1809
1839
  if (locked !== void 0) {
1810
1840
  if (requested !== void 0 && requested !== locked.model) {
1811
- throw new import_common7.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
1841
+ throw new import_common8.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
1812
1842
  }
1813
1843
  return locked.model;
1814
1844
  }
@@ -1852,7 +1882,7 @@ var AgentService = class {
1852
1882
  };
1853
1883
  }
1854
1884
  await this.requireQueue().publish(result.threadId);
1855
- throw new import_common7.ConflictException({
1885
+ throw new import_common8.ConflictException({
1856
1886
  statusCode: 409,
1857
1887
  code: "run_active",
1858
1888
  message: `thread ${result.threadId} already has a turn running`
@@ -1870,7 +1900,7 @@ var AgentService = class {
1870
1900
  let threadId = params.threadId;
1871
1901
  if (threadId === void 0) {
1872
1902
  if (params.regenerate === true) {
1873
- throw new import_common7.BadRequestException("regenerate requires an existing threadId");
1903
+ throw new import_common8.BadRequestException("regenerate requires an existing threadId");
1874
1904
  }
1875
1905
  const created = await this.store.createThread({
1876
1906
  actor: params.actor,
@@ -1912,6 +1942,11 @@ var AgentService = class {
1912
1942
  }
1913
1943
  const mode = params.mode ?? "auto";
1914
1944
  const { live, stale } = await queue.holder(threadId, this.runner);
1945
+ if (stale !== null) {
1946
+ await (0, import_nestjs_agent_core10.settleDeadRun)(this.store, {
1947
+ runId: stale
1948
+ });
1949
+ }
1915
1950
  if (live === null && mode !== "queue") {
1916
1951
  const runId = crypto.randomUUID();
1917
1952
  if (await queue.queueStore().claimActiveStream(threadId, runId, stale !== null ? {
@@ -1924,7 +1959,7 @@ var AgentService = class {
1924
1959
  }
1925
1960
  }
1926
1961
  if (params.regenerate === true) {
1927
- throw new import_common7.ConflictException({
1962
+ throw new import_common8.ConflictException({
1928
1963
  statusCode: 409,
1929
1964
  code: "run_active",
1930
1965
  message: "cannot regenerate while a turn is running on this thread"
@@ -2021,7 +2056,7 @@ var AgentService = class {
2021
2056
  const store = queue.queueStore();
2022
2057
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
2023
2058
  if (patch.message !== void 0 && patch.message.trim().length === 0) {
2024
- throw new import_common7.BadRequestException("message must not be empty");
2059
+ throw new import_common8.BadRequestException("message must not be empty");
2025
2060
  }
2026
2061
  const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
2027
2062
  if (patch.message !== void 0 || attachments !== void 0) {
@@ -2034,15 +2069,15 @@ var AgentService = class {
2034
2069
  } : {}
2035
2070
  });
2036
2071
  if (updated === null) {
2037
- throw new import_common7.GoneException(`queued message ${messageId} already started or was removed`);
2072
+ throw new import_common8.GoneException(`queued message ${messageId} already started or was removed`);
2038
2073
  }
2039
2074
  }
2040
2075
  if (patch.position !== void 0) {
2041
2076
  if (!Number.isInteger(patch.position) || patch.position < 0) {
2042
- throw new import_common7.BadRequestException("position must be a non-negative integer");
2077
+ throw new import_common8.BadRequestException("position must be a non-negative integer");
2043
2078
  }
2044
2079
  if (!await store.moveQueuedMessage(messageId, patch.position)) {
2045
- throw new import_common7.GoneException(`queued message ${messageId} already started or was removed`);
2080
+ throw new import_common8.GoneException(`queued message ${messageId} already started or was removed`);
2046
2081
  }
2047
2082
  }
2048
2083
  return queue.publish(threadId);
@@ -2052,7 +2087,7 @@ var AgentService = class {
2052
2087
  const queue = this.requireQueue();
2053
2088
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
2054
2089
  if (!await queue.queueStore().removeQueuedMessage(messageId)) {
2055
- throw new import_common7.GoneException(`queued message ${messageId} already started or was removed`);
2090
+ throw new import_common8.GoneException(`queued message ${messageId} already started or was removed`);
2056
2091
  }
2057
2092
  return queue.publish(threadId);
2058
2093
  }
@@ -2071,7 +2106,7 @@ var AgentService = class {
2071
2106
  const queue = this.requireQueue();
2072
2107
  const store = queue.queueStore();
2073
2108
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
2074
- const gone = /* @__PURE__ */ __name(() => new import_common7.GoneException(`queued message ${messageId} already started or was removed`), "gone");
2109
+ const gone = /* @__PURE__ */ __name(() => new import_common8.GoneException(`queued message ${messageId} already started or was removed`), "gone");
2075
2110
  const marked = await store.updateQueuedMessage(messageId, {
2076
2111
  interrupt: true
2077
2112
  });
@@ -2079,7 +2114,7 @@ var AgentService = class {
2079
2114
  throw gone();
2080
2115
  }
2081
2116
  if (marked.interrupt !== true) {
2082
- throw new import_common7.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
2117
+ throw new import_common8.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
2083
2118
  }
2084
2119
  if (!await store.moveQueuedMessage(messageId, 0)) {
2085
2120
  throw gone();
@@ -2138,7 +2173,7 @@ var AgentService = class {
2138
2173
  async assertOwnsQueuedMessage(actor, messageId) {
2139
2174
  const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
2140
2175
  if (message === null) {
2141
- throw new import_common7.NotFoundException(`queued message ${messageId} not found`);
2176
+ throw new import_common8.NotFoundException(`queued message ${messageId} not found`);
2142
2177
  }
2143
2178
  await this.assertOwnsThread(actor, message.threadId);
2144
2179
  return message.threadId;
@@ -2159,7 +2194,7 @@ var AgentService = class {
2159
2194
  }
2160
2195
  const staging = this.staging;
2161
2196
  if (staging === void 0 || typeof staging.resolve !== "function") {
2162
- throw new import_common7.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
2197
+ throw new import_common8.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
2163
2198
  }
2164
2199
  const resolved = [];
2165
2200
  for (const ref of refs) {
@@ -2168,7 +2203,7 @@ var AgentService = class {
2168
2203
  actor
2169
2204
  });
2170
2205
  if (attachment === null) {
2171
- throw new import_common7.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
2206
+ throw new import_common8.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
2172
2207
  }
2173
2208
  resolved.push(attachment);
2174
2209
  }
@@ -2272,8 +2307,29 @@ var AgentService = class {
2272
2307
  async signalToolCall(toolCallId2, reply) {
2273
2308
  await this.assertNotExpired(toolCallId2);
2274
2309
  const runId = await this.resolveRunForToolCall(toolCallId2);
2310
+ await this.assertRunWaiting(runId);
2275
2311
  return this.runner.signal(runId, toolCallId2, reply);
2276
2312
  }
2313
+ /**
2314
+ * Refuse a decision addressed at a run that is over (`409 run_not_active`). The runtime would take
2315
+ * the signal and buffer it for a run that never comes back — the person's "yes" is accepted, the
2316
+ * card says so, and nothing runs. Settles the calls the dead run left awaiting a decision on the
2317
+ * way out, so the card stops asking. A runner that cannot say whether a run is alive is taken at
2318
+ * its word that it is, and so is one that fails to answer.
2319
+ */
2320
+ async assertRunWaiting(runId) {
2321
+ if (typeof this.runner.isRunActive !== "function") {
2322
+ return;
2323
+ }
2324
+ const active = await this.runner.isRunActive(runId).catch(() => true);
2325
+ if (active) {
2326
+ return;
2327
+ }
2328
+ await (0, import_nestjs_agent_core10.settleDeadRun)(this.store, {
2329
+ runId
2330
+ });
2331
+ throw new RunNotActiveException(runId);
2332
+ }
2277
2333
  async cancel(actor, runId) {
2278
2334
  await this.assertOwnsActiveStream(actor, runId);
2279
2335
  return this.runner.cancel(runId);
@@ -2317,7 +2373,7 @@ var AgentService = class {
2317
2373
  return;
2318
2374
  }
2319
2375
  if (this.store.updateThread === void 0) {
2320
- throw new import_common7.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
2376
+ throw new import_common8.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
2321
2377
  }
2322
2378
  const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
2323
2379
  await this.store.updateThread(threadId, {
@@ -2335,10 +2391,10 @@ var AgentService = class {
2335
2391
  validateTitle(title) {
2336
2392
  const trimmed = title.trim();
2337
2393
  if (trimmed.length === 0) {
2338
- throw new import_common7.BadRequestException("title must not be empty");
2394
+ throw new import_common8.BadRequestException("title must not be empty");
2339
2395
  }
2340
2396
  if (trimmed.length > 200) {
2341
- throw new import_common7.BadRequestException("title must be at most 200 characters");
2397
+ throw new import_common8.BadRequestException("title must be at most 200 characters");
2342
2398
  }
2343
2399
  return trimmed;
2344
2400
  }
@@ -2441,21 +2497,21 @@ var AgentService = class {
2441
2497
  */
2442
2498
  async setMessageFeedback(actor, messageId, input) {
2443
2499
  if (input.value !== null && input.value !== "up" && input.value !== "down") {
2444
- throw new import_common7.BadRequestException("value must be 'up', 'down' or null");
2500
+ throw new import_common8.BadRequestException("value must be 'up', 'down' or null");
2445
2501
  }
2446
2502
  if (input.comment !== void 0 && typeof input.comment !== "string") {
2447
- throw new import_common7.BadRequestException("comment must be a string");
2503
+ throw new import_common8.BadRequestException("comment must be a string");
2448
2504
  }
2449
2505
  const comment = input.comment?.trim();
2450
2506
  if (comment !== void 0 && comment.length > 2e3) {
2451
- throw new import_common7.BadRequestException("comment must be at most 2000 characters");
2507
+ throw new import_common8.BadRequestException("comment must be at most 2000 characters");
2452
2508
  }
2453
2509
  if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
2454
- throw new import_common7.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
2510
+ throw new import_common8.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
2455
2511
  }
2456
2512
  const threadId = await this.store.threadOfMessage(messageId);
2457
2513
  if (threadId === null) {
2458
- throw new import_common7.NotFoundException(`message ${messageId} not found`);
2514
+ throw new import_common8.NotFoundException(`message ${messageId} not found`);
2459
2515
  }
2460
2516
  await this.assertOwnsThread(actor, threadId);
2461
2517
  const feedback = input.value === null ? null : {
@@ -2503,7 +2559,7 @@ var AgentService = class {
2503
2559
  const list = this.attachmentInventory();
2504
2560
  const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
2505
2561
  if (referencedMediaIds === void 0) {
2506
- throw new import_common7.NotImplementedException("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
2562
+ throw new import_common8.NotImplementedException("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
2507
2563
  }
2508
2564
  const stagedBefore = options.olderThan.toISOString();
2509
2565
  const inventory = await list({
@@ -2525,7 +2581,7 @@ var AgentService = class {
2525
2581
  attachmentInventory() {
2526
2582
  const list = this.staging?.list?.bind(this.staging);
2527
2583
  if (list === void 0) {
2528
- throw new import_common7.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
2584
+ throw new import_common8.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
2529
2585
  }
2530
2586
  return list;
2531
2587
  }
@@ -2536,10 +2592,10 @@ var AgentService = class {
2536
2592
  async assertOwnsThread(actor, threadId) {
2537
2593
  const owner = await this.store.ownerOfThread(threadId);
2538
2594
  if (owner === null) {
2539
- throw new import_common7.NotFoundException(`thread ${threadId} not found`);
2595
+ throw new import_common8.NotFoundException(`thread ${threadId} not found`);
2540
2596
  }
2541
2597
  if (owner !== actor.id) {
2542
- throw new import_common7.ForbiddenException("thread belongs to another actor");
2598
+ throw new import_common8.ForbiddenException("thread belongs to another actor");
2543
2599
  }
2544
2600
  }
2545
2601
  /**
@@ -2550,10 +2606,10 @@ var AgentService = class {
2550
2606
  async assertOwnsToolCall(actor, toolCallId2) {
2551
2607
  const owner = await this.store.ownerOfToolCall(toolCallId2);
2552
2608
  if (owner === null) {
2553
- throw new import_common7.NotFoundException(`tool call ${toolCallId2} not found`);
2609
+ throw new import_common8.NotFoundException(`tool call ${toolCallId2} not found`);
2554
2610
  }
2555
2611
  if (owner !== actor.id) {
2556
- throw new import_common7.ForbiddenException("tool call belongs to another actor");
2612
+ throw new import_common8.ForbiddenException("tool call belongs to another actor");
2557
2613
  }
2558
2614
  }
2559
2615
  /**
@@ -2568,12 +2624,12 @@ var AgentService = class {
2568
2624
  if (this.store.toolCallInput === void 0) {
2569
2625
  return;
2570
2626
  }
2571
- const questions = (0, import_nestjs_agent_core9.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
2627
+ const questions = (0, import_nestjs_agent_core10.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
2572
2628
  for (const question of questions) {
2573
2629
  const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
2574
- const problem = (0, import_nestjs_agent_core9.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
2630
+ const problem = (0, import_nestjs_agent_core10.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
2575
2631
  if (problem !== null) {
2576
- throw new import_common7.BadRequestException(`answers["${question.id}"] ${problem}`);
2632
+ throw new import_common8.BadRequestException(`answers["${question.id}"] ${problem}`);
2577
2633
  }
2578
2634
  }
2579
2635
  }
@@ -2585,21 +2641,21 @@ var AgentService = class {
2585
2641
  */
2586
2642
  async assertMayDecide(actor, toolCallId2) {
2587
2643
  const approval = await this.store.toolCallApproval?.(toolCallId2);
2588
- const approver = approval?.approver ?? import_nestjs_agent_core9.REQUESTER_APPROVER;
2589
- if (approver === import_nestjs_agent_core9.REQUESTER_APPROVER) {
2644
+ const approver = approval?.approver ?? import_nestjs_agent_core10.REQUESTER_APPROVER;
2645
+ if (approver === import_nestjs_agent_core10.REQUESTER_APPROVER) {
2590
2646
  return this.assertOwnsToolCall(actor, toolCallId2);
2591
2647
  }
2592
2648
  const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
2593
2649
  if (requesterRef === null) {
2594
- throw new import_common7.NotFoundException(`tool call ${toolCallId2} not found`);
2650
+ throw new import_common8.NotFoundException(`tool call ${toolCallId2} not found`);
2595
2651
  }
2596
- const allowed = await (0, import_nestjs_agent_core9.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
2652
+ const allowed = await (0, import_nestjs_agent_core10.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
2597
2653
  toolCallId: toolCallId2,
2598
2654
  approver,
2599
2655
  requesterRef
2600
2656
  });
2601
2657
  if (!allowed) {
2602
- throw new import_common7.ForbiddenException(`this approval is for ${approver}`);
2658
+ throw new import_common8.ForbiddenException(`this approval is for ${approver}`);
2603
2659
  }
2604
2660
  }
2605
2661
  /**
@@ -2615,7 +2671,7 @@ var AgentService = class {
2615
2671
  }
2616
2672
  const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
2617
2673
  if (lapsed) {
2618
- throw new import_common7.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
2674
+ throw new import_common8.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
2619
2675
  }
2620
2676
  }
2621
2677
  /**
@@ -2628,7 +2684,7 @@ var AgentService = class {
2628
2684
  async resolveRunForToolCall(toolCallId2) {
2629
2685
  const runId = await this.store.runForToolCall(toolCallId2);
2630
2686
  if (runId === null) {
2631
- throw new import_common7.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
2687
+ throw new import_common8.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
2632
2688
  }
2633
2689
  return runId;
2634
2690
  }
@@ -2636,27 +2692,27 @@ var AgentService = class {
2636
2692
  async assertOwnsActiveStream(actor, runId) {
2637
2693
  const owner = await this.store.ownerOfActiveStream(runId);
2638
2694
  if (owner === null) {
2639
- throw new import_common7.NotFoundException(`no active run ${runId}`);
2695
+ throw new import_common8.NotFoundException(`no active run ${runId}`);
2640
2696
  }
2641
2697
  if (owner !== actor.id) {
2642
- throw new import_common7.ForbiddenException("run belongs to another actor");
2698
+ throw new import_common8.ForbiddenException("run belongs to another actor");
2643
2699
  }
2644
2700
  }
2645
2701
  };
2646
2702
  AgentService = _ts_decorate7([
2647
- (0, import_common7.Injectable)(),
2648
- _ts_param6(0, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_RUNNER)),
2649
- _ts_param6(1, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_STORE)),
2650
- _ts_param6(2, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_DEPS_FACTORY)),
2651
- _ts_param6(3, (0, import_common7.Optional)()),
2652
- _ts_param6(3, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
2653
- _ts_param6(4, (0, import_common7.Optional)()),
2654
- _ts_param6(4, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_MODEL_CATALOG)),
2655
- _ts_param6(5, (0, import_common7.Optional)()),
2656
- _ts_param6(5, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_QUOTA_PROVIDER)),
2657
- _ts_param6(6, (0, import_common7.Optional)()),
2658
- _ts_param6(6, (0, import_common7.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
2659
- _ts_param6(7, (0, import_common7.Optional)()),
2703
+ (0, import_common8.Injectable)(),
2704
+ _ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_RUNNER)),
2705
+ _ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_STORE)),
2706
+ _ts_param6(2, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_DEPS_FACTORY)),
2707
+ _ts_param6(3, (0, import_common8.Optional)()),
2708
+ _ts_param6(3, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_ATTACHMENT_STAGING)),
2709
+ _ts_param6(4, (0, import_common8.Optional)()),
2710
+ _ts_param6(4, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_MODEL_CATALOG)),
2711
+ _ts_param6(5, (0, import_common8.Optional)()),
2712
+ _ts_param6(5, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_QUOTA_PROVIDER)),
2713
+ _ts_param6(6, (0, import_common8.Optional)()),
2714
+ _ts_param6(6, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_OPTIONS)),
2715
+ _ts_param6(7, (0, import_common8.Optional)()),
2660
2716
  _ts_metadata6("design:type", Function),
2661
2717
  _ts_metadata6("design:paramtypes", [
2662
2718
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
@@ -2671,7 +2727,7 @@ AgentService = _ts_decorate7([
2671
2727
  ], AgentService);
2672
2728
 
2673
2729
  // src/approval-port.adapter.ts
2674
- var import_common8 = require("@nestjs/common");
2730
+ var import_common9 = require("@nestjs/common");
2675
2731
  function _ts_decorate8(decorators, target, key, desc) {
2676
2732
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2677
2733
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2730,7 +2786,7 @@ var AgentApprovalPortAdapter = class {
2730
2786
  }
2731
2787
  };
2732
2788
  AgentApprovalPortAdapter = _ts_decorate8([
2733
- (0, import_common8.Injectable)(),
2789
+ (0, import_common9.Injectable)(),
2734
2790
  _ts_metadata7("design:type", Function),
2735
2791
  _ts_metadata7("design:paramtypes", [
2736
2792
  typeof AgentService === "undefined" ? Object : AgentService
@@ -2738,8 +2794,8 @@ AgentApprovalPortAdapter = _ts_decorate8([
2738
2794
  ], AgentApprovalPortAdapter);
2739
2795
 
2740
2796
  // src/controller/agents.controller.ts
2741
- var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
2742
- var import_common9 = require("@nestjs/common");
2797
+ var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
2798
+ var import_common10 = require("@nestjs/common");
2743
2799
  function _ts_decorate9(decorators, target, key, desc) {
2744
2800
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2745
2801
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2788,25 +2844,25 @@ var AgentsController = class {
2788
2844
  }
2789
2845
  };
2790
2846
  _ts_decorate9([
2791
- (0, import_common9.Get)(),
2847
+ (0, import_common10.Get)(),
2792
2848
  _ts_metadata8("design:type", Function),
2793
2849
  _ts_metadata8("design:paramtypes", []),
2794
2850
  _ts_metadata8("design:returntype", Array)
2795
2851
  ], AgentsController.prototype, "list", null);
2796
2852
  AgentsController = _ts_decorate9([
2797
- (0, import_common9.Controller)("agents"),
2798
- _ts_param7(0, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_REGISTRY)),
2799
- _ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core10.AGENT_DEPS_FACTORY)),
2853
+ (0, import_common10.Controller)("agents"),
2854
+ _ts_param7(0, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_REGISTRY)),
2855
+ _ts_param7(1, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_DEPS_FACTORY)),
2800
2856
  _ts_metadata8("design:type", Function),
2801
2857
  _ts_metadata8("design:paramtypes", [
2802
- typeof import_nestjs_agent_core10.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core10.AgentRegistry,
2858
+ typeof import_nestjs_agent_core11.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core11.AgentRegistry,
2803
2859
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
2804
2860
  ])
2805
2861
  ], AgentsController);
2806
2862
 
2807
2863
  // src/controller/attachments.controller.ts
2808
- var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
2809
- var import_common10 = require("@nestjs/common");
2864
+ var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2865
+ var import_common11 = require("@nestjs/common");
2810
2866
  var import_platform_express = require("@nestjs/platform-express");
2811
2867
 
2812
2868
  // src/attachment-limits.ts
@@ -2894,17 +2950,17 @@ var AttachmentsController = class {
2894
2950
  }
2895
2951
  async upload(req, file) {
2896
2952
  if (this.staging === void 0) {
2897
- throw new import_common10.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2953
+ throw new import_common11.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2898
2954
  }
2899
2955
  if (file === void 0) {
2900
- throw new import_common10.BadRequestException('multipart field "file" is required');
2956
+ throw new import_common11.BadRequestException('multipart field "file" is required');
2901
2957
  }
2902
2958
  const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
2903
2959
  if (!allowedContentTypes.includes(file.mimetype)) {
2904
- throw new import_common10.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
2960
+ throw new import_common11.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
2905
2961
  }
2906
2962
  if (file.size > maxBytes) {
2907
- throw new import_common10.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
2963
+ throw new import_common11.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
2908
2964
  }
2909
2965
  const actor = await this.actorResolver.resolve(req);
2910
2966
  return this.staging.stage({
@@ -2917,8 +2973,8 @@ var AttachmentsController = class {
2917
2973
  }
2918
2974
  };
2919
2975
  _ts_decorate10([
2920
- (0, import_common10.Get)(),
2921
- _ts_param8(0, (0, import_common10.Req)()),
2976
+ (0, import_common11.Get)(),
2977
+ _ts_param8(0, (0, import_common11.Req)()),
2922
2978
  _ts_metadata9("design:type", Function),
2923
2979
  _ts_metadata9("design:paramtypes", [
2924
2980
  typeof Request === "undefined" ? Object : Request
@@ -2926,14 +2982,14 @@ _ts_decorate10([
2926
2982
  _ts_metadata9("design:returntype", Promise)
2927
2983
  ], AttachmentsController.prototype, "list", null);
2928
2984
  _ts_decorate10([
2929
- (0, import_common10.Post)(),
2930
- (0, import_common10.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
2985
+ (0, import_common11.Post)(),
2986
+ (0, import_common11.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
2931
2987
  limits: {
2932
2988
  fileSize: HARD_MAX_ATTACHMENT_BYTES
2933
2989
  }
2934
2990
  })),
2935
- _ts_param8(0, (0, import_common10.Req)()),
2936
- _ts_param8(1, (0, import_common10.UploadedFile)()),
2991
+ _ts_param8(0, (0, import_common11.Req)()),
2992
+ _ts_param8(1, (0, import_common11.UploadedFile)()),
2937
2993
  _ts_metadata9("design:type", Function),
2938
2994
  _ts_metadata9("design:paramtypes", [
2939
2995
  typeof Request === "undefined" ? Object : Request,
@@ -2942,11 +2998,11 @@ _ts_decorate10([
2942
2998
  _ts_metadata9("design:returntype", Promise)
2943
2999
  ], AttachmentsController.prototype, "upload", null);
2944
3000
  AttachmentsController = _ts_decorate10([
2945
- (0, import_common10.Controller)("attachments"),
2946
- _ts_param8(0, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_OPTIONS)),
2947
- _ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
2948
- _ts_param8(3, (0, import_common10.Optional)()),
2949
- _ts_param8(3, (0, import_common10.Inject)(import_nestjs_agent_core11.AGENT_ATTACHMENT_STAGING)),
3001
+ (0, import_common11.Controller)("attachments"),
3002
+ _ts_param8(0, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_OPTIONS)),
3003
+ _ts_param8(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
3004
+ _ts_param8(3, (0, import_common11.Optional)()),
3005
+ _ts_param8(3, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ATTACHMENT_STAGING)),
2950
3006
  _ts_metadata9("design:type", Function),
2951
3007
  _ts_metadata9("design:paramtypes", [
2952
3008
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -2957,8 +3013,8 @@ AttachmentsController = _ts_decorate10([
2957
3013
  ], AttachmentsController);
2958
3014
 
2959
3015
  // src/controller/chat.controller.ts
2960
- var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
2961
- var import_common11 = require("@nestjs/common");
3016
+ var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
3017
+ var import_common12 = require("@nestjs/common");
2962
3018
  function _ts_decorate11(decorators, target, key, desc) {
2963
3019
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2964
3020
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -2995,7 +3051,7 @@ function sendMode(body) {
2995
3051
  if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
2996
3052
  return body.mode;
2997
3053
  }
2998
- throw new import_common11.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
3054
+ throw new import_common12.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
2999
3055
  }
3000
3056
  __name(sendMode, "sendMode");
3001
3057
  function attachmentRefs(claimed) {
@@ -3003,21 +3059,21 @@ function attachmentRefs(claimed) {
3003
3059
  return [];
3004
3060
  }
3005
3061
  if (!Array.isArray(claimed)) {
3006
- throw new import_common11.BadRequestException("attachments must be an array of { mediaId }");
3062
+ throw new import_common12.BadRequestException("attachments must be an array of { mediaId }");
3007
3063
  }
3008
3064
  if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
3009
- throw new import_common11.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
3065
+ throw new import_common12.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
3010
3066
  }
3011
3067
  return claimed.map((entry) => {
3012
3068
  if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
3013
- throw new import_common11.BadRequestException("each attachment must be an object with a mediaId");
3069
+ throw new import_common12.BadRequestException("each attachment must be an object with a mediaId");
3014
3070
  }
3015
3071
  if (Object.keys(entry).some((key) => key !== "mediaId")) {
3016
- throw new import_common11.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
3072
+ throw new import_common12.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
3017
3073
  }
3018
3074
  const { mediaId } = entry;
3019
3075
  if (typeof mediaId !== "string" || mediaId.length === 0) {
3020
- throw new import_common11.BadRequestException("each attachment must carry a non-empty string mediaId");
3076
+ throw new import_common12.BadRequestException("each attachment must carry a non-empty string mediaId");
3021
3077
  }
3022
3078
  return {
3023
3079
  mediaId
@@ -3150,13 +3206,10 @@ data: ${line}
3150
3206
  }
3151
3207
  res.write("event: done\ndata: {}\n\n");
3152
3208
  } catch (error) {
3153
- const payload = error instanceof import_nestjs_agent_core12.AgentStreamError ? {
3209
+ const payload = error instanceof import_nestjs_agent_core13.AgentStreamError ? {
3154
3210
  code: error.code,
3155
3211
  message: error.message
3156
- } : {
3157
- code: "run_failed",
3158
- message: error instanceof Error ? error.message : "stream error"
3159
- };
3212
+ } : (0, import_nestjs_agent_core13.streamFailure)(error);
3160
3213
  res.write(`event: error
3161
3214
  data: ${JSON.stringify(payload)}
3162
3215
 
@@ -3166,10 +3219,10 @@ data: ${JSON.stringify(payload)}
3166
3219
  }
3167
3220
  };
3168
3221
  _ts_decorate11([
3169
- (0, import_common11.Post)("chat"),
3170
- _ts_param9(0, (0, import_common11.Req)()),
3171
- _ts_param9(1, (0, import_common11.Res)()),
3172
- _ts_param9(2, (0, import_common11.Body)()),
3222
+ (0, import_common12.Post)("chat"),
3223
+ _ts_param9(0, (0, import_common12.Req)()),
3224
+ _ts_param9(1, (0, import_common12.Res)()),
3225
+ _ts_param9(2, (0, import_common12.Body)()),
3173
3226
  _ts_metadata10("design:type", Function),
3174
3227
  _ts_metadata10("design:paramtypes", [
3175
3228
  typeof Request === "undefined" ? Object : Request,
@@ -3179,11 +3232,11 @@ _ts_decorate11([
3179
3232
  _ts_metadata10("design:returntype", Promise)
3180
3233
  ], ChatController.prototype, "chat", null);
3181
3234
  _ts_decorate11([
3182
- (0, import_common11.Get)("chat/:runId/stream"),
3183
- _ts_param9(0, (0, import_common11.Req)()),
3184
- _ts_param9(1, (0, import_common11.Param)("runId")),
3185
- _ts_param9(2, (0, import_common11.Res)()),
3186
- _ts_param9(3, (0, import_common11.Query)("after")),
3235
+ (0, import_common12.Get)("chat/:runId/stream"),
3236
+ _ts_param9(0, (0, import_common12.Req)()),
3237
+ _ts_param9(1, (0, import_common12.Param)("runId")),
3238
+ _ts_param9(2, (0, import_common12.Res)()),
3239
+ _ts_param9(3, (0, import_common12.Query)("after")),
3187
3240
  _ts_metadata10("design:type", Function),
3188
3241
  _ts_metadata10("design:paramtypes", [
3189
3242
  typeof Request === "undefined" ? Object : Request,
@@ -3194,9 +3247,9 @@ _ts_decorate11([
3194
3247
  _ts_metadata10("design:returntype", Promise)
3195
3248
  ], ChatController.prototype, "stream", null);
3196
3249
  _ts_decorate11([
3197
- (0, import_common11.Post)("chat/:runId/cancel"),
3198
- _ts_param9(0, (0, import_common11.Req)()),
3199
- _ts_param9(1, (0, import_common11.Param)("runId")),
3250
+ (0, import_common12.Post)("chat/:runId/cancel"),
3251
+ _ts_param9(0, (0, import_common12.Req)()),
3252
+ _ts_param9(1, (0, import_common12.Param)("runId")),
3200
3253
  _ts_metadata10("design:type", Function),
3201
3254
  _ts_metadata10("design:paramtypes", [
3202
3255
  typeof Request === "undefined" ? Object : Request,
@@ -3205,8 +3258,8 @@ _ts_decorate11([
3205
3258
  _ts_metadata10("design:returntype", Promise)
3206
3259
  ], ChatController.prototype, "cancel", null);
3207
3260
  ChatController = _ts_decorate11([
3208
- (0, import_common11.Controller)(),
3209
- _ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
3261
+ (0, import_common12.Controller)(),
3262
+ _ts_param9(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
3210
3263
  _ts_metadata10("design:type", Function),
3211
3264
  _ts_metadata10("design:paramtypes", [
3212
3265
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3224,8 +3277,8 @@ function parseCursor(raw) {
3224
3277
  __name(parseCursor, "parseCursor");
3225
3278
 
3226
3279
  // src/controller/config.controller.ts
3227
- var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
3228
- var import_common12 = require("@nestjs/common");
3280
+ var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
3281
+ var import_common13 = require("@nestjs/common");
3229
3282
 
3230
3283
  // src/resolver/anonymous-actor-resolver.ts
3231
3284
  var import_node_crypto2 = require("crypto");
@@ -3372,8 +3425,8 @@ var ConfigController = class {
3372
3425
  }
3373
3426
  };
3374
3427
  _ts_decorate12([
3375
- (0, import_common12.Get)(),
3376
- _ts_param10(0, (0, import_common12.Req)()),
3428
+ (0, import_common13.Get)(),
3429
+ _ts_param10(0, (0, import_common13.Req)()),
3377
3430
  _ts_metadata11("design:type", Function),
3378
3431
  _ts_metadata11("design:paramtypes", [
3379
3432
  typeof Request === "undefined" ? Object : Request
@@ -3381,13 +3434,13 @@ _ts_decorate12([
3381
3434
  _ts_metadata11("design:returntype", Promise)
3382
3435
  ], ConfigController.prototype, "config", null);
3383
3436
  ConfigController = _ts_decorate12([
3384
- (0, import_common12.Controller)("config"),
3385
- _ts_param10(0, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_OPTIONS)),
3386
- _ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
3387
- _ts_param10(2, (0, import_common12.Optional)()),
3388
- _ts_param10(2, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ATTACHMENT_STAGING)),
3389
- _ts_param10(3, (0, import_common12.Optional)()),
3390
- _ts_param10(3, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_MODEL_CATALOG)),
3437
+ (0, import_common13.Controller)("config"),
3438
+ _ts_param10(0, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
3439
+ _ts_param10(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
3440
+ _ts_param10(2, (0, import_common13.Optional)()),
3441
+ _ts_param10(2, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ATTACHMENT_STAGING)),
3442
+ _ts_param10(3, (0, import_common13.Optional)()),
3443
+ _ts_param10(3, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_MODEL_CATALOG)),
3391
3444
  _ts_metadata11("design:type", Function),
3392
3445
  _ts_metadata11("design:paramtypes", [
3393
3446
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -3398,8 +3451,8 @@ ConfigController = _ts_decorate12([
3398
3451
  ], ConfigController);
3399
3452
 
3400
3453
  // src/controller/memories.controller.ts
3401
- var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
3402
- var import_common13 = require("@nestjs/common");
3454
+ var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
3455
+ var import_common14 = require("@nestjs/common");
3403
3456
  function _ts_decorate13(decorators, target, key, desc) {
3404
3457
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3405
3458
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3459,20 +3512,20 @@ var MemoriesController = class {
3459
3512
  */
3460
3513
  async forget(req, id) {
3461
3514
  if (this.memory === void 0) {
3462
- throw new import_common13.NotFoundException("No memory is configured in this deployment.");
3515
+ throw new import_common14.NotFoundException("No memory is configured in this deployment.");
3463
3516
  }
3464
3517
  const actor = await this.actorResolver.resolve(req);
3465
3518
  const digest = await this.unbounded("", actor);
3466
3519
  const entry = digest.entries.find((candidate) => candidate.id === id);
3467
3520
  if (entry === void 0) {
3468
- throw new import_common13.NotFoundException(`No memory with id "${id}".`);
3521
+ throw new import_common14.NotFoundException(`No memory with id "${id}".`);
3469
3522
  }
3470
- const verdict = (0, import_nestjs_agent_core14.memoryForgetVerdict)({
3523
+ const verdict = (0, import_nestjs_agent_core15.memoryForgetVerdict)({
3471
3524
  record: entry,
3472
3525
  actor
3473
3526
  });
3474
3527
  if (!verdict.allowed) {
3475
- throw new import_common13.ForbiddenException(verdict.reason);
3528
+ throw new import_common14.ForbiddenException(verdict.reason);
3476
3529
  }
3477
3530
  return {
3478
3531
  forgotten: await this.memory.provider.forget({
@@ -3486,7 +3539,7 @@ var MemoriesController = class {
3486
3539
  }
3487
3540
  async unbounded(threadId, actor) {
3488
3541
  const config = this.memory;
3489
- return await (0, import_nestjs_agent_core14.offerMemories)({
3542
+ return await (0, import_nestjs_agent_core15.offerMemories)({
3490
3543
  config: {
3491
3544
  ...config,
3492
3545
  maxMemories: Number.POSITIVE_INFINITY
@@ -3499,9 +3552,9 @@ var MemoriesController = class {
3499
3552
  }
3500
3553
  };
3501
3554
  _ts_decorate13([
3502
- (0, import_common13.Get)(),
3503
- _ts_param11(0, (0, import_common13.Req)()),
3504
- _ts_param11(1, (0, import_common13.Query)("threadId")),
3555
+ (0, import_common14.Get)(),
3556
+ _ts_param11(0, (0, import_common14.Req)()),
3557
+ _ts_param11(1, (0, import_common14.Query)("threadId")),
3505
3558
  _ts_metadata12("design:type", Function),
3506
3559
  _ts_metadata12("design:paramtypes", [
3507
3560
  typeof Request === "undefined" ? Object : Request,
@@ -3510,9 +3563,9 @@ _ts_decorate13([
3510
3563
  _ts_metadata12("design:returntype", Promise)
3511
3564
  ], MemoriesController.prototype, "list", null);
3512
3565
  _ts_decorate13([
3513
- (0, import_common13.Delete)(":id"),
3514
- _ts_param11(0, (0, import_common13.Req)()),
3515
- _ts_param11(1, (0, import_common13.Param)("id")),
3566
+ (0, import_common14.Delete)(":id"),
3567
+ _ts_param11(0, (0, import_common14.Req)()),
3568
+ _ts_param11(1, (0, import_common14.Param)("id")),
3516
3569
  _ts_metadata12("design:type", Function),
3517
3570
  _ts_metadata12("design:paramtypes", [
3518
3571
  typeof Request === "undefined" ? Object : Request,
@@ -3521,10 +3574,10 @@ _ts_decorate13([
3521
3574
  _ts_metadata12("design:returntype", Promise)
3522
3575
  ], MemoriesController.prototype, "forget", null);
3523
3576
  MemoriesController = _ts_decorate13([
3524
- (0, import_common13.Controller)("memories"),
3525
- _ts_param11(0, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
3526
- _ts_param11(1, (0, import_common13.Optional)()),
3527
- _ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_MEMORY)),
3577
+ (0, import_common14.Controller)("memories"),
3578
+ _ts_param11(0, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
3579
+ _ts_param11(1, (0, import_common14.Optional)()),
3580
+ _ts_param11(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_MEMORY)),
3528
3581
  _ts_metadata12("design:type", Function),
3529
3582
  _ts_metadata12("design:paramtypes", [
3530
3583
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
@@ -3533,8 +3586,8 @@ MemoriesController = _ts_decorate13([
3533
3586
  ], MemoriesController);
3534
3587
 
3535
3588
  // src/controller/messages.controller.ts
3536
- var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
3537
- var import_common14 = require("@nestjs/common");
3589
+ var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
3590
+ var import_common15 = require("@nestjs/common");
3538
3591
  function _ts_decorate14(decorators, target, key, desc) {
3539
3592
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3540
3593
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3589,11 +3642,11 @@ var MessagesController = class {
3589
3642
  }
3590
3643
  };
3591
3644
  _ts_decorate14([
3592
- (0, import_common14.Post)(":id/feedback"),
3593
- (0, import_common14.HttpCode)(200),
3594
- _ts_param12(0, (0, import_common14.Req)()),
3595
- _ts_param12(1, (0, import_common14.Param)("id")),
3596
- _ts_param12(2, (0, import_common14.Body)()),
3645
+ (0, import_common15.Post)(":id/feedback"),
3646
+ (0, import_common15.HttpCode)(200),
3647
+ _ts_param12(0, (0, import_common15.Req)()),
3648
+ _ts_param12(1, (0, import_common15.Param)("id")),
3649
+ _ts_param12(2, (0, import_common15.Body)()),
3597
3650
  _ts_metadata13("design:type", Function),
3598
3651
  _ts_metadata13("design:paramtypes", [
3599
3652
  typeof Request === "undefined" ? Object : Request,
@@ -3603,8 +3656,8 @@ _ts_decorate14([
3603
3656
  _ts_metadata13("design:returntype", Promise)
3604
3657
  ], MessagesController.prototype, "feedback", null);
3605
3658
  MessagesController = _ts_decorate14([
3606
- (0, import_common14.Controller)("messages"),
3607
- _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
3659
+ (0, import_common15.Controller)("messages"),
3660
+ _ts_param12(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
3608
3661
  _ts_metadata13("design:type", Function),
3609
3662
  _ts_metadata13("design:paramtypes", [
3610
3663
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3613,8 +3666,8 @@ MessagesController = _ts_decorate14([
3613
3666
  ], MessagesController);
3614
3667
 
3615
3668
  // src/controller/models.controller.ts
3616
- var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
3617
- var import_common15 = require("@nestjs/common");
3669
+ var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
3670
+ var import_common16 = require("@nestjs/common");
3618
3671
  function _ts_decorate15(decorators, target, key, desc) {
3619
3672
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3620
3673
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3661,9 +3714,9 @@ var ModelsController = class {
3661
3714
  }
3662
3715
  };
3663
3716
  _ts_decorate15([
3664
- (0, import_common15.Get)(),
3665
- _ts_param13(0, (0, import_common15.Req)()),
3666
- _ts_param13(1, (0, import_common15.Query)("agent")),
3717
+ (0, import_common16.Get)(),
3718
+ _ts_param13(0, (0, import_common16.Req)()),
3719
+ _ts_param13(1, (0, import_common16.Query)("agent")),
3667
3720
  _ts_metadata14("design:type", Function),
3668
3721
  _ts_metadata14("design:paramtypes", [
3669
3722
  typeof Request === "undefined" ? Object : Request,
@@ -3672,8 +3725,8 @@ _ts_decorate15([
3672
3725
  _ts_metadata14("design:returntype", Promise)
3673
3726
  ], ModelsController.prototype, "list", null);
3674
3727
  ModelsController = _ts_decorate15([
3675
- (0, import_common15.Controller)("models"),
3676
- _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
3728
+ (0, import_common16.Controller)("models"),
3729
+ _ts_param13(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
3677
3730
  _ts_metadata14("design:type", Function),
3678
3731
  _ts_metadata14("design:paramtypes", [
3679
3732
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3682,8 +3735,8 @@ ModelsController = _ts_decorate15([
3682
3735
  ], ModelsController);
3683
3736
 
3684
3737
  // src/controller/queue.controller.ts
3685
- var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
3686
- var import_common16 = require("@nestjs/common");
3738
+ var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
3739
+ var import_common17 = require("@nestjs/common");
3687
3740
  function _ts_decorate16(decorators, target, key, desc) {
3688
3741
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3689
3742
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3733,10 +3786,10 @@ var QueueController = class {
3733
3786
  async update(req, messageId, body) {
3734
3787
  const actor = await this.actorResolver.resolve(req);
3735
3788
  if (body.message !== void 0 && typeof body.message !== "string") {
3736
- throw new import_common16.BadRequestException("message must be a string");
3789
+ throw new import_common17.BadRequestException("message must be a string");
3737
3790
  }
3738
3791
  if (body.position !== void 0 && typeof body.position !== "number") {
3739
- throw new import_common16.BadRequestException("position must be a number");
3792
+ throw new import_common17.BadRequestException("position must be a number");
3740
3793
  }
3741
3794
  const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
3742
3795
  return this.agent.updateQueuedMessage(actor, messageId, {
@@ -3764,9 +3817,9 @@ var QueueController = class {
3764
3817
  }
3765
3818
  };
3766
3819
  _ts_decorate16([
3767
- (0, import_common16.Get)("threads/:id/queue"),
3768
- _ts_param14(0, (0, import_common16.Req)()),
3769
- _ts_param14(1, (0, import_common16.Param)("id")),
3820
+ (0, import_common17.Get)("threads/:id/queue"),
3821
+ _ts_param14(0, (0, import_common17.Req)()),
3822
+ _ts_param14(1, (0, import_common17.Param)("id")),
3770
3823
  _ts_metadata15("design:type", Function),
3771
3824
  _ts_metadata15("design:paramtypes", [
3772
3825
  typeof Request === "undefined" ? Object : Request,
@@ -3775,9 +3828,9 @@ _ts_decorate16([
3775
3828
  _ts_metadata15("design:returntype", Promise)
3776
3829
  ], QueueController.prototype, "list", null);
3777
3830
  _ts_decorate16([
3778
- (0, import_common16.Delete)("threads/:id/queue"),
3779
- _ts_param14(0, (0, import_common16.Req)()),
3780
- _ts_param14(1, (0, import_common16.Param)("id")),
3831
+ (0, import_common17.Delete)("threads/:id/queue"),
3832
+ _ts_param14(0, (0, import_common17.Req)()),
3833
+ _ts_param14(1, (0, import_common17.Param)("id")),
3781
3834
  _ts_metadata15("design:type", Function),
3782
3835
  _ts_metadata15("design:paramtypes", [
3783
3836
  typeof Request === "undefined" ? Object : Request,
@@ -3786,9 +3839,9 @@ _ts_decorate16([
3786
3839
  _ts_metadata15("design:returntype", Promise)
3787
3840
  ], QueueController.prototype, "clear", null);
3788
3841
  _ts_decorate16([
3789
- (0, import_common16.Post)("threads/:id/queue/resume"),
3790
- _ts_param14(0, (0, import_common16.Req)()),
3791
- _ts_param14(1, (0, import_common16.Param)("id")),
3842
+ (0, import_common17.Post)("threads/:id/queue/resume"),
3843
+ _ts_param14(0, (0, import_common17.Req)()),
3844
+ _ts_param14(1, (0, import_common17.Param)("id")),
3792
3845
  _ts_metadata15("design:type", Function),
3793
3846
  _ts_metadata15("design:paramtypes", [
3794
3847
  typeof Request === "undefined" ? Object : Request,
@@ -3797,10 +3850,10 @@ _ts_decorate16([
3797
3850
  _ts_metadata15("design:returntype", Promise)
3798
3851
  ], QueueController.prototype, "resume", null);
3799
3852
  _ts_decorate16([
3800
- (0, import_common16.Patch)("queue/:messageId"),
3801
- _ts_param14(0, (0, import_common16.Req)()),
3802
- _ts_param14(1, (0, import_common16.Param)("messageId")),
3803
- _ts_param14(2, (0, import_common16.Body)()),
3853
+ (0, import_common17.Patch)("queue/:messageId"),
3854
+ _ts_param14(0, (0, import_common17.Req)()),
3855
+ _ts_param14(1, (0, import_common17.Param)("messageId")),
3856
+ _ts_param14(2, (0, import_common17.Body)()),
3804
3857
  _ts_metadata15("design:type", Function),
3805
3858
  _ts_metadata15("design:paramtypes", [
3806
3859
  typeof Request === "undefined" ? Object : Request,
@@ -3810,9 +3863,9 @@ _ts_decorate16([
3810
3863
  _ts_metadata15("design:returntype", Promise)
3811
3864
  ], QueueController.prototype, "update", null);
3812
3865
  _ts_decorate16([
3813
- (0, import_common16.Post)("queue/:messageId/interrupt"),
3814
- _ts_param14(0, (0, import_common16.Req)()),
3815
- _ts_param14(1, (0, import_common16.Param)("messageId")),
3866
+ (0, import_common17.Post)("queue/:messageId/interrupt"),
3867
+ _ts_param14(0, (0, import_common17.Req)()),
3868
+ _ts_param14(1, (0, import_common17.Param)("messageId")),
3816
3869
  _ts_metadata15("design:type", Function),
3817
3870
  _ts_metadata15("design:paramtypes", [
3818
3871
  typeof Request === "undefined" ? Object : Request,
@@ -3821,9 +3874,9 @@ _ts_decorate16([
3821
3874
  _ts_metadata15("design:returntype", Promise)
3822
3875
  ], QueueController.prototype, "interrupt", null);
3823
3876
  _ts_decorate16([
3824
- (0, import_common16.Delete)("queue/:messageId"),
3825
- _ts_param14(0, (0, import_common16.Req)()),
3826
- _ts_param14(1, (0, import_common16.Param)("messageId")),
3877
+ (0, import_common17.Delete)("queue/:messageId"),
3878
+ _ts_param14(0, (0, import_common17.Req)()),
3879
+ _ts_param14(1, (0, import_common17.Param)("messageId")),
3827
3880
  _ts_metadata15("design:type", Function),
3828
3881
  _ts_metadata15("design:paramtypes", [
3829
3882
  typeof Request === "undefined" ? Object : Request,
@@ -3832,8 +3885,8 @@ _ts_decorate16([
3832
3885
  _ts_metadata15("design:returntype", Promise)
3833
3886
  ], QueueController.prototype, "remove", null);
3834
3887
  QueueController = _ts_decorate16([
3835
- (0, import_common16.Controller)(),
3836
- _ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
3888
+ (0, import_common17.Controller)(),
3889
+ _ts_param14(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
3837
3890
  _ts_metadata15("design:type", Function),
3838
3891
  _ts_metadata15("design:paramtypes", [
3839
3892
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3842,8 +3895,8 @@ QueueController = _ts_decorate16([
3842
3895
  ], QueueController);
3843
3896
 
3844
3897
  // src/controller/quota.controller.ts
3845
- var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
3846
- var import_common17 = require("@nestjs/common");
3898
+ var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3899
+ var import_common18 = require("@nestjs/common");
3847
3900
  function _ts_decorate17(decorators, target, key, desc) {
3848
3901
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3849
3902
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3890,8 +3943,8 @@ var QuotaController = class {
3890
3943
  }
3891
3944
  };
3892
3945
  _ts_decorate17([
3893
- (0, import_common17.Get)(),
3894
- _ts_param15(0, (0, import_common17.Req)()),
3946
+ (0, import_common18.Get)(),
3947
+ _ts_param15(0, (0, import_common18.Req)()),
3895
3948
  _ts_metadata16("design:type", Function),
3896
3949
  _ts_metadata16("design:paramtypes", [
3897
3950
  typeof Request === "undefined" ? Object : Request
@@ -3899,8 +3952,8 @@ _ts_decorate17([
3899
3952
  _ts_metadata16("design:returntype", Promise)
3900
3953
  ], QuotaController.prototype, "report", null);
3901
3954
  QuotaController = _ts_decorate17([
3902
- (0, import_common17.Controller)("quota"),
3903
- _ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
3955
+ (0, import_common18.Controller)("quota"),
3956
+ _ts_param15(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
3904
3957
  _ts_metadata16("design:type", Function),
3905
3958
  _ts_metadata16("design:paramtypes", [
3906
3959
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3909,8 +3962,8 @@ QuotaController = _ts_decorate17([
3909
3962
  ], QuotaController);
3910
3963
 
3911
3964
  // src/controller/skills.controller.ts
3912
- var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3913
- var import_common18 = require("@nestjs/common");
3965
+ var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3966
+ var import_common19 = require("@nestjs/common");
3914
3967
  function _ts_decorate18(decorators, target, key, desc) {
3915
3968
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3916
3969
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -3952,7 +4005,7 @@ var SkillsController = class {
3952
4005
  return [];
3953
4006
  }
3954
4007
  const actor = await this.actorResolver.resolve(req);
3955
- const offer = await (0, import_nestjs_agent_core19.offerSkills)(this.skills, {
4008
+ const offer = await (0, import_nestjs_agent_core20.offerSkills)(this.skills, {
3956
4009
  actor,
3957
4010
  threadId: threadId ?? ""
3958
4011
  });
@@ -3960,9 +4013,9 @@ var SkillsController = class {
3960
4013
  }
3961
4014
  };
3962
4015
  _ts_decorate18([
3963
- (0, import_common18.Get)(),
3964
- _ts_param16(0, (0, import_common18.Req)()),
3965
- _ts_param16(1, (0, import_common18.Query)("threadId")),
4016
+ (0, import_common19.Get)(),
4017
+ _ts_param16(0, (0, import_common19.Req)()),
4018
+ _ts_param16(1, (0, import_common19.Query)("threadId")),
3966
4019
  _ts_metadata17("design:type", Function),
3967
4020
  _ts_metadata17("design:paramtypes", [
3968
4021
  typeof Request === "undefined" ? Object : Request,
@@ -3971,10 +4024,10 @@ _ts_decorate18([
3971
4024
  _ts_metadata17("design:returntype", Promise)
3972
4025
  ], SkillsController.prototype, "list", null);
3973
4026
  SkillsController = _ts_decorate18([
3974
- (0, import_common18.Controller)("skills"),
3975
- _ts_param16(0, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
3976
- _ts_param16(1, (0, import_common18.Optional)()),
3977
- _ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_SKILLS)),
4027
+ (0, import_common19.Controller)("skills"),
4028
+ _ts_param16(0, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
4029
+ _ts_param16(1, (0, import_common19.Optional)()),
4030
+ _ts_param16(1, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_SKILLS)),
3978
4031
  _ts_metadata17("design:type", Function),
3979
4032
  _ts_metadata17("design:paramtypes", [
3980
4033
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
@@ -3983,8 +4036,8 @@ SkillsController = _ts_decorate18([
3983
4036
  ], SkillsController);
3984
4037
 
3985
4038
  // src/controller/threads.controller.ts
3986
- var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3987
- var import_common19 = require("@nestjs/common");
4039
+ var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
4040
+ var import_common20 = require("@nestjs/common");
3988
4041
  function _ts_decorate19(decorators, target, key, desc) {
3989
4042
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3990
4043
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -4078,8 +4131,8 @@ var ThreadsController = class {
4078
4131
  }
4079
4132
  };
4080
4133
  _ts_decorate19([
4081
- (0, import_common19.Get)(),
4082
- _ts_param17(0, (0, import_common19.Req)()),
4134
+ (0, import_common20.Get)(),
4135
+ _ts_param17(0, (0, import_common20.Req)()),
4083
4136
  _ts_metadata18("design:type", Function),
4084
4137
  _ts_metadata18("design:paramtypes", [
4085
4138
  typeof Request === "undefined" ? Object : Request
@@ -4087,9 +4140,9 @@ _ts_decorate19([
4087
4140
  _ts_metadata18("design:returntype", Promise)
4088
4141
  ], ThreadsController.prototype, "list", null);
4089
4142
  _ts_decorate19([
4090
- (0, import_common19.Get)(":id"),
4091
- _ts_param17(0, (0, import_common19.Req)()),
4092
- _ts_param17(1, (0, import_common19.Param)("id")),
4143
+ (0, import_common20.Get)(":id"),
4144
+ _ts_param17(0, (0, import_common20.Req)()),
4145
+ _ts_param17(1, (0, import_common20.Param)("id")),
4093
4146
  _ts_metadata18("design:type", Function),
4094
4147
  _ts_metadata18("design:paramtypes", [
4095
4148
  typeof Request === "undefined" ? Object : Request,
@@ -4098,9 +4151,9 @@ _ts_decorate19([
4098
4151
  _ts_metadata18("design:returntype", Promise)
4099
4152
  ], ThreadsController.prototype, "detail", null);
4100
4153
  _ts_decorate19([
4101
- (0, import_common19.Delete)(":id"),
4102
- _ts_param17(0, (0, import_common19.Req)()),
4103
- _ts_param17(1, (0, import_common19.Param)("id")),
4154
+ (0, import_common20.Delete)(":id"),
4155
+ _ts_param17(0, (0, import_common20.Req)()),
4156
+ _ts_param17(1, (0, import_common20.Param)("id")),
4104
4157
  _ts_metadata18("design:type", Function),
4105
4158
  _ts_metadata18("design:paramtypes", [
4106
4159
  typeof Request === "undefined" ? Object : Request,
@@ -4109,10 +4162,10 @@ _ts_decorate19([
4109
4162
  _ts_metadata18("design:returntype", Promise)
4110
4163
  ], ThreadsController.prototype, "remove", null);
4111
4164
  _ts_decorate19([
4112
- (0, import_common19.Post)(":id/fork-from/:messageId"),
4113
- _ts_param17(0, (0, import_common19.Req)()),
4114
- _ts_param17(1, (0, import_common19.Param)("id")),
4115
- _ts_param17(2, (0, import_common19.Param)("messageId")),
4165
+ (0, import_common20.Post)(":id/fork-from/:messageId"),
4166
+ _ts_param17(0, (0, import_common20.Req)()),
4167
+ _ts_param17(1, (0, import_common20.Param)("id")),
4168
+ _ts_param17(2, (0, import_common20.Param)("messageId")),
4116
4169
  _ts_metadata18("design:type", Function),
4117
4170
  _ts_metadata18("design:paramtypes", [
4118
4171
  typeof Request === "undefined" ? Object : Request,
@@ -4122,10 +4175,10 @@ _ts_decorate19([
4122
4175
  _ts_metadata18("design:returntype", Promise)
4123
4176
  ], ThreadsController.prototype, "fork", null);
4124
4177
  _ts_decorate19([
4125
- (0, import_common19.Patch)(":id"),
4126
- _ts_param17(0, (0, import_common19.Req)()),
4127
- _ts_param17(1, (0, import_common19.Param)("id")),
4128
- _ts_param17(2, (0, import_common19.Body)()),
4178
+ (0, import_common20.Patch)(":id"),
4179
+ _ts_param17(0, (0, import_common20.Req)()),
4180
+ _ts_param17(1, (0, import_common20.Param)("id")),
4181
+ _ts_param17(2, (0, import_common20.Body)()),
4129
4182
  _ts_metadata18("design:type", Function),
4130
4183
  _ts_metadata18("design:paramtypes", [
4131
4184
  typeof Request === "undefined" ? Object : Request,
@@ -4135,9 +4188,9 @@ _ts_decorate19([
4135
4188
  _ts_metadata18("design:returntype", Promise)
4136
4189
  ], ThreadsController.prototype, "update", null);
4137
4190
  _ts_decorate19([
4138
- (0, import_common19.Post)(":id/promote"),
4139
- _ts_param17(0, (0, import_common19.Req)()),
4140
- _ts_param17(1, (0, import_common19.Param)("id")),
4191
+ (0, import_common20.Post)(":id/promote"),
4192
+ _ts_param17(0, (0, import_common20.Req)()),
4193
+ _ts_param17(1, (0, import_common20.Param)("id")),
4141
4194
  _ts_metadata18("design:type", Function),
4142
4195
  _ts_metadata18("design:paramtypes", [
4143
4196
  typeof Request === "undefined" ? Object : Request,
@@ -4146,10 +4199,10 @@ _ts_decorate19([
4146
4199
  _ts_metadata18("design:returntype", Promise)
4147
4200
  ], ThreadsController.prototype, "promote", null);
4148
4201
  _ts_decorate19([
4149
- (0, import_common19.Delete)(":id/from/:messageId"),
4150
- _ts_param17(0, (0, import_common19.Req)()),
4151
- _ts_param17(1, (0, import_common19.Param)("id")),
4152
- _ts_param17(2, (0, import_common19.Param)("messageId")),
4202
+ (0, import_common20.Delete)(":id/from/:messageId"),
4203
+ _ts_param17(0, (0, import_common20.Req)()),
4204
+ _ts_param17(1, (0, import_common20.Param)("id")),
4205
+ _ts_param17(2, (0, import_common20.Param)("messageId")),
4153
4206
  _ts_metadata18("design:type", Function),
4154
4207
  _ts_metadata18("design:paramtypes", [
4155
4208
  typeof Request === "undefined" ? Object : Request,
@@ -4159,8 +4212,8 @@ _ts_decorate19([
4159
4212
  _ts_metadata18("design:returntype", Promise)
4160
4213
  ], ThreadsController.prototype, "truncateFrom", null);
4161
4214
  ThreadsController = _ts_decorate19([
4162
- (0, import_common19.Controller)("threads"),
4163
- _ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
4215
+ (0, import_common20.Controller)("threads"),
4216
+ _ts_param17(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
4164
4217
  _ts_metadata18("design:type", Function),
4165
4218
  _ts_metadata18("design:paramtypes", [
4166
4219
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -4169,8 +4222,8 @@ ThreadsController = _ts_decorate19([
4169
4222
  ], ThreadsController);
4170
4223
 
4171
4224
  // src/controller/tool-call.controller.ts
4172
- var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
4173
- var import_common20 = require("@nestjs/common");
4225
+ var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
4226
+ var import_common21 = require("@nestjs/common");
4174
4227
  function _ts_decorate20(decorators, target, key, desc) {
4175
4228
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4176
4229
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -4205,7 +4258,7 @@ var MAX_VIA_LENGTH = 64;
4205
4258
  var DEFAULT_VIA = "web";
4206
4259
  function toolCallId(claimed) {
4207
4260
  if (typeof claimed !== "string" || claimed.length === 0) {
4208
- throw new import_common20.BadRequestException("toolCallId must be a non-empty string");
4261
+ throw new import_common21.BadRequestException("toolCallId must be a non-empty string");
4209
4262
  }
4210
4263
  return claimed;
4211
4264
  }
@@ -4215,10 +4268,10 @@ function rejectReason(claimed) {
4215
4268
  return void 0;
4216
4269
  }
4217
4270
  if (typeof claimed !== "string") {
4218
- throw new import_common20.BadRequestException("reason must be a string");
4271
+ throw new import_common21.BadRequestException("reason must be a string");
4219
4272
  }
4220
4273
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
4221
- throw new import_common20.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
4274
+ throw new import_common21.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
4222
4275
  }
4223
4276
  return claimed;
4224
4277
  }
@@ -4228,7 +4281,7 @@ function remember(claimed) {
4228
4281
  return false;
4229
4282
  }
4230
4283
  if (typeof claimed !== "boolean") {
4231
- throw new import_common20.BadRequestException("remember must be a boolean");
4284
+ throw new import_common21.BadRequestException("remember must be a boolean");
4232
4285
  }
4233
4286
  return claimed;
4234
4287
  }
@@ -4238,7 +4291,7 @@ function via(claimed) {
4238
4291
  return DEFAULT_VIA;
4239
4292
  }
4240
4293
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
4241
- throw new import_common20.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
4294
+ throw new import_common21.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
4242
4295
  }
4243
4296
  return claimed;
4244
4297
  }
@@ -4248,26 +4301,26 @@ function answers(claimed) {
4248
4301
  return void 0;
4249
4302
  }
4250
4303
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
4251
- throw new import_common20.BadRequestException("answers must be an object of questionId \u2192 chosen values");
4304
+ throw new import_common21.BadRequestException("answers must be an object of questionId \u2192 chosen values");
4252
4305
  }
4253
4306
  const entries = Object.entries(claimed);
4254
4307
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
4255
- throw new import_common20.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
4308
+ throw new import_common21.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
4256
4309
  }
4257
4310
  const validated = /* @__PURE__ */ Object.create(null);
4258
4311
  for (const [questionId, values] of entries) {
4259
4312
  if (!Array.isArray(values)) {
4260
- throw new import_common20.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
4313
+ throw new import_common21.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
4261
4314
  }
4262
4315
  if (values.length > MAX_VALUES_PER_QUESTION) {
4263
- throw new import_common20.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
4316
+ throw new import_common21.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
4264
4317
  }
4265
4318
  for (const value of values) {
4266
4319
  if (typeof value !== "string") {
4267
- throw new import_common20.BadRequestException(`answers["${questionId}"] must contain only strings`);
4320
+ throw new import_common21.BadRequestException(`answers["${questionId}"] must contain only strings`);
4268
4321
  }
4269
4322
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
4270
- throw new import_common20.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
4323
+ throw new import_common21.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
4271
4324
  }
4272
4325
  }
4273
4326
  validated[questionId] = values;
@@ -4330,9 +4383,9 @@ var ToolCallController = class {
4330
4383
  }
4331
4384
  };
4332
4385
  _ts_decorate20([
4333
- (0, import_common20.Post)("approve"),
4334
- _ts_param18(0, (0, import_common20.Req)()),
4335
- _ts_param18(1, (0, import_common20.Body)()),
4386
+ (0, import_common21.Post)("approve"),
4387
+ _ts_param18(0, (0, import_common21.Req)()),
4388
+ _ts_param18(1, (0, import_common21.Body)()),
4336
4389
  _ts_metadata19("design:type", Function),
4337
4390
  _ts_metadata19("design:paramtypes", [
4338
4391
  typeof Request === "undefined" ? Object : Request,
@@ -4341,9 +4394,9 @@ _ts_decorate20([
4341
4394
  _ts_metadata19("design:returntype", Promise)
4342
4395
  ], ToolCallController.prototype, "approve", null);
4343
4396
  _ts_decorate20([
4344
- (0, import_common20.Post)("reject"),
4345
- _ts_param18(0, (0, import_common20.Req)()),
4346
- _ts_param18(1, (0, import_common20.Body)()),
4397
+ (0, import_common21.Post)("reject"),
4398
+ _ts_param18(0, (0, import_common21.Req)()),
4399
+ _ts_param18(1, (0, import_common21.Body)()),
4347
4400
  _ts_metadata19("design:type", Function),
4348
4401
  _ts_metadata19("design:paramtypes", [
4349
4402
  typeof Request === "undefined" ? Object : Request,
@@ -4352,9 +4405,9 @@ _ts_decorate20([
4352
4405
  _ts_metadata19("design:returntype", Promise)
4353
4406
  ], ToolCallController.prototype, "reject", null);
4354
4407
  _ts_decorate20([
4355
- (0, import_common20.Post)("answer"),
4356
- _ts_param18(0, (0, import_common20.Req)()),
4357
- _ts_param18(1, (0, import_common20.Body)()),
4408
+ (0, import_common21.Post)("answer"),
4409
+ _ts_param18(0, (0, import_common21.Req)()),
4410
+ _ts_param18(1, (0, import_common21.Body)()),
4358
4411
  _ts_metadata19("design:type", Function),
4359
4412
  _ts_metadata19("design:paramtypes", [
4360
4413
  typeof Request === "undefined" ? Object : Request,
@@ -4363,9 +4416,9 @@ _ts_decorate20([
4363
4416
  _ts_metadata19("design:returntype", Promise)
4364
4417
  ], ToolCallController.prototype, "answer", null);
4365
4418
  _ts_decorate20([
4366
- (0, import_common20.Post)("skip"),
4367
- _ts_param18(0, (0, import_common20.Req)()),
4368
- _ts_param18(1, (0, import_common20.Body)()),
4419
+ (0, import_common21.Post)("skip"),
4420
+ _ts_param18(0, (0, import_common21.Req)()),
4421
+ _ts_param18(1, (0, import_common21.Body)()),
4369
4422
  _ts_metadata19("design:type", Function),
4370
4423
  _ts_metadata19("design:paramtypes", [
4371
4424
  typeof Request === "undefined" ? Object : Request,
@@ -4374,8 +4427,8 @@ _ts_decorate20([
4374
4427
  _ts_metadata19("design:returntype", Promise)
4375
4428
  ], ToolCallController.prototype, "skip", null);
4376
4429
  ToolCallController = _ts_decorate20([
4377
- (0, import_common20.Controller)("tool-call"),
4378
- _ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
4430
+ (0, import_common21.Controller)("tool-call"),
4431
+ _ts_param18(1, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
4379
4432
  _ts_metadata19("design:type", Function),
4380
4433
  _ts_metadata19("design:paramtypes", [
4381
4434
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -4384,8 +4437,8 @@ ToolCallController = _ts_decorate20([
4384
4437
  ], ToolCallController);
4385
4438
 
4386
4439
  // src/controller/tools.controller.ts
4387
- var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
4388
- var import_common21 = require("@nestjs/common");
4440
+ var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
4441
+ var import_common22 = require("@nestjs/common");
4389
4442
  function _ts_decorate21(decorators, target, key, desc) {
4390
4443
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4391
4444
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -4425,11 +4478,11 @@ var ToolsController = class {
4425
4478
  this.agents = agents;
4426
4479
  }
4427
4480
  async list(req, agent) {
4428
- if (agent !== void 0 && agent !== import_nestjs_agent_core22.ALL_AGENTS && this.agents.get(agent) === void 0) {
4429
- throw new import_common21.NotFoundException(`No agent named "${agent}"`);
4481
+ if (agent !== void 0 && agent !== import_nestjs_agent_core23.ALL_AGENTS && this.agents.get(agent) === void 0) {
4482
+ throw new import_common22.NotFoundException(`No agent named "${agent}"`);
4430
4483
  }
4431
4484
  const actor = await this.actorResolver.resolve(req);
4432
- const names = agent === import_nestjs_agent_core22.ALL_AGENTS ? [
4485
+ const names = agent === import_nestjs_agent_core23.ALL_AGENTS ? [
4433
4486
  void 0,
4434
4487
  ...this.agents.list().map((definition) => definition.name)
4435
4488
  ] : [
@@ -4456,9 +4509,9 @@ var ToolsController = class {
4456
4509
  }
4457
4510
  };
4458
4511
  _ts_decorate21([
4459
- (0, import_common21.Get)(),
4460
- _ts_param19(0, (0, import_common21.Req)()),
4461
- _ts_param19(1, (0, import_common21.Query)("agent")),
4512
+ (0, import_common22.Get)(),
4513
+ _ts_param19(0, (0, import_common22.Req)()),
4514
+ _ts_param19(1, (0, import_common22.Query)("agent")),
4462
4515
  _ts_metadata20("design:type", Function),
4463
4516
  _ts_metadata20("design:paramtypes", [
4464
4517
  typeof Request === "undefined" ? Object : Request,
@@ -4467,21 +4520,21 @@ _ts_decorate21([
4467
4520
  _ts_metadata20("design:returntype", Promise)
4468
4521
  ], ToolsController.prototype, "list", null);
4469
4522
  ToolsController = _ts_decorate21([
4470
- (0, import_common21.Controller)("tools"),
4471
- _ts_param19(0, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
4472
- _ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_DEPS_FACTORY)),
4473
- _ts_param19(2, (0, import_common21.Inject)(import_nestjs_agent_core22.AGENT_REGISTRY)),
4523
+ (0, import_common22.Controller)("tools"),
4524
+ _ts_param19(0, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_ACTOR_RESOLVER)),
4525
+ _ts_param19(1, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_DEPS_FACTORY)),
4526
+ _ts_param19(2, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_REGISTRY)),
4474
4527
  _ts_metadata20("design:type", Function),
4475
4528
  _ts_metadata20("design:paramtypes", [
4476
4529
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4477
4530
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
4478
- typeof import_nestjs_agent_core22.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core22.AgentRegistry
4531
+ typeof import_nestjs_agent_core23.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core23.AgentRegistry
4479
4532
  ])
4480
4533
  ], ToolsController);
4481
4534
 
4482
4535
  // src/discovery/agent-discovery.service.ts
4483
- var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
4484
- var import_common22 = require("@nestjs/common");
4536
+ var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
4537
+ var import_common23 = require("@nestjs/common");
4485
4538
  var import_core = require("@nestjs/core");
4486
4539
 
4487
4540
  // src/decorator/agent.decorator.ts
@@ -4532,7 +4585,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
4532
4585
  scanner;
4533
4586
  registry;
4534
4587
  contributors;
4535
- logger = new import_common22.Logger(_AgentDiscoveryService.name);
4588
+ logger = new import_common23.Logger(_AgentDiscoveryService.name);
4536
4589
  constructor(discovery, scanner, registry, contributors) {
4537
4590
  this.discovery = discovery;
4538
4591
  this.scanner = scanner;
@@ -4651,21 +4704,21 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
4651
4704
  }
4652
4705
  };
4653
4706
  AgentDiscoveryService = _ts_decorate22([
4654
- (0, import_common22.Injectable)(),
4655
- _ts_param20(2, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_REGISTRY)),
4656
- _ts_param20(3, (0, import_common22.Inject)(import_nestjs_agent_core23.AGENT_PROMPT_CONTRIBUTORS)),
4707
+ (0, import_common23.Injectable)(),
4708
+ _ts_param20(2, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_REGISTRY)),
4709
+ _ts_param20(3, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_PROMPT_CONTRIBUTORS)),
4657
4710
  _ts_metadata21("design:type", Function),
4658
4711
  _ts_metadata21("design:paramtypes", [
4659
4712
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
4660
4713
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
4661
- typeof import_nestjs_agent_core23.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core23.AgentRegistry,
4714
+ typeof import_nestjs_agent_core24.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core24.AgentRegistry,
4662
4715
  Array
4663
4716
  ])
4664
4717
  ], AgentDiscoveryService);
4665
4718
 
4666
4719
  // src/discovery/ai-tool-discovery.service.ts
4667
- var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
4668
- var import_common23 = require("@nestjs/common");
4720
+ var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
4721
+ var import_common24 = require("@nestjs/common");
4669
4722
  var import_core2 = require("@nestjs/core");
4670
4723
  var import_zod = require("zod");
4671
4724
 
@@ -4719,7 +4772,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4719
4772
  registry;
4720
4773
  agents;
4721
4774
  options;
4722
- logger = new import_common23.Logger(_AiToolDiscoveryService.name);
4775
+ logger = new import_common24.Logger(_AiToolDiscoveryService.name);
4723
4776
  constructor(discovery, registry, agents, options) {
4724
4777
  this.discovery = discovery;
4725
4778
  this.registry = registry;
@@ -4804,7 +4857,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4804
4857
  let delegates = 0;
4805
4858
  for (const definition of this.agents.list()) {
4806
4859
  for (const edge of definition.delegatesTo ?? []) {
4807
- const { agent: target, detached } = (0, import_nestjs_agent_core24.normalizeDelegation)(edge);
4860
+ const { agent: target, detached } = (0, import_nestjs_agent_core25.normalizeDelegation)(edge);
4808
4861
  const targetDefinition = this.agents.get(target);
4809
4862
  if (targetDefinition === void 0) {
4810
4863
  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.`);
@@ -4855,10 +4908,10 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4855
4908
  }
4856
4909
  };
4857
4910
  AiToolDiscoveryService = _ts_decorate23([
4858
- (0, import_common23.Injectable)(),
4859
- _ts_param21(1, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_TOOL_REGISTRY)),
4860
- _ts_param21(2, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_REGISTRY)),
4861
- _ts_param21(3, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_OPTIONS)),
4911
+ (0, import_common24.Injectable)(),
4912
+ _ts_param21(1, (0, import_common24.Inject)(import_nestjs_agent_core25.AGENT_TOOL_REGISTRY)),
4913
+ _ts_param21(2, (0, import_common24.Inject)(import_nestjs_agent_core25.AGENT_REGISTRY)),
4914
+ _ts_param21(3, (0, import_common24.Inject)(import_nestjs_agent_core25.AGENT_OPTIONS)),
4862
4915
  _ts_metadata22("design:type", Function),
4863
4916
  _ts_metadata22("design:paramtypes", [
4864
4917
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
@@ -4869,20 +4922,20 @@ AiToolDiscoveryService = _ts_decorate23([
4869
4922
  ], AiToolDiscoveryService);
4870
4923
 
4871
4924
  // src/discovery/skill-discovery.service.ts
4872
- var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
4873
- var import_common24 = require("@nestjs/common");
4925
+ var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
4926
+ var import_common25 = require("@nestjs/common");
4874
4927
  var import_core3 = require("@nestjs/core");
4875
4928
 
4876
4929
  // src/decorator/skill.decorator.ts
4877
4930
  var import_reflect_metadata4 = require("reflect-metadata");
4878
- var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
4931
+ var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
4879
4932
  var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
4880
4933
  function readSkillMetadata(target) {
4881
4934
  return Reflect.getMetadata(SKILL_METADATA, target);
4882
4935
  }
4883
4936
  __name(readSkillMetadata, "readSkillMetadata");
4884
4937
  function skillScope(options) {
4885
- return options.scope ?? import_nestjs_agent_core25.GLOBAL_SCOPE;
4938
+ return options.scope ?? import_nestjs_agent_core26.GLOBAL_SCOPE;
4886
4939
  }
4887
4940
  __name(skillScope, "skillScope");
4888
4941
 
@@ -4919,7 +4972,7 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
4919
4972
  }
4920
4973
  discovery;
4921
4974
  declared;
4922
- logger = new import_common24.Logger(_SkillDiscoveryService.name);
4975
+ logger = new import_common25.Logger(_SkillDiscoveryService.name);
4923
4976
  constructor(discovery, declared) {
4924
4977
  this.discovery = discovery;
4925
4978
  this.declared = declared;
@@ -4957,8 +5010,8 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
4957
5010
  }
4958
5011
  };
4959
5012
  SkillDiscoveryService = _ts_decorate24([
4960
- (0, import_common24.Injectable)(),
4961
- _ts_param22(1, (0, import_common24.Inject)(import_nestjs_agent_core26.AGENT_SKILL_SOURCES)),
5013
+ (0, import_common25.Injectable)(),
5014
+ _ts_param22(1, (0, import_common25.Inject)(import_nestjs_agent_core27.AGENT_SKILL_SOURCES)),
4962
5015
  _ts_metadata23("design:type", Function),
4963
5016
  _ts_metadata23("design:paramtypes", [
4964
5017
  typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
@@ -4967,7 +5020,7 @@ SkillDiscoveryService = _ts_decorate24([
4967
5020
  ], SkillDiscoveryService);
4968
5021
 
4969
5022
  // src/ledger-quota-provider.ts
4970
- var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
5023
+ var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
4971
5024
  var LedgerQuotaProvider = class {
4972
5025
  static {
4973
5026
  __name(this, "LedgerQuotaProvider");
@@ -4987,12 +5040,12 @@ var LedgerQuotaProvider = class {
4987
5040
  await this.dayWindow(actorRef, now)
4988
5041
  ];
4989
5042
  if (this.store.usageBetween !== void 0) {
4990
- const range = (0, import_nestjs_agent_core27.quotaPeriodRange)("month", now);
5043
+ const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("month", now);
4991
5044
  const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
4992
5045
  windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
4993
5046
  }
4994
- const blocked = (0, import_nestjs_agent_core27.exhaustedWindow)(windows);
4995
- const warning = (0, import_nestjs_agent_core27.quotaWarning)(windows);
5047
+ const blocked = (0, import_nestjs_agent_core28.exhaustedWindow)(windows);
5048
+ const warning = (0, import_nestjs_agent_core28.quotaWarning)(windows);
4996
5049
  return {
4997
5050
  windows,
4998
5051
  ...blocked !== void 0 ? {
@@ -5004,7 +5057,7 @@ var LedgerQuotaProvider = class {
5004
5057
  };
5005
5058
  }
5006
5059
  async dayWindow(actorRef, now) {
5007
- const range = (0, import_nestjs_agent_core27.quotaPeriodRange)("day", now);
5060
+ const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("day", now);
5008
5061
  const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
5009
5062
  return this.window("day", usedTokens, costUsd, range.resetsAt);
5010
5063
  }
@@ -5029,8 +5082,8 @@ var LedgerQuotaProvider = class {
5029
5082
  };
5030
5083
 
5031
5084
  // src/runner/inline-agent-runner.ts
5032
- var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
5033
- var import_common25 = require("@nestjs/common");
5085
+ var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
5086
+ var import_common26 = require("@nestjs/common");
5034
5087
  function _ts_decorate25(decorators, target, key, desc) {
5035
5088
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5036
5089
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -5064,7 +5117,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5064
5117
  factory;
5065
5118
  store;
5066
5119
  queue;
5067
- logger = new import_common25.Logger(_InlineAgentRunner.name);
5120
+ logger = new import_common26.Logger(_InlineAgentRunner.name);
5068
5121
  pending = /* @__PURE__ */ new Map();
5069
5122
  /**
5070
5123
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -5084,7 +5137,15 @@ var InlineAgentRunner = class _InlineAgentRunner {
5084
5137
  * that was running it is gone (a restart), and a thread it still holds is a stale claim.
5085
5138
  */
5086
5139
  async isRunActive(runId) {
5087
- return this.live.has(runId);
5140
+ if (this.live.has(runId)) {
5141
+ return true;
5142
+ }
5143
+ for (const key of this.pending.keys()) {
5144
+ if (key.startsWith(`${runId}:`)) {
5145
+ return true;
5146
+ }
5147
+ }
5148
+ return false;
5088
5149
  }
5089
5150
  async start(input, options = {}) {
5090
5151
  const runId = options.runId ?? crypto.randomUUID();
@@ -5105,18 +5166,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
5105
5166
  ],
5106
5167
  input
5107
5168
  });
5108
- void (0, import_nestjs_agent_core28.runAgentLoop)({
5169
+ void (0, import_nestjs_agent_core29.runAgentLoop)({
5109
5170
  ...deps,
5110
5171
  day
5111
- }, input, hooks).then(() => (0, import_nestjs_agent_core28.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
5112
- if (error instanceof import_nestjs_agent_core28.RunCancelledError) {
5172
+ }, input, hooks).then(() => (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
5173
+ if (error instanceof import_nestjs_agent_core29.RunCancelledError) {
5113
5174
  await this.settleCancelled(runId, input, deps);
5114
5175
  return;
5115
5176
  }
5116
5177
  const message = error instanceof Error ? error.message : String(error);
5117
- const code = (0, import_nestjs_agent_core28.agentFailureCode)(error);
5178
+ const code = (0, import_nestjs_agent_core29.agentFailureCode)(error);
5118
5179
  this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
5119
- (0, import_nestjs_agent_core28.publishAgentRunFailed)({
5180
+ (0, import_nestjs_agent_core29.publishAgentRunFailed)({
5120
5181
  runId,
5121
5182
  code,
5122
5183
  message
@@ -5127,13 +5188,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
5127
5188
  errorCode: code,
5128
5189
  errorMessage: message
5129
5190
  });
5191
+ await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core29.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
5130
5192
  const writer = await deps.sink.open(runId);
5131
5193
  await this.settleQueue(writer, input, runId, "failed", message);
5132
- await (0, import_nestjs_agent_core28.releaseThreadRun)(this.store, input.threadId, runId);
5133
- await writer.fail({
5134
- code,
5135
- message
5136
- });
5194
+ await (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId);
5195
+ await writer.fail((0, import_nestjs_agent_core29.streamFailure)(error));
5137
5196
  }).finally(() => {
5138
5197
  this.cancelled.delete(runId);
5139
5198
  this.live.delete(runId);
@@ -5169,7 +5228,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5169
5228
  for (const [key, waiter] of this.pending) {
5170
5229
  if (key.startsWith(`${runId}:`)) {
5171
5230
  this.pending.delete(key);
5172
- waiter.reject(new import_nestjs_agent_core28.RunCancelledError());
5231
+ waiter.reject(new import_nestjs_agent_core29.RunCancelledError());
5173
5232
  }
5174
5233
  }
5175
5234
  await Promise.resolve();
@@ -5184,8 +5243,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
5184
5243
  this.logger.log(`agent run ${runId} cancelled`);
5185
5244
  const writer = await deps.sink.open(runId);
5186
5245
  await this.settleQueue(writer, input, runId, "cancelled");
5187
- await (0, import_nestjs_agent_core28.releaseThreadRun)(this.store, input.threadId, runId);
5188
- await writer.write((0, import_nestjs_agent_core28.encodeStreamEvent)({
5246
+ await (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId);
5247
+ await writer.write((0, import_nestjs_agent_core29.encodeStreamEvent)({
5189
5248
  kind: "cancelled"
5190
5249
  }));
5191
5250
  await writer.end();
@@ -5220,7 +5279,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5220
5279
  runId: nextRunId
5221
5280
  }));
5222
5281
  if (frame !== void 0) {
5223
- await writer.write((0, import_nestjs_agent_core28.encodeStreamEvent)(frame));
5282
+ await writer.write((0, import_nestjs_agent_core29.encodeStreamEvent)(frame));
5224
5283
  }
5225
5284
  } catch (failure) {
5226
5285
  this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
@@ -5291,7 +5350,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5291
5350
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
5292
5351
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
5293
5352
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
5294
- parallel: import_nestjs_agent_core28.settleAll,
5353
+ parallel: import_nestjs_agent_core29.settleAll,
5295
5354
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
5296
5355
  runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
5297
5356
  agentName,
@@ -5342,7 +5401,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5342
5401
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
5343
5402
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
5344
5403
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
5345
- parallel: import_nestjs_agent_core28.settleAll,
5404
+ parallel: import_nestjs_agent_core29.settleAll,
5346
5405
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
5347
5406
  runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
5348
5407
  agentName: childName,
@@ -5375,7 +5434,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5375
5434
  }
5376
5435
  }), "startAgent")
5377
5436
  };
5378
- void (0, import_nestjs_agent_core28.runAgentLoop)({
5437
+ void (0, import_nestjs_agent_core29.runAgentLoop)({
5379
5438
  ...deps,
5380
5439
  day
5381
5440
  }, {
@@ -5389,13 +5448,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
5389
5448
  parentRunId,
5390
5449
  deliverTo
5391
5450
  }, hooks).catch(async (error) => {
5392
- const cancelled = error instanceof import_nestjs_agent_core28.RunCancelledError;
5451
+ const cancelled = error instanceof import_nestjs_agent_core29.RunCancelledError;
5393
5452
  const message = error instanceof Error ? error.message : String(error);
5394
5453
  if (!cancelled) {
5395
5454
  this.logger.error(`detached agent run ${runId} failed: ${message}`);
5396
- (0, import_nestjs_agent_core28.publishAgentRunFailed)({
5455
+ (0, import_nestjs_agent_core29.publishAgentRunFailed)({
5397
5456
  runId,
5398
- code: (0, import_nestjs_agent_core28.agentFailureCode)(error),
5457
+ code: (0, import_nestjs_agent_core29.agentFailureCode)(error),
5399
5458
  message
5400
5459
  });
5401
5460
  }
@@ -5403,11 +5462,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
5403
5462
  runId,
5404
5463
  status: cancelled ? "cancelled" : "failed",
5405
5464
  ...cancelled ? {} : {
5406
- errorCode: (0, import_nestjs_agent_core28.agentFailureCode)(error),
5465
+ errorCode: (0, import_nestjs_agent_core29.agentFailureCode)(error),
5407
5466
  errorMessage: message
5408
5467
  }
5409
5468
  });
5410
- await (0, import_nestjs_agent_core28.settleUnsettledDelegation)({
5469
+ await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core29.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
5470
+ await (0, import_nestjs_agent_core29.settleUnsettledDelegation)({
5411
5471
  store: this.store,
5412
5472
  delivery: deliverTo,
5413
5473
  agent: agentName,
@@ -5446,7 +5506,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5446
5506
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
5447
5507
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
5448
5508
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
5449
- parallel: import_nestjs_agent_core28.settleAll,
5509
+ parallel: import_nestjs_agent_core29.settleAll,
5450
5510
  // A child stops when it is cancelled OR when the run a human is actually watching is: the
5451
5511
  // canceller names the top-level run, which is the only id that ever left the server.
5452
5512
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
@@ -5481,7 +5541,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5481
5541
  }), "startAgent")
5482
5542
  };
5483
5543
  try {
5484
- return await (0, import_nestjs_agent_core28.runAgentLoop)({
5544
+ return await (0, import_nestjs_agent_core29.runAgentLoop)({
5485
5545
  ...deps,
5486
5546
  day
5487
5547
  }, {
@@ -5501,10 +5561,10 @@ var InlineAgentRunner = class _InlineAgentRunner {
5501
5561
  }
5502
5562
  };
5503
5563
  InlineAgentRunner = _ts_decorate25([
5504
- (0, import_common25.Injectable)(),
5505
- _ts_param23(0, (0, import_common25.Inject)(import_nestjs_agent_core28.AGENT_DEPS_FACTORY)),
5506
- _ts_param23(1, (0, import_common25.Inject)(import_nestjs_agent_core28.AGENT_STORE)),
5507
- _ts_param23(2, (0, import_common25.Optional)()),
5564
+ (0, import_common26.Injectable)(),
5565
+ _ts_param23(0, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
5566
+ _ts_param23(1, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_STORE)),
5567
+ _ts_param23(2, (0, import_common26.Optional)()),
5508
5568
  _ts_metadata24("design:type", Function),
5509
5569
  _ts_metadata24("design:paramtypes", [
5510
5570
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
@@ -5518,7 +5578,7 @@ function isThreadTurn2(input) {
5518
5578
  __name(isThreadTurn2, "isThreadTurn");
5519
5579
 
5520
5580
  // src/skills-config.ts
5521
- var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
5581
+ var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
5522
5582
  function declaredSkillProvider(declared) {
5523
5583
  return {
5524
5584
  list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
@@ -5544,7 +5604,7 @@ function resolveSkillsConfig(options, declared) {
5544
5604
  declaredSkillProvider(declared)
5545
5605
  ];
5546
5606
  return {
5547
- provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core29.compositeSkillProvider)(providers),
5607
+ provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core30.compositeSkillProvider)(providers),
5548
5608
  ...options.scopes !== void 0 ? {
5549
5609
  scopes: options.scopes
5550
5610
  } : {},
@@ -5571,11 +5631,11 @@ function _ts_decorate26(decorators, target, key, desc) {
5571
5631
  }
5572
5632
  __name(_ts_decorate26, "_ts_decorate");
5573
5633
  var DEFAULT_PATH = "agent";
5574
- var logger = new import_common26.Logger("AgentModule");
5634
+ var logger = new import_common27.Logger("AgentModule");
5575
5635
  function externalStoreWrapper(modules) {
5576
5636
  for (const module2 of modules.values()) {
5577
5637
  if (module2.metatype === AgentModule) continue;
5578
- const wrapper = module2.providers.get(import_nestjs_agent_core30.AGENT_STORE);
5638
+ const wrapper = module2.providers.get(import_nestjs_agent_core31.AGENT_STORE);
5579
5639
  if (wrapper !== void 0) return wrapper;
5580
5640
  }
5581
5641
  return void 0;
@@ -5606,7 +5666,7 @@ function resolveStore(options, modules) {
5606
5666
  const external = externalStoreWrapper(modules);
5607
5667
  if (external !== void 0) return forwardingStore(external);
5608
5668
  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()).");
5609
- return new import_nestjs_agent_core30.InMemoryAgentStore();
5669
+ return new import_nestjs_agent_core31.InMemoryAgentStore();
5610
5670
  }
5611
5671
  __name(resolveStore, "resolveStore");
5612
5672
  function isQuotaProvider(quota) {
@@ -5622,99 +5682,99 @@ __name(resolveCatalog, "resolveCatalog");
5622
5682
  function sharedProviders(durable) {
5623
5683
  const providers = [
5624
5684
  {
5625
- provide: import_nestjs_agent_core30.AGENT_TOOL_REGISTRY,
5626
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core30.ToolRegistry(), "useFactory")
5685
+ provide: import_nestjs_agent_core31.AGENT_TOOL_REGISTRY,
5686
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core31.ToolRegistry(), "useFactory")
5627
5687
  },
5628
5688
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
5629
5689
  {
5630
- provide: import_nestjs_agent_core30.AGENT_REGISTRY,
5631
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core30.AgentRegistry(), "useFactory")
5690
+ provide: import_nestjs_agent_core31.AGENT_REGISTRY,
5691
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core31.AgentRegistry(), "useFactory")
5632
5692
  },
5633
5693
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
5634
5694
  {
5635
- provide: import_nestjs_agent_core30.AGENT_PROMPT_CONTRIBUTORS,
5695
+ provide: import_nestjs_agent_core31.AGENT_PROMPT_CONTRIBUTORS,
5636
5696
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
5637
5697
  },
5638
5698
  // Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
5639
5699
  // read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
5640
5700
  {
5641
- provide: import_nestjs_agent_core30.AGENT_SKILL_SOURCES,
5701
+ provide: import_nestjs_agent_core31.AGENT_SKILL_SOURCES,
5642
5702
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
5643
5703
  },
5644
5704
  {
5645
5705
  // One resolution, shared by the loop's deps and the listing endpoint: a second one would
5646
5706
  // drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
5647
5707
  // host configured none — which is what keeps the turn's checkpoint sequence unchanged.
5648
- provide: import_nestjs_agent_core30.AGENT_SKILLS,
5708
+ provide: import_nestjs_agent_core31.AGENT_SKILLS,
5649
5709
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
5650
5710
  inject: [
5651
- import_nestjs_agent_core30.AGENT_OPTIONS,
5652
- import_nestjs_agent_core30.AGENT_SKILL_SOURCES
5711
+ import_nestjs_agent_core31.AGENT_OPTIONS,
5712
+ import_nestjs_agent_core31.AGENT_SKILL_SOURCES
5653
5713
  ]
5654
5714
  },
5655
5715
  {
5656
5716
  // One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
5657
5717
  // shown what the model was shown, and two resolutions would eventually disagree about that.
5658
- provide: import_nestjs_agent_core30.AGENT_MEMORY,
5718
+ provide: import_nestjs_agent_core31.AGENT_MEMORY,
5659
5719
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
5660
5720
  inject: [
5661
- import_nestjs_agent_core30.AGENT_OPTIONS
5721
+ import_nestjs_agent_core31.AGENT_OPTIONS
5662
5722
  ]
5663
5723
  },
5664
5724
  {
5665
- provide: import_nestjs_agent_core30.AGENT_SINK,
5725
+ provide: import_nestjs_agent_core31.AGENT_SINK,
5666
5726
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
5667
5727
  inject: [
5668
- import_nestjs_agent_core30.AGENT_OPTIONS
5728
+ import_nestjs_agent_core31.AGENT_OPTIONS
5669
5729
  ]
5670
5730
  },
5671
5731
  {
5672
- provide: import_nestjs_agent_core30.AGENT_ROLES_POLICY,
5673
- useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core30.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
5732
+ provide: import_nestjs_agent_core31.AGENT_ROLES_POLICY,
5733
+ useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core31.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
5674
5734
  inject: [
5675
- import_nestjs_agent_core30.AGENT_OPTIONS
5735
+ import_nestjs_agent_core31.AGENT_OPTIONS
5676
5736
  ]
5677
5737
  },
5678
5738
  {
5679
- provide: import_nestjs_agent_core30.AGENT_ACTOR_RESOLVER,
5739
+ provide: import_nestjs_agent_core31.AGENT_ACTOR_RESOLVER,
5680
5740
  useFactory: /* @__PURE__ */ __name((options) => {
5681
5741
  if (options.actorResolver !== void 0) return options.actorResolver;
5682
5742
  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.");
5683
5743
  return new AnonymousActorResolver();
5684
5744
  }, "useFactory"),
5685
5745
  inject: [
5686
- import_nestjs_agent_core30.AGENT_OPTIONS
5746
+ import_nestjs_agent_core31.AGENT_OPTIONS
5687
5747
  ]
5688
5748
  },
5689
5749
  {
5690
- provide: import_nestjs_agent_core30.AGENT_MODEL,
5750
+ provide: import_nestjs_agent_core31.AGENT_MODEL,
5691
5751
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
5692
5752
  inject: [
5693
- import_nestjs_agent_core30.AGENT_OPTIONS
5753
+ import_nestjs_agent_core31.AGENT_OPTIONS
5694
5754
  ]
5695
5755
  },
5696
5756
  {
5697
5757
  // `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
5698
5758
  // omitted, the ledger provider still reports usage, with no ceiling to block on.
5699
- provide: import_nestjs_agent_core30.AGENT_QUOTA_PROVIDER,
5759
+ provide: import_nestjs_agent_core31.AGENT_QUOTA_PROVIDER,
5700
5760
  useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
5701
5761
  warnAt: o.quota.warnAt
5702
5762
  } : {}), "useFactory"),
5703
5763
  inject: [
5704
- import_nestjs_agent_core30.AGENT_OPTIONS,
5705
- import_nestjs_agent_core30.AGENT_STORE
5764
+ import_nestjs_agent_core31.AGENT_OPTIONS,
5765
+ import_nestjs_agent_core31.AGENT_STORE
5706
5766
  ]
5707
5767
  },
5708
5768
  {
5709
- provide: import_nestjs_agent_core30.AGENT_MODEL_CATALOG,
5769
+ provide: import_nestjs_agent_core31.AGENT_MODEL_CATALOG,
5710
5770
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
5711
5771
  inject: [
5712
- import_nestjs_agent_core30.AGENT_OPTIONS
5772
+ import_nestjs_agent_core31.AGENT_OPTIONS
5713
5773
  ]
5714
5774
  },
5715
5775
  AgentDepsFactory2,
5716
5776
  {
5717
- provide: import_nestjs_agent_core30.AGENT_DEPS_FACTORY,
5777
+ provide: import_nestjs_agent_core31.AGENT_DEPS_FACTORY,
5718
5778
  useExisting: AgentDepsFactory2
5719
5779
  },
5720
5780
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -5731,21 +5791,21 @@ function sharedProviders(durable) {
5731
5791
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
5732
5792
  AgentApprovalPortAdapter,
5733
5793
  {
5734
- provide: import_nestjs_agent_core30.AGENT_APPROVAL_PORT,
5794
+ provide: import_nestjs_agent_core31.AGENT_APPROVAL_PORT,
5735
5795
  useExisting: AgentApprovalPortAdapter
5736
5796
  }
5737
5797
  ];
5738
5798
  providers.push({
5739
- provide: import_nestjs_agent_core30.AGENT_STORE,
5799
+ provide: import_nestjs_agent_core31.AGENT_STORE,
5740
5800
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
5741
5801
  inject: [
5742
- import_nestjs_agent_core30.AGENT_OPTIONS,
5802
+ import_nestjs_agent_core31.AGENT_OPTIONS,
5743
5803
  import_core4.ModulesContainer
5744
5804
  ]
5745
5805
  });
5746
5806
  if (durable) {
5747
5807
  providers.push({
5748
- provide: import_nestjs_agent_core30.AGENT_RUNNER,
5808
+ provide: import_nestjs_agent_core31.AGENT_RUNNER,
5749
5809
  useFactory: /* @__PURE__ */ __name((durableRunner) => {
5750
5810
  if (durableRunner === void 0) {
5751
5811
  throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
@@ -5754,14 +5814,14 @@ function sharedProviders(durable) {
5754
5814
  }, "useFactory"),
5755
5815
  inject: [
5756
5816
  {
5757
- token: import_nestjs_agent_core30.AGENT_DURABLE_RUNNER,
5817
+ token: import_nestjs_agent_core31.AGENT_DURABLE_RUNNER,
5758
5818
  optional: true
5759
5819
  }
5760
5820
  ]
5761
5821
  });
5762
5822
  } else {
5763
5823
  providers.push({
5764
- provide: import_nestjs_agent_core30.AGENT_RUNNER,
5824
+ provide: import_nestjs_agent_core31.AGENT_RUNNER,
5765
5825
  useExisting: InlineAgentRunner
5766
5826
  });
5767
5827
  }
@@ -5770,25 +5830,25 @@ function sharedProviders(durable) {
5770
5830
  __name(sharedProviders, "sharedProviders");
5771
5831
  function exportsFor() {
5772
5832
  return [
5773
- import_nestjs_agent_core30.AGENT_OPTIONS,
5774
- import_nestjs_agent_core30.AGENT_TOOL_REGISTRY,
5775
- import_nestjs_agent_core30.AGENT_REGISTRY,
5776
- import_nestjs_agent_core30.AGENT_SINK,
5777
- import_nestjs_agent_core30.AGENT_ROLES_POLICY,
5778
- import_nestjs_agent_core30.AGENT_ACTOR_RESOLVER,
5779
- import_nestjs_agent_core30.AGENT_MODEL,
5780
- import_nestjs_agent_core30.AGENT_STORE,
5781
- import_nestjs_agent_core30.AGENT_MODEL_CATALOG,
5782
- import_nestjs_agent_core30.AGENT_QUOTA_PROVIDER,
5783
- import_nestjs_agent_core30.AGENT_PROMPT_CONTRIBUTORS,
5784
- import_nestjs_agent_core30.AGENT_SKILLS,
5785
- import_nestjs_agent_core30.AGENT_MEMORY,
5786
- import_nestjs_agent_core30.AGENT_DEPS_FACTORY,
5833
+ import_nestjs_agent_core31.AGENT_OPTIONS,
5834
+ import_nestjs_agent_core31.AGENT_TOOL_REGISTRY,
5835
+ import_nestjs_agent_core31.AGENT_REGISTRY,
5836
+ import_nestjs_agent_core31.AGENT_SINK,
5837
+ import_nestjs_agent_core31.AGENT_ROLES_POLICY,
5838
+ import_nestjs_agent_core31.AGENT_ACTOR_RESOLVER,
5839
+ import_nestjs_agent_core31.AGENT_MODEL,
5840
+ import_nestjs_agent_core31.AGENT_STORE,
5841
+ import_nestjs_agent_core31.AGENT_MODEL_CATALOG,
5842
+ import_nestjs_agent_core31.AGENT_QUOTA_PROVIDER,
5843
+ import_nestjs_agent_core31.AGENT_PROMPT_CONTRIBUTORS,
5844
+ import_nestjs_agent_core31.AGENT_SKILLS,
5845
+ import_nestjs_agent_core31.AGENT_MEMORY,
5846
+ import_nestjs_agent_core31.AGENT_DEPS_FACTORY,
5787
5847
  AgentDepsFactory2,
5788
5848
  AgentService,
5789
5849
  ChatQueueService,
5790
5850
  InlineAgentRunner,
5791
- import_nestjs_agent_core30.AGENT_APPROVAL_PORT
5851
+ import_nestjs_agent_core31.AGENT_APPROVAL_PORT
5792
5852
  ];
5793
5853
  }
5794
5854
  __name(exportsFor, "exportsFor");
@@ -5852,7 +5912,7 @@ var AgentModule = class _AgentModule {
5852
5912
  controllers: controllersForSurface(options.surface),
5853
5913
  providers: [
5854
5914
  {
5855
- provide: import_nestjs_agent_core30.AGENT_OPTIONS,
5915
+ provide: import_nestjs_agent_core31.AGENT_OPTIONS,
5856
5916
  useValue: options
5857
5917
  },
5858
5918
  ...sharedProviders(options.durable ?? false),
@@ -5875,7 +5935,7 @@ var AgentModule = class _AgentModule {
5875
5935
  controllers: controllersForSurface(options.surface),
5876
5936
  providers: [
5877
5937
  {
5878
- provide: import_nestjs_agent_core30.AGENT_OPTIONS,
5938
+ provide: import_nestjs_agent_core31.AGENT_OPTIONS,
5879
5939
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
5880
5940
  // authoritative on the async config object (they decided the actual wiring above), and
5881
5941
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -5897,8 +5957,8 @@ var AgentModule = class _AgentModule {
5897
5957
  }
5898
5958
  };
5899
5959
  AgentModule = _ts_decorate26([
5900
- (0, import_common26.Global)(),
5901
- (0, import_common26.Module)({})
5960
+ (0, import_common27.Global)(),
5961
+ (0, import_common27.Module)({})
5902
5962
  ], AgentModule);
5903
5963
 
5904
5964
  // src/durable/agent-durable.ts