@dudousxd/nestjs-agent 0.4.1 → 0.5.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.
@@ -2,10 +2,10 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/durable/agent-run.workflow.ts
5
- import { AGENT_DEPS_FACTORY, AGENT_STORE, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
5
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE, QuotaExceededError, publishAgentRunFailed, runAgentLoop } from "@dudousxd/nestjs-agent-core";
6
6
  import { Workflow } from "@dudousxd/nestjs-durable";
7
7
  import { ContinueAsNew, WorkflowSuspended } from "@dudousxd/nestjs-durable-core";
8
- import { Inject, Injectable } from "@nestjs/common";
8
+ import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
9
9
 
10
10
  // src/agent-deps.ts
11
11
  function utcDay(date = /* @__PURE__ */ new Date()) {
@@ -23,7 +23,10 @@ function childSinkWriter(writer) {
23
23
  }
24
24
  __name(childSinkWriter, "childSinkWriter");
25
25
 
26
- // src/durable/agent-run.workflow.ts
26
+ // src/durable/agent-run.steps.ts
27
+ import { AGENT_DEPS_FACTORY, withToolTimeout } from "@dudousxd/nestjs-agent-core";
28
+ import { Step } from "@dudousxd/nestjs-durable";
29
+ import { Inject, Injectable } from "@nestjs/common";
27
30
  function _ts_decorate(decorators, target, key, desc) {
28
31
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
32
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -41,15 +44,107 @@ function _ts_param(paramIndex, decorator) {
41
44
  };
42
45
  }
43
46
  __name(_ts_param, "_ts_param");
47
+ var AgentRunSteps = class {
48
+ static {
49
+ __name(this, "AgentRunSteps");
50
+ }
51
+ factory;
52
+ constructor(factory) {
53
+ this.factory = factory;
54
+ }
55
+ /**
56
+ * Retryable: every side effect (persist/quota/stream markers) happens loop-side under
57
+ * `hooks.step`, so a durable retry only re-runs the model call and re-streams its tokens — never
58
+ * double-writes. NEVER call `writer.end()`/`fail()` here: the workflow owns the stream's lifecycle,
59
+ * across however many turns/retries it takes.
60
+ */
61
+ async llm(input) {
62
+ const deps = this.factory.forAgent(input.agentName);
63
+ const tools = await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, deps.toolAllowList);
64
+ const opened = await deps.sink.open(input.sinkRunId);
65
+ const writer = input.childSink ? childSinkWriter(opened) : opened;
66
+ return deps.model.runTurn({
67
+ system: input.system,
68
+ messages: input.messages,
69
+ tools,
70
+ sink: writer
71
+ });
72
+ }
73
+ /**
74
+ * No retries — a tool may not be idempotent (a bare `@Step()` carries none, unlike `llm` above).
75
+ * The timeout is applied HERE, handler-side, via `withToolTimeout` — never as a durable dispatch
76
+ * `timeoutMs`, which bounds engine liveness (retryable) rather than the tool's own business outcome.
77
+ */
78
+ async tool(input) {
79
+ const deps = this.factory.forAgent(input.ctx.agentName);
80
+ const ctx = {
81
+ ...input.ctx
82
+ };
83
+ const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
84
+ return input.timeoutMs !== void 0 ? withToolTimeout(invocation, input.timeoutMs, input.toolName) : invocation;
85
+ }
86
+ };
87
+ _ts_decorate([
88
+ Step({
89
+ retries: 3
90
+ }),
91
+ _ts_metadata("design:type", Function),
92
+ _ts_metadata("design:paramtypes", [
93
+ typeof DispatchedLlmInput === "undefined" ? Object : DispatchedLlmInput
94
+ ]),
95
+ _ts_metadata("design:returntype", Promise)
96
+ ], AgentRunSteps.prototype, "llm", null);
97
+ _ts_decorate([
98
+ Step(),
99
+ _ts_metadata("design:type", Function),
100
+ _ts_metadata("design:paramtypes", [
101
+ typeof ToolStepEnvelope === "undefined" ? Object : ToolStepEnvelope
102
+ ]),
103
+ _ts_metadata("design:returntype", Promise)
104
+ ], AgentRunSteps.prototype, "tool", null);
105
+ AgentRunSteps = _ts_decorate([
106
+ Injectable(),
107
+ _ts_param(0, Inject(AGENT_DEPS_FACTORY)),
108
+ _ts_metadata("design:type", Function),
109
+ _ts_metadata("design:paramtypes", [
110
+ typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
111
+ ])
112
+ ], AgentRunSteps);
113
+
114
+ // src/durable/dispatched-steps.token.ts
115
+ var AGENT_DISPATCHED_STEPS = Symbol.for("@dudousxd/nestjs-agent:dispatched-steps");
116
+
117
+ // src/durable/agent-run.workflow.ts
118
+ function _ts_decorate2(decorators, target, key, desc) {
119
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
120
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
121
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
122
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
123
+ }
124
+ __name(_ts_decorate2, "_ts_decorate");
125
+ function _ts_metadata2(k, v) {
126
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
127
+ }
128
+ __name(_ts_metadata2, "_ts_metadata");
129
+ function _ts_param2(paramIndex, decorator) {
130
+ return function(target, key) {
131
+ decorator(target, key, paramIndex);
132
+ };
133
+ }
134
+ __name(_ts_param2, "_ts_param");
44
135
  var AgentRunWorkflow = class _AgentRunWorkflow {
45
136
  static {
46
137
  __name(this, "AgentRunWorkflow");
47
138
  }
48
139
  factory;
49
140
  store;
50
- constructor(factory, store) {
141
+ steps;
142
+ dispatchedSteps;
143
+ constructor(factory, store, steps, dispatchedSteps) {
51
144
  this.factory = factory;
52
145
  this.store = store;
146
+ this.steps = steps;
147
+ this.dispatchedSteps = dispatchedSteps;
53
148
  }
54
149
  async run(ctx, input) {
55
150
  const day = input.day ?? utcDay();
@@ -64,6 +159,8 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
64
159
  openSink: /* @__PURE__ */ __name(async () => input.sinkRunId !== void 0 ? childSinkWriter(await deps.sink.open(sinkRunId)) : deps.sink.open(ctx.runId), "openSink"),
65
160
  awaitApproval: /* @__PURE__ */ __name((call) => ctx.waitForSignal(`tool:${ctx.runId}:${call.id}`), "awaitApproval"),
66
161
  step: /* @__PURE__ */ __name((name, fn) => ctx.localStep(name, fn), "step"),
162
+ // Dispatched-step suspends must escape the loop's tool catch — control flow, not a tool failure.
163
+ isControlFlowError: /* @__PURE__ */ __name((error) => error instanceof WorkflowSuspended || error instanceof ContinueAsNew, "isControlFlowError"),
67
164
  runAgent: /* @__PURE__ */ __name(async (agentName, task) => {
68
165
  const subThreadId = await ctx.localStep(`subthread:${agentName}`, async () => {
69
166
  const thread = await this.store.createThread({
@@ -81,7 +178,20 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
81
178
  delegationDepth: (input.delegationDepth ?? 0) + 1,
82
179
  sinkRunId
83
180
  });
84
- }, "runAgent")
181
+ }, "runAgent"),
182
+ // Routes the two long steps through AgentRunSteps as engine-dispatched `ctx.step`s instead of
183
+ // `ctx.localStep`s, so a turn isn't pinned to this workflow worker for the model call or a tool
184
+ // execution. `sinkRunId`/`childSink` are sink routing this workflow already resolved above —
185
+ // core's dispatchLlm signature stays sink-topology-agnostic, so we add them here, not in core.
186
+ ...this.dispatchedSteps ? {
187
+ dispatchLlm: /* @__PURE__ */ __name((_index, envelope) => ctx.step(this.steps.llm, {
188
+ ...envelope,
189
+ runId: ctx.runId,
190
+ sinkRunId,
191
+ childSink: input.sinkRunId !== void 0
192
+ }), "dispatchLlm"),
193
+ dispatchTool: /* @__PURE__ */ __name((_call, envelope) => ctx.step(this.steps.tool, envelope), "dispatchTool")
194
+ } : {}
85
195
  };
86
196
  try {
87
197
  const result = await runAgentLoop({
@@ -101,6 +211,12 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
101
211
  code,
102
212
  message
103
213
  });
214
+ await ctx.localStep("persist:run:fail", () => this.store.recordRunEnd?.({
215
+ runId: ctx.runId,
216
+ status: "failed",
217
+ errorCode: code,
218
+ errorMessage: message
219
+ }) ?? Promise.resolve());
104
220
  await ctx.localStep("deactivate", () => this.store.setActiveStream(input.threadId, null));
105
221
  const writer = await hooks.openSink();
106
222
  await writer.fail({
@@ -111,18 +227,21 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
111
227
  }
112
228
  }
113
229
  };
114
- AgentRunWorkflow = _ts_decorate([
115
- Injectable(),
230
+ AgentRunWorkflow = _ts_decorate2([
231
+ Injectable2(),
116
232
  Workflow({
117
233
  name: "agent.run",
118
234
  version: "1"
119
235
  }),
120
- _ts_param(0, Inject(AGENT_DEPS_FACTORY)),
121
- _ts_param(1, Inject(AGENT_STORE)),
122
- _ts_metadata("design:type", Function),
123
- _ts_metadata("design:paramtypes", [
236
+ _ts_param2(0, Inject2(AGENT_DEPS_FACTORY2)),
237
+ _ts_param2(1, Inject2(AGENT_STORE)),
238
+ _ts_param2(3, Inject2(AGENT_DISPATCHED_STEPS)),
239
+ _ts_metadata2("design:type", Function),
240
+ _ts_metadata2("design:paramtypes", [
124
241
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
125
- typeof AgentStore === "undefined" ? Object : AgentStore
242
+ typeof AgentStore === "undefined" ? Object : AgentStore,
243
+ typeof AgentRunSteps === "undefined" ? Object : AgentRunSteps,
244
+ Boolean
126
245
  ])
127
246
  ], AgentRunWorkflow);
128
247
 
@@ -130,18 +249,18 @@ AgentRunWorkflow = _ts_decorate([
130
249
  import { randomUUID } from "node:crypto";
131
250
  import { WorkflowService } from "@dudousxd/nestjs-durable";
132
251
  import { WorkflowSuspended as WorkflowSuspended2 } from "@dudousxd/nestjs-durable-core";
133
- import { Injectable as Injectable2 } from "@nestjs/common";
134
- function _ts_decorate2(decorators, target, key, desc) {
252
+ import { Injectable as Injectable3 } from "@nestjs/common";
253
+ function _ts_decorate3(decorators, target, key, desc) {
135
254
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
136
255
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
137
256
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
138
257
  return c > 3 && r && Object.defineProperty(target, key, r), r;
139
258
  }
140
- __name(_ts_decorate2, "_ts_decorate");
141
- function _ts_metadata2(k, v) {
259
+ __name(_ts_decorate3, "_ts_decorate");
260
+ function _ts_metadata3(k, v) {
142
261
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
143
262
  }
144
- __name(_ts_metadata2, "_ts_metadata");
263
+ __name(_ts_metadata3, "_ts_metadata");
145
264
  var DurableAgentRunner = class {
146
265
  static {
147
266
  __name(this, "DurableAgentRunner");
@@ -174,24 +293,95 @@ var DurableAgentRunner = class {
174
293
  await Promise.resolve();
175
294
  }
176
295
  };
177
- DurableAgentRunner = _ts_decorate2([
178
- Injectable2(),
179
- _ts_metadata2("design:type", Function),
180
- _ts_metadata2("design:paramtypes", [
296
+ DurableAgentRunner = _ts_decorate3([
297
+ Injectable3(),
298
+ _ts_metadata3("design:type", Function),
299
+ _ts_metadata3("design:paramtypes", [
181
300
  typeof WorkflowService === "undefined" ? Object : WorkflowService
182
301
  ])
183
302
  ], DurableAgentRunner);
184
303
 
185
304
  // src/durable/agent-durable.module.ts
186
- import { AGENT_DURABLE_RUNNER } from "@dudousxd/nestjs-agent-core";
187
- import { Global, Module } from "@nestjs/common";
188
- function _ts_decorate3(decorators, target, key, desc) {
305
+ import { AGENT_DURABLE_RUNNER, AGENT_OPTIONS, AGENT_SINK } from "@dudousxd/nestjs-agent-core";
306
+ import { Global, Logger, Module } from "@nestjs/common";
307
+
308
+ // src/in-process-sink.ts
309
+ import { AgentStreamError } from "@dudousxd/nestjs-agent-core";
310
+ var InProcessTokenStreamSink = class {
311
+ static {
312
+ __name(this, "InProcessTokenStreamSink");
313
+ }
314
+ runs = /* @__PURE__ */ new Map();
315
+ buffer(runId) {
316
+ let buf = this.runs.get(runId);
317
+ if (buf === void 0) {
318
+ buf = {
319
+ chunks: [],
320
+ ended: false,
321
+ notify: /* @__PURE__ */ new Set()
322
+ };
323
+ this.runs.set(runId, buf);
324
+ }
325
+ return buf;
326
+ }
327
+ wake(buf) {
328
+ for (const resolve of buf.notify) {
329
+ resolve();
330
+ }
331
+ buf.notify.clear();
332
+ }
333
+ open(runId) {
334
+ const buf = this.buffer(runId);
335
+ return {
336
+ write: /* @__PURE__ */ __name((chunk) => {
337
+ buf.chunks.push(chunk);
338
+ this.wake(buf);
339
+ }, "write"),
340
+ end: /* @__PURE__ */ __name(() => {
341
+ buf.ended = true;
342
+ this.wake(buf);
343
+ }, "end"),
344
+ fail: /* @__PURE__ */ __name((error) => {
345
+ buf.failure = error;
346
+ buf.ended = true;
347
+ this.wake(buf);
348
+ }, "fail")
349
+ };
350
+ }
351
+ async *subscribe(runId) {
352
+ const buf = this.buffer(runId);
353
+ let index = 0;
354
+ while (true) {
355
+ while (index < buf.chunks.length) {
356
+ const chunk = buf.chunks[index];
357
+ index += 1;
358
+ if (chunk !== void 0) {
359
+ yield chunk;
360
+ }
361
+ }
362
+ if (buf.ended) {
363
+ if (buf.failure !== void 0) {
364
+ throw new AgentStreamError(buf.failure);
365
+ }
366
+ return;
367
+ }
368
+ await new Promise((resolve) => buf.notify.add(resolve));
369
+ }
370
+ }
371
+ close(runId) {
372
+ this.runs.delete(runId);
373
+ }
374
+ };
375
+
376
+ // src/durable/agent-durable.module.ts
377
+ function _ts_decorate4(decorators, target, key, desc) {
189
378
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
190
379
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
191
380
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
192
381
  return c > 3 && r && Object.defineProperty(target, key, r), r;
193
382
  }
194
- __name(_ts_decorate3, "_ts_decorate");
383
+ __name(_ts_decorate4, "_ts_decorate");
384
+ var logger = new Logger("AgentDurableModule");
195
385
  var AgentDurableModule = class _AgentDurableModule {
196
386
  static {
197
387
  __name(this, "AgentDurableModule");
@@ -208,50 +398,67 @@ var AgentDurableModule = class _AgentDurableModule {
208
398
  };
209
399
  }
210
400
  };
211
- AgentDurableModule = _ts_decorate3([
401
+ AgentDurableModule = _ts_decorate4([
212
402
  Global(),
213
403
  Module({
214
404
  providers: [
215
405
  AgentRunWorkflow,
406
+ AgentRunSteps,
216
407
  DurableAgentRunner,
217
408
  {
218
409
  provide: AGENT_DURABLE_RUNNER,
219
410
  useExisting: DurableAgentRunner
411
+ },
412
+ {
413
+ provide: AGENT_DISPATCHED_STEPS,
414
+ useFactory: /* @__PURE__ */ __name((options, sink) => {
415
+ const enabled = options.dispatchedSteps ?? false;
416
+ if (enabled && sink instanceof InProcessTokenStreamSink) {
417
+ logger.warn("dispatchedSteps is enabled with the default InProcessTokenStreamSink, which only buffers tokens in-process. A dispatched `llm` step served by a different worker cannot stream into this buffer. Wire a cross-process TokenStreamSink (e.g. a Redis pub/sub sink) via AgentModule.forRoot({ sink }) before running multi-pod.");
418
+ }
419
+ return enabled;
420
+ }, "useFactory"),
421
+ inject: [
422
+ AGENT_OPTIONS,
423
+ AGENT_SINK
424
+ ]
220
425
  }
221
426
  ],
222
427
  exports: [
223
428
  AGENT_DURABLE_RUNNER,
224
- AgentRunWorkflow
429
+ AgentRunWorkflow,
430
+ AgentRunSteps,
431
+ AGENT_DISPATCHED_STEPS
225
432
  ]
226
433
  })
227
434
  ], AgentDurableModule);
228
435
 
229
436
  // src/agent.module.ts
230
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
437
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, AGENT_MODEL as AGENT_MODEL2, AGENT_OPTIONS as AGENT_OPTIONS5, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE3, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry5, DefaultRolesPolicy, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
231
438
  import { Global as Global2, Module as Module2 } from "@nestjs/common";
232
439
  import { DiscoveryModule, RouterModule } from "@nestjs/core";
233
440
 
234
441
  // src/agent-deps.factory.ts
235
- import { AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_STORE as AGENT_STORE2, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
236
- import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
237
- import { Inject as Inject2, Injectable as Injectable3, Optional } from "@nestjs/common";
238
- function _ts_decorate4(decorators, target, key, desc) {
442
+ import { AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE2, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2 } from "@dudousxd/nestjs-agent-core";
443
+ import { AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
444
+ import { Inject as Inject3, Injectable as Injectable4, Optional } from "@nestjs/common";
445
+ function _ts_decorate5(decorators, target, key, desc) {
239
446
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
240
447
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
241
448
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
242
449
  return c > 3 && r && Object.defineProperty(target, key, r), r;
243
450
  }
244
- __name(_ts_decorate4, "_ts_decorate");
245
- function _ts_metadata3(k, v) {
451
+ __name(_ts_decorate5, "_ts_decorate");
452
+ function _ts_metadata4(k, v) {
246
453
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
247
454
  }
248
- __name(_ts_metadata3, "_ts_metadata");
249
- function _ts_param2(paramIndex, decorator) {
455
+ __name(_ts_metadata4, "_ts_metadata");
456
+ function _ts_param3(paramIndex, decorator) {
250
457
  return function(target, key) {
251
458
  decorator(target, key, paramIndex);
252
459
  };
253
460
  }
254
- __name(_ts_param2, "_ts_param");
461
+ __name(_ts_param3, "_ts_param");
255
462
  function delegateToolName(target) {
256
463
  return `ask_${target.replace(/[^a-zA-Z0-9]+/g, "_")}`;
257
464
  }
@@ -359,21 +566,21 @@ var AgentDepsFactory2 = class {
359
566
  return void 0;
360
567
  }
361
568
  };
362
- AgentDepsFactory2 = _ts_decorate4([
363
- Injectable3(),
364
- _ts_param2(0, Inject2(AGENT_OPTIONS)),
365
- _ts_param2(1, Inject2(AGENT_MODEL)),
366
- _ts_param2(2, Inject2(AGENT_STORE2)),
367
- _ts_param2(3, Inject2(AGENT_SINK)),
368
- _ts_param2(4, Inject2(AGENT_ROLES_POLICY)),
369
- _ts_param2(5, Inject2(AGENT_TOOL_REGISTRY)),
370
- _ts_param2(6, Inject2(AGENT_REGISTRY)),
371
- _ts_param2(7, Inject2(AGENT_PROMPT_CONTRIBUTORS)),
372
- _ts_param2(8, Inject2(AGENT_QUOTA_STORE)),
373
- _ts_param2(9, Optional()),
374
- _ts_param2(9, Inject2(AGENT_PRICING_STORE)),
375
- _ts_metadata3("design:type", Function),
376
- _ts_metadata3("design:paramtypes", [
569
+ AgentDepsFactory2 = _ts_decorate5([
570
+ Injectable4(),
571
+ _ts_param3(0, Inject3(AGENT_OPTIONS2)),
572
+ _ts_param3(1, Inject3(AGENT_MODEL)),
573
+ _ts_param3(2, Inject3(AGENT_STORE2)),
574
+ _ts_param3(3, Inject3(AGENT_SINK2)),
575
+ _ts_param3(4, Inject3(AGENT_ROLES_POLICY)),
576
+ _ts_param3(5, Inject3(AGENT_TOOL_REGISTRY)),
577
+ _ts_param3(6, Inject3(AGENT_REGISTRY)),
578
+ _ts_param3(7, Inject3(AGENT_PROMPT_CONTRIBUTORS)),
579
+ _ts_param3(8, Inject3(AGENT_QUOTA_STORE)),
580
+ _ts_param3(9, Optional()),
581
+ _ts_param3(9, Inject3(AGENT_PRICING_STORE)),
582
+ _ts_metadata4("design:type", Function),
583
+ _ts_metadata4("design:paramtypes", [
377
584
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
378
585
  typeof ModelProvider === "undefined" ? Object : ModelProvider,
379
586
  typeof AgentStore === "undefined" ? Object : AgentStore,
@@ -388,25 +595,25 @@ AgentDepsFactory2 = _ts_decorate4([
388
595
  ], AgentDepsFactory2);
389
596
 
390
597
  // src/agent.service.ts
391
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE3 } from "@dudousxd/nestjs-agent-core";
392
- import { BadRequestException, ForbiddenException, Inject as Inject3, Injectable as Injectable4, NotFoundException, NotImplementedException } from "@nestjs/common";
393
- function _ts_decorate5(decorators, target, key, desc) {
598
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_QUOTA_STORE as AGENT_QUOTA_STORE2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE3 } from "@dudousxd/nestjs-agent-core";
599
+ import { BadRequestException, ForbiddenException, Inject as Inject4, Injectable as Injectable5, NotFoundException, NotImplementedException } from "@nestjs/common";
600
+ function _ts_decorate6(decorators, target, key, desc) {
394
601
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
395
602
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
396
603
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
397
604
  return c > 3 && r && Object.defineProperty(target, key, r), r;
398
605
  }
399
- __name(_ts_decorate5, "_ts_decorate");
400
- function _ts_metadata4(k, v) {
606
+ __name(_ts_decorate6, "_ts_decorate");
607
+ function _ts_metadata5(k, v) {
401
608
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
402
609
  }
403
- __name(_ts_metadata4, "_ts_metadata");
404
- function _ts_param3(paramIndex, decorator) {
610
+ __name(_ts_metadata5, "_ts_metadata");
611
+ function _ts_param4(paramIndex, decorator) {
405
612
  return function(target, key) {
406
613
  decorator(target, key, paramIndex);
407
614
  };
408
615
  }
409
- __name(_ts_param3, "_ts_param");
616
+ __name(_ts_param4, "_ts_param");
410
617
  var AgentService = class {
411
618
  static {
412
619
  __name(this, "AgentService");
@@ -656,14 +863,14 @@ var AgentService = class {
656
863
  }
657
864
  }
658
865
  };
659
- AgentService = _ts_decorate5([
660
- Injectable4(),
661
- _ts_param3(0, Inject3(AGENT_RUNNER)),
662
- _ts_param3(1, Inject3(AGENT_STORE3)),
663
- _ts_param3(2, Inject3(AGENT_DEPS_FACTORY2)),
664
- _ts_param3(3, Inject3(AGENT_QUOTA_STORE2)),
665
- _ts_metadata4("design:type", Function),
666
- _ts_metadata4("design:paramtypes", [
866
+ AgentService = _ts_decorate6([
867
+ Injectable5(),
868
+ _ts_param4(0, Inject4(AGENT_RUNNER)),
869
+ _ts_param4(1, Inject4(AGENT_STORE3)),
870
+ _ts_param4(2, Inject4(AGENT_DEPS_FACTORY3)),
871
+ _ts_param4(3, Inject4(AGENT_QUOTA_STORE2)),
872
+ _ts_metadata5("design:type", Function),
873
+ _ts_metadata5("design:paramtypes", [
667
874
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
668
875
  typeof AgentStore === "undefined" ? Object : AgentStore,
669
876
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
@@ -672,25 +879,25 @@ AgentService = _ts_decorate5([
672
879
  ], AgentService);
673
880
 
674
881
  // src/controller/agents.controller.ts
675
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
676
- import { Controller, Get, Inject as Inject4 } from "@nestjs/common";
677
- function _ts_decorate6(decorators, target, key, desc) {
882
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
883
+ import { Controller, Get, Inject as Inject5 } from "@nestjs/common";
884
+ function _ts_decorate7(decorators, target, key, desc) {
678
885
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
679
886
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
680
887
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
681
888
  return c > 3 && r && Object.defineProperty(target, key, r), r;
682
889
  }
683
- __name(_ts_decorate6, "_ts_decorate");
684
- function _ts_metadata5(k, v) {
890
+ __name(_ts_decorate7, "_ts_decorate");
891
+ function _ts_metadata6(k, v) {
685
892
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
686
893
  }
687
- __name(_ts_metadata5, "_ts_metadata");
688
- function _ts_param4(paramIndex, decorator) {
894
+ __name(_ts_metadata6, "_ts_metadata");
895
+ function _ts_param5(paramIndex, decorator) {
689
896
  return function(target, key) {
690
897
  decorator(target, key, paramIndex);
691
898
  };
692
899
  }
693
- __name(_ts_param4, "_ts_param");
900
+ __name(_ts_param5, "_ts_param");
694
901
  var AgentsController = class {
695
902
  static {
696
903
  __name(this, "AgentsController");
@@ -712,44 +919,44 @@ var AgentsController = class {
712
919
  }));
713
920
  }
714
921
  };
715
- _ts_decorate6([
922
+ _ts_decorate7([
716
923
  Get(),
717
- _ts_metadata5("design:type", Function),
718
- _ts_metadata5("design:paramtypes", []),
719
- _ts_metadata5("design:returntype", Array)
924
+ _ts_metadata6("design:type", Function),
925
+ _ts_metadata6("design:paramtypes", []),
926
+ _ts_metadata6("design:returntype", Array)
720
927
  ], AgentsController.prototype, "list", null);
721
- AgentsController = _ts_decorate6([
928
+ AgentsController = _ts_decorate7([
722
929
  Controller("agents"),
723
- _ts_param4(0, Inject4(AGENT_REGISTRY2)),
724
- _ts_param4(1, Inject4(AGENT_DEPS_FACTORY3)),
725
- _ts_metadata5("design:type", Function),
726
- _ts_metadata5("design:paramtypes", [
930
+ _ts_param5(0, Inject5(AGENT_REGISTRY2)),
931
+ _ts_param5(1, Inject5(AGENT_DEPS_FACTORY4)),
932
+ _ts_metadata6("design:type", Function),
933
+ _ts_metadata6("design:paramtypes", [
727
934
  typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
728
935
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
729
936
  ])
730
937
  ], AgentsController);
731
938
 
732
939
  // src/controller/attachments.controller.ts
733
- import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS2 } from "@dudousxd/nestjs-agent-core";
734
- import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as Inject5, NotImplementedException as NotImplementedException2, Optional as Optional2, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
940
+ import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING, AGENT_OPTIONS as AGENT_OPTIONS3 } from "@dudousxd/nestjs-agent-core";
941
+ import { BadRequestException as BadRequestException2, Controller as Controller2, Inject as Inject6, NotImplementedException as NotImplementedException2, Optional as Optional2, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
735
942
  import { FileInterceptor } from "@nestjs/platform-express";
736
- function _ts_decorate7(decorators, target, key, desc) {
943
+ function _ts_decorate8(decorators, target, key, desc) {
737
944
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
738
945
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
739
946
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
740
947
  return c > 3 && r && Object.defineProperty(target, key, r), r;
741
948
  }
742
- __name(_ts_decorate7, "_ts_decorate");
743
- function _ts_metadata6(k, v) {
949
+ __name(_ts_decorate8, "_ts_decorate");
950
+ function _ts_metadata7(k, v) {
744
951
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
745
952
  }
746
- __name(_ts_metadata6, "_ts_metadata");
747
- function _ts_param5(paramIndex, decorator) {
953
+ __name(_ts_metadata7, "_ts_metadata");
954
+ function _ts_param6(paramIndex, decorator) {
748
955
  return function(target, key) {
749
956
  decorator(target, key, paramIndex);
750
957
  };
751
958
  }
752
- __name(_ts_param5, "_ts_param");
959
+ __name(_ts_param6, "_ts_param");
753
960
  var DEFAULT_MAX_ATTACHMENT_BYTES = 20 * 1024 * 1024;
754
961
  var DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES = [
755
962
  "image/png",
@@ -808,26 +1015,26 @@ var AttachmentsController = class {
808
1015
  });
809
1016
  }
810
1017
  };
811
- _ts_decorate7([
1018
+ _ts_decorate8([
812
1019
  Post(),
813
1020
  UseInterceptors(FileInterceptor("file")),
814
- _ts_param5(0, Req()),
815
- _ts_param5(1, UploadedFile()),
816
- _ts_metadata6("design:type", Function),
817
- _ts_metadata6("design:paramtypes", [
1021
+ _ts_param6(0, Req()),
1022
+ _ts_param6(1, UploadedFile()),
1023
+ _ts_metadata7("design:type", Function),
1024
+ _ts_metadata7("design:paramtypes", [
818
1025
  typeof Request === "undefined" ? Object : Request,
819
1026
  Object
820
1027
  ]),
821
- _ts_metadata6("design:returntype", Promise)
1028
+ _ts_metadata7("design:returntype", Promise)
822
1029
  ], AttachmentsController.prototype, "upload", null);
823
- AttachmentsController = _ts_decorate7([
1030
+ AttachmentsController = _ts_decorate8([
824
1031
  Controller2("attachments"),
825
- _ts_param5(0, Inject5(AGENT_OPTIONS2)),
826
- _ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER)),
827
- _ts_param5(2, Optional2()),
828
- _ts_param5(2, Inject5(AGENT_ATTACHMENT_STAGING)),
829
- _ts_metadata6("design:type", Function),
830
- _ts_metadata6("design:paramtypes", [
1032
+ _ts_param6(0, Inject6(AGENT_OPTIONS3)),
1033
+ _ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER)),
1034
+ _ts_param6(2, Optional2()),
1035
+ _ts_param6(2, Inject6(AGENT_ATTACHMENT_STAGING)),
1036
+ _ts_metadata7("design:type", Function),
1037
+ _ts_metadata7("design:paramtypes", [
831
1038
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
832
1039
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
833
1040
  Object
@@ -835,25 +1042,25 @@ AttachmentsController = _ts_decorate7([
835
1042
  ], AttachmentsController);
836
1043
 
837
1044
  // src/controller/chat.controller.ts
838
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError } from "@dudousxd/nestjs-agent-core";
839
- import { Body, Controller as Controller3, Get as Get2, Inject as Inject6, Param, Post as Post2, Req as Req2, Res } from "@nestjs/common";
840
- function _ts_decorate8(decorators, target, key, desc) {
1045
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2 } from "@dudousxd/nestjs-agent-core";
1046
+ import { Body, Controller as Controller3, Get as Get2, Inject as Inject7, Param, Post as Post2, Req as Req2, Res } from "@nestjs/common";
1047
+ function _ts_decorate9(decorators, target, key, desc) {
841
1048
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
842
1049
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
843
1050
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
844
1051
  return c > 3 && r && Object.defineProperty(target, key, r), r;
845
1052
  }
846
- __name(_ts_decorate8, "_ts_decorate");
847
- function _ts_metadata7(k, v) {
1053
+ __name(_ts_decorate9, "_ts_decorate");
1054
+ function _ts_metadata8(k, v) {
848
1055
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
849
1056
  }
850
- __name(_ts_metadata7, "_ts_metadata");
851
- function _ts_param6(paramIndex, decorator) {
1057
+ __name(_ts_metadata8, "_ts_metadata");
1058
+ function _ts_param7(paramIndex, decorator) {
852
1059
  return function(target, key) {
853
1060
  decorator(target, key, paramIndex);
854
1061
  };
855
1062
  }
856
- __name(_ts_param6, "_ts_param");
1063
+ __name(_ts_param7, "_ts_param");
857
1064
  var ChatController = class {
858
1065
  static {
859
1066
  __name(this, "ChatController");
@@ -941,7 +1148,7 @@ data: ${JSON.stringify({
941
1148
  }
942
1149
  res.write("event: done\ndata: {}\n\n");
943
1150
  } catch (error) {
944
- const payload = error instanceof AgentStreamError ? {
1151
+ const payload = error instanceof AgentStreamError2 ? {
945
1152
  code: error.code,
946
1153
  message: error.message
947
1154
  } : {
@@ -956,46 +1163,46 @@ data: ${JSON.stringify(payload)}
956
1163
  res.end();
957
1164
  }
958
1165
  };
959
- _ts_decorate8([
1166
+ _ts_decorate9([
960
1167
  Post2("chat"),
961
- _ts_param6(0, Req2()),
962
- _ts_param6(1, Res()),
963
- _ts_param6(2, Body()),
964
- _ts_metadata7("design:type", Function),
965
- _ts_metadata7("design:paramtypes", [
1168
+ _ts_param7(0, Req2()),
1169
+ _ts_param7(1, Res()),
1170
+ _ts_param7(2, Body()),
1171
+ _ts_metadata8("design:type", Function),
1172
+ _ts_metadata8("design:paramtypes", [
966
1173
  typeof Request === "undefined" ? Object : Request,
967
1174
  typeof Response === "undefined" ? Object : Response,
968
1175
  typeof ChatBody === "undefined" ? Object : ChatBody
969
1176
  ]),
970
- _ts_metadata7("design:returntype", Promise)
1177
+ _ts_metadata8("design:returntype", Promise)
971
1178
  ], ChatController.prototype, "chat", null);
972
- _ts_decorate8([
1179
+ _ts_decorate9([
973
1180
  Get2("chat/:runId/stream"),
974
- _ts_param6(0, Param("runId")),
975
- _ts_param6(1, Res()),
976
- _ts_metadata7("design:type", Function),
977
- _ts_metadata7("design:paramtypes", [
1181
+ _ts_param7(0, Param("runId")),
1182
+ _ts_param7(1, Res()),
1183
+ _ts_metadata8("design:type", Function),
1184
+ _ts_metadata8("design:paramtypes", [
978
1185
  String,
979
1186
  typeof Response === "undefined" ? Object : Response
980
1187
  ]),
981
- _ts_metadata7("design:returntype", Promise)
1188
+ _ts_metadata8("design:returntype", Promise)
982
1189
  ], ChatController.prototype, "stream", null);
983
- _ts_decorate8([
1190
+ _ts_decorate9([
984
1191
  Post2("chat/:runId/cancel"),
985
- _ts_param6(0, Req2()),
986
- _ts_param6(1, Param("runId")),
987
- _ts_metadata7("design:type", Function),
988
- _ts_metadata7("design:paramtypes", [
1192
+ _ts_param7(0, Req2()),
1193
+ _ts_param7(1, Param("runId")),
1194
+ _ts_metadata8("design:type", Function),
1195
+ _ts_metadata8("design:paramtypes", [
989
1196
  typeof Request === "undefined" ? Object : Request,
990
1197
  String
991
1198
  ]),
992
- _ts_metadata7("design:returntype", Promise)
1199
+ _ts_metadata8("design:returntype", Promise)
993
1200
  ], ChatController.prototype, "cancel", null);
994
- ChatController = _ts_decorate8([
1201
+ ChatController = _ts_decorate9([
995
1202
  Controller3(),
996
- _ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER2)),
997
- _ts_metadata7("design:type", Function),
998
- _ts_metadata7("design:paramtypes", [
1203
+ _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER2)),
1204
+ _ts_metadata8("design:type", Function),
1205
+ _ts_metadata8("design:paramtypes", [
999
1206
  typeof AgentService === "undefined" ? Object : AgentService,
1000
1207
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1001
1208
  ])
@@ -1003,24 +1210,24 @@ ChatController = _ts_decorate8([
1003
1210
 
1004
1211
  // src/controller/quota.controller.ts
1005
1212
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3 } from "@dudousxd/nestjs-agent-core";
1006
- import { Controller as Controller4, Get as Get3, Inject as Inject7, Req as Req3 } from "@nestjs/common";
1007
- function _ts_decorate9(decorators, target, key, desc) {
1213
+ import { Controller as Controller4, Get as Get3, Inject as Inject8, Req as Req3 } from "@nestjs/common";
1214
+ function _ts_decorate10(decorators, target, key, desc) {
1008
1215
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1009
1216
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1010
1217
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1011
1218
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1012
1219
  }
1013
- __name(_ts_decorate9, "_ts_decorate");
1014
- function _ts_metadata8(k, v) {
1220
+ __name(_ts_decorate10, "_ts_decorate");
1221
+ function _ts_metadata9(k, v) {
1015
1222
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1016
1223
  }
1017
- __name(_ts_metadata8, "_ts_metadata");
1018
- function _ts_param7(paramIndex, decorator) {
1224
+ __name(_ts_metadata9, "_ts_metadata");
1225
+ function _ts_param8(paramIndex, decorator) {
1019
1226
  return function(target, key) {
1020
1227
  decorator(target, key, paramIndex);
1021
1228
  };
1022
1229
  }
1023
- __name(_ts_param7, "_ts_param");
1230
+ __name(_ts_param8, "_ts_param");
1024
1231
  var QuotaController = class {
1025
1232
  static {
1026
1233
  __name(this, "QuotaController");
@@ -1036,20 +1243,20 @@ var QuotaController = class {
1036
1243
  return this.agent.quotaToday(actor.id);
1037
1244
  }
1038
1245
  };
1039
- _ts_decorate9([
1246
+ _ts_decorate10([
1040
1247
  Get3("today"),
1041
- _ts_param7(0, Req3()),
1042
- _ts_metadata8("design:type", Function),
1043
- _ts_metadata8("design:paramtypes", [
1248
+ _ts_param8(0, Req3()),
1249
+ _ts_metadata9("design:type", Function),
1250
+ _ts_metadata9("design:paramtypes", [
1044
1251
  typeof Request === "undefined" ? Object : Request
1045
1252
  ]),
1046
- _ts_metadata8("design:returntype", Promise)
1253
+ _ts_metadata9("design:returntype", Promise)
1047
1254
  ], QuotaController.prototype, "today", null);
1048
- QuotaController = _ts_decorate9([
1255
+ QuotaController = _ts_decorate10([
1049
1256
  Controller4("quota"),
1050
- _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER3)),
1051
- _ts_metadata8("design:type", Function),
1052
- _ts_metadata8("design:paramtypes", [
1257
+ _ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER3)),
1258
+ _ts_metadata9("design:type", Function),
1259
+ _ts_metadata9("design:paramtypes", [
1053
1260
  typeof AgentService === "undefined" ? Object : AgentService,
1054
1261
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1055
1262
  ])
@@ -1057,24 +1264,24 @@ QuotaController = _ts_decorate9([
1057
1264
 
1058
1265
  // src/controller/threads.controller.ts
1059
1266
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4 } from "@dudousxd/nestjs-agent-core";
1060
- import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as Inject8, Param as Param2, Patch, Post as Post3, Req as Req4 } from "@nestjs/common";
1061
- function _ts_decorate10(decorators, target, key, desc) {
1267
+ import { Body as Body2, Controller as Controller5, Delete, Get as Get4, Inject as Inject9, Param as Param2, Patch, Post as Post3, Req as Req4 } from "@nestjs/common";
1268
+ function _ts_decorate11(decorators, target, key, desc) {
1062
1269
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1063
1270
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1064
1271
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1065
1272
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1066
1273
  }
1067
- __name(_ts_decorate10, "_ts_decorate");
1068
- function _ts_metadata9(k, v) {
1274
+ __name(_ts_decorate11, "_ts_decorate");
1275
+ function _ts_metadata10(k, v) {
1069
1276
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1070
1277
  }
1071
- __name(_ts_metadata9, "_ts_metadata");
1072
- function _ts_param8(paramIndex, decorator) {
1278
+ __name(_ts_metadata10, "_ts_metadata");
1279
+ function _ts_param9(paramIndex, decorator) {
1073
1280
  return function(target, key) {
1074
1281
  decorator(target, key, paramIndex);
1075
1282
  };
1076
1283
  }
1077
- __name(_ts_param8, "_ts_param");
1284
+ __name(_ts_param9, "_ts_param");
1078
1285
  var ThreadsController = class {
1079
1286
  static {
1080
1287
  __name(this, "ThreadsController");
@@ -1138,92 +1345,92 @@ var ThreadsController = class {
1138
1345
  };
1139
1346
  }
1140
1347
  };
1141
- _ts_decorate10([
1348
+ _ts_decorate11([
1142
1349
  Get4(),
1143
- _ts_param8(0, Req4()),
1144
- _ts_metadata9("design:type", Function),
1145
- _ts_metadata9("design:paramtypes", [
1350
+ _ts_param9(0, Req4()),
1351
+ _ts_metadata10("design:type", Function),
1352
+ _ts_metadata10("design:paramtypes", [
1146
1353
  typeof Request === "undefined" ? Object : Request
1147
1354
  ]),
1148
- _ts_metadata9("design:returntype", Promise)
1355
+ _ts_metadata10("design:returntype", Promise)
1149
1356
  ], ThreadsController.prototype, "list", null);
1150
- _ts_decorate10([
1357
+ _ts_decorate11([
1151
1358
  Get4(":id"),
1152
- _ts_param8(0, Req4()),
1153
- _ts_param8(1, Param2("id")),
1154
- _ts_metadata9("design:type", Function),
1155
- _ts_metadata9("design:paramtypes", [
1359
+ _ts_param9(0, Req4()),
1360
+ _ts_param9(1, Param2("id")),
1361
+ _ts_metadata10("design:type", Function),
1362
+ _ts_metadata10("design:paramtypes", [
1156
1363
  typeof Request === "undefined" ? Object : Request,
1157
1364
  String
1158
1365
  ]),
1159
- _ts_metadata9("design:returntype", Promise)
1366
+ _ts_metadata10("design:returntype", Promise)
1160
1367
  ], ThreadsController.prototype, "detail", null);
1161
- _ts_decorate10([
1368
+ _ts_decorate11([
1162
1369
  Delete(":id"),
1163
- _ts_param8(0, Req4()),
1164
- _ts_param8(1, Param2("id")),
1165
- _ts_metadata9("design:type", Function),
1166
- _ts_metadata9("design:paramtypes", [
1370
+ _ts_param9(0, Req4()),
1371
+ _ts_param9(1, Param2("id")),
1372
+ _ts_metadata10("design:type", Function),
1373
+ _ts_metadata10("design:paramtypes", [
1167
1374
  typeof Request === "undefined" ? Object : Request,
1168
1375
  String
1169
1376
  ]),
1170
- _ts_metadata9("design:returntype", Promise)
1377
+ _ts_metadata10("design:returntype", Promise)
1171
1378
  ], ThreadsController.prototype, "remove", null);
1172
- _ts_decorate10([
1379
+ _ts_decorate11([
1173
1380
  Post3(":id/fork-from/:messageId"),
1174
- _ts_param8(0, Req4()),
1175
- _ts_param8(1, Param2("id")),
1176
- _ts_param8(2, Param2("messageId")),
1177
- _ts_metadata9("design:type", Function),
1178
- _ts_metadata9("design:paramtypes", [
1381
+ _ts_param9(0, Req4()),
1382
+ _ts_param9(1, Param2("id")),
1383
+ _ts_param9(2, Param2("messageId")),
1384
+ _ts_metadata10("design:type", Function),
1385
+ _ts_metadata10("design:paramtypes", [
1179
1386
  typeof Request === "undefined" ? Object : Request,
1180
1387
  String,
1181
1388
  String
1182
1389
  ]),
1183
- _ts_metadata9("design:returntype", Promise)
1390
+ _ts_metadata10("design:returntype", Promise)
1184
1391
  ], ThreadsController.prototype, "fork", null);
1185
- _ts_decorate10([
1392
+ _ts_decorate11([
1186
1393
  Patch(":id"),
1187
- _ts_param8(0, Req4()),
1188
- _ts_param8(1, Param2("id")),
1189
- _ts_param8(2, Body2()),
1190
- _ts_metadata9("design:type", Function),
1191
- _ts_metadata9("design:paramtypes", [
1394
+ _ts_param9(0, Req4()),
1395
+ _ts_param9(1, Param2("id")),
1396
+ _ts_param9(2, Body2()),
1397
+ _ts_metadata10("design:type", Function),
1398
+ _ts_metadata10("design:paramtypes", [
1192
1399
  typeof Request === "undefined" ? Object : Request,
1193
1400
  String,
1194
1401
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
1195
1402
  ]),
1196
- _ts_metadata9("design:returntype", Promise)
1403
+ _ts_metadata10("design:returntype", Promise)
1197
1404
  ], ThreadsController.prototype, "update", null);
1198
- _ts_decorate10([
1405
+ _ts_decorate11([
1199
1406
  Post3(":id/promote"),
1200
- _ts_param8(0, Req4()),
1201
- _ts_param8(1, Param2("id")),
1202
- _ts_metadata9("design:type", Function),
1203
- _ts_metadata9("design:paramtypes", [
1407
+ _ts_param9(0, Req4()),
1408
+ _ts_param9(1, Param2("id")),
1409
+ _ts_metadata10("design:type", Function),
1410
+ _ts_metadata10("design:paramtypes", [
1204
1411
  typeof Request === "undefined" ? Object : Request,
1205
1412
  String
1206
1413
  ]),
1207
- _ts_metadata9("design:returntype", Promise)
1414
+ _ts_metadata10("design:returntype", Promise)
1208
1415
  ], ThreadsController.prototype, "promote", null);
1209
- _ts_decorate10([
1416
+ _ts_decorate11([
1210
1417
  Delete(":id/from/:messageId"),
1211
- _ts_param8(0, Req4()),
1212
- _ts_param8(1, Param2("id")),
1213
- _ts_param8(2, Param2("messageId")),
1214
- _ts_metadata9("design:type", Function),
1215
- _ts_metadata9("design:paramtypes", [
1418
+ _ts_param9(0, Req4()),
1419
+ _ts_param9(1, Param2("id")),
1420
+ _ts_param9(2, Param2("messageId")),
1421
+ _ts_metadata10("design:type", Function),
1422
+ _ts_metadata10("design:paramtypes", [
1216
1423
  typeof Request === "undefined" ? Object : Request,
1217
1424
  String,
1218
1425
  String
1219
1426
  ]),
1220
- _ts_metadata9("design:returntype", Promise)
1427
+ _ts_metadata10("design:returntype", Promise)
1221
1428
  ], ThreadsController.prototype, "truncateFrom", null);
1222
- ThreadsController = _ts_decorate10([
1429
+ ThreadsController = _ts_decorate11([
1223
1430
  Controller5("threads"),
1224
- _ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER4)),
1225
- _ts_metadata9("design:type", Function),
1226
- _ts_metadata9("design:paramtypes", [
1431
+ _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER4)),
1432
+ _ts_metadata10("design:type", Function),
1433
+ _ts_metadata10("design:paramtypes", [
1227
1434
  typeof AgentService === "undefined" ? Object : AgentService,
1228
1435
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1229
1436
  ])
@@ -1231,24 +1438,24 @@ ThreadsController = _ts_decorate10([
1231
1438
 
1232
1439
  // src/controller/tool-call.controller.ts
1233
1440
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
1234
- import { Body as Body3, Controller as Controller6, Inject as Inject9, Post as Post4, Req as Req5 } from "@nestjs/common";
1235
- function _ts_decorate11(decorators, target, key, desc) {
1441
+ import { Body as Body3, Controller as Controller6, Inject as Inject10, Post as Post4, Req as Req5 } from "@nestjs/common";
1442
+ function _ts_decorate12(decorators, target, key, desc) {
1236
1443
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1237
1444
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1238
1445
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1239
1446
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1240
1447
  }
1241
- __name(_ts_decorate11, "_ts_decorate");
1242
- function _ts_metadata10(k, v) {
1448
+ __name(_ts_decorate12, "_ts_decorate");
1449
+ function _ts_metadata11(k, v) {
1243
1450
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1244
1451
  }
1245
- __name(_ts_metadata10, "_ts_metadata");
1246
- function _ts_param9(paramIndex, decorator) {
1452
+ __name(_ts_metadata11, "_ts_metadata");
1453
+ function _ts_param10(paramIndex, decorator) {
1247
1454
  return function(target, key) {
1248
1455
  decorator(target, key, paramIndex);
1249
1456
  };
1250
1457
  }
1251
- __name(_ts_param9, "_ts_param");
1458
+ __name(_ts_param10, "_ts_param");
1252
1459
  var ToolCallController = class {
1253
1460
  static {
1254
1461
  __name(this, "ToolCallController");
@@ -1274,33 +1481,33 @@ var ToolCallController = class {
1274
1481
  };
1275
1482
  }
1276
1483
  };
1277
- _ts_decorate11([
1484
+ _ts_decorate12([
1278
1485
  Post4("approve"),
1279
- _ts_param9(0, Req5()),
1280
- _ts_param9(1, Body3()),
1281
- _ts_metadata10("design:type", Function),
1282
- _ts_metadata10("design:paramtypes", [
1486
+ _ts_param10(0, Req5()),
1487
+ _ts_param10(1, Body3()),
1488
+ _ts_metadata11("design:type", Function),
1489
+ _ts_metadata11("design:paramtypes", [
1283
1490
  typeof Request === "undefined" ? Object : Request,
1284
1491
  typeof ApproveBody === "undefined" ? Object : ApproveBody
1285
1492
  ]),
1286
- _ts_metadata10("design:returntype", Promise)
1493
+ _ts_metadata11("design:returntype", Promise)
1287
1494
  ], ToolCallController.prototype, "approve", null);
1288
- _ts_decorate11([
1495
+ _ts_decorate12([
1289
1496
  Post4("reject"),
1290
- _ts_param9(0, Req5()),
1291
- _ts_param9(1, Body3()),
1292
- _ts_metadata10("design:type", Function),
1293
- _ts_metadata10("design:paramtypes", [
1497
+ _ts_param10(0, Req5()),
1498
+ _ts_param10(1, Body3()),
1499
+ _ts_metadata11("design:type", Function),
1500
+ _ts_metadata11("design:paramtypes", [
1294
1501
  typeof Request === "undefined" ? Object : Request,
1295
1502
  typeof RejectBody === "undefined" ? Object : RejectBody
1296
1503
  ]),
1297
- _ts_metadata10("design:returntype", Promise)
1504
+ _ts_metadata11("design:returntype", Promise)
1298
1505
  ], ToolCallController.prototype, "reject", null);
1299
- ToolCallController = _ts_decorate11([
1506
+ ToolCallController = _ts_decorate12([
1300
1507
  Controller6("tool-call"),
1301
- _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER5)),
1302
- _ts_metadata10("design:type", Function),
1303
- _ts_metadata10("design:paramtypes", [
1508
+ _ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER5)),
1509
+ _ts_metadata11("design:type", Function),
1510
+ _ts_metadata11("design:paramtypes", [
1304
1511
  typeof AgentService === "undefined" ? Object : AgentService,
1305
1512
  typeof ActorResolver === "undefined" ? Object : ActorResolver
1306
1513
  ])
@@ -1308,7 +1515,7 @@ ToolCallController = _ts_decorate11([
1308
1515
 
1309
1516
  // src/discovery/agent-discovery.service.ts
1310
1517
  import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY3, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
1311
- import { Inject as Inject10, Injectable as Injectable5, Logger } from "@nestjs/common";
1518
+ import { Inject as Inject11, Injectable as Injectable6, Logger as Logger2 } from "@nestjs/common";
1312
1519
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
1313
1520
 
1314
1521
  // src/decorator/agent.decorator.ts
@@ -1325,23 +1532,23 @@ var SYSTEM_PROMPT_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt");
1325
1532
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
1326
1533
 
1327
1534
  // src/discovery/agent-discovery.service.ts
1328
- function _ts_decorate12(decorators, target, key, desc) {
1535
+ function _ts_decorate13(decorators, target, key, desc) {
1329
1536
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1330
1537
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1331
1538
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1332
1539
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1333
1540
  }
1334
- __name(_ts_decorate12, "_ts_decorate");
1335
- function _ts_metadata11(k, v) {
1541
+ __name(_ts_decorate13, "_ts_decorate");
1542
+ function _ts_metadata12(k, v) {
1336
1543
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1337
1544
  }
1338
- __name(_ts_metadata11, "_ts_metadata");
1339
- function _ts_param10(paramIndex, decorator) {
1545
+ __name(_ts_metadata12, "_ts_metadata");
1546
+ function _ts_param11(paramIndex, decorator) {
1340
1547
  return function(target, key) {
1341
1548
  decorator(target, key, paramIndex);
1342
1549
  };
1343
1550
  }
1344
- __name(_ts_param10, "_ts_param");
1551
+ __name(_ts_param11, "_ts_param");
1345
1552
  var AgentDiscoveryService = class _AgentDiscoveryService {
1346
1553
  static {
1347
1554
  __name(this, "AgentDiscoveryService");
@@ -1350,7 +1557,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
1350
1557
  scanner;
1351
1558
  registry;
1352
1559
  contributors;
1353
- logger = new Logger(_AgentDiscoveryService.name);
1560
+ logger = new Logger2(_AgentDiscoveryService.name);
1354
1561
  constructor(discovery, scanner, registry, contributors) {
1355
1562
  this.discovery = discovery;
1356
1563
  this.scanner = scanner;
@@ -1438,12 +1645,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
1438
1645
  return (ctx) => candidate.call(instance, ctx);
1439
1646
  }
1440
1647
  };
1441
- AgentDiscoveryService = _ts_decorate12([
1442
- Injectable5(),
1443
- _ts_param10(2, Inject10(AGENT_REGISTRY3)),
1444
- _ts_param10(3, Inject10(AGENT_PROMPT_CONTRIBUTORS2)),
1445
- _ts_metadata11("design:type", Function),
1446
- _ts_metadata11("design:paramtypes", [
1648
+ AgentDiscoveryService = _ts_decorate13([
1649
+ Injectable6(),
1650
+ _ts_param11(2, Inject11(AGENT_REGISTRY3)),
1651
+ _ts_param11(3, Inject11(AGENT_PROMPT_CONTRIBUTORS2)),
1652
+ _ts_metadata12("design:type", Function),
1653
+ _ts_metadata12("design:paramtypes", [
1447
1654
  typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
1448
1655
  typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
1449
1656
  typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4,
@@ -1452,8 +1659,8 @@ AgentDiscoveryService = _ts_decorate12([
1452
1659
  ], AgentDiscoveryService);
1453
1660
 
1454
1661
  // src/discovery/ai-tool-discovery.service.ts
1455
- import { AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
1456
- import { Inject as Inject11, Injectable as Injectable6, Logger as Logger2 } from "@nestjs/common";
1662
+ import { AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_REGISTRY as AGENT_REGISTRY4, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2 } from "@dudousxd/nestjs-agent-core";
1663
+ import { Inject as Inject12, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
1457
1664
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
1458
1665
  import { z } from "zod";
1459
1666
 
@@ -1473,23 +1680,23 @@ function isBrandedFunctionalTool(value) {
1473
1680
  __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
1474
1681
 
1475
1682
  // src/discovery/ai-tool-discovery.service.ts
1476
- function _ts_decorate13(decorators, target, key, desc) {
1683
+ function _ts_decorate14(decorators, target, key, desc) {
1477
1684
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1478
1685
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1479
1686
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1480
1687
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1481
1688
  }
1482
- __name(_ts_decorate13, "_ts_decorate");
1483
- function _ts_metadata12(k, v) {
1689
+ __name(_ts_decorate14, "_ts_decorate");
1690
+ function _ts_metadata13(k, v) {
1484
1691
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1485
1692
  }
1486
- __name(_ts_metadata12, "_ts_metadata");
1487
- function _ts_param11(paramIndex, decorator) {
1693
+ __name(_ts_metadata13, "_ts_metadata");
1694
+ function _ts_param12(paramIndex, decorator) {
1488
1695
  return function(target, key) {
1489
1696
  decorator(target, key, paramIndex);
1490
1697
  };
1491
1698
  }
1492
- __name(_ts_param11, "_ts_param");
1699
+ __name(_ts_param12, "_ts_param");
1493
1700
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
1494
1701
  static {
1495
1702
  __name(this, "AiToolDiscoveryService");
@@ -1498,7 +1705,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
1498
1705
  registry;
1499
1706
  agents;
1500
1707
  options;
1501
- logger = new Logger2(_AiToolDiscoveryService.name);
1708
+ logger = new Logger3(_AiToolDiscoveryService.name);
1502
1709
  constructor(discovery, registry, agents, options) {
1503
1710
  this.discovery = discovery;
1504
1711
  this.registry = registry;
@@ -1596,13 +1803,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
1596
1803
  return true;
1597
1804
  }
1598
1805
  };
1599
- AiToolDiscoveryService = _ts_decorate13([
1600
- Injectable6(),
1601
- _ts_param11(1, Inject11(AGENT_TOOL_REGISTRY2)),
1602
- _ts_param11(2, Inject11(AGENT_REGISTRY4)),
1603
- _ts_param11(3, Inject11(AGENT_OPTIONS3)),
1604
- _ts_metadata12("design:type", Function),
1605
- _ts_metadata12("design:paramtypes", [
1806
+ AiToolDiscoveryService = _ts_decorate14([
1807
+ Injectable7(),
1808
+ _ts_param12(1, Inject12(AGENT_TOOL_REGISTRY2)),
1809
+ _ts_param12(2, Inject12(AGENT_REGISTRY4)),
1810
+ _ts_param12(3, Inject12(AGENT_OPTIONS4)),
1811
+ _ts_metadata13("design:type", Function),
1812
+ _ts_metadata13("design:paramtypes", [
1606
1813
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
1607
1814
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
1608
1815
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -1610,74 +1817,6 @@ AiToolDiscoveryService = _ts_decorate13([
1610
1817
  ])
1611
1818
  ], AiToolDiscoveryService);
1612
1819
 
1613
- // src/in-process-sink.ts
1614
- import { AgentStreamError as AgentStreamError2 } from "@dudousxd/nestjs-agent-core";
1615
- var InProcessTokenStreamSink = class {
1616
- static {
1617
- __name(this, "InProcessTokenStreamSink");
1618
- }
1619
- runs = /* @__PURE__ */ new Map();
1620
- buffer(runId) {
1621
- let buf = this.runs.get(runId);
1622
- if (buf === void 0) {
1623
- buf = {
1624
- chunks: [],
1625
- ended: false,
1626
- notify: /* @__PURE__ */ new Set()
1627
- };
1628
- this.runs.set(runId, buf);
1629
- }
1630
- return buf;
1631
- }
1632
- wake(buf) {
1633
- for (const resolve of buf.notify) {
1634
- resolve();
1635
- }
1636
- buf.notify.clear();
1637
- }
1638
- open(runId) {
1639
- const buf = this.buffer(runId);
1640
- return {
1641
- write: /* @__PURE__ */ __name((chunk) => {
1642
- buf.chunks.push(chunk);
1643
- this.wake(buf);
1644
- }, "write"),
1645
- end: /* @__PURE__ */ __name(() => {
1646
- buf.ended = true;
1647
- this.wake(buf);
1648
- }, "end"),
1649
- fail: /* @__PURE__ */ __name((error) => {
1650
- buf.failure = error;
1651
- buf.ended = true;
1652
- this.wake(buf);
1653
- }, "fail")
1654
- };
1655
- }
1656
- async *subscribe(runId) {
1657
- const buf = this.buffer(runId);
1658
- let index = 0;
1659
- while (true) {
1660
- while (index < buf.chunks.length) {
1661
- const chunk = buf.chunks[index];
1662
- index += 1;
1663
- if (chunk !== void 0) {
1664
- yield chunk;
1665
- }
1666
- }
1667
- if (buf.ended) {
1668
- if (buf.failure !== void 0) {
1669
- throw new AgentStreamError2(buf.failure);
1670
- }
1671
- return;
1672
- }
1673
- await new Promise((resolve) => buf.notify.add(resolve));
1674
- }
1675
- }
1676
- close(runId) {
1677
- this.runs.delete(runId);
1678
- }
1679
- };
1680
-
1681
1820
  // src/ledger-quota-store.ts
1682
1821
  var LedgerQuotaStore = class {
1683
1822
  static {
@@ -1702,32 +1841,32 @@ var LedgerQuotaStore = class {
1702
1841
  };
1703
1842
 
1704
1843
  // src/runner/inline-agent-runner.ts
1705
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_STORE as AGENT_STORE4, QuotaExceededError as QuotaExceededError2, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2 } from "@dudousxd/nestjs-agent-core";
1706
- import { Inject as Inject12, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
1707
- function _ts_decorate14(decorators, target, key, desc) {
1844
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_STORE as AGENT_STORE4, QuotaExceededError as QuotaExceededError2, publishAgentRunFailed as publishAgentRunFailed2, runAgentLoop as runAgentLoop2 } from "@dudousxd/nestjs-agent-core";
1845
+ import { Inject as Inject13, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
1846
+ function _ts_decorate15(decorators, target, key, desc) {
1708
1847
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1709
1848
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1710
1849
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1711
1850
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1712
1851
  }
1713
- __name(_ts_decorate14, "_ts_decorate");
1714
- function _ts_metadata13(k, v) {
1852
+ __name(_ts_decorate15, "_ts_decorate");
1853
+ function _ts_metadata14(k, v) {
1715
1854
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1716
1855
  }
1717
- __name(_ts_metadata13, "_ts_metadata");
1718
- function _ts_param12(paramIndex, decorator) {
1856
+ __name(_ts_metadata14, "_ts_metadata");
1857
+ function _ts_param13(paramIndex, decorator) {
1719
1858
  return function(target, key) {
1720
1859
  decorator(target, key, paramIndex);
1721
1860
  };
1722
1861
  }
1723
- __name(_ts_param12, "_ts_param");
1862
+ __name(_ts_param13, "_ts_param");
1724
1863
  var InlineAgentRunner = class _InlineAgentRunner {
1725
1864
  static {
1726
1865
  __name(this, "InlineAgentRunner");
1727
1866
  }
1728
1867
  factory;
1729
1868
  store;
1730
- logger = new Logger3(_InlineAgentRunner.name);
1869
+ logger = new Logger4(_InlineAgentRunner.name);
1731
1870
  pending = /* @__PURE__ */ new Map();
1732
1871
  constructor(factory, store) {
1733
1872
  this.factory = factory;
@@ -1750,6 +1889,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
1750
1889
  code,
1751
1890
  message
1752
1891
  });
1892
+ await this.store.recordRunEnd?.({
1893
+ runId,
1894
+ status: "failed",
1895
+ errorCode: code,
1896
+ errorMessage: message
1897
+ });
1753
1898
  await this.store.setActiveStream(input.threadId, null);
1754
1899
  const writer = await deps.sink.open(runId);
1755
1900
  await writer.fail({
@@ -1826,25 +1971,25 @@ var InlineAgentRunner = class _InlineAgentRunner {
1826
1971
  }
1827
1972
  }
1828
1973
  };
1829
- InlineAgentRunner = _ts_decorate14([
1830
- Injectable7(),
1831
- _ts_param12(0, Inject12(AGENT_DEPS_FACTORY4)),
1832
- _ts_param12(1, Inject12(AGENT_STORE4)),
1833
- _ts_metadata13("design:type", Function),
1834
- _ts_metadata13("design:paramtypes", [
1974
+ InlineAgentRunner = _ts_decorate15([
1975
+ Injectable8(),
1976
+ _ts_param13(0, Inject13(AGENT_DEPS_FACTORY5)),
1977
+ _ts_param13(1, Inject13(AGENT_STORE4)),
1978
+ _ts_metadata14("design:type", Function),
1979
+ _ts_metadata14("design:paramtypes", [
1835
1980
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
1836
1981
  typeof AgentStore === "undefined" ? Object : AgentStore
1837
1982
  ])
1838
1983
  ], InlineAgentRunner);
1839
1984
 
1840
1985
  // src/agent.module.ts
1841
- function _ts_decorate15(decorators, target, key, desc) {
1986
+ function _ts_decorate16(decorators, target, key, desc) {
1842
1987
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1843
1988
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1844
1989
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1845
1990
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1846
1991
  }
1847
- __name(_ts_decorate15, "_ts_decorate");
1992
+ __name(_ts_decorate16, "_ts_decorate");
1848
1993
  var DEFAULT_PATH = "agent";
1849
1994
  function sharedProviders(durable, includeStore) {
1850
1995
  const providers = [
@@ -1863,31 +2008,31 @@ function sharedProviders(durable, includeStore) {
1863
2008
  useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
1864
2009
  },
1865
2010
  {
1866
- provide: AGENT_SINK2,
2011
+ provide: AGENT_SINK3,
1867
2012
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
1868
2013
  inject: [
1869
- AGENT_OPTIONS4
2014
+ AGENT_OPTIONS5
1870
2015
  ]
1871
2016
  },
1872
2017
  {
1873
2018
  provide: AGENT_ROLES_POLICY2,
1874
2019
  useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new DefaultRolesPolicy(options.defaultRoles), "useFactory"),
1875
2020
  inject: [
1876
- AGENT_OPTIONS4
2021
+ AGENT_OPTIONS5
1877
2022
  ]
1878
2023
  },
1879
2024
  {
1880
2025
  provide: AGENT_ACTOR_RESOLVER6,
1881
2026
  useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
1882
2027
  inject: [
1883
- AGENT_OPTIONS4
2028
+ AGENT_OPTIONS5
1884
2029
  ]
1885
2030
  },
1886
2031
  {
1887
2032
  provide: AGENT_MODEL2,
1888
2033
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
1889
2034
  inject: [
1890
- AGENT_OPTIONS4
2035
+ AGENT_OPTIONS5
1891
2036
  ]
1892
2037
  },
1893
2038
  {
@@ -1897,13 +2042,13 @@ function sharedProviders(durable, includeStore) {
1897
2042
  provide: AGENT_QUOTA_STORE3,
1898
2043
  useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
1899
2044
  inject: [
1900
- AGENT_OPTIONS4,
2045
+ AGENT_OPTIONS5,
1901
2046
  AGENT_STORE5
1902
2047
  ]
1903
2048
  },
1904
2049
  AgentDepsFactory2,
1905
2050
  {
1906
- provide: AGENT_DEPS_FACTORY5,
2051
+ provide: AGENT_DEPS_FACTORY6,
1907
2052
  useExisting: AgentDepsFactory2
1908
2053
  },
1909
2054
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -1918,7 +2063,7 @@ function sharedProviders(durable, includeStore) {
1918
2063
  provide: AGENT_STORE5,
1919
2064
  useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
1920
2065
  inject: [
1921
- AGENT_OPTIONS4
2066
+ AGENT_OPTIONS5
1922
2067
  ]
1923
2068
  });
1924
2069
  }
@@ -1949,10 +2094,10 @@ function sharedProviders(durable, includeStore) {
1949
2094
  __name(sharedProviders, "sharedProviders");
1950
2095
  function exportsFor(includeStore) {
1951
2096
  return [
1952
- AGENT_OPTIONS4,
2097
+ AGENT_OPTIONS5,
1953
2098
  AGENT_TOOL_REGISTRY3,
1954
2099
  AGENT_REGISTRY5,
1955
- AGENT_SINK2,
2100
+ AGENT_SINK3,
1956
2101
  AGENT_ROLES_POLICY2,
1957
2102
  AGENT_ACTOR_RESOLVER6,
1958
2103
  AGENT_MODEL2,
@@ -1961,7 +2106,7 @@ function exportsFor(includeStore) {
1961
2106
  ] : [],
1962
2107
  AGENT_QUOTA_STORE3,
1963
2108
  AGENT_PROMPT_CONTRIBUTORS3,
1964
- AGENT_DEPS_FACTORY5,
2109
+ AGENT_DEPS_FACTORY6,
1965
2110
  AgentDepsFactory2,
1966
2111
  AgentService,
1967
2112
  InlineAgentRunner
@@ -2009,11 +2154,18 @@ function routerFor(path) {
2009
2154
  ]);
2010
2155
  }
2011
2156
  __name(routerFor, "routerFor");
2157
+ function assertDispatchedStepsRequiresDurable(dispatchedSteps, durable) {
2158
+ if (dispatchedSteps && !durable) {
2159
+ throw new Error("AgentModule dispatchedSteps: true requires durable: true \u2014 dispatched steps are routed durable steps (AgentRunSteps.llm/tool) with no in-process equivalent.");
2160
+ }
2161
+ }
2162
+ __name(assertDispatchedStepsRequiresDurable, "assertDispatchedStepsRequiresDurable");
2012
2163
  var AgentModule = class _AgentModule {
2013
2164
  static {
2014
2165
  __name(this, "AgentModule");
2015
2166
  }
2016
2167
  static forRoot(options) {
2168
+ assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
2017
2169
  const path = options.path ?? DEFAULT_PATH;
2018
2170
  const includeStore = options.store !== void 0;
2019
2171
  applyGuards(options.guards);
@@ -2027,7 +2179,7 @@ var AgentModule = class _AgentModule {
2027
2179
  controllers: controllersFor(options.attachments?.upload === true),
2028
2180
  providers: [
2029
2181
  {
2030
- provide: AGENT_OPTIONS4,
2182
+ provide: AGENT_OPTIONS5,
2031
2183
  useValue: options
2032
2184
  },
2033
2185
  ...sharedProviders(options.durable ?? false, includeStore),
@@ -2037,6 +2189,7 @@ var AgentModule = class _AgentModule {
2037
2189
  };
2038
2190
  }
2039
2191
  static forRootAsync(options) {
2192
+ assertDispatchedStepsRequiresDurable(options.dispatchedSteps ?? false, options.durable ?? false);
2040
2193
  const path = options.path ?? DEFAULT_PATH;
2041
2194
  const includeStore = options.externalStore !== true;
2042
2195
  applyGuards(options.guards);
@@ -2051,7 +2204,7 @@ var AgentModule = class _AgentModule {
2051
2204
  controllers: controllersFor(options.attachmentsUpload === true),
2052
2205
  providers: [
2053
2206
  {
2054
- provide: AGENT_OPTIONS4,
2207
+ provide: AGENT_OPTIONS5,
2055
2208
  useFactory: options.useFactory,
2056
2209
  inject: options.inject ?? []
2057
2210
  },
@@ -2062,7 +2215,7 @@ var AgentModule = class _AgentModule {
2062
2215
  };
2063
2216
  }
2064
2217
  };
2065
- AgentModule = _ts_decorate15([
2218
+ AgentModule = _ts_decorate16([
2066
2219
  Global2(),
2067
2220
  Module2({})
2068
2221
  ], AgentModule);
@@ -2079,7 +2232,9 @@ function agentDurable(options) {
2079
2232
  }
2080
2233
  __name(agentDurable, "agentDurable");
2081
2234
  export {
2235
+ AGENT_DISPATCHED_STEPS,
2082
2236
  AgentDurableModule,
2237
+ AgentRunSteps,
2083
2238
  AgentRunWorkflow,
2084
2239
  DurableAgentRunner,
2085
2240
  agentDurable