@dudousxd/nestjs-agent 1.19.3 → 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, 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
 
@@ -97,14 +99,24 @@ var AgentRunSteps = class {
97
99
  const tools = withMemoryTool({
98
100
  tools: withSkillTool({
99
101
  tools: withAskTool({
100
- tools: await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, deps.toolAllowList, {
101
- ...input.threadId !== void 0 ? {
102
- threadId: input.threadId
103
- } : {},
104
- ...input.agentName !== void 0 ? {
105
- agentName: input.agentName
106
- } : {}
107
- }),
102
+ tools: await deps.registry.definitionsFor(
103
+ input.actor,
104
+ deps.rolesPolicy,
105
+ // The persona narrowing the loop journaled in `persona:resolve` rides the envelope:
106
+ // this worker's own persona config may already say something else.
107
+ intersectAllowLists(deps.toolAllowList, input.personaAllowedTools),
108
+ {
109
+ ...input.threadId !== void 0 ? {
110
+ threadId: input.threadId
111
+ } : {},
112
+ ...input.preflightContext?.uiCapabilities !== void 0 ? {
113
+ uiCapabilities: input.preflightContext.uiCapabilities
114
+ } : {},
115
+ ...input.agentName !== void 0 ? {
116
+ agentName: input.agentName
117
+ } : {}
118
+ }
119
+ ),
108
120
  ask: deps.ask
109
121
  }),
110
122
  enabled: deps.skills !== void 0
@@ -130,6 +142,67 @@ var AgentRunSteps = class {
130
142
  } : {}
131
143
  })), frames.summary());
132
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
+ }
133
206
  return buffer === void 0 ? stamped : {
134
207
  ...stamped,
135
208
  bufferedFrames: buffer.frames()
@@ -155,7 +228,7 @@ var AgentRunSteps = class {
155
228
  }
156
229
  const sinkRunId = input.sinkRunId;
157
230
  let opened;
158
- 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) => {
159
232
  opened ??= Promise.resolve(deps.sink.open(sinkRunId)).then((writer) => input.childSink === true ? childSinkWriter(writer) : writer);
160
233
  await (await opened).write(encodeStreamEvent(event));
161
234
  });
@@ -171,25 +244,38 @@ var AgentRunSteps = class {
171
244
  classify: localClassify
172
245
  } : {}
173
246
  };
174
- const output = await traceToolExecution(input.ctx.runId, {
175
- toolCallId: input.toolCallId,
176
- toolName: input.toolName,
177
- toolType: input.toolType
178
- }, () => invokeWithTransientRetry(() => {
179
- ui.restart();
180
- const invocation = deps.registry.invoke(input.toolName, input.input, ctx, deps.rolesPolicy);
181
- return input.timeoutMs !== void 0 ? withToolTimeout(invocation, input.timeoutMs, input.toolName) : invocation;
182
- }, transientRetry, {
183
- onRetry: /* @__PURE__ */ __name((attempt, error) => {
184
- publishAgentToolRetry({
185
- toolName: input.toolName,
186
- toolCallId: input.toolCallId,
187
- attempt,
188
- 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
189
260
  });
190
- }, "onRetry")
191
- }));
192
- 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;
193
279
  }
194
280
  };
195
281
  _ts_decorate([
@@ -589,7 +675,7 @@ var AgentRunWorkflow = class _AgentRunWorkflow {
589
675
  });
590
676
  throw error;
591
677
  }
