@dudousxd/nestjs-agent 1.20.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/{chat-queue.service-C0hr7dqx.d.cts → chat-queue.service-CTyX_yNr.d.ts} +48 -3
- package/dist/{chat-queue.service-C0hr7dqx.d.ts → chat-queue.service-Dx9OsjcF.d.cts} +48 -3
- package/dist/durable/index.cjs +1662 -839
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +3 -1
- package/dist/durable/index.d.ts +3 -1
- package/dist/durable/index.js +1395 -572
- package/dist/durable/index.js.map +1 -1
- package/dist/genui/index.cjs +1 -0
- package/dist/genui/index.cjs.map +1 -1
- package/dist/genui/index.d.cts +1 -1
- package/dist/genui/index.d.ts +1 -1
- package/dist/genui/index.js +1 -0
- package/dist/genui/index.js.map +1 -1
- package/dist/index.cjs +1647 -831
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -9
- package/dist/index.d.ts +140 -9
- package/dist/index.js +1417 -605
- package/dist/index.js.map +1 -1
- package/dist/sink-redis/index.cjs +7 -2
- package/dist/sink-redis/index.cjs.map +1 -1
- package/dist/sink-redis/index.d.cts +6 -3
- package/dist/sink-redis/index.d.ts +6 -3
- package/dist/sink-redis/index.js +7 -2
- package/dist/sink-redis/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2,14 +2,61 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/agent.module.ts
|
|
5
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
6
|
-
import { Global, Logger as
|
|
5
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER14, AGENT_APPROVAL_PORT, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY7, AGENT_DURABLE_RUNNER, AGENT_MEMORY as AGENT_MEMORY3, AGENT_MODEL as AGENT_MODEL2, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG3, AGENT_OPTIONS as AGENT_OPTIONS9, AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS3, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER3, AGENT_REGISTRY as AGENT_REGISTRY6, AGENT_ROLES_POLICY as AGENT_ROLES_POLICY2, AGENT_RUNNER as AGENT_RUNNER2, AGENT_SINK as AGENT_SINK3, AGENT_SKILLS as AGENT_SKILLS3, AGENT_SKILL_SOURCES as AGENT_SKILL_SOURCES2, AGENT_STORE as AGENT_STORE7, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY3, AgentRegistry as AgentRegistry6, ClosedRolesPolicy, DefaultRolesPolicy, InMemoryAgentStore, ToolRegistry as ToolRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
6
|
+
import { Global, Logger as Logger7, Module as Module2 } from "@nestjs/common";
|
|
7
7
|
import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
|
|
8
8
|
|
|
9
9
|
// src/agent-deps.factory.ts
|
|
10
|
+
import { assertIndependentActionCapabilities } from "@dudousxd/nestjs-agent-core";
|
|
10
11
|
import { AGENT_MEMORY, AGENT_MODEL, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_REGISTRY, AGENT_ROLES_POLICY, AGENT_SINK, AGENT_SKILLS, AGENT_STORE, AGENT_TOOL_REGISTRY, AgentRegistry as AgentRegistry2, ToolRegistry as ToolRegistry2, findPersona, intersectAllowLists, normalizeDelegation, personaCatalogEntry, resolvePersonaAlias, summarizeWithModel, windowHistory } from "@dudousxd/nestjs-agent-core";
|
|
11
12
|
import { AGENT_OPTIONS } from "@dudousxd/nestjs-agent-core";
|
|
12
|
-
import { BadRequestException, Inject, Injectable, Optional } from "@nestjs/common";
|
|
13
|
+
import { BadRequestException, Inject as Inject2, Injectable, Optional } from "@nestjs/common";
|
|
14
|
+
|
|
15
|
+
// src/genui/agent-genui.module.ts
|
|
16
|
+
import { defineCatalog, genuiTools } from "@dudousxd/nestjs-agent-core/genui";
|
|
17
|
+
import { Inject, Module } from "@nestjs/common";
|
|
18
|
+
|
|
19
|
+
// src/functional-tool.ts
|
|
20
|
+
import { createFunctionalTool } from "@dudousxd/nestjs-agent-core";
|
|
21
|
+
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
22
|
+
function brand(tool) {
|
|
23
|
+
return {
|
|
24
|
+
[AGENT_TOOL_BRAND]: true,
|
|
25
|
+
spec: tool.spec,
|
|
26
|
+
handler: tool.handler
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
__name(brand, "brand");
|
|
30
|
+
function isBrandedFunctionalTool(value) {
|
|
31
|
+
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
32
|
+
}
|
|
33
|
+
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
34
|
+
function provideAgentTool(factoryOrTool, inject) {
|
|
35
|
+
const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
|
|
36
|
+
if (typeof factoryOrTool === "function") {
|
|
37
|
+
return {
|
|
38
|
+
provide,
|
|
39
|
+
useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
|
|
40
|
+
inject: inject ?? []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
provide,
|
|
45
|
+
useValue: brand(factoryOrTool)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
__name(provideAgentTool, "provideAgentTool");
|
|
49
|
+
function provideAgentTools(factory, inject) {
|
|
50
|
+
return {
|
|
51
|
+
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
52
|
+
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
53
|
+
inject: inject ?? []
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
__name(provideAgentTools, "provideAgentTools");
|
|
57
|
+
var defineTool = createFunctionalTool;
|
|
58
|
+
|
|
59
|
+
// src/genui/agent-genui.module.ts
|
|
13
60
|
function _ts_decorate(decorators, target, key, desc) {
|
|
14
61
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
62
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -24,6 +71,124 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
24
71
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
72
|
}
|
|
26
73
|
__name(_ts_decorate, "_ts_decorate");
|
|
74
|
+
var GENUI_CATALOG = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-catalog");
|
|
75
|
+
var GENUI_OPTIONS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:genui-options");
|
|
76
|
+
var GenuiCatalogResolver = class {
|
|
77
|
+
static {
|
|
78
|
+
__name(this, "GenuiCatalogResolver");
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
function resolverProviders(resolver) {
|
|
82
|
+
if (resolver === void 0) return [];
|
|
83
|
+
return [
|
|
84
|
+
typeof resolver === "function" ? {
|
|
85
|
+
provide: GenuiCatalogResolver,
|
|
86
|
+
useClass: resolver
|
|
87
|
+
} : {
|
|
88
|
+
provide: GenuiCatalogResolver,
|
|
89
|
+
useValue: resolver
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
__name(resolverProviders, "resolverProviders");
|
|
94
|
+
function toolOptions(options, resolver) {
|
|
95
|
+
const { catalog: _catalog, ...rest } = options;
|
|
96
|
+
return {
|
|
97
|
+
...rest,
|
|
98
|
+
...resolver !== void 0 ? {
|
|
99
|
+
resolveCatalog: /* @__PURE__ */ __name((scope) => resolver.resolve(scope), "resolveCatalog")
|
|
100
|
+
} : {}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
__name(toolOptions, "toolOptions");
|
|
104
|
+
function coreProviders(resolver) {
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
provide: GENUI_CATALOG,
|
|
108
|
+
useFactory: /* @__PURE__ */ __name((options) => options.catalog ?? defineCatalog([]), "useFactory"),
|
|
109
|
+
inject: [
|
|
110
|
+
GENUI_OPTIONS
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
...resolverProviders(resolver),
|
|
114
|
+
// The generated tools, registered by the agent module's discovery like any `provideAgentTool`.
|
|
115
|
+
// Built from the injected catalog, so `overrideProvider(GENUI_CATALOG)` changes them too.
|
|
116
|
+
provideAgentTools((options, catalog, perRequest) => genuiTools(catalog, toolOptions(options, perRequest)), [
|
|
117
|
+
GENUI_OPTIONS,
|
|
118
|
+
GENUI_CATALOG,
|
|
119
|
+
{
|
|
120
|
+
token: GenuiCatalogResolver,
|
|
121
|
+
optional: true
|
|
122
|
+
}
|
|
123
|
+
])
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
__name(coreProviders, "coreProviders");
|
|
127
|
+
var EXPORTS = [
|
|
128
|
+
GENUI_CATALOG,
|
|
129
|
+
GENUI_OPTIONS
|
|
130
|
+
];
|
|
131
|
+
var AgentGenuiModule = class _AgentGenuiModule {
|
|
132
|
+
static {
|
|
133
|
+
__name(this, "AgentGenuiModule");
|
|
134
|
+
}
|
|
135
|
+
static forRoot(options = {}) {
|
|
136
|
+
const { resolver, ...rest } = options;
|
|
137
|
+
return {
|
|
138
|
+
module: _AgentGenuiModule,
|
|
139
|
+
global: true,
|
|
140
|
+
providers: [
|
|
141
|
+
{
|
|
142
|
+
provide: GENUI_OPTIONS,
|
|
143
|
+
useValue: rest
|
|
144
|
+
},
|
|
145
|
+
...coreProviders(resolver)
|
|
146
|
+
],
|
|
147
|
+
exports: resolver === void 0 ? EXPORTS : [
|
|
148
|
+
...EXPORTS,
|
|
149
|
+
GenuiCatalogResolver
|
|
150
|
+
]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
static forRootAsync(options) {
|
|
154
|
+
return {
|
|
155
|
+
module: _AgentGenuiModule,
|
|
156
|
+
global: true,
|
|
157
|
+
imports: options.imports ?? [],
|
|
158
|
+
providers: [
|
|
159
|
+
{
|
|
160
|
+
provide: GENUI_OPTIONS,
|
|
161
|
+
useFactory: options.useFactory,
|
|
162
|
+
inject: options.inject ?? []
|
|
163
|
+
},
|
|
164
|
+
...coreProviders(options.resolver)
|
|
165
|
+
],
|
|
166
|
+
exports: options.resolver === void 0 ? EXPORTS : [
|
|
167
|
+
...EXPORTS,
|
|
168
|
+
GenuiCatalogResolver
|
|
169
|
+
]
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
AgentGenuiModule = _ts_decorate([
|
|
174
|
+
Module({})
|
|
175
|
+
], AgentGenuiModule);
|
|
176
|
+
|
|
177
|
+
// src/agent-deps.factory.ts
|
|
178
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
179
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
180
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
181
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
182
|
+
} else {
|
|
183
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
184
|
+
if (d = decorators[i]) {
|
|
185
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
190
|
+
}
|
|
191
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
27
192
|
function _ts_metadata(metadataKey, metadataValue) {
|
|
28
193
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
29
194
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
@@ -56,7 +221,9 @@ var AgentDepsFactory2 = class {
|
|
|
56
221
|
pricingStore;
|
|
57
222
|
skills;
|
|
58
223
|
memory;
|
|
59
|
-
|
|
224
|
+
uiCatalog;
|
|
225
|
+
uiCatalogResolver;
|
|
226
|
+
constructor(options, model, store, sink, rolesPolicy, registry, agents, promptContributors, pricingStore, skills, memory, uiCatalog, uiCatalogResolver) {
|
|
60
227
|
this.options = options;
|
|
61
228
|
this.model = model;
|
|
62
229
|
this.store = store;
|
|
@@ -68,6 +235,9 @@ var AgentDepsFactory2 = class {
|
|
|
68
235
|
this.pricingStore = pricingStore;
|
|
69
236
|
this.skills = skills;
|
|
70
237
|
this.memory = memory;
|
|
238
|
+
this.uiCatalog = uiCatalog;
|
|
239
|
+
this.uiCatalogResolver = uiCatalogResolver;
|
|
240
|
+
if (options.actionApprovalMode === "independent") assertIndependentActionCapabilities(store, options.backgroundActorResolver);
|
|
71
241
|
}
|
|
72
242
|
/** The turn's memory seam, shared with the read-back endpoint. Undefined → memory is not configured. */
|
|
73
243
|
memoryConfig() {
|
|
@@ -156,6 +326,18 @@ var AgentDepsFactory2 = class {
|
|
|
156
326
|
}
|
|
157
327
|
return definition?.defaultPersona;
|
|
158
328
|
}
|
|
329
|
+
forProposal(proposal, _actor) {
|
|
330
|
+
const name = proposal.executionContext?.agentName;
|
|
331
|
+
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`);
|
|
332
|
+
const deps = this.forAgent(name);
|
|
333
|
+
const id = proposal.executionContext?.persona;
|
|
334
|
+
if (id !== void 0) {
|
|
335
|
+
const persona = deps.personas?.find((persona2) => persona2.id === id);
|
|
336
|
+
if (!persona) throw new Error(`Recorded persona ${id} no longer exists`);
|
|
337
|
+
return this.withPersona(deps, persona);
|
|
338
|
+
}
|
|
339
|
+
return deps;
|
|
340
|
+
}
|
|
159
341
|
forAgent(agentName) {
|
|
160
342
|
const name = agentName ?? this.defaultAgentName();
|
|
161
343
|
if (agentName !== void 0 && !this.agents.has(agentName)) {
|
|
@@ -174,12 +356,27 @@ var AgentDepsFactory2 = class {
|
|
|
174
356
|
return {
|
|
175
357
|
model: this.model,
|
|
176
358
|
store: this.store,
|
|
359
|
+
...this.options.actionApprovalMode !== void 0 ? {
|
|
360
|
+
actionApprovalMode: this.options.actionApprovalMode
|
|
361
|
+
} : {},
|
|
177
362
|
sink: this.sink,
|
|
178
363
|
rolesPolicy: this.rolesPolicy,
|
|
179
364
|
...this.options.approvalPolicy !== void 0 ? {
|
|
180
365
|
approvalPolicy: this.options.approvalPolicy
|
|
181
366
|
} : {},
|
|
182
367
|
registry: this.registry,
|
|
368
|
+
...this.uiCatalog !== void 0 || this.uiCatalogResolver !== void 0 ? {
|
|
369
|
+
resolveUiCatalog: /* @__PURE__ */ __name((scope) => {
|
|
370
|
+
const catalog = this.uiCatalogResolver?.resolve({
|
|
371
|
+
...scope,
|
|
372
|
+
...scope.actor.tenantRef !== void 0 ? {
|
|
373
|
+
tenant: scope.actor.tenantRef
|
|
374
|
+
} : {}
|
|
375
|
+
}) ?? this.uiCatalog;
|
|
376
|
+
if (!catalog) throw new Error("UI catalog unavailable");
|
|
377
|
+
return catalog;
|
|
378
|
+
}, "resolveUiCatalog")
|
|
379
|
+
} : {},
|
|
183
380
|
promptContributors: this.promptContributors,
|
|
184
381
|
systemPrompt: definition?.systemPrompt ?? this.options.systemPrompt ?? "You are a helpful assistant.",
|
|
185
382
|
maxSteps: definition?.maxSteps ?? 8,
|
|
@@ -330,22 +527,25 @@ var AgentDepsFactory2 = class {
|
|
|
330
527
|
return void 0;
|
|
331
528
|
}
|
|
332
529
|
};
|
|
333
|
-
AgentDepsFactory2 =
|
|
530
|
+
AgentDepsFactory2 = _ts_decorate2([
|
|
334
531
|
Injectable(),
|
|
335
|
-
_ts_param(0,
|
|
336
|
-
_ts_param(1,
|
|
337
|
-
_ts_param(2,
|
|
338
|
-
_ts_param(3,
|
|
339
|
-
_ts_param(4,
|
|
340
|
-
_ts_param(5,
|
|
341
|
-
_ts_param(6,
|
|
342
|
-
_ts_param(7,
|
|
532
|
+
_ts_param(0, Inject2(AGENT_OPTIONS)),
|
|
533
|
+
_ts_param(1, Inject2(AGENT_MODEL)),
|
|
534
|
+
_ts_param(2, Inject2(AGENT_STORE)),
|
|
535
|
+
_ts_param(3, Inject2(AGENT_SINK)),
|
|
536
|
+
_ts_param(4, Inject2(AGENT_ROLES_POLICY)),
|
|
537
|
+
_ts_param(5, Inject2(AGENT_TOOL_REGISTRY)),
|
|
538
|
+
_ts_param(6, Inject2(AGENT_REGISTRY)),
|
|
539
|
+
_ts_param(7, Inject2(AGENT_PROMPT_CONTRIBUTORS)),
|
|
343
540
|
_ts_param(8, Optional()),
|
|
344
|
-
_ts_param(8,
|
|
541
|
+
_ts_param(8, Inject2(AGENT_PRICING_STORE)),
|
|
345
542
|
_ts_param(9, Optional()),
|
|
346
|
-
_ts_param(9,
|
|
543
|
+
_ts_param(9, Inject2(AGENT_SKILLS)),
|
|
347
544
|
_ts_param(10, Optional()),
|
|
348
|
-
_ts_param(10,
|
|
545
|
+
_ts_param(10, Inject2(AGENT_MEMORY)),
|
|
546
|
+
_ts_param(11, Optional()),
|
|
547
|
+
_ts_param(11, Inject2(GENUI_CATALOG)),
|
|
548
|
+
_ts_param(12, Optional()),
|
|
349
549
|
_ts_metadata("design:type", Function),
|
|
350
550
|
_ts_metadata("design:paramtypes", [
|
|
351
551
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -358,13 +558,15 @@ AgentDepsFactory2 = _ts_decorate([
|
|
|
358
558
|
Array,
|
|
359
559
|
Object,
|
|
360
560
|
Object,
|
|
361
|
-
Object
|
|
561
|
+
Object,
|
|
562
|
+
typeof Catalog === "undefined" ? Object : Catalog,
|
|
563
|
+
typeof GenuiCatalogResolver === "undefined" ? Object : GenuiCatalogResolver
|
|
362
564
|
])
|
|
363
565
|
], AgentDepsFactory2);
|
|
364
566
|
|
|
365
567
|
// src/agent.service.ts
|
|
366
|
-
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_MODEL_CATALOG, AGENT_OPTIONS as
|
|
367
|
-
import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException, GoneException, HttpException, HttpStatus, Inject as
|
|
568
|
+
import { AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING2, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY2, AGENT_MODEL_CATALOG, AGENT_OPTIONS as AGENT_OPTIONS4, AGENT_QUOTA_PROVIDER as AGENT_QUOTA_PROVIDER2, AGENT_RUNNER, AGENT_STORE as AGENT_STORE4, REQUESTER_APPROVER, findCatalogModel, mayDecideApproval as mayDecideApproval2, readElicitationQuestions, settleDeadRun, validateElicitationAnswer } from "@dudousxd/nestjs-agent-core";
|
|
569
|
+
import { BadRequestException as BadRequestException2, ConflictException as ConflictException2, ForbiddenException as ForbiddenException2, GoneException, HttpException, HttpStatus, Inject as Inject5, Injectable as Injectable4, NotFoundException as NotFoundException2, NotImplementedException as NotImplementedException3, Optional as Optional3 } from "@nestjs/common";
|
|
368
570
|
|
|
369
571
|
// src/agent-deps.ts
|
|
370
572
|
function utcDay(date = /* @__PURE__ */ new Date()) {
|
|
@@ -388,9 +590,208 @@ function childSinkWriter(writer) {
|
|
|
388
590
|
}
|
|
389
591
|
__name(childSinkWriter, "childSinkWriter");
|
|
390
592
|
|
|
593
|
+
// src/proposals/action-proposal.service.ts
|
|
594
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS2, AGENT_STORE as AGENT_STORE2, DEFAULT_TEXT_ACTION_PROPOSAL_REPLIES, DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY, mayDecideApproval, parseTextActionProposalCommand, resolveTextActionProposalDecision, textActionProposalReply, toActionProposalMutationView, toActionProposalView } from "@dudousxd/nestjs-agent-core";
|
|
595
|
+
import { ForbiddenException, Inject as Inject3, Injectable as Injectable2, NotFoundException, NotImplementedException } from "@nestjs/common";
|
|
596
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
597
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
598
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
599
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
600
|
+
} else {
|
|
601
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
602
|
+
if (d = decorators[i]) {
|
|
603
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
608
|
+
}
|
|
609
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
610
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
611
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
612
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
616
|
+
function _ts_param2(paramIndex, decorator) {
|
|
617
|
+
return function(target, key) {
|
|
618
|
+
decorator(target, key, paramIndex);
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
__name(_ts_param2, "_ts_param");
|
|
622
|
+
var ActionProposalService = class {
|
|
623
|
+
static {
|
|
624
|
+
__name(this, "ActionProposalService");
|
|
625
|
+
}
|
|
626
|
+
store;
|
|
627
|
+
options;
|
|
628
|
+
constructor(store, options) {
|
|
629
|
+
this.store = store;
|
|
630
|
+
this.options = options;
|
|
631
|
+
const text = options.actionProposalText;
|
|
632
|
+
this.vocabulary = {
|
|
633
|
+
...DEFAULT_TEXT_ACTION_PROPOSAL_VOCABULARY,
|
|
634
|
+
...text?.vocabulary
|
|
635
|
+
};
|
|
636
|
+
this.replies = {
|
|
637
|
+
...DEFAULT_TEXT_ACTION_PROPOSAL_REPLIES,
|
|
638
|
+
...text?.replies
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/** The words a text decision is made of, and what the agent answers — English unless configured. */
|
|
642
|
+
vocabulary;
|
|
643
|
+
replies;
|
|
644
|
+
capability() {
|
|
645
|
+
const store = this.store;
|
|
646
|
+
if (typeof store.getThreadActionProposalScope !== "function" || typeof store.listActionProposals !== "function") throw new NotImplementedException("Action proposals are unavailable");
|
|
647
|
+
return store;
|
|
648
|
+
}
|
|
649
|
+
async scope(threadId, actor) {
|
|
650
|
+
const scope = await this.capability().getThreadActionProposalScope(threadId);
|
|
651
|
+
if (!scope) throw new NotFoundException("Thread not found");
|
|
652
|
+
if (scope.tenantRef !== (actor.tenantRef ?? null)) throw new ForbiddenException("Wrong proposal tenant");
|
|
653
|
+
return scope;
|
|
654
|
+
}
|
|
655
|
+
mayDecide(actor, proposal) {
|
|
656
|
+
return mayDecideApproval(this.options.approvalPolicy, actor, {
|
|
657
|
+
toolCallId: proposal.originToolCallId,
|
|
658
|
+
approver: proposal.approver,
|
|
659
|
+
requesterRef: proposal.actorRef
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
async listPage(threadId, actor, query = {}) {
|
|
663
|
+
const scope = await this.scope(threadId, actor);
|
|
664
|
+
const rows = await this.capability().listActionProposals(scope, {
|
|
665
|
+
limit: 1e3,
|
|
666
|
+
...query
|
|
667
|
+
});
|
|
668
|
+
const visible = [];
|
|
669
|
+
for (const row of rows) if (scope.actorRef === actor.id || await this.mayDecide(actor, row)) visible.push(row);
|
|
670
|
+
const last = rows.at(-1);
|
|
671
|
+
return {
|
|
672
|
+
// The public view: a row carries the worker's lease token and the tool's idempotency key.
|
|
673
|
+
items: visible.map(toActionProposalView),
|
|
674
|
+
...rows.length === 1e3 && last ? {
|
|
675
|
+
next: {
|
|
676
|
+
createdAt: last.createdAt,
|
|
677
|
+
id: last.id
|
|
678
|
+
}
|
|
679
|
+
} : {}
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
async list(threadId, actor) {
|
|
683
|
+
return (await this.listPage(threadId, actor)).items;
|
|
684
|
+
}
|
|
685
|
+
async decide(threadId, proposalId, actor, command) {
|
|
686
|
+
const scope = await this.scope(threadId, actor);
|
|
687
|
+
const proposal = await this.capability().getActionProposal(scope, proposalId);
|
|
688
|
+
if (!proposal) throw new NotFoundException("Proposal not found");
|
|
689
|
+
if (!await this.mayDecide(actor, proposal)) throw new ForbiddenException("May not decide this proposal");
|
|
690
|
+
const result = await this.capability().decideActionProposal(scope, proposalId, {
|
|
691
|
+
decision: command.decision,
|
|
692
|
+
actorRef: actor.id,
|
|
693
|
+
via: command.via ?? "web",
|
|
694
|
+
...command.remember !== void 0 ? {
|
|
695
|
+
remember: command.remember
|
|
696
|
+
} : {},
|
|
697
|
+
...command.reason !== void 0 ? {
|
|
698
|
+
reason: command.reason
|
|
699
|
+
} : {}
|
|
700
|
+
});
|
|
701
|
+
return toActionProposalMutationView(result);
|
|
702
|
+
}
|
|
703
|
+
async handleTextDecision(threadId, actor, text) {
|
|
704
|
+
const command = parseTextActionProposalCommand(text, this.vocabulary);
|
|
705
|
+
if (command.status === "unmatched") return command;
|
|
706
|
+
if (command.proposalId !== void 0) {
|
|
707
|
+
const result2 = await this.decide(threadId, command.proposalId, actor, {
|
|
708
|
+
decision: command.decision,
|
|
709
|
+
remember: command.remember,
|
|
710
|
+
via: "text"
|
|
711
|
+
});
|
|
712
|
+
return this.textReceipt(threadId, result2, command.decision);
|
|
713
|
+
}
|
|
714
|
+
const candidates = [];
|
|
715
|
+
const scope = await this.scope(threadId, actor);
|
|
716
|
+
const pending = await this.capability().listActionProposals(scope, {
|
|
717
|
+
decision: "pending",
|
|
718
|
+
limit: 1e3
|
|
719
|
+
});
|
|
720
|
+
for (const proposal of pending) if (await this.mayDecide(actor, proposal)) candidates.push(proposal);
|
|
721
|
+
const resolution = resolveTextActionProposalDecision(text, candidates, this.vocabulary);
|
|
722
|
+
if (resolution.status === "unmatched") return resolution;
|
|
723
|
+
const saturated = pending.length === 1e3 && !text.includes("#");
|
|
724
|
+
if (resolution.status === "ambiguous" || saturated) {
|
|
725
|
+
const proposalIds = candidates.map(({ id }) => id);
|
|
726
|
+
return {
|
|
727
|
+
threadId,
|
|
728
|
+
proposalDecision: {
|
|
729
|
+
status: "ambiguous",
|
|
730
|
+
proposalIds
|
|
731
|
+
},
|
|
732
|
+
text: saturated ? this.replies.tooMany : this.replies.ambiguous(proposalIds)
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
const result = await this.decide(threadId, resolution.proposalId, actor, {
|
|
736
|
+
decision: resolution.decision,
|
|
737
|
+
remember: resolution.remember,
|
|
738
|
+
via: "text"
|
|
739
|
+
});
|
|
740
|
+
return this.textReceipt(threadId, result, resolution.decision);
|
|
741
|
+
}
|
|
742
|
+
textReceipt(threadId, result, decision) {
|
|
743
|
+
return {
|
|
744
|
+
threadId,
|
|
745
|
+
proposalDecision: result,
|
|
746
|
+
text: this.reply(result, decision)
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
/** The configured reply to a decision the store answered with `result`. */
|
|
750
|
+
reply(result, decision) {
|
|
751
|
+
return textActionProposalReply(result, decision, this.replies);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
ActionProposalService = _ts_decorate3([
|
|
755
|
+
Injectable2(),
|
|
756
|
+
_ts_param2(0, Inject3(AGENT_STORE2)),
|
|
757
|
+
_ts_param2(1, Inject3(AGENT_OPTIONS2)),
|
|
758
|
+
_ts_metadata2("design:type", Function),
|
|
759
|
+
_ts_metadata2("design:paramtypes", [
|
|
760
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
761
|
+
typeof Pick === "undefined" ? Object : Pick
|
|
762
|
+
])
|
|
763
|
+
], ActionProposalService);
|
|
764
|
+
|
|
391
765
|
// src/queue/chat-queue.service.ts
|
|
392
|
-
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_OPTIONS as
|
|
393
|
-
import { Inject as
|
|
766
|
+
import { AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_OPTIONS as AGENT_OPTIONS3, AGENT_QUOTA_PROVIDER, AGENT_SINK as AGENT_SINK2, AGENT_STORE as AGENT_STORE3, encodeStreamEvent, isChatQueueStore, queuedMessageView } from "@dudousxd/nestjs-agent-core";
|
|
767
|
+
import { Inject as Inject4, Injectable as Injectable3, Logger, NotImplementedException as NotImplementedException2, Optional as Optional2 } from "@nestjs/common";
|
|
768
|
+
|
|
769
|
+
// src/quota-exceeded.ts
|
|
770
|
+
import { publishAgentQuotaExceeded } from "@dudousxd/nestjs-agent-core";
|
|
771
|
+
function publishQuotaBlocked(actor, report, blocked) {
|
|
772
|
+
const window = report.windows.find((candidate) => candidate.period === blocked.period);
|
|
773
|
+
const payload = {
|
|
774
|
+
actorId: actor.id,
|
|
775
|
+
period: blocked.period,
|
|
776
|
+
...blocked.reason !== void 0 ? {
|
|
777
|
+
reason: blocked.reason
|
|
778
|
+
} : {},
|
|
779
|
+
...window?.usedTokens !== void 0 ? {
|
|
780
|
+
usedTokens: window.usedTokens
|
|
781
|
+
} : {},
|
|
782
|
+
...window?.limitTokens !== void 0 ? {
|
|
783
|
+
limitTokens: window.limitTokens
|
|
784
|
+
} : {},
|
|
785
|
+
...window !== void 0 ? {
|
|
786
|
+
usedUsd: window.usedUsd
|
|
787
|
+
} : {},
|
|
788
|
+
...window?.limitUsd !== void 0 ? {
|
|
789
|
+
limitUsd: window.limitUsd
|
|
790
|
+
} : {}
|
|
791
|
+
};
|
|
792
|
+
publishAgentQuotaExceeded(payload);
|
|
793
|
+
}
|
|
794
|
+
__name(publishQuotaBlocked, "publishQuotaBlocked");
|
|
394
795
|
|
|
395
796
|
// src/thread-persona.ts
|
|
396
797
|
async function threadPersona(store, threadId) {
|
|
@@ -403,7 +804,7 @@ async function threadPersona(store, threadId) {
|
|
|
403
804
|
__name(threadPersona, "threadPersona");
|
|
404
805
|
|
|
405
806
|
// src/queue/chat-queue.service.ts
|
|
406
|
-
function
|
|
807
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
407
808
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
408
809
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
409
810
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -416,19 +817,19 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
416
817
|
}
|
|
417
818
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
418
819
|
}
|
|
419
|
-
__name(
|
|
420
|
-
function
|
|
820
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
821
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
421
822
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
422
823
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
423
824
|
}
|
|
424
825
|
}
|
|
425
|
-
__name(
|
|
426
|
-
function
|
|
826
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
827
|
+
function _ts_param3(paramIndex, decorator) {
|
|
427
828
|
return function(target, key) {
|
|
428
829
|
decorator(target, key, paramIndex);
|
|
429
830
|
};
|
|
430
831
|
}
|
|
431
|
-
__name(
|
|
832
|
+
__name(_ts_param3, "_ts_param");
|
|
432
833
|
var MAX_DRAIN_ATTEMPTS = 8;
|
|
433
834
|
var ChatQueueService = class _ChatQueueService {
|
|
434
835
|
static {
|
|
@@ -461,7 +862,7 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
461
862
|
/** The bound store as a queue store, or a 501 naming what is missing. */
|
|
462
863
|
queueStore() {
|
|
463
864
|
if (!isChatQueueStore(this.store)) {
|
|
464
|
-
throw new
|
|
865
|
+
throw new NotImplementedException2("Queueing messages requires an AgentStore that implements ChatQueueStore (enqueueMessage, listQueue, \u2026, claimActiveStream, releaseActiveStream); the bound store does not.");
|
|
465
866
|
}
|
|
466
867
|
return this.store;
|
|
467
868
|
}
|
|
@@ -688,6 +1089,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
688
1089
|
} : {},
|
|
689
1090
|
...input.pageContext !== void 0 ? {
|
|
690
1091
|
pageContext: input.pageContext
|
|
1092
|
+
} : {},
|
|
1093
|
+
...input.uiCapabilities !== void 0 ? {
|
|
1094
|
+
uiCapabilities: input.uiCapabilities
|
|
691
1095
|
} : {}
|
|
692
1096
|
});
|
|
693
1097
|
await store.setQueuePause(threadId, {
|
|
@@ -732,12 +1136,14 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
732
1136
|
return null;
|
|
733
1137
|
}
|
|
734
1138
|
try {
|
|
735
|
-
const
|
|
1139
|
+
const report = await this.quotaProvider.report({
|
|
736
1140
|
actor
|
|
737
1141
|
});
|
|
1142
|
+
const { blocked } = report;
|
|
738
1143
|
if (blocked === void 0) {
|
|
739
1144
|
return null;
|
|
740
1145
|
}
|
|
1146
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
741
1147
|
return blocked.reason ?? `The ${blocked.period === "day" ? "daily" : "monthly"} quota is used up`;
|
|
742
1148
|
} catch {
|
|
743
1149
|
return null;
|
|
@@ -768,6 +1174,9 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
768
1174
|
...message.pageContext !== void 0 ? {
|
|
769
1175
|
pageContext: message.pageContext
|
|
770
1176
|
} : {},
|
|
1177
|
+
...message.uiCapabilities !== void 0 ? {
|
|
1178
|
+
uiCapabilities: message.uiCapabilities
|
|
1179
|
+
} : {},
|
|
771
1180
|
...message.model !== void 0 ? {
|
|
772
1181
|
model: message.model
|
|
773
1182
|
} : {}
|
|
@@ -821,20 +1230,20 @@ var ChatQueueService = class _ChatQueueService {
|
|
|
821
1230
|
}));
|
|
822
1231
|
}
|
|
823
1232
|
};
|
|
824
|
-
ChatQueueService =
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
1233
|
+
ChatQueueService = _ts_decorate4([
|
|
1234
|
+
Injectable3(),
|
|
1235
|
+
_ts_param3(0, Inject4(AGENT_STORE3)),
|
|
1236
|
+
_ts_param3(1, Inject4(AGENT_SINK2)),
|
|
1237
|
+
_ts_param3(2, Optional2()),
|
|
1238
|
+
_ts_param3(2, Inject4(AGENT_QUOTA_PROVIDER)),
|
|
1239
|
+
_ts_param3(3, Optional2()),
|
|
1240
|
+
_ts_param3(3, Inject4(AGENT_OPTIONS3)),
|
|
1241
|
+
_ts_param3(4, Optional2()),
|
|
1242
|
+
_ts_param3(4, Inject4(AGENT_ATTACHMENT_STAGING)),
|
|
1243
|
+
_ts_param3(5, Optional2()),
|
|
1244
|
+
_ts_param3(5, Inject4(AGENT_DEPS_FACTORY)),
|
|
1245
|
+
_ts_metadata3("design:type", Function),
|
|
1246
|
+
_ts_metadata3("design:paramtypes", [
|
|
838
1247
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
839
1248
|
typeof TokenStreamSink === "undefined" ? Object : TokenStreamSink,
|
|
840
1249
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
@@ -886,7 +1295,7 @@ var RunNotActiveException = class extends ConflictException {
|
|
|
886
1295
|
};
|
|
887
1296
|
|
|
888
1297
|
// src/agent.service.ts
|
|
889
|
-
function
|
|
1298
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
890
1299
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
891
1300
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
892
1301
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -899,19 +1308,19 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
899
1308
|
}
|
|
900
1309
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
901
1310
|
}
|
|
902
|
-
__name(
|
|
903
|
-
function
|
|
1311
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
1312
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
904
1313
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
905
1314
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
906
1315
|
}
|
|
907
1316
|
}
|
|
908
|
-
__name(
|
|
909
|
-
function
|
|
1317
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
1318
|
+
function _ts_param4(paramIndex, decorator) {
|
|
910
1319
|
return function(target, key) {
|
|
911
1320
|
decorator(target, key, paramIndex);
|
|
912
1321
|
};
|
|
913
1322
|
}
|
|
914
|
-
__name(
|
|
1323
|
+
__name(_ts_param4, "_ts_param");
|
|
915
1324
|
var AgentService = class {
|
|
916
1325
|
static {
|
|
917
1326
|
__name(this, "AgentService");
|
|
@@ -924,7 +1333,8 @@ var AgentService = class {
|
|
|
924
1333
|
quotaProvider;
|
|
925
1334
|
options;
|
|
926
1335
|
queue;
|
|
927
|
-
|
|
1336
|
+
proposals;
|
|
1337
|
+
constructor(runner, store, deps, staging, models, quotaProvider, options, queue, proposals) {
|
|
928
1338
|
this.runner = runner;
|
|
929
1339
|
this.store = store;
|
|
930
1340
|
this.deps = deps;
|
|
@@ -933,6 +1343,28 @@ var AgentService = class {
|
|
|
933
1343
|
this.quotaProvider = quotaProvider;
|
|
934
1344
|
this.options = options;
|
|
935
1345
|
this.queue = queue;
|
|
1346
|
+
this.proposals = proposals;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Decide one independent proposal through the scoped proposal service — what the native
|
|
1350
|
+
* `action-proposals/:id/approve|reject` routes call — and the reply to show for it. `404` when
|
|
1351
|
+
* proposals are not on, `403`/`404` when this actor may not decide it.
|
|
1352
|
+
*/
|
|
1353
|
+
async decideActionProposal(actor, threadId, proposalId, command) {
|
|
1354
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) {
|
|
1355
|
+
throw new NotFoundException2("Proposal not found");
|
|
1356
|
+
}
|
|
1357
|
+
const result = await this.proposals.decide(threadId, proposalId, actor, command);
|
|
1358
|
+
return {
|
|
1359
|
+
proposalDecision: result,
|
|
1360
|
+
text: this.proposals.reply(result, command.decision)
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
async handleTextDecision(threadId, actor, text) {
|
|
1364
|
+
if (this.options?.actionApprovalMode !== "independent" || !this.proposals) return {
|
|
1365
|
+
status: "unmatched"
|
|
1366
|
+
};
|
|
1367
|
+
return this.proposals.handleTextDecision(threadId, actor, text);
|
|
936
1368
|
}
|
|
937
1369
|
/** The queue service when the bound store can hold a queue, else `undefined`. */
|
|
938
1370
|
queueing() {
|
|
@@ -942,7 +1374,7 @@ var AgentService = class {
|
|
|
942
1374
|
requireQueue() {
|
|
943
1375
|
const queue = this.queueing();
|
|
944
1376
|
if (queue === void 0) {
|
|
945
|
-
throw new
|
|
1377
|
+
throw new NotImplementedException3("Queueing messages requires an AgentStore that implements ChatQueueStore; the bound store does not.");
|
|
946
1378
|
}
|
|
947
1379
|
return queue;
|
|
948
1380
|
}
|
|
@@ -975,10 +1407,12 @@ var AgentService = class {
|
|
|
975
1407
|
if (this.options?.quota === void 0 || this.quotaProvider === void 0) {
|
|
976
1408
|
return;
|
|
977
1409
|
}
|
|
978
|
-
const
|
|
1410
|
+
const report = await this.quotaProvider.report({
|
|
979
1411
|
actor
|
|
980
1412
|
});
|
|
1413
|
+
const { blocked } = report;
|
|
981
1414
|
if (blocked !== void 0) {
|
|
1415
|
+
publishQuotaBlocked(actor, report, blocked);
|
|
982
1416
|
throw new HttpException({
|
|
983
1417
|
statusCode: HttpStatus.TOO_MANY_REQUESTS,
|
|
984
1418
|
code: "quota_exceeded",
|
|
@@ -1064,7 +1498,10 @@ var AgentService = class {
|
|
|
1064
1498
|
const result = await this.send({
|
|
1065
1499
|
...params,
|
|
1066
1500
|
mode: "auto"
|
|
1501
|
+
}, {
|
|
1502
|
+
textDecisions: false
|
|
1067
1503
|
});
|
|
1504
|
+
if ("proposalDecision" in result) throw new Error("Unexpected text decision in run-only API");
|
|
1068
1505
|
if (result.queued !== true) {
|
|
1069
1506
|
return result;
|
|
1070
1507
|
}
|
|
@@ -1092,7 +1529,11 @@ var AgentService = class {
|
|
|
1092
1529
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
1093
1530
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
1094
1531
|
*/
|
|
1095
|
-
async send(params) {
|
|
1532
|
+
async send(params, sendOptions = {}) {
|
|
1533
|
+
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
1534
|
+
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
1535
|
+
if ("proposalDecision" in decision) return decision;
|
|
1536
|
+
}
|
|
1096
1537
|
await this.assertWithinQuota(params.actor);
|
|
1097
1538
|
const target = this.deps.resolveAgent(await this.resolveAgentName(params.agentName, params.threadId));
|
|
1098
1539
|
const agentName = target.agentName;
|
|
@@ -1141,12 +1582,16 @@ var AgentService = class {
|
|
|
1141
1582
|
...params.pageContext !== void 0 ? {
|
|
1142
1583
|
pageContext: params.pageContext
|
|
1143
1584
|
} : {},
|
|
1585
|
+
...params.uiCapabilities !== void 0 ? {
|
|
1586
|
+
uiCapabilities: params.uiCapabilities
|
|
1587
|
+
} : {},
|
|
1144
1588
|
...model !== void 0 ? {
|
|
1145
1589
|
model
|
|
1146
1590
|
} : {}
|
|
1147
1591
|
};
|
|
1148
1592
|
const queue = this.queueing();
|
|
1149
1593
|
if (queue === void 0) {
|
|
1594
|
+
if (this.options?.actionApprovalMode === "independent") throw new Error("Independent actions require queued thread admission");
|
|
1150
1595
|
const { runId } = await this.runner.start(input);
|
|
1151
1596
|
await this.store.setActiveStream(threadId, runId);
|
|
1152
1597
|
return {
|
|
@@ -1227,6 +1672,9 @@ var AgentService = class {
|
|
|
1227
1672
|
...input.pageContext !== void 0 ? {
|
|
1228
1673
|
pageContext: input.pageContext
|
|
1229
1674
|
} : {},
|
|
1675
|
+
...input.uiCapabilities !== void 0 ? {
|
|
1676
|
+
uiCapabilities: input.uiCapabilities
|
|
1677
|
+
} : {},
|
|
1230
1678
|
...interrupting !== void 0 ? {
|
|
1231
1679
|
interrupt: true,
|
|
1232
1680
|
at: "head"
|
|
@@ -1331,7 +1779,7 @@ var AgentService = class {
|
|
|
1331
1779
|
throw gone();
|
|
1332
1780
|
}
|
|
1333
1781
|
if (marked.interrupt !== true) {
|
|
1334
|
-
throw new
|
|
1782
|
+
throw new NotImplementedException3("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
1335
1783
|
}
|
|
1336
1784
|
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
1337
1785
|
throw gone();
|
|
@@ -1390,7 +1838,7 @@ var AgentService = class {
|
|
|
1390
1838
|
async assertOwnsQueuedMessage(actor, messageId) {
|
|
1391
1839
|
const message = await this.requireQueue().queueStore().getQueuedMessage(messageId);
|
|
1392
1840
|
if (message === null) {
|
|
1393
|
-
throw new
|
|
1841
|
+
throw new NotFoundException2(`queued message ${messageId} not found`);
|
|
1394
1842
|
}
|
|
1395
1843
|
await this.assertOwnsThread(actor, message.threadId);
|
|
1396
1844
|
return message.threadId;
|
|
@@ -1411,7 +1859,7 @@ var AgentService = class {
|
|
|
1411
1859
|
}
|
|
1412
1860
|
const staging = this.staging;
|
|
1413
1861
|
if (staging === void 0 || typeof staging.resolve !== "function") {
|
|
1414
|
-
throw new
|
|
1862
|
+
throw new NotImplementedException3("Message attachments require an AGENT_ATTACHMENT_STAGING provider implementing resolve(); attachment urls are never taken from the request.");
|
|
1415
1863
|
}
|
|
1416
1864
|
const resolved = [];
|
|
1417
1865
|
for (const ref of refs) {
|
|
@@ -1420,7 +1868,7 @@ var AgentService = class {
|
|
|
1420
1868
|
actor
|
|
1421
1869
|
});
|
|
1422
1870
|
if (attachment === null) {
|
|
1423
|
-
throw new
|
|
1871
|
+
throw new ForbiddenException2(`attachment ${ref.mediaId} is not available to this actor`);
|
|
1424
1872
|
}
|
|
1425
1873
|
resolved.push(attachment);
|
|
1426
1874
|
}
|
|
@@ -1522,6 +1970,7 @@ var AgentService = class {
|
|
|
1522
1970
|
* not the thread's own actor).
|
|
1523
1971
|
*/
|
|
1524
1972
|
async signalToolCall(toolCallId2, reply) {
|
|
1973
|
+
if ((await this.store.toolCallApproval?.(toolCallId2))?.status === "proposed") throw new ConflictException2("Independent proposals require the scoped proposal decision route");
|
|
1525
1974
|
await this.assertNotExpired(toolCallId2);
|
|
1526
1975
|
const runId = await this.resolveRunForToolCall(toolCallId2);
|
|
1527
1976
|
await this.assertRunWaiting(runId);
|
|
@@ -1562,7 +2011,7 @@ var AgentService = class {
|
|
|
1562
2011
|
throw new RunNotActiveException(runId);
|
|
1563
2012
|
}
|
|
1564
2013
|
if (owner !== actor.id) {
|
|
1565
|
-
throw new
|
|
2014
|
+
throw new ForbiddenException2("run belongs to another actor");
|
|
1566
2015
|
}
|
|
1567
2016
|
}
|
|
1568
2017
|
/**
|
|
@@ -1622,7 +2071,7 @@ var AgentService = class {
|
|
|
1622
2071
|
return;
|
|
1623
2072
|
}
|
|
1624
2073
|
if (this.store.updateThread === void 0) {
|
|
1625
|
-
throw new
|
|
2074
|
+
throw new NotImplementedException3("Setting a thread's defaultAgent, model or persona requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1626
2075
|
}
|
|
1627
2076
|
const model = patch.model === void 0 || patch.model === null ? patch.model : await this.assertModelAllowed(actor, patch.defaultAgent ?? await this.resolveAgentName(void 0, threadId), patch.model);
|
|
1628
2077
|
if (patch.persona !== void 0 && patch.persona !== null) {
|
|
@@ -1793,11 +2242,11 @@ var AgentService = class {
|
|
|
1793
2242
|
throw new BadRequestException2("comment must be at most 2000 characters");
|
|
1794
2243
|
}
|
|
1795
2244
|
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
1796
|
-
throw new
|
|
2245
|
+
throw new NotImplementedException3("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
1797
2246
|
}
|
|
1798
2247
|
const threadId = await this.store.threadOfMessage(messageId);
|
|
1799
2248
|
if (threadId === null) {
|
|
1800
|
-
throw new
|
|
2249
|
+
throw new NotFoundException2(`message ${messageId} not found`);
|
|
1801
2250
|
}
|
|
1802
2251
|
await this.assertOwnsThread(actor, threadId);
|
|
1803
2252
|
const feedback = input.value === null ? null : {
|
|
@@ -1845,7 +2294,7 @@ var AgentService = class {
|
|
|
1845
2294
|
const list = this.attachmentInventory();
|
|
1846
2295
|
const referencedMediaIds = this.store.referencedMediaIds?.bind(this.store);
|
|
1847
2296
|
if (referencedMediaIds === void 0) {
|
|
1848
|
-
throw new
|
|
2297
|
+
throw new NotImplementedException3("Collecting attachments requires an AgentStore that implements referencedMediaIds(); the bound store cannot say which media a message still references, and guessing would delete files that are in use.");
|
|
1849
2298
|
}
|
|
1850
2299
|
const stagedBefore = options.olderThan.toISOString();
|
|
1851
2300
|
const inventory = await list({
|
|
@@ -1867,7 +2316,7 @@ var AgentService = class {
|
|
|
1867
2316
|
attachmentInventory() {
|
|
1868
2317
|
const list = this.staging?.list?.bind(this.staging);
|
|
1869
2318
|
if (list === void 0) {
|
|
1870
|
-
throw new
|
|
2319
|
+
throw new NotImplementedException3("Listing attachments requires an AGENT_ATTACHMENT_STAGING provider implementing list(); the host owns the staged bytes, so only it can enumerate them.");
|
|
1871
2320
|
}
|
|
1872
2321
|
return list;
|
|
1873
2322
|
}
|
|
@@ -1878,10 +2327,10 @@ var AgentService = class {
|
|
|
1878
2327
|
async assertOwnsThread(actor, threadId) {
|
|
1879
2328
|
const owner = await this.store.ownerOfThread(threadId);
|
|
1880
2329
|
if (owner === null) {
|
|
1881
|
-
throw new
|
|
2330
|
+
throw new NotFoundException2(`thread ${threadId} not found`);
|
|
1882
2331
|
}
|
|
1883
2332
|
if (owner !== actor.id) {
|
|
1884
|
-
throw new
|
|
2333
|
+
throw new ForbiddenException2("thread belongs to another actor");
|
|
1885
2334
|
}
|
|
1886
2335
|
}
|
|
1887
2336
|
/**
|
|
@@ -1892,10 +2341,10 @@ var AgentService = class {
|
|
|
1892
2341
|
async assertOwnsToolCall(actor, toolCallId2) {
|
|
1893
2342
|
const owner = await this.store.ownerOfToolCall(toolCallId2);
|
|
1894
2343
|
if (owner === null) {
|
|
1895
|
-
throw new
|
|
2344
|
+
throw new NotFoundException2(`tool call ${toolCallId2} not found`);
|
|
1896
2345
|
}
|
|
1897
2346
|
if (owner !== actor.id) {
|
|
1898
|
-
throw new
|
|
2347
|
+
throw new ForbiddenException2("tool call belongs to another actor");
|
|
1899
2348
|
}
|
|
1900
2349
|
}
|
|
1901
2350
|
/**
|
|
@@ -1933,15 +2382,15 @@ var AgentService = class {
|
|
|
1933
2382
|
}
|
|
1934
2383
|
const requesterRef = await this.store.ownerOfToolCall(toolCallId2);
|
|
1935
2384
|
if (requesterRef === null) {
|
|
1936
|
-
throw new
|
|
2385
|
+
throw new NotFoundException2(`tool call ${toolCallId2} not found`);
|
|
1937
2386
|
}
|
|
1938
|
-
const allowed = await
|
|
2387
|
+
const allowed = await mayDecideApproval2(this.deps.forAgent().approvalPolicy, actor, {
|
|
1939
2388
|
toolCallId: toolCallId2,
|
|
1940
2389
|
approver,
|
|
1941
2390
|
requesterRef
|
|
1942
2391
|
});
|
|
1943
2392
|
if (!allowed) {
|
|
1944
|
-
throw new
|
|
2393
|
+
throw new ForbiddenException2(`this approval is for ${approver}`);
|
|
1945
2394
|
}
|
|
1946
2395
|
}
|
|
1947
2396
|
/**
|
|
@@ -1970,7 +2419,7 @@ var AgentService = class {
|
|
|
1970
2419
|
async resolveRunForToolCall(toolCallId2) {
|
|
1971
2420
|
const runId = await this.store.runForToolCall(toolCallId2);
|
|
1972
2421
|
if (runId === null) {
|
|
1973
|
-
throw new
|
|
2422
|
+
throw new NotFoundException2(`tool call ${toolCallId2} has no active run to signal`);
|
|
1974
2423
|
}
|
|
1975
2424
|
return runId;
|
|
1976
2425
|
}
|
|
@@ -1978,29 +2427,30 @@ var AgentService = class {
|
|
|
1978
2427
|
async assertOwnsActiveStream(actor, runId) {
|
|
1979
2428
|
const owner = await this.store.ownerOfActiveStream(runId);
|
|
1980
2429
|
if (owner === null) {
|
|
1981
|
-
throw new
|
|
2430
|
+
throw new NotFoundException2(`no active run ${runId}`);
|
|
1982
2431
|
}
|
|
1983
2432
|
if (owner !== actor.id) {
|
|
1984
|
-
throw new
|
|
2433
|
+
throw new ForbiddenException2("run belongs to another actor");
|
|
1985
2434
|
}
|
|
1986
2435
|
}
|
|
1987
2436
|
};
|
|
1988
|
-
AgentService =
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2437
|
+
AgentService = _ts_decorate5([
|
|
2438
|
+
Injectable4(),
|
|
2439
|
+
_ts_param4(0, Inject5(AGENT_RUNNER)),
|
|
2440
|
+
_ts_param4(1, Inject5(AGENT_STORE4)),
|
|
2441
|
+
_ts_param4(2, Inject5(AGENT_DEPS_FACTORY2)),
|
|
2442
|
+
_ts_param4(3, Optional3()),
|
|
2443
|
+
_ts_param4(3, Inject5(AGENT_ATTACHMENT_STAGING2)),
|
|
2444
|
+
_ts_param4(4, Optional3()),
|
|
2445
|
+
_ts_param4(4, Inject5(AGENT_MODEL_CATALOG)),
|
|
2446
|
+
_ts_param4(5, Optional3()),
|
|
2447
|
+
_ts_param4(5, Inject5(AGENT_QUOTA_PROVIDER2)),
|
|
2448
|
+
_ts_param4(6, Optional3()),
|
|
2449
|
+
_ts_param4(6, Inject5(AGENT_OPTIONS4)),
|
|
2450
|
+
_ts_param4(7, Optional3()),
|
|
2451
|
+
_ts_param4(8, Optional3()),
|
|
2452
|
+
_ts_metadata4("design:type", Function),
|
|
2453
|
+
_ts_metadata4("design:paramtypes", [
|
|
2004
2454
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
2005
2455
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
2006
2456
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
@@ -2008,13 +2458,14 @@ AgentService = _ts_decorate3([
|
|
|
2008
2458
|
typeof ModelCatalog === "undefined" ? Object : ModelCatalog,
|
|
2009
2459
|
typeof QuotaProvider === "undefined" ? Object : QuotaProvider,
|
|
2010
2460
|
typeof Pick === "undefined" ? Object : Pick,
|
|
2011
|
-
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
2461
|
+
typeof ChatQueueService === "undefined" ? Object : ChatQueueService,
|
|
2462
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
2012
2463
|
])
|
|
2013
2464
|
], AgentService);
|
|
2014
2465
|
|
|
2015
2466
|
// src/approval-port.adapter.ts
|
|
2016
|
-
import { Injectable as
|
|
2017
|
-
function
|
|
2467
|
+
import { Injectable as Injectable5, NotImplementedException as NotImplementedException4, Optional as Optional4 } from "@nestjs/common";
|
|
2468
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
2018
2469
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2019
2470
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2020
2471
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2027,20 +2478,48 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2027
2478
|
}
|
|
2028
2479
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2029
2480
|
}
|
|
2030
|
-
__name(
|
|
2031
|
-
function
|
|
2481
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
2482
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
2032
2483
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2033
2484
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2034
2485
|
}
|
|
2035
2486
|
}
|
|
2036
|
-
__name(
|
|
2487
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
2488
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2489
|
+
return function(target, key) {
|
|
2490
|
+
decorator(target, key, paramIndex);
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
__name(_ts_param5, "_ts_param");
|
|
2037
2494
|
var AgentApprovalPortAdapter = class {
|
|
2038
2495
|
static {
|
|
2039
2496
|
__name(this, "AgentApprovalPortAdapter");
|
|
2040
2497
|
}
|
|
2041
2498
|
agent;
|
|
2042
|
-
|
|
2499
|
+
proposals;
|
|
2500
|
+
constructor(agent, proposals) {
|
|
2043
2501
|
this.agent = agent;
|
|
2502
|
+
this.proposals = proposals;
|
|
2503
|
+
}
|
|
2504
|
+
async approveActionProposal(actor, target, opts) {
|
|
2505
|
+
if (!this.proposals) throw new NotImplementedException4("Action proposals unavailable");
|
|
2506
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
2507
|
+
decision: "approved",
|
|
2508
|
+
...opts?.remember !== void 0 ? {
|
|
2509
|
+
remember: opts.remember
|
|
2510
|
+
} : {},
|
|
2511
|
+
via: opts?.decidedVia ?? "console"
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
async rejectActionProposal(actor, target, opts) {
|
|
2515
|
+
if (!this.proposals) throw new NotImplementedException4("Action proposals unavailable");
|
|
2516
|
+
return this.proposals.decide(target.threadId, target.proposalId, actor, {
|
|
2517
|
+
decision: "rejected",
|
|
2518
|
+
...opts?.reason !== void 0 ? {
|
|
2519
|
+
reason: opts.reason
|
|
2520
|
+
} : {},
|
|
2521
|
+
via: opts?.decidedVia ?? "console"
|
|
2522
|
+
});
|
|
2044
2523
|
}
|
|
2045
2524
|
async approve(toolCallId2, opts) {
|
|
2046
2525
|
await this.agent.signalToolCall(toolCallId2, {
|
|
@@ -2071,18 +2550,20 @@ var AgentApprovalPortAdapter = class {
|
|
|
2071
2550
|
});
|
|
2072
2551
|
}
|
|
2073
2552
|
};
|
|
2074
|
-
AgentApprovalPortAdapter =
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2553
|
+
AgentApprovalPortAdapter = _ts_decorate6([
|
|
2554
|
+
Injectable5(),
|
|
2555
|
+
_ts_param5(1, Optional4()),
|
|
2556
|
+
_ts_metadata5("design:type", Function),
|
|
2557
|
+
_ts_metadata5("design:paramtypes", [
|
|
2558
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2559
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService
|
|
2079
2560
|
])
|
|
2080
2561
|
], AgentApprovalPortAdapter);
|
|
2081
2562
|
|
|
2082
2563
|
// src/controller/agents.controller.ts
|
|
2083
2564
|
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY3, AGENT_REGISTRY as AGENT_REGISTRY2, AgentRegistry as AgentRegistry3 } from "@dudousxd/nestjs-agent-core";
|
|
2084
|
-
import { Controller, Get, Inject as
|
|
2085
|
-
function
|
|
2565
|
+
import { Controller, Get, Inject as Inject6 } from "@nestjs/common";
|
|
2566
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
2086
2567
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2087
2568
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2088
2569
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2095,19 +2576,19 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
2095
2576
|
}
|
|
2096
2577
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2097
2578
|
}
|
|
2098
|
-
__name(
|
|
2099
|
-
function
|
|
2579
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
2580
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
2100
2581
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2101
2582
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2102
2583
|
}
|
|
2103
2584
|
}
|
|
2104
|
-
__name(
|
|
2105
|
-
function
|
|
2585
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
2586
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2106
2587
|
return function(target, key) {
|
|
2107
2588
|
decorator(target, key, paramIndex);
|
|
2108
2589
|
};
|
|
2109
2590
|
}
|
|
2110
|
-
__name(
|
|
2591
|
+
__name(_ts_param6, "_ts_param");
|
|
2111
2592
|
var AgentsController = class {
|
|
2112
2593
|
static {
|
|
2113
2594
|
__name(this, "AgentsController");
|
|
@@ -2138,26 +2619,26 @@ var AgentsController = class {
|
|
|
2138
2619
|
});
|
|
2139
2620
|
}
|
|
2140
2621
|
};
|
|
2141
|
-
|
|
2622
|
+
_ts_decorate7([
|
|
2142
2623
|
Get(),
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2624
|
+
_ts_metadata6("design:type", Function),
|
|
2625
|
+
_ts_metadata6("design:paramtypes", []),
|
|
2626
|
+
_ts_metadata6("design:returntype", Array)
|
|
2146
2627
|
], AgentsController.prototype, "list", null);
|
|
2147
|
-
AgentsController =
|
|
2628
|
+
AgentsController = _ts_decorate7([
|
|
2148
2629
|
Controller("agents"),
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2630
|
+
_ts_param6(0, Inject6(AGENT_REGISTRY2)),
|
|
2631
|
+
_ts_param6(1, Inject6(AGENT_DEPS_FACTORY3)),
|
|
2632
|
+
_ts_metadata6("design:type", Function),
|
|
2633
|
+
_ts_metadata6("design:paramtypes", [
|
|
2153
2634
|
typeof AgentRegistry3 === "undefined" ? Object : AgentRegistry3,
|
|
2154
2635
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory
|
|
2155
2636
|
])
|
|
2156
2637
|
], AgentsController);
|
|
2157
2638
|
|
|
2158
2639
|
// src/controller/attachments.controller.ts
|
|
2159
|
-
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as
|
|
2160
|
-
import { BadRequestException as BadRequestException3, Controller as Controller2, Get as Get2, Inject as
|
|
2640
|
+
import { AGENT_ACTOR_RESOLVER, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING3, AGENT_OPTIONS as AGENT_OPTIONS5 } from "@dudousxd/nestjs-agent-core";
|
|
2641
|
+
import { BadRequestException as BadRequestException3, Controller as Controller2, Get as Get2, Inject as Inject7, NotImplementedException as NotImplementedException5, Optional as Optional5, PayloadTooLargeException, Post, Req, UnsupportedMediaTypeException, UploadedFile, UseInterceptors } from "@nestjs/common";
|
|
2161
2642
|
import { FileInterceptor } from "@nestjs/platform-express";
|
|
2162
2643
|
|
|
2163
2644
|
// src/attachment-limits.ts
|
|
@@ -2186,7 +2667,7 @@ function attachmentLimits(options, staging) {
|
|
|
2186
2667
|
__name(attachmentLimits, "attachmentLimits");
|
|
2187
2668
|
|
|
2188
2669
|
// src/controller/attachments.controller.ts
|
|
2189
|
-
function
|
|
2670
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2190
2671
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2191
2672
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2192
2673
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2199,19 +2680,19 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
2199
2680
|
}
|
|
2200
2681
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2201
2682
|
}
|
|
2202
|
-
__name(
|
|
2203
|
-
function
|
|
2683
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2684
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
2204
2685
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2205
2686
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2206
2687
|
}
|
|
2207
2688
|
}
|
|
2208
|
-
__name(
|
|
2209
|
-
function
|
|
2689
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
2690
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2210
2691
|
return function(target, key) {
|
|
2211
2692
|
decorator(target, key, paramIndex);
|
|
2212
2693
|
};
|
|
2213
2694
|
}
|
|
2214
|
-
__name(
|
|
2695
|
+
__name(_ts_param7, "_ts_param");
|
|
2215
2696
|
var HARD_MAX_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
2216
2697
|
var ATTACHMENT_PAGE_SIZE = 50;
|
|
2217
2698
|
var AttachmentsController = class {
|
|
@@ -2245,7 +2726,7 @@ var AttachmentsController = class {
|
|
|
2245
2726
|
}
|
|
2246
2727
|
async upload(req, file) {
|
|
2247
2728
|
if (this.staging === void 0) {
|
|
2248
|
-
throw new
|
|
2729
|
+
throw new NotImplementedException5("Attachment upload is not configured on this server: bind AGENT_ATTACHMENT_STAGING (e.g. import AgentMediaAttachmentsModule).");
|
|
2249
2730
|
}
|
|
2250
2731
|
if (file === void 0) {
|
|
2251
2732
|
throw new BadRequestException3('multipart field "file" is required');
|
|
@@ -2267,39 +2748,39 @@ var AttachmentsController = class {
|
|
|
2267
2748
|
});
|
|
2268
2749
|
}
|
|
2269
2750
|
};
|
|
2270
|
-
|
|
2751
|
+
_ts_decorate8([
|
|
2271
2752
|
Get2(),
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2753
|
+
_ts_param7(0, Req()),
|
|
2754
|
+
_ts_metadata7("design:type", Function),
|
|
2755
|
+
_ts_metadata7("design:paramtypes", [
|
|
2275
2756
|
typeof Request === "undefined" ? Object : Request
|
|
2276
2757
|
]),
|
|
2277
|
-
|
|
2758
|
+
_ts_metadata7("design:returntype", Promise)
|
|
2278
2759
|
], AttachmentsController.prototype, "list", null);
|
|
2279
|
-
|
|
2760
|
+
_ts_decorate8([
|
|
2280
2761
|
Post(),
|
|
2281
2762
|
UseInterceptors(FileInterceptor("file", {
|
|
2282
2763
|
limits: {
|
|
2283
2764
|
fileSize: HARD_MAX_ATTACHMENT_BYTES
|
|
2284
2765
|
}
|
|
2285
2766
|
})),
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2767
|
+
_ts_param7(0, Req()),
|
|
2768
|
+
_ts_param7(1, UploadedFile()),
|
|
2769
|
+
_ts_metadata7("design:type", Function),
|
|
2770
|
+
_ts_metadata7("design:paramtypes", [
|
|
2290
2771
|
typeof Request === "undefined" ? Object : Request,
|
|
2291
2772
|
Object
|
|
2292
2773
|
]),
|
|
2293
|
-
|
|
2774
|
+
_ts_metadata7("design:returntype", Promise)
|
|
2294
2775
|
], AttachmentsController.prototype, "upload", null);
|
|
2295
|
-
AttachmentsController =
|
|
2776
|
+
AttachmentsController = _ts_decorate8([
|
|
2296
2777
|
Controller2("attachments"),
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2778
|
+
_ts_param7(0, Inject7(AGENT_OPTIONS5)),
|
|
2779
|
+
_ts_param7(1, Inject7(AGENT_ACTOR_RESOLVER)),
|
|
2780
|
+
_ts_param7(3, Optional5()),
|
|
2781
|
+
_ts_param7(3, Inject7(AGENT_ATTACHMENT_STAGING3)),
|
|
2782
|
+
_ts_metadata7("design:type", Function),
|
|
2783
|
+
_ts_metadata7("design:paramtypes", [
|
|
2303
2784
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2304
2785
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2305
2786
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
@@ -2309,8 +2790,9 @@ AttachmentsController = _ts_decorate6([
|
|
|
2309
2790
|
|
|
2310
2791
|
// src/controller/chat.controller.ts
|
|
2311
2792
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER2, AgentStreamError, streamFailure } from "@dudousxd/nestjs-agent-core";
|
|
2312
|
-
import {
|
|
2313
|
-
|
|
2793
|
+
import { validateUiCapabilities } from "@dudousxd/nestjs-agent-core/genui";
|
|
2794
|
+
import { BadRequestException as BadRequestException4, Body, Controller as Controller3, Get as Get3, Inject as Inject8, Param, Post as Post2, Query, Req as Req2, Res } from "@nestjs/common";
|
|
2795
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2314
2796
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2315
2797
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2316
2798
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2323,19 +2805,19 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
2323
2805
|
}
|
|
2324
2806
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2325
2807
|
}
|
|
2326
|
-
__name(
|
|
2327
|
-
function
|
|
2808
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2809
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
2328
2810
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2329
2811
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2330
2812
|
}
|
|
2331
2813
|
}
|
|
2332
|
-
__name(
|
|
2333
|
-
function
|
|
2814
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2815
|
+
function _ts_param8(paramIndex, decorator) {
|
|
2334
2816
|
return function(target, key) {
|
|
2335
2817
|
decorator(target, key, paramIndex);
|
|
2336
2818
|
};
|
|
2337
2819
|
}
|
|
2338
|
-
__name(
|
|
2820
|
+
__name(_ts_param8, "_ts_param");
|
|
2339
2821
|
function sendMode(body) {
|
|
2340
2822
|
if (body.interrupt === true) {
|
|
2341
2823
|
return "interrupt";
|
|
@@ -2396,9 +2878,18 @@ var ChatController = class {
|
|
|
2396
2878
|
const actor = await this.actorResolver.resolve(req);
|
|
2397
2879
|
const attachments = attachmentRefs(body.attachments);
|
|
2398
2880
|
const mode = sendMode(body);
|
|
2881
|
+
let uiCapabilities;
|
|
2882
|
+
try {
|
|
2883
|
+
uiCapabilities = body.uiCapabilities === void 0 ? void 0 : validateUiCapabilities(body.uiCapabilities);
|
|
2884
|
+
} catch {
|
|
2885
|
+
throw new BadRequestException4("Invalid UI capabilities");
|
|
2886
|
+
}
|
|
2399
2887
|
const result = await this.agent.send({
|
|
2400
2888
|
actor,
|
|
2401
2889
|
message: body.message,
|
|
2890
|
+
...uiCapabilities !== void 0 ? {
|
|
2891
|
+
uiCapabilities
|
|
2892
|
+
} : {},
|
|
2402
2893
|
...body.threadId !== void 0 ? {
|
|
2403
2894
|
threadId: body.threadId
|
|
2404
2895
|
} : {},
|
|
@@ -2425,6 +2916,10 @@ var ChatController = class {
|
|
|
2425
2916
|
} : {},
|
|
2426
2917
|
mode
|
|
2427
2918
|
});
|
|
2919
|
+
if ("proposalDecision" in result) {
|
|
2920
|
+
res.status(200).json(result);
|
|
2921
|
+
return;
|
|
2922
|
+
}
|
|
2428
2923
|
if (result.queued === true) {
|
|
2429
2924
|
res.status(202).json(result);
|
|
2430
2925
|
return;
|
|
@@ -2516,50 +3011,50 @@ data: ${JSON.stringify(payload)}
|
|
|
2516
3011
|
res.end();
|
|
2517
3012
|
}
|
|
2518
3013
|
};
|
|
2519
|
-
|
|
3014
|
+
_ts_decorate9([
|
|
2520
3015
|
Post2("chat"),
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
3016
|
+
_ts_param8(0, Req2()),
|
|
3017
|
+
_ts_param8(1, Res()),
|
|
3018
|
+
_ts_param8(2, Body()),
|
|
3019
|
+
_ts_metadata8("design:type", Function),
|
|
3020
|
+
_ts_metadata8("design:paramtypes", [
|
|
2526
3021
|
typeof Request === "undefined" ? Object : Request,
|
|
2527
3022
|
typeof Response === "undefined" ? Object : Response,
|
|
2528
3023
|
typeof ChatBody === "undefined" ? Object : ChatBody
|
|
2529
3024
|
]),
|
|
2530
|
-
|
|
3025
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2531
3026
|
], ChatController.prototype, "chat", null);
|
|
2532
|
-
|
|
3027
|
+
_ts_decorate9([
|
|
2533
3028
|
Get3("chat/:runId/stream"),
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
3029
|
+
_ts_param8(0, Req2()),
|
|
3030
|
+
_ts_param8(1, Param("runId")),
|
|
3031
|
+
_ts_param8(2, Res()),
|
|
3032
|
+
_ts_param8(3, Query("after")),
|
|
3033
|
+
_ts_metadata8("design:type", Function),
|
|
3034
|
+
_ts_metadata8("design:paramtypes", [
|
|
2540
3035
|
typeof Request === "undefined" ? Object : Request,
|
|
2541
3036
|
String,
|
|
2542
3037
|
typeof Response === "undefined" ? Object : Response,
|
|
2543
3038
|
String
|
|
2544
3039
|
]),
|
|
2545
|
-
|
|
3040
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2546
3041
|
], ChatController.prototype, "stream", null);
|
|
2547
|
-
|
|
3042
|
+
_ts_decorate9([
|
|
2548
3043
|
Post2("chat/:runId/cancel"),
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
3044
|
+
_ts_param8(0, Req2()),
|
|
3045
|
+
_ts_param8(1, Param("runId")),
|
|
3046
|
+
_ts_metadata8("design:type", Function),
|
|
3047
|
+
_ts_metadata8("design:paramtypes", [
|
|
2553
3048
|
typeof Request === "undefined" ? Object : Request,
|
|
2554
3049
|
String
|
|
2555
3050
|
]),
|
|
2556
|
-
|
|
3051
|
+
_ts_metadata8("design:returntype", Promise)
|
|
2557
3052
|
], ChatController.prototype, "cancel", null);
|
|
2558
|
-
ChatController =
|
|
3053
|
+
ChatController = _ts_decorate9([
|
|
2559
3054
|
Controller3(),
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
3055
|
+
_ts_param8(1, Inject8(AGENT_ACTOR_RESOLVER2)),
|
|
3056
|
+
_ts_metadata8("design:type", Function),
|
|
3057
|
+
_ts_metadata8("design:paramtypes", [
|
|
2563
3058
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2564
3059
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2565
3060
|
])
|
|
@@ -2575,8 +3070,8 @@ function parseCursor(raw) {
|
|
|
2575
3070
|
__name(parseCursor, "parseCursor");
|
|
2576
3071
|
|
|
2577
3072
|
// src/controller/config.controller.ts
|
|
2578
|
-
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING4, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as
|
|
2579
|
-
import { Controller as Controller4, Get as Get4, Inject as
|
|
3073
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER3, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING4, AGENT_MODEL_CATALOG as AGENT_MODEL_CATALOG2, AGENT_OPTIONS as AGENT_OPTIONS6 } from "@dudousxd/nestjs-agent-core";
|
|
3074
|
+
import { Controller as Controller4, Get as Get4, Inject as Inject9, Optional as Optional6, Req as Req3 } from "@nestjs/common";
|
|
2580
3075
|
|
|
2581
3076
|
// src/resolver/anonymous-actor-resolver.ts
|
|
2582
3077
|
import { createHash, randomBytes } from "crypto";
|
|
@@ -2666,7 +3161,7 @@ var AnonymousActorResolver = class {
|
|
|
2666
3161
|
};
|
|
2667
3162
|
|
|
2668
3163
|
// src/controller/config.controller.ts
|
|
2669
|
-
function
|
|
3164
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2670
3165
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2671
3166
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2672
3167
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2679,19 +3174,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2679
3174
|
}
|
|
2680
3175
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2681
3176
|
}
|
|
2682
|
-
__name(
|
|
2683
|
-
function
|
|
3177
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
3178
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
2684
3179
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2685
3180
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2686
3181
|
}
|
|
2687
3182
|
}
|
|
2688
|
-
__name(
|
|
2689
|
-
function
|
|
3183
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
3184
|
+
function _ts_param9(paramIndex, decorator) {
|
|
2690
3185
|
return function(target, key) {
|
|
2691
3186
|
decorator(target, key, paramIndex);
|
|
2692
3187
|
};
|
|
2693
3188
|
}
|
|
2694
|
-
__name(
|
|
3189
|
+
__name(_ts_param9, "_ts_param");
|
|
2695
3190
|
var ConfigController = class {
|
|
2696
3191
|
static {
|
|
2697
3192
|
__name(this, "ConfigController");
|
|
@@ -2722,25 +3217,25 @@ var ConfigController = class {
|
|
|
2722
3217
|
};
|
|
2723
3218
|
}
|
|
2724
3219
|
};
|
|
2725
|
-
|
|
3220
|
+
_ts_decorate10([
|
|
2726
3221
|
Get4(),
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
3222
|
+
_ts_param9(0, Req3()),
|
|
3223
|
+
_ts_metadata9("design:type", Function),
|
|
3224
|
+
_ts_metadata9("design:paramtypes", [
|
|
2730
3225
|
typeof Request === "undefined" ? Object : Request
|
|
2731
3226
|
]),
|
|
2732
|
-
|
|
3227
|
+
_ts_metadata9("design:returntype", Promise)
|
|
2733
3228
|
], ConfigController.prototype, "config", null);
|
|
2734
|
-
ConfigController =
|
|
3229
|
+
ConfigController = _ts_decorate10([
|
|
2735
3230
|
Controller4("config"),
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
3231
|
+
_ts_param9(0, Inject9(AGENT_OPTIONS6)),
|
|
3232
|
+
_ts_param9(1, Inject9(AGENT_ACTOR_RESOLVER3)),
|
|
3233
|
+
_ts_param9(2, Optional6()),
|
|
3234
|
+
_ts_param9(2, Inject9(AGENT_ATTACHMENT_STAGING4)),
|
|
3235
|
+
_ts_param9(3, Optional6()),
|
|
3236
|
+
_ts_param9(3, Inject9(AGENT_MODEL_CATALOG2)),
|
|
3237
|
+
_ts_metadata9("design:type", Function),
|
|
3238
|
+
_ts_metadata9("design:paramtypes", [
|
|
2744
3239
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
2745
3240
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2746
3241
|
Object,
|
|
@@ -2750,8 +3245,8 @@ ConfigController = _ts_decorate8([
|
|
|
2750
3245
|
|
|
2751
3246
|
// src/controller/memories.controller.ts
|
|
2752
3247
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER4, AGENT_MEMORY as AGENT_MEMORY2, memoryForgetVerdict, offerMemories } from "@dudousxd/nestjs-agent-core";
|
|
2753
|
-
import { Controller as Controller5, Delete, ForbiddenException as
|
|
2754
|
-
function
|
|
3248
|
+
import { Controller as Controller5, Delete, ForbiddenException as ForbiddenException3, Get as Get5, Inject as Inject10, NotFoundException as NotFoundException3, Optional as Optional7, Param as Param2, Query as Query2, Req as Req4 } from "@nestjs/common";
|
|
3249
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2755
3250
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2756
3251
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2757
3252
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2764,19 +3259,19 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
2764
3259
|
}
|
|
2765
3260
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2766
3261
|
}
|
|
2767
|
-
__name(
|
|
2768
|
-
function
|
|
3262
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
3263
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
2769
3264
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2770
3265
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2771
3266
|
}
|
|
2772
3267
|
}
|
|
2773
|
-
__name(
|
|
2774
|
-
function
|
|
3268
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
3269
|
+
function _ts_param10(paramIndex, decorator) {
|
|
2775
3270
|
return function(target, key) {
|
|
2776
3271
|
decorator(target, key, paramIndex);
|
|
2777
3272
|
};
|
|
2778
3273
|
}
|
|
2779
|
-
__name(
|
|
3274
|
+
__name(_ts_param10, "_ts_param");
|
|
2780
3275
|
var MemoriesController = class {
|
|
2781
3276
|
static {
|
|
2782
3277
|
__name(this, "MemoriesController");
|
|
@@ -2810,20 +3305,20 @@ var MemoriesController = class {
|
|
|
2810
3305
|
*/
|
|
2811
3306
|
async forget(req, id) {
|
|
2812
3307
|
if (this.memory === void 0) {
|
|
2813
|
-
throw new
|
|
3308
|
+
throw new NotFoundException3("No memory is configured in this deployment.");
|
|
2814
3309
|
}
|
|
2815
3310
|
const actor = await this.actorResolver.resolve(req);
|
|
2816
3311
|
const digest = await this.unbounded("", actor);
|
|
2817
3312
|
const entry = digest.entries.find((candidate) => candidate.id === id);
|
|
2818
3313
|
if (entry === void 0) {
|
|
2819
|
-
throw new
|
|
3314
|
+
throw new NotFoundException3(`No memory with id "${id}".`);
|
|
2820
3315
|
}
|
|
2821
3316
|
const verdict = memoryForgetVerdict({
|
|
2822
3317
|
record: entry,
|
|
2823
3318
|
actor
|
|
2824
3319
|
});
|
|
2825
3320
|
if (!verdict.allowed) {
|
|
2826
|
-
throw new
|
|
3321
|
+
throw new ForbiddenException3(verdict.reason);
|
|
2827
3322
|
}
|
|
2828
3323
|
return {
|
|
2829
3324
|
forgotten: await this.memory.provider.forget({
|
|
@@ -2849,35 +3344,35 @@ var MemoriesController = class {
|
|
|
2849
3344
|
});
|
|
2850
3345
|
}
|
|
2851
3346
|
};
|
|
2852
|
-
|
|
3347
|
+
_ts_decorate11([
|
|
2853
3348
|
Get5(),
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
3349
|
+
_ts_param10(0, Req4()),
|
|
3350
|
+
_ts_param10(1, Query2("threadId")),
|
|
3351
|
+
_ts_metadata10("design:type", Function),
|
|
3352
|
+
_ts_metadata10("design:paramtypes", [
|
|
2858
3353
|
typeof Request === "undefined" ? Object : Request,
|
|
2859
3354
|
String
|
|
2860
3355
|
]),
|
|
2861
|
-
|
|
3356
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2862
3357
|
], MemoriesController.prototype, "list", null);
|
|
2863
|
-
|
|
3358
|
+
_ts_decorate11([
|
|
2864
3359
|
Delete(":id"),
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
3360
|
+
_ts_param10(0, Req4()),
|
|
3361
|
+
_ts_param10(1, Param2("id")),
|
|
3362
|
+
_ts_metadata10("design:type", Function),
|
|
3363
|
+
_ts_metadata10("design:paramtypes", [
|
|
2869
3364
|
typeof Request === "undefined" ? Object : Request,
|
|
2870
3365
|
String
|
|
2871
3366
|
]),
|
|
2872
|
-
|
|
3367
|
+
_ts_metadata10("design:returntype", Promise)
|
|
2873
3368
|
], MemoriesController.prototype, "forget", null);
|
|
2874
|
-
MemoriesController =
|
|
3369
|
+
MemoriesController = _ts_decorate11([
|
|
2875
3370
|
Controller5("memories"),
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
3371
|
+
_ts_param10(0, Inject10(AGENT_ACTOR_RESOLVER4)),
|
|
3372
|
+
_ts_param10(1, Optional7()),
|
|
3373
|
+
_ts_param10(1, Inject10(AGENT_MEMORY2)),
|
|
3374
|
+
_ts_metadata10("design:type", Function),
|
|
3375
|
+
_ts_metadata10("design:paramtypes", [
|
|
2881
3376
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2882
3377
|
Object
|
|
2883
3378
|
])
|
|
@@ -2885,8 +3380,8 @@ MemoriesController = _ts_decorate9([
|
|
|
2885
3380
|
|
|
2886
3381
|
// src/controller/messages.controller.ts
|
|
2887
3382
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER5 } from "@dudousxd/nestjs-agent-core";
|
|
2888
|
-
import { Body as Body2, Controller as Controller6, HttpCode, Inject as
|
|
2889
|
-
function
|
|
3383
|
+
import { Body as Body2, Controller as Controller6, HttpCode, Inject as Inject11, Param as Param3, Post as Post3, Req as Req5 } from "@nestjs/common";
|
|
3384
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2890
3385
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2891
3386
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2892
3387
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2899,19 +3394,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
2899
3394
|
}
|
|
2900
3395
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2901
3396
|
}
|
|
2902
|
-
__name(
|
|
2903
|
-
function
|
|
3397
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3398
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2904
3399
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2905
3400
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2906
3401
|
}
|
|
2907
3402
|
}
|
|
2908
|
-
__name(
|
|
2909
|
-
function
|
|
3403
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
3404
|
+
function _ts_param11(paramIndex, decorator) {
|
|
2910
3405
|
return function(target, key) {
|
|
2911
3406
|
decorator(target, key, paramIndex);
|
|
2912
3407
|
};
|
|
2913
3408
|
}
|
|
2914
|
-
__name(
|
|
3409
|
+
__name(_ts_param11, "_ts_param");
|
|
2915
3410
|
var MessagesController = class {
|
|
2916
3411
|
static {
|
|
2917
3412
|
__name(this, "MessagesController");
|
|
@@ -2939,25 +3434,25 @@ var MessagesController = class {
|
|
|
2939
3434
|
};
|
|
2940
3435
|
}
|
|
2941
3436
|
};
|
|
2942
|
-
|
|
3437
|
+
_ts_decorate12([
|
|
2943
3438
|
Post3(":id/feedback"),
|
|
2944
3439
|
HttpCode(200),
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
3440
|
+
_ts_param11(0, Req5()),
|
|
3441
|
+
_ts_param11(1, Param3("id")),
|
|
3442
|
+
_ts_param11(2, Body2()),
|
|
3443
|
+
_ts_metadata11("design:type", Function),
|
|
3444
|
+
_ts_metadata11("design:paramtypes", [
|
|
2950
3445
|
typeof Request === "undefined" ? Object : Request,
|
|
2951
3446
|
String,
|
|
2952
3447
|
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
2953
3448
|
]),
|
|
2954
|
-
|
|
3449
|
+
_ts_metadata11("design:returntype", Promise)
|
|
2955
3450
|
], MessagesController.prototype, "feedback", null);
|
|
2956
|
-
MessagesController =
|
|
3451
|
+
MessagesController = _ts_decorate12([
|
|
2957
3452
|
Controller6("messages"),
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
3453
|
+
_ts_param11(1, Inject11(AGENT_ACTOR_RESOLVER5)),
|
|
3454
|
+
_ts_metadata11("design:type", Function),
|
|
3455
|
+
_ts_metadata11("design:paramtypes", [
|
|
2961
3456
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2962
3457
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2963
3458
|
])
|
|
@@ -2965,8 +3460,8 @@ MessagesController = _ts_decorate10([
|
|
|
2965
3460
|
|
|
2966
3461
|
// src/controller/models.controller.ts
|
|
2967
3462
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER6 } from "@dudousxd/nestjs-agent-core";
|
|
2968
|
-
import { Controller as Controller7, Get as Get6, Inject as
|
|
2969
|
-
function
|
|
3463
|
+
import { Controller as Controller7, Get as Get6, Inject as Inject12, Query as Query3, Req as Req6 } from "@nestjs/common";
|
|
3464
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
2970
3465
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2971
3466
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2972
3467
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2979,19 +3474,19 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
2979
3474
|
}
|
|
2980
3475
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2981
3476
|
}
|
|
2982
|
-
__name(
|
|
2983
|
-
function
|
|
3477
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3478
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
2984
3479
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2985
3480
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2986
3481
|
}
|
|
2987
3482
|
}
|
|
2988
|
-
__name(
|
|
2989
|
-
function
|
|
3483
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3484
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2990
3485
|
return function(target, key) {
|
|
2991
3486
|
decorator(target, key, paramIndex);
|
|
2992
3487
|
};
|
|
2993
3488
|
}
|
|
2994
|
-
__name(
|
|
3489
|
+
__name(_ts_param12, "_ts_param");
|
|
2995
3490
|
var ModelsController = class {
|
|
2996
3491
|
static {
|
|
2997
3492
|
__name(this, "ModelsController");
|
|
@@ -3011,22 +3506,22 @@ var ModelsController = class {
|
|
|
3011
3506
|
return this.agent.listModels(actor, agent);
|
|
3012
3507
|
}
|
|
3013
3508
|
};
|
|
3014
|
-
|
|
3509
|
+
_ts_decorate13([
|
|
3015
3510
|
Get6(),
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3511
|
+
_ts_param12(0, Req6()),
|
|
3512
|
+
_ts_param12(1, Query3("agent")),
|
|
3513
|
+
_ts_metadata12("design:type", Function),
|
|
3514
|
+
_ts_metadata12("design:paramtypes", [
|
|
3020
3515
|
typeof Request === "undefined" ? Object : Request,
|
|
3021
3516
|
String
|
|
3022
3517
|
]),
|
|
3023
|
-
|
|
3518
|
+
_ts_metadata12("design:returntype", Promise)
|
|
3024
3519
|
], ModelsController.prototype, "list", null);
|
|
3025
|
-
ModelsController =
|
|
3520
|
+
ModelsController = _ts_decorate13([
|
|
3026
3521
|
Controller7("models"),
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3522
|
+
_ts_param12(1, Inject12(AGENT_ACTOR_RESOLVER6)),
|
|
3523
|
+
_ts_metadata12("design:type", Function),
|
|
3524
|
+
_ts_metadata12("design:paramtypes", [
|
|
3030
3525
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3031
3526
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3032
3527
|
])
|
|
@@ -3034,8 +3529,8 @@ ModelsController = _ts_decorate11([
|
|
|
3034
3529
|
|
|
3035
3530
|
// src/controller/queue.controller.ts
|
|
3036
3531
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER7 } from "@dudousxd/nestjs-agent-core";
|
|
3037
|
-
import { BadRequestException as BadRequestException5, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as
|
|
3038
|
-
function
|
|
3532
|
+
import { BadRequestException as BadRequestException5, Body as Body3, Controller as Controller8, Delete as Delete2, Get as Get7, Inject as Inject13, Param as Param4, Patch, Post as Post4, Req as Req7 } from "@nestjs/common";
|
|
3533
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
3039
3534
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3040
3535
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3041
3536
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3048,19 +3543,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3048
3543
|
}
|
|
3049
3544
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3050
3545
|
}
|
|
3051
|
-
__name(
|
|
3052
|
-
function
|
|
3546
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
3547
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3053
3548
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3054
3549
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3055
3550
|
}
|
|
3056
3551
|
}
|
|
3057
|
-
__name(
|
|
3058
|
-
function
|
|
3552
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3553
|
+
function _ts_param13(paramIndex, decorator) {
|
|
3059
3554
|
return function(target, key) {
|
|
3060
3555
|
decorator(target, key, paramIndex);
|
|
3061
3556
|
};
|
|
3062
3557
|
}
|
|
3063
|
-
__name(
|
|
3558
|
+
__name(_ts_param13, "_ts_param");
|
|
3064
3559
|
var QueueController = class {
|
|
3065
3560
|
static {
|
|
3066
3561
|
__name(this, "QueueController");
|
|
@@ -3114,79 +3609,79 @@ var QueueController = class {
|
|
|
3114
3609
|
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
3115
3610
|
}
|
|
3116
3611
|
};
|
|
3117
|
-
|
|
3612
|
+
_ts_decorate14([
|
|
3118
3613
|
Get7("threads/:id/queue"),
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3614
|
+
_ts_param13(0, Req7()),
|
|
3615
|
+
_ts_param13(1, Param4("id")),
|
|
3616
|
+
_ts_metadata13("design:type", Function),
|
|
3617
|
+
_ts_metadata13("design:paramtypes", [
|
|
3123
3618
|
typeof Request === "undefined" ? Object : Request,
|
|
3124
3619
|
String
|
|
3125
3620
|
]),
|
|
3126
|
-
|
|
3621
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3127
3622
|
], QueueController.prototype, "list", null);
|
|
3128
|
-
|
|
3623
|
+
_ts_decorate14([
|
|
3129
3624
|
Delete2("threads/:id/queue"),
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3625
|
+
_ts_param13(0, Req7()),
|
|
3626
|
+
_ts_param13(1, Param4("id")),
|
|
3627
|
+
_ts_metadata13("design:type", Function),
|
|
3628
|
+
_ts_metadata13("design:paramtypes", [
|
|
3134
3629
|
typeof Request === "undefined" ? Object : Request,
|
|
3135
3630
|
String
|
|
3136
3631
|
]),
|
|
3137
|
-
|
|
3632
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3138
3633
|
], QueueController.prototype, "clear", null);
|
|
3139
|
-
|
|
3634
|
+
_ts_decorate14([
|
|
3140
3635
|
Post4("threads/:id/queue/resume"),
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3636
|
+
_ts_param13(0, Req7()),
|
|
3637
|
+
_ts_param13(1, Param4("id")),
|
|
3638
|
+
_ts_metadata13("design:type", Function),
|
|
3639
|
+
_ts_metadata13("design:paramtypes", [
|
|
3145
3640
|
typeof Request === "undefined" ? Object : Request,
|
|
3146
3641
|
String
|
|
3147
3642
|
]),
|
|
3148
|
-
|
|
3643
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3149
3644
|
], QueueController.prototype, "resume", null);
|
|
3150
|
-
|
|
3645
|
+
_ts_decorate14([
|
|
3151
3646
|
Patch("queue/:messageId"),
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3647
|
+
_ts_param13(0, Req7()),
|
|
3648
|
+
_ts_param13(1, Param4("messageId")),
|
|
3649
|
+
_ts_param13(2, Body3()),
|
|
3650
|
+
_ts_metadata13("design:type", Function),
|
|
3651
|
+
_ts_metadata13("design:paramtypes", [
|
|
3157
3652
|
typeof Request === "undefined" ? Object : Request,
|
|
3158
3653
|
String,
|
|
3159
3654
|
typeof UpdateQueuedMessageBody === "undefined" ? Object : UpdateQueuedMessageBody
|
|
3160
3655
|
]),
|
|
3161
|
-
|
|
3656
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3162
3657
|
], QueueController.prototype, "update", null);
|
|
3163
|
-
|
|
3658
|
+
_ts_decorate14([
|
|
3164
3659
|
Post4("queue/:messageId/interrupt"),
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3660
|
+
_ts_param13(0, Req7()),
|
|
3661
|
+
_ts_param13(1, Param4("messageId")),
|
|
3662
|
+
_ts_metadata13("design:type", Function),
|
|
3663
|
+
_ts_metadata13("design:paramtypes", [
|
|
3169
3664
|
typeof Request === "undefined" ? Object : Request,
|
|
3170
3665
|
String
|
|
3171
3666
|
]),
|
|
3172
|
-
|
|
3667
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3173
3668
|
], QueueController.prototype, "interrupt", null);
|
|
3174
|
-
|
|
3669
|
+
_ts_decorate14([
|
|
3175
3670
|
Delete2("queue/:messageId"),
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3671
|
+
_ts_param13(0, Req7()),
|
|
3672
|
+
_ts_param13(1, Param4("messageId")),
|
|
3673
|
+
_ts_metadata13("design:type", Function),
|
|
3674
|
+
_ts_metadata13("design:paramtypes", [
|
|
3180
3675
|
typeof Request === "undefined" ? Object : Request,
|
|
3181
3676
|
String
|
|
3182
3677
|
]),
|
|
3183
|
-
|
|
3678
|
+
_ts_metadata13("design:returntype", Promise)
|
|
3184
3679
|
], QueueController.prototype, "remove", null);
|
|
3185
|
-
QueueController =
|
|
3680
|
+
QueueController = _ts_decorate14([
|
|
3186
3681
|
Controller8(),
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3682
|
+
_ts_param13(1, Inject13(AGENT_ACTOR_RESOLVER7)),
|
|
3683
|
+
_ts_metadata13("design:type", Function),
|
|
3684
|
+
_ts_metadata13("design:paramtypes", [
|
|
3190
3685
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3191
3686
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3192
3687
|
])
|
|
@@ -3194,8 +3689,8 @@ QueueController = _ts_decorate12([
|
|
|
3194
3689
|
|
|
3195
3690
|
// src/controller/quota.controller.ts
|
|
3196
3691
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER8 } from "@dudousxd/nestjs-agent-core";
|
|
3197
|
-
import { Controller as Controller9, Get as Get8, Inject as
|
|
3198
|
-
function
|
|
3692
|
+
import { Controller as Controller9, Get as Get8, Inject as Inject14, Req as Req8 } from "@nestjs/common";
|
|
3693
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
3199
3694
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3200
3695
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3201
3696
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3208,19 +3703,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
3208
3703
|
}
|
|
3209
3704
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3210
3705
|
}
|
|
3211
|
-
__name(
|
|
3212
|
-
function
|
|
3706
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
3707
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
3213
3708
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3214
3709
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3215
3710
|
}
|
|
3216
3711
|
}
|
|
3217
|
-
__name(
|
|
3218
|
-
function
|
|
3712
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
3713
|
+
function _ts_param14(paramIndex, decorator) {
|
|
3219
3714
|
return function(target, key) {
|
|
3220
3715
|
decorator(target, key, paramIndex);
|
|
3221
3716
|
};
|
|
3222
3717
|
}
|
|
3223
|
-
__name(
|
|
3718
|
+
__name(_ts_param14, "_ts_param");
|
|
3224
3719
|
var QuotaController = class {
|
|
3225
3720
|
static {
|
|
3226
3721
|
__name(this, "QuotaController");
|
|
@@ -3240,20 +3735,20 @@ var QuotaController = class {
|
|
|
3240
3735
|
return this.agent.quotaReport(actor);
|
|
3241
3736
|
}
|
|
3242
3737
|
};
|
|
3243
|
-
|
|
3738
|
+
_ts_decorate15([
|
|
3244
3739
|
Get8(),
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3740
|
+
_ts_param14(0, Req8()),
|
|
3741
|
+
_ts_metadata14("design:type", Function),
|
|
3742
|
+
_ts_metadata14("design:paramtypes", [
|
|
3248
3743
|
typeof Request === "undefined" ? Object : Request
|
|
3249
3744
|
]),
|
|
3250
|
-
|
|
3745
|
+
_ts_metadata14("design:returntype", Promise)
|
|
3251
3746
|
], QuotaController.prototype, "report", null);
|
|
3252
|
-
QuotaController =
|
|
3747
|
+
QuotaController = _ts_decorate15([
|
|
3253
3748
|
Controller9("quota"),
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3749
|
+
_ts_param14(1, Inject14(AGENT_ACTOR_RESOLVER8)),
|
|
3750
|
+
_ts_metadata14("design:type", Function),
|
|
3751
|
+
_ts_metadata14("design:paramtypes", [
|
|
3257
3752
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3258
3753
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3259
3754
|
])
|
|
@@ -3261,8 +3756,8 @@ QuotaController = _ts_decorate13([
|
|
|
3261
3756
|
|
|
3262
3757
|
// src/controller/skills.controller.ts
|
|
3263
3758
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER9, AGENT_SKILLS as AGENT_SKILLS2, offerSkills } from "@dudousxd/nestjs-agent-core";
|
|
3264
|
-
import { Controller as Controller10, Get as Get9, Inject as
|
|
3265
|
-
function
|
|
3759
|
+
import { Controller as Controller10, Get as Get9, Inject as Inject15, Optional as Optional8, Query as Query4, Req as Req9 } from "@nestjs/common";
|
|
3760
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
3266
3761
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3267
3762
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3268
3763
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3275,19 +3770,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
3275
3770
|
}
|
|
3276
3771
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3277
3772
|
}
|
|
3278
|
-
__name(
|
|
3279
|
-
function
|
|
3773
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
3774
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
3280
3775
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3281
3776
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3282
3777
|
}
|
|
3283
3778
|
}
|
|
3284
|
-
__name(
|
|
3285
|
-
function
|
|
3779
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
3780
|
+
function _ts_param15(paramIndex, decorator) {
|
|
3286
3781
|
return function(target, key) {
|
|
3287
3782
|
decorator(target, key, paramIndex);
|
|
3288
3783
|
};
|
|
3289
3784
|
}
|
|
3290
|
-
__name(
|
|
3785
|
+
__name(_ts_param15, "_ts_param");
|
|
3291
3786
|
var SkillsController = class {
|
|
3292
3787
|
static {
|
|
3293
3788
|
__name(this, "SkillsController");
|
|
@@ -3310,24 +3805,24 @@ var SkillsController = class {
|
|
|
3310
3805
|
return offer.entries;
|
|
3311
3806
|
}
|
|
3312
3807
|
};
|
|
3313
|
-
|
|
3808
|
+
_ts_decorate16([
|
|
3314
3809
|
Get9(),
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3810
|
+
_ts_param15(0, Req9()),
|
|
3811
|
+
_ts_param15(1, Query4("threadId")),
|
|
3812
|
+
_ts_metadata15("design:type", Function),
|
|
3813
|
+
_ts_metadata15("design:paramtypes", [
|
|
3319
3814
|
typeof Request === "undefined" ? Object : Request,
|
|
3320
3815
|
String
|
|
3321
3816
|
]),
|
|
3322
|
-
|
|
3817
|
+
_ts_metadata15("design:returntype", Promise)
|
|
3323
3818
|
], SkillsController.prototype, "list", null);
|
|
3324
|
-
SkillsController =
|
|
3819
|
+
SkillsController = _ts_decorate16([
|
|
3325
3820
|
Controller10("skills"),
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3821
|
+
_ts_param15(0, Inject15(AGENT_ACTOR_RESOLVER9)),
|
|
3822
|
+
_ts_param15(1, Optional8()),
|
|
3823
|
+
_ts_param15(1, Inject15(AGENT_SKILLS2)),
|
|
3824
|
+
_ts_metadata15("design:type", Function),
|
|
3825
|
+
_ts_metadata15("design:paramtypes", [
|
|
3331
3826
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3332
3827
|
Object
|
|
3333
3828
|
])
|
|
@@ -3335,8 +3830,8 @@ SkillsController = _ts_decorate14([
|
|
|
3335
3830
|
|
|
3336
3831
|
// src/controller/threads.controller.ts
|
|
3337
3832
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER10 } from "@dudousxd/nestjs-agent-core";
|
|
3338
|
-
import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as
|
|
3339
|
-
function
|
|
3833
|
+
import { Body as Body4, Controller as Controller11, Delete as Delete3, Get as Get10, Inject as Inject16, Param as Param5, Patch as Patch2, Post as Post5, Req as Req10 } from "@nestjs/common";
|
|
3834
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
3340
3835
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3341
3836
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3342
3837
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3349,19 +3844,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
3349
3844
|
}
|
|
3350
3845
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3351
3846
|
}
|
|
3352
|
-
__name(
|
|
3353
|
-
function
|
|
3847
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
3848
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
3354
3849
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3355
3850
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3356
3851
|
}
|
|
3357
3852
|
}
|
|
3358
|
-
__name(
|
|
3359
|
-
function
|
|
3853
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
3854
|
+
function _ts_param16(paramIndex, decorator) {
|
|
3360
3855
|
return function(target, key) {
|
|
3361
3856
|
decorator(target, key, paramIndex);
|
|
3362
3857
|
};
|
|
3363
3858
|
}
|
|
3364
|
-
__name(
|
|
3859
|
+
__name(_ts_param16, "_ts_param");
|
|
3365
3860
|
var ThreadsController = class {
|
|
3366
3861
|
static {
|
|
3367
3862
|
__name(this, "ThreadsController");
|
|
@@ -3431,92 +3926,92 @@ var ThreadsController = class {
|
|
|
3431
3926
|
};
|
|
3432
3927
|
}
|
|
3433
3928
|
};
|
|
3434
|
-
|
|
3929
|
+
_ts_decorate17([
|
|
3435
3930
|
Get10(),
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3931
|
+
_ts_param16(0, Req10()),
|
|
3932
|
+
_ts_metadata16("design:type", Function),
|
|
3933
|
+
_ts_metadata16("design:paramtypes", [
|
|
3439
3934
|
typeof Request === "undefined" ? Object : Request
|
|
3440
3935
|
]),
|
|
3441
|
-
|
|
3936
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3442
3937
|
], ThreadsController.prototype, "list", null);
|
|
3443
|
-
|
|
3938
|
+
_ts_decorate17([
|
|
3444
3939
|
Get10(":id"),
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3940
|
+
_ts_param16(0, Req10()),
|
|
3941
|
+
_ts_param16(1, Param5("id")),
|
|
3942
|
+
_ts_metadata16("design:type", Function),
|
|
3943
|
+
_ts_metadata16("design:paramtypes", [
|
|
3449
3944
|
typeof Request === "undefined" ? Object : Request,
|
|
3450
3945
|
String
|
|
3451
3946
|
]),
|
|
3452
|
-
|
|
3947
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3453
3948
|
], ThreadsController.prototype, "detail", null);
|
|
3454
|
-
|
|
3949
|
+
_ts_decorate17([
|
|
3455
3950
|
Delete3(":id"),
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3951
|
+
_ts_param16(0, Req10()),
|
|
3952
|
+
_ts_param16(1, Param5("id")),
|
|
3953
|
+
_ts_metadata16("design:type", Function),
|
|
3954
|
+
_ts_metadata16("design:paramtypes", [
|
|
3460
3955
|
typeof Request === "undefined" ? Object : Request,
|
|
3461
3956
|
String
|
|
3462
3957
|
]),
|
|
3463
|
-
|
|
3958
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3464
3959
|
], ThreadsController.prototype, "remove", null);
|
|
3465
|
-
|
|
3960
|
+
_ts_decorate17([
|
|
3466
3961
|
Post5(":id/fork-from/:messageId"),
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3962
|
+
_ts_param16(0, Req10()),
|
|
3963
|
+
_ts_param16(1, Param5("id")),
|
|
3964
|
+
_ts_param16(2, Param5("messageId")),
|
|
3965
|
+
_ts_metadata16("design:type", Function),
|
|
3966
|
+
_ts_metadata16("design:paramtypes", [
|
|
3472
3967
|
typeof Request === "undefined" ? Object : Request,
|
|
3473
3968
|
String,
|
|
3474
3969
|
String
|
|
3475
3970
|
]),
|
|
3476
|
-
|
|
3971
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3477
3972
|
], ThreadsController.prototype, "fork", null);
|
|
3478
|
-
|
|
3973
|
+
_ts_decorate17([
|
|
3479
3974
|
Patch2(":id"),
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3975
|
+
_ts_param16(0, Req10()),
|
|
3976
|
+
_ts_param16(1, Param5("id")),
|
|
3977
|
+
_ts_param16(2, Body4()),
|
|
3978
|
+
_ts_metadata16("design:type", Function),
|
|
3979
|
+
_ts_metadata16("design:paramtypes", [
|
|
3485
3980
|
typeof Request === "undefined" ? Object : Request,
|
|
3486
3981
|
String,
|
|
3487
3982
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
3488
3983
|
]),
|
|
3489
|
-
|
|
3984
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3490
3985
|
], ThreadsController.prototype, "update", null);
|
|
3491
|
-
|
|
3986
|
+
_ts_decorate17([
|
|
3492
3987
|
Post5(":id/promote"),
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3988
|
+
_ts_param16(0, Req10()),
|
|
3989
|
+
_ts_param16(1, Param5("id")),
|
|
3990
|
+
_ts_metadata16("design:type", Function),
|
|
3991
|
+
_ts_metadata16("design:paramtypes", [
|
|
3497
3992
|
typeof Request === "undefined" ? Object : Request,
|
|
3498
3993
|
String
|
|
3499
3994
|
]),
|
|
3500
|
-
|
|
3995
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3501
3996
|
], ThreadsController.prototype, "promote", null);
|
|
3502
|
-
|
|
3997
|
+
_ts_decorate17([
|
|
3503
3998
|
Delete3(":id/from/:messageId"),
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3999
|
+
_ts_param16(0, Req10()),
|
|
4000
|
+
_ts_param16(1, Param5("id")),
|
|
4001
|
+
_ts_param16(2, Param5("messageId")),
|
|
4002
|
+
_ts_metadata16("design:type", Function),
|
|
4003
|
+
_ts_metadata16("design:paramtypes", [
|
|
3509
4004
|
typeof Request === "undefined" ? Object : Request,
|
|
3510
4005
|
String,
|
|
3511
4006
|
String
|
|
3512
4007
|
]),
|
|
3513
|
-
|
|
4008
|
+
_ts_metadata16("design:returntype", Promise)
|
|
3514
4009
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
3515
|
-
ThreadsController =
|
|
4010
|
+
ThreadsController = _ts_decorate17([
|
|
3516
4011
|
Controller11("threads"),
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
4012
|
+
_ts_param16(1, Inject16(AGENT_ACTOR_RESOLVER10)),
|
|
4013
|
+
_ts_metadata16("design:type", Function),
|
|
4014
|
+
_ts_metadata16("design:paramtypes", [
|
|
3520
4015
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3521
4016
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3522
4017
|
])
|
|
@@ -3524,8 +4019,8 @@ ThreadsController = _ts_decorate15([
|
|
|
3524
4019
|
|
|
3525
4020
|
// src/controller/tool-call.controller.ts
|
|
3526
4021
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER11 } from "@dudousxd/nestjs-agent-core";
|
|
3527
|
-
import { BadRequestException as BadRequestException6, Body as Body5, Controller as Controller12, Inject as
|
|
3528
|
-
function
|
|
4022
|
+
import { BadRequestException as BadRequestException6, Body as Body5, Controller as Controller12, Inject as Inject17, Post as Post6, Req as Req11 } from "@nestjs/common";
|
|
4023
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
3529
4024
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3530
4025
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3531
4026
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3538,19 +4033,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
3538
4033
|
}
|
|
3539
4034
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3540
4035
|
}
|
|
3541
|
-
__name(
|
|
3542
|
-
function
|
|
4036
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
4037
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
3543
4038
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3544
4039
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3545
4040
|
}
|
|
3546
4041
|
}
|
|
3547
|
-
__name(
|
|
3548
|
-
function
|
|
4042
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
4043
|
+
function _ts_param17(paramIndex, decorator) {
|
|
3549
4044
|
return function(target, key) {
|
|
3550
4045
|
decorator(target, key, paramIndex);
|
|
3551
4046
|
};
|
|
3552
4047
|
}
|
|
3553
|
-
__name(
|
|
4048
|
+
__name(_ts_param17, "_ts_param");
|
|
3554
4049
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
3555
4050
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
3556
4051
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -3683,55 +4178,55 @@ var ToolCallController = class {
|
|
|
3683
4178
|
};
|
|
3684
4179
|
}
|
|
3685
4180
|
};
|
|
3686
|
-
|
|
4181
|
+
_ts_decorate18([
|
|
3687
4182
|
Post6("approve"),
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
4183
|
+
_ts_param17(0, Req11()),
|
|
4184
|
+
_ts_param17(1, Body5()),
|
|
4185
|
+
_ts_metadata17("design:type", Function),
|
|
4186
|
+
_ts_metadata17("design:paramtypes", [
|
|
3692
4187
|
typeof Request === "undefined" ? Object : Request,
|
|
3693
4188
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
3694
4189
|
]),
|
|
3695
|
-
|
|
4190
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3696
4191
|
], ToolCallController.prototype, "approve", null);
|
|
3697
|
-
|
|
4192
|
+
_ts_decorate18([
|
|
3698
4193
|
Post6("reject"),
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
4194
|
+
_ts_param17(0, Req11()),
|
|
4195
|
+
_ts_param17(1, Body5()),
|
|
4196
|
+
_ts_metadata17("design:type", Function),
|
|
4197
|
+
_ts_metadata17("design:paramtypes", [
|
|
3703
4198
|
typeof Request === "undefined" ? Object : Request,
|
|
3704
4199
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
3705
4200
|
]),
|
|
3706
|
-
|
|
4201
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3707
4202
|
], ToolCallController.prototype, "reject", null);
|
|
3708
|
-
|
|
4203
|
+
_ts_decorate18([
|
|
3709
4204
|
Post6("answer"),
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
4205
|
+
_ts_param17(0, Req11()),
|
|
4206
|
+
_ts_param17(1, Body5()),
|
|
4207
|
+
_ts_metadata17("design:type", Function),
|
|
4208
|
+
_ts_metadata17("design:paramtypes", [
|
|
3714
4209
|
typeof Request === "undefined" ? Object : Request,
|
|
3715
4210
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
3716
4211
|
]),
|
|
3717
|
-
|
|
4212
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3718
4213
|
], ToolCallController.prototype, "answer", null);
|
|
3719
|
-
|
|
4214
|
+
_ts_decorate18([
|
|
3720
4215
|
Post6("skip"),
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
4216
|
+
_ts_param17(0, Req11()),
|
|
4217
|
+
_ts_param17(1, Body5()),
|
|
4218
|
+
_ts_metadata17("design:type", Function),
|
|
4219
|
+
_ts_metadata17("design:paramtypes", [
|
|
3725
4220
|
typeof Request === "undefined" ? Object : Request,
|
|
3726
4221
|
Object
|
|
3727
4222
|
]),
|
|
3728
|
-
|
|
4223
|
+
_ts_metadata17("design:returntype", Promise)
|
|
3729
4224
|
], ToolCallController.prototype, "skip", null);
|
|
3730
|
-
ToolCallController =
|
|
4225
|
+
ToolCallController = _ts_decorate18([
|
|
3731
4226
|
Controller12("tool-call"),
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
4227
|
+
_ts_param17(1, Inject17(AGENT_ACTOR_RESOLVER11)),
|
|
4228
|
+
_ts_metadata17("design:type", Function),
|
|
4229
|
+
_ts_metadata17("design:paramtypes", [
|
|
3735
4230
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
3736
4231
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
3737
4232
|
])
|
|
@@ -3739,8 +4234,8 @@ ToolCallController = _ts_decorate16([
|
|
|
3739
4234
|
|
|
3740
4235
|
// src/controller/tools.controller.ts
|
|
3741
4236
|
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER12, AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY4, AGENT_REGISTRY as AGENT_REGISTRY3, ALL_AGENTS, AgentRegistry as AgentRegistry4 } from "@dudousxd/nestjs-agent-core";
|
|
3742
|
-
import { Controller as Controller13, Get as Get11, Inject as
|
|
3743
|
-
function
|
|
4237
|
+
import { Controller as Controller13, Get as Get11, Inject as Inject18, NotFoundException as NotFoundException4, Query as Query5, Req as Req12 } from "@nestjs/common";
|
|
4238
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
3744
4239
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3745
4240
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3746
4241
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3753,19 +4248,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
3753
4248
|
}
|
|
3754
4249
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3755
4250
|
}
|
|
3756
|
-
__name(
|
|
3757
|
-
function
|
|
4251
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
4252
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
3758
4253
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3759
4254
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3760
4255
|
}
|
|
3761
4256
|
}
|
|
3762
|
-
__name(
|
|
3763
|
-
function
|
|
4257
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
4258
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3764
4259
|
return function(target, key) {
|
|
3765
4260
|
decorator(target, key, paramIndex);
|
|
3766
4261
|
};
|
|
3767
4262
|
}
|
|
3768
|
-
__name(
|
|
4263
|
+
__name(_ts_param18, "_ts_param");
|
|
3769
4264
|
var ToolsController = class {
|
|
3770
4265
|
static {
|
|
3771
4266
|
__name(this, "ToolsController");
|
|
@@ -3780,7 +4275,7 @@ var ToolsController = class {
|
|
|
3780
4275
|
}
|
|
3781
4276
|
async list(req, agent) {
|
|
3782
4277
|
if (agent !== void 0 && agent !== ALL_AGENTS && this.agents.get(agent) === void 0) {
|
|
3783
|
-
throw new
|
|
4278
|
+
throw new NotFoundException4(`No agent named "${agent}"`);
|
|
3784
4279
|
}
|
|
3785
4280
|
const actor = await this.actorResolver.resolve(req);
|
|
3786
4281
|
const names = agent === ALL_AGENTS ? [
|
|
@@ -3809,24 +4304,24 @@ var ToolsController = class {
|
|
|
3809
4304
|
];
|
|
3810
4305
|
}
|
|
3811
4306
|
};
|
|
3812
|
-
|
|
4307
|
+
_ts_decorate19([
|
|
3813
4308
|
Get11(),
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
4309
|
+
_ts_param18(0, Req12()),
|
|
4310
|
+
_ts_param18(1, Query5("agent")),
|
|
4311
|
+
_ts_metadata18("design:type", Function),
|
|
4312
|
+
_ts_metadata18("design:paramtypes", [
|
|
3818
4313
|
typeof Request === "undefined" ? Object : Request,
|
|
3819
4314
|
String
|
|
3820
4315
|
]),
|
|
3821
|
-
|
|
4316
|
+
_ts_metadata18("design:returntype", Promise)
|
|
3822
4317
|
], ToolsController.prototype, "list", null);
|
|
3823
|
-
ToolsController =
|
|
4318
|
+
ToolsController = _ts_decorate19([
|
|
3824
4319
|
Controller13("tools"),
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
4320
|
+
_ts_param18(0, Inject18(AGENT_ACTOR_RESOLVER12)),
|
|
4321
|
+
_ts_param18(1, Inject18(AGENT_DEPS_FACTORY4)),
|
|
4322
|
+
_ts_param18(2, Inject18(AGENT_REGISTRY3)),
|
|
4323
|
+
_ts_metadata18("design:type", Function),
|
|
4324
|
+
_ts_metadata18("design:paramtypes", [
|
|
3830
4325
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
3831
4326
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3832
4327
|
typeof AgentRegistry4 === "undefined" ? Object : AgentRegistry4
|
|
@@ -3835,7 +4330,7 @@ ToolsController = _ts_decorate17([
|
|
|
3835
4330
|
|
|
3836
4331
|
// src/discovery/agent-discovery.service.ts
|
|
3837
4332
|
import { AGENT_PROMPT_CONTRIBUTORS as AGENT_PROMPT_CONTRIBUTORS2, AGENT_REGISTRY as AGENT_REGISTRY4, AgentRegistry as AgentRegistry5 } from "@dudousxd/nestjs-agent-core";
|
|
3838
|
-
import { Inject as
|
|
4333
|
+
import { Inject as Inject19, Injectable as Injectable6, Logger as Logger2 } from "@nestjs/common";
|
|
3839
4334
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
3840
4335
|
|
|
3841
4336
|
// src/decorator/agent.decorator.ts
|
|
@@ -3870,7 +4365,7 @@ function SystemPromptContributor() {
|
|
|
3870
4365
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
3871
4366
|
|
|
3872
4367
|
// src/discovery/agent-discovery.service.ts
|
|
3873
|
-
function
|
|
4368
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3874
4369
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3875
4370
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3876
4371
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3883,19 +4378,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3883
4378
|
}
|
|
3884
4379
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3885
4380
|
}
|
|
3886
|
-
__name(
|
|
3887
|
-
function
|
|
4381
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
4382
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3888
4383
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3889
4384
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3890
4385
|
}
|
|
3891
4386
|
}
|
|
3892
|
-
__name(
|
|
3893
|
-
function
|
|
4387
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
4388
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3894
4389
|
return function(target, key) {
|
|
3895
4390
|
decorator(target, key, paramIndex);
|
|
3896
4391
|
};
|
|
3897
4392
|
}
|
|
3898
|
-
__name(
|
|
4393
|
+
__name(_ts_param19, "_ts_param");
|
|
3899
4394
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
3900
4395
|
static {
|
|
3901
4396
|
__name(this, "AgentDiscoveryService");
|
|
@@ -4061,12 +4556,12 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
4061
4556
|
return (ctx) => candidate.call(instance, ctx);
|
|
4062
4557
|
}
|
|
4063
4558
|
};
|
|
4064
|
-
AgentDiscoveryService =
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4559
|
+
AgentDiscoveryService = _ts_decorate20([
|
|
4560
|
+
Injectable6(),
|
|
4561
|
+
_ts_param19(2, Inject19(AGENT_REGISTRY4)),
|
|
4562
|
+
_ts_param19(3, Inject19(AGENT_PROMPT_CONTRIBUTORS2)),
|
|
4563
|
+
_ts_metadata19("design:type", Function),
|
|
4564
|
+
_ts_metadata19("design:paramtypes", [
|
|
4070
4565
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
4071
4566
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
4072
4567
|
typeof AgentRegistry5 === "undefined" ? Object : AgentRegistry5,
|
|
@@ -4075,8 +4570,8 @@ AgentDiscoveryService = _ts_decorate18([
|
|
|
4075
4570
|
], AgentDiscoveryService);
|
|
4076
4571
|
|
|
4077
4572
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4078
|
-
import { AGENT_OPTIONS as
|
|
4079
|
-
import { Inject as
|
|
4573
|
+
import { AGENT_OPTIONS as AGENT_OPTIONS7, AGENT_REGISTRY as AGENT_REGISTRY5, AGENT_TOOL_REGISTRY as AGENT_TOOL_REGISTRY2, normalizeDelegation as normalizeDelegation2 } from "@dudousxd/nestjs-agent-core";
|
|
4574
|
+
import { Inject as Inject20, Injectable as Injectable7, Logger as Logger3 } from "@nestjs/common";
|
|
4080
4575
|
import { DiscoveryService as DiscoveryService2 } from "@nestjs/core";
|
|
4081
4576
|
import { z } from "zod";
|
|
4082
4577
|
|
|
@@ -4108,46 +4603,8 @@ function readAiToolMetadata(target) {
|
|
|
4108
4603
|
}
|
|
4109
4604
|
__name(readAiToolMetadata, "readAiToolMetadata");
|
|
4110
4605
|
|
|
4111
|
-
// src/functional-tool.ts
|
|
4112
|
-
var AGENT_TOOL_BRAND = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:functional-tool");
|
|
4113
|
-
function brand(tool) {
|
|
4114
|
-
return {
|
|
4115
|
-
[AGENT_TOOL_BRAND]: true,
|
|
4116
|
-
spec: tool.spec,
|
|
4117
|
-
handler: tool.handler
|
|
4118
|
-
};
|
|
4119
|
-
}
|
|
4120
|
-
__name(brand, "brand");
|
|
4121
|
-
function isBrandedFunctionalTool(value) {
|
|
4122
|
-
return AGENT_TOOL_BRAND in value && "spec" in value && "handler" in value;
|
|
4123
|
-
}
|
|
4124
|
-
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
4125
|
-
function provideAgentTool(factoryOrTool, inject) {
|
|
4126
|
-
const provide = /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-instance");
|
|
4127
|
-
if (typeof factoryOrTool === "function") {
|
|
4128
|
-
return {
|
|
4129
|
-
provide,
|
|
4130
|
-
useFactory: /* @__PURE__ */ __name((...deps) => brand(factoryOrTool(...deps)), "useFactory"),
|
|
4131
|
-
inject: inject ?? []
|
|
4132
|
-
};
|
|
4133
|
-
}
|
|
4134
|
-
return {
|
|
4135
|
-
provide,
|
|
4136
|
-
useValue: brand(factoryOrTool)
|
|
4137
|
-
};
|
|
4138
|
-
}
|
|
4139
|
-
__name(provideAgentTool, "provideAgentTool");
|
|
4140
|
-
function provideAgentTools(factory, inject) {
|
|
4141
|
-
return {
|
|
4142
|
-
provide: /* @__PURE__ */ Symbol("nestjs-agent:functional-tool-list"),
|
|
4143
|
-
useFactory: /* @__PURE__ */ __name(async (...deps) => (await factory(...deps)).map(brand), "useFactory"),
|
|
4144
|
-
inject: inject ?? []
|
|
4145
|
-
};
|
|
4146
|
-
}
|
|
4147
|
-
__name(provideAgentTools, "provideAgentTools");
|
|
4148
|
-
|
|
4149
4606
|
// src/discovery/ai-tool-discovery.service.ts
|
|
4150
|
-
function
|
|
4607
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
4151
4608
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4152
4609
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4153
4610
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4160,19 +4617,19 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
4160
4617
|
}
|
|
4161
4618
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4162
4619
|
}
|
|
4163
|
-
__name(
|
|
4164
|
-
function
|
|
4620
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
4621
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
4165
4622
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4166
4623
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4167
4624
|
}
|
|
4168
4625
|
}
|
|
4169
|
-
__name(
|
|
4170
|
-
function
|
|
4626
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
4627
|
+
function _ts_param20(paramIndex, decorator) {
|
|
4171
4628
|
return function(target, key) {
|
|
4172
4629
|
decorator(target, key, paramIndex);
|
|
4173
4630
|
};
|
|
4174
4631
|
}
|
|
4175
|
-
__name(
|
|
4632
|
+
__name(_ts_param20, "_ts_param");
|
|
4176
4633
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
4177
4634
|
static {
|
|
4178
4635
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -4240,9 +4697,18 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4240
4697
|
} : {},
|
|
4241
4698
|
...meta.terminal === true ? {
|
|
4242
4699
|
terminal: true
|
|
4700
|
+
} : {},
|
|
4701
|
+
...meta.replacementKey !== void 0 ? {
|
|
4702
|
+
replacementKey: meta.replacementKey
|
|
4243
4703
|
} : {}
|
|
4244
4704
|
}, {
|
|
4245
4705
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
4706
|
+
...typeof handler.present === "function" ? {
|
|
4707
|
+
present: /* @__PURE__ */ __name((output, ctx) => instance.present(output, ctx), "present")
|
|
4708
|
+
} : {},
|
|
4709
|
+
...typeof handler.preflight === "function" ? {
|
|
4710
|
+
preflight: /* @__PURE__ */ __name((input, ctx, options) => instance.preflight(input, ctx, options), "preflight")
|
|
4711
|
+
} : {},
|
|
4246
4712
|
// Forwarded, not copied: the registry holds this wrapper rather than the provider, so an
|
|
4247
4713
|
// `isEnabled()`/`canUse()` left behind here would be a gate that silently never applies.
|
|
4248
4714
|
// Called through `instance` so each keeps its `this` (and its injected deps).
|
|
@@ -4316,13 +4782,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
4316
4782
|
return true;
|
|
4317
4783
|
}
|
|
4318
4784
|
};
|
|
4319
|
-
AiToolDiscoveryService =
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4785
|
+
AiToolDiscoveryService = _ts_decorate21([
|
|
4786
|
+
Injectable7(),
|
|
4787
|
+
_ts_param20(1, Inject20(AGENT_TOOL_REGISTRY2)),
|
|
4788
|
+
_ts_param20(2, Inject20(AGENT_REGISTRY5)),
|
|
4789
|
+
_ts_param20(3, Inject20(AGENT_OPTIONS7)),
|
|
4790
|
+
_ts_metadata20("design:type", Function),
|
|
4791
|
+
_ts_metadata20("design:paramtypes", [
|
|
4326
4792
|
typeof DiscoveryService2 === "undefined" ? Object : DiscoveryService2,
|
|
4327
4793
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
4328
4794
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -4332,7 +4798,7 @@ AiToolDiscoveryService = _ts_decorate19([
|
|
|
4332
4798
|
|
|
4333
4799
|
// src/discovery/skill-discovery.service.ts
|
|
4334
4800
|
import { AGENT_SKILL_SOURCES } from "@dudousxd/nestjs-agent-core";
|
|
4335
|
-
import { Inject as
|
|
4801
|
+
import { Inject as Inject21, Injectable as Injectable8, Logger as Logger4 } from "@nestjs/common";
|
|
4336
4802
|
import { DiscoveryService as DiscoveryService3 } from "@nestjs/core";
|
|
4337
4803
|
|
|
4338
4804
|
// src/decorator/skill.decorator.ts
|
|
@@ -4355,7 +4821,7 @@ function skillScope(options) {
|
|
|
4355
4821
|
__name(skillScope, "skillScope");
|
|
4356
4822
|
|
|
4357
4823
|
// src/discovery/skill-discovery.service.ts
|
|
4358
|
-
function
|
|
4824
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
4359
4825
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4360
4826
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4361
4827
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4368,19 +4834,19 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
4368
4834
|
}
|
|
4369
4835
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4370
4836
|
}
|
|
4371
|
-
__name(
|
|
4372
|
-
function
|
|
4837
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
4838
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
4373
4839
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4374
4840
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4375
4841
|
}
|
|
4376
4842
|
}
|
|
4377
|
-
__name(
|
|
4378
|
-
function
|
|
4843
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
4844
|
+
function _ts_param21(paramIndex, decorator) {
|
|
4379
4845
|
return function(target, key) {
|
|
4380
4846
|
decorator(target, key, paramIndex);
|
|
4381
4847
|
};
|
|
4382
4848
|
}
|
|
4383
|
-
__name(
|
|
4849
|
+
__name(_ts_param21, "_ts_param");
|
|
4384
4850
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
4385
4851
|
static {
|
|
4386
4852
|
__name(this, "SkillDiscoveryService");
|
|
@@ -4424,11 +4890,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
4424
4890
|
return flat === void 0 ? void 0 : () => flat;
|
|
4425
4891
|
}
|
|
4426
4892
|
};
|
|
4427
|
-
SkillDiscoveryService =
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4893
|
+
SkillDiscoveryService = _ts_decorate22([
|
|
4894
|
+
Injectable8(),
|
|
4895
|
+
_ts_param21(1, Inject21(AGENT_SKILL_SOURCES)),
|
|
4896
|
+
_ts_metadata21("design:type", Function),
|
|
4897
|
+
_ts_metadata21("design:paramtypes", [
|
|
4432
4898
|
typeof DiscoveryService3 === "undefined" ? Object : DiscoveryService3,
|
|
4433
4899
|
Array
|
|
4434
4900
|
])
|
|
@@ -4564,13 +5030,248 @@ var LedgerQuotaProvider = class {
|
|
|
4564
5030
|
}
|
|
4565
5031
|
};
|
|
4566
5032
|
|
|
5033
|
+
// src/proposals/action-proposal-worker.service.ts
|
|
5034
|
+
import { randomUUID } from "crypto";
|
|
5035
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY5, AGENT_OPTIONS as AGENT_OPTIONS8, AGENT_STORE as AGENT_STORE5, ActionProposalExecutor, ActionProposalWorker, assertIndependentActionCapabilities as assertIndependentActionCapabilities2 } from "@dudousxd/nestjs-agent-core";
|
|
5036
|
+
import { Inject as Inject22, Injectable as Injectable9, Logger as Logger5 } from "@nestjs/common";
|
|
5037
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
5038
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5039
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5040
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5041
|
+
} else {
|
|
5042
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
5043
|
+
if (d = decorators[i]) {
|
|
5044
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5045
|
+
}
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
5048
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5049
|
+
}
|
|
5050
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
5051
|
+
function _ts_metadata22(metadataKey, metadataValue) {
|
|
5052
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5053
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
5054
|
+
}
|
|
5055
|
+
}
|
|
5056
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
5057
|
+
function _ts_param22(paramIndex, decorator) {
|
|
5058
|
+
return function(target, key) {
|
|
5059
|
+
decorator(target, key, paramIndex);
|
|
5060
|
+
};
|
|
5061
|
+
}
|
|
5062
|
+
__name(_ts_param22, "_ts_param");
|
|
5063
|
+
var ActionProposalWorkerService = class _ActionProposalWorkerService {
|
|
5064
|
+
static {
|
|
5065
|
+
__name(this, "ActionProposalWorkerService");
|
|
5066
|
+
}
|
|
5067
|
+
store;
|
|
5068
|
+
options;
|
|
5069
|
+
deps;
|
|
5070
|
+
worker;
|
|
5071
|
+
logger = new Logger5(_ActionProposalWorkerService.name);
|
|
5072
|
+
constructor(store, options, deps) {
|
|
5073
|
+
this.store = store;
|
|
5074
|
+
this.options = options;
|
|
5075
|
+
this.deps = deps;
|
|
5076
|
+
}
|
|
5077
|
+
onModuleInit() {
|
|
5078
|
+
if (this.options.actionApprovalMode !== "independent") return;
|
|
5079
|
+
assertIndependentActionCapabilities2(this.store, this.options.backgroundActorResolver);
|
|
5080
|
+
if (this.options.surface === "http") return;
|
|
5081
|
+
const resolver = this.options.backgroundActorResolver;
|
|
5082
|
+
if (!resolver) throw new Error("BackgroundActorResolver is required");
|
|
5083
|
+
this.worker = new ActionProposalWorker({
|
|
5084
|
+
store: this.store,
|
|
5085
|
+
workerId: randomUUID(),
|
|
5086
|
+
...this.options.actionProposalWorker,
|
|
5087
|
+
executor: new ActionProposalExecutor({
|
|
5088
|
+
resolver,
|
|
5089
|
+
resolveExecution: /* @__PURE__ */ __name(async (proposal, actor) => {
|
|
5090
|
+
const deps = this.deps.forProposal(proposal, actor);
|
|
5091
|
+
return {
|
|
5092
|
+
registry: deps.registry,
|
|
5093
|
+
rolesPolicy: deps.rolesPolicy,
|
|
5094
|
+
...deps.resolveUiCatalog !== void 0 ? {
|
|
5095
|
+
resolveUiCatalog: deps.resolveUiCatalog
|
|
5096
|
+
} : {},
|
|
5097
|
+
...deps.toolAllowList !== void 0 ? {
|
|
5098
|
+
allowedTools: deps.toolAllowList
|
|
5099
|
+
} : {}
|
|
5100
|
+
};
|
|
5101
|
+
}, "resolveExecution")
|
|
5102
|
+
}),
|
|
5103
|
+
onError: /* @__PURE__ */ __name((error) => this.logger.error(error), "onError")
|
|
5104
|
+
});
|
|
5105
|
+
this.worker.start();
|
|
5106
|
+
}
|
|
5107
|
+
async onModuleDestroy() {
|
|
5108
|
+
await this.worker?.stop();
|
|
5109
|
+
}
|
|
5110
|
+
};
|
|
5111
|
+
ActionProposalWorkerService = _ts_decorate23([
|
|
5112
|
+
Injectable9(),
|
|
5113
|
+
_ts_param22(0, Inject22(AGENT_STORE5)),
|
|
5114
|
+
_ts_param22(1, Inject22(AGENT_OPTIONS8)),
|
|
5115
|
+
_ts_param22(2, Inject22(AGENT_DEPS_FACTORY5)),
|
|
5116
|
+
_ts_metadata22("design:type", Function),
|
|
5117
|
+
_ts_metadata22("design:paramtypes", [
|
|
5118
|
+
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
5119
|
+
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
5120
|
+
typeof AgentDepsFactory2 === "undefined" ? Object : AgentDepsFactory2
|
|
5121
|
+
])
|
|
5122
|
+
], ActionProposalWorkerService);
|
|
5123
|
+
|
|
5124
|
+
// src/proposals/action-proposal.controller.ts
|
|
5125
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER13, validateActionProposalListQuery } from "@dudousxd/nestjs-agent-core";
|
|
5126
|
+
import { BadRequestException as BadRequestException7, Body as Body6, Controller as Controller14, Get as Get12, Inject as Inject23, Param as Param6, Post as Post7, Query as Query6, Req as Req13, Res as Res2 } from "@nestjs/common";
|
|
5127
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
5128
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5129
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5130
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5131
|
+
} else {
|
|
5132
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
5133
|
+
if (d = decorators[i]) {
|
|
5134
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5135
|
+
}
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5139
|
+
}
|
|
5140
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
5141
|
+
function _ts_metadata23(metadataKey, metadataValue) {
|
|
5142
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5143
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
5147
|
+
function _ts_param23(paramIndex, decorator) {
|
|
5148
|
+
return function(target, key) {
|
|
5149
|
+
decorator(target, key, paramIndex);
|
|
5150
|
+
};
|
|
5151
|
+
}
|
|
5152
|
+
__name(_ts_param23, "_ts_param");
|
|
5153
|
+
function bodyFields(body, field2) {
|
|
5154
|
+
if (body === void 0) return {};
|
|
5155
|
+
if (typeof body !== "object" || body === null || Array.isArray(body) || Object.keys(body).some((key) => key !== field2)) throw new BadRequestException7(`Only ${field2} is accepted`);
|
|
5156
|
+
const value = body;
|
|
5157
|
+
if (value[field2] !== void 0 && (field2 === "remember" && typeof value[field2] !== "boolean" || field2 === "reason" && typeof value[field2] !== "string")) throw new BadRequestException7(`Invalid ${field2}`);
|
|
5158
|
+
return value;
|
|
5159
|
+
}
|
|
5160
|
+
__name(bodyFields, "bodyFields");
|
|
5161
|
+
var ActionProposalController = class {
|
|
5162
|
+
static {
|
|
5163
|
+
__name(this, "ActionProposalController");
|
|
5164
|
+
}
|
|
5165
|
+
proposals;
|
|
5166
|
+
actors;
|
|
5167
|
+
constructor(proposals, actors) {
|
|
5168
|
+
this.proposals = proposals;
|
|
5169
|
+
this.actors = actors;
|
|
5170
|
+
}
|
|
5171
|
+
async list(threadId, request, cursor, response) {
|
|
5172
|
+
let query = {};
|
|
5173
|
+
if (cursor !== void 0) {
|
|
5174
|
+
try {
|
|
5175
|
+
if (typeof cursor !== "string") throw new Error("Invalid cursor");
|
|
5176
|
+
query = {
|
|
5177
|
+
after: JSON.parse(cursor)
|
|
5178
|
+
};
|
|
5179
|
+
validateActionProposalListQuery(query);
|
|
5180
|
+
} catch {
|
|
5181
|
+
throw new BadRequestException7("Invalid action proposal cursor");
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
const page = await this.proposals.listPage(threadId, await this.actors.resolve(request), query);
|
|
5185
|
+
if (page.next) {
|
|
5186
|
+
response.setHeader("X-Action-Proposals-Next", encodeURIComponent(JSON.stringify(page.next)));
|
|
5187
|
+
const exposed = response.getHeader("Access-Control-Expose-Headers");
|
|
5188
|
+
response.setHeader("Access-Control-Expose-Headers", `${exposed === void 0 ? "" : `${String(exposed)}, `}X-Action-Proposals-Next`);
|
|
5189
|
+
}
|
|
5190
|
+
return page.items;
|
|
5191
|
+
}
|
|
5192
|
+
async approve(threadId, proposalId, request, body) {
|
|
5193
|
+
const value = bodyFields(body, "remember");
|
|
5194
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
5195
|
+
decision: "approved",
|
|
5196
|
+
...typeof value.remember === "boolean" ? {
|
|
5197
|
+
remember: value.remember
|
|
5198
|
+
} : {}
|
|
5199
|
+
});
|
|
5200
|
+
}
|
|
5201
|
+
async reject(threadId, proposalId, request, body) {
|
|
5202
|
+
const value = bodyFields(body, "reason");
|
|
5203
|
+
return this.proposals.decide(threadId, proposalId, await this.actors.resolve(request), {
|
|
5204
|
+
decision: "rejected",
|
|
5205
|
+
...typeof value.reason === "string" ? {
|
|
5206
|
+
reason: value.reason
|
|
5207
|
+
} : {}
|
|
5208
|
+
});
|
|
5209
|
+
}
|
|
5210
|
+
};
|
|
5211
|
+
_ts_decorate24([
|
|
5212
|
+
Get12(),
|
|
5213
|
+
_ts_param23(0, Param6("threadId")),
|
|
5214
|
+
_ts_param23(1, Req13()),
|
|
5215
|
+
_ts_param23(2, Query6("after")),
|
|
5216
|
+
_ts_param23(3, Res2({
|
|
5217
|
+
passthrough: true
|
|
5218
|
+
})),
|
|
5219
|
+
_ts_metadata23("design:type", Function),
|
|
5220
|
+
_ts_metadata23("design:paramtypes", [
|
|
5221
|
+
String,
|
|
5222
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5223
|
+
Object,
|
|
5224
|
+
typeof Response === "undefined" ? Object : Response
|
|
5225
|
+
]),
|
|
5226
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5227
|
+
], ActionProposalController.prototype, "list", null);
|
|
5228
|
+
_ts_decorate24([
|
|
5229
|
+
Post7(":proposalId/approve"),
|
|
5230
|
+
_ts_param23(0, Param6("threadId")),
|
|
5231
|
+
_ts_param23(1, Param6("proposalId")),
|
|
5232
|
+
_ts_param23(2, Req13()),
|
|
5233
|
+
_ts_param23(3, Body6()),
|
|
5234
|
+
_ts_metadata23("design:type", Function),
|
|
5235
|
+
_ts_metadata23("design:paramtypes", [
|
|
5236
|
+
String,
|
|
5237
|
+
String,
|
|
5238
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5239
|
+
Object
|
|
5240
|
+
]),
|
|
5241
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5242
|
+
], ActionProposalController.prototype, "approve", null);
|
|
5243
|
+
_ts_decorate24([
|
|
5244
|
+
Post7(":proposalId/reject"),
|
|
5245
|
+
_ts_param23(0, Param6("threadId")),
|
|
5246
|
+
_ts_param23(1, Param6("proposalId")),
|
|
5247
|
+
_ts_param23(2, Req13()),
|
|
5248
|
+
_ts_param23(3, Body6()),
|
|
5249
|
+
_ts_metadata23("design:type", Function),
|
|
5250
|
+
_ts_metadata23("design:paramtypes", [
|
|
5251
|
+
String,
|
|
5252
|
+
String,
|
|
5253
|
+
typeof Request === "undefined" ? Object : Request,
|
|
5254
|
+
Object
|
|
5255
|
+
]),
|
|
5256
|
+
_ts_metadata23("design:returntype", Promise)
|
|
5257
|
+
], ActionProposalController.prototype, "reject", null);
|
|
5258
|
+
ActionProposalController = _ts_decorate24([
|
|
5259
|
+
Controller14("threads/:threadId/action-proposals"),
|
|
5260
|
+
_ts_param23(1, Inject23(AGENT_ACTOR_RESOLVER13)),
|
|
5261
|
+
_ts_metadata23("design:type", Function),
|
|
5262
|
+
_ts_metadata23("design:paramtypes", [
|
|
5263
|
+
typeof ActionProposalService === "undefined" ? Object : ActionProposalService,
|
|
5264
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
5265
|
+
])
|
|
5266
|
+
], ActionProposalController);
|
|
5267
|
+
|
|
4567
5268
|
// src/queue/chat-queue.token.ts
|
|
4568
5269
|
var AGENT_CHAT_QUEUE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:chat-queue");
|
|
4569
5270
|
|
|
4570
5271
|
// src/runner/inline-agent-runner.ts
|
|
4571
|
-
import { AGENT_DEPS_FACTORY as
|
|
4572
|
-
import { Inject as
|
|
4573
|
-
function
|
|
5272
|
+
import { AGENT_DEPS_FACTORY as AGENT_DEPS_FACTORY6, AGENT_STORE as AGENT_STORE6, RUN_ENDED_BEFORE_TOOL_CALL, RunCancelledError, agentFailureCode, encodeStreamEvent as encodeStreamEvent2, publishAgentRunFailed, releaseThreadRun, runAgentLoop, settleAll, settleUnsettledDelegation, streamFailure as streamFailure2 } from "@dudousxd/nestjs-agent-core";
|
|
5273
|
+
import { Inject as Inject24, Injectable as Injectable10, Logger as Logger6, Optional as Optional9 } from "@nestjs/common";
|
|
5274
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4574
5275
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4575
5276
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
4576
5277
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4583,19 +5284,19 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
4583
5284
|
}
|
|
4584
5285
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4585
5286
|
}
|
|
4586
|
-
__name(
|
|
4587
|
-
function
|
|
5287
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
5288
|
+
function _ts_metadata24(metadataKey, metadataValue) {
|
|
4588
5289
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
4589
5290
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
4590
5291
|
}
|
|
4591
5292
|
}
|
|
4592
|
-
__name(
|
|
4593
|
-
function
|
|
5293
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
5294
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4594
5295
|
return function(target, key) {
|
|
4595
5296
|
decorator(target, key, paramIndex);
|
|
4596
5297
|
};
|
|
4597
5298
|
}
|
|
4598
|
-
__name(
|
|
5299
|
+
__name(_ts_param24, "_ts_param");
|
|
4599
5300
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
4600
5301
|
static {
|
|
4601
5302
|
__name(this, "InlineAgentRunner");
|
|
@@ -4603,7 +5304,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
4603
5304
|
factory;
|
|
4604
5305
|
store;
|
|
4605
5306
|
queue;
|
|
4606
|
-
logger = new
|
|
5307
|
+
logger = new Logger6(_InlineAgentRunner.name);
|
|
4607
5308
|
pending = /* @__PURE__ */ new Map();
|
|
4608
5309
|
/**
|
|
4609
5310
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -5046,13 +5747,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
5046
5747
|
}
|
|
5047
5748
|
}
|
|
5048
5749
|
};
|
|
5049
|
-
InlineAgentRunner =
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5750
|
+
InlineAgentRunner = _ts_decorate25([
|
|
5751
|
+
Injectable10(),
|
|
5752
|
+
_ts_param24(0, Inject24(AGENT_DEPS_FACTORY6)),
|
|
5753
|
+
_ts_param24(1, Inject24(AGENT_STORE6)),
|
|
5754
|
+
_ts_param24(2, Optional9()),
|
|
5755
|
+
_ts_metadata24("design:type", Function),
|
|
5756
|
+
_ts_metadata24("design:paramtypes", [
|
|
5056
5757
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
5057
5758
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
5058
5759
|
typeof ChatQueueService === "undefined" ? Object : ChatQueueService
|
|
@@ -5102,7 +5803,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
5102
5803
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
5103
5804
|
|
|
5104
5805
|
// src/agent.module.ts
|
|
5105
|
-
function
|
|
5806
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
5106
5807
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5107
5808
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5108
5809
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5115,18 +5816,18 @@ function _ts_decorate22(decorators, target, key, desc) {
|
|
|
5115
5816
|
}
|
|
5116
5817
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5117
5818
|
}
|
|
5118
|
-
__name(
|
|
5819
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
5119
5820
|
var DEFAULT_PATH = "agent";
|
|
5120
|
-
var logger = new
|
|
5121
|
-
function
|
|
5821
|
+
var logger = new Logger7("AgentModule");
|
|
5822
|
+
function externalWrapper(modules, token) {
|
|
5122
5823
|
for (const module of modules.values()) {
|
|
5123
5824
|
if (module.metatype === AgentModule) continue;
|
|
5124
|
-
const wrapper = module.providers.get(
|
|
5825
|
+
const wrapper = module.providers.get(token);
|
|
5125
5826
|
if (wrapper !== void 0) return wrapper;
|
|
5126
5827
|
}
|
|
5127
5828
|
return void 0;
|
|
5128
5829
|
}
|
|
5129
|
-
__name(
|
|
5830
|
+
__name(externalWrapper, "externalWrapper");
|
|
5130
5831
|
function forwardingStore(wrapper) {
|
|
5131
5832
|
const target = /* @__PURE__ */ __name(() => {
|
|
5132
5833
|
const instance = wrapper.instance;
|
|
@@ -5149,12 +5850,36 @@ function forwardingStore(wrapper) {
|
|
|
5149
5850
|
__name(forwardingStore, "forwardingStore");
|
|
5150
5851
|
function resolveStore(options, modules) {
|
|
5151
5852
|
if (options.store !== void 0) return options.store;
|
|
5152
|
-
const external =
|
|
5853
|
+
const external = externalWrapper(modules, AGENT_STORE7);
|
|
5153
5854
|
if (external !== void 0) return forwardingStore(external);
|
|
5154
5855
|
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()).");
|
|
5155
5856
|
return new InMemoryAgentStore();
|
|
5156
5857
|
}
|
|
5157
5858
|
__name(resolveStore, "resolveStore");
|
|
5859
|
+
function resolveRolesPolicy(options, modules) {
|
|
5860
|
+
const external = externalWrapper(modules, AGENT_ROLES_POLICY2);
|
|
5861
|
+
if (options.rolesPolicy !== void 0) {
|
|
5862
|
+
if (external !== void 0) {
|
|
5863
|
+
logger.warn("Both a `rolesPolicy` option and a module binding AGENT_ROLES_POLICY (e.g. AgentAuthzModule) are configured \u2014 the `rolesPolicy` option wins.");
|
|
5864
|
+
}
|
|
5865
|
+
return options.rolesPolicy;
|
|
5866
|
+
}
|
|
5867
|
+
if (external !== void 0) return forwardingPolicy(external);
|
|
5868
|
+
return options.emptyRoles === "deny" ? new ClosedRolesPolicy(options.defaultRoles) : new DefaultRolesPolicy(options.defaultRoles);
|
|
5869
|
+
}
|
|
5870
|
+
__name(resolveRolesPolicy, "resolveRolesPolicy");
|
|
5871
|
+
function forwardingPolicy(wrapper) {
|
|
5872
|
+
return {
|
|
5873
|
+
can(actor, tool) {
|
|
5874
|
+
const policy = wrapper.instance;
|
|
5875
|
+
if (policy === void 0 || policy === null) {
|
|
5876
|
+
throw new Error("AgentModule: the AGENT_ROLES_POLICY bound by another module is not ready yet");
|
|
5877
|
+
}
|
|
5878
|
+
return policy.can(actor, tool);
|
|
5879
|
+
}
|
|
5880
|
+
};
|
|
5881
|
+
}
|
|
5882
|
+
__name(forwardingPolicy, "forwardingPolicy");
|
|
5158
5883
|
function isQuotaProvider(quota) {
|
|
5159
5884
|
return quota !== void 0 && typeof quota.report === "function";
|
|
5160
5885
|
}
|
|
@@ -5194,7 +5919,7 @@ function sharedProviders(durable) {
|
|
|
5194
5919
|
provide: AGENT_SKILLS3,
|
|
5195
5920
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
5196
5921
|
inject: [
|
|
5197
|
-
|
|
5922
|
+
AGENT_OPTIONS9,
|
|
5198
5923
|
AGENT_SKILL_SOURCES2
|
|
5199
5924
|
]
|
|
5200
5925
|
},
|
|
@@ -5204,39 +5929,40 @@ function sharedProviders(durable) {
|
|
|
5204
5929
|
provide: AGENT_MEMORY3,
|
|
5205
5930
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
5206
5931
|
inject: [
|
|
5207
|
-
|
|
5932
|
+
AGENT_OPTIONS9
|
|
5208
5933
|
]
|
|
5209
5934
|
},
|
|
5210
5935
|
{
|
|
5211
5936
|
provide: AGENT_SINK3,
|
|
5212
5937
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
5213
5938
|
inject: [
|
|
5214
|
-
|
|
5939
|
+
AGENT_OPTIONS9
|
|
5215
5940
|
]
|
|
5216
5941
|
},
|
|
5217
5942
|
{
|
|
5218
5943
|
provide: AGENT_ROLES_POLICY2,
|
|
5219
|
-
useFactory: /* @__PURE__ */ __name((options) =>
|
|
5944
|
+
useFactory: /* @__PURE__ */ __name((options, modules) => resolveRolesPolicy(options, modules), "useFactory"),
|
|
5220
5945
|
inject: [
|
|
5221
|
-
|
|
5946
|
+
AGENT_OPTIONS9,
|
|
5947
|
+
ModulesContainer
|
|
5222
5948
|
]
|
|
5223
5949
|
},
|
|
5224
5950
|
{
|
|
5225
|
-
provide:
|
|
5951
|
+
provide: AGENT_ACTOR_RESOLVER14,
|
|
5226
5952
|
useFactory: /* @__PURE__ */ __name((options) => {
|
|
5227
5953
|
if (options.actorResolver !== void 0) return options.actorResolver;
|
|
5228
5954
|
logger.warn("No `actorResolver` configured \u2014 the agent endpoints are PUBLIC: every browser gets its own anonymous identity (an HttpOnly cookie). Set `actorResolver: requestUserActorResolver()` (or your own) to require login.");
|
|
5229
5955
|
return new AnonymousActorResolver();
|
|
5230
5956
|
}, "useFactory"),
|
|
5231
5957
|
inject: [
|
|
5232
|
-
|
|
5958
|
+
AGENT_OPTIONS9
|
|
5233
5959
|
]
|
|
5234
5960
|
},
|
|
5235
5961
|
{
|
|
5236
5962
|
provide: AGENT_MODEL2,
|
|
5237
5963
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
5238
5964
|
inject: [
|
|
5239
|
-
|
|
5965
|
+
AGENT_OPTIONS9
|
|
5240
5966
|
]
|
|
5241
5967
|
},
|
|
5242
5968
|
{
|
|
@@ -5247,20 +5973,20 @@ function sharedProviders(durable) {
|
|
|
5247
5973
|
warnAt: o.quota.warnAt
|
|
5248
5974
|
} : {}), "useFactory"),
|
|
5249
5975
|
inject: [
|
|
5250
|
-
|
|
5251
|
-
|
|
5976
|
+
AGENT_OPTIONS9,
|
|
5977
|
+
AGENT_STORE7
|
|
5252
5978
|
]
|
|
5253
5979
|
},
|
|
5254
5980
|
{
|
|
5255
5981
|
provide: AGENT_MODEL_CATALOG3,
|
|
5256
5982
|
useFactory: /* @__PURE__ */ __name((o) => resolveCatalog(o), "useFactory"),
|
|
5257
5983
|
inject: [
|
|
5258
|
-
|
|
5984
|
+
AGENT_OPTIONS9
|
|
5259
5985
|
]
|
|
5260
5986
|
},
|
|
5261
5987
|
AgentDepsFactory2,
|
|
5262
5988
|
{
|
|
5263
|
-
provide:
|
|
5989
|
+
provide: AGENT_DEPS_FACTORY7,
|
|
5264
5990
|
useExisting: AgentDepsFactory2
|
|
5265
5991
|
},
|
|
5266
5992
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -5277,6 +6003,8 @@ function sharedProviders(durable) {
|
|
|
5277
6003
|
},
|
|
5278
6004
|
InlineAgentRunner,
|
|
5279
6005
|
AgentService,
|
|
6006
|
+
ActionProposalService,
|
|
6007
|
+
ActionProposalWorkerService,
|
|
5280
6008
|
// Bound ALWAYS (durable or inline) — the console's cross-thread approvals inbox routes decisions
|
|
5281
6009
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
5282
6010
|
AgentApprovalPortAdapter,
|
|
@@ -5286,10 +6014,10 @@ function sharedProviders(durable) {
|
|
|
5286
6014
|
}
|
|
5287
6015
|
];
|
|
5288
6016
|
providers.push({
|
|
5289
|
-
provide:
|
|
6017
|
+
provide: AGENT_STORE7,
|
|
5290
6018
|
useFactory: /* @__PURE__ */ __name((o, modules) => resolveStore(o, modules), "useFactory"),
|
|
5291
6019
|
inject: [
|
|
5292
|
-
|
|
6020
|
+
AGENT_OPTIONS9,
|
|
5293
6021
|
ModulesContainer
|
|
5294
6022
|
]
|
|
5295
6023
|
});
|
|
@@ -5320,22 +6048,24 @@ function sharedProviders(durable) {
|
|
|
5320
6048
|
__name(sharedProviders, "sharedProviders");
|
|
5321
6049
|
function exportsFor() {
|
|
5322
6050
|
return [
|
|
5323
|
-
|
|
6051
|
+
AGENT_OPTIONS9,
|
|
5324
6052
|
AGENT_TOOL_REGISTRY3,
|
|
5325
6053
|
AGENT_REGISTRY6,
|
|
5326
6054
|
AGENT_SINK3,
|
|
5327
6055
|
AGENT_ROLES_POLICY2,
|
|
5328
|
-
|
|
6056
|
+
AGENT_ACTOR_RESOLVER14,
|
|
5329
6057
|
AGENT_MODEL2,
|
|
5330
|
-
|
|
6058
|
+
AGENT_STORE7,
|
|
5331
6059
|
AGENT_MODEL_CATALOG3,
|
|
5332
6060
|
AGENT_QUOTA_PROVIDER3,
|
|
5333
6061
|
AGENT_PROMPT_CONTRIBUTORS3,
|
|
5334
6062
|
AGENT_SKILLS3,
|
|
5335
6063
|
AGENT_MEMORY3,
|
|
5336
|
-
|
|
6064
|
+
AGENT_DEPS_FACTORY7,
|
|
5337
6065
|
AgentDepsFactory2,
|
|
5338
6066
|
AgentService,
|
|
6067
|
+
ActionProposalService,
|
|
6068
|
+
ActionProposalWorkerService,
|
|
5339
6069
|
ChatQueueService,
|
|
5340
6070
|
AGENT_CHAT_QUEUE,
|
|
5341
6071
|
InlineAgentRunner,
|
|
@@ -5344,6 +6074,7 @@ function exportsFor() {
|
|
|
5344
6074
|
}
|
|
5345
6075
|
__name(exportsFor, "exportsFor");
|
|
5346
6076
|
var BASE_CONTROLLERS = [
|
|
6077
|
+
ActionProposalController,
|
|
5347
6078
|
ChatController,
|
|
5348
6079
|
QueueController,
|
|
5349
6080
|
ThreadsController,
|
|
@@ -5416,7 +6147,7 @@ var AgentModule = class _AgentModule {
|
|
|
5416
6147
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5417
6148
|
providers: [
|
|
5418
6149
|
{
|
|
5419
|
-
provide:
|
|
6150
|
+
provide: AGENT_OPTIONS9,
|
|
5420
6151
|
useValue: options
|
|
5421
6152
|
},
|
|
5422
6153
|
...sharedProviders(options.durable ?? false),
|
|
@@ -5440,7 +6171,7 @@ var AgentModule = class _AgentModule {
|
|
|
5440
6171
|
controllers: controllersForSurface(options.surface, options.adapters),
|
|
5441
6172
|
providers: [
|
|
5442
6173
|
{
|
|
5443
|
-
provide:
|
|
6174
|
+
provide: AGENT_OPTIONS9,
|
|
5444
6175
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
5445
6176
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
5446
6177
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -5462,16 +6193,16 @@ var AgentModule = class _AgentModule {
|
|
|
5462
6193
|
};
|
|
5463
6194
|
}
|
|
5464
6195
|
};
|
|
5465
|
-
AgentModule =
|
|
6196
|
+
AgentModule = _ts_decorate26([
|
|
5466
6197
|
Global(),
|
|
5467
|
-
|
|
6198
|
+
Module2({})
|
|
5468
6199
|
], AgentModule);
|
|
5469
6200
|
|
|
5470
6201
|
// src/ag-ui/ag-ui.adapter.ts
|
|
5471
|
-
import { AGENT_ACTOR_RESOLVER as
|
|
5472
|
-
import { AG_UI_CUSTOM, agUiEvents, agUiFramesFromNdjson, agUiSse, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn } from "@dudousxd/nestjs-agent-core/ag-ui";
|
|
5473
|
-
import { BadRequestException as
|
|
5474
|
-
function
|
|
6202
|
+
import { AGENT_ACTOR_RESOLVER as AGENT_ACTOR_RESOLVER15, AGENT_ATTACHMENT_STAGING as AGENT_ATTACHMENT_STAGING5, AGENT_OPTIONS as AGENT_OPTIONS10 } from "@dudousxd/nestjs-agent-core";
|
|
6203
|
+
import { AG_UI_CUSTOM, actionProposalDecisionEvents, agUiEvents, agUiFramesFromNdjson, agUiSse, parseRunInput, planResume, readAnswersPayload, readApprovalPayload, readContext, readForwardedProps, readUserTurn } from "@dudousxd/nestjs-agent-core/ag-ui";
|
|
6204
|
+
import { BadRequestException as BadRequestException8, Body as Body7, Controller as Controller15, ForbiddenException as ForbiddenException4, HttpCode as HttpCode2, Inject as Inject25, Optional as Optional10, Post as Post8, Req as Req14, Res as Res3 } from "@nestjs/common";
|
|
6205
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
5475
6206
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5476
6207
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
5477
6208
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5484,22 +6215,22 @@ function _ts_decorate23(decorators, target, key, desc) {
|
|
|
5484
6215
|
}
|
|
5485
6216
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5486
6217
|
}
|
|
5487
|
-
__name(
|
|
5488
|
-
function
|
|
6218
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
6219
|
+
function _ts_metadata25(metadataKey, metadataValue) {
|
|
5489
6220
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
5490
6221
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
5491
6222
|
}
|
|
5492
6223
|
}
|
|
5493
|
-
__name(
|
|
5494
|
-
function
|
|
6224
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
6225
|
+
function _ts_param25(paramIndex, decorator) {
|
|
5495
6226
|
return function(target, key) {
|
|
5496
6227
|
decorator(target, key, paramIndex);
|
|
5497
6228
|
};
|
|
5498
6229
|
}
|
|
5499
|
-
__name(
|
|
6230
|
+
__name(_ts_param25, "_ts_param");
|
|
5500
6231
|
var AG_UI_VIA = "ag-ui";
|
|
5501
6232
|
function invalid(code, message) {
|
|
5502
|
-
return new
|
|
6233
|
+
return new BadRequestException8({
|
|
5503
6234
|
statusCode: 400,
|
|
5504
6235
|
code,
|
|
5505
6236
|
message
|
|
@@ -5555,6 +6286,19 @@ var AgUiRunHandler = class {
|
|
|
5555
6286
|
warnings.push(`The resume entry ${id} answers an interrupt this agent did not raise.`);
|
|
5556
6287
|
}
|
|
5557
6288
|
const first = plan.decisions[0];
|
|
6289
|
+
if (first !== void 0 && plan.decisions.every((d) => d.address.kind === "proposal")) {
|
|
6290
|
+
const decided = await this.decideProposals(actor, plan.decisions);
|
|
6291
|
+
this.writeEvents(res, [
|
|
6292
|
+
...warningEvents(warnings),
|
|
6293
|
+
...decided.flatMap((outcome, index) => actionProposalDecisionEvents({
|
|
6294
|
+
threadId: input.threadId,
|
|
6295
|
+
runId: index === 0 ? input.runId : `${input.runId}:${index}`,
|
|
6296
|
+
text: outcome.text,
|
|
6297
|
+
proposalDecision: outcome.proposalDecision
|
|
6298
|
+
}))
|
|
6299
|
+
]);
|
|
6300
|
+
return;
|
|
6301
|
+
}
|
|
5558
6302
|
if (first !== void 0) {
|
|
5559
6303
|
const streamRunId = first.address.stream;
|
|
5560
6304
|
await this.agent.assertResumable(actor, streamRunId);
|
|
@@ -5578,7 +6322,22 @@ var AgUiRunHandler = class {
|
|
|
5578
6322
|
warnings.push(...turn.dropped);
|
|
5579
6323
|
const owner = await this.agent.threadOwner(input.threadId);
|
|
5580
6324
|
if (owner !== null && owner !== actor.id) {
|
|
5581
|
-
throw new
|
|
6325
|
+
throw new ForbiddenException4("thread belongs to another actor");
|
|
6326
|
+
}
|
|
6327
|
+
if (owner !== null && turn.media.length === 0) {
|
|
6328
|
+
const decision = await this.agent.handleTextDecision(input.threadId, actor, turn.text);
|
|
6329
|
+
if ("proposalDecision" in decision) {
|
|
6330
|
+
this.writeEvents(res, [
|
|
6331
|
+
...warningEvents(warnings),
|
|
6332
|
+
...actionProposalDecisionEvents({
|
|
6333
|
+
threadId: input.threadId,
|
|
6334
|
+
runId: input.runId,
|
|
6335
|
+
text: decision.text,
|
|
6336
|
+
proposalDecision: decision.proposalDecision
|
|
6337
|
+
})
|
|
6338
|
+
]);
|
|
6339
|
+
return;
|
|
6340
|
+
}
|
|
5582
6341
|
}
|
|
5583
6342
|
const refs = await this.stage(actor, turn.media, warnings);
|
|
5584
6343
|
if (turn.text.trim().length === 0 && refs.length === 0) {
|
|
@@ -5608,6 +6367,9 @@ var AgUiRunHandler = class {
|
|
|
5608
6367
|
...forwarded.model !== void 0 ? {
|
|
5609
6368
|
model: forwarded.model
|
|
5610
6369
|
} : {},
|
|
6370
|
+
...forwarded.uiCapabilities !== void 0 ? {
|
|
6371
|
+
uiCapabilities: forwarded.uiCapabilities
|
|
6372
|
+
} : {},
|
|
5611
6373
|
...pageContext !== void 0 ? {
|
|
5612
6374
|
pageContext
|
|
5613
6375
|
} : {},
|
|
@@ -5665,9 +6427,11 @@ var AgUiRunHandler = class {
|
|
|
5665
6427
|
*/
|
|
5666
6428
|
async settle(actor, decisions) {
|
|
5667
6429
|
const deliveries = [];
|
|
6430
|
+
const proposals = decisions.filter((decision) => decision.address.kind === "proposal");
|
|
5668
6431
|
for (const { address, entry } of decisions) {
|
|
5669
6432
|
const { toolCallId: toolCallId2 } = address;
|
|
5670
6433
|
const abandoned = entry.status === "cancelled";
|
|
6434
|
+
if (address.kind === "proposal") continue;
|
|
5671
6435
|
if (address.kind === "approval") {
|
|
5672
6436
|
await this.agent.checkDecision(actor, toolCallId2);
|
|
5673
6437
|
const decision = abandoned ? {
|
|
@@ -5704,9 +6468,53 @@ var AgUiRunHandler = class {
|
|
|
5704
6468
|
via: AG_UI_VIA
|
|
5705
6469
|
}));
|
|
5706
6470
|
}
|
|
6471
|
+
if (proposals.length > 0) await this.decideProposals(actor, proposals);
|
|
5707
6472
|
for (const deliver of deliveries) await deliver();
|
|
5708
6473
|
}
|
|
5709
6474
|
/**
|
|
6475
|
+
* Decide independent proposals through the proposal service — the call the native
|
|
6476
|
+
* `action-proposals/:id/approve|reject` routes make — never by signalling the origin run, which
|
|
6477
|
+
* is not waiting. Every payload is checked before the first decision; a refusal is the service's
|
|
6478
|
+
* own `403`/`404`.
|
|
6479
|
+
*/
|
|
6480
|
+
async decideProposals(actor, decisions) {
|
|
6481
|
+
const planned = decisions.map(({ address, entry }) => {
|
|
6482
|
+
const decision = entry.status === "cancelled" ? {
|
|
6483
|
+
approved: false
|
|
6484
|
+
} : readApprovalPayload(entry.payload);
|
|
6485
|
+
if (decision === null || address.proposalId === void 0 || address.threadId === void 0) {
|
|
6486
|
+
throw invalid("invalid_resume", "an approval is answered with { approved: boolean, reason?, remember? }");
|
|
6487
|
+
}
|
|
6488
|
+
return {
|
|
6489
|
+
address,
|
|
6490
|
+
decision
|
|
6491
|
+
};
|
|
6492
|
+
});
|
|
6493
|
+
const outcomes = [];
|
|
6494
|
+
for (const { address, decision } of planned) {
|
|
6495
|
+
outcomes.push(await this.agent.decideActionProposal(actor, address.threadId, address.proposalId, {
|
|
6496
|
+
decision: decision.approved ? "approved" : "rejected",
|
|
6497
|
+
via: AG_UI_VIA,
|
|
6498
|
+
...decision.remember !== void 0 ? {
|
|
6499
|
+
remember: decision.remember
|
|
6500
|
+
} : {},
|
|
6501
|
+
...decision.reason !== void 0 ? {
|
|
6502
|
+
reason: decision.reason
|
|
6503
|
+
} : {}
|
|
6504
|
+
}));
|
|
6505
|
+
}
|
|
6506
|
+
return outcomes;
|
|
6507
|
+
}
|
|
6508
|
+
/** Answer with a complete list of events, no run behind them. */
|
|
6509
|
+
writeEvents(res, events) {
|
|
6510
|
+
res.status(200);
|
|
6511
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
6512
|
+
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
6513
|
+
res.flushHeaders();
|
|
6514
|
+
for (const event of events) res.write(agUiSse(event));
|
|
6515
|
+
res.end();
|
|
6516
|
+
}
|
|
6517
|
+
/**
|
|
5710
6518
|
* Pipe a run to the client as AG-UI 1.0 over SSE: one event per `data:` line, from `RUN_STARTED`
|
|
5711
6519
|
* to the run's terminal event. It ends when the run stops to ask — the library run stays parked,
|
|
5712
6520
|
* and the request that answers re-attaches to it.
|
|
@@ -5752,29 +6560,29 @@ function agUiAdapter(options = {}) {
|
|
|
5752
6560
|
return this.handle(req, res, body);
|
|
5753
6561
|
}
|
|
5754
6562
|
};
|
|
5755
|
-
|
|
5756
|
-
|
|
6563
|
+
_ts_decorate27([
|
|
6564
|
+
Post8(path),
|
|
5757
6565
|
HttpCode2(200),
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
6566
|
+
_ts_param25(0, Req14()),
|
|
6567
|
+
_ts_param25(1, Res3()),
|
|
6568
|
+
_ts_param25(2, Body7()),
|
|
6569
|
+
_ts_metadata25("design:type", Function),
|
|
6570
|
+
_ts_metadata25("design:paramtypes", [
|
|
5763
6571
|
typeof Request === "undefined" ? Object : Request,
|
|
5764
6572
|
typeof Response === "undefined" ? Object : Response,
|
|
5765
6573
|
Object
|
|
5766
6574
|
]),
|
|
5767
|
-
|
|
6575
|
+
_ts_metadata25("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
5768
6576
|
], AgUiController.prototype, "run", null);
|
|
5769
|
-
AgUiController =
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
6577
|
+
AgUiController = _ts_decorate27([
|
|
6578
|
+
Controller15(),
|
|
6579
|
+
_ts_param25(0, Inject25(AgentService)),
|
|
6580
|
+
_ts_param25(1, Inject25(AGENT_ACTOR_RESOLVER15)),
|
|
6581
|
+
_ts_param25(2, Inject25(AGENT_OPTIONS10)),
|
|
6582
|
+
_ts_param25(3, Optional10()),
|
|
6583
|
+
_ts_param25(3, Inject25(AGENT_ATTACHMENT_STAGING5)),
|
|
6584
|
+
_ts_metadata25("design:type", Function),
|
|
6585
|
+
_ts_metadata25("design:paramtypes", [
|
|
5778
6586
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
5779
6587
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
5780
6588
|
typeof AgentModuleOptions === "undefined" ? Object : AgentModuleOptions,
|
|
@@ -5872,6 +6680,9 @@ export {
|
|
|
5872
6680
|
AGENT_TOOL_BRAND,
|
|
5873
6681
|
AI_TOOL_METADATA,
|
|
5874
6682
|
ATTACHMENT_PAGE_SIZE,
|
|
6683
|
+
ActionProposalController,
|
|
6684
|
+
ActionProposalService,
|
|
6685
|
+
ActionProposalWorkerService,
|
|
5875
6686
|
AgUiRunHandler,
|
|
5876
6687
|
Agent,
|
|
5877
6688
|
AgentApprovalPortAdapter,
|
|
@@ -5910,6 +6721,7 @@ export {
|
|
|
5910
6721
|
attachmentLimits,
|
|
5911
6722
|
declaredSkillProvider,
|
|
5912
6723
|
defaultRequestUserMapper,
|
|
6724
|
+
defineTool,
|
|
5913
6725
|
delegateToolName,
|
|
5914
6726
|
provideAgentTool,
|
|
5915
6727
|
provideAgentTools,
|