@dudousxd/nestjs-agent 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,14 +2,59 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/agent.module.ts
5
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS7, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
6
- import { Global, Logger as Logger6, Module } from "@nestjs/common";
5
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS9, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE7, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
6
+ import { Global, Logger as Logger7, Module as Module2 } from "@nestjs/common";
7
7
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
8
8
 
9
9
  // src/agent-deps.factory.ts
10
+ import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
10
11
  import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_SKILLS, AGENT_STORE, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, findPersona, intersectAllowLists, normalizeDelegation, personaCatalogEntry, resolvePersonaAlias, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
11
12
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
12
- import { BadRequestException, Inject, Injectable, Optional } from "@nestjs/common";
13
+ import { BadRequestException, Inject as Inject2, Injectable, Optional } from "@nestjs/common";
14
+
15
+ // src/genui/agent-genui.module.ts
16
+ import { defineCatalog, genuiTools } from "@dudousxd/nestjs-agent-core/genui";
17
+ import { Inject, Module } from "@nestjs/common";
18
+
19
+ // src/functional-tool.ts
20
+ var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
21
+ function brand(tool) {
22
+ return {
23
+ [AGENT_TOOL_BRAND]: true,
24
+ spec: tool.spec,
25
+ handler: tool.handler
26
+ };
27
+ }
28
+ __name(brand, "brand");
29
+ function isBrandedFunctionalTool(value) {
30
+ return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
31
+ }
32
+ __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
33
+ function provideAgentTool(factoryOrTool, inject) {
34
+ const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
35
+ if (typeof factoryOrTool === "function") {
36
+ return {
37
+ provide,
38
+ useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
39
+ inject: inject ?? []
40
+ };
41
+ }
42
+ return {
43
+ provide,
44
+ useValue: brand(factoryOrTool)
45
+ };
46
+ }
47
+ __name(provideAgentTool, "provideAgentTool");
48
+ function provideAgentTools(factory, inject) {
49
+ return {
50
+ provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
51
+ useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
52
+ inject: inject ?? []
53
+ };
54
+ }
55
+ __name(provideAgentTools, "provideAgentTools");
56
+
57
+ // src/genui/agent-genui.module.ts
13
58
  function _ts_decorate(decorators, target, key, desc) {
14
59
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
60
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -24,6 +69,124 @@ function _ts_decorate(decorators, target, key, desc) {
24
69
  return c > 3 && r && Object.defineProperty(target, key, r), r;
25
70
  }
26
71
  __name(_ts_decorate, "_ts_decorate");
72
+ var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
73
+ var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
74
+ var GenuiCatalogResolver = class {
75
+ static {
76
+ __name(this, "GenuiCatalogResolver");
77
+ }
78
+ };
79
+ function resolverProviders(resolver) {
80
+ if (resolver === void 0) return [];
81
+ return [
82
+ typeof resolver === "function" ? {
83
+ provide: GenuiCatalogResolver,
84
+ useClass: resolver
85
+ } : {
86
+ provide: GenuiCatalogResolver,
87
+ useValue: resolver
88
+ }
89
+ ];
90
+ }
91
+ __name(resolverProviders, "resolverProviders");
92
+ function toolOptions(options, resolver) {
93
+ const { catalog: _catalog, ...rest } = options;
94
+ return {
95
+ ...rest,
96
+ ...resolver !== void 0 ? {
97
+ resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
98
+ } : {}
99
+ };
100
+ }
101
+ __name(toolOptions, "toolOptions");
102
+ function coreProviders(resolver) {
103
+ return [
104
+ {
105
+ provide: GENUI_CATALOG,
106
+ useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? defineCatalog([]), "useFactory"),
107
+ inject: [
108
+ GENUI_OPTIONS
109
+ ]
110
+ },
111
+ ...resolverProviders(resolver),
112
+ // The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
113
+ // Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
114
+ provideAgentTools((options, catalog, perRequest) => genuiTools(catalog, toolOptions(options, perRequest)), [
115
+ GENUI_OPTIONS,
116
+ GENUI_CATALOG,
117
+ {
118
+ token: GenuiCatalogResolver,
119
+ optional: true
120
+ }
121
+ ])
122
+ ];
123
+ }
124
+ __name(coreProviders, "coreProviders");
125
+ var EXPORTS = [
126
+ GENUI_CATALOG,
127
+ GENUI_OPTIONS
128
+ ];
129
+ var AgentGenuiModule = class _AgentGenuiModule {
130
+ static {
131
+ __name(this, "AgentGenuiModule");
132
+ }
133
+ static forRoot(options = {}) {
134
+ const { resolver, ...rest } = options;
135
+ return {
136
+ module: _AgentGenuiModule,
137
+ global: true,
138
+ providers: [
139
+ {
140
+ provide: GENUI_OPTIONS,
141
+ useValue: rest
142
+ },
143
+ ...coreProviders(resolver)
144
+ ],
145
+ exports: resolver === void 0 ? EXPORTS : [
146
+ ...EXPORTS,
147
+ GenuiCatalogResolver
148
+ ]
149
+ };
150
+ }
151
+ static forRootAsync(options) {
152
+ return {
153
+ module: _AgentGenuiModule,
154
+ global: true,
155
+ imports: options.imports ?? [],
156
+ providers: [
157
+ {
158
+ provide: GENUI_OPTIONS,
159
+ useFactory: options.useFactory,
160
+ inject: options.inject ?? []
161
+ },
162
+ ...coreProviders(options.resolver)
163
+ ],
164
+ exports: options.resolver === void 0 ? EXPORTS : [
165
+ ...EXPORTS,
166
+ GenuiCatalogResolver
167
+ ]
168
+ };
169
+ }
170
+ };
171
+ AgentGenuiModule = _ts_decorate([
172
+ Module({})
173
+ ], AgentGenuiModule);
174
+
175
+ // src/agent-deps.factory.ts
176
+ function _ts_decorate2(decorators, target, key, desc) {
177
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
178
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
179
+ r = Reflect.decorate(decorators, target, key, desc);
180
+ } else {
181
+ for (var i = decorators.length - 1; i >= 0; i--) {
182
+ if (d = decorators[i]) {
183
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
184
+ }
185
+ }
186
+ }
187
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
188
+ }
189
+ __name(_ts_decorate2, "_ts_decorate");
27
190
  function _ts_metadata(metadataKey, metadataValue) {
28
191
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
29
192
  return Reflect.metadata(metadataKey, metadataValue);
@@ -56,7 +219,9 @@ var AgentDepsFactory2 = class {
56
219
  pricingStore;
57
220
  skills;
58
221
  memory;
59
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory) {
222
+ uiCatalog;
223
+ uiCatalogResolver;
224
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
60
225
  this.options = options;
61
226
  this.model = model;
62
227
  this.store = store;
@@ -68,6 +233,9 @@ var AgentDepsFactory2 = class {
68
233
  this.pricingStore = pricingStore;
69
234
  this.skills = skills;
70
235
  this.memory = memory;
236
+ this.uiCatalog = uiCatalog;
237
+ this.uiCatalogResolver = uiCatalogResolver;
238
+ if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
71
239
  }
72
240
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
73
241
  memoryConfig() {
@@ -156,6 +324,18 @@ var AgentDepsFactory2 = class {
156
324
  }
157
325
  return definition?.defaultPersona;
158
326
  }
327
+ forProposal(proposal, _actor) {
328
+ const name = proposal.executionContext?.agentName;
329
+ if (name !== void 0 && !this.agents.has(name) && !(name === "default" && this.defaultAgentName() === "default" && this.agents.list().length === 0)) throw new Error(`Recorded agent ${name} no longer exists`);
330
+ const deps = this.forAgent(name);
331
+ const id = proposal.executionContext?.persona;
332
+ if (id !== void 0) {
333
+ const persona = deps.personas?.find((persona2) => persona2.id === id);
334
+ if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
335
+ return this.withPersona(deps, persona);
336
+ }
337
+ return deps;
338
+ }
159
339
  forAgent(agentName) {
160
340
  const name = agentName ?? this.defaultAgentName();
161
341
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -174,12 +354,27 @@ var AgentDepsFactory2 = class {
174
354
  return {
175
355
  model: this.model,
176
356
  store: this.store,
357
+ ...this.options.actionApprovalMode !== void 0 ? {
358
+ actionApprovalMode: this.options.actionApprovalMode
359
+ } : {},
177
360
  sink: this.sink,
178
361
  rolesPolicy: this.rolesPolicy,
179
362
  ...this.options.approvalPolicy !== void 0 ? {
180
363
  approvalPolicy: this.options.approvalPolicy
181
364
  } : {},
182
365
  registry: this.registry,
366
+ ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
367
+ resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
368
+ const catalog = this.uiCatalogResolver?.resolve({
369
+ ...scope,
370
+ ...scope.actor.tenantRef !== void 0 ? {
371
+ tenant: scope.actor.tenantRef
372
+ } : {}
373
+ }) ?? this.uiCatalog;
374
+ if (!catalog) throw new Error("UI catalog unavailable");
375
+ return catalog;
376
+ }, "resolveUiCatalog")
377
+ } : {},
183
378
  promptContributors: this.promptContributors,
184
379
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
185
380
  maxSteps: definition?.maxSteps ?? 8,
@@ -330,22 +525,25 @@ var AgentDepsFactory2 = class {
330
525
  return void 0;
331
526
  }
332
527
  };
333
- AgentDepsFactory2 = _ts_decorate([
528
+ AgentDepsFactory2 = _ts_decorate2([
334
529
  Injectable(),
335
- _ts_param(0, Inject(AGENT_OPTIONS)),
336
- _ts_param(1, Inject(AGENT_MODEL)),
337
- _ts_param(2, Inject(AGENT_STORE)),
338
- _ts_param(3, Inject(AGENT_SINK)),
339
- _ts_param(4, Inject(AGENT_ROLES_POLICY)),
340
- _ts_param(5, Inject(AGENT_TOOL_REGISTRY)),
341
- _ts_param(6, Inject(AGENT_REGISTRY)),
342
- _ts_param(7, Inject(AGENT_PROMPT_CONTRIBUTORS)),
530
+ _ts_param(0, Inject2(AGENT_OPTIONS)),
531
+ _ts_param(1, Inject2(AGENT_MODEL)),
532
+ _ts_param(2, Inject2(AGENT_STORE)),
533
+ _ts_param(3, Inject2(AGENT_SINK)),
534
+ _ts_param(4, Inject2(AGENT_ROLES_POLICY)),
535
+ _ts_param(5, Inject2(AGENT_TOOL_REGISTRY)),
536
+ _ts_param(6, Inject2(AGENT_REGISTRY)),
537
+ _ts_param(7, Inject2(AGENT_PROMPT_CONTRIBUTORS)),
343
538
  _ts_param(8, Optional()),
344
- _ts_param(8, Inject(AGENT_PRICING_STORE)),
539
+ _ts_param(8, Inject2(AGENT_PRICING_STORE)),
345
540
  _ts_param(9, Optional()),
346
- _ts_param(9, Inject(AGENT_SKILLS)),
541
+ _ts_param(9, Inject2(AGENT_SKILLS)),
347
542
  _ts_param(10, Optional()),
348
- _ts_param(10, Inject(AGENT_MEMORY)),
543
+ _ts_param(10, Inject2(AGENT_MEMORY)),
544
+ _ts_param(11, Optional()),
545
+ _ts_param(11, Inject2(GENUI_CATALOG)),
546
+ _ts_param(12, Optional()),
349
547
  _ts_metadata("design:type", Function),
350
548
  _ts_metadata("design:paramtypes", [
351
549
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -358,13 +556,15 @@ AgentDepsFactory2 = _ts_decorate([
358
556
  Array,
359
557
  Object,
360
558
  Object,
361
- Object
559
+ Object,
560
+ typeof Catalog === "undefined" ? Object : Catalog,
561
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
362
562
  ])
363
563
  ], AgentDepsFactory2);
364
564
 
365
565
  // src/agent.service.ts
366
- import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE3, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, settleDeadRun, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
367
- import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject3, Injectable as Injectable3, NotFoundException, NotImplementedException as NotImplementedException2, Optional as Optional3 } from "@nestjs/common";
566
+ import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval as mayDecideApproval2, readElicitationQuestions, settleDeadRun, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
567
+ import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException as ForbiddenException2, GoneException, HttpException, HttpStatus, Inject as Inject5, Injectable as Injectable4, NotFoundException as NotFoundException2, NotImplementedException as NotImplementedException3, Optional as Optional3 } from "@nestjs/common";
368
568
 
369
569
  // src/agent-deps.ts
370
570
  function utcDay(date = /* @__PURE__ */ new Date()) {
@@ -388,9 +588,159 @@ function childSinkWriter(writer) {
388
588
  }
389
589
  __name(childSinkWriter, "childSinkWriter");
390
590
 
591
+ // src/proposals/action-proposal.service.ts
592
+ import { AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_STORE as AGENT_STORE2, mayDecideApproval, parseTextActionProposalCommand, resolveTextActionProposalDecision } from "@dudousxd/nestjs-agent-core";
593
+ import { ForbiddenException, Inject as Inject3, Injectable as Injectable2, NotFoundException, NotImplementedException } from "@nestjs/common";
594
+ function _ts_decorate3(decorators, target, key, desc) {
595
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
596
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
597
+ r = Reflect.decorate(decorators, target, key, desc);
598
+ } else {
599
+ for (var i = decorators.length - 1; i >= 0; i--) {
600
+ if (d = decorators[i]) {
601
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
602
+ }
603
+ }
604
+ }
605
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
606
+ }
607
+ __name(_ts_decorate3, "_ts_decorate");
608
+ function _ts_metadata2(metadataKey, metadataValue) {
609
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
610
+ return Reflect.metadata(metadataKey, metadataValue);
611
+ }
612
+ }
613
+ __name(_ts_metadata2, "_ts_metadata");
614
+ function _ts_param2(paramIndex, decorator) {
615
+ return function(target, key) {
616
+ decorator(target, key, paramIndex);
617
+ };
618
+ }
619
+ __name(_ts_param2, "_ts_param");
620
+ var ActionProposalService = class {
621
+ static {
622
+ __name(this, "ActionProposalService");
623
+ }
624
+ store;
625
+ options;
626
+ constructor(store, options) {
627
+ this.store = store;
628
+ this.options = options;
629
+ }
630
+ capability() {
631
+ const store = this.store;
632
+ if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new NotImplementedException("Action proposals are unavailable");
633
+ return store;
634
+ }
635
+ async scope(threadId, actor) {
636
+ const scope = await this.capability().getThreadActionProposalScope(threadId);
637
+ if (!scope) throw new NotFoundException("Thread not found");
638
+ if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new ForbiddenException("Wrong proposal tenant");
639
+ return scope;
640
+ }
641
+ mayDecide(actor, proposal) {
642
+ return mayDecideApproval(this.options.approvalPolicy, actor, {
643
+ toolCallId: proposal.originToolCallId,
644
+ approver: proposal.approver,
645
+ requesterRef: proposal.actorRef
646
+ });
647
+ }
648
+ async listPage(threadId, actor, query = {}) {
649
+ const scope = await this.scope(threadId, actor);
650
+ const rows = await this.capability().listActionProposals(scope, {
651
+ limit: 1e3,
652
+ ...query
653
+ });
654
+ const visible = [];
655
+ for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
656
+ const last = rows.at(-1);
657
+ return {
658
+ items: visible,
659
+ ...rows.length === 1e3 && last ? {
660
+ next: {
661
+ createdAt: last.createdAt,
662
+ id: last.id
663
+ }
664
+ } : {}
665
+ };
666
+ }
667
+ async list(threadId, actor) {
668
+ return (await this.listPage(threadId, actor)).items;
669
+ }
670
+ async decide(threadId, proposalId, actor, command) {
671
+ const scope = await this.scope(threadId, actor);
672
+ const proposal = await this.capability().getActionProposal(scope, proposalId);
673
+ if (!proposal) throw new NotFoundException("Proposal not found");
674
+ if (!await this.mayDecide(actor, proposal)) throw new ForbiddenException("May not decide this proposal");
675
+ return this.capability().decideActionProposal(scope, proposalId, {
676
+ decision: command.decision,
677
+ actorRef: actor.id,
678
+ via: command.via ?? "web",
679
+ ...command.remember !== void 0 ? {
680
+ remember: command.remember
681
+ } : {},
682
+ ...command.reason !== void 0 ? {
683
+ reason: command.reason
684
+ } : {}
685
+ });
686
+ }
687
+ async handleTextDecision(threadId, actor, text) {
688
+ const command = parseTextActionProposalCommand(text);
689
+ if (command.status === "unmatched") return command;
690
+ if (command.proposalId !== void 0) {
691
+ const result2 = await this.decide(threadId, command.proposalId, actor, {
692
+ decision: command.decision,
693
+ remember: command.remember,
694
+ via: "text"
695
+ });
696
+ return this.textReceipt(threadId, result2);
697
+ }
698
+ const candidates = [];
699
+ const scope = await this.scope(threadId, actor);
700
+ const pending = await this.capability().listActionProposals(scope, {
701
+ decision: "pending",
702
+ limit: 1e3
703
+ });
704
+ for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
705
+ const resolution = resolveTextActionProposalDecision(text, candidates);
706
+ if (resolution.status === "unmatched") return resolution;
707
+ if (resolution.status === "ambiguous" || resolution.status === "decision" && pending.length === 1e3 && !text.includes("#")) return {
708
+ threadId,
709
+ proposalDecision: {
710
+ status: "ambiguous",
711
+ proposalIds: candidates.map(({ id }) => id)
712
+ },
713
+ text: `Choose the action to decide: ${candidates.map(({ id }) => id).map((id) => `#${id}`).join(", ")}`
714
+ };
715
+ const result = await this.decide(threadId, resolution.proposalId, actor, {
716
+ decision: resolution.decision,
717
+ remember: resolution.remember,
718
+ via: "text"
719
+ });
720
+ return this.textReceipt(threadId, result);
721
+ }
722
+ textReceipt(threadId, result) {
723
+ return {
724
+ threadId,
725
+ proposalDecision: result,
726
+ text: result.proposal?.decision === "approved" ? "Action approved and queued for execution." : `Action ${result.proposal?.decision ?? result.status}; no execution was performed by this decision.`
727
+ };
728
+ }
729
+ };
730
+ ActionProposalService = _ts_decorate3([
731
+ Injectable2(),
732
+ _ts_param2(0, Inject3(AGENT_STORE2)),
733
+ _ts_param2(1, Inject3(AGENT_OPTIONS2)),
734
+ _ts_metadata2("design:type", Function),
735
+ _ts_metadata2("design:paramtypes", [
736
+ typeof AgentStore === "undefined" ? Object : AgentStore,
737
+ typeof Pick === "undefined" ? Object : Pick
738
+ ])
739
+ ], ActionProposalService);
740
+
391
741
  // src/queue/chat-queue.service.ts
392
- import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE2, encodeStreamEvent, isChatQueueStore, queuedMessageView } from "@dudousxd/nestjs-agent-core";
393
- import { Inject as Inject2, Injectable as Injectable2, Logger, NotImplementedException, Optional as Optional2 } from "@nestjs/common";
742
+ import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE3, encodeStreamEvent, isChatQueueStore, queuedMessageView } from "@dudousxd/nestjs-agent-core";
743
+ import { Inject as Inject4, Injectable as Injectable3, Logger, NotImplementedException as NotImplementedException2, Optional as Optional2 } from "@nestjs/common";
394
744
 