592
- if (isReplayIntegrityError(error)) {
678
+ if (isReplayIntegrityError2(error)) {
593
679
  const detail = error.message;
594
680
  const code2 = agentFailureCode(error);
595
681
  this.logger.error(`agent run ${ctx.runId} failed (${code2}): ${detail}`);
@@ -1085,14 +1171,44 @@ AgentDurableModule = _ts_decorate4([
1085
1171
  ], AgentDurableModule);
1086
1172
 
1087
1173
  // src/agent.module.ts
1088
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, 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";
1089
- 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";
1090
1176
  import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
1091
1177
 
1092
1178
  // src/agent-deps.factory.ts
1093
- 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, normalizeDelegation, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
1179
+ import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
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";
1094
1181
  import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
1095
- import { 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
1096
1212
  function _ts_decorate5(decorators, target, key, desc) {
1097
1213
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1098
1214
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -1107,6 +1223,124 @@ function _ts_decorate5(decorators, target, key, desc) {
1107
1223
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1108
1224
  }
1109
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");
1110
1344
  function _ts_metadata4(metadataKey, metadataValue) {
1111
1345
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1112
1346
  return Reflect.metadata(metadataKey, metadataValue);
@@ -1139,7 +1373,9 @@ var AgentDepsFactory2 = class {
1139
1373
  pricingStore;
1140
1374
  skills;
1141
1375
  memory;
1142
- 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) {
1143
1379
  this.options = options;
1144
1380
  this.model = model;
1145
1381
  this.store = store;
@@ -1151,6 +1387,9 @@ var AgentDepsFactory2 = class {
1151
1387
  this.pricingStore = pricingStore;
1152
1388
  this.skills = skills;
1153
1389
  this.memory = memory;
1390
+ this.uiCatalog = uiCatalog;
1391
+ this.uiCatalogResolver = uiCatalogResolver;
1392
+ if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
1154
1393
  }
1155
1394
  /** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
1156
1395
  memoryConfig() {
@@ -1190,8 +1429,76 @@ var AgentDepsFactory2 = class {
1190
1429
  ...delegated
1191
1430
  ];
1192
1431
  }
1432
+ /**
1433
+ * The agent a name stands for: itself when it is a registered agent (or unknown — the bare
1434
+ * assistant), else the agent whose persona took the name over (`Persona.aliases`) and that persona.
1435
+ */
1436
+ resolveAgent(name) {
1437
+ if (this.agents.has(name)) {
1438
+ return {
1439
+ agentName: name
1440
+ };
1441
+ }
1442
+ const alias = resolvePersonaAlias(this.agents.list(), name);
1443
+ return alias === void 0 ? {
1444
+ agentName: name
1445
+ } : {
1446
+ agentName: alias.agent,
1447
+ persona: alias.persona
1448
+ };
1449
+ }
1450
+ /** `agentName`'s personas as a picker reads them. Empty when it declares none. */
1451
+ personaCatalog(agentName) {
1452
+ return (this.agents.get(agentName)?.personas ?? []).map(personaCatalogEntry);
1453
+ }
1454
+ /** The persona `agentName` runs under when nothing names one. Undefined → none. */
1455
+ defaultPersona(agentName) {
1456
+ return this.agents.get(agentName)?.defaultPersona;
1457
+ }
1458
+ /**
1459
+ * The persona a turn of `agentName` runs under, most specific first: the one the send names
1460
+ * (refused with `400 persona_not_found` when the agent does not declare it), else the thread's
1461
+ * pinned one when this agent declares it, else the agent's default. Undefined → none.
1462
+ */
1463
+ resolvePersona(args) {
1464
+ const definition = this.agents.get(args.agentName);
1465
+ if (args.requested !== void 0) {
1466
+ if (findPersona(definition, args.requested) === void 0) {
1467
+ throw new BadRequestException({
1468
+ statusCode: 400,
1469
+ code: "persona_not_found",
1470
+ message: `agent "${args.agentName}" has no persona "${args.requested}"`
1471
+ });
1472
+ }
1473
+ return args.requested;
1474
+ }
1475
+ const pinned = args.threadPersona ?? void 0;
1476
+ if (pinned !== void 0 && findPersona(definition, pinned) !== void 0) {
1477
+ return pinned;
1478
+ }
1479
+ return definition?.defaultPersona;
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
+ }
1193
1493
  forAgent(agentName) {
1194
1494
  const name = agentName ?? this.defaultAgentName();
1495
+ if (agentName !== void 0 && !this.agents.has(agentName)) {
1496
+ const alias = resolvePersonaAlias(this.agents.list(), agentName);
1497
+ const persona = alias === void 0 ? void 0 : findPersona(this.agents.get(alias.agent), alias.persona);
1498
+ if (alias !== void 0 && persona !== void 0) {
1499
+ return this.withPersona(this.forAgent(alias.agent), persona);
1500
+ }
1501
+ }
1195
1502
  const definition = this.agents.get(name);
1196
1503
  const toolAllowList = this.effectiveTools(definition);
1197
1504
  const followUpsCount = this.followUpsCount();
@@ -1201,12 +1508,27 @@ var AgentDepsFactory2 = class {
1201
1508
  return {
1202
1509
  model: this.model,
1203
1510
  store: this.store,
1511
+ ...this.options.actionApprovalMode !== void 0 ? {
1512
+ actionApprovalMode: this.options.actionApprovalMode
1513
+ } : {},
1204
1514
  sink: this.sink,
1205
1515
  rolesPolicy: this.rolesPolicy,
1206
1516
  ...this.options.approvalPolicy !== void 0 ? {
1207
1517
  approvalPolicy: this.options.approvalPolicy
1208
1518
  } : {},
1209
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
+ } : {},
1210
1532
  promptContributors: this.promptContributors,
1211
1533
  systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
1212
1534
  maxSteps: definition?.maxSteps ?? 8,
@@ -1256,6 +1578,9 @@ var AgentDepsFactory2 = class {
1256
1578
  ...toolAllowList !== void 0 ? {
1257
1579
  toolAllowList
1258
1580
  } : {},
1581
+ ...definition?.personas !== void 0 ? {
1582
+ personas: definition.personas
1583
+ } : {},
1259
1584
  ...this.options.toolTimeoutMs !== void 0 ? {
1260
1585
  toolTimeoutMs: this.options.toolTimeoutMs
1261
1586
  } : {},
@@ -1274,6 +1599,45 @@ var AgentDepsFactory2 = class {
1274
1599
  };
1275
1600
  }
1276
1601
  /**
1602
+ * A persona baked into an agent's deps — how a run journaled under an agent name that a persona
1603
+ * has since taken over (`Persona.aliases`) is served. That run names no persona of its own (it
1604
+ * predates them, and its input cannot change), so the persona applies the way the old agent's own
1605
+ * config did: as config, re-read on every replay, with no checkpoint of its own.
1606
+ */
1607
+ withPersona(deps, persona) {
1608
+ const base = deps.systemPrompt;
1609
+ const ref = {
1610
+ id: persona.id,
1611
+ label: persona.label
1612
+ };
1613
+ const resolve = /* @__PURE__ */ __name(async (prompt, ctx) => typeof prompt === "function" ? prompt(ctx) : prompt, "resolve");
1614
+ const own = persona.systemPrompt;
1615
+ const systemPrompt = /* @__PURE__ */ __name(async (ctx) => {
1616
+ const scoped = {
1617
+ ...ctx,
1618
+ persona: ref
1619
+ };
1620
+ if (own === void 0) {
1621
+ return resolve(base, scoped);
1622
+ }
1623
+ const basePrompt = typeof own === "function" ? await resolve(base, scoped) : void 0;
1624
+ return resolve(own, {
1625
+ ...scoped,
1626
+ ...basePrompt !== void 0 ? {
1627
+ basePrompt
1628
+ } : {}
1629
+ });
1630
+ }, "systemPrompt");
1631
+ const toolAllowList = intersectAllowLists2(deps.toolAllowList, persona.allowedTools);
1632
+ return {
1633
+ ...deps,
1634
+ systemPrompt,
1635
+ ...toolAllowList !== void 0 ? {
1636
+ toolAllowList
1637
+ } : {}
1638
+ };
1639
+ }
1640
+ /**
1277
1641
  * The ceiling on how much of a thread this agent's turns carry, most specific wins: the agent's
1278
1642
  * own `@Agent({ history })`, else a module-wide custom `historyPolicy`, else the module-wide
1279
1643
  * `history` window. Undefined → unbounded, the behaviour of a module that configures none.
@@ -1315,22 +1679,25 @@ var AgentDepsFactory2 = class {
1315
1679
  return void 0;
1316
1680
  }
1317
1681
  };
1318
- AgentDepsFactory2 = _ts_decorate5([
1682
+ AgentDepsFactory2 = _ts_decorate6([
1319
1683
  Injectable4(),
1320
- _ts_param4(0, Inject4(AGENT_OPTIONS)),
1321
- _ts_param4(1, Inject4(AGENT_MODEL)),
1322
- _ts_param4(2, Inject4(AGENT_STORE3)),
1323
- _ts_param4(3, Inject4(AGENT_SINK2)),
1324
- _ts_param4(4, Inject4(AGENT_ROLES_POLICY)),
1325
- _ts_param4(5, Inject4(AGENT_TOOL_REGISTRY)),
1326
- _ts_param4(6, Inject4(AGENT_REGISTRY)),
1327
- _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)),
1328
1692
  _ts_param4(8, Optional3()),
1329
- _ts_param4(8, Inject4(AGENT_PRICING_STORE)),
1693
+ _ts_param4(8, Inject5(AGENT_PRICING_STORE)),
1330
1694
  _ts_param4(9, Optional3()),
1331
- _ts_param4(9, Inject4(AGENT_SKILLS)),
1695
+ _ts_param4(9, Inject5(AGENT_SKILLS)),
1332
1696
  _ts_param4(10, Optional3()),
1333
- _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()),
1334
1701
  _ts_metadata4("design:type", Function),
1335
1702
  _ts_metadata4("design:paramtypes", [
1336
1703
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
@@ -1343,18 +1710,20 @@ AgentDepsFactory2 = _ts_decorate5([
1343
1710
  Array,
1344
1711
  Object,
1345
1712
  Object,
1346
- Object
1713
+ Object,
1714
+ typeof Catalog === "undefined" ? Object : Catalog,
1715
+ typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
1347
1716
  ])
1348
1717
  ], AgentDepsFactory2);
1349
1718
 
1350
1719
  // src/agent.service.ts
1351
- import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, 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";
1352
- import { BadRequestException, 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";
1353
1722
 
1354
- // src/queue/chat-queue.service.ts
1355
- import { AGENT_ATTACHMENT_STAGING, 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";
1356
- import { Inject as Inject5, Injectable as Injectable5, Logger as Logger3, NotImplementedException, Optional as Optional4 } from "@nestjs/common";
1357
- function _ts_decorate6(decorators, target, key, desc) {
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) {
1358
1727
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1359
1728
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1360
1729
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1367,7 +1736,7 @@ function _ts_decorate6(decorators, target, key, desc) {
1367
1736
  }
1368
1737
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1369
1738
  }
1370
- __name(_ts_decorate6, "_ts_decorate");
1739
+ __name(_ts_decorate7, "_ts_decorate");
1371
1740
  function _ts_metadata5(metadataKey, metadataValue) {
1372
1741
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1373
1742
  return Reflect.metadata(metadataKey, metadataValue);
@@ -1380,6 +1749,168 @@ function _ts_param5(paramIndex, decorator) {
1380
1749
  };
1381
1750
  }
1382
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);
1872
+
1873
+ // src/queue/chat-queue.service.ts
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";
1876
+
1877
+ // src/thread-persona.ts
1878
+ async function threadPersona(store, threadId) {
1879
+ const projecting = store;
1880
+ if (typeof projecting.personaForThread === "function") {
1881
+ return projecting.personaForThread(threadId);
1882
+ }
1883
+ return (await store.getThread(threadId))?.persona ?? null;
1884
+ }
1885
+ __name(threadPersona, "threadPersona");
1886
+
1887
+ // src/queue/chat-queue.service.ts
1888
+ function _ts_decorate8(decorators, target, key, desc) {
1889
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1890
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1891
+ r = Reflect.decorate(decorators, target, key, desc);
1892
+ } else {
1893
+ for (var i = decorators.length - 1; i >= 0; i--) {
1894
+ if (d = decorators[i]) {
1895
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1896
+ }
1897
+ }
1898
+ }
1899
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1900
+ }
1901
+ __name(_ts_decorate8, "_ts_decorate");
1902
+ function _ts_metadata6(metadataKey, metadataValue) {
1903
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1904
+ return Reflect.metadata(metadataKey, metadataValue);
1905
+ }
1906
+ }
1907
+ __name(_ts_metadata6, "_ts_metadata");
1908
+ function _ts_param6(paramIndex, decorator) {
1909
+ return function(target, key) {
1910
+ decorator(target, key, paramIndex);
1911
+ };
1912
+ }
1913
+ __name(_ts_param6, "_ts_param");
1383
1914
  var MAX_DRAIN_ATTEMPTS = 8;
1384
1915
  var ChatQueueService2 = class _ChatQueueService {
1385
1916
  static {
@@ -1390,18 +1921,20 @@ var ChatQueueService2 = class _ChatQueueService {
1390
1921
  quotaProvider;
1391
1922
  options;
1392
1923
  staging;
1924
+ deps;
1393
1925
  logger = new Logger3(_ChatQueueService.name);
1394
1926
  /**
1395
1927
  * Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
1396
1928
  * alive whatever the runner says — it simply has not registered the run yet.
1397
1929
  */
1398
1930
  starting = /* @__PURE__ */ new Set();
1399
- constructor(store, sink, quotaProvider, options, staging) {
1931
+ constructor(store, sink, quotaProvider, options, staging, deps) {
1400
1932
  this.store = store;
1401
1933
  this.sink = sink;
1402
1934
  this.quotaProvider = quotaProvider;
1403
1935
  this.options = options;
1404
1936
  this.staging = staging;
1937
+ this.deps = deps;
1405
1938
  }
1406
1939
  /** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
1407
1940
  get supported() {
@@ -1410,7 +1943,7 @@ var ChatQueueService2 = class _ChatQueueService {
1410
1943
  /** The bound store as a queue store, or a 501 naming what is missing. */
1411
1944
  queueStore() {
1412
1945
  if (!isChatQueueStore(this.store)) {
1413
- 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.");
1414
1947
  }
1415
1948
  return this.store;
1416
1949
  }
@@ -1637,6 +2170,9 @@ var ChatQueueService2 = class _ChatQueueService {
1637
2170
  } : {},
1638
2171
  ...input.pageContext !== void 0 ? {
1639
2172
  pageContext: input.pageContext
2173
+ } : {},
2174
+ ...input.uiCapabilities !== void 0 ? {
2175
+ uiCapabilities: input.uiCapabilities
1640
2176
  } : {}
1641
2177
  });
1642
2178
  await store.setQueuePause(threadId, {
@@ -1699,13 +2235,17 @@ var ChatQueueService2 = class _ChatQueueService {
1699
2235
  */
1700
2236
  async inputFor(message) {
1701
2237
  const attachments = await this.freshAttachments(message.actor, message.attachments ?? []);
2238
+ const { agentName, persona } = await this.targetFor(message);
1702
2239
  return {
1703
2240
  threadId: message.threadId,
1704
2241
  actor: message.actor,
1705
2242
  userText: message.content,
1706
2243
  day: utcDay(),
1707
- ...message.agentName !== void 0 ? {
1708
- agentName: message.agentName
2244
+ ...agentName !== void 0 ? {
2245
+ agentName
2246
+ } : {},
2247
+ ...persona !== void 0 ? {
2248
+ persona
1709
2249
  } : {},
1710
2250
  ...attachments.length > 0 ? {
1711
2251
  attachments
@@ -1713,11 +2253,45 @@ var ChatQueueService2 = class _ChatQueueService {
1713
2253
  ...message.pageContext !== void 0 ? {
1714
2254
  pageContext: message.pageContext
1715
2255
  } : {},
2256
+ ...message.uiCapabilities !== void 0 ? {
2257
+ uiCapabilities: message.uiCapabilities
2258
+ } : {},
1716
2259
  ...message.model !== void 0 ? {
1717
2260
  model: message.model
1718
2261
  } : {}
1719
2262
  };
1720
2263
  }
2264
+ /**
2265
+ * The agent and persona a queued message starts as. A message carries the persona its send
2266
+ * resolved; one that carries none — queued before personas existed, or by a host that sets none —
2267
+ * resolves it now, exactly as a send would: an agent name a persona took over, then the thread's
2268
+ * pinned persona, then the agent's default. Never refused here: nobody is waiting on a 400.
2269
+ */
2270
+ async targetFor(message) {
2271
+ const deps = this.deps;
2272
+ if (message.persona !== void 0 || deps === void 0 || message.agentName === void 0) {
2273
+ return {
2274
+ ...message.agentName !== void 0 ? {
2275
+ agentName: message.agentName
2276
+ } : {},
2277
+ ...message.persona !== void 0 ? {
2278
+ persona: message.persona
2279
+ } : {}
2280
+ };
2281
+ }
2282
+ const target = deps.resolveAgent(message.agentName);
2283
+ const hasPersonas = deps.personaCatalog(target.agentName).length > 0;
2284
+ const persona = target.persona ?? (hasPersonas ? deps.resolvePersona({
2285
+ agentName: target.agentName,
2286
+ threadPersona: await threadPersona(this.store, message.threadId)
2287
+ }) : void 0);
2288
+ return {
2289
+ agentName: target.agentName,
2290
+ ...persona !== void 0 ? {
2291
+ persona
2292
+ } : {}
2293
+ };
2294
+ }
1721
2295
  async freshAttachments(actor, attachments) {
1722
2296
  const staging = this.staging;
1723
2297
  if (attachments.length === 0 || staging === void 0 || typeof staging.resolve !== "function") {
@@ -1735,23 +2309,26 @@ var ChatQueueService2 = class _ChatQueueService {
1735
2309
  }));
1736
2310
  }
1737
2311
  };
1738
- ChatQueueService2 = _ts_decorate6([
1739
- Injectable5(),
1740
- _ts_param5(0, Inject5(AGENT_STORE4)),
1741
- _ts_param5(1, Inject5(AGENT_SINK3)),
1742
- _ts_param5(2, Optional4()),
1743
- _ts_param5(2, Inject5(AGENT_QUOTA_PROVIDER)),
1744
- _ts_param5(3, Optional4()),
1745
- _ts_param5(3, Inject5(AGENT_OPTIONS2)),
1746
- _ts_param5(4, Optional4()),
1747
- _ts_param5(4, Inject5(AGENT_ATTACHMENT_STAGING)),
1748
- _ts_metadata5("design:type", Function),
1749
- _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", [
1750
2326
  typeof AgentStore === "undefined" ? Object : AgentStore,
1751
2327
  typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
1752
2328
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
1753
2329
  typeof Pick === "undefined" ? Object : Pick,
1754
- typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
2330
+ typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
2331
+ typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
1755
2332
  ])
1756
2333
  ], ChatQueueService2);
1757
2334
  function pauseReasonFor(outcome, head) {
@@ -1797,7 +2374,7 @@ var RunNotActiveException = class extends ConflictException {
1797
2374
  };
1798
2375
 
1799
2376
  // src/agent.service.ts
1800
- function _ts_decorate7(decorators, target, key, desc) {
2377
+ function _ts_decorate9(decorators, target, key, desc) {
1801
2378
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1802
2379
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1803
2380
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1810,19 +2387,19 @@ function _ts_decorate7(decorators, target, key, desc) {
1810
2387
  }
1811
2388
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1812
2389
  }
1813
- __name(_ts_decorate7, "_ts_decorate");
1814
- function _ts_metadata6(metadataKey, metadataValue) {
2390
+ __name(_ts_decorate9, "_ts_decorate");
2391
+ function _ts_metadata7(metadataKey, metadataValue) {
1815
2392
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1816
2393
  return Reflect.metadata(metadataKey, metadataValue);
1817
2394
  }
1818
2395
  }
1819
- __name(_ts_metadata6, "_ts_metadata");
1820
- function _ts_param6(paramIndex, decorator) {
2396
+ __name(_ts_metadata7, "_ts_metadata");
2397
+ function _ts_param7(paramIndex, decorator) {
1821
2398
  return function(target, key) {
1822
2399
  decorator(target, key, paramIndex);
1823
2400
  };
1824
2401
  }
1825
- __name(_ts_param6, "_ts_param");
2402
+ __name(_ts_param7, "_ts_param");
1826
2403
  var AgentService = class {
1827
2404
  static {
1828
2405
  __name(this, "AgentService");
@@ -1835,7 +2412,8 @@ var AgentService = class {
1835
2412
  quotaProvider;
1836
2413
  options;
1837
2414
  queue;
1838
- constructor(runner, store, deps, staging, models, quotaProvider, options, queue) {
2415
+ proposals;
2416
+ constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
1839
2417
  this.runner = runner;
1840
2418
  this.store = store;
1841
2419
  this.deps = deps;
@@ -1844,6 +2422,13 @@ var AgentService = class {
1844
2422
  this.quotaProvider = quotaProvider;
1845
2423
  this.options = options;
1846
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);
1847
2432
  }
1848
2433
  /** The queue service when the bound store can hold a queue, else `undefined`. */
1849
2434
  queueing() {
@@ -1853,7 +2438,7 @@ var AgentService = class {
1853
2438
  requireQueue() {
1854
2439
  const queue = this.queueing();
1855
2440
  if (queue === void 0) {
1856
- 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.");
1857
2442
  }
1858
2443
  return queue;
1859
2444
  }
@@ -1923,17 +2508,17 @@ var AgentService = class {
1923
2508
  */
1924
2509
  async assertModelAllowed(actor, agent, model) {
1925
2510
  if (this.models === void 0) {
1926
- throw new BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
2511
+ throw new BadRequestException2(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
1927
2512
  }
1928
2513
  const entry = findCatalogModel(await this.models.list({
1929
2514
  actor,
1930
2515
  agent
1931
2516
  }), model);
1932
2517
  if (entry === void 0) {
1933
- throw new BadRequestException(`model "${model}" is not offered`);
2518
+ throw new BadRequestException2(`model "${model}" is not offered`);
1934
2519
  }
1935
2520
  if (!entry.available) {
1936
- throw new BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
2521
+ throw new BadRequestException2(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
1937
2522
  }
1938
2523
  return entry.id;
1939
2524
  }
@@ -1949,7 +2534,7 @@ var AgentService = class {
1949
2534
  })).locked : void 0;
1950
2535
  if (locked !== void 0) {
1951
2536
  if (requested !== void 0 && requested !== locked.model) {
1952
- throw new BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
2537
+ throw new BadRequestException2(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
1953
2538
  }
1954
2539
  return locked.model;
1955
2540
  }
@@ -1975,7 +2560,10 @@ var AgentService = class {
1975
2560
  const result = await this.send({
1976
2561
  ...params,
1977
2562
  mode: "auto"
2563
+ }, {
2564
+ textDecisions: false
1978
2565
  });
2566
+ if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
1979
2567
  if (result.queued !== true) {
1980
2568
  return result;
1981
2569
  }
@@ -2003,15 +2591,21 @@ var AgentService = class {
2003
2591
  * Send a message: start a turn, or — when its thread already has one running — queue the message
2004
2592
  * to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
2005
2593
  */
2006
- 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
+ }
2007
2599
  await this.assertWithinQuota(params.actor);
2008
- const agentName = await this.resolveAgentName(params.agentName, params.threadId);
2600
+ const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
2601
+ const agentName = target.agentName;
2602
+ const persona = await this.resolvePersona(agentName, params.personaId ?? target.persona, params.threadId);
2009
2603
  const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
2010
2604
  const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
2011
2605
  let threadId = params.threadId;
2012
2606
  if (threadId === void 0) {
2013
2607
  if (params.regenerate === true) {
2014
- throw new BadRequestException("regenerate requires an existing threadId");
2608
+ throw new BadRequestException2("regenerate requires an existing threadId");
2015
2609
  }
2016
2610
  const created = await this.store.createThread({
2017
2611
  actor: params.actor,
@@ -2020,11 +2614,17 @@ var AgentService = class {
2020
2614
  } : {},
2021
2615
  ...params.newThreadId !== void 0 ? {
2022
2616
  id: params.newThreadId
2617
+ } : {},
2618
+ ...params.personaId !== void 0 ? {
2619
+ persona: params.personaId
2023
2620
  } : {}
2024
2621
  });
2025
2622
  threadId = created.id;
2026
2623
  } else {
2027
2624
  await this.assertOwnsThread(params.actor, threadId);
2625
+ if (params.personaId !== void 0) {
2626
+ await this.pinThreadPersona(threadId, params.personaId);
2627
+ }
2028
2628
  }
2029
2629
  const input = {
2030
2630
  threadId,
@@ -2032,6 +2632,9 @@ var AgentService = class {
2032
2632
  userText: params.message,
2033
2633
  day: utcDay(),
2034
2634
  agentName,
2635
+ ...persona !== void 0 ? {
2636
+ persona
2637
+ } : {},
2035
2638
  ...params.regenerate === true ? {
2036
2639
  regenerate: true
2037
2640
  } : {},
@@ -2041,12 +2644,16 @@ var AgentService = class {
2041
2644
  ...params.pageContext !== void 0 ? {
2042
2645
  pageContext: params.pageContext
2043
2646
  } : {},
2647
+ ...params.uiCapabilities !== void 0 ? {
2648
+ uiCapabilities: params.uiCapabilities
2649
+ } : {},
2044
2650
  ...model !== void 0 ? {
2045
2651
  model
2046
2652
  } : {}
2047
2653
  };
2048
2654
  const queue = this.queueing();
2049
2655
  if (queue === void 0) {
2656
+ if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
2050
2657
  const { runId } = await this.runner.start(input);
2051
2658
  await this.store.setActiveStream(threadId, runId);
2052
2659
  return {
@@ -2118,12 +2725,18 @@ var AgentService = class {
2118
2725
  ...input.agentName !== void 0 ? {
2119
2726
  agentName: input.agentName
2120
2727
  } : {},
2728
+ ...input.persona !== void 0 ? {
2729
+ persona: input.persona
2730
+ } : {},
2121
2731
  ...input.model !== void 0 ? {
2122
2732
  model: input.model
2123
2733
  } : {},
2124
2734
  ...input.pageContext !== void 0 ? {
2125
2735
  pageContext: input.pageContext
2126
2736
  } : {},
2737
+ ...input.uiCapabilities !== void 0 ? {
2738
+ uiCapabilities: input.uiCapabilities
2739
+ } : {},
2127
2740
  ...interrupting !== void 0 ? {
2128
2741
  interrupt: true,
2129
2742
  at: "head"
@@ -2170,7 +2783,7 @@ var AgentService = class {
2170
2783
  const store = queue.queueStore();
2171
2784
  const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
2172
2785
  if (patch.message !== void 0 && patch.message.trim().length === 0) {
2173
- throw new BadRequestException("message must not be empty");
2786
+ throw new BadRequestException2("message must not be empty");
2174
2787
  }
2175
2788
  const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
2176
2789
  if (patch.message !== void 0 || attachments !== void 0) {
@@ -2188,7 +2801,7 @@ var AgentService = class {
2188
2801
  }
2189
2802
  if (patch.position !== void 0) {
2190
2803
  if (!Number.isInteger(patch.position) || patch.position < 0) {
2191
- throw new BadRequestException("position must be a non-negative integer");
2804
+ throw new BadRequestException2("position must be a non-negative integer");
2192
2805
  }
2193
2806
  if (!await store.moveQueuedMessage(messageId, patch.position)) {
2194
2807
  throw new GoneException(`queued message ${messageId} already started or was removed`);
@@ -2228,7 +2841,7 @@ var AgentService = class {
2228
2841
  throw gone();
2229
2842
  }
2230
2843
  if (marked.interrupt !== true) {
2231
- 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.");
2232
2845
  }
2233
2846
  if (!await store.moveQueuedMessage(messageId, 0)) {
2234
2847
  throw gone();
@@ -2287,7 +2900,7 @@ var AgentService = class {
2287
2900
  async assertOwnsQueuedMessage(actor, messageId) {
2288
2901
  const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
2289
2902
  if (message === null) {
2290
- throw new NotFoundException(`queued message ${messageId} not found`);
2903
+ throw new NotFoundException2(`queued message ${messageId} not found`);
2291
2904
  }
2292
2905
  await this.assertOwnsThread(actor, message.threadId);
2293
2906
  return message.threadId;
@@ -2308,7 +2921,7 @@ var AgentService = class {
2308
2921
  }
2309
2922
  const staging = this.staging;
2310
2923
  if (staging === void 0 || typeof staging.resolve !== "function") {
2311
- 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.");
2312
2925
  }
2313
2926
  const resolved = [];
2314
2927
  for (const ref of refs) {
@@ -2317,7 +2930,7 @@ var AgentService = class {
2317
2930
  actor
2318
2931
  });
2319
2932
  if (attachment === null) {
2320
- 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`);
2321
2934
  }
2322
2935
  resolved.push(attachment);
2323
2936
  }
@@ -2419,6 +3032,7 @@ var AgentService = class {
2419
3032
  * not the thread's own actor).
2420
3033
  */
2421
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");
2422
3036
  await this.assertNotExpired(toolCallId2);
2423
3037
  const runId = await this.resolveRunForToolCall(toolCallId2);
2424
3038
  await this.assertRunWaiting(runId);
@@ -2459,7 +3073,7 @@ var AgentService = class {
2459
3073
  throw new RunNotActiveException(runId);
2460
3074
  }
2461
3075
  if (owner !== actor.id) {
2462
- throw new ForbiddenException("run belongs to another actor");
3076
+ throw new ForbiddenException2("run belongs to another actor");
2463
3077
  }
2464
3078
  }
2465
3079
  /**
@@ -2512,16 +3126,22 @@ var AgentService = class {
2512
3126
  async updateThread(actor, threadId, patch) {
2513
3127
  const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
2514
3128
  await this.assertOwnsThread(actor, threadId);
2515
- if (patch.defaultAgent === void 0 && patch.model === void 0) {
3129
+ if (patch.defaultAgent === void 0 && patch.model === void 0 && patch.persona === void 0) {
2516
3130
  if (title !== void 0) {
2517
3131
  await this.store.setTitle(threadId, title);
2518
3132
  }
2519
3133
  return;
2520
3134
  }
2521
3135
  if (this.store.updateThread === void 0) {
2522
- throw new NotImplementedException2("Setting a thread's defaultAgent or model 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.");
2523
3137
  }
2524
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);
3139
+ if (patch.persona !== void 0 && patch.persona !== null) {
3140
+ this.deps.resolvePersona({
3141
+ agentName: this.deps.resolveAgent(patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId)).agentName,
3142
+ requested: patch.persona
3143
+ });
3144
+ }
2525
3145
  await this.store.updateThread(threadId, {
2526
3146
  ...title !== void 0 ? {
2527
3147
  title
@@ -2531,16 +3151,46 @@ var AgentService = class {
2531
3151
  } : {},
2532
3152
  ...model !== void 0 ? {
2533
3153
  model
3154
+ } : {},
3155
+ ...patch.persona !== void 0 ? {
3156
+ persona: patch.persona
3157
+ } : {}
3158
+ });
3159
+ }
3160
+ /**
3161
+ * The persona this send runs under — see {@link AgentDepsFactory.resolvePersona}. The thread's
3162
+ * pinned persona is read only when the send names none AND the agent has personas to pick from.
3163
+ */
3164
+ async resolvePersona(agentName, requested, threadId) {
3165
+ const needsThread = requested === void 0 && threadId !== void 0 && this.deps.personaCatalog(agentName).length > 0;
3166
+ return this.deps.resolvePersona({
3167
+ agentName,
3168
+ ...requested !== void 0 ? {
3169
+ requested
3170
+ } : {},
3171
+ ...needsThread ? {
3172
+ threadPersona: await threadPersona(this.store, threadId)
2534
3173
  } : {}
2535
3174
  });
2536
3175
  }
3176
+ /** Pin `persona` on the thread when it is not already — a no-op on a store that cannot. */
3177
+ async pinThreadPersona(threadId, persona) {
3178
+ if (this.store.updateThread === void 0) {
3179
+ return;
3180
+ }
3181
+ if (await threadPersona(this.store, threadId) !== persona) {
3182
+ await this.store.updateThread(threadId, {
3183
+ persona
3184
+ });
3185
+ }
3186
+ }
2537
3187
  validateTitle(title) {
2538
3188
  const trimmed = title.trim();
2539
3189
  if (trimmed.length === 0) {
2540
- throw new BadRequestException("title must not be empty");
3190
+ throw new BadRequestException2("title must not be empty");
2541
3191
  }
2542
3192
  if (trimmed.length > 200) {
2543
- throw new BadRequestException("title must be at most 200 characters");
3193
+ throw new BadRequestException2("title must be at most 200 characters");
2544
3194
  }
2545
3195
  return trimmed;
2546
3196
  }
@@ -2579,6 +3229,7 @@ var AgentService = class {
2579
3229
  ...thread,
2580
3230
  defaultAgent: thread.defaultAgent ?? null,
2581
3231
  model: thread.model ?? null,
3232
+ persona: thread.persona ?? null,
2582
3233
  activeRunId: await this.store.activeRunForThread?.(thread.id) ?? thread.activeRunId ?? null
2583
3234
  };
2584
3235
  }
@@ -2643,21 +3294,21 @@ var AgentService = class {
2643
3294
  */
2644
3295
  async setMessageFeedback(actor, messageId, input) {
2645
3296
  if (input.value !== null && input.value !== "up" && input.value !== "down") {
2646
- throw new BadRequestException("value must be 'up', 'down' or null");
3297
+ throw new BadRequestException2("value must be 'up', 'down' or null");
2647
3298
  }
2648
3299
  if (input.comment !== void 0 && typeof input.comment !== "string") {
2649
- throw new BadRequestException("comment must be a string");
3300
+ throw new BadRequestException2("comment must be a string");
2650
3301
  }
2651
3302
  const comment = input.comment?.trim();
2652
3303
  if (comment !== void 0 && comment.length > 2e3) {
2653
- throw new BadRequestException("comment must be at most 2000 characters");
3304
+ throw new BadRequestException2("comment must be at most 2000 characters");
2654
3305
  }
2655
3306
  if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
2656
- 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.");
2657
3308
  }
2658
3309
  const threadId = await this.store.threadOfMessage(messageId);
2659
3310
  if (threadId === null) {
2660
- throw new NotFoundException(`message ${messageId} not found`);
3311
+ throw new NotFoundException2(`message ${messageId} not found`);
2661
3312
  }
2662
3313
  await this.assertOwnsThread(actor, threadId);
2663
3314
  const feedback = input.value === null ? null : {
@@ -2705,7 +3356,7 @@ var AgentService = class {
2705
3356
  const list = this.attachmentInventory();
2706
3357
  const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
2707
3358
  if (referencedMediaIds === void 0) {
2708
- 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.");
2709
3360
  }
2710
3361
  const stagedBefore = options.olderThan.toISOString();
2711
3362
  const inventory = await list({
@@ -2727,7 +3378,7 @@ var AgentService = class {
2727
3378
  attachmentInventory() {
2728
3379
  const list = this.staging?.list?.bind(this.staging);
2729
3380
  if (list === void 0) {
2730
- 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.");
2731
3382
  }
2732
3383
  return list;
2733
3384
  }
@@ -2738,10 +3389,10 @@ var AgentService = class {
2738
3389
  async assertOwnsThread(actor, threadId) {
2739
3390
  const owner = await this.store.ownerOfThread(threadId);
2740
3391
  if (owner === null) {
2741
- throw new NotFoundException(`thread ${threadId} not found`);
3392
+ throw new NotFoundException2(`thread ${threadId} not found`);
2742
3393
  }
2743
3394
  if (owner !== actor.id) {
2744
- throw new ForbiddenException("thread belongs to another actor");
3395
+ throw new ForbiddenException2("thread belongs to another actor");
2745
3396
  }
2746
3397
  }
2747
3398
  /**
@@ -2752,10 +3403,10 @@ var AgentService = class {
2752
3403
  async assertOwnsToolCall(actor, toolCallId2) {
2753
3404
  const owner = await this.store.ownerOfToolCall(toolCallId2);
2754
3405
  if (owner === null) {
2755
- throw new NotFoundException(`tool call ${toolCallId2} not found`);
3406
+ throw new NotFoundException2(`tool call ${toolCallId2} not found`);
2756
3407
  }
2757
3408
  if (owner !== actor.id) {
2758
- throw new ForbiddenException("tool call belongs to another actor");
3409
+ throw new ForbiddenException2("tool call belongs to another actor");
2759
3410
  }
2760
3411
  }
2761
3412
  /**
@@ -2775,7 +3426,7 @@ var AgentService = class {
2775
3426
  const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
2776
3427
  const problem = validateElicitationAnswer(question, submitted ?? question.defaults ?? []);
2777
3428
  if (problem !== null) {
2778
- throw new BadRequestException(`answers["${question.id}"] ${problem}`);
3429
+ throw new BadRequestException2(`answers["${question.id}"] ${problem}`);
2779
3430
  }
2780
3431
  }
2781
3432
  }
@@ -2793,15 +3444,15 @@ var AgentService = class {
2793
3444
  }
2794
3445
  const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
2795
3446
  if (requesterRef === null) {
2796
- throw new NotFoundException(`tool call ${toolCallId2} not found`);
3447
+ throw new NotFoundException2(`tool call ${toolCallId2} not found`);
2797
3448
  }
2798
- const allowed = await mayDecideApproval(this.deps.forAgent().approvalPolicy, actor, {
3449
+ const allowed = await mayDecideApproval2(this.deps.forAgent().approvalPolicy, actor, {
2799
3450
  toolCallId: toolCallId2,
2800
3451
  approver,
2801
3452
  requesterRef
2802
3453
  });
2803
3454
  if (!allowed) {
2804
- throw new ForbiddenException(`this approval is for ${approver}`);
3455
+ throw new ForbiddenException2(`this approval is for ${approver}`);
2805
3456
  }
2806
3457
  }
2807
3458
  /**
@@ -2830,7 +3481,7 @@ var AgentService = class {
2830
3481
  async resolveRunForToolCall(toolCallId2) {
2831
3482
  const runId = await this.store.runForToolCall(toolCallId2);
2832
3483
  if (runId === null) {
2833
- 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`);
2834
3485
  }
2835
3486
  return runId;
2836
3487
  }
@@ -2838,29 +3489,30 @@ var AgentService = class {
2838
3489
  async assertOwnsActiveStream(actor, runId) {
2839
3490
  const owner = await this.store.ownerOfActiveStream(runId);
2840
3491
  if (owner === null) {
2841
- throw new NotFoundException(`no active run ${runId}`);
3492
+ throw new NotFoundException2(`no active run ${runId}`);
2842
3493
  }
2843
3494
  if (owner !== actor.id) {
2844
- throw new ForbiddenException("run belongs to another actor");
3495
+ throw new ForbiddenException2("run belongs to another actor");
2845
3496
  }
2846
3497
  }
2847
3498
  };
2848
- AgentService = _ts_decorate7([
2849
- Injectable6(),
2850
- _ts_param6(0, Inject6(AGENT_RUNNER)),
2851
- _ts_param6(1, Inject6(AGENT_STORE5)),
2852
- _ts_param6(2, Inject6(AGENT_DEPS_FACTORY3)),
2853
- _ts_param6(3, Optional5()),
2854
- _ts_param6(3, Inject6(AGENT_ATTACHMENT_STAGING2)),
2855
- _ts_param6(4, Optional5()),
2856
- _ts_param6(4, Inject6(AGENT_MODEL_CATALOG)),
2857
- _ts_param6(5, Optional5()),
2858
- _ts_param6(5, Inject6(AGENT_QUOTA_PROVIDER2)),
2859
- _ts_param6(6, Optional5()),
2860
- _ts_param6(6, Inject6(AGENT_OPTIONS3)),
2861
- _ts_param6(7, Optional5()),
2862
- _ts_metadata6("design:type", Function),
2863
- _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", [
2864
3516
  typeof AgentRunner === "undefined" ? Object : AgentRunner,
2865
3517
  typeof AgentStore === "undefined" ? Object : AgentStore,
2866
3518
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
@@ -2868,13 +3520,14 @@ AgentService = _ts_decorate7([
2868
3520
  typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
2869
3521
  typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
2870
3522
  typeof Pick === "undefined" ? Object : Pick,
2871
- typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
3523
+ typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2,
3524
+ typeof ActionProposalService === "undefined" ? Object : ActionProposalService
2872
3525
  ])
2873
3526
  ], AgentService);
2874
3527
 
2875
3528
  // src/approval-port.adapter.ts
2876
- import { Injectable as Injectable7 } from "@nestjs/common";
2877
- 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) {
2878
3531
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2879
3532
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2880
3533
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2887,20 +3540,48 @@ function _ts_decorate8(decorators, target, key, desc) {
2887
3540
  }
2888
3541
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2889
3542
  }
2890
- __name(_ts_decorate8, "_ts_decorate");
2891
- function _ts_metadata7(metadataKey, metadataValue) {
3543
+ __name(_ts_decorate10, "_ts_decorate");
3544
+ function _ts_metadata8(metadataKey, metadataValue) {
2892
3545
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2893
3546
  return Reflect.metadata(metadataKey, metadataValue);
2894
3547
  }
2895
3548
  }
2896
- __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");
2897
3556
  var AgentApprovalPortAdapter = class {
2898
3557
  static {
2899
3558
  __name(this, "AgentApprovalPortAdapter");
2900
3559
  }
2901
3560
  agent;
2902
- constructor(agent) {
3561
+ proposals;
3562
+ constructor(agent, proposals) {
2903
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
+ });
2904
3585
  }
2905
3586
  async approve(toolCallId2, opts) {
2906
3587
  await this.agent.signalToolCall(toolCallId2, {
@@ -2931,18 +3612,20 @@ var AgentApprovalPortAdapter = class {
2931
3612
  });
2932
3613
  }
2933
3614
  };
2934
- AgentApprovalPortAdapter = _ts_decorate8([
2935
- Injectable7(),
2936
- _ts_metadata7("design:type", Function),
2937
- _ts_metadata7("design:paramtypes", [
2938
- 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
2939
3622
  ])
2940
3623
  ], AgentApprovalPortAdapter);
2941
3624
 
2942
3625
  // src/controller/agents.controller.ts
2943
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
2944
- import { Controller, Get, Inject as Inject7 } from "@nestjs/common";
2945
- function _ts_decorate9(decorators, target, key, desc) {
3626
+ import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
3627
+ import { Controller, Get, Inject as Inject9 } from "@nestjs/common";
3628
+ function _ts_decorate11(decorators, target, key, desc) {
2946
3629
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2947
3630
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2948
3631
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2955,19 +3638,19 @@ function _ts_decorate9(decorators, target, key, desc) {
2955
3638
  }
2956
3639
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2957
3640
  }
2958
- __name(_ts_decorate9, "_ts_decorate");
2959
- function _ts_metadata8(metadataKey, metadataValue) {
3641
+ __name(_ts_decorate11, "_ts_decorate");
3642
+ function _ts_metadata9(metadataKey, metadataValue) {
2960
3643
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2961
3644
  return Reflect.metadata(metadataKey, metadataValue);
2962
3645
  }
2963
3646
  }
2964
- __name(_ts_metadata8, "_ts_metadata");
2965
- function _ts_param7(paramIndex, decorator) {
3647
+ __name(_ts_metadata9, "_ts_metadata");
3648
+ function _ts_param9(paramIndex, decorator) {
2966
3649
  return function(target, key) {
2967
3650
  decorator(target, key, paramIndex);
2968
3651
  };
2969
3652
  }
2970
- __name(_ts_param7, "_ts_param");
3653
+ __name(_ts_param9, "_ts_param");
2971
3654
  var AgentsController = class {
2972
3655
  static {
2973
3656
  __name(this, "AgentsController");
@@ -2980,35 +3663,44 @@ var AgentsController = class {
2980
3663
  }
2981
3664
  list() {
2982
3665
  const defaultAgentName = this.depsFactory.defaultAgentName();
2983
- return this.agents.list().map((definition) => ({
2984
- name: definition.name,
2985
- description: definition.description ?? "",
2986
- ...definition.name === defaultAgentName ? {
2987
- isDefault: true
2988
- } : {}
2989
- }));
3666
+ return this.agents.list().map((definition) => {
3667
+ const personas = this.depsFactory.personaCatalog(definition.name);
3668
+ return {
3669
+ name: definition.name,
3670
+ description: definition.description ?? "",
3671
+ ...definition.name === defaultAgentName ? {
3672
+ isDefault: true
3673
+ } : {},
3674
+ ...personas.length > 0 ? {
3675
+ personas
3676
+ } : {},
3677
+ ...definition.defaultPersona !== void 0 ? {
3678
+ defaultPersona: definition.defaultPersona
3679
+ } : {}
3680
+ };
3681
+ });
2990
3682
  }
2991
3683
  };
2992
- _ts_decorate9([
3684
+ _ts_decorate11([
2993
3685
  Get(),
2994
- _ts_metadata8("design:type", Function),
2995
- _ts_metadata8("design:paramtypes", []),
2996
- _ts_metadata8("design:returntype", Array)
3686
+ _ts_metadata9("design:type", Function),
3687
+ _ts_metadata9("design:paramtypes", []),
3688
+ _ts_metadata9("design:returntype", Array)
2997
3689
  ], AgentsController.prototype, "list", null);
2998
- AgentsController = _ts_decorate9([
3690
+ AgentsController = _ts_decorate11([
2999
3691
  Controller("agents"),
3000
- _ts_param7(0, Inject7(AGENT_REGISTRY2)),
3001
- _ts_param7(1, Inject7(AGENT_DEPS_FACTORY4)),
3002
- _ts_metadata8("design:type", Function),
3003
- _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", [
3004
3696
  typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
3005
3697
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
3006
3698
  ])
3007
3699
  ], AgentsController);
3008
3700
 
3009
3701
  // src/controller/attachments.controller.ts
3010
- import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS4 } from "@dudousxd/nestjs-agent-core";
3011
- import { BadRequestException as BadRequestException2, 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";
3012
3704
  import { FileInterceptor } from "@nestjs/platform-express";
3013
3705
 
3014
3706
  // src/attachment-limits.ts
@@ -3037,7 +3729,7 @@ function attachmentLimits(options, staging) {
3037
3729
  __name(attachmentLimits, "attachmentLimits");
3038
3730
 
3039
3731
  // src/controller/attachments.controller.ts
3040
- function _ts_decorate10(decorators, target, key, desc) {
3732
+ function _ts_decorate12(decorators, target, key, desc) {
3041
3733
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3042
3734
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3043
3735
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3050,19 +3742,19 @@ function _ts_decorate10(decorators, target, key, desc) {
3050
3742
  }
3051
3743
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3052
3744
  }
3053
- __name(_ts_decorate10, "_ts_decorate");
3054
- function _ts_metadata9(metadataKey, metadataValue) {
3745
+ __name(_ts_decorate12, "_ts_decorate");
3746
+ function _ts_metadata10(metadataKey, metadataValue) {
3055
3747
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3056
3748
  return Reflect.metadata(metadataKey, metadataValue);
3057
3749
  }
3058
3750
  }
3059
- __name(_ts_metadata9, "_ts_metadata");
3060
- function _ts_param8(paramIndex, decorator) {
3751
+ __name(_ts_metadata10, "_ts_metadata");
3752
+ function _ts_param10(paramIndex, decorator) {
3061
3753
  return function(target, key) {
3062
3754
  decorator(target, key, paramIndex);
3063
3755
  };
3064
3756
  }
3065
- __name(_ts_param8, "_ts_param");
3757
+ __name(_ts_param10, "_ts_param");
3066
3758
  var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
3067
3759
  var ATTACHMENT_PAGE_SIZE = 50;
3068
3760
  var AttachmentsController = class {
@@ -3096,10 +3788,10 @@ var AttachmentsController = class {
3096
3788
  }
3097
3789
  async upload(req, file) {
3098
3790
  if (this.staging === void 0) {
3099
- 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).");
3100
3792
  }
3101
3793
  if (file === void 0) {
3102
- throw new BadRequestException2('multipart field "file" is required');
3794
+ throw new BadRequestException3('multipart field "file" is required');
3103
3795
  }
3104
3796
  const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
3105
3797
  if (!allowedContentTypes.includes(file.mimetype)) {
@@ -3118,39 +3810,39 @@ var AttachmentsController = class {
3118
3810
  });
3119
3811
  }
3120
3812
  };
3121
- _ts_decorate10([
3813
+ _ts_decorate12([
3122
3814
  Get2(),
3123
- _ts_param8(0, Req()),
3124
- _ts_metadata9("design:type", Function),
3125
- _ts_metadata9("design:paramtypes", [
3815
+ _ts_param10(0, Req()),
3816
+ _ts_metadata10("design:type", Function),
3817
+ _ts_metadata10("design:paramtypes", [
3126
3818
  typeof Request === "undefined" ? Object : Request
3127
3819
  ]),
3128
- _ts_metadata9("design:returntype", Promise)
3820
+ _ts_metadata10("design:returntype", Promise)
3129
3821
  ], AttachmentsController.prototype, "list", null);
3130
- _ts_decorate10([
3822
+ _ts_decorate12([
3131
3823
  Post(),
3132
3824
  UseInterceptors(FileInterceptor("file", {
3133
3825
  limits: {
3134
3826
  fileSize: HARD_MAX_ATTACHMENT_BYTES
3135
3827
  }
3136
3828
  })),
3137
- _ts_param8(0, Req()),
3138
- _ts_param8(1, UploadedFile()),
3139
- _ts_metadata9("design:type", Function),
3140
- _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", [
3141
3833
  typeof Request === "undefined" ? Object : Request,
3142
3834
  Object
3143
3835
  ]),
3144
- _ts_metadata9("design:returntype", Promise)
3836
+ _ts_metadata10("design:returntype", Promise)
3145
3837
  ], AttachmentsController.prototype, "upload", null);
3146
- AttachmentsController = _ts_decorate10([
3838
+ AttachmentsController = _ts_decorate12([
3147
3839
  Controller2("attachments"),
3148
- _ts_param8(0, Inject8(AGENT_OPTIONS4)),
3149
- _ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER)),
3150
- _ts_param8(3, Optional6()),
3151
- _ts_param8(3, Inject8(AGENT_ATTACHMENT_STAGING3)),
3152
- _ts_metadata9("design:type", Function),
3153
- _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", [
3154
3846
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
3155
3847
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3156
3848
  typeof AgentService === "undefined" ? Object : AgentService,
@@ -3160,8 +3852,9 @@ AttachmentsController = _ts_decorate10([
3160
3852
 
3161
3853
  // src/controller/chat.controller.ts
3162
3854
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError as AgentStreamError2, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
3163
- import { BadRequestException as BadRequestException3, Body, Controller as Controller3, Get as Get3, Inject as Inject9, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
3164
- 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) {
3165
3858
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3166
3859
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3167
3860
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3174,19 +3867,19 @@ function _ts_decorate11(decorators, target, key, desc) {
3174
3867
  }
3175
3868
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3176
3869
  }
3177
- __name(_ts_decorate11, "_ts_decorate");
3178
- function _ts_metadata10(metadataKey, metadataValue) {
3870
+ __name(_ts_decorate13, "_ts_decorate");
3871
+ function _ts_metadata11(metadataKey, metadataValue) {
3179
3872
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3180
3873
  return Reflect.metadata(metadataKey, metadataValue);
3181
3874
  }
3182
3875
  }
3183
- __name(_ts_metadata10, "_ts_metadata");
3184
- function _ts_param9(paramIndex, decorator) {
3876
+ __name(_ts_metadata11, "_ts_metadata");
3877
+ function _ts_param11(paramIndex, decorator) {
3185
3878
  return function(target, key) {
3186
3879
  decorator(target, key, paramIndex);
3187
3880
  };
3188
3881
  }
3189
- __name(_ts_param9, "_ts_param");
3882
+ __name(_ts_param11, "_ts_param");
3190
3883
  function sendMode(body) {
3191
3884
  if (body.interrupt === true) {
3192
3885
  return "interrupt";
@@ -3197,7 +3890,7 @@ function sendMode(body) {
3197
3890
  if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
3198
3891
  return body.mode;
3199
3892
  }
3200
- throw new BadRequestException3("mode must be 'auto', 'queue' or 'interrupt'");
3893
+ throw new BadRequestException4("mode must be 'auto', 'queue' or 'interrupt'");
3201
3894
  }
3202
3895
  __name(sendMode, "sendMode");
3203
3896
  function attachmentRefs(claimed) {
@@ -3205,21 +3898,21 @@ function attachmentRefs(claimed) {
3205
3898
  return [];
3206
3899
  }
3207
3900
  if (!Array.isArray(claimed)) {
3208
- throw new BadRequestException3("attachments must be an array of { mediaId }");
3901
+ throw new BadRequestException4("attachments must be an array of { mediaId }");
3209
3902
  }
3210
3903
  if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
3211
- throw new BadRequestException3(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
3904
+ throw new BadRequestException4(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
3212
3905
  }
3213
3906
  return claimed.map((entry) => {
3214
3907
  if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
3215
- throw new BadRequestException3("each attachment must be an object with a mediaId");
3908
+ throw new BadRequestException4("each attachment must be an object with a mediaId");
3216
3909
  }
3217
3910
  if (Object.keys(entry).some((key) => key !== "mediaId")) {
3218
- throw new BadRequestException3("attachments are { mediaId } refs \u2014 send nothing but the id");
3911
+ throw new BadRequestException4("attachments are { mediaId } refs \u2014 send nothing but the id");
3219
3912
  }
3220
3913
  const { mediaId } = entry;
3221
3914
  if (typeof mediaId !== "string" || mediaId.length === 0) {
3222
- throw new BadRequestException3("each attachment must carry a non-empty string mediaId");
3915
+ throw new BadRequestException4("each attachment must carry a non-empty string mediaId");
3223
3916
  }
3224
3917
  return {
3225
3918
  mediaId
@@ -3247,15 +3940,27 @@ var ChatController = class {
3247
3940
  const actor = await this.actorResolver.resolve(req);
3248
3941
  const attachments = attachmentRefs(body.attachments);
3249
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
+ }
3250
3949
  const result = await this.agent.send({
3251
3950
  actor,
3252
3951
  message: body.message,
3952
+ ...uiCapabilities !== void 0 ? {
3953
+ uiCapabilities
3954
+ } : {},
3253
3955
  ...body.threadId !== void 0 ? {
3254
3956
  threadId: body.threadId
3255
3957
  } : {},
3256
3958
  ...body.agent !== void 0 ? {
3257
3959
  agentName: body.agent
3258
3960
  } : {},
3961
+ ...typeof body.persona === "string" && body.persona.length > 0 ? {
3962
+ personaId: body.persona
3963
+ } : {},
3259
3964
  ...attachments.length > 0 ? {
3260
3965
  attachments
3261
3966
  } : {},
@@ -3273,6 +3978,10 @@ var ChatController = class {
3273
3978
  } : {},
3274
3979
  mode
3275
3980
  });
3981
+ if ("proposalDecision" in result) {
3982
+ res.status(200).json(result);
3983
+ return;
3984
+ }
3276
3985
  if (result.queued === true) {
3277
3986
  res.status(202).json(result);
3278
3987
  return;
@@ -3364,50 +4073,50 @@ data: ${JSON.stringify(payload)}
3364
4073
  res.end();
3365
4074
  }
3366
4075
  };
3367
- _ts_decorate11([
4076
+ _ts_decorate13([
3368
4077
  Post2("chat"),
3369
- _ts_param9(0, Req2()),
3370
- _ts_param9(1, Res()),
3371
- _ts_param9(2, Body()),
3372
- _ts_metadata10("design:type", Function),
3373
- _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", [
3374
4083
  typeof Request === "undefined" ? Object : Request,
3375
4084
  typeof Response === "undefined" ? Object : Response,
3376
4085
  typeof ChatBody === "undefined" ? Object : ChatBody
3377
4086
  ]),
3378
- _ts_metadata10("design:returntype", Promise)
4087
+ _ts_metadata11("design:returntype", Promise)
3379
4088
  ], ChatController.prototype, "chat", null);
3380
- _ts_decorate11([
4089
+ _ts_decorate13([
3381
4090
  Get3("chat/:runId/stream"),
3382
- _ts_param9(0, Req2()),
3383
- _ts_param9(1, Param("runId")),
3384
- _ts_param9(2, Res()),
3385
- _ts_param9(3, Query("after")),
3386
- _ts_metadata10("design:type", Function),
3387
- _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", [
3388
4097
  typeof Request === "undefined" ? Object : Request,
3389
4098
  String,
3390
4099
  typeof Response === "undefined" ? Object : Response,
3391
4100
  String
3392
4101
  ]),
3393
- _ts_metadata10("design:returntype", Promise)
4102
+ _ts_metadata11("design:returntype", Promise)
3394
4103
  ], ChatController.prototype, "stream", null);
3395
- _ts_decorate11([
4104
+ _ts_decorate13([
3396
4105
  Post2("chat/:runId/cancel"),
3397
- _ts_param9(0, Req2()),
3398
- _ts_param9(1, Param("runId")),
3399
- _ts_metadata10("design:type", Function),
3400
- _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", [
3401
4110
  typeof Request === "undefined" ? Object : Request,
3402
4111
  String
3403
4112
  ]),
3404
- _ts_metadata10("design:returntype", Promise)
4113
+ _ts_metadata11("design:returntype", Promise)
3405
4114
  ], ChatController.prototype, "cancel", null);
3406
- ChatController = _ts_decorate11([
4115
+ ChatController = _ts_decorate13([
3407
4116
  Controller3(),
3408
- _ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER2)),
3409
- _ts_metadata10("design:type", Function),
3410
- _ts_metadata10("design:paramtypes", [
4117
+ _ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER2)),
4118
+ _ts_metadata11("design:type", Function),
4119
+ _ts_metadata11("design:paramtypes", [
3411
4120
  typeof AgentService === "undefined" ? Object : AgentService,
3412
4121
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3413
4122
  ])
@@ -3423,8 +4132,8 @@ function parseCursor(raw) {
3423
4132
  __name(parseCursor, "parseCursor");
3424
4133
 
3425
4134
  // src/controller/config.controller.ts
3426
- 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";
3427
- 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";
3428
4137
 
3429
4138
  // src/resolver/anonymous-actor-resolver.ts
3430
4139
  import { createHash, randomBytes } from "crypto";
@@ -3514,7 +4223,7 @@ var AnonymousActorResolver = class {
3514
4223
  };
3515
4224
 
3516
4225
  // src/controller/config.controller.ts
3517
- function _ts_decorate12(decorators, target, key, desc) {
4226
+ function _ts_decorate14(decorators, target, key, desc) {
3518
4227
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3519
4228
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3520
4229
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3527,19 +4236,19 @@ function _ts_decorate12(decorators, target, key, desc) {
3527
4236
  }
3528
4237
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3529
4238
  }
3530
- __name(_ts_decorate12, "_ts_decorate");
3531
- function _ts_metadata11(metadataKey, metadataValue) {
4239
+ __name(_ts_decorate14, "_ts_decorate");
4240
+ function _ts_metadata12(metadataKey, metadataValue) {
3532
4241
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3533
4242
  return Reflect.metadata(metadataKey, metadataValue);
3534
4243
  }
3535
4244
  }
3536
- __name(_ts_metadata11, "_ts_metadata");
3537
- function _ts_param10(paramIndex, decorator) {
4245
+ __name(_ts_metadata12, "_ts_metadata");
4246
+ function _ts_param12(paramIndex, decorator) {
3538
4247
  return function(target, key) {
3539
4248
  decorator(target, key, paramIndex);
3540
4249
  };
3541
4250
  }
3542
- __name(_ts_param10, "_ts_param");
4251
+ __name(_ts_param12, "_ts_param");
3543
4252
  var ConfigController = class {
3544
4253
  static {
3545
4254
  __name(this, "ConfigController");
@@ -3570,25 +4279,25 @@ var ConfigController = class {
3570
4279
  };
3571
4280
  }
3572
4281
  };
3573
- _ts_decorate12([
4282
+ _ts_decorate14([
3574
4283
  Get4(),
3575
- _ts_param10(0, Req3()),
3576
- _ts_metadata11("design:type", Function),
3577
- _ts_metadata11("design:paramtypes", [
4284
+ _ts_param12(0, Req3()),
4285
+ _ts_metadata12("design:type", Function),
4286
+ _ts_metadata12("design:paramtypes", [
3578
4287
  typeof Request === "undefined" ? Object : Request
3579
4288
  ]),
3580
- _ts_metadata11("design:returntype", Promise)
4289
+ _ts_metadata12("design:returntype", Promise)
3581
4290
  ], ConfigController.prototype, "config", null);
3582
- ConfigController = _ts_decorate12([
4291
+ ConfigController = _ts_decorate14([
3583
4292
  Controller4("config"),
3584
- _ts_param10(0, Inject10(AGENT_OPTIONS5)),
3585
- _ts_param10(1, Inject10(AGENT_ACTOR_RESOLVER3)),
3586
- _ts_param10(2, Optional7()),
3587
- _ts_param10(2, Inject10(AGENT_ATTACHMENT_STAGING4)),
3588
- _ts_param10(3, Optional7()),
3589
- _ts_param10(3, Inject10(AGENT_MODEL_CATALOG2)),
3590
- _ts_metadata11("design:type", Function),
3591
- _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", [
3592
4301
  typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
3593
4302
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3594
4303
  Object,
@@ -3598,8 +4307,8 @@ ConfigController = _ts_decorate12([
3598
4307
 
3599
4308
  // src/controller/memories.controller.ts
3600
4309
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
3601
- 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";
3602
- 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) {
3603
4312
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3604
4313
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3605
4314
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3612,19 +4321,19 @@ function _ts_decorate13(decorators, target, key, desc) {
3612
4321
  }
3613
4322
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3614
4323
  }
3615
- __name(_ts_decorate13, "_ts_decorate");
3616
- function _ts_metadata12(metadataKey, metadataValue) {
4324
+ __name(_ts_decorate15, "_ts_decorate");
4325
+ function _ts_metadata13(metadataKey, metadataValue) {
3617
4326
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3618
4327
  return Reflect.metadata(metadataKey, metadataValue);
3619
4328
  }
3620
4329
  }
3621
- __name(_ts_metadata12, "_ts_metadata");
3622
- function _ts_param11(paramIndex, decorator) {
4330
+ __name(_ts_metadata13, "_ts_metadata");
4331
+ function _ts_param13(paramIndex, decorator) {
3623
4332
  return function(target, key) {
3624
4333
  decorator(target, key, paramIndex);
3625
4334
  };
3626
4335
  }
3627
- __name(_ts_param11, "_ts_param");
4336
+ __name(_ts_param13, "_ts_param");
3628
4337
  var MemoriesController = class {
3629
4338
  static {
3630
4339
  __name(this, "MemoriesController");
@@ -3658,20 +4367,20 @@ var MemoriesController = class {
3658
4367
  */
3659
4368
  async forget(req, id) {
3660
4369
  if (this.memory === void 0) {
3661
- throw new NotFoundException2("No memory is configured in this deployment.");
4370
+ throw new NotFoundException3("No memory is configured in this deployment.");
3662
4371
  }
3663
4372
  const actor = await this.actorResolver.resolve(req);
3664
4373
  const digest = await this.unbounded("", actor);
3665
4374
  const entry = digest.entries.find((candidate) => candidate.id === id);
3666
4375
  if (entry === void 0) {
3667
- throw new NotFoundException2(`No memory with id "${id}".`);
4376
+ throw new NotFoundException3(`No memory with id "${id}".`);
3668
4377
  }
3669
4378
  const verdict = memoryForgetVerdict({
3670
4379
  record: entry,
3671
4380
  actor
3672
4381
  });
3673
4382
  if (!verdict.allowed) {
3674
- throw new ForbiddenException2(verdict.reason);
4383
+ throw new ForbiddenException3(verdict.reason);
3675
4384
  }
3676
4385
  return {
3677
4386
  forgotten: await this.memory.provider.forget({
@@ -3697,35 +4406,35 @@ var MemoriesController = class {
3697
4406
  });
3698
4407
  }
3699
4408
  };
3700
- _ts_decorate13([
4409
+ _ts_decorate15([
3701
4410
  Get5(),
3702
- _ts_param11(0, Req4()),
3703
- _ts_param11(1, Query2("threadId")),
3704
- _ts_metadata12("design:type", Function),
3705
- _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", [
3706
4415
  typeof Request === "undefined" ? Object : Request,
3707
4416
  String
3708
4417
  ]),
3709
- _ts_metadata12("design:returntype", Promise)
4418
+ _ts_metadata13("design:returntype", Promise)
3710
4419
  ], MemoriesController.prototype, "list", null);
3711
- _ts_decorate13([
4420
+ _ts_decorate15([
3712
4421
  Delete(":id"),
3713
- _ts_param11(0, Req4()),
3714
- _ts_param11(1, Param2("id")),
3715
- _ts_metadata12("design:type", Function),
3716
- _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", [
3717
4426
  typeof Request === "undefined" ? Object : Request,
3718
4427
  String
3719
4428
  ]),
3720
- _ts_metadata12("design:returntype", Promise)
4429
+ _ts_metadata13("design:returntype", Promise)
3721
4430
  ], MemoriesController.prototype, "forget", null);
3722
- MemoriesController = _ts_decorate13([
4431
+ MemoriesController = _ts_decorate15([
3723
4432
  Controller5("memories"),
3724
- _ts_param11(0, Inject11(AGENT_ACTOR_RESOLVER4)),
3725
- _ts_param11(1, Optional8()),
3726
- _ts_param11(1, Inject11(AGENT_MEMORY2)),
3727
- _ts_metadata12("design:type", Function),
3728
- _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", [
3729
4438
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
3730
4439
  Object
3731
4440
  ])
@@ -3733,8 +4442,8 @@ MemoriesController = _ts_decorate13([
3733
4442
 
3734
4443
  // src/controller/messages.controller.ts
3735
4444
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
3736
- import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject12, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
3737
- 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) {
3738
4447
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3739
4448
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3740
4449
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3747,19 +4456,19 @@ function _ts_decorate14(decorators, target, key, desc) {
3747
4456
  }
3748
4457
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3749
4458
  }
3750
- __name(_ts_decorate14, "_ts_decorate");
3751
- function _ts_metadata13(metadataKey, metadataValue) {
4459
+ __name(_ts_decorate16, "_ts_decorate");
4460
+ function _ts_metadata14(metadataKey, metadataValue) {
3752
4461
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3753
4462
  return Reflect.metadata(metadataKey, metadataValue);
3754
4463
  }
3755
4464
  }
3756
- __name(_ts_metadata13, "_ts_metadata");
3757
- function _ts_param12(paramIndex, decorator) {
4465
+ __name(_ts_metadata14, "_ts_metadata");
4466
+ function _ts_param14(paramIndex, decorator) {
3758
4467
  return function(target, key) {
3759
4468
  decorator(target, key, paramIndex);
3760
4469
  };
3761
4470
  }
3762
- __name(_ts_param12, "_ts_param");
4471
+ __name(_ts_param14, "_ts_param");
3763
4472
  var MessagesController = class {
3764
4473
  static {
3765
4474
  __name(this, "MessagesController");
@@ -3787,25 +4496,25 @@ var MessagesController = class {
3787
4496
  };
3788
4497
  }
3789
4498
  };
3790
- _ts_decorate14([
4499
+ _ts_decorate16([
3791
4500
  Post3(":id/feedback"),
3792
4501
  HttpCode(200),
3793
- _ts_param12(0, Req5()),
3794
- _ts_param12(1, Param3("id")),
3795
- _ts_param12(2, Body2()),
3796
- _ts_metadata13("design:type", Function),
3797
- _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", [
3798
4507
  typeof Request === "undefined" ? Object : Request,
3799
4508
  String,
3800
4509
  typeof FeedbackBody === "undefined" ? Object : FeedbackBody
3801
4510
  ]),
3802
- _ts_metadata13("design:returntype", Promise)
4511
+ _ts_metadata14("design:returntype", Promise)
3803
4512
  ], MessagesController.prototype, "feedback", null);
3804
- MessagesController = _ts_decorate14([
4513
+ MessagesController = _ts_decorate16([
3805
4514
  Controller6("messages"),
3806
- _ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER5)),
3807
- _ts_metadata13("design:type", Function),
3808
- _ts_metadata13("design:paramtypes", [
4515
+ _ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER5)),
4516
+ _ts_metadata14("design:type", Function),
4517
+ _ts_metadata14("design:paramtypes", [
3809
4518
  typeof AgentService === "undefined" ? Object : AgentService,
3810
4519
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3811
4520
  ])
@@ -3813,8 +4522,8 @@ MessagesController = _ts_decorate14([
3813
4522
 
3814
4523
  // src/controller/models.controller.ts
3815
4524
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
3816
- import { Controller as Controller7, Get as Get6, Inject as Inject13, Query as Query3, Req as Req6 } from "@nestjs/common";
3817
- 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) {
3818
4527
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3819
4528
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3820
4529
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3827,19 +4536,19 @@ function _ts_decorate15(decorators, target, key, desc) {
3827
4536
  }
3828
4537
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3829
4538
  }
3830
- __name(_ts_decorate15, "_ts_decorate");
3831
- function _ts_metadata14(metadataKey, metadataValue) {
4539
+ __name(_ts_decorate17, "_ts_decorate");
4540
+ function _ts_metadata15(metadataKey, metadataValue) {
3832
4541
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3833
4542
  return Reflect.metadata(metadataKey, metadataValue);
3834
4543
  }
3835
4544
  }
3836
- __name(_ts_metadata14, "_ts_metadata");
3837
- function _ts_param13(paramIndex, decorator) {
4545
+ __name(_ts_metadata15, "_ts_metadata");
4546
+ function _ts_param15(paramIndex, decorator) {
3838
4547
  return function(target, key) {
3839
4548
  decorator(target, key, paramIndex);
3840
4549
  };
3841
4550
  }
3842
- __name(_ts_param13, "_ts_param");
4551
+ __name(_ts_param15, "_ts_param");
3843
4552
  var ModelsController = class {
3844
4553
  static {
3845
4554
  __name(this, "ModelsController");
@@ -3859,22 +4568,22 @@ var ModelsController = class {
3859
4568
  return this.agent.listModels(actor, agent);
3860
4569
  }
3861
4570
  };
3862
- _ts_decorate15([
4571
+ _ts_decorate17([
3863
4572
  Get6(),
3864
- _ts_param13(0, Req6()),
3865
- _ts_param13(1, Query3("agent")),
3866
- _ts_metadata14("design:type", Function),
3867
- _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", [
3868
4577
  typeof Request === "undefined" ? Object : Request,
3869
4578
  String
3870
4579
  ]),
3871
- _ts_metadata14("design:returntype", Promise)
4580
+ _ts_metadata15("design:returntype", Promise)
3872
4581
  ], ModelsController.prototype, "list", null);
3873
- ModelsController = _ts_decorate15([
4582
+ ModelsController = _ts_decorate17([
3874
4583
  Controller7("models"),
3875
- _ts_param13(1, Inject13(AGENT_ACTOR_RESOLVER6)),
3876
- _ts_metadata14("design:type", Function),
3877
- _ts_metadata14("design:paramtypes", [
4584
+ _ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER6)),
4585
+ _ts_metadata15("design:type", Function),
4586
+ _ts_metadata15("design:paramtypes", [
3878
4587
  typeof AgentService === "undefined" ? Object : AgentService,
3879
4588
  typeof ActorResolver === "undefined" ? Object : ActorResolver
3880
4589
  ])
@@ -3882,8 +4591,8 @@ ModelsController = _ts_decorate15([
3882
4591
 
3883
4592
  // src/controller/queue.controller.ts
3884
4593
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
3885
- import { BadRequestException as BadRequestException4, 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";
3886
- 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) {
3887
4596
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3888
4597
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
3889
4598
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3896,19 +4605,19 @@ function _ts_decorate16(decorators, target, key, desc) {
3896
4605
  }
3897
4606
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3898
4607
  }
3899
- __name(_ts_decorate16, "_ts_decorate");
3900
- function _ts_metadata15(metadataKey, metadataValue) {
4608
+ __name(_ts_decorate18, "_ts_decorate");
4609
+ function _ts_metadata16(metadataKey, metadataValue) {
3901
4610
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
3902
4611
  return Reflect.metadata(metadataKey, metadataValue);
3903
4612
  }
3904
4613
  }
3905
- __name(_ts_metadata15, "_ts_metadata");
3906
- function _ts_param14(paramIndex, decorator) {
4614
+ __name(_ts_metadata16, "_ts_metadata");
4615
+ function _ts_param16(paramIndex, decorator) {
3907
4616
  return function(target, key) {
3908
4617
  decorator(target, key, paramIndex);
3909
4618
  };
3910
4619
  }
3911
- __name(_ts_param14, "_ts_param");
4620
+ __name(_ts_param16, "_ts_param");
3912
4621
  var QueueController = class {
3913
4622
  static {
3914
4623
  __name(this, "QueueController");
@@ -3932,10 +4641,10 @@ var QueueController = class {
3932
4641
  async update(req, messageId, body) {
3933
4642
  const actor = await this.actorResolver.resolve(req);
3934
4643
  if (body.message !== void 0 && typeof body.message !== "string") {
3935
- throw new BadRequestException4("message must be a string");
4644
+ throw new BadRequestException5("message must be a string");
3936
4645
  }
3937
4646
  if (body.position !== void 0 && typeof body.position !== "number") {
3938
- throw new BadRequestException4("position must be a number");
4647
+ throw new BadRequestException5("position must be a number");
3939
4648
  }
3940
4649
  const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
3941
4650
  return this.agent.updateQueuedMessage(actor, messageId, {
@@ -3962,79 +4671,79 @@ var QueueController = class {
3962
4671
  return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
3963
4672
  }
3964
4673
  };
3965
- _ts_decorate16([
4674
+ _ts_decorate18([
3966
4675
  Get7("threads/:id/queue"),
3967
- _ts_param14(0, Req7()),
3968
- _ts_param14(1, Param4("id")),
3969
- _ts_metadata15("design:type", Function),
3970
- _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", [
3971
4680
  typeof Request === "undefined" ? Object : Request,
3972
4681
  String
3973
4682
  ]),
3974
- _ts_metadata15("design:returntype", Promise)
4683
+ _ts_metadata16("design:returntype", Promise)
3975
4684
  ], QueueController.prototype, "list", null);
3976
- _ts_decorate16([
4685
+ _ts_decorate18([
3977
4686
  Delete2("threads/:id/queue"),
3978
- _ts_param14(0, Req7()),
3979
- _ts_param14(1, Param4("id")),
3980
- _ts_metadata15("design:type", Function),
3981
- _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", [
3982
4691
  typeof Request === "undefined" ? Object : Request,
3983
4692
  String
3984
4693
  ]),
3985
- _ts_metadata15("design:returntype", Promise)
4694
+ _ts_metadata16("design:returntype", Promise)
3986
4695
  ], QueueController.prototype, "clear", null);
3987
- _ts_decorate16([
4696
+ _ts_decorate18([
3988
4697
  Post4("threads/:id/queue/resume"),
3989
- _ts_param14(0, Req7()),
3990
- _ts_param14(1, Param4("id")),
3991
- _ts_metadata15("design:type", Function),
3992
- _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", [
3993
4702
  typeof Request === "undefined" ? Object : Request,
3994
4703
  String
3995
4704
  ]),
3996
- _ts_metadata15("design:returntype", Promise)
4705
+ _ts_metadata16("design:returntype", Promise)
3997
4706
  ], QueueController.prototype, "resume", null);
3998
- _ts_decorate16([
4707
+ _ts_decorate18([
3999
4708
  Patch("queue/:messageId"),
4000
- _ts_param14(0, Req7()),
4001
- _ts_param14(1, Param4("messageId")),
4002
- _ts_param14(2, Body3()),
4003
- _ts_metadata15("design:type", Function),
4004
- _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", [
4005
4714
  typeof Request === "undefined" ? Object : Request,
4006
4715
  String,
4007
4716
  typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
4008
4717
  ]),
4009
- _ts_metadata15("design:returntype", Promise)
4718
+ _ts_metadata16("design:returntype", Promise)
4010
4719
  ], QueueController.prototype, "update", null);
4011
- _ts_decorate16([
4720
+ _ts_decorate18([
4012
4721
  Post4("queue/:messageId/interrupt"),
4013
- _ts_param14(0, Req7()),
4014
- _ts_param14(1, Param4("messageId")),
4015
- _ts_metadata15("design:type", Function),
4016
- _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", [
4017
4726
  typeof Request === "undefined" ? Object : Request,
4018
4727
  String
4019
4728
  ]),
4020
- _ts_metadata15("design:returntype", Promise)
4729
+ _ts_metadata16("design:returntype", Promise)
4021
4730
  ], QueueController.prototype, "interrupt", null);
4022
- _ts_decorate16([
4731
+ _ts_decorate18([
4023
4732
  Delete2("queue/:messageId"),
4024
- _ts_param14(0, Req7()),
4025
- _ts_param14(1, Param4("messageId")),
4026
- _ts_metadata15("design:type", Function),
4027
- _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", [
4028
4737
  typeof Request === "undefined" ? Object : Request,
4029
4738
  String
4030
4739
  ]),
4031
- _ts_metadata15("design:returntype", Promise)
4740
+ _ts_metadata16("design:returntype", Promise)
4032
4741
  ], QueueController.prototype, "remove", null);
4033
- QueueController = _ts_decorate16([
4742
+ QueueController = _ts_decorate18([
4034
4743
  Controller8(),
4035
- _ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER7)),
4036
- _ts_metadata15("design:type", Function),
4037
- _ts_metadata15("design:paramtypes", [
4744
+ _ts_param16(1, Inject16(AGENT_ACTOR_RESOLVER7)),
4745
+ _ts_metadata16("design:type", Function),
4746
+ _ts_metadata16("design:paramtypes", [
4038
4747
  typeof AgentService === "undefined" ? Object : AgentService,
4039
4748
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4040
4749
  ])
@@ -4042,8 +4751,8 @@ QueueController = _ts_decorate16([
4042
4751
 
4043
4752
  // src/controller/quota.controller.ts
4044
4753
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
4045
- import { Controller as Controller9, Get as Get8, Inject as Inject15, Req as Req8 } from "@nestjs/common";
4046
- 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) {
4047
4756
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4048
4757
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4049
4758
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4056,19 +4765,19 @@ function _ts_decorate17(decorators, target, key, desc) {
4056
4765
  }
4057
4766
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4058
4767
  }
4059
- __name(_ts_decorate17, "_ts_decorate");
4060
- function _ts_metadata16(metadataKey, metadataValue) {
4768
+ __name(_ts_decorate19, "_ts_decorate");
4769
+ function _ts_metadata17(metadataKey, metadataValue) {
4061
4770
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4062
4771
  return Reflect.metadata(metadataKey, metadataValue);
4063
4772
  }
4064
4773
  }
4065
- __name(_ts_metadata16, "_ts_metadata");
4066
- function _ts_param15(paramIndex, decorator) {
4774
+ __name(_ts_metadata17, "_ts_metadata");
4775
+ function _ts_param17(paramIndex, decorator) {
4067
4776
  return function(target, key) {
4068
4777
  decorator(target, key, paramIndex);
4069
4778
  };
4070
4779
  }
4071
- __name(_ts_param15, "_ts_param");
4780
+ __name(_ts_param17, "_ts_param");
4072
4781
  var QuotaController = class {
4073
4782
  static {
4074
4783
  __name(this, "QuotaController");
@@ -4088,20 +4797,20 @@ var QuotaController = class {
4088
4797
  return this.agent.quotaReport(actor);
4089
4798
  }
4090
4799
  };
4091
- _ts_decorate17([
4800
+ _ts_decorate19([
4092
4801
  Get8(),
4093
- _ts_param15(0, Req8()),
4094
- _ts_metadata16("design:type", Function),
4095
- _ts_metadata16("design:paramtypes", [
4802
+ _ts_param17(0, Req8()),
4803
+ _ts_metadata17("design:type", Function),
4804
+ _ts_metadata17("design:paramtypes", [
4096
4805
  typeof Request === "undefined" ? Object : Request
4097
4806
  ]),
4098
- _ts_metadata16("design:returntype", Promise)
4807
+ _ts_metadata17("design:returntype", Promise)
4099
4808
  ], QuotaController.prototype, "report", null);
4100
- QuotaController = _ts_decorate17([
4809
+ QuotaController = _ts_decorate19([
4101
4810
  Controller9("quota"),
4102
- _ts_param15(1, Inject15(AGENT_ACTOR_RESOLVER8)),
4103
- _ts_metadata16("design:type", Function),
4104
- _ts_metadata16("design:paramtypes", [
4811
+ _ts_param17(1, Inject17(AGENT_ACTOR_RESOLVER8)),
4812
+ _ts_metadata17("design:type", Function),
4813
+ _ts_metadata17("design:paramtypes", [
4105
4814
  typeof AgentService === "undefined" ? Object : AgentService,
4106
4815
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4107
4816
  ])
@@ -4109,8 +4818,8 @@ QuotaController = _ts_decorate17([
4109
4818
 
4110
4819
  // src/controller/skills.controller.ts
4111
4820
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
4112
- import { Controller as Controller10, Get as Get9, Inject as Inject16, Optional as Optional9, Query as Query4, Req as Req9 } from "@nestjs/common";
4113
- 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) {
4114
4823
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4115
4824
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4116
4825
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4123,19 +4832,19 @@ function _ts_decorate18(decorators, target, key, desc) {
4123
4832
  }
4124
4833
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4125
4834
  }
4126
- __name(_ts_decorate18, "_ts_decorate");
4127
- function _ts_metadata17(metadataKey, metadataValue) {
4835
+ __name(_ts_decorate20, "_ts_decorate");
4836
+ function _ts_metadata18(metadataKey, metadataValue) {
4128
4837
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4129
4838
  return Reflect.metadata(metadataKey, metadataValue);
4130
4839
  }
4131
4840
  }
4132
- __name(_ts_metadata17, "_ts_metadata");
4133
- function _ts_param16(paramIndex, decorator) {
4841
+ __name(_ts_metadata18, "_ts_metadata");
4842
+ function _ts_param18(paramIndex, decorator) {
4134
4843
  return function(target, key) {
4135
4844
  decorator(target, key, paramIndex);
4136
4845
  };
4137
4846
  }
4138
- __name(_ts_param16, "_ts_param");
4847
+ __name(_ts_param18, "_ts_param");
4139
4848
  var SkillsController = class {
4140
4849
  static {
4141
4850
  __name(this, "SkillsController");
@@ -4158,24 +4867,24 @@ var SkillsController = class {
4158
4867
  return offer.entries;
4159
4868
  }
4160
4869
  };
4161
- _ts_decorate18([
4870
+ _ts_decorate20([
4162
4871
  Get9(),
4163
- _ts_param16(0, Req9()),
4164
- _ts_param16(1, Query4("threadId")),
4165
- _ts_metadata17("design:type", Function),
4166
- _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", [
4167
4876
  typeof Request === "undefined" ? Object : Request,
4168
4877
  String
4169
4878
  ]),
4170
- _ts_metadata17("design:returntype", Promise)
4879
+ _ts_metadata18("design:returntype", Promise)
4171
4880
  ], SkillsController.prototype, "list", null);
4172
- SkillsController = _ts_decorate18([
4881
+ SkillsController = _ts_decorate20([
4173
4882
  Controller10("skills"),
4174
- _ts_param16(0, Inject16(AGENT_ACTOR_RESOLVER9)),
4175
- _ts_param16(1, Optional9()),
4176
- _ts_param16(1, Inject16(AGENT_SKILLS2)),
4177
- _ts_metadata17("design:type", Function),
4178
- _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", [
4179
4888
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4180
4889
  Object
4181
4890
  ])
@@ -4183,8 +4892,8 @@ SkillsController = _ts_decorate18([
4183
4892
 
4184
4893
  // src/controller/threads.controller.ts
4185
4894
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
4186
- 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";
4187
- 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) {
4188
4897
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4189
4898
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4190
4899
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4197,19 +4906,19 @@ function _ts_decorate19(decorators, target, key, desc) {
4197
4906
  }
4198
4907
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4199
4908
  }
4200
- __name(_ts_decorate19, "_ts_decorate");
4201
- function _ts_metadata18(metadataKey, metadataValue) {
4909
+ __name(_ts_decorate21, "_ts_decorate");
4910
+ function _ts_metadata19(metadataKey, metadataValue) {
4202
4911
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4203
4912
  return Reflect.metadata(metadataKey, metadataValue);
4204
4913
  }
4205
4914
  }
4206
- __name(_ts_metadata18, "_ts_metadata");
4207
- function _ts_param17(paramIndex, decorator) {
4915
+ __name(_ts_metadata19, "_ts_metadata");
4916
+ function _ts_param19(paramIndex, decorator) {
4208
4917
  return function(target, key) {
4209
4918
  decorator(target, key, paramIndex);
4210
4919
  };
4211
4920
  }
4212
- __name(_ts_param17, "_ts_param");
4921
+ __name(_ts_param19, "_ts_param");
4213
4922
  var ThreadsController = class {
4214
4923
  static {
4215
4924
  __name(this, "ThreadsController");
@@ -4255,6 +4964,9 @@ var ThreadsController = class {
4255
4964
  } : {},
4256
4965
  ..."model" in body ? {
4257
4966
  model: body.model ?? null
4967
+ } : {},
4968
+ ..."persona" in body ? {
4969
+ persona: body.persona ?? null
4258
4970
  } : {}
4259
4971
  });
4260
4972
  return {
@@ -4276,92 +4988,92 @@ var ThreadsController = class {
4276
4988
  };
4277
4989
  }
4278
4990
  };
4279
- _ts_decorate19([
4991
+ _ts_decorate21([
4280
4992
  Get10(),
4281
- _ts_param17(0, Req10()),
4282
- _ts_metadata18("design:type", Function),
4283
- _ts_metadata18("design:paramtypes", [
4993
+ _ts_param19(0, Req10()),
4994
+ _ts_metadata19("design:type", Function),
4995
+ _ts_metadata19("design:paramtypes", [
4284
4996
  typeof Request === "undefined" ? Object : Request
4285
4997
  ]),
4286
- _ts_metadata18("design:returntype", Promise)
4998
+ _ts_metadata19("design:returntype", Promise)
4287
4999
  ], ThreadsController.prototype, "list", null);
4288
- _ts_decorate19([
5000
+ _ts_decorate21([
4289
5001
  Get10(":id"),
4290
- _ts_param17(0, Req10()),
4291
- _ts_param17(1, Param5("id")),
4292
- _ts_metadata18("design:type", Function),
4293
- _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", [
4294
5006
  typeof Request === "undefined" ? Object : Request,
4295
5007
  String
4296
5008
  ]),
4297
- _ts_metadata18("design:returntype", Promise)
5009
+ _ts_metadata19("design:returntype", Promise)
4298
5010
  ], ThreadsController.prototype, "detail", null);
4299
- _ts_decorate19([
5011
+ _ts_decorate21([
4300
5012
  Delete3(":id"),
4301
- _ts_param17(0, Req10()),
4302
- _ts_param17(1, Param5("id")),
4303
- _ts_metadata18("design:type", Function),
4304
- _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", [
4305
5017
  typeof Request === "undefined" ? Object : Request,
4306
5018
  String
4307
5019
  ]),
4308
- _ts_metadata18("design:returntype", Promise)
5020
+ _ts_metadata19("design:returntype", Promise)
4309
5021
  ], ThreadsController.prototype, "remove", null);
4310
- _ts_decorate19([
5022
+ _ts_decorate21([
4311
5023
  Post5(":id/fork-from/:messageId"),
4312
- _ts_param17(0, Req10()),
4313
- _ts_param17(1, Param5("id")),
4314
- _ts_param17(2, Param5("messageId")),
4315
- _ts_metadata18("design:type", Function),
4316
- _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", [
4317
5029
  typeof Request === "undefined" ? Object : Request,
4318
5030
  String,
4319
5031
  String
4320
5032
  ]),
4321
- _ts_metadata18("design:returntype", Promise)
5033
+ _ts_metadata19("design:returntype", Promise)
4322
5034
  ], ThreadsController.prototype, "fork", null);
4323
- _ts_decorate19([
5035
+ _ts_decorate21([
4324
5036
  Patch2(":id"),
4325
- _ts_param17(0, Req10()),
4326
- _ts_param17(1, Param5("id")),
4327
- _ts_param17(2, Body4()),
4328
- _ts_metadata18("design:type", Function),
4329
- _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", [
4330
5042
  typeof Request === "undefined" ? Object : Request,
4331
5043
  String,
4332
5044
  typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
4333
5045
  ]),
4334
- _ts_metadata18("design:returntype", Promise)
5046
+ _ts_metadata19("design:returntype", Promise)
4335
5047
  ], ThreadsController.prototype, "update", null);
4336
- _ts_decorate19([
5048
+ _ts_decorate21([
4337
5049
  Post5(":id/promote"),
4338
- _ts_param17(0, Req10()),
4339
- _ts_param17(1, Param5("id")),
4340
- _ts_metadata18("design:type", Function),
4341
- _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", [
4342
5054
  typeof Request === "undefined" ? Object : Request,
4343
5055
  String
4344
5056
  ]),
4345
- _ts_metadata18("design:returntype", Promise)
5057
+ _ts_metadata19("design:returntype", Promise)
4346
5058
  ], ThreadsController.prototype, "promote", null);
4347
- _ts_decorate19([
5059
+ _ts_decorate21([
4348
5060
  Delete3(":id/from/:messageId"),
4349
- _ts_param17(0, Req10()),
4350
- _ts_param17(1, Param5("id")),
4351
- _ts_param17(2, Param5("messageId")),
4352
- _ts_metadata18("design:type", Function),
4353
- _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", [
4354
5066
  typeof Request === "undefined" ? Object : Request,
4355
5067
  String,
4356
5068
  String
4357
5069
  ]),
4358
- _ts_metadata18("design:returntype", Promise)
5070
+ _ts_metadata19("design:returntype", Promise)
4359
5071
  ], ThreadsController.prototype, "truncateFrom", null);
4360
- ThreadsController = _ts_decorate19([
5072
+ ThreadsController = _ts_decorate21([
4361
5073
  Controller11("threads"),
4362
- _ts_param17(1, Inject17(AGENT_ACTOR_RESOLVER10)),
4363
- _ts_metadata18("design:type", Function),
4364
- _ts_metadata18("design:paramtypes", [
5074
+ _ts_param19(1, Inject19(AGENT_ACTOR_RESOLVER10)),
5075
+ _ts_metadata19("design:type", Function),
5076
+ _ts_metadata19("design:paramtypes", [
4365
5077
  typeof AgentService === "undefined" ? Object : AgentService,
4366
5078
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4367
5079
  ])
@@ -4369,8 +5081,8 @@ ThreadsController = _ts_decorate19([
4369
5081
 
4370
5082
  // src/controller/tool-call.controller.ts
4371
5083
  import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11 } from "@dudousxd/nestjs-agent-core";
4372
- import { BadRequestException as BadRequestException5, Body as Body5, Controller as Controller12, Inject as Inject18, Post as Post6, Req as Req11 } from "@nestjs/common";
4373
- 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) {
4374
5086
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4375
5087
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4376
5088
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4383,19 +5095,19 @@ function _ts_decorate20(decorators, target, key, desc) {
4383
5095
  }
4384
5096
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4385
5097
  }
4386
- __name(_ts_decorate20, "_ts_decorate");
4387
- function _ts_metadata19(metadataKey, metadataValue) {
5098
+ __name(_ts_decorate22, "_ts_decorate");
5099
+ function _ts_metadata20(metadataKey, metadataValue) {
4388
5100
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4389
5101
  return Reflect.metadata(metadataKey, metadataValue);
4390
5102
  }
4391
5103
  }
4392
- __name(_ts_metadata19, "_ts_metadata");
4393
- function _ts_param18(paramIndex, decorator) {
5104
+ __name(_ts_metadata20, "_ts_metadata");
5105
+ function _ts_param20(paramIndex, decorator) {
4394
5106
  return function(target, key) {
4395
5107
  decorator(target, key, paramIndex);
4396
5108
  };
4397
5109
  }
4398
- __name(_ts_param18, "_ts_param");
5110
+ __name(_ts_param20, "_ts_param");
4399
5111
  var MAX_ANSWERED_QUESTIONS = 100;
4400
5112
  var MAX_VALUES_PER_QUESTION = 100;
4401
5113
  var MAX_ANSWER_VALUE_LENGTH = 4096;
@@ -4404,7 +5116,7 @@ var MAX_VIA_LENGTH = 64;
4404
5116
  var DEFAULT_VIA = "web";
4405
5117
  function toolCallId(claimed) {
4406
5118
  if (typeof claimed !== "string" || claimed.length === 0) {
4407
- throw new BadRequestException5("toolCallId must be a non-empty string");
5119
+ throw new BadRequestException6("toolCallId must be a non-empty string");
4408
5120
  }
4409
5121
  return claimed;
4410
5122
  }
@@ -4414,10 +5126,10 @@ function rejectReason(claimed) {
4414
5126
  return void 0;
4415
5127
  }
4416
5128
  if (typeof claimed !== "string") {
4417
- throw new BadRequestException5("reason must be a string");
5129
+ throw new BadRequestException6("reason must be a string");
4418
5130
  }
4419
5131
  if (claimed.length > MAX_REJECT_REASON_LENGTH) {
4420
- throw new BadRequestException5(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
5132
+ throw new BadRequestException6(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
4421
5133
  }
4422
5134
  return claimed;
4423
5135
  }
@@ -4427,7 +5139,7 @@ function remember(claimed) {
4427
5139
  return false;
4428
5140
  }
4429
5141
  if (typeof claimed !== "boolean") {
4430
- throw new BadRequestException5("remember must be a boolean");
5142
+ throw new BadRequestException6("remember must be a boolean");
4431
5143
  }
4432
5144
  return claimed;
4433
5145
  }
@@ -4437,7 +5149,7 @@ function via(claimed) {
4437
5149
  return DEFAULT_VIA;
4438
5150
  }
4439
5151
  if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
4440
- throw new BadRequestException5(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
5152
+ throw new BadRequestException6(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
4441
5153
  }
4442
5154
  return claimed;
4443
5155
  }
@@ -4447,26 +5159,26 @@ function answers(claimed) {
4447
5159
  return void 0;
4448
5160
  }
4449
5161
  if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
4450
- throw new BadRequestException5("answers must be an object of questionId \u2192 chosen values");
5162
+ throw new BadRequestException6("answers must be an object of questionId \u2192 chosen values");
4451
5163
  }
4452
5164
  const entries = Object.entries(claimed);
4453
5165
  if (entries.length > MAX_ANSWERED_QUESTIONS) {
4454
- throw new BadRequestException5(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
5166
+ throw new BadRequestException6(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
4455
5167
  }
4456
5168
  const validated = /* @__PURE__ */ Object.create(null);
4457
5169
  for (const [questionId, values] of entries) {
4458
5170
  if (!Array.isArray(values)) {
4459
- throw new BadRequestException5(`answers["${questionId}"] must be an array of chosen values`);
5171
+ throw new BadRequestException6(`answers["${questionId}"] must be an array of chosen values`);
4460
5172
  }
4461
5173
  if (values.length > MAX_VALUES_PER_QUESTION) {
4462
- throw new BadRequestException5(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
5174
+ throw new BadRequestException6(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
4463
5175
  }
4464
5176
  for (const value of values) {
4465
5177
  if (typeof value !== "string") {
4466
- throw new BadRequestException5(`answers["${questionId}"] must contain only strings`);
5178
+ throw new BadRequestException6(`answers["${questionId}"] must contain only strings`);
4467
5179
  }
4468
5180
  if (value.length > MAX_ANSWER_VALUE_LENGTH) {
4469
- throw new BadRequestException5(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
5181
+ throw new BadRequestException6(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
4470
5182
  }
4471
5183
  }
4472
5184
  validated[questionId] = values;
@@ -4528,64 +5240,64 @@ var ToolCallController = class {
4528
5240
  };
4529
5241
  }
4530
5242
  };
4531
- _ts_decorate20([
5243
+ _ts_decorate22([
4532
5244
  Post6("approve"),
4533
- _ts_param18(0, Req11()),
4534
- _ts_param18(1, Body5()),
4535
- _ts_metadata19("design:type", Function),
4536
- _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", [
4537
5249
  typeof Request === "undefined" ? Object : Request,
4538
5250
  typeof ApproveBody === "undefined" ? Object : ApproveBody
4539
5251
  ]),
4540
- _ts_metadata19("design:returntype", Promise)
5252
+ _ts_metadata20("design:returntype", Promise)
4541
5253
  ], ToolCallController.prototype, "approve", null);
4542
- _ts_decorate20([
5254
+ _ts_decorate22([
4543
5255
  Post6("reject"),
4544
- _ts_param18(0, Req11()),
4545
- _ts_param18(1, Body5()),
4546
- _ts_metadata19("design:type", Function),
4547
- _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", [
4548
5260
  typeof Request === "undefined" ? Object : Request,
4549
5261
  typeof RejectBody === "undefined" ? Object : RejectBody
4550
5262
  ]),
4551
- _ts_metadata19("design:returntype", Promise)
5263
+ _ts_metadata20("design:returntype", Promise)
4552
5264
  ], ToolCallController.prototype, "reject", null);
4553
- _ts_decorate20([
5265
+ _ts_decorate22([
4554
5266
  Post6("answer"),
4555
- _ts_param18(0, Req11()),
4556
- _ts_param18(1, Body5()),
4557
- _ts_metadata19("design:type", Function),
4558
- _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", [
4559
5271
  typeof Request === "undefined" ? Object : Request,
4560
5272
  typeof AnswerBody === "undefined" ? Object : AnswerBody
4561
5273
  ]),
4562
- _ts_metadata19("design:returntype", Promise)
5274
+ _ts_metadata20("design:returntype", Promise)
4563
5275
  ], ToolCallController.prototype, "answer", null);
4564
- _ts_decorate20([
5276
+ _ts_decorate22([
4565
5277
  Post6("skip"),
4566
- _ts_param18(0, Req11()),
4567
- _ts_param18(1, Body5()),
4568
- _ts_metadata19("design:type", Function),
4569
- _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", [
4570
5282
  typeof Request === "undefined" ? Object : Request,
4571
5283
  Object
4572
5284
  ]),
4573
- _ts_metadata19("design:returntype", Promise)
5285
+ _ts_metadata20("design:returntype", Promise)
4574
5286
  ], ToolCallController.prototype, "skip", null);
4575
- ToolCallController = _ts_decorate20([
5287
+ ToolCallController = _ts_decorate22([
4576
5288
  Controller12("tool-call"),
4577
- _ts_param18(1, Inject18(AGENT_ACTOR_RESOLVER11)),
4578
- _ts_metadata19("design:type", Function),
4579
- _ts_metadata19("design:paramtypes", [
5289
+ _ts_param20(1, Inject20(AGENT_ACTOR_RESOLVER11)),
5290
+ _ts_metadata20("design:type", Function),
5291
+ _ts_metadata20("design:paramtypes", [
4580
5292
  typeof AgentService === "undefined" ? Object : AgentService,
4581
5293
  typeof ActorResolver === "undefined" ? Object : ActorResolver
4582
5294
  ])
4583
5295
  ], ToolCallController);
4584
5296
 
4585
5297
  // src/controller/tools.controller.ts
4586
- import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_REGISTRY as AGENT_REGISTRY3, ALL_AGENTS, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
4587
- import { Controller as Controller13, Get as Get11, Inject as Inject19, NotFoundException as NotFoundException3, Query as Query5, Req as Req12 } from "@nestjs/common";
4588
- function _ts_decorate21(decorators, target, key, desc) {
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";
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) {
4589
5301
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4590
5302
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4591
5303
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4598,19 +5310,19 @@ function _ts_decorate21(decorators, target, key, desc) {
4598
5310
  }
4599
5311
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4600
5312
  }
4601
- __name(_ts_decorate21, "_ts_decorate");
4602
- function _ts_metadata20(metadataKey, metadataValue) {
5313
+ __name(_ts_decorate23, "_ts_decorate");
5314
+ function _ts_metadata21(metadataKey, metadataValue) {
4603
5315
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4604
5316
  return Reflect.metadata(metadataKey, metadataValue);
4605
5317
  }
4606
5318
  }
4607
- __name(_ts_metadata20, "_ts_metadata");
4608
- function _ts_param19(paramIndex, decorator) {
5319
+ __name(_ts_metadata21, "_ts_metadata");
5320
+ function _ts_param21(paramIndex, decorator) {
4609
5321
  return function(target, key) {
4610
5322
  decorator(target, key, paramIndex);
4611
5323
  };
4612
5324
  }
4613
- __name(_ts_param19, "_ts_param");
5325
+ __name(_ts_param21, "_ts_param");
4614
5326
  var ToolsController = class {
4615
5327
  static {
4616
5328
  __name(this, "ToolsController");
@@ -4625,7 +5337,7 @@ var ToolsController = class {
4625
5337
  }
4626
5338
  async list(req, agent) {
4627
5339
  if (agent !== void 0 && agent !== ALL_AGENTS && this.agents.get(agent) === void 0) {
4628
- throw new NotFoundException3(`No agent named "${agent}"`);
5340
+ throw new NotFoundException4(`No agent named "${agent}"`);
4629
5341
  }
4630
5342
  const actor = await this.actorResolver.resolve(req);
4631
5343
  const names = agent === ALL_AGENTS ? [
@@ -4654,24 +5366,24 @@ var ToolsController = class {
4654
5366
  ];
4655
5367
  }
4656
5368
  };
4657
- _ts_decorate21([
5369
+ _ts_decorate23([
4658
5370
  Get11(),
4659
- _ts_param19(0, Req12()),
4660
- _ts_param19(1, Query5("agent")),
4661
- _ts_metadata20("design:type", Function),
4662
- _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", [
4663
5375
  typeof Request === "undefined" ? Object : Request,
4664
5376
  String
4665
5377
  ]),
4666
- _ts_metadata20("design:returntype", Promise)
5378
+ _ts_metadata21("design:returntype", Promise)
4667
5379
  ], ToolsController.prototype, "list", null);
4668
- ToolsController = _ts_decorate21([
5380
+ ToolsController = _ts_decorate23([
4669
5381
  Controller13("tools"),
4670
- _ts_param19(0, Inject19(AGENT_ACTOR_RESOLVER12)),
4671
- _ts_param19(1, Inject19(AGENT_DEPS_FACTORY5)),
4672
- _ts_param19(2, Inject19(AGENT_REGISTRY3)),
4673
- _ts_metadata20("design:type", Function),
4674
- _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", [
4675
5387
  typeof ActorResolver === "undefined" ? Object : ActorResolver,
4676
5388
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
4677
5389
  typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
@@ -4680,7 +5392,7 @@ ToolsController = _ts_decorate21([
4680
5392
 
4681
5393
  // src/discovery/agent-discovery.service.ts
4682
5394
  import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
4683
- 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";
4684
5396
  import { DiscoveryService, MetadataScanner } from "@nestjs/core";
4685
5397
 
4686
5398
  // src/decorator/agent.decorator.ts
@@ -4697,7 +5409,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
4697
5409
  var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
4698
5410
 
4699
5411
  // src/discovery/agent-discovery.service.ts
4700
- function _ts_decorate22(decorators, target, key, desc) {
5412
+ function _ts_decorate24(decorators, target, key, desc) {
4701
5413
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4702
5414
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4703
5415
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4710,19 +5422,19 @@ function _ts_decorate22(decorators, target, key, desc) {
4710
5422
  }
4711
5423
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4712
5424
  }
4713
- __name(_ts_decorate22, "_ts_decorate");
4714
- function _ts_metadata21(metadataKey, metadataValue) {
5425
+ __name(_ts_decorate24, "_ts_decorate");
5426
+ function _ts_metadata22(metadataKey, metadataValue) {
4715
5427
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4716
5428
  return Reflect.metadata(metadataKey, metadataValue);
4717
5429
  }
4718
5430
  }
4719
- __name(_ts_metadata21, "_ts_metadata");
4720
- function _ts_param20(paramIndex, decorator) {
5431
+ __name(_ts_metadata22, "_ts_metadata");
5432
+ function _ts_param22(paramIndex, decorator) {
4721
5433
  return function(target, key) {
4722
5434
  decorator(target, key, paramIndex);
4723
5435
  };
4724
5436
  }
4725
- __name(_ts_param20, "_ts_param");
5437
+ __name(_ts_param22, "_ts_param");
4726
5438
  var AgentDiscoveryService = class _AgentDiscoveryService {
4727
5439
  static {
4728
5440
  __name(this, "AgentDiscoveryService");
@@ -4750,6 +5462,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
4750
5462
  }
4751
5463
  this.collectContributors(instance);
4752
5464
  }
5465
+ this.assertPersonas(this.registry.list());
4753
5466
  }
4754
5467
  /** Build the internal {@link AgentDefinition} from an `@Agent` instance and its options. */
4755
5468
  definitionFrom(instance, meta) {
@@ -4793,10 +5506,48 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
4793
5506
  } : {},
4794
5507
  ...meta.handoff !== void 0 ? {
4795
5508
  delegatesTo: this.handoffEdges(meta)
5509
+ } : {},
5510
+ ...meta.personas !== void 0 ? {
5511
+ personas: meta.personas
5512
+ } : {},
5513
+ ...meta.defaultPersona !== void 0 ? {
5514
+ defaultPersona: meta.defaultPersona
4796
5515
  } : {}
4797
5516
  };
4798
5517
  }
4799
5518
  /**
5519
+ * Refuse to boot on a persona declaration that could only fail later, per request: a default that
5520
+ * names no persona, an id declared twice, an alias two personas claim, or an alias that is a real
5521
+ * agent's name (which would never be reached — a registered agent always wins).
5522
+ */
5523
+ assertPersonas(definitions) {
5524
+ const agentNames = new Set(definitions.map((definition) => definition.name));
5525
+ const aliasOwner = /* @__PURE__ */ new Map();
5526
+ for (const definition of definitions) {
5527
+ const ids = /* @__PURE__ */ new Set();
5528
+ for (const persona of definition.personas ?? []) {
5529
+ if (ids.has(persona.id)) {
5530
+ throw new Error(`Agent "${definition.name}" declares persona "${persona.id}" twice.`);
5531
+ }
5532
+ ids.add(persona.id);
5533
+ for (const alias of persona.aliases ?? []) {
5534
+ const owner = `${definition.name}/${persona.id}`;
5535
+ if (agentNames.has(alias)) {
5536
+ throw new Error(`Persona ${owner} claims the alias "${alias}", which is a registered agent's name.`);
5537
+ }
5538
+ const previous = aliasOwner.get(alias);
5539
+ if (previous !== void 0) {
5540
+ throw new Error(`Personas ${previous} and ${owner} both claim the alias "${alias}".`);
5541
+ }
5542
+ aliasOwner.set(alias, owner);
5543
+ }
5544
+ }
5545
+ if (definition.defaultPersona !== void 0 && !ids.has(definition.defaultPersona)) {
5546
+ throw new Error(`Agent "${definition.name}" names "${definition.defaultPersona}" as its default persona, but declares no persona with that id.`);
5547
+ }
5548
+ }
5549
+ }
5550
+ /**
4800
5551
  * Resolve each handoff entry to an {@link AgentDelegation} — its target's registered name, plus
4801
5552
  * whether that edge detaches (skipping non-agent classes). A bare name is kept for a plain edge
4802
5553
  * rather than an always-object form, so a definition an older host built by hand still reads.
@@ -4849,12 +5600,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
4849
5600
  return (ctx) => candidate.call(instance, ctx);
4850
5601
  }
4851
5602
  };
4852
- AgentDiscoveryService = _ts_decorate22([
4853
- Injectable8(),
4854
- _ts_param20(2, Inject20(AGENT_REGISTRY4)),
4855
- _ts_param20(3, Inject20(AGENT_PROMPT_CONTRIBUTORS2)),
4856
- _ts_metadata21("design:type", Function),
4857
- _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", [
4858
5609
  typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
4859
5610
  typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
4860
5611
  typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
@@ -4863,8 +5614,8 @@ AgentDiscoveryService = _ts_decorate22([
4863
5614
  ], AgentDiscoveryService);
4864
5615
 
4865
5616
  // src/discovery/ai-tool-discovery.service.ts
4866
- 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";
4867
- 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";
4868
5619
  import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
4869
5620
  import { z } from "zod";
4870
5621
 
@@ -4876,15 +5627,8 @@ function readAiToolMetadata(target) {
4876
5627
  }
4877
5628
  __name(readAiToolMetadata, "readAiToolMetadata");
4878
5629
 
4879
- // src/functional-tool.ts
4880
- var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
4881
- function isBrandedFunctionalTool(value) {
4882
- return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
4883
- }
4884
- __name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
4885
-
4886
5630
  // src/discovery/ai-tool-discovery.service.ts
4887
- function _ts_decorate23(decorators, target, key, desc) {
5631
+ function _ts_decorate25(decorators, target, key, desc) {
4888
5632
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4889
5633
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
4890
5634
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4897,19 +5641,19 @@ function _ts_decorate23(decorators, target, key, desc) {
4897
5641
  }
4898
5642
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4899
5643
  }
4900
- __name(_ts_decorate23, "_ts_decorate");
4901
- function _ts_metadata22(metadataKey, metadataValue) {
5644
+ __name(_ts_decorate25, "_ts_decorate");
5645
+ function _ts_metadata23(metadataKey, metadataValue) {
4902
5646
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
4903
5647
  return Reflect.metadata(metadataKey, metadataValue);
4904
5648
  }
4905
5649
  }
4906
- __name(_ts_metadata22, "_ts_metadata");
4907
- function _ts_param21(paramIndex, decorator) {
5650
+ __name(_ts_metadata23, "_ts_metadata");
5651
+ function _ts_param23(paramIndex, decorator) {
4908
5652
  return function(target, key) {
4909
5653
  decorator(target, key, paramIndex);
4910
5654
  };
4911
5655
  }
4912
- __name(_ts_param21, "_ts_param");
5656
+ __name(_ts_param23, "_ts_param");
4913
5657
  var AiToolDiscoveryService = class _AiToolDiscoveryService {
4914
5658
  static {
4915
5659
  __name(this, "AiToolDiscoveryService");
@@ -4977,9 +5721,15 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
4977
5721
  } : {},
4978
5722
  ...meta.terminal === true ? {
4979
5723
  terminal: true
5724
+ } : {},
5725
+ ...meta.replacementKey !== void 0 ? {
5726
+ replacementKey: meta.replacementKey
4980
5727
  } : {}
4981
5728
  }, {
4982
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
+ } : {},
4983
5733
  // Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
4984
5734
  // `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
4985
5735
  // Called through `instance` so each keeps its `this` (and its injected deps).
@@ -5053,13 +5803,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
5053
5803
  return true;
5054
5804
  }
5055
5805
  };
5056
- AiToolDiscoveryService = _ts_decorate23([
5057
- Injectable9(),
5058
- _ts_param21(1, Inject21(AGENT_TOOL_REGISTRY2)),
5059
- _ts_param21(2, Inject21(AGENT_REGISTRY5)),
5060
- _ts_param21(3, Inject21(AGENT_OPTIONS6)),
5061
- _ts_metadata22("design:type", Function),
5062
- _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", [
5063
5813
  typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
5064
5814
  typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
5065
5815
  typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
@@ -5069,7 +5819,7 @@ AiToolDiscoveryService = _ts_decorate23([
5069
5819
 
5070
5820
  // src/discovery/skill-discovery.service.ts
5071
5821
  import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
5072
- 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";
5073
5823
  import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
5074
5824
 
5075
5825
  // src/decorator/skill.decorator.ts
@@ -5086,7 +5836,7 @@ function skillScope(options) {
5086
5836
  __name(skillScope, "skillScope");
5087
5837
 
5088
5838
  // src/discovery/skill-discovery.service.ts
5089
- function _ts_decorate24(decorators, target, key, desc) {
5839
+ function _ts_decorate26(decorators, target, key, desc) {
5090
5840
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5091
5841
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5092
5842
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5099,19 +5849,19 @@ function _ts_decorate24(decorators, target, key, desc) {
5099
5849
  }
5100
5850
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5101
5851
  }
5102
- __name(_ts_decorate24, "_ts_decorate");
5103
- function _ts_metadata23(metadataKey, metadataValue) {
5852
+ __name(_ts_decorate26, "_ts_decorate");
5853
+ function _ts_metadata24(metadataKey, metadataValue) {
5104
5854
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5105
5855
  return Reflect.metadata(metadataKey, metadataValue);
5106
5856
  }
5107
5857
  }
5108
- __name(_ts_metadata23, "_ts_metadata");
5109
- function _ts_param22(paramIndex, decorator) {
5858
+ __name(_ts_metadata24, "_ts_metadata");
5859
+ function _ts_param24(paramIndex, decorator) {
5110
5860
  return function(target, key) {
5111
5861
  decorator(target, key, paramIndex);
5112
5862
  };
5113
5863
  }
5114
- __name(_ts_param22, "_ts_param");
5864
+ __name(_ts_param24, "_ts_param");
5115
5865
  var SkillDiscoveryService = class _SkillDiscoveryService {
5116
5866
  static {
5117
5867
  __name(this, "SkillDiscoveryService");
@@ -5155,11 +5905,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
5155
5905
  return flat === void 0 ? void 0 : () => flat;
5156
5906
  }
5157
5907
  };
5158
- SkillDiscoveryService = _ts_decorate24([
5159
- Injectable10(),
5160
- _ts_param22(1, Inject22(AGENT_SKILL_SOURCES)),
5161
- _ts_metadata23("design:type", Function),
5162
- _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", [
5163
5913
  typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
5164
5914
  Array
5165
5915
  ])
@@ -5227,10 +5977,245 @@ var LedgerQuotaProvider = class {
5227
5977
  }
5228
5978
  };
5229
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
+
5230
6215
  // src/runner/inline-agent-runner.ts
5231
- import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, 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";
5232
- import { Inject as Inject23, Injectable as Injectable11, Logger as Logger7, Optional as Optional10 } from "@nestjs/common";
5233
- 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) {
5234
6219
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5235
6220
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5236
6221
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5243,19 +6228,19 @@ function _ts_decorate25(decorators, target, key, desc) {
5243
6228
  }
5244
6229
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5245
6230
  }
5246
- __name(_ts_decorate25, "_ts_decorate");
5247
- function _ts_metadata24(metadataKey, metadataValue) {
6231
+ __name(_ts_decorate29, "_ts_decorate");
6232
+ function _ts_metadata27(metadataKey, metadataValue) {
5248
6233
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
5249
6234
  return Reflect.metadata(metadataKey, metadataValue);
5250
6235
  }
5251
6236
  }
5252
- __name(_ts_metadata24, "_ts_metadata");
5253
- function _ts_param23(paramIndex, decorator) {
6237
+ __name(_ts_metadata27, "_ts_metadata");
6238
+ function _ts_param27(paramIndex, decorator) {
5254
6239
  return function(target, key) {
5255
6240
  decorator(target, key, paramIndex);
5256
6241
  };
5257
6242
  }
5258
- __name(_ts_param23, "_ts_param");
6243
+ __name(_ts_param27, "_ts_param");
5259
6244
  var InlineAgentRunner = class _InlineAgentRunner {
5260
6245
  static {
5261
6246
  __name(this, "InlineAgentRunner");
@@ -5263,7 +6248,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
5263
6248
  factory;
5264
6249
  store;
5265
6250
  queue;
5266
- logger = new Logger7(_InlineAgentRunner.name);
6251
+ logger = new Logger8(_InlineAgentRunner.name);
5267
6252
  pending = /* @__PURE__ */ new Map();
5268
6253
  /**
5269
6254
  * Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
@@ -5706,13 +6691,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
5706
6691
  }
5707
6692
  }
5708
6693
  };
5709
- InlineAgentRunner = _ts_decorate25([
5710
- Injectable11(),
5711
- _ts_param23(0, Inject23(AGENT_DEPS_FACTORY6)),
5712
- _ts_param23(1, Inject23(AGENT_STORE6)),
5713
- _ts_param23(2, Optional10()),
5714
- _ts_metadata24("design:type", Function),
5715
- _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", [
5716
6701
  typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
5717
6702
  typeof AgentStore === "undefined" ? Object : AgentStore,
5718
6703
  typeof ChatQueueService2 === "undefined" ? Object : ChatQueueService2
@@ -5762,7 +6747,7 @@ function resolveSkillsConfig(options, declared) {
5762
6747
  __name(resolveSkillsConfig, "resolveSkillsConfig");
5763
6748
 
5764
6749
  // src/agent.module.ts
5765
- function _ts_decorate26(decorators, target, key, desc) {
6750
+ function _ts_decorate30(decorators, target, key, desc) {
5766
6751
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5767
6752
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
5768
6753
  r = Reflect.decorate(decorators, target, key, desc);
@@ -5775,13 +6760,13 @@ function _ts_decorate26(decorators, target, key, desc) {
5775
6760
  }
5776
6761
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5777
6762
  }
5778
- __name(_ts_decorate26, "_ts_decorate");
6763
+ __name(_ts_decorate30, "_ts_decorate");
5779
6764
  var DEFAULT_PATH = "agent";
5780
- var logger = new Logger8("AgentModule");
6765
+ var logger = new Logger9("AgentModule");
5781
6766
  function externalStoreWrapper(modules) {
5782
6767
  for (const module of modules.values()) {
5783
6768
  if (module.metatype === AgentModule) continue;
5784
- const wrapper = module.providers.get(AGENT_STORE7);
6769
+ const wrapper = module.providers.get(AGENT_STORE9);
5785
6770
  if (wrapper !== void 0) return wrapper;
5786
6771
  }
5787
6772
  return void 0;
@@ -5854,7 +6839,7 @@ function sharedProviders(durable) {
5854
6839
  provide: AGENT_SKILLS3,
5855
6840
  useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
5856
6841
  inject: [
5857
- AGENT_OPTIONS7,
6842
+ AGENT_OPTIONS9,
5858
6843
  AGENT_SKILL_SOURCES2
5859
6844
  ]
5860
6845
  },
@@ -5864,39 +6849,39 @@ function sharedProviders(durable) {
5864
6849
  provide: AGENT_MEMORY3,
5865
6850
  useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
5866
6851
  inject: [
5867
- AGENT_OPTIONS7
6852
+ AGENT_OPTIONS9
5868
6853
  ]
5869
6854
  },
5870
6855
  {
5871
6856
  provide: AGENT_SINK4,
5872
6857
  useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
5873
6858
  inject: [
5874
- AGENT_OPTIONS7
6859
+ AGENT_OPTIONS9
5875
6860
  ]
5876
6861
  },
5877
6862
  {
5878
6863
  provide: AGENT_ROLES_POLICY2,
5879
6864
  useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new ClosedRolesPolicy(options.defaultRoles) : new DefaultRolesPolicy(options.defaultRoles)), "useFactory"),
5880
6865
  inject: [
5881
- AGENT_OPTIONS7
6866
+ AGENT_OPTIONS9
5882
6867
  ]
5883
6868
  },
5884
6869
  {
5885
- provide: AGENT_ACTOR_RESOLVER13,
6870
+ provide: AGENT_ACTOR_RESOLVER14,
5886
6871
  useFactory: /* @__PURE__ */ __name((options) => {
5887
6872
  if (options.actorResolver !== void 0) return options.actorResolver;
5888
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.");
5889
6874
  return new AnonymousActorResolver();
5890
6875
  }, "useFactory"),
5891
6876
  inject: [
5892
- AGENT_OPTIONS7
6877
+ AGENT_OPTIONS9
5893
6878
  ]
5894
6879
  },
5895
6880
  {
5896
6881
  provide: AGENT_MODEL2,
5897
6882
  useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
5898
6883
  inject: [
5899
- AGENT_OPTIONS7
6884
+ AGENT_OPTIONS9
5900
6885
  ]
5901
6886
  },
5902
6887
  {
@@ -5907,20 +6892,20 @@ function sharedProviders(durable) {
5907
6892
  warnAt: o.quota.warnAt
5908
6893
  } : {}), "useFactory"),
5909
6894
  inject: [
5910
- AGENT_OPTIONS7,
5911
- AGENT_STORE7
6895
+ AGENT_OPTIONS9,
6896
+ AGENT_STORE9
5912
6897
  ]
5913
6898
  },
5914
6899
  {
5915
6900
  provide: AGENT_MODEL_CATALOG3,
5916
6901
  useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
5917
6902
  inject: [
5918
- AGENT_OPTIONS7
6903
+ AGENT_OPTIONS9
5919
6904
  ]
5920
6905
  },
5921
6906
  AgentDepsFactory2,
5922
6907
  {
5923
- provide: AGENT_DEPS_FACTORY7,
6908
+ provide: AGENT_DEPS_FACTORY9,
5924
6909
  useExisting: AgentDepsFactory2
5925
6910
  },
5926
6911
  // Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
@@ -5937,6 +6922,8 @@ function sharedProviders(durable) {
5937
6922
  },
5938
6923
  InlineAgentRunner,
5939
6924
  AgentService,
6925
+ ActionProposalService,
6926
+ ActionProposalWorkerService,
5940
6927
  // Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
5941
6928
  // through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
5942
6929
  AgentApprovalPortAdapter,
@@ -5946,10 +6933,10 @@ function sharedProviders(durable) {
5946
6933
  }
5947
6934
  ];
5948
6935
  providers.push({
5949
- provide: AGENT_STORE7,
6936
+ provide: AGENT_STORE9,
5950
6937
  useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
5951
6938
  inject: [
5952
- AGENT_OPTIONS7,
6939
+ AGENT_OPTIONS9,
5953
6940
  ModulesContainer
5954
6941
  ]
5955
6942
  });
@@ -5980,22 +6967,24 @@ function sharedProviders(durable) {
5980
6967
  __name(sharedProviders, "sharedProviders");
5981
6968
  function exportsFor() {
5982
6969
  return [
5983
- AGENT_OPTIONS7,
6970
+ AGENT_OPTIONS9,
5984
6971
  AGENT_TOOL_REGISTRY3,
5985
6972
  AGENT_REGISTRY6,
5986
6973
  AGENT_SINK4,
5987
6974
  AGENT_ROLES_POLICY2,
5988
- AGENT_ACTOR_RESOLVER13,
6975
+ AGENT_ACTOR_RESOLVER14,
5989
6976
  AGENT_MODEL2,
5990
- AGENT_STORE7,
6977
+ AGENT_STORE9,
5991
6978
  AGENT_MODEL_CATALOG3,
5992
6979
  AGENT_QUOTA_PROVIDER3,
5993
6980
  AGENT_PROMPT_CONTRIBUTORS3,
5994
6981
  AGENT_SKILLS3,
5995
6982
  AGENT_MEMORY3,
5996
- AGENT_DEPS_FACTORY7,
6983
+ AGENT_DEPS_FACTORY9,
5997
6984
  AgentDepsFactory2,
5998
6985
  AgentService,
6986
+ ActionProposalService,
6987
+ ActionProposalWorkerService,
5999
6988
  ChatQueueService2,
6000
6989
  AGENT_CHAT_QUEUE,
6001
6990
  InlineAgentRunner,
@@ -6004,6 +6993,7 @@ function exportsFor() {
6004
6993
  }
6005
6994
  __name(exportsFor, "exportsFor");
6006
6995
  var BASE_CONTROLLERS = [
6996
+ ActionProposalController,
6007
6997
  ChatController,
6008
6998
  QueueController,
6009
6999
  ThreadsController,
@@ -6076,7 +7066,7 @@ var AgentModule = class _AgentModule {
6076
7066
  controllers: controllersForSurface(options.surface, options.adapters),
6077
7067
  providers: [
6078
7068
  {
6079
- provide: AGENT_OPTIONS7,
7069
+ provide: AGENT_OPTIONS9,
6080
7070
  useValue: options
6081
7071
  },
6082
7072
  ...sharedProviders(options.durable ?? false),
@@ -6100,7 +7090,7 @@ var AgentModule = class _AgentModule {
6100
7090
  controllers: controllersForSurface(options.surface, options.adapters),
6101
7091
  providers: [
6102
7092
  {
6103
- provide: AGENT_OPTIONS7,
7093
+ provide: AGENT_OPTIONS9,
6104
7094
  // Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
6105
7095
  // authoritative on the async config object (they decided the actual wiring above), and
6106
7096
  // the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
@@ -6122,9 +7112,9 @@ var AgentModule = class _AgentModule {
6122
7112
  };
6123
7113
  }
6124
7114
  };
6125
- AgentModule = _ts_decorate26([
7115
+ AgentModule = _ts_decorate30([
6126
7116
  Global2(),
6127
- Module2({})
7117
+ Module3({})
6128
7118
  ], AgentModule);
6129
7119
 
6130
7120
  // src/durable/agent-durable.ts