@dudousxd/nestjs-agent 1.20.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/{chat-queue.service-C0hr7dqx.d.cts → chat-queue.service-CTyX_yNr.d.ts} +48 -3
- package/dist/{chat-queue.service-C0hr7dqx.d.ts → chat-queue.service-Dx9OsjcF.d.cts} +48 -3
- package/dist/durable/index.cjs +1662 -839
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +3 -1
- package/dist/durable/index.d.ts +3 -1
- package/dist/durable/index.js +1395 -572
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.cjs +1 -0
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/genui/index.js +1 -0
- package/dist/genui/index.js.map +1 -1
- package/dist/index.cjs +1647 -831
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -9
- package/dist/index.d.ts +140 -9
- package/dist/index.js +1417 -605
- package/dist/index.js.map +1 -1
- package/dist/sink-redis/index.cjs +7 -2
- package/dist/sink-redis/index.cjs.map +1 -1
- package/dist/sink-redis/index.d.cts +6 -3
- package/dist/sink-redis/index.d.ts +6 -3
- package/dist/sink-redis/index.js +7 -2
- package/dist/sink-redis/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,9 @@ __export(index_exports, {
|
|
|
27
27
|
AGENT_TOOL_BRAND: () => AGENT_TOOL_BRAND,
|
|
28
28
|
AI_TOOL_METADATA: () => AI_TOOL_METADATA,
|
|
29
29
|
ATTACHMENT_PAGE_SIZE: () => ATTACHMENT_PAGE_SIZE,
|
|
30
|
+
ActionProposalController: () => ActionProposalController,
|
|
31
|
+
ActionProposalService: () => ActionProposalService,
|
|
32
|
+
ActionProposalWorkerService: () => ActionProposalWorkerService,
|
|
30
33
|
AgUiRunHandler: () => AgUiRunHandler,
|
|
31
34
|
Agent: () => Agent,
|
|
32
35
|
AgentApprovalPortAdapter: () => AgentApprovalPortAdapter,
|
|
@@ -65,6 +68,7 @@ __export(index_exports, {
|
|
|
65
68
|
attachmentLimits: () => attachmentLimits,
|
|
66
69
|
declaredSkillProvider: () => declaredSkillProvider,
|
|
67
70
|
defaultRequestUserMapper: () => defaultRequestUserMapper,
|
|
71
|
+
defineTool: () => defineTool,
|
|
68
72
|
delegateToolName: () => delegateToolName,
|
|
69
73
|
provideAgentTool: () => provideAgentTool,
|
|
70
74
|
provideAgentTools: () => provideAgentTools,
|
|
@@ -81,14 +85,61 @@ __export(index_exports, {
|
|
|
81
85
|
module.exports = __toCommonJS(index_exports);
|
|
82
86
|
|
|
83
87
|
// src/agent.module.ts
|
|
84
|
-
var
|
|
85
|
-
var
|
|
88
|
+
var import_nestjs_agent_core33 = require("@dudousxd/nestjs-agent-core");
|
|
89
|
+
var import_common27 = require("@nestjs/common");
|
|
86
90
|
var import_core4 = require("@nestjs/core");
|
|
87
91
|
|
|
88
92
|
// src/agent-deps.factory.ts
|
|
89
|
-
var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
|
|
90
93
|
var import_nestjs_agent_core2 = require("@dudousxd/nestjs-agent-core");
|
|
94
|
+
var import_nestjs_agent_core3 = require("@dudousxd/nestjs-agent-core");
|
|
95
|
+
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
96
|
+
var import_common2 = require("@nestjs/common");
|
|
97
|
+
|
|
98
|
+
// src/genui/agent-genui.module.ts
|
|
99
|
+
var import_genui = require("@dudousxd/nestjs-agent-core/genui");
|
|
91
100
|
var import_common = require("@nestjs/common");
|
|
101
|
+
|
|
102
|
+
// src/functional-tool.ts
|
|
103
|
+
var import_nestjs_agent_core = require("@dudousxd/nestjs-agent-core");
|
|
104
|
+
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
105
|
+
function brand(tool) {
|
|
106
|
+
return {
|
|
107
|
+
[AGENT_TOOL_BRAND]: true,
|
|
108
|
+
spec: tool.spec,
|
|
109
|
+
handler: tool.handler
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
__name(brand, "brand");
|
|
113
|
+
function isBrandedFunctionalTool(value) {
|
|
114
|
+
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
115
|
+
}
|
|
116
|
+
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
117
|
+
function provideAgentTool(factoryOrTool, inject) {
|
|
118
|
+
const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
|
|
119
|
+
if (typeof factoryOrTool === "function") {
|
|
120
|
+
return {
|
|
121
|
+
provide,
|
|
122
|
+
useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
|
|
123
|
+
inject: inject ?? []
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
provide,
|
|
128
|
+
useValue: brand(factoryOrTool)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
__name(provideAgentTool, "provideAgentTool");
|
|
132
|
+
function provideAgentTools(factory, inject) {
|
|
133
|
+
return {
|
|
134
|
+
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
135
|
+
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
136
|
+
inject: inject ?? []
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
__name(provideAgentTools, "provideAgentTools");
|
|
140
|
+
var defineTool = import_nestjs_agent_core.createFunctionalTool;
|
|
141
|
+
|
|
142
|
+
// src/genui/agent-genui.module.ts
|
|
92
143
|
function _ts_decorate(decorators, target, key, desc) {
|
|
93
144
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
94
145
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -103,6 +154,124 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
103
154
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
104
155
|
}
|
|
105
156
|
__name(_ts_decorate, "_ts_decorate");
|
|
157
|
+
var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
|
|
158
|
+
var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
|
|
159
|
+
var GenuiCatalogResolver = class {
|
|
160
|
+
static {
|
|
161
|
+
__name(this, "GenuiCatalogResolver");
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
function resolverProviders(resolver) {
|
|
165
|
+
if (resolver === void 0) return [];
|
|
166
|
+
return [
|
|
167
|
+
typeof resolver === "function" ? {
|
|
168
|
+
provide: GenuiCatalogResolver,
|
|
169
|
+
useClass: resolver
|
|
170
|
+
} : {
|
|
171
|
+
provide: GenuiCatalogResolver,
|
|
172
|
+
useValue: resolver
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
__name(resolverProviders, "resolverProviders");
|
|
177
|
+
function toolOptions(options, resolver) {
|
|
178
|
+
const { catalog: _catalog, ...rest } = options;
|
|
179
|
+
return {
|
|
180
|
+
...rest,
|
|
181
|
+
...resolver !== void 0 ? {
|
|
182
|
+
resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
|
|
183
|
+
} : {}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
__name(toolOptions, "toolOptions");
|
|
187
|
+
function coreProviders(resolver) {
|
|
188
|
+
return [
|
|
189
|
+
{
|
|
190
|
+
provide: GENUI_CATALOG,
|
|
191
|
+
useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? (0, import_genui.defineCatalog)([]), "useFactory"),
|
|
192
|
+
inject: [
|
|
193
|
+
GENUI_OPTIONS
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
...resolverProviders(resolver),
|
|
197
|
+
// The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
|
|
198
|
+
// Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
|
|
199
|
+
provideAgentTools((options, catalog, perRequest) => (0, import_genui.genuiTools)(catalog, toolOptions(options, perRequest)), [
|
|
200
|
+
GENUI_OPTIONS,
|
|
201
|
+
GENUI_CATALOG,
|
|
202
|
+
{
|
|
203
|
+
token: GenuiCatalogResolver,
|
|
204
|
+
optional: true
|
|
205
|
+
}
|
|
206
|
+
])
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
__name(coreProviders, "coreProviders");
|
|
210
|
+
var EXPORTS = [
|
|
211
|
+
GENUI_CATALOG,
|
|
212
|
+
GENUI_OPTIONS
|
|
213
|
+
];
|
|
214
|
+
var AgentGenuiModule = class _AgentGenuiModule {
|
|
215
|
+
static {
|
|
216
|
+
__name(this, "AgentGenuiModule");
|
|
217
|
+
}
|
|
218
|
+
static forRoot(options = {}) {
|
|
219
|
+
const { resolver, ...rest } = options;
|
|
220
|
+
return {
|
|
221
|
+
module: _AgentGenuiModule,
|
|
222
|
+
global: true,
|
|
223
|
+
providers: [
|
|
224
|
+
{
|
|
225
|
+
provide: GENUI_OPTIONS,
|
|
226
|
+
useValue: rest
|
|
227
|
+
},
|
|
228
|
+
...coreProviders(resolver)
|
|
229
|
+
],
|
|
230
|
+
exports: resolver === void 0 ? EXPORTS : [
|
|
231
|
+
...EXPORTS,
|
|
232
|
+
GenuiCatalogResolver
|
|
233
|
+
]
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
static forRootAsync(options) {
|
|
237
|
+
return {
|
|
238
|
+
module: _AgentGenuiModule,
|
|
239
|
+
global: true,
|
|
240
|
+
imports: options.imports ?? [],
|
|
241
|
+
providers: [
|
|
242
|
+
{
|
|
243
|
+
provide: GENUI_OPTIONS,
|
|
244
|
+
useFactory: options.useFactory,
|
|
245
|
+
inject: options.inject ?? []
|
|
246
|
+
},
|
|
247
|
+
...coreProviders(options.resolver)
|
|
248
|
+
],
|
|
249
|
+
exports: options.resolver === void 0 ? EXPORTS : [
|
|
250
|
+
...EXPORTS,
|
|
251
|
+
GenuiCatalogResolver
|
|
252
|
+
]
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
AgentGenuiModule = _ts_decorate([
|
|
257
|
+
(0, import_common.Module)({})
|
|
258
|
+
], AgentGenuiModule);
|
|
259
|
+
|
|
260
|
+
// src/agent-deps.factory.ts
|
|
261
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
262
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
263
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
264
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
265
|
+
} else {
|
|
266
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
267
|
+
if (d = decorators[i]) {
|
|
268
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
273
|
+
}
|
|
274
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
106
275
|
function _ts_metadata(metadataKey, metadataValue) {
|
|
107
276
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
108
277
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -135,7 +304,9 @@ var AgentDepsFactory2 = class {
|
|
|
135
304
|
pricingStore;
|
|
136
305
|
skills;
|
|
137
306
|
memory;
|
|
138
|
-
|
|
307
|
+
uiCatalog;
|
|
308
|
+
uiCatalogResolver;
|
|
309
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
|
|
139
310
|
this.options = options;
|
|
140
311
|
this.model = model;
|
|
141
312
|
this.store = store;
|
|
@@ -147,6 +318,9 @@ var AgentDepsFactory2 = class {
|
|
|
147
318
|
this.pricingStore = pricingStore;
|
|
148
319
|
this.skills = skills;
|
|
149
320
|
this.memory = memory;
|
|
321
|
+
this.uiCatalog = uiCatalog;
|
|
322
|
+
this.uiCatalogResolver = uiCatalogResolver;
|
|
323
|
+
if (options.actionApprovalMode === "independent") (0, import_nestjs_agent_core2.assertIndependentActionCapabilities)(store, options.backgroundActorResolver);
|
|
150
324
|
}
|
|
151
325
|
/** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
|
|
152
326
|
memoryConfig() {
|
|
@@ -172,7 +346,7 @@ var AgentDepsFactory2 = class {
|
|
|
172
346
|
return void 0;
|
|
173
347
|
}
|
|
174
348
|
const delegated = (definition.delegatesTo ?? []).map((edge) => {
|
|
175
|
-
const { agent, detached } = (0,
|
|
349
|
+
const { agent, detached } = (0, import_nestjs_agent_core3.normalizeDelegation)(edge);
|
|
176
350
|
return delegateToolName({
|
|
177
351
|
target: agent,
|
|
178
352
|
detached
|
|
@@ -196,7 +370,7 @@ var AgentDepsFactory2 = class {
|
|
|
196
370
|
agentName: name
|
|
197
371
|
};
|
|
198
372
|
}
|
|
199
|
-
const alias = (0,
|
|
373
|
+
const alias = (0, import_nestjs_agent_core3.resolvePersonaAlias)(this.agents.list(), name);
|
|
200
374
|
return alias === void 0 ? {
|
|
201
375
|
agentName: name
|
|
202
376
|
} : {
|
|
@@ -206,7 +380,7 @@ var AgentDepsFactory2 = class {
|
|
|
206
380
|
}
|
|
207
381
|
/** `agentName`'s personas as a picker reads them. Empty when it declares none. */
|
|
208
382
|
personaCatalog(agentName) {
|
|
209
|
-
return (this.agents.get(agentName)?.personas ?? []).map(
|
|
383
|
+
return (this.agents.get(agentName)?.personas ?? []).map(import_nestjs_agent_core3.personaCatalogEntry);
|
|
210
384
|
}
|
|
211
385
|
/** The persona `agentName` runs under when nothing names one. Undefined → none. */
|
|
212
386
|
defaultPersona(agentName) {
|
|
@@ -220,8 +394,8 @@ var AgentDepsFactory2 = class {
|
|
|
220
394
|
resolvePersona(args) {
|
|
221
395
|
const definition = this.agents.get(args.agentName);
|
|
222
396
|
if (args.requested !== void 0) {
|
|
223
|
-
if ((0,
|
|
224
|
-
throw new
|
|
397
|
+
if ((0, import_nestjs_agent_core3.findPersona)(definition, args.requested) === void 0) {
|
|
398
|
+
throw new import_common2.BadRequestException({
|
|
225
399
|
statusCode: 400,
|
|
226
400
|
code: "persona_not_found",
|
|
227
401
|
message: `agent "${args.agentName}" has no persona "${args.requested}"`
|
|
@@ -230,16 +404,28 @@ var AgentDepsFactory2 = class {
|
|
|
230
404
|
return args.requested;
|
|
231
405
|
}
|
|
232
406
|
const pinned = args.threadPersona ?? void 0;
|
|
233
|
-
if (pinned !== void 0 && (0,
|
|
407
|
+
if (pinned !== void 0 && (0, import_nestjs_agent_core3.findPersona)(definition, pinned) !== void 0) {
|
|
234
408
|
return pinned;
|
|
235
409
|
}
|
|
236
410
|
return definition?.defaultPersona;
|
|
237
411
|
}
|
|
412
|
+
forProposal(proposal, _actor) {
|
|
413
|
+
const name = proposal.executionContext?.agentName;
|
|
414
|
+
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`);
|
|
415
|
+
const deps = this.forAgent(name);
|
|
416
|
+
const id = proposal.executionContext?.persona;
|
|
417
|
+
if (id !== void 0) {
|
|
418
|
+
const persona = deps.personas?.find((persona2) => persona2.id === id);
|
|
419
|
+
if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
|
|
420
|
+
return this.withPersona(deps, persona);
|
|
421
|
+
}
|
|
422
|
+
return deps;
|
|
423
|
+
}
|
|
238
424
|
forAgent(agentName) {
|
|
239
425
|
const name = agentName ?? this.defaultAgentName();
|
|
240
426
|
if (agentName !== void 0 && !this.agents.has(agentName)) {
|
|
241
|
-
const alias = (0,
|
|
242
|
-
const persona = alias === void 0 ? void 0 : (0,
|
|
427
|
+
const alias = (0, import_nestjs_agent_core3.resolvePersonaAlias)(this.agents.list(), agentName);
|
|
428
|
+
const persona = alias === void 0 ? void 0 : (0, import_nestjs_agent_core3.findPersona)(this.agents.get(alias.agent), alias.persona);
|
|
243
429
|
if (alias !== void 0 && persona !== void 0) {
|
|
244
430
|
return this.withPersona(this.forAgent(alias.agent), persona);
|
|
245
431
|
}
|
|
@@ -253,12 +439,27 @@ var AgentDepsFactory2 = class {
|
|
|
253
439
|
return {
|
|
254
440
|
model: this.model,
|
|
255
441
|
store: this.store,
|
|
442
|
+
...this.options.actionApprovalMode !== void 0 ? {
|
|
443
|
+
actionApprovalMode: this.options.actionApprovalMode
|
|
444
|
+
} : {},
|
|
256
445
|
sink: this.sink,
|
|
257
446
|
rolesPolicy: this.rolesPolicy,
|
|
258
447
|
...this.options.approvalPolicy !== void 0 ? {
|
|
259
448
|
approvalPolicy: this.options.approvalPolicy
|
|
260
449
|
} : {},
|
|
261
450
|
registry: this.registry,
|
|
451
|
+
...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
|
|
452
|
+
resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
|
|
453
|
+
const catalog = this.uiCatalogResolver?.resolve({
|
|
454
|
+
...scope,
|
|
455
|
+
...scope.actor.tenantRef !== void 0 ? {
|
|
456
|
+
tenant: scope.actor.tenantRef
|
|
457
|
+
} : {}
|
|
458
|
+
}) ?? this.uiCatalog;
|
|
459
|
+
if (!catalog) throw new Error("UI catalog unavailable");
|
|
460
|
+
return catalog;
|
|
461
|
+
}, "resolveUiCatalog")
|
|
462
|
+
} : {},
|
|
262
463
|
promptContributors: this.promptContributors,
|
|
263
464
|
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
264
465
|
maxSteps: definition?.maxSteps ?? 8,
|
|
@@ -358,7 +559,7 @@ var AgentDepsFactory2 = class {
|
|
|
358
559
|
} : {}
|
|
359
560
|
});
|
|
360
561
|
}, "systemPrompt");
|
|
361
|
-
const toolAllowList = (0,
|
|
562
|
+
const toolAllowList = (0, import_nestjs_agent_core3.intersectAllowLists)(deps.toolAllowList, persona.allowedTools);
|
|
362
563
|
return {
|
|
363
564
|
...deps,
|
|
364
565
|
systemPrompt,
|
|
@@ -383,7 +584,7 @@ var AgentDepsFactory2 = class {
|
|
|
383
584
|
}
|
|
384
585
|
/** Build the built-in window policy from the declarative `{ maxMessages, maxTokens, summarize }`. */
|
|
385
586
|
window(config) {
|
|
386
|
-
return (0,
|
|
587
|
+
return (0, import_nestjs_agent_core3.windowHistory)({
|
|
387
588
|
...config.maxMessages !== void 0 ? {
|
|
388
589
|
maxMessages: config.maxMessages
|
|
389
590
|
} : {},
|
|
@@ -393,7 +594,7 @@ var AgentDepsFactory2 = class {
|
|
|
393
594
|
// The shared module model, not a per-agent one: an agent's `modelId` is an accounting label,
|
|
394
595
|
// and only one provider is ever bound.
|
|
395
596
|
...config.summarize === true ? {
|
|
396
|
-
summarize: (0,
|
|
597
|
+
summarize: (0, import_nestjs_agent_core3.summarizeWithModel)(this.model)
|
|
397
598
|
} : {}
|
|
398
599
|
});
|
|
399
600
|
}
|
|
@@ -409,22 +610,25 @@ var AgentDepsFactory2 = class {
|
|
|
409
610
|
return void 0;
|
|
410
611
|
}
|
|
411
612
|
};
|
|
412
|
-
AgentDepsFactory2 =
|
|
413
|
-
(0,
|
|
414
|
-
_ts_param(0, (0,
|
|
415
|
-
_ts_param(1, (0,
|
|
416
|
-
_ts_param(2, (0,
|
|
417
|
-
_ts_param(3, (0,
|
|
418
|
-
_ts_param(4, (0,
|
|
419
|
-
_ts_param(5, (0,
|
|
420
|
-
_ts_param(6, (0,
|
|
421
|
-
_ts_param(7, (0,
|
|
422
|
-
_ts_param(8, (0,
|
|
423
|
-
_ts_param(8, (0,
|
|
424
|
-
_ts_param(9, (0,
|
|
425
|
-
_ts_param(9, (0,
|
|
426
|
-
_ts_param(10, (0,
|
|
427
|
-
_ts_param(10, (0,
|
|
613
|
+
AgentDepsFactory2 = _ts_decorate2([
|
|
614
|
+
(0, import_common2.Injectable)(),
|
|
615
|
+
_ts_param(0, (0, import_common2.Inject)(import_nestjs_agent_core4.AGENT_OPTIONS)),
|
|
616
|
+
_ts_param(1, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_MODEL)),
|
|
617
|
+
_ts_param(2, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_STORE)),
|
|
618
|
+
_ts_param(3, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_SINK)),
|
|
619
|
+
_ts_param(4, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_ROLES_POLICY)),
|
|
620
|
+
_ts_param(5, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_TOOL_REGISTRY)),
|
|
621
|
+
_ts_param(6, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_REGISTRY)),
|
|
622
|
+
_ts_param(7, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_PROMPT_CONTRIBUTORS)),
|
|
623
|
+
_ts_param(8, (0, import_common2.Optional)()),
|
|
624
|
+
_ts_param(8, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_PRICING_STORE)),
|
|
625
|
+
_ts_param(9, (0, import_common2.Optional)()),
|
|
626
|
+
_ts_param(9, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_SKILLS)),
|
|
627
|
+
_ts_param(10, (0, import_common2.Optional)()),
|
|
628
|
+
_ts_param(10, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_MEMORY)),
|
|
629
|
+
_ts_param(11, (0, import_common2.Optional)()),
|
|
630
|
+
_ts_param(11, (0, import_common2.Inject)(GENUI_CATALOG)),
|
|
631
|
+
_ts_param(12, (0, import_common2.Optional)()),
|
|
428
632
|
_ts_metadata("design:type", Function),
|
|
429
633
|
_ts_metadata("design:paramtypes", [
|
|
430
634
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -432,18 +636,20 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
432
636
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
433
637
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
434
638
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
435
|
-
typeof
|
|
436
|
-
typeof
|
|
639
|
+
typeof import_nestjs_agent_core3.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core3.ToolRegistry,
|
|
640
|
+
typeof import_nestjs_agent_core3.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core3.AgentRegistry,
|
|
437
641
|
Array,
|
|
438
642
|
Object,
|
|
439
643
|
Object,
|
|
440
|
-
Object
|
|
644
|
+
Object,
|
|
645
|
+
typeof Catalog === "undefined" ? Object : Catalog,
|
|
646
|
+
typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
|
|
441
647
|
])
|
|
442
648
|
], AgentDepsFactory2);
|
|
443
649
|
|
|
444
650
|
// src/agent.service.ts
|
|
445
|
-
var
|
|
446
|
-
var
|
|
651
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
652
|
+
var import_common6 = require("@nestjs/common");
|
|
447
653
|
|
|
448
654
|
// src/agent-deps.ts
|
|
449
655
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -467,9 +673,208 @@ function childSinkWriter(writer) {
|
|
|
467
673
|
}
|
|
468
674
|
__name(childSinkWriter, "childSinkWriter");
|
|
469
675
|
|
|
676
|
+
// src/proposals/action-proposal.service.ts
|
|
677
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
678
|
+
var import_common3 = require("@nestjs/common");
|
|
679
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
680
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
681
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
682
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
683
|
+
} else {
|
|
684
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
685
|
+
if (d = decorators[i]) {
|
|
686
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
691
|
+
}
|
|
692
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
693
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
694
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
695
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
699
|
+
function _ts_param2(paramIndex, decorator) {
|
|
700
|
+
return function(target, key) {
|
|
701
|
+
decorator(target, key, paramIndex);
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
__name(_ts_param2, "_ts_param");
|
|
705
|
+
var ActionProposalService = class {
|
|
706
|
+
static {
|
|
707
|
+
__name(this, "ActionProposalService");
|
|
708
|
+
}
|
|
709
|
+
store;
|
|
710
|
+
options;
|
|
711
|
+
constructor(store, options) {
|
|
712
|
+
this.store = store;
|
|
713
|
+
this.options = options;
|
|
714
|
+
const text = options.actionProposalText;
|
|
715
|
+
this.vocabulary = {
|
|
716
|
+
...import_nestjs_agent_core5.DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY,
|
|
717
|
+
...text?.vocabulary
|
|
718
|
+
};
|
|
719
|
+
this.replies = {
|
|
720
|
+
...import_nestjs_agent_core5.DEFAULT_TEXT_ACTION_PROPOSAL_REPLIES,
|
|
721
|
+
...text?.replies
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
/** The words a text decision is made of, and what the agent answers — English unless configured. */
|
|
725
|
+
vocabulary;
|
|
726
|
+
replies;
|
|
727
|
+
capability() {
|
|
728
|
+
const store = this.store;
|
|
729
|
+
if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new import_common3.NotImplementedException("Action proposals are unavailable");
|
|
730
|
+
return store;
|
|
731
|
+
}
|
|
732
|
+
async scope(threadId, actor) {
|
|
733
|
+
const scope = await this.capability().getThreadActionProposalScope(threadId);
|
|
734
|
+
if (!scope) throw new import_common3.NotFoundException("Thread not found");
|
|
735
|
+
if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new import_common3.ForbiddenException("Wrong proposal tenant");
|
|
736
|
+
return scope;
|
|
737
|
+
}
|
|
738
|
+
mayDecide(actor, proposal) {
|
|
739
|
+
return (0, import_nestjs_agent_core5.mayDecideApproval)(this.options.approvalPolicy, actor, {
|
|
740
|
+
toolCallId: proposal.originToolCallId,
|
|
741
|
+
approver: proposal.approver,
|
|
742
|
+
requesterRef: proposal.actorRef
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
async listPage(threadId, actor, query = {}) {
|
|
746
|
+
const scope = await this.scope(threadId, actor);
|
|
747
|
+
const rows = await this.capability().listActionProposals(scope, {
|
|
748
|
+
limit: 1e3,
|
|
749
|
+
...query
|
|
750
|
+
});
|
|
751
|
+
const visible = [];
|
|
752
|
+
for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
|
|
753
|
+
const last = rows.at(-1);
|
|
754
|
+
return {
|
|
755
|
+
// The public view: a row carries the worker's lease token and the tool's idempotency key.
|
|
756
|
+
items: visible.map(import_nestjs_agent_core5.toActionProposalView),
|
|
757
|
+
...rows.length === 1e3 && last ? {
|
|
758
|
+
next: {
|
|
759
|
+
createdAt: last.createdAt,
|
|
760
|
+
id: last.id
|
|
761
|
+
}
|
|
762
|
+
} : {}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
async list(threadId, actor) {
|
|
766
|
+
return (await this.listPage(threadId, actor)).items;
|
|
767
|
+
}
|
|
768
|
+
async decide(threadId, proposalId, actor, command) {
|
|
769
|
+
const scope = await this.scope(threadId, actor);
|
|
770
|
+
const proposal = await this.capability().getActionProposal(scope, proposalId);
|
|
771
|
+
if (!proposal) throw new import_common3.NotFoundException("Proposal not found");
|
|
772
|
+
if (!await this.mayDecide(actor, proposal)) throw new import_common3.ForbiddenException("May not decide this proposal");
|
|
773
|
+
const result = await this.capability().decideActionProposal(scope, proposalId, {
|
|
774
|
+
decision: command.decision,
|
|
775
|
+
actorRef: actor.id,
|
|
776
|
+
via: command.via ?? "web",
|
|
777
|
+
...command.remember !== void 0 ? {
|
|
778
|
+
remember: command.remember
|
|
779
|
+
} : {},
|
|
780
|
+
...command.reason !== void 0 ? {
|
|
781
|
+
reason: command.reason
|
|
782
|
+
} : {}
|
|
783
|
+
});
|
|
784
|
+
return (0, import_nestjs_agent_core5.toActionProposalMutationView)(result);
|
|
785
|
+
}
|
|
786
|
+
async handleTextDecision(threadId, actor, text) {
|
|
787
|
+
const command = (0, import_nestjs_agent_core5.parseTextActionProposalCommand)(text, this.vocabulary);
|
|
788
|
+
if (command.status === "unmatched") return command;
|
|
789
|
+
if (command.proposalId !== void 0) {
|
|
790
|
+
const result2 = await this.decide(threadId, command.proposalId, actor, {
|
|
791
|
+
decision: command.decision,
|
|
792
|
+
remember: command.remember,
|
|
793
|
+
via: "text"
|
|
794
|
+
});
|
|
795
|
+
return this.textReceipt(threadId, result2, command.decision);
|
|
796
|
+
}
|
|
797
|
+
const candidates = [];
|
|
798
|
+
const scope = await this.scope(threadId, actor);
|
|
799
|
+
const pending = await this.capability().listActionProposals(scope, {
|
|
800
|
+
decision: "pending",
|
|
801
|
+
limit: 1e3
|
|
802
|
+
});
|
|
803
|
+
for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
|
|
804
|
+
const resolution = (0, import_nestjs_agent_core5.resolveTextActionProposalDecision)(text, candidates, this.vocabulary);
|
|
805
|
+
if (resolution.status === "unmatched") return resolution;
|
|
806
|
+
const saturated = pending.length === 1e3 && !text.includes("#");
|
|
807
|
+
if (resolution.status === "ambiguous" || saturated) {
|
|
808
|
+
const proposalIds = candidates.map(({ id }) => id);
|
|
809
|
+
return {
|
|
810
|
+
threadId,
|
|
811
|
+
proposalDecision: {
|
|
812
|
+
status: "ambiguous",
|
|
813
|
+
proposalIds
|
|
814
|
+
},
|
|
815
|
+
text: saturated ? this.replies.tooMany : this.replies.ambiguous(proposalIds)
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
const result = await this.decide(threadId, resolution.proposalId, actor, {
|
|
819
|
+
decision: resolution.decision,
|
|
820
|
+
remember: resolution.remember,
|
|
821
|
+
via: "text"
|
|
822
|
+
});
|
|
823
|
+
return this.textReceipt(threadId, result, resolution.decision);
|
|
824
|
+
}
|
|
825
|
+
textReceipt(threadId, result, decision) {
|
|
826
|
+
return {
|
|
827
|
+
threadId,
|
|
828
|
+
proposalDecision: result,
|
|
829
|
+
text: this.reply(result, decision)
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
/** The configured reply to a decision the store answered with `result`. */
|
|
833
|
+
reply(result, decision) {
|
|
834
|
+
return (0, import_nestjs_agent_core5.textActionProposalReply)(result, decision, this.replies);
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
ActionProposalService = _ts_decorate3([
|
|
838
|
+
(0, import_common3.Injectable)(),
|
|
839
|
+
_ts_param2(0, (0, import_common3.Inject)(import_nestjs_agent_core5.AGENT_STORE)),
|
|
840
|
+
_ts_param2(1, (0, import_common3.Inject)(import_nestjs_agent_core5.AGENT_OPTIONS)),
|
|
841
|
+
_ts_metadata2("design:type", Function),
|
|
842
|
+
_ts_metadata2("design:paramtypes", [
|
|
843
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
844
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
845
|
+
])
|
|
846
|
+
], ActionProposalService);
|
|
847
|
+
|
|
470
848
|
// src/queue/chat-queue.service.ts
|
|
471
|
-
var
|
|
472
|
-
var
|
|
849
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
850
|
+
var import_common4 = require("@nestjs/common");
|
|
851
|
+
|
|
852
|
+
// src/quota-exceeded.ts
|
|
853
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
854
|
+
function publishQuotaBlocked(actor, report, blocked) {
|
|
855
|
+
const window = report.windows.find((candidate) => candidate.period === blocked.period);
|
|
856
|
+
const payload = {
|
|
857
|
+
actorId: actor.id,
|
|
858
|
+
period: blocked.period,
|
|
859
|
+
...blocked.reason !== void 0 ? {
|
|
860
|
+
reason: blocked.reason
|
|
861
|
+
} : {},
|
|
862
|
+
...window?.usedTokens !== void 0 ? {
|
|
863
|
+
usedTokens: window.usedTokens
|
|
864
|
+
} : {},
|
|
865
|
+
...window?.limitTokens !== void 0 ? {
|
|
866
|
+
limitTokens: window.limitTokens
|
|
867
|
+
} : {},
|
|
868
|
+
...window !== void 0 ? {
|
|
869
|
+
usedUsd: window.usedUsd
|
|
870
|
+
} : {},
|
|
871
|
+
...window?.limitUsd !== void 0 ? {
|
|
872
|
+
limitUsd: window.limitUsd
|
|
873
|
+
} : {}
|
|
874
|
+
};
|
|
875
|
+
(0, import_nestjs_agent_core6.publishAgentQuotaExceeded)(payload);
|
|
876
|
+
}
|
|
877
|
+
__name(publishQuotaBlocked, "publishQuotaBlocked");
|
|
473
878
|
|
|
474
879
|
// src/thread-persona.ts
|
|
475
880
|
async function threadPersona(store, threadId) {
|
|
@@ -482,7 +887,7 @@ async function threadPersona(store, threadId) {
|
|
|
482
887
|
__name(threadPersona, "threadPersona");
|
|
483
888
|
|
|
484
889
|
// src/queue/chat-queue.service.ts
|
|
485
|
-
function
|
|
890
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
486
891
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
487
892
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
488
893
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -495,19 +900,19 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
495
900
|
}
|
|
496
901
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
497
902
|
}
|
|
498
|
-
__name(
|
|
499
|
-
function
|
|
903
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
904
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
500
905
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
501
906
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
502
907
|
}
|
|
503
908
|
}
|
|
504
|
-
__name(
|
|
505
|
-
function
|
|
909
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
910
|
+
function _ts_param3(paramIndex, decorator) {
|
|
506
911
|
return function(target, key) {
|
|
507
912
|
decorator(target, key, paramIndex);
|
|
508
913
|
};
|
|
509
914
|
}
|
|
510
|
-
__name(
|
|
915
|
+
__name(_ts_param3, "_ts_param");
|
|
511
916
|
var MAX_DRAIN_ATTEMPTS = 8;
|
|
512
917
|
var ChatQueueService = class _ChatQueueService {
|
|
513
918
|
static {
|
|
@@ -519,7 +924,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
519
924
|
options;
|
|
520
925
|
staging;
|
|
521
926
|
deps;
|
|
522
|
-
logger = new
|
|
927
|
+
logger = new import_common4.Logger(_ChatQueueService.name);
|
|
523
928
|
/**
|
|
524
929
|
* Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
|
|
525
930
|
* alive whatever the runner says — it simply has not registered the run yet.
|
|
@@ -535,12 +940,12 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
535
940
|
}
|
|
536
941
|
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
537
942
|
get supported() {
|
|
538
|
-
return (0,
|
|
943
|
+
return (0, import_nestjs_agent_core7.isChatQueueStore)(this.store);
|
|
539
944
|
}
|
|
540
945
|
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
541
946
|
queueStore() {
|
|
542
|
-
if (!(0,
|
|
543
|
-
throw new
|
|
947
|
+
if (!(0, import_nestjs_agent_core7.isChatQueueStore)(this.store)) {
|
|
948
|
+
throw new import_common4.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
544
949
|
}
|
|
545
950
|
return this.store;
|
|
546
951
|
}
|
|
@@ -551,7 +956,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
551
956
|
store.queuePause(threadId)
|
|
552
957
|
]);
|
|
553
958
|
return {
|
|
554
|
-
items: items.map(
|
|
959
|
+
items: items.map(import_nestjs_agent_core7.queuedMessageView),
|
|
555
960
|
paused
|
|
556
961
|
};
|
|
557
962
|
}
|
|
@@ -602,7 +1007,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
602
1007
|
* A no-op returning `{}` on a store without a queue.
|
|
603
1008
|
*/
|
|
604
1009
|
async plan(args) {
|
|
605
|
-
if (!(0,
|
|
1010
|
+
if (!(0, import_nestjs_agent_core7.isChatQueueStore)(this.store)) {
|
|
606
1011
|
return {};
|
|
607
1012
|
}
|
|
608
1013
|
const store = this.store;
|
|
@@ -702,7 +1107,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
702
1107
|
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
703
1108
|
*/
|
|
704
1109
|
async kick(threadId, runner) {
|
|
705
|
-
if (!(0,
|
|
1110
|
+
if (!(0, import_nestjs_agent_core7.isChatQueueStore)(this.store)) {
|
|
706
1111
|
return void 0;
|
|
707
1112
|
}
|
|
708
1113
|
const { live, stale } = await this.holder(threadId, runner);
|
|
@@ -767,6 +1172,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
767
1172
|
} : {},
|
|
768
1173
|
...input.pageContext !== void 0 ? {
|
|
769
1174
|
pageContext: input.pageContext
|
|
1175
|
+
} : {},
|
|
1176
|
+
...input.uiCapabilities !== void 0 ? {
|
|
1177
|
+
uiCapabilities: input.uiCapabilities
|
|
770
1178
|
} : {}
|
|
771
1179
|
});
|
|
772
1180
|
await store.setQueuePause(threadId, {
|
|
@@ -803,7 +1211,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
803
1211
|
}
|
|
804
1212
|
async write(runId, frame) {
|
|
805
1213
|
const writer = await this.sink.open(runId);
|
|
806
|
-
await writer.write((0,
|
|
1214
|
+
await writer.write((0, import_nestjs_agent_core7.encodeStreamEvent)(frame));
|
|
807
1215
|
}
|
|
808
1216
|
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
809
1217
|
async quotaBlock(actor) {
|
|
@@ -811,12 +1219,14 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
811
1219
|
return null;
|
|
812
1220
|
}
|
|
813
1221
|
try {
|
|
814
|
-
const
|
|
1222
|
+
const report = await this.quotaProvider.report({
|
|
815
1223
|
actor
|
|
816
1224
|
});
|
|
1225
|
+
const { blocked } = report;
|
|
817
1226
|
if (blocked === void 0) {
|
|
818
1227
|
return null;
|
|
819
1228
|
}
|
|
1229
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
820
1230
|
return blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`;
|
|
821
1231
|
} catch {
|
|
822
1232
|
return null;
|
|
@@ -847,6 +1257,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
847
1257
|
...message.pageContext !== void 0 ? {
|
|
848
1258
|
pageContext: message.pageContext
|
|
849
1259
|
} : {},
|
|
1260
|
+
...message.uiCapabilities !== void 0 ? {
|
|
1261
|
+
uiCapabilities: message.uiCapabilities
|
|
1262
|
+
} : {},
|
|
850
1263
|
...message.model !== void 0 ? {
|
|
851
1264
|
model: message.model
|
|
852
1265
|
} : {}
|
|
@@ -900,20 +1313,20 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
900
1313
|
}));
|
|
901
1314
|
}
|
|
902
1315
|
};
|
|
903
|
-
ChatQueueService =
|
|
904
|
-
(0,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1316
|
+
ChatQueueService = _ts_decorate4([
|
|
1317
|
+
(0, import_common4.Injectable)(),
|
|
1318
|
+
_ts_param3(0, (0, import_common4.Inject)(import_nestjs_agent_core7.AGENT_STORE)),
|
|
1319
|
+
_ts_param3(1, (0, import_common4.Inject)(import_nestjs_agent_core7.AGENT_SINK)),
|
|
1320
|
+
_ts_param3(2, (0, import_common4.Optional)()),
|
|
1321
|
+
_ts_param3(2, (0, import_common4.Inject)(import_nestjs_agent_core7.AGENT_QUOTA_PROVIDER)),
|
|
1322
|
+
_ts_param3(3, (0, import_common4.Optional)()),
|
|
1323
|
+
_ts_param3(3, (0, import_common4.Inject)(import_nestjs_agent_core7.AGENT_OPTIONS)),
|
|
1324
|
+
_ts_param3(4, (0, import_common4.Optional)()),
|
|
1325
|
+
_ts_param3(4, (0, import_common4.Inject)(import_nestjs_agent_core7.AGENT_ATTACHMENT_STAGING)),
|
|
1326
|
+
_ts_param3(5, (0, import_common4.Optional)()),
|
|
1327
|
+
_ts_param3(5, (0, import_common4.Inject)(import_nestjs_agent_core7.AGENT_DEPS_FACTORY)),
|
|
1328
|
+
_ts_metadata3("design:type", Function),
|
|
1329
|
+
_ts_metadata3("design:paramtypes", [
|
|
917
1330
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
918
1331
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
919
1332
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -936,7 +1349,7 @@ function queueFrame(items, paused, started) {
|
|
|
936
1349
|
return {
|
|
937
1350
|
kind: "queue",
|
|
938
1351
|
queue: {
|
|
939
|
-
items: items.map(
|
|
1352
|
+
items: items.map(import_nestjs_agent_core7.queuedMessageView),
|
|
940
1353
|
paused
|
|
941
1354
|
},
|
|
942
1355
|
...started !== void 0 ? {
|
|
@@ -947,25 +1360,25 @@ function queueFrame(items, paused, started) {
|
|
|
947
1360
|
__name(queueFrame, "queueFrame");
|
|
948
1361
|
|
|
949
1362
|
// src/run-not-active.exception.ts
|
|
950
|
-
var
|
|
951
|
-
var
|
|
952
|
-
var RunNotActiveException = class extends
|
|
1363
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
1364
|
+
var import_common5 = require("@nestjs/common");
|
|
1365
|
+
var RunNotActiveException = class extends import_common5.ConflictException {
|
|
953
1366
|
static {
|
|
954
1367
|
__name(this, "RunNotActiveException");
|
|
955
1368
|
}
|
|
956
1369
|
runId;
|
|
957
|
-
code =
|
|
1370
|
+
code = import_nestjs_agent_core8.RUN_NOT_ACTIVE_CODE;
|
|
958
1371
|
constructor(runId) {
|
|
959
1372
|
super({
|
|
960
1373
|
statusCode: 409,
|
|
961
|
-
code:
|
|
962
|
-
message:
|
|
1374
|
+
code: import_nestjs_agent_core8.RUN_NOT_ACTIVE_CODE,
|
|
1375
|
+
message: import_nestjs_agent_core8.RUN_NOT_ACTIVE_MESSAGE
|
|
963
1376
|
}), this.runId = runId;
|
|
964
1377
|
}
|
|
965
1378
|
};
|
|
966
1379
|
|
|
967
1380
|
// src/agent.service.ts
|
|
968
|
-
function
|
|
1381
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
969
1382
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
970
1383
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
971
1384
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -978,19 +1391,19 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
978
1391
|
}
|
|
979
1392
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
980
1393
|
}
|
|
981
|
-
__name(
|
|
982
|
-
function
|
|
1394
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1395
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
983
1396
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
984
1397
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
985
1398
|
}
|
|
986
1399
|
}
|
|
987
|
-
__name(
|
|
988
|
-
function
|
|
1400
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1401
|
+
function _ts_param4(paramIndex, decorator) {
|
|
989
1402
|
return function(target, key) {
|
|
990
1403
|
decorator(target, key, paramIndex);
|
|
991
1404
|
};
|
|
992
1405
|
}
|
|
993
|
-
__name(
|
|
1406
|
+
__name(_ts_param4, "_ts_param");
|
|
994
1407
|
var AgentService = class {
|
|
995
1408
|
static {
|
|
996
1409
|
__name(this, "AgentService");
|
|
@@ -1003,7 +1416,8 @@ var AgentService = class {
|
|
|
1003
1416
|
quotaProvider;
|
|
1004
1417
|
options;
|
|
1005
1418
|
queue;
|
|
1006
|
-
|
|
1419
|
+
proposals;
|
|
1420
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
|
|
1007
1421
|
this.runner = runner;
|
|
1008
1422
|
this.store = store;
|
|
1009
1423
|
this.deps = deps;
|
|
@@ -1012,6 +1426,28 @@ var AgentService = class {
|
|
|
1012
1426
|
this.quotaProvider = quotaProvider;
|
|
1013
1427
|
this.options = options;
|
|
1014
1428
|
this.queue = queue;
|
|
1429
|
+
this.proposals = proposals;
|
|
1430
|
+
}
|
|
1431
|
+
/**
|
|
1432
|
+
* Decide one independent proposal through the scoped proposal service — what the native
|
|
1433
|
+
* `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
|
|
1434
|
+
* proposals are not on, `403`/`404` when this actor may not decide it.
|
|
1435
|
+
*/
|
|
1436
|
+
async decideActionProposal(actor, threadId, proposalId, command) {
|
|
1437
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) {
|
|
1438
|
+
throw new import_common6.NotFoundException("Proposal not found");
|
|
1439
|
+
}
|
|
1440
|
+
const result = await this.proposals.decide(threadId, proposalId, actor, command);
|
|
1441
|
+
return {
|
|
1442
|
+
proposalDecision: result,
|
|
1443
|
+
text: this.proposals.reply(result, command.decision)
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
async handleTextDecision(threadId, actor, text) {
|
|
1447
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
1448
|
+
status: "unmatched"
|
|
1449
|
+
};
|
|
1450
|
+
return this.proposals.handleTextDecision(threadId, actor, text);
|
|
1015
1451
|
}
|
|
1016
1452
|
/** The queue service when the bound store can hold a queue, else `undefined`. */
|
|
1017
1453
|
queueing() {
|
|
@@ -1021,7 +1457,7 @@ var AgentService = class {
|
|
|
1021
1457
|
requireQueue() {
|
|
1022
1458
|
const queue = this.queueing();
|
|
1023
1459
|
if (queue === void 0) {
|
|
1024
|
-
throw new
|
|
1460
|
+
throw new import_common6.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
1025
1461
|
}
|
|
1026
1462
|
return queue;
|
|
1027
1463
|
}
|
|
@@ -1054,16 +1490,18 @@ var AgentService = class {
|
|
|
1054
1490
|
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
1055
1491
|
return;
|
|
1056
1492
|
}
|
|
1057
|
-
const
|
|
1493
|
+
const report = await this.quotaProvider.report({
|
|
1058
1494
|
actor
|
|
1059
1495
|
});
|
|
1496
|
+
const { blocked } = report;
|
|
1060
1497
|
if (blocked !== void 0) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1498
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
1499
|
+
throw new import_common6.HttpException({
|
|
1500
|
+
statusCode: import_common6.HttpStatus.TOO_MANY_REQUESTS,
|
|
1063
1501
|
code: "quota_exceeded",
|
|
1064
1502
|
period: blocked.period,
|
|
1065
1503
|
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
1066
|
-
},
|
|
1504
|
+
}, import_common6.HttpStatus.TOO_MANY_REQUESTS);
|
|
1067
1505
|
}
|
|
1068
1506
|
}
|
|
1069
1507
|
/**
|
|
@@ -1091,17 +1529,17 @@ var AgentService = class {
|
|
|
1091
1529
|
*/
|
|
1092
1530
|
async assertModelAllowed(actor, agent, model) {
|
|
1093
1531
|
if (this.models === void 0) {
|
|
1094
|
-
throw new
|
|
1532
|
+
throw new import_common6.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
1095
1533
|
}
|
|
1096
|
-
const entry = (0,
|
|
1534
|
+
const entry = (0, import_nestjs_agent_core9.findCatalogModel)(await this.models.list({
|
|
1097
1535
|
actor,
|
|
1098
1536
|
agent
|
|
1099
1537
|
}), model);
|
|
1100
1538
|
if (entry === void 0) {
|
|
1101
|
-
throw new
|
|
1539
|
+
throw new import_common6.BadRequestException(`model "${model}" is not offered`);
|
|
1102
1540
|
}
|
|
1103
1541
|
if (!entry.available) {
|
|
1104
|
-
throw new
|
|
1542
|
+
throw new import_common6.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
1105
1543
|
}
|
|
1106
1544
|
return entry.id;
|
|
1107
1545
|
}
|
|
@@ -1117,7 +1555,7 @@ var AgentService = class {
|
|
|
1117
1555
|
})).locked : void 0;
|
|
1118
1556
|
if (locked !== void 0) {
|
|
1119
1557
|
if (requested !== void 0 && requested !== locked.model) {
|
|
1120
|
-
throw new
|
|
1558
|
+
throw new import_common6.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
|
|
1121
1559
|
}
|
|
1122
1560
|
return locked.model;
|
|
1123
1561
|
}
|
|
@@ -1143,7 +1581,10 @@ var AgentService = class {
|
|
|
1143
1581
|
const result = await this.send({
|
|
1144
1582
|
...params,
|
|
1145
1583
|
mode: "auto"
|
|
1584
|
+
}, {
|
|
1585
|
+
textDecisions: false
|
|
1146
1586
|
});
|
|
1587
|
+
if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
|
|
1147
1588
|
if (result.queued !== true) {
|
|
1148
1589
|
return result;
|
|
1149
1590
|
}
|
|
@@ -1161,7 +1602,7 @@ var AgentService = class {
|
|
|
1161
1602
|
};
|
|
1162
1603
|
}
|
|
1163
1604
|
await this.requireQueue().publish(result.threadId);
|
|
1164
|
-
throw new
|
|
1605
|
+
throw new import_common6.ConflictException({
|
|
1165
1606
|
statusCode: 409,
|
|
1166
1607
|
code: "run_active",
|
|
1167
1608
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -1171,7 +1612,11 @@ var AgentService = class {
|
|
|
1171
1612
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
1172
1613
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
1173
1614
|
*/
|
|
1174
|
-
async send(params) {
|
|
1615
|
+
async send(params, sendOptions = {}) {
|
|
1616
|
+
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
1617
|
+
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
1618
|
+
if ("proposalDecision" in decision) return decision;
|
|
1619
|
+
}
|
|
1175
1620
|
await this.assertWithinQuota(params.actor);
|
|
1176
1621
|
const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
|
|
1177
1622
|
const agentName = target.agentName;
|
|
@@ -1181,7 +1626,7 @@ var AgentService = class {
|
|
|
1181
1626
|
let threadId = params.threadId;
|
|
1182
1627
|
if (threadId === void 0) {
|
|
1183
1628
|
if (params.regenerate === true) {
|
|
1184
|
-
throw new
|
|
1629
|
+
throw new import_common6.BadRequestException("regenerate requires an existing threadId");
|
|
1185
1630
|
}
|
|
1186
1631
|
const created = await this.store.createThread({
|
|
1187
1632
|
actor: params.actor,
|
|
@@ -1220,12 +1665,16 @@ var AgentService = class {
|
|
|
1220
1665
|
...params.pageContext !== void 0 ? {
|
|
1221
1666
|
pageContext: params.pageContext
|
|
1222
1667
|
} : {},
|
|
1668
|
+
...params.uiCapabilities !== void 0 ? {
|
|
1669
|
+
uiCapabilities: params.uiCapabilities
|
|
1670
|
+
} : {},
|
|
1223
1671
|
...model !== void 0 ? {
|
|
1224
1672
|
model
|
|
1225
1673
|
} : {}
|
|
1226
1674
|
};
|
|
1227
1675
|
const queue = this.queueing();
|
|
1228
1676
|
if (queue === void 0) {
|
|
1677
|
+
if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
|
|
1229
1678
|
const { runId } = await this.runner.start(input);
|
|
1230
1679
|
await this.store.setActiveStream(threadId, runId);
|
|
1231
1680
|
return {
|
|
@@ -1236,7 +1685,7 @@ var AgentService = class {
|
|
|
1236
1685
|
const mode = params.mode ?? "auto";
|
|
1237
1686
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
1238
1687
|
if (stale !== null) {
|
|
1239
|
-
await (0,
|
|
1688
|
+
await (0, import_nestjs_agent_core9.settleDeadRun)(this.store, {
|
|
1240
1689
|
runId: stale
|
|
1241
1690
|
});
|
|
1242
1691
|
}
|
|
@@ -1252,7 +1701,7 @@ var AgentService = class {
|
|
|
1252
1701
|
}
|
|
1253
1702
|
}
|
|
1254
1703
|
if (params.regenerate === true) {
|
|
1255
|
-
throw new
|
|
1704
|
+
throw new import_common6.ConflictException({
|
|
1256
1705
|
statusCode: 409,
|
|
1257
1706
|
code: "run_active",
|
|
1258
1707
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -1306,6 +1755,9 @@ var AgentService = class {
|
|
|
1306
1755
|
...input.pageContext !== void 0 ? {
|
|
1307
1756
|
pageContext: input.pageContext
|
|
1308
1757
|
} : {},
|
|
1758
|
+
...input.uiCapabilities !== void 0 ? {
|
|
1759
|
+
uiCapabilities: input.uiCapabilities
|
|
1760
|
+
} : {},
|
|
1309
1761
|
...interrupting !== void 0 ? {
|
|
1310
1762
|
interrupt: true,
|
|
1311
1763
|
at: "head"
|
|
@@ -1352,7 +1804,7 @@ var AgentService = class {
|
|
|
1352
1804
|
const store = queue.queueStore();
|
|
1353
1805
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1354
1806
|
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
1355
|
-
throw new
|
|
1807
|
+
throw new import_common6.BadRequestException("message must not be empty");
|
|
1356
1808
|
}
|
|
1357
1809
|
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
1358
1810
|
if (patch.message !== void 0 || attachments !== void 0) {
|
|
@@ -1365,15 +1817,15 @@ var AgentService = class {
|
|
|
1365
1817
|
} : {}
|
|
1366
1818
|
});
|
|
1367
1819
|
if (updated === null) {
|
|
1368
|
-
throw new
|
|
1820
|
+
throw new import_common6.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1369
1821
|
}
|
|
1370
1822
|
}
|
|
1371
1823
|
if (patch.position !== void 0) {
|
|
1372
1824
|
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
1373
|
-
throw new
|
|
1825
|
+
throw new import_common6.BadRequestException("position must be a non-negative integer");
|
|
1374
1826
|
}
|
|
1375
1827
|
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
1376
|
-
throw new
|
|
1828
|
+
throw new import_common6.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1377
1829
|
}
|
|
1378
1830
|
}
|
|
1379
1831
|
return queue.publish(threadId);
|
|
@@ -1383,7 +1835,7 @@ var AgentService = class {
|
|
|
1383
1835
|
const queue = this.requireQueue();
|
|
1384
1836
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1385
1837
|
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
1386
|
-
throw new
|
|
1838
|
+
throw new import_common6.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1387
1839
|
}
|
|
1388
1840
|
return queue.publish(threadId);
|
|
1389
1841
|
}
|
|
@@ -1402,7 +1854,7 @@ var AgentService = class {
|
|
|
1402
1854
|
const queue = this.requireQueue();
|
|
1403
1855
|
const store = queue.queueStore();
|
|
1404
1856
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1405
|
-
const gone = /* @__PURE__ */ __name(() => new
|
|
1857
|
+
const gone = /* @__PURE__ */ __name(() => new import_common6.GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
1406
1858
|
const marked = await store.updateQueuedMessage(messageId, {
|
|
1407
1859
|
interrupt: true
|
|
1408
1860
|
});
|
|
@@ -1410,7 +1862,7 @@ var AgentService = class {
|
|
|
1410
1862
|
throw gone();
|
|
1411
1863
|
}
|
|
1412
1864
|
if (marked.interrupt !== true) {
|
|
1413
|
-
throw new
|
|
1865
|
+
throw new import_common6.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
1414
1866
|
}
|
|
1415
1867
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
1416
1868
|
throw gone();
|
|
@@ -1469,7 +1921,7 @@ var AgentService = class {
|
|
|
1469
1921
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
1470
1922
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
1471
1923
|
if (message === null) {
|
|
1472
|
-
throw new
|
|
1924
|
+
throw new import_common6.NotFoundException(`queued message ${messageId} not found`);
|
|
1473
1925
|
}
|
|
1474
1926
|
await this.assertOwnsThread(actor, message.threadId);
|
|
1475
1927
|
return message.threadId;
|
|
@@ -1490,7 +1942,7 @@ var AgentService = class {
|
|
|
1490
1942
|
}
|
|
1491
1943
|
const staging = this.staging;
|
|
1492
1944
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
1493
|
-
throw new
|
|
1945
|
+
throw new import_common6.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
1494
1946
|
}
|
|
1495
1947
|
const resolved = [];
|
|
1496
1948
|
for (const ref of refs) {
|
|
@@ -1499,7 +1951,7 @@ var AgentService = class {
|
|
|
1499
1951
|
actor
|
|
1500
1952
|
});
|
|
1501
1953
|
if (attachment === null) {
|
|
1502
|
-
throw new
|
|
1954
|
+
throw new import_common6.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
|
|
1503
1955
|
}
|
|
1504
1956
|
resolved.push(attachment);
|
|
1505
1957
|
}
|
|
@@ -1601,6 +2053,7 @@ var AgentService = class {
|
|
|
1601
2053
|
* not the thread's own actor).
|
|
1602
2054
|
*/
|
|
1603
2055
|
async signalToolCall(toolCallId2, reply) {
|
|
2056
|
+
if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new import_common6.ConflictException("Independent proposals require the scoped proposal decision route");
|
|
1604
2057
|
await this.assertNotExpired(toolCallId2);
|
|
1605
2058
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
1606
2059
|
await this.assertRunWaiting(runId);
|
|
@@ -1621,7 +2074,7 @@ var AgentService = class {
|
|
|
1621
2074
|
if (active) {
|
|
1622
2075
|
return;
|
|
1623
2076
|
}
|
|
1624
|
-
await (0,
|
|
2077
|
+
await (0, import_nestjs_agent_core9.settleDeadRun)(this.store, {
|
|
1625
2078
|
runId
|
|
1626
2079
|
});
|
|
1627
2080
|
throw new RunNotActiveException(runId);
|
|
@@ -1641,7 +2094,7 @@ var AgentService = class {
|
|
|
1641
2094
|
throw new RunNotActiveException(runId);
|
|
1642
2095
|
}
|
|
1643
2096
|
if (owner !== actor.id) {
|
|
1644
|
-
throw new
|
|
2097
|
+
throw new import_common6.ForbiddenException("run belongs to another actor");
|
|
1645
2098
|
}
|
|
1646
2099
|
}
|
|
1647
2100
|
/**
|
|
@@ -1701,7 +2154,7 @@ var AgentService = class {
|
|
|
1701
2154
|
return;
|
|
1702
2155
|
}
|
|
1703
2156
|
if (this.store.updateThread === void 0) {
|
|
1704
|
-
throw new
|
|
2157
|
+
throw new import_common6.NotImplementedException("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1705
2158
|
}
|
|
1706
2159
|
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);
|
|
1707
2160
|
if (patch.persona !== void 0 && patch.persona !== null) {
|
|
@@ -1755,10 +2208,10 @@ var AgentService = class {
|
|
|
1755
2208
|
validateTitle(title) {
|
|
1756
2209
|
const trimmed = title.trim();
|
|
1757
2210
|
if (trimmed.length === 0) {
|
|
1758
|
-
throw new
|
|
2211
|
+
throw new import_common6.BadRequestException("title must not be empty");
|
|
1759
2212
|
}
|
|
1760
2213
|
if (trimmed.length > 200) {
|
|
1761
|
-
throw new
|
|
2214
|
+
throw new import_common6.BadRequestException("title must be at most 200 characters");
|
|
1762
2215
|
}
|
|
1763
2216
|
return trimmed;
|
|
1764
2217
|
}
|
|
@@ -1862,21 +2315,21 @@ var AgentService = class {
|
|
|
1862
2315
|
*/
|
|
1863
2316
|
async setMessageFeedback(actor, messageId, input) {
|
|
1864
2317
|
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
1865
|
-
throw new
|
|
2318
|
+
throw new import_common6.BadRequestException("value must be 'up', 'down' or null");
|
|
1866
2319
|
}
|
|
1867
2320
|
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
1868
|
-
throw new
|
|
2321
|
+
throw new import_common6.BadRequestException("comment must be a string");
|
|
1869
2322
|
}
|
|
1870
2323
|
const comment = input.comment?.trim();
|
|
1871
2324
|
if (comment !== void 0 && comment.length > 2e3) {
|
|
1872
|
-
throw new
|
|
2325
|
+
throw new import_common6.BadRequestException("comment must be at most 2000 characters");
|
|
1873
2326
|
}
|
|
1874
2327
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
1875
|
-
throw new
|
|
2328
|
+
throw new import_common6.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
1876
2329
|
}
|
|
1877
2330
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
1878
2331
|
if (threadId === null) {
|
|
1879
|
-
throw new
|
|
2332
|
+
throw new import_common6.NotFoundException(`message ${messageId} not found`);
|
|
1880
2333
|
}
|
|
1881
2334
|
await this.assertOwnsThread(actor, threadId);
|
|
1882
2335
|
const feedback = input.value === null ? null : {
|
|
@@ -1924,7 +2377,7 @@ var AgentService = class {
|
|
|
1924
2377
|
const list = this.attachmentInventory();
|
|
1925
2378
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
1926
2379
|
if (referencedMediaIds === void 0) {
|
|
1927
|
-
throw new
|
|
2380
|
+
throw new import_common6.NotImplementedException("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.");
|
|
1928
2381
|
}
|
|
1929
2382
|
const stagedBefore = options.olderThan.toISOString();
|
|
1930
2383
|
const inventory = await list({
|
|
@@ -1946,7 +2399,7 @@ var AgentService = class {
|
|
|
1946
2399
|
attachmentInventory() {
|
|
1947
2400
|
const list = this.staging?.list?.bind(this.staging);
|
|
1948
2401
|
if (list === void 0) {
|
|
1949
|
-
throw new
|
|
2402
|
+
throw new import_common6.NotImplementedException("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
|
|
1950
2403
|
}
|
|
1951
2404
|
return list;
|
|
1952
2405
|
}
|
|
@@ -1957,10 +2410,10 @@ var AgentService = class {
|
|
|
1957
2410
|
async assertOwnsThread(actor, threadId) {
|
|
1958
2411
|
const owner = await this.store.ownerOfThread(threadId);
|
|
1959
2412
|
if (owner === null) {
|
|
1960
|
-
throw new
|
|
2413
|
+
throw new import_common6.NotFoundException(`thread ${threadId} not found`);
|
|
1961
2414
|
}
|
|
1962
2415
|
if (owner !== actor.id) {
|
|
1963
|
-
throw new
|
|
2416
|
+
throw new import_common6.ForbiddenException("thread belongs to another actor");
|
|
1964
2417
|
}
|
|
1965
2418
|
}
|
|
1966
2419
|
/**
|
|
@@ -1971,10 +2424,10 @@ var AgentService = class {
|
|
|
1971
2424
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
1972
2425
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
1973
2426
|
if (owner === null) {
|
|
1974
|
-
throw new
|
|
2427
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
1975
2428
|
}
|
|
1976
2429
|
if (owner !== actor.id) {
|
|
1977
|
-
throw new
|
|
2430
|
+
throw new import_common6.ForbiddenException("tool call belongs to another actor");
|
|
1978
2431
|
}
|
|
1979
2432
|
}
|
|
1980
2433
|
/**
|
|
@@ -1989,12 +2442,12 @@ var AgentService = class {
|
|
|
1989
2442
|
if (this.store.toolCallInput === void 0) {
|
|
1990
2443
|
return;
|
|
1991
2444
|
}
|
|
1992
|
-
const questions = (0,
|
|
2445
|
+
const questions = (0, import_nestjs_agent_core9.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
1993
2446
|
for (const question of questions) {
|
|
1994
2447
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
1995
|
-
const problem = (0,
|
|
2448
|
+
const problem = (0, import_nestjs_agent_core9.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
1996
2449
|
if (problem !== null) {
|
|
1997
|
-
throw new
|
|
2450
|
+
throw new import_common6.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
1998
2451
|
}
|
|
1999
2452
|
}
|
|
2000
2453
|
}
|
|
@@ -2006,21 +2459,21 @@ var AgentService = class {
|
|
|
2006
2459
|
*/
|
|
2007
2460
|
async assertMayDecide(actor, toolCallId2) {
|
|
2008
2461
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
2009
|
-
const approver = approval?.approver ??
|
|
2010
|
-
if (approver ===
|
|
2462
|
+
const approver = approval?.approver ?? import_nestjs_agent_core9.REQUESTER_APPROVER;
|
|
2463
|
+
if (approver === import_nestjs_agent_core9.REQUESTER_APPROVER) {
|
|
2011
2464
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
2012
2465
|
}
|
|
2013
2466
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
2014
2467
|
if (requesterRef === null) {
|
|
2015
|
-
throw new
|
|
2468
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
2016
2469
|
}
|
|
2017
|
-
const allowed = await (0,
|
|
2470
|
+
const allowed = await (0, import_nestjs_agent_core9.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
2018
2471
|
toolCallId: toolCallId2,
|
|
2019
2472
|
approver,
|
|
2020
2473
|
requesterRef
|
|
2021
2474
|
});
|
|
2022
2475
|
if (!allowed) {
|
|
2023
|
-
throw new
|
|
2476
|
+
throw new import_common6.ForbiddenException(`this approval is for ${approver}`);
|
|
2024
2477
|
}
|
|
2025
2478
|
}
|
|
2026
2479
|
/**
|
|
@@ -2036,7 +2489,7 @@ var AgentService = class {
|
|
|
2036
2489
|
}
|
|
2037
2490
|
const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
|
|
2038
2491
|
if (lapsed) {
|
|
2039
|
-
throw new
|
|
2492
|
+
throw new import_common6.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
|
|
2040
2493
|
}
|
|
2041
2494
|
}
|
|
2042
2495
|
/**
|
|
@@ -2049,7 +2502,7 @@ var AgentService = class {
|
|
|
2049
2502
|
async resolveRunForToolCall(toolCallId2) {
|
|
2050
2503
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
2051
2504
|
if (runId === null) {
|
|
2052
|
-
throw new
|
|
2505
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
|
|
2053
2506
|
}
|
|
2054
2507
|
return runId;
|
|
2055
2508
|
}
|
|
@@ -2057,29 +2510,30 @@ var AgentService = class {
|
|
|
2057
2510
|
async assertOwnsActiveStream(actor, runId) {
|
|
2058
2511
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
2059
2512
|
if (owner === null) {
|
|
2060
|
-
throw new
|
|
2513
|
+
throw new import_common6.NotFoundException(`no active run ${runId}`);
|
|
2061
2514
|
}
|
|
2062
2515
|
if (owner !== actor.id) {
|
|
2063
|
-
throw new
|
|
2516
|
+
throw new import_common6.ForbiddenException("run belongs to another actor");
|
|
2064
2517
|
}
|
|
2065
2518
|
}
|
|
2066
2519
|
};
|
|
2067
|
-
AgentService =
|
|
2068
|
-
(0,
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2520
|
+
AgentService = _ts_decorate5([
|
|
2521
|
+
(0, import_common6.Injectable)(),
|
|
2522
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_RUNNER)),
|
|
2523
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_STORE)),
|
|
2524
|
+
_ts_param4(2, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_DEPS_FACTORY)),
|
|
2525
|
+
_ts_param4(3, (0, import_common6.Optional)()),
|
|
2526
|
+
_ts_param4(3, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
|
|
2527
|
+
_ts_param4(4, (0, import_common6.Optional)()),
|
|
2528
|
+
_ts_param4(4, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_MODEL_CATALOG)),
|
|
2529
|
+
_ts_param4(5, (0, import_common6.Optional)()),
|
|
2530
|
+
_ts_param4(5, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_QUOTA_PROVIDER)),
|
|
2531
|
+
_ts_param4(6, (0, import_common6.Optional)()),
|
|
2532
|
+
_ts_param4(6, (0, import_common6.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
|
|
2533
|
+
_ts_param4(7, (0, import_common6.Optional)()),
|
|
2534
|
+
_ts_param4(8, (0, import_common6.Optional)()),
|
|
2535
|
+
_ts_metadata4("design:type", Function),
|
|
2536
|
+
_ts_metadata4("design:paramtypes", [
|
|
2083
2537
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
2084
2538
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
2085
2539
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -2087,13 +2541,14 @@ AgentService = _ts_decorate3([
|
|
|
2087
2541
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
2088
2542
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
2089
2543
|
typeof Pick === "undefined" ? Object : Pick,
|
|
2090
|
-
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
2544
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService,
|
|
2545
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
2091
2546
|
])
|
|
2092
2547
|
], AgentService);
|
|
2093
2548
|
|
|
2094
2549
|
// src/approval-port.adapter.ts
|
|
2095
|
-
var
|
|
2096
|
-
function
|
|
2550
|
+
var import_common7 = require("@nestjs/common");
|
|
2551
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
2097
2552
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2098
2553
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2099
2554
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2106,20 +2561,48 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2106
2561
|
}
|
|
2107
2562
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2108
2563
|
}
|
|
2109
|
-
__name(
|
|
2110
|
-
function
|
|
2564
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
2565
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
2111
2566
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2112
2567
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2113
2568
|
}
|
|
2114
2569
|
}
|
|
2115
|
-
__name(
|
|
2570
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
2571
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2572
|
+
return function(target, key) {
|
|
2573
|
+
decorator(target, key, paramIndex);
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
__name(_ts_param5, "_ts_param");
|
|
2116
2577
|
var AgentApprovalPortAdapter = class {
|
|
2117
2578
|
static {
|
|
2118
2579
|
__name(this, "AgentApprovalPortAdapter");
|
|
2119
2580
|
}
|
|
2120
2581
|
agent;
|
|
2121
|
-
|
|
2582
|
+
proposals;
|
|
2583
|
+
constructor(agent, proposals) {
|
|
2122
2584
|
this.agent = agent;
|
|
2585
|
+
this.proposals = proposals;
|
|
2586
|
+
}
|
|
2587
|
+
async approveActionProposal(actor, target, opts) {
|
|
2588
|
+
if (!this.proposals) throw new import_common7.NotImplementedException("Action proposals unavailable");
|
|
2589
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
2590
|
+
decision: "approved",
|
|
2591
|
+
...opts?.remember !== void 0 ? {
|
|
2592
|
+
remember: opts.remember
|
|
2593
|
+
} : {},
|
|
2594
|
+
via: opts?.decidedVia ?? "console"
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2597
|
+
async rejectActionProposal(actor, target, opts) {
|
|
2598
|
+
if (!this.proposals) throw new import_common7.NotImplementedException("Action proposals unavailable");
|
|
2599
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
2600
|
+
decision: "rejected",
|
|
2601
|
+
...opts?.reason !== void 0 ? {
|
|
2602
|
+
reason: opts.reason
|
|
2603
|
+
} : {},
|
|
2604
|
+
via: opts?.decidedVia ?? "console"
|
|
2605
|
+
});
|
|
2123
2606
|
}
|
|
2124
2607
|
async approve(toolCallId2, opts) {
|
|
2125
2608
|
await this.agent.signalToolCall(toolCallId2, {
|
|
@@ -2150,18 +2633,20 @@ var AgentApprovalPortAdapter = class {
|
|
|
2150
2633
|
});
|
|
2151
2634
|
}
|
|
2152
2635
|
};
|
|
2153
|
-
AgentApprovalPortAdapter =
|
|
2154
|
-
(0,
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2636
|
+
AgentApprovalPortAdapter = _ts_decorate6([
|
|
2637
|
+
(0, import_common7.Injectable)(),
|
|
2638
|
+
_ts_param5(1, (0, import_common7.Optional)()),
|
|
2639
|
+
_ts_metadata5("design:type", Function),
|
|
2640
|
+
_ts_metadata5("design:paramtypes", [
|
|
2641
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2642
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
2158
2643
|
])
|
|
2159
2644
|
], AgentApprovalPortAdapter);
|
|
2160
2645
|
|
|
2161
2646
|
// src/controller/agents.controller.ts
|
|
2162
|
-
var
|
|
2163
|
-
var
|
|
2164
|
-
function
|
|
2647
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
2648
|
+
var import_common8 = require("@nestjs/common");
|
|
2649
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
2165
2650
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2166
2651
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2167
2652
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2174,19 +2659,19 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
2174
2659
|
}
|
|
2175
2660
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2176
2661
|
}
|
|
2177
|
-
__name(
|
|
2178
|
-
function
|
|
2662
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
2663
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
2179
2664
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2180
2665
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2181
2666
|
}
|
|
2182
2667
|
}
|
|
2183
|
-
__name(
|
|
2184
|
-
function
|
|
2668
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
2669
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2185
2670
|
return function(target, key) {
|
|
2186
2671
|
decorator(target, key, paramIndex);
|
|
2187
2672
|
};
|
|
2188
2673
|
}
|
|
2189
|
-
__name(
|
|
2674
|
+
__name(_ts_param6, "_ts_param");
|
|
2190
2675
|
var AgentsController = class {
|
|
2191
2676
|
static {
|
|
2192
2677
|
__name(this, "AgentsController");
|
|
@@ -2217,26 +2702,26 @@ var AgentsController = class {
|
|
|
2217
2702
|
});
|
|
2218
2703
|
}
|
|
2219
2704
|
};
|
|
2220
|
-
|
|
2221
|
-
(0,
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2705
|
+
_ts_decorate7([
|
|
2706
|
+
(0, import_common8.Get)(),
|
|
2707
|
+
_ts_metadata6("design:type", Function),
|
|
2708
|
+
_ts_metadata6("design:paramtypes", []),
|
|
2709
|
+
_ts_metadata6("design:returntype", Array)
|
|
2225
2710
|
], AgentsController.prototype, "list", null);
|
|
2226
|
-
AgentsController =
|
|
2227
|
-
(0,
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
typeof
|
|
2711
|
+
AgentsController = _ts_decorate7([
|
|
2712
|
+
(0, import_common8.Controller)("agents"),
|
|
2713
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_REGISTRY)),
|
|
2714
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core10.AGENT_DEPS_FACTORY)),
|
|
2715
|
+
_ts_metadata6("design:type", Function),
|
|
2716
|
+
_ts_metadata6("design:paramtypes", [
|
|
2717
|
+
typeof import_nestjs_agent_core10.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core10.AgentRegistry,
|
|
2233
2718
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
2234
2719
|
])
|
|
2235
2720
|
], AgentsController);
|
|
2236
2721
|
|
|
2237
2722
|
// src/controller/attachments.controller.ts
|
|
2238
|
-
var
|
|
2239
|
-
var
|
|
2723
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
2724
|
+
var import_common9 = require("@nestjs/common");
|
|
2240
2725
|
var import_platform_express = require("@nestjs/platform-express");
|
|
2241
2726
|
|
|
2242
2727
|
// src/attachment-limits.ts
|
|
@@ -2265,7 +2750,7 @@ function attachmentLimits(options, staging) {
|
|
|
2265
2750
|
__name(attachmentLimits, "attachmentLimits");
|
|
2266
2751
|
|
|
2267
2752
|
// src/controller/attachments.controller.ts
|
|
2268
|
-
function
|
|
2753
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2269
2754
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2270
2755
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2271
2756
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2278,19 +2763,19 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
2278
2763
|
}
|
|
2279
2764
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2280
2765
|
}
|
|
2281
|
-
__name(
|
|
2282
|
-
function
|
|
2766
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2767
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
2283
2768
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2284
2769
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2285
2770
|
}
|
|
2286
2771
|
}
|
|
2287
|
-
__name(
|
|
2288
|
-
function
|
|
2772
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2773
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2289
2774
|
return function(target, key) {
|
|
2290
2775
|
decorator(target, key, paramIndex);
|
|
2291
2776
|
};
|
|
2292
2777
|
}
|
|
2293
|
-
__name(
|
|
2778
|
+
__name(_ts_param7, "_ts_param");
|
|
2294
2779
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
2295
2780
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
2296
2781
|
var AttachmentsController = class {
|
|
@@ -2324,17 +2809,17 @@ var AttachmentsController = class {
|
|
|
2324
2809
|
}
|
|
2325
2810
|
async upload(req, file) {
|
|
2326
2811
|
if (this.staging === void 0) {
|
|
2327
|
-
throw new
|
|
2812
|
+
throw new import_common9.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
2328
2813
|
}
|
|
2329
2814
|
if (file === void 0) {
|
|
2330
|
-
throw new
|
|
2815
|
+
throw new import_common9.BadRequestException('multipart field "file" is required');
|
|
2331
2816
|
}
|
|
2332
2817
|
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
2333
2818
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
2334
|
-
throw new
|
|
2819
|
+
throw new import_common9.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
2335
2820
|
}
|
|
2336
2821
|
if (file.size > maxBytes) {
|
|
2337
|
-
throw new
|
|
2822
|
+
throw new import_common9.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
2338
2823
|
}
|
|
2339
2824
|
const actor = await this.actorResolver.resolve(req);
|
|
2340
2825
|
return this.staging.stage({
|
|
@@ -2346,39 +2831,39 @@ var AttachmentsController = class {
|
|
|
2346
2831
|
});
|
|
2347
2832
|
}
|
|
2348
2833
|
};
|
|
2349
|
-
|
|
2350
|
-
(0,
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2834
|
+
_ts_decorate8([
|
|
2835
|
+
(0, import_common9.Get)(),
|
|
2836
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
2837
|
+
_ts_metadata7("design:type", Function),
|
|
2838
|
+
_ts_metadata7("design:paramtypes", [
|
|
2354
2839
|
typeof Request === "undefined" ? Object : Request
|
|
2355
2840
|
]),
|
|
2356
|
-
|
|
2841
|
+
_ts_metadata7("design:returntype", Promise)
|
|
2357
2842
|
], AttachmentsController.prototype, "list", null);
|
|
2358
|
-
|
|
2359
|
-
(0,
|
|
2360
|
-
(0,
|
|
2843
|
+
_ts_decorate8([
|
|
2844
|
+
(0, import_common9.Post)(),
|
|
2845
|
+
(0, import_common9.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
|
|
2361
2846
|
limits: {
|
|
2362
2847
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
2363
2848
|
}
|
|
2364
2849
|
})),
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2850
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
2851
|
+
_ts_param7(1, (0, import_common9.UploadedFile)()),
|
|
2852
|
+
_ts_metadata7("design:type", Function),
|
|
2853
|
+
_ts_metadata7("design:paramtypes", [
|
|
2369
2854
|
typeof Request === "undefined" ? Object : Request,
|
|
2370
2855
|
Object
|
|
2371
2856
|
]),
|
|
2372
|
-
|
|
2857
|
+
_ts_metadata7("design:returntype", Promise)
|
|
2373
2858
|
], AttachmentsController.prototype, "upload", null);
|
|
2374
|
-
AttachmentsController =
|
|
2375
|
-
(0,
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2859
|
+
AttachmentsController = _ts_decorate8([
|
|
2860
|
+
(0, import_common9.Controller)("attachments"),
|
|
2861
|
+
_ts_param7(0, (0, import_common9.Inject)(import_nestjs_agent_core11.AGENT_OPTIONS)),
|
|
2862
|
+
_ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
|
|
2863
|
+
_ts_param7(3, (0, import_common9.Optional)()),
|
|
2864
|
+
_ts_param7(3, (0, import_common9.Inject)(import_nestjs_agent_core11.AGENT_ATTACHMENT_STAGING)),
|
|
2865
|
+
_ts_metadata7("design:type", Function),
|
|
2866
|
+
_ts_metadata7("design:paramtypes", [
|
|
2382
2867
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2383
2868
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2384
2869
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2387,9 +2872,10 @@ AttachmentsController = _ts_decorate6([
|
|
|
2387
2872
|
], AttachmentsController);
|
|
2388
2873
|
|
|
2389
2874
|
// src/controller/chat.controller.ts
|
|
2390
|
-
var
|
|
2391
|
-
var
|
|
2392
|
-
|
|
2875
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
2876
|
+
var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
|
|
2877
|
+
var import_common10 = require("@nestjs/common");
|
|
2878
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2393
2879
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2394
2880
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2395
2881
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2402,19 +2888,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
2402
2888
|
}
|
|
2403
2889
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2404
2890
|
}
|
|
2405
|
-
__name(
|
|
2406
|
-
function
|
|
2891
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2892
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
2407
2893
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2408
2894
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2409
2895
|
}
|
|
2410
2896
|
}
|
|
2411
|
-
__name(
|
|
2412
|
-
function
|
|
2897
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2898
|
+
function _ts_param8(paramIndex, decorator) {
|
|
2413
2899
|
return function(target, key) {
|
|
2414
2900
|
decorator(target, key, paramIndex);
|
|
2415
2901
|
};
|
|
2416
2902
|
}
|
|
2417
|
-
__name(
|
|
2903
|
+
__name(_ts_param8, "_ts_param");
|
|
2418
2904
|
function sendMode(body) {
|
|
2419
2905
|
if (body.interrupt === true) {
|
|
2420
2906
|
return "interrupt";
|
|
@@ -2425,7 +2911,7 @@ function sendMode(body) {
|
|
|
2425
2911
|
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
2426
2912
|
return body.mode;
|
|
2427
2913
|
}
|
|
2428
|
-
throw new
|
|
2914
|
+
throw new import_common10.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
|
|
2429
2915
|
}
|
|
2430
2916
|
__name(sendMode, "sendMode");
|
|
2431
2917
|
function attachmentRefs(claimed) {
|
|
@@ -2433,21 +2919,21 @@ function attachmentRefs(claimed) {
|
|
|
2433
2919
|
return [];
|
|
2434
2920
|
}
|
|
2435
2921
|
if (!Array.isArray(claimed)) {
|
|
2436
|
-
throw new
|
|
2922
|
+
throw new import_common10.BadRequestException("attachments must be an array of { mediaId }");
|
|
2437
2923
|
}
|
|
2438
2924
|
if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
2439
|
-
throw new
|
|
2925
|
+
throw new import_common10.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
|
|
2440
2926
|
}
|
|
2441
2927
|
return claimed.map((entry) => {
|
|
2442
2928
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
2443
|
-
throw new
|
|
2929
|
+
throw new import_common10.BadRequestException("each attachment must be an object with a mediaId");
|
|
2444
2930
|
}
|
|
2445
2931
|
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
2446
|
-
throw new
|
|
2932
|
+
throw new import_common10.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
2447
2933
|
}
|
|
2448
2934
|
const { mediaId } = entry;
|
|
2449
2935
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
2450
|
-
throw new
|
|
2936
|
+
throw new import_common10.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
2451
2937
|
}
|
|
2452
2938
|
return {
|
|
2453
2939
|
mediaId
|
|
@@ -2475,9 +2961,18 @@ var ChatController = class {
|
|
|
2475
2961
|
const actor = await this.actorResolver.resolve(req);
|
|
2476
2962
|
const attachments = attachmentRefs(body.attachments);
|
|
2477
2963
|
const mode = sendMode(body);
|
|
2964
|
+
let uiCapabilities;
|
|
2965
|
+
try {
|
|
2966
|
+
uiCapabilities = body.uiCapabilities === void 0 ? void 0 : (0, import_genui2.validateUiCapabilities)(body.uiCapabilities);
|
|
2967
|
+
} catch {
|
|
2968
|
+
throw new import_common10.BadRequestException("Invalid UI capabilities");
|
|
2969
|
+
}
|
|
2478
2970
|
const result = await this.agent.send({
|
|
2479
2971
|
actor,
|
|
2480
2972
|
message: body.message,
|
|
2973
|
+
...uiCapabilities !== void 0 ? {
|
|
2974
|
+
uiCapabilities
|
|
2975
|
+
} : {},
|
|
2481
2976
|
...body.threadId !== void 0 ? {
|
|
2482
2977
|
threadId: body.threadId
|
|
2483
2978
|
} : {},
|
|
@@ -2504,6 +2999,10 @@ var ChatController = class {
|
|
|
2504
2999
|
} : {},
|
|
2505
3000
|
mode
|
|
2506
3001
|
});
|
|
3002
|
+
if ("proposalDecision" in result) {
|
|
3003
|
+
res.status(200).json(result);
|
|
3004
|
+
return;
|
|
3005
|
+
}
|
|
2507
3006
|
if (result.queued === true) {
|
|
2508
3007
|
res.status(202).json(result);
|
|
2509
3008
|
return;
|
|
@@ -2583,10 +3082,10 @@ data: ${line}
|
|
|
2583
3082
|
}
|
|
2584
3083
|
res.write("event: done\ndata: {}\n\n");
|
|
2585
3084
|
} catch (error) {
|
|
2586
|
-
const payload = error instanceof
|
|
3085
|
+
const payload = error instanceof import_nestjs_agent_core12.AgentStreamError ? {
|
|
2587
3086
|
code: error.code,
|
|
2588
3087
|
message: error.message
|
|
2589
|
-
} : (0,
|
|
3088
|
+
} : (0, import_nestjs_agent_core12.streamFailure)(error);
|
|
2590
3089
|
res.write(`event: error
|
|
2591
3090
|
data: ${JSON.stringify(payload)}
|
|
2592
3091
|
|
|
@@ -2595,50 +3094,50 @@ data: ${JSON.stringify(payload)}
|
|
|
2595
3094
|
res.end();
|
|
2596
3095
|
}
|
|
2597
3096
|
};
|
|
2598
|
-
|
|
2599
|
-
(0,
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3097
|
+
_ts_decorate9([
|
|
3098
|
+
(0, import_common10.Post)("chat"),
|
|
3099
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
3100
|
+
_ts_param8(1, (0, import_common10.Res)()),
|
|
3101
|
+
_ts_param8(2, (0, import_common10.Body)()),
|
|
3102
|
+
_ts_metadata8("design:type", Function),
|
|
3103
|
+
_ts_metadata8("design:paramtypes", [
|
|
2605
3104
|
typeof Request === "undefined" ? Object : Request,
|
|
2606
3105
|
typeof Response === "undefined" ? Object : Response,
|
|
2607
3106
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
2608
3107
|
]),
|
|
2609
|
-
|
|
3108
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2610
3109
|
], ChatController.prototype, "chat", null);
|
|
2611
|
-
|
|
2612
|
-
(0,
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
3110
|
+
_ts_decorate9([
|
|
3111
|
+
(0, import_common10.Get)("chat/:runId/stream"),
|
|
3112
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
3113
|
+
_ts_param8(1, (0, import_common10.Param)("runId")),
|
|
3114
|
+
_ts_param8(2, (0, import_common10.Res)()),
|
|
3115
|
+
_ts_param8(3, (0, import_common10.Query)("after")),
|
|
3116
|
+
_ts_metadata8("design:type", Function),
|
|
3117
|
+
_ts_metadata8("design:paramtypes", [
|
|
2619
3118
|
typeof Request === "undefined" ? Object : Request,
|
|
2620
3119
|
String,
|
|
2621
3120
|
typeof Response === "undefined" ? Object : Response,
|
|
2622
3121
|
String
|
|
2623
3122
|
]),
|
|
2624
|
-
|
|
3123
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2625
3124
|
], ChatController.prototype, "stream", null);
|
|
2626
|
-
|
|
2627
|
-
(0,
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
3125
|
+
_ts_decorate9([
|
|
3126
|
+
(0, import_common10.Post)("chat/:runId/cancel"),
|
|
3127
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
3128
|
+
_ts_param8(1, (0, import_common10.Param)("runId")),
|
|
3129
|
+
_ts_metadata8("design:type", Function),
|
|
3130
|
+
_ts_metadata8("design:paramtypes", [
|
|
2632
3131
|
typeof Request === "undefined" ? Object : Request,
|
|
2633
3132
|
String
|
|
2634
3133
|
]),
|
|
2635
|
-
|
|
3134
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2636
3135
|
], ChatController.prototype, "cancel", null);
|
|
2637
|
-
ChatController =
|
|
2638
|
-
(0,
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
3136
|
+
ChatController = _ts_decorate9([
|
|
3137
|
+
(0, import_common10.Controller)(),
|
|
3138
|
+
_ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
3139
|
+
_ts_metadata8("design:type", Function),
|
|
3140
|
+
_ts_metadata8("design:paramtypes", [
|
|
2642
3141
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2643
3142
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2644
3143
|
])
|
|
@@ -2654,8 +3153,8 @@ function parseCursor(raw) {
|
|
|
2654
3153
|
__name(parseCursor, "parseCursor");
|
|
2655
3154
|
|
|
2656
3155
|
// src/controller/config.controller.ts
|
|
2657
|
-
var
|
|
2658
|
-
var
|
|
3156
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
3157
|
+
var import_common11 = require("@nestjs/common");
|
|
2659
3158
|
|
|
2660
3159
|
// src/resolver/anonymous-actor-resolver.ts
|
|
2661
3160
|
var import_node_crypto = require("crypto");
|
|
@@ -2745,7 +3244,7 @@ var AnonymousActorResolver = class {
|
|
|
2745
3244
|
};
|
|
2746
3245
|
|
|
2747
3246
|
// src/controller/config.controller.ts
|
|
2748
|
-
function
|
|
3247
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2749
3248
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2750
3249
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2751
3250
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2758,19 +3257,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2758
3257
|
}
|
|
2759
3258
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2760
3259
|
}
|
|
2761
|
-
__name(
|
|
2762
|
-
function
|
|
3260
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
3261
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
2763
3262
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2764
3263
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2765
3264
|
}
|
|
2766
3265
|
}
|
|
2767
|
-
__name(
|
|
2768
|
-
function
|
|
3266
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
3267
|
+
function _ts_param9(paramIndex, decorator) {
|
|
2769
3268
|
return function(target, key) {
|
|
2770
3269
|
decorator(target, key, paramIndex);
|
|
2771
3270
|
};
|
|
2772
3271
|
}
|
|
2773
|
-
__name(
|
|
3272
|
+
__name(_ts_param9, "_ts_param");
|
|
2774
3273
|
var ConfigController = class {
|
|
2775
3274
|
static {
|
|
2776
3275
|
__name(this, "ConfigController");
|
|
@@ -2801,25 +3300,25 @@ var ConfigController = class {
|
|
|
2801
3300
|
};
|
|
2802
3301
|
}
|
|
2803
3302
|
};
|
|
2804
|
-
|
|
2805
|
-
(0,
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
3303
|
+
_ts_decorate10([
|
|
3304
|
+
(0, import_common11.Get)(),
|
|
3305
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
3306
|
+
_ts_metadata9("design:type", Function),
|
|
3307
|
+
_ts_metadata9("design:paramtypes", [
|
|
2809
3308
|
typeof Request === "undefined" ? Object : Request
|
|
2810
3309
|
]),
|
|
2811
|
-
|
|
3310
|
+
_ts_metadata9("design:returntype", Promise)
|
|
2812
3311
|
], ConfigController.prototype, "config", null);
|
|
2813
|
-
ConfigController =
|
|
2814
|
-
(0,
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
3312
|
+
ConfigController = _ts_decorate10([
|
|
3313
|
+
(0, import_common11.Controller)("config"),
|
|
3314
|
+
_ts_param9(0, (0, import_common11.Inject)(import_nestjs_agent_core13.AGENT_OPTIONS)),
|
|
3315
|
+
_ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
3316
|
+
_ts_param9(2, (0, import_common11.Optional)()),
|
|
3317
|
+
_ts_param9(2, (0, import_common11.Inject)(import_nestjs_agent_core13.AGENT_ATTACHMENT_STAGING)),
|
|
3318
|
+
_ts_param9(3, (0, import_common11.Optional)()),
|
|
3319
|
+
_ts_param9(3, (0, import_common11.Inject)(import_nestjs_agent_core13.AGENT_MODEL_CATALOG)),
|
|
3320
|
+
_ts_metadata9("design:type", Function),
|
|
3321
|
+
_ts_metadata9("design:paramtypes", [
|
|
2823
3322
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2824
3323
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2825
3324
|
Object,
|
|
@@ -2828,9 +3327,9 @@ ConfigController = _ts_decorate8([
|
|
|
2828
3327
|
], ConfigController);
|
|
2829
3328
|
|
|
2830
3329
|
// src/controller/memories.controller.ts
|
|
2831
|
-
var
|
|
2832
|
-
var
|
|
2833
|
-
function
|
|
3330
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
3331
|
+
var import_common12 = require("@nestjs/common");
|
|
3332
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2834
3333
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2835
3334
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2836
3335
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2843,19 +3342,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
2843
3342
|
}
|
|
2844
3343
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2845
3344
|
}
|
|
2846
|
-
__name(
|
|
2847
|
-
function
|
|
3345
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
3346
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
2848
3347
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2849
3348
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2850
3349
|
}
|
|
2851
3350
|
}
|
|
2852
|
-
__name(
|
|
2853
|
-
function
|
|
3351
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
3352
|
+
function _ts_param10(paramIndex, decorator) {
|
|
2854
3353
|
return function(target, key) {
|
|
2855
3354
|
decorator(target, key, paramIndex);
|
|
2856
3355
|
};
|
|
2857
3356
|
}
|
|
2858
|
-
__name(
|
|
3357
|
+
__name(_ts_param10, "_ts_param");
|
|
2859
3358
|
var MemoriesController = class {
|
|
2860
3359
|
static {
|
|
2861
3360
|
__name(this, "MemoriesController");
|
|
@@ -2889,20 +3388,20 @@ var MemoriesController = class {
|
|
|
2889
3388
|
*/
|
|
2890
3389
|
async forget(req, id) {
|
|
2891
3390
|
if (this.memory === void 0) {
|
|
2892
|
-
throw new
|
|
3391
|
+
throw new import_common12.NotFoundException("No memory is configured in this deployment.");
|
|
2893
3392
|
}
|
|
2894
3393
|
const actor = await this.actorResolver.resolve(req);
|
|
2895
3394
|
const digest = await this.unbounded("", actor);
|
|
2896
3395
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
2897
3396
|
if (entry === void 0) {
|
|
2898
|
-
throw new
|
|
3397
|
+
throw new import_common12.NotFoundException(`No memory with id "${id}".`);
|
|
2899
3398
|
}
|
|
2900
|
-
const verdict = (0,
|
|
3399
|
+
const verdict = (0, import_nestjs_agent_core14.memoryForgetVerdict)({
|
|
2901
3400
|
record: entry,
|
|
2902
3401
|
actor
|
|
2903
3402
|
});
|
|
2904
3403
|
if (!verdict.allowed) {
|
|
2905
|
-
throw new
|
|
3404
|
+
throw new import_common12.ForbiddenException(verdict.reason);
|
|
2906
3405
|
}
|
|
2907
3406
|
return {
|
|
2908
3407
|
forgotten: await this.memory.provider.forget({
|
|
@@ -2916,7 +3415,7 @@ var MemoriesController = class {
|
|
|
2916
3415
|
}
|
|
2917
3416
|
async unbounded(threadId, actor) {
|
|
2918
3417
|
const config = this.memory;
|
|
2919
|
-
return await (0,
|
|
3418
|
+
return await (0, import_nestjs_agent_core14.offerMemories)({
|
|
2920
3419
|
config: {
|
|
2921
3420
|
...config,
|
|
2922
3421
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -2928,44 +3427,44 @@ var MemoriesController = class {
|
|
|
2928
3427
|
});
|
|
2929
3428
|
}
|
|
2930
3429
|
};
|
|
2931
|
-
|
|
2932
|
-
(0,
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
3430
|
+
_ts_decorate11([
|
|
3431
|
+
(0, import_common12.Get)(),
|
|
3432
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
3433
|
+
_ts_param10(1, (0, import_common12.Query)("threadId")),
|
|
3434
|
+
_ts_metadata10("design:type", Function),
|
|
3435
|
+
_ts_metadata10("design:paramtypes", [
|
|
2937
3436
|
typeof Request === "undefined" ? Object : Request,
|
|
2938
3437
|
String
|
|
2939
3438
|
]),
|
|
2940
|
-
|
|
3439
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2941
3440
|
], MemoriesController.prototype, "list", null);
|
|
2942
|
-
|
|
2943
|
-
(0,
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3441
|
+
_ts_decorate11([
|
|
3442
|
+
(0, import_common12.Delete)(":id"),
|
|
3443
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
3444
|
+
_ts_param10(1, (0, import_common12.Param)("id")),
|
|
3445
|
+
_ts_metadata10("design:type", Function),
|
|
3446
|
+
_ts_metadata10("design:paramtypes", [
|
|
2948
3447
|
typeof Request === "undefined" ? Object : Request,
|
|
2949
3448
|
String
|
|
2950
3449
|
]),
|
|
2951
|
-
|
|
3450
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2952
3451
|
], MemoriesController.prototype, "forget", null);
|
|
2953
|
-
MemoriesController =
|
|
2954
|
-
(0,
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
3452
|
+
MemoriesController = _ts_decorate11([
|
|
3453
|
+
(0, import_common12.Controller)("memories"),
|
|
3454
|
+
_ts_param10(0, (0, import_common12.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
3455
|
+
_ts_param10(1, (0, import_common12.Optional)()),
|
|
3456
|
+
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core14.AGENT_MEMORY)),
|
|
3457
|
+
_ts_metadata10("design:type", Function),
|
|
3458
|
+
_ts_metadata10("design:paramtypes", [
|
|
2960
3459
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2961
3460
|
Object
|
|
2962
3461
|
])
|
|
2963
3462
|
], MemoriesController);
|
|
2964
3463
|
|
|
2965
3464
|
// src/controller/messages.controller.ts
|
|
2966
|
-
var
|
|
2967
|
-
var
|
|
2968
|
-
function
|
|
3465
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
3466
|
+
var import_common13 = require("@nestjs/common");
|
|
3467
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2969
3468
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2970
3469
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2971
3470
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2978,19 +3477,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
2978
3477
|
}
|
|
2979
3478
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2980
3479
|
}
|
|
2981
|
-
__name(
|
|
2982
|
-
function
|
|
3480
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3481
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2983
3482
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2984
3483
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2985
3484
|
}
|
|
2986
3485
|
}
|
|
2987
|
-
__name(
|
|
2988
|
-
function
|
|
3486
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
3487
|
+
function _ts_param11(paramIndex, decorator) {
|
|
2989
3488
|
return function(target, key) {
|
|
2990
3489
|
decorator(target, key, paramIndex);
|
|
2991
3490
|
};
|
|
2992
3491
|
}
|
|
2993
|
-
__name(
|
|
3492
|
+
__name(_ts_param11, "_ts_param");
|
|
2994
3493
|
var MessagesController = class {
|
|
2995
3494
|
static {
|
|
2996
3495
|
__name(this, "MessagesController");
|
|
@@ -3018,34 +3517,34 @@ var MessagesController = class {
|
|
|
3018
3517
|
};
|
|
3019
3518
|
}
|
|
3020
3519
|
};
|
|
3021
|
-
|
|
3022
|
-
(0,
|
|
3023
|
-
(0,
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3520
|
+
_ts_decorate12([
|
|
3521
|
+
(0, import_common13.Post)(":id/feedback"),
|
|
3522
|
+
(0, import_common13.HttpCode)(200),
|
|
3523
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
3524
|
+
_ts_param11(1, (0, import_common13.Param)("id")),
|
|
3525
|
+
_ts_param11(2, (0, import_common13.Body)()),
|
|
3526
|
+
_ts_metadata11("design:type", Function),
|
|
3527
|
+
_ts_metadata11("design:paramtypes", [
|
|
3029
3528
|
typeof Request === "undefined" ? Object : Request,
|
|
3030
3529
|
String,
|
|
3031
3530
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
3032
3531
|
]),
|
|
3033
|
-
|
|
3532
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3034
3533
|
], MessagesController.prototype, "feedback", null);
|
|
3035
|
-
MessagesController =
|
|
3036
|
-
(0,
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3534
|
+
MessagesController = _ts_decorate12([
|
|
3535
|
+
(0, import_common13.Controller)("messages"),
|
|
3536
|
+
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
3537
|
+
_ts_metadata11("design:type", Function),
|
|
3538
|
+
_ts_metadata11("design:paramtypes", [
|
|
3040
3539
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3041
3540
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3042
3541
|
])
|
|
3043
3542
|
], MessagesController);
|
|
3044
3543
|
|
|
3045
3544
|
// src/controller/models.controller.ts
|
|
3046
|
-
var
|
|
3047
|
-
var
|
|
3048
|
-
function
|
|
3545
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
3546
|
+
var import_common14 = require("@nestjs/common");
|
|
3547
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
3049
3548
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3050
3549
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3051
3550
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3058,19 +3557,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
3058
3557
|
}
|
|
3059
3558
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3060
3559
|
}
|
|
3061
|
-
__name(
|
|
3062
|
-
function
|
|
3560
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3561
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
3063
3562
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3064
3563
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3065
3564
|
}
|
|
3066
3565
|
}
|
|
3067
|
-
__name(
|
|
3068
|
-
function
|
|
3566
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3567
|
+
function _ts_param12(paramIndex, decorator) {
|
|
3069
3568
|
return function(target, key) {
|
|
3070
3569
|
decorator(target, key, paramIndex);
|
|
3071
3570
|
};
|
|
3072
3571
|
}
|
|
3073
|
-
__name(
|
|
3572
|
+
__name(_ts_param12, "_ts_param");
|
|
3074
3573
|
var ModelsController = class {
|
|
3075
3574
|
static {
|
|
3076
3575
|
__name(this, "ModelsController");
|
|
@@ -3090,31 +3589,31 @@ var ModelsController = class {
|
|
|
3090
3589
|
return this.agent.listModels(actor, agent);
|
|
3091
3590
|
}
|
|
3092
3591
|
};
|
|
3093
|
-
|
|
3094
|
-
(0,
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3592
|
+
_ts_decorate13([
|
|
3593
|
+
(0, import_common14.Get)(),
|
|
3594
|
+
_ts_param12(0, (0, import_common14.Req)()),
|
|
3595
|
+
_ts_param12(1, (0, import_common14.Query)("agent")),
|
|
3596
|
+
_ts_metadata12("design:type", Function),
|
|
3597
|
+
_ts_metadata12("design:paramtypes", [
|
|
3099
3598
|
typeof Request === "undefined" ? Object : Request,
|
|
3100
3599
|
String
|
|
3101
3600
|
]),
|
|
3102
|
-
|
|
3601
|
+
_ts_metadata12("design:returntype", Promise)
|
|
3103
3602
|
], ModelsController.prototype, "list", null);
|
|
3104
|
-
ModelsController =
|
|
3105
|
-
(0,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3603
|
+
ModelsController = _ts_decorate13([
|
|
3604
|
+
(0, import_common14.Controller)("models"),
|
|
3605
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
3606
|
+
_ts_metadata12("design:type", Function),
|
|
3607
|
+
_ts_metadata12("design:paramtypes", [
|
|
3109
3608
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3110
3609
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3111
3610
|
])
|
|
3112
3611
|
], ModelsController);
|
|
3113
3612
|
|
|
3114
3613
|
// src/controller/queue.controller.ts
|
|
3115
|
-
var
|
|
3116
|
-
var
|
|
3117
|
-
function
|
|
3614
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3615
|
+
var import_common15 = require("@nestjs/common");
|
|
3616
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
3118
3617
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3119
3618
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3120
3619
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3127,19 +3626,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3127
3626
|
}
|
|
3128
3627
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3129
3628
|
}
|
|
3130
|
-
__name(
|
|
3131
|
-
function
|
|
3629
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
3630
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3132
3631
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3133
3632
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3134
3633
|
}
|
|
3135
3634
|
}
|
|
3136
|
-
__name(
|
|
3137
|
-
function
|
|
3635
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3636
|
+
function _ts_param13(paramIndex, decorator) {
|
|
3138
3637
|
return function(target, key) {
|
|
3139
3638
|
decorator(target, key, paramIndex);
|
|
3140
3639
|
};
|
|
3141
3640
|
}
|
|
3142
|
-
__name(
|
|
3641
|
+
__name(_ts_param13, "_ts_param");
|
|
3143
3642
|
var QueueController = class {
|
|
3144
3643
|
static {
|
|
3145
3644
|
__name(this, "QueueController");
|
|
@@ -3163,10 +3662,10 @@ var QueueController = class {
|
|
|
3163
3662
|
async update(req, messageId, body) {
|
|
3164
3663
|
const actor = await this.actorResolver.resolve(req);
|
|
3165
3664
|
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
3166
|
-
throw new
|
|
3665
|
+
throw new import_common15.BadRequestException("message must be a string");
|
|
3167
3666
|
}
|
|
3168
3667
|
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
3169
|
-
throw new
|
|
3668
|
+
throw new import_common15.BadRequestException("position must be a number");
|
|
3170
3669
|
}
|
|
3171
3670
|
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
3172
3671
|
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
@@ -3193,88 +3692,88 @@ var QueueController = class {
|
|
|
3193
3692
|
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
3194
3693
|
}
|
|
3195
3694
|
};
|
|
3196
|
-
|
|
3197
|
-
(0,
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3695
|
+
_ts_decorate14([
|
|
3696
|
+
(0, import_common15.Get)("threads/:id/queue"),
|
|
3697
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3698
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
3699
|
+
_ts_metadata13("design:type", Function),
|
|
3700
|
+
_ts_metadata13("design:paramtypes", [
|
|
3202
3701
|
typeof Request === "undefined" ? Object : Request,
|
|
3203
3702
|
String
|
|
3204
3703
|
]),
|
|
3205
|
-
|
|
3704
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3206
3705
|
], QueueController.prototype, "list", null);
|
|
3207
|
-
|
|
3208
|
-
(0,
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3706
|
+
_ts_decorate14([
|
|
3707
|
+
(0, import_common15.Delete)("threads/:id/queue"),
|
|
3708
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3709
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
3710
|
+
_ts_metadata13("design:type", Function),
|
|
3711
|
+
_ts_metadata13("design:paramtypes", [
|
|
3213
3712
|
typeof Request === "undefined" ? Object : Request,
|
|
3214
3713
|
String
|
|
3215
3714
|
]),
|
|
3216
|
-
|
|
3715
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3217
3716
|
], QueueController.prototype, "clear", null);
|
|
3218
|
-
|
|
3219
|
-
(0,
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3717
|
+
_ts_decorate14([
|
|
3718
|
+
(0, import_common15.Post)("threads/:id/queue/resume"),
|
|
3719
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3720
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
3721
|
+
_ts_metadata13("design:type", Function),
|
|
3722
|
+
_ts_metadata13("design:paramtypes", [
|
|
3224
3723
|
typeof Request === "undefined" ? Object : Request,
|
|
3225
3724
|
String
|
|
3226
3725
|
]),
|
|
3227
|
-
|
|
3726
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3228
3727
|
], QueueController.prototype, "resume", null);
|
|
3229
|
-
|
|
3230
|
-
(0,
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3728
|
+
_ts_decorate14([
|
|
3729
|
+
(0, import_common15.Patch)("queue/:messageId"),
|
|
3730
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3731
|
+
_ts_param13(1, (0, import_common15.Param)("messageId")),
|
|
3732
|
+
_ts_param13(2, (0, import_common15.Body)()),
|
|
3733
|
+
_ts_metadata13("design:type", Function),
|
|
3734
|
+
_ts_metadata13("design:paramtypes", [
|
|
3236
3735
|
typeof Request === "undefined" ? Object : Request,
|
|
3237
3736
|
String,
|
|
3238
3737
|
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
3239
3738
|
]),
|
|
3240
|
-
|
|
3739
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3241
3740
|
], QueueController.prototype, "update", null);
|
|
3242
|
-
|
|
3243
|
-
(0,
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3741
|
+
_ts_decorate14([
|
|
3742
|
+
(0, import_common15.Post)("queue/:messageId/interrupt"),
|
|
3743
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3744
|
+
_ts_param13(1, (0, import_common15.Param)("messageId")),
|
|
3745
|
+
_ts_metadata13("design:type", Function),
|
|
3746
|
+
_ts_metadata13("design:paramtypes", [
|
|
3248
3747
|
typeof Request === "undefined" ? Object : Request,
|
|
3249
3748
|
String
|
|
3250
3749
|
]),
|
|
3251
|
-
|
|
3750
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3252
3751
|
], QueueController.prototype, "interrupt", null);
|
|
3253
|
-
|
|
3254
|
-
(0,
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3752
|
+
_ts_decorate14([
|
|
3753
|
+
(0, import_common15.Delete)("queue/:messageId"),
|
|
3754
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3755
|
+
_ts_param13(1, (0, import_common15.Param)("messageId")),
|
|
3756
|
+
_ts_metadata13("design:type", Function),
|
|
3757
|
+
_ts_metadata13("design:paramtypes", [
|
|
3259
3758
|
typeof Request === "undefined" ? Object : Request,
|
|
3260
3759
|
String
|
|
3261
3760
|
]),
|
|
3262
|
-
|
|
3761
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3263
3762
|
], QueueController.prototype, "remove", null);
|
|
3264
|
-
QueueController =
|
|
3265
|
-
(0,
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3763
|
+
QueueController = _ts_decorate14([
|
|
3764
|
+
(0, import_common15.Controller)(),
|
|
3765
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
3766
|
+
_ts_metadata13("design:type", Function),
|
|
3767
|
+
_ts_metadata13("design:paramtypes", [
|
|
3269
3768
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3270
3769
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3271
3770
|
])
|
|
3272
3771
|
], QueueController);
|
|
3273
3772
|
|
|
3274
3773
|
// src/controller/quota.controller.ts
|
|
3275
|
-
var
|
|
3276
|
-
var
|
|
3277
|
-
function
|
|
3774
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3775
|
+
var import_common16 = require("@nestjs/common");
|
|
3776
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
3278
3777
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3279
3778
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3280
3779
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3287,19 +3786,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
3287
3786
|
}
|
|
3288
3787
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3289
3788
|
}
|
|
3290
|
-
__name(
|
|
3291
|
-
function
|
|
3789
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3790
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
3292
3791
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3293
3792
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3294
3793
|
}
|
|
3295
3794
|
}
|
|
3296
|
-
__name(
|
|
3297
|
-
function
|
|
3795
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
3796
|
+
function _ts_param14(paramIndex, decorator) {
|
|
3298
3797
|
return function(target, key) {
|
|
3299
3798
|
decorator(target, key, paramIndex);
|
|
3300
3799
|
};
|
|
3301
3800
|
}
|
|
3302
|
-
__name(
|
|
3801
|
+
__name(_ts_param14, "_ts_param");
|
|
3303
3802
|
var QuotaController = class {
|
|
3304
3803
|
static {
|
|
3305
3804
|
__name(this, "QuotaController");
|
|
@@ -3319,29 +3818,29 @@ var QuotaController = class {
|
|
|
3319
3818
|
return this.agent.quotaReport(actor);
|
|
3320
3819
|
}
|
|
3321
3820
|
};
|
|
3322
|
-
|
|
3323
|
-
(0,
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3821
|
+
_ts_decorate15([
|
|
3822
|
+
(0, import_common16.Get)(),
|
|
3823
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3824
|
+
_ts_metadata14("design:type", Function),
|
|
3825
|
+
_ts_metadata14("design:paramtypes", [
|
|
3327
3826
|
typeof Request === "undefined" ? Object : Request
|
|
3328
3827
|
]),
|
|
3329
|
-
|
|
3828
|
+
_ts_metadata14("design:returntype", Promise)
|
|
3330
3829
|
], QuotaController.prototype, "report", null);
|
|
3331
|
-
QuotaController =
|
|
3332
|
-
(0,
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3830
|
+
QuotaController = _ts_decorate15([
|
|
3831
|
+
(0, import_common16.Controller)("quota"),
|
|
3832
|
+
_ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3833
|
+
_ts_metadata14("design:type", Function),
|
|
3834
|
+
_ts_metadata14("design:paramtypes", [
|
|
3336
3835
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3337
3836
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3338
3837
|
])
|
|
3339
3838
|
], QuotaController);
|
|
3340
3839
|
|
|
3341
3840
|
// src/controller/skills.controller.ts
|
|
3342
|
-
var
|
|
3343
|
-
var
|
|
3344
|
-
function
|
|
3841
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3842
|
+
var import_common17 = require("@nestjs/common");
|
|
3843
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
3345
3844
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3346
3845
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3347
3846
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3354,19 +3853,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
3354
3853
|
}
|
|
3355
3854
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3356
3855
|
}
|
|
3357
|
-
__name(
|
|
3358
|
-
function
|
|
3856
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3857
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
3359
3858
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3360
3859
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3361
3860
|
}
|
|
3362
3861
|
}
|
|
3363
|
-
__name(
|
|
3364
|
-
function
|
|
3862
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3863
|
+
function _ts_param15(paramIndex, decorator) {
|
|
3365
3864
|
return function(target, key) {
|
|
3366
3865
|
decorator(target, key, paramIndex);
|
|
3367
3866
|
};
|
|
3368
3867
|
}
|
|
3369
|
-
__name(
|
|
3868
|
+
__name(_ts_param15, "_ts_param");
|
|
3370
3869
|
var SkillsController = class {
|
|
3371
3870
|
static {
|
|
3372
3871
|
__name(this, "SkillsController");
|
|
@@ -3382,40 +3881,40 @@ var SkillsController = class {
|
|
|
3382
3881
|
return [];
|
|
3383
3882
|
}
|
|
3384
3883
|
const actor = await this.actorResolver.resolve(req);
|
|
3385
|
-
const offer = await (0,
|
|
3884
|
+
const offer = await (0, import_nestjs_agent_core19.offerSkills)(this.skills, {
|
|
3386
3885
|
actor,
|
|
3387
3886
|
threadId: threadId ?? ""
|
|
3388
3887
|
});
|
|
3389
3888
|
return offer.entries;
|
|
3390
3889
|
}
|
|
3391
3890
|
};
|
|
3392
|
-
|
|
3393
|
-
(0,
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3891
|
+
_ts_decorate16([
|
|
3892
|
+
(0, import_common17.Get)(),
|
|
3893
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3894
|
+
_ts_param15(1, (0, import_common17.Query)("threadId")),
|
|
3895
|
+
_ts_metadata15("design:type", Function),
|
|
3896
|
+
_ts_metadata15("design:paramtypes", [
|
|
3398
3897
|
typeof Request === "undefined" ? Object : Request,
|
|
3399
3898
|
String
|
|
3400
3899
|
]),
|
|
3401
|
-
|
|
3900
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3402
3901
|
], SkillsController.prototype, "list", null);
|
|
3403
|
-
SkillsController =
|
|
3404
|
-
(0,
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3902
|
+
SkillsController = _ts_decorate16([
|
|
3903
|
+
(0, import_common17.Controller)("skills"),
|
|
3904
|
+
_ts_param15(0, (0, import_common17.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
3905
|
+
_ts_param15(1, (0, import_common17.Optional)()),
|
|
3906
|
+
_ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core19.AGENT_SKILLS)),
|
|
3907
|
+
_ts_metadata15("design:type", Function),
|
|
3908
|
+
_ts_metadata15("design:paramtypes", [
|
|
3410
3909
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3411
3910
|
Object
|
|
3412
3911
|
])
|
|
3413
3912
|
], SkillsController);
|
|
3414
3913
|
|
|
3415
3914
|
// src/controller/threads.controller.ts
|
|
3416
|
-
var
|
|
3417
|
-
var
|
|
3418
|
-
function
|
|
3915
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3916
|
+
var import_common18 = require("@nestjs/common");
|
|
3917
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
3419
3918
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3420
3919
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3421
3920
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3428,19 +3927,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
3428
3927
|
}
|
|
3429
3928
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3430
3929
|
}
|
|
3431
|
-
__name(
|
|
3432
|
-
function
|
|
3930
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3931
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
3433
3932
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3434
3933
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3435
3934
|
}
|
|
3436
3935
|
}
|
|
3437
|
-
__name(
|
|
3438
|
-
function
|
|
3936
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
3937
|
+
function _ts_param16(paramIndex, decorator) {
|
|
3439
3938
|
return function(target, key) {
|
|
3440
3939
|
decorator(target, key, paramIndex);
|
|
3441
3940
|
};
|
|
3442
3941
|
}
|
|
3443
|
-
__name(
|
|
3942
|
+
__name(_ts_param16, "_ts_param");
|
|
3444
3943
|
var ThreadsController = class {
|
|
3445
3944
|
static {
|
|
3446
3945
|
__name(this, "ThreadsController");
|
|
@@ -3510,101 +4009,101 @@ var ThreadsController = class {
|
|
|
3510
4009
|
};
|
|
3511
4010
|
}
|
|
3512
4011
|
};
|
|
3513
|
-
|
|
3514
|
-
(0,
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
4012
|
+
_ts_decorate17([
|
|
4013
|
+
(0, import_common18.Get)(),
|
|
4014
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4015
|
+
_ts_metadata16("design:type", Function),
|
|
4016
|
+
_ts_metadata16("design:paramtypes", [
|
|
3518
4017
|
typeof Request === "undefined" ? Object : Request
|
|
3519
4018
|
]),
|
|
3520
|
-
|
|
4019
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3521
4020
|
], ThreadsController.prototype, "list", null);
|
|
3522
|
-
|
|
3523
|
-
(0,
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
4021
|
+
_ts_decorate17([
|
|
4022
|
+
(0, import_common18.Get)(":id"),
|
|
4023
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4024
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4025
|
+
_ts_metadata16("design:type", Function),
|
|
4026
|
+
_ts_metadata16("design:paramtypes", [
|
|
3528
4027
|
typeof Request === "undefined" ? Object : Request,
|
|
3529
4028
|
String
|
|
3530
4029
|
]),
|
|
3531
|
-
|
|
4030
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3532
4031
|
], ThreadsController.prototype, "detail", null);
|
|
3533
|
-
|
|
3534
|
-
(0,
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
4032
|
+
_ts_decorate17([
|
|
4033
|
+
(0, import_common18.Delete)(":id"),
|
|
4034
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4035
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4036
|
+
_ts_metadata16("design:type", Function),
|
|
4037
|
+
_ts_metadata16("design:paramtypes", [
|
|
3539
4038
|
typeof Request === "undefined" ? Object : Request,
|
|
3540
4039
|
String
|
|
3541
4040
|
]),
|
|
3542
|
-
|
|
4041
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3543
4042
|
], ThreadsController.prototype, "remove", null);
|
|
3544
|
-
|
|
3545
|
-
(0,
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
4043
|
+
_ts_decorate17([
|
|
4044
|
+
(0, import_common18.Post)(":id/fork-from/:messageId"),
|
|
4045
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4046
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4047
|
+
_ts_param16(2, (0, import_common18.Param)("messageId")),
|
|
4048
|
+
_ts_metadata16("design:type", Function),
|
|
4049
|
+
_ts_metadata16("design:paramtypes", [
|
|
3551
4050
|
typeof Request === "undefined" ? Object : Request,
|
|
3552
4051
|
String,
|
|
3553
4052
|
String
|
|
3554
4053
|
]),
|
|
3555
|
-
|
|
4054
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3556
4055
|
], ThreadsController.prototype, "fork", null);
|
|
3557
|
-
|
|
3558
|
-
(0,
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
4056
|
+
_ts_decorate17([
|
|
4057
|
+
(0, import_common18.Patch)(":id"),
|
|
4058
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4059
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4060
|
+
_ts_param16(2, (0, import_common18.Body)()),
|
|
4061
|
+
_ts_metadata16("design:type", Function),
|
|
4062
|
+
_ts_metadata16("design:paramtypes", [
|
|
3564
4063
|
typeof Request === "undefined" ? Object : Request,
|
|
3565
4064
|
String,
|
|
3566
4065
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
3567
4066
|
]),
|
|
3568
|
-
|
|
4067
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3569
4068
|
], ThreadsController.prototype, "update", null);
|
|
3570
|
-
|
|
3571
|
-
(0,
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
4069
|
+
_ts_decorate17([
|
|
4070
|
+
(0, import_common18.Post)(":id/promote"),
|
|
4071
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4072
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4073
|
+
_ts_metadata16("design:type", Function),
|
|
4074
|
+
_ts_metadata16("design:paramtypes", [
|
|
3576
4075
|
typeof Request === "undefined" ? Object : Request,
|
|
3577
4076
|
String
|
|
3578
4077
|
]),
|
|
3579
|
-
|
|
4078
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3580
4079
|
], ThreadsController.prototype, "promote", null);
|
|
3581
|
-
|
|
3582
|
-
(0,
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
4080
|
+
_ts_decorate17([
|
|
4081
|
+
(0, import_common18.Delete)(":id/from/:messageId"),
|
|
4082
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4083
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4084
|
+
_ts_param16(2, (0, import_common18.Param)("messageId")),
|
|
4085
|
+
_ts_metadata16("design:type", Function),
|
|
4086
|
+
_ts_metadata16("design:paramtypes", [
|
|
3588
4087
|
typeof Request === "undefined" ? Object : Request,
|
|
3589
4088
|
String,
|
|
3590
4089
|
String
|
|
3591
4090
|
]),
|
|
3592
|
-
|
|
4091
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3593
4092
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
3594
|
-
ThreadsController =
|
|
3595
|
-
(0,
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
4093
|
+
ThreadsController = _ts_decorate17([
|
|
4094
|
+
(0, import_common18.Controller)("threads"),
|
|
4095
|
+
_ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4096
|
+
_ts_metadata16("design:type", Function),
|
|
4097
|
+
_ts_metadata16("design:paramtypes", [
|
|
3599
4098
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3600
4099
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3601
4100
|
])
|
|
3602
4101
|
], ThreadsController);
|
|
3603
4102
|
|
|
3604
4103
|
// src/controller/tool-call.controller.ts
|
|
3605
|
-
var
|
|
3606
|
-
var
|
|
3607
|
-
function
|
|
4104
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4105
|
+
var import_common19 = require("@nestjs/common");
|
|
4106
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
3608
4107
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3609
4108
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3610
4109
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3617,19 +4116,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
3617
4116
|
}
|
|
3618
4117
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3619
4118
|
}
|
|
3620
|
-
__name(
|
|
3621
|
-
function
|
|
4119
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
4120
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
3622
4121
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3623
4122
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3624
4123
|
}
|
|
3625
4124
|
}
|
|
3626
|
-
__name(
|
|
3627
|
-
function
|
|
4125
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4126
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3628
4127
|
return function(target, key) {
|
|
3629
4128
|
decorator(target, key, paramIndex);
|
|
3630
4129
|
};
|
|
3631
4130
|
}
|
|
3632
|
-
__name(
|
|
4131
|
+
__name(_ts_param17, "_ts_param");
|
|
3633
4132
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
3634
4133
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
3635
4134
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -3638,7 +4137,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
3638
4137
|
var DEFAULT_VIA = "web";
|
|
3639
4138
|
function toolCallId(claimed) {
|
|
3640
4139
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
3641
|
-
throw new
|
|
4140
|
+
throw new import_common19.BadRequestException("toolCallId must be a non-empty string");
|
|
3642
4141
|
}
|
|
3643
4142
|
return claimed;
|
|
3644
4143
|
}
|
|
@@ -3648,10 +4147,10 @@ function rejectReason(claimed) {
|
|
|
3648
4147
|
return void 0;
|
|
3649
4148
|
}
|
|
3650
4149
|
if (typeof claimed !== "string") {
|
|
3651
|
-
throw new
|
|
4150
|
+
throw new import_common19.BadRequestException("reason must be a string");
|
|
3652
4151
|
}
|
|
3653
4152
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
3654
|
-
throw new
|
|
4153
|
+
throw new import_common19.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
3655
4154
|
}
|
|
3656
4155
|
return claimed;
|
|
3657
4156
|
}
|
|
@@ -3661,7 +4160,7 @@ function remember(claimed) {
|
|
|
3661
4160
|
return false;
|
|
3662
4161
|
}
|
|
3663
4162
|
if (typeof claimed !== "boolean") {
|
|
3664
|
-
throw new
|
|
4163
|
+
throw new import_common19.BadRequestException("remember must be a boolean");
|
|
3665
4164
|
}
|
|
3666
4165
|
return claimed;
|
|
3667
4166
|
}
|
|
@@ -3671,7 +4170,7 @@ function via(claimed) {
|
|
|
3671
4170
|
return DEFAULT_VIA;
|
|
3672
4171
|
}
|
|
3673
4172
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
3674
|
-
throw new
|
|
4173
|
+
throw new import_common19.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
3675
4174
|
}
|
|
3676
4175
|
return claimed;
|
|
3677
4176
|
}
|
|
@@ -3681,26 +4180,26 @@ function answers(claimed) {
|
|
|
3681
4180
|
return void 0;
|
|
3682
4181
|
}
|
|
3683
4182
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
3684
|
-
throw new
|
|
4183
|
+
throw new import_common19.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
3685
4184
|
}
|
|
3686
4185
|
const entries = Object.entries(claimed);
|
|
3687
4186
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
3688
|
-
throw new
|
|
4187
|
+
throw new import_common19.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
3689
4188
|
}
|
|
3690
4189
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
3691
4190
|
for (const [questionId, values] of entries) {
|
|
3692
4191
|
if (!Array.isArray(values)) {
|
|
3693
|
-
throw new
|
|
4192
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
3694
4193
|
}
|
|
3695
4194
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
3696
|
-
throw new
|
|
4195
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
3697
4196
|
}
|
|
3698
4197
|
for (const value of values) {
|
|
3699
4198
|
if (typeof value !== "string") {
|
|
3700
|
-
throw new
|
|
4199
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
3701
4200
|
}
|
|
3702
4201
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
3703
|
-
throw new
|
|
4202
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
3704
4203
|
}
|
|
3705
4204
|
}
|
|
3706
4205
|
validated[questionId] = values;
|
|
@@ -3762,64 +4261,64 @@ var ToolCallController = class {
|
|
|
3762
4261
|
};
|
|
3763
4262
|
}
|
|
3764
4263
|
};
|
|
3765
|
-
|
|
3766
|
-
(0,
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
4264
|
+
_ts_decorate18([
|
|
4265
|
+
(0, import_common19.Post)("approve"),
|
|
4266
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4267
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4268
|
+
_ts_metadata17("design:type", Function),
|
|
4269
|
+
_ts_metadata17("design:paramtypes", [
|
|
3771
4270
|
typeof Request === "undefined" ? Object : Request,
|
|
3772
4271
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
3773
4272
|
]),
|
|
3774
|
-
|
|
4273
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3775
4274
|
], ToolCallController.prototype, "approve", null);
|
|
3776
|
-
|
|
3777
|
-
(0,
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
4275
|
+
_ts_decorate18([
|
|
4276
|
+
(0, import_common19.Post)("reject"),
|
|
4277
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4278
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4279
|
+
_ts_metadata17("design:type", Function),
|
|
4280
|
+
_ts_metadata17("design:paramtypes", [
|
|
3782
4281
|
typeof Request === "undefined" ? Object : Request,
|
|
3783
4282
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
3784
4283
|
]),
|
|
3785
|
-
|
|
4284
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3786
4285
|
], ToolCallController.prototype, "reject", null);
|
|
3787
|
-
|
|
3788
|
-
(0,
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
4286
|
+
_ts_decorate18([
|
|
4287
|
+
(0, import_common19.Post)("answer"),
|
|
4288
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4289
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4290
|
+
_ts_metadata17("design:type", Function),
|
|
4291
|
+
_ts_metadata17("design:paramtypes", [
|
|
3793
4292
|
typeof Request === "undefined" ? Object : Request,
|
|
3794
4293
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
3795
4294
|
]),
|
|
3796
|
-
|
|
4295
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3797
4296
|
], ToolCallController.prototype, "answer", null);
|
|
3798
|
-
|
|
3799
|
-
(0,
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
4297
|
+
_ts_decorate18([
|
|
4298
|
+
(0, import_common19.Post)("skip"),
|
|
4299
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4300
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4301
|
+
_ts_metadata17("design:type", Function),
|
|
4302
|
+
_ts_metadata17("design:paramtypes", [
|
|
3804
4303
|
typeof Request === "undefined" ? Object : Request,
|
|
3805
4304
|
Object
|
|
3806
4305
|
]),
|
|
3807
|
-
|
|
4306
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3808
4307
|
], ToolCallController.prototype, "skip", null);
|
|
3809
|
-
ToolCallController =
|
|
3810
|
-
(0,
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
4308
|
+
ToolCallController = _ts_decorate18([
|
|
4309
|
+
(0, import_common19.Controller)("tool-call"),
|
|
4310
|
+
_ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core21.AGENT_ACTOR_RESOLVER)),
|
|
4311
|
+
_ts_metadata17("design:type", Function),
|
|
4312
|
+
_ts_metadata17("design:paramtypes", [
|
|
3814
4313
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3815
4314
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3816
4315
|
])
|
|
3817
4316
|
], ToolCallController);
|
|
3818
4317
|
|
|
3819
4318
|
// src/controller/tools.controller.ts
|
|
3820
|
-
var
|
|
3821
|
-
var
|
|
3822
|
-
function
|
|
4319
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4320
|
+
var import_common20 = require("@nestjs/common");
|
|
4321
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3823
4322
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3824
4323
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3825
4324
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3832,19 +4331,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
3832
4331
|
}
|
|
3833
4332
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3834
4333
|
}
|
|
3835
|
-
__name(
|
|
3836
|
-
function
|
|
4334
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4335
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3837
4336
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3838
4337
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3839
4338
|
}
|
|
3840
4339
|
}
|
|
3841
|
-
__name(
|
|
3842
|
-
function
|
|
4340
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
4341
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3843
4342
|
return function(target, key) {
|
|
3844
4343
|
decorator(target, key, paramIndex);
|
|
3845
4344
|
};
|
|
3846
4345
|
}
|
|
3847
|
-
__name(
|
|
4346
|
+
__name(_ts_param18, "_ts_param");
|
|
3848
4347
|
var ToolsController = class {
|
|
3849
4348
|
static {
|
|
3850
4349
|
__name(this, "ToolsController");
|
|
@@ -3858,11 +4357,11 @@ var ToolsController = class {
|
|
|
3858
4357
|
this.agents = agents;
|
|
3859
4358
|
}
|
|
3860
4359
|
async list(req, agent) {
|
|
3861
|
-
if (agent !== void 0 && agent !==
|
|
3862
|
-
throw new
|
|
4360
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core22.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
4361
|
+
throw new import_common20.NotFoundException(`No agent named "${agent}"`);
|
|
3863
4362
|
}
|
|
3864
4363
|
const actor = await this.actorResolver.resolve(req);
|
|
3865
|
-
const names = agent ===
|
|
4364
|
+
const names = agent === import_nestjs_agent_core22.ALL_AGENTS ? [
|
|
3866
4365
|
void 0,
|
|
3867
4366
|
...this.agents.list().map((definition) => definition.name)
|
|
3868
4367
|
] : [
|
|
@@ -3888,33 +4387,33 @@ var ToolsController = class {
|
|
|
3888
4387
|
];
|
|
3889
4388
|
}
|
|
3890
4389
|
};
|
|
3891
|
-
|
|
3892
|
-
(0,
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
4390
|
+
_ts_decorate19([
|
|
4391
|
+
(0, import_common20.Get)(),
|
|
4392
|
+
_ts_param18(0, (0, import_common20.Req)()),
|
|
4393
|
+
_ts_param18(1, (0, import_common20.Query)("agent")),
|
|
4394
|
+
_ts_metadata18("design:type", Function),
|
|
4395
|
+
_ts_metadata18("design:paramtypes", [
|
|
3897
4396
|
typeof Request === "undefined" ? Object : Request,
|
|
3898
4397
|
String
|
|
3899
4398
|
]),
|
|
3900
|
-
|
|
4399
|
+
_ts_metadata18("design:returntype", Promise)
|
|
3901
4400
|
], ToolsController.prototype, "list", null);
|
|
3902
|
-
ToolsController =
|
|
3903
|
-
(0,
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
4401
|
+
ToolsController = _ts_decorate19([
|
|
4402
|
+
(0, import_common20.Controller)("tools"),
|
|
4403
|
+
_ts_param18(0, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_ACTOR_RESOLVER)),
|
|
4404
|
+
_ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_DEPS_FACTORY)),
|
|
4405
|
+
_ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core22.AGENT_REGISTRY)),
|
|
4406
|
+
_ts_metadata18("design:type", Function),
|
|
4407
|
+
_ts_metadata18("design:paramtypes", [
|
|
3909
4408
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3910
4409
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3911
|
-
typeof
|
|
4410
|
+
typeof import_nestjs_agent_core22.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core22.AgentRegistry
|
|
3912
4411
|
])
|
|
3913
4412
|
], ToolsController);
|
|
3914
4413
|
|
|
3915
4414
|
// src/discovery/agent-discovery.service.ts
|
|
3916
|
-
var
|
|
3917
|
-
var
|
|
4415
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4416
|
+
var import_common21 = require("@nestjs/common");
|
|
3918
4417
|
var import_core = require("@nestjs/core");
|
|
3919
4418
|
|
|
3920
4419
|
// src/decorator/agent.decorator.ts
|
|
@@ -3949,7 +4448,7 @@ function SystemPromptContributor() {
|
|
|
3949
4448
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
3950
4449
|
|
|
3951
4450
|
// src/discovery/agent-discovery.service.ts
|
|
3952
|
-
function
|
|
4451
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3953
4452
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3954
4453
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3955
4454
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3962,19 +4461,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3962
4461
|
}
|
|
3963
4462
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3964
4463
|
}
|
|
3965
|
-
__name(
|
|
3966
|
-
function
|
|
4464
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4465
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3967
4466
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3968
4467
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3969
4468
|
}
|
|
3970
4469
|
}
|
|
3971
|
-
__name(
|
|
3972
|
-
function
|
|
4470
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
4471
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3973
4472
|
return function(target, key) {
|
|
3974
4473
|
decorator(target, key, paramIndex);
|
|
3975
4474
|
};
|
|
3976
4475
|
}
|
|
3977
|
-
__name(
|
|
4476
|
+
__name(_ts_param19, "_ts_param");
|
|
3978
4477
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
3979
4478
|
static {
|
|
3980
4479
|
__name(this, "AgentDiscoveryService");
|
|
@@ -3983,7 +4482,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3983
4482
|
scanner;
|
|
3984
4483
|
registry;
|
|
3985
4484
|
contributors;
|
|
3986
|
-
logger = new
|
|
4485
|
+
logger = new import_common21.Logger(_AgentDiscoveryService.name);
|
|
3987
4486
|
constructor(discovery, scanner, registry, contributors) {
|
|
3988
4487
|
this.discovery = discovery;
|
|
3989
4488
|
this.scanner = scanner;
|
|
@@ -4140,22 +4639,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4140
4639
|
return (ctx) => candidate.call(instance, ctx);
|
|
4141
4640
|
}
|
|
4142
4641
|
};
|
|
4143
|
-
AgentDiscoveryService =
|
|
4144
|
-
(0,
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4642
|
+
AgentDiscoveryService = _ts_decorate20([
|
|
4643
|
+
(0, import_common21.Injectable)(),
|
|
4644
|
+
_ts_param19(2, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_REGISTRY)),
|
|
4645
|
+
_ts_param19(3, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_PROMPT_CONTRIBUTORS)),
|
|
4646
|
+
_ts_metadata19("design:type", Function),
|
|
4647
|
+
_ts_metadata19("design:paramtypes", [
|
|
4149
4648
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
4150
4649
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
4151
|
-
typeof
|
|
4650
|
+
typeof import_nestjs_agent_core23.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core23.AgentRegistry,
|
|
4152
4651
|
Array
|
|
4153
4652
|
])
|
|
4154
4653
|
], AgentDiscoveryService);
|
|
4155
4654
|
|
|
4156
4655
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4157
|
-
var
|
|
4158
|
-
var
|
|
4656
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4657
|
+
var import_common22 = require("@nestjs/common");
|
|
4159
4658
|
var import_core2 = require("@nestjs/core");
|
|
4160
4659
|
var import_zod = require("zod");
|
|
4161
4660
|
|
|
@@ -4187,46 +4686,8 @@ function readAiToolMetadata(target) {
|
|
|
4187
4686
|
}
|
|
4188
4687
|
__name(readAiToolMetadata, "readAiToolMetadata");
|
|
4189
4688
|
|
|
4190
|
-
// src/functional-tool.ts
|
|
4191
|
-
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
4192
|
-
function brand(tool) {
|
|
4193
|
-
return {
|
|
4194
|
-
[AGENT_TOOL_BRAND]: true,
|
|
4195
|
-
spec: tool.spec,
|
|
4196
|
-
handler: tool.handler
|
|
4197
|
-
};
|
|
4198
|
-
}
|
|
4199
|
-
__name(brand, "brand");
|
|
4200
|
-
function isBrandedFunctionalTool(value) {
|
|
4201
|
-
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
4202
|
-
}
|
|
4203
|
-
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
4204
|
-
function provideAgentTool(factoryOrTool, inject) {
|
|
4205
|
-
const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
|
|
4206
|
-
if (typeof factoryOrTool === "function") {
|
|
4207
|
-
return {
|
|
4208
|
-
provide,
|
|
4209
|
-
useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
|
|
4210
|
-
inject: inject ?? []
|
|
4211
|
-
};
|
|
4212
|
-
}
|
|
4213
|
-
return {
|
|
4214
|
-
provide,
|
|
4215
|
-
useValue: brand(factoryOrTool)
|
|
4216
|
-
};
|
|
4217
|
-
}
|
|
4218
|
-
__name(provideAgentTool, "provideAgentTool");
|
|
4219
|
-
function provideAgentTools(factory, inject) {
|
|
4220
|
-
return {
|
|
4221
|
-
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
4222
|
-
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
4223
|
-
inject: inject ?? []
|
|
4224
|
-
};
|
|
4225
|
-
}
|
|
4226
|
-
__name(provideAgentTools, "provideAgentTools");
|
|
4227
|
-
|
|
4228
4689
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4229
|
-
function
|
|
4690
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
4230
4691
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4231
4692
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4232
4693
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4239,19 +4700,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
4239
4700
|
}
|
|
4240
4701
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4241
4702
|
}
|
|
4242
|
-
__name(
|
|
4243
|
-
function
|
|
4703
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
4704
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
4244
4705
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4245
4706
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4246
4707
|
}
|
|
4247
4708
|
}
|
|
4248
|
-
__name(
|
|
4249
|
-
function
|
|
4709
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
4710
|
+
function _ts_param20(paramIndex, decorator) {
|
|
4250
4711
|
return function(target, key) {
|
|
4251
4712
|
decorator(target, key, paramIndex);
|
|
4252
4713
|
};
|
|
4253
4714
|
}
|
|
4254
|
-
__name(
|
|
4715
|
+
__name(_ts_param20, "_ts_param");
|
|
4255
4716
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
4256
4717
|
static {
|
|
4257
4718
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -4260,7 +4721,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4260
4721
|
registry;
|
|
4261
4722
|
agents;
|
|
4262
4723
|
options;
|
|
4263
|
-
logger = new
|
|
4724
|
+
logger = new import_common22.Logger(_AiToolDiscoveryService.name);
|
|
4264
4725
|
constructor(discovery, registry, agents, options) {
|
|
4265
4726
|
this.discovery = discovery;
|
|
4266
4727
|
this.registry = registry;
|
|
@@ -4319,9 +4780,18 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4319
4780
|
} : {},
|
|
4320
4781
|
...meta.terminal === true ? {
|
|
4321
4782
|
terminal: true
|
|
4783
|
+
} : {},
|
|
4784
|
+
...meta.replacementKey !== void 0 ? {
|
|
4785
|
+
replacementKey: meta.replacementKey
|
|
4322
4786
|
} : {}
|
|
4323
4787
|
}, {
|
|
4324
4788
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
4789
|
+
...typeof handler.present === "function" ? {
|
|
4790
|
+
present: /* @__PURE__ */ __name((output, ctx) => instance.present(output, ctx), "present")
|
|
4791
|
+
} : {},
|
|
4792
|
+
...typeof handler.preflight === "function" ? {
|
|
4793
|
+
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
4794
|
+
} : {},
|
|
4325
4795
|
// Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
|
|
4326
4796
|
// `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
|
|
4327
4797
|
// Called through `instance` so each keeps its `this` (and its injected deps).
|
|
@@ -4345,7 +4815,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4345
4815
|
let delegates = 0;
|
|
4346
4816
|
for (const definition of this.agents.list()) {
|
|
4347
4817
|
for (const edge of definition.delegatesTo ?? []) {
|
|
4348
|
-
const { agent: target, detached } = (0,
|
|
4818
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core24.normalizeDelegation)(edge);
|
|
4349
4819
|
const targetDefinition = this.agents.get(target);
|
|
4350
4820
|
if (targetDefinition === void 0) {
|
|
4351
4821
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -4395,13 +4865,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4395
4865
|
return true;
|
|
4396
4866
|
}
|
|
4397
4867
|
};
|
|
4398
|
-
AiToolDiscoveryService =
|
|
4399
|
-
(0,
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4868
|
+
AiToolDiscoveryService = _ts_decorate21([
|
|
4869
|
+
(0, import_common22.Injectable)(),
|
|
4870
|
+
_ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_TOOL_REGISTRY)),
|
|
4871
|
+
_ts_param20(2, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_REGISTRY)),
|
|
4872
|
+
_ts_param20(3, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_OPTIONS)),
|
|
4873
|
+
_ts_metadata20("design:type", Function),
|
|
4874
|
+
_ts_metadata20("design:paramtypes", [
|
|
4405
4875
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
4406
4876
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
4407
4877
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -4410,13 +4880,13 @@ AiToolDiscoveryService = _ts_decorate19([
|
|
|
4410
4880
|
], AiToolDiscoveryService);
|
|
4411
4881
|
|
|
4412
4882
|
// src/discovery/skill-discovery.service.ts
|
|
4413
|
-
var
|
|
4414
|
-
var
|
|
4883
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4884
|
+
var import_common23 = require("@nestjs/common");
|
|
4415
4885
|
var import_core3 = require("@nestjs/core");
|
|
4416
4886
|
|
|
4417
4887
|
// src/decorator/skill.decorator.ts
|
|
4418
4888
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
4419
|
-
var
|
|
4889
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4420
4890
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
4421
4891
|
function Skill(options) {
|
|
4422
4892
|
return (target) => {
|
|
@@ -4429,12 +4899,12 @@ function readSkillMetadata(target) {
|
|
|
4429
4899
|
}
|
|
4430
4900
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
4431
4901
|
function skillScope(options) {
|
|
4432
|
-
return options.scope ??
|
|
4902
|
+
return options.scope ?? import_nestjs_agent_core25.GLOBAL_SCOPE;
|
|
4433
4903
|
}
|
|
4434
4904
|
__name(skillScope, "skillScope");
|
|
4435
4905
|
|
|
4436
4906
|
// src/discovery/skill-discovery.service.ts
|
|
4437
|
-
function
|
|
4907
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
4438
4908
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4439
4909
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4440
4910
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4447,26 +4917,26 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
4447
4917
|
}
|
|
4448
4918
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4449
4919
|
}
|
|
4450
|
-
__name(
|
|
4451
|
-
function
|
|
4920
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
4921
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
4452
4922
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4453
4923
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4454
4924
|
}
|
|
4455
4925
|
}
|
|
4456
|
-
__name(
|
|
4457
|
-
function
|
|
4926
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
4927
|
+
function _ts_param21(paramIndex, decorator) {
|
|
4458
4928
|
return function(target, key) {
|
|
4459
4929
|
decorator(target, key, paramIndex);
|
|
4460
4930
|
};
|
|
4461
4931
|
}
|
|
4462
|
-
__name(
|
|
4932
|
+
__name(_ts_param21, "_ts_param");
|
|
4463
4933
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
4464
4934
|
static {
|
|
4465
4935
|
__name(this, "SkillDiscoveryService");
|
|
4466
4936
|
}
|
|
4467
4937
|
discovery;
|
|
4468
4938
|
declared;
|
|
4469
|
-
logger = new
|
|
4939
|
+
logger = new import_common23.Logger(_SkillDiscoveryService.name);
|
|
4470
4940
|
constructor(discovery, declared) {
|
|
4471
4941
|
this.discovery = discovery;
|
|
4472
4942
|
this.declared = declared;
|
|
@@ -4503,18 +4973,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4503
4973
|
return flat === void 0 ? void 0 : () => flat;
|
|
4504
4974
|
}
|
|
4505
4975
|
};
|
|
4506
|
-
SkillDiscoveryService =
|
|
4507
|
-
(0,
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4976
|
+
SkillDiscoveryService = _ts_decorate22([
|
|
4977
|
+
(0, import_common23.Injectable)(),
|
|
4978
|
+
_ts_param21(1, (0, import_common23.Inject)(import_nestjs_agent_core26.AGENT_SKILL_SOURCES)),
|
|
4979
|
+
_ts_metadata21("design:type", Function),
|
|
4980
|
+
_ts_metadata21("design:paramtypes", [
|
|
4511
4981
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
4512
4982
|
Array
|
|
4513
4983
|
])
|
|
4514
4984
|
], SkillDiscoveryService);
|
|
4515
4985
|
|
|
4516
4986
|
// src/in-process-sink.ts
|
|
4517
|
-
var
|
|
4987
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
4518
4988
|
var InProcessTokenStreamSink = class {
|
|
4519
4989
|
static {
|
|
4520
4990
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -4569,7 +5039,7 @@ var InProcessTokenStreamSink = class {
|
|
|
4569
5039
|
}
|
|
4570
5040
|
if (buf.ended) {
|
|
4571
5041
|
if (buf.failure !== void 0) {
|
|
4572
|
-
throw new
|
|
5042
|
+
throw new import_nestjs_agent_core27.AgentStreamError(buf.failure);
|
|
4573
5043
|
}
|
|
4574
5044
|
return;
|
|
4575
5045
|
}
|
|
@@ -4582,7 +5052,7 @@ var InProcessTokenStreamSink = class {
|
|
|
4582
5052
|
};
|
|
4583
5053
|
|
|
4584
5054
|
// src/ledger-quota-provider.ts
|
|
4585
|
-
var
|
|
5055
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
4586
5056
|
var LedgerQuotaProvider = class {
|
|
4587
5057
|
static {
|
|
4588
5058
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -4602,12 +5072,12 @@ var LedgerQuotaProvider = class {
|
|
|
4602
5072
|
await this.dayWindow(actorRef, now)
|
|
4603
5073
|
];
|
|
4604
5074
|
if (this.store.usageBetween !== void 0) {
|
|
4605
|
-
const range = (0,
|
|
5075
|
+
const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("month", now);
|
|
4606
5076
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
4607
5077
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
4608
5078
|
}
|
|
4609
|
-
const blocked = (0,
|
|
4610
|
-
const warning = (0,
|
|
5079
|
+
const blocked = (0, import_nestjs_agent_core28.exhaustedWindow)(windows);
|
|
5080
|
+
const warning = (0, import_nestjs_agent_core28.quotaWarning)(windows);
|
|
4611
5081
|
return {
|
|
4612
5082
|
windows,
|
|
4613
5083
|
...blocked !== void 0 ? {
|
|
@@ -4619,7 +5089,7 @@ var LedgerQuotaProvider = class {
|
|
|
4619
5089
|
};
|
|
4620
5090
|
}
|
|
4621
5091
|
async dayWindow(actorRef, now) {
|
|
4622
|
-
const range = (0,
|
|
5092
|
+
const range = (0, import_nestjs_agent_core28.quotaPeriodRange)("day", now);
|
|
4623
5093
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
4624
5094
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
4625
5095
|
}
|
|
@@ -4643,13 +5113,248 @@ var LedgerQuotaProvider = class {
|
|
|
4643
5113
|
}
|
|
4644
5114
|
};
|
|
4645
5115
|
|
|
5116
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
5117
|
+
var import_node_crypto2 = require("crypto");
|
|
5118
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5119
|
+
var import_common24 = require("@nestjs/common");
|
|
5120
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
5121
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5122
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5123
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5124
|
+
} else {
|
|
5125
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
5126
|
+
if (d = decorators[i]) {
|
|
5127
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5132
|
+
}
|
|
5133
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
5134
|
+
function _ts_metadata22(metadataKey, metadataValue) {
|
|
5135
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5136
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
5137
|
+
}
|
|
5138
|
+
}
|
|
5139
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
5140
|
+
function _ts_param22(paramIndex, decorator) {
|
|
5141
|
+
return function(target, key) {
|
|
5142
|
+
decorator(target, key, paramIndex);
|
|
5143
|
+
};
|
|
5144
|
+
}
|
|
5145
|
+
__name(_ts_param22, "_ts_param");
|
|
5146
|
+
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
5147
|
+
static {
|
|
5148
|
+
__name(this, "ActionProposalWorkerService");
|
|
5149
|
+
}
|
|
5150
|
+
store;
|
|
5151
|
+
options;
|
|
5152
|
+
deps;
|
|
5153
|
+
worker;
|
|
5154
|
+
logger = new import_common24.Logger(_ActionProposalWorkerService.name);
|
|
5155
|
+
constructor(store, options, deps) {
|
|
5156
|
+
this.store = store;
|
|
5157
|
+
this.options = options;
|
|
5158
|
+
this.deps = deps;
|
|
5159
|
+
}
|
|
5160
|
+
onModuleInit() {
|
|
5161
|
+
if (this.options.actionApprovalMode !== "independent") return;
|
|
5162
|
+
(0, import_nestjs_agent_core29.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
5163
|
+
if (this.options.surface === "http") return;
|
|
5164
|
+
const resolver = this.options.backgroundActorResolver;
|
|
5165
|
+
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
5166
|
+
this.worker = new import_nestjs_agent_core29.ActionProposalWorker({
|
|
5167
|
+
store: this.store,
|
|
5168
|
+
workerId: (0, import_node_crypto2.randomUUID)(),
|
|
5169
|
+
...this.options.actionProposalWorker,
|
|
5170
|
+
executor: new import_nestjs_agent_core29.ActionProposalExecutor({
|
|
5171
|
+
resolver,
|
|
5172
|
+
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
5173
|
+
const deps = this.deps.forProposal(proposal, actor);
|
|
5174
|
+
return {
|
|
5175
|
+
registry: deps.registry,
|
|
5176
|
+
rolesPolicy: deps.rolesPolicy,
|
|
5177
|
+
...deps.resolveUiCatalog !== void 0 ? {
|
|
5178
|
+
resolveUiCatalog: deps.resolveUiCatalog
|
|
5179
|
+
} : {},
|
|
5180
|
+
...deps.toolAllowList !== void 0 ? {
|
|
5181
|
+
allowedTools: deps.toolAllowList
|
|
5182
|
+
} : {}
|
|
5183
|
+
};
|
|
5184
|
+
}, "resolveExecution")
|
|
5185
|
+
}),
|
|
5186
|
+
onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
|
|
5187
|
+
});
|
|
5188
|
+
this.worker.start();
|
|
5189
|
+
}
|
|
5190
|
+
async onModuleDestroy() {
|
|
5191
|
+
await this.worker?.stop();
|
|
5192
|
+
}
|
|
5193
|
+
};
|
|
5194
|
+
ActionProposalWorkerService = _ts_decorate23([
|
|
5195
|
+
(0, import_common24.Injectable)(),
|
|
5196
|
+
_ts_param22(0, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_STORE)),
|
|
5197
|
+
_ts_param22(1, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_OPTIONS)),
|
|
5198
|
+
_ts_param22(2, (0, import_common24.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
|
|
5199
|
+
_ts_metadata22("design:type", Function),
|
|
5200
|
+
_ts_metadata22("design:paramtypes", [
|
|
5201
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
5202
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
5203
|
+
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
5204
|
+
])
|
|
5205
|
+
], ActionProposalWorkerService);
|
|
5206
|
+
|
|
5207
|
+
// src/proposals/action-proposal.controller.ts
|
|
5208
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5209
|
+
var import_common25 = require("@nestjs/common");
|
|
5210
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
5211
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5212
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5213
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5214
|
+
} else {
|
|
5215
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
5216
|
+
if (d = decorators[i]) {
|
|
5217
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5222
|
+
}
|
|
5223
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
5224
|
+
function _ts_metadata23(metadataKey, metadataValue) {
|
|
5225
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5226
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
5227
|
+
}
|
|
5228
|
+
}
|
|
5229
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
5230
|
+
function _ts_param23(paramIndex, decorator) {
|
|
5231
|
+
return function(target, key) {
|
|
5232
|
+
decorator(target, key, paramIndex);
|
|
5233
|
+
};
|
|
5234
|
+
}
|
|
5235
|
+
__name(_ts_param23, "_ts_param");
|
|
5236
|
+
function bodyFields(body, field2) {
|
|
5237
|
+
if (body === void 0) return {};
|
|
5238
|
+
if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field2)) throw new import_common25.BadRequestException(`Only ${field2} is accepted`);
|
|
5239
|
+
const value = body;
|
|
5240
|
+
if (value[field2] !== void 0 && (field2 === "remember" && typeof value[field2] !== "boolean" || field2 === "reason" && typeof value[field2] !== "string")) throw new import_common25.BadRequestException(`Invalid ${field2}`);
|
|
5241
|
+
return value;
|
|
5242
|
+
}
|
|
5243
|
+
__name(bodyFields, "bodyFields");
|
|
5244
|
+
var ActionProposalController = class {
|
|
5245
|
+
static {
|
|
5246
|
+
__name(this, "ActionProposalController");
|
|
5247
|
+
}
|
|
5248
|
+
proposals;
|
|
5249
|
+
actors;
|
|
5250
|
+
constructor(proposals, actors) {
|
|
5251
|
+
this.proposals = proposals;
|
|
5252
|
+
this.actors = actors;
|
|
5253
|
+
}
|
|
5254
|
+
async list(threadId, request, cursor, response) {
|
|
5255
|
+
let query = {};
|
|
5256
|
+
if (cursor !== void 0) {
|
|
5257
|
+
try {
|
|
5258
|
+
if (typeof cursor !== "string") throw new Error("Invalid cursor");
|
|
5259
|
+
query = {
|
|
5260
|
+
after: JSON.parse(cursor)
|
|
5261
|
+
};
|
|
5262
|
+
(0, import_nestjs_agent_core30.validateActionProposalListQuery)(query);
|
|
5263
|
+
} catch {
|
|
5264
|
+
throw new import_common25.BadRequestException("Invalid action proposal cursor");
|
|
5265
|
+
}
|
|
5266
|
+
}
|
|
5267
|
+
const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
|
|
5268
|
+
if (page.next) {
|
|
5269
|
+
response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
|
|
5270
|
+
const exposed = response.getHeader("Access-Control-Expose-Headers");
|
|
5271
|
+
response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
|
|
5272
|
+
}
|
|
5273
|
+
return page.items;
|
|
5274
|
+
}
|
|
5275
|
+
async approve(threadId, proposalId, request, body) {
|
|
5276
|
+
const value = bodyFields(body, "remember");
|
|
5277
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
5278
|
+
decision: "approved",
|
|
5279
|
+
...typeof value.remember === "boolean" ? {
|
|
5280
|
+
remember: value.remember
|
|
5281
|
+
} : {}
|
|
5282
|
+
});
|
|
5283
|
+
}
|
|
5284
|
+
async reject(threadId, proposalId, request, body) {
|
|
5285
|
+
const value = bodyFields(body, "reason");
|
|
5286
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
5287
|
+
decision: "rejected",
|
|
5288
|
+
...typeof value.reason === "string" ? {
|
|
5289
|
+
reason: value.reason
|
|
5290
|
+
} : {}
|
|
5291
|
+
});
|
|
5292
|
+
}
|
|
5293
|
+
};
|
|
5294
|
+
_ts_decorate24([
|
|
5295
|
+
(0, import_common25.Get)(),
|
|
5296
|
+
_ts_param23(0, (0, import_common25.Param)("threadId")),
|
|
5297
|
+
_ts_param23(1, (0, import_common25.Req)()),
|
|
5298
|
+
_ts_param23(2, (0, import_common25.Query)("after")),
|
|
5299
|
+
_ts_param23(3, (0, import_common25.Res)({
|
|
5300
|
+
passthrough: true
|
|
5301
|
+
})),
|
|
5302
|
+
_ts_metadata23("design:type", Function),
|
|
5303
|
+
_ts_metadata23("design:paramtypes", [
|
|
5304
|
+
String,
|
|
5305
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5306
|
+
Object,
|
|
5307
|
+
typeof Response === "undefined" ? Object : Response
|
|
5308
|
+
]),
|
|
5309
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5310
|
+
], ActionProposalController.prototype, "list", null);
|
|
5311
|
+
_ts_decorate24([
|
|
5312
|
+
(0, import_common25.Post)(":proposalId/approve"),
|
|
5313
|
+
_ts_param23(0, (0, import_common25.Param)("threadId")),
|
|
5314
|
+
_ts_param23(1, (0, import_common25.Param)("proposalId")),
|
|
5315
|
+
_ts_param23(2, (0, import_common25.Req)()),
|
|
5316
|
+
_ts_param23(3, (0, import_common25.Body)()),
|
|
5317
|
+
_ts_metadata23("design:type", Function),
|
|
5318
|
+
_ts_metadata23("design:paramtypes", [
|
|
5319
|
+
String,
|
|
5320
|
+
String,
|
|
5321
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5322
|
+
Object
|
|
5323
|
+
]),
|
|
5324
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5325
|
+
], ActionProposalController.prototype, "approve", null);
|
|
5326
|
+
_ts_decorate24([
|
|
5327
|
+
(0, import_common25.Post)(":proposalId/reject"),
|
|
5328
|
+
_ts_param23(0, (0, import_common25.Param)("threadId")),
|
|
5329
|
+
_ts_param23(1, (0, import_common25.Param)("proposalId")),
|
|
5330
|
+
_ts_param23(2, (0, import_common25.Req)()),
|
|
5331
|
+
_ts_param23(3, (0, import_common25.Body)()),
|
|
5332
|
+
_ts_metadata23("design:type", Function),
|
|
5333
|
+
_ts_metadata23("design:paramtypes", [
|
|
5334
|
+
String,
|
|
5335
|
+
String,
|
|
5336
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5337
|
+
Object
|
|
5338
|
+
]),
|
|
5339
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5340
|
+
], ActionProposalController.prototype, "reject", null);
|
|
5341
|
+
ActionProposalController = _ts_decorate24([
|
|
5342
|
+
(0, import_common25.Controller)("threads/:threadId/action-proposals"),
|
|
5343
|
+
_ts_param23(1, (0, import_common25.Inject)(import_nestjs_agent_core30.AGENT_ACTOR_RESOLVER)),
|
|
5344
|
+
_ts_metadata23("design:type", Function),
|
|
5345
|
+
_ts_metadata23("design:paramtypes", [
|
|
5346
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
5347
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
5348
|
+
])
|
|
5349
|
+
], ActionProposalController);
|
|
5350
|
+
|
|
4646
5351
|
// src/queue/chat-queue.token.ts
|
|
4647
5352
|
var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
|
|
4648
5353
|
|
|
4649
5354
|
// src/runner/inline-agent-runner.ts
|
|
4650
|
-
var
|
|
4651
|
-
var
|
|
4652
|
-
function
|
|
5355
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
5356
|
+
var import_common26 = require("@nestjs/common");
|
|
5357
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4653
5358
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4654
5359
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4655
5360
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4662,19 +5367,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
4662
5367
|
}
|
|
4663
5368
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4664
5369
|
}
|
|
4665
|
-
__name(
|
|
4666
|
-
function
|
|
5370
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
5371
|
+
function _ts_metadata24(metadataKey, metadataValue) {
|
|
4667
5372
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4668
5373
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4669
5374
|
}
|
|
4670
5375
|
}
|
|
4671
|
-
__name(
|
|
4672
|
-
function
|
|
5376
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
5377
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4673
5378
|
return function(target, key) {
|
|
4674
5379
|
decorator(target, key, paramIndex);
|
|
4675
5380
|
};
|
|
4676
5381
|
}
|
|
4677
|
-
__name(
|
|
5382
|
+
__name(_ts_param24, "_ts_param");
|
|
4678
5383
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
4679
5384
|
static {
|
|
4680
5385
|
__name(this, "InlineAgentRunner");
|
|
@@ -4682,7 +5387,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4682
5387
|
factory;
|
|
4683
5388
|
store;
|
|
4684
5389
|
queue;
|
|
4685
|
-
logger = new
|
|
5390
|
+
logger = new import_common26.Logger(_InlineAgentRunner.name);
|
|
4686
5391
|
pending = /* @__PURE__ */ new Map();
|
|
4687
5392
|
/**
|
|
4688
5393
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -4731,18 +5436,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4731
5436
|
],
|
|
4732
5437
|
input
|
|
4733
5438
|
});
|
|
4734
|
-
void (0,
|
|
5439
|
+
void (0, import_nestjs_agent_core31.runAgentLoop)({
|
|
4735
5440
|
...deps,
|
|
4736
5441
|
day
|
|
4737
|
-
}, input, hooks).then(() => (0,
|
|
4738
|
-
if (error instanceof
|
|
5442
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core31.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
5443
|
+
if (error instanceof import_nestjs_agent_core31.RunCancelledError) {
|
|
4739
5444
|
await this.settleCancelled(runId, input, deps);
|
|
4740
5445
|
return;
|
|
4741
5446
|
}
|
|
4742
5447
|
const message = error instanceof Error ? error.message : String(error);
|
|
4743
|
-
const code = (0,
|
|
5448
|
+
const code = (0, import_nestjs_agent_core31.agentFailureCode)(error);
|
|
4744
5449
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
4745
|
-
(0,
|
|
5450
|
+
(0, import_nestjs_agent_core31.publishAgentRunFailed)({
|
|
4746
5451
|
runId,
|
|
4747
5452
|
code,
|
|
4748
5453
|
message
|
|
@@ -4753,11 +5458,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4753
5458
|
errorCode: code,
|
|
4754
5459
|
errorMessage: message
|
|
4755
5460
|
});
|
|
4756
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
5461
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core31.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
4757
5462
|
const writer = await deps.sink.open(runId);
|
|
4758
5463
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
4759
|
-
await (0,
|
|
4760
|
-
await writer.fail((0,
|
|
5464
|
+
await (0, import_nestjs_agent_core31.releaseThreadRun)(this.store, input.threadId, runId);
|
|
5465
|
+
await writer.fail((0, import_nestjs_agent_core31.streamFailure)(error));
|
|
4761
5466
|
}).finally(() => {
|
|
4762
5467
|
this.cancelled.delete(runId);
|
|
4763
5468
|
this.live.delete(runId);
|
|
@@ -4793,7 +5498,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4793
5498
|
for (const [key, waiter] of this.pending) {
|
|
4794
5499
|
if (key.startsWith(`${runId}:`)) {
|
|
4795
5500
|
this.pending.delete(key);
|
|
4796
|
-
waiter.reject(new
|
|
5501
|
+
waiter.reject(new import_nestjs_agent_core31.RunCancelledError());
|
|
4797
5502
|
}
|
|
4798
5503
|
}
|
|
4799
5504
|
await Promise.resolve();
|
|
@@ -4808,8 +5513,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4808
5513
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
4809
5514
|
const writer = await deps.sink.open(runId);
|
|
4810
5515
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
4811
|
-
await (0,
|
|
4812
|
-
await writer.write((0,
|
|
5516
|
+
await (0, import_nestjs_agent_core31.releaseThreadRun)(this.store, input.threadId, runId);
|
|
5517
|
+
await writer.write((0, import_nestjs_agent_core31.encodeStreamEvent)({
|
|
4813
5518
|
kind: "cancelled"
|
|
4814
5519
|
}));
|
|
4815
5520
|
await writer.end();
|
|
@@ -4844,7 +5549,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4844
5549
|
runId: nextRunId
|
|
4845
5550
|
}));
|
|
4846
5551
|
if (frame !== void 0) {
|
|
4847
|
-
await writer.write((0,
|
|
5552
|
+
await writer.write((0, import_nestjs_agent_core31.encodeStreamEvent)(frame));
|
|
4848
5553
|
}
|
|
4849
5554
|
} catch (failure) {
|
|
4850
5555
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -4915,7 +5620,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4915
5620
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4916
5621
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4917
5622
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4918
|
-
parallel:
|
|
5623
|
+
parallel: import_nestjs_agent_core31.settleAll,
|
|
4919
5624
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
4920
5625
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
4921
5626
|
agentName,
|
|
@@ -4966,7 +5671,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4966
5671
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4967
5672
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4968
5673
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4969
|
-
parallel:
|
|
5674
|
+
parallel: import_nestjs_agent_core31.settleAll,
|
|
4970
5675
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
4971
5676
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
4972
5677
|
agentName: childName,
|
|
@@ -4999,7 +5704,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4999
5704
|
}
|
|
5000
5705
|
}), "startAgent")
|
|
5001
5706
|
};
|
|
5002
|
-
void (0,
|
|
5707
|
+
void (0, import_nestjs_agent_core31.runAgentLoop)({
|
|
5003
5708
|
...deps,
|
|
5004
5709
|
day
|
|
5005
5710
|
}, {
|
|
@@ -5013,13 +5718,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5013
5718
|
parentRunId,
|
|
5014
5719
|
deliverTo
|
|
5015
5720
|
}, hooks).catch(async (error) => {
|
|
5016
|
-
const cancelled = error instanceof
|
|
5721
|
+
const cancelled = error instanceof import_nestjs_agent_core31.RunCancelledError;
|
|
5017
5722
|
const message = error instanceof Error ? error.message : String(error);
|
|
5018
5723
|
if (!cancelled) {
|
|
5019
5724
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
5020
|
-
(0,
|
|
5725
|
+
(0, import_nestjs_agent_core31.publishAgentRunFailed)({
|
|
5021
5726
|
runId,
|
|
5022
|
-
code: (0,
|
|
5727
|
+
code: (0, import_nestjs_agent_core31.agentFailureCode)(error),
|
|
5023
5728
|
message
|
|
5024
5729
|
});
|
|
5025
5730
|
}
|
|
@@ -5027,12 +5732,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5027
5732
|
runId,
|
|
5028
5733
|
status: cancelled ? "cancelled" : "failed",
|
|
5029
5734
|
...cancelled ? {} : {
|
|
5030
|
-
errorCode: (0,
|
|
5735
|
+
errorCode: (0, import_nestjs_agent_core31.agentFailureCode)(error),
|
|
5031
5736
|
errorMessage: message
|
|
5032
5737
|
}
|
|
5033
5738
|
});
|
|
5034
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
5035
|
-
await (0,
|
|
5739
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core31.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
5740
|
+
await (0, import_nestjs_agent_core31.settleUnsettledDelegation)({
|
|
5036
5741
|
store: this.store,
|
|
5037
5742
|
delivery: deliverTo,
|
|
5038
5743
|
agent: agentName,
|
|
@@ -5071,7 +5776,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5071
5776
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5072
5777
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5073
5778
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5074
|
-
parallel:
|
|
5779
|
+
parallel: import_nestjs_agent_core31.settleAll,
|
|
5075
5780
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
5076
5781
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
5077
5782
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -5106,7 +5811,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5106
5811
|
}), "startAgent")
|
|
5107
5812
|
};
|
|
5108
5813
|
try {
|
|
5109
|
-
return await (0,
|
|
5814
|
+
return await (0, import_nestjs_agent_core31.runAgentLoop)({
|
|
5110
5815
|
...deps,
|
|
5111
5816
|
day
|
|
5112
5817
|
}, {
|
|
@@ -5125,13 +5830,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5125
5830
|
}
|
|
5126
5831
|
}
|
|
5127
5832
|
};
|
|
5128
|
-
InlineAgentRunner =
|
|
5129
|
-
(0,
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5833
|
+
InlineAgentRunner = _ts_decorate25([
|
|
5834
|
+
(0, import_common26.Injectable)(),
|
|
5835
|
+
_ts_param24(0, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_DEPS_FACTORY)),
|
|
5836
|
+
_ts_param24(1, (0, import_common26.Inject)(import_nestjs_agent_core31.AGENT_STORE)),
|
|
5837
|
+
_ts_param24(2, (0, import_common26.Optional)()),
|
|
5838
|
+
_ts_metadata24("design:type", Function),
|
|
5839
|
+
_ts_metadata24("design:paramtypes", [
|
|
5135
5840
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
5136
5841
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
5137
5842
|
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
@@ -5143,7 +5848,7 @@ function isThreadTurn(input) {
|
|
|
5143
5848
|
__name(isThreadTurn, "isThreadTurn");
|
|
5144
5849
|
|
|
5145
5850
|
// src/skills-config.ts
|
|
5146
|
-
var
|
|
5851
|
+
var import_nestjs_agent_core32 = require("@dudousxd/nestjs-agent-core");
|
|
5147
5852
|
function declaredSkillProvider(declared) {
|
|
5148
5853
|
return {
|
|
5149
5854
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -5169,7 +5874,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
5169
5874
|
declaredSkillProvider(declared)
|
|
5170
5875
|
];
|
|
5171
5876
|
return {
|
|
5172
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
5877
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core32.compositeSkillProvider)(providers),
|
|
5173
5878
|
...options.scopes !== void 0 ? {
|
|
5174
5879
|
scopes: options.scopes
|
|
5175
5880
|
} : {},
|
|
@@ -5181,7 +5886,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
5181
5886
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
5182
5887
|
|
|
5183
5888
|
// src/agent.module.ts
|
|
5184
|
-
function
|
|
5889
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
5185
5890
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5186
5891
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5187
5892
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5194,18 +5899,18 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
5194
5899
|
}
|
|
5195
5900
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5196
5901
|
}
|
|
5197
|
-
__name(
|
|
5902
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
5198
5903
|
var DEFAULT_PATH = "agent";
|
|
5199
|
-
var logger = new
|
|
5200
|
-
function
|
|
5904
|
+
var logger = new import_common27.Logger("AgentModule");
|
|
5905
|
+
function externalWrapper(modules, token) {
|
|
5201
5906
|
for (const module2 of modules.values()) {
|
|
5202
5907
|
if (module2.metatype === AgentModule) continue;
|
|
5203
|
-
const wrapper = module2.providers.get(
|
|
5908
|
+
const wrapper = module2.providers.get(token);
|
|
5204
5909
|
if (wrapper !== void 0) return wrapper;
|
|
5205
5910
|
}
|
|
5206
5911
|
return void 0;
|
|
5207
5912
|
}
|
|
5208
|
-
__name(
|
|
5913
|
+
__name(externalWrapper, "externalWrapper");
|
|
5209
5914
|
function forwardingStore(wrapper) {
|
|
5210
5915
|
const target = /* @__PURE__ */ __name(() => {
|
|
5211
5916
|
const instance = wrapper.instance;
|
|
@@ -5228,12 +5933,36 @@ function forwardingStore(wrapper) {
|
|
|
5228
5933
|
__name(forwardingStore, "forwardingStore");
|
|
5229
5934
|
function resolveStore(options, modules) {
|
|
5230
5935
|
if (options.store !== void 0) return options.store;
|
|
5231
|
-
const external =
|
|
5936
|
+
const external = externalWrapper(modules, import_nestjs_agent_core33.AGENT_STORE);
|
|
5232
5937
|
if (external !== void 0) return forwardingStore(external);
|
|
5233
5938
|
logger.warn("No `store` configured and no store module imported \u2014 using the in-memory store. Threads are lost on restart and not shared between processes: not for production. Pass `store`, or import a store module (e.g. MikroOrmAgentStoreModule.forFeature()).");
|
|
5234
|
-
return new
|
|
5939
|
+
return new import_nestjs_agent_core33.InMemoryAgentStore();
|
|
5235
5940
|
}
|
|
5236
5941
|
__name(resolveStore, "resolveStore");
|
|
5942
|
+
function resolveRolesPolicy(options, modules) {
|
|
5943
|
+
const external = externalWrapper(modules, import_nestjs_agent_core33.AGENT_ROLES_POLICY);
|
|
5944
|
+
if (options.rolesPolicy !== void 0) {
|
|
5945
|
+
if (external !== void 0) {
|
|
5946
|
+
logger.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
5947
|
+
}
|
|
5948
|
+
return options.rolesPolicy;
|
|
5949
|
+
}
|
|
5950
|
+
if (external !== void 0) return forwardingPolicy(external);
|
|
5951
|
+
return options.emptyRoles === "deny" ? new import_nestjs_agent_core33.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core33.DefaultRolesPolicy(options.defaultRoles);
|
|
5952
|
+
}
|
|
5953
|
+
__name(resolveRolesPolicy, "resolveRolesPolicy");
|
|
5954
|
+
function forwardingPolicy(wrapper) {
|
|
5955
|
+
return {
|
|
5956
|
+
can(actor, tool) {
|
|
5957
|
+
const policy = wrapper.instance;
|
|
5958
|
+
if (policy === void 0 || policy === null) {
|
|
5959
|
+
throw new Error("AgentModule: the AGENT_ROLES_POLICY bound by another module is not ready yet");
|
|
5960
|
+
}
|
|
5961
|
+
return policy.can(actor, tool);
|
|
5962
|
+
}
|
|
5963
|
+
};
|
|
5964
|
+
}
|
|
5965
|
+
__name(forwardingPolicy, "forwardingPolicy");
|
|
5237
5966
|
function isQuotaProvider(quota) {
|
|
5238
5967
|
return quota !== void 0 && typeof quota.report === "function";
|
|
5239
5968
|
}
|
|
@@ -5247,99 +5976,100 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
5247
5976
|
function sharedProviders(durable) {
|
|
5248
5977
|
const providers = [
|
|
5249
5978
|
{
|
|
5250
|
-
provide:
|
|
5251
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
5979
|
+
provide: import_nestjs_agent_core33.AGENT_TOOL_REGISTRY,
|
|
5980
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core33.ToolRegistry(), "useFactory")
|
|
5252
5981
|
},
|
|
5253
5982
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
5254
5983
|
{
|
|
5255
|
-
provide:
|
|
5256
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
5984
|
+
provide: import_nestjs_agent_core33.AGENT_REGISTRY,
|
|
5985
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core33.AgentRegistry(), "useFactory")
|
|
5257
5986
|
},
|
|
5258
5987
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
5259
5988
|
{
|
|
5260
|
-
provide:
|
|
5989
|
+
provide: import_nestjs_agent_core33.AGENT_PROMPT_CONTRIBUTORS,
|
|
5261
5990
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
5262
5991
|
},
|
|
5263
5992
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
5264
5993
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
5265
5994
|
{
|
|
5266
|
-
provide:
|
|
5995
|
+
provide: import_nestjs_agent_core33.AGENT_SKILL_SOURCES,
|
|
5267
5996
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
5268
5997
|
},
|
|
5269
5998
|
{
|
|
5270
5999
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
5271
6000
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
5272
6001
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
5273
|
-
provide:
|
|
6002
|
+
provide: import_nestjs_agent_core33.AGENT_SKILLS,
|
|
5274
6003
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
5275
6004
|
inject: [
|
|
5276
|
-
|
|
5277
|
-
|
|
6005
|
+
import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
6006
|
+
import_nestjs_agent_core33.AGENT_SKILL_SOURCES
|
|
5278
6007
|
]
|
|
5279
6008
|
},
|
|
5280
6009
|
{
|
|
5281
6010
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
5282
6011
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
5283
|
-
provide:
|
|
6012
|
+
provide: import_nestjs_agent_core33.AGENT_MEMORY,
|
|
5284
6013
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
5285
6014
|
inject: [
|
|
5286
|
-
|
|
6015
|
+
import_nestjs_agent_core33.AGENT_OPTIONS
|
|
5287
6016
|
]
|
|
5288
6017
|
},
|
|
5289
6018
|
{
|
|
5290
|
-
provide:
|
|
6019
|
+
provide: import_nestjs_agent_core33.AGENT_SINK,
|
|
5291
6020
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
5292
6021
|
inject: [
|
|
5293
|
-
|
|
6022
|
+
import_nestjs_agent_core33.AGENT_OPTIONS
|
|
5294
6023
|
]
|
|
5295
6024
|
},
|
|
5296
6025
|
{
|
|
5297
|
-
provide:
|
|
5298
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
6026
|
+
provide: import_nestjs_agent_core33.AGENT_ROLES_POLICY,
|
|
6027
|
+
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
5299
6028
|
inject: [
|
|
5300
|
-
|
|
6029
|
+
import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
6030
|
+
import_core4.ModulesContainer
|
|
5301
6031
|
]
|
|
5302
6032
|
},
|
|
5303
6033
|
{
|
|
5304
|
-
provide:
|
|
6034
|
+
provide: import_nestjs_agent_core33.AGENT_ACTOR_RESOLVER,
|
|
5305
6035
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
5306
6036
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
5307
6037
|
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.");
|
|
5308
6038
|
return new AnonymousActorResolver();
|
|
5309
6039
|
}, "useFactory"),
|
|
5310
6040
|
inject: [
|
|
5311
|
-
|
|
6041
|
+
import_nestjs_agent_core33.AGENT_OPTIONS
|
|
5312
6042
|
]
|
|
5313
6043
|
},
|
|
5314
6044
|
{
|
|
5315
|
-
provide:
|
|
6045
|
+
provide: import_nestjs_agent_core33.AGENT_MODEL,
|
|
5316
6046
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
5317
6047
|
inject: [
|
|
5318
|
-
|
|
6048
|
+
import_nestjs_agent_core33.AGENT_OPTIONS
|
|
5319
6049
|
]
|
|
5320
6050
|
},
|
|
5321
6051
|
{
|
|
5322
6052
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
5323
6053
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
5324
|
-
provide:
|
|
6054
|
+
provide: import_nestjs_agent_core33.AGENT_QUOTA_PROVIDER,
|
|
5325
6055
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
5326
6056
|
warnAt: o.quota.warnAt
|
|
5327
6057
|
} : {}), "useFactory"),
|
|
5328
6058
|
inject: [
|
|
5329
|
-
|
|
5330
|
-
|
|
6059
|
+
import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
6060
|
+
import_nestjs_agent_core33.AGENT_STORE
|
|
5331
6061
|
]
|
|
5332
6062
|
},
|
|
5333
6063
|
{
|
|
5334
|
-
provide:
|
|
6064
|
+
provide: import_nestjs_agent_core33.AGENT_MODEL_CATALOG,
|
|
5335
6065
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
5336
6066
|
inject: [
|
|
5337
|
-
|
|
6067
|
+
import_nestjs_agent_core33.AGENT_OPTIONS
|
|
5338
6068
|
]
|
|
5339
6069
|
},
|
|
5340
6070
|
AgentDepsFactory2,
|
|
5341
6071
|
{
|
|
5342
|
-
provide:
|
|
6072
|
+
provide: import_nestjs_agent_core33.AGENT_DEPS_FACTORY,
|
|
5343
6073
|
useExisting: AgentDepsFactory2
|
|
5344
6074
|
},
|
|
5345
6075
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -5356,25 +6086,27 @@ function sharedProviders(durable) {
|
|
|
5356
6086
|
},
|
|
5357
6087
|
InlineAgentRunner,
|
|
5358
6088
|
AgentService,
|
|
6089
|
+
ActionProposalService,
|
|
6090
|
+
ActionProposalWorkerService,
|
|
5359
6091
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
5360
6092
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
5361
6093
|
AgentApprovalPortAdapter,
|
|
5362
6094
|
{
|
|
5363
|
-
provide:
|
|
6095
|
+
provide: import_nestjs_agent_core33.AGENT_APPROVAL_PORT,
|
|
5364
6096
|
useExisting: AgentApprovalPortAdapter
|
|
5365
6097
|
}
|
|
5366
6098
|
];
|
|
5367
6099
|
providers.push({
|
|
5368
|
-
provide:
|
|
6100
|
+
provide: import_nestjs_agent_core33.AGENT_STORE,
|
|
5369
6101
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
5370
6102
|
inject: [
|
|
5371
|
-
|
|
6103
|
+
import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
5372
6104
|
import_core4.ModulesContainer
|
|
5373
6105
|
]
|
|
5374
6106
|
});
|
|
5375
6107
|
if (durable) {
|
|
5376
6108
|
providers.push({
|
|
5377
|
-
provide:
|
|
6109
|
+
provide: import_nestjs_agent_core33.AGENT_RUNNER,
|
|
5378
6110
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
5379
6111
|
if (durableRunner === void 0) {
|
|
5380
6112
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -5383,14 +6115,14 @@ function sharedProviders(durable) {
|
|
|
5383
6115
|
}, "useFactory"),
|
|
5384
6116
|
inject: [
|
|
5385
6117
|
{
|
|
5386
|
-
token:
|
|
6118
|
+
token: import_nestjs_agent_core33.AGENT_DURABLE_RUNNER,
|
|
5387
6119
|
optional: true
|
|
5388
6120
|
}
|
|
5389
6121
|
]
|
|
5390
6122
|
});
|
|
5391
6123
|
} else {
|
|
5392
6124
|
providers.push({
|
|
5393
|
-
provide:
|
|
6125
|
+
provide: import_nestjs_agent_core33.AGENT_RUNNER,
|
|
5394
6126
|
useExisting: InlineAgentRunner
|
|
5395
6127
|
});
|
|
5396
6128
|
}
|
|
@@ -5399,30 +6131,33 @@ function sharedProviders(durable) {
|
|
|
5399
6131
|
__name(sharedProviders, "sharedProviders");
|
|
5400
6132
|
function exportsFor() {
|
|
5401
6133
|
return [
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
6134
|
+
import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
6135
|
+
import_nestjs_agent_core33.AGENT_TOOL_REGISTRY,
|
|
6136
|
+
import_nestjs_agent_core33.AGENT_REGISTRY,
|
|
6137
|
+
import_nestjs_agent_core33.AGENT_SINK,
|
|
6138
|
+
import_nestjs_agent_core33.AGENT_ROLES_POLICY,
|
|
6139
|
+
import_nestjs_agent_core33.AGENT_ACTOR_RESOLVER,
|
|
6140
|
+
import_nestjs_agent_core33.AGENT_MODEL,
|
|
6141
|
+
import_nestjs_agent_core33.AGENT_STORE,
|
|
6142
|
+
import_nestjs_agent_core33.AGENT_MODEL_CATALOG,
|
|
6143
|
+
import_nestjs_agent_core33.AGENT_QUOTA_PROVIDER,
|
|
6144
|
+
import_nestjs_agent_core33.AGENT_PROMPT_CONTRIBUTORS,
|
|
6145
|
+
import_nestjs_agent_core33.AGENT_SKILLS,
|
|
6146
|
+
import_nestjs_agent_core33.AGENT_MEMORY,
|
|
6147
|
+
import_nestjs_agent_core33.AGENT_DEPS_FACTORY,
|
|
5416
6148
|
AgentDepsFactory2,
|
|
5417
6149
|
AgentService,
|
|
6150
|
+
ActionProposalService,
|
|
6151
|
+
ActionProposalWorkerService,
|
|
5418
6152
|
ChatQueueService,
|
|
5419
6153
|
AGENT_CHAT_QUEUE,
|
|
5420
6154
|
InlineAgentRunner,
|
|
5421
|
-
|
|
6155
|
+
import_nestjs_agent_core33.AGENT_APPROVAL_PORT
|
|
5422
6156
|
];
|
|
5423
6157
|
}
|
|
5424
6158
|
__name(exportsFor, "exportsFor");
|
|
5425
6159
|
var BASE_CONTROLLERS = [
|
|
6160
|
+
ActionProposalController,
|
|
5426
6161
|
ChatController,
|
|
5427
6162
|
QueueController,
|
|
5428
6163
|
ThreadsController,
|
|
@@ -5495,7 +6230,7 @@ var AgentModule = class _AgentModule {
|
|
|
5495
6230
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5496
6231
|
providers: [
|
|
5497
6232
|
{
|
|
5498
|
-
provide:
|
|
6233
|
+
provide: import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
5499
6234
|
useValue: options
|
|
5500
6235
|
},
|
|
5501
6236
|
...sharedProviders(options.durable ?? false),
|
|
@@ -5519,7 +6254,7 @@ var AgentModule = class _AgentModule {
|
|
|
5519
6254
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5520
6255
|
providers: [
|
|
5521
6256
|
{
|
|
5522
|
-
provide:
|
|
6257
|
+
provide: import_nestjs_agent_core33.AGENT_OPTIONS,
|
|
5523
6258
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
5524
6259
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
5525
6260
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -5541,16 +6276,16 @@ var AgentModule = class _AgentModule {
|
|
|
5541
6276
|
};
|
|
5542
6277
|
}
|
|
5543
6278
|
};
|
|
5544
|
-
AgentModule =
|
|
5545
|
-
(0,
|
|
5546
|
-
(0,
|
|
6279
|
+
AgentModule = _ts_decorate26([
|
|
6280
|
+
(0, import_common27.Global)(),
|
|
6281
|
+
(0, import_common27.Module)({})
|
|
5547
6282
|
], AgentModule);
|
|
5548
6283
|
|
|
5549
6284
|
// src/ag-ui/ag-ui.adapter.ts
|
|
5550
|
-
var
|
|
6285
|
+
var import_nestjs_agent_core34 = require("@dudousxd/nestjs-agent-core");
|
|
5551
6286
|
var import_ag_ui = require("@dudousxd/nestjs-agent-core/ag-ui");
|
|
5552
|
-
var
|
|
5553
|
-
function
|
|
6287
|
+
var import_common28 = require("@nestjs/common");
|
|
6288
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
5554
6289
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5555
6290
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5556
6291
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5563,22 +6298,22 @@ function _ts_decorate23(decorators, target, key, desc) {
|
|
|
5563
6298
|
}
|
|
5564
6299
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5565
6300
|
}
|
|
5566
|
-
__name(
|
|
5567
|
-
function
|
|
6301
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
6302
|
+
function _ts_metadata25(metadataKey, metadataValue) {
|
|
5568
6303
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5569
6304
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5570
6305
|
}
|
|
5571
6306
|
}
|
|
5572
|
-
__name(
|
|
5573
|
-
function
|
|
6307
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
6308
|
+
function _ts_param25(paramIndex, decorator) {
|
|
5574
6309
|
return function(target, key) {
|
|
5575
6310
|
decorator(target, key, paramIndex);
|
|
5576
6311
|
};
|
|
5577
6312
|
}
|
|
5578
|
-
__name(
|
|
6313
|
+
__name(_ts_param25, "_ts_param");
|
|
5579
6314
|
var AG_UI_VIA = "ag-ui";
|
|
5580
6315
|
function invalid(code, message) {
|
|
5581
|
-
return new
|
|
6316
|
+
return new import_common28.BadRequestException({
|
|
5582
6317
|
statusCode: 400,
|
|
5583
6318
|
code,
|
|
5584
6319
|
message
|
|
@@ -5634,6 +6369,19 @@ var AgUiRunHandler = class {
|
|
|
5634
6369
|
warnings.push(`The resume entry ${id} answers an interrupt this agent did not raise.`);
|
|
5635
6370
|
}
|
|
5636
6371
|
const first = plan.decisions[0];
|
|
6372
|
+
if (first !== void 0 && plan.decisions.every((d) => d.address.kind === "proposal")) {
|
|
6373
|
+
const decided = await this.decideProposals(actor, plan.decisions);
|
|
6374
|
+
this.writeEvents(res, [
|
|
6375
|
+
...warningEvents(warnings),
|
|
6376
|
+
...decided.flatMap((outcome, index) => (0, import_ag_ui.actionProposalDecisionEvents)({
|
|
6377
|
+
threadId: input.threadId,
|
|
6378
|
+
runId: index === 0 ? input.runId : `${input.runId}:${index}`,
|
|
6379
|
+
text: outcome.text,
|
|
6380
|
+
proposalDecision: outcome.proposalDecision
|
|
6381
|
+
}))
|
|
6382
|
+
]);
|
|
6383
|
+
return;
|
|
6384
|
+
}
|
|
5637
6385
|
if (first !== void 0) {
|
|
5638
6386
|
const streamRunId = first.address.stream;
|
|
5639
6387
|
await this.agent.assertResumable(actor, streamRunId);
|
|
@@ -5657,7 +6405,22 @@ var AgUiRunHandler = class {
|
|
|
5657
6405
|
warnings.push(...turn.dropped);
|
|
5658
6406
|
const owner = await this.agent.threadOwner(input.threadId);
|
|
5659
6407
|
if (owner !== null && owner !== actor.id) {
|
|
5660
|
-
throw new
|
|
6408
|
+
throw new import_common28.ForbiddenException("thread belongs to another actor");
|
|
6409
|
+
}
|
|
6410
|
+
if (owner !== null && turn.media.length === 0) {
|
|
6411
|
+
const decision = await this.agent.handleTextDecision(input.threadId, actor, turn.text);
|
|
6412
|
+
if ("proposalDecision" in decision) {
|
|
6413
|
+
this.writeEvents(res, [
|
|
6414
|
+
...warningEvents(warnings),
|
|
6415
|
+
...(0, import_ag_ui.actionProposalDecisionEvents)({
|
|
6416
|
+
threadId: input.threadId,
|
|
6417
|
+
runId: input.runId,
|
|
6418
|
+
text: decision.text,
|
|
6419
|
+
proposalDecision: decision.proposalDecision
|
|
6420
|
+
})
|
|
6421
|
+
]);
|
|
6422
|
+
return;
|
|
6423
|
+
}
|
|
5661
6424
|
}
|
|
5662
6425
|
const refs = await this.stage(actor, turn.media, warnings);
|
|
5663
6426
|
if (turn.text.trim().length === 0 && refs.length === 0) {
|
|
@@ -5687,6 +6450,9 @@ var AgUiRunHandler = class {
|
|
|
5687
6450
|
...forwarded.model !== void 0 ? {
|
|
5688
6451
|
model: forwarded.model
|
|
5689
6452
|
} : {},
|
|
6453
|
+
...forwarded.uiCapabilities !== void 0 ? {
|
|
6454
|
+
uiCapabilities: forwarded.uiCapabilities
|
|
6455
|
+
} : {},
|
|
5690
6456
|
...pageContext !== void 0 ? {
|
|
5691
6457
|
pageContext
|
|
5692
6458
|
} : {},
|
|
@@ -5744,9 +6510,11 @@ var AgUiRunHandler = class {
|
|
|
5744
6510
|
*/
|
|
5745
6511
|
async settle(actor, decisions) {
|
|
5746
6512
|
const deliveries = [];
|
|
6513
|
+
const proposals = decisions.filter((decision) => decision.address.kind === "proposal");
|
|
5747
6514
|
for (const { address, entry } of decisions) {
|
|
5748
6515
|
const { toolCallId: toolCallId2 } = address;
|
|
5749
6516
|
const abandoned = entry.status === "cancelled";
|
|
6517
|
+
if (address.kind === "proposal") continue;
|
|
5750
6518
|
if (address.kind === "approval") {
|
|
5751
6519
|
await this.agent.checkDecision(actor, toolCallId2);
|
|
5752
6520
|
const decision = abandoned ? {
|
|
@@ -5783,9 +6551,53 @@ var AgUiRunHandler = class {
|
|
|
5783
6551
|
via: AG_UI_VIA
|
|
5784
6552
|
}));
|
|
5785
6553
|
}
|
|
6554
|
+
if (proposals.length > 0) await this.decideProposals(actor, proposals);
|
|
5786
6555
|
for (const deliver of deliveries) await deliver();
|
|
5787
6556
|
}
|
|
5788
6557
|
/**
|
|
6558
|
+
* Decide independent proposals through the proposal service — the call the native
|
|
6559
|
+
* `action-proposals/:id/approve|reject` routes make — never by signalling the origin run, which
|
|
6560
|
+
* is not waiting. Every payload is checked before the first decision; a refusal is the service's
|
|
6561
|
+
* own `403`/`404`.
|
|
6562
|
+
*/
|
|
6563
|
+
async decideProposals(actor, decisions) {
|
|
6564
|
+
const planned = decisions.map(({ address, entry }) => {
|
|
6565
|
+
const decision = entry.status === "cancelled" ? {
|
|
6566
|
+
approved: false
|
|
6567
|
+
} : (0, import_ag_ui.readApprovalPayload)(entry.payload);
|
|
6568
|
+
if (decision === null || address.proposalId === void 0 || address.threadId === void 0) {
|
|
6569
|
+
throw invalid("invalid_resume", "an approval is answered with { approved: boolean, reason?, remember? }");
|
|
6570
|
+
}
|
|
6571
|
+
return {
|
|
6572
|
+
address,
|
|
6573
|
+
decision
|
|
6574
|
+
};
|
|
6575
|
+
});
|
|
6576
|
+
const outcomes = [];
|
|
6577
|
+
for (const { address, decision } of planned) {
|
|
6578
|
+
outcomes.push(await this.agent.decideActionProposal(actor, address.threadId, address.proposalId, {
|
|
6579
|
+
decision: decision.approved ? "approved" : "rejected",
|
|
6580
|
+
via: AG_UI_VIA,
|
|
6581
|
+
...decision.remember !== void 0 ? {
|
|
6582
|
+
remember: decision.remember
|
|
6583
|
+
} : {},
|
|
6584
|
+
...decision.reason !== void 0 ? {
|
|
6585
|
+
reason: decision.reason
|
|
6586
|
+
} : {}
|
|
6587
|
+
}));
|
|
6588
|
+
}
|
|
6589
|
+
return outcomes;
|
|
6590
|
+
}
|
|
6591
|
+
/** Answer with a complete list of events, no run behind them. */
|
|
6592
|
+
writeEvents(res, events) {
|
|
6593
|
+
res.status(200);
|
|
6594
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
6595
|
+
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
6596
|
+
res.flushHeaders();
|
|
6597
|
+
for (const event of events) res.write((0, import_ag_ui.agUiSse)(event));
|
|
6598
|
+
res.end();
|
|
6599
|
+
}
|
|
6600
|
+
/**
|
|
5789
6601
|
* Pipe a run to the client as AG-UI 1.0 over SSE: one event per `data:` line, from `RUN_STARTED`
|
|
5790
6602
|
* to the run's terminal event. It ends when the run stops to ask — the library run stays parked,
|
|
5791
6603
|
* and the request that answers re-attaches to it.
|
|
@@ -5831,29 +6643,29 @@ function agUiAdapter(options = {}) {
|
|
|
5831
6643
|
return this.handle(req, res, body);
|
|
5832
6644
|
}
|
|
5833
6645
|
};
|
|
5834
|
-
|
|
5835
|
-
(0,
|
|
5836
|
-
(0,
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
6646
|
+
_ts_decorate27([
|
|
6647
|
+
(0, import_common28.Post)(path),
|
|
6648
|
+
(0, import_common28.HttpCode)(200),
|
|
6649
|
+
_ts_param25(0, (0, import_common28.Req)()),
|
|
6650
|
+
_ts_param25(1, (0, import_common28.Res)()),
|
|
6651
|
+
_ts_param25(2, (0, import_common28.Body)()),
|
|
6652
|
+
_ts_metadata25("design:type", Function),
|
|
6653
|
+
_ts_metadata25("design:paramtypes", [
|
|
5842
6654
|
typeof Request === "undefined" ? Object : Request,
|
|
5843
6655
|
typeof Response === "undefined" ? Object : Response,
|
|
5844
6656
|
Object
|
|
5845
6657
|
]),
|
|
5846
|
-
|
|
6658
|
+
_ts_metadata25("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5847
6659
|
], AgUiController.prototype, "run", null);
|
|
5848
|
-
AgUiController =
|
|
5849
|
-
(0,
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
6660
|
+
AgUiController = _ts_decorate27([
|
|
6661
|
+
(0, import_common28.Controller)(),
|
|
6662
|
+
_ts_param25(0, (0, import_common28.Inject)(AgentService)),
|
|
6663
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core34.AGENT_ACTOR_RESOLVER)),
|
|
6664
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core34.AGENT_OPTIONS)),
|
|
6665
|
+
_ts_param25(3, (0, import_common28.Optional)()),
|
|
6666
|
+
_ts_param25(3, (0, import_common28.Inject)(import_nestjs_agent_core34.AGENT_ATTACHMENT_STAGING)),
|
|
6667
|
+
_ts_metadata25("design:type", Function),
|
|
6668
|
+
_ts_metadata25("design:paramtypes", [
|
|
5857
6669
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
5858
6670
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
5859
6671
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -5870,7 +6682,7 @@ function agUiAdapter(options = {}) {
|
|
|
5870
6682
|
__name(agUiAdapter, "agUiAdapter");
|
|
5871
6683
|
|
|
5872
6684
|
// src/resolver/header-actor-resolver.ts
|
|
5873
|
-
var
|
|
6685
|
+
var import_common29 = require("@nestjs/common");
|
|
5874
6686
|
function readHeader(req, name) {
|
|
5875
6687
|
if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
|
|
5876
6688
|
const { headers } = req;
|
|
@@ -5886,7 +6698,7 @@ var HeaderActorResolver = class {
|
|
|
5886
6698
|
resolve(req) {
|
|
5887
6699
|
const id = readHeader(req, "x-actor-id");
|
|
5888
6700
|
if (id === void 0 || id.length === 0) {
|
|
5889
|
-
throw new
|
|
6701
|
+
throw new import_common29.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
|
|
5890
6702
|
}
|
|
5891
6703
|
const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
|
|
5892
6704
|
const tenantRef = readHeader(req, "x-tenant-ref");
|
|
@@ -5901,7 +6713,7 @@ var HeaderActorResolver = class {
|
|
|
5901
6713
|
};
|
|
5902
6714
|
|
|
5903
6715
|
// src/resolver/request-user-actor-resolver.ts
|
|
5904
|
-
var
|
|
6716
|
+
var import_common30 = require("@nestjs/common");
|
|
5905
6717
|
function field(user, ...names) {
|
|
5906
6718
|
for (const name of names) {
|
|
5907
6719
|
const value = user[name];
|
|
@@ -5913,7 +6725,7 @@ __name(field, "field");
|
|
|
5913
6725
|
function defaultRequestUserMapper(user) {
|
|
5914
6726
|
const id = field(user, "id", "sub", "_id", "userId");
|
|
5915
6727
|
if (id === void 0) {
|
|
5916
|
-
throw new
|
|
6728
|
+
throw new import_common30.UnauthorizedException("requestUserActorResolver: req.user has no id/sub/_id/userId \u2014 pass a mapper: requestUserActorResolver((user) => ({ id: \u2026, roles: \u2026 }))");
|
|
5917
6729
|
}
|
|
5918
6730
|
const rawRoles = field(user, "roles", "role");
|
|
5919
6731
|
const roles = Array.isArray(rawRoles) ? rawRoles.map(String) : typeof rawRoles === "string" ? [
|
|
@@ -5934,7 +6746,7 @@ function requestUserActorResolver(map) {
|
|
|
5934
6746
|
async resolve(req) {
|
|
5935
6747
|
const user = typeof req === "object" && req !== null ? req.user : void 0;
|
|
5936
6748
|
if (user === void 0 || user === null || user === false) {
|
|
5937
|
-
throw new
|
|
6749
|
+
throw new import_common30.UnauthorizedException("Sign in to use the agent.");
|
|
5938
6750
|
}
|
|
5939
6751
|
if (map !== void 0) return map(user, req);
|
|
5940
6752
|
return defaultRequestUserMapper(user);
|
|
@@ -5952,6 +6764,9 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
5952
6764
|
AGENT_TOOL_BRAND,
|
|
5953
6765
|
AI_TOOL_METADATA,
|
|
5954
6766
|
ATTACHMENT_PAGE_SIZE,
|
|
6767
|
+
ActionProposalController,
|
|
6768
|
+
ActionProposalService,
|
|
6769
|
+
ActionProposalWorkerService,
|
|
5955
6770
|
AgUiRunHandler,
|
|
5956
6771
|
Agent,
|
|
5957
6772
|
AgentApprovalPortAdapter,
|
|
@@ -5990,6 +6805,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
5990
6805
|
attachmentLimits,
|
|
5991
6806
|
declaredSkillProvider,
|
|
5992
6807
|
defaultRequestUserMapper,
|
|
6808
|
+
defineTool,
|
|
5993
6809
|
delegateToolName,
|
|
5994
6810
|
provideAgentTool,
|
|
5995
6811
|
provideAgentTools,
|