@dudousxd/nestjs-agent 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/{chat-queue.service-C0hr7dqx.d.ts → chat-queue.service-CGsR40Ct.d.cts} +16 -2
- package/dist/{chat-queue.service-C0hr7dqx.d.cts → chat-queue.service-XG9RQCjU.d.ts} +16 -2
- package/dist/durable/index.cjs +1556 -830
- 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 +1290 -564
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.d.cts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/index.cjs +1487 -825
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -9
- package/dist/index.d.ts +111 -9
- package/dist/index.js +1258 -599
- package/dist/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,
|
|
@@ -81,14 +84,59 @@ __export(index_exports, {
|
|
|
81
84
|
module.exports = __toCommonJS(index_exports);
|
|
82
85
|
|
|
83
86
|
// src/agent.module.ts
|
|
84
|
-
var
|
|
85
|
-
var
|
|
87
|
+
var import_nestjs_agent_core31 = require("@dudousxd/nestjs-agent-core");
|
|
88
|
+
var import_common27 = require("@nestjs/common");
|
|
86
89
|
var import_core4 = require("@nestjs/core");
|
|
87
90
|
|
|
88
91
|
// src/agent-deps.factory.ts
|
|
89
92
|
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_common2 = require("@nestjs/common");
|
|
96
|
+
|
|
97
|
+
// src/genui/agent-genui.module.ts
|
|
98
|
+
var import_genui = require("@dudousxd/nestjs-agent-core/genui");
|
|
91
99
|
var import_common = require("@nestjs/common");
|
|
100
|
+
|
|
101
|
+
// src/functional-tool.ts
|
|
102
|
+
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
103
|
+
function brand(tool) {
|
|
104
|
+
return {
|
|
105
|
+
[AGENT_TOOL_BRAND]: true,
|
|
106
|
+
spec: tool.spec,
|
|
107
|
+
handler: tool.handler
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
__name(brand, "brand");
|
|
111
|
+
function isBrandedFunctionalTool(value) {
|
|
112
|
+
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
113
|
+
}
|
|
114
|
+
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
115
|
+
function provideAgentTool(factoryOrTool, inject) {
|
|
116
|
+
const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
|
|
117
|
+
if (typeof factoryOrTool === "function") {
|
|
118
|
+
return {
|
|
119
|
+
provide,
|
|
120
|
+
useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
|
|
121
|
+
inject: inject ?? []
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
provide,
|
|
126
|
+
useValue: brand(factoryOrTool)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
__name(provideAgentTool, "provideAgentTool");
|
|
130
|
+
function provideAgentTools(factory, inject) {
|
|
131
|
+
return {
|
|
132
|
+
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
133
|
+
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
134
|
+
inject: inject ?? []
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
__name(provideAgentTools, "provideAgentTools");
|
|
138
|
+
|
|
139
|
+
// src/genui/agent-genui.module.ts
|
|
92
140
|
function _ts_decorate(decorators, target, key, desc) {
|
|
93
141
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
94
142
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -103,6 +151,124 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
103
151
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
104
152
|
}
|
|
105
153
|
__name(_ts_decorate, "_ts_decorate");
|
|
154
|
+
var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
|
|
155
|
+
var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
|
|
156
|
+
var GenuiCatalogResolver = class {
|
|
157
|
+
static {
|
|
158
|
+
__name(this, "GenuiCatalogResolver");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
function resolverProviders(resolver) {
|
|
162
|
+
if (resolver === void 0) return [];
|
|
163
|
+
return [
|
|
164
|
+
typeof resolver === "function" ? {
|
|
165
|
+
provide: GenuiCatalogResolver,
|
|
166
|
+
useClass: resolver
|
|
167
|
+
} : {
|
|
168
|
+
provide: GenuiCatalogResolver,
|
|
169
|
+
useValue: resolver
|
|
170
|
+
}
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
__name(resolverProviders, "resolverProviders");
|
|
174
|
+
function toolOptions(options, resolver) {
|
|
175
|
+
const { catalog: _catalog, ...rest } = options;
|
|
176
|
+
return {
|
|
177
|
+
...rest,
|
|
178
|
+
...resolver !== void 0 ? {
|
|
179
|
+
resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
|
|
180
|
+
} : {}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
__name(toolOptions, "toolOptions");
|
|
184
|
+
function coreProviders(resolver) {
|
|
185
|
+
return [
|
|
186
|
+
{
|
|
187
|
+
provide: GENUI_CATALOG,
|
|
188
|
+
useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? (0, import_genui.defineCatalog)([]), "useFactory"),
|
|
189
|
+
inject: [
|
|
190
|
+
GENUI_OPTIONS
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
...resolverProviders(resolver),
|
|
194
|
+
// The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
|
|
195
|
+
// Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
|
|
196
|
+
provideAgentTools((options, catalog, perRequest) => (0, import_genui.genuiTools)(catalog, toolOptions(options, perRequest)), [
|
|
197
|
+
GENUI_OPTIONS,
|
|
198
|
+
GENUI_CATALOG,
|
|
199
|
+
{
|
|
200
|
+
token: GenuiCatalogResolver,
|
|
201
|
+
optional: true
|
|
202
|
+
}
|
|
203
|
+
])
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
__name(coreProviders, "coreProviders");
|
|
207
|
+
var EXPORTS = [
|
|
208
|
+
GENUI_CATALOG,
|
|
209
|
+
GENUI_OPTIONS
|
|
210
|
+
];
|
|
211
|
+
var AgentGenuiModule = class _AgentGenuiModule {
|
|
212
|
+
static {
|
|
213
|
+
__name(this, "AgentGenuiModule");
|
|
214
|
+
}
|
|
215
|
+
static forRoot(options = {}) {
|
|
216
|
+
const { resolver, ...rest } = options;
|
|
217
|
+
return {
|
|
218
|
+
module: _AgentGenuiModule,
|
|
219
|
+
global: true,
|
|
220
|
+
providers: [
|
|
221
|
+
{
|
|
222
|
+
provide: GENUI_OPTIONS,
|
|
223
|
+
useValue: rest
|
|
224
|
+
},
|
|
225
|
+
...coreProviders(resolver)
|
|
226
|
+
],
|
|
227
|
+
exports: resolver === void 0 ? EXPORTS : [
|
|
228
|
+
...EXPORTS,
|
|
229
|
+
GenuiCatalogResolver
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
static forRootAsync(options) {
|
|
234
|
+
return {
|
|
235
|
+
module: _AgentGenuiModule,
|
|
236
|
+
global: true,
|
|
237
|
+
imports: options.imports ?? [],
|
|
238
|
+
providers: [
|
|
239
|
+
{
|
|
240
|
+
provide: GENUI_OPTIONS,
|
|
241
|
+
useFactory: options.useFactory,
|
|
242
|
+
inject: options.inject ?? []
|
|
243
|
+
},
|
|
244
|
+
...coreProviders(options.resolver)
|
|
245
|
+
],
|
|
246
|
+
exports: options.resolver === void 0 ? EXPORTS : [
|
|
247
|
+
...EXPORTS,
|
|
248
|
+
GenuiCatalogResolver
|
|
249
|
+
]
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
AgentGenuiModule = _ts_decorate([
|
|
254
|
+
(0, import_common.Module)({})
|
|
255
|
+
], AgentGenuiModule);
|
|
256
|
+
|
|
257
|
+
// src/agent-deps.factory.ts
|
|
258
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
259
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
260
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
261
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
262
|
+
} else {
|
|
263
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
264
|
+
if (d = decorators[i]) {
|
|
265
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
270
|
+
}
|
|
271
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
106
272
|
function _ts_metadata(metadataKey, metadataValue) {
|
|
107
273
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
108
274
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -135,7 +301,9 @@ var AgentDepsFactory2 = class {
|
|
|
135
301
|
pricingStore;
|
|
136
302
|
skills;
|
|
137
303
|
memory;
|
|
138
|
-
|
|
304
|
+
uiCatalog;
|
|
305
|
+
uiCatalogResolver;
|
|
306
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
|
|
139
307
|
this.options = options;
|
|
140
308
|
this.model = model;
|
|
141
309
|
this.store = store;
|
|
@@ -147,6 +315,9 @@ var AgentDepsFactory2 = class {
|
|
|
147
315
|
this.pricingStore = pricingStore;
|
|
148
316
|
this.skills = skills;
|
|
149
317
|
this.memory = memory;
|
|
318
|
+
this.uiCatalog = uiCatalog;
|
|
319
|
+
this.uiCatalogResolver = uiCatalogResolver;
|
|
320
|
+
if (options.actionApprovalMode === "independent") (0, import_nestjs_agent_core.assertIndependentActionCapabilities)(store, options.backgroundActorResolver);
|
|
150
321
|
}
|
|
151
322
|
/** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
|
|
152
323
|
memoryConfig() {
|
|
@@ -172,7 +343,7 @@ var AgentDepsFactory2 = class {
|
|
|
172
343
|
return void 0;
|
|
173
344
|
}
|
|
174
345
|
const delegated = (definition.delegatesTo ?? []).map((edge) => {
|
|
175
|
-
const { agent, detached } = (0,
|
|
346
|
+
const { agent, detached } = (0, import_nestjs_agent_core2.normalizeDelegation)(edge);
|
|
176
347
|
return delegateToolName({
|
|
177
348
|
target: agent,
|
|
178
349
|
detached
|
|
@@ -196,7 +367,7 @@ var AgentDepsFactory2 = class {
|
|
|
196
367
|
agentName: name
|
|
197
368
|
};
|
|
198
369
|
}
|
|
199
|
-
const alias = (0,
|
|
370
|
+
const alias = (0, import_nestjs_agent_core2.resolvePersonaAlias)(this.agents.list(), name);
|
|
200
371
|
return alias === void 0 ? {
|
|
201
372
|
agentName: name
|
|
202
373
|
} : {
|
|
@@ -206,7 +377,7 @@ var AgentDepsFactory2 = class {
|
|
|
206
377
|
}
|
|
207
378
|
/** `agentName`'s personas as a picker reads them. Empty when it declares none. */
|
|
208
379
|
personaCatalog(agentName) {
|
|
209
|
-
return (this.agents.get(agentName)?.personas ?? []).map(
|
|
380
|
+
return (this.agents.get(agentName)?.personas ?? []).map(import_nestjs_agent_core2.personaCatalogEntry);
|
|
210
381
|
}
|
|
211
382
|
/** The persona `agentName` runs under when nothing names one. Undefined → none. */
|
|
212
383
|
defaultPersona(agentName) {
|
|
@@ -220,8 +391,8 @@ var AgentDepsFactory2 = class {
|
|
|
220
391
|
resolvePersona(args) {
|
|
221
392
|
const definition = this.agents.get(args.agentName);
|
|
222
393
|
if (args.requested !== void 0) {
|
|
223
|
-
if ((0,
|
|
224
|
-
throw new
|
|
394
|
+
if ((0, import_nestjs_agent_core2.findPersona)(definition, args.requested) === void 0) {
|
|
395
|
+
throw new import_common2.BadRequestException({
|
|
225
396
|
statusCode: 400,
|
|
226
397
|
code: "persona_not_found",
|
|
227
398
|
message: `agent "${args.agentName}" has no persona "${args.requested}"`
|
|
@@ -230,16 +401,28 @@ var AgentDepsFactory2 = class {
|
|
|
230
401
|
return args.requested;
|
|
231
402
|
}
|
|
232
403
|
const pinned = args.threadPersona ?? void 0;
|
|
233
|
-
if (pinned !== void 0 && (0,
|
|
404
|
+
if (pinned !== void 0 && (0, import_nestjs_agent_core2.findPersona)(definition, pinned) !== void 0) {
|
|
234
405
|
return pinned;
|
|
235
406
|
}
|
|
236
407
|
return definition?.defaultPersona;
|
|
237
408
|
}
|
|
409
|
+
forProposal(proposal, _actor) {
|
|
410
|
+
const name = proposal.executionContext?.agentName;
|
|
411
|
+
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`);
|
|
412
|
+
const deps = this.forAgent(name);
|
|
413
|
+
const id = proposal.executionContext?.persona;
|
|
414
|
+
if (id !== void 0) {
|
|
415
|
+
const persona = deps.personas?.find((persona2) => persona2.id === id);
|
|
416
|
+
if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
|
|
417
|
+
return this.withPersona(deps, persona);
|
|
418
|
+
}
|
|
419
|
+
return deps;
|
|
420
|
+
}
|
|
238
421
|
forAgent(agentName) {
|
|
239
422
|
const name = agentName ?? this.defaultAgentName();
|
|
240
423
|
if (agentName !== void 0 && !this.agents.has(agentName)) {
|
|
241
|
-
const alias = (0,
|
|
242
|
-
const persona = alias === void 0 ? void 0 : (0,
|
|
424
|
+
const alias = (0, import_nestjs_agent_core2.resolvePersonaAlias)(this.agents.list(), agentName);
|
|
425
|
+
const persona = alias === void 0 ? void 0 : (0, import_nestjs_agent_core2.findPersona)(this.agents.get(alias.agent), alias.persona);
|
|
243
426
|
if (alias !== void 0 && persona !== void 0) {
|
|
244
427
|
return this.withPersona(this.forAgent(alias.agent), persona);
|
|
245
428
|
}
|
|
@@ -253,12 +436,27 @@ var AgentDepsFactory2 = class {
|
|
|
253
436
|
return {
|
|
254
437
|
model: this.model,
|
|
255
438
|
store: this.store,
|
|
439
|
+
...this.options.actionApprovalMode !== void 0 ? {
|
|
440
|
+
actionApprovalMode: this.options.actionApprovalMode
|
|
441
|
+
} : {},
|
|
256
442
|
sink: this.sink,
|
|
257
443
|
rolesPolicy: this.rolesPolicy,
|
|
258
444
|
...this.options.approvalPolicy !== void 0 ? {
|
|
259
445
|
approvalPolicy: this.options.approvalPolicy
|
|
260
446
|
} : {},
|
|
261
447
|
registry: this.registry,
|
|
448
|
+
...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
|
|
449
|
+
resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
|
|
450
|
+
const catalog = this.uiCatalogResolver?.resolve({
|
|
451
|
+
...scope,
|
|
452
|
+
...scope.actor.tenantRef !== void 0 ? {
|
|
453
|
+
tenant: scope.actor.tenantRef
|
|
454
|
+
} : {}
|
|
455
|
+
}) ?? this.uiCatalog;
|
|
456
|
+
if (!catalog) throw new Error("UI catalog unavailable");
|
|
457
|
+
return catalog;
|
|
458
|
+
}, "resolveUiCatalog")
|
|
459
|
+
} : {},
|
|
262
460
|
promptContributors: this.promptContributors,
|
|
263
461
|
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
264
462
|
maxSteps: definition?.maxSteps ?? 8,
|
|
@@ -358,7 +556,7 @@ var AgentDepsFactory2 = class {
|
|
|
358
556
|
} : {}
|
|
359
557
|
});
|
|
360
558
|
}, "systemPrompt");
|
|
361
|
-
const toolAllowList = (0,
|
|
559
|
+
const toolAllowList = (0, import_nestjs_agent_core2.intersectAllowLists)(deps.toolAllowList, persona.allowedTools);
|
|
362
560
|
return {
|
|
363
561
|
...deps,
|
|
364
562
|
systemPrompt,
|
|
@@ -383,7 +581,7 @@ var AgentDepsFactory2 = class {
|
|
|
383
581
|
}
|
|
384
582
|
/** Build the built-in window policy from the declarative `{ maxMessages, maxTokens, summarize }`. */
|
|
385
583
|
window(config) {
|
|
386
|
-
return (0,
|
|
584
|
+
return (0, import_nestjs_agent_core2.windowHistory)({
|
|
387
585
|
...config.maxMessages !== void 0 ? {
|
|
388
586
|
maxMessages: config.maxMessages
|
|
389
587
|
} : {},
|
|
@@ -393,7 +591,7 @@ var AgentDepsFactory2 = class {
|
|
|
393
591
|
// The shared module model, not a per-agent one: an agent's `modelId` is an accounting label,
|
|
394
592
|
// and only one provider is ever bound.
|
|
395
593
|
...config.summarize === true ? {
|
|
396
|
-
summarize: (0,
|
|
594
|
+
summarize: (0, import_nestjs_agent_core2.summarizeWithModel)(this.model)
|
|
397
595
|
} : {}
|
|
398
596
|
});
|
|
399
597
|
}
|
|
@@ -409,22 +607,25 @@ var AgentDepsFactory2 = class {
|
|
|
409
607
|
return void 0;
|
|
410
608
|
}
|
|
411
609
|
};
|
|
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,
|
|
610
|
+
AgentDepsFactory2 = _ts_decorate2([
|
|
611
|
+
(0, import_common2.Injectable)(),
|
|
612
|
+
_ts_param(0, (0, import_common2.Inject)(import_nestjs_agent_core3.AGENT_OPTIONS)),
|
|
613
|
+
_ts_param(1, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_MODEL)),
|
|
614
|
+
_ts_param(2, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_STORE)),
|
|
615
|
+
_ts_param(3, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_SINK)),
|
|
616
|
+
_ts_param(4, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_ROLES_POLICY)),
|
|
617
|
+
_ts_param(5, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_TOOL_REGISTRY)),
|
|
618
|
+
_ts_param(6, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_REGISTRY)),
|
|
619
|
+
_ts_param(7, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_PROMPT_CONTRIBUTORS)),
|
|
620
|
+
_ts_param(8, (0, import_common2.Optional)()),
|
|
621
|
+
_ts_param(8, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_PRICING_STORE)),
|
|
622
|
+
_ts_param(9, (0, import_common2.Optional)()),
|
|
623
|
+
_ts_param(9, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_SKILLS)),
|
|
624
|
+
_ts_param(10, (0, import_common2.Optional)()),
|
|
625
|
+
_ts_param(10, (0, import_common2.Inject)(import_nestjs_agent_core2.AGENT_MEMORY)),
|
|
626
|
+
_ts_param(11, (0, import_common2.Optional)()),
|
|
627
|
+
_ts_param(11, (0, import_common2.Inject)(GENUI_CATALOG)),
|
|
628
|
+
_ts_param(12, (0, import_common2.Optional)()),
|
|
428
629
|
_ts_metadata("design:type", Function),
|
|
429
630
|
_ts_metadata("design:paramtypes", [
|
|
430
631
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -432,18 +633,20 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
432
633
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
433
634
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
434
635
|
typeof RolesPolicy === "undefined" ? Object : RolesPolicy,
|
|
435
|
-
typeof
|
|
436
|
-
typeof
|
|
636
|
+
typeof import_nestjs_agent_core2.ToolRegistry === "undefined" ? Object : import_nestjs_agent_core2.ToolRegistry,
|
|
637
|
+
typeof import_nestjs_agent_core2.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core2.AgentRegistry,
|
|
437
638
|
Array,
|
|
438
639
|
Object,
|
|
439
640
|
Object,
|
|
440
|
-
Object
|
|
641
|
+
Object,
|
|
642
|
+
typeof Catalog === "undefined" ? Object : Catalog,
|
|
643
|
+
typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
|
|
441
644
|
])
|
|
442
645
|
], AgentDepsFactory2);
|
|
443
646
|
|
|
444
647
|
// src/agent.service.ts
|
|
445
|
-
var
|
|
446
|
-
var
|
|
648
|
+
var import_nestjs_agent_core7 = require("@dudousxd/nestjs-agent-core");
|
|
649
|
+
var import_common6 = require("@nestjs/common");
|
|
447
650
|
|
|
448
651
|
// src/agent-deps.ts
|
|
449
652
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -467,9 +670,159 @@ function childSinkWriter(writer) {
|
|
|
467
670
|
}
|
|
468
671
|
__name(childSinkWriter, "childSinkWriter");
|
|
469
672
|
|
|
673
|
+
// src/proposals/action-proposal.service.ts
|
|
674
|
+
var import_nestjs_agent_core4 = require("@dudousxd/nestjs-agent-core");
|
|
675
|
+
var import_common3 = require("@nestjs/common");
|
|
676
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
677
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
678
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
679
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
680
|
+
} else {
|
|
681
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
682
|
+
if (d = decorators[i]) {
|
|
683
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
688
|
+
}
|
|
689
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
690
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
691
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
692
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
696
|
+
function _ts_param2(paramIndex, decorator) {
|
|
697
|
+
return function(target, key) {
|
|
698
|
+
decorator(target, key, paramIndex);
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
__name(_ts_param2, "_ts_param");
|
|
702
|
+
var ActionProposalService = class {
|
|
703
|
+
static {
|
|
704
|
+
__name(this, "ActionProposalService");
|
|
705
|
+
}
|
|
706
|
+
store;
|
|
707
|
+
options;
|
|
708
|
+
constructor(store, options) {
|
|
709
|
+
this.store = store;
|
|
710
|
+
this.options = options;
|
|
711
|
+
}
|
|
712
|
+
capability() {
|
|
713
|
+
const store = this.store;
|
|
714
|
+
if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new import_common3.NotImplementedException("Action proposals are unavailable");
|
|
715
|
+
return store;
|
|
716
|
+
}
|
|
717
|
+
async scope(threadId, actor) {
|
|
718
|
+
const scope = await this.capability().getThreadActionProposalScope(threadId);
|
|
719
|
+
if (!scope) throw new import_common3.NotFoundException("Thread not found");
|
|
720
|
+
if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new import_common3.ForbiddenException("Wrong proposal tenant");
|
|
721
|
+
return scope;
|
|
722
|
+
}
|
|
723
|
+
mayDecide(actor, proposal) {
|
|
724
|
+
return (0, import_nestjs_agent_core4.mayDecideApproval)(this.options.approvalPolicy, actor, {
|
|
725
|
+
toolCallId: proposal.originToolCallId,
|
|
726
|
+
approver: proposal.approver,
|
|
727
|
+
requesterRef: proposal.actorRef
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
async listPage(threadId, actor, query = {}) {
|
|
731
|
+
const scope = await this.scope(threadId, actor);
|
|
732
|
+
const rows = await this.capability().listActionProposals(scope, {
|
|
733
|
+
limit: 1e3,
|
|
734
|
+
...query
|
|
735
|
+
});
|
|
736
|
+
const visible = [];
|
|
737
|
+
for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
|
|
738
|
+
const last = rows.at(-1);
|
|
739
|
+
return {
|
|
740
|
+
items: visible,
|
|
741
|
+
...rows.length === 1e3 && last ? {
|
|
742
|
+
next: {
|
|
743
|
+
createdAt: last.createdAt,
|
|
744
|
+
id: last.id
|
|
745
|
+
}
|
|
746
|
+
} : {}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
async list(threadId, actor) {
|
|
750
|
+
return (await this.listPage(threadId, actor)).items;
|
|
751
|
+
}
|
|
752
|
+
async decide(threadId, proposalId, actor, command) {
|
|
753
|
+
const scope = await this.scope(threadId, actor);
|
|
754
|
+
const proposal = await this.capability().getActionProposal(scope, proposalId);
|
|
755
|
+
if (!proposal) throw new import_common3.NotFoundException("Proposal not found");
|
|
756
|
+
if (!await this.mayDecide(actor, proposal)) throw new import_common3.ForbiddenException("May not decide this proposal");
|
|
757
|
+
return this.capability().decideActionProposal(scope, proposalId, {
|
|
758
|
+
decision: command.decision,
|
|
759
|
+
actorRef: actor.id,
|
|
760
|
+
via: command.via ?? "web",
|
|
761
|
+
...command.remember !== void 0 ? {
|
|
762
|
+
remember: command.remember
|
|
763
|
+
} : {},
|
|
764
|
+
...command.reason !== void 0 ? {
|
|
765
|
+
reason: command.reason
|
|
766
|
+
} : {}
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
async handleTextDecision(threadId, actor, text) {
|
|
770
|
+
const command = (0, import_nestjs_agent_core4.parseTextActionProposalCommand)(text);
|
|
771
|
+
if (command.status === "unmatched") return command;
|
|
772
|
+
if (command.proposalId !== void 0) {
|
|
773
|
+
const result2 = await this.decide(threadId, command.proposalId, actor, {
|
|
774
|
+
decision: command.decision,
|
|
775
|
+
remember: command.remember,
|
|
776
|
+
via: "text"
|
|
777
|
+
});
|
|
778
|
+
return this.textReceipt(threadId, result2);
|
|
779
|
+
}
|
|
780
|
+
const candidates = [];
|
|
781
|
+
const scope = await this.scope(threadId, actor);
|
|
782
|
+
const pending = await this.capability().listActionProposals(scope, {
|
|
783
|
+
decision: "pending",
|
|
784
|
+
limit: 1e3
|
|
785
|
+
});
|
|
786
|
+
for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
|
|
787
|
+
const resolution = (0, import_nestjs_agent_core4.resolveTextActionProposalDecision)(text, candidates);
|
|
788
|
+
if (resolution.status === "unmatched") return resolution;
|
|
789
|
+
if (resolution.status === "ambiguous" || resolution.status === "decision" && pending.length === 1e3 && !text.includes("#")) return {
|
|
790
|
+
threadId,
|
|
791
|
+
proposalDecision: {
|
|
792
|
+
status: "ambiguous",
|
|
793
|
+
proposalIds: candidates.map(({ id }) => id)
|
|
794
|
+
},
|
|
795
|
+
text: `Choose the action to decide: ${candidates.map(({ id }) => id).map((id) => `#${id}`).join(", ")}`
|
|
796
|
+
};
|
|
797
|
+
const result = await this.decide(threadId, resolution.proposalId, actor, {
|
|
798
|
+
decision: resolution.decision,
|
|
799
|
+
remember: resolution.remember,
|
|
800
|
+
via: "text"
|
|
801
|
+
});
|
|
802
|
+
return this.textReceipt(threadId, result);
|
|
803
|
+
}
|
|
804
|
+
textReceipt(threadId, result) {
|
|
805
|
+
return {
|
|
806
|
+
threadId,
|
|
807
|
+
proposalDecision: result,
|
|
808
|
+
text: result.proposal?.decision === "approved" ? "Action approved and queued for execution." : `Action ${result.proposal?.decision ?? result.status}; no execution was performed by this decision.`
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
ActionProposalService = _ts_decorate3([
|
|
813
|
+
(0, import_common3.Injectable)(),
|
|
814
|
+
_ts_param2(0, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_STORE)),
|
|
815
|
+
_ts_param2(1, (0, import_common3.Inject)(import_nestjs_agent_core4.AGENT_OPTIONS)),
|
|
816
|
+
_ts_metadata2("design:type", Function),
|
|
817
|
+
_ts_metadata2("design:paramtypes", [
|
|
818
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
819
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
820
|
+
])
|
|
821
|
+
], ActionProposalService);
|
|
822
|
+
|
|
470
823
|
// src/queue/chat-queue.service.ts
|
|
471
|
-
var
|
|
472
|
-
var
|
|
824
|
+
var import_nestjs_agent_core5 = require("@dudousxd/nestjs-agent-core");
|
|
825
|
+
var import_common4 = require("@nestjs/common");
|
|
473
826
|
|
|
474
827
|
// src/thread-persona.ts
|
|
475
828
|
async function threadPersona(store, threadId) {
|
|
@@ -482,7 +835,7 @@ async function threadPersona(store, threadId) {
|
|
|
482
835
|
__name(threadPersona, "threadPersona");
|
|
483
836
|
|
|
484
837
|
// src/queue/chat-queue.service.ts
|
|
485
|
-
function
|
|
838
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
486
839
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
487
840
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
488
841
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -495,19 +848,19 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
495
848
|
}
|
|
496
849
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
497
850
|
}
|
|
498
|
-
__name(
|
|
499
|
-
function
|
|
851
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
852
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
500
853
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
501
854
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
502
855
|
}
|
|
503
856
|
}
|
|
504
|
-
__name(
|
|
505
|
-
function
|
|
857
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
858
|
+
function _ts_param3(paramIndex, decorator) {
|
|
506
859
|
return function(target, key) {
|
|
507
860
|
decorator(target, key, paramIndex);
|
|
508
861
|
};
|
|
509
862
|
}
|
|
510
|
-
__name(
|
|
863
|
+
__name(_ts_param3, "_ts_param");
|
|
511
864
|
var MAX_DRAIN_ATTEMPTS = 8;
|
|
512
865
|
var ChatQueueService = class _ChatQueueService {
|
|
513
866
|
static {
|
|
@@ -519,7 +872,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
519
872
|
options;
|
|
520
873
|
staging;
|
|
521
874
|
deps;
|
|
522
|
-
logger = new
|
|
875
|
+
logger = new import_common4.Logger(_ChatQueueService.name);
|
|
523
876
|
/**
|
|
524
877
|
* Runs this process claimed a thread for and has not handed to a runner yet. A holder in here is
|
|
525
878
|
* alive whatever the runner says — it simply has not registered the run yet.
|
|
@@ -535,12 +888,12 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
535
888
|
}
|
|
536
889
|
/** Whether the bound store can hold a queue. Without one, a busy thread is not queued. */
|
|
537
890
|
get supported() {
|
|
538
|
-
return (0,
|
|
891
|
+
return (0, import_nestjs_agent_core5.isChatQueueStore)(this.store);
|
|
539
892
|
}
|
|
540
893
|
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
541
894
|
queueStore() {
|
|
542
|
-
if (!(0,
|
|
543
|
-
throw new
|
|
895
|
+
if (!(0, import_nestjs_agent_core5.isChatQueueStore)(this.store)) {
|
|
896
|
+
throw new import_common4.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
544
897
|
}
|
|
545
898
|
return this.store;
|
|
546
899
|
}
|
|
@@ -551,7 +904,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
551
904
|
store.queuePause(threadId)
|
|
552
905
|
]);
|
|
553
906
|
return {
|
|
554
|
-
items: items.map(
|
|
907
|
+
items: items.map(import_nestjs_agent_core5.queuedMessageView),
|
|
555
908
|
paused
|
|
556
909
|
};
|
|
557
910
|
}
|
|
@@ -602,7 +955,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
602
955
|
* A no-op returning `{}` on a store without a queue.
|
|
603
956
|
*/
|
|
604
957
|
async plan(args) {
|
|
605
|
-
if (!(0,
|
|
958
|
+
if (!(0, import_nestjs_agent_core5.isChatQueueStore)(this.store)) {
|
|
606
959
|
return {};
|
|
607
960
|
}
|
|
608
961
|
const store = this.store;
|
|
@@ -702,7 +1055,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
702
1055
|
* (its settle drains) or while the queue is paused. Answers the started run's id, if any.
|
|
703
1056
|
*/
|
|
704
1057
|
async kick(threadId, runner) {
|
|
705
|
-
if (!(0,
|
|
1058
|
+
if (!(0, import_nestjs_agent_core5.isChatQueueStore)(this.store)) {
|
|
706
1059
|
return void 0;
|
|
707
1060
|
}
|
|
708
1061
|
const { live, stale } = await this.holder(threadId, runner);
|
|
@@ -767,6 +1120,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
767
1120
|
} : {},
|
|
768
1121
|
...input.pageContext !== void 0 ? {
|
|
769
1122
|
pageContext: input.pageContext
|
|
1123
|
+
} : {},
|
|
1124
|
+
...input.uiCapabilities !== void 0 ? {
|
|
1125
|
+
uiCapabilities: input.uiCapabilities
|
|
770
1126
|
} : {}
|
|
771
1127
|
});
|
|
772
1128
|
await store.setQueuePause(threadId, {
|
|
@@ -803,7 +1159,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
803
1159
|
}
|
|
804
1160
|
async write(runId, frame) {
|
|
805
1161
|
const writer = await this.sink.open(runId);
|
|
806
|
-
await writer.write((0,
|
|
1162
|
+
await writer.write((0, import_nestjs_agent_core5.encodeStreamEvent)(frame));
|
|
807
1163
|
}
|
|
808
1164
|
/** Why `actor` may not start a turn now (the quota message), or `null`. */
|
|
809
1165
|
async quotaBlock(actor) {
|
|
@@ -847,6 +1203,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
847
1203
|
...message.pageContext !== void 0 ? {
|
|
848
1204
|
pageContext: message.pageContext
|
|
849
1205
|
} : {},
|
|
1206
|
+
...message.uiCapabilities !== void 0 ? {
|
|
1207
|
+
uiCapabilities: message.uiCapabilities
|
|
1208
|
+
} : {},
|
|
850
1209
|
...message.model !== void 0 ? {
|
|
851
1210
|
model: message.model
|
|
852
1211
|
} : {}
|
|
@@ -900,20 +1259,20 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
900
1259
|
}));
|
|
901
1260
|
}
|
|
902
1261
|
};
|
|
903
|
-
ChatQueueService =
|
|
904
|
-
(0,
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1262
|
+
ChatQueueService = _ts_decorate4([
|
|
1263
|
+
(0, import_common4.Injectable)(),
|
|
1264
|
+
_ts_param3(0, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_STORE)),
|
|
1265
|
+
_ts_param3(1, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_SINK)),
|
|
1266
|
+
_ts_param3(2, (0, import_common4.Optional)()),
|
|
1267
|
+
_ts_param3(2, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_QUOTA_PROVIDER)),
|
|
1268
|
+
_ts_param3(3, (0, import_common4.Optional)()),
|
|
1269
|
+
_ts_param3(3, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_OPTIONS)),
|
|
1270
|
+
_ts_param3(4, (0, import_common4.Optional)()),
|
|
1271
|
+
_ts_param3(4, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_ATTACHMENT_STAGING)),
|
|
1272
|
+
_ts_param3(5, (0, import_common4.Optional)()),
|
|
1273
|
+
_ts_param3(5, (0, import_common4.Inject)(import_nestjs_agent_core5.AGENT_DEPS_FACTORY)),
|
|
1274
|
+
_ts_metadata3("design:type", Function),
|
|
1275
|
+
_ts_metadata3("design:paramtypes", [
|
|
917
1276
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
918
1277
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
919
1278
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -936,7 +1295,7 @@ function queueFrame(items, paused, started) {
|
|
|
936
1295
|
return {
|
|
937
1296
|
kind: "queue",
|
|
938
1297
|
queue: {
|
|
939
|
-
items: items.map(
|
|
1298
|
+
items: items.map(import_nestjs_agent_core5.queuedMessageView),
|
|
940
1299
|
paused
|
|
941
1300
|
},
|
|
942
1301
|
...started !== void 0 ? {
|
|
@@ -947,25 +1306,25 @@ function queueFrame(items, paused, started) {
|
|
|
947
1306
|
__name(queueFrame, "queueFrame");
|
|
948
1307
|
|
|
949
1308
|
// src/run-not-active.exception.ts
|
|
950
|
-
var
|
|
951
|
-
var
|
|
952
|
-
var RunNotActiveException = class extends
|
|
1309
|
+
var import_nestjs_agent_core6 = require("@dudousxd/nestjs-agent-core");
|
|
1310
|
+
var import_common5 = require("@nestjs/common");
|
|
1311
|
+
var RunNotActiveException = class extends import_common5.ConflictException {
|
|
953
1312
|
static {
|
|
954
1313
|
__name(this, "RunNotActiveException");
|
|
955
1314
|
}
|
|
956
1315
|
runId;
|
|
957
|
-
code =
|
|
1316
|
+
code = import_nestjs_agent_core6.RUN_NOT_ACTIVE_CODE;
|
|
958
1317
|
constructor(runId) {
|
|
959
1318
|
super({
|
|
960
1319
|
statusCode: 409,
|
|
961
|
-
code:
|
|
962
|
-
message:
|
|
1320
|
+
code: import_nestjs_agent_core6.RUN_NOT_ACTIVE_CODE,
|
|
1321
|
+
message: import_nestjs_agent_core6.RUN_NOT_ACTIVE_MESSAGE
|
|
963
1322
|
}), this.runId = runId;
|
|
964
1323
|
}
|
|
965
1324
|
};
|
|
966
1325
|
|
|
967
1326
|
// src/agent.service.ts
|
|
968
|
-
function
|
|
1327
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
969
1328
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
970
1329
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
971
1330
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -978,19 +1337,19 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
978
1337
|
}
|
|
979
1338
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
980
1339
|
}
|
|
981
|
-
__name(
|
|
982
|
-
function
|
|
1340
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1341
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
983
1342
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
984
1343
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
985
1344
|
}
|
|
986
1345
|
}
|
|
987
|
-
__name(
|
|
988
|
-
function
|
|
1346
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1347
|
+
function _ts_param4(paramIndex, decorator) {
|
|
989
1348
|
return function(target, key) {
|
|
990
1349
|
decorator(target, key, paramIndex);
|
|
991
1350
|
};
|
|
992
1351
|
}
|
|
993
|
-
__name(
|
|
1352
|
+
__name(_ts_param4, "_ts_param");
|
|
994
1353
|
var AgentService = class {
|
|
995
1354
|
static {
|
|
996
1355
|
__name(this, "AgentService");
|
|
@@ -1003,7 +1362,8 @@ var AgentService = class {
|
|
|
1003
1362
|
quotaProvider;
|
|
1004
1363
|
options;
|
|
1005
1364
|
queue;
|
|
1006
|
-
|
|
1365
|
+
proposals;
|
|
1366
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
|
|
1007
1367
|
this.runner = runner;
|
|
1008
1368
|
this.store = store;
|
|
1009
1369
|
this.deps = deps;
|
|
@@ -1012,6 +1372,13 @@ var AgentService = class {
|
|
|
1012
1372
|
this.quotaProvider = quotaProvider;
|
|
1013
1373
|
this.options = options;
|
|
1014
1374
|
this.queue = queue;
|
|
1375
|
+
this.proposals = proposals;
|
|
1376
|
+
}
|
|
1377
|
+
async handleTextDecision(threadId, actor, text) {
|
|
1378
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
1379
|
+
status: "unmatched"
|
|
1380
|
+
};
|
|
1381
|
+
return this.proposals.handleTextDecision(threadId, actor, text);
|
|
1015
1382
|
}
|
|
1016
1383
|
/** The queue service when the bound store can hold a queue, else `undefined`. */
|
|
1017
1384
|
queueing() {
|
|
@@ -1021,7 +1388,7 @@ var AgentService = class {
|
|
|
1021
1388
|
requireQueue() {
|
|
1022
1389
|
const queue = this.queueing();
|
|
1023
1390
|
if (queue === void 0) {
|
|
1024
|
-
throw new
|
|
1391
|
+
throw new import_common6.NotImplementedException("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
1025
1392
|
}
|
|
1026
1393
|
return queue;
|
|
1027
1394
|
}
|
|
@@ -1058,12 +1425,12 @@ var AgentService = class {
|
|
|
1058
1425
|
actor
|
|
1059
1426
|
});
|
|
1060
1427
|
if (blocked !== void 0) {
|
|
1061
|
-
throw new
|
|
1062
|
-
statusCode:
|
|
1428
|
+
throw new import_common6.HttpException({
|
|
1429
|
+
statusCode: import_common6.HttpStatus.TOO_MANY_REQUESTS,
|
|
1063
1430
|
code: "quota_exceeded",
|
|
1064
1431
|
period: blocked.period,
|
|
1065
1432
|
message: blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`
|
|
1066
|
-
},
|
|
1433
|
+
}, import_common6.HttpStatus.TOO_MANY_REQUESTS);
|
|
1067
1434
|
}
|
|
1068
1435
|
}
|
|
1069
1436
|
/**
|
|
@@ -1091,17 +1458,17 @@ var AgentService = class {
|
|
|
1091
1458
|
*/
|
|
1092
1459
|
async assertModelAllowed(actor, agent, model) {
|
|
1093
1460
|
if (this.models === void 0) {
|
|
1094
|
-
throw new
|
|
1461
|
+
throw new import_common6.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
1095
1462
|
}
|
|
1096
|
-
const entry = (0,
|
|
1463
|
+
const entry = (0, import_nestjs_agent_core7.findCatalogModel)(await this.models.list({
|
|
1097
1464
|
actor,
|
|
1098
1465
|
agent
|
|
1099
1466
|
}), model);
|
|
1100
1467
|
if (entry === void 0) {
|
|
1101
|
-
throw new
|
|
1468
|
+
throw new import_common6.BadRequestException(`model "${model}" is not offered`);
|
|
1102
1469
|
}
|
|
1103
1470
|
if (!entry.available) {
|
|
1104
|
-
throw new
|
|
1471
|
+
throw new import_common6.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
1105
1472
|
}
|
|
1106
1473
|
return entry.id;
|
|
1107
1474
|
}
|
|
@@ -1117,7 +1484,7 @@ var AgentService = class {
|
|
|
1117
1484
|
})).locked : void 0;
|
|
1118
1485
|
if (locked !== void 0) {
|
|
1119
1486
|
if (requested !== void 0 && requested !== locked.model) {
|
|
1120
|
-
throw new
|
|
1487
|
+
throw new import_common6.BadRequestException(`model "${requested}" cannot be selected: ${locked.reason ?? `this agent always uses "${locked.model}"`}`);
|
|
1121
1488
|
}
|
|
1122
1489
|
return locked.model;
|
|
1123
1490
|
}
|
|
@@ -1143,7 +1510,10 @@ var AgentService = class {
|
|
|
1143
1510
|
const result = await this.send({
|
|
1144
1511
|
...params,
|
|
1145
1512
|
mode: "auto"
|
|
1513
|
+
}, {
|
|
1514
|
+
textDecisions: false
|
|
1146
1515
|
});
|
|
1516
|
+
if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
|
|
1147
1517
|
if (result.queued !== true) {
|
|
1148
1518
|
return result;
|
|
1149
1519
|
}
|
|
@@ -1161,7 +1531,7 @@ var AgentService = class {
|
|
|
1161
1531
|
};
|
|
1162
1532
|
}
|
|
1163
1533
|
await this.requireQueue().publish(result.threadId);
|
|
1164
|
-
throw new
|
|
1534
|
+
throw new import_common6.ConflictException({
|
|
1165
1535
|
statusCode: 409,
|
|
1166
1536
|
code: "run_active",
|
|
1167
1537
|
message: `thread ${result.threadId} already has a turn running`
|
|
@@ -1171,7 +1541,11 @@ var AgentService = class {
|
|
|
1171
1541
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
1172
1542
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
1173
1543
|
*/
|
|
1174
|
-
async send(params) {
|
|
1544
|
+
async send(params, sendOptions = {}) {
|
|
1545
|
+
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
1546
|
+
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
1547
|
+
if ("proposalDecision" in decision) return decision;
|
|
1548
|
+
}
|
|
1175
1549
|
await this.assertWithinQuota(params.actor);
|
|
1176
1550
|
const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
|
|
1177
1551
|
const agentName = target.agentName;
|
|
@@ -1181,7 +1555,7 @@ var AgentService = class {
|
|
|
1181
1555
|
let threadId = params.threadId;
|
|
1182
1556
|
if (threadId === void 0) {
|
|
1183
1557
|
if (params.regenerate === true) {
|
|
1184
|
-
throw new
|
|
1558
|
+
throw new import_common6.BadRequestException("regenerate requires an existing threadId");
|
|
1185
1559
|
}
|
|
1186
1560
|
const created = await this.store.createThread({
|
|
1187
1561
|
actor: params.actor,
|
|
@@ -1220,12 +1594,16 @@ var AgentService = class {
|
|
|
1220
1594
|
...params.pageContext !== void 0 ? {
|
|
1221
1595
|
pageContext: params.pageContext
|
|
1222
1596
|
} : {},
|
|
1597
|
+
...params.uiCapabilities !== void 0 ? {
|
|
1598
|
+
uiCapabilities: params.uiCapabilities
|
|
1599
|
+
} : {},
|
|
1223
1600
|
...model !== void 0 ? {
|
|
1224
1601
|
model
|
|
1225
1602
|
} : {}
|
|
1226
1603
|
};
|
|
1227
1604
|
const queue = this.queueing();
|
|
1228
1605
|
if (queue === void 0) {
|
|
1606
|
+
if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
|
|
1229
1607
|
const { runId } = await this.runner.start(input);
|
|
1230
1608
|
await this.store.setActiveStream(threadId, runId);
|
|
1231
1609
|
return {
|
|
@@ -1236,7 +1614,7 @@ var AgentService = class {
|
|
|
1236
1614
|
const mode = params.mode ?? "auto";
|
|
1237
1615
|
const { live, stale } = await queue.holder(threadId, this.runner);
|
|
1238
1616
|
if (stale !== null) {
|
|
1239
|
-
await (0,
|
|
1617
|
+
await (0, import_nestjs_agent_core7.settleDeadRun)(this.store, {
|
|
1240
1618
|
runId: stale
|
|
1241
1619
|
});
|
|
1242
1620
|
}
|
|
@@ -1252,7 +1630,7 @@ var AgentService = class {
|
|
|
1252
1630
|
}
|
|
1253
1631
|
}
|
|
1254
1632
|
if (params.regenerate === true) {
|
|
1255
|
-
throw new
|
|
1633
|
+
throw new import_common6.ConflictException({
|
|
1256
1634
|
statusCode: 409,
|
|
1257
1635
|
code: "run_active",
|
|
1258
1636
|
message: "cannot regenerate while a turn is running on this thread"
|
|
@@ -1306,6 +1684,9 @@ var AgentService = class {
|
|
|
1306
1684
|
...input.pageContext !== void 0 ? {
|
|
1307
1685
|
pageContext: input.pageContext
|
|
1308
1686
|
} : {},
|
|
1687
|
+
...input.uiCapabilities !== void 0 ? {
|
|
1688
|
+
uiCapabilities: input.uiCapabilities
|
|
1689
|
+
} : {},
|
|
1309
1690
|
...interrupting !== void 0 ? {
|
|
1310
1691
|
interrupt: true,
|
|
1311
1692
|
at: "head"
|
|
@@ -1352,7 +1733,7 @@ var AgentService = class {
|
|
|
1352
1733
|
const store = queue.queueStore();
|
|
1353
1734
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1354
1735
|
if (patch.message !== void 0 && patch.message.trim().length === 0) {
|
|
1355
|
-
throw new
|
|
1736
|
+
throw new import_common6.BadRequestException("message must not be empty");
|
|
1356
1737
|
}
|
|
1357
1738
|
const attachments = patch.attachments === void 0 || patch.attachments === null ? patch.attachments : await this.resolveAttachments(actor, patch.attachments);
|
|
1358
1739
|
if (patch.message !== void 0 || attachments !== void 0) {
|
|
@@ -1365,15 +1746,15 @@ var AgentService = class {
|
|
|
1365
1746
|
} : {}
|
|
1366
1747
|
});
|
|
1367
1748
|
if (updated === null) {
|
|
1368
|
-
throw new
|
|
1749
|
+
throw new import_common6.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1369
1750
|
}
|
|
1370
1751
|
}
|
|
1371
1752
|
if (patch.position !== void 0) {
|
|
1372
1753
|
if (!Number.isInteger(patch.position) || patch.position < 0) {
|
|
1373
|
-
throw new
|
|
1754
|
+
throw new import_common6.BadRequestException("position must be a non-negative integer");
|
|
1374
1755
|
}
|
|
1375
1756
|
if (!await store.moveQueuedMessage(messageId, patch.position)) {
|
|
1376
|
-
throw new
|
|
1757
|
+
throw new import_common6.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1377
1758
|
}
|
|
1378
1759
|
}
|
|
1379
1760
|
return queue.publish(threadId);
|
|
@@ -1383,7 +1764,7 @@ var AgentService = class {
|
|
|
1383
1764
|
const queue = this.requireQueue();
|
|
1384
1765
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1385
1766
|
if (!await queue.queueStore().removeQueuedMessage(messageId)) {
|
|
1386
|
-
throw new
|
|
1767
|
+
throw new import_common6.GoneException(`queued message ${messageId} already started or was removed`);
|
|
1387
1768
|
}
|
|
1388
1769
|
return queue.publish(threadId);
|
|
1389
1770
|
}
|
|
@@ -1402,7 +1783,7 @@ var AgentService = class {
|
|
|
1402
1783
|
const queue = this.requireQueue();
|
|
1403
1784
|
const store = queue.queueStore();
|
|
1404
1785
|
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1405
|
-
const gone = /* @__PURE__ */ __name(() => new
|
|
1786
|
+
const gone = /* @__PURE__ */ __name(() => new import_common6.GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
1406
1787
|
const marked = await store.updateQueuedMessage(messageId, {
|
|
1407
1788
|
interrupt: true
|
|
1408
1789
|
});
|
|
@@ -1410,7 +1791,7 @@ var AgentService = class {
|
|
|
1410
1791
|
throw gone();
|
|
1411
1792
|
}
|
|
1412
1793
|
if (marked.interrupt !== true) {
|
|
1413
|
-
throw new
|
|
1794
|
+
throw new import_common6.NotImplementedException("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
1414
1795
|
}
|
|
1415
1796
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
1416
1797
|
throw gone();
|
|
@@ -1469,7 +1850,7 @@ var AgentService = class {
|
|
|
1469
1850
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
1470
1851
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
1471
1852
|
if (message === null) {
|
|
1472
|
-
throw new
|
|
1853
|
+
throw new import_common6.NotFoundException(`queued message ${messageId} not found`);
|
|
1473
1854
|
}
|
|
1474
1855
|
await this.assertOwnsThread(actor, message.threadId);
|
|
1475
1856
|
return message.threadId;
|
|
@@ -1490,7 +1871,7 @@ var AgentService = class {
|
|
|
1490
1871
|
}
|
|
1491
1872
|
const staging = this.staging;
|
|
1492
1873
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
1493
|
-
throw new
|
|
1874
|
+
throw new import_common6.NotImplementedException("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
1494
1875
|
}
|
|
1495
1876
|
const resolved = [];
|
|
1496
1877
|
for (const ref of refs) {
|
|
@@ -1499,7 +1880,7 @@ var AgentService = class {
|
|
|
1499
1880
|
actor
|
|
1500
1881
|
});
|
|
1501
1882
|
if (attachment === null) {
|
|
1502
|
-
throw new
|
|
1883
|
+
throw new import_common6.ForbiddenException(`attachment ${ref.mediaId} is not available to this actor`);
|
|
1503
1884
|
}
|
|
1504
1885
|
resolved.push(attachment);
|
|
1505
1886
|
}
|
|
@@ -1601,6 +1982,7 @@ var AgentService = class {
|
|
|
1601
1982
|
* not the thread's own actor).
|
|
1602
1983
|
*/
|
|
1603
1984
|
async signalToolCall(toolCallId2, reply) {
|
|
1985
|
+
if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new import_common6.ConflictException("Independent proposals require the scoped proposal decision route");
|
|
1604
1986
|
await this.assertNotExpired(toolCallId2);
|
|
1605
1987
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
1606
1988
|
await this.assertRunWaiting(runId);
|
|
@@ -1621,7 +2003,7 @@ var AgentService = class {
|
|
|
1621
2003
|
if (active) {
|
|
1622
2004
|
return;
|
|
1623
2005
|
}
|
|
1624
|
-
await (0,
|
|
2006
|
+
await (0, import_nestjs_agent_core7.settleDeadRun)(this.store, {
|
|
1625
2007
|
runId
|
|
1626
2008
|
});
|
|
1627
2009
|
throw new RunNotActiveException(runId);
|
|
@@ -1641,7 +2023,7 @@ var AgentService = class {
|
|
|
1641
2023
|
throw new RunNotActiveException(runId);
|
|
1642
2024
|
}
|
|
1643
2025
|
if (owner !== actor.id) {
|
|
1644
|
-
throw new
|
|
2026
|
+
throw new import_common6.ForbiddenException("run belongs to another actor");
|
|
1645
2027
|
}
|
|
1646
2028
|
}
|
|
1647
2029
|
/**
|
|
@@ -1701,7 +2083,7 @@ var AgentService = class {
|
|
|
1701
2083
|
return;
|
|
1702
2084
|
}
|
|
1703
2085
|
if (this.store.updateThread === void 0) {
|
|
1704
|
-
throw new
|
|
2086
|
+
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
2087
|
}
|
|
1706
2088
|
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
2089
|
if (patch.persona !== void 0 && patch.persona !== null) {
|
|
@@ -1755,10 +2137,10 @@ var AgentService = class {
|
|
|
1755
2137
|
validateTitle(title) {
|
|
1756
2138
|
const trimmed = title.trim();
|
|
1757
2139
|
if (trimmed.length === 0) {
|
|
1758
|
-
throw new
|
|
2140
|
+
throw new import_common6.BadRequestException("title must not be empty");
|
|
1759
2141
|
}
|
|
1760
2142
|
if (trimmed.length > 200) {
|
|
1761
|
-
throw new
|
|
2143
|
+
throw new import_common6.BadRequestException("title must be at most 200 characters");
|
|
1762
2144
|
}
|
|
1763
2145
|
return trimmed;
|
|
1764
2146
|
}
|
|
@@ -1862,21 +2244,21 @@ var AgentService = class {
|
|
|
1862
2244
|
*/
|
|
1863
2245
|
async setMessageFeedback(actor, messageId, input) {
|
|
1864
2246
|
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
1865
|
-
throw new
|
|
2247
|
+
throw new import_common6.BadRequestException("value must be 'up', 'down' or null");
|
|
1866
2248
|
}
|
|
1867
2249
|
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
1868
|
-
throw new
|
|
2250
|
+
throw new import_common6.BadRequestException("comment must be a string");
|
|
1869
2251
|
}
|
|
1870
2252
|
const comment = input.comment?.trim();
|
|
1871
2253
|
if (comment !== void 0 && comment.length > 2e3) {
|
|
1872
|
-
throw new
|
|
2254
|
+
throw new import_common6.BadRequestException("comment must be at most 2000 characters");
|
|
1873
2255
|
}
|
|
1874
2256
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
1875
|
-
throw new
|
|
2257
|
+
throw new import_common6.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
1876
2258
|
}
|
|
1877
2259
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
1878
2260
|
if (threadId === null) {
|
|
1879
|
-
throw new
|
|
2261
|
+
throw new import_common6.NotFoundException(`message ${messageId} not found`);
|
|
1880
2262
|
}
|
|
1881
2263
|
await this.assertOwnsThread(actor, threadId);
|
|
1882
2264
|
const feedback = input.value === null ? null : {
|
|
@@ -1924,7 +2306,7 @@ var AgentService = class {
|
|
|
1924
2306
|
const list = this.attachmentInventory();
|
|
1925
2307
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
1926
2308
|
if (referencedMediaIds === void 0) {
|
|
1927
|
-
throw new
|
|
2309
|
+
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
2310
|
}
|
|
1929
2311
|
const stagedBefore = options.olderThan.toISOString();
|
|
1930
2312
|
const inventory = await list({
|
|
@@ -1946,7 +2328,7 @@ var AgentService = class {
|
|
|
1946
2328
|
attachmentInventory() {
|
|
1947
2329
|
const list = this.staging?.list?.bind(this.staging);
|
|
1948
2330
|
if (list === void 0) {
|
|
1949
|
-
throw new
|
|
2331
|
+
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
2332
|
}
|
|
1951
2333
|
return list;
|
|
1952
2334
|
}
|
|
@@ -1957,10 +2339,10 @@ var AgentService = class {
|
|
|
1957
2339
|
async assertOwnsThread(actor, threadId) {
|
|
1958
2340
|
const owner = await this.store.ownerOfThread(threadId);
|
|
1959
2341
|
if (owner === null) {
|
|
1960
|
-
throw new
|
|
2342
|
+
throw new import_common6.NotFoundException(`thread ${threadId} not found`);
|
|
1961
2343
|
}
|
|
1962
2344
|
if (owner !== actor.id) {
|
|
1963
|
-
throw new
|
|
2345
|
+
throw new import_common6.ForbiddenException("thread belongs to another actor");
|
|
1964
2346
|
}
|
|
1965
2347
|
}
|
|
1966
2348
|
/**
|
|
@@ -1971,10 +2353,10 @@ var AgentService = class {
|
|
|
1971
2353
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
1972
2354
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
1973
2355
|
if (owner === null) {
|
|
1974
|
-
throw new
|
|
2356
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
1975
2357
|
}
|
|
1976
2358
|
if (owner !== actor.id) {
|
|
1977
|
-
throw new
|
|
2359
|
+
throw new import_common6.ForbiddenException("tool call belongs to another actor");
|
|
1978
2360
|
}
|
|
1979
2361
|
}
|
|
1980
2362
|
/**
|
|
@@ -1989,12 +2371,12 @@ var AgentService = class {
|
|
|
1989
2371
|
if (this.store.toolCallInput === void 0) {
|
|
1990
2372
|
return;
|
|
1991
2373
|
}
|
|
1992
|
-
const questions = (0,
|
|
2374
|
+
const questions = (0, import_nestjs_agent_core7.readElicitationQuestions)(await this.store.toolCallInput(toolCallId2));
|
|
1993
2375
|
for (const question of questions) {
|
|
1994
2376
|
const submitted = Object.hasOwn(answers2, question.id) ? answers2[question.id] : void 0;
|
|
1995
|
-
const problem = (0,
|
|
2377
|
+
const problem = (0, import_nestjs_agent_core7.validateElicitationAnswer)(question, submitted ?? question.defaults ?? []);
|
|
1996
2378
|
if (problem !== null) {
|
|
1997
|
-
throw new
|
|
2379
|
+
throw new import_common6.BadRequestException(`answers["${question.id}"] ${problem}`);
|
|
1998
2380
|
}
|
|
1999
2381
|
}
|
|
2000
2382
|
}
|
|
@@ -2006,21 +2388,21 @@ var AgentService = class {
|
|
|
2006
2388
|
*/
|
|
2007
2389
|
async assertMayDecide(actor, toolCallId2) {
|
|
2008
2390
|
const approval = await this.store.toolCallApproval?.(toolCallId2);
|
|
2009
|
-
const approver = approval?.approver ??
|
|
2010
|
-
if (approver ===
|
|
2391
|
+
const approver = approval?.approver ?? import_nestjs_agent_core7.REQUESTER_APPROVER;
|
|
2392
|
+
if (approver === import_nestjs_agent_core7.REQUESTER_APPROVER) {
|
|
2011
2393
|
return this.assertOwnsToolCall(actor, toolCallId2);
|
|
2012
2394
|
}
|
|
2013
2395
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
2014
2396
|
if (requesterRef === null) {
|
|
2015
|
-
throw new
|
|
2397
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId2} not found`);
|
|
2016
2398
|
}
|
|
2017
|
-
const allowed = await (0,
|
|
2399
|
+
const allowed = await (0, import_nestjs_agent_core7.mayDecideApproval)(this.deps.forAgent().approvalPolicy, actor, {
|
|
2018
2400
|
toolCallId: toolCallId2,
|
|
2019
2401
|
approver,
|
|
2020
2402
|
requesterRef
|
|
2021
2403
|
});
|
|
2022
2404
|
if (!allowed) {
|
|
2023
|
-
throw new
|
|
2405
|
+
throw new import_common6.ForbiddenException(`this approval is for ${approver}`);
|
|
2024
2406
|
}
|
|
2025
2407
|
}
|
|
2026
2408
|
/**
|
|
@@ -2036,7 +2418,7 @@ var AgentService = class {
|
|
|
2036
2418
|
}
|
|
2037
2419
|
const lapsed = approval.status === "expired" || approval.status === "pending_approval" && approval.expiresAt !== null && Date.parse(approval.expiresAt) <= Date.now();
|
|
2038
2420
|
if (lapsed) {
|
|
2039
|
-
throw new
|
|
2421
|
+
throw new import_common6.GoneException(`the approval request for tool call ${toolCallId2} has expired`);
|
|
2040
2422
|
}
|
|
2041
2423
|
}
|
|
2042
2424
|
/**
|
|
@@ -2049,7 +2431,7 @@ var AgentService = class {
|
|
|
2049
2431
|
async resolveRunForToolCall(toolCallId2) {
|
|
2050
2432
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
2051
2433
|
if (runId === null) {
|
|
2052
|
-
throw new
|
|
2434
|
+
throw new import_common6.NotFoundException(`tool call ${toolCallId2} has no active run to signal`);
|
|
2053
2435
|
}
|
|
2054
2436
|
return runId;
|
|
2055
2437
|
}
|
|
@@ -2057,29 +2439,30 @@ var AgentService = class {
|
|
|
2057
2439
|
async assertOwnsActiveStream(actor, runId) {
|
|
2058
2440
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
2059
2441
|
if (owner === null) {
|
|
2060
|
-
throw new
|
|
2442
|
+
throw new import_common6.NotFoundException(`no active run ${runId}`);
|
|
2061
2443
|
}
|
|
2062
2444
|
if (owner !== actor.id) {
|
|
2063
|
-
throw new
|
|
2445
|
+
throw new import_common6.ForbiddenException("run belongs to another actor");
|
|
2064
2446
|
}
|
|
2065
2447
|
}
|
|
2066
2448
|
};
|
|
2067
|
-
AgentService =
|
|
2068
|
-
(0,
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2449
|
+
AgentService = _ts_decorate5([
|
|
2450
|
+
(0, import_common6.Injectable)(),
|
|
2451
|
+
_ts_param4(0, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_RUNNER)),
|
|
2452
|
+
_ts_param4(1, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_STORE)),
|
|
2453
|
+
_ts_param4(2, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_DEPS_FACTORY)),
|
|
2454
|
+
_ts_param4(3, (0, import_common6.Optional)()),
|
|
2455
|
+
_ts_param4(3, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_ATTACHMENT_STAGING)),
|
|
2456
|
+
_ts_param4(4, (0, import_common6.Optional)()),
|
|
2457
|
+
_ts_param4(4, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_MODEL_CATALOG)),
|
|
2458
|
+
_ts_param4(5, (0, import_common6.Optional)()),
|
|
2459
|
+
_ts_param4(5, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_QUOTA_PROVIDER)),
|
|
2460
|
+
_ts_param4(6, (0, import_common6.Optional)()),
|
|
2461
|
+
_ts_param4(6, (0, import_common6.Inject)(import_nestjs_agent_core7.AGENT_OPTIONS)),
|
|
2462
|
+
_ts_param4(7, (0, import_common6.Optional)()),
|
|
2463
|
+
_ts_param4(8, (0, import_common6.Optional)()),
|
|
2464
|
+
_ts_metadata4("design:type", Function),
|
|
2465
|
+
_ts_metadata4("design:paramtypes", [
|
|
2083
2466
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
2084
2467
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
2085
2468
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -2087,13 +2470,14 @@ AgentService = _ts_decorate3([
|
|
|
2087
2470
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
2088
2471
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
2089
2472
|
typeof Pick === "undefined" ? Object : Pick,
|
|
2090
|
-
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
2473
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService,
|
|
2474
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
2091
2475
|
])
|
|
2092
2476
|
], AgentService);
|
|
2093
2477
|
|
|
2094
2478
|
// src/approval-port.adapter.ts
|
|
2095
|
-
var
|
|
2096
|
-
function
|
|
2479
|
+
var import_common7 = require("@nestjs/common");
|
|
2480
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
2097
2481
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2098
2482
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2099
2483
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2106,20 +2490,48 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2106
2490
|
}
|
|
2107
2491
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2108
2492
|
}
|
|
2109
|
-
__name(
|
|
2110
|
-
function
|
|
2493
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
2494
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
2111
2495
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2112
2496
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2113
2497
|
}
|
|
2114
2498
|
}
|
|
2115
|
-
__name(
|
|
2499
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
2500
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2501
|
+
return function(target, key) {
|
|
2502
|
+
decorator(target, key, paramIndex);
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
__name(_ts_param5, "_ts_param");
|
|
2116
2506
|
var AgentApprovalPortAdapter = class {
|
|
2117
2507
|
static {
|
|
2118
2508
|
__name(this, "AgentApprovalPortAdapter");
|
|
2119
2509
|
}
|
|
2120
2510
|
agent;
|
|
2121
|
-
|
|
2511
|
+
proposals;
|
|
2512
|
+
constructor(agent, proposals) {
|
|
2122
2513
|
this.agent = agent;
|
|
2514
|
+
this.proposals = proposals;
|
|
2515
|
+
}
|
|
2516
|
+
async approveActionProposal(actor, target, opts) {
|
|
2517
|
+
if (!this.proposals) throw new import_common7.NotImplementedException("Action proposals unavailable");
|
|
2518
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
2519
|
+
decision: "approved",
|
|
2520
|
+
...opts?.remember !== void 0 ? {
|
|
2521
|
+
remember: opts.remember
|
|
2522
|
+
} : {},
|
|
2523
|
+
via: opts?.decidedVia ?? "console"
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
async rejectActionProposal(actor, target, opts) {
|
|
2527
|
+
if (!this.proposals) throw new import_common7.NotImplementedException("Action proposals unavailable");
|
|
2528
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
2529
|
+
decision: "rejected",
|
|
2530
|
+
...opts?.reason !== void 0 ? {
|
|
2531
|
+
reason: opts.reason
|
|
2532
|
+
} : {},
|
|
2533
|
+
via: opts?.decidedVia ?? "console"
|
|
2534
|
+
});
|
|
2123
2535
|
}
|
|
2124
2536
|
async approve(toolCallId2, opts) {
|
|
2125
2537
|
await this.agent.signalToolCall(toolCallId2, {
|
|
@@ -2150,18 +2562,20 @@ var AgentApprovalPortAdapter = class {
|
|
|
2150
2562
|
});
|
|
2151
2563
|
}
|
|
2152
2564
|
};
|
|
2153
|
-
AgentApprovalPortAdapter =
|
|
2154
|
-
(0,
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2565
|
+
AgentApprovalPortAdapter = _ts_decorate6([
|
|
2566
|
+
(0, import_common7.Injectable)(),
|
|
2567
|
+
_ts_param5(1, (0, import_common7.Optional)()),
|
|
2568
|
+
_ts_metadata5("design:type", Function),
|
|
2569
|
+
_ts_metadata5("design:paramtypes", [
|
|
2570
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2571
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
2158
2572
|
])
|
|
2159
2573
|
], AgentApprovalPortAdapter);
|
|
2160
2574
|
|
|
2161
2575
|
// src/controller/agents.controller.ts
|
|
2162
|
-
var
|
|
2163
|
-
var
|
|
2164
|
-
function
|
|
2576
|
+
var import_nestjs_agent_core8 = require("@dudousxd/nestjs-agent-core");
|
|
2577
|
+
var import_common8 = require("@nestjs/common");
|
|
2578
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
2165
2579
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2166
2580
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2167
2581
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2174,19 +2588,19 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
2174
2588
|
}
|
|
2175
2589
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2176
2590
|
}
|
|
2177
|
-
__name(
|
|
2178
|
-
function
|
|
2591
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
2592
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
2179
2593
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2180
2594
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2181
2595
|
}
|
|
2182
2596
|
}
|
|
2183
|
-
__name(
|
|
2184
|
-
function
|
|
2597
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
2598
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2185
2599
|
return function(target, key) {
|
|
2186
2600
|
decorator(target, key, paramIndex);
|
|
2187
2601
|
};
|
|
2188
2602
|
}
|
|
2189
|
-
__name(
|
|
2603
|
+
__name(_ts_param6, "_ts_param");
|
|
2190
2604
|
var AgentsController = class {
|
|
2191
2605
|
static {
|
|
2192
2606
|
__name(this, "AgentsController");
|
|
@@ -2217,26 +2631,26 @@ var AgentsController = class {
|
|
|
2217
2631
|
});
|
|
2218
2632
|
}
|
|
2219
2633
|
};
|
|
2220
|
-
|
|
2221
|
-
(0,
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2634
|
+
_ts_decorate7([
|
|
2635
|
+
(0, import_common8.Get)(),
|
|
2636
|
+
_ts_metadata6("design:type", Function),
|
|
2637
|
+
_ts_metadata6("design:paramtypes", []),
|
|
2638
|
+
_ts_metadata6("design:returntype", Array)
|
|
2225
2639
|
], AgentsController.prototype, "list", null);
|
|
2226
|
-
AgentsController =
|
|
2227
|
-
(0,
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
typeof
|
|
2640
|
+
AgentsController = _ts_decorate7([
|
|
2641
|
+
(0, import_common8.Controller)("agents"),
|
|
2642
|
+
_ts_param6(0, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_REGISTRY)),
|
|
2643
|
+
_ts_param6(1, (0, import_common8.Inject)(import_nestjs_agent_core8.AGENT_DEPS_FACTORY)),
|
|
2644
|
+
_ts_metadata6("design:type", Function),
|
|
2645
|
+
_ts_metadata6("design:paramtypes", [
|
|
2646
|
+
typeof import_nestjs_agent_core8.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core8.AgentRegistry,
|
|
2233
2647
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
2234
2648
|
])
|
|
2235
2649
|
], AgentsController);
|
|
2236
2650
|
|
|
2237
2651
|
// src/controller/attachments.controller.ts
|
|
2238
|
-
var
|
|
2239
|
-
var
|
|
2652
|
+
var import_nestjs_agent_core9 = require("@dudousxd/nestjs-agent-core");
|
|
2653
|
+
var import_common9 = require("@nestjs/common");
|
|
2240
2654
|
var import_platform_express = require("@nestjs/platform-express");
|
|
2241
2655
|
|
|
2242
2656
|
// src/attachment-limits.ts
|
|
@@ -2265,7 +2679,7 @@ function attachmentLimits(options, staging) {
|
|
|
2265
2679
|
__name(attachmentLimits, "attachmentLimits");
|
|
2266
2680
|
|
|
2267
2681
|
// src/controller/attachments.controller.ts
|
|
2268
|
-
function
|
|
2682
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2269
2683
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2270
2684
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2271
2685
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2278,19 +2692,19 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
2278
2692
|
}
|
|
2279
2693
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2280
2694
|
}
|
|
2281
|
-
__name(
|
|
2282
|
-
function
|
|
2695
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2696
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
2283
2697
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2284
2698
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2285
2699
|
}
|
|
2286
2700
|
}
|
|
2287
|
-
__name(
|
|
2288
|
-
function
|
|
2701
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2702
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2289
2703
|
return function(target, key) {
|
|
2290
2704
|
decorator(target, key, paramIndex);
|
|
2291
2705
|
};
|
|
2292
2706
|
}
|
|
2293
|
-
__name(
|
|
2707
|
+
__name(_ts_param7, "_ts_param");
|
|
2294
2708
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
2295
2709
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
2296
2710
|
var AttachmentsController = class {
|
|
@@ -2324,17 +2738,17 @@ var AttachmentsController = class {
|
|
|
2324
2738
|
}
|
|
2325
2739
|
async upload(req, file) {
|
|
2326
2740
|
if (this.staging === void 0) {
|
|
2327
|
-
throw new
|
|
2741
|
+
throw new import_common9.NotImplementedException("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
2328
2742
|
}
|
|
2329
2743
|
if (file === void 0) {
|
|
2330
|
-
throw new
|
|
2744
|
+
throw new import_common9.BadRequestException('multipart field "file" is required');
|
|
2331
2745
|
}
|
|
2332
2746
|
const { allowedContentTypes, maxBytes } = attachmentLimits(this.options, this.staging);
|
|
2333
2747
|
if (!allowedContentTypes.includes(file.mimetype)) {
|
|
2334
|
-
throw new
|
|
2748
|
+
throw new import_common9.UnsupportedMediaTypeException(`content type "${file.mimetype}" is not allowed (allowed: ${allowedContentTypes.join(", ")})`);
|
|
2335
2749
|
}
|
|
2336
2750
|
if (file.size > maxBytes) {
|
|
2337
|
-
throw new
|
|
2751
|
+
throw new import_common9.PayloadTooLargeException(`file exceeds the ${maxBytes}-byte limit`);
|
|
2338
2752
|
}
|
|
2339
2753
|
const actor = await this.actorResolver.resolve(req);
|
|
2340
2754
|
return this.staging.stage({
|
|
@@ -2346,39 +2760,39 @@ var AttachmentsController = class {
|
|
|
2346
2760
|
});
|
|
2347
2761
|
}
|
|
2348
2762
|
};
|
|
2349
|
-
|
|
2350
|
-
(0,
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2763
|
+
_ts_decorate8([
|
|
2764
|
+
(0, import_common9.Get)(),
|
|
2765
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
2766
|
+
_ts_metadata7("design:type", Function),
|
|
2767
|
+
_ts_metadata7("design:paramtypes", [
|
|
2354
2768
|
typeof Request === "undefined" ? Object : Request
|
|
2355
2769
|
]),
|
|
2356
|
-
|
|
2770
|
+
_ts_metadata7("design:returntype", Promise)
|
|
2357
2771
|
], AttachmentsController.prototype, "list", null);
|
|
2358
|
-
|
|
2359
|
-
(0,
|
|
2360
|
-
(0,
|
|
2772
|
+
_ts_decorate8([
|
|
2773
|
+
(0, import_common9.Post)(),
|
|
2774
|
+
(0, import_common9.UseInterceptors)((0, import_platform_express.FileInterceptor)("file", {
|
|
2361
2775
|
limits: {
|
|
2362
2776
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
2363
2777
|
}
|
|
2364
2778
|
})),
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2779
|
+
_ts_param7(0, (0, import_common9.Req)()),
|
|
2780
|
+
_ts_param7(1, (0, import_common9.UploadedFile)()),
|
|
2781
|
+
_ts_metadata7("design:type", Function),
|
|
2782
|
+
_ts_metadata7("design:paramtypes", [
|
|
2369
2783
|
typeof Request === "undefined" ? Object : Request,
|
|
2370
2784
|
Object
|
|
2371
2785
|
]),
|
|
2372
|
-
|
|
2786
|
+
_ts_metadata7("design:returntype", Promise)
|
|
2373
2787
|
], AttachmentsController.prototype, "upload", null);
|
|
2374
|
-
AttachmentsController =
|
|
2375
|
-
(0,
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2788
|
+
AttachmentsController = _ts_decorate8([
|
|
2789
|
+
(0, import_common9.Controller)("attachments"),
|
|
2790
|
+
_ts_param7(0, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_OPTIONS)),
|
|
2791
|
+
_ts_param7(1, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ACTOR_RESOLVER)),
|
|
2792
|
+
_ts_param7(3, (0, import_common9.Optional)()),
|
|
2793
|
+
_ts_param7(3, (0, import_common9.Inject)(import_nestjs_agent_core9.AGENT_ATTACHMENT_STAGING)),
|
|
2794
|
+
_ts_metadata7("design:type", Function),
|
|
2795
|
+
_ts_metadata7("design:paramtypes", [
|
|
2382
2796
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2383
2797
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2384
2798
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2387,9 +2801,10 @@ AttachmentsController = _ts_decorate6([
|
|
|
2387
2801
|
], AttachmentsController);
|
|
2388
2802
|
|
|
2389
2803
|
// src/controller/chat.controller.ts
|
|
2390
|
-
var
|
|
2391
|
-
var
|
|
2392
|
-
|
|
2804
|
+
var import_nestjs_agent_core10 = require("@dudousxd/nestjs-agent-core");
|
|
2805
|
+
var import_genui2 = require("@dudousxd/nestjs-agent-core/genui");
|
|
2806
|
+
var import_common10 = require("@nestjs/common");
|
|
2807
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2393
2808
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2394
2809
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2395
2810
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2402,19 +2817,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
2402
2817
|
}
|
|
2403
2818
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2404
2819
|
}
|
|
2405
|
-
__name(
|
|
2406
|
-
function
|
|
2820
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2821
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
2407
2822
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2408
2823
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2409
2824
|
}
|
|
2410
2825
|
}
|
|
2411
|
-
__name(
|
|
2412
|
-
function
|
|
2826
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2827
|
+
function _ts_param8(paramIndex, decorator) {
|
|
2413
2828
|
return function(target, key) {
|
|
2414
2829
|
decorator(target, key, paramIndex);
|
|
2415
2830
|
};
|
|
2416
2831
|
}
|
|
2417
|
-
__name(
|
|
2832
|
+
__name(_ts_param8, "_ts_param");
|
|
2418
2833
|
function sendMode(body) {
|
|
2419
2834
|
if (body.interrupt === true) {
|
|
2420
2835
|
return "interrupt";
|
|
@@ -2425,7 +2840,7 @@ function sendMode(body) {
|
|
|
2425
2840
|
if (body.mode === "auto" || body.mode === "queue" || body.mode === "interrupt") {
|
|
2426
2841
|
return body.mode;
|
|
2427
2842
|
}
|
|
2428
|
-
throw new
|
|
2843
|
+
throw new import_common10.BadRequestException("mode must be 'auto', 'queue' or 'interrupt'");
|
|
2429
2844
|
}
|
|
2430
2845
|
__name(sendMode, "sendMode");
|
|
2431
2846
|
function attachmentRefs(claimed) {
|
|
@@ -2433,21 +2848,21 @@ function attachmentRefs(claimed) {
|
|
|
2433
2848
|
return [];
|
|
2434
2849
|
}
|
|
2435
2850
|
if (!Array.isArray(claimed)) {
|
|
2436
|
-
throw new
|
|
2851
|
+
throw new import_common10.BadRequestException("attachments must be an array of { mediaId }");
|
|
2437
2852
|
}
|
|
2438
2853
|
if (claimed.length > MAX_ATTACHMENTS_PER_MESSAGE) {
|
|
2439
|
-
throw new
|
|
2854
|
+
throw new import_common10.BadRequestException(`a message may carry at most ${MAX_ATTACHMENTS_PER_MESSAGE} attachments`);
|
|
2440
2855
|
}
|
|
2441
2856
|
return claimed.map((entry) => {
|
|
2442
2857
|
if (typeof entry !== "object" || entry === null || !("mediaId" in entry)) {
|
|
2443
|
-
throw new
|
|
2858
|
+
throw new import_common10.BadRequestException("each attachment must be an object with a mediaId");
|
|
2444
2859
|
}
|
|
2445
2860
|
if (Object.keys(entry).some((key) => key !== "mediaId")) {
|
|
2446
|
-
throw new
|
|
2861
|
+
throw new import_common10.BadRequestException("attachments are { mediaId } refs \u2014 send nothing but the id");
|
|
2447
2862
|
}
|
|
2448
2863
|
const { mediaId } = entry;
|
|
2449
2864
|
if (typeof mediaId !== "string" || mediaId.length === 0) {
|
|
2450
|
-
throw new
|
|
2865
|
+
throw new import_common10.BadRequestException("each attachment must carry a non-empty string mediaId");
|
|
2451
2866
|
}
|
|
2452
2867
|
return {
|
|
2453
2868
|
mediaId
|
|
@@ -2475,9 +2890,18 @@ var ChatController = class {
|
|
|
2475
2890
|
const actor = await this.actorResolver.resolve(req);
|
|
2476
2891
|
const attachments = attachmentRefs(body.attachments);
|
|
2477
2892
|
const mode = sendMode(body);
|
|
2893
|
+
let uiCapabilities;
|
|
2894
|
+
try {
|
|
2895
|
+
uiCapabilities = body.uiCapabilities === void 0 ? void 0 : (0, import_genui2.validateUiCapabilities)(body.uiCapabilities);
|
|
2896
|
+
} catch {
|
|
2897
|
+
throw new import_common10.BadRequestException("Invalid UI capabilities");
|
|
2898
|
+
}
|
|
2478
2899
|
const result = await this.agent.send({
|
|
2479
2900
|
actor,
|
|
2480
2901
|
message: body.message,
|
|
2902
|
+
...uiCapabilities !== void 0 ? {
|
|
2903
|
+
uiCapabilities
|
|
2904
|
+
} : {},
|
|
2481
2905
|
...body.threadId !== void 0 ? {
|
|
2482
2906
|
threadId: body.threadId
|
|
2483
2907
|
} : {},
|
|
@@ -2504,6 +2928,10 @@ var ChatController = class {
|
|
|
2504
2928
|
} : {},
|
|
2505
2929
|
mode
|
|
2506
2930
|
});
|
|
2931
|
+
if ("proposalDecision" in result) {
|
|
2932
|
+
res.status(200).json(result);
|
|
2933
|
+
return;
|
|
2934
|
+
}
|
|
2507
2935
|
if (result.queued === true) {
|
|
2508
2936
|
res.status(202).json(result);
|
|
2509
2937
|
return;
|
|
@@ -2583,10 +3011,10 @@ data: ${line}
|
|
|
2583
3011
|
}
|
|
2584
3012
|
res.write("event: done\ndata: {}\n\n");
|
|
2585
3013
|
} catch (error) {
|
|
2586
|
-
const payload = error instanceof
|
|
3014
|
+
const payload = error instanceof import_nestjs_agent_core10.AgentStreamError ? {
|
|
2587
3015
|
code: error.code,
|
|
2588
3016
|
message: error.message
|
|
2589
|
-
} : (0,
|
|
3017
|
+
} : (0, import_nestjs_agent_core10.streamFailure)(error);
|
|
2590
3018
|
res.write(`event: error
|
|
2591
3019
|
data: ${JSON.stringify(payload)}
|
|
2592
3020
|
|
|
@@ -2595,50 +3023,50 @@ data: ${JSON.stringify(payload)}
|
|
|
2595
3023
|
res.end();
|
|
2596
3024
|
}
|
|
2597
3025
|
};
|
|
2598
|
-
|
|
2599
|
-
(0,
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3026
|
+
_ts_decorate9([
|
|
3027
|
+
(0, import_common10.Post)("chat"),
|
|
3028
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
3029
|
+
_ts_param8(1, (0, import_common10.Res)()),
|
|
3030
|
+
_ts_param8(2, (0, import_common10.Body)()),
|
|
3031
|
+
_ts_metadata8("design:type", Function),
|
|
3032
|
+
_ts_metadata8("design:paramtypes", [
|
|
2605
3033
|
typeof Request === "undefined" ? Object : Request,
|
|
2606
3034
|
typeof Response === "undefined" ? Object : Response,
|
|
2607
3035
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
2608
3036
|
]),
|
|
2609
|
-
|
|
3037
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2610
3038
|
], ChatController.prototype, "chat", null);
|
|
2611
|
-
|
|
2612
|
-
(0,
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
3039
|
+
_ts_decorate9([
|
|
3040
|
+
(0, import_common10.Get)("chat/:runId/stream"),
|
|
3041
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
3042
|
+
_ts_param8(1, (0, import_common10.Param)("runId")),
|
|
3043
|
+
_ts_param8(2, (0, import_common10.Res)()),
|
|
3044
|
+
_ts_param8(3, (0, import_common10.Query)("after")),
|
|
3045
|
+
_ts_metadata8("design:type", Function),
|
|
3046
|
+
_ts_metadata8("design:paramtypes", [
|
|
2619
3047
|
typeof Request === "undefined" ? Object : Request,
|
|
2620
3048
|
String,
|
|
2621
3049
|
typeof Response === "undefined" ? Object : Response,
|
|
2622
3050
|
String
|
|
2623
3051
|
]),
|
|
2624
|
-
|
|
3052
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2625
3053
|
], ChatController.prototype, "stream", null);
|
|
2626
|
-
|
|
2627
|
-
(0,
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
3054
|
+
_ts_decorate9([
|
|
3055
|
+
(0, import_common10.Post)("chat/:runId/cancel"),
|
|
3056
|
+
_ts_param8(0, (0, import_common10.Req)()),
|
|
3057
|
+
_ts_param8(1, (0, import_common10.Param)("runId")),
|
|
3058
|
+
_ts_metadata8("design:type", Function),
|
|
3059
|
+
_ts_metadata8("design:paramtypes", [
|
|
2632
3060
|
typeof Request === "undefined" ? Object : Request,
|
|
2633
3061
|
String
|
|
2634
3062
|
]),
|
|
2635
|
-
|
|
3063
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2636
3064
|
], ChatController.prototype, "cancel", null);
|
|
2637
|
-
ChatController =
|
|
2638
|
-
(0,
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
3065
|
+
ChatController = _ts_decorate9([
|
|
3066
|
+
(0, import_common10.Controller)(),
|
|
3067
|
+
_ts_param8(1, (0, import_common10.Inject)(import_nestjs_agent_core10.AGENT_ACTOR_RESOLVER)),
|
|
3068
|
+
_ts_metadata8("design:type", Function),
|
|
3069
|
+
_ts_metadata8("design:paramtypes", [
|
|
2642
3070
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2643
3071
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2644
3072
|
])
|
|
@@ -2654,8 +3082,8 @@ function parseCursor(raw) {
|
|
|
2654
3082
|
__name(parseCursor, "parseCursor");
|
|
2655
3083
|
|
|
2656
3084
|
// src/controller/config.controller.ts
|
|
2657
|
-
var
|
|
2658
|
-
var
|
|
3085
|
+
var import_nestjs_agent_core11 = require("@dudousxd/nestjs-agent-core");
|
|
3086
|
+
var import_common11 = require("@nestjs/common");
|
|
2659
3087
|
|
|
2660
3088
|
// src/resolver/anonymous-actor-resolver.ts
|
|
2661
3089
|
var import_node_crypto = require("crypto");
|
|
@@ -2745,7 +3173,7 @@ var AnonymousActorResolver = class {
|
|
|
2745
3173
|
};
|
|
2746
3174
|
|
|
2747
3175
|
// src/controller/config.controller.ts
|
|
2748
|
-
function
|
|
3176
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2749
3177
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2750
3178
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2751
3179
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2758,19 +3186,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2758
3186
|
}
|
|
2759
3187
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2760
3188
|
}
|
|
2761
|
-
__name(
|
|
2762
|
-
function
|
|
3189
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
3190
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
2763
3191
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2764
3192
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2765
3193
|
}
|
|
2766
3194
|
}
|
|
2767
|
-
__name(
|
|
2768
|
-
function
|
|
3195
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
3196
|
+
function _ts_param9(paramIndex, decorator) {
|
|
2769
3197
|
return function(target, key) {
|
|
2770
3198
|
decorator(target, key, paramIndex);
|
|
2771
3199
|
};
|
|
2772
3200
|
}
|
|
2773
|
-
__name(
|
|
3201
|
+
__name(_ts_param9, "_ts_param");
|
|
2774
3202
|
var ConfigController = class {
|
|
2775
3203
|
static {
|
|
2776
3204
|
__name(this, "ConfigController");
|
|
@@ -2801,25 +3229,25 @@ var ConfigController = class {
|
|
|
2801
3229
|
};
|
|
2802
3230
|
}
|
|
2803
3231
|
};
|
|
2804
|
-
|
|
2805
|
-
(0,
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
3232
|
+
_ts_decorate10([
|
|
3233
|
+
(0, import_common11.Get)(),
|
|
3234
|
+
_ts_param9(0, (0, import_common11.Req)()),
|
|
3235
|
+
_ts_metadata9("design:type", Function),
|
|
3236
|
+
_ts_metadata9("design:paramtypes", [
|
|
2809
3237
|
typeof Request === "undefined" ? Object : Request
|
|
2810
3238
|
]),
|
|
2811
|
-
|
|
3239
|
+
_ts_metadata9("design:returntype", Promise)
|
|
2812
3240
|
], ConfigController.prototype, "config", null);
|
|
2813
|
-
ConfigController =
|
|
2814
|
-
(0,
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
3241
|
+
ConfigController = _ts_decorate10([
|
|
3242
|
+
(0, import_common11.Controller)("config"),
|
|
3243
|
+
_ts_param9(0, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_OPTIONS)),
|
|
3244
|
+
_ts_param9(1, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ACTOR_RESOLVER)),
|
|
3245
|
+
_ts_param9(2, (0, import_common11.Optional)()),
|
|
3246
|
+
_ts_param9(2, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_ATTACHMENT_STAGING)),
|
|
3247
|
+
_ts_param9(3, (0, import_common11.Optional)()),
|
|
3248
|
+
_ts_param9(3, (0, import_common11.Inject)(import_nestjs_agent_core11.AGENT_MODEL_CATALOG)),
|
|
3249
|
+
_ts_metadata9("design:type", Function),
|
|
3250
|
+
_ts_metadata9("design:paramtypes", [
|
|
2823
3251
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2824
3252
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2825
3253
|
Object,
|
|
@@ -2828,9 +3256,9 @@ ConfigController = _ts_decorate8([
|
|
|
2828
3256
|
], ConfigController);
|
|
2829
3257
|
|
|
2830
3258
|
// src/controller/memories.controller.ts
|
|
2831
|
-
var
|
|
2832
|
-
var
|
|
2833
|
-
function
|
|
3259
|
+
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
3260
|
+
var import_common12 = require("@nestjs/common");
|
|
3261
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2834
3262
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2835
3263
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2836
3264
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2843,19 +3271,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
2843
3271
|
}
|
|
2844
3272
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2845
3273
|
}
|
|
2846
|
-
__name(
|
|
2847
|
-
function
|
|
3274
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
3275
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
2848
3276
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2849
3277
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2850
3278
|
}
|
|
2851
3279
|
}
|
|
2852
|
-
__name(
|
|
2853
|
-
function
|
|
3280
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
3281
|
+
function _ts_param10(paramIndex, decorator) {
|
|
2854
3282
|
return function(target, key) {
|
|
2855
3283
|
decorator(target, key, paramIndex);
|
|
2856
3284
|
};
|
|
2857
3285
|
}
|
|
2858
|
-
__name(
|
|
3286
|
+
__name(_ts_param10, "_ts_param");
|
|
2859
3287
|
var MemoriesController = class {
|
|
2860
3288
|
static {
|
|
2861
3289
|
__name(this, "MemoriesController");
|
|
@@ -2889,20 +3317,20 @@ var MemoriesController = class {
|
|
|
2889
3317
|
*/
|
|
2890
3318
|
async forget(req, id) {
|
|
2891
3319
|
if (this.memory === void 0) {
|
|
2892
|
-
throw new
|
|
3320
|
+
throw new import_common12.NotFoundException("No memory is configured in this deployment.");
|
|
2893
3321
|
}
|
|
2894
3322
|
const actor = await this.actorResolver.resolve(req);
|
|
2895
3323
|
const digest = await this.unbounded("", actor);
|
|
2896
3324
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
2897
3325
|
if (entry === void 0) {
|
|
2898
|
-
throw new
|
|
3326
|
+
throw new import_common12.NotFoundException(`No memory with id "${id}".`);
|
|
2899
3327
|
}
|
|
2900
|
-
const verdict = (0,
|
|
3328
|
+
const verdict = (0, import_nestjs_agent_core12.memoryForgetVerdict)({
|
|
2901
3329
|
record: entry,
|
|
2902
3330
|
actor
|
|
2903
3331
|
});
|
|
2904
3332
|
if (!verdict.allowed) {
|
|
2905
|
-
throw new
|
|
3333
|
+
throw new import_common12.ForbiddenException(verdict.reason);
|
|
2906
3334
|
}
|
|
2907
3335
|
return {
|
|
2908
3336
|
forgotten: await this.memory.provider.forget({
|
|
@@ -2916,7 +3344,7 @@ var MemoriesController = class {
|
|
|
2916
3344
|
}
|
|
2917
3345
|
async unbounded(threadId, actor) {
|
|
2918
3346
|
const config = this.memory;
|
|
2919
|
-
return await (0,
|
|
3347
|
+
return await (0, import_nestjs_agent_core12.offerMemories)({
|
|
2920
3348
|
config: {
|
|
2921
3349
|
...config,
|
|
2922
3350
|
maxMemories: Number.POSITIVE_INFINITY
|
|
@@ -2928,44 +3356,44 @@ var MemoriesController = class {
|
|
|
2928
3356
|
});
|
|
2929
3357
|
}
|
|
2930
3358
|
};
|
|
2931
|
-
|
|
2932
|
-
(0,
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
3359
|
+
_ts_decorate11([
|
|
3360
|
+
(0, import_common12.Get)(),
|
|
3361
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
3362
|
+
_ts_param10(1, (0, import_common12.Query)("threadId")),
|
|
3363
|
+
_ts_metadata10("design:type", Function),
|
|
3364
|
+
_ts_metadata10("design:paramtypes", [
|
|
2937
3365
|
typeof Request === "undefined" ? Object : Request,
|
|
2938
3366
|
String
|
|
2939
3367
|
]),
|
|
2940
|
-
|
|
3368
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2941
3369
|
], MemoriesController.prototype, "list", null);
|
|
2942
|
-
|
|
2943
|
-
(0,
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3370
|
+
_ts_decorate11([
|
|
3371
|
+
(0, import_common12.Delete)(":id"),
|
|
3372
|
+
_ts_param10(0, (0, import_common12.Req)()),
|
|
3373
|
+
_ts_param10(1, (0, import_common12.Param)("id")),
|
|
3374
|
+
_ts_metadata10("design:type", Function),
|
|
3375
|
+
_ts_metadata10("design:paramtypes", [
|
|
2948
3376
|
typeof Request === "undefined" ? Object : Request,
|
|
2949
3377
|
String
|
|
2950
3378
|
]),
|
|
2951
|
-
|
|
3379
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2952
3380
|
], MemoriesController.prototype, "forget", null);
|
|
2953
|
-
MemoriesController =
|
|
2954
|
-
(0,
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
3381
|
+
MemoriesController = _ts_decorate11([
|
|
3382
|
+
(0, import_common12.Controller)("memories"),
|
|
3383
|
+
_ts_param10(0, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
3384
|
+
_ts_param10(1, (0, import_common12.Optional)()),
|
|
3385
|
+
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_MEMORY)),
|
|
3386
|
+
_ts_metadata10("design:type", Function),
|
|
3387
|
+
_ts_metadata10("design:paramtypes", [
|
|
2960
3388
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2961
3389
|
Object
|
|
2962
3390
|
])
|
|
2963
3391
|
], MemoriesController);
|
|
2964
3392
|
|
|
2965
3393
|
// src/controller/messages.controller.ts
|
|
2966
|
-
var
|
|
2967
|
-
var
|
|
2968
|
-
function
|
|
3394
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
3395
|
+
var import_common13 = require("@nestjs/common");
|
|
3396
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2969
3397
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2970
3398
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2971
3399
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2978,19 +3406,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
2978
3406
|
}
|
|
2979
3407
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2980
3408
|
}
|
|
2981
|
-
__name(
|
|
2982
|
-
function
|
|
3409
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3410
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2983
3411
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2984
3412
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2985
3413
|
}
|
|
2986
3414
|
}
|
|
2987
|
-
__name(
|
|
2988
|
-
function
|
|
3415
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
3416
|
+
function _ts_param11(paramIndex, decorator) {
|
|
2989
3417
|
return function(target, key) {
|
|
2990
3418
|
decorator(target, key, paramIndex);
|
|
2991
3419
|
};
|
|
2992
3420
|
}
|
|
2993
|
-
__name(
|
|
3421
|
+
__name(_ts_param11, "_ts_param");
|
|
2994
3422
|
var MessagesController = class {
|
|
2995
3423
|
static {
|
|
2996
3424
|
__name(this, "MessagesController");
|
|
@@ -3018,34 +3446,34 @@ var MessagesController = class {
|
|
|
3018
3446
|
};
|
|
3019
3447
|
}
|
|
3020
3448
|
};
|
|
3021
|
-
|
|
3022
|
-
(0,
|
|
3023
|
-
(0,
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3449
|
+
_ts_decorate12([
|
|
3450
|
+
(0, import_common13.Post)(":id/feedback"),
|
|
3451
|
+
(0, import_common13.HttpCode)(200),
|
|
3452
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
3453
|
+
_ts_param11(1, (0, import_common13.Param)("id")),
|
|
3454
|
+
_ts_param11(2, (0, import_common13.Body)()),
|
|
3455
|
+
_ts_metadata11("design:type", Function),
|
|
3456
|
+
_ts_metadata11("design:paramtypes", [
|
|
3029
3457
|
typeof Request === "undefined" ? Object : Request,
|
|
3030
3458
|
String,
|
|
3031
3459
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
3032
3460
|
]),
|
|
3033
|
-
|
|
3461
|
+
_ts_metadata11("design:returntype", Promise)
|
|
3034
3462
|
], MessagesController.prototype, "feedback", null);
|
|
3035
|
-
MessagesController =
|
|
3036
|
-
(0,
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3463
|
+
MessagesController = _ts_decorate12([
|
|
3464
|
+
(0, import_common13.Controller)("messages"),
|
|
3465
|
+
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
3466
|
+
_ts_metadata11("design:type", Function),
|
|
3467
|
+
_ts_metadata11("design:paramtypes", [
|
|
3040
3468
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3041
3469
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3042
3470
|
])
|
|
3043
3471
|
], MessagesController);
|
|
3044
3472
|
|
|
3045
3473
|
// src/controller/models.controller.ts
|
|
3046
|
-
var
|
|
3047
|
-
var
|
|
3048
|
-
function
|
|
3474
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
3475
|
+
var import_common14 = require("@nestjs/common");
|
|
3476
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
3049
3477
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3050
3478
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3051
3479
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3058,19 +3486,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
3058
3486
|
}
|
|
3059
3487
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3060
3488
|
}
|
|
3061
|
-
__name(
|
|
3062
|
-
function
|
|
3489
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3490
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
3063
3491
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3064
3492
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3065
3493
|
}
|
|
3066
3494
|
}
|
|
3067
|
-
__name(
|
|
3068
|
-
function
|
|
3495
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3496
|
+
function _ts_param12(paramIndex, decorator) {
|
|
3069
3497
|
return function(target, key) {
|
|
3070
3498
|
decorator(target, key, paramIndex);
|
|
3071
3499
|
};
|
|
3072
3500
|
}
|
|
3073
|
-
__name(
|
|
3501
|
+
__name(_ts_param12, "_ts_param");
|
|
3074
3502
|
var ModelsController = class {
|
|
3075
3503
|
static {
|
|
3076
3504
|
__name(this, "ModelsController");
|
|
@@ -3090,31 +3518,31 @@ var ModelsController = class {
|
|
|
3090
3518
|
return this.agent.listModels(actor, agent);
|
|
3091
3519
|
}
|
|
3092
3520
|
};
|
|
3093
|
-
|
|
3094
|
-
(0,
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3521
|
+
_ts_decorate13([
|
|
3522
|
+
(0, import_common14.Get)(),
|
|
3523
|
+
_ts_param12(0, (0, import_common14.Req)()),
|
|
3524
|
+
_ts_param12(1, (0, import_common14.Query)("agent")),
|
|
3525
|
+
_ts_metadata12("design:type", Function),
|
|
3526
|
+
_ts_metadata12("design:paramtypes", [
|
|
3099
3527
|
typeof Request === "undefined" ? Object : Request,
|
|
3100
3528
|
String
|
|
3101
3529
|
]),
|
|
3102
|
-
|
|
3530
|
+
_ts_metadata12("design:returntype", Promise)
|
|
3103
3531
|
], ModelsController.prototype, "list", null);
|
|
3104
|
-
ModelsController =
|
|
3105
|
-
(0,
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3532
|
+
ModelsController = _ts_decorate13([
|
|
3533
|
+
(0, import_common14.Controller)("models"),
|
|
3534
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
3535
|
+
_ts_metadata12("design:type", Function),
|
|
3536
|
+
_ts_metadata12("design:paramtypes", [
|
|
3109
3537
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3110
3538
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3111
3539
|
])
|
|
3112
3540
|
], ModelsController);
|
|
3113
3541
|
|
|
3114
3542
|
// src/controller/queue.controller.ts
|
|
3115
|
-
var
|
|
3116
|
-
var
|
|
3117
|
-
function
|
|
3543
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
3544
|
+
var import_common15 = require("@nestjs/common");
|
|
3545
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
3118
3546
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3119
3547
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3120
3548
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3127,19 +3555,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3127
3555
|
}
|
|
3128
3556
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3129
3557
|
}
|
|
3130
|
-
__name(
|
|
3131
|
-
function
|
|
3558
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
3559
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3132
3560
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3133
3561
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3134
3562
|
}
|
|
3135
3563
|
}
|
|
3136
|
-
__name(
|
|
3137
|
-
function
|
|
3564
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3565
|
+
function _ts_param13(paramIndex, decorator) {
|
|
3138
3566
|
return function(target, key) {
|
|
3139
3567
|
decorator(target, key, paramIndex);
|
|
3140
3568
|
};
|
|
3141
3569
|
}
|
|
3142
|
-
__name(
|
|
3570
|
+
__name(_ts_param13, "_ts_param");
|
|
3143
3571
|
var QueueController = class {
|
|
3144
3572
|
static {
|
|
3145
3573
|
__name(this, "QueueController");
|
|
@@ -3163,10 +3591,10 @@ var QueueController = class {
|
|
|
3163
3591
|
async update(req, messageId, body) {
|
|
3164
3592
|
const actor = await this.actorResolver.resolve(req);
|
|
3165
3593
|
if (body.message !== void 0 && typeof body.message !== "string") {
|
|
3166
|
-
throw new
|
|
3594
|
+
throw new import_common15.BadRequestException("message must be a string");
|
|
3167
3595
|
}
|
|
3168
3596
|
if (body.position !== void 0 && typeof body.position !== "number") {
|
|
3169
|
-
throw new
|
|
3597
|
+
throw new import_common15.BadRequestException("position must be a number");
|
|
3170
3598
|
}
|
|
3171
3599
|
const attachments = body.attachments === void 0 ? void 0 : body.attachments === null ? null : attachmentRefs(body.attachments);
|
|
3172
3600
|
return this.agent.updateQueuedMessage(actor, messageId, {
|
|
@@ -3193,88 +3621,88 @@ var QueueController = class {
|
|
|
3193
3621
|
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
3194
3622
|
}
|
|
3195
3623
|
};
|
|
3196
|
-
|
|
3197
|
-
(0,
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3624
|
+
_ts_decorate14([
|
|
3625
|
+
(0, import_common15.Get)("threads/:id/queue"),
|
|
3626
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3627
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
3628
|
+
_ts_metadata13("design:type", Function),
|
|
3629
|
+
_ts_metadata13("design:paramtypes", [
|
|
3202
3630
|
typeof Request === "undefined" ? Object : Request,
|
|
3203
3631
|
String
|
|
3204
3632
|
]),
|
|
3205
|
-
|
|
3633
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3206
3634
|
], QueueController.prototype, "list", null);
|
|
3207
|
-
|
|
3208
|
-
(0,
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3635
|
+
_ts_decorate14([
|
|
3636
|
+
(0, import_common15.Delete)("threads/:id/queue"),
|
|
3637
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3638
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
3639
|
+
_ts_metadata13("design:type", Function),
|
|
3640
|
+
_ts_metadata13("design:paramtypes", [
|
|
3213
3641
|
typeof Request === "undefined" ? Object : Request,
|
|
3214
3642
|
String
|
|
3215
3643
|
]),
|
|
3216
|
-
|
|
3644
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3217
3645
|
], QueueController.prototype, "clear", null);
|
|
3218
|
-
|
|
3219
|
-
(0,
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3646
|
+
_ts_decorate14([
|
|
3647
|
+
(0, import_common15.Post)("threads/:id/queue/resume"),
|
|
3648
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3649
|
+
_ts_param13(1, (0, import_common15.Param)("id")),
|
|
3650
|
+
_ts_metadata13("design:type", Function),
|
|
3651
|
+
_ts_metadata13("design:paramtypes", [
|
|
3224
3652
|
typeof Request === "undefined" ? Object : Request,
|
|
3225
3653
|
String
|
|
3226
3654
|
]),
|
|
3227
|
-
|
|
3655
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3228
3656
|
], QueueController.prototype, "resume", null);
|
|
3229
|
-
|
|
3230
|
-
(0,
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3657
|
+
_ts_decorate14([
|
|
3658
|
+
(0, import_common15.Patch)("queue/:messageId"),
|
|
3659
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3660
|
+
_ts_param13(1, (0, import_common15.Param)("messageId")),
|
|
3661
|
+
_ts_param13(2, (0, import_common15.Body)()),
|
|
3662
|
+
_ts_metadata13("design:type", Function),
|
|
3663
|
+
_ts_metadata13("design:paramtypes", [
|
|
3236
3664
|
typeof Request === "undefined" ? Object : Request,
|
|
3237
3665
|
String,
|
|
3238
3666
|
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
3239
3667
|
]),
|
|
3240
|
-
|
|
3668
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3241
3669
|
], QueueController.prototype, "update", null);
|
|
3242
|
-
|
|
3243
|
-
(0,
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3670
|
+
_ts_decorate14([
|
|
3671
|
+
(0, import_common15.Post)("queue/:messageId/interrupt"),
|
|
3672
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3673
|
+
_ts_param13(1, (0, import_common15.Param)("messageId")),
|
|
3674
|
+
_ts_metadata13("design:type", Function),
|
|
3675
|
+
_ts_metadata13("design:paramtypes", [
|
|
3248
3676
|
typeof Request === "undefined" ? Object : Request,
|
|
3249
3677
|
String
|
|
3250
3678
|
]),
|
|
3251
|
-
|
|
3679
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3252
3680
|
], QueueController.prototype, "interrupt", null);
|
|
3253
|
-
|
|
3254
|
-
(0,
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3681
|
+
_ts_decorate14([
|
|
3682
|
+
(0, import_common15.Delete)("queue/:messageId"),
|
|
3683
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
3684
|
+
_ts_param13(1, (0, import_common15.Param)("messageId")),
|
|
3685
|
+
_ts_metadata13("design:type", Function),
|
|
3686
|
+
_ts_metadata13("design:paramtypes", [
|
|
3259
3687
|
typeof Request === "undefined" ? Object : Request,
|
|
3260
3688
|
String
|
|
3261
3689
|
]),
|
|
3262
|
-
|
|
3690
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3263
3691
|
], QueueController.prototype, "remove", null);
|
|
3264
|
-
QueueController =
|
|
3265
|
-
(0,
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3692
|
+
QueueController = _ts_decorate14([
|
|
3693
|
+
(0, import_common15.Controller)(),
|
|
3694
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
3695
|
+
_ts_metadata13("design:type", Function),
|
|
3696
|
+
_ts_metadata13("design:paramtypes", [
|
|
3269
3697
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3270
3698
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3271
3699
|
])
|
|
3272
3700
|
], QueueController);
|
|
3273
3701
|
|
|
3274
3702
|
// src/controller/quota.controller.ts
|
|
3275
|
-
var
|
|
3276
|
-
var
|
|
3277
|
-
function
|
|
3703
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
3704
|
+
var import_common16 = require("@nestjs/common");
|
|
3705
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
3278
3706
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3279
3707
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3280
3708
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3287,19 +3715,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
3287
3715
|
}
|
|
3288
3716
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3289
3717
|
}
|
|
3290
|
-
__name(
|
|
3291
|
-
function
|
|
3718
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3719
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
3292
3720
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3293
3721
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3294
3722
|
}
|
|
3295
3723
|
}
|
|
3296
|
-
__name(
|
|
3297
|
-
function
|
|
3724
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
3725
|
+
function _ts_param14(paramIndex, decorator) {
|
|
3298
3726
|
return function(target, key) {
|
|
3299
3727
|
decorator(target, key, paramIndex);
|
|
3300
3728
|
};
|
|
3301
3729
|
}
|
|
3302
|
-
__name(
|
|
3730
|
+
__name(_ts_param14, "_ts_param");
|
|
3303
3731
|
var QuotaController = class {
|
|
3304
3732
|
static {
|
|
3305
3733
|
__name(this, "QuotaController");
|
|
@@ -3319,29 +3747,29 @@ var QuotaController = class {
|
|
|
3319
3747
|
return this.agent.quotaReport(actor);
|
|
3320
3748
|
}
|
|
3321
3749
|
};
|
|
3322
|
-
|
|
3323
|
-
(0,
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3750
|
+
_ts_decorate15([
|
|
3751
|
+
(0, import_common16.Get)(),
|
|
3752
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
3753
|
+
_ts_metadata14("design:type", Function),
|
|
3754
|
+
_ts_metadata14("design:paramtypes", [
|
|
3327
3755
|
typeof Request === "undefined" ? Object : Request
|
|
3328
3756
|
]),
|
|
3329
|
-
|
|
3757
|
+
_ts_metadata14("design:returntype", Promise)
|
|
3330
3758
|
], QuotaController.prototype, "report", null);
|
|
3331
|
-
QuotaController =
|
|
3332
|
-
(0,
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3759
|
+
QuotaController = _ts_decorate15([
|
|
3760
|
+
(0, import_common16.Controller)("quota"),
|
|
3761
|
+
_ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
3762
|
+
_ts_metadata14("design:type", Function),
|
|
3763
|
+
_ts_metadata14("design:paramtypes", [
|
|
3336
3764
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3337
3765
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3338
3766
|
])
|
|
3339
3767
|
], QuotaController);
|
|
3340
3768
|
|
|
3341
3769
|
// src/controller/skills.controller.ts
|
|
3342
|
-
var
|
|
3343
|
-
var
|
|
3344
|
-
function
|
|
3770
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
3771
|
+
var import_common17 = require("@nestjs/common");
|
|
3772
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
3345
3773
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3346
3774
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3347
3775
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3354,19 +3782,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
3354
3782
|
}
|
|
3355
3783
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3356
3784
|
}
|
|
3357
|
-
__name(
|
|
3358
|
-
function
|
|
3785
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3786
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
3359
3787
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3360
3788
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3361
3789
|
}
|
|
3362
3790
|
}
|
|
3363
|
-
__name(
|
|
3364
|
-
function
|
|
3791
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3792
|
+
function _ts_param15(paramIndex, decorator) {
|
|
3365
3793
|
return function(target, key) {
|
|
3366
3794
|
decorator(target, key, paramIndex);
|
|
3367
3795
|
};
|
|
3368
3796
|
}
|
|
3369
|
-
__name(
|
|
3797
|
+
__name(_ts_param15, "_ts_param");
|
|
3370
3798
|
var SkillsController = class {
|
|
3371
3799
|
static {
|
|
3372
3800
|
__name(this, "SkillsController");
|
|
@@ -3382,40 +3810,40 @@ var SkillsController = class {
|
|
|
3382
3810
|
return [];
|
|
3383
3811
|
}
|
|
3384
3812
|
const actor = await this.actorResolver.resolve(req);
|
|
3385
|
-
const offer = await (0,
|
|
3813
|
+
const offer = await (0, import_nestjs_agent_core17.offerSkills)(this.skills, {
|
|
3386
3814
|
actor,
|
|
3387
3815
|
threadId: threadId ?? ""
|
|
3388
3816
|
});
|
|
3389
3817
|
return offer.entries;
|
|
3390
3818
|
}
|
|
3391
3819
|
};
|
|
3392
|
-
|
|
3393
|
-
(0,
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3820
|
+
_ts_decorate16([
|
|
3821
|
+
(0, import_common17.Get)(),
|
|
3822
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3823
|
+
_ts_param15(1, (0, import_common17.Query)("threadId")),
|
|
3824
|
+
_ts_metadata15("design:type", Function),
|
|
3825
|
+
_ts_metadata15("design:paramtypes", [
|
|
3398
3826
|
typeof Request === "undefined" ? Object : Request,
|
|
3399
3827
|
String
|
|
3400
3828
|
]),
|
|
3401
|
-
|
|
3829
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3402
3830
|
], SkillsController.prototype, "list", null);
|
|
3403
|
-
SkillsController =
|
|
3404
|
-
(0,
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3831
|
+
SkillsController = _ts_decorate16([
|
|
3832
|
+
(0, import_common17.Controller)("skills"),
|
|
3833
|
+
_ts_param15(0, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
3834
|
+
_ts_param15(1, (0, import_common17.Optional)()),
|
|
3835
|
+
_ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core17.AGENT_SKILLS)),
|
|
3836
|
+
_ts_metadata15("design:type", Function),
|
|
3837
|
+
_ts_metadata15("design:paramtypes", [
|
|
3410
3838
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3411
3839
|
Object
|
|
3412
3840
|
])
|
|
3413
3841
|
], SkillsController);
|
|
3414
3842
|
|
|
3415
3843
|
// src/controller/threads.controller.ts
|
|
3416
|
-
var
|
|
3417
|
-
var
|
|
3418
|
-
function
|
|
3844
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
3845
|
+
var import_common18 = require("@nestjs/common");
|
|
3846
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
3419
3847
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3420
3848
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3421
3849
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3428,19 +3856,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
3428
3856
|
}
|
|
3429
3857
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3430
3858
|
}
|
|
3431
|
-
__name(
|
|
3432
|
-
function
|
|
3859
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3860
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
3433
3861
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3434
3862
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3435
3863
|
}
|
|
3436
3864
|
}
|
|
3437
|
-
__name(
|
|
3438
|
-
function
|
|
3865
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
3866
|
+
function _ts_param16(paramIndex, decorator) {
|
|
3439
3867
|
return function(target, key) {
|
|
3440
3868
|
decorator(target, key, paramIndex);
|
|
3441
3869
|
};
|
|
3442
3870
|
}
|
|
3443
|
-
__name(
|
|
3871
|
+
__name(_ts_param16, "_ts_param");
|
|
3444
3872
|
var ThreadsController = class {
|
|
3445
3873
|
static {
|
|
3446
3874
|
__name(this, "ThreadsController");
|
|
@@ -3510,101 +3938,101 @@ var ThreadsController = class {
|
|
|
3510
3938
|
};
|
|
3511
3939
|
}
|
|
3512
3940
|
};
|
|
3513
|
-
|
|
3514
|
-
(0,
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3941
|
+
_ts_decorate17([
|
|
3942
|
+
(0, import_common18.Get)(),
|
|
3943
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3944
|
+
_ts_metadata16("design:type", Function),
|
|
3945
|
+
_ts_metadata16("design:paramtypes", [
|
|
3518
3946
|
typeof Request === "undefined" ? Object : Request
|
|
3519
3947
|
]),
|
|
3520
|
-
|
|
3948
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3521
3949
|
], ThreadsController.prototype, "list", null);
|
|
3522
|
-
|
|
3523
|
-
(0,
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3950
|
+
_ts_decorate17([
|
|
3951
|
+
(0, import_common18.Get)(":id"),
|
|
3952
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3953
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
3954
|
+
_ts_metadata16("design:type", Function),
|
|
3955
|
+
_ts_metadata16("design:paramtypes", [
|
|
3528
3956
|
typeof Request === "undefined" ? Object : Request,
|
|
3529
3957
|
String
|
|
3530
3958
|
]),
|
|
3531
|
-
|
|
3959
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3532
3960
|
], ThreadsController.prototype, "detail", null);
|
|
3533
|
-
|
|
3534
|
-
(0,
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3961
|
+
_ts_decorate17([
|
|
3962
|
+
(0, import_common18.Delete)(":id"),
|
|
3963
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3964
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
3965
|
+
_ts_metadata16("design:type", Function),
|
|
3966
|
+
_ts_metadata16("design:paramtypes", [
|
|
3539
3967
|
typeof Request === "undefined" ? Object : Request,
|
|
3540
3968
|
String
|
|
3541
3969
|
]),
|
|
3542
|
-
|
|
3970
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3543
3971
|
], ThreadsController.prototype, "remove", null);
|
|
3544
|
-
|
|
3545
|
-
(0,
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3972
|
+
_ts_decorate17([
|
|
3973
|
+
(0, import_common18.Post)(":id/fork-from/:messageId"),
|
|
3974
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3975
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
3976
|
+
_ts_param16(2, (0, import_common18.Param)("messageId")),
|
|
3977
|
+
_ts_metadata16("design:type", Function),
|
|
3978
|
+
_ts_metadata16("design:paramtypes", [
|
|
3551
3979
|
typeof Request === "undefined" ? Object : Request,
|
|
3552
3980
|
String,
|
|
3553
3981
|
String
|
|
3554
3982
|
]),
|
|
3555
|
-
|
|
3983
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3556
3984
|
], ThreadsController.prototype, "fork", null);
|
|
3557
|
-
|
|
3558
|
-
(0,
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3985
|
+
_ts_decorate17([
|
|
3986
|
+
(0, import_common18.Patch)(":id"),
|
|
3987
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3988
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
3989
|
+
_ts_param16(2, (0, import_common18.Body)()),
|
|
3990
|
+
_ts_metadata16("design:type", Function),
|
|
3991
|
+
_ts_metadata16("design:paramtypes", [
|
|
3564
3992
|
typeof Request === "undefined" ? Object : Request,
|
|
3565
3993
|
String,
|
|
3566
3994
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
3567
3995
|
]),
|
|
3568
|
-
|
|
3996
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3569
3997
|
], ThreadsController.prototype, "update", null);
|
|
3570
|
-
|
|
3571
|
-
(0,
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3998
|
+
_ts_decorate17([
|
|
3999
|
+
(0, import_common18.Post)(":id/promote"),
|
|
4000
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4001
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4002
|
+
_ts_metadata16("design:type", Function),
|
|
4003
|
+
_ts_metadata16("design:paramtypes", [
|
|
3576
4004
|
typeof Request === "undefined" ? Object : Request,
|
|
3577
4005
|
String
|
|
3578
4006
|
]),
|
|
3579
|
-
|
|
4007
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3580
4008
|
], ThreadsController.prototype, "promote", null);
|
|
3581
|
-
|
|
3582
|
-
(0,
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
4009
|
+
_ts_decorate17([
|
|
4010
|
+
(0, import_common18.Delete)(":id/from/:messageId"),
|
|
4011
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
4012
|
+
_ts_param16(1, (0, import_common18.Param)("id")),
|
|
4013
|
+
_ts_param16(2, (0, import_common18.Param)("messageId")),
|
|
4014
|
+
_ts_metadata16("design:type", Function),
|
|
4015
|
+
_ts_metadata16("design:paramtypes", [
|
|
3588
4016
|
typeof Request === "undefined" ? Object : Request,
|
|
3589
4017
|
String,
|
|
3590
4018
|
String
|
|
3591
4019
|
]),
|
|
3592
|
-
|
|
4020
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3593
4021
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
3594
|
-
ThreadsController =
|
|
3595
|
-
(0,
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
4022
|
+
ThreadsController = _ts_decorate17([
|
|
4023
|
+
(0, import_common18.Controller)("threads"),
|
|
4024
|
+
_ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
4025
|
+
_ts_metadata16("design:type", Function),
|
|
4026
|
+
_ts_metadata16("design:paramtypes", [
|
|
3599
4027
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3600
4028
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3601
4029
|
])
|
|
3602
4030
|
], ThreadsController);
|
|
3603
4031
|
|
|
3604
4032
|
// src/controller/tool-call.controller.ts
|
|
3605
|
-
var
|
|
3606
|
-
var
|
|
3607
|
-
function
|
|
4033
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
4034
|
+
var import_common19 = require("@nestjs/common");
|
|
4035
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
3608
4036
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3609
4037
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3610
4038
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3617,19 +4045,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
3617
4045
|
}
|
|
3618
4046
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3619
4047
|
}
|
|
3620
|
-
__name(
|
|
3621
|
-
function
|
|
4048
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
4049
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
3622
4050
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3623
4051
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3624
4052
|
}
|
|
3625
4053
|
}
|
|
3626
|
-
__name(
|
|
3627
|
-
function
|
|
4054
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4055
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3628
4056
|
return function(target, key) {
|
|
3629
4057
|
decorator(target, key, paramIndex);
|
|
3630
4058
|
};
|
|
3631
4059
|
}
|
|
3632
|
-
__name(
|
|
4060
|
+
__name(_ts_param17, "_ts_param");
|
|
3633
4061
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
3634
4062
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
3635
4063
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -3638,7 +4066,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
3638
4066
|
var DEFAULT_VIA = "web";
|
|
3639
4067
|
function toolCallId(claimed) {
|
|
3640
4068
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
3641
|
-
throw new
|
|
4069
|
+
throw new import_common19.BadRequestException("toolCallId must be a non-empty string");
|
|
3642
4070
|
}
|
|
3643
4071
|
return claimed;
|
|
3644
4072
|
}
|
|
@@ -3648,10 +4076,10 @@ function rejectReason(claimed) {
|
|
|
3648
4076
|
return void 0;
|
|
3649
4077
|
}
|
|
3650
4078
|
if (typeof claimed !== "string") {
|
|
3651
|
-
throw new
|
|
4079
|
+
throw new import_common19.BadRequestException("reason must be a string");
|
|
3652
4080
|
}
|
|
3653
4081
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
3654
|
-
throw new
|
|
4082
|
+
throw new import_common19.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
3655
4083
|
}
|
|
3656
4084
|
return claimed;
|
|
3657
4085
|
}
|
|
@@ -3661,7 +4089,7 @@ function remember(claimed) {
|
|
|
3661
4089
|
return false;
|
|
3662
4090
|
}
|
|
3663
4091
|
if (typeof claimed !== "boolean") {
|
|
3664
|
-
throw new
|
|
4092
|
+
throw new import_common19.BadRequestException("remember must be a boolean");
|
|
3665
4093
|
}
|
|
3666
4094
|
return claimed;
|
|
3667
4095
|
}
|
|
@@ -3671,7 +4099,7 @@ function via(claimed) {
|
|
|
3671
4099
|
return DEFAULT_VIA;
|
|
3672
4100
|
}
|
|
3673
4101
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
3674
|
-
throw new
|
|
4102
|
+
throw new import_common19.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
3675
4103
|
}
|
|
3676
4104
|
return claimed;
|
|
3677
4105
|
}
|
|
@@ -3681,26 +4109,26 @@ function answers(claimed) {
|
|
|
3681
4109
|
return void 0;
|
|
3682
4110
|
}
|
|
3683
4111
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
3684
|
-
throw new
|
|
4112
|
+
throw new import_common19.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
3685
4113
|
}
|
|
3686
4114
|
const entries = Object.entries(claimed);
|
|
3687
4115
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
3688
|
-
throw new
|
|
4116
|
+
throw new import_common19.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
3689
4117
|
}
|
|
3690
4118
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
3691
4119
|
for (const [questionId, values] of entries) {
|
|
3692
4120
|
if (!Array.isArray(values)) {
|
|
3693
|
-
throw new
|
|
4121
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
3694
4122
|
}
|
|
3695
4123
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
3696
|
-
throw new
|
|
4124
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
3697
4125
|
}
|
|
3698
4126
|
for (const value of values) {
|
|
3699
4127
|
if (typeof value !== "string") {
|
|
3700
|
-
throw new
|
|
4128
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
3701
4129
|
}
|
|
3702
4130
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
3703
|
-
throw new
|
|
4131
|
+
throw new import_common19.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
3704
4132
|
}
|
|
3705
4133
|
}
|
|
3706
4134
|
validated[questionId] = values;
|
|
@@ -3762,64 +4190,64 @@ var ToolCallController = class {
|
|
|
3762
4190
|
};
|
|
3763
4191
|
}
|
|
3764
4192
|
};
|
|
3765
|
-
|
|
3766
|
-
(0,
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
4193
|
+
_ts_decorate18([
|
|
4194
|
+
(0, import_common19.Post)("approve"),
|
|
4195
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4196
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4197
|
+
_ts_metadata17("design:type", Function),
|
|
4198
|
+
_ts_metadata17("design:paramtypes", [
|
|
3771
4199
|
typeof Request === "undefined" ? Object : Request,
|
|
3772
4200
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
3773
4201
|
]),
|
|
3774
|
-
|
|
4202
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3775
4203
|
], ToolCallController.prototype, "approve", null);
|
|
3776
|
-
|
|
3777
|
-
(0,
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
4204
|
+
_ts_decorate18([
|
|
4205
|
+
(0, import_common19.Post)("reject"),
|
|
4206
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4207
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4208
|
+
_ts_metadata17("design:type", Function),
|
|
4209
|
+
_ts_metadata17("design:paramtypes", [
|
|
3782
4210
|
typeof Request === "undefined" ? Object : Request,
|
|
3783
4211
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
3784
4212
|
]),
|
|
3785
|
-
|
|
4213
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3786
4214
|
], ToolCallController.prototype, "reject", null);
|
|
3787
|
-
|
|
3788
|
-
(0,
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
4215
|
+
_ts_decorate18([
|
|
4216
|
+
(0, import_common19.Post)("answer"),
|
|
4217
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4218
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4219
|
+
_ts_metadata17("design:type", Function),
|
|
4220
|
+
_ts_metadata17("design:paramtypes", [
|
|
3793
4221
|
typeof Request === "undefined" ? Object : Request,
|
|
3794
4222
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
3795
4223
|
]),
|
|
3796
|
-
|
|
4224
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3797
4225
|
], ToolCallController.prototype, "answer", null);
|
|
3798
|
-
|
|
3799
|
-
(0,
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
4226
|
+
_ts_decorate18([
|
|
4227
|
+
(0, import_common19.Post)("skip"),
|
|
4228
|
+
_ts_param17(0, (0, import_common19.Req)()),
|
|
4229
|
+
_ts_param17(1, (0, import_common19.Body)()),
|
|
4230
|
+
_ts_metadata17("design:type", Function),
|
|
4231
|
+
_ts_metadata17("design:paramtypes", [
|
|
3804
4232
|
typeof Request === "undefined" ? Object : Request,
|
|
3805
4233
|
Object
|
|
3806
4234
|
]),
|
|
3807
|
-
|
|
4235
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3808
4236
|
], ToolCallController.prototype, "skip", null);
|
|
3809
|
-
ToolCallController =
|
|
3810
|
-
(0,
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
4237
|
+
ToolCallController = _ts_decorate18([
|
|
4238
|
+
(0, import_common19.Controller)("tool-call"),
|
|
4239
|
+
_ts_param17(1, (0, import_common19.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
4240
|
+
_ts_metadata17("design:type", Function),
|
|
4241
|
+
_ts_metadata17("design:paramtypes", [
|
|
3814
4242
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3815
4243
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3816
4244
|
])
|
|
3817
4245
|
], ToolCallController);
|
|
3818
4246
|
|
|
3819
4247
|
// src/controller/tools.controller.ts
|
|
3820
|
-
var
|
|
3821
|
-
var
|
|
3822
|
-
function
|
|
4248
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
4249
|
+
var import_common20 = require("@nestjs/common");
|
|
4250
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3823
4251
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3824
4252
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3825
4253
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3832,19 +4260,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
3832
4260
|
}
|
|
3833
4261
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3834
4262
|
}
|
|
3835
|
-
__name(
|
|
3836
|
-
function
|
|
4263
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4264
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3837
4265
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3838
4266
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3839
4267
|
}
|
|
3840
4268
|
}
|
|
3841
|
-
__name(
|
|
3842
|
-
function
|
|
4269
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
4270
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3843
4271
|
return function(target, key) {
|
|
3844
4272
|
decorator(target, key, paramIndex);
|
|
3845
4273
|
};
|
|
3846
4274
|
}
|
|
3847
|
-
__name(
|
|
4275
|
+
__name(_ts_param18, "_ts_param");
|
|
3848
4276
|
var ToolsController = class {
|
|
3849
4277
|
static {
|
|
3850
4278
|
__name(this, "ToolsController");
|
|
@@ -3858,11 +4286,11 @@ var ToolsController = class {
|
|
|
3858
4286
|
this.agents = agents;
|
|
3859
4287
|
}
|
|
3860
4288
|
async list(req, agent) {
|
|
3861
|
-
if (agent !== void 0 && agent !==
|
|
3862
|
-
throw new
|
|
4289
|
+
if (agent !== void 0 && agent !== import_nestjs_agent_core20.ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
4290
|
+
throw new import_common20.NotFoundException(`No agent named "${agent}"`);
|
|
3863
4291
|
}
|
|
3864
4292
|
const actor = await this.actorResolver.resolve(req);
|
|
3865
|
-
const names = agent ===
|
|
4293
|
+
const names = agent === import_nestjs_agent_core20.ALL_AGENTS ? [
|
|
3866
4294
|
void 0,
|
|
3867
4295
|
...this.agents.list().map((definition) => definition.name)
|
|
3868
4296
|
] : [
|
|
@@ -3888,33 +4316,33 @@ var ToolsController = class {
|
|
|
3888
4316
|
];
|
|
3889
4317
|
}
|
|
3890
4318
|
};
|
|
3891
|
-
|
|
3892
|
-
(0,
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
4319
|
+
_ts_decorate19([
|
|
4320
|
+
(0, import_common20.Get)(),
|
|
4321
|
+
_ts_param18(0, (0, import_common20.Req)()),
|
|
4322
|
+
_ts_param18(1, (0, import_common20.Query)("agent")),
|
|
4323
|
+
_ts_metadata18("design:type", Function),
|
|
4324
|
+
_ts_metadata18("design:paramtypes", [
|
|
3897
4325
|
typeof Request === "undefined" ? Object : Request,
|
|
3898
4326
|
String
|
|
3899
4327
|
]),
|
|
3900
|
-
|
|
4328
|
+
_ts_metadata18("design:returntype", Promise)
|
|
3901
4329
|
], ToolsController.prototype, "list", null);
|
|
3902
|
-
ToolsController =
|
|
3903
|
-
(0,
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
4330
|
+
ToolsController = _ts_decorate19([
|
|
4331
|
+
(0, import_common20.Controller)("tools"),
|
|
4332
|
+
_ts_param18(0, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER)),
|
|
4333
|
+
_ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_DEPS_FACTORY)),
|
|
4334
|
+
_ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
|
|
4335
|
+
_ts_metadata18("design:type", Function),
|
|
4336
|
+
_ts_metadata18("design:paramtypes", [
|
|
3909
4337
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3910
4338
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3911
|
-
typeof
|
|
4339
|
+
typeof import_nestjs_agent_core20.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core20.AgentRegistry
|
|
3912
4340
|
])
|
|
3913
4341
|
], ToolsController);
|
|
3914
4342
|
|
|
3915
4343
|
// src/discovery/agent-discovery.service.ts
|
|
3916
|
-
var
|
|
3917
|
-
var
|
|
4344
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
4345
|
+
var import_common21 = require("@nestjs/common");
|
|
3918
4346
|
var import_core = require("@nestjs/core");
|
|
3919
4347
|
|
|
3920
4348
|
// src/decorator/agent.decorator.ts
|
|
@@ -3949,7 +4377,7 @@ function SystemPromptContributor() {
|
|
|
3949
4377
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
3950
4378
|
|
|
3951
4379
|
// src/discovery/agent-discovery.service.ts
|
|
3952
|
-
function
|
|
4380
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3953
4381
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3954
4382
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3955
4383
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3962,19 +4390,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3962
4390
|
}
|
|
3963
4391
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3964
4392
|
}
|
|
3965
|
-
__name(
|
|
3966
|
-
function
|
|
4393
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4394
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3967
4395
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3968
4396
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3969
4397
|
}
|
|
3970
4398
|
}
|
|
3971
|
-
__name(
|
|
3972
|
-
function
|
|
4399
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
4400
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3973
4401
|
return function(target, key) {
|
|
3974
4402
|
decorator(target, key, paramIndex);
|
|
3975
4403
|
};
|
|
3976
4404
|
}
|
|
3977
|
-
__name(
|
|
4405
|
+
__name(_ts_param19, "_ts_param");
|
|
3978
4406
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
3979
4407
|
static {
|
|
3980
4408
|
__name(this, "AgentDiscoveryService");
|
|
@@ -3983,7 +4411,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3983
4411
|
scanner;
|
|
3984
4412
|
registry;
|
|
3985
4413
|
contributors;
|
|
3986
|
-
logger = new
|
|
4414
|
+
logger = new import_common21.Logger(_AgentDiscoveryService.name);
|
|
3987
4415
|
constructor(discovery, scanner, registry, contributors) {
|
|
3988
4416
|
this.discovery = discovery;
|
|
3989
4417
|
this.scanner = scanner;
|
|
@@ -4140,22 +4568,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4140
4568
|
return (ctx) => candidate.call(instance, ctx);
|
|
4141
4569
|
}
|
|
4142
4570
|
};
|
|
4143
|
-
AgentDiscoveryService =
|
|
4144
|
-
(0,
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4571
|
+
AgentDiscoveryService = _ts_decorate20([
|
|
4572
|
+
(0, import_common21.Injectable)(),
|
|
4573
|
+
_ts_param19(2, (0, import_common21.Inject)(import_nestjs_agent_core21.AGENT_REGISTRY)),
|
|
4574
|
+
_ts_param19(3, (0, import_common21.Inject)(import_nestjs_agent_core21.AGENT_PROMPT_CONTRIBUTORS)),
|
|
4575
|
+
_ts_metadata19("design:type", Function),
|
|
4576
|
+
_ts_metadata19("design:paramtypes", [
|
|
4149
4577
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
4150
4578
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
4151
|
-
typeof
|
|
4579
|
+
typeof import_nestjs_agent_core21.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core21.AgentRegistry,
|
|
4152
4580
|
Array
|
|
4153
4581
|
])
|
|
4154
4582
|
], AgentDiscoveryService);
|
|
4155
4583
|
|
|
4156
4584
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4157
|
-
var
|
|
4158
|
-
var
|
|
4585
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
4586
|
+
var import_common22 = require("@nestjs/common");
|
|
4159
4587
|
var import_core2 = require("@nestjs/core");
|
|
4160
4588
|
var import_zod = require("zod");
|
|
4161
4589
|
|
|
@@ -4187,46 +4615,8 @@ function readAiToolMetadata(target) {
|
|
|
4187
4615
|
}
|
|
4188
4616
|
__name(readAiToolMetadata, "readAiToolMetadata");
|
|
4189
4617
|
|
|
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
4618
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4229
|
-
function
|
|
4619
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
4230
4620
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4231
4621
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4232
4622
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4239,19 +4629,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
4239
4629
|
}
|
|
4240
4630
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4241
4631
|
}
|
|
4242
|
-
__name(
|
|
4243
|
-
function
|
|
4632
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
4633
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
4244
4634
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4245
4635
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4246
4636
|
}
|
|
4247
4637
|
}
|
|
4248
|
-
__name(
|
|
4249
|
-
function
|
|
4638
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
4639
|
+
function _ts_param20(paramIndex, decorator) {
|
|
4250
4640
|
return function(target, key) {
|
|
4251
4641
|
decorator(target, key, paramIndex);
|
|
4252
4642
|
};
|
|
4253
4643
|
}
|
|
4254
|
-
__name(
|
|
4644
|
+
__name(_ts_param20, "_ts_param");
|
|
4255
4645
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
4256
4646
|
static {
|
|
4257
4647
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -4260,7 +4650,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4260
4650
|
registry;
|
|
4261
4651
|
agents;
|
|
4262
4652
|
options;
|
|
4263
|
-
logger = new
|
|
4653
|
+
logger = new import_common22.Logger(_AiToolDiscoveryService.name);
|
|
4264
4654
|
constructor(discovery, registry, agents, options) {
|
|
4265
4655
|
this.discovery = discovery;
|
|
4266
4656
|
this.registry = registry;
|
|
@@ -4319,9 +4709,15 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4319
4709
|
} : {},
|
|
4320
4710
|
...meta.terminal === true ? {
|
|
4321
4711
|
terminal: true
|
|
4712
|
+
} : {},
|
|
4713
|
+
...meta.replacementKey !== void 0 ? {
|
|
4714
|
+
replacementKey: meta.replacementKey
|
|
4322
4715
|
} : {}
|
|
4323
4716
|
}, {
|
|
4324
4717
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
4718
|
+
...typeof handler.preflight === "function" ? {
|
|
4719
|
+
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
4720
|
+
} : {},
|
|
4325
4721
|
// Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
|
|
4326
4722
|
// `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
|
|
4327
4723
|
// Called through `instance` so each keeps its `this` (and its injected deps).
|
|
@@ -4345,7 +4741,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4345
4741
|
let delegates = 0;
|
|
4346
4742
|
for (const definition of this.agents.list()) {
|
|
4347
4743
|
for (const edge of definition.delegatesTo ?? []) {
|
|
4348
|
-
const { agent: target, detached } = (0,
|
|
4744
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core22.normalizeDelegation)(edge);
|
|
4349
4745
|
const targetDefinition = this.agents.get(target);
|
|
4350
4746
|
if (targetDefinition === void 0) {
|
|
4351
4747
|
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 +4791,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4395
4791
|
return true;
|
|
4396
4792
|
}
|
|
4397
4793
|
};
|
|
4398
|
-
AiToolDiscoveryService =
|
|
4399
|
-
(0,
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4794
|
+
AiToolDiscoveryService = _ts_decorate21([
|
|
4795
|
+
(0, import_common22.Injectable)(),
|
|
4796
|
+
_ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core22.AGENT_TOOL_REGISTRY)),
|
|
4797
|
+
_ts_param20(2, (0, import_common22.Inject)(import_nestjs_agent_core22.AGENT_REGISTRY)),
|
|
4798
|
+
_ts_param20(3, (0, import_common22.Inject)(import_nestjs_agent_core22.AGENT_OPTIONS)),
|
|
4799
|
+
_ts_metadata20("design:type", Function),
|
|
4800
|
+
_ts_metadata20("design:paramtypes", [
|
|
4405
4801
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
4406
4802
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
4407
4803
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -4410,13 +4806,13 @@ AiToolDiscoveryService = _ts_decorate19([
|
|
|
4410
4806
|
], AiToolDiscoveryService);
|
|
4411
4807
|
|
|
4412
4808
|
// src/discovery/skill-discovery.service.ts
|
|
4413
|
-
var
|
|
4414
|
-
var
|
|
4809
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
4810
|
+
var import_common23 = require("@nestjs/common");
|
|
4415
4811
|
var import_core3 = require("@nestjs/core");
|
|
4416
4812
|
|
|
4417
4813
|
// src/decorator/skill.decorator.ts
|
|
4418
4814
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
4419
|
-
var
|
|
4815
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
4420
4816
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
4421
4817
|
function Skill(options) {
|
|
4422
4818
|
return (target) => {
|
|
@@ -4429,12 +4825,12 @@ function readSkillMetadata(target) {
|
|
|
4429
4825
|
}
|
|
4430
4826
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
4431
4827
|
function skillScope(options) {
|
|
4432
|
-
return options.scope ??
|
|
4828
|
+
return options.scope ?? import_nestjs_agent_core23.GLOBAL_SCOPE;
|
|
4433
4829
|
}
|
|
4434
4830
|
__name(skillScope, "skillScope");
|
|
4435
4831
|
|
|
4436
4832
|
// src/discovery/skill-discovery.service.ts
|
|
4437
|
-
function
|
|
4833
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
4438
4834
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4439
4835
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4440
4836
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4447,26 +4843,26 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
4447
4843
|
}
|
|
4448
4844
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4449
4845
|
}
|
|
4450
|
-
__name(
|
|
4451
|
-
function
|
|
4846
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
4847
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
4452
4848
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4453
4849
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4454
4850
|
}
|
|
4455
4851
|
}
|
|
4456
|
-
__name(
|
|
4457
|
-
function
|
|
4852
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
4853
|
+
function _ts_param21(paramIndex, decorator) {
|
|
4458
4854
|
return function(target, key) {
|
|
4459
4855
|
decorator(target, key, paramIndex);
|
|
4460
4856
|
};
|
|
4461
4857
|
}
|
|
4462
|
-
__name(
|
|
4858
|
+
__name(_ts_param21, "_ts_param");
|
|
4463
4859
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
4464
4860
|
static {
|
|
4465
4861
|
__name(this, "SkillDiscoveryService");
|
|
4466
4862
|
}
|
|
4467
4863
|
discovery;
|
|
4468
4864
|
declared;
|
|
4469
|
-
logger = new
|
|
4865
|
+
logger = new import_common23.Logger(_SkillDiscoveryService.name);
|
|
4470
4866
|
constructor(discovery, declared) {
|
|
4471
4867
|
this.discovery = discovery;
|
|
4472
4868
|
this.declared = declared;
|
|
@@ -4503,18 +4899,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4503
4899
|
return flat === void 0 ? void 0 : () => flat;
|
|
4504
4900
|
}
|
|
4505
4901
|
};
|
|
4506
|
-
SkillDiscoveryService =
|
|
4507
|
-
(0,
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4902
|
+
SkillDiscoveryService = _ts_decorate22([
|
|
4903
|
+
(0, import_common23.Injectable)(),
|
|
4904
|
+
_ts_param21(1, (0, import_common23.Inject)(import_nestjs_agent_core24.AGENT_SKILL_SOURCES)),
|
|
4905
|
+
_ts_metadata21("design:type", Function),
|
|
4906
|
+
_ts_metadata21("design:paramtypes", [
|
|
4511
4907
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
4512
4908
|
Array
|
|
4513
4909
|
])
|
|
4514
4910
|
], SkillDiscoveryService);
|
|
4515
4911
|
|
|
4516
4912
|
// src/in-process-sink.ts
|
|
4517
|
-
var
|
|
4913
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
4518
4914
|
var InProcessTokenStreamSink = class {
|
|
4519
4915
|
static {
|
|
4520
4916
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -4569,7 +4965,7 @@ var InProcessTokenStreamSink = class {
|
|
|
4569
4965
|
}
|
|
4570
4966
|
if (buf.ended) {
|
|
4571
4967
|
if (buf.failure !== void 0) {
|
|
4572
|
-
throw new
|
|
4968
|
+
throw new import_nestjs_agent_core25.AgentStreamError(buf.failure);
|
|
4573
4969
|
}
|
|
4574
4970
|
return;
|
|
4575
4971
|
}
|
|
@@ -4582,7 +4978,7 @@ var InProcessTokenStreamSink = class {
|
|
|
4582
4978
|
};
|
|
4583
4979
|
|
|
4584
4980
|
// src/ledger-quota-provider.ts
|
|
4585
|
-
var
|
|
4981
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
4586
4982
|
var LedgerQuotaProvider = class {
|
|
4587
4983
|
static {
|
|
4588
4984
|
__name(this, "LedgerQuotaProvider");
|
|
@@ -4602,12 +4998,12 @@ var LedgerQuotaProvider = class {
|
|
|
4602
4998
|
await this.dayWindow(actorRef, now)
|
|
4603
4999
|
];
|
|
4604
5000
|
if (this.store.usageBetween !== void 0) {
|
|
4605
|
-
const range = (0,
|
|
5001
|
+
const range = (0, import_nestjs_agent_core26.quotaPeriodRange)("month", now);
|
|
4606
5002
|
const used = await this.store.usageBetween(actorRef, range.fromDay, range.toDay);
|
|
4607
5003
|
windows.push(this.window("month", used.usedTokens, used.costUsd, range.resetsAt));
|
|
4608
5004
|
}
|
|
4609
|
-
const blocked = (0,
|
|
4610
|
-
const warning = (0,
|
|
5005
|
+
const blocked = (0, import_nestjs_agent_core26.exhaustedWindow)(windows);
|
|
5006
|
+
const warning = (0, import_nestjs_agent_core26.quotaWarning)(windows);
|
|
4611
5007
|
return {
|
|
4612
5008
|
windows,
|
|
4613
5009
|
...blocked !== void 0 ? {
|
|
@@ -4619,7 +5015,7 @@ var LedgerQuotaProvider = class {
|
|
|
4619
5015
|
};
|
|
4620
5016
|
}
|
|
4621
5017
|
async dayWindow(actorRef, now) {
|
|
4622
|
-
const range = (0,
|
|
5018
|
+
const range = (0, import_nestjs_agent_core26.quotaPeriodRange)("day", now);
|
|
4623
5019
|
const { usedTokens, costUsd } = await this.store.quotaToday(actorRef, range.fromDay);
|
|
4624
5020
|
return this.window("day", usedTokens, costUsd, range.resetsAt);
|
|
4625
5021
|
}
|
|
@@ -4643,13 +5039,248 @@ var LedgerQuotaProvider = class {
|
|
|
4643
5039
|
}
|
|
4644
5040
|
};
|
|
4645
5041
|
|
|
5042
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
5043
|
+
var import_node_crypto2 = require("crypto");
|
|
5044
|
+
var import_nestjs_agent_core27 = require("@dudousxd/nestjs-agent-core");
|
|
5045
|
+
var import_common24 = require("@nestjs/common");
|
|
5046
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
5047
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5048
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5049
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5050
|
+
} else {
|
|
5051
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
5052
|
+
if (d = decorators[i]) {
|
|
5053
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5054
|
+
}
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
5057
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5058
|
+
}
|
|
5059
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
5060
|
+
function _ts_metadata22(metadataKey, metadataValue) {
|
|
5061
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5062
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
5066
|
+
function _ts_param22(paramIndex, decorator) {
|
|
5067
|
+
return function(target, key) {
|
|
5068
|
+
decorator(target, key, paramIndex);
|
|
5069
|
+
};
|
|
5070
|
+
}
|
|
5071
|
+
__name(_ts_param22, "_ts_param");
|
|
5072
|
+
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
5073
|
+
static {
|
|
5074
|
+
__name(this, "ActionProposalWorkerService");
|
|
5075
|
+
}
|
|
5076
|
+
store;
|
|
5077
|
+
options;
|
|
5078
|
+
deps;
|
|
5079
|
+
worker;
|
|
5080
|
+
logger = new import_common24.Logger(_ActionProposalWorkerService.name);
|
|
5081
|
+
constructor(store, options, deps) {
|
|
5082
|
+
this.store = store;
|
|
5083
|
+
this.options = options;
|
|
5084
|
+
this.deps = deps;
|
|
5085
|
+
}
|
|
5086
|
+
onModuleInit() {
|
|
5087
|
+
if (this.options.actionApprovalMode !== "independent") return;
|
|
5088
|
+
(0, import_nestjs_agent_core27.assertIndependentActionCapabilities)(this.store, this.options.backgroundActorResolver);
|
|
5089
|
+
if (this.options.surface === "http") return;
|
|
5090
|
+
const resolver = this.options.backgroundActorResolver;
|
|
5091
|
+
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
5092
|
+
this.worker = new import_nestjs_agent_core27.ActionProposalWorker({
|
|
5093
|
+
store: this.store,
|
|
5094
|
+
workerId: (0, import_node_crypto2.randomUUID)(),
|
|
5095
|
+
...this.options.actionProposalWorker,
|
|
5096
|
+
executor: new import_nestjs_agent_core27.ActionProposalExecutor({
|
|
5097
|
+
resolver,
|
|
5098
|
+
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
5099
|
+
const deps = this.deps.forProposal(proposal, actor);
|
|
5100
|
+
return {
|
|
5101
|
+
registry: deps.registry,
|
|
5102
|
+
rolesPolicy: deps.rolesPolicy,
|
|
5103
|
+
...deps.resolveUiCatalog !== void 0 ? {
|
|
5104
|
+
resolveUiCatalog: deps.resolveUiCatalog
|
|
5105
|
+
} : {},
|
|
5106
|
+
...deps.toolAllowList !== void 0 ? {
|
|
5107
|
+
allowedTools: deps.toolAllowList
|
|
5108
|
+
} : {}
|
|
5109
|
+
};
|
|
5110
|
+
}, "resolveExecution")
|
|
5111
|
+
}),
|
|
5112
|
+
onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
|
|
5113
|
+
});
|
|
5114
|
+
this.worker.start();
|
|
5115
|
+
}
|
|
5116
|
+
async onModuleDestroy() {
|
|
5117
|
+
await this.worker?.stop();
|
|
5118
|
+
}
|
|
5119
|
+
};
|
|
5120
|
+
ActionProposalWorkerService = _ts_decorate23([
|
|
5121
|
+
(0, import_common24.Injectable)(),
|
|
5122
|
+
_ts_param22(0, (0, import_common24.Inject)(import_nestjs_agent_core27.AGENT_STORE)),
|
|
5123
|
+
_ts_param22(1, (0, import_common24.Inject)(import_nestjs_agent_core27.AGENT_OPTIONS)),
|
|
5124
|
+
_ts_param22(2, (0, import_common24.Inject)(import_nestjs_agent_core27.AGENT_DEPS_FACTORY)),
|
|
5125
|
+
_ts_metadata22("design:type", Function),
|
|
5126
|
+
_ts_metadata22("design:paramtypes", [
|
|
5127
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
5128
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
5129
|
+
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
5130
|
+
])
|
|
5131
|
+
], ActionProposalWorkerService);
|
|
5132
|
+
|
|
5133
|
+
// src/proposals/action-proposal.controller.ts
|
|
5134
|
+
var import_nestjs_agent_core28 = require("@dudousxd/nestjs-agent-core");
|
|
5135
|
+
var import_common25 = require("@nestjs/common");
|
|
5136
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
5137
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5138
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5139
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5140
|
+
} else {
|
|
5141
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
5142
|
+
if (d = decorators[i]) {
|
|
5143
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5148
|
+
}
|
|
5149
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
5150
|
+
function _ts_metadata23(metadataKey, metadataValue) {
|
|
5151
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5152
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5155
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
5156
|
+
function _ts_param23(paramIndex, decorator) {
|
|
5157
|
+
return function(target, key) {
|
|
5158
|
+
decorator(target, key, paramIndex);
|
|
5159
|
+
};
|
|
5160
|
+
}
|
|
5161
|
+
__name(_ts_param23, "_ts_param");
|
|
5162
|
+
function bodyFields(body, field2) {
|
|
5163
|
+
if (body === void 0) return {};
|
|
5164
|
+
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`);
|
|
5165
|
+
const value = body;
|
|
5166
|
+
if (value[field2] !== void 0 && (field2 === "remember" && typeof value[field2] !== "boolean" || field2 === "reason" && typeof value[field2] !== "string")) throw new import_common25.BadRequestException(`Invalid ${field2}`);
|
|
5167
|
+
return value;
|
|
5168
|
+
}
|
|
5169
|
+
__name(bodyFields, "bodyFields");
|
|
5170
|
+
var ActionProposalController = class {
|
|
5171
|
+
static {
|
|
5172
|
+
__name(this, "ActionProposalController");
|
|
5173
|
+
}
|
|
5174
|
+
proposals;
|
|
5175
|
+
actors;
|
|
5176
|
+
constructor(proposals, actors) {
|
|
5177
|
+
this.proposals = proposals;
|
|
5178
|
+
this.actors = actors;
|
|
5179
|
+
}
|
|
5180
|
+
async list(threadId, request, cursor, response) {
|
|
5181
|
+
let query = {};
|
|
5182
|
+
if (cursor !== void 0) {
|
|
5183
|
+
try {
|
|
5184
|
+
if (typeof cursor !== "string") throw new Error("Invalid cursor");
|
|
5185
|
+
query = {
|
|
5186
|
+
after: JSON.parse(cursor)
|
|
5187
|
+
};
|
|
5188
|
+
(0, import_nestjs_agent_core28.validateActionProposalListQuery)(query);
|
|
5189
|
+
} catch {
|
|
5190
|
+
throw new import_common25.BadRequestException("Invalid action proposal cursor");
|
|
5191
|
+
}
|
|
5192
|
+
}
|
|
5193
|
+
const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
|
|
5194
|
+
if (page.next) {
|
|
5195
|
+
response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
|
|
5196
|
+
const exposed = response.getHeader("Access-Control-Expose-Headers");
|
|
5197
|
+
response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
|
|
5198
|
+
}
|
|
5199
|
+
return page.items;
|
|
5200
|
+
}
|
|
5201
|
+
async approve(threadId, proposalId, request, body) {
|
|
5202
|
+
const value = bodyFields(body, "remember");
|
|
5203
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
5204
|
+
decision: "approved",
|
|
5205
|
+
...typeof value.remember === "boolean" ? {
|
|
5206
|
+
remember: value.remember
|
|
5207
|
+
} : {}
|
|
5208
|
+
});
|
|
5209
|
+
}
|
|
5210
|
+
async reject(threadId, proposalId, request, body) {
|
|
5211
|
+
const value = bodyFields(body, "reason");
|
|
5212
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
5213
|
+
decision: "rejected",
|
|
5214
|
+
...typeof value.reason === "string" ? {
|
|
5215
|
+
reason: value.reason
|
|
5216
|
+
} : {}
|
|
5217
|
+
});
|
|
5218
|
+
}
|
|
5219
|
+
};
|
|
5220
|
+
_ts_decorate24([
|
|
5221
|
+
(0, import_common25.Get)(),
|
|
5222
|
+
_ts_param23(0, (0, import_common25.Param)("threadId")),
|
|
5223
|
+
_ts_param23(1, (0, import_common25.Req)()),
|
|
5224
|
+
_ts_param23(2, (0, import_common25.Query)("after")),
|
|
5225
|
+
_ts_param23(3, (0, import_common25.Res)({
|
|
5226
|
+
passthrough: true
|
|
5227
|
+
})),
|
|
5228
|
+
_ts_metadata23("design:type", Function),
|
|
5229
|
+
_ts_metadata23("design:paramtypes", [
|
|
5230
|
+
String,
|
|
5231
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5232
|
+
Object,
|
|
5233
|
+
typeof Response === "undefined" ? Object : Response
|
|
5234
|
+
]),
|
|
5235
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5236
|
+
], ActionProposalController.prototype, "list", null);
|
|
5237
|
+
_ts_decorate24([
|
|
5238
|
+
(0, import_common25.Post)(":proposalId/approve"),
|
|
5239
|
+
_ts_param23(0, (0, import_common25.Param)("threadId")),
|
|
5240
|
+
_ts_param23(1, (0, import_common25.Param)("proposalId")),
|
|
5241
|
+
_ts_param23(2, (0, import_common25.Req)()),
|
|
5242
|
+
_ts_param23(3, (0, import_common25.Body)()),
|
|
5243
|
+
_ts_metadata23("design:type", Function),
|
|
5244
|
+
_ts_metadata23("design:paramtypes", [
|
|
5245
|
+
String,
|
|
5246
|
+
String,
|
|
5247
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5248
|
+
Object
|
|
5249
|
+
]),
|
|
5250
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5251
|
+
], ActionProposalController.prototype, "approve", null);
|
|
5252
|
+
_ts_decorate24([
|
|
5253
|
+
(0, import_common25.Post)(":proposalId/reject"),
|
|
5254
|
+
_ts_param23(0, (0, import_common25.Param)("threadId")),
|
|
5255
|
+
_ts_param23(1, (0, import_common25.Param)("proposalId")),
|
|
5256
|
+
_ts_param23(2, (0, import_common25.Req)()),
|
|
5257
|
+
_ts_param23(3, (0, import_common25.Body)()),
|
|
5258
|
+
_ts_metadata23("design:type", Function),
|
|
5259
|
+
_ts_metadata23("design:paramtypes", [
|
|
5260
|
+
String,
|
|
5261
|
+
String,
|
|
5262
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5263
|
+
Object
|
|
5264
|
+
]),
|
|
5265
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5266
|
+
], ActionProposalController.prototype, "reject", null);
|
|
5267
|
+
ActionProposalController = _ts_decorate24([
|
|
5268
|
+
(0, import_common25.Controller)("threads/:threadId/action-proposals"),
|
|
5269
|
+
_ts_param23(1, (0, import_common25.Inject)(import_nestjs_agent_core28.AGENT_ACTOR_RESOLVER)),
|
|
5270
|
+
_ts_metadata23("design:type", Function),
|
|
5271
|
+
_ts_metadata23("design:paramtypes", [
|
|
5272
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
5273
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
5274
|
+
])
|
|
5275
|
+
], ActionProposalController);
|
|
5276
|
+
|
|
4646
5277
|
// src/queue/chat-queue.token.ts
|
|
4647
5278
|
var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
|
|
4648
5279
|
|
|
4649
5280
|
// src/runner/inline-agent-runner.ts
|
|
4650
|
-
var
|
|
4651
|
-
var
|
|
4652
|
-
function
|
|
5281
|
+
var import_nestjs_agent_core29 = require("@dudousxd/nestjs-agent-core");
|
|
5282
|
+
var import_common26 = require("@nestjs/common");
|
|
5283
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4653
5284
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4654
5285
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4655
5286
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4662,19 +5293,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
4662
5293
|
}
|
|
4663
5294
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4664
5295
|
}
|
|
4665
|
-
__name(
|
|
4666
|
-
function
|
|
5296
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
5297
|
+
function _ts_metadata24(metadataKey, metadataValue) {
|
|
4667
5298
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4668
5299
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4669
5300
|
}
|
|
4670
5301
|
}
|
|
4671
|
-
__name(
|
|
4672
|
-
function
|
|
5302
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
5303
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4673
5304
|
return function(target, key) {
|
|
4674
5305
|
decorator(target, key, paramIndex);
|
|
4675
5306
|
};
|
|
4676
5307
|
}
|
|
4677
|
-
__name(
|
|
5308
|
+
__name(_ts_param24, "_ts_param");
|
|
4678
5309
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
4679
5310
|
static {
|
|
4680
5311
|
__name(this, "InlineAgentRunner");
|
|
@@ -4682,7 +5313,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4682
5313
|
factory;
|
|
4683
5314
|
store;
|
|
4684
5315
|
queue;
|
|
4685
|
-
logger = new
|
|
5316
|
+
logger = new import_common26.Logger(_InlineAgentRunner.name);
|
|
4686
5317
|
pending = /* @__PURE__ */ new Map();
|
|
4687
5318
|
/**
|
|
4688
5319
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -4731,18 +5362,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4731
5362
|
],
|
|
4732
5363
|
input
|
|
4733
5364
|
});
|
|
4734
|
-
void (0,
|
|
5365
|
+
void (0, import_nestjs_agent_core29.runAgentLoop)({
|
|
4735
5366
|
...deps,
|
|
4736
5367
|
day
|
|
4737
|
-
}, input, hooks).then(() => (0,
|
|
4738
|
-
if (error instanceof
|
|
5368
|
+
}, input, hooks).then(() => (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId)).catch(async (error) => {
|
|
5369
|
+
if (error instanceof import_nestjs_agent_core29.RunCancelledError) {
|
|
4739
5370
|
await this.settleCancelled(runId, input, deps);
|
|
4740
5371
|
return;
|
|
4741
5372
|
}
|
|
4742
5373
|
const message = error instanceof Error ? error.message : String(error);
|
|
4743
|
-
const code = (0,
|
|
5374
|
+
const code = (0, import_nestjs_agent_core29.agentFailureCode)(error);
|
|
4744
5375
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
4745
|
-
(0,
|
|
5376
|
+
(0, import_nestjs_agent_core29.publishAgentRunFailed)({
|
|
4746
5377
|
runId,
|
|
4747
5378
|
code,
|
|
4748
5379
|
message
|
|
@@ -4753,11 +5384,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4753
5384
|
errorCode: code,
|
|
4754
5385
|
errorMessage: message
|
|
4755
5386
|
});
|
|
4756
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
5387
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core29.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
4757
5388
|
const writer = await deps.sink.open(runId);
|
|
4758
5389
|
await this.settleQueue(writer, input, runId, "failed", message);
|
|
4759
|
-
await (0,
|
|
4760
|
-
await writer.fail((0,
|
|
5390
|
+
await (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId);
|
|
5391
|
+
await writer.fail((0, import_nestjs_agent_core29.streamFailure)(error));
|
|
4761
5392
|
}).finally(() => {
|
|
4762
5393
|
this.cancelled.delete(runId);
|
|
4763
5394
|
this.live.delete(runId);
|
|
@@ -4793,7 +5424,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4793
5424
|
for (const [key, waiter] of this.pending) {
|
|
4794
5425
|
if (key.startsWith(`${runId}:`)) {
|
|
4795
5426
|
this.pending.delete(key);
|
|
4796
|
-
waiter.reject(new
|
|
5427
|
+
waiter.reject(new import_nestjs_agent_core29.RunCancelledError());
|
|
4797
5428
|
}
|
|
4798
5429
|
}
|
|
4799
5430
|
await Promise.resolve();
|
|
@@ -4808,8 +5439,8 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4808
5439
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
4809
5440
|
const writer = await deps.sink.open(runId);
|
|
4810
5441
|
await this.settleQueue(writer, input, runId, "cancelled");
|
|
4811
|
-
await (0,
|
|
4812
|
-
await writer.write((0,
|
|
5442
|
+
await (0, import_nestjs_agent_core29.releaseThreadRun)(this.store, input.threadId, runId);
|
|
5443
|
+
await writer.write((0, import_nestjs_agent_core29.encodeStreamEvent)({
|
|
4813
5444
|
kind: "cancelled"
|
|
4814
5445
|
}));
|
|
4815
5446
|
await writer.end();
|
|
@@ -4844,7 +5475,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4844
5475
|
runId: nextRunId
|
|
4845
5476
|
}));
|
|
4846
5477
|
if (frame !== void 0) {
|
|
4847
|
-
await writer.write((0,
|
|
5478
|
+
await writer.write((0, import_nestjs_agent_core29.encodeStreamEvent)(frame));
|
|
4848
5479
|
}
|
|
4849
5480
|
} catch (failure) {
|
|
4850
5481
|
this.logger.error(`could not advance the queue of thread ${input.threadId} after run ${runId}: ${failure instanceof Error ? failure.message : String(failure)}`);
|
|
@@ -4915,7 +5546,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4915
5546
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4916
5547
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4917
5548
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4918
|
-
parallel:
|
|
5549
|
+
parallel: import_nestjs_agent_core29.settleAll,
|
|
4919
5550
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
4920
5551
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
4921
5552
|
agentName,
|
|
@@ -4966,7 +5597,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4966
5597
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
4967
5598
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
4968
5599
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
4969
|
-
parallel:
|
|
5600
|
+
parallel: import_nestjs_agent_core29.settleAll,
|
|
4970
5601
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
4971
5602
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
4972
5603
|
agentName: childName,
|
|
@@ -4999,7 +5630,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4999
5630
|
}
|
|
5000
5631
|
}), "startAgent")
|
|
5001
5632
|
};
|
|
5002
|
-
void (0,
|
|
5633
|
+
void (0, import_nestjs_agent_core29.runAgentLoop)({
|
|
5003
5634
|
...deps,
|
|
5004
5635
|
day
|
|
5005
5636
|
}, {
|
|
@@ -5013,13 +5644,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5013
5644
|
parentRunId,
|
|
5014
5645
|
deliverTo
|
|
5015
5646
|
}, hooks).catch(async (error) => {
|
|
5016
|
-
const cancelled = error instanceof
|
|
5647
|
+
const cancelled = error instanceof import_nestjs_agent_core29.RunCancelledError;
|
|
5017
5648
|
const message = error instanceof Error ? error.message : String(error);
|
|
5018
5649
|
if (!cancelled) {
|
|
5019
5650
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
5020
|
-
(0,
|
|
5651
|
+
(0, import_nestjs_agent_core29.publishAgentRunFailed)({
|
|
5021
5652
|
runId,
|
|
5022
|
-
code: (0,
|
|
5653
|
+
code: (0, import_nestjs_agent_core29.agentFailureCode)(error),
|
|
5023
5654
|
message
|
|
5024
5655
|
});
|
|
5025
5656
|
}
|
|
@@ -5027,12 +5658,12 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5027
5658
|
runId,
|
|
5028
5659
|
status: cancelled ? "cancelled" : "failed",
|
|
5029
5660
|
...cancelled ? {} : {
|
|
5030
|
-
errorCode: (0,
|
|
5661
|
+
errorCode: (0, import_nestjs_agent_core29.agentFailureCode)(error),
|
|
5031
5662
|
errorMessage: message
|
|
5032
5663
|
}
|
|
5033
5664
|
});
|
|
5034
|
-
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId,
|
|
5035
|
-
await (0,
|
|
5665
|
+
await Promise.resolve(this.store.failUnsettledToolCalls?.(runId, import_nestjs_agent_core29.RUN_ENDED_BEFORE_TOOL_CALL)).catch(() => 0);
|
|
5666
|
+
await (0, import_nestjs_agent_core29.settleUnsettledDelegation)({
|
|
5036
5667
|
store: this.store,
|
|
5037
5668
|
delivery: deliverTo,
|
|
5038
5669
|
agent: agentName,
|
|
@@ -5071,7 +5702,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5071
5702
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
5072
5703
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
5073
5704
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
5074
|
-
parallel:
|
|
5705
|
+
parallel: import_nestjs_agent_core29.settleAll,
|
|
5075
5706
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
5076
5707
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
5077
5708
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -5106,7 +5737,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5106
5737
|
}), "startAgent")
|
|
5107
5738
|
};
|
|
5108
5739
|
try {
|
|
5109
|
-
return await (0,
|
|
5740
|
+
return await (0, import_nestjs_agent_core29.runAgentLoop)({
|
|
5110
5741
|
...deps,
|
|
5111
5742
|
day
|
|
5112
5743
|
}, {
|
|
@@ -5125,13 +5756,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5125
5756
|
}
|
|
5126
5757
|
}
|
|
5127
5758
|
};
|
|
5128
|
-
InlineAgentRunner =
|
|
5129
|
-
(0,
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5759
|
+
InlineAgentRunner = _ts_decorate25([
|
|
5760
|
+
(0, import_common26.Injectable)(),
|
|
5761
|
+
_ts_param24(0, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_DEPS_FACTORY)),
|
|
5762
|
+
_ts_param24(1, (0, import_common26.Inject)(import_nestjs_agent_core29.AGENT_STORE)),
|
|
5763
|
+
_ts_param24(2, (0, import_common26.Optional)()),
|
|
5764
|
+
_ts_metadata24("design:type", Function),
|
|
5765
|
+
_ts_metadata24("design:paramtypes", [
|
|
5135
5766
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
5136
5767
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
5137
5768
|
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
@@ -5143,7 +5774,7 @@ function isThreadTurn(input) {
|
|
|
5143
5774
|
__name(isThreadTurn, "isThreadTurn");
|
|
5144
5775
|
|
|
5145
5776
|
// src/skills-config.ts
|
|
5146
|
-
var
|
|
5777
|
+
var import_nestjs_agent_core30 = require("@dudousxd/nestjs-agent-core");
|
|
5147
5778
|
function declaredSkillProvider(declared) {
|
|
5148
5779
|
return {
|
|
5149
5780
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -5169,7 +5800,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
5169
5800
|
declaredSkillProvider(declared)
|
|
5170
5801
|
];
|
|
5171
5802
|
return {
|
|
5172
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
5803
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core30.compositeSkillProvider)(providers),
|
|
5173
5804
|
...options.scopes !== void 0 ? {
|
|
5174
5805
|
scopes: options.scopes
|
|
5175
5806
|
} : {},
|
|
@@ -5181,7 +5812,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
5181
5812
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
5182
5813
|
|
|
5183
5814
|
// src/agent.module.ts
|
|
5184
|
-
function
|
|
5815
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
5185
5816
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5186
5817
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5187
5818
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5194,13 +5825,13 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
5194
5825
|
}
|
|
5195
5826
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5196
5827
|
}
|
|
5197
|
-
__name(
|
|
5828
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
5198
5829
|
var DEFAULT_PATH = "agent";
|
|
5199
|
-
var logger = new
|
|
5830
|
+
var logger = new import_common27.Logger("AgentModule");
|
|
5200
5831
|
function externalStoreWrapper(modules) {
|
|
5201
5832
|
for (const module2 of modules.values()) {
|
|
5202
5833
|
if (module2.metatype === AgentModule) continue;
|
|
5203
|
-
const wrapper = module2.providers.get(
|
|
5834
|
+
const wrapper = module2.providers.get(import_nestjs_agent_core31.AGENT_STORE);
|
|
5204
5835
|
if (wrapper !== void 0) return wrapper;
|
|
5205
5836
|
}
|
|
5206
5837
|
return void 0;
|
|
@@ -5231,7 +5862,7 @@ function resolveStore(options, modules) {
|
|
|
5231
5862
|
const external = externalStoreWrapper(modules);
|
|
5232
5863
|
if (external !== void 0) return forwardingStore(external);
|
|
5233
5864
|
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
|
|
5865
|
+
return new import_nestjs_agent_core31.InMemoryAgentStore();
|
|
5235
5866
|
}
|
|
5236
5867
|
__name(resolveStore, "resolveStore");
|
|
5237
5868
|
function isQuotaProvider(quota) {
|
|
@@ -5247,99 +5878,99 @@ __name(resolveCatalog, "resolveCatalog");
|
|
|
5247
5878
|
function sharedProviders(durable) {
|
|
5248
5879
|
const providers = [
|
|
5249
5880
|
{
|
|
5250
|
-
provide:
|
|
5251
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
5881
|
+
provide: import_nestjs_agent_core31.AGENT_TOOL_REGISTRY,
|
|
5882
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core31.ToolRegistry(), "useFactory")
|
|
5252
5883
|
},
|
|
5253
5884
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
5254
5885
|
{
|
|
5255
|
-
provide:
|
|
5256
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
5886
|
+
provide: import_nestjs_agent_core31.AGENT_REGISTRY,
|
|
5887
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core31.AgentRegistry(), "useFactory")
|
|
5257
5888
|
},
|
|
5258
5889
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
5259
5890
|
{
|
|
5260
|
-
provide:
|
|
5891
|
+
provide: import_nestjs_agent_core31.AGENT_PROMPT_CONTRIBUTORS,
|
|
5261
5892
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
5262
5893
|
},
|
|
5263
5894
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
5264
5895
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
5265
5896
|
{
|
|
5266
|
-
provide:
|
|
5897
|
+
provide: import_nestjs_agent_core31.AGENT_SKILL_SOURCES,
|
|
5267
5898
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
5268
5899
|
},
|
|
5269
5900
|
{
|
|
5270
5901
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
5271
5902
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
5272
5903
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
5273
|
-
provide:
|
|
5904
|
+
provide: import_nestjs_agent_core31.AGENT_SKILLS,
|
|
5274
5905
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
5275
5906
|
inject: [
|
|
5276
|
-
|
|
5277
|
-
|
|
5907
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5908
|
+
import_nestjs_agent_core31.AGENT_SKILL_SOURCES
|
|
5278
5909
|
]
|
|
5279
5910
|
},
|
|
5280
5911
|
{
|
|
5281
5912
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
5282
5913
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
5283
|
-
provide:
|
|
5914
|
+
provide: import_nestjs_agent_core31.AGENT_MEMORY,
|
|
5284
5915
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
5285
5916
|
inject: [
|
|
5286
|
-
|
|
5917
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5287
5918
|
]
|
|
5288
5919
|
},
|
|
5289
5920
|
{
|
|
5290
|
-
provide:
|
|
5921
|
+
provide: import_nestjs_agent_core31.AGENT_SINK,
|
|
5291
5922
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
5292
5923
|
inject: [
|
|
5293
|
-
|
|
5924
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5294
5925
|
]
|
|
5295
5926
|
},
|
|
5296
5927
|
{
|
|
5297
|
-
provide:
|
|
5298
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new
|
|
5928
|
+
provide: import_nestjs_agent_core31.AGENT_ROLES_POLICY,
|
|
5929
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? (options.emptyRoles === "deny" ? new import_nestjs_agent_core31.ClosedRolesPolicy(options.defaultRoles) : new import_nestjs_agent_core31.DefaultRolesPolicy(options.defaultRoles)), "useFactory"),
|
|
5299
5930
|
inject: [
|
|
5300
|
-
|
|
5931
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5301
5932
|
]
|
|
5302
5933
|
},
|
|
5303
5934
|
{
|
|
5304
|
-
provide:
|
|
5935
|
+
provide: import_nestjs_agent_core31.AGENT_ACTOR_RESOLVER,
|
|
5305
5936
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
5306
5937
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
5307
5938
|
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
5939
|
return new AnonymousActorResolver();
|
|
5309
5940
|
}, "useFactory"),
|
|
5310
5941
|
inject: [
|
|
5311
|
-
|
|
5942
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5312
5943
|
]
|
|
5313
5944
|
},
|
|
5314
5945
|
{
|
|
5315
|
-
provide:
|
|
5946
|
+
provide: import_nestjs_agent_core31.AGENT_MODEL,
|
|
5316
5947
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
5317
5948
|
inject: [
|
|
5318
|
-
|
|
5949
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5319
5950
|
]
|
|
5320
5951
|
},
|
|
5321
5952
|
{
|
|
5322
5953
|
// `quota` is either a provider of the host's own or ceilings for the built-in ledger one;
|
|
5323
5954
|
// omitted, the ledger provider still reports usage, with no ceiling to block on.
|
|
5324
|
-
provide:
|
|
5955
|
+
provide: import_nestjs_agent_core31.AGENT_QUOTA_PROVIDER,
|
|
5325
5956
|
useFactory: /* @__PURE__ */ __name((o, store) => isQuotaProvider(o.quota) ? o.quota : new LedgerQuotaProvider(store, o.quota?.limits, o.quota?.warnAt !== void 0 ? {
|
|
5326
5957
|
warnAt: o.quota.warnAt
|
|
5327
5958
|
} : {}), "useFactory"),
|
|
5328
5959
|
inject: [
|
|
5329
|
-
|
|
5330
|
-
|
|
5960
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5961
|
+
import_nestjs_agent_core31.AGENT_STORE
|
|
5331
5962
|
]
|
|
5332
5963
|
},
|
|
5333
5964
|
{
|
|
5334
|
-
provide:
|
|
5965
|
+
provide: import_nestjs_agent_core31.AGENT_MODEL_CATALOG,
|
|
5335
5966
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
5336
5967
|
inject: [
|
|
5337
|
-
|
|
5968
|
+
import_nestjs_agent_core31.AGENT_OPTIONS
|
|
5338
5969
|
]
|
|
5339
5970
|
},
|
|
5340
5971
|
AgentDepsFactory2,
|
|
5341
5972
|
{
|
|
5342
|
-
provide:
|
|
5973
|
+
provide: import_nestjs_agent_core31.AGENT_DEPS_FACTORY,
|
|
5343
5974
|
useExisting: AgentDepsFactory2
|
|
5344
5975
|
},
|
|
5345
5976
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -5356,25 +5987,27 @@ function sharedProviders(durable) {
|
|
|
5356
5987
|
},
|
|
5357
5988
|
InlineAgentRunner,
|
|
5358
5989
|
AgentService,
|
|
5990
|
+
ActionProposalService,
|
|
5991
|
+
ActionProposalWorkerService,
|
|
5359
5992
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
5360
5993
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
5361
5994
|
AgentApprovalPortAdapter,
|
|
5362
5995
|
{
|
|
5363
|
-
provide:
|
|
5996
|
+
provide: import_nestjs_agent_core31.AGENT_APPROVAL_PORT,
|
|
5364
5997
|
useExisting: AgentApprovalPortAdapter
|
|
5365
5998
|
}
|
|
5366
5999
|
];
|
|
5367
6000
|
providers.push({
|
|
5368
|
-
provide:
|
|
6001
|
+
provide: import_nestjs_agent_core31.AGENT_STORE,
|
|
5369
6002
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
5370
6003
|
inject: [
|
|
5371
|
-
|
|
6004
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5372
6005
|
import_core4.ModulesContainer
|
|
5373
6006
|
]
|
|
5374
6007
|
});
|
|
5375
6008
|
if (durable) {
|
|
5376
6009
|
providers.push({
|
|
5377
|
-
provide:
|
|
6010
|
+
provide: import_nestjs_agent_core31.AGENT_RUNNER,
|
|
5378
6011
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
5379
6012
|
if (durableRunner === void 0) {
|
|
5380
6013
|
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 +6016,14 @@ function sharedProviders(durable) {
|
|
|
5383
6016
|
}, "useFactory"),
|
|
5384
6017
|
inject: [
|
|
5385
6018
|
{
|
|
5386
|
-
token:
|
|
6019
|
+
token: import_nestjs_agent_core31.AGENT_DURABLE_RUNNER,
|
|
5387
6020
|
optional: true
|
|
5388
6021
|
}
|
|
5389
6022
|
]
|
|
5390
6023
|
});
|
|
5391
6024
|
} else {
|
|
5392
6025
|
providers.push({
|
|
5393
|
-
provide:
|
|
6026
|
+
provide: import_nestjs_agent_core31.AGENT_RUNNER,
|
|
5394
6027
|
useExisting: InlineAgentRunner
|
|
5395
6028
|
});
|
|
5396
6029
|
}
|
|
@@ -5399,30 +6032,33 @@ function sharedProviders(durable) {
|
|
|
5399
6032
|
__name(sharedProviders, "sharedProviders");
|
|
5400
6033
|
function exportsFor() {
|
|
5401
6034
|
return [
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
6035
|
+
import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
6036
|
+
import_nestjs_agent_core31.AGENT_TOOL_REGISTRY,
|
|
6037
|
+
import_nestjs_agent_core31.AGENT_REGISTRY,
|
|
6038
|
+
import_nestjs_agent_core31.AGENT_SINK,
|
|
6039
|
+
import_nestjs_agent_core31.AGENT_ROLES_POLICY,
|
|
6040
|
+
import_nestjs_agent_core31.AGENT_ACTOR_RESOLVER,
|
|
6041
|
+
import_nestjs_agent_core31.AGENT_MODEL,
|
|
6042
|
+
import_nestjs_agent_core31.AGENT_STORE,
|
|
6043
|
+
import_nestjs_agent_core31.AGENT_MODEL_CATALOG,
|
|
6044
|
+
import_nestjs_agent_core31.AGENT_QUOTA_PROVIDER,
|
|
6045
|
+
import_nestjs_agent_core31.AGENT_PROMPT_CONTRIBUTORS,
|
|
6046
|
+
import_nestjs_agent_core31.AGENT_SKILLS,
|
|
6047
|
+
import_nestjs_agent_core31.AGENT_MEMORY,
|
|
6048
|
+
import_nestjs_agent_core31.AGENT_DEPS_FACTORY,
|
|
5416
6049
|
AgentDepsFactory2,
|
|
5417
6050
|
AgentService,
|
|
6051
|
+
ActionProposalService,
|
|
6052
|
+
ActionProposalWorkerService,
|
|
5418
6053
|
ChatQueueService,
|
|
5419
6054
|
AGENT_CHAT_QUEUE,
|
|
5420
6055
|
InlineAgentRunner,
|
|
5421
|
-
|
|
6056
|
+
import_nestjs_agent_core31.AGENT_APPROVAL_PORT
|
|
5422
6057
|
];
|
|
5423
6058
|
}
|
|
5424
6059
|
__name(exportsFor, "exportsFor");
|
|
5425
6060
|
var BASE_CONTROLLERS = [
|
|
6061
|
+
ActionProposalController,
|
|
5426
6062
|
ChatController,
|
|
5427
6063
|
QueueController,
|
|
5428
6064
|
ThreadsController,
|
|
@@ -5495,7 +6131,7 @@ var AgentModule = class _AgentModule {
|
|
|
5495
6131
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5496
6132
|
providers: [
|
|
5497
6133
|
{
|
|
5498
|
-
provide:
|
|
6134
|
+
provide: import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5499
6135
|
useValue: options
|
|
5500
6136
|
},
|
|
5501
6137
|
...sharedProviders(options.durable ?? false),
|
|
@@ -5519,7 +6155,7 @@ var AgentModule = class _AgentModule {
|
|
|
5519
6155
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5520
6156
|
providers: [
|
|
5521
6157
|
{
|
|
5522
|
-
provide:
|
|
6158
|
+
provide: import_nestjs_agent_core31.AGENT_OPTIONS,
|
|
5523
6159
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
5524
6160
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
5525
6161
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -5541,16 +6177,16 @@ var AgentModule = class _AgentModule {
|
|
|
5541
6177
|
};
|
|
5542
6178
|
}
|
|
5543
6179
|
};
|
|
5544
|
-
AgentModule =
|
|
5545
|
-
(0,
|
|
5546
|
-
(0,
|
|
6180
|
+
AgentModule = _ts_decorate26([
|
|
6181
|
+
(0, import_common27.Global)(),
|
|
6182
|
+
(0, import_common27.Module)({})
|
|
5547
6183
|
], AgentModule);
|
|
5548
6184
|
|
|
5549
6185
|
// src/ag-ui/ag-ui.adapter.ts
|
|
5550
|
-
var
|
|
6186
|
+
var import_nestjs_agent_core32 = require("@dudousxd/nestjs-agent-core");
|
|
5551
6187
|
var import_ag_ui = require("@dudousxd/nestjs-agent-core/ag-ui");
|
|
5552
|
-
var
|
|
5553
|
-
function
|
|
6188
|
+
var import_common28 = require("@nestjs/common");
|
|
6189
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
5554
6190
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5555
6191
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5556
6192
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5563,22 +6199,22 @@ function _ts_decorate23(decorators, target, key, desc) {
|
|
|
5563
6199
|
}
|
|
5564
6200
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5565
6201
|
}
|
|
5566
|
-
__name(
|
|
5567
|
-
function
|
|
6202
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
6203
|
+
function _ts_metadata25(metadataKey, metadataValue) {
|
|
5568
6204
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5569
6205
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5570
6206
|
}
|
|
5571
6207
|
}
|
|
5572
|
-
__name(
|
|
5573
|
-
function
|
|
6208
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
6209
|
+
function _ts_param25(paramIndex, decorator) {
|
|
5574
6210
|
return function(target, key) {
|
|
5575
6211
|
decorator(target, key, paramIndex);
|
|
5576
6212
|
};
|
|
5577
6213
|
}
|
|
5578
|
-
__name(
|
|
6214
|
+
__name(_ts_param25, "_ts_param");
|
|
5579
6215
|
var AG_UI_VIA = "ag-ui";
|
|
5580
6216
|
function invalid(code, message) {
|
|
5581
|
-
return new
|
|
6217
|
+
return new import_common28.BadRequestException({
|
|
5582
6218
|
statusCode: 400,
|
|
5583
6219
|
code,
|
|
5584
6220
|
message
|
|
@@ -5657,7 +6293,27 @@ var AgUiRunHandler = class {
|
|
|
5657
6293
|
warnings.push(...turn.dropped);
|
|
5658
6294
|
const owner = await this.agent.threadOwner(input.threadId);
|
|
5659
6295
|
if (owner !== null && owner !== actor.id) {
|
|
5660
|
-
throw new
|
|
6296
|
+
throw new import_common28.ForbiddenException("thread belongs to another actor");
|
|
6297
|
+
}
|
|
6298
|
+
if (owner !== null && turn.media.length === 0) {
|
|
6299
|
+
const decision = await this.agent.handleTextDecision(input.threadId, actor, turn.text);
|
|
6300
|
+
if ("proposalDecision" in decision) {
|
|
6301
|
+
res.status(200);
|
|
6302
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
6303
|
+
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
6304
|
+
res.flushHeaders();
|
|
6305
|
+
for (const event of [
|
|
6306
|
+
...warningEvents(warnings),
|
|
6307
|
+
...(0, import_ag_ui.actionProposalDecisionEvents)({
|
|
6308
|
+
threadId: input.threadId,
|
|
6309
|
+
runId: input.runId,
|
|
6310
|
+
text: decision.text,
|
|
6311
|
+
proposalDecision: decision.proposalDecision
|
|
6312
|
+
})
|
|
6313
|
+
]) res.write((0, import_ag_ui.agUiSse)(event));
|
|
6314
|
+
res.end();
|
|
6315
|
+
return;
|
|
6316
|
+
}
|
|
5661
6317
|
}
|
|
5662
6318
|
const refs = await this.stage(actor, turn.media, warnings);
|
|
5663
6319
|
if (turn.text.trim().length === 0 && refs.length === 0) {
|
|
@@ -5687,6 +6343,9 @@ var AgUiRunHandler = class {
|
|
|
5687
6343
|
...forwarded.model !== void 0 ? {
|
|
5688
6344
|
model: forwarded.model
|
|
5689
6345
|
} : {},
|
|
6346
|
+
...forwarded.uiCapabilities !== void 0 ? {
|
|
6347
|
+
uiCapabilities: forwarded.uiCapabilities
|
|
6348
|
+
} : {},
|
|
5690
6349
|
...pageContext !== void 0 ? {
|
|
5691
6350
|
pageContext
|
|
5692
6351
|
} : {},
|
|
@@ -5831,29 +6490,29 @@ function agUiAdapter(options = {}) {
|
|
|
5831
6490
|
return this.handle(req, res, body);
|
|
5832
6491
|
}
|
|
5833
6492
|
};
|
|
5834
|
-
|
|
5835
|
-
(0,
|
|
5836
|
-
(0,
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
6493
|
+
_ts_decorate27([
|
|
6494
|
+
(0, import_common28.Post)(path),
|
|
6495
|
+
(0, import_common28.HttpCode)(200),
|
|
6496
|
+
_ts_param25(0, (0, import_common28.Req)()),
|
|
6497
|
+
_ts_param25(1, (0, import_common28.Res)()),
|
|
6498
|
+
_ts_param25(2, (0, import_common28.Body)()),
|
|
6499
|
+
_ts_metadata25("design:type", Function),
|
|
6500
|
+
_ts_metadata25("design:paramtypes", [
|
|
5842
6501
|
typeof Request === "undefined" ? Object : Request,
|
|
5843
6502
|
typeof Response === "undefined" ? Object : Response,
|
|
5844
6503
|
Object
|
|
5845
6504
|
]),
|
|
5846
|
-
|
|
6505
|
+
_ts_metadata25("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5847
6506
|
], AgUiController.prototype, "run", null);
|
|
5848
|
-
AgUiController =
|
|
5849
|
-
(0,
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
6507
|
+
AgUiController = _ts_decorate27([
|
|
6508
|
+
(0, import_common28.Controller)(),
|
|
6509
|
+
_ts_param25(0, (0, import_common28.Inject)(AgentService)),
|
|
6510
|
+
_ts_param25(1, (0, import_common28.Inject)(import_nestjs_agent_core32.AGENT_ACTOR_RESOLVER)),
|
|
6511
|
+
_ts_param25(2, (0, import_common28.Inject)(import_nestjs_agent_core32.AGENT_OPTIONS)),
|
|
6512
|
+
_ts_param25(3, (0, import_common28.Optional)()),
|
|
6513
|
+
_ts_param25(3, (0, import_common28.Inject)(import_nestjs_agent_core32.AGENT_ATTACHMENT_STAGING)),
|
|
6514
|
+
_ts_metadata25("design:type", Function),
|
|
6515
|
+
_ts_metadata25("design:paramtypes", [
|
|
5857
6516
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
5858
6517
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
5859
6518
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -5870,7 +6529,7 @@ function agUiAdapter(options = {}) {
|
|
|
5870
6529
|
__name(agUiAdapter, "agUiAdapter");
|
|
5871
6530
|
|
|
5872
6531
|
// src/resolver/header-actor-resolver.ts
|
|
5873
|
-
var
|
|
6532
|
+
var import_common29 = require("@nestjs/common");
|
|
5874
6533
|
function readHeader(req, name) {
|
|
5875
6534
|
if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
|
|
5876
6535
|
const { headers } = req;
|
|
@@ -5886,7 +6545,7 @@ var HeaderActorResolver = class {
|
|
|
5886
6545
|
resolve(req) {
|
|
5887
6546
|
const id = readHeader(req, "x-actor-id");
|
|
5888
6547
|
if (id === void 0 || id.length === 0) {
|
|
5889
|
-
throw new
|
|
6548
|
+
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
6549
|
}
|
|
5891
6550
|
const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
|
|
5892
6551
|
const tenantRef = readHeader(req, "x-tenant-ref");
|
|
@@ -5901,7 +6560,7 @@ var HeaderActorResolver = class {
|
|
|
5901
6560
|
};
|
|
5902
6561
|
|
|
5903
6562
|
// src/resolver/request-user-actor-resolver.ts
|
|
5904
|
-
var
|
|
6563
|
+
var import_common30 = require("@nestjs/common");
|
|
5905
6564
|
function field(user, ...names) {
|
|
5906
6565
|
for (const name of names) {
|
|
5907
6566
|
const value = user[name];
|
|
@@ -5913,7 +6572,7 @@ __name(field, "field");
|
|
|
5913
6572
|
function defaultRequestUserMapper(user) {
|
|
5914
6573
|
const id = field(user, "id", "sub", "_id", "userId");
|
|
5915
6574
|
if (id === void 0) {
|
|
5916
|
-
throw new
|
|
6575
|
+
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
6576
|
}
|
|
5918
6577
|
const rawRoles = field(user, "roles", "role");
|
|
5919
6578
|
const roles = Array.isArray(rawRoles) ? rawRoles.map(String) : typeof rawRoles === "string" ? [
|
|
@@ -5934,7 +6593,7 @@ function requestUserActorResolver(map) {
|
|
|
5934
6593
|
async resolve(req) {
|
|
5935
6594
|
const user = typeof req === "object" && req !== null ? req.user : void 0;
|
|
5936
6595
|
if (user === void 0 || user === null || user === false) {
|
|
5937
|
-
throw new
|
|
6596
|
+
throw new import_common30.UnauthorizedException("Sign in to use the agent.");
|
|
5938
6597
|
}
|
|
5939
6598
|
if (map !== void 0) return map(user, req);
|
|
5940
6599
|
return defaultRequestUserMapper(user);
|
|
@@ -5952,6 +6611,9 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
5952
6611
|
AGENT_TOOL_BRAND,
|
|
5953
6612
|
AI_TOOL_METADATA,
|
|
5954
6613
|
ATTACHMENT_PAGE_SIZE,
|
|
6614
|
+
ActionProposalController,
|
|
6615
|
+
ActionProposalService,
|
|
6616
|
+
ActionProposalWorkerService,
|
|
5955
6617
|
AgUiRunHandler,
|
|
5956
6618
|
Agent,
|
|
5957
6619
|
AgentApprovalPortAdapter,
|