395
745
  // src/thread-persona.ts
396
746
  async function threadPersona(store, threadId) {
@@ -403,7 +753,7 @@ async function threadPersona(store, threadId) {
403
753
  __name(threadPersona, "threadPersona");
404
754
 
405
755
  // src/queue/chat-queue.service.ts
406
- function _ts_decorate2(decorators, target, key, desc) {
756
+ function _ts_decorate4(decorators, target, key, desc) {
407
757
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
408
758
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
409
759
  r = Reflect.decorate(decorators, target, key, desc);
@@ -416,19 +766,19 @@ function _ts_decorate2(decorators, target, key, desc) {
416
766
  }
417
767
  return c > 3 && r && Object.defineProperty(target, key, r), r;
418
768
  }
419
- __name(_ts_decorate2, "_ts_decorate");
420
- function _ts_metadata2(metadataKey, metadataValue) {
769
+ __name(_ts_decorate4, "_ts_decorate");
770
+ function _ts_metadata3(metadataKey, metadataValue) {
421
771
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
422
772
  return Reflect.metadata(metadataKey, metadataValue);
423
773
  }
424
774
  }
425
- __name(_ts_metadata2, "_ts_metadata");
426
- function _ts_param2(paramIndex, decorator) {
775
+ __name(_ts_metadata3, "_ts_metadata");
776
+ function _ts_param3(paramIndex, decorator) {
427
777
  return function(target, key) {
428
778
  decorator(target, key, paramIndex);
429
779
  };
430
780
  }
431
- __name(_ts_param2, "_ts_param");
781
+ __name(_ts_param3, "_ts_param");
432
782
  var MAX_DRAIN_ATTEMPTS = 8;
433
783
  var ChatQueueService = class _ChatQueueService {
434
784
  static {
@@ -461,7 +811,7 @@ var ChatQueueService = class _ChatQueueService {
461
811
  /** The bound store as a queue store, or a 501 naming what is missing. */
462
812
  queueStore() {
463
813
  if (!isChatQueueStore(this.store)) {
464
- throw new NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
814
+ throw new NotImplementedException2("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
465
815
  }
466
816
  return this.store;
467
817
  }
@@ -688,6 +1038,9 @@ var ChatQueueService = class _ChatQueueService {
688
1038
  } : {},
689
1039
  ...input.pageContext !== void 0 ? {
690
1040
  pageContext: input.pageContext
1041
+ } : {},
1042
+ ...input.uiCapabilities !== void 0 ? {
1043
+ uiCapabilities: input.uiCapabilities
691
1044
  } : {}
692
1045
  });
693
1046
  await store.setQueuePause(threadId, {
@@ -768,6 +1121,9 @@ var ChatQueueService = class _ChatQueueService {
768
1121
  ...message.pageContext !== void 0 ? {
769
1122
  pageContext: message.pageContext
770
1123
  } : {},
1124
+ ...message.uiCapabilities !== void 0 ? {
1125
+ uiCapabilities: message.uiCapabilities
1126
+ } : {},
771
1127
  ...message.model !== void 0 ? {
772
1128
  model: message.model
773
1129
  } : {}
@@ -821,20 +1177,20 @@ var ChatQueueService = class _ChatQueueService {
821
1177
  }));
822
1178
  }
823
1179
  };
824
- ChatQueueService = _ts_decorate2([
825
- Injectable2(),
826
- _ts_param2(0, Inject2(AGENT_STORE2)),
827
- _ts_param2(1, Inject2(AGENT_SINK2)),
828
- _ts_param2(2, Optional2()),
829
- _ts_param2(2, Inject2(AGENT_QUOTA_PROVIDER)),
830
- _ts_param2(3, Optional2()),
831
- _ts_param2(3, Inject2(AGENT_OPTIONS2)),
832
- _ts_param2(4, Optional2()),
833
- _ts_param2(4, Inject2(AGENT_ATTACHMENT_STAGING)),
834
- _ts_param2(5, Optional2()),
835
- _ts_param2(5, Inject2(AGENT_DEPS_FACTORY)),
836
- _ts_metadata2("design:type", Function),
837
- _ts_metadata2("design:paramtypes", [
1180
+ ChatQueueService = _ts_decorate4([
1181
+ Injectable3(),
1182
+ _ts_param3(0, Inject4(AGENT_STORE3)),
1183
+ _ts_param3(1, Inject4(AGENT_SINK2)),
1184
+ _ts_param3(2, Optional2()),
1185
+ _ts_param3(2, Inject4(AGENT_QUOTA_PROVIDER)),
1186
+ _ts_param3(3, Optional2()),
1187
+ _ts_param3(3, Inject4(AGENT_OPTIONS3)),
1188
+ _ts_param3(4, Optional2()),
1189
+ _ts_param3(4, Inject4(AGENT_ATTACHMENT_STAGING)),
1190
+ _ts_param3(5, Optional2()),
1191
+ _ts_param3(5, Inject4(AGENT_DEPS_FACTORY)),
1192
+ _ts_metadata3("design:type", Function),
1193
+ _ts_metadata3("design:paramtypes", [
838
1194
  typeof AgentStore === "undefined" ? Object : AgentStore,
839
1195
  typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
840
1196
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
@@ -886,7 +1242,7 @@ var RunNotActiveException = class extends ConflictException {
886
1242
  };
887
1243
 
888
1244
  // src/agent.service.ts
889
- function _ts_decorate3(decorators, target, key, desc) {
1245
+ function _ts_decorate5(decorators, target, key, desc) {
890
1246
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
891
1247
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
892
1248
  r = Reflect.decorate(decorators, target, key, desc);
@@ -899,19 +1255,19 @@ function _ts_decorate3(decorators, target, key, desc) {
899
1255
  }
900
1256
  return c > 3 && r && Object.defineProperty(target, key, r), r;
901
1257
  }
902
- __name(_ts_decorate3, "_ts_decorate");
903
- function _ts_metadata3(metadataKey, metadataValue) {
1258
+ __name(_ts_decorate5, "_ts_decorate");
1259
+ function _ts_metadata4(metadataKey, metadataValue) {
904
1260
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
905
1261
  return Reflect.metadata(metadataKey, metadataValue);
906
1262
  }
907
1263
  }
908
- __name(_ts_metadata3, "_ts_metadata");
909
- function _ts_param3(paramIndex, decorator) {
1264
+ __name(_ts_metadata4, "_ts_metadata");
1265
+ function _ts_param4(paramIndex, decorator) {
910
1266
  return function(target, key) {
911
1267
  decorator(target, key, paramIndex);
912
1268
  };
913
1269
  }
914
- __name(_ts_param3, "_ts_param");
1270
+ __name(_ts_param4, "_ts_param");
915
1271
  var AgentService = class {
916
1272
  static {
917
1273
  __name(this, "AgentService");
@@ -924,7 +1280,8 @@ var AgentService = class {
924
1280
  quotaProvider;
925
1281
  options;
926
1282
  queue;
927
- constructor(runner, store, deps, staging, models, quotaProvider, options, queue) {
1283
+ proposals;
1284
+ constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
928
1285
  this.runner = runner;
929
1286
  this.store = store;
930
1287
  this.deps = deps;
@@ -933,6 +1290,13 @@ var AgentService = class {
933
1290
  this.quotaProvider = quotaProvider;
934
1291
  this.options = options;
935
1292
  this.queue = queue;
1293
+ this.proposals = proposals;
1294
+ }
1295
+ async handleTextDecision(threadId, actor, text) {
1296
+ if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
1297
+ status: "unmatched"
1298
+ };
1299
+ return this.proposals.handleTextDecision(threadId, actor, text);
936
1300
  }
937
1301
  /** The queue service when the bound store can hold a queue, else `undefined`. */
938
1302
  queueing() {
@@ -942,7 +1306,7 @@ var AgentService = class {
942
1306
  requireQueue() {
943
1307
  const queue = this.queueing();
944
1308
  if (queue === void 0) {
945
- throw new NotImplementedException2("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
1309
+ throw new NotImplementedException3("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
946
1310
  }
947
1311
  return queue;
948
1312
  }
@@ -1064,7 +1428,10 @@ var AgentService = class {
1064
1428
  const result = await this.send({
1065
1429
  ...params,
1066
1430
  mode: "auto"
1431
+ }, {
1432
+ textDecisions: false
1067
1433
  });
1434
+ if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
1068
1435
  if (result.queued !== true) {
1069
1436
  return result;
1070
1437
  }
@@ -1092,7 +1459,11 @@ var AgentService = class {
1092
1459
  * Send a message: start a turn, or — when its thread already has one running — queue the message
1093
1460
  * to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
1094
1461
  */
1095
- async send(params) {
1462
+ async send(params, sendOptions = {}) {
1463
+ if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
1464
+ const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
1465
+ if ("proposalDecision" in decision) return decision;
1466
+ }
1096
1467
  await this.assertWithinQuota(params.actor);
1097
1468
  const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
1098
1469
  const agentName = target.agentName;
@@ -1141,12 +1512,16 @@ var AgentService = class {
1141
1512
  ...params.pageContext !== void 0 ? {
1142
1513
  pageContext: params.pageContext
1143
1514
  } : {},
1515
+ ...params.uiCapabilities !== void 0 ? {
1516
+ uiCapabilities: params.uiCapabilities
1517
+ } : {},
1144
1518
  ...model !== void 0 ? {
1145
1519
  model
1146
1520
  } : {}
1147
1521
  };
1148
1522
  const queue = this.queueing();
1149
1523
  if (queue === void 0) {
1524
+ if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
1150
1525
  const { runId } = await this.runner.start(input);
1151
1526
  await this.store.setActiveStream(threadId, runId);
1152
1527
  return {
@@ -1227,6 +1602,9 @@ var AgentService = class {
1227
1602
  ...input.pageContext !== void 0 ? {
1228
1603
  pageContext: input.pageContext
1229
1604
  } : {},
1605
+ ...input.uiCapabilities !== void 0 ? {
1606
+ uiCapabilities: input.uiCapabilities
1607
+ } : {},
1230
1608
  ...interrupting !== void 0 ? {
1231
1609
  interrupt: true,
1232
1610
  at: "head"
@@ -1331,7 +1709,7 @@ var AgentService = class {
1331
1709
  throw gone();
1332
1710
  }
1333
1711
  if (marked.interrupt !== true) {
1334
- throw new NotImplementedException2("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
1712
+ throw new NotImplementedException3("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
1335
1713
  }
1336
1714
  if (!await store.moveQueuedMessage(messageId, 0)) {
1337
1715
  throw gone();
@@ -1390,7 +1768,7 @@ var AgentService = class {
1390
1768
  async assertOwnsQueuedMessage(actor, messageId) {
1391
1769
  const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
1392
1770
  if (message === null) {
1393
- throw new NotFoundException(`queued message ${messageId} not found`);
1771
+ throw new NotFoundException2(`queued message ${messageId} not found`);
1394
1772
  }
1395
1773
  await this.assertOwnsThread(actor, message.threadId);
1396
1774
  return message.threadId;
@@ -1411,7 +1789,7 @@ var AgentService = class {
1411
1789
  }
1412
1790
  const staging = this.staging;
1413
1791
  if (staging === void 0 || typeof staging.resolve !== "function") {
1414
- throw new NotImplementedException2("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
1792
+ throw new NotImplementedException3("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
1415
1793
  }
1416
1794
  const resolved = [];
1417
1795
  for (const ref of refs) {
@@ -1420,7 +1798,7 @@ var AgentService = class {
1420
1798
  actor
1421
1799
  });
1422
1800
  if (attachment === null) {
1423
- throw new ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
1801
+ throw new ForbiddenException2(`attachment ${ref.mediaId} is not available to this actor`);
1424
1802
  }
1425
1803
  resolved.push(attachment);
1426
1804
  }
@@ -1522,6 +1900,7 @@ var AgentService = class {
1522
1900
  * not the thread's own actor).
1523
1901
  */
1524
1902
  async signalToolCall(toolCallId2, reply) {
1903
+ if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new ConflictException2("Independent proposals require the scoped proposal decision route");
1525
1904
  await this.assertNotExpired(toolCallId2);
1526
1905
  const runId = await this.resolveRunForToolCall(toolCallId2);
1527
1906
  await this.assertRunWaiting(runId);
@@ -1562,7 +1941,7 @@ var AgentService = class {
1562
1941
  throw new RunNotActiveException(runId);
1563
1942
  }
1564
1943
  if (owner !== actor.id) {
1565
- throw new ForbiddenException("run belongs to another actor");
1944
+ throw new ForbiddenException2("run belongs to another actor");
1566
1945
  }
1567
1946
  }
1568
1947
  /**
@@ -1622,7 +2001,7 @@ var AgentService = class {
1622
2001
  return;
1623
2002
  }
1624
2003
  if (this.store.updateThread === void 0) {
1625
- throw new NotImplementedException2("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
2004
+ throw new NotImplementedException3("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
1626
2005
  }
1627
2006
  const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
1628
2007
  if (patch.persona !== void 0 && patch.persona !== null) {
@@ -1793,11 +2172,11 @@ var AgentService = class {
1793
2172
  throw new BadRequestException2("comment must be at most 2000 characters");
1794
2173
  }
1795
2174
  if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
1796
- throw new NotImplementedException2("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
2175
+ throw new NotImplementedException3("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
1797
2176
  }
1798
2177
  const threadId = await this.store.threadOfMessage(messageId);
1799
2178
  if (threadId === null) {
1800
- throw new NotFoundException(`message ${messageId} not found`);
2179
+ throw new NotFoundException2(`message ${messageId} not found`);
1801
2180
  }
1802
2181
  await this.assertOwnsThread(actor, threadId);
1803
2182
  const feedback = input.value === null ? null : {
@@ -1845,7 +2224,7 @@ var AgentService = class {
1845
2224
  const list = this.attachmentInventory();
1846
2225
  const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
1847
2226
  if (referencedMediaIds === void 0) {
1848
- throw new NotImplementedException2("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
2227
+ throw new NotImplementedException3("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
1849
2228
  }
1850
2229
  const stagedBefore = options.olderThan.toISOString();
1851
2230
  const inventory = await list({
@@ -1867,7 +2246,7 @@ var AgentService = class {
1867
2246
  attachmentInventory() {
1868
2247
  const list = this.staging?.list?.bind(this.staging);
1869
2248
  if (list === void 0) {
1870
- throw new NotImplementedException2("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
2249
+ throw new NotImplementedException3("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
1871
2250
  }
1872
2251
  return list;
1873
2252
  }
@@ -1878,10 +2257,10 @@ var AgentService = class {
1878
2257
  async assertOwnsThread(actor, threadId) {
1879
2258
  const owner = await this.store.ownerOfThread(threadId);
1880
2259
  if (owner === null) {
1881
- throw new NotFoundException(`thread ${threadId} not found`);
2260
+ throw new NotFoundException2(`thread ${threadId} not found`);
1882
2261
  }
1883
2262
  if (owner !== actor.id) {
1884
- throw new ForbiddenException("thread belongs to another actor");
2263
+ throw new ForbiddenException2("thread belongs to another actor");
1885
2264
  }
1886
2265
  }
1887
2266
  /**
@@ -1892,10 +2271,10 @@ var AgentService = class {
1892
2271
  async assertOwnsToolCall(actor, toolCallId2) {
1893
2272
  const owner = await this.store.ownerOfToolCall(toolCallId2);
1894
2273
  if (owner === null) {
1895
- throw new NotFoundException(`tool call ${toolCallId2} not found`);
2274
+ throw new NotFoundException2(`tool call ${toolCallId2} not found`);
1896
2275
  }
1897
2276
  if (owner !== actor.id) {
1898
- throw new ForbiddenException("tool call belongs to another actor");
2277
+ throw new ForbiddenException2("tool call belongs to another actor");
1899
2278
  }
1900
2279
  }
1901
2280
  /**
@@ -1933,15 +2312,15 @@ var AgentService = class {
1933
2312
  }
1934
2313
  const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
1935
2314
  if (requesterRef === null) {
1936
- throw new NotFoundException(`tool call ${toolCallId2} not found`);
2315
+ throw new NotFoundException2(`tool call ${toolCallId2} not found`);
1937
2316
  }
1938
- const allowed = await mayDecideApproval(this.deps.forAgent().approvalPolicy, actor, {
2317
+ const allowed = await mayDecideApproval2(this.deps.forAgent().approvalPolicy, actor, {
1939
2318
  toolCallId: toolCallId2,
1940
2319
  approver,
1941
2320
  requesterRef
1942
2321
  });
1943
2322
  if (!allowed) {
1944
- throw new ForbiddenException(`this approval is for ${approver}`);
2323
+ throw new ForbiddenException2(`this approval is for ${approver}`);
1945
2324
  }
1946
2325
  }
1947
2326
  /**
@@ -1970,7 +2349,7 @@ var AgentService = class {
1970
2349
  async resolveRunForToolCall(toolCallId2) {
1971
2350
  const runId = await this.store.runForToolCall(toolCallId2);
1972
2351
  if (runId === null) {
1973
- throw new NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
2352
+ throw new NotFoundException2(`tool call ${toolCallId2} has no active run to signal`);
1974
2353
  }
1975
2354
  return runId;
1976
2355
  }
@@ -1978,29 +2357,30 @@ var AgentService = class {
1978
2357
  async assertOwnsActiveStream(actor, runId) {
1979
2358
  const owner = await this.store.ownerOfActiveStream(runId);
1980
2359
  if (owner === null) {
1981
- throw new NotFoundException(`no active run ${runId}`);
2360
+ throw new NotFoundException2(`no active run ${runId}`);
1982
2361
  }
1983
2362
  if (owner !== actor.id) {
1984
- throw new ForbiddenException("run belongs to another actor");
2363
+ throw new ForbiddenException2("run belongs to another actor");
1985
2364
  }
1986
2365
  }
1987
2366
  };
1988
- AgentService = _ts_decorate3([
1989
- Injectable3(),
1990
- _ts_param3(0, Inject3(AGENT_RUNNER)),
1991
- _ts_param3(1, Inject3(AGENT_STORE3)),
1992
- _ts_param3(2, Inject3(AGENT_DEPS_FACTORY2)),
1993
- _ts_param3(3, Optional3()),
1994
- _ts_param3(3, Inject3(AGENT_ATTACHMENT_STAGING2)),
1995
- _ts_param3(4, Optional3()),
1996
- _ts_param3(4, Inject3(AGENT_MODEL_CATALOG)),
1997
- _ts_param3(5, Optional3()),
1998
- _ts_param3(5, Inject3(AGENT_QUOTA_PROVIDER2)),
1999
- _ts_param3(6, Optional3()),
2000
- _ts_param3(6, Inject3(AGENT_OPTIONS3)),
2001
- _ts_param3(7, Optional3()),
2002
- _ts_metadata3("design:type", Function),
2003
- _ts_metadata3("design:paramtypes", [
2367
+ AgentService = _ts_decorate5([
2368
+ Injectable4(),
2369
+ _ts_param4(0, Inject5(AGENT_RUNNER)),
2370
+ _ts_param4(1, Inject5(AGENT_STORE4)),
2371
+ _ts_param4(2, Inject5(AGENT_DEPS_FACTORY2)),
2372
+ _ts_param4(3, Optional3()),
2373
+ _ts_param4(3, Inject5(AGENT_ATTACHMENT_STAGING2)),
2374
+ _ts_param4(4, Optional3()),
2375
+ _ts_param4(4, Inject5(AGENT_MODEL_CATALOG)),
2376
+ _ts_param4(5, Optional3()),
2377
+ _ts_param4(5, Inject5(AGENT_QUOTA_PROVIDER2)),
2378
+ _ts_param4(6, Optional3()),
2379
+ _ts_param4(6, Inject5(AGENT_OPTIONS4)),
2380
+ _ts_param4(7, Optional3()),
2381
+ _ts_param4(8, Optional3()),
2382
+ _ts_metadata4("design:type", Function),
2383
+ _ts_metadata4("design:paramtypes", [
2004
2384
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
2005
2385
  typeof AgentStore === "undefined" ? Object : AgentStore,
2006
2386
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
@@ -2008,13 +2388,14 @@ AgentService = _ts_decorate3([
2008
2388
  typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
2009
2389
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
2010
2390
  typeof Pick === "undefined" ? Object : Pick,
2011
- typeof ChatQueueService === "undefined" ? Object : ChatQueueService
2391
+ typeof ChatQueueService === "undefined" ? Object : ChatQueueService,
2392
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService
2012
2393
  ])
2013
2394
  ], AgentService);
2014
2395
 
2015
2396
  // src/approval-port.adapter.ts
2016
- import { Injectable as Injectable4 } from "@nestjs/common";
2017
- function _ts_decorate4(decorators, target, key, desc) {
2397
+ import { Injectable as Injectable5, NotImplementedException as NotImplementedException4, Optional as Optional4 } from "@nestjs/common";
2398
+ function _ts_decorate6(decorators, target, key, desc) {
2018
2399
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2019
2400
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2020
2401
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2027,20 +2408,48 @@ function _ts_decorate4(decorators, target, key, desc) {
2027
2408
  }
2028
2409
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2029
2410
  }
2030
- __name(_ts_decorate4, "_ts_decorate");
2031
- function _ts_metadata4(metadataKey, metadataValue) {
2411
+ __name(_ts_decorate6, "_ts_decorate");
2412
+ function _ts_metadata5(metadataKey, metadataValue) {
2032
2413
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2033
2414
  return Reflect.metadata(metadataKey, metadataValue);
2034
2415
  }
2035
2416
  }
2036
- __name(_ts_metadata4, "_ts_metadata");
2417
+ __name(_ts_metadata5, "_ts_metadata");
2418
+ function _ts_param5(paramIndex, decorator) {
2419
+ return function(target, key) {
2420
+ decorator(target, key, paramIndex);
2421
+ };
2422
+ }
2423
+ __name(_ts_param5, "_ts_param");
2037
2424
  var AgentApprovalPortAdapter = class {
2038
2425
  static {
2039
2426
  __name(this, "AgentApprovalPortAdapter");
2040
2427
  }
2041
2428
  agent;
2042
- constructor(agent) {
2429
+ proposals;
2430
+ constructor(agent, proposals) {
2043
2431
  this.agent = agent;
2432
+ this.proposals = proposals;
2433
+ }
2434
+ async approveActionProposal(actor, target, opts) {
2435
+ if (!this.proposals) throw new NotImplementedException4("Action proposals unavailable");
2436
+ return this.proposals.decide(target.threadId, target.proposalId, actor, {
2437
+ decision: "approved",
2438
+ ...opts?.remember !== void 0 ? {
2439
+ remember: opts.remember
2440
+ } : {},
2441
+ via: opts?.decidedVia ?? "console"
2442
+ });
2443
+ }
2444
+ async rejectActionProposal(actor, target, opts) {
2445
+ if (!this.proposals) throw new NotImplementedException4("Action proposals unavailable");
2446
+ return this.proposals.decide(target.threadId, target.proposalId, actor, {
2447
+ decision: "rejected",
2448
+ ...opts?.reason !== void 0 ? {
2449
+ reason: opts.reason
2450
+ } : {},
2451
+ via: opts?.decidedVia ?? "console"
2452
+ });
2044
2453
  }
2045
2454
  async approve(toolCallId2, opts) {
2046
2455
  await this.agent.signalToolCall(toolCallId2, {
@@ -2071,18 +2480,20 @@ var AgentApprovalPortAdapter = class {
2071
2480
  });
2072
2481
  }
2073
2482
  };
2074
- AgentApprovalPortAdapter = _ts_decorate4([
2075
- Injectable4(),
2076
- _ts_metadata4("design:type", Function),
2077
- _ts_metadata4("design:paramtypes", [
2078
- typeof AgentService === "undefined" ? Object : AgentService
2483
+ AgentApprovalPortAdapter = _ts_decorate6([
2484
+ Injectable5(),
2485
+ _ts_param5(1, Optional4()),
2486
+ _ts_metadata5("design:type", Function),
2487
+ _ts_metadata5("design:paramtypes", [
2488
+ typeof AgentService === "undefined" ? Object : AgentService,
2489
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService
2079
2490
  ])
2080
2491
  ], AgentApprovalPortAdapter);
2081
2492
 
2082
2493
  // src/controller/agents.controller.ts
2083
2494
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
2084
- import { Controller, Get, Inject as Inject4 } from "@nestjs/common";
2085
- function _ts_decorate5(decorators, target, key, desc) {
2495
+ import { Controller, Get, Inject as Inject6 } from "@nestjs/common";
2496
+ function _ts_decorate7(decorators, target, key, desc) {
2086
2497
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2087
2498
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2088
2499
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2095,19 +2506,19 @@ function _ts_decorate5(decorators, target, key, desc) {
2095
2506
  }
2096
2507
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2097
2508
  }
2098
- __name(_ts_decorate5, "_ts_decorate");
2099
- function _ts_metadata5(metadataKey, metadataValue) {
2509
+ __name(_ts_decorate7, "_ts_decorate");
2510
+ function _ts_metadata6(metadataKey, metadataValue) {
2100
2511
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2101
2512
  return Reflect.metadata(metadataKey, metadataValue);
2102
2513
  }
2103
2514
  }
2104
- __name(_ts_metadata5, "_ts_metadata");
2105
- function _ts_param4(paramIndex, decorator) {
2515
+ __name(_ts_metadata6, "_ts_metadata");
2516
+ function _ts_param6(paramIndex, decorator) {
2106
2517
  return function(target, key) {
2107
2518
  decorator(target, key, paramIndex);
2108
2519
  };
2109
2520
  }
2110
- __name(_ts_param4, "_ts_param");
2521
+ __name(_ts_param6, "_ts_param");
2111
2522
  var AgentsController = class {
2112
2523
  static {
2113
2524
  __name(this, "AgentsController");
@@ -2138,26 +2549,26 @@ var AgentsController = class {
2138
2549
  });
2139
2550
  }
2140
2551
  };
2141
- _ts_decorate5([
2552
+ _ts_decorate7([
2142
2553
  Get(),
2143
- _ts_metadata5("design:type", Function),
2144
- _ts_metadata5("design:paramtypes", []),
2145
- _ts_metadata5("design:returntype", Array)
2554
+ _ts_metadata6("design:type", Function),
2555
+ _ts_metadata6("design:paramtypes", []),
2556
+ _ts_metadata6("design:returntype", Array)
2146
2557
  ], AgentsController.prototype, "list", null);
2147
- AgentsController = _ts_decorate5([
2558
+ AgentsController = _ts_decorate7([
2148
2559
  Controller("agents"),
2149
- _ts_param4(0, Inject4(AGENT_REGISTRY2)),
2150
- _ts_param4(1, Inject4(AGENT_DEPS_FACTORY3)),
2151
- _ts_metadata5("design:type", Function),
2152
- _ts_metadata5("design:paramtypes", [
2560
+ _ts_param6(0, Inject6(AGENT_REGISTRY2)),
2561
+ _ts_param6(1, Inject6(AGENT_DEPS_FACTORY3)),
2562
+ _ts_metadata6("design:type", Function),
2563
+ _ts_metadata6("design:paramtypes", [
2153
2564
  typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
2154
2565
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
2155
2566
  ])
2156
2567
  ], AgentsController);
2157
2568
 
2158
2569
  // src/controller/attachments.controller.ts
2159
- import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
2160
- import { BadRequestException as BadRequestException3, Controller as Controller2, Get as Get2, Inject as Inject5, NotImplementedException as NotImplementedException3, Optional as Optional4, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
2570
+ import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS5 } from "@dudousxd/nestjs-agent-core";
2571
+ import { BadRequestException as BadRequestException3, Controller as Controller2, Get as Get2, Inject as Inject7, NotImplementedException as NotImplementedException5, Optional as Optional5, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
2161
2572
  import { FileInterceptor } from "@nestjs/platform-express";
2162
2573
 
2163
2574
  // src/attachment-limits.ts
@@ -2186,7 +2597,7 @@ function attachmentLimits(options, staging) {
2186
2597
  __name(attachmentLimits, "attachmentLimits");
2187
2598
 
2188
2599
  // src/controller/attachments.controller.ts
2189
- function _ts_decorate6(decorators, target, key, desc) {
2600
+ function _ts_decorate8(decorators, target, key, desc) {
2190
2601
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2191
2602
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2192
2603
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2199,19 +2610,19 @@ function _ts_decorate6(decorators, target, key, desc) {
2199
2610
  }
2200
2611
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2201
2612
  }
2202
- __name(_ts_decorate6, "_ts_decorate");
2203
- function _ts_metadata6(metadataKey, metadataValue) {
2613
+ __name(_ts_decorate8, "_ts_decorate");
2614
+ function _ts_metadata7(metadataKey, metadataValue) {
2204
2615
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2205
2616
  return Reflect.metadata(metadataKey, metadataValue);
2206
2617
  }
2207
2618
  }
2208
- __name(_ts_metadata6, "_ts_metadata");
2209
- function _ts_param5(paramIndex, decorator) {
2619
+ __name(_ts_metadata7, "_ts_metadata");
2620
+ function _ts_param7(paramIndex, decorator) {
2210
2621
  return function(target, key) {
2211
2622
  decorator(target, key, paramIndex);
2212
2623
  };
2213
2624
  }
2214
- __name(_ts_param5, "_ts_param");
2625
+ __name(_ts_param7, "_ts_param");
2215
2626
  var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
2216
2627
  var ATTACHMENT_PAGE_SIZE = 50;
2217
2628
  var AttachmentsController = class {
@@ -2245,7 +2656,7 @@ var AttachmentsController = class {
2245
2656
  }
2246
2657
  async upload(req, file) {
2247
2658
  if (this.staging === void 0) {
2248
- throw new NotImplementedException3("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2659
+ throw new NotImplementedException5("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
2249
2660
  }
2250
2661
  if (file === void 0) {
2251
2662
  throw new BadRequestException3('multipart field "file" is required');
@@ -2267,39 +2678,39 @@ var AttachmentsController = class {
2267
2678
  });
2268
2679
  }
2269
2680
  };
2270
- _ts_decorate6([
2681
+ _ts_decorate8([
2271
2682
  Get2(),
2272
- _ts_param5(0, Req()),
2273
- _ts_metadata6("design:type", Function),
2274
- _ts_metadata6("design:paramtypes", [
2683
+ _ts_param7(0, Req()),
2684
+ _ts_metadata7("design:type", Function),
2685
+ _ts_metadata7("design:paramtypes", [
2275
2686
  typeof Request === "undefined" ? Object : Request
2276
2687
  ]),
2277
- _ts_metadata6("design:returntype", Promise)
2688
+ _ts_metadata7("design:returntype", Promise)
2278
2689
  ], AttachmentsController.prototype, "list", null);
2279
- _ts_decorate6([
2690
+ _ts_decorate8([
2280
2691
  Post(),
2281
2692
  UseInterceptors(FileInterceptor("file", {
2282
2693
  limits: {
2283
2694
  fileSize: HARD_MAX_ATTACHMENT_BYTES
2284
2695
  }
2285
2696
  })),
2286
- _ts_param5(0, Req()),
2287
- _ts_param5(1, UploadedFile()),
2288
- _ts_metadata6("design:type", Function),
2289
- _ts_metadata6("design:paramtypes", [
2697
+ _ts_param7(0, Req()),
2698
+ _ts_param7(1, UploadedFile()),
2699
+ _ts_metadata7("design:type", Function),
2700
+ _ts_metadata7("design:paramtypes", [
2290
2701
  typeof Request === "undefined" ? Object : Request,
2291
2702
  Object
2292
2703
  ]),
2293
- _ts_metadata6("design:returntype", Promise)
2704
+ _ts_metadata7("design:returntype", Promise)
2294
2705
  ], AttachmentsController.prototype, "upload", null);
2295
- AttachmentsController = _ts_decorate6([
2706
+ AttachmentsController = _ts_decorate8([
2296
2707
  Controller2("attachments"),
2297
- _ts_param5(0, Inject5(AGENT_OPTIONS4)),
2298
- _ts_param5(1, Inject5(AGENT_ACTOR_RESOLVER)),
2299
- _ts_param5(3, Optional4()),
2300
- _ts_param5(3, Inject5(AGENT_ATTACHMENT_STAGING3)),
2301
- _ts_metadata6("design:type", Function),
2302
- _ts_metadata6("design:paramtypes", [
2708
+ _ts_param7(0, Inject7(AGENT_OPTIONS5)),
2709
+ _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER)),
2710
+ _ts_param7(3, Optional5()),
2711
+ _ts_param7(3, Inject7(AGENT_ATTACHMENT_STAGING3)),
2712
+ _ts_metadata7("design:type", Function),
2713
+ _ts_metadata7("design:paramtypes", [
2303
2714
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
2304
2715
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2305
2716
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -2309,8 +2720,9 @@ AttachmentsController = _ts_decorate6([
2309
2720
 
2310
2721
  // src/controller/chat.controller.ts
2311
2722
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError, streamFailure } from "@dudousxd/nestjs-agent-core";
2312
- import { BadRequestException as BadRequestException4, Body, Controller as Controller3, Get as Get3, Inject as Inject6, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
2313
- function _ts_decorate7(decorators, target, key, desc) {
2723
+ import { validateUiCapabilities } from "@dudousxd/nestjs-agent-core/genui";
2724
+ import { BadRequestException as BadRequestException4, Body, Controller as Controller3, Get as Get3, Inject as Inject8, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
2725
+ function _ts_decorate9(decorators, target, key, desc) {
2314
2726
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2315
2727
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2316
2728
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2323,19 +2735,19 @@ function _ts_decorate7(decorators, target, key, desc) {
2323
2735
  }
2324
2736
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2325
2737
  }
2326
- __name(_ts_decorate7, "_ts_decorate");
2327
- function _ts_metadata7(metadataKey, metadataValue) {
2738
+ __name(_ts_decorate9, "_ts_decorate");
2739
+ function _ts_metadata8(metadataKey, metadataValue) {
2328
2740
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2329
2741
  return Reflect.metadata(metadataKey, metadataValue);
2330
2742
  }
2331
2743
  }
2332
- __name(_ts_metadata7, "_ts_metadata");
2333
- function _ts_param6(paramIndex, decorator) {
2744
+ __name(_ts_metadata8, "_ts_metadata");
2745
+ function _ts_param8(paramIndex, decorator) {
2334
2746
  return function(target, key) {
2335
2747
  decorator(target, key, paramIndex);
2336
2748
  };
2337
2749
  }
2338
- __name(_ts_param6, "_ts_param");
2750
+ __name(_ts_param8, "_ts_param");
2339
2751
  function sendMode(body) {
2340
2752
  if (body.interrupt === true) {
2341
2753
  return "interrupt";
@@ -2396,9 +2808,18 @@ var ChatController = class {
2396
2808
  const actor = await this.actorResolver.resolve(req);
2397
2809
  const attachments = attachmentRefs(body.attachments);
2398
2810
  const mode = sendMode(body);
2811
+ let uiCapabilities;
2812
+ try {
2813
+ uiCapabilities = body.uiCapabilities === void 0 ? void 0 : validateUiCapabilities(body.uiCapabilities);
2814
+ } catch {
2815
+ throw new BadRequestException4("Invalid UI capabilities");
2816
+ }
2399
2817
  const result = await this.agent.send({
2400
2818
  actor,
2401
2819
  message: body.message,
2820
+ ...uiCapabilities !== void 0 ? {
2821
+ uiCapabilities
2822
+ } : {},
2402
2823
  ...body.threadId !== void 0 ? {
2403
2824
  threadId: body.threadId
2404
2825
  } : {},
@@ -2425,6 +2846,10 @@ var ChatController = class {
2425
2846
  } : {},
2426
2847
  mode
2427
2848
  });
2849
+ if ("proposalDecision" in result) {
2850
+ res.status(200).json(result);
2851
+ return;
2852
+ }
2428
2853
  if (result.queued === true) {
2429
2854
  res.status(202).json(result);
2430
2855
  return;
@@ -2516,50 +2941,50 @@ data: ${JSON.stringify(payload)}
2516
2941
  res.end();
2517
2942
  }
2518
2943
  };
2519
- _ts_decorate7([
2944
+ _ts_decorate9([
2520
2945
  Post2("chat"),
2521
- _ts_param6(0, Req2()),
2522
- _ts_param6(1, Res()),
2523
- _ts_param6(2, Body()),
2524
- _ts_metadata7("design:type", Function),
2525
- _ts_metadata7("design:paramtypes", [
2946
+ _ts_param8(0, Req2()),
2947
+ _ts_param8(1, Res()),
2948
+ _ts_param8(2, Body()),
2949
+ _ts_metadata8("design:type", Function),
2950
+ _ts_metadata8("design:paramtypes", [
2526
2951
  typeof Request === "undefined" ? Object : Request,
2527
2952
  typeof Response === "undefined" ? Object : Response,
2528
2953
  typeof ChatBody === "undefined" ? Object : ChatBody
2529
2954
  ]),
2530
- _ts_metadata7("design:returntype", Promise)
2955
+ _ts_metadata8("design:returntype", Promise)
2531
2956
  ], ChatController.prototype, "chat", null);
2532
- _ts_decorate7([
2957
+ _ts_decorate9([
2533
2958
  Get3("chat/:runId/stream"),
2534
- _ts_param6(0, Req2()),
2535
- _ts_param6(1, Param("runId")),
2536
- _ts_param6(2, Res()),
2537
- _ts_param6(3, Query("after")),
2538
- _ts_metadata7("design:type", Function),
2539
- _ts_metadata7("design:paramtypes", [
2959
+ _ts_param8(0, Req2()),
2960
+ _ts_param8(1, Param("runId")),
2961
+ _ts_param8(2, Res()),
2962
+ _ts_param8(3, Query("after")),
2963
+ _ts_metadata8("design:type", Function),
2964
+ _ts_metadata8("design:paramtypes", [
2540
2965
  typeof Request === "undefined" ? Object : Request,
2541
2966
  String,
2542
2967
  typeof Response === "undefined" ? Object : Response,
2543
2968
  String
2544
2969
  ]),
2545
- _ts_metadata7("design:returntype", Promise)
2970
+ _ts_metadata8("design:returntype", Promise)
2546
2971
  ], ChatController.prototype, "stream", null);
2547
- _ts_decorate7([
2972
+ _ts_decorate9([
2548
2973
  Post2("chat/:runId/cancel"),
2549
- _ts_param6(0, Req2()),
2550
- _ts_param6(1, Param("runId")),
2551
- _ts_metadata7("design:type", Function),
2552
- _ts_metadata7("design:paramtypes", [
2974
+ _ts_param8(0, Req2()),
2975
+ _ts_param8(1, Param("runId")),
2976
+ _ts_metadata8("design:type", Function),
2977
+ _ts_metadata8("design:paramtypes", [
2553
2978
  typeof Request === "undefined" ? Object : Request,
2554
2979
  String
2555
2980
  ]),
2556
- _ts_metadata7("design:returntype", Promise)
2981
+ _ts_metadata8("design:returntype", Promise)
2557
2982
  ], ChatController.prototype, "cancel", null);
2558
- ChatController = _ts_decorate7([
2983
+ ChatController = _ts_decorate9([
2559
2984
  Controller3(),
2560
- _ts_param6(1, Inject6(AGENT_ACTOR_RESOLVER2)),
2561
- _ts_metadata7("design:type", Function),
2562
- _ts_metadata7("design:paramtypes", [
2985
+ _ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER2)),
2986
+ _ts_metadata8("design:type", Function),
2987
+ _ts_metadata8("design:paramtypes", [
2563
2988
  typeof AgentService === "undefined" ? Object : AgentService,
2564
2989
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2565
2990
  ])
@@ -2575,8 +3000,8 @@ function parseCursor(raw) {
2575
3000
  __name(parseCursor, "parseCursor");
2576
3001
 
2577
3002
  // src/controller/config.controller.ts
2578
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING4, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS5 } from "@dudousxd/nestjs-agent-core";
2579
- import { Controller as Controller4, Get as Get4, Inject as Inject7, Optional as Optional5, Req as Req3 } from "@nestjs/common";
3003
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING4, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS6 } from "@dudousxd/nestjs-agent-core";
3004
+ import { Controller as Controller4, Get as Get4, Inject as Inject9, Optional as Optional6, Req as Req3 } from "@nestjs/common";
2580
3005
 
2581
3006
  // src/resolver/anonymous-actor-resolver.ts
2582
3007
  import { createHash, randomBytes } from "crypto";
@@ -2666,7 +3091,7 @@ var AnonymousActorResolver = class {
2666
3091
  };
2667
3092
 
2668
3093
  // src/controller/config.controller.ts
2669
- function _ts_decorate8(decorators, target, key, desc) {
3094
+ function _ts_decorate10(decorators, target, key, desc) {
2670
3095
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2671
3096
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2672
3097
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2679,19 +3104,19 @@ function _ts_decorate8(decorators, target, key, desc) {
2679
3104
  }
2680
3105
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2681
3106
  }
2682
- __name(_ts_decorate8, "_ts_decorate");
2683
- function _ts_metadata8(metadataKey, metadataValue) {
3107
+ __name(_ts_decorate10, "_ts_decorate");
3108
+ function _ts_metadata9(metadataKey, metadataValue) {
2684
3109
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2685
3110
  return Reflect.metadata(metadataKey, metadataValue);
2686
3111
  }
2687
3112
  }
2688
- __name(_ts_metadata8, "_ts_metadata");
2689
- function _ts_param7(paramIndex, decorator) {
3113
+ __name(_ts_metadata9, "_ts_metadata");
3114
+ function _ts_param9(paramIndex, decorator) {
2690
3115
  return function(target, key) {
2691
3116
  decorator(target, key, paramIndex);
2692
3117
  };
2693
3118
  }
2694
- __name(_ts_param7, "_ts_param");
3119
+ __name(_ts_param9, "_ts_param");
2695
3120
  var ConfigController = class {
2696
3121
  static {
2697
3122
  __name(this, "ConfigController");
@@ -2722,25 +3147,25 @@ var ConfigController = class {
2722
3147
  };
2723
3148
  }
2724
3149
  };
2725
- _ts_decorate8([
3150
+ _ts_decorate10([
2726
3151
  Get4(),
2727
- _ts_param7(0, Req3()),
2728
- _ts_metadata8("design:type", Function),
2729
- _ts_metadata8("design:paramtypes", [
3152
+ _ts_param9(0, Req3()),
3153
+ _ts_metadata9("design:type", Function),
3154
+ _ts_metadata9("design:paramtypes", [
2730
3155
  typeof Request === "undefined" ? Object : Request
2731
3156
  ]),
2732
- _ts_metadata8("design:returntype", Promise)
3157
+ _ts_metadata9("design:returntype", Promise)
2733
3158
  ], ConfigController.prototype, "config", null);
2734
- ConfigController = _ts_decorate8([
3159
+ ConfigController = _ts_decorate10([
2735
3160
  Controller4("config"),
2736
- _ts_param7(0, Inject7(AGENT_OPTIONS5)),
2737
- _ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER3)),
2738
- _ts_param7(2, Optional5()),
2739
- _ts_param7(2, Inject7(AGENT_ATTACHMENT_STAGING4)),
2740
- _ts_param7(3, Optional5()),
2741
- _ts_param7(3, Inject7(AGENT_MODEL_CATALOG2)),
2742
- _ts_metadata8("design:type", Function),
2743
- _ts_metadata8("design:paramtypes", [
3161
+ _ts_param9(0, Inject9(AGENT_OPTIONS6)),
3162
+ _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER3)),
3163
+ _ts_param9(2, Optional6()),
3164
+ _ts_param9(2, Inject9(AGENT_ATTACHMENT_STAGING4)),
3165
+ _ts_param9(3, Optional6()),
3166
+ _ts_param9(3, Inject9(AGENT_MODEL_CATALOG2)),
3167
+ _ts_metadata9("design:type", Function),
3168
+ _ts_metadata9("design:paramtypes", [
2744
3169
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
2745
3170
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2746
3171
  Object,
@@ -2750,8 +3175,8 @@ ConfigController = _ts_decorate8([
2750
3175
 
2751
3176
  // src/controller/memories.controller.ts
2752
3177
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
2753
- import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException2, Get as Get5, Inject as Inject8, NotFoundException as NotFoundException2, Optional as Optional6, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
2754
- function _ts_decorate9(decorators, target, key, desc) {
3178
+ import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException3, Get as Get5, Inject as Inject10, NotFoundException as NotFoundException3, Optional as Optional7, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
3179
+ function _ts_decorate11(decorators, target, key, desc) {
2755
3180
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2756
3181
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2757
3182
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2764,19 +3189,19 @@ function _ts_decorate9(decorators, target, key, desc) {
2764
3189
  }
2765
3190
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2766
3191
  }
2767
- __name(_ts_decorate9, "_ts_decorate");
2768
- function _ts_metadata9(metadataKey, metadataValue) {
3192
+ __name(_ts_decorate11, "_ts_decorate");
3193
+ function _ts_metadata10(metadataKey, metadataValue) {
2769
3194
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2770
3195
  return Reflect.metadata(metadataKey, metadataValue);
2771
3196
  }
2772
3197
  }
2773
- __name(_ts_metadata9, "_ts_metadata");
2774
- function _ts_param8(paramIndex, decorator) {
3198
+ __name(_ts_metadata10, "_ts_metadata");
3199
+ function _ts_param10(paramIndex, decorator) {
2775
3200
  return function(target, key) {
2776
3201
  decorator(target, key, paramIndex);
2777
3202
  };
2778
3203
  }
2779
- __name(_ts_param8, "_ts_param");
3204
+ __name(_ts_param10, "_ts_param");
2780
3205
  var MemoriesController = class {
2781
3206
  static {
2782
3207
  __name(this, "MemoriesController");
@@ -2810,20 +3235,20 @@ var MemoriesController = class {
2810
3235
  */
2811
3236
  async forget(req, id) {
2812
3237
  if (this.memory === void 0) {
2813
- throw new NotFoundException2("No memory is configured in this deployment.");
3238
+ throw new NotFoundException3("No memory is configured in this deployment.");
2814
3239
  }
2815
3240
  const actor = await this.actorResolver.resolve(req);
2816
3241
  const digest = await this.unbounded("", actor);
2817
3242
  const entry = digest.entries.find((candidate) => candidate.id === id);
2818
3243
  if (entry === void 0) {
2819
- throw new NotFoundException2(`No memory with id "${id}".`);
3244
+ throw new NotFoundException3(`No memory with id "${id}".`);
2820
3245
  }
2821
3246
  const verdict = memoryForgetVerdict({
2822
3247
  record: entry,
2823
3248
  actor
2824
3249
  });
2825
3250
  if (!verdict.allowed) {
2826
- throw new ForbiddenException2(verdict.reason);
3251
+ throw new ForbiddenException3(verdict.reason);
2827
3252
  }
2828
3253
  return {
2829
3254
  forgotten: await this.memory.provider.forget({
@@ -2849,35 +3274,35 @@ var MemoriesController = class {
2849
3274
  });
2850
3275
  }
2851
3276
  };
2852
- _ts_decorate9([
3277
+ _ts_decorate11([
2853
3278
  Get5(),
2854
- _ts_param8(0, Req4()),
2855
- _ts_param8(1, Query2("threadId")),
2856
- _ts_metadata9("design:type", Function),
2857
- _ts_metadata9("design:paramtypes", [
3279
+ _ts_param10(0, Req4()),
3280
+ _ts_param10(1, Query2("threadId")),
3281
+ _ts_metadata10("design:type", Function),
3282
+ _ts_metadata10("design:paramtypes", [
2858
3283
  typeof Request === "undefined" ? Object : Request,
2859
3284
  String
2860
3285
  ]),
2861
- _ts_metadata9("design:returntype", Promise)
3286
+ _ts_metadata10("design:returntype", Promise)
2862
3287
  ], MemoriesController.prototype, "list", null);
2863
- _ts_decorate9([
3288
+ _ts_decorate11([
2864
3289
  Delete(":id"),
2865
- _ts_param8(0, Req4()),
2866
- _ts_param8(1, Param2("id")),
2867
- _ts_metadata9("design:type", Function),
2868
- _ts_metadata9("design:paramtypes", [
3290
+ _ts_param10(0, Req4()),
3291
+ _ts_param10(1, Param2("id")),
3292
+ _ts_metadata10("design:type", Function),
3293
+ _ts_metadata10("design:paramtypes", [
2869
3294
  typeof Request === "undefined" ? Object : Request,
2870
3295
  String
2871
3296
  ]),
2872
- _ts_metadata9("design:returntype", Promise)
3297
+ _ts_metadata10("design:returntype", Promise)
2873
3298
  ], MemoriesController.prototype, "forget", null);
2874
- MemoriesController = _ts_decorate9([
3299
+ MemoriesController = _ts_decorate11([
2875
3300
  Controller5("memories"),
2876
- _ts_param8(0, Inject8(AGENT_ACTOR_RESOLVER4)),
2877
- _ts_param8(1, Optional6()),
2878
- _ts_param8(1, Inject8(AGENT_MEMORY2)),
2879
- _ts_metadata9("design:type", Function),
2880
- _ts_metadata9("design:paramtypes", [
3301
+ _ts_param10(0, Inject10(AGENT_ACTOR_RESOLVER4)),
3302
+ _ts_param10(1, Optional7()),
3303
+ _ts_param10(1, Inject10(AGENT_MEMORY2)),
3304
+ _ts_metadata10("design:type", Function),
3305
+ _ts_metadata10("design:paramtypes", [
2881
3306
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
2882
3307
  Object
2883
3308
  ])
@@ -2885,8 +3310,8 @@ MemoriesController = _ts_decorate9([
2885
3310
 
2886
3311
  // src/controller/messages.controller.ts
2887
3312
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
2888
- import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject9, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
2889
- function _ts_decorate10(decorators, target, key, desc) {
3313
+ import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject11, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
3314
+ function _ts_decorate12(decorators, target, key, desc) {
2890
3315
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2891
3316
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2892
3317
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2899,19 +3324,19 @@ function _ts_decorate10(decorators, target, key, desc) {
2899
3324
  }
2900
3325
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2901
3326
  }
2902
- __name(_ts_decorate10, "_ts_decorate");
2903
- function _ts_metadata10(metadataKey, metadataValue) {
3327
+ __name(_ts_decorate12, "_ts_decorate");
3328
+ function _ts_metadata11(metadataKey, metadataValue) {
2904
3329
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2905
3330
  return Reflect.metadata(metadataKey, metadataValue);
2906
3331
  }
2907
3332
  }
2908
- __name(_ts_metadata10, "_ts_metadata");
2909
- function _ts_param9(paramIndex, decorator) {
3333
+ __name(_ts_metadata11, "_ts_metadata");
3334
+ function _ts_param11(paramIndex, decorator) {
2910
3335
  return function(target, key) {
2911
3336
  decorator(target, key, paramIndex);
2912
3337
  };
2913
3338
  }
2914
- __name(_ts_param9, "_ts_param");
3339
+ __name(_ts_param11, "_ts_param");
2915
3340
  var MessagesController = class {
2916
3341
  static {
2917
3342
  __name(this, "MessagesController");
@@ -2939,25 +3364,25 @@ var MessagesController = class {
2939
3364
  };
2940
3365
  }
2941
3366
  };
2942
- _ts_decorate10([
3367
+ _ts_decorate12([
2943
3368
  Post3(":id/feedback"),
2944
3369
  HttpCode(200),
2945
- _ts_param9(0, Req5()),
2946
- _ts_param9(1, Param3("id")),
2947
- _ts_param9(2, Body2()),
2948
- _ts_metadata10("design:type", Function),
2949
- _ts_metadata10("design:paramtypes", [
3370
+ _ts_param11(0, Req5()),
3371
+ _ts_param11(1, Param3("id")),
3372
+ _ts_param11(2, Body2()),
3373
+ _ts_metadata11("design:type", Function),
3374
+ _ts_metadata11("design:paramtypes", [
2950
3375
  typeof Request === "undefined" ? Object : Request,
2951
3376
  String,
2952
3377
  typeof FeedbackBody === "undefined" ? Object : FeedbackBody
2953
3378
  ]),
2954
- _ts_metadata10("design:returntype", Promise)
3379
+ _ts_metadata11("design:returntype", Promise)
2955
3380
  ], MessagesController.prototype, "feedback", null);
2956
- MessagesController = _ts_decorate10([
3381
+ MessagesController = _ts_decorate12([
2957
3382
  Controller6("messages"),
2958
- _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER5)),
2959
- _ts_metadata10("design:type", Function),
2960
- _ts_metadata10("design:paramtypes", [
3383
+ _ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER5)),
3384
+ _ts_metadata11("design:type", Function),
3385
+ _ts_metadata11("design:paramtypes", [
2961
3386
  typeof AgentService === "undefined" ? Object : AgentService,
2962
3387
  typeof ActorResolver === "undefined" ? Object : ActorResolver
2963
3388
  ])
@@ -2965,8 +3390,8 @@ MessagesController = _ts_decorate10([
2965
3390
 
2966
3391
  // src/controller/models.controller.ts
2967
3392
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
2968
- import { Controller as Controller7, Get as Get6, Inject as Inject10, Query as Query3, Req as Req6 } from "@nestjs/common";
2969
- function _ts_decorate11(decorators, target, key, desc) {
3393
+ import { Controller as Controller7, Get as Get6, Inject as Inject12, Query as Query3, Req as Req6 } from "@nestjs/common";
3394
+ function _ts_decorate13(decorators, target, key, desc) {
2970
3395
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2971
3396
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2972
3397
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2979,19 +3404,19 @@ function _ts_decorate11(decorators, target, key, desc) {
2979
3404
  }
2980
3405
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2981
3406
  }
2982
- __name(_ts_decorate11, "_ts_decorate");
2983
- function _ts_metadata11(metadataKey, metadataValue) {
3407
+ __name(_ts_decorate13, "_ts_decorate");
3408
+ function _ts_metadata12(metadataKey, metadataValue) {
2984
3409
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2985
3410
  return Reflect.metadata(metadataKey, metadataValue);
2986
3411
  }
2987
3412
  }
2988
- __name(_ts_metadata11, "_ts_metadata");
2989
- function _ts_param10(paramIndex, decorator) {
3413
+ __name(_ts_metadata12, "_ts_metadata");
3414
+ function _ts_param12(paramIndex, decorator) {
2990
3415
  return function(target, key) {
2991
3416
  decorator(target, key, paramIndex);
2992
3417
  };
2993
3418
  }
2994
- __name(_ts_param10, "_ts_param");
3419
+ __name(_ts_param12, "_ts_param");
2995
3420
  var ModelsController = class {
2996
3421
  static {
2997
3422
  __name(this, "ModelsController");
@@ -3011,22 +3436,22 @@ var ModelsController = class {
3011
3436
  return this.agent.listModels(actor, agent);
3012
3437
  }
3013
3438
  };
3014
- _ts_decorate11([
3439
+ _ts_decorate13([
3015
3440
  Get6(),
3016
- _ts_param10(0, Req6()),
3017
- _ts_param10(1, Query3("agent")),
3018
- _ts_metadata11("design:type", Function),
3019
- _ts_metadata11("design:paramtypes", [
3441
+ _ts_param12(0, Req6()),
3442
+ _ts_param12(1, Query3("agent")),
3443
+ _ts_metadata12("design:type", Function),
3444
+ _ts_metadata12("design:paramtypes", [
3020
3445
  typeof Request === "undefined" ? Object : Request,
3021
3446
  String
3022
3447
  ]),
3023
- _ts_metadata11("design:returntype", Promise)
3448
+ _ts_metadata12("design:returntype", Promise)
3024
3449
  ], ModelsController.prototype, "list", null);
3025
- ModelsController = _ts_decorate11([
3450
+ ModelsController = _ts_decorate13([
3026
3451
  Controller7("models"),
3027
- _ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER6)),
3028
- _ts_metadata11("design:type", Function),
3029
- _ts_metadata11("design:paramtypes", [
3452
+ _ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER6)),
3453
+ _ts_metadata12("design:type", Function),
3454
+ _ts_metadata12("design:paramtypes", [
3030
3455
  typeof AgentService === "undefined" ? Object : AgentService,
3031
3456
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3032
3457
  ])
@@ -3034,8 +3459,8 @@ ModelsController = _ts_decorate11([
3034
3459
 
3035
3460
  // src/controller/queue.controller.ts
3036
3461
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
3037
- import { BadRequestException as BadRequestException5, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as Inject11, Param as Param4, Patch, Post as Post4, Req as Req7 } from "@nestjs/common";
3038
- function _ts_decorate12(decorators, target, key, desc) {
3462
+ import { BadRequestException as BadRequestException5, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as Inject13, Param as Param4, Patch, Post as Post4, Req as Req7 } from "@nestjs/common";
3463
+ function _ts_decorate14(decorators, target, key, desc) {
3039
3464
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3040
3465
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3041
3466
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3048,19 +3473,19 @@ function _ts_decorate12(decorators, target, key, desc) {
3048
3473
  }
3049
3474
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3050
3475
  }
3051
- __name(_ts_decorate12, "_ts_decorate");
3052
- function _ts_metadata12(metadataKey, metadataValue) {
3476
+ __name(_ts_decorate14, "_ts_decorate");
3477
+ function _ts_metadata13(metadataKey, metadataValue) {
3053
3478
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3054
3479
  return Reflect.metadata(metadataKey, metadataValue);
3055
3480
  }
3056
3481
  }
3057
- __name(_ts_metadata12, "_ts_metadata");
3058
- function _ts_param11(paramIndex, decorator) {
3482
+ __name(_ts_metadata13, "_ts_metadata");
3483
+ function _ts_param13(paramIndex, decorator) {
3059
3484
  return function(target, key) {
3060
3485
  decorator(target, key, paramIndex);
3061
3486
  };
3062
3487
  }
3063
- __name(_ts_param11, "_ts_param");
3488
+ __name(_ts_param13, "_ts_param");
3064
3489
  var QueueController = class {
3065
3490
  static {
3066
3491
  __name(this, "QueueController");
@@ -3114,79 +3539,79 @@ var QueueController = class {
3114
3539
  return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
3115
3540
  }
3116
3541
  };
3117
- _ts_decorate12([
3542
+ _ts_decorate14([
3118
3543
  Get7("threads/:id/queue"),
3119
- _ts_param11(0, Req7()),
3120
- _ts_param11(1, Param4("id")),
3121
- _ts_metadata12("design:type", Function),
3122
- _ts_metadata12("design:paramtypes", [
3544
+ _ts_param13(0, Req7()),
3545
+ _ts_param13(1, Param4("id")),
3546
+ _ts_metadata13("design:type", Function),
3547
+ _ts_metadata13("design:paramtypes", [
3123
3548
  typeof Request === "undefined" ? Object : Request,
3124
3549
  String
3125
3550
  ]),
3126
- _ts_metadata12("design:returntype", Promise)
3551
+ _ts_metadata13("design:returntype", Promise)
3127
3552
  ], QueueController.prototype, "list", null);
3128
- _ts_decorate12([
3553
+ _ts_decorate14([
3129
3554
  Delete2("threads/:id/queue"),
3130
- _ts_param11(0, Req7()),
3131
- _ts_param11(1, Param4("id")),
3132
- _ts_metadata12("design:type", Function),
3133
- _ts_metadata12("design:paramtypes", [
3555
+ _ts_param13(0, Req7()),
3556
+ _ts_param13(1, Param4("id")),
3557
+ _ts_metadata13("design:type", Function),
3558
+ _ts_metadata13("design:paramtypes", [
3134
3559
  typeof Request === "undefined" ? Object : Request,
3135
3560
  String
3136
3561
  ]),
3137
- _ts_metadata12("design:returntype", Promise)
3562
+ _ts_metadata13("design:returntype", Promise)
3138
3563
  ], QueueController.prototype, "clear", null);
3139
- _ts_decorate12([
3564
+ _ts_decorate14([
3140
3565
  Post4("threads/:id/queue/resume"),
3141
- _ts_param11(0, Req7()),
3142
- _ts_param11(1, Param4("id")),
3143
- _ts_metadata12("design:type", Function),
3144
- _ts_metadata12("design:paramtypes", [
3566
+ _ts_param13(0, Req7()),
3567
+ _ts_param13(1, Param4("id")),
3568
+ _ts_metadata13("design:type", Function),
3569
+ _ts_metadata13("design:paramtypes", [
3145
3570
  typeof Request === "undefined" ? Object : Request,
3146
3571
  String
3147
3572
  ]),
3148
- _ts_metadata12("design:returntype", Promise)
3573
+ _ts_metadata13("design:returntype", Promise)
3149
3574
  ], QueueController.prototype, "resume", null);
3150
- _ts_decorate12([
3575
+ _ts_decorate14([
3151
3576
  Patch("queue/:messageId"),
3152
- _ts_param11(0, Req7()),
3153
- _ts_param11(1, Param4("messageId")),
3154
- _ts_param11(2, Body3()),
3155
- _ts_metadata12("design:type", Function),
3156
- _ts_metadata12("design:paramtypes", [
3577
+ _ts_param13(0, Req7()),
3578
+ _ts_param13(1, Param4("messageId")),
3579
+ _ts_param13(2, Body3()),
3580
+ _ts_metadata13("design:type", Function),
3581
+ _ts_metadata13("design:paramtypes", [
3157
3582
  typeof Request === "undefined" ? Object : Request,
3158
3583
  String,
3159
3584
  typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
3160
3585
  ]),
3161
- _ts_metadata12("design:returntype", Promise)
3586
+ _ts_metadata13("design:returntype", Promise)
3162
3587
  ], QueueController.prototype, "update", null);
3163
- _ts_decorate12([
3588
+ _ts_decorate14([
3164
3589
  Post4("queue/:messageId/interrupt"),
3165
- _ts_param11(0, Req7()),
3166
- _ts_param11(1, Param4("messageId")),
3167
- _ts_metadata12("design:type", Function),
3168
- _ts_metadata12("design:paramtypes", [
3590
+ _ts_param13(0, Req7()),
3591
+ _ts_param13(1, Param4("messageId")),
3592
+ _ts_metadata13("design:type", Function),
3593
+ _ts_metadata13("design:paramtypes", [
3169
3594
  typeof Request === "undefined" ? Object : Request,
3170
3595
  String
3171
3596
  ]),
3172
- _ts_metadata12("design:returntype", Promise)
3597
+ _ts_metadata13("design:returntype", Promise)
3173
3598
  ], QueueController.prototype, "interrupt", null);
3174
- _ts_decorate12([
3599
+ _ts_decorate14([
3175
3600
  Delete2("queue/:messageId"),
3176
- _ts_param11(0, Req7()),
3177
- _ts_param11(1, Param4("messageId")),
3178
- _ts_metadata12("design:type", Function),
3179
- _ts_metadata12("design:paramtypes", [
3601
+ _ts_param13(0, Req7()),
3602
+ _ts_param13(1, Param4("messageId")),
3603
+ _ts_metadata13("design:type", Function),
3604
+ _ts_metadata13("design:paramtypes", [
3180
3605
  typeof Request === "undefined" ? Object : Request,
3181
3606
  String
3182
3607
  ]),
3183
- _ts_metadata12("design:returntype", Promise)
3608
+ _ts_metadata13("design:returntype", Promise)
3184
3609
  ], QueueController.prototype, "remove", null);
3185
- QueueController = _ts_decorate12([
3610
+ QueueController = _ts_decorate14([
3186
3611
  Controller8(),
3187
- _ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER7)),
3188
- _ts_metadata12("design:type", Function),
3189
- _ts_metadata12("design:paramtypes", [
3612
+ _ts_param13(1, Inject13(AGENT_ACTOR_RESOLVER7)),
3613
+ _ts_metadata13("design:type", Function),
3614
+ _ts_metadata13("design:paramtypes", [
3190
3615
  typeof AgentService === "undefined" ? Object : AgentService,
3191
3616
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3192
3617
  ])
@@ -3194,8 +3619,8 @@ QueueController = _ts_decorate12([
3194
3619
 
3195
3620
  // src/controller/quota.controller.ts
3196
3621
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
3197
- import { Controller as Controller9, Get as Get8, Inject as Inject12, Req as Req8 } from "@nestjs/common";
3198
- function _ts_decorate13(decorators, target, key, desc) {
3622
+ import { Controller as Controller9, Get as Get8, Inject as Inject14, Req as Req8 } from "@nestjs/common";
3623
+ function _ts_decorate15(decorators, target, key, desc) {
3199
3624
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3200
3625
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3201
3626
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3208,19 +3633,19 @@ function _ts_decorate13(decorators, target, key, desc) {
3208
3633
  }
3209
3634
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3210
3635
  }
3211
- __name(_ts_decorate13, "_ts_decorate");
3212
- function _ts_metadata13(metadataKey, metadataValue) {
3636
+ __name(_ts_decorate15, "_ts_decorate");
3637
+ function _ts_metadata14(metadataKey, metadataValue) {
3213
3638
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3214
3639
  return Reflect.metadata(metadataKey, metadataValue);
3215
3640
  }
3216
3641
  }
3217
- __name(_ts_metadata13, "_ts_metadata");
3218
- function _ts_param12(paramIndex, decorator) {
3642
+ __name(_ts_metadata14, "_ts_metadata");
3643
+ function _ts_param14(paramIndex, decorator) {
3219
3644
  return function(target, key) {
3220
3645
  decorator(target, key, paramIndex);
3221
3646
  };
3222
3647
  }
3223
- __name(_ts_param12, "_ts_param");
3648
+ __name(_ts_param14, "_ts_param");
3224
3649
  var QuotaController = class {
3225
3650
  static {
3226
3651
  __name(this, "QuotaController");
@@ -3240,20 +3665,20 @@ var QuotaController = class {
3240
3665
  return this.agent.quotaReport(actor);
3241
3666
  }
3242
3667
  };
3243
- _ts_decorate13([
3668
+ _ts_decorate15([
3244
3669
  Get8(),
3245
- _ts_param12(0, Req8()),
3246
- _ts_metadata13("design:type", Function),
3247
- _ts_metadata13("design:paramtypes", [
3670
+ _ts_param14(0, Req8()),
3671
+ _ts_metadata14("design:type", Function),
3672
+ _ts_metadata14("design:paramtypes", [
3248
3673
  typeof Request === "undefined" ? Object : Request
3249
3674
  ]),
3250
- _ts_metadata13("design:returntype", Promise)
3675
+ _ts_metadata14("design:returntype", Promise)
3251
3676
  ], QuotaController.prototype, "report", null);
3252
- QuotaController = _ts_decorate13([
3677
+ QuotaController = _ts_decorate15([
3253
3678
  Controller9("quota"),
3254
- _ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER8)),
3255
- _ts_metadata13("design:type", Function),
3256
- _ts_metadata13("design:paramtypes", [
3679
+ _ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER8)),
3680
+ _ts_metadata14("design:type", Function),
3681
+ _ts_metadata14("design:paramtypes", [
3257
3682
  typeof AgentService === "undefined" ? Object : AgentService,
3258
3683
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3259
3684
  ])
@@ -3261,8 +3686,8 @@ QuotaController = _ts_decorate13([
3261
3686
 
3262
3687
  // src/controller/skills.controller.ts
3263
3688
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
3264
- import { Controller as Controller10, Get as Get9, Inject as Inject13, Optional as Optional7, Query as Query4, Req as Req9 } from "@nestjs/common";
3265
- function _ts_decorate14(decorators, target, key, desc) {
3689
+ import { Controller as Controller10, Get as Get9, Inject as Inject15, Optional as Optional8, Query as Query4, Req as Req9 } from "@nestjs/common";
3690
+ function _ts_decorate16(decorators, target, key, desc) {
3266
3691
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3267
3692
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3268
3693
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3275,19 +3700,19 @@ function _ts_decorate14(decorators, target, key, desc) {
3275
3700
  }
3276
3701
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3277
3702
  }
3278
- __name(_ts_decorate14, "_ts_decorate");
3279
- function _ts_metadata14(metadataKey, metadataValue) {
3703
+ __name(_ts_decorate16, "_ts_decorate");
3704
+ function _ts_metadata15(metadataKey, metadataValue) {
3280
3705
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3281
3706
  return Reflect.metadata(metadataKey, metadataValue);
3282
3707
  }
3283
3708
  }
3284
- __name(_ts_metadata14, "_ts_metadata");
3285
- function _ts_param13(paramIndex, decorator) {
3709
+ __name(_ts_metadata15, "_ts_metadata");
3710
+ function _ts_param15(paramIndex, decorator) {
3286
3711
  return function(target, key) {
3287
3712
  decorator(target, key, paramIndex);
3288
3713
  };
3289
3714
  }
3290
- __name(_ts_param13, "_ts_param");
3715
+ __name(_ts_param15, "_ts_param");
3291
3716
  var SkillsController = class {
3292
3717
  static {
3293
3718
  __name(this, "SkillsController");
@@ -3310,24 +3735,24 @@ var SkillsController = class {
3310
3735
  return offer.entries;
3311
3736
  }
3312
3737
  };
3313
- _ts_decorate14([
3738
+ _ts_decorate16([
3314
3739
  Get9(),
3315
- _ts_param13(0, Req9()),
3316
- _ts_param13(1, Query4("threadId")),
3317
- _ts_metadata14("design:type", Function),
3318
- _ts_metadata14("design:paramtypes", [
3740
+ _ts_param15(0, Req9()),
3741
+ _ts_param15(1, Query4("threadId")),
3742
+ _ts_metadata15("design:type", Function),
3743
+ _ts_metadata15("design:paramtypes", [
3319
3744
  typeof Request === "undefined" ? Object : Request,
3320
3745
  String
3321
3746
  ]),
3322
- _ts_metadata14("design:returntype", Promise)
3747
+ _ts_metadata15("design:returntype", Promise)
3323
3748
  ], SkillsController.prototype, "list", null);
3324
- SkillsController = _ts_decorate14([
3749
+ SkillsController = _ts_decorate16([
3325
3750
  Controller10("skills"),
3326
- _ts_param13(0, Inject13(AGENT_ACTOR_RESOLVER9)),
3327
- _ts_param13(1, Optional7()),
3328
- _ts_param13(1, Inject13(AGENT_SKILLS2)),
3329
- _ts_metadata14("design:type", Function),
3330
- _ts_metadata14("design:paramtypes", [
3751
+ _ts_param15(0, Inject15(AGENT_ACTOR_RESOLVER9)),
3752
+ _ts_param15(1, Optional8()),
3753
+ _ts_param15(1, Inject15(AGENT_SKILLS2)),
3754
+ _ts_metadata15("design:type", Function),
3755
+ _ts_metadata15("design:paramtypes", [
3331
3756
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3332
3757
  Object
3333
3758
  ])
@@ -3335,8 +3760,8 @@ SkillsController = _ts_decorate14([
3335
3760
 
3336
3761
  // src/controller/threads.controller.ts
3337
3762
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
3338
- import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as Inject14, Param as Param5, Patch as Patch2, Post as Post5, Req as Req10 } from "@nestjs/common";
3339
- function _ts_decorate15(decorators, target, key, desc) {
3763
+ import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as Inject16, Param as Param5, Patch as Patch2, Post as Post5, Req as Req10 } from "@nestjs/common";
3764
+ function _ts_decorate17(decorators, target, key, desc) {
3340
3765
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3341
3766
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3342
3767
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3349,19 +3774,19 @@ function _ts_decorate15(decorators, target, key, desc) {
3349
3774
  }
3350
3775
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3351
3776
  }
3352
- __name(_ts_decorate15, "_ts_decorate");
3353
- function _ts_metadata15(metadataKey, metadataValue) {
3777
+ __name(_ts_decorate17, "_ts_decorate");
3778
+ function _ts_metadata16(metadataKey, metadataValue) {
3354
3779
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3355
3780
  return Reflect.metadata(metadataKey, metadataValue);
3356
3781
  }
3357
3782
  }
3358
- __name(_ts_metadata15, "_ts_metadata");
3359
- function _ts_param14(paramIndex, decorator) {
3783
+ __name(_ts_metadata16, "_ts_metadata");
3784
+ function _ts_param16(paramIndex, decorator) {
3360
3785
  return function(target, key) {
3361
3786
  decorator(target, key, paramIndex);
3362
3787
  };
3363
3788
  }
3364
- __name(_ts_param14, "_ts_param");
3789
+ __name(_ts_param16, "_ts_param");
3365
3790
  var ThreadsController = class {
3366
3791
  static {
3367
3792
  __name(this, "ThreadsController");
@@ -3431,92 +3856,92 @@ var ThreadsController = class {
3431
3856
  };
3432
3857
  }
3433
3858
  };
3434
- _ts_decorate15([
3859
+ _ts_decorate17([
3435
3860
  Get10(),
3436
- _ts_param14(0, Req10()),
3437
- _ts_metadata15("design:type", Function),
3438
- _ts_metadata15("design:paramtypes", [
3861
+ _ts_param16(0, Req10()),
3862
+ _ts_metadata16("design:type", Function),
3863
+ _ts_metadata16("design:paramtypes", [
3439
3864
  typeof Request === "undefined" ? Object : Request
3440
3865
  ]),
3441
- _ts_metadata15("design:returntype", Promise)
3866
+ _ts_metadata16("design:returntype", Promise)
3442
3867
  ], ThreadsController.prototype, "list", null);
3443
- _ts_decorate15([
3868
+ _ts_decorate17([
3444
3869
  Get10(":id"),
3445
- _ts_param14(0, Req10()),
3446
- _ts_param14(1, Param5("id")),
3447
- _ts_metadata15("design:type", Function),
3448
- _ts_metadata15("design:paramtypes", [
3870
+ _ts_param16(0, Req10()),
3871
+ _ts_param16(1, Param5("id")),
3872
+ _ts_metadata16("design:type", Function),
3873
+ _ts_metadata16("design:paramtypes", [
3449
3874
  typeof Request === "undefined" ? Object : Request,
3450
3875
  String
3451
3876
  ]),
3452
- _ts_metadata15("design:returntype", Promise)
3877
+ _ts_metadata16("design:returntype", Promise)
3453
3878
  ], ThreadsController.prototype, "detail", null);
3454
- _ts_decorate15([
3879
+ _ts_decorate17([
3455
3880
  Delete3(":id"),
3456
- _ts_param14(0, Req10()),
3457
- _ts_param14(1, Param5("id")),
3458
- _ts_metadata15("design:type", Function),
3459
- _ts_metadata15("design:paramtypes", [
3881
+ _ts_param16(0, Req10()),
3882
+ _ts_param16(1, Param5("id")),
3883
+ _ts_metadata16("design:type", Function),
3884
+ _ts_metadata16("design:paramtypes", [
3460
3885
  typeof Request === "undefined" ? Object : Request,
3461
3886
  String
3462
3887
  ]),
3463
- _ts_metadata15("design:returntype", Promise)
3888
+ _ts_metadata16("design:returntype", Promise)
3464
3889
  ], ThreadsController.prototype, "remove", null);
3465
- _ts_decorate15([
3890
+ _ts_decorate17([
3466
3891
  Post5(":id/fork-from/:messageId"),
3467
- _ts_param14(0, Req10()),
3468
- _ts_param14(1, Param5("id")),
3469
- _ts_param14(2, Param5("messageId")),
3470
- _ts_metadata15("design:type", Function),
3471
- _ts_metadata15("design:paramtypes", [
3892
+ _ts_param16(0, Req10()),
3893
+ _ts_param16(1, Param5("id")),
3894
+ _ts_param16(2, Param5("messageId")),
3895
+ _ts_metadata16("design:type", Function),
3896
+ _ts_metadata16("design:paramtypes", [
3472
3897
  typeof Request === "undefined" ? Object : Request,
3473
3898
  String,
3474
3899
  String
3475
3900
  ]),
3476
- _ts_metadata15("design:returntype", Promise)
3901
+ _ts_metadata16("design:returntype", Promise)
3477
3902
  ], ThreadsController.prototype, "fork", null);
3478
- _ts_decorate15([
3903
+ _ts_decorate17([
3479
3904
  Patch2(":id"),
3480
- _ts_param14(0, Req10()),
3481
- _ts_param14(1, Param5("id")),
3482
- _ts_param14(2, Body4()),
3483
- _ts_metadata15("design:type", Function),
3484
- _ts_metadata15("design:paramtypes", [
3905
+ _ts_param16(0, Req10()),
3906
+ _ts_param16(1, Param5("id")),
3907
+ _ts_param16(2, Body4()),
3908
+ _ts_metadata16("design:type", Function),
3909
+ _ts_metadata16("design:paramtypes", [
3485
3910
  typeof Request === "undefined" ? Object : Request,
3486
3911
  String,
3487
3912
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
3488
3913
  ]),
3489
- _ts_metadata15("design:returntype", Promise)
3914
+ _ts_metadata16("design:returntype", Promise)
3490
3915
  ], ThreadsController.prototype, "update", null);
3491
- _ts_decorate15([
3916
+ _ts_decorate17([
3492
3917
  Post5(":id/promote"),
3493
- _ts_param14(0, Req10()),
3494
- _ts_param14(1, Param5("id")),
3495
- _ts_metadata15("design:type", Function),
3496
- _ts_metadata15("design:paramtypes", [
3918
+ _ts_param16(0, Req10()),
3919
+ _ts_param16(1, Param5("id")),
3920
+ _ts_metadata16("design:type", Function),
3921
+ _ts_metadata16("design:paramtypes", [
3497
3922
  typeof Request === "undefined" ? Object : Request,
3498
3923
  String
3499
3924
  ]),
3500
- _ts_metadata15("design:returntype", Promise)
3925
+ _ts_metadata16("design:returntype", Promise)
3501
3926
  ], ThreadsController.prototype, "promote", null);
3502
- _ts_decorate15([
3927
+ _ts_decorate17([
3503
3928
  Delete3(":id/from/:messageId"),
3504
- _ts_param14(0, Req10()),
3505
- _ts_param14(1, Param5("id")),
3506
- _ts_param14(2, Param5("messageId")),
3507
- _ts_metadata15("design:type", Function),
3508
- _ts_metadata15("design:paramtypes", [
3929
+ _ts_param16(0, Req10()),
3930
+ _ts_param16(1, Param5("id")),
3931
+ _ts_param16(2, Param5("messageId")),
3932
+ _ts_metadata16("design:type", Function),
3933
+ _ts_metadata16("design:paramtypes", [
3509
3934
  typeof Request === "undefined" ? Object : Request,
3510
3935
  String,
3511
3936
  String
3512
3937
  ]),
3513
- _ts_metadata15("design:returntype", Promise)
3938
+ _ts_metadata16("design:returntype", Promise)
3514
3939
  ], ThreadsController.prototype, "truncateFrom", null);
3515
- ThreadsController = _ts_decorate15([
3940
+ ThreadsController = _ts_decorate17([
3516
3941
  Controller11("threads"),
3517
- _ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER10)),
3518
- _ts_metadata15("design:type", Function),
3519
- _ts_metadata15("design:paramtypes", [
3942
+ _ts_param16(1, Inject16(AGENT_ACTOR_RESOLVER10)),
3943
+ _ts_metadata16("design:type", Function),
3944
+ _ts_metadata16("design:paramtypes", [
3520
3945
  typeof AgentService === "undefined" ? Object : AgentService,
3521
3946
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3522
3947
  ])
@@ -3524,8 +3949,8 @@ ThreadsController = _ts_decorate15([
3524
3949
 
3525
3950
  // src/controller/tool-call.controller.ts
3526
3951
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11 } from "@dudousxd/nestjs-agent-core";
3527
- import { BadRequestException as BadRequestException6, Body as Body5, Controller as Controller12, Inject as Inject15, Post as Post6, Req as Req11 } from "@nestjs/common";
3528
- function _ts_decorate16(decorators, target, key, desc) {
3952
+ import { BadRequestException as BadRequestException6, Body as Body5, Controller as Controller12, Inject as Inject17, Post as Post6, Req as Req11 } from "@nestjs/common";
3953
+ function _ts_decorate18(decorators, target, key, desc) {
3529
3954
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3530
3955
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3531
3956
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3538,19 +3963,19 @@ function _ts_decorate16(decorators, target, key, desc) {
3538
3963
  }
3539
3964
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3540
3965
  }
3541
- __name(_ts_decorate16, "_ts_decorate");
3542
- function _ts_metadata16(metadataKey, metadataValue) {
3966
+ __name(_ts_decorate18, "_ts_decorate");
3967
+ function _ts_metadata17(metadataKey, metadataValue) {
3543
3968
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3544
3969
  return Reflect.metadata(metadataKey, metadataValue);
3545
3970
  }
3546
3971
  }
3547
- __name(_ts_metadata16, "_ts_metadata");
3548
- function _ts_param15(paramIndex, decorator) {
3972
+ __name(_ts_metadata17, "_ts_metadata");
3973
+ function _ts_param17(paramIndex, decorator) {
3549
3974
  return function(target, key) {
3550
3975
  decorator(target, key, paramIndex);
3551
3976
  };
3552
3977
  }
3553
- __name(_ts_param15, "_ts_param");
3978
+ __name(_ts_param17, "_ts_param");
3554
3979
  var MAX_ANSWERED_QUESTIONS = 100;
3555
3980
  var MAX_VALUES_PER_QUESTION = 100;
3556
3981
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -3683,55 +4108,55 @@ var ToolCallController = class {
3683
4108
  };
3684
4109
  }
3685
4110
  };
3686
- _ts_decorate16([
4111
+ _ts_decorate18([
3687
4112
  Post6("approve"),
3688
- _ts_param15(0, Req11()),
3689
- _ts_param15(1, Body5()),
3690
- _ts_metadata16("design:type", Function),
3691
- _ts_metadata16("design:paramtypes", [
4113
+ _ts_param17(0, Req11()),
4114
+ _ts_param17(1, Body5()),
4115
+ _ts_metadata17("design:type", Function),
4116
+ _ts_metadata17("design:paramtypes", [
3692
4117
  typeof Request === "undefined" ? Object : Request,
3693
4118
  typeof ApproveBody === "undefined" ? Object : ApproveBody
3694
4119
  ]),
3695
- _ts_metadata16("design:returntype", Promise)
4120
+ _ts_metadata17("design:returntype", Promise)
3696
4121
  ], ToolCallController.prototype, "approve", null);
3697
- _ts_decorate16([
4122
+ _ts_decorate18([
3698
4123
  Post6("reject"),
3699
- _ts_param15(0, Req11()),
3700
- _ts_param15(1, Body5()),
3701
- _ts_metadata16("design:type", Function),
3702
- _ts_metadata16("design:paramtypes", [
4124
+ _ts_param17(0, Req11()),
4125
+ _ts_param17(1, Body5()),
4126
+ _ts_metadata17("design:type", Function),
4127
+ _ts_metadata17("design:paramtypes", [
3703
4128
  typeof Request === "undefined" ? Object : Request,
3704
4129
  typeof RejectBody === "undefined" ? Object : RejectBody
3705
4130
  ]),
3706
- _ts_metadata16("design:returntype", Promise)
4131
+ _ts_metadata17("design:returntype", Promise)
3707
4132
  ], ToolCallController.prototype, "reject", null);
3708
- _ts_decorate16([
4133
+ _ts_decorate18([
3709
4134
  Post6("answer"),
3710
- _ts_param15(0, Req11()),
3711
- _ts_param15(1, Body5()),
3712
- _ts_metadata16("design:type", Function),
3713
- _ts_metadata16("design:paramtypes", [
4135
+ _ts_param17(0, Req11()),
4136
+ _ts_param17(1, Body5()),
4137
+ _ts_metadata17("design:type", Function),
4138
+ _ts_metadata17("design:paramtypes", [
3714
4139
  typeof Request === "undefined" ? Object : Request,
3715
4140
  typeof AnswerBody === "undefined" ? Object : AnswerBody
3716
4141
  ]),
3717
- _ts_metadata16("design:returntype", Promise)
4142
+ _ts_metadata17("design:returntype", Promise)
3718
4143
  ], ToolCallController.prototype, "answer", null);
3719
- _ts_decorate16([
4144
+ _ts_decorate18([
3720
4145
  Post6("skip"),
3721
- _ts_param15(0, Req11()),
3722
- _ts_param15(1, Body5()),
3723
- _ts_metadata16("design:type", Function),
3724
- _ts_metadata16("design:paramtypes", [
4146
+ _ts_param17(0, Req11()),
4147
+ _ts_param17(1, Body5()),
4148
+ _ts_metadata17("design:type", Function),
4149
+ _ts_metadata17("design:paramtypes", [
3725
4150
  typeof Request === "undefined" ? Object : Request,
3726
4151
  Object
3727
4152
  ]),
3728
- _ts_metadata16("design:returntype", Promise)
4153
+ _ts_metadata17("design:returntype", Promise)
3729
4154
  ], ToolCallController.prototype, "skip", null);
3730
- ToolCallController = _ts_decorate16([
4155
+ ToolCallController = _ts_decorate18([
3731
4156
  Controller12("tool-call"),
3732
- _ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER11)),
3733
- _ts_metadata16("design:type", Function),
3734
- _ts_metadata16("design:paramtypes", [
4157
+ _ts_param17(1, Inject17(AGENT_ACTOR_RESOLVER11)),
4158
+ _ts_metadata17("design:type", Function),
4159
+ _ts_metadata17("design:paramtypes", [
3735
4160
  typeof AgentService === "undefined" ? Object : AgentService,
3736
4161
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3737
4162
  ])
@@ -3739,8 +4164,8 @@ ToolCallController = _ts_decorate16([
3739
4164
 
3740
4165
  // src/controller/tools.controller.ts
3741
4166
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY3, ALL_AGENTS, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
3742
- import { Controller as Controller13, Get as Get11, Inject as Inject16, NotFoundException as NotFoundException3, Query as Query5, Req as Req12 } from "@nestjs/common";
3743
- function _ts_decorate17(decorators, target, key, desc) {
4167
+ import { Controller as Controller13, Get as Get11, Inject as Inject18, NotFoundException as NotFoundException4, Query as Query5, Req as Req12 } from "@nestjs/common";
4168
+ function _ts_decorate19(decorators, target, key, desc) {
3744
4169
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3745
4170
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3746
4171
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3753,19 +4178,19 @@ function _ts_decorate17(decorators, target, key, desc) {
3753
4178
  }
3754
4179
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3755
4180
  }
3756
- __name(_ts_decorate17, "_ts_decorate");
3757
- function _ts_metadata17(metadataKey, metadataValue) {
4181
+ __name(_ts_decorate19, "_ts_decorate");
4182
+ function _ts_metadata18(metadataKey, metadataValue) {
3758
4183
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3759
4184
  return Reflect.metadata(metadataKey, metadataValue);
3760
4185
  }
3761
4186
  }
3762
- __name(_ts_metadata17, "_ts_metadata");
3763
- function _ts_param16(paramIndex, decorator) {
4187
+ __name(_ts_metadata18, "_ts_metadata");
4188
+ function _ts_param18(paramIndex, decorator) {
3764
4189
  return function(target, key) {
3765
4190
  decorator(target, key, paramIndex);
3766
4191
  };
3767
4192
  }
3768
- __name(_ts_param16, "_ts_param");
4193
+ __name(_ts_param18, "_ts_param");
3769
4194
  var ToolsController = class {
3770
4195
  static {
3771
4196
  __name(this, "ToolsController");
@@ -3780,7 +4205,7 @@ var ToolsController = class {
3780
4205
  }
3781
4206
  async list(req, agent) {
3782
4207
  if (agent !== void 0 && agent !== ALL_AGENTS && this.agents.get(agent) === void 0) {
3783
- throw new NotFoundException3(`No agent named "${agent}"`);
4208
+ throw new NotFoundException4(`No agent named "${agent}"`);
3784
4209
  }
3785
4210
  const actor = await this.actorResolver.resolve(req);
3786
4211
  const names = agent === ALL_AGENTS ? [
@@ -3809,24 +4234,24 @@ var ToolsController = class {
3809
4234
  ];
3810
4235
  }
3811
4236
  };
3812
- _ts_decorate17([
4237
+ _ts_decorate19([
3813
4238
  Get11(),
3814
- _ts_param16(0, Req12()),
3815
- _ts_param16(1, Query5("agent")),
3816
- _ts_metadata17("design:type", Function),
3817
- _ts_metadata17("design:paramtypes", [
4239
+ _ts_param18(0, Req12()),
4240
+ _ts_param18(1, Query5("agent")),
4241
+ _ts_metadata18("design:type", Function),
4242
+ _ts_metadata18("design:paramtypes", [
3818
4243
  typeof Request === "undefined" ? Object : Request,
3819
4244
  String
3820
4245
  ]),
3821
- _ts_metadata17("design:returntype", Promise)
4246
+ _ts_metadata18("design:returntype", Promise)
3822
4247
  ], ToolsController.prototype, "list", null);
3823
- ToolsController = _ts_decorate17([
4248
+ ToolsController = _ts_decorate19([
3824
4249
  Controller13("tools"),
3825
- _ts_param16(0, Inject16(AGENT_ACTOR_RESOLVER12)),
3826
- _ts_param16(1, Inject16(AGENT_DEPS_FACTORY4)),
3827
- _ts_param16(2, Inject16(AGENT_REGISTRY3)),
3828
- _ts_metadata17("design:type", Function),
3829
- _ts_metadata17("design:paramtypes", [
4250
+ _ts_param18(0, Inject18(AGENT_ACTOR_RESOLVER12)),
4251
+ _ts_param18(1, Inject18(AGENT_DEPS_FACTORY4)),
4252
+ _ts_param18(2, Inject18(AGENT_REGISTRY3)),
4253
+ _ts_metadata18("design:type", Function),
4254
+ _ts_metadata18("design:paramtypes", [
3830
4255
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3831
4256
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
3832
4257
  typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
@@ -3835,7 +4260,7 @@ ToolsController = _ts_decorate17([
3835
4260
 
3836
4261
  // src/discovery/agent-discovery.service.ts
3837
4262
  import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
3838
- import { Inject as Inject17, Injectable as Injectable5, Logger as Logger2 } from "@nestjs/common";
4263
+ import { Inject as Inject19, Injectable as Injectable6, Logger as Logger2 } from "@nestjs/common";
3839
4264
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
3840
4265
 
3841
4266
  // src/decorator/agent.decorator.ts
@@ -3870,7 +4295,7 @@ function SystemPromptContributor() {
3870
4295
  __name(SystemPromptContributor, "SystemPromptContributor");
3871
4296
 
3872
4297
  // src/discovery/agent-discovery.service.ts
3873
- function _ts_decorate18(decorators, target, key, desc) {
4298
+ function _ts_decorate20(decorators, target, key, desc) {
3874
4299
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3875
4300
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3876
4301
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3883,19 +4308,19 @@ function _ts_decorate18(decorators, target, key, desc) {
3883
4308
  }
3884
4309
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3885
4310
  }
3886
- __name(_ts_decorate18, "_ts_decorate");
3887
- function _ts_metadata18(metadataKey, metadataValue) {
4311
+ __name(_ts_decorate20, "_ts_decorate");
4312
+ function _ts_metadata19(metadataKey, metadataValue) {
3888
4313
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3889
4314
  return Reflect.metadata(metadataKey, metadataValue);
3890
4315
  }
3891
4316
  }
3892
- __name(_ts_metadata18, "_ts_metadata");
3893
- function _ts_param17(paramIndex, decorator) {
4317
+ __name(_ts_metadata19, "_ts_metadata");
4318
+ function _ts_param19(paramIndex, decorator) {
3894
4319
  return function(target, key) {
3895
4320
  decorator(target, key, paramIndex);
3896
4321
  };
3897
4322
  }
3898
- __name(_ts_param17, "_ts_param");
4323
+ __name(_ts_param19, "_ts_param");
3899
4324
  var AgentDiscoveryService = class _AgentDiscoveryService {
3900
4325
  static {
3901
4326
  __name(this, "AgentDiscoveryService");
@@ -4061,12 +4486,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
4061
4486
  return (ctx) => candidate.call(instance, ctx);
4062
4487
  }
4063
4488
  };
4064
- AgentDiscoveryService = _ts_decorate18([
4065
- Injectable5(),
4066
- _ts_param17(2, Inject17(AGENT_REGISTRY4)),
4067
- _ts_param17(3, Inject17(AGENT_PROMPT_CONTRIBUTORS2)),
4068
- _ts_metadata18("design:type", Function),
4069
- _ts_metadata18("design:paramtypes", [
4489
+ AgentDiscoveryService = _ts_decorate20([
4490
+ Injectable6(),
4491
+ _ts_param19(2, Inject19(AGENT_REGISTRY4)),
4492
+ _ts_param19(3, Inject19(AGENT_PROMPT_CONTRIBUTORS2)),
4493
+ _ts_metadata19("design:type", Function),
4494
+ _ts_metadata19("design:paramtypes", [
4070
4495
  typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
4071
4496
  typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
4072
4497
  typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
@@ -4075,8 +4500,8 @@ AgentDiscoveryService = _ts_decorate18([
4075
4500
  ], AgentDiscoveryService);
4076
4501
 
4077
4502
  // src/discovery/ai-tool-discovery.service.ts
4078
- import { AGENT_OPTIONS as AGENT_OPTIONS6, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
4079
- import { Inject as Inject18, Injectable as Injectable6, Logger as Logger3 } from "@nestjs/common";
4503
+ import { AGENT_OPTIONS as AGENT_OPTIONS7, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
4504
+ import { Inject as Inject20, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
4080
4505
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
4081
4506
  import { z } from "zod";
4082
4507
 
@@ -4108,46 +4533,8 @@ function readAiToolMetadata(target) {
4108
4533
  }
4109
4534
  __name(readAiToolMetadata, "readAiToolMetadata");
4110
4535
 
4111
- // src/functional-tool.ts
4112
- var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
4113
- function brand(tool) {
4114
- return {
4115
- [AGENT_TOOL_BRAND]: true,
4116
- spec: tool.spec,
4117
- handler: tool.handler
4118
- };
4119
- }
4120
- __name(brand, "brand");
4121
- function isBrandedFunctionalTool(value) {
4122
- return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
4123
- }
4124
- __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
4125
- function provideAgentTool(factoryOrTool, inject) {
4126
- const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
4127
- if (typeof factoryOrTool === "function") {
4128
- return {
4129
- provide,
4130
- useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
4131
- inject: inject ?? []
4132
- };
4133
- }
4134
- return {
4135
- provide,
4136
- useValue: brand(factoryOrTool)
4137
- };
4138
- }
4139
- __name(provideAgentTool, "provideAgentTool");
4140
- function provideAgentTools(factory, inject) {
4141
- return {
4142
- provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
4143
- useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
4144
- inject: inject ?? []
4145
- };
4146
- }
4147
- __name(provideAgentTools, "provideAgentTools");
4148
-
4149
4536
  // src/discovery/ai-tool-discovery.service.ts
4150
- function _ts_decorate19(decorators, target, key, desc) {
4537
+ function _ts_decorate21(decorators, target, key, desc) {
4151
4538
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4152
4539
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4153
4540
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4160,19 +4547,19 @@ function _ts_decorate19(decorators, target, key, desc) {
4160
4547
  }
4161
4548
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4162
4549
  }
4163
- __name(_ts_decorate19, "_ts_decorate");
4164
- function _ts_metadata19(metadataKey, metadataValue) {
4550
+ __name(_ts_decorate21, "_ts_decorate");
4551
+ function _ts_metadata20(metadataKey, metadataValue) {
4165
4552
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4166
4553
  return Reflect.metadata(metadataKey, metadataValue);
4167
4554
  }
4168
4555
  }
4169
- __name(_ts_metadata19, "_ts_metadata");
4170
- function _ts_param18(paramIndex, decorator) {
4556
+ __name(_ts_metadata20, "_ts_metadata");
4557
+ function _ts_param20(paramIndex, decorator) {
4171
4558
  return function(target, key) {
4172
4559
  decorator(target, key, paramIndex);
4173
4560
  };
4174
4561
  }
4175
- __name(_ts_param18, "_ts_param");
4562
+ __name(_ts_param20, "_ts_param");
4176
4563
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
4177
4564
  static {
4178
4565
  __name(this, "AiToolDiscoveryService");
@@ -4240,9 +4627,15 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4240
4627
  } : {},
4241
4628
  ...meta.terminal === true ? {
4242
4629
  terminal: true
4630
+ } : {},
4631
+ ...meta.replacementKey !== void 0 ? {
4632
+ replacementKey: meta.replacementKey
4243
4633
  } : {}
4244
4634
  }, {
4245
4635
  execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
4636
+ ...typeof handler.preflight === "function" ? {
4637
+ preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
4638
+ } : {},
4246
4639
  // Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
4247
4640
  // `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
4248
4641
  // Called through `instance` so each keeps its `this` (and its injected deps).
@@ -4316,13 +4709,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4316
4709
  return true;
4317
4710
  }
4318
4711
  };
4319
- AiToolDiscoveryService = _ts_decorate19([
4320
- Injectable6(),
4321
- _ts_param18(1, Inject18(AGENT_TOOL_REGISTRY2)),
4322
- _ts_param18(2, Inject18(AGENT_REGISTRY5)),
4323
- _ts_param18(3, Inject18(AGENT_OPTIONS6)),
4324
- _ts_metadata19("design:type", Function),
4325
- _ts_metadata19("design:paramtypes", [
4712
+ AiToolDiscoveryService = _ts_decorate21([
4713
+ Injectable7(),
4714
+ _ts_param20(1, Inject20(AGENT_TOOL_REGISTRY2)),
4715
+ _ts_param20(2, Inject20(AGENT_REGISTRY5)),
4716
+ _ts_param20(3, Inject20(AGENT_OPTIONS7)),
4717
+ _ts_metadata20("design:type", Function),
4718
+ _ts_metadata20("design:paramtypes", [
4326
4719
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
4327
4720
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
4328
4721
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -4332,7 +4725,7 @@ AiToolDiscoveryService = _ts_decorate19([
4332
4725
 
4333
4726
  // src/discovery/skill-discovery.service.ts
4334
4727
  import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
4335
- import { Inject as Inject19, Injectable as Injectable7, Logger as Logger4 } from "@nestjs/common";
4728
+ import { Inject as Inject21, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
4336
4729
  import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
4337
4730
 
4338
4731
  // src/decorator/skill.decorator.ts
@@ -4355,7 +4748,7 @@ function skillScope(options) {
4355
4748
  __name(skillScope, "skillScope");
4356
4749
 
4357
4750
  // src/discovery/skill-discovery.service.ts
4358
- function _ts_decorate20(decorators, target, key, desc) {
4751
+ function _ts_decorate22(decorators, target, key, desc) {
4359
4752
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4360
4753
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4361
4754
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4368,19 +4761,19 @@ function _ts_decorate20(decorators, target, key, desc) {
4368
4761
  }
4369
4762
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4370
4763
  }
4371
- __name(_ts_decorate20, "_ts_decorate");
4372
- function _ts_metadata20(metadataKey, metadataValue) {
4764
+ __name(_ts_decorate22, "_ts_decorate");
4765
+ function _ts_metadata21(metadataKey, metadataValue) {
4373
4766
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4374
4767
  return Reflect.metadata(metadataKey, metadataValue);
4375
4768
  }
4376
4769
  }
4377
- __name(_ts_metadata20, "_ts_metadata");
4378
- function _ts_param19(paramIndex, decorator) {
4770
+ __name(_ts_metadata21, "_ts_metadata");
4771
+ function _ts_param21(paramIndex, decorator) {
4379
4772
  return function(target, key) {
4380
4773
  decorator(target, key, paramIndex);
4381
4774
  };
4382
4775
  }
4383
- __name(_ts_param19, "_ts_param");
4776
+ __name(_ts_param21, "_ts_param");
4384
4777
  var SkillDiscoveryService = class _SkillDiscoveryService {
4385
4778
  static {
4386
4779
  __name(this, "SkillDiscoveryService");
@@ -4424,11 +4817,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
4424
4817
  return flat === void 0 ? void 0 : () => flat;
4425
4818
  }
4426
4819
  };
4427
- SkillDiscoveryService = _ts_decorate20([
4428
- Injectable7(),
4429
- _ts_param19(1, Inject19(AGENT_SKILL_SOURCES)),
4430
- _ts_metadata20("design:type", Function),
4431
- _ts_metadata20("design:paramtypes", [
4820
+ SkillDiscoveryService = _ts_decorate22([
4821
+ Injectable8(),
4822
+ _ts_param21(1, Inject21(AGENT_SKILL_SOURCES)),
4823
+ _ts_metadata21("design:type", Function),
4824
+ _ts_metadata21("design:paramtypes", [
4432
4825
  typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
4433
4826
  Array
4434
4827
  ])
@@ -4564,13 +4957,248 @@ var LedgerQuotaProvider = class {
4564
4957
  }
4565
4958
  };
4566
4959
 
4960
+ // src/proposals/action-proposal-worker.service.ts
4961
+ import { randomUUID } from "crypto";
4962
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_STORE as AGENT_STORE5, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
4963
+ import { Inject as Inject22, Injectable as Injectable9, Logger as Logger5 } from "@nestjs/common";
4964
+ function _ts_decorate23(decorators, target, key, desc) {
4965
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4966
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4967
+ r = Reflect.decorate(decorators, target, key, desc);
4968
+ } else {
4969
+ for (var i = decorators.length - 1; i >= 0; i--) {
4970
+ if (d = decorators[i]) {
4971
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4972
+ }
4973
+ }
4974
+ }
4975
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4976
+ }
4977
+ __name(_ts_decorate23, "_ts_decorate");
4978
+ function _ts_metadata22(metadataKey, metadataValue) {
4979
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4980
+ return Reflect.metadata(metadataKey, metadataValue);
4981
+ }
4982
+ }
4983
+ __name(_ts_metadata22, "_ts_metadata");
4984
+ function _ts_param22(paramIndex, decorator) {
4985
+ return function(target, key) {
4986
+ decorator(target, key, paramIndex);
4987
+ };
4988
+ }
4989
+ __name(_ts_param22, "_ts_param");
4990
+ var ActionProposalWorkerService = class _ActionProposalWorkerService {
4991
+ static {
4992
+ __name(this, "ActionProposalWorkerService");
4993
+ }
4994
+ store;
4995
+ options;
4996
+ deps;
4997
+ worker;
4998
+ logger = new Logger5(_ActionProposalWorkerService.name);
4999
+ constructor(store, options, deps) {
5000
+ this.store = store;
5001
+ this.options = options;
5002
+ this.deps = deps;
5003
+ }
5004
+ onModuleInit() {
5005
+ if (this.options.actionApprovalMode !== "independent") return;
5006
+ assertIndependentActionCapabilities2(this.store, this.options.backgroundActorResolver);
5007
+ if (this.options.surface === "http") return;
5008
+ const resolver = this.options.backgroundActorResolver;
5009
+ if (!resolver) throw new Error("BackgroundActorResolver is required");
5010
+ this.worker = new ActionProposalWorker({
5011
+ store: this.store,
5012
+ workerId: randomUUID(),
5013
+ ...this.options.actionProposalWorker,
5014
+ executor: new ActionProposalExecutor({
5015
+ resolver,
5016
+ resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
5017
+ const deps = this.deps.forProposal(proposal, actor);
5018
+ return {
5019
+ registry: deps.registry,
5020
+ rolesPolicy: deps.rolesPolicy,
5021
+ ...deps.resolveUiCatalog !== void 0 ? {
5022
+ resolveUiCatalog: deps.resolveUiCatalog
5023
+ } : {},
5024
+ ...deps.toolAllowList !== void 0 ? {
5025
+ allowedTools: deps.toolAllowList
5026
+ } : {}
5027
+ };
5028
+ }, "resolveExecution")
5029
+ }),
5030
+ onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
5031
+ });
5032
+ this.worker.start();
5033
+ }
5034
+ async onModuleDestroy() {
5035
+ await this.worker?.stop();
5036
+ }
5037
+ };
5038
+ ActionProposalWorkerService = _ts_decorate23([
5039
+ Injectable9(),
5040
+ _ts_param22(0, Inject22(AGENT_STORE5)),
5041
+ _ts_param22(1, Inject22(AGENT_OPTIONS8)),
5042
+ _ts_param22(2, Inject22(AGENT_DEPS_FACTORY5)),
5043
+ _ts_metadata22("design:type", Function),
5044
+ _ts_metadata22("design:paramtypes", [
5045
+ typeof AgentStore === "undefined" ? Object : AgentStore,
5046
+ typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
5047
+ typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
5048
+ ])
5049
+ ], ActionProposalWorkerService);
5050
+
5051
+ // src/proposals/action-proposal.controller.ts
5052
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, validateActionProposalListQuery } from "@dudousxd/nestjs-agent-core";
5053
+ import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as Inject23, Param as Param6, Post as Post7, Query as Query6, Req as Req13, Res as Res2 } from "@nestjs/common";
5054
+ function _ts_decorate24(decorators, target, key, desc) {
5055
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5056
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5057
+ r = Reflect.decorate(decorators, target, key, desc);
5058
+ } else {
5059
+ for (var i = decorators.length - 1; i >= 0; i--) {
5060
+ if (d = decorators[i]) {
5061
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5062
+ }
5063
+ }
5064
+ }
5065
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5066
+ }
5067
+ __name(_ts_decorate24, "_ts_decorate");
5068
+ function _ts_metadata23(metadataKey, metadataValue) {
5069
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5070
+ return Reflect.metadata(metadataKey, metadataValue);
5071
+ }
5072
+ }
5073
+ __name(_ts_metadata23, "_ts_metadata");
5074
+ function _ts_param23(paramIndex, decorator) {
5075
+ return function(target, key) {
5076
+ decorator(target, key, paramIndex);
5077
+ };
5078
+ }
5079
+ __name(_ts_param23, "_ts_param");
5080
+ function bodyFields(body, field2) {
5081
+ if (body === void 0) return {};
5082
+ if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field2)) throw new BadRequestException7(`Only ${field2} is accepted`);
5083
+ const value = body;
5084
+ if (value[field2] !== void 0 && (field2 === "remember" && typeof value[field2] !== "boolean" || field2 === "reason" && typeof value[field2] !== "string")) throw new BadRequestException7(`Invalid ${field2}`);
5085
+ return value;
5086
+ }
5087
+ __name(bodyFields, "bodyFields");
5088
+ var ActionProposalController = class {
5089
+ static {
5090
+ __name(this, "ActionProposalController");
5091
+ }
5092
+ proposals;
5093
+ actors;
5094
+ constructor(proposals, actors) {
5095
+ this.proposals = proposals;
5096
+ this.actors = actors;
5097
+ }
5098
+ async list(threadId, request, cursor, response) {
5099
+ let query = {};
5100
+ if (cursor !== void 0) {
5101
+ try {
5102
+ if (typeof cursor !== "string") throw new Error("Invalid cursor");
5103
+ query = {
5104
+ after: JSON.parse(cursor)
5105
+ };
5106
+ validateActionProposalListQuery(query);
5107
+ } catch {
5108
+ throw new BadRequestException7("Invalid action proposal cursor");
5109
+ }
5110
+ }
5111
+ const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
5112
+ if (page.next) {
5113
+ response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
5114
+ const exposed = response.getHeader("Access-Control-Expose-Headers");
5115
+ response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
5116
+ }
5117
+ return page.items;
5118
+ }
5119
+ async approve(threadId, proposalId, request, body) {
5120
+ const value = bodyFields(body, "remember");
5121
+ return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
5122
+ decision: "approved",
5123
+ ...typeof value.remember === "boolean" ? {
5124
+ remember: value.remember
5125
+ } : {}
5126
+ });
5127
+ }
5128
+ async reject(threadId, proposalId, request, body) {
5129
+ const value = bodyFields(body, "reason");
5130
+ return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
5131
+ decision: "rejected",
5132
+ ...typeof value.reason === "string" ? {
5133
+ reason: value.reason
5134
+ } : {}
5135
+ });
5136
+ }
5137
+ };
5138
+ _ts_decorate24([
5139
+ Get12(),
5140
+ _ts_param23(0, Param6("threadId")),
5141
+ _ts_param23(1, Req13()),
5142
+ _ts_param23(2, Query6("after")),
5143
+ _ts_param23(3, Res2({
5144
+ passthrough: true
5145
+ })),
5146
+ _ts_metadata23("design:type", Function),
5147
+ _ts_metadata23("design:paramtypes", [
5148
+ String,
5149
+ typeof Request === "undefined" ? Object : Request,
5150
+ Object,
5151
+ typeof Response === "undefined" ? Object : Response
5152
+ ]),
5153
+ _ts_metadata23("design:returntype", Promise)
5154
+ ], ActionProposalController.prototype, "list", null);
5155
+ _ts_decorate24([
5156
+ Post7(":proposalId/approve"),
5157
+ _ts_param23(0, Param6("threadId")),
5158
+ _ts_param23(1, Param6("proposalId")),
5159
+ _ts_param23(2, Req13()),
5160
+ _ts_param23(3, Body6()),
5161
+ _ts_metadata23("design:type", Function),
5162
+ _ts_metadata23("design:paramtypes", [
5163
+ String,
5164
+ String,
5165
+ typeof Request === "undefined" ? Object : Request,
5166
+ Object
5167
+ ]),
5168
+ _ts_metadata23("design:returntype", Promise)
5169
+ ], ActionProposalController.prototype, "approve", null);
5170
+ _ts_decorate24([
5171
+ Post7(":proposalId/reject"),
5172
+ _ts_param23(0, Param6("threadId")),
5173
+ _ts_param23(1, Param6("proposalId")),
5174
+ _ts_param23(2, Req13()),
5175
+ _ts_param23(3, Body6()),
5176
+ _ts_metadata23("design:type", Function),
5177
+ _ts_metadata23("design:paramtypes", [
5178
+ String,
5179
+ String,
5180
+ typeof Request === "undefined" ? Object : Request,
5181
+ Object
5182
+ ]),
5183
+ _ts_metadata23("design:returntype", Promise)
5184
+ ], ActionProposalController.prototype, "reject", null);
5185
+ ActionProposalController = _ts_decorate24([
5186
+ Controller14("threads/:threadId/action-proposals"),
5187
+ _ts_param23(1, Inject23(AGENT_ACTOR_RESOLVER13)),
5188
+ _ts_metadata23("design:type", Function),
5189
+ _ts_metadata23("design:paramtypes", [
5190
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
5191
+ typeof ActorResolver === "undefined" ? Object : ActorResolver
5192
+ ])
5193
+ ], ActionProposalController);
5194
+
4567
5195
  // src/queue/chat-queue.token.ts
4568
5196
  var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
4569
5197
 
4570
5198
  // src/runner/inline-agent-runner.ts
4571
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_STORE as AGENT_STORE4, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleUnsettledDelegation, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
4572
- import { Inject as Inject20, Injectable as Injectable8, Logger as Logger5, Optional as Optional8 } from "@nestjs/common";
4573
- function _ts_decorate21(decorators, target, key, desc) {
5199
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleUnsettledDelegation, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
5200
+ import { Inject as Inject24, Injectable as Injectable10, Logger as Logger6, Optional as Optional9 } from "@nestjs/common";
5201
+ function _ts_decorate25(decorators, target, key, desc) {
4574
5202
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4575
5203
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4576
5204
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4583,19 +5211,19 @@ function _ts_decorate21(decorators, target, key, desc) {
4583
5211
  }
4584
5212
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4585
5213
  }
4586
- __name(_ts_decorate21, "_ts_decorate");
4587
- function _ts_metadata21(metadataKey, metadataValue) {
5214
+ __name(_ts_decorate25, "_ts_decorate");
5215
+ function _ts_metadata24(metadataKey, metadataValue) {
4588
5216
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4589
5217
  return Reflect.metadata(metadataKey, metadataValue);
4590
5218
  }
4591
5219
  }
4592
- __name(_ts_metadata21, "_ts_metadata");
4593
- function _ts_param20(paramIndex, decorator) {
5220
+ __name(_ts_metadata24, "_ts_metadata");
5221
+ function _ts_param24(paramIndex, decorator) {
4594
5222
  return function(target, key) {
4595
5223
  decorator(target, key, paramIndex);
4596
5224
  };
4597
5225
  }
4598
- __name(_ts_param20, "_ts_param");
5226
+ __name(_ts_param24, "_ts_param");
4599
5227
  var InlineAgentRunner = class _InlineAgentRunner {
4600
5228
  static {
4601
5229
  __name(this, "InlineAgentRunner");
@@ -4603,7 +5231,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
4603
5231
  factory;
4604
5232
  store;
4605
5233
  queue;
4606
- logger = new Logger5(_InlineAgentRunner.name);
5234
+ logger = new Logger6(_InlineAgentRunner.name);
4607
5235
  pending = /* @__PURE__ */ new Map();
4608
5236
  /**
4609
5237
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -5046,13 +5674,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
5046
5674
  }
5047
5675
  }
5048
5676
  };
5049
- InlineAgentRunner = _ts_decorate21([
5050
- Injectable8(),
5051
- _ts_param20(0, Inject20(AGENT_DEPS_FACTORY5)),
5052
- _ts_param20(1, Inject20(AGENT_STORE4)),
5053
- _ts_param20(2, Optional8()),
5054
- _ts_metadata21("design:type", Function),
5055
- _ts_metadata21("design:paramtypes", [
5677
+ InlineAgentRunner = _ts_decorate25([
5678
+ Injectable10(),
5679
+ _ts_param24(0, Inject24(AGENT_DEPS_FACTORY6)),
5680
+ _ts_param24(1, Inject24(AGENT_STORE6)),
5681
+ _ts_param24(2, Optional9()),
5682
+ _ts_metadata24("design:type", Function),
5683
+ _ts_metadata24("design:paramtypes", [
5056
5684
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
5057
5685
  typeof AgentStore === "undefined" ? Object : AgentStore,
5058
5686
  typeof ChatQueueService === "undefined" ? Object : ChatQueueService
@@ -5102,7 +5730,7 @@ function resolveSkillsConfig(options, declared) {
5102
5730
  __name(resolveSkillsConfig, "resolveSkillsConfig");
5103
5731
 
5104
5732
  // src/agent.module.ts
5105
- function _ts_decorate22(decorators, target, key, desc) {
5733
+ function _ts_decorate26(decorators, target, key, desc) {
5106
5734
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5107
5735
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5108
5736
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5115,13 +5743,13 @@ function _ts_decorate22(decorators, target, key, desc) {
5115
5743
  }
5116
5744
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5117
5745
  }
5118
- __name(_ts_decorate22, "_ts_decorate");
5746
+ __name(_ts_decorate26, "_ts_decorate");
5119
5747
  var DEFAULT_PATH = "agent";
5120
- var logger = new Logger6("AgentModule");
5748
+ var logger = new Logger7("AgentModule");
5121
5749
  function externalStoreWrapper(modules) {
5122
5750
  for (const module of modules.values()) {
5123
5751
  if (module.metatype === AgentModule) continue;
5124
- const wrapper = module.providers.get(AGENT_STORE5);
5752
+ const wrapper = module.providers.get(AGENT_STORE7);
5125
5753
  if (wrapper !== void 0) return wrapper;
5126
5754
  }
5127
5755
  return void 0;
@@ -5194,7 +5822,7 @@ function sharedProviders(durable) {
5194
5822
  provide: AGENT_SKILLS3,
5195
5823
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
5196
5824
  inject: [
5197
- AGENT_OPTIONS7,
5825
+ AGENT_OPTIONS9,
5198
5826
  AGENT_SKILL_SOURCES2
5199
5827
  ]
5200
5828
  },
@@ -5204,39 +5832,39 @@ function sharedProviders(durable) {
5204
5832
  provide: AGENT_MEMORY3,
5205
5833
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
5206
5834
  inject: [
5207
- AGENT_OPTIONS7
5835
+ AGENT_OPTIONS9
5208
5836
  ]
5209
5837
  },
5210
5838
  {
5211
5839
  provide: AGENT_SINK3,
5212
5840
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
5213
5841
  inject: [
5214
- AGENT_OPTIONS7
5842
+ AGENT_OPTIONS9
5215
5843
  ]
5216
5844
  },
5217
5845
  {
5218
5846
  provide: AGENT_ROLES_POLICY2,
5219
5847
  useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new ClosedRolesPolicy(options.defaultRoles) : new DefaultRolesPolicy(options.defaultRoles)), "useFactory"),
5220
5848
  inject: [
5221
- AGENT_OPTIONS7
5849
+ AGENT_OPTIONS9
5222
5850
  ]
5223
5851
  },
5224
5852
  {
5225
- provide: AGENT_ACTOR_RESOLVER13,
5853
+ provide: AGENT_ACTOR_RESOLVER14,
5226
5854
  useFactory: /* @__PURE__ */ __name((options) => {
5227
5855
  if (options.actorResolver !== void 0) return options.actorResolver;
5228
5856
  logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
5229
5857
  return new AnonymousActorResolver();
5230
5858
  }, "useFactory"),
5231
5859
  inject: [
5232
- AGENT_OPTIONS7
5860
+ AGENT_OPTIONS9
5233
5861
  ]
5234
5862
  },
5235
5863
  {
5236
5864
  provide: AGENT_MODEL2,
5237
5865
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
5238
5866
  inject: [
5239
- AGENT_OPTIONS7
5867
+ AGENT_OPTIONS9
5240
5868
  ]
5241
5869
  },
5242
5870
  {
@@ -5247,20 +5875,20 @@ function sharedProviders(durable) {
5247
5875
  warnAt: o.quota.warnAt
5248
5876
  } : {}), "useFactory"),
5249
5877
  inject: [
5250
- AGENT_OPTIONS7,
5251
- AGENT_STORE5
5878
+ AGENT_OPTIONS9,
5879
+ AGENT_STORE7
5252
5880
  ]
5253
5881
  },
5254
5882
  {
5255
5883
  provide: AGENT_MODEL_CATALOG3,
5256
5884
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
5257
5885
  inject: [
5258
- AGENT_OPTIONS7
5886
+ AGENT_OPTIONS9
5259
5887
  ]
5260
5888
  },
5261
5889
  AgentDepsFactory2,
5262
5890
  {
5263
- provide: AGENT_DEPS_FACTORY6,
5891
+ provide: AGENT_DEPS_FACTORY7,
5264
5892
  useExisting: AgentDepsFactory2
5265
5893
  },
5266
5894
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -5277,6 +5905,8 @@ function sharedProviders(durable) {
5277
5905
  },
5278
5906
  InlineAgentRunner,
5279
5907
  AgentService,
5908
+ ActionProposalService,
5909
+ ActionProposalWorkerService,
5280
5910
  // Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
5281
5911
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
5282
5912
  AgentApprovalPortAdapter,
@@ -5286,10 +5916,10 @@ function sharedProviders(durable) {
5286
5916
  }
5287
5917
  ];
5288
5918
  providers.push({
5289
- provide: AGENT_STORE5,
5919
+ provide: AGENT_STORE7,
5290
5920
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
5291
5921
  inject: [
5292
- AGENT_OPTIONS7,
5922
+ AGENT_OPTIONS9,
5293
5923
  ModulesContainer
5294
5924
  ]
5295
5925
  });
@@ -5320,22 +5950,24 @@ function sharedProviders(durable) {
5320
5950
  __name(sharedProviders, "sharedProviders");
5321
5951
  function exportsFor() {
5322
5952
  return [
5323
- AGENT_OPTIONS7,
5953
+ AGENT_OPTIONS9,
5324
5954
  AGENT_TOOL_REGISTRY3,
5325
5955
  AGENT_REGISTRY6,
5326
5956
  AGENT_SINK3,
5327
5957
  AGENT_ROLES_POLICY2,
5328
- AGENT_ACTOR_RESOLVER13,
5958
+ AGENT_ACTOR_RESOLVER14,
5329
5959
  AGENT_MODEL2,
5330
- AGENT_STORE5,
5960
+ AGENT_STORE7,
5331
5961
  AGENT_MODEL_CATALOG3,
5332
5962
  AGENT_QUOTA_PROVIDER3,
5333
5963
  AGENT_PROMPT_CONTRIBUTORS3,
5334
5964
  AGENT_SKILLS3,
5335
5965
  AGENT_MEMORY3,
5336
- AGENT_DEPS_FACTORY6,
5966
+ AGENT_DEPS_FACTORY7,
5337
5967
  AgentDepsFactory2,
5338
5968
  AgentService,
5969
+ ActionProposalService,
5970
+ ActionProposalWorkerService,
5339
5971
  ChatQueueService,
5340
5972
  AGENT_CHAT_QUEUE,
5341
5973
  InlineAgentRunner,
@@ -5344,6 +5976,7 @@ function exportsFor() {
5344
5976
  }
5345
5977
  __name(exportsFor, "exportsFor");
5346
5978
  var BASE_CONTROLLERS = [
5979
+ ActionProposalController,
5347
5980
  ChatController,
5348
5981
  QueueController,
5349
5982
  ThreadsController,
@@ -5416,7 +6049,7 @@ var AgentModule = class _AgentModule {
5416
6049
  controllers: controllersForSurface(options.surface, options.adapters),
5417
6050
  providers: [
5418
6051
  {
5419
- provide: AGENT_OPTIONS7,
6052
+ provide: AGENT_OPTIONS9,
5420
6053
  useValue: options
5421
6054
  },
5422
6055
  ...sharedProviders(options.durable ?? false),
@@ -5440,7 +6073,7 @@ var AgentModule = class _AgentModule {
5440
6073
  controllers: controllersForSurface(options.surface, options.adapters),
5441
6074
  providers: [
5442
6075
  {
5443
- provide: AGENT_OPTIONS7,
6076
+ provide: AGENT_OPTIONS9,
5444
6077
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
5445
6078
  // authoritative on the async config object (they decided the actual wiring above), and
5446
6079
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -5462,16 +6095,16 @@ var AgentModule = class _AgentModule {
5462
6095
  };
5463
6096
  }
5464
6097
  };
5465
- AgentModule = _ts_decorate22([
6098
+ AgentModule = _ts_decorate26([
5466
6099
  Global(),
5467
- Module({})
6100
+ Module2({})
5468
6101
  ], AgentModule);
5469
6102
 
5470
6103
  // src/ag-ui/ag-ui.adapter.ts
5471
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING5, AGENT_OPTIONS as AGENT_OPTIONS8 } from "@dudousxd/nestjs-agent-core";
5472
- import { AG_UI_CUSTOM, agUiEvents, agUiFramesFromNdjson, agUiSse, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn } from "@dudousxd/nestjs-agent-core/ag-ui";
5473
- import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, ForbiddenException as ForbiddenException3, HttpCode as HttpCode2, Inject as Inject21, Optional as Optional9, Post as Post7, Req as Req13, Res as Res2 } from "@nestjs/common";
5474
- function _ts_decorate23(decorators, target, key, desc) {
6104
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER15, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING5, AGENT_OPTIONS as AGENT_OPTIONS10 } from "@dudousxd/nestjs-agent-core";
6105
+ import { AG_UI_CUSTOM, actionProposalDecisionEvents, agUiEvents, agUiFramesFromNdjson, agUiSse, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn } from "@dudousxd/nestjs-agent-core/ag-ui";
6106
+ import { BadRequestException as BadRequestException8, Body as Body7, Controller as Controller15, ForbiddenException as ForbiddenException4, HttpCode as HttpCode2, Inject as Inject25, Optional as Optional10, Post as Post8, Req as Req14, Res as Res3 } from "@nestjs/common";
6107
+ function _ts_decorate27(decorators, target, key, desc) {
5475
6108
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5476
6109
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5477
6110
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5484,22 +6117,22 @@ function _ts_decorate23(decorators, target, key, desc) {
5484
6117
  }
5485
6118
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5486
6119
  }
5487
- __name(_ts_decorate23, "_ts_decorate");
5488
- function _ts_metadata22(metadataKey, metadataValue) {
6120
+ __name(_ts_decorate27, "_ts_decorate");
6121
+ function _ts_metadata25(metadataKey, metadataValue) {
5489
6122
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5490
6123
  return Reflect.metadata(metadataKey, metadataValue);
5491
6124
  }
5492
6125
  }
5493
- __name(_ts_metadata22, "_ts_metadata");
5494
- function _ts_param21(paramIndex, decorator) {
6126
+ __name(_ts_metadata25, "_ts_metadata");
6127
+ function _ts_param25(paramIndex, decorator) {
5495
6128
  return function(target, key) {
5496
6129
  decorator(target, key, paramIndex);
5497
6130
  };
5498
6131
  }
5499
- __name(_ts_param21, "_ts_param");
6132
+ __name(_ts_param25, "_ts_param");
5500
6133
  var AG_UI_VIA = "ag-ui";
5501
6134
  function invalid(code, message) {
5502
- return new BadRequestException7({
6135
+ return new BadRequestException8({
5503
6136
  statusCode: 400,
5504
6137
  code,
5505
6138
  message
@@ -5578,7 +6211,27 @@ var AgUiRunHandler = class {
5578
6211
  warnings.push(...turn.dropped);
5579
6212
  const owner = await this.agent.threadOwner(input.threadId);
5580
6213
  if (owner !== null && owner !== actor.id) {
5581
- throw new ForbiddenException3("thread belongs to another actor");
6214
+ throw new ForbiddenException4("thread belongs to another actor");
6215
+ }
6216
+ if (owner !== null && turn.media.length === 0) {
6217
+ const decision = await this.agent.handleTextDecision(input.threadId, actor, turn.text);
6218
+ if ("proposalDecision" in decision) {
6219
+ res.status(200);
6220
+ res.setHeader("Content-Type", "text/event-stream");
6221
+ res.setHeader("Cache-Control", "no-cache, no-transform");
6222
+ res.flushHeaders();
6223
+ for (const event of [
6224
+ ...warningEvents(warnings),
6225
+ ...actionProposalDecisionEvents({
6226
+ threadId: input.threadId,
6227
+ runId: input.runId,
6228
+ text: decision.text,
6229
+ proposalDecision: decision.proposalDecision
6230
+ })
6231
+ ]) res.write(agUiSse(event));
6232
+ res.end();
6233
+ return;
6234
+ }
5582
6235
  }
5583
6236
  const refs = await this.stage(actor, turn.media, warnings);
5584
6237
  if (turn.text.trim().length === 0 && refs.length === 0) {
@@ -5608,6 +6261,9 @@ var AgUiRunHandler = class {
5608
6261
  ...forwarded.model !== void 0 ? {
5609
6262
  model: forwarded.model
5610
6263
  } : {},
6264
+ ...forwarded.uiCapabilities !== void 0 ? {
6265
+ uiCapabilities: forwarded.uiCapabilities
6266
+ } : {},
5611
6267
  ...pageContext !== void 0 ? {
5612
6268
  pageContext
5613
6269
  } : {},
@@ -5752,29 +6408,29 @@ function agUiAdapter(options = {}) {
5752
6408
  return this.handle(req, res, body);
5753
6409
  }
5754
6410
  };
5755
- _ts_decorate23([
5756
- Post7(path),
6411
+ _ts_decorate27([
6412
+ Post8(path),
5757
6413
  HttpCode2(200),
5758
- _ts_param21(0, Req13()),
5759
- _ts_param21(1, Res2()),
5760
- _ts_param21(2, Body6()),
5761
- _ts_metadata22("design:type", Function),
5762
- _ts_metadata22("design:paramtypes", [
6414
+ _ts_param25(0, Req14()),
6415
+ _ts_param25(1, Res3()),
6416
+ _ts_param25(2, Body7()),
6417
+ _ts_metadata25("design:type", Function),
6418
+ _ts_metadata25("design:paramtypes", [
5763
6419
  typeof Request === "undefined" ? Object : Request,
5764
6420
  typeof Response === "undefined" ? Object : Response,
5765
6421
  Object
5766
6422
  ]),
5767
- _ts_metadata22("design:returntype", typeof Promise === "undefined" ? Object : Promise)
6423
+ _ts_metadata25("design:returntype", typeof Promise === "undefined" ? Object : Promise)
5768
6424
  ], AgUiController.prototype, "run", null);
5769
- AgUiController = _ts_decorate23([
5770
- Controller14(),
5771
- _ts_param21(0, Inject21(AgentService)),
5772
- _ts_param21(1, Inject21(AGENT_ACTOR_RESOLVER14)),
5773
- _ts_param21(2, Inject21(AGENT_OPTIONS8)),
5774
- _ts_param21(3, Optional9()),
5775
- _ts_param21(3, Inject21(AGENT_ATTACHMENT_STAGING5)),
5776
- _ts_metadata22("design:type", Function),
5777
- _ts_metadata22("design:paramtypes", [
6425
+ AgUiController = _ts_decorate27([
6426
+ Controller15(),
6427
+ _ts_param25(0, Inject25(AgentService)),
6428
+ _ts_param25(1, Inject25(AGENT_ACTOR_RESOLVER15)),
6429
+ _ts_param25(2, Inject25(AGENT_OPTIONS10)),
6430
+ _ts_param25(3, Optional10()),
6431
+ _ts_param25(3, Inject25(AGENT_ATTACHMENT_STAGING5)),
6432
+ _ts_metadata25("design:type", Function),
6433
+ _ts_metadata25("design:paramtypes", [
5778
6434
  typeof AgentService === "undefined" ? Object : AgentService,
5779
6435
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
5780
6436
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -5872,6 +6528,9 @@ export {
5872
6528
  AGENT_TOOL_BRAND,
5873
6529
  AI_TOOL_METADATA,
5874
6530
  ATTACHMENT_PAGE_SIZE,
6531
+ ActionProposalController,
6532
+ ActionProposalService,
6533
+ ActionProposalWorkerService,
5875
6534
  AgUiRunHandler,
5876
6535
  Agent,
5877
6536
  AgentApprovalPortAdapter,