@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.
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/durable/agent-run.workflow.ts
5
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, isReplayIntegrityError, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleDeadRun, settleUnsettledDelegation, streamFailure } from "@dudousxd/nestjs-agent-core";
5
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_STORE, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, isReplayIntegrityError as isReplayIntegrityError2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleDeadRun, settleUnsettledDelegation, streamFailure } from "@dudousxd/nestjs-agent-core";
6
6
  import { RUN_GATEWAY, Workflow, WorkflowService } from "@dudousxd/nestjs-durable";
7
7
  import { isWorkflowControlFlowSignal } from "@dudousxd/nestjs-durable-core";
8
8
  import { Inject as Inject2, Injectable as Injectable2, Logger, Optional } from "@nestjs/common";
@@ -33,7 +33,9 @@ __name(childSinkWriter, "childSinkWriter");
33
33
  var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
34
34
 
35
35
  // src/durable/agent-run.steps.ts
36
- import { AGENT_DEPS_FACTORY, createFrameBuffer, createUiCollector, encodeStreamEvent, intersectAllowLists, invokeWithTransientRetry, observeTurnFrames, publishAgentToolRetry, stampToolKinds, toolCallContext, traceLlmTurn, traceToolExecution, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput } from "@dudousxd/nestjs-agent-core";
36
+ import { createNegotiatedUiCollector } from "@dudousxd/nestjs-agent-core";
37
+ import { prepareActionProposal, resolveActionProposalApproval } from "@dudousxd/nestjs-agent-core";
38
+ import { AGENT_DEPS_FACTORY, createFrameBuffer, createNoopEmitUi, encodeStreamEvent, intersectAllowLists, invokeWithTransientRetry, isControlFlowSignal, isReplayIntegrityError, observeTurnFrames, publishAgentToolRetry, stampToolKinds, toolCallContext, traceLlmTurn, traceToolExecution, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, wrapToolPreflightDenied, wrapToolStepOutput } from "@dudousxd/nestjs-agent-core";
37
39
  import { Step } from "@dudousxd/nestjs-durable";
38
40
  import { Inject, Injectable } from "@nestjs/common";
39
41
 
@@ -107,6 +109,9 @@ var AgentRunSteps = class {
107
109
  ...input.threadId !== void 0 ? {
108
110
  threadId: input.threadId
109
111
  } : {},
112
+ ...input.preflightContext?.uiCapabilities !== void 0 ? {
113
+ uiCapabilities: input.preflightContext.uiCapabilities
114
+ } : {},
110
115
  ...input.agentName !== void 0 ? {
111
116
  agentName: input.agentName
112
117
  } : {}
@@ -137,6 +142,67 @@ var AgentRunSteps = class {
137
142
  } : {}
138
143
  })), frames.summary());
139
144
  const stamped = stampToolKinds(turn, deps);
145
+ const allowedTools = intersectAllowLists(deps.toolAllowList, input.personaAllowedTools);
146
+ for (const call of stamped.toolCalls) {
147
+ if (call.kind !== "action") continue;
148
+ try {
149
+ const context = input.preflightContext ?? {
150
+ actor: input.actor,
151
+ threadId: input.threadId ?? "",
152
+ runId: input.runId,
153
+ requestId: input.runId,
154
+ ...input.agentName !== void 0 ? {
155
+ agentName: input.agentName
156
+ } : {}
157
+ };
158
+ if (input.actionApprovalMode === "independent") {
159
+ const spec = deps.registry.spec(call.name);
160
+ call.actionApproval = await resolveActionProposalApproval({
161
+ actor: input.actor,
162
+ store: deps.store,
163
+ tool: {
164
+ name: call.name,
165
+ kind: "action",
166
+ ...spec !== void 0 ? {
167
+ spec
168
+ } : {}
169
+ },
170
+ thread: {
171
+ threadId: context.threadId,
172
+ runId: input.runId,
173
+ ...input.agentName !== void 0 ? {
174
+ agentName: input.agentName
175
+ } : {}
176
+ },
177
+ ...deps.approvalPolicy !== void 0 ? {
178
+ policy: deps.approvalPolicy
179
+ } : {}
180
+ });
181
+ }
182
+ if (call.actionApproval?.mode === "ask") {
183
+ call.prepared = await prepareActionProposal(deps.registry, call.name, call.input, {
184
+ ...toolCallContext(context, call.id),
185
+ emitUi: createNoopEmitUi(call.id)
186
+ }, deps.rolesPolicy, allowedTools === void 0 ? {} : {
187
+ allowedTools
188
+ });
189
+ call.preflight = call.prepared.preflight;
190
+ } else {
191
+ call.preflight = await deps.registry.prepare(call.name, call.input, {
192
+ ...toolCallContext(context, call.id),
193
+ emitUi: createNoopEmitUi(call.id)
194
+ }, deps.rolesPolicy, allowedTools === void 0 ? {} : {
195
+ allowedTools
196
+ });
197
+ }
198
+ } catch (error) {
199
+ if (isControlFlowSignal(error) || isReplayIntegrityError(error)) throw error;
200
+ call.preflight = {
201
+ status: "failed",
202
+ error: error instanceof Error ? error.message : String(error)
203
+ };
204
+ }
205
+ }
140
206
  return buffer === void 0 ? stamped : {
141
207
  ...stamped,
142
208
  bufferedFrames: buffer.frames()
@@ -162,7 +228,7 @@ var AgentRunSteps = class {
162
228
  }
163
229
  const sinkRunId = input.sinkRunId;
164
230
  let opened;
165
- const ui = createUiCollector(input.toolCallId, sinkRunId === void 0 ? void 0 : async (event) => {
231
+ const ui = createNegotiatedUiCollector(input.toolCallId, input.ctx, deps.resolveUiCatalog, sinkRunId === void 0 ? void 0 : async (event) => {
166
232
  opened ??= Promise.resolve(deps.sink.open(sinkRunId)).then((writer) => input.childSink === true ? childSinkWriter(writer) : writer);
167
233
  await (await opened).write(encodeStreamEvent(event));
168
234
  });
@@ -178,27 +244,38 @@ var AgentRunSteps = class {
178
244
  classify: localClassify
179
245
  } : {}
180
246
  };
181
- const output = await traceToolExecution(input.ctx.runId, {
182
- toolCallId: input.toolCallId,
183
- toolName: input.toolName,
184
- toolType: input.toolType
185
- }, () => invokeWithTransientRetry(() => {
186
- ui.restart();
187
- const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy, input.allowedTools !== void 0 ? {
188
- allowedTools: input.allowedTools
189
- } : {});
190
- return input.timeoutMs !== void 0 ? withToolTimeout(invocation, input.timeoutMs, input.toolName) : invocation;
191
- }, transientRetry, {
192
- onRetry: /* @__PURE__ */ __name((attempt, error) => {
193
- publishAgentToolRetry({
194
- toolName: input.toolName,
195
- toolCallId: input.toolCallId,
196
- attempt,
197
- message: error instanceof Error ? error.message : String(error)
247
+ const allowedTools = intersectAllowLists(deps.toolAllowList, input.allowedTools === void 0 ? void 0 : [
248
+ ...input.allowedTools
249
+ ]);
250
+ let output;
251
+ try {
252
+ output = await traceToolExecution(input.ctx.runId, {
253
+ toolCallId: input.toolCallId,
254
+ toolName: input.toolName,
255
+ toolType: input.toolType
256
+ }, () => invokeWithTransientRetry(() => {
257
+ ui.restart();
258
+ const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy, allowedTools === void 0 ? {} : {
259
+ allowedTools
198
260
  });
199
- }, "onRetry")
200
- }));
201
- return input.collectUi === true ? wrapToolStepOutput(output, ui.components()) : output;
261
+ return input.timeoutMs !== void 0 ? withToolTimeout(invocation, input.timeoutMs, input.toolName) : invocation;
262
+ }, transientRetry, {
263
+ onRetry: /* @__PURE__ */ __name((attempt, error) => {
264
+ publishAgentToolRetry({
265
+ toolName: input.toolName,
266
+ toolCallId: input.toolCallId,
267
+ attempt,
268
+ message: error instanceof Error ? error.message : String(error)
269
+ });
270
+ }, "onRetry")
271
+ }));
272
+ } catch (error) {
273
+ if (error instanceof Error && error.name === "ToolPreflightDeniedError") {
274
+ return wrapToolPreflightDenied(error.message);
275
+ }
276
+ throw error;
277
+ }
278
+ return input.collectUi === true ? wrapToolStepOutput(output, ui.components(), ui.text()) : output;
202
279
  }
203
280
  };
204
281
  _ts_decorate([
@@ -598,7 +675,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
598
675
  });
599
676
  throw error;
600
677
  }
