@dudousxd/nestjs-agent 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -143,8 +143,15 @@ var AgentRunSteps = class {
143
143
  if (deps.registry.spec(input.toolName)?.kind === "action" && input.toolType !== "action") {
144
144
  throw new Error(`tool "${input.toolName}" is an action tool but was dispatched without approval: the dispatching process resolved its kind against a registry that does not have it`);
145
145
  }
146
+ const sinkRunId = input.sinkRunId;
147
+ let opened;
148
+ const ui = (0, import_nestjs_agent_core.createUiCollector)(input.toolCallId, sinkRunId === void 0 ? void 0 : async (event) => {
149
+ opened ??= Promise.resolve(deps.sink.open(sinkRunId)).then((writer) => input.childSink === true ? childSinkWriter(writer) : writer);
150
+ await (await opened).write((0, import_nestjs_agent_core.encodeStreamEvent)(event));
151
+ });
146
152
  const ctx = {
147
- ...input.ctx
153
+ ...input.ctx,
154
+ emitUi: ui.emit
148
155
  };
149
156
  const localClassify = deps.toolTransientRetry !== false ? deps.toolTransientRetry?.classify : void 0;
150
157
  const transientRetry = input.transientRetry === false ? false : {
@@ -154,11 +161,12 @@ var AgentRunSteps = class {
154
161
  classify: localClassify
155
162
  } : {}
156
163
  };
157
- return (0, import_nestjs_agent_core.traceToolExecution)(input.ctx.runId, {
164
+ const output = await (0, import_nestjs_agent_core.traceToolExecution)(input.ctx.runId, {
158
165
  toolCallId: input.toolCallId,
159
166
  toolName: input.toolName,
160
167
  toolType: input.toolType
161
168
  }, () => (0, import_nestjs_agent_core.invokeWithTransientRetry)(() => {
169
+ ui.restart();
162
170
  const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
163
171
  return input.timeoutMs !== void 0 ? (0, import_nestjs_agent_core.withToolTimeout)(invocation, input.timeoutMs, input.toolName) : invocation;
164
172
  }, transientRetry, {
@@ -171,6 +179,7 @@ var AgentRunSteps = class {
171
179
  });
172
180
  }, "onRetry")
173
181
  }));
182
+ return input.collectUi === true ? (0, import_nestjs_agent_core.wrapToolStepOutput)(output, ui.components()) : output;
174
183
  }
175
184
  };
176
185
  _ts_decorate([
@@ -414,7 +423,10 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
414
423
  dispatchTool: /* @__PURE__ */ __name((call, envelope) => ctx.step(AgentRunSteps.prototype.tool, {
415
424
  ...envelope,
416
425
  toolCallId: call.id,
417
- toolType: call.kind === "action" ? "action" : "read"
426
+ toolType: call.kind === "action" ? "action" : "read",
427
+ // Where `ctx.emitUi` streams from the worker — the llm step's routing.
428
+ sinkRunId,
429
+ childSink: input.sinkRunId !== void 0
418
430
  }), "dispatchTool")
419
431
  } : {}
420
432
  };
@@ -806,8 +818,8 @@ AgentDurableModule = _ts_decorate4([
806
818
  ], AgentDurableModule);
807
819
 
808
820
  // src/agent.module.ts
809
- var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
810
- var import_common21 = require("@nestjs/common");
821
+ var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
822
+ var import_common22 = require("@nestjs/common");
811
823
  var import_core4 = require("@nestjs/core");
812
824
 
813
825
  // src/agent-deps.factory.ts
@@ -1409,6 +1421,40 @@ var AgentService = class {
1409
1421
  return this.store.truncateFrom(threadId, messageId);
1410
1422
  }
1411
1423
  /**
1424
+ * Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
1425
+ * to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
1426
+ * on a store without `threadOfMessage` + `setMessageFeedback`.
1427
+ */
1428
+ async setMessageFeedback(actor, messageId, input) {
1429
+ if (input.value !== null && input.value !== "up" && input.value !== "down") {
1430
+ throw new import_common6.BadRequestException("value must be 'up', 'down' or null");
1431
+ }
1432
+ if (input.comment !== void 0 && typeof input.comment !== "string") {
1433
+ throw new import_common6.BadRequestException("comment must be a string");
1434
+ }
1435
+ const comment = input.comment?.trim();
1436
+ if (comment !== void 0 && comment.length > 2e3) {
1437
+ throw new import_common6.BadRequestException("comment must be at most 2000 characters");
1438
+ }
1439
+ if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
1440
+ throw new import_common6.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
1441
+ }
1442
+ const threadId = await this.store.threadOfMessage(messageId);
1443
+ if (threadId === null) {
1444
+ throw new import_common6.NotFoundException(`message ${messageId} not found`);
1445
+ }
1446
+ await this.assertOwnsThread(actor, threadId);
1447
+ const feedback = input.value === null ? null : {
1448
+ value: input.value,
1449
+ ...comment !== void 0 && comment.length > 0 ? {
1450
+ comment
1451
+ } : {},
1452
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1453
+ };
1454
+ await this.store.setMessageFeedback(messageId, feedback);
1455
+ return feedback;
1456
+ }
1457
+ /**
1412
1458
  * Every file this actor has staged, newest first — across threads, including uploads that were
1413
1459
  * never sent, which nothing else on this surface can see.
1414
1460
  *
@@ -1997,9 +2043,15 @@ var ChatController = class {
1997
2043
  });
1998
2044
  await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
1999
2045
  }
2000
- async stream(req, runId, res) {
2046
+ /**
2047
+ * Attach to a run's stream: every buffered frame, then live ones. `?after=<seq>` (or the SSE
2048
+ * `Last-Event-ID` header a browser `EventSource` sends on its own) skips the frames a reconnecting
2049
+ * client already has — see {@link pipe} for how frames are numbered.
2050
+ */
2051
+ async stream(req, runId, res, after) {
2001
2052
  const actor = await this.actorResolver.resolve(req);
2002
- await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId));
2053
+ const cursor = parseCursor(after) ?? parseCursor(req.headers["last-event-id"]) ?? 0;
2054
+ await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId), void 0, cursor);
2003
2055
  }
2004
2056
  async cancel(req, runId) {
2005
2057
  const actor = await this.actorResolver.resolve(req);
@@ -2008,7 +2060,15 @@ var ChatController = class {
2008
2060
  aborted: true
2009
2061
  };
2010
2062
  }
2011
- async pipe(res, runId, events, threadId) {
2063
+ /**
2064
+ * Every `data:` frame carries an SSE `id:` — its 1-based sequence number within the run. The
2065
+ * number is a pure function of the run's buffered stream (every sink replays a run from its first
2066
+ * chunk, in write order), so the same frame gets the same number on the POST that started the run
2067
+ * and on any later `GET …/stream`, whichever replica serves it. A reconnecting client passes the
2068
+ * last one it saw as `?after=`; frames at or below it are read off the sink but not re-sent.
2069
+ * `meta`, `done` and `error` carry no id: `meta` is re-sent on every attach, the terminals once.
2070
+ */
2071
+ async pipe(res, runId, events, threadId, after = 0) {
2012
2072
  res.setHeader("Content-Type", "text/event-stream");
2013
2073
  res.setHeader("Cache-Control", "no-cache");
2014
2074
  res.setHeader("Connection", "keep-alive");
@@ -2025,6 +2085,16 @@ data: ${JSON.stringify({
2025
2085
  `);
2026
2086
  const decoder = new TextDecoder();
2027
2087
  let buffer = "";
2088
+ let seq = 0;
2089
+ const forward = /* @__PURE__ */ __name((line) => {
2090
+ seq += 1;
2091
+ if (seq > after) {
2092
+ res.write(`id: ${seq}
2093
+ data: ${line}
2094
+
2095
+ `);
2096
+ }
2097
+ }, "forward");
2028
2098
  try {
2029
2099
  for await (const chunk of events) {
2030
2100
  buffer += decoder.decode(chunk, {
@@ -2035,17 +2105,13 @@ data: ${JSON.stringify({
2035
2105
  const line = buffer.slice(0, newline);
2036
2106
  buffer = buffer.slice(newline + 1);
2037
2107
  if (line.length > 0) {
2038
- res.write(`data: ${line}
2039
-
2040
- `);
2108
+ forward(line);
2041
2109
  }
2042
2110
  newline = buffer.indexOf("\n");
2043
2111
  }
2044
2112
  }
2045
2113
  if (buffer.length > 0) {
2046
- res.write(`data: ${buffer}
2047
-
2048
- `);
2114
+ forward(buffer);
2049
2115
  }
2050
2116
  res.write("event: done\ndata: {}\n\n");
2051
2117
  } catch (error) {
@@ -2082,11 +2148,13 @@ _ts_decorate10([
2082
2148
  _ts_param8(0, (0, import_common10.Req)()),
2083
2149
  _ts_param8(1, (0, import_common10.Param)("runId")),
2084
2150
  _ts_param8(2, (0, import_common10.Res)()),
2151
+ _ts_param8(3, (0, import_common10.Query)("after")),
2085
2152
  _ts_metadata9("design:type", Function),
2086
2153
  _ts_metadata9("design:paramtypes", [
2087
2154
  typeof Request === "undefined" ? Object : Request,
2088
2155
  String,
2089
- typeof Response === "undefined" ? Object : Response
2156
+ typeof Response === "undefined" ? Object : Response,
2157
+ String
2090
2158
  ]),
2091
2159
  _ts_metadata9("design:returntype", Promise)
2092
2160
  ], ChatController.prototype, "stream", null);
@@ -2110,6 +2178,15 @@ ChatController = _ts_decorate10([
2110
2178
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2111
2179
  ])
2112
2180
  ], ChatController);
2181
+ function parseCursor(raw) {
2182
+ const value = Array.isArray(raw) ? raw[0] : raw;
2183
+ if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
2184
+ return void 0;
2185
+ }
2186
+ const parsed = Number(value.trim());
2187
+ return Number.isSafeInteger(parsed) ? parsed : void 0;
2188
+ }
2189
+ __name(parseCursor, "parseCursor");
2113
2190
 
2114
2191
  // src/controller/memories.controller.ts
2115
2192
  var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
@@ -2246,7 +2323,7 @@ MemoriesController = _ts_decorate11([
2246
2323
  ])
2247
2324
  ], MemoriesController);
2248
2325
 
2249
- // src/controller/quota.controller.ts
2326
+ // src/controller/messages.controller.ts
2250
2327
  var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
2251
2328
  var import_common12 = require("@nestjs/common");
2252
2329
  function _ts_decorate12(decorators, target, key, desc) {
@@ -2275,9 +2352,9 @@ function _ts_param10(paramIndex, decorator) {
2275
2352
  };
2276
2353
  }
2277
2354
  __name(_ts_param10, "_ts_param");
2278
- var QuotaController = class {
2355
+ var MessagesController = class {
2279
2356
  static {
2280
- __name(this, "QuotaController");
2357
+ __name(this, "MessagesController");
2281
2358
  }
2282
2359
  agent;
2283
2360
  actorResolver;
@@ -2285,31 +2362,48 @@ var QuotaController = class {
2285
2362
  this.agent = agent;
2286
2363
  this.actorResolver = actorResolver;
2287
2364
  }
2288
- async today(req) {
2365
+ /**
2366
+ * Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
2367
+ * (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
2368
+ */
2369
+ async feedback(req, id, body) {
2289
2370
  const actor = await this.actorResolver.resolve(req);
2290
- return this.agent.quotaToday(actor.id);
2371
+ const feedback = await this.agent.setMessageFeedback(actor, id, {
2372
+ value: body?.value ?? null,
2373
+ ...body?.comment !== void 0 ? {
2374
+ comment: body.comment
2375
+ } : {}
2376
+ });
2377
+ return {
2378
+ feedback
2379
+ };
2291
2380
  }
2292
2381
  };
2293
2382
  _ts_decorate12([
2294
- (0, import_common12.Get)("today"),
2383
+ (0, import_common12.Post)(":id/feedback"),
2384
+ (0, import_common12.HttpCode)(200),
2295
2385
  _ts_param10(0, (0, import_common12.Req)()),
2386
+ _ts_param10(1, (0, import_common12.Param)("id")),
2387
+ _ts_param10(2, (0, import_common12.Body)()),
2296
2388
  _ts_metadata11("design:type", Function),
2297
2389
  _ts_metadata11("design:paramtypes", [
2298
- typeof Request === "undefined" ? Object : Request
2390
+ typeof Request === "undefined" ? Object : Request,
2391
+ String,
2392
+ typeof FeedbackBody === "undefined" ? Object : FeedbackBody
2299
2393
  ]),
2300
2394
  _ts_metadata11("design:returntype", Promise)
2301
- ], QuotaController.prototype, "today", null);
2302
- QuotaController = _ts_decorate12([
2303
- (0, import_common12.Controller)("quota"),
2395
+ ], MessagesController.prototype, "feedback", null);
2396
+ MessagesController = _ts_decorate12([
2397
+ (0, import_common12.Controller)("messages"),
2304
2398
  _ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
2305
2399
  _ts_metadata11("design:type", Function),
2306
2400
  _ts_metadata11("design:paramtypes", [
2307
2401
  typeof AgentService === "undefined" ? Object : AgentService,
2308
2402
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2309
2403
  ])
2310
- ], QuotaController);
2404
+ ], MessagesController);
2311
2405
 
2312
- // src/controller/skills.controller.ts
2406
+ // src/controller/quota.controller.ts
2313
2407
  var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
2314
2408
  var import_common13 = require("@nestjs/common");
2315
2409
  function _ts_decorate13(decorators, target, key, desc) {
@@ -2338,6 +2432,69 @@ function _ts_param11(paramIndex, decorator) {
2338
2432
  };
2339
2433
  }
2340
2434
  __name(_ts_param11, "_ts_param");
2435
+ var QuotaController = class {
2436
+ static {
2437
+ __name(this, "QuotaController");
2438
+ }
2439
+ agent;
2440
+ actorResolver;
2441
+ constructor(agent, actorResolver) {
2442
+ this.agent = agent;
2443
+ this.actorResolver = actorResolver;
2444
+ }
2445
+ async today(req) {
2446
+ const actor = await this.actorResolver.resolve(req);
2447
+ return this.agent.quotaToday(actor.id);
2448
+ }
2449
+ };
2450
+ _ts_decorate13([
2451
+ (0, import_common13.Get)("today"),
2452
+ _ts_param11(0, (0, import_common13.Req)()),
2453
+ _ts_metadata12("design:type", Function),
2454
+ _ts_metadata12("design:paramtypes", [
2455
+ typeof Request === "undefined" ? Object : Request
2456
+ ]),
2457
+ _ts_metadata12("design:returntype", Promise)
2458
+ ], QuotaController.prototype, "today", null);
2459
+ QuotaController = _ts_decorate13([
2460
+ (0, import_common13.Controller)("quota"),
2461
+ _ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
2462
+ _ts_metadata12("design:type", Function),
2463
+ _ts_metadata12("design:paramtypes", [
2464
+ typeof AgentService === "undefined" ? Object : AgentService,
2465
+ typeof ActorResolver === "undefined" ? Object : ActorResolver
2466
+ ])
2467
+ ], QuotaController);
2468
+
2469
+ // src/controller/skills.controller.ts
2470
+ var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2471
+ var import_common14 = require("@nestjs/common");
2472
+ function _ts_decorate14(decorators, target, key, desc) {
2473
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2474
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2475
+ r = Reflect.decorate(decorators, target, key, desc);
2476
+ } else {
2477
+ for (var i = decorators.length - 1; i >= 0; i--) {
2478
+ if (d = decorators[i]) {
2479
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2480
+ }
2481
+ }
2482
+ }
2483
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2484
+ }
2485
+ __name(_ts_decorate14, "_ts_decorate");
2486
+ function _ts_metadata13(metadataKey, metadataValue) {
2487
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2488
+ return Reflect.metadata(metadataKey, metadataValue);
2489
+ }
2490
+ }
2491
+ __name(_ts_metadata13, "_ts_metadata");
2492
+ function _ts_param12(paramIndex, decorator) {
2493
+ return function(target, key) {
2494
+ decorator(target, key, paramIndex);
2495
+ };
2496
+ }
2497
+ __name(_ts_param12, "_ts_param");
2341
2498
  var SkillsController = class {
2342
2499
  static {
2343
2500
  __name(this, "SkillsController");
@@ -2353,40 +2510,40 @@ var SkillsController = class {
2353
2510
  return [];
2354
2511
  }
2355
2512
  const actor = await this.actorResolver.resolve(req);
2356
- const offer = await (0, import_nestjs_agent_core14.offerSkills)(this.skills, {
2513
+ const offer = await (0, import_nestjs_agent_core15.offerSkills)(this.skills, {
2357
2514
  actor,
2358
2515
  threadId: threadId ?? ""
2359
2516
  });
2360
2517
  return offer.entries;
2361
2518
  }
2362
2519
  };
2363
- _ts_decorate13([
2364
- (0, import_common13.Get)(),
2365
- _ts_param11(0, (0, import_common13.Req)()),
2366
- _ts_param11(1, (0, import_common13.Query)("threadId")),
2367
- _ts_metadata12("design:type", Function),
2368
- _ts_metadata12("design:paramtypes", [
2520
+ _ts_decorate14([
2521
+ (0, import_common14.Get)(),
2522
+ _ts_param12(0, (0, import_common14.Req)()),
2523
+ _ts_param12(1, (0, import_common14.Query)("threadId")),
2524
+ _ts_metadata13("design:type", Function),
2525
+ _ts_metadata13("design:paramtypes", [
2369
2526
  typeof Request === "undefined" ? Object : Request,
2370
2527
  String
2371
2528
  ]),
2372
- _ts_metadata12("design:returntype", Promise)
2529
+ _ts_metadata13("design:returntype", Promise)
2373
2530
  ], SkillsController.prototype, "list", null);
2374
- SkillsController = _ts_decorate13([
2375
- (0, import_common13.Controller)("skills"),
2376
- _ts_param11(0, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
2377
- _ts_param11(1, (0, import_common13.Optional)()),
2378
- _ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_SKILLS)),
2379
- _ts_metadata12("design:type", Function),
2380
- _ts_metadata12("design:paramtypes", [
2531
+ SkillsController = _ts_decorate14([
2532
+ (0, import_common14.Controller)("skills"),
2533
+ _ts_param12(0, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
2534
+ _ts_param12(1, (0, import_common14.Optional)()),
2535
+ _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_SKILLS)),
2536
+ _ts_metadata13("design:type", Function),
2537
+ _ts_metadata13("design:paramtypes", [
2381
2538
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2382
2539
  Object
2383
2540
  ])
2384
2541
  ], SkillsController);
2385
2542
 
2386
2543
  // src/controller/threads.controller.ts
2387
- var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
2388
- var import_common14 = require("@nestjs/common");
2389
- function _ts_decorate14(decorators, target, key, desc) {
2544
+ var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2545
+ var import_common15 = require("@nestjs/common");
2546
+ function _ts_decorate15(decorators, target, key, desc) {
2390
2547
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2391
2548
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2392
2549
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2399,19 +2556,19 @@ function _ts_decorate14(decorators, target, key, desc) {
2399
2556
  }
2400
2557
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2401
2558
  }
2402
- __name(_ts_decorate14, "_ts_decorate");
2403
- function _ts_metadata13(metadataKey, metadataValue) {
2559
+ __name(_ts_decorate15, "_ts_decorate");
2560
+ function _ts_metadata14(metadataKey, metadataValue) {
2404
2561
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2405
2562
  return Reflect.metadata(metadataKey, metadataValue);
2406
2563
  }
2407
2564
  }
2408
- __name(_ts_metadata13, "_ts_metadata");
2409
- function _ts_param12(paramIndex, decorator) {
2565
+ __name(_ts_metadata14, "_ts_metadata");
2566
+ function _ts_param13(paramIndex, decorator) {
2410
2567
  return function(target, key) {
2411
2568
  decorator(target, key, paramIndex);
2412
2569
  };
2413
2570
  }
2414
- __name(_ts_param12, "_ts_param");
2571
+ __name(_ts_param13, "_ts_param");
2415
2572
  var ThreadsController = class {
2416
2573
  static {
2417
2574
  __name(this, "ThreadsController");
@@ -2475,101 +2632,101 @@ var ThreadsController = class {
2475
2632
  };
2476
2633
  }
2477
2634
  };
2478
- _ts_decorate14([
2479
- (0, import_common14.Get)(),
2480
- _ts_param12(0, (0, import_common14.Req)()),
2481
- _ts_metadata13("design:type", Function),
2482
- _ts_metadata13("design:paramtypes", [
2635
+ _ts_decorate15([
2636
+ (0, import_common15.Get)(),
2637
+ _ts_param13(0, (0, import_common15.Req)()),
2638
+ _ts_metadata14("design:type", Function),
2639
+ _ts_metadata14("design:paramtypes", [
2483
2640
  typeof Request === "undefined" ? Object : Request
2484
2641
  ]),
2485
- _ts_metadata13("design:returntype", Promise)
2642
+ _ts_metadata14("design:returntype", Promise)
2486
2643
  ], ThreadsController.prototype, "list", null);
2487
- _ts_decorate14([
2488
- (0, import_common14.Get)(":id"),
2489
- _ts_param12(0, (0, import_common14.Req)()),
2490
- _ts_param12(1, (0, import_common14.Param)("id")),
2491
- _ts_metadata13("design:type", Function),
2492
- _ts_metadata13("design:paramtypes", [
2644
+ _ts_decorate15([
2645
+ (0, import_common15.Get)(":id"),
2646
+ _ts_param13(0, (0, import_common15.Req)()),
2647
+ _ts_param13(1, (0, import_common15.Param)("id")),
2648
+ _ts_metadata14("design:type", Function),
2649
+ _ts_metadata14("design:paramtypes", [
2493
2650
  typeof Request === "undefined" ? Object : Request,
2494
2651
  String
2495
2652
  ]),
2496
- _ts_metadata13("design:returntype", Promise)
2653
+ _ts_metadata14("design:returntype", Promise)
2497
2654
  ], ThreadsController.prototype, "detail", null);
2498
- _ts_decorate14([
2499
- (0, import_common14.Delete)(":id"),
2500
- _ts_param12(0, (0, import_common14.Req)()),
2501
- _ts_param12(1, (0, import_common14.Param)("id")),
2502
- _ts_metadata13("design:type", Function),
2503
- _ts_metadata13("design:paramtypes", [
2655
+ _ts_decorate15([
2656
+ (0, import_common15.Delete)(":id"),
2657
+ _ts_param13(0, (0, import_common15.Req)()),
2658
+ _ts_param13(1, (0, import_common15.Param)("id")),
2659
+ _ts_metadata14("design:type", Function),
2660
+ _ts_metadata14("design:paramtypes", [
2504
2661
  typeof Request === "undefined" ? Object : Request,
2505
2662
  String
2506
2663
  ]),
2507
- _ts_metadata13("design:returntype", Promise)
2664
+ _ts_metadata14("design:returntype", Promise)
2508
2665
  ], ThreadsController.prototype, "remove", null);
2509
- _ts_decorate14([
2510
- (0, import_common14.Post)(":id/fork-from/:messageId"),
2511
- _ts_param12(0, (0, import_common14.Req)()),
2512
- _ts_param12(1, (0, import_common14.Param)("id")),
2513
- _ts_param12(2, (0, import_common14.Param)("messageId")),
2514
- _ts_metadata13("design:type", Function),
2515
- _ts_metadata13("design:paramtypes", [
2666
+ _ts_decorate15([
2667
+ (0, import_common15.Post)(":id/fork-from/:messageId"),
2668
+ _ts_param13(0, (0, import_common15.Req)()),
2669
+ _ts_param13(1, (0, import_common15.Param)("id")),
2670
+ _ts_param13(2, (0, import_common15.Param)("messageId")),
2671
+ _ts_metadata14("design:type", Function),
2672
+ _ts_metadata14("design:paramtypes", [
2516
2673
  typeof Request === "undefined" ? Object : Request,
2517
2674
  String,
2518
2675
  String
2519
2676
  ]),
2520
- _ts_metadata13("design:returntype", Promise)
2677
+ _ts_metadata14("design:returntype", Promise)
2521
2678
  ], ThreadsController.prototype, "fork", null);
2522
- _ts_decorate14([
2523
- (0, import_common14.Patch)(":id"),
2524
- _ts_param12(0, (0, import_common14.Req)()),
2525
- _ts_param12(1, (0, import_common14.Param)("id")),
2526
- _ts_param12(2, (0, import_common14.Body)()),
2527
- _ts_metadata13("design:type", Function),
2528
- _ts_metadata13("design:paramtypes", [
2679
+ _ts_decorate15([
2680
+ (0, import_common15.Patch)(":id"),
2681
+ _ts_param13(0, (0, import_common15.Req)()),
2682
+ _ts_param13(1, (0, import_common15.Param)("id")),
2683
+ _ts_param13(2, (0, import_common15.Body)()),
2684
+ _ts_metadata14("design:type", Function),
2685
+ _ts_metadata14("design:paramtypes", [
2529
2686
  typeof Request === "undefined" ? Object : Request,
2530
2687
  String,
2531
2688
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
2532
2689
  ]),
2533
- _ts_metadata13("design:returntype", Promise)
2690
+ _ts_metadata14("design:returntype", Promise)
2534
2691
  ], ThreadsController.prototype, "update", null);
2535
- _ts_decorate14([
2536
- (0, import_common14.Post)(":id/promote"),
2537
- _ts_param12(0, (0, import_common14.Req)()),
2538
- _ts_param12(1, (0, import_common14.Param)("id")),
2539
- _ts_metadata13("design:type", Function),
2540
- _ts_metadata13("design:paramtypes", [
2692
+ _ts_decorate15([
2693
+ (0, import_common15.Post)(":id/promote"),
2694
+ _ts_param13(0, (0, import_common15.Req)()),
2695
+ _ts_param13(1, (0, import_common15.Param)("id")),
2696
+ _ts_metadata14("design:type", Function),
2697
+ _ts_metadata14("design:paramtypes", [
2541
2698
  typeof Request === "undefined" ? Object : Request,
2542
2699
  String
2543
2700
  ]),
2544
- _ts_metadata13("design:returntype", Promise)
2701
+ _ts_metadata14("design:returntype", Promise)
2545
2702
  ], ThreadsController.prototype, "promote", null);
2546
- _ts_decorate14([
2547
- (0, import_common14.Delete)(":id/from/:messageId"),
2548
- _ts_param12(0, (0, import_common14.Req)()),
2549
- _ts_param12(1, (0, import_common14.Param)("id")),
2550
- _ts_param12(2, (0, import_common14.Param)("messageId")),
2551
- _ts_metadata13("design:type", Function),
2552
- _ts_metadata13("design:paramtypes", [
2703
+ _ts_decorate15([
2704
+ (0, import_common15.Delete)(":id/from/:messageId"),
2705
+ _ts_param13(0, (0, import_common15.Req)()),
2706
+ _ts_param13(1, (0, import_common15.Param)("id")),
2707
+ _ts_param13(2, (0, import_common15.Param)("messageId")),
2708
+ _ts_metadata14("design:type", Function),
2709
+ _ts_metadata14("design:paramtypes", [
2553
2710
  typeof Request === "undefined" ? Object : Request,
2554
2711
  String,
2555
2712
  String
2556
2713
  ]),
2557
- _ts_metadata13("design:returntype", Promise)
2714
+ _ts_metadata14("design:returntype", Promise)
2558
2715
  ], ThreadsController.prototype, "truncateFrom", null);
2559
- ThreadsController = _ts_decorate14([
2560
- (0, import_common14.Controller)("threads"),
2561
- _ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
2562
- _ts_metadata13("design:type", Function),
2563
- _ts_metadata13("design:paramtypes", [
2716
+ ThreadsController = _ts_decorate15([
2717
+ (0, import_common15.Controller)("threads"),
2718
+ _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
2719
+ _ts_metadata14("design:type", Function),
2720
+ _ts_metadata14("design:paramtypes", [
2564
2721
  typeof AgentService === "undefined" ? Object : AgentService,
2565
2722
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2566
2723
  ])
2567
2724
  ], ThreadsController);
2568
2725
 
2569
2726
  // src/controller/tool-call.controller.ts
2570
- var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
2571
- var import_common15 = require("@nestjs/common");
2572
- function _ts_decorate15(decorators, target, key, desc) {
2727
+ var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2728
+ var import_common16 = require("@nestjs/common");
2729
+ function _ts_decorate16(decorators, target, key, desc) {
2573
2730
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2574
2731
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2575
2732
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2582,19 +2739,19 @@ function _ts_decorate15(decorators, target, key, desc) {
2582
2739
  }
2583
2740
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2584
2741
  }
2585
- __name(_ts_decorate15, "_ts_decorate");
2586
- function _ts_metadata14(metadataKey, metadataValue) {
2742
+ __name(_ts_decorate16, "_ts_decorate");
2743
+ function _ts_metadata15(metadataKey, metadataValue) {
2587
2744
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2588
2745
  return Reflect.metadata(metadataKey, metadataValue);
2589
2746
  }
2590
2747
  }
2591
- __name(_ts_metadata14, "_ts_metadata");
2592
- function _ts_param13(paramIndex, decorator) {
2748
+ __name(_ts_metadata15, "_ts_metadata");
2749
+ function _ts_param14(paramIndex, decorator) {
2593
2750
  return function(target, key) {
2594
2751
  decorator(target, key, paramIndex);
2595
2752
  };
2596
2753
  }
2597
- __name(_ts_param13, "_ts_param");
2754
+ __name(_ts_param14, "_ts_param");
2598
2755
  var MAX_ANSWERED_QUESTIONS = 100;
2599
2756
  var MAX_VALUES_PER_QUESTION = 100;
2600
2757
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -2603,7 +2760,7 @@ var MAX_VIA_LENGTH = 64;
2603
2760
  var DEFAULT_VIA = "web";
2604
2761
  function toolCallId(claimed) {
2605
2762
  if (typeof claimed !== "string" || claimed.length === 0) {
2606
- throw new import_common15.BadRequestException("toolCallId must be a non-empty string");
2763
+ throw new import_common16.BadRequestException("toolCallId must be a non-empty string");
2607
2764
  }
2608
2765
  return claimed;
2609
2766
  }
@@ -2613,10 +2770,10 @@ function rejectReason(claimed) {
2613
2770
  return void 0;
2614
2771
  }
2615
2772
  if (typeof claimed !== "string") {
2616
- throw new import_common15.BadRequestException("reason must be a string");
2773
+ throw new import_common16.BadRequestException("reason must be a string");
2617
2774
  }
2618
2775
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
2619
- throw new import_common15.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
2776
+ throw new import_common16.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
2620
2777
  }
2621
2778
  return claimed;
2622
2779
  }
@@ -2626,7 +2783,7 @@ function remember(claimed) {
2626
2783
  return false;
2627
2784
  }
2628
2785
  if (typeof claimed !== "boolean") {
2629
- throw new import_common15.BadRequestException("remember must be a boolean");
2786
+ throw new import_common16.BadRequestException("remember must be a boolean");
2630
2787
  }
2631
2788
  return claimed;
2632
2789
  }
@@ -2636,7 +2793,7 @@ function via(claimed) {
2636
2793
  return DEFAULT_VIA;
2637
2794
  }
2638
2795
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
2639
- throw new import_common15.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
2796
+ throw new import_common16.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
2640
2797
  }
2641
2798
  return claimed;
2642
2799
  }
@@ -2646,26 +2803,26 @@ function answers(claimed) {
2646
2803
  return void 0;
2647
2804
  }
2648
2805
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
2649
- throw new import_common15.BadRequestException("answers must be an object of questionId \u2192 chosen values");
2806
+ throw new import_common16.BadRequestException("answers must be an object of questionId \u2192 chosen values");
2650
2807
  }
2651
2808
  const entries = Object.entries(claimed);
2652
2809
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
2653
- throw new import_common15.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
2810
+ throw new import_common16.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
2654
2811
  }
2655
2812
  const validated = /* @__PURE__ */ Object.create(null);
2656
2813
  for (const [questionId, values] of entries) {
2657
2814
  if (!Array.isArray(values)) {
2658
- throw new import_common15.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
2815
+ throw new import_common16.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
2659
2816
  }
2660
2817
  if (values.length > MAX_VALUES_PER_QUESTION) {
2661
- throw new import_common15.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
2818
+ throw new import_common16.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
2662
2819
  }
2663
2820
  for (const value of values) {
2664
2821
  if (typeof value !== "string") {
2665
- throw new import_common15.BadRequestException(`answers["${questionId}"] must contain only strings`);
2822
+ throw new import_common16.BadRequestException(`answers["${questionId}"] must contain only strings`);
2666
2823
  }
2667
2824
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
2668
- throw new import_common15.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
2825
+ throw new import_common16.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
2669
2826
  }
2670
2827
  }
2671
2828
  validated[questionId] = values;
@@ -2723,64 +2880,64 @@ var ToolCallController = class {
2723
2880
  };
2724
2881
  }
2725
2882
  };
2726
- _ts_decorate15([
2727
- (0, import_common15.Post)("approve"),
2728
- _ts_param13(0, (0, import_common15.Req)()),
2729
- _ts_param13(1, (0, import_common15.Body)()),
2730
- _ts_metadata14("design:type", Function),
2731
- _ts_metadata14("design:paramtypes", [
2883
+ _ts_decorate16([
2884
+ (0, import_common16.Post)("approve"),
2885
+ _ts_param14(0, (0, import_common16.Req)()),
2886
+ _ts_param14(1, (0, import_common16.Body)()),
2887
+ _ts_metadata15("design:type", Function),
2888
+ _ts_metadata15("design:paramtypes", [
2732
2889
  typeof Request === "undefined" ? Object : Request,
2733
2890
  typeof ApproveBody === "undefined" ? Object : ApproveBody
2734
2891
  ]),
2735
- _ts_metadata14("design:returntype", Promise)
2892
+ _ts_metadata15("design:returntype", Promise)
2736
2893
  ], ToolCallController.prototype, "approve", null);
2737
- _ts_decorate15([
2738
- (0, import_common15.Post)("reject"),
2739
- _ts_param13(0, (0, import_common15.Req)()),
2740
- _ts_param13(1, (0, import_common15.Body)()),
2741
- _ts_metadata14("design:type", Function),
2742
- _ts_metadata14("design:paramtypes", [
2894
+ _ts_decorate16([
2895
+ (0, import_common16.Post)("reject"),
2896
+ _ts_param14(0, (0, import_common16.Req)()),
2897
+ _ts_param14(1, (0, import_common16.Body)()),
2898
+ _ts_metadata15("design:type", Function),
2899
+ _ts_metadata15("design:paramtypes", [
2743
2900
  typeof Request === "undefined" ? Object : Request,
2744
2901
  typeof RejectBody === "undefined" ? Object : RejectBody
2745
2902
  ]),
2746
- _ts_metadata14("design:returntype", Promise)
2903
+ _ts_metadata15("design:returntype", Promise)
2747
2904
  ], ToolCallController.prototype, "reject", null);
2748
- _ts_decorate15([
2749
- (0, import_common15.Post)("answer"),
2750
- _ts_param13(0, (0, import_common15.Req)()),
2751
- _ts_param13(1, (0, import_common15.Body)()),
2752
- _ts_metadata14("design:type", Function),
2753
- _ts_metadata14("design:paramtypes", [
2905
+ _ts_decorate16([
2906
+ (0, import_common16.Post)("answer"),
2907
+ _ts_param14(0, (0, import_common16.Req)()),
2908
+ _ts_param14(1, (0, import_common16.Body)()),
2909
+ _ts_metadata15("design:type", Function),
2910
+ _ts_metadata15("design:paramtypes", [
2754
2911
  typeof Request === "undefined" ? Object : Request,
2755
2912
  typeof AnswerBody === "undefined" ? Object : AnswerBody
2756
2913
  ]),
2757
- _ts_metadata14("design:returntype", Promise)
2914
+ _ts_metadata15("design:returntype", Promise)
2758
2915
  ], ToolCallController.prototype, "answer", null);
2759
- _ts_decorate15([
2760
- (0, import_common15.Post)("skip"),
2761
- _ts_param13(0, (0, import_common15.Req)()),
2762
- _ts_param13(1, (0, import_common15.Body)()),
2763
- _ts_metadata14("design:type", Function),
2764
- _ts_metadata14("design:paramtypes", [
2916
+ _ts_decorate16([
2917
+ (0, import_common16.Post)("skip"),
2918
+ _ts_param14(0, (0, import_common16.Req)()),
2919
+ _ts_param14(1, (0, import_common16.Body)()),
2920
+ _ts_metadata15("design:type", Function),
2921
+ _ts_metadata15("design:paramtypes", [
2765
2922
  typeof Request === "undefined" ? Object : Request,
2766
2923
  Object
2767
2924
  ]),
2768
- _ts_metadata14("design:returntype", Promise)
2925
+ _ts_metadata15("design:returntype", Promise)
2769
2926
  ], ToolCallController.prototype, "skip", null);
2770
- ToolCallController = _ts_decorate15([
2771
- (0, import_common15.Controller)("tool-call"),
2772
- _ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
2773
- _ts_metadata14("design:type", Function),
2774
- _ts_metadata14("design:paramtypes", [
2927
+ ToolCallController = _ts_decorate16([
2928
+ (0, import_common16.Controller)("tool-call"),
2929
+ _ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
2930
+ _ts_metadata15("design:type", Function),
2931
+ _ts_metadata15("design:paramtypes", [
2775
2932
  typeof AgentService === "undefined" ? Object : AgentService,
2776
2933
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2777
2934
  ])
2778
2935
  ], ToolCallController);
2779
2936
 
2780
2937
  // src/controller/tools.controller.ts
2781
- var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
2782
- var import_common16 = require("@nestjs/common");
2783
- function _ts_decorate16(decorators, target, key, desc) {
2938
+ var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2939
+ var import_common17 = require("@nestjs/common");
2940
+ function _ts_decorate17(decorators, target, key, desc) {
2784
2941
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2785
2942
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2786
2943
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2793,19 +2950,19 @@ function _ts_decorate16(decorators, target, key, desc) {
2793
2950
  }
2794
2951
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2795
2952
  }
2796
- __name(_ts_decorate16, "_ts_decorate");
2797
- function _ts_metadata15(metadataKey, metadataValue) {
2953
+ __name(_ts_decorate17, "_ts_decorate");
2954
+ function _ts_metadata16(metadataKey, metadataValue) {
2798
2955
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2799
2956
  return Reflect.metadata(metadataKey, metadataValue);
2800
2957
  }
2801
2958
  }
2802
- __name(_ts_metadata15, "_ts_metadata");
2803
- function _ts_param14(paramIndex, decorator) {
2959
+ __name(_ts_metadata16, "_ts_metadata");
2960
+ function _ts_param15(paramIndex, decorator) {
2804
2961
  return function(target, key) {
2805
2962
  decorator(target, key, paramIndex);
2806
2963
  };
2807
2964
  }
2808
- __name(_ts_param14, "_ts_param");
2965
+ __name(_ts_param15, "_ts_param");
2809
2966
  var ToolsController = class {
2810
2967
  static {
2811
2968
  __name(this, "ToolsController");
@@ -2820,7 +2977,7 @@ var ToolsController = class {
2820
2977
  }
2821
2978
  async list(req, agent) {
2822
2979
  if (agent !== void 0 && this.agents.get(agent) === void 0) {
2823
- throw new import_common16.NotFoundException(`No agent named "${agent}"`);
2980
+ throw new import_common17.NotFoundException(`No agent named "${agent}"`);
2824
2981
  }
2825
2982
  const actor = await this.actorResolver.resolve(req);
2826
2983
  const deps = this.depsFactory.forAgent(agent);
@@ -2834,33 +2991,33 @@ var ToolsController = class {
2834
2991
  }));
2835
2992
  }
2836
2993
  };
2837
- _ts_decorate16([
2838
- (0, import_common16.Get)(),
2839
- _ts_param14(0, (0, import_common16.Req)()),
2840
- _ts_param14(1, (0, import_common16.Query)("agent")),
2841
- _ts_metadata15("design:type", Function),
2842
- _ts_metadata15("design:paramtypes", [
2994
+ _ts_decorate17([
2995
+ (0, import_common17.Get)(),
2996
+ _ts_param15(0, (0, import_common17.Req)()),
2997
+ _ts_param15(1, (0, import_common17.Query)("agent")),
2998
+ _ts_metadata16("design:type", Function),
2999
+ _ts_metadata16("design:paramtypes", [
2843
3000
  typeof Request === "undefined" ? Object : Request,
2844
3001
  String
2845
3002
  ]),
2846
- _ts_metadata15("design:returntype", Promise)
3003
+ _ts_metadata16("design:returntype", Promise)
2847
3004
  ], ToolsController.prototype, "list", null);
2848
- ToolsController = _ts_decorate16([
2849
- (0, import_common16.Controller)("tools"),
2850
- _ts_param14(0, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
2851
- _ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_DEPS_FACTORY)),
2852
- _ts_param14(2, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_REGISTRY)),
2853
- _ts_metadata15("design:type", Function),
2854
- _ts_metadata15("design:paramtypes", [
3005
+ ToolsController = _ts_decorate17([
3006
+ (0, import_common17.Controller)("tools"),
3007
+ _ts_param15(0, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
3008
+ _ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_DEPS_FACTORY)),
3009
+ _ts_param15(2, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_REGISTRY)),
3010
+ _ts_metadata16("design:type", Function),
3011
+ _ts_metadata16("design:paramtypes", [
2855
3012
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2856
3013
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
2857
- typeof import_nestjs_agent_core17.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core17.AgentRegistry
3014
+ typeof import_nestjs_agent_core18.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core18.AgentRegistry
2858
3015
  ])
2859
3016
  ], ToolsController);
2860
3017
 
2861
3018
  // src/discovery/agent-discovery.service.ts
2862
- var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
2863
- var import_common17 = require("@nestjs/common");
3019
+ var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3020
+ var import_common18 = require("@nestjs/common");
2864
3021
  var import_core = require("@nestjs/core");
2865
3022
 
2866
3023
  // src/decorator/agent.decorator.ts
@@ -2877,7 +3034,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
2877
3034
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
2878
3035
 
2879
3036
  // src/discovery/agent-discovery.service.ts
2880
- function _ts_decorate17(decorators, target, key, desc) {
3037
+ function _ts_decorate18(decorators, target, key, desc) {
2881
3038
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2882
3039
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2883
3040
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2890,19 +3047,19 @@ function _ts_decorate17(decorators, target, key, desc) {
2890
3047
  }
2891
3048
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2892
3049
  }
2893
- __name(_ts_decorate17, "_ts_decorate");
2894
- function _ts_metadata16(metadataKey, metadataValue) {
3050
+ __name(_ts_decorate18, "_ts_decorate");
3051
+ function _ts_metadata17(metadataKey, metadataValue) {
2895
3052
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2896
3053
  return Reflect.metadata(metadataKey, metadataValue);
2897
3054
  }
2898
3055
  }
2899
- __name(_ts_metadata16, "_ts_metadata");
2900
- function _ts_param15(paramIndex, decorator) {
3056
+ __name(_ts_metadata17, "_ts_metadata");
3057
+ function _ts_param16(paramIndex, decorator) {
2901
3058
  return function(target, key) {
2902
3059
  decorator(target, key, paramIndex);
2903
3060
  };
2904
3061
  }
2905
- __name(_ts_param15, "_ts_param");
3062
+ __name(_ts_param16, "_ts_param");
2906
3063
  var AgentDiscoveryService = class _AgentDiscoveryService {
2907
3064
  static {
2908
3065
  __name(this, "AgentDiscoveryService");
@@ -2911,7 +3068,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
2911
3068
  scanner;
2912
3069
  registry;
2913
3070
  contributors;
2914
- logger = new import_common17.Logger(_AgentDiscoveryService.name);
3071
+ logger = new import_common18.Logger(_AgentDiscoveryService.name);
2915
3072
  constructor(discovery, scanner, registry, contributors) {
2916
3073
  this.discovery = discovery;
2917
3074
  this.scanner = scanner;
@@ -3029,22 +3186,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
3029
3186
  return (ctx) => candidate.call(instance, ctx);
3030
3187
  }
3031
3188
  };
3032
- AgentDiscoveryService = _ts_decorate17([
3033
- (0, import_common17.Injectable)(),
3034
- _ts_param15(2, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_REGISTRY)),
3035
- _ts_param15(3, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_PROMPT_CONTRIBUTORS)),
3036
- _ts_metadata16("design:type", Function),
3037
- _ts_metadata16("design:paramtypes", [
3189
+ AgentDiscoveryService = _ts_decorate18([
3190
+ (0, import_common18.Injectable)(),
3191
+ _ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
3192
+ _ts_param16(3, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_PROMPT_CONTRIBUTORS)),
3193
+ _ts_metadata17("design:type", Function),
3194
+ _ts_metadata17("design:paramtypes", [
3038
3195
  typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
3039
3196
  typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
3040
- typeof import_nestjs_agent_core18.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core18.AgentRegistry,
3197
+ typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry,
3041
3198
  Array
3042
3199
  ])
3043
3200
  ], AgentDiscoveryService);
3044
3201
 
3045
3202
  // src/discovery/ai-tool-discovery.service.ts
3046
- var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
3047
- var import_common18 = require("@nestjs/common");
3203
+ var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3204
+ var import_common19 = require("@nestjs/common");
3048
3205
  var import_core2 = require("@nestjs/core");
3049
3206
  var import_zod = require("zod");
3050
3207
 
@@ -3064,7 +3221,7 @@ function isBrandedFunctionalTool(value) {
3064
3221
  __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
3065
3222
 
3066
3223
  // src/discovery/ai-tool-discovery.service.ts
3067
- function _ts_decorate18(decorators, target, key, desc) {
3224
+ function _ts_decorate19(decorators, target, key, desc) {
3068
3225
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3069
3226
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3070
3227
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3077,19 +3234,19 @@ function _ts_decorate18(decorators, target, key, desc) {
3077
3234
  }
3078
3235
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3079
3236
  }
3080
- __name(_ts_decorate18, "_ts_decorate");
3081
- function _ts_metadata17(metadataKey, metadataValue) {
3237
+ __name(_ts_decorate19, "_ts_decorate");
3238
+ function _ts_metadata18(metadataKey, metadataValue) {
3082
3239
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3083
3240
  return Reflect.metadata(metadataKey, metadataValue);
3084
3241
  }
3085
3242
  }
3086
- __name(_ts_metadata17, "_ts_metadata");
3087
- function _ts_param16(paramIndex, decorator) {
3243
+ __name(_ts_metadata18, "_ts_metadata");
3244
+ function _ts_param17(paramIndex, decorator) {
3088
3245
  return function(target, key) {
3089
3246
  decorator(target, key, paramIndex);
3090
3247
  };
3091
3248
  }
3092
- __name(_ts_param16, "_ts_param");
3249
+ __name(_ts_param17, "_ts_param");
3093
3250
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
3094
3251
  static {
3095
3252
  __name(this, "AiToolDiscoveryService");
@@ -3098,7 +3255,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3098
3255
  registry;
3099
3256
  agents;
3100
3257
  options;
3101
- logger = new import_common18.Logger(_AiToolDiscoveryService.name);
3258
+ logger = new import_common19.Logger(_AiToolDiscoveryService.name);
3102
3259
  constructor(discovery, registry, agents, options) {
3103
3260
  this.discovery = discovery;
3104
3261
  this.registry = registry;
@@ -3146,6 +3303,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3146
3303
  } : {},
3147
3304
  ...meta.presentation !== void 0 ? {
3148
3305
  presentation: meta.presentation
3306
+ } : {},
3307
+ ...meta.terminal === true ? {
3308
+ terminal: true
3149
3309
  } : {}
3150
3310
  }, {
3151
3311
  execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
@@ -3169,7 +3329,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3169
3329
  let delegates = 0;
3170
3330
  for (const definition of this.agents.list()) {
3171
3331
  for (const edge of definition.delegatesTo ?? []) {
3172
- const { agent: target, detached } = (0, import_nestjs_agent_core19.normalizeDelegation)(edge);
3332
+ const { agent: target, detached } = (0, import_nestjs_agent_core20.normalizeDelegation)(edge);
3173
3333
  const targetDefinition = this.agents.get(target);
3174
3334
  if (targetDefinition === void 0) {
3175
3335
  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.`);
@@ -3219,13 +3379,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
3219
3379
  return true;
3220
3380
  }
3221
3381
  };
3222
- AiToolDiscoveryService = _ts_decorate18([
3223
- (0, import_common18.Injectable)(),
3224
- _ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_TOOL_REGISTRY)),
3225
- _ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
3226
- _ts_param16(3, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_OPTIONS)),
3227
- _ts_metadata17("design:type", Function),
3228
- _ts_metadata17("design:paramtypes", [
3382
+ AiToolDiscoveryService = _ts_decorate19([
3383
+ (0, import_common19.Injectable)(),
3384
+ _ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_TOOL_REGISTRY)),
3385
+ _ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
3386
+ _ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_OPTIONS)),
3387
+ _ts_metadata18("design:type", Function),
3388
+ _ts_metadata18("design:paramtypes", [
3229
3389
  typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
3230
3390
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
3231
3391
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -3234,25 +3394,25 @@ AiToolDiscoveryService = _ts_decorate18([
3234
3394
  ], AiToolDiscoveryService);
3235
3395
 
3236
3396
  // src/discovery/skill-discovery.service.ts
3237
- var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
3238
- var import_common19 = require("@nestjs/common");
3397
+ var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
3398
+ var import_common20 = require("@nestjs/common");
3239
3399
  var import_core3 = require("@nestjs/core");
3240
3400
 
3241
3401
  // src/decorator/skill.decorator.ts
3242
3402
  var import_reflect_metadata4 = require("reflect-metadata");
3243
- var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
3403
+ var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
3244
3404
  var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
3245
3405
  function readSkillMetadata(target) {
3246
3406
  return Reflect.getMetadata(SKILL_METADATA, target);
3247
3407
  }
3248
3408
  __name(readSkillMetadata, "readSkillMetadata");
3249
3409
  function skillScope(options) {
3250
- return options.scope ?? import_nestjs_agent_core20.GLOBAL_SCOPE;
3410
+ return options.scope ?? import_nestjs_agent_core21.GLOBAL_SCOPE;
3251
3411
  }
3252
3412
  __name(skillScope, "skillScope");
3253
3413
 
3254
3414
  // src/discovery/skill-discovery.service.ts
3255
- function _ts_decorate19(decorators, target, key, desc) {
3415
+ function _ts_decorate20(decorators, target, key, desc) {
3256
3416
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3257
3417
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3258
3418
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3265,26 +3425,26 @@ function _ts_decorate19(decorators, target, key, desc) {
3265
3425
  }
3266
3426
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3267
3427
  }
3268
- __name(_ts_decorate19, "_ts_decorate");
3269
- function _ts_metadata18(metadataKey, metadataValue) {
3428
+ __name(_ts_decorate20, "_ts_decorate");
3429
+ function _ts_metadata19(metadataKey, metadataValue) {
3270
3430
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3271
3431
  return Reflect.metadata(metadataKey, metadataValue);
3272
3432
  }
3273
3433
  }
3274
- __name(_ts_metadata18, "_ts_metadata");
3275
- function _ts_param17(paramIndex, decorator) {
3434
+ __name(_ts_metadata19, "_ts_metadata");
3435
+ function _ts_param18(paramIndex, decorator) {
3276
3436
  return function(target, key) {
3277
3437
  decorator(target, key, paramIndex);
3278
3438
  };
3279
3439
  }
3280
- __name(_ts_param17, "_ts_param");
3440
+ __name(_ts_param18, "_ts_param");
3281
3441
  var SkillDiscoveryService = class _SkillDiscoveryService {
3282
3442
  static {
3283
3443
  __name(this, "SkillDiscoveryService");
3284
3444
  }
3285
3445
  discovery;
3286
3446
  declared;
3287
- logger = new import_common19.Logger(_SkillDiscoveryService.name);
3447
+ logger = new import_common20.Logger(_SkillDiscoveryService.name);
3288
3448
  constructor(discovery, declared) {
3289
3449
  this.discovery = discovery;
3290
3450
  this.declared = declared;
@@ -3321,11 +3481,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
3321
3481
  return flat === void 0 ? void 0 : () => flat;
3322
3482
  }
3323
3483
  };
3324
- SkillDiscoveryService = _ts_decorate19([
3325
- (0, import_common19.Injectable)(),
3326
- _ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core21.AGENT_SKILL_SOURCES)),
3327
- _ts_metadata18("design:type", Function),
3328
- _ts_metadata18("design:paramtypes", [
3484
+ SkillDiscoveryService = _ts_decorate20([
3485
+ (0, import_common20.Injectable)(),
3486
+ _ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_SKILL_SOURCES)),
3487
+ _ts_metadata19("design:type", Function),
3488
+ _ts_metadata19("design:paramtypes", [
3329
3489
  typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
3330
3490
  Array
3331
3491
  ])
@@ -3355,9 +3515,9 @@ var LedgerQuotaStore = class {
3355
3515
  };
3356
3516
 
3357
3517
  // src/runner/inline-agent-runner.ts
3358
- var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
3359
- var import_common20 = require("@nestjs/common");
3360
- function _ts_decorate20(decorators, target, key, desc) {
3518
+ var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
3519
+ var import_common21 = require("@nestjs/common");
3520
+ function _ts_decorate21(decorators, target, key, desc) {
3361
3521
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3362
3522
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3363
3523
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3370,26 +3530,26 @@ function _ts_decorate20(decorators, target, key, desc) {
3370
3530
  }
3371
3531
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3372
3532
  }
3373
- __name(_ts_decorate20, "_ts_decorate");
3374
- function _ts_metadata19(metadataKey, metadataValue) {
3533
+ __name(_ts_decorate21, "_ts_decorate");
3534
+ function _ts_metadata20(metadataKey, metadataValue) {
3375
3535
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3376
3536
  return Reflect.metadata(metadataKey, metadataValue);
3377
3537
  }
3378
3538
  }
3379
- __name(_ts_metadata19, "_ts_metadata");
3380
- function _ts_param18(paramIndex, decorator) {
3539
+ __name(_ts_metadata20, "_ts_metadata");
3540
+ function _ts_param19(paramIndex, decorator) {
3381
3541
  return function(target, key) {
3382
3542
  decorator(target, key, paramIndex);
3383
3543
  };
3384
3544
  }
3385
- __name(_ts_param18, "_ts_param");
3545
+ __name(_ts_param19, "_ts_param");
3386
3546
  var InlineAgentRunner = class _InlineAgentRunner {
3387
3547
  static {
3388
3548
  __name(this, "InlineAgentRunner");
3389
3549
  }
3390
3550
  factory;
3391
3551
  store;
3392
- logger = new import_common20.Logger(_InlineAgentRunner.name);
3552
+ logger = new import_common21.Logger(_InlineAgentRunner.name);
3393
3553
  pending = /* @__PURE__ */ new Map();
3394
3554
  /**
3395
3555
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -3418,18 +3578,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
3418
3578
  ] : []
3419
3579
  ]
3420
3580
  });
3421
- void (0, import_nestjs_agent_core22.runAgentLoop)({
3581
+ void (0, import_nestjs_agent_core23.runAgentLoop)({
3422
3582
  ...deps,
3423
3583
  day
3424
3584
  }, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
3425
- if (error instanceof import_nestjs_agent_core22.RunCancelledError) {
3585
+ if (error instanceof import_nestjs_agent_core23.RunCancelledError) {
3426
3586
  await this.settleCancelled(runId, input.threadId, deps);
3427
3587
  return;
3428
3588
  }
3429
3589
  const message = error instanceof Error ? error.message : String(error);
3430
- const code = (0, import_nestjs_agent_core22.agentFailureCode)(error);
3590
+ const code = (0, import_nestjs_agent_core23.agentFailureCode)(error);
3431
3591
  this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
3432
- (0, import_nestjs_agent_core22.publishAgentRunFailed)({
3592
+ (0, import_nestjs_agent_core23.publishAgentRunFailed)({
3433
3593
  runId,
3434
3594
  code,
3435
3595
  message
@@ -3478,7 +3638,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3478
3638
  for (const [key, waiter] of this.pending) {
3479
3639
  if (key.startsWith(`${runId}:`)) {
3480
3640
  this.pending.delete(key);
3481
- waiter.reject(new import_nestjs_agent_core22.RunCancelledError());
3641
+ waiter.reject(new import_nestjs_agent_core23.RunCancelledError());
3482
3642
  }
3483
3643
  }
3484
3644
  await Promise.resolve();
@@ -3493,7 +3653,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3493
3653
  this.logger.log(`agent run ${runId} cancelled`);
3494
3654
  await this.store.setActiveStream(threadId, null);
3495
3655
  const writer = await deps.sink.open(runId);
3496
- await writer.write((0, import_nestjs_agent_core22.encodeStreamEvent)({
3656
+ await writer.write((0, import_nestjs_agent_core23.encodeStreamEvent)({
3497
3657
  kind: "cancelled"
3498
3658
  }));
3499
3659
  await writer.end();
@@ -3554,7 +3714,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3554
3714
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3555
3715
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3556
3716
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3557
- parallel: import_nestjs_agent_core22.settleAll,
3717
+ parallel: import_nestjs_agent_core23.settleAll,
3558
3718
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
3559
3719
  runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
3560
3720
  agentName,
@@ -3605,7 +3765,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3605
3765
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3606
3766
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3607
3767
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3608
- parallel: import_nestjs_agent_core22.settleAll,
3768
+ parallel: import_nestjs_agent_core23.settleAll,
3609
3769
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
3610
3770
  runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
3611
3771
  agentName: childName,
@@ -3638,7 +3798,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3638
3798
  }
3639
3799
  }), "startAgent")
3640
3800
  };
3641
- void (0, import_nestjs_agent_core22.runAgentLoop)({
3801
+ void (0, import_nestjs_agent_core23.runAgentLoop)({
3642
3802
  ...deps,
3643
3803
  day
3644
3804
  }, {
@@ -3652,13 +3812,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
3652
3812
  parentRunId,
3653
3813
  deliverTo
3654
3814
  }, hooks).catch(async (error) => {
3655
- const cancelled = error instanceof import_nestjs_agent_core22.RunCancelledError;
3815
+ const cancelled = error instanceof import_nestjs_agent_core23.RunCancelledError;
3656
3816
  const message = error instanceof Error ? error.message : String(error);
3657
3817
  if (!cancelled) {
3658
3818
  this.logger.error(`detached agent run ${runId} failed: ${message}`);
3659
- (0, import_nestjs_agent_core22.publishAgentRunFailed)({
3819
+ (0, import_nestjs_agent_core23.publishAgentRunFailed)({
3660
3820
  runId,
3661
- code: (0, import_nestjs_agent_core22.agentFailureCode)(error),
3821
+ code: (0, import_nestjs_agent_core23.agentFailureCode)(error),
3662
3822
  message
3663
3823
  });
3664
3824
  }
@@ -3666,11 +3826,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
3666
3826
  runId,
3667
3827
  status: cancelled ? "cancelled" : "failed",
3668
3828
  ...cancelled ? {} : {
3669
- errorCode: (0, import_nestjs_agent_core22.agentFailureCode)(error),
3829
+ errorCode: (0, import_nestjs_agent_core23.agentFailureCode)(error),
3670
3830
  errorMessage: message
3671
3831
  }
3672
3832
  });
3673
- await (0, import_nestjs_agent_core22.settleUnsettledDelegation)({
3833
+ await (0, import_nestjs_agent_core23.settleUnsettledDelegation)({
3674
3834
  store: this.store,
3675
3835
  delivery: deliverTo,
3676
3836
  agent: agentName,
@@ -3709,7 +3869,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3709
3869
  awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
3710
3870
  awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
3711
3871
  step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
3712
- parallel: import_nestjs_agent_core22.settleAll,
3872
+ parallel: import_nestjs_agent_core23.settleAll,
3713
3873
  // A child stops when it is cancelled OR when the run a human is actually watching is: the
3714
3874
  // canceller names the top-level run, which is the only id that ever left the server.
3715
3875
  cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
@@ -3744,7 +3904,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
3744
3904
  }), "startAgent")
3745
3905
  };
3746
3906
  try {
3747
- return await (0, import_nestjs_agent_core22.runAgentLoop)({
3907
+ return await (0, import_nestjs_agent_core23.runAgentLoop)({
3748
3908
  ...deps,
3749
3909
  day
3750
3910
  }, {
@@ -3763,19 +3923,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
3763
3923
  }
3764
3924
  }
3765
3925
  };
3766
- InlineAgentRunner = _ts_decorate20([
3767
- (0, import_common20.Injectable)(),
3768
- _ts_param18(0, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_DEPS_FACTORY)),
3769
- _ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_STORE)),
3770
- _ts_metadata19("design:type", Function),
3771
- _ts_metadata19("design:paramtypes", [
3926
+ InlineAgentRunner = _ts_decorate21([
3927
+ (0, import_common21.Injectable)(),
3928
+ _ts_param19(0, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_DEPS_FACTORY)),
3929
+ _ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_STORE)),
3930
+ _ts_metadata20("design:type", Function),
3931
+ _ts_metadata20("design:paramtypes", [
3772
3932
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
3773
3933
  typeof AgentStore === "undefined" ? Object : AgentStore
3774
3934
  ])
3775
3935
  ], InlineAgentRunner);
3776
3936
 
3777
3937
  // src/skills-config.ts
3778
- var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
3938
+ var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
3779
3939
  function declaredSkillProvider(declared) {
3780
3940
  return {
3781
3941
  list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
@@ -3801,7 +3961,7 @@ function resolveSkillsConfig(options, declared) {
3801
3961
  declaredSkillProvider(declared)
3802
3962
  ];
3803
3963
  return {
3804
- provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core23.compositeSkillProvider)(providers),
3964
+ provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core24.compositeSkillProvider)(providers),
3805
3965
  ...options.scopes !== void 0 ? {
3806
3966
  scopes: options.scopes
3807
3967
  } : {},
@@ -3813,7 +3973,7 @@ function resolveSkillsConfig(options, declared) {
3813
3973
  __name(resolveSkillsConfig, "resolveSkillsConfig");
3814
3974
 
3815
3975
  // src/agent.module.ts
3816
- function _ts_decorate21(decorators, target, key, desc) {
3976
+ function _ts_decorate22(decorators, target, key, desc) {
3817
3977
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3818
3978
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3819
3979
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3826,92 +3986,92 @@ function _ts_decorate21(decorators, target, key, desc) {
3826
3986
  }
3827
3987
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3828
3988
  }
3829
- __name(_ts_decorate21, "_ts_decorate");
3989
+ __name(_ts_decorate22, "_ts_decorate");
3830
3990
  var DEFAULT_PATH = "agent";
3831
3991
  function sharedProviders(durable, includeStore) {
3832
3992
  const providers = [
3833
3993
  {
3834
- provide: import_nestjs_agent_core24.AGENT_TOOL_REGISTRY,
3835
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core24.ToolRegistry(), "useFactory")
3994
+ provide: import_nestjs_agent_core25.AGENT_TOOL_REGISTRY,
3995
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core25.ToolRegistry(), "useFactory")
3836
3996
  },
3837
3997
  // Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
3838
3998
  {
3839
- provide: import_nestjs_agent_core24.AGENT_REGISTRY,
3840
- useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core24.AgentRegistry(), "useFactory")
3999
+ provide: import_nestjs_agent_core25.AGENT_REGISTRY,
4000
+ useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core25.AgentRegistry(), "useFactory")
3841
4001
  },
3842
4002
  // A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
3843
4003
  {
3844
- provide: import_nestjs_agent_core24.AGENT_PROMPT_CONTRIBUTORS,
4004
+ provide: import_nestjs_agent_core25.AGENT_PROMPT_CONTRIBUTORS,
3845
4005
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
3846
4006
  },
3847
4007
  // Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
3848
4008
  // read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
3849
4009
  {
3850
- provide: import_nestjs_agent_core24.AGENT_SKILL_SOURCES,
4010
+ provide: import_nestjs_agent_core25.AGENT_SKILL_SOURCES,
3851
4011
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
3852
4012
  },
3853
4013
  {
3854
4014
  // One resolution, shared by the loop's deps and the listing endpoint: a second one would
3855
4015
  // drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
3856
4016
  // host configured none — which is what keeps the turn's checkpoint sequence unchanged.
3857
- provide: import_nestjs_agent_core24.AGENT_SKILLS,
4017
+ provide: import_nestjs_agent_core25.AGENT_SKILLS,
3858
4018
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
3859
4019
  inject: [
3860
- import_nestjs_agent_core24.AGENT_OPTIONS,
3861
- import_nestjs_agent_core24.AGENT_SKILL_SOURCES
4020
+ import_nestjs_agent_core25.AGENT_OPTIONS,
4021
+ import_nestjs_agent_core25.AGENT_SKILL_SOURCES
3862
4022
  ]
3863
4023
  },
3864
4024
  {
3865
4025
  // One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
3866
4026
  // shown what the model was shown, and two resolutions would eventually disagree about that.
3867
- provide: import_nestjs_agent_core24.AGENT_MEMORY,
4027
+ provide: import_nestjs_agent_core25.AGENT_MEMORY,
3868
4028
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
3869
4029
  inject: [
3870
- import_nestjs_agent_core24.AGENT_OPTIONS
4030
+ import_nestjs_agent_core25.AGENT_OPTIONS
3871
4031
  ]
3872
4032
  },
3873
4033
  {
3874
- provide: import_nestjs_agent_core24.AGENT_SINK,
4034
+ provide: import_nestjs_agent_core25.AGENT_SINK,
3875
4035
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
3876
4036
  inject: [
3877
- import_nestjs_agent_core24.AGENT_OPTIONS
4037
+ import_nestjs_agent_core25.AGENT_OPTIONS
3878
4038
  ]
3879
4039
  },
3880
4040
  {
3881
- provide: import_nestjs_agent_core24.AGENT_ROLES_POLICY,
3882
- useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core24.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
4041
+ provide: import_nestjs_agent_core25.AGENT_ROLES_POLICY,
4042
+ useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core25.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
3883
4043
  inject: [
3884
- import_nestjs_agent_core24.AGENT_OPTIONS
4044
+ import_nestjs_agent_core25.AGENT_OPTIONS
3885
4045
  ]
3886
4046
  },
3887
4047
  {
3888
- provide: import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER,
4048
+ provide: import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER,
3889
4049
  useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
3890
4050
  inject: [
3891
- import_nestjs_agent_core24.AGENT_OPTIONS
4051
+ import_nestjs_agent_core25.AGENT_OPTIONS
3892
4052
  ]
3893
4053
  },
3894
4054
  {
3895
- provide: import_nestjs_agent_core24.AGENT_MODEL,
4055
+ provide: import_nestjs_agent_core25.AGENT_MODEL,
3896
4056
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
3897
4057
  inject: [
3898
- import_nestjs_agent_core24.AGENT_OPTIONS
4058
+ import_nestjs_agent_core25.AGENT_OPTIONS
3899
4059
  ]
3900
4060
  },
3901
4061
  {
3902
4062
  // An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
3903
4063
  // store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
3904
4064
  // the loop already writes, so enforcement needs no extra shared state across replicas.
3905
- provide: import_nestjs_agent_core24.AGENT_QUOTA_STORE,
4065
+ provide: import_nestjs_agent_core25.AGENT_QUOTA_STORE,
3906
4066
  useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
3907
4067
  inject: [
3908
- import_nestjs_agent_core24.AGENT_OPTIONS,
3909
- import_nestjs_agent_core24.AGENT_STORE
4068
+ import_nestjs_agent_core25.AGENT_OPTIONS,
4069
+ import_nestjs_agent_core25.AGENT_STORE
3910
4070
  ]
3911
4071
  },
3912
4072
  AgentDepsFactory2,
3913
4073
  {
3914
- provide: import_nestjs_agent_core24.AGENT_DEPS_FACTORY,
4074
+ provide: import_nestjs_agent_core25.AGENT_DEPS_FACTORY,
3915
4075
  useExisting: AgentDepsFactory2
3916
4076
  },
3917
4077
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -3925,22 +4085,22 @@ function sharedProviders(durable, includeStore) {
3925
4085
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
3926
4086
  AgentApprovalPortAdapter,
3927
4087
  {
3928
- provide: import_nestjs_agent_core24.AGENT_APPROVAL_PORT,
4088
+ provide: import_nestjs_agent_core25.AGENT_APPROVAL_PORT,
3929
4089
  useExisting: AgentApprovalPortAdapter
3930
4090
  }
3931
4091
  ];
3932
4092
  if (includeStore) {
3933
4093
  providers.push({
3934
- provide: import_nestjs_agent_core24.AGENT_STORE,
4094
+ provide: import_nestjs_agent_core25.AGENT_STORE,
3935
4095
  useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
3936
4096
  inject: [
3937
- import_nestjs_agent_core24.AGENT_OPTIONS
4097
+ import_nestjs_agent_core25.AGENT_OPTIONS
3938
4098
  ]
3939
4099
  });
3940
4100
  }
3941
4101
  if (durable) {
3942
4102
  providers.push({
3943
- provide: import_nestjs_agent_core24.AGENT_RUNNER,
4103
+ provide: import_nestjs_agent_core25.AGENT_RUNNER,
3944
4104
  useFactory: /* @__PURE__ */ __name((durableRunner) => {
3945
4105
  if (durableRunner === void 0) {
3946
4106
  throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
@@ -3949,14 +4109,14 @@ function sharedProviders(durable, includeStore) {
3949
4109
  }, "useFactory"),
3950
4110
  inject: [
3951
4111
  {
3952
- token: import_nestjs_agent_core24.AGENT_DURABLE_RUNNER,
4112
+ token: import_nestjs_agent_core25.AGENT_DURABLE_RUNNER,
3953
4113
  optional: true
3954
4114
  }
3955
4115
  ]
3956
4116
  });
3957
4117
  } else {
3958
4118
  providers.push({
3959
- provide: import_nestjs_agent_core24.AGENT_RUNNER,
4119
+ provide: import_nestjs_agent_core25.AGENT_RUNNER,
3960
4120
  useExisting: InlineAgentRunner
3961
4121
  });
3962
4122
  }
@@ -3965,25 +4125,25 @@ function sharedProviders(durable, includeStore) {
3965
4125
  __name(sharedProviders, "sharedProviders");
3966
4126
  function exportsFor(includeStore) {
3967
4127
  return [
3968
- import_nestjs_agent_core24.AGENT_OPTIONS,
3969
- import_nestjs_agent_core24.AGENT_TOOL_REGISTRY,
3970
- import_nestjs_agent_core24.AGENT_REGISTRY,
3971
- import_nestjs_agent_core24.AGENT_SINK,
3972
- import_nestjs_agent_core24.AGENT_ROLES_POLICY,
3973
- import_nestjs_agent_core24.AGENT_ACTOR_RESOLVER,
3974
- import_nestjs_agent_core24.AGENT_MODEL,
4128
+ import_nestjs_agent_core25.AGENT_OPTIONS,
4129
+ import_nestjs_agent_core25.AGENT_TOOL_REGISTRY,
4130
+ import_nestjs_agent_core25.AGENT_REGISTRY,
4131
+ import_nestjs_agent_core25.AGENT_SINK,
4132
+ import_nestjs_agent_core25.AGENT_ROLES_POLICY,
4133
+ import_nestjs_agent_core25.AGENT_ACTOR_RESOLVER,
4134
+ import_nestjs_agent_core25.AGENT_MODEL,
3975
4135
  ...includeStore ? [
3976
- import_nestjs_agent_core24.AGENT_STORE
4136
+ import_nestjs_agent_core25.AGENT_STORE
3977
4137
  ] : [],
3978
- import_nestjs_agent_core24.AGENT_QUOTA_STORE,
3979
- import_nestjs_agent_core24.AGENT_PROMPT_CONTRIBUTORS,
3980
- import_nestjs_agent_core24.AGENT_SKILLS,
3981
- import_nestjs_agent_core24.AGENT_MEMORY,
3982
- import_nestjs_agent_core24.AGENT_DEPS_FACTORY,
4138
+ import_nestjs_agent_core25.AGENT_QUOTA_STORE,
4139
+ import_nestjs_agent_core25.AGENT_PROMPT_CONTRIBUTORS,
4140
+ import_nestjs_agent_core25.AGENT_SKILLS,
4141
+ import_nestjs_agent_core25.AGENT_MEMORY,
4142
+ import_nestjs_agent_core25.AGENT_DEPS_FACTORY,
3983
4143
  AgentDepsFactory2,
3984
4144
  AgentService,
3985
4145
  InlineAgentRunner,
3986
- import_nestjs_agent_core24.AGENT_APPROVAL_PORT
4146
+ import_nestjs_agent_core25.AGENT_APPROVAL_PORT
3987
4147
  ];
3988
4148
  }
3989
4149
  __name(exportsFor, "exportsFor");
@@ -3995,7 +4155,8 @@ var BASE_CONTROLLERS = [
3995
4155
  AgentsController,
3996
4156
  SkillsController,
3997
4157
  MemoriesController,
3998
- ToolsController
4158
+ ToolsController,
4159
+ MessagesController
3999
4160
  ];
4000
4161
  var GUARDABLE_CONTROLLERS = [
4001
4162
  ...BASE_CONTROLLERS,
@@ -4053,7 +4214,7 @@ var AgentModule = class _AgentModule {
4053
4214
  controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
4054
4215
  providers: [
4055
4216
  {
4056
- provide: import_nestjs_agent_core24.AGENT_OPTIONS,
4217
+ provide: import_nestjs_agent_core25.AGENT_OPTIONS,
4057
4218
  useValue: options
4058
4219
  },
4059
4220
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -4077,7 +4238,7 @@ var AgentModule = class _AgentModule {
4077
4238
  controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
4078
4239
  providers: [
4079
4240
  {
4080
- provide: import_nestjs_agent_core24.AGENT_OPTIONS,
4241
+ provide: import_nestjs_agent_core25.AGENT_OPTIONS,
4081
4242
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
4082
4243
  // authoritative on the async config object (they decided the actual wiring above), and
4083
4244
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -4098,9 +4259,9 @@ var AgentModule = class _AgentModule {
4098
4259
  };
4099
4260
  }
4100
4261
  };
4101
- AgentModule = _ts_decorate21([
4102
- (0, import_common21.Global)(),
4103
- (0, import_common21.Module)({})
4262
+ AgentModule = _ts_decorate22([
4263
+ (0, import_common22.Global)(),
4264
+ (0, import_common22.Module)({})
4104
4265
  ], AgentModule);
4105
4266
 
4106
4267
  // src/durable/agent-durable.ts