601
- if (isReplayIntegrityError(error)) {
678
+ if (isReplayIntegrityError2(error)) {
602
679
  const detail = error.message;
603
680
  const code2 = agentFailureCode(error);
604
681
  this.logger.error(`agent run ${ctx.runId} failed (${code2}): ${detail}`);
@@ -1094,14 +1171,44 @@ AgentDurableModule = _ts_decorate4([
1094
1171
  ], AgentDurableModule);
1095
1172
 
1096
1173
  // src/agent.module.ts
1097
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY8, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, 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_SINK4, 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";
1098
- import { Global as Global2, Logger as Logger8, Module as Module2 } from "@nestjs/common";
1174
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY9, AGENT_DURABLE_RUNNER as AGENT_DURABLE_RUNNER2, 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_SINK4, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE9, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
1175
+ import { Global as Global2, Logger as Logger9, Module as Module3 } from "@nestjs/common";
1099
1176
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
1100
1177
 
1101
1178
  // src/agent-deps.factory.ts
1179
+ import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
1102
1180
  import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK as AGENT_SINK2, AGENT_SKILLS, AGENT_STORE as AGENT_STORE3, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, findPersona, intersectAllowLists as intersectAllowLists2, normalizeDelegation, personaCatalogEntry, resolvePersonaAlias, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
1103
1181
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
1104
- import { BadRequestException, Inject as Inject4, Injectable as Injectable4, Optional as Optional3 } from "@nestjs/common";
1182
+ import { BadRequestException, Inject as Inject5, Injectable as Injectable4, Optional as Optional3 } from "@nestjs/common";
1183
+
1184
+ // src/genui/agent-genui.module.ts
1185
+ import { defineCatalog, genuiTools } from "@dudousxd/nestjs-agent-core/genui";
1186
+ import { Inject as Inject4, Module as Module2 } from "@nestjs/common";
1187
+
1188
+ // src/functional-tool.ts
1189
+ var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
1190
+ function brand(tool) {
1191
+ return {
1192
+ [AGENT_TOOL_BRAND]: true,
1193
+ spec: tool.spec,
1194
+ handler: tool.handler
1195
+ };
1196
+ }
1197
+ __name(brand, "brand");
1198
+ function isBrandedFunctionalTool(value) {
1199
+ return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
1200
+ }
1201
+ __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
1202
+ function provideAgentTools(factory, inject) {
1203
+ return {
1204
+ provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
1205
+ useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
1206
+ inject: inject ?? []
1207
+ };
1208
+ }
1209
+ __name(provideAgentTools, "provideAgentTools");
1210
+
1211
+ // src/genui/agent-genui.module.ts
1105
1212
  function _ts_decorate5(decorators, target, key, desc) {
1106
1213
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1107
1214
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1116,6 +1223,124 @@ function _ts_decorate5(decorators, target, key, desc) {
1116
1223
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1117
1224
  }
1118
1225
  __name(_ts_decorate5, "_ts_decorate");
1226
+ var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
1227
+ var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
1228
+ var GenuiCatalogResolver = class {
1229
+ static {
1230
+ __name(this, "GenuiCatalogResolver");
1231
+ }
1232
+ };
1233
+ function resolverProviders(resolver) {
1234
+ if (resolver === void 0) return [];
1235
+ return [
1236
+ typeof resolver === "function" ? {
1237
+ provide: GenuiCatalogResolver,
1238
+ useClass: resolver
1239
+ } : {
1240
+ provide: GenuiCatalogResolver,
1241
+ useValue: resolver
1242
+ }
1243
+ ];
1244
+ }
1245
+ __name(resolverProviders, "resolverProviders");
1246
+ function toolOptions(options, resolver) {
1247
+ const { catalog: _catalog, ...rest } = options;
1248
+ return {
1249
+ ...rest,
1250
+ ...resolver !== void 0 ? {
1251
+ resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
1252
+ } : {}
1253
+ };
1254
+ }
1255
+ __name(toolOptions, "toolOptions");
1256
+ function coreProviders(resolver) {
1257
+ return [
1258
+ {
1259
+ provide: GENUI_CATALOG,
1260
+ useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? defineCatalog([]), "useFactory"),
1261
+ inject: [
1262
+ GENUI_OPTIONS
1263
+ ]
1264
+ },
1265
+ ...resolverProviders(resolver),
1266
+ // The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
1267
+ // Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
1268
+ provideAgentTools((options, catalog, perRequest) => genuiTools(catalog, toolOptions(options, perRequest)), [
1269
+ GENUI_OPTIONS,
1270
+ GENUI_CATALOG,
1271
+ {
1272
+ token: GenuiCatalogResolver,
1273
+ optional: true
1274
+ }
1275
+ ])
1276
+ ];
1277
+ }
1278
+ __name(coreProviders, "coreProviders");
1279
+ var EXPORTS = [
1280
+ GENUI_CATALOG,
1281
+ GENUI_OPTIONS
1282
+ ];
1283
+ var AgentGenuiModule = class _AgentGenuiModule {
1284
+ static {
1285
+ __name(this, "AgentGenuiModule");
1286
+ }
1287
+ static forRoot(options = {}) {
1288
+ const { resolver, ...rest } = options;
1289
+ return {
1290
+ module: _AgentGenuiModule,
1291
+ global: true,
1292
+ providers: [
1293
+ {
1294
+ provide: GENUI_OPTIONS,
1295
+ useValue: rest
1296
+ },
1297
+ ...coreProviders(resolver)
1298
+ ],
1299
+ exports: resolver === void 0 ? EXPORTS : [
1300
+ ...EXPORTS,
1301
+ GenuiCatalogResolver
1302
+ ]
1303
+ };
1304
+ }
1305
+ static forRootAsync(options) {
1306
+ return {
1307
+ module: _AgentGenuiModule,
1308
+ global: true,
1309
+ imports: options.imports ?? [],
1310
+ providers: [
1311
+ {
1312
+ provide: GENUI_OPTIONS,
1313
+ useFactory: options.useFactory,
1314
+ inject: options.inject ?? []
1315
+ },
1316
+ ...coreProviders(options.resolver)
1317
+ ],
1318
+ exports: options.resolver === void 0 ? EXPORTS : [
1319
+ ...EXPORTS,
1320
+ GenuiCatalogResolver
1321
+ ]
1322
+ };
1323
+ }
1324
+ };
1325
+ AgentGenuiModule = _ts_decorate5([
1326
+ Module2({})
1327
+ ], AgentGenuiModule);
1328
+
1329
+ // src/agent-deps.factory.ts
1330
+ function _ts_decorate6(decorators, target, key, desc) {
1331
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1332
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1333
+ r = Reflect.decorate(decorators, target, key, desc);
1334
+ } else {
1335
+ for (var i = decorators.length - 1; i >= 0; i--) {
1336
+ if (d = decorators[i]) {
1337
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1338
+ }
1339
+ }
1340
+ }
1341
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1342
+ }
1343
+ __name(_ts_decorate6, "_ts_decorate");
1119
1344
  function _ts_metadata4(metadataKey, metadataValue) {
1120
1345
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1121
1346
  return Reflect.metadata(metadataKey, metadataValue);
@@ -1148,7 +1373,9 @@ var AgentDepsFactory2 = class {
1148
1373
  pricingStore;
1149
1374
  skills;
1150
1375
  memory;
1151
- constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory) {
1376
+ uiCatalog;
1377
+ uiCatalogResolver;
1378
+ constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
1152
1379
  this.options = options;
1153
1380
  this.model = model;
1154
1381
  this.store = store;
@@ -1160,6 +1387,9 @@ var AgentDepsFactory2 = class {
1160
1387
  this.pricingStore = pricingStore;
1161
1388
  this.skills = skills;
1162
1389
  this.memory = memory;
1390
+ this.uiCatalog = uiCatalog;
1391
+ this.uiCatalogResolver = uiCatalogResolver;
1392
+ if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
1163
1393
  }
1164
1394
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
1165
1395
  memoryConfig() {
@@ -1248,6 +1478,18 @@ var AgentDepsFactory2 = class {
1248
1478
  }
1249
1479
  return definition?.defaultPersona;
1250
1480
  }
1481
+ forProposal(proposal, _actor) {
1482
+ const name = proposal.executionContext?.agentName;
1483
+ 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`);
1484
+ const deps = this.forAgent(name);
1485
+ const id = proposal.executionContext?.persona;
1486
+ if (id !== void 0) {
1487
+ const persona = deps.personas?.find((persona2) => persona2.id === id);
1488
+ if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
1489
+ return this.withPersona(deps, persona);
1490
+ }
1491
+ return deps;
1492
+ }
1251
1493
  forAgent(agentName) {
1252
1494
  const name = agentName ?? this.defaultAgentName();
1253
1495
  if (agentName !== void 0 && !this.agents.has(agentName)) {
@@ -1266,12 +1508,27 @@ var AgentDepsFactory2 = class {
1266
1508
  return {
1267
1509
  model: this.model,
1268
1510
  store: this.store,
1511
+ ...this.options.actionApprovalMode !== void 0 ? {
1512
+ actionApprovalMode: this.options.actionApprovalMode
1513
+ } : {},
1269
1514
  sink: this.sink,
1270
1515
  rolesPolicy: this.rolesPolicy,
1271
1516
  ...this.options.approvalPolicy !== void 0 ? {
1272
1517
  approvalPolicy: this.options.approvalPolicy
1273
1518
  } : {},
1274
1519
  registry: this.registry,
1520
+ ...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
1521
+ resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
1522
+ const catalog = this.uiCatalogResolver?.resolve({
1523
+ ...scope,
1524
+ ...scope.actor.tenantRef !== void 0 ? {
1525
+ tenant: scope.actor.tenantRef
1526
+ } : {}
1527
+ }) ?? this.uiCatalog;
1528
+ if (!catalog) throw new Error("UI catalog unavailable");
1529
+ return catalog;
1530
+ }, "resolveUiCatalog")
1531
+ } : {},
1275
1532
  promptContributors: this.promptContributors,
1276
1533
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
1277
1534
  maxSteps: definition?.maxSteps ?? 8,
@@ -1422,22 +1679,25 @@ var AgentDepsFactory2 = class {
1422
1679
  return void 0;
1423
1680
  }
1424
1681
  };
1425
- AgentDepsFactory2 = _ts_decorate5([
1682
+ AgentDepsFactory2 = _ts_decorate6([
1426
1683
  Injectable4(),
1427
- _ts_param4(0, Inject4(AGENT_OPTIONS)),
1428
- _ts_param4(1, Inject4(AGENT_MODEL)),
1429
- _ts_param4(2, Inject4(AGENT_STORE3)),
1430
- _ts_param4(3, Inject4(AGENT_SINK2)),
1431
- _ts_param4(4, Inject4(AGENT_ROLES_POLICY)),
1432
- _ts_param4(5, Inject4(AGENT_TOOL_REGISTRY)),
1433
- _ts_param4(6, Inject4(AGENT_REGISTRY)),
1434
- _ts_param4(7, Inject4(AGENT_PROMPT_CONTRIBUTORS)),
1684
+ _ts_param4(0, Inject5(AGENT_OPTIONS)),
1685
+ _ts_param4(1, Inject5(AGENT_MODEL)),
1686
+ _ts_param4(2, Inject5(AGENT_STORE3)),
1687
+ _ts_param4(3, Inject5(AGENT_SINK2)),
1688
+ _ts_param4(4, Inject5(AGENT_ROLES_POLICY)),
1689
+ _ts_param4(5, Inject5(AGENT_TOOL_REGISTRY)),
1690
+ _ts_param4(6, Inject5(AGENT_REGISTRY)),
1691
+ _ts_param4(7, Inject5(AGENT_PROMPT_CONTRIBUTORS)),
1435
1692
  _ts_param4(8, Optional3()),
1436
- _ts_param4(8, Inject4(AGENT_PRICING_STORE)),
1693
+ _ts_param4(8, Inject5(AGENT_PRICING_STORE)),
1437
1694
  _ts_param4(9, Optional3()),
1438
- _ts_param4(9, Inject4(AGENT_SKILLS)),
1695
+ _ts_param4(9, Inject5(AGENT_SKILLS)),
1439
1696
  _ts_param4(10, Optional3()),
1440
- _ts_param4(10, Inject4(AGENT_MEMORY)),
1697
+ _ts_param4(10, Inject5(AGENT_MEMORY)),
1698
+ _ts_param4(11, Optional3()),
1699
+ _ts_param4(11, Inject5(GENUI_CATALOG)),
1700
+ _ts_param4(12, Optional3()),
1441
1701
  _ts_metadata4("design:type", Function),
1442
1702
  _ts_metadata4("design:paramtypes", [
1443
1703
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -1450,17 +1710,169 @@ AgentDepsFactory2 = _ts_decorate5([
1450
1710
  Array,
1451
1711
  Object,
1452
1712
  Object,
1453
- Object
1713
+ Object,
1714
+ typeof Catalog === "undefined" ? Object : Catalog,
1715
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
1454
1716
  ])
1455
1717
  ], AgentDepsFactory2);
1456
1718
 
1457
1719
  // src/agent.service.ts
1458
- import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE5, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval, readElicitationQuestions, settleDeadRun as settleDeadRun2, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
1459
- import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as Inject6, Injectable as Injectable6, NotFoundException, NotImplementedException as NotImplementedException2, Optional as Optional5 } from "@nestjs/common";
1720
+ import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE6, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval as mayDecideApproval2, readElicitationQuestions, settleDeadRun as settleDeadRun2, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
1721
+ import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException as ForbiddenException2, GoneException, HttpException, HttpStatus, Inject as Inject8, Injectable as Injectable7, NotFoundException as NotFoundException2, NotImplementedException as NotImplementedException3, Optional as Optional5 } from "@nestjs/common";
1722
+
1723
+ // src/proposals/action-proposal.service.ts
1724
+ import { AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_STORE as AGENT_STORE4, mayDecideApproval, parseTextActionProposalCommand, resolveTextActionProposalDecision } from "@dudousxd/nestjs-agent-core";
1725
+ import { ForbiddenException, Inject as Inject6, Injectable as Injectable5, NotFoundException, NotImplementedException } from "@nestjs/common";
1726
+ function _ts_decorate7(decorators, target, key, desc) {
1727
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1728
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1729
+ r = Reflect.decorate(decorators, target, key, desc);
1730
+ } else {
1731
+ for (var i = decorators.length - 1; i >= 0; i--) {
1732
+ if (d = decorators[i]) {
1733
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1734
+ }
1735
+ }
1736
+ }
1737
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1738
+ }
1739
+ __name(_ts_decorate7, "_ts_decorate");
1740
+ function _ts_metadata5(metadataKey, metadataValue) {
1741
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1742
+ return Reflect.metadata(metadataKey, metadataValue);
1743
+ }
1744
+ }
1745
+ __name(_ts_metadata5, "_ts_metadata");
1746
+ function _ts_param5(paramIndex, decorator) {
1747
+ return function(target, key) {
1748
+ decorator(target, key, paramIndex);
1749
+ };
1750
+ }
1751
+ __name(_ts_param5, "_ts_param");
1752
+ var ActionProposalService = class {
1753
+ static {
1754
+ __name(this, "ActionProposalService");
1755
+ }
1756
+ store;
1757
+ options;
1758
+ constructor(store, options) {
1759
+ this.store = store;
1760
+ this.options = options;
1761
+ }
1762
+ capability() {
1763
+ const store = this.store;
1764
+ if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new NotImplementedException("Action proposals are unavailable");
1765
+ return store;
1766
+ }
1767
+ async scope(threadId, actor) {
1768
+ const scope = await this.capability().getThreadActionProposalScope(threadId);
1769
+ if (!scope) throw new NotFoundException("Thread not found");
1770
+ if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new ForbiddenException("Wrong proposal tenant");
1771
+ return scope;
1772
+ }
1773
+ mayDecide(actor, proposal) {
1774
+ return mayDecideApproval(this.options.approvalPolicy, actor, {
1775
+ toolCallId: proposal.originToolCallId,
1776
+ approver: proposal.approver,
1777
+ requesterRef: proposal.actorRef
1778
+ });
1779
+ }
1780
+ async listPage(threadId, actor, query = {}) {
1781
+ const scope = await this.scope(threadId, actor);
1782
+ const rows = await this.capability().listActionProposals(scope, {
1783
+ limit: 1e3,
1784
+ ...query
1785
+ });
1786
+ const visible = [];
1787
+ for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
1788
+ const last = rows.at(-1);
1789
+ return {
1790
+ items: visible,
1791
+ ...rows.length === 1e3 && last ? {
1792
+ next: {
1793
+ createdAt: last.createdAt,
1794
+ id: last.id
1795
+ }
1796
+ } : {}
1797
+ };
1798
+ }
1799
+ async list(threadId, actor) {
1800
+ return (await this.listPage(threadId, actor)).items;
1801
+ }
1802
+ async decide(threadId, proposalId, actor, command) {
1803
+ const scope = await this.scope(threadId, actor);
1804
+ const proposal = await this.capability().getActionProposal(scope, proposalId);
1805
+ if (!proposal) throw new NotFoundException("Proposal not found");
1806
+ if (!await this.mayDecide(actor, proposal)) throw new ForbiddenException("May not decide this proposal");
1807
+ return this.capability().decideActionProposal(scope, proposalId, {
1808
+ decision: command.decision,
1809
+ actorRef: actor.id,
1810
+ via: command.via ?? "web",
1811
+ ...command.remember !== void 0 ? {
1812
+ remember: command.remember
1813
+ } : {},
1814
+ ...command.reason !== void 0 ? {
1815
+ reason: command.reason
1816
+ } : {}
1817
+ });
1818
+ }
1819
+ async handleTextDecision(threadId, actor, text) {
1820
+ const command = parseTextActionProposalCommand(text);
1821
+ if (command.status === "unmatched") return command;
1822
+ if (command.proposalId !== void 0) {
1823
+ const result2 = await this.decide(threadId, command.proposalId, actor, {
1824
+ decision: command.decision,
1825
+ remember: command.remember,
1826
+ via: "text"
1827
+ });
1828
+ return this.textReceipt(threadId, result2);
1829
+ }
1830
+ const candidates = [];
1831
+ const scope = await this.scope(threadId, actor);
1832
+ const pending = await this.capability().listActionProposals(scope, {
1833
+ decision: "pending",
1834
+ limit: 1e3
1835
+ });
1836
+ for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
1837
+ const resolution = resolveTextActionProposalDecision(text, candidates);
1838
+ if (resolution.status === "unmatched") return resolution;
1839
+ if (resolution.status === "ambiguous" || resolution.status === "decision" && pending.length === 1e3 && !text.includes("#")) return {
1840
+ threadId,
1841
+ proposalDecision: {
1842
+ status: "ambiguous",
1843
+ proposalIds: candidates.map(({ id }) => id)
1844
+ },
1845
+ text: `Choose the action to decide: ${candidates.map(({ id }) => id).map((id) => `#${id}`).join(", ")}`
1846
+ };
1847
+ const result = await this.decide(threadId, resolution.proposalId, actor, {
1848
+ decision: resolution.decision,
1849
+ remember: resolution.remember,
1850
+ via: "text"
1851
+ });
1852
+ return this.textReceipt(threadId, result);
1853
+ }
1854
+ textReceipt(threadId, result) {
1855
+ return {
1856
+ threadId,
1857
+ proposalDecision: result,
1858
+ text: result.proposal?.decision === "approved" ? "Action approved and queued for execution." : `Action ${result.proposal?.decision ?? result.status}; no execution was performed by this decision.`
1859
+ };
1860
+ }
1861
+ };
1862
+ ActionProposalService = _ts_decorate7([
1863
+ Injectable5(),
1864
+ _ts_param5(0, Inject6(AGENT_STORE4)),
1865
+ _ts_param5(1, Inject6(AGENT_OPTIONS2)),
1866
+ _ts_metadata5("design:type", Function),
1867
+ _ts_metadata5("design:paramtypes", [
1868
+ typeof AgentStore === "undefined" ? Object : AgentStore,
1869
+ typeof Pick === "undefined" ? Object : Pick
1870
+ ])
1871
+ ], ActionProposalService);
1460
1872
 
1461
1873
  // src/queue/chat-queue.service.ts
1462
- import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_QUOTA_PROVIDER, AGENT_SINK as AGENT_SINK3, AGENT_STORE as AGENT_STORE4, encodeStreamEvent as encodeStreamEvent4, isChatQueueStore, queuedMessageView } from "@dudousxd/nestjs-agent-core";
1463
- import { Inject as Inject5, Injectable as Injectable5, Logger as Logger3, NotImplementedException, Optional as Optional4 } from "@nestjs/common";
1874
+ import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER, AGENT_SINK as AGENT_SINK3, AGENT_STORE as AGENT_STORE5, encodeStreamEvent as encodeStreamEvent4, isChatQueueStore, queuedMessageView } from "@dudousxd/nestjs-agent-core";
1875
+ import { Inject as Inject7, Injectable as Injectable6, Logger as Logger3, NotImplementedException as NotImplementedException2, Optional as Optional4 } from "@nestjs/common";
1464
1876
 
1465
1877
  // src/thread-persona.ts
1466
1878
  async function threadPersona(store, threadId) {
@@ -1473,7 +1885,7 @@ async function threadPersona(store, threadId) {
1473
1885
  __name(threadPersona, "threadPersona");
1474
1886
 
1475
1887
  // src/queue/chat-queue.service.ts
1476
- function _ts_decorate6(decorators, target, key, desc) {
1888
+ function _ts_decorate8(decorators, target, key, desc) {
1477
1889
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1478
1890
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1479
1891
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1486,19 +1898,19 @@ function _ts_decorate6(decorators, target, key, desc) {
1486
1898
  }
1487
1899
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1488
1900
  }
1489
- __name(_ts_decorate6, "_ts_decorate");
1490
- function _ts_metadata5(metadataKey, metadataValue) {
1901
+ __name(_ts_decorate8, "_ts_decorate");
1902
+ function _ts_metadata6(metadataKey, metadataValue) {
1491
1903
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1492
1904
  return Reflect.metadata(metadataKey, metadataValue);
1493
1905
  }
1494
1906
  }
1495
- __name(_ts_metadata5, "_ts_metadata");
1496
- function _ts_param5(paramIndex, decorator) {
1907
+ __name(_ts_metadata6, "_ts_metadata");
1908
+ function _ts_param6(paramIndex, decorator) {
1497
1909
  return function(target, key) {
1498
1910
  decorator(target, key, paramIndex);
1499
1911
  };
1500
1912
  }
1501
- __name(_ts_param5, "_ts_param");
1913
+ __name(_ts_param6, "_ts_param");
1502
1914
  var MAX_DRAIN_ATTEMPTS = 8;
1503
1915
  var ChatQueueService2 = class _ChatQueueService {
1504
1916
  static {
@@ -1531,7 +1943,7 @@ var ChatQueueService2 = class _ChatQueueService {
1531
1943
  /** The bound store as a queue store, or a 501 naming what is missing. */
1532
1944
  queueStore() {
1533
1945
  if (!isChatQueueStore(this.store)) {
1534
- throw new NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
1946
+ throw new NotImplementedException2("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
1535
1947
  }
1536
1948
  return this.store;
1537
1949
  }
@@ -1758,6 +2170,9 @@ var ChatQueueService2 = class _ChatQueueService {
1758
2170
  } : {},
1759
2171
  ...input.pageContext !== void 0 ? {
1760
2172
  pageContext: input.pageContext
2173
+ } : {},
2174
+ ...input.uiCapabilities !== void 0 ? {
2175
+ uiCapabilities: input.uiCapabilities
1761
2176
  } : {}
1762
2177
  });
1763
2178
  await store.setQueuePause(threadId, {
@@ -1838,6 +2253,9 @@ var ChatQueueService2 = class _ChatQueueService {
1838
2253
  ...message.pageContext !== void 0 ? {
1839
2254
  pageContext: message.pageContext
1840
2255
  } : {},
2256
+ ...message.uiCapabilities !== void 0 ? {
2257
+ uiCapabilities: message.uiCapabilities
2258
+ } : {},
1841
2259
  ...message.model !== void 0 ? {
1842
2260
  model: message.model
1843
2261
  } : {}
@@ -1891,20 +2309,20 @@ var ChatQueueService2 = class _ChatQueueService {
1891
2309
  }));
1892
2310
  }
1893
2311
  };
1894
- ChatQueueService2 = _ts_decorate6([
1895
- Injectable5(),
1896
- _ts_param5(0, Inject5(AGENT_STORE4)),
1897
- _ts_param5(1, Inject5(AGENT_SINK3)),
1898
- _ts_param5(2, Optional4()),
1899
- _ts_param5(2, Inject5(AGENT_QUOTA_PROVIDER)),
1900
- _ts_param5(3, Optional4()),
1901
- _ts_param5(3, Inject5(AGENT_OPTIONS2)),
1902
- _ts_param5(4, Optional4()),
1903
- _ts_param5(4, Inject5(AGENT_ATTACHMENT_STAGING)),
1904
- _ts_param5(5, Optional4()),
1905
- _ts_param5(5, Inject5(AGENT_DEPS_FACTORY3)),
1906
- _ts_metadata5("design:type", Function),
1907
- _ts_metadata5("design:paramtypes", [
2312
+ ChatQueueService2 = _ts_decorate8([
2313
+ Injectable6(),
2314
+ _ts_param6(0, Inject7(AGENT_STORE5)),
2315
+ _ts_param6(1, Inject7(AGENT_SINK3)),
2316
+ _ts_param6(2, Optional4()),
2317
+ _ts_param6(2, Inject7(AGENT_QUOTA_PROVIDER)),
2318
+ _ts_param6(3, Optional4()),
2319
+ _ts_param6(3, Inject7(AGENT_OPTIONS3)),
2320
+ _ts_param6(4, Optional4()),
2321
+ _ts_param6(4, Inject7(AGENT_ATTACHMENT_STAGING)),
2322
+ _ts_param6(5, Optional4()),
2323
+ _ts_param6(5, Inject7(AGENT_DEPS_FACTORY3)),
2324
+ _ts_metadata6("design:type", Function),
2325
+ _ts_metadata6("design:paramtypes", [
1908
2326
  typeof AgentStore === "undefined" ? Object : AgentStore,
1909
2327
  typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
1910
2328
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
@@ -1956,7 +2374,7 @@ var RunNotActiveException = class extends ConflictException {
1956
2374
  };
1957
2375
 
1958
2376
  // src/agent.service.ts
1959
- function _ts_decorate7(decorators, target, key, desc) {
2377
+ function _ts_decorate9(decorators, target, key, desc) {
1960
2378
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1961
2379
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1962
2380
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1969,19 +2387,19 @@ function _ts_decorate7(decorators, target, key, desc) {
1969
2387
  }
1970
2388
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1971
2389
  }
1972
- __name(_ts_decorate7, "_ts_decorate");
1973
- function _ts_metadata6(metadataKey, metadataValue) {
2390
+ __name(_ts_decorate9, "_ts_decorate");
2391
+ function _ts_metadata7(metadataKey, metadataValue) {
1974
2392
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1975
2393
  return Reflect.metadata(metadataKey, metadataValue);
1976
2394
  }
1977
2395
  }
1978
- __name(_ts_metadata6, "_ts_metadata");
1979
- function _ts_param6(paramIndex, decorator) {
2396
+ __name(_ts_metadata7, "_ts_metadata");
2397
+ function _ts_param7(paramIndex, decorator) {
1980
2398
  return function(target, key) {
1981
2399
  decorator(target, key, paramIndex);
1982
2400
  };
1983
2401
  }
1984
- __name(_ts_param6, "_ts_param");
2402
+ __name(_ts_param7, "_ts_param");
1985
2403
  var AgentService = class {
1986
2404
  static {
1987
2405
  __name(this, "AgentService");
@@ -1994,7 +2412,8 @@ var AgentService = class {
1994
2412
  quotaProvider;
1995
2413
  options;
1996
2414
  queue;
1997
- constructor(runner, store, deps, staging, models, quotaProvider, options, queue) {
2415
+ proposals;
2416
+ constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
1998
2417
  this.runner = runner;
1999
2418
  this.store = store;
2000
2419
  this.deps = deps;
@@ -2003,6 +2422,13 @@ var AgentService = class {
2003
2422
  this.quotaProvider = quotaProvider;
2004
2423
  this.options = options;
2005
2424
  this.queue = queue;
2425
+ this.proposals = proposals;
2426
+ }
2427
+ async handleTextDecision(threadId, actor, text) {
2428
+ if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
2429
+ status: "unmatched"
2430
+ };
2431
+ return this.proposals.handleTextDecision(threadId, actor, text);
2006
2432
  }
2007
2433
  /** The queue service when the bound store can hold a queue, else `undefined`. */
2008
2434
  queueing() {
@@ -2012,7 +2438,7 @@ var AgentService = class {
2012
2438
  requireQueue() {
2013
2439
  const queue = this.queueing();
2014
2440
  if (queue === void 0) {
2015
- throw new NotImplementedException2("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
2441
+ throw new NotImplementedException3("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
2016
2442
  }
2017
2443
  return queue;
2018
2444
  }
@@ -2134,7 +2560,10 @@ var AgentService = class {
2134
2560
  const result = await this.send({
2135
2561
  ...params,
2136
2562
  mode: "auto"
2563
+ }, {
2564
+ textDecisions: false
2137
2565
  });
2566
+ if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
2138
2567
  if (result.queued !== true) {
2139
2568
  return result;
2140
2569
  }
@@ -2162,7 +2591,11 @@ var AgentService = class {
2162
2591
  * Send a message: start a turn, or — when its thread already has one running — queue the message
2163
2592
  * to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
2164
2593
  */
2165
- async send(params) {
2594
+ async send(params, sendOptions = {}) {
2595
+ if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
2596
+ const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
2597
+ if ("proposalDecision" in decision) return decision;
2598
+ }
2166
2599
  await this.assertWithinQuota(params.actor);
2167
2600
  const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
2168
2601
  const agentName = target.agentName;
@@ -2211,12 +2644,16 @@ var AgentService = class {
2211
2644
  ...params.pageContext !== void 0 ? {
2212
2645
  pageContext: params.pageContext
2213
2646
  } : {},
2647
+ ...params.uiCapabilities !== void 0 ? {
2648
+ uiCapabilities: params.uiCapabilities
2649
+ } : {},
2214
2650
  ...model !== void 0 ? {
2215
2651
  model
2216
2652
  } : {}
2217
2653
  };
2218
2654
  const queue = this.queueing();
2219
2655
  if (queue === void 0) {
2656
+ if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
2220
2657
  const { runId } = await this.runner.start(input);
2221
2658
  await this.store.setActiveStream(threadId, runId);
2222
2659
  return {
@@ -2297,6 +2734,9 @@ var AgentService = class {
2297
2734
  ...input.pageContext !== void 0 ? {
2298
2735
  pageContext: input.pageContext
2299
2736
  } : {},
2737
+ ...input.uiCapabilities !== void 0 ? {
2738
+ uiCapabilities: input.uiCapabilities
2739
+ } : {},
2300
2740
  ...interrupting !== void 0 ? {
2301
2741
  interrupt: true,
2302
2742
  at: "head"
@@ -2401,7 +2841,7 @@ var AgentService = class {
2401
2841
  throw gone();
2402
2842
  }
2403
2843
  if (marked.interrupt !== true) {
2404
- throw new NotImplementedException2("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
2844
+ throw new NotImplementedException3("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
2405
2845
  }
2406
2846
  if (!await store.moveQueuedMessage(messageId, 0)) {
2407
2847
  throw gone();
@@ -2460,7 +2900,7 @@ var AgentService = class {
2460
2900
  async assertOwnsQueuedMessage(actor, messageId) {
2461
2901
  const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
2462
2902
  if (message === null) {
2463
- throw new NotFoundException(`queued message ${messageId} not found`);
2903
+ throw new NotFoundException2(`queued message ${messageId} not found`);
2464
2904
  }
2465
2905
  await this.assertOwnsThread(actor, message.threadId);
2466
2906
  return message.threadId;
@@ -2481,7 +2921,7 @@ var AgentService = class {
2481
2921
  }
2482
2922
  const staging = this.staging;
2483
2923
  if (staging === void 0 || typeof staging.resolve !== "function") {
2484
- throw new NotImplementedException2("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
2924
+ throw new NotImplementedException3("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
2485
2925
  }
2486
2926
  const resolved = [];
2487
2927
  for (const ref of refs) {
@@ -2490,7 +2930,7 @@ var AgentService = class {
2490
2930
  actor
2491
2931
  });
2492
2932
  if (attachment === null) {
2493
- throw new ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
2933
+ throw new ForbiddenException2(`attachment ${ref.mediaId} is not available to this actor`);
2494
2934
  }
2495
2935
  resolved.push(attachment);
2496
2936
  }
@@ -2592,6 +3032,7 @@ var AgentService = class {
2592
3032
  * not the thread's own actor).
2593
3033
  */
2594
3034
  async signalToolCall(toolCallId2, reply) {
3035
+ if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new ConflictException2("Independent proposals require the scoped proposal decision route");
2595
3036
  await this.assertNotExpired(toolCallId2);
2596
3037
  const runId = await this.resolveRunForToolCall(toolCallId2);
2597
3038
  await this.assertRunWaiting(runId);
@@ -2632,7 +3073,7 @@ var AgentService = class {
2632
3073
  throw new RunNotActiveException(runId);
2633
3074
  }
2634
3075
  if (owner !== actor.id) {
2635
- throw new ForbiddenException("run belongs to another actor");
3076
+ throw new ForbiddenException2("run belongs to another actor");
2636
3077
  }
2637
3078
  }
2638
3079
  /**
@@ -2692,7 +3133,7 @@ var AgentService = class {
2692
3133
  return;
2693
3134
  }
2694
3135
  if (this.store.updateThread === void 0) {
2695
- throw new NotImplementedException2("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
3136
+ throw new NotImplementedException3("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
2696
3137
  }
2697
3138
  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);
2698
3139
  if (patch.persona !== void 0 && patch.persona !== null) {
@@ -2863,11 +3304,11 @@ var AgentService = class {
2863
3304
  throw new BadRequestException2("comment must be at most 2000 characters");
2864
3305
  }
2865
3306
  if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
2866
- throw new NotImplementedException2("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
3307
+ throw new NotImplementedException3("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
2867
3308
  }
2868
3309
  const threadId = await this.store.threadOfMessage(messageId);
2869
3310
  if (threadId === null) {
2870
- throw new NotFoundException(`message ${messageId} not found`);
3311
+ throw new NotFoundException2(`message ${messageId} not found`);
2871
3312
  }
2872
3313
  await this.assertOwnsThread(actor, threadId);
2873
3314
  const feedback = input.value === null ? null : {
@@ -2915,7 +3356,7 @@ var AgentService = class {
2915
3356
  const list = this.attachmentInventory();
2916
3357
  const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
2917
3358
  if (referencedMediaIds === void 0) {
2918
- 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.");
3359
+ 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.");
2919
3360
  }
2920
3361
  const stagedBefore = options.olderThan.toISOString();
2921
3362
  const inventory = await list({
@@ -2937,7 +3378,7 @@ var AgentService = class {
2937
3378
  attachmentInventory() {
2938
3379
  const list = this.staging?.list?.bind(this.staging);
2939
3380
  if (list === void 0) {
2940
- 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.");
3381
+ 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.");
2941
3382
  }
2942
3383
  return list;
2943
3384
  }
@@ -2948,10 +3389,10 @@ var AgentService = class {
2948
3389
  async assertOwnsThread(actor, threadId) {
2949
3390
  const owner = await this.store.ownerOfThread(threadId);
2950
3391
  if (owner === null) {
2951
- throw new NotFoundException(`thread ${threadId} not found`);
3392
+ throw new NotFoundException2(`thread ${threadId} not found`);
2952
3393
  }
2953
3394
  if (owner !== actor.id) {
2954
- throw new ForbiddenException("thread belongs to another actor");
3395
+ throw new ForbiddenException2("thread belongs to another actor");
2955
3396
  }
2956
3397
  }
2957
3398
  /**
@@ -2962,10 +3403,10 @@ var AgentService = class {
2962
3403
  async assertOwnsToolCall(actor, toolCallId2) {
2963
3404
  const owner = await this.store.ownerOfToolCall(toolCallId2);
2964
3405
  if (owner === null) {
2965
- throw new NotFoundException(`tool call ${toolCallId2} not found`);
3406
+ throw new NotFoundException2(`tool call ${toolCallId2} not found`);
2966
3407
  }
2967
3408
  if (owner !== actor.id) {
2968
- throw new ForbiddenException("tool call belongs to another actor");
3409
+ throw new ForbiddenException2("tool call belongs to another actor");
2969
3410
  }
2970
3411
  }
2971
3412
  /**
@@ -3003,15 +3444,15 @@ var AgentService = class {
3003
3444
  }
3004
3445
  const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
3005
3446
  if (requesterRef === null) {
3006
- throw new NotFoundException(`tool call ${toolCallId2} not found`);
3447
+ throw new NotFoundException2(`tool call ${toolCallId2} not found`);
3007
3448
  }
3008
- const allowed = await mayDecideApproval(this.deps.forAgent().approvalPolicy, actor, {
3449
+ const allowed = await mayDecideApproval2(this.deps.forAgent().approvalPolicy, actor, {
3009
3450
  toolCallId: toolCallId2,
3010
3451
  approver,
3011
3452
  requesterRef
3012
3453
  });
3013
3454
  if (!allowed) {
3014
- throw new ForbiddenException(`this approval is for ${approver}`);
3455
+ throw new ForbiddenException2(`this approval is for ${approver}`);
3015
3456
  }
3016
3457
  }
3017
3458
  /**
@@ -3040,7 +3481,7 @@ var AgentService = class {
3040
3481
  async resolveRunForToolCall(toolCallId2) {
3041
3482
  const runId = await this.store.runForToolCall(toolCallId2);
3042
3483
  if (runId === null) {
3043
- throw new NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
3484
+ throw new NotFoundException2(`tool call ${toolCallId2} has no active run to signal`);
3044
3485
  }
3045
3486
  return runId;
3046
3487
  }
@@ -3048,29 +3489,30 @@ var AgentService = class {
3048
3489
  async assertOwnsActiveStream(actor, runId) {
3049
3490
  const owner = await this.store.ownerOfActiveStream(runId);
3050
3491
  if (owner === null) {
3051
- throw new NotFoundException(`no active run ${runId}`);
3492
+ throw new NotFoundException2(`no active run ${runId}`);
3052
3493
  }
3053
3494
  if (owner !== actor.id) {
3054
- throw new ForbiddenException("run belongs to another actor");
3495
+ throw new ForbiddenException2("run belongs to another actor");
3055
3496
  }
3056
3497
  }
3057
3498
  };
3058
- AgentService = _ts_decorate7([
3059
- Injectable6(),
3060
- _ts_param6(0, Inject6(AGENT_RUNNER)),
3061
- _ts_param6(1, Inject6(AGENT_STORE5)),
3062
- _ts_param6(2, Inject6(AGENT_DEPS_FACTORY4)),
3063
- _ts_param6(3, Optional5()),
3064
- _ts_param6(3, Inject6(AGENT_ATTACHMENT_STAGING2)),
3065
- _ts_param6(4, Optional5()),
3066
- _ts_param6(4, Inject6(AGENT_MODEL_CATALOG)),
3067
- _ts_param6(5, Optional5()),
3068
- _ts_param6(5, Inject6(AGENT_QUOTA_PROVIDER2)),
3069
- _ts_param6(6, Optional5()),
3070
- _ts_param6(6, Inject6(AGENT_OPTIONS3)),
3071
- _ts_param6(7, Optional5()),
3072
- _ts_metadata6("design:type", Function),
3073
- _ts_metadata6("design:paramtypes", [
3499
+ AgentService = _ts_decorate9([
3500
+ Injectable7(),
3501
+ _ts_param7(0, Inject8(AGENT_RUNNER)),
3502
+ _ts_param7(1, Inject8(AGENT_STORE6)),
3503
+ _ts_param7(2, Inject8(AGENT_DEPS_FACTORY4)),
3504
+ _ts_param7(3, Optional5()),
3505
+ _ts_param7(3, Inject8(AGENT_ATTACHMENT_STAGING2)),
3506
+ _ts_param7(4, Optional5()),
3507
+ _ts_param7(4, Inject8(AGENT_MODEL_CATALOG)),
3508
+ _ts_param7(5, Optional5()),
3509
+ _ts_param7(5, Inject8(AGENT_QUOTA_PROVIDER2)),
3510
+ _ts_param7(6, Optional5()),
3511
+ _ts_param7(6, Inject8(AGENT_OPTIONS4)),
3512
+ _ts_param7(7, Optional5()),
3513
+ _ts_param7(8, Optional5()),
3514
+ _ts_metadata7("design:type", Function),
3515
+ _ts_metadata7("design:paramtypes", [
3074
3516
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
3075
3517
  typeof AgentStore === "undefined" ? Object : AgentStore,
3076
3518
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
@@ -3078,13 +3520,14 @@ AgentService = _ts_decorate7([
3078
3520
  typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
3079
3521
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
3080
3522
  typeof Pick === "undefined" ? Object : Pick,
3081
- typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
3523
+ typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2,
3524
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService
3082
3525
  ])
3083
3526
  ], AgentService);
3084
3527
 
3085
3528
  // src/approval-port.adapter.ts
3086
- import { Injectable as Injectable7 } from "@nestjs/common";
3087
- function _ts_decorate8(decorators, target, key, desc) {
3529
+ import { Injectable as Injectable8, NotImplementedException as NotImplementedException4, Optional as Optional6 } from "@nestjs/common";
3530
+ function _ts_decorate10(decorators, target, key, desc) {
3088
3531
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3089
3532
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3090
3533
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3097,20 +3540,48 @@ function _ts_decorate8(decorators, target, key, desc) {
3097
3540
  }
3098
3541
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3099
3542
  }
3100
- __name(_ts_decorate8, "_ts_decorate");
3101
- function _ts_metadata7(metadataKey, metadataValue) {
3543
+ __name(_ts_decorate10, "_ts_decorate");
3544
+ function _ts_metadata8(metadataKey, metadataValue) {
3102
3545
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3103
3546
  return Reflect.metadata(metadataKey, metadataValue);
3104
3547
  }
3105
3548
  }
3106
- __name(_ts_metadata7, "_ts_metadata");
3549
+ __name(_ts_metadata8, "_ts_metadata");
3550
+ function _ts_param8(paramIndex, decorator) {
3551
+ return function(target, key) {
3552
+ decorator(target, key, paramIndex);
3553
+ };
3554
+ }
3555
+ __name(_ts_param8, "_ts_param");
3107
3556
  var AgentApprovalPortAdapter = class {
3108
3557
  static {
3109
3558
  __name(this, "AgentApprovalPortAdapter");
3110
3559
  }
3111
3560
  agent;
3112
- constructor(agent) {
3561
+ proposals;
3562
+ constructor(agent, proposals) {
3113
3563
  this.agent = agent;
3564
+ this.proposals = proposals;
3565
+ }
3566
+ async approveActionProposal(actor, target, opts) {
3567
+ if (!this.proposals) throw new NotImplementedException4("Action proposals unavailable");
3568
+ return this.proposals.decide(target.threadId, target.proposalId, actor, {
3569
+ decision: "approved",
3570
+ ...opts?.remember !== void 0 ? {
3571
+ remember: opts.remember
3572
+ } : {},
3573
+ via: opts?.decidedVia ?? "console"
3574
+ });
3575
+ }
3576
+ async rejectActionProposal(actor, target, opts) {
3577
+ if (!this.proposals) throw new NotImplementedException4("Action proposals unavailable");
3578
+ return this.proposals.decide(target.threadId, target.proposalId, actor, {
3579
+ decision: "rejected",
3580
+ ...opts?.reason !== void 0 ? {
3581
+ reason: opts.reason
3582
+ } : {},
3583
+ via: opts?.decidedVia ?? "console"
3584
+ });
3114
3585
  }
3115
3586
  async approve(toolCallId2, opts) {
3116
3587
  await this.agent.signalToolCall(toolCallId2, {
@@ -3141,18 +3612,20 @@ var AgentApprovalPortAdapter = class {
3141
3612
  });
3142
3613
  }
3143
3614
  };
3144
- AgentApprovalPortAdapter = _ts_decorate8([
3145
- Injectable7(),
3146
- _ts_metadata7("design:type", Function),
3147
- _ts_metadata7("design:paramtypes", [
3148
- typeof AgentService === "undefined" ? Object : AgentService
3615
+ AgentApprovalPortAdapter = _ts_decorate10([
3616
+ Injectable8(),
3617
+ _ts_param8(1, Optional6()),
3618
+ _ts_metadata8("design:type", Function),
3619
+ _ts_metadata8("design:paramtypes", [
3620
+ typeof AgentService === "undefined" ? Object : AgentService,
3621
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService
3149
3622
  ])
3150
3623
  ], AgentApprovalPortAdapter);
3151
3624
 
3152
3625
  // src/controller/agents.controller.ts
3153
3626
  import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
3154
- import { Controller, Get, Inject as Inject7 } from "@nestjs/common";
3155
- function _ts_decorate9(decorators, target, key, desc) {
3627
+ import { Controller, Get, Inject as Inject9 } from "@nestjs/common";
3628
+ function _ts_decorate11(decorators, target, key, desc) {
3156
3629
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3157
3630
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3158
3631
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3165,19 +3638,19 @@ function _ts_decorate9(decorators, target, key, desc) {
3165
3638
  }
3166
3639
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3167
3640
  }
3168
- __name(_ts_decorate9, "_ts_decorate");
3169
- function _ts_metadata8(metadataKey, metadataValue) {
3641
+ __name(_ts_decorate11, "_ts_decorate");
3642
+ function _ts_metadata9(metadataKey, metadataValue) {
3170
3643
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3171
3644
  return Reflect.metadata(metadataKey, metadataValue);
3172
3645
  }
3173
3646
  }
3174
- __name(_ts_metadata8, "_ts_metadata");
3175
- function _ts_param7(paramIndex, decorator) {
3647
+ __name(_ts_metadata9, "_ts_metadata");
3648
+ function _ts_param9(paramIndex, decorator) {
3176
3649
  return function(target, key) {
3177
3650
  decorator(target, key, paramIndex);
3178
3651
  };
3179
3652
  }
3180
- __name(_ts_param7, "_ts_param");
3653
+ __name(_ts_param9, "_ts_param");
3181
3654
  var AgentsController = class {
3182
3655
  static {
3183
3656
  __name(this, "AgentsController");
@@ -3208,26 +3681,26 @@ var AgentsController = class {
3208
3681
  });
3209
3682
  }
3210
3683
  };
3211
- _ts_decorate9([
3684
+ _ts_decorate11([
3212
3685
  Get(),
3213
- _ts_metadata8("design:type", Function),
3214
- _ts_metadata8("design:paramtypes", []),
3215
- _ts_metadata8("design:returntype", Array)
3686
+ _ts_metadata9("design:type", Function),
3687
+ _ts_metadata9("design:paramtypes", []),
3688
+ _ts_metadata9("design:returntype", Array)
3216
3689
  ], AgentsController.prototype, "list", null);
3217
- AgentsController = _ts_decorate9([
3690
+ AgentsController = _ts_decorate11([
3218
3691
  Controller("agents"),
3219
- _ts_param7(0, Inject7(AGENT_REGISTRY2)),
3220
- _ts_param7(1, Inject7(AGENT_DEPS_FACTORY5)),
3221
- _ts_metadata8("design:type", Function),
3222
- _ts_metadata8("design:paramtypes", [
3692
+ _ts_param9(0, Inject9(AGENT_REGISTRY2)),
3693
+ _ts_param9(1, Inject9(AGENT_DEPS_FACTORY5)),
3694
+ _ts_metadata9("design:type", Function),
3695
+ _ts_metadata9("design:paramtypes", [
3223
3696
  typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
3224
3697
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
3225
3698
  ])
3226
3699
  ], AgentsController);
3227
3700
 
3228
3701
  // src/controller/attachments.controller.ts
3229
- import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
3230
- import { BadRequestException as BadRequestException3, Controller as Controller2, Get as Get2, Inject as Inject8, NotImplementedException as NotImplementedException3, Optional as Optional6, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
3702
+ import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS5 } from "@dudousxd/nestjs-agent-core";
3703
+ import { BadRequestException as BadRequestException3, Controller as Controller2, Get as Get2, Inject as Inject10, NotImplementedException as NotImplementedException5, Optional as Optional7, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
3231
3704
  import { FileInterceptor } from "@nestjs/platform-express";
3232
3705
 
3233
3706
  // src/attachment-limits.ts
@@ -3256,7 +3729,7 @@ function attachmentLimits(options, staging) {
3256
3729
  __name(attachmentLimits, "attachmentLimits");
3257
3730
 
3258
3731
  // src/controller/attachments.controller.ts
3259
- function _ts_decorate10(decorators, target, key, desc) {
3732
+ function _ts_decorate12(decorators, target, key, desc) {
3260
3733
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3261
3734
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3262
3735
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3269,19 +3742,19 @@ function _ts_decorate10(decorators, target, key, desc) {
3269
3742
  }
3270
3743
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3271
3744
  }
3272
- __name(_ts_decorate10, "_ts_decorate");
3273
- function _ts_metadata9(metadataKey, metadataValue) {
3745
+ __name(_ts_decorate12, "_ts_decorate");
3746
+ function _ts_metadata10(metadataKey, metadataValue) {
3274
3747
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3275
3748
  return Reflect.metadata(metadataKey, metadataValue);
3276
3749
  }
3277
3750
  }
3278
- __name(_ts_metadata9, "_ts_metadata");
3279
- function _ts_param8(paramIndex, decorator) {
3751
+ __name(_ts_metadata10, "_ts_metadata");
3752
+ function _ts_param10(paramIndex, decorator) {
3280
3753
  return function(target, key) {
3281
3754
  decorator(target, key, paramIndex);
3282
3755
  };
3283
3756
  }
3284
- __name(_ts_param8, "_ts_param");
3757
+ __name(_ts_param10, "_ts_param");
3285
3758
  var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
3286
3759
  var ATTACHMENT_PAGE_SIZE = 50;
3287
3760
  var AttachmentsController = class {
@@ -3315,7 +3788,7 @@ var AttachmentsController = class {
3315
3788
  }
3316
3789
  async upload(req, file) {
3317
3790
  if (this.staging === void 0) {
3318
- throw new NotImplementedException3("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
3791
+ throw new NotImplementedException5("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
3319
3792
  }
3320
3793
  if (file === void 0) {
3321
3794
  throw new BadRequestException3('multipart field "file" is required');
@@ -3337,39 +3810,39 @@ var AttachmentsController = class {
3337
3810
  });
3338
3811
  }
3339
3812
  };
3340
- _ts_decorate10([
3813
+ _ts_decorate12([
3341
3814
  Get2(),
3342
- _ts_param8(0, Req()),
3343
- _ts_metadata9("design:type", Function),
3344
- _ts_metadata9("design:paramtypes", [
3815
+ _ts_param10(0, Req()),
3816
+ _ts_metadata10("design:type", Function),
3817
+ _ts_metadata10("design:paramtypes", [
3345
3818
  typeof Request === "undefined" ? Object : Request
3346
3819
  ]),
3347
- _ts_metadata9("design:returntype", Promise)
3820
+ _ts_metadata10("design:returntype", Promise)
3348
3821
  ], AttachmentsController.prototype, "list", null);
3349
- _ts_decorate10([
3822
+ _ts_decorate12([
3350
3823
  Post(),
3351
3824
  UseInterceptors(FileInterceptor("file", {
3352
3825
  limits: {
3353
3826
  fileSize: HARD_MAX_ATTACHMENT_BYTES
3354
3827
  }
3355
3828
  })),
3356
- _ts_param8(0, Req()),
3357
- _ts_param8(1, UploadedFile()),
3358
- _ts_metadata9("design:type", Function),
3359
- _ts_metadata9("design:paramtypes", [
3829
+ _ts_param10(0, Req()),
3830
+ _ts_param10(1, UploadedFile()),
3831
+ _ts_metadata10("design:type", Function),
3832
+ _ts_metadata10("design:paramtypes", [
3360
3833
  typeof Request === "undefined" ? Object : Request,
3361
3834
  Object
3362
3835
  ]),
3363
- _ts_metadata9("design:returntype", Promise)
3836
+ _ts_metadata10("design:returntype", Promise)
3364
3837
  ], AttachmentsController.prototype, "upload", null);
3365
- AttachmentsController = _ts_decorate10([
3838
+ AttachmentsController = _ts_decorate12([
3366
3839
  Controller2("attachments"),
3367
- _ts_param8(0, Inject8(AGENT_OPTIONS4)),
3368
- _ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER)),
3369
- _ts_param8(3, Optional6()),
3370
- _ts_param8(3, Inject8(AGENT_ATTACHMENT_STAGING3)),
3371
- _ts_metadata9("design:type", Function),
3372
- _ts_metadata9("design:paramtypes", [
3840
+ _ts_param10(0, Inject10(AGENT_OPTIONS5)),
3841
+ _ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER)),
3842
+ _ts_param10(3, Optional7()),
3843
+ _ts_param10(3, Inject10(AGENT_ATTACHMENT_STAGING3)),
3844
+ _ts_metadata10("design:type", Function),
3845
+ _ts_metadata10("design:paramtypes", [
3373
3846
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
3374
3847
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3375
3848
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3379,8 +3852,9 @@ AttachmentsController = _ts_decorate10([
3379
3852
 
3380
3853
  // src/controller/chat.controller.ts
3381
3854
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
3382
- import { BadRequestException as BadRequestException4, Body, Controller as Controller3, Get as Get3, Inject as Inject9, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
3383
- function _ts_decorate11(decorators, target, key, desc) {
3855
+ import { validateUiCapabilities } from "@dudousxd/nestjs-agent-core/genui";
3856
+ import { BadRequestException as BadRequestException4, Body, Controller as Controller3, Get as Get3, Inject as Inject11, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
3857
+ function _ts_decorate13(decorators, target, key, desc) {
3384
3858
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3385
3859
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3386
3860
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3393,19 +3867,19 @@ function _ts_decorate11(decorators, target, key, desc) {
3393
3867
  }
3394
3868
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3395
3869
  }
3396
- __name(_ts_decorate11, "_ts_decorate");
3397
- function _ts_metadata10(metadataKey, metadataValue) {
3870
+ __name(_ts_decorate13, "_ts_decorate");
3871
+ function _ts_metadata11(metadataKey, metadataValue) {
3398
3872
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3399
3873
  return Reflect.metadata(metadataKey, metadataValue);
3400
3874
  }
3401
3875
  }
3402
- __name(_ts_metadata10, "_ts_metadata");
3403
- function _ts_param9(paramIndex, decorator) {
3876
+ __name(_ts_metadata11, "_ts_metadata");
3877
+ function _ts_param11(paramIndex, decorator) {
3404
3878
  return function(target, key) {
3405
3879
  decorator(target, key, paramIndex);
3406
3880
  };
3407
3881
  }
3408
- __name(_ts_param9, "_ts_param");
3882
+ __name(_ts_param11, "_ts_param");
3409
3883
  function sendMode(body) {
3410
3884
  if (body.interrupt === true) {
3411
3885
  return "interrupt";
@@ -3466,9 +3940,18 @@ var ChatController = class {
3466
3940
  const actor = await this.actorResolver.resolve(req);
3467
3941
  const attachments = attachmentRefs(body.attachments);
3468
3942
  const mode = sendMode(body);
3943
+ let uiCapabilities;
3944
+ try {
3945
+ uiCapabilities = body.uiCapabilities === void 0 ? void 0 : validateUiCapabilities(body.uiCapabilities);
3946
+ } catch {
3947
+ throw new BadRequestException4("Invalid UI capabilities");
3948
+ }
3469
3949
  const result = await this.agent.send({
3470
3950
  actor,
3471
3951
  message: body.message,
3952
+ ...uiCapabilities !== void 0 ? {
3953
+ uiCapabilities
3954
+ } : {},
3472
3955
  ...body.threadId !== void 0 ? {
3473
3956
  threadId: body.threadId
3474
3957
  } : {},
@@ -3495,6 +3978,10 @@ var ChatController = class {
3495
3978
  } : {},
3496
3979
  mode
3497
3980
  });
3981
+ if ("proposalDecision" in result) {
3982
+ res.status(200).json(result);
3983
+ return;
3984
+ }
3498
3985
  if (result.queued === true) {
3499
3986
  res.status(202).json(result);
3500
3987
  return;
@@ -3586,50 +4073,50 @@ data: ${JSON.stringify(payload)}
3586
4073
  res.end();
3587
4074
  }
3588
4075
  };
3589
- _ts_decorate11([
4076
+ _ts_decorate13([
3590
4077
  Post2("chat"),
3591
- _ts_param9(0, Req2()),
3592
- _ts_param9(1, Res()),
3593
- _ts_param9(2, Body()),
3594
- _ts_metadata10("design:type", Function),
3595
- _ts_metadata10("design:paramtypes", [
4078
+ _ts_param11(0, Req2()),
4079
+ _ts_param11(1, Res()),
4080
+ _ts_param11(2, Body()),
4081
+ _ts_metadata11("design:type", Function),
4082
+ _ts_metadata11("design:paramtypes", [
3596
4083
  typeof Request === "undefined" ? Object : Request,
3597
4084
  typeof Response === "undefined" ? Object : Response,
3598
4085
  typeof ChatBody === "undefined" ? Object : ChatBody
3599
4086
  ]),
3600
- _ts_metadata10("design:returntype", Promise)
4087
+ _ts_metadata11("design:returntype", Promise)
3601
4088
  ], ChatController.prototype, "chat", null);
3602
- _ts_decorate11([
4089
+ _ts_decorate13([
3603
4090
  Get3("chat/:runId/stream"),
3604
- _ts_param9(0, Req2()),
3605
- _ts_param9(1, Param("runId")),
3606
- _ts_param9(2, Res()),
3607
- _ts_param9(3, Query("after")),
3608
- _ts_metadata10("design:type", Function),
3609
- _ts_metadata10("design:paramtypes", [
4091
+ _ts_param11(0, Req2()),
4092
+ _ts_param11(1, Param("runId")),
4093
+ _ts_param11(2, Res()),
4094
+ _ts_param11(3, Query("after")),
4095
+ _ts_metadata11("design:type", Function),
4096
+ _ts_metadata11("design:paramtypes", [
3610
4097
  typeof Request === "undefined" ? Object : Request,
3611
4098
  String,
3612
4099
  typeof Response === "undefined" ? Object : Response,
3613
4100
  String
3614
4101
  ]),
3615
- _ts_metadata10("design:returntype", Promise)
4102
+ _ts_metadata11("design:returntype", Promise)
3616
4103
  ], ChatController.prototype, "stream", null);
3617
- _ts_decorate11([
4104
+ _ts_decorate13([
3618
4105
  Post2("chat/:runId/cancel"),
3619
- _ts_param9(0, Req2()),
3620
- _ts_param9(1, Param("runId")),
3621
- _ts_metadata10("design:type", Function),
3622
- _ts_metadata10("design:paramtypes", [
4106
+ _ts_param11(0, Req2()),
4107
+ _ts_param11(1, Param("runId")),
4108
+ _ts_metadata11("design:type", Function),
4109
+ _ts_metadata11("design:paramtypes", [
3623
4110
  typeof Request === "undefined" ? Object : Request,
3624
4111
  String
3625
4112
  ]),
3626
- _ts_metadata10("design:returntype", Promise)
4113
+ _ts_metadata11("design:returntype", Promise)
3627
4114
  ], ChatController.prototype, "cancel", null);
3628
- ChatController = _ts_decorate11([
4115
+ ChatController = _ts_decorate13([
3629
4116
  Controller3(),
3630
- _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER2)),
3631
- _ts_metadata10("design:type", Function),
3632
- _ts_metadata10("design:paramtypes", [
4117
+ _ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER2)),
4118
+ _ts_metadata11("design:type", Function),
4119
+ _ts_metadata11("design:paramtypes", [
3633
4120
  typeof AgentService === "undefined" ? Object : AgentService,
3634
4121
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3635
4122
  ])
@@ -3645,8 +4132,8 @@ function parseCursor(raw) {
3645
4132
  __name(parseCursor, "parseCursor");
3646
4133
 
3647
4134
  // src/controller/config.controller.ts
3648
- 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";
3649
- import { Controller as Controller4, Get as Get4, Inject as Inject10, Optional as Optional7, Req as Req3 } from "@nestjs/common";
4135
+ 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";
4136
+ import { Controller as Controller4, Get as Get4, Inject as Inject12, Optional as Optional8, Req as Req3 } from "@nestjs/common";
3650
4137
 
3651
4138
  // src/resolver/anonymous-actor-resolver.ts
3652
4139
  import { createHash, randomBytes } from "crypto";
@@ -3736,7 +4223,7 @@ var AnonymousActorResolver = class {
3736
4223
  };
3737
4224
 
3738
4225
  // src/controller/config.controller.ts
3739
- function _ts_decorate12(decorators, target, key, desc) {
4226
+ function _ts_decorate14(decorators, target, key, desc) {
3740
4227
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3741
4228
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3742
4229
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3749,19 +4236,19 @@ function _ts_decorate12(decorators, target, key, desc) {
3749
4236
  }
3750
4237
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3751
4238
  }
3752
- __name(_ts_decorate12, "_ts_decorate");
3753
- function _ts_metadata11(metadataKey, metadataValue) {
4239
+ __name(_ts_decorate14, "_ts_decorate");
4240
+ function _ts_metadata12(metadataKey, metadataValue) {
3754
4241
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3755
4242
  return Reflect.metadata(metadataKey, metadataValue);
3756
4243
  }
3757
4244
  }
3758
- __name(_ts_metadata11, "_ts_metadata");
3759
- function _ts_param10(paramIndex, decorator) {
4245
+ __name(_ts_metadata12, "_ts_metadata");
4246
+ function _ts_param12(paramIndex, decorator) {
3760
4247
  return function(target, key) {
3761
4248
  decorator(target, key, paramIndex);
3762
4249
  };
3763
4250
  }
3764
- __name(_ts_param10, "_ts_param");
4251
+ __name(_ts_param12, "_ts_param");
3765
4252
  var ConfigController = class {
3766
4253
  static {
3767
4254
  __name(this, "ConfigController");
@@ -3792,25 +4279,25 @@ var ConfigController = class {
3792
4279
  };
3793
4280
  }
3794
4281
  };
3795
- _ts_decorate12([
4282
+ _ts_decorate14([
3796
4283
  Get4(),
3797
- _ts_param10(0, Req3()),
3798
- _ts_metadata11("design:type", Function),
3799
- _ts_metadata11("design:paramtypes", [
4284
+ _ts_param12(0, Req3()),
4285
+ _ts_metadata12("design:type", Function),
4286
+ _ts_metadata12("design:paramtypes", [
3800
4287
  typeof Request === "undefined" ? Object : Request
3801
4288
  ]),
3802
- _ts_metadata11("design:returntype", Promise)
4289
+ _ts_metadata12("design:returntype", Promise)
3803
4290
  ], ConfigController.prototype, "config", null);
3804
- ConfigController = _ts_decorate12([
4291
+ ConfigController = _ts_decorate14([
3805
4292
  Controller4("config"),
3806
- _ts_param10(0, Inject10(AGENT_OPTIONS5)),
3807
- _ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER3)),
3808
- _ts_param10(2, Optional7()),
3809
- _ts_param10(2, Inject10(AGENT_ATTACHMENT_STAGING4)),
3810
- _ts_param10(3, Optional7()),
3811
- _ts_param10(3, Inject10(AGENT_MODEL_CATALOG2)),
3812
- _ts_metadata11("design:type", Function),
3813
- _ts_metadata11("design:paramtypes", [
4293
+ _ts_param12(0, Inject12(AGENT_OPTIONS6)),
4294
+ _ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER3)),
4295
+ _ts_param12(2, Optional8()),
4296
+ _ts_param12(2, Inject12(AGENT_ATTACHMENT_STAGING4)),
4297
+ _ts_param12(3, Optional8()),
4298
+ _ts_param12(3, Inject12(AGENT_MODEL_CATALOG2)),
4299
+ _ts_metadata12("design:type", Function),
4300
+ _ts_metadata12("design:paramtypes", [
3814
4301
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
3815
4302
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3816
4303
  Object,
@@ -3820,8 +4307,8 @@ ConfigController = _ts_decorate12([
3820
4307
 
3821
4308
  // src/controller/memories.controller.ts
3822
4309
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
3823
- import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException2, Get as Get5, Inject as Inject11, NotFoundException as NotFoundException2, Optional as Optional8, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
3824
- function _ts_decorate13(decorators, target, key, desc) {
4310
+ import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException3, Get as Get5, Inject as Inject13, NotFoundException as NotFoundException3, Optional as Optional9, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
4311
+ function _ts_decorate15(decorators, target, key, desc) {
3825
4312
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3826
4313
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3827
4314
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3834,19 +4321,19 @@ function _ts_decorate13(decorators, target, key, desc) {
3834
4321
  }
3835
4322
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3836
4323
  }
3837
- __name(_ts_decorate13, "_ts_decorate");
3838
- function _ts_metadata12(metadataKey, metadataValue) {
4324
+ __name(_ts_decorate15, "_ts_decorate");
4325
+ function _ts_metadata13(metadataKey, metadataValue) {
3839
4326
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3840
4327
  return Reflect.metadata(metadataKey, metadataValue);
3841
4328
  }
3842
4329
  }
3843
- __name(_ts_metadata12, "_ts_metadata");
3844
- function _ts_param11(paramIndex, decorator) {
4330
+ __name(_ts_metadata13, "_ts_metadata");
4331
+ function _ts_param13(paramIndex, decorator) {
3845
4332
  return function(target, key) {
3846
4333
  decorator(target, key, paramIndex);
3847
4334
  };
3848
4335
  }
3849
- __name(_ts_param11, "_ts_param");
4336
+ __name(_ts_param13, "_ts_param");
3850
4337
  var MemoriesController = class {
3851
4338
  static {
3852
4339
  __name(this, "MemoriesController");
@@ -3880,20 +4367,20 @@ var MemoriesController = class {
3880
4367
  */
3881
4368
  async forget(req, id) {
3882
4369
  if (this.memory === void 0) {
3883
- throw new NotFoundException2("No memory is configured in this deployment.");
4370
+ throw new NotFoundException3("No memory is configured in this deployment.");
3884
4371
  }
3885
4372
  const actor = await this.actorResolver.resolve(req);
3886
4373
  const digest = await this.unbounded("", actor);
3887
4374
  const entry = digest.entries.find((candidate) => candidate.id === id);
3888
4375
  if (entry === void 0) {
3889
- throw new NotFoundException2(`No memory with id "${id}".`);
4376
+ throw new NotFoundException3(`No memory with id "${id}".`);
3890
4377
  }
3891
4378
  const verdict = memoryForgetVerdict({
3892
4379
  record: entry,
3893
4380
  actor
3894
4381
  });
3895
4382
  if (!verdict.allowed) {
3896
- throw new ForbiddenException2(verdict.reason);
4383
+ throw new ForbiddenException3(verdict.reason);
3897
4384
  }
3898
4385
  return {
3899
4386
  forgotten: await this.memory.provider.forget({
@@ -3919,35 +4406,35 @@ var MemoriesController = class {
3919
4406
  });
3920
4407
  }
3921
4408
  };
3922
- _ts_decorate13([
4409
+ _ts_decorate15([
3923
4410
  Get5(),
3924
- _ts_param11(0, Req4()),
3925
- _ts_param11(1, Query2("threadId")),
3926
- _ts_metadata12("design:type", Function),
3927
- _ts_metadata12("design:paramtypes", [
4411
+ _ts_param13(0, Req4()),
4412
+ _ts_param13(1, Query2("threadId")),
4413
+ _ts_metadata13("design:type", Function),
4414
+ _ts_metadata13("design:paramtypes", [
3928
4415
  typeof Request === "undefined" ? Object : Request,
3929
4416
  String
3930
4417
  ]),
3931
- _ts_metadata12("design:returntype", Promise)
4418
+ _ts_metadata13("design:returntype", Promise)
3932
4419
  ], MemoriesController.prototype, "list", null);
3933
- _ts_decorate13([
4420
+ _ts_decorate15([
3934
4421
  Delete(":id"),
3935
- _ts_param11(0, Req4()),
3936
- _ts_param11(1, Param2("id")),
3937
- _ts_metadata12("design:type", Function),
3938
- _ts_metadata12("design:paramtypes", [
4422
+ _ts_param13(0, Req4()),
4423
+ _ts_param13(1, Param2("id")),
4424
+ _ts_metadata13("design:type", Function),
4425
+ _ts_metadata13("design:paramtypes", [
3939
4426
  typeof Request === "undefined" ? Object : Request,
3940
4427
  String
3941
4428
  ]),
3942
- _ts_metadata12("design:returntype", Promise)
4429
+ _ts_metadata13("design:returntype", Promise)
3943
4430
  ], MemoriesController.prototype, "forget", null);
3944
- MemoriesController = _ts_decorate13([
4431
+ MemoriesController = _ts_decorate15([
3945
4432
  Controller5("memories"),
3946
- _ts_param11(0, Inject11(AGENT_ACTOR_RESOLVER4)),
3947
- _ts_param11(1, Optional8()),
3948
- _ts_param11(1, Inject11(AGENT_MEMORY2)),
3949
- _ts_metadata12("design:type", Function),
3950
- _ts_metadata12("design:paramtypes", [
4433
+ _ts_param13(0, Inject13(AGENT_ACTOR_RESOLVER4)),
4434
+ _ts_param13(1, Optional9()),
4435
+ _ts_param13(1, Inject13(AGENT_MEMORY2)),
4436
+ _ts_metadata13("design:type", Function),
4437
+ _ts_metadata13("design:paramtypes", [
3951
4438
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3952
4439
  Object
3953
4440
  ])
@@ -3955,8 +4442,8 @@ MemoriesController = _ts_decorate13([
3955
4442
 
3956
4443
  // src/controller/messages.controller.ts
3957
4444
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
3958
- import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject12, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
3959
- function _ts_decorate14(decorators, target, key, desc) {
4445
+ import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject14, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
4446
+ function _ts_decorate16(decorators, target, key, desc) {
3960
4447
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3961
4448
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3962
4449
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3969,19 +4456,19 @@ function _ts_decorate14(decorators, target, key, desc) {
3969
4456
  }
3970
4457
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3971
4458
  }
3972
- __name(_ts_decorate14, "_ts_decorate");
3973
- function _ts_metadata13(metadataKey, metadataValue) {
4459
+ __name(_ts_decorate16, "_ts_decorate");
4460
+ function _ts_metadata14(metadataKey, metadataValue) {
3974
4461
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3975
4462
  return Reflect.metadata(metadataKey, metadataValue);
3976
4463
  }
3977
4464
  }
3978
- __name(_ts_metadata13, "_ts_metadata");
3979
- function _ts_param12(paramIndex, decorator) {
4465
+ __name(_ts_metadata14, "_ts_metadata");
4466
+ function _ts_param14(paramIndex, decorator) {
3980
4467
  return function(target, key) {
3981
4468
  decorator(target, key, paramIndex);
3982
4469
  };
3983
4470
  }
3984
- __name(_ts_param12, "_ts_param");
4471
+ __name(_ts_param14, "_ts_param");
3985
4472
  var MessagesController = class {
3986
4473
  static {
3987
4474
  __name(this, "MessagesController");
@@ -4009,25 +4496,25 @@ var MessagesController = class {
4009
4496
  };
4010
4497
  }
4011
4498
  };
4012
- _ts_decorate14([
4499
+ _ts_decorate16([
4013
4500
  Post3(":id/feedback"),
4014
4501
  HttpCode(200),
4015
- _ts_param12(0, Req5()),
4016
- _ts_param12(1, Param3("id")),
4017
- _ts_param12(2, Body2()),
4018
- _ts_metadata13("design:type", Function),
4019
- _ts_metadata13("design:paramtypes", [
4502
+ _ts_param14(0, Req5()),
4503
+ _ts_param14(1, Param3("id")),
4504
+ _ts_param14(2, Body2()),
4505
+ _ts_metadata14("design:type", Function),
4506
+ _ts_metadata14("design:paramtypes", [
4020
4507
  typeof Request === "undefined" ? Object : Request,
4021
4508
  String,
4022
4509
  typeof FeedbackBody === "undefined" ? Object : FeedbackBody
4023
4510
  ]),
4024
- _ts_metadata13("design:returntype", Promise)
4511
+ _ts_metadata14("design:returntype", Promise)
4025
4512
  ], MessagesController.prototype, "feedback", null);
4026
- MessagesController = _ts_decorate14([
4513
+ MessagesController = _ts_decorate16([
4027
4514
  Controller6("messages"),
4028
- _ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER5)),
4029
- _ts_metadata13("design:type", Function),
4030
- _ts_metadata13("design:paramtypes", [
4515
+ _ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER5)),
4516
+ _ts_metadata14("design:type", Function),
4517
+ _ts_metadata14("design:paramtypes", [
4031
4518
  typeof AgentService === "undefined" ? Object : AgentService,
4032
4519
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4033
4520
  ])
@@ -4035,8 +4522,8 @@ MessagesController = _ts_decorate14([
4035
4522
 
4036
4523
  // src/controller/models.controller.ts
4037
4524
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
4038
- import { Controller as Controller7, Get as Get6, Inject as Inject13, Query as Query3, Req as Req6 } from "@nestjs/common";
4039
- function _ts_decorate15(decorators, target, key, desc) {
4525
+ import { Controller as Controller7, Get as Get6, Inject as Inject15, Query as Query3, Req as Req6 } from "@nestjs/common";
4526
+ function _ts_decorate17(decorators, target, key, desc) {
4040
4527
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4041
4528
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4042
4529
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4049,19 +4536,19 @@ function _ts_decorate15(decorators, target, key, desc) {
4049
4536
  }
4050
4537
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4051
4538
  }
4052
- __name(_ts_decorate15, "_ts_decorate");
4053
- function _ts_metadata14(metadataKey, metadataValue) {
4539
+ __name(_ts_decorate17, "_ts_decorate");
4540
+ function _ts_metadata15(metadataKey, metadataValue) {
4054
4541
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4055
4542
  return Reflect.metadata(metadataKey, metadataValue);
4056
4543
  }
4057
4544
  }
4058
- __name(_ts_metadata14, "_ts_metadata");
4059
- function _ts_param13(paramIndex, decorator) {
4545
+ __name(_ts_metadata15, "_ts_metadata");
4546
+ function _ts_param15(paramIndex, decorator) {
4060
4547
  return function(target, key) {
4061
4548
  decorator(target, key, paramIndex);
4062
4549
  };
4063
4550
  }
4064
- __name(_ts_param13, "_ts_param");
4551
+ __name(_ts_param15, "_ts_param");
4065
4552
  var ModelsController = class {
4066
4553
  static {
4067
4554
  __name(this, "ModelsController");
@@ -4081,22 +4568,22 @@ var ModelsController = class {
4081
4568
  return this.agent.listModels(actor, agent);
4082
4569
  }
4083
4570
  };
4084
- _ts_decorate15([
4571
+ _ts_decorate17([
4085
4572
  Get6(),
4086
- _ts_param13(0, Req6()),
4087
- _ts_param13(1, Query3("agent")),
4088
- _ts_metadata14("design:type", Function),
4089
- _ts_metadata14("design:paramtypes", [
4573
+ _ts_param15(0, Req6()),
4574
+ _ts_param15(1, Query3("agent")),
4575
+ _ts_metadata15("design:type", Function),
4576
+ _ts_metadata15("design:paramtypes", [
4090
4577
  typeof Request === "undefined" ? Object : Request,
4091
4578
  String
4092
4579
  ]),
4093
- _ts_metadata14("design:returntype", Promise)
4580
+ _ts_metadata15("design:returntype", Promise)
4094
4581
  ], ModelsController.prototype, "list", null);
4095
- ModelsController = _ts_decorate15([
4582
+ ModelsController = _ts_decorate17([
4096
4583
  Controller7("models"),
4097
- _ts_param13(1, Inject13(AGENT_ACTOR_RESOLVER6)),
4098
- _ts_metadata14("design:type", Function),
4099
- _ts_metadata14("design:paramtypes", [
4584
+ _ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER6)),
4585
+ _ts_metadata15("design:type", Function),
4586
+ _ts_metadata15("design:paramtypes", [
4100
4587
  typeof AgentService === "undefined" ? Object : AgentService,
4101
4588
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4102
4589
  ])
@@ -4104,8 +4591,8 @@ ModelsController = _ts_decorate15([
4104
4591
 
4105
4592
  // src/controller/queue.controller.ts
4106
4593
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
4107
- import { BadRequestException as BadRequestException5, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as Inject14, Param as Param4, Patch, Post as Post4, Req as Req7 } from "@nestjs/common";
4108
- function _ts_decorate16(decorators, target, key, desc) {
4594
+ import { BadRequestException as BadRequestException5, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as Inject16, Param as Param4, Patch, Post as Post4, Req as Req7 } from "@nestjs/common";
4595
+ function _ts_decorate18(decorators, target, key, desc) {
4109
4596
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4110
4597
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4111
4598
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4118,19 +4605,19 @@ function _ts_decorate16(decorators, target, key, desc) {
4118
4605
  }
4119
4606
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4120
4607
  }
4121
- __name(_ts_decorate16, "_ts_decorate");
4122
- function _ts_metadata15(metadataKey, metadataValue) {
4608
+ __name(_ts_decorate18, "_ts_decorate");
4609
+ function _ts_metadata16(metadataKey, metadataValue) {
4123
4610
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4124
4611
  return Reflect.metadata(metadataKey, metadataValue);
4125
4612
  }
4126
4613
  }
4127
- __name(_ts_metadata15, "_ts_metadata");
4128
- function _ts_param14(paramIndex, decorator) {
4614
+ __name(_ts_metadata16, "_ts_metadata");
4615
+ function _ts_param16(paramIndex, decorator) {
4129
4616
  return function(target, key) {
4130
4617
  decorator(target, key, paramIndex);
4131
4618
  };
4132
4619
  }
4133
- __name(_ts_param14, "_ts_param");
4620
+ __name(_ts_param16, "_ts_param");
4134
4621
  var QueueController = class {
4135
4622
  static {
4136
4623
  __name(this, "QueueController");
@@ -4184,79 +4671,79 @@ var QueueController = class {
4184
4671
  return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
4185
4672
  }
4186
4673
  };
4187
- _ts_decorate16([
4674
+ _ts_decorate18([
4188
4675
  Get7("threads/:id/queue"),
4189
- _ts_param14(0, Req7()),
4190
- _ts_param14(1, Param4("id")),
4191
- _ts_metadata15("design:type", Function),
4192
- _ts_metadata15("design:paramtypes", [
4676
+ _ts_param16(0, Req7()),
4677
+ _ts_param16(1, Param4("id")),
4678
+ _ts_metadata16("design:type", Function),
4679
+ _ts_metadata16("design:paramtypes", [
4193
4680
  typeof Request === "undefined" ? Object : Request,
4194
4681
  String
4195
4682
  ]),
4196
- _ts_metadata15("design:returntype", Promise)
4683
+ _ts_metadata16("design:returntype", Promise)
4197
4684
  ], QueueController.prototype, "list", null);
4198
- _ts_decorate16([
4685
+ _ts_decorate18([
4199
4686
  Delete2("threads/:id/queue"),
4200
- _ts_param14(0, Req7()),
4201
- _ts_param14(1, Param4("id")),
4202
- _ts_metadata15("design:type", Function),
4203
- _ts_metadata15("design:paramtypes", [
4687
+ _ts_param16(0, Req7()),
4688
+ _ts_param16(1, Param4("id")),
4689
+ _ts_metadata16("design:type", Function),
4690
+ _ts_metadata16("design:paramtypes", [
4204
4691
  typeof Request === "undefined" ? Object : Request,
4205
4692
  String
4206
4693
  ]),
4207
- _ts_metadata15("design:returntype", Promise)
4694
+ _ts_metadata16("design:returntype", Promise)
4208
4695
  ], QueueController.prototype, "clear", null);
4209
- _ts_decorate16([
4696
+ _ts_decorate18([
4210
4697
  Post4("threads/:id/queue/resume"),
4211
- _ts_param14(0, Req7()),
4212
- _ts_param14(1, Param4("id")),
4213
- _ts_metadata15("design:type", Function),
4214
- _ts_metadata15("design:paramtypes", [
4698
+ _ts_param16(0, Req7()),
4699
+ _ts_param16(1, Param4("id")),
4700
+ _ts_metadata16("design:type", Function),
4701
+ _ts_metadata16("design:paramtypes", [
4215
4702
  typeof Request === "undefined" ? Object : Request,
4216
4703
  String
4217
4704
  ]),
4218
- _ts_metadata15("design:returntype", Promise)
4705
+ _ts_metadata16("design:returntype", Promise)
4219
4706
  ], QueueController.prototype, "resume", null);
4220
- _ts_decorate16([
4707
+ _ts_decorate18([
4221
4708
  Patch("queue/:messageId"),
4222
- _ts_param14(0, Req7()),
4223
- _ts_param14(1, Param4("messageId")),
4224
- _ts_param14(2, Body3()),
4225
- _ts_metadata15("design:type", Function),
4226
- _ts_metadata15("design:paramtypes", [
4709
+ _ts_param16(0, Req7()),
4710
+ _ts_param16(1, Param4("messageId")),
4711
+ _ts_param16(2, Body3()),
4712
+ _ts_metadata16("design:type", Function),
4713
+ _ts_metadata16("design:paramtypes", [
4227
4714
  typeof Request === "undefined" ? Object : Request,
4228
4715
  String,
4229
4716
  typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
4230
4717
  ]),
4231
- _ts_metadata15("design:returntype", Promise)
4718
+ _ts_metadata16("design:returntype", Promise)
4232
4719
  ], QueueController.prototype, "update", null);
4233
- _ts_decorate16([
4720
+ _ts_decorate18([
4234
4721
  Post4("queue/:messageId/interrupt"),
4235
- _ts_param14(0, Req7()),
4236
- _ts_param14(1, Param4("messageId")),
4237
- _ts_metadata15("design:type", Function),
4238
- _ts_metadata15("design:paramtypes", [
4722
+ _ts_param16(0, Req7()),
4723
+ _ts_param16(1, Param4("messageId")),
4724
+ _ts_metadata16("design:type", Function),
4725
+ _ts_metadata16("design:paramtypes", [
4239
4726
  typeof Request === "undefined" ? Object : Request,
4240
4727
  String
4241
4728
  ]),
4242
- _ts_metadata15("design:returntype", Promise)
4729
+ _ts_metadata16("design:returntype", Promise)
4243
4730
  ], QueueController.prototype, "interrupt", null);
4244
- _ts_decorate16([
4731
+ _ts_decorate18([
4245
4732
  Delete2("queue/:messageId"),
4246
- _ts_param14(0, Req7()),
4247
- _ts_param14(1, Param4("messageId")),
4248
- _ts_metadata15("design:type", Function),
4249
- _ts_metadata15("design:paramtypes", [
4733
+ _ts_param16(0, Req7()),
4734
+ _ts_param16(1, Param4("messageId")),
4735
+ _ts_metadata16("design:type", Function),
4736
+ _ts_metadata16("design:paramtypes", [
4250
4737
  typeof Request === "undefined" ? Object : Request,
4251
4738
  String
4252
4739
  ]),
4253
- _ts_metadata15("design:returntype", Promise)
4740
+ _ts_metadata16("design:returntype", Promise)
4254
4741
  ], QueueController.prototype, "remove", null);
4255
- QueueController = _ts_decorate16([
4742
+ QueueController = _ts_decorate18([
4256
4743
  Controller8(),
4257
- _ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER7)),
4258
- _ts_metadata15("design:type", Function),
4259
- _ts_metadata15("design:paramtypes", [
4744
+ _ts_param16(1, Inject16(AGENT_ACTOR_RESOLVER7)),
4745
+ _ts_metadata16("design:type", Function),
4746
+ _ts_metadata16("design:paramtypes", [
4260
4747
  typeof AgentService === "undefined" ? Object : AgentService,
4261
4748
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4262
4749
  ])
@@ -4264,8 +4751,8 @@ QueueController = _ts_decorate16([
4264
4751
 
4265
4752
  // src/controller/quota.controller.ts
4266
4753
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
4267
- import { Controller as Controller9, Get as Get8, Inject as Inject15, Req as Req8 } from "@nestjs/common";
4268
- function _ts_decorate17(decorators, target, key, desc) {
4754
+ import { Controller as Controller9, Get as Get8, Inject as Inject17, Req as Req8 } from "@nestjs/common";
4755
+ function _ts_decorate19(decorators, target, key, desc) {
4269
4756
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4270
4757
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4271
4758
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4278,19 +4765,19 @@ function _ts_decorate17(decorators, target, key, desc) {
4278
4765
  }
4279
4766
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4280
4767
  }
4281
- __name(_ts_decorate17, "_ts_decorate");
4282
- function _ts_metadata16(metadataKey, metadataValue) {
4768
+ __name(_ts_decorate19, "_ts_decorate");
4769
+ function _ts_metadata17(metadataKey, metadataValue) {
4283
4770
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4284
4771
  return Reflect.metadata(metadataKey, metadataValue);
4285
4772
  }
4286
4773
  }
4287
- __name(_ts_metadata16, "_ts_metadata");
4288
- function _ts_param15(paramIndex, decorator) {
4774
+ __name(_ts_metadata17, "_ts_metadata");
4775
+ function _ts_param17(paramIndex, decorator) {
4289
4776
  return function(target, key) {
4290
4777
  decorator(target, key, paramIndex);
4291
4778
  };
4292
4779
  }
4293
- __name(_ts_param15, "_ts_param");
4780
+ __name(_ts_param17, "_ts_param");
4294
4781
  var QuotaController = class {
4295
4782
  static {
4296
4783
  __name(this, "QuotaController");
@@ -4310,20 +4797,20 @@ var QuotaController = class {
4310
4797
  return this.agent.quotaReport(actor);
4311
4798
  }
4312
4799
  };
4313
- _ts_decorate17([
4800
+ _ts_decorate19([
4314
4801
  Get8(),
4315
- _ts_param15(0, Req8()),
4316
- _ts_metadata16("design:type", Function),
4317
- _ts_metadata16("design:paramtypes", [
4802
+ _ts_param17(0, Req8()),
4803
+ _ts_metadata17("design:type", Function),
4804
+ _ts_metadata17("design:paramtypes", [
4318
4805
  typeof Request === "undefined" ? Object : Request
4319
4806
  ]),
4320
- _ts_metadata16("design:returntype", Promise)
4807
+ _ts_metadata17("design:returntype", Promise)
4321
4808
  ], QuotaController.prototype, "report", null);
4322
- QuotaController = _ts_decorate17([
4809
+ QuotaController = _ts_decorate19([
4323
4810
  Controller9("quota"),
4324
- _ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER8)),
4325
- _ts_metadata16("design:type", Function),
4326
- _ts_metadata16("design:paramtypes", [
4811
+ _ts_param17(1, Inject17(AGENT_ACTOR_RESOLVER8)),
4812
+ _ts_metadata17("design:type", Function),
4813
+ _ts_metadata17("design:paramtypes", [
4327
4814
  typeof AgentService === "undefined" ? Object : AgentService,
4328
4815
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4329
4816
  ])
@@ -4331,8 +4818,8 @@ QuotaController = _ts_decorate17([
4331
4818
 
4332
4819
  // src/controller/skills.controller.ts
4333
4820
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
4334
- import { Controller as Controller10, Get as Get9, Inject as Inject16, Optional as Optional9, Query as Query4, Req as Req9 } from "@nestjs/common";
4335
- function _ts_decorate18(decorators, target, key, desc) {
4821
+ import { Controller as Controller10, Get as Get9, Inject as Inject18, Optional as Optional10, Query as Query4, Req as Req9 } from "@nestjs/common";
4822
+ function _ts_decorate20(decorators, target, key, desc) {
4336
4823
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4337
4824
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4338
4825
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4345,19 +4832,19 @@ function _ts_decorate18(decorators, target, key, desc) {
4345
4832
  }
4346
4833
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4347
4834
  }
4348
- __name(_ts_decorate18, "_ts_decorate");
4349
- function _ts_metadata17(metadataKey, metadataValue) {
4835
+ __name(_ts_decorate20, "_ts_decorate");
4836
+ function _ts_metadata18(metadataKey, metadataValue) {
4350
4837
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4351
4838
  return Reflect.metadata(metadataKey, metadataValue);
4352
4839
  }
4353
4840
  }
4354
- __name(_ts_metadata17, "_ts_metadata");
4355
- function _ts_param16(paramIndex, decorator) {
4841
+ __name(_ts_metadata18, "_ts_metadata");
4842
+ function _ts_param18(paramIndex, decorator) {
4356
4843
  return function(target, key) {
4357
4844
  decorator(target, key, paramIndex);
4358
4845
  };
4359
4846
  }
4360
- __name(_ts_param16, "_ts_param");
4847
+ __name(_ts_param18, "_ts_param");
4361
4848
  var SkillsController = class {
4362
4849
  static {
4363
4850
  __name(this, "SkillsController");
@@ -4380,24 +4867,24 @@ var SkillsController = class {
4380
4867
  return offer.entries;
4381
4868
  }
4382
4869
  };
4383
- _ts_decorate18([
4870
+ _ts_decorate20([
4384
4871
  Get9(),
4385
- _ts_param16(0, Req9()),
4386
- _ts_param16(1, Query4("threadId")),
4387
- _ts_metadata17("design:type", Function),
4388
- _ts_metadata17("design:paramtypes", [
4872
+ _ts_param18(0, Req9()),
4873
+ _ts_param18(1, Query4("threadId")),
4874
+ _ts_metadata18("design:type", Function),
4875
+ _ts_metadata18("design:paramtypes", [
4389
4876
  typeof Request === "undefined" ? Object : Request,
4390
4877
  String
4391
4878
  ]),
4392
- _ts_metadata17("design:returntype", Promise)
4879
+ _ts_metadata18("design:returntype", Promise)
4393
4880
  ], SkillsController.prototype, "list", null);
4394
- SkillsController = _ts_decorate18([
4881
+ SkillsController = _ts_decorate20([
4395
4882
  Controller10("skills"),
4396
- _ts_param16(0, Inject16(AGENT_ACTOR_RESOLVER9)),
4397
- _ts_param16(1, Optional9()),
4398
- _ts_param16(1, Inject16(AGENT_SKILLS2)),
4399
- _ts_metadata17("design:type", Function),
4400
- _ts_metadata17("design:paramtypes", [
4883
+ _ts_param18(0, Inject18(AGENT_ACTOR_RESOLVER9)),
4884
+ _ts_param18(1, Optional10()),
4885
+ _ts_param18(1, Inject18(AGENT_SKILLS2)),
4886
+ _ts_metadata18("design:type", Function),
4887
+ _ts_metadata18("design:paramtypes", [
4401
4888
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4402
4889
  Object
4403
4890
  ])
@@ -4405,8 +4892,8 @@ SkillsController = _ts_decorate18([
4405
4892
 
4406
4893
  // src/controller/threads.controller.ts
4407
4894
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
4408
- import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as Inject17, Param as Param5, Patch as Patch2, Post as Post5, Req as Req10 } from "@nestjs/common";
4409
- function _ts_decorate19(decorators, target, key, desc) {
4895
+ import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as Inject19, Param as Param5, Patch as Patch2, Post as Post5, Req as Req10 } from "@nestjs/common";
4896
+ function _ts_decorate21(decorators, target, key, desc) {
4410
4897
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4411
4898
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4412
4899
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4419,19 +4906,19 @@ function _ts_decorate19(decorators, target, key, desc) {
4419
4906
  }
4420
4907
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4421
4908
  }
4422
- __name(_ts_decorate19, "_ts_decorate");
4423
- function _ts_metadata18(metadataKey, metadataValue) {
4909
+ __name(_ts_decorate21, "_ts_decorate");
4910
+ function _ts_metadata19(metadataKey, metadataValue) {
4424
4911
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4425
4912
  return Reflect.metadata(metadataKey, metadataValue);
4426
4913
  }
4427
4914
  }
4428
- __name(_ts_metadata18, "_ts_metadata");
4429
- function _ts_param17(paramIndex, decorator) {
4915
+ __name(_ts_metadata19, "_ts_metadata");
4916
+ function _ts_param19(paramIndex, decorator) {
4430
4917
  return function(target, key) {
4431
4918
  decorator(target, key, paramIndex);
4432
4919
  };
4433
4920
  }
4434
- __name(_ts_param17, "_ts_param");
4921
+ __name(_ts_param19, "_ts_param");
4435
4922
  var ThreadsController = class {
4436
4923
  static {
4437
4924
  __name(this, "ThreadsController");
@@ -4501,92 +4988,92 @@ var ThreadsController = class {
4501
4988
  };
4502
4989
  }
4503
4990
  };
4504
- _ts_decorate19([
4991
+ _ts_decorate21([
4505
4992
  Get10(),
4506
- _ts_param17(0, Req10()),
4507
- _ts_metadata18("design:type", Function),
4508
- _ts_metadata18("design:paramtypes", [
4993
+ _ts_param19(0, Req10()),
4994
+ _ts_metadata19("design:type", Function),
4995
+ _ts_metadata19("design:paramtypes", [
4509
4996
  typeof Request === "undefined" ? Object : Request
4510
4997
  ]),
4511
- _ts_metadata18("design:returntype", Promise)
4998
+ _ts_metadata19("design:returntype", Promise)
4512
4999
  ], ThreadsController.prototype, "list", null);
4513
- _ts_decorate19([
5000
+ _ts_decorate21([
4514
5001
  Get10(":id"),
4515
- _ts_param17(0, Req10()),
4516
- _ts_param17(1, Param5("id")),
4517
- _ts_metadata18("design:type", Function),
4518
- _ts_metadata18("design:paramtypes", [
5002
+ _ts_param19(0, Req10()),
5003
+ _ts_param19(1, Param5("id")),
5004
+ _ts_metadata19("design:type", Function),
5005
+ _ts_metadata19("design:paramtypes", [
4519
5006
  typeof Request === "undefined" ? Object : Request,
4520
5007
  String
4521
5008
  ]),
4522
- _ts_metadata18("design:returntype", Promise)
5009
+ _ts_metadata19("design:returntype", Promise)
4523
5010
  ], ThreadsController.prototype, "detail", null);
4524
- _ts_decorate19([
5011
+ _ts_decorate21([
4525
5012
  Delete3(":id"),
4526
- _ts_param17(0, Req10()),
4527
- _ts_param17(1, Param5("id")),
4528
- _ts_metadata18("design:type", Function),
4529
- _ts_metadata18("design:paramtypes", [
5013
+ _ts_param19(0, Req10()),
5014
+ _ts_param19(1, Param5("id")),
5015
+ _ts_metadata19("design:type", Function),
5016
+ _ts_metadata19("design:paramtypes", [
4530
5017
  typeof Request === "undefined" ? Object : Request,
4531
5018
  String
4532
5019
  ]),
4533
- _ts_metadata18("design:returntype", Promise)
5020
+ _ts_metadata19("design:returntype", Promise)
4534
5021
  ], ThreadsController.prototype, "remove", null);
4535
- _ts_decorate19([
5022
+ _ts_decorate21([
4536
5023
  Post5(":id/fork-from/:messageId"),
4537
- _ts_param17(0, Req10()),
4538
- _ts_param17(1, Param5("id")),
4539
- _ts_param17(2, Param5("messageId")),
4540
- _ts_metadata18("design:type", Function),
4541
- _ts_metadata18("design:paramtypes", [
5024
+ _ts_param19(0, Req10()),
5025
+ _ts_param19(1, Param5("id")),
5026
+ _ts_param19(2, Param5("messageId")),
5027
+ _ts_metadata19("design:type", Function),
5028
+ _ts_metadata19("design:paramtypes", [
4542
5029
  typeof Request === "undefined" ? Object : Request,
4543
5030
  String,
4544
5031
  String
4545
5032
  ]),
4546
- _ts_metadata18("design:returntype", Promise)
5033
+ _ts_metadata19("design:returntype", Promise)
4547
5034
  ], ThreadsController.prototype, "fork", null);
4548
- _ts_decorate19([
5035
+ _ts_decorate21([
4549
5036
  Patch2(":id"),
4550
- _ts_param17(0, Req10()),
4551
- _ts_param17(1, Param5("id")),
4552
- _ts_param17(2, Body4()),
4553
- _ts_metadata18("design:type", Function),
4554
- _ts_metadata18("design:paramtypes", [
5037
+ _ts_param19(0, Req10()),
5038
+ _ts_param19(1, Param5("id")),
5039
+ _ts_param19(2, Body4()),
5040
+ _ts_metadata19("design:type", Function),
5041
+ _ts_metadata19("design:paramtypes", [
4555
5042
  typeof Request === "undefined" ? Object : Request,
4556
5043
  String,
4557
5044
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
4558
5045
  ]),
4559
- _ts_metadata18("design:returntype", Promise)
5046
+ _ts_metadata19("design:returntype", Promise)
4560
5047
  ], ThreadsController.prototype, "update", null);
4561
- _ts_decorate19([
5048
+ _ts_decorate21([
4562
5049
  Post5(":id/promote"),
4563
- _ts_param17(0, Req10()),
4564
- _ts_param17(1, Param5("id")),
4565
- _ts_metadata18("design:type", Function),
4566
- _ts_metadata18("design:paramtypes", [
5050
+ _ts_param19(0, Req10()),
5051
+ _ts_param19(1, Param5("id")),
5052
+ _ts_metadata19("design:type", Function),
5053
+ _ts_metadata19("design:paramtypes", [
4567
5054
  typeof Request === "undefined" ? Object : Request,
4568
5055
  String
4569
5056
  ]),
4570
- _ts_metadata18("design:returntype", Promise)
5057
+ _ts_metadata19("design:returntype", Promise)
4571
5058
  ], ThreadsController.prototype, "promote", null);
4572
- _ts_decorate19([
5059
+ _ts_decorate21([
4573
5060
  Delete3(":id/from/:messageId"),
4574
- _ts_param17(0, Req10()),
4575
- _ts_param17(1, Param5("id")),
4576
- _ts_param17(2, Param5("messageId")),
4577
- _ts_metadata18("design:type", Function),
4578
- _ts_metadata18("design:paramtypes", [
5061
+ _ts_param19(0, Req10()),
5062
+ _ts_param19(1, Param5("id")),
5063
+ _ts_param19(2, Param5("messageId")),
5064
+ _ts_metadata19("design:type", Function),
5065
+ _ts_metadata19("design:paramtypes", [
4579
5066
  typeof Request === "undefined" ? Object : Request,
4580
5067
  String,
4581
5068
  String
4582
5069
  ]),
4583
- _ts_metadata18("design:returntype", Promise)
5070
+ _ts_metadata19("design:returntype", Promise)
4584
5071
  ], ThreadsController.prototype, "truncateFrom", null);
4585
- ThreadsController = _ts_decorate19([
5072
+ ThreadsController = _ts_decorate21([
4586
5073
  Controller11("threads"),
4587
- _ts_param17(1, Inject17(AGENT_ACTOR_RESOLVER10)),
4588
- _ts_metadata18("design:type", Function),
4589
- _ts_metadata18("design:paramtypes", [
5074
+ _ts_param19(1, Inject19(AGENT_ACTOR_RESOLVER10)),
5075
+ _ts_metadata19("design:type", Function),
5076
+ _ts_metadata19("design:paramtypes", [
4590
5077
  typeof AgentService === "undefined" ? Object : AgentService,
4591
5078
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4592
5079
  ])
@@ -4594,8 +5081,8 @@ ThreadsController = _ts_decorate19([
4594
5081
 
4595
5082
  // src/controller/tool-call.controller.ts
4596
5083
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11 } from "@dudousxd/nestjs-agent-core";
4597
- import { BadRequestException as BadRequestException6, Body as Body5, Controller as Controller12, Inject as Inject18, Post as Post6, Req as Req11 } from "@nestjs/common";
4598
- function _ts_decorate20(decorators, target, key, desc) {
5084
+ import { BadRequestException as BadRequestException6, Body as Body5, Controller as Controller12, Inject as Inject20, Post as Post6, Req as Req11 } from "@nestjs/common";
5085
+ function _ts_decorate22(decorators, target, key, desc) {
4599
5086
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4600
5087
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4601
5088
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4608,19 +5095,19 @@ function _ts_decorate20(decorators, target, key, desc) {
4608
5095
  }
4609
5096
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4610
5097
  }
4611
- __name(_ts_decorate20, "_ts_decorate");
4612
- function _ts_metadata19(metadataKey, metadataValue) {
5098
+ __name(_ts_decorate22, "_ts_decorate");
5099
+ function _ts_metadata20(metadataKey, metadataValue) {
4613
5100
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4614
5101
  return Reflect.metadata(metadataKey, metadataValue);
4615
5102
  }
4616
5103
  }
4617
- __name(_ts_metadata19, "_ts_metadata");
4618
- function _ts_param18(paramIndex, decorator) {
5104
+ __name(_ts_metadata20, "_ts_metadata");
5105
+ function _ts_param20(paramIndex, decorator) {
4619
5106
  return function(target, key) {
4620
5107
  decorator(target, key, paramIndex);
4621
5108
  };
4622
5109
  }
4623
- __name(_ts_param18, "_ts_param");
5110
+ __name(_ts_param20, "_ts_param");
4624
5111
  var MAX_ANSWERED_QUESTIONS = 100;
4625
5112
  var MAX_VALUES_PER_QUESTION = 100;
4626
5113
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -4753,55 +5240,55 @@ var ToolCallController = class {
4753
5240
  };
4754
5241
  }
4755
5242
  };
4756
- _ts_decorate20([
5243
+ _ts_decorate22([
4757
5244
  Post6("approve"),
4758
- _ts_param18(0, Req11()),
4759
- _ts_param18(1, Body5()),
4760
- _ts_metadata19("design:type", Function),
4761
- _ts_metadata19("design:paramtypes", [
5245
+ _ts_param20(0, Req11()),
5246
+ _ts_param20(1, Body5()),
5247
+ _ts_metadata20("design:type", Function),
5248
+ _ts_metadata20("design:paramtypes", [
4762
5249
  typeof Request === "undefined" ? Object : Request,
4763
5250
  typeof ApproveBody === "undefined" ? Object : ApproveBody
4764
5251
  ]),
4765
- _ts_metadata19("design:returntype", Promise)
5252
+ _ts_metadata20("design:returntype", Promise)
4766
5253
  ], ToolCallController.prototype, "approve", null);
4767
- _ts_decorate20([
5254
+ _ts_decorate22([
4768
5255
  Post6("reject"),
4769
- _ts_param18(0, Req11()),
4770
- _ts_param18(1, Body5()),
4771
- _ts_metadata19("design:type", Function),
4772
- _ts_metadata19("design:paramtypes", [
5256
+ _ts_param20(0, Req11()),
5257
+ _ts_param20(1, Body5()),
5258
+ _ts_metadata20("design:type", Function),
5259
+ _ts_metadata20("design:paramtypes", [
4773
5260
  typeof Request === "undefined" ? Object : Request,
4774
5261
  typeof RejectBody === "undefined" ? Object : RejectBody
4775
5262
  ]),
4776
- _ts_metadata19("design:returntype", Promise)
5263
+ _ts_metadata20("design:returntype", Promise)
4777
5264
  ], ToolCallController.prototype, "reject", null);
4778
- _ts_decorate20([
5265
+ _ts_decorate22([
4779
5266
  Post6("answer"),
4780
- _ts_param18(0, Req11()),
4781
- _ts_param18(1, Body5()),
4782
- _ts_metadata19("design:type", Function),
4783
- _ts_metadata19("design:paramtypes", [
5267
+ _ts_param20(0, Req11()),
5268
+ _ts_param20(1, Body5()),
5269
+ _ts_metadata20("design:type", Function),
5270
+ _ts_metadata20("design:paramtypes", [
4784
5271
  typeof Request === "undefined" ? Object : Request,
4785
5272
  typeof AnswerBody === "undefined" ? Object : AnswerBody
4786
5273
  ]),
4787
- _ts_metadata19("design:returntype", Promise)
5274
+ _ts_metadata20("design:returntype", Promise)
4788
5275
  ], ToolCallController.prototype, "answer", null);
4789
- _ts_decorate20([
5276
+ _ts_decorate22([
4790
5277
  Post6("skip"),
4791
- _ts_param18(0, Req11()),
4792
- _ts_param18(1, Body5()),
4793
- _ts_metadata19("design:type", Function),
4794
- _ts_metadata19("design:paramtypes", [
5278
+ _ts_param20(0, Req11()),
5279
+ _ts_param20(1, Body5()),
5280
+ _ts_metadata20("design:type", Function),
5281
+ _ts_metadata20("design:paramtypes", [
4795
5282
  typeof Request === "undefined" ? Object : Request,
4796
5283
  Object
4797
5284
  ]),
4798
- _ts_metadata19("design:returntype", Promise)
5285
+ _ts_metadata20("design:returntype", Promise)
4799
5286
  ], ToolCallController.prototype, "skip", null);
4800
- ToolCallController = _ts_decorate20([
5287
+ ToolCallController = _ts_decorate22([
4801
5288
  Controller12("tool-call"),
4802
- _ts_param18(1, Inject18(AGENT_ACTOR_RESOLVER11)),
4803
- _ts_metadata19("design:type", Function),
4804
- _ts_metadata19("design:paramtypes", [
5289
+ _ts_param20(1, Inject20(AGENT_ACTOR_RESOLVER11)),
5290
+ _ts_metadata20("design:type", Function),
5291
+ _ts_metadata20("design:paramtypes", [
4805
5292
  typeof AgentService === "undefined" ? Object : AgentService,
4806
5293
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4807
5294
  ])
@@ -4809,8 +5296,8 @@ ToolCallController = _ts_decorate20([
4809
5296
 
4810
5297
  // src/controller/tools.controller.ts
4811
5298
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_REGISTRY as AGENT_REGISTRY3, ALL_AGENTS, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
4812
- import { Controller as Controller13, Get as Get11, Inject as Inject19, NotFoundException as NotFoundException3, Query as Query5, Req as Req12 } from "@nestjs/common";
4813
- function _ts_decorate21(decorators, target, key, desc) {
5299
+ import { Controller as Controller13, Get as Get11, Inject as Inject21, NotFoundException as NotFoundException4, Query as Query5, Req as Req12 } from "@nestjs/common";
5300
+ function _ts_decorate23(decorators, target, key, desc) {
4814
5301
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4815
5302
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4816
5303
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4823,19 +5310,19 @@ function _ts_decorate21(decorators, target, key, desc) {
4823
5310
  }
4824
5311
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4825
5312
  }
4826
- __name(_ts_decorate21, "_ts_decorate");
4827
- function _ts_metadata20(metadataKey, metadataValue) {
5313
+ __name(_ts_decorate23, "_ts_decorate");
5314
+ function _ts_metadata21(metadataKey, metadataValue) {
4828
5315
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4829
5316
  return Reflect.metadata(metadataKey, metadataValue);
4830
5317
  }
4831
5318
  }
4832
- __name(_ts_metadata20, "_ts_metadata");
4833
- function _ts_param19(paramIndex, decorator) {
5319
+ __name(_ts_metadata21, "_ts_metadata");
5320
+ function _ts_param21(paramIndex, decorator) {
4834
5321
  return function(target, key) {
4835
5322
  decorator(target, key, paramIndex);
4836
5323
  };
4837
5324
  }
4838
- __name(_ts_param19, "_ts_param");
5325
+ __name(_ts_param21, "_ts_param");
4839
5326
  var ToolsController = class {
4840
5327
  static {
4841
5328
  __name(this, "ToolsController");
@@ -4850,7 +5337,7 @@ var ToolsController = class {
4850
5337
  }
4851
5338
  async list(req, agent) {
4852
5339
  if (agent !== void 0 && agent !== ALL_AGENTS && this.agents.get(agent) === void 0) {
4853
- throw new NotFoundException3(`No agent named "${agent}"`);
5340
+ throw new NotFoundException4(`No agent named "${agent}"`);
4854
5341
  }
4855
5342
  const actor = await this.actorResolver.resolve(req);
4856
5343
  const names = agent === ALL_AGENTS ? [
@@ -4879,24 +5366,24 @@ var ToolsController = class {
4879
5366
  ];
4880
5367
  }
4881
5368
  };
4882
- _ts_decorate21([
5369
+ _ts_decorate23([
4883
5370
  Get11(),
4884
- _ts_param19(0, Req12()),
4885
- _ts_param19(1, Query5("agent")),
4886
- _ts_metadata20("design:type", Function),
4887
- _ts_metadata20("design:paramtypes", [
5371
+ _ts_param21(0, Req12()),
5372
+ _ts_param21(1, Query5("agent")),
5373
+ _ts_metadata21("design:type", Function),
5374
+ _ts_metadata21("design:paramtypes", [
4888
5375
  typeof Request === "undefined" ? Object : Request,
4889
5376
  String
4890
5377
  ]),
4891
- _ts_metadata20("design:returntype", Promise)
5378
+ _ts_metadata21("design:returntype", Promise)
4892
5379
  ], ToolsController.prototype, "list", null);
4893
- ToolsController = _ts_decorate21([
5380
+ ToolsController = _ts_decorate23([
4894
5381
  Controller13("tools"),
4895
- _ts_param19(0, Inject19(AGENT_ACTOR_RESOLVER12)),
4896
- _ts_param19(1, Inject19(AGENT_DEPS_FACTORY6)),
4897
- _ts_param19(2, Inject19(AGENT_REGISTRY3)),
4898
- _ts_metadata20("design:type", Function),
4899
- _ts_metadata20("design:paramtypes", [
5382
+ _ts_param21(0, Inject21(AGENT_ACTOR_RESOLVER12)),
5383
+ _ts_param21(1, Inject21(AGENT_DEPS_FACTORY6)),
5384
+ _ts_param21(2, Inject21(AGENT_REGISTRY3)),
5385
+ _ts_metadata21("design:type", Function),
5386
+ _ts_metadata21("design:paramtypes", [
4900
5387
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4901
5388
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
4902
5389
  typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
@@ -4905,7 +5392,7 @@ ToolsController = _ts_decorate21([
4905
5392
 
4906
5393
  // src/discovery/agent-discovery.service.ts
4907
5394
  import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
4908
- import { Inject as Inject20, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
5395
+ import { Inject as Inject22, Injectable as Injectable9, Logger as Logger4 } from "@nestjs/common";
4909
5396
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
4910
5397
 
4911
5398
  // src/decorator/agent.decorator.ts
@@ -4922,7 +5409,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
4922
5409
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
4923
5410
 
4924
5411
  // src/discovery/agent-discovery.service.ts
4925
- function _ts_decorate22(decorators, target, key, desc) {
5412
+ function _ts_decorate24(decorators, target, key, desc) {
4926
5413
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4927
5414
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4928
5415
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4935,19 +5422,19 @@ function _ts_decorate22(decorators, target, key, desc) {
4935
5422
  }
4936
5423
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4937
5424
  }
4938
- __name(_ts_decorate22, "_ts_decorate");
4939
- function _ts_metadata21(metadataKey, metadataValue) {
5425
+ __name(_ts_decorate24, "_ts_decorate");
5426
+ function _ts_metadata22(metadataKey, metadataValue) {
4940
5427
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4941
5428
  return Reflect.metadata(metadataKey, metadataValue);
4942
5429
  }
4943
5430
  }
4944
- __name(_ts_metadata21, "_ts_metadata");
4945
- function _ts_param20(paramIndex, decorator) {
5431
+ __name(_ts_metadata22, "_ts_metadata");
5432
+ function _ts_param22(paramIndex, decorator) {
4946
5433
  return function(target, key) {
4947
5434
  decorator(target, key, paramIndex);
4948
5435
  };
4949
5436
  }
4950
- __name(_ts_param20, "_ts_param");
5437
+ __name(_ts_param22, "_ts_param");
4951
5438
  var AgentDiscoveryService = class _AgentDiscoveryService {
4952
5439
  static {
4953
5440
  __name(this, "AgentDiscoveryService");
@@ -5113,12 +5600,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
5113
5600
  return (ctx) => candidate.call(instance, ctx);
5114
5601
  }
5115
5602
  };
5116
- AgentDiscoveryService = _ts_decorate22([
5117
- Injectable8(),
5118
- _ts_param20(2, Inject20(AGENT_REGISTRY4)),
5119
- _ts_param20(3, Inject20(AGENT_PROMPT_CONTRIBUTORS2)),
5120
- _ts_metadata21("design:type", Function),
5121
- _ts_metadata21("design:paramtypes", [
5603
+ AgentDiscoveryService = _ts_decorate24([
5604
+ Injectable9(),
5605
+ _ts_param22(2, Inject22(AGENT_REGISTRY4)),
5606
+ _ts_param22(3, Inject22(AGENT_PROMPT_CONTRIBUTORS2)),
5607
+ _ts_metadata22("design:type", Function),
5608
+ _ts_metadata22("design:paramtypes", [
5122
5609
  typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
5123
5610
  typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
5124
5611
  typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
@@ -5127,8 +5614,8 @@ AgentDiscoveryService = _ts_decorate22([
5127
5614
  ], AgentDiscoveryService);
5128
5615
 
5129
5616
  // src/discovery/ai-tool-discovery.service.ts
5130
- 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";
5131
- import { Inject as Inject21, Injectable as Injectable9, Logger as Logger5 } from "@nestjs/common";
5617
+ 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";
5618
+ import { Inject as Inject23, Injectable as Injectable10, Logger as Logger5 } from "@nestjs/common";
5132
5619
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
5133
5620
  import { z } from "zod";
5134
5621
 
@@ -5140,15 +5627,8 @@ function readAiToolMetadata(target) {
5140
5627
  }
5141
5628
  __name(readAiToolMetadata, "readAiToolMetadata");
5142
5629
 
5143
- // src/functional-tool.ts
5144
- var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
5145
- function isBrandedFunctionalTool(value) {
5146
- return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
5147
- }
5148
- __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
5149
-
5150
5630
  // src/discovery/ai-tool-discovery.service.ts
5151
- function _ts_decorate23(decorators, target, key, desc) {
5631
+ function _ts_decorate25(decorators, target, key, desc) {
5152
5632
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5153
5633
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5154
5634
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5161,19 +5641,19 @@ function _ts_decorate23(decorators, target, key, desc) {
5161
5641
  }
5162
5642
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5163
5643
  }
5164
- __name(_ts_decorate23, "_ts_decorate");
5165
- function _ts_metadata22(metadataKey, metadataValue) {
5644
+ __name(_ts_decorate25, "_ts_decorate");
5645
+ function _ts_metadata23(metadataKey, metadataValue) {
5166
5646
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5167
5647
  return Reflect.metadata(metadataKey, metadataValue);
5168
5648
  }
5169
5649
  }
5170
- __name(_ts_metadata22, "_ts_metadata");
5171
- function _ts_param21(paramIndex, decorator) {
5650
+ __name(_ts_metadata23, "_ts_metadata");
5651
+ function _ts_param23(paramIndex, decorator) {
5172
5652
  return function(target, key) {
5173
5653
  decorator(target, key, paramIndex);
5174
5654
  };
5175
5655
  }
5176
- __name(_ts_param21, "_ts_param");
5656
+ __name(_ts_param23, "_ts_param");
5177
5657
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
5178
5658
  static {
5179
5659
  __name(this, "AiToolDiscoveryService");
@@ -5241,9 +5721,15 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
5241
5721
  } : {},
5242
5722
  ...meta.terminal === true ? {
5243
5723
  terminal: true
5724
+ } : {},
5725
+ ...meta.replacementKey !== void 0 ? {
5726
+ replacementKey: meta.replacementKey
5244
5727
  } : {}
5245
5728
  }, {
5246
5729
  execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
5730
+ ...typeof handler.preflight === "function" ? {
5731
+ preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
5732
+ } : {},
5247
5733
  // Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
5248
5734
  // `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
5249
5735
  // Called through `instance` so each keeps its `this` (and its injected deps).
@@ -5317,13 +5803,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
5317
5803
  return true;
5318
5804
  }
5319
5805
  };
5320
- AiToolDiscoveryService = _ts_decorate23([
5321
- Injectable9(),
5322
- _ts_param21(1, Inject21(AGENT_TOOL_REGISTRY2)),
5323
- _ts_param21(2, Inject21(AGENT_REGISTRY5)),
5324
- _ts_param21(3, Inject21(AGENT_OPTIONS6)),
5325
- _ts_metadata22("design:type", Function),
5326
- _ts_metadata22("design:paramtypes", [
5806
+ AiToolDiscoveryService = _ts_decorate25([
5807
+ Injectable10(),
5808
+ _ts_param23(1, Inject23(AGENT_TOOL_REGISTRY2)),
5809
+ _ts_param23(2, Inject23(AGENT_REGISTRY5)),
5810
+ _ts_param23(3, Inject23(AGENT_OPTIONS7)),
5811
+ _ts_metadata23("design:type", Function),
5812
+ _ts_metadata23("design:paramtypes", [
5327
5813
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
5328
5814
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
5329
5815
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -5333,7 +5819,7 @@ AiToolDiscoveryService = _ts_decorate23([
5333
5819
 
5334
5820
  // src/discovery/skill-discovery.service.ts
5335
5821
  import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
5336
- import { Inject as Inject22, Injectable as Injectable10, Logger as Logger6 } from "@nestjs/common";
5822
+ import { Inject as Inject24, Injectable as Injectable11, Logger as Logger6 } from "@nestjs/common";
5337
5823
  import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
5338
5824
 
5339
5825
  // src/decorator/skill.decorator.ts
@@ -5350,7 +5836,7 @@ function skillScope(options) {
5350
5836
  __name(skillScope, "skillScope");
5351
5837
 
5352
5838
  // src/discovery/skill-discovery.service.ts
5353
- function _ts_decorate24(decorators, target, key, desc) {
5839
+ function _ts_decorate26(decorators, target, key, desc) {
5354
5840
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5355
5841
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5356
5842
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5363,19 +5849,19 @@ function _ts_decorate24(decorators, target, key, desc) {
5363
5849
  }
5364
5850
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5365
5851
  }
5366
- __name(_ts_decorate24, "_ts_decorate");
5367
- function _ts_metadata23(metadataKey, metadataValue) {
5852
+ __name(_ts_decorate26, "_ts_decorate");
5853
+ function _ts_metadata24(metadataKey, metadataValue) {
5368
5854
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5369
5855
  return Reflect.metadata(metadataKey, metadataValue);
5370
5856
  }
5371
5857
  }
5372
- __name(_ts_metadata23, "_ts_metadata");
5373
- function _ts_param22(paramIndex, decorator) {
5858
+ __name(_ts_metadata24, "_ts_metadata");
5859
+ function _ts_param24(paramIndex, decorator) {
5374
5860
  return function(target, key) {
5375
5861
  decorator(target, key, paramIndex);
5376
5862
  };
5377
5863
  }
5378
- __name(_ts_param22, "_ts_param");
5864
+ __name(_ts_param24, "_ts_param");
5379
5865
  var SkillDiscoveryService = class _SkillDiscoveryService {
5380
5866
  static {
5381
5867
  __name(this, "SkillDiscoveryService");
@@ -5419,11 +5905,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
5419
5905
  return flat === void 0 ? void 0 : () => flat;
5420
5906
  }
5421
5907
  };
5422
- SkillDiscoveryService = _ts_decorate24([
5423
- Injectable10(),
5424
- _ts_param22(1, Inject22(AGENT_SKILL_SOURCES)),
5425
- _ts_metadata23("design:type", Function),
5426
- _ts_metadata23("design:paramtypes", [
5908
+ SkillDiscoveryService = _ts_decorate26([
5909
+ Injectable11(),
5910
+ _ts_param24(1, Inject24(AGENT_SKILL_SOURCES)),
5911
+ _ts_metadata24("design:type", Function),
5912
+ _ts_metadata24("design:paramtypes", [
5427
5913
  typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
5428
5914
  Array
5429
5915
  ])
@@ -5491,10 +5977,245 @@ var LedgerQuotaProvider = class {
5491
5977
  }
5492
5978
  };
5493
5979
 
5980
+ // src/proposals/action-proposal-worker.service.ts
5981
+ import { randomUUID as randomUUID2 } from "crypto";
5982
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_STORE as AGENT_STORE7, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
5983
+ import { Inject as Inject25, Injectable as Injectable12, Logger as Logger7 } from "@nestjs/common";
5984
+ function _ts_decorate27(decorators, target, key, desc) {
5985
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5986
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5987
+ r = Reflect.decorate(decorators, target, key, desc);
5988
+ } else {
5989
+ for (var i = decorators.length - 1; i >= 0; i--) {
5990
+ if (d = decorators[i]) {
5991
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5992
+ }
5993
+ }
5994
+ }
5995
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5996
+ }
5997
+ __name(_ts_decorate27, "_ts_decorate");
5998
+ function _ts_metadata25(metadataKey, metadataValue) {
5999
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
6000
+ return Reflect.metadata(metadataKey, metadataValue);
6001
+ }
6002
+ }
6003
+ __name(_ts_metadata25, "_ts_metadata");
6004
+ function _ts_param25(paramIndex, decorator) {
6005
+ return function(target, key) {
6006
+ decorator(target, key, paramIndex);
6007
+ };
6008
+ }
6009
+ __name(_ts_param25, "_ts_param");
6010
+ var ActionProposalWorkerService = class _ActionProposalWorkerService {
6011
+ static {
6012
+ __name(this, "ActionProposalWorkerService");
6013
+ }
6014
+ store;
6015
+ options;
6016
+ deps;
6017
+ worker;
6018
+ logger = new Logger7(_ActionProposalWorkerService.name);
6019
+ constructor(store, options, deps) {
6020
+ this.store = store;
6021
+ this.options = options;
6022
+ this.deps = deps;
6023
+ }
6024
+ onModuleInit() {
6025
+ if (this.options.actionApprovalMode !== "independent") return;
6026
+ assertIndependentActionCapabilities2(this.store, this.options.backgroundActorResolver);
6027
+ if (this.options.surface === "http") return;
6028
+ const resolver = this.options.backgroundActorResolver;
6029
+ if (!resolver) throw new Error("BackgroundActorResolver is required");
6030
+ this.worker = new ActionProposalWorker({
6031
+ store: this.store,
6032
+ workerId: randomUUID2(),
6033
+ ...this.options.actionProposalWorker,
6034
+ executor: new ActionProposalExecutor({
6035
+ resolver,
6036
+ resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
6037
+ const deps = this.deps.forProposal(proposal, actor);
6038
+ return {
6039
+ registry: deps.registry,
6040
+ rolesPolicy: deps.rolesPolicy,
6041
+ ...deps.resolveUiCatalog !== void 0 ? {
6042
+ resolveUiCatalog: deps.resolveUiCatalog
6043
+ } : {},
6044
+ ...deps.toolAllowList !== void 0 ? {
6045
+ allowedTools: deps.toolAllowList
6046
+ } : {}
6047
+ };
6048
+ }, "resolveExecution")
6049
+ }),
6050
+ onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
6051
+ });
6052
+ this.worker.start();
6053
+ }
6054
+ async onModuleDestroy() {
6055
+ await this.worker?.stop();
6056
+ }
6057
+ };
6058
+ ActionProposalWorkerService = _ts_decorate27([
6059
+ Injectable12(),
6060
+ _ts_param25(0, Inject25(AGENT_STORE7)),
6061
+ _ts_param25(1, Inject25(AGENT_OPTIONS8)),
6062
+ _ts_param25(2, Inject25(AGENT_DEPS_FACTORY7)),
6063
+ _ts_metadata25("design:type", Function),
6064
+ _ts_metadata25("design:paramtypes", [
6065
+ typeof AgentStore === "undefined" ? Object : AgentStore,
6066
+ typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
6067
+ typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
6068
+ ])
6069
+ ], ActionProposalWorkerService);
6070
+
6071
+ // src/proposals/action-proposal.controller.ts
6072
+ import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, validateActionProposalListQuery } from "@dudousxd/nestjs-agent-core";
6073
+ import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as Inject26, Param as Param6, Post as Post7, Query as Query6, Req as Req13, Res as Res2 } from "@nestjs/common";
6074
+ function _ts_decorate28(decorators, target, key, desc) {
6075
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6076
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
6077
+ r = Reflect.decorate(decorators, target, key, desc);
6078
+ } else {
6079
+ for (var i = decorators.length - 1; i >= 0; i--) {
6080
+ if (d = decorators[i]) {
6081
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6082
+ }
6083
+ }
6084
+ }
6085
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6086
+ }
6087
+ __name(_ts_decorate28, "_ts_decorate");
6088
+ function _ts_metadata26(metadataKey, metadataValue) {
6089
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
6090
+ return Reflect.metadata(metadataKey, metadataValue);
6091
+ }
6092
+ }
6093
+ __name(_ts_metadata26, "_ts_metadata");
6094
+ function _ts_param26(paramIndex, decorator) {
6095
+ return function(target, key) {
6096
+ decorator(target, key, paramIndex);
6097
+ };
6098
+ }
6099
+ __name(_ts_param26, "_ts_param");
6100
+ function bodyFields(body, field) {
6101
+ if (body === void 0) return {};
6102
+ if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field)) throw new BadRequestException7(`Only ${field} is accepted`);
6103
+ const value = body;
6104
+ if (value[field] !== void 0 && (field === "remember" && typeof value[field] !== "boolean" || field === "reason" && typeof value[field] !== "string")) throw new BadRequestException7(`Invalid ${field}`);
6105
+ return value;
6106
+ }
6107
+ __name(bodyFields, "bodyFields");
6108
+ var ActionProposalController = class {
6109
+ static {
6110
+ __name(this, "ActionProposalController");
6111
+ }
6112
+ proposals;
6113
+ actors;
6114
+ constructor(proposals, actors) {
6115
+ this.proposals = proposals;
6116
+ this.actors = actors;
6117
+ }
6118
+ async list(threadId, request, cursor, response) {
6119
+ let query = {};
6120
+ if (cursor !== void 0) {
6121
+ try {
6122
+ if (typeof cursor !== "string") throw new Error("Invalid cursor");
6123
+ query = {
6124
+ after: JSON.parse(cursor)
6125
+ };
6126
+ validateActionProposalListQuery(query);
6127
+ } catch {
6128
+ throw new BadRequestException7("Invalid action proposal cursor");
6129
+ }
6130
+ }
6131
+ const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
6132
+ if (page.next) {
6133
+ response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
6134
+ const exposed = response.getHeader("Access-Control-Expose-Headers");
6135
+ response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
6136
+ }
6137
+ return page.items;
6138
+ }
6139
+ async approve(threadId, proposalId, request, body) {
6140
+ const value = bodyFields(body, "remember");
6141
+ return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
6142
+ decision: "approved",
6143
+ ...typeof value.remember === "boolean" ? {
6144
+ remember: value.remember
6145
+ } : {}
6146
+ });
6147
+ }
6148
+ async reject(threadId, proposalId, request, body) {
6149
+ const value = bodyFields(body, "reason");
6150
+ return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
6151
+ decision: "rejected",
6152
+ ...typeof value.reason === "string" ? {
6153
+ reason: value.reason
6154
+ } : {}
6155
+ });
6156
+ }
6157
+ };
6158
+ _ts_decorate28([
6159
+ Get12(),
6160
+ _ts_param26(0, Param6("threadId")),
6161
+ _ts_param26(1, Req13()),
6162
+ _ts_param26(2, Query6("after")),
6163
+ _ts_param26(3, Res2({
6164
+ passthrough: true
6165
+ })),
6166
+ _ts_metadata26("design:type", Function),
6167
+ _ts_metadata26("design:paramtypes", [
6168
+ String,
6169
+ typeof Request === "undefined" ? Object : Request,
6170
+ Object,
6171
+ typeof Response === "undefined" ? Object : Response
6172
+ ]),
6173
+ _ts_metadata26("design:returntype", Promise)
6174
+ ], ActionProposalController.prototype, "list", null);
6175
+ _ts_decorate28([
6176
+ Post7(":proposalId/approve"),
6177
+ _ts_param26(0, Param6("threadId")),
6178
+ _ts_param26(1, Param6("proposalId")),
6179
+ _ts_param26(2, Req13()),
6180
+ _ts_param26(3, Body6()),
6181
+ _ts_metadata26("design:type", Function),
6182
+ _ts_metadata26("design:paramtypes", [
6183
+ String,
6184
+ String,
6185
+ typeof Request === "undefined" ? Object : Request,
6186
+ Object
6187
+ ]),
6188
+ _ts_metadata26("design:returntype", Promise)
6189
+ ], ActionProposalController.prototype, "approve", null);
6190
+ _ts_decorate28([
6191
+ Post7(":proposalId/reject"),
6192
+ _ts_param26(0, Param6("threadId")),
6193
+ _ts_param26(1, Param6("proposalId")),
6194
+ _ts_param26(2, Req13()),
6195
+ _ts_param26(3, Body6()),
6196
+ _ts_metadata26("design:type", Function),
6197
+ _ts_metadata26("design:paramtypes", [
6198
+ String,
6199
+ String,
6200
+ typeof Request === "undefined" ? Object : Request,
6201
+ Object
6202
+ ]),
6203
+ _ts_metadata26("design:returntype", Promise)
6204
+ ], ActionProposalController.prototype, "reject", null);
6205
+ ActionProposalController = _ts_decorate28([
6206
+ Controller14("threads/:threadId/action-proposals"),
6207
+ _ts_param26(1, Inject26(AGENT_ACTOR_RESOLVER13)),
6208
+ _ts_metadata26("design:type", Function),
6209
+ _ts_metadata26("design:paramtypes", [
6210
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
6211
+ typeof ActorResolver === "undefined" ? Object : ActorResolver
6212
+ ])
6213
+ ], ActionProposalController);
6214
+
5494
6215
  // src/runner/inline-agent-runner.ts
5495
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL as RUN_ENDED_BEFORE_TOOL_CALL2, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent5, publishAgentRunFailed as publishAgentRunFailed2, releaseThreadRun as releaseThreadRun3, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation3, streamFailure as streamFailure3 } from "@dudousxd/nestjs-agent-core";
5496
- import { Inject as Inject23, Injectable as Injectable11, Logger as Logger7, Optional as Optional10 } from "@nestjs/common";
5497
- function _ts_decorate25(decorators, target, key, desc) {
6216
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY8, AGENT_STORE as AGENT_STORE8, RUN_ENDED_BEFORE_TOOL_CALL as RUN_ENDED_BEFORE_TOOL_CALL2, RunCancelledError as RunCancelledError2, agentFailureCode as agentFailureCode2, encodeStreamEvent as encodeStreamEvent5, publishAgentRunFailed as publishAgentRunFailed2, releaseThreadRun as releaseThreadRun3, runAgentLoop as runAgentLoop2, settleAll as settleAll2, settleUnsettledDelegation as settleUnsettledDelegation3, streamFailure as streamFailure3 } from "@dudousxd/nestjs-agent-core";
6217
+ import { Inject as Inject27, Injectable as Injectable13, Logger as Logger8, Optional as Optional11 } from "@nestjs/common";
6218
+ function _ts_decorate29(decorators, target, key, desc) {
5498
6219
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5499
6220
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5500
6221
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5507,19 +6228,19 @@ function _ts_decorate25(decorators, target, key, desc) {
5507
6228
  }
5508
6229
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5509
6230
  }
5510
- __name(_ts_decorate25, "_ts_decorate");
5511
- function _ts_metadata24(metadataKey, metadataValue) {
6231
+ __name(_ts_decorate29, "_ts_decorate");
6232
+ function _ts_metadata27(metadataKey, metadataValue) {
5512
6233
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5513
6234
  return Reflect.metadata(metadataKey, metadataValue);
5514
6235
  }
5515
6236
  }
5516
- __name(_ts_metadata24, "_ts_metadata");
5517
- function _ts_param23(paramIndex, decorator) {
6237
+ __name(_ts_metadata27, "_ts_metadata");
6238
+ function _ts_param27(paramIndex, decorator) {
5518
6239
  return function(target, key) {
5519
6240
  decorator(target, key, paramIndex);
5520
6241
  };
5521
6242
  }
5522
- __name(_ts_param23, "_ts_param");
6243
+ __name(_ts_param27, "_ts_param");
5523
6244
  var InlineAgentRunner = class _InlineAgentRunner {
5524
6245
  static {
5525
6246
  __name(this, "InlineAgentRunner");
@@ -5527,7 +6248,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5527
6248
  factory;
5528
6249
  store;
5529
6250
  queue;
5530
- logger = new Logger7(_InlineAgentRunner.name);
6251
+ logger = new Logger8(_InlineAgentRunner.name);
5531
6252
  pending = /* @__PURE__ */ new Map();
5532
6253
  /**
5533
6254
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -5970,13 +6691,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
5970
6691
  }
5971
6692
  }
5972
6693
  };
5973
- InlineAgentRunner = _ts_decorate25([
5974
- Injectable11(),
5975
- _ts_param23(0, Inject23(AGENT_DEPS_FACTORY7)),
5976
- _ts_param23(1, Inject23(AGENT_STORE6)),
5977
- _ts_param23(2, Optional10()),
5978
- _ts_metadata24("design:type", Function),
5979
- _ts_metadata24("design:paramtypes", [
6694
+ InlineAgentRunner = _ts_decorate29([
6695
+ Injectable13(),
6696
+ _ts_param27(0, Inject27(AGENT_DEPS_FACTORY8)),
6697
+ _ts_param27(1, Inject27(AGENT_STORE8)),
6698
+ _ts_param27(2, Optional11()),
6699
+ _ts_metadata27("design:type", Function),
6700
+ _ts_metadata27("design:paramtypes", [
5980
6701
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
5981
6702
  typeof AgentStore === "undefined" ? Object : AgentStore,
5982
6703
  typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
@@ -6026,7 +6747,7 @@ function resolveSkillsConfig(options, declared) {
6026
6747
  __name(resolveSkillsConfig, "resolveSkillsConfig");
6027
6748
 
6028
6749
  // src/agent.module.ts
6029
- function _ts_decorate26(decorators, target, key, desc) {
6750
+ function _ts_decorate30(decorators, target, key, desc) {
6030
6751
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6031
6752
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
6032
6753
  r = Reflect.decorate(decorators, target, key, desc);
@@ -6039,13 +6760,13 @@ function _ts_decorate26(decorators, target, key, desc) {
6039
6760
  }
6040
6761
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6041
6762
  }
6042
- __name(_ts_decorate26, "_ts_decorate");
6763
+ __name(_ts_decorate30, "_ts_decorate");
6043
6764
  var DEFAULT_PATH = "agent";
6044
- var logger = new Logger8("AgentModule");
6765
+ var logger = new Logger9("AgentModule");
6045
6766
  function externalStoreWrapper(modules) {
6046
6767
  for (const module of modules.values()) {
6047
6768
  if (module.metatype === AgentModule) continue;
6048
- const wrapper = module.providers.get(AGENT_STORE7);
6769
+ const wrapper = module.providers.get(AGENT_STORE9);
6049
6770
  if (wrapper !== void 0) return wrapper;
6050
6771
  }
6051
6772
  return void 0;
@@ -6118,7 +6839,7 @@ function sharedProviders(durable) {
6118
6839
  provide: AGENT_SKILLS3,
6119
6840
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
6120
6841
  inject: [
6121
- AGENT_OPTIONS7,
6842
+ AGENT_OPTIONS9,
6122
6843
  AGENT_SKILL_SOURCES2
6123
6844
  ]
6124
6845
  },
@@ -6128,39 +6849,39 @@ function sharedProviders(durable) {
6128
6849
  provide: AGENT_MEMORY3,
6129
6850
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
6130
6851
  inject: [
6131
- AGENT_OPTIONS7
6852
+ AGENT_OPTIONS9
6132
6853
  ]
6133
6854
  },
6134
6855
  {
6135
6856
  provide: AGENT_SINK4,
6136
6857
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
6137
6858
  inject: [
6138
- AGENT_OPTIONS7
6859
+ AGENT_OPTIONS9
6139
6860
  ]
6140
6861
  },
6141
6862
  {
6142
6863
  provide: AGENT_ROLES_POLICY2,
6143
6864
  useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new ClosedRolesPolicy(options.defaultRoles) : new DefaultRolesPolicy(options.defaultRoles)), "useFactory"),
6144
6865
  inject: [
6145
- AGENT_OPTIONS7
6866
+ AGENT_OPTIONS9
6146
6867
  ]
6147
6868
  },
6148
6869
  {
6149
- provide: AGENT_ACTOR_RESOLVER13,
6870
+ provide: AGENT_ACTOR_RESOLVER14,
6150
6871
  useFactory: /* @__PURE__ */ __name((options) => {
6151
6872
  if (options.actorResolver !== void 0) return options.actorResolver;
6152
6873
  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.");
6153
6874
  return new AnonymousActorResolver();
6154
6875
  }, "useFactory"),
6155
6876
  inject: [
6156
- AGENT_OPTIONS7
6877
+ AGENT_OPTIONS9
6157
6878
  ]
6158
6879
  },
6159
6880
  {
6160
6881
  provide: AGENT_MODEL2,
6161
6882
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
6162
6883
  inject: [
6163
- AGENT_OPTIONS7
6884
+ AGENT_OPTIONS9
6164
6885
  ]
6165
6886
  },
6166
6887
  {
@@ -6171,20 +6892,20 @@ function sharedProviders(durable) {
6171
6892
  warnAt: o.quota.warnAt
6172
6893
  } : {}), "useFactory"),
6173
6894
  inject: [
6174
- AGENT_OPTIONS7,
6175
- AGENT_STORE7
6895
+ AGENT_OPTIONS9,
6896
+ AGENT_STORE9
6176
6897
  ]
6177
6898
  },
6178
6899
  {
6179
6900
  provide: AGENT_MODEL_CATALOG3,
6180
6901
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
6181
6902
  inject: [
6182
- AGENT_OPTIONS7
6903
+ AGENT_OPTIONS9
6183
6904
  ]
6184
6905
  },
6185
6906
  AgentDepsFactory2,
6186
6907
  {
6187
- provide: AGENT_DEPS_FACTORY8,
6908
+ provide: AGENT_DEPS_FACTORY9,
6188
6909
  useExisting: AgentDepsFactory2
6189
6910
  },
6190
6911
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -6201,6 +6922,8 @@ function sharedProviders(durable) {
6201
6922
  },
6202
6923
  InlineAgentRunner,
6203
6924
  AgentService,
6925
+ ActionProposalService,
6926
+ ActionProposalWorkerService,
6204
6927
  // Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
6205
6928
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
6206
6929
  AgentApprovalPortAdapter,
@@ -6210,10 +6933,10 @@ function sharedProviders(durable) {
6210
6933
  }
6211
6934
  ];
6212
6935
  providers.push({
6213
- provide: AGENT_STORE7,
6936
+ provide: AGENT_STORE9,
6214
6937
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
6215
6938
  inject: [
6216
- AGENT_OPTIONS7,
6939
+ AGENT_OPTIONS9,
6217
6940
  ModulesContainer
6218
6941
  ]
6219
6942
  });
@@ -6244,22 +6967,24 @@ function sharedProviders(durable) {
6244
6967
  __name(sharedProviders, "sharedProviders");
6245
6968
  function exportsFor() {
6246
6969
  return [
6247
- AGENT_OPTIONS7,
6970
+ AGENT_OPTIONS9,
6248
6971
  AGENT_TOOL_REGISTRY3,
6249
6972
  AGENT_REGISTRY6,
6250
6973
  AGENT_SINK4,
6251
6974
  AGENT_ROLES_POLICY2,
6252
- AGENT_ACTOR_RESOLVER13,
6975
+ AGENT_ACTOR_RESOLVER14,
6253
6976
  AGENT_MODEL2,
6254
- AGENT_STORE7,
6977
+ AGENT_STORE9,
6255
6978
  AGENT_MODEL_CATALOG3,
6256
6979
  AGENT_QUOTA_PROVIDER3,
6257
6980
  AGENT_PROMPT_CONTRIBUTORS3,
6258
6981
  AGENT_SKILLS3,
6259
6982
  AGENT_MEMORY3,
6260
- AGENT_DEPS_FACTORY8,
6983
+ AGENT_DEPS_FACTORY9,
6261
6984
  AgentDepsFactory2,
6262
6985
  AgentService,
6986
+ ActionProposalService,
6987
+ ActionProposalWorkerService,
6263
6988
  ChatQueueService2,
6264
6989
  AGENT_CHAT_QUEUE,
6265
6990
  InlineAgentRunner,
@@ -6268,6 +6993,7 @@ function exportsFor() {
6268
6993
  }
6269
6994
  __name(exportsFor, "exportsFor");
6270
6995
  var BASE_CONTROLLERS = [
6996
+ ActionProposalController,
6271
6997
  ChatController,
6272
6998
  QueueController,
6273
6999
  ThreadsController,
@@ -6340,7 +7066,7 @@ var AgentModule = class _AgentModule {
6340
7066
  controllers: controllersForSurface(options.surface, options.adapters),
6341
7067
  providers: [
6342
7068
  {
6343
- provide: AGENT_OPTIONS7,
7069
+ provide: AGENT_OPTIONS9,
6344
7070
  useValue: options
6345
7071
  },
6346
7072
  ...sharedProviders(options.durable ?? false),
@@ -6364,7 +7090,7 @@ var AgentModule = class _AgentModule {
6364
7090
  controllers: controllersForSurface(options.surface, options.adapters),
6365
7091
  providers: [
6366
7092
  {
6367
- provide: AGENT_OPTIONS7,
7093
+ provide: AGENT_OPTIONS9,
6368
7094
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
6369
7095
  // authoritative on the async config object (they decided the actual wiring above), and
6370
7096
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -6386,9 +7112,9 @@ var AgentModule = class _AgentModule {
6386
7112
  };
6387
7113
  }
6388
7114
  };
6389
- AgentModule = _ts_decorate26([
7115
+ AgentModule = _ts_decorate30([
6390
7116
  Global2(),
6391
- Module2({})
7117
+ Module3({})
6392
7118
  ], AgentModule);
6393
7119
 
6394
7120
  // src/durable/agent-durable.ts