@dudousxd/nestjs-agent 1.5.0 → 1.7.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 +49 -0
- package/dist/{agent-deps.factory-CUyVPsa1.d.cts → agent-deps.factory-CiC5Va9J.d.cts} +7 -1
- package/dist/{agent-deps.factory-CUyVPsa1.d.ts → agent-deps.factory-CiC5Va9J.d.ts} +7 -1
- package/dist/durable/index.cjs +622 -319
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +531 -228
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +626 -322
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -5
- package/dist/index.d.ts +67 -5
- package/dist/index.js +529 -227
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/durable/index.cjs
CHANGED
|
@@ -120,7 +120,10 @@ var AgentRunSteps = class {
|
|
|
120
120
|
system: input.system,
|
|
121
121
|
messages: input.messages,
|
|
122
122
|
tools,
|
|
123
|
-
sink: frames.writer
|
|
123
|
+
sink: frames.writer,
|
|
124
|
+
...input.model !== void 0 ? {
|
|
125
|
+
model: input.model
|
|
126
|
+
} : {}
|
|
124
127
|
})), frames.summary());
|
|
125
128
|
const stamped = (0, import_nestjs_agent_core.stampToolKinds)(turn, deps);
|
|
126
129
|
return buffer === void 0 ? stamped : {
|
|
@@ -818,8 +821,8 @@ AgentDurableModule = _ts_decorate4([
|
|
|
818
821
|
], AgentDurableModule);
|
|
819
822
|
|
|
820
823
|
// src/agent.module.ts
|
|
821
|
-
var
|
|
822
|
-
var
|
|
824
|
+
var import_nestjs_agent_core26 = require("@dudousxd/nestjs-agent-core");
|
|
825
|
+
var import_common23 = require("@nestjs/common");
|
|
823
826
|
var import_core4 = require("@nestjs/core");
|
|
824
827
|
|
|
825
828
|
// src/agent-deps.factory.ts
|
|
@@ -1125,15 +1128,72 @@ var AgentService = class {
|
|
|
1125
1128
|
deps;
|
|
1126
1129
|
quota;
|
|
1127
1130
|
staging;
|
|
1128
|
-
|
|
1131
|
+
models;
|
|
1132
|
+
constructor(runner, store, deps, quota, staging, models) {
|
|
1129
1133
|
this.runner = runner;
|
|
1130
1134
|
this.store = store;
|
|
1131
1135
|
this.deps = deps;
|
|
1132
1136
|
this.quota = quota;
|
|
1133
1137
|
this.staging = staging;
|
|
1138
|
+
this.models = models;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The models `actor` may pick for `agent` (`GET <base>/models`). An empty catalog when none is
|
|
1142
|
+
* bound, so a picker simply has nothing to offer.
|
|
1143
|
+
*/
|
|
1144
|
+
async listModels(actor, agent) {
|
|
1145
|
+
if (this.models === void 0) {
|
|
1146
|
+
return {
|
|
1147
|
+
providers: [],
|
|
1148
|
+
default: null
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
return this.models.list({
|
|
1152
|
+
actor,
|
|
1153
|
+
...agent !== void 0 ? {
|
|
1154
|
+
agent
|
|
1155
|
+
} : {}
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* `model` if the catalog offers it to this actor and agent right now, else a 400 naming why. The
|
|
1160
|
+
* one gate every model choice passes — a send's own, and a thread's pinned one at the moment it is
|
|
1161
|
+
* pinned and again at every turn that runs on it (availability can change in between).
|
|
1162
|
+
*/
|
|
1163
|
+
async assertModelAllowed(actor, agent, model) {
|
|
1164
|
+
if (this.models === void 0) {
|
|
1165
|
+
throw new import_common6.BadRequestException(`model "${model}" cannot be selected: no ModelCatalog is configured (AgentModule.forRoot({ models }))`);
|
|
1166
|
+
}
|
|
1167
|
+
const entry = (0, import_nestjs_agent_core8.findCatalogModel)(await this.models.list({
|
|
1168
|
+
actor,
|
|
1169
|
+
agent
|
|
1170
|
+
}), model);
|
|
1171
|
+
if (entry === void 0) {
|
|
1172
|
+
throw new import_common6.BadRequestException(`model "${model}" is not offered`);
|
|
1173
|
+
}
|
|
1174
|
+
if (!entry.available) {
|
|
1175
|
+
throw new import_common6.BadRequestException(`model "${model}" is not available${entry.unavailableReason ? `: ${entry.unavailableReason}` : ""}`);
|
|
1176
|
+
}
|
|
1177
|
+
return entry.id;
|
|
1178
|
+
}
|
|
1179
|
+
/** The model a turn runs on: the send's own, else the thread's pinned one, else none. */
|
|
1180
|
+
async resolveModel(actor, agent, requested, threadId) {
|
|
1181
|
+
const model = requested ?? (threadId !== void 0 ? await this.threadModel(threadId) : null);
|
|
1182
|
+
if (model === null || model === void 0) {
|
|
1183
|
+
return void 0;
|
|
1184
|
+
}
|
|
1185
|
+
return this.assertModelAllowed(actor, agent, model);
|
|
1186
|
+
}
|
|
1187
|
+
async threadModel(threadId) {
|
|
1188
|
+
const projecting = this.store;
|
|
1189
|
+
if (typeof projecting.modelForThread === "function") {
|
|
1190
|
+
return projecting.modelForThread(threadId);
|
|
1191
|
+
}
|
|
1192
|
+
return (await this.store.getThread(threadId))?.model ?? null;
|
|
1134
1193
|
}
|
|
1135
1194
|
async chat(params) {
|
|
1136
1195
|
const agentName = await this.resolveAgentName(params.agentName, params.threadId);
|
|
1196
|
+
const model = await this.resolveModel(params.actor, agentName, params.model, params.threadId);
|
|
1137
1197
|
const attachments = await this.resolveAttachments(params.actor, params.attachments ?? []);
|
|
1138
1198
|
let threadId = params.threadId;
|
|
1139
1199
|
if (threadId === void 0) {
|
|
@@ -1164,6 +1224,9 @@ var AgentService = class {
|
|
|
1164
1224
|
} : {},
|
|
1165
1225
|
...params.pageContext !== void 0 ? {
|
|
1166
1226
|
pageContext: params.pageContext
|
|
1227
|
+
} : {},
|
|
1228
|
+
...model !== void 0 ? {
|
|
1229
|
+
model
|
|
1167
1230
|
} : {}
|
|
1168
1231
|
};
|
|
1169
1232
|
const { runId } = await this.runner.start(input);
|
|
@@ -1334,20 +1397,26 @@ var AgentService = class {
|
|
|
1334
1397
|
async updateThread(actor, threadId, patch) {
|
|
1335
1398
|
const title = patch.title !== void 0 ? this.validateTitle(patch.title) : void 0;
|
|
1336
1399
|
await this.assertOwnsThread(actor, threadId);
|
|
1337
|
-
if (patch.defaultAgent === void 0) {
|
|
1400
|
+
if (patch.defaultAgent === void 0 && patch.model === void 0) {
|
|
1338
1401
|
if (title !== void 0) {
|
|
1339
1402
|
await this.store.setTitle(threadId, title);
|
|
1340
1403
|
}
|
|
1341
1404
|
return;
|
|
1342
1405
|
}
|
|
1343
1406
|
if (this.store.updateThread === void 0) {
|
|
1344
|
-
throw new import_common6.NotImplementedException("Setting a thread's defaultAgent requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1407
|
+
throw new import_common6.NotImplementedException("Setting a thread's defaultAgent or model requires an AgentStore that implements updateThread(); the bound store does not support it.");
|
|
1345
1408
|
}
|
|
1409
|
+
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);
|
|
1346
1410
|
await this.store.updateThread(threadId, {
|
|
1347
1411
|
...title !== void 0 ? {
|
|
1348
1412
|
title
|
|
1349
1413
|
} : {},
|
|
1350
|
-
|
|
1414
|
+
...patch.defaultAgent !== void 0 ? {
|
|
1415
|
+
defaultAgent: patch.defaultAgent
|
|
1416
|
+
} : {},
|
|
1417
|
+
...model !== void 0 ? {
|
|
1418
|
+
model
|
|
1419
|
+
} : {}
|
|
1351
1420
|
});
|
|
1352
1421
|
}
|
|
1353
1422
|
validateTitle(title) {
|
|
@@ -1394,6 +1463,7 @@ var AgentService = class {
|
|
|
1394
1463
|
return {
|
|
1395
1464
|
...thread,
|
|
1396
1465
|
defaultAgent: thread.defaultAgent ?? null,
|
|
1466
|
+
model: thread.model ?? null,
|
|
1397
1467
|
activeRunId: await this.store.activeRunForThread?.(thread.id) ?? null
|
|
1398
1468
|
};
|
|
1399
1469
|
}
|
|
@@ -1421,6 +1491,40 @@ var AgentService = class {
|
|
|
1421
1491
|
return this.store.truncateFrom(threadId, messageId);
|
|
1422
1492
|
}
|
|
1423
1493
|
/**
|
|
1494
|
+
* Rate a message in one of `actor`'s threads: `'up'`/`'down'` with an optional comment, or `null`
|
|
1495
|
+
* to clear the rating. Answers `404` for an unknown message, `403` for another actor's, and `501`
|
|
1496
|
+
* on a store without `threadOfMessage` + `setMessageFeedback`.
|
|
1497
|
+
*/
|
|
1498
|
+
async setMessageFeedback(actor, messageId, input) {
|
|
1499
|
+
if (input.value !== null && input.value !== "up" && input.value !== "down") {
|
|
1500
|
+
throw new import_common6.BadRequestException("value must be 'up', 'down' or null");
|
|
1501
|
+
}
|
|
1502
|
+
if (input.comment !== void 0 && typeof input.comment !== "string") {
|
|
1503
|
+
throw new import_common6.BadRequestException("comment must be a string");
|
|
1504
|
+
}
|
|
1505
|
+
const comment = input.comment?.trim();
|
|
1506
|
+
if (comment !== void 0 && comment.length > 2e3) {
|
|
1507
|
+
throw new import_common6.BadRequestException("comment must be at most 2000 characters");
|
|
1508
|
+
}
|
|
1509
|
+
if (this.store.threadOfMessage === void 0 || this.store.setMessageFeedback === void 0) {
|
|
1510
|
+
throw new import_common6.NotImplementedException("Message feedback requires an AgentStore that implements threadOfMessage() and setMessageFeedback(); the bound store does not support it.");
|
|
1511
|
+
}
|
|
1512
|
+
const threadId = await this.store.threadOfMessage(messageId);
|
|
1513
|
+
if (threadId === null) {
|
|
1514
|
+
throw new import_common6.NotFoundException(`message ${messageId} not found`);
|
|
1515
|
+
}
|
|
1516
|
+
await this.assertOwnsThread(actor, threadId);
|
|
1517
|
+
const feedback = input.value === null ? null : {
|
|
1518
|
+
value: input.value,
|
|
1519
|
+
...comment !== void 0 && comment.length > 0 ? {
|
|
1520
|
+
comment
|
|
1521
|
+
} : {},
|
|
1522
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1523
|
+
};
|
|
1524
|
+
await this.store.setMessageFeedback(messageId, feedback);
|
|
1525
|
+
return feedback;
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1424
1528
|
* Every file this actor has staged, newest first — across threads, including uploads that were
|
|
1425
1529
|
* never sent, which nothing else on this surface can see.
|
|
1426
1530
|
*
|
|
@@ -1627,13 +1731,16 @@ AgentService = _ts_decorate6([
|
|
|
1627
1731
|
_ts_param5(3, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_QUOTA_STORE)),
|
|
1628
1732
|
_ts_param5(4, (0, import_common6.Optional)()),
|
|
1629
1733
|
_ts_param5(4, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_ATTACHMENT_STAGING)),
|
|
1734
|
+
_ts_param5(5, (0, import_common6.Optional)()),
|
|
1735
|
+
_ts_param5(5, (0, import_common6.Inject)(import_nestjs_agent_core8.AGENT_MODEL_CATALOG)),
|
|
1630
1736
|
_ts_metadata5("design:type", Function),
|
|
1631
1737
|
_ts_metadata5("design:paramtypes", [
|
|
1632
1738
|
typeof AgentRunner === "undefined" ? Object : AgentRunner,
|
|
1633
1739
|
typeof AgentStore === "undefined" ? Object : AgentStore,
|
|
1634
1740
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
1635
1741
|
Object,
|
|
1636
|
-
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore
|
|
1742
|
+
typeof AttachmentStagingStore === "undefined" ? Object : AttachmentStagingStore,
|
|
1743
|
+
typeof ModelCatalog === "undefined" ? Object : ModelCatalog
|
|
1637
1744
|
])
|
|
1638
1745
|
], AgentService);
|
|
1639
1746
|
|
|
@@ -2005,13 +2112,22 @@ var ChatController = class {
|
|
|
2005
2112
|
} : {},
|
|
2006
2113
|
...body.transient === true ? {
|
|
2007
2114
|
transient: true
|
|
2115
|
+
} : {},
|
|
2116
|
+
...typeof body.model === "string" && body.model.length > 0 ? {
|
|
2117
|
+
model: body.model
|
|
2008
2118
|
} : {}
|
|
2009
2119
|
});
|
|
2010
2120
|
await this.pipe(res, runId, this.agent.subscribe(runId), threadId);
|
|
2011
2121
|
}
|
|
2012
|
-
|
|
2122
|
+
/**
|
|
2123
|
+
* Attach to a run's stream: every buffered frame, then live ones. `?after=<seq>` (or the SSE
|
|
2124
|
+
* `Last-Event-ID` header a browser `EventSource` sends on its own) skips the frames a reconnecting
|
|
2125
|
+
* client already has — see {@link pipe} for how frames are numbered.
|
|
2126
|
+
*/
|
|
2127
|
+
async stream(req, runId, res, after) {
|
|
2013
2128
|
const actor = await this.actorResolver.resolve(req);
|
|
2014
|
-
|
|
2129
|
+
const cursor = parseCursor(after) ?? parseCursor(req.headers["last-event-id"]) ?? 0;
|
|
2130
|
+
await this.pipe(res, runId, await this.agent.subscribeAs(actor, runId), void 0, cursor);
|
|
2015
2131
|
}
|
|
2016
2132
|
async cancel(req, runId) {
|
|
2017
2133
|
const actor = await this.actorResolver.resolve(req);
|
|
@@ -2020,7 +2136,15 @@ var ChatController = class {
|
|
|
2020
2136
|
aborted: true
|
|
2021
2137
|
};
|
|
2022
2138
|
}
|
|
2023
|
-
|
|
2139
|
+
/**
|
|
2140
|
+
* Every `data:` frame carries an SSE `id:` — its 1-based sequence number within the run. The
|
|
2141
|
+
* number is a pure function of the run's buffered stream (every sink replays a run from its first
|
|
2142
|
+
* chunk, in write order), so the same frame gets the same number on the POST that started the run
|
|
2143
|
+
* and on any later `GET …/stream`, whichever replica serves it. A reconnecting client passes the
|
|
2144
|
+
* last one it saw as `?after=`; frames at or below it are read off the sink but not re-sent.
|
|
2145
|
+
* `meta`, `done` and `error` carry no id: `meta` is re-sent on every attach, the terminals once.
|
|
2146
|
+
*/
|
|
2147
|
+
async pipe(res, runId, events, threadId, after = 0) {
|
|
2024
2148
|
res.setHeader("Content-Type", "text/event-stream");
|
|
2025
2149
|
res.setHeader("Cache-Control", "no-cache");
|
|
2026
2150
|
res.setHeader("Connection", "keep-alive");
|
|
@@ -2037,6 +2161,16 @@ data: ${JSON.stringify({
|
|
|
2037
2161
|
`);
|
|
2038
2162
|
const decoder = new TextDecoder();
|
|
2039
2163
|
let buffer = "";
|
|
2164
|
+
let seq = 0;
|
|
2165
|
+
const forward = /* @__PURE__ */ __name((line) => {
|
|
2166
|
+
seq += 1;
|
|
2167
|
+
if (seq > after) {
|
|
2168
|
+
res.write(`id: ${seq}
|
|
2169
|
+
data: ${line}
|
|
2170
|
+
|
|
2171
|
+
`);
|
|
2172
|
+
}
|
|
2173
|
+
}, "forward");
|
|
2040
2174
|
try {
|
|
2041
2175
|
for await (const chunk of events) {
|
|
2042
2176
|
buffer += decoder.decode(chunk, {
|
|
@@ -2047,17 +2181,13 @@ data: ${JSON.stringify({
|
|
|
2047
2181
|
const line = buffer.slice(0, newline);
|
|
2048
2182
|
buffer = buffer.slice(newline + 1);
|
|
2049
2183
|
if (line.length > 0) {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
`);
|
|
2184
|
+
forward(line);
|
|
2053
2185
|
}
|
|
2054
2186
|
newline = buffer.indexOf("\n");
|
|
2055
2187
|
}
|
|
2056
2188
|
}
|
|
2057
2189
|
if (buffer.length > 0) {
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
`);
|
|
2190
|
+
forward(buffer);
|
|
2061
2191
|
}
|
|
2062
2192
|
res.write("event: done\ndata: {}\n\n");
|
|
2063
2193
|
} catch (error) {
|
|
@@ -2094,11 +2224,13 @@ _ts_decorate10([
|
|
|
2094
2224
|
_ts_param8(0, (0, import_common10.Req)()),
|
|
2095
2225
|
_ts_param8(1, (0, import_common10.Param)("runId")),
|
|
2096
2226
|
_ts_param8(2, (0, import_common10.Res)()),
|
|
2227
|
+
_ts_param8(3, (0, import_common10.Query)("after")),
|
|
2097
2228
|
_ts_metadata9("design:type", Function),
|
|
2098
2229
|
_ts_metadata9("design:paramtypes", [
|
|
2099
2230
|
typeof Request === "undefined" ? Object : Request,
|
|
2100
2231
|
String,
|
|
2101
|
-
typeof Response === "undefined" ? Object : Response
|
|
2232
|
+
typeof Response === "undefined" ? Object : Response,
|
|
2233
|
+
String
|
|
2102
2234
|
]),
|
|
2103
2235
|
_ts_metadata9("design:returntype", Promise)
|
|
2104
2236
|
], ChatController.prototype, "stream", null);
|
|
@@ -2122,6 +2254,15 @@ ChatController = _ts_decorate10([
|
|
|
2122
2254
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2123
2255
|
])
|
|
2124
2256
|
], ChatController);
|
|
2257
|
+
function parseCursor(raw) {
|
|
2258
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
2259
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
|
|
2260
|
+
return void 0;
|
|
2261
|
+
}
|
|
2262
|
+
const parsed = Number(value.trim());
|
|
2263
|
+
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
2264
|
+
}
|
|
2265
|
+
__name(parseCursor, "parseCursor");
|
|
2125
2266
|
|
|
2126
2267
|
// src/controller/memories.controller.ts
|
|
2127
2268
|
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
@@ -2258,7 +2399,7 @@ MemoriesController = _ts_decorate11([
|
|
|
2258
2399
|
])
|
|
2259
2400
|
], MemoriesController);
|
|
2260
2401
|
|
|
2261
|
-
// src/controller/
|
|
2402
|
+
// src/controller/messages.controller.ts
|
|
2262
2403
|
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2263
2404
|
var import_common12 = require("@nestjs/common");
|
|
2264
2405
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
@@ -2287,9 +2428,9 @@ function _ts_param10(paramIndex, decorator) {
|
|
|
2287
2428
|
};
|
|
2288
2429
|
}
|
|
2289
2430
|
__name(_ts_param10, "_ts_param");
|
|
2290
|
-
var
|
|
2431
|
+
var MessagesController = class {
|
|
2291
2432
|
static {
|
|
2292
|
-
__name(this, "
|
|
2433
|
+
__name(this, "MessagesController");
|
|
2293
2434
|
}
|
|
2294
2435
|
agent;
|
|
2295
2436
|
actorResolver;
|
|
@@ -2297,31 +2438,48 @@ var QuotaController = class {
|
|
|
2297
2438
|
this.agent = agent;
|
|
2298
2439
|
this.actorResolver = actorResolver;
|
|
2299
2440
|
}
|
|
2300
|
-
|
|
2441
|
+
/**
|
|
2442
|
+
* Rate a message: `{ value: 'up' | 'down' | null, comment? }`. Answers the stored rating
|
|
2443
|
+
* (`{ feedback: null }` once cleared). Only the thread's owner may rate its messages.
|
|
2444
|
+
*/
|
|
2445
|
+
async feedback(req, id, body) {
|
|
2301
2446
|
const actor = await this.actorResolver.resolve(req);
|
|
2302
|
-
|
|
2447
|
+
const feedback = await this.agent.setMessageFeedback(actor, id, {
|
|
2448
|
+
value: body?.value ?? null,
|
|
2449
|
+
...body?.comment !== void 0 ? {
|
|
2450
|
+
comment: body.comment
|
|
2451
|
+
} : {}
|
|
2452
|
+
});
|
|
2453
|
+
return {
|
|
2454
|
+
feedback
|
|
2455
|
+
};
|
|
2303
2456
|
}
|
|
2304
2457
|
};
|
|
2305
2458
|
_ts_decorate12([
|
|
2306
|
-
(0, import_common12.
|
|
2459
|
+
(0, import_common12.Post)(":id/feedback"),
|
|
2460
|
+
(0, import_common12.HttpCode)(200),
|
|
2307
2461
|
_ts_param10(0, (0, import_common12.Req)()),
|
|
2462
|
+
_ts_param10(1, (0, import_common12.Param)("id")),
|
|
2463
|
+
_ts_param10(2, (0, import_common12.Body)()),
|
|
2308
2464
|
_ts_metadata11("design:type", Function),
|
|
2309
2465
|
_ts_metadata11("design:paramtypes", [
|
|
2310
|
-
typeof Request === "undefined" ? Object : Request
|
|
2466
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2467
|
+
String,
|
|
2468
|
+
typeof FeedbackBody === "undefined" ? Object : FeedbackBody
|
|
2311
2469
|
]),
|
|
2312
2470
|
_ts_metadata11("design:returntype", Promise)
|
|
2313
|
-
],
|
|
2314
|
-
|
|
2315
|
-
(0, import_common12.Controller)("
|
|
2471
|
+
], MessagesController.prototype, "feedback", null);
|
|
2472
|
+
MessagesController = _ts_decorate12([
|
|
2473
|
+
(0, import_common12.Controller)("messages"),
|
|
2316
2474
|
_ts_param10(1, (0, import_common12.Inject)(import_nestjs_agent_core13.AGENT_ACTOR_RESOLVER)),
|
|
2317
2475
|
_ts_metadata11("design:type", Function),
|
|
2318
2476
|
_ts_metadata11("design:paramtypes", [
|
|
2319
2477
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2320
2478
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2321
2479
|
])
|
|
2322
|
-
],
|
|
2480
|
+
], MessagesController);
|
|
2323
2481
|
|
|
2324
|
-
// src/controller/
|
|
2482
|
+
// src/controller/models.controller.ts
|
|
2325
2483
|
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
2326
2484
|
var import_common13 = require("@nestjs/common");
|
|
2327
2485
|
function _ts_decorate13(decorators, target, key, desc) {
|
|
@@ -2350,6 +2508,138 @@ function _ts_param11(paramIndex, decorator) {
|
|
|
2350
2508
|
};
|
|
2351
2509
|
}
|
|
2352
2510
|
__name(_ts_param11, "_ts_param");
|
|
2511
|
+
var ModelsController = class {
|
|
2512
|
+
static {
|
|
2513
|
+
__name(this, "ModelsController");
|
|
2514
|
+
}
|
|
2515
|
+
agent;
|
|
2516
|
+
actorResolver;
|
|
2517
|
+
constructor(agent, actorResolver) {
|
|
2518
|
+
this.agent = agent;
|
|
2519
|
+
this.actorResolver = actorResolver;
|
|
2520
|
+
}
|
|
2521
|
+
/**
|
|
2522
|
+
* The models the caller may pick for `agent` (the default agent when omitted), grouped by
|
|
2523
|
+
* provider, with badges and availability — the bound `ModelCatalog`'s answer, or an empty one.
|
|
2524
|
+
*/
|
|
2525
|
+
async list(req, agent) {
|
|
2526
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2527
|
+
return this.agent.listModels(actor, agent);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
_ts_decorate13([
|
|
2531
|
+
(0, import_common13.Get)(),
|
|
2532
|
+
_ts_param11(0, (0, import_common13.Req)()),
|
|
2533
|
+
_ts_param11(1, (0, import_common13.Query)("agent")),
|
|
2534
|
+
_ts_metadata12("design:type", Function),
|
|
2535
|
+
_ts_metadata12("design:paramtypes", [
|
|
2536
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2537
|
+
String
|
|
2538
|
+
]),
|
|
2539
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2540
|
+
], ModelsController.prototype, "list", null);
|
|
2541
|
+
ModelsController = _ts_decorate13([
|
|
2542
|
+
(0, import_common13.Controller)("models"),
|
|
2543
|
+
_ts_param11(1, (0, import_common13.Inject)(import_nestjs_agent_core14.AGENT_ACTOR_RESOLVER)),
|
|
2544
|
+
_ts_metadata12("design:type", Function),
|
|
2545
|
+
_ts_metadata12("design:paramtypes", [
|
|
2546
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2547
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2548
|
+
])
|
|
2549
|
+
], ModelsController);
|
|
2550
|
+
|
|
2551
|
+
// src/controller/quota.controller.ts
|
|
2552
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2553
|
+
var import_common14 = require("@nestjs/common");
|
|
2554
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2555
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2556
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2557
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2558
|
+
} else {
|
|
2559
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2560
|
+
if (d = decorators[i]) {
|
|
2561
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
2565
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2566
|
+
}
|
|
2567
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2568
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
2569
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2570
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2574
|
+
function _ts_param12(paramIndex, decorator) {
|
|
2575
|
+
return function(target, key) {
|
|
2576
|
+
decorator(target, key, paramIndex);
|
|
2577
|
+
};
|
|
2578
|
+
}
|
|
2579
|
+
__name(_ts_param12, "_ts_param");
|
|
2580
|
+
var QuotaController = class {
|
|
2581
|
+
static {
|
|
2582
|
+
__name(this, "QuotaController");
|
|
2583
|
+
}
|
|
2584
|
+
agent;
|
|
2585
|
+
actorResolver;
|
|
2586
|
+
constructor(agent, actorResolver) {
|
|
2587
|
+
this.agent = agent;
|
|
2588
|
+
this.actorResolver = actorResolver;
|
|
2589
|
+
}
|
|
2590
|
+
async today(req) {
|
|
2591
|
+
const actor = await this.actorResolver.resolve(req);
|
|
2592
|
+
return this.agent.quotaToday(actor.id);
|
|
2593
|
+
}
|
|
2594
|
+
};
|
|
2595
|
+
_ts_decorate14([
|
|
2596
|
+
(0, import_common14.Get)("today"),
|
|
2597
|
+
_ts_param12(0, (0, import_common14.Req)()),
|
|
2598
|
+
_ts_metadata13("design:type", Function),
|
|
2599
|
+
_ts_metadata13("design:paramtypes", [
|
|
2600
|
+
typeof Request === "undefined" ? Object : Request
|
|
2601
|
+
]),
|
|
2602
|
+
_ts_metadata13("design:returntype", Promise)
|
|
2603
|
+
], QuotaController.prototype, "today", null);
|
|
2604
|
+
QuotaController = _ts_decorate14([
|
|
2605
|
+
(0, import_common14.Controller)("quota"),
|
|
2606
|
+
_ts_param12(1, (0, import_common14.Inject)(import_nestjs_agent_core15.AGENT_ACTOR_RESOLVER)),
|
|
2607
|
+
_ts_metadata13("design:type", Function),
|
|
2608
|
+
_ts_metadata13("design:paramtypes", [
|
|
2609
|
+
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2610
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2611
|
+
])
|
|
2612
|
+
], QuotaController);
|
|
2613
|
+
|
|
2614
|
+
// src/controller/skills.controller.ts
|
|
2615
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
2616
|
+
var import_common15 = require("@nestjs/common");
|
|
2617
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2618
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2619
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2620
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2621
|
+
} else {
|
|
2622
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2623
|
+
if (d = decorators[i]) {
|
|
2624
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2629
|
+
}
|
|
2630
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2631
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2632
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2633
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2637
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2638
|
+
return function(target, key) {
|
|
2639
|
+
decorator(target, key, paramIndex);
|
|
2640
|
+
};
|
|
2641
|
+
}
|
|
2642
|
+
__name(_ts_param13, "_ts_param");
|
|
2353
2643
|
var SkillsController = class {
|
|
2354
2644
|
static {
|
|
2355
2645
|
__name(this, "SkillsController");
|
|
@@ -2365,40 +2655,40 @@ var SkillsController = class {
|
|
|
2365
2655
|
return [];
|
|
2366
2656
|
}
|
|
2367
2657
|
const actor = await this.actorResolver.resolve(req);
|
|
2368
|
-
const offer = await (0,
|
|
2658
|
+
const offer = await (0, import_nestjs_agent_core16.offerSkills)(this.skills, {
|
|
2369
2659
|
actor,
|
|
2370
2660
|
threadId: threadId ?? ""
|
|
2371
2661
|
});
|
|
2372
2662
|
return offer.entries;
|
|
2373
2663
|
}
|
|
2374
2664
|
};
|
|
2375
|
-
|
|
2376
|
-
(0,
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2665
|
+
_ts_decorate15([
|
|
2666
|
+
(0, import_common15.Get)(),
|
|
2667
|
+
_ts_param13(0, (0, import_common15.Req)()),
|
|
2668
|
+
_ts_param13(1, (0, import_common15.Query)("threadId")),
|
|
2669
|
+
_ts_metadata14("design:type", Function),
|
|
2670
|
+
_ts_metadata14("design:paramtypes", [
|
|
2381
2671
|
typeof Request === "undefined" ? Object : Request,
|
|
2382
2672
|
String
|
|
2383
2673
|
]),
|
|
2384
|
-
|
|
2674
|
+
_ts_metadata14("design:returntype", Promise)
|
|
2385
2675
|
], SkillsController.prototype, "list", null);
|
|
2386
|
-
SkillsController =
|
|
2387
|
-
(0,
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2676
|
+
SkillsController = _ts_decorate15([
|
|
2677
|
+
(0, import_common15.Controller)("skills"),
|
|
2678
|
+
_ts_param13(0, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_ACTOR_RESOLVER)),
|
|
2679
|
+
_ts_param13(1, (0, import_common15.Optional)()),
|
|
2680
|
+
_ts_param13(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_SKILLS)),
|
|
2681
|
+
_ts_metadata14("design:type", Function),
|
|
2682
|
+
_ts_metadata14("design:paramtypes", [
|
|
2393
2683
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2394
2684
|
Object
|
|
2395
2685
|
])
|
|
2396
2686
|
], SkillsController);
|
|
2397
2687
|
|
|
2398
2688
|
// src/controller/threads.controller.ts
|
|
2399
|
-
var
|
|
2400
|
-
var
|
|
2401
|
-
function
|
|
2689
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
2690
|
+
var import_common16 = require("@nestjs/common");
|
|
2691
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2402
2692
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2403
2693
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2404
2694
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2411,19 +2701,19 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2411
2701
|
}
|
|
2412
2702
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2413
2703
|
}
|
|
2414
|
-
__name(
|
|
2415
|
-
function
|
|
2704
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2705
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2416
2706
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2417
2707
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2418
2708
|
}
|
|
2419
2709
|
}
|
|
2420
|
-
__name(
|
|
2421
|
-
function
|
|
2710
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2711
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2422
2712
|
return function(target, key) {
|
|
2423
2713
|
decorator(target, key, paramIndex);
|
|
2424
2714
|
};
|
|
2425
2715
|
}
|
|
2426
|
-
__name(
|
|
2716
|
+
__name(_ts_param14, "_ts_param");
|
|
2427
2717
|
var ThreadsController = class {
|
|
2428
2718
|
static {
|
|
2429
2719
|
__name(this, "ThreadsController");
|
|
@@ -2466,6 +2756,9 @@ var ThreadsController = class {
|
|
|
2466
2756
|
} : {},
|
|
2467
2757
|
..."defaultAgent" in body ? {
|
|
2468
2758
|
defaultAgent: body.defaultAgent ?? null
|
|
2759
|
+
} : {},
|
|
2760
|
+
..."model" in body ? {
|
|
2761
|
+
model: body.model ?? null
|
|
2469
2762
|
} : {}
|
|
2470
2763
|
});
|
|
2471
2764
|
return {
|
|
@@ -2487,101 +2780,101 @@ var ThreadsController = class {
|
|
|
2487
2780
|
};
|
|
2488
2781
|
}
|
|
2489
2782
|
};
|
|
2490
|
-
|
|
2491
|
-
(0,
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2783
|
+
_ts_decorate16([
|
|
2784
|
+
(0, import_common16.Get)(),
|
|
2785
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2786
|
+
_ts_metadata15("design:type", Function),
|
|
2787
|
+
_ts_metadata15("design:paramtypes", [
|
|
2495
2788
|
typeof Request === "undefined" ? Object : Request
|
|
2496
2789
|
]),
|
|
2497
|
-
|
|
2790
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2498
2791
|
], ThreadsController.prototype, "list", null);
|
|
2499
|
-
|
|
2500
|
-
(0,
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2792
|
+
_ts_decorate16([
|
|
2793
|
+
(0, import_common16.Get)(":id"),
|
|
2794
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2795
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2796
|
+
_ts_metadata15("design:type", Function),
|
|
2797
|
+
_ts_metadata15("design:paramtypes", [
|
|
2505
2798
|
typeof Request === "undefined" ? Object : Request,
|
|
2506
2799
|
String
|
|
2507
2800
|
]),
|
|
2508
|
-
|
|
2801
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2509
2802
|
], ThreadsController.prototype, "detail", null);
|
|
2510
|
-
|
|
2511
|
-
(0,
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2803
|
+
_ts_decorate16([
|
|
2804
|
+
(0, import_common16.Delete)(":id"),
|
|
2805
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2806
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2807
|
+
_ts_metadata15("design:type", Function),
|
|
2808
|
+
_ts_metadata15("design:paramtypes", [
|
|
2516
2809
|
typeof Request === "undefined" ? Object : Request,
|
|
2517
2810
|
String
|
|
2518
2811
|
]),
|
|
2519
|
-
|
|
2812
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2520
2813
|
], ThreadsController.prototype, "remove", null);
|
|
2521
|
-
|
|
2522
|
-
(0,
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2814
|
+
_ts_decorate16([
|
|
2815
|
+
(0, import_common16.Post)(":id/fork-from/:messageId"),
|
|
2816
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2817
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2818
|
+
_ts_param14(2, (0, import_common16.Param)("messageId")),
|
|
2819
|
+
_ts_metadata15("design:type", Function),
|
|
2820
|
+
_ts_metadata15("design:paramtypes", [
|
|
2528
2821
|
typeof Request === "undefined" ? Object : Request,
|
|
2529
2822
|
String,
|
|
2530
2823
|
String
|
|
2531
2824
|
]),
|
|
2532
|
-
|
|
2825
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2533
2826
|
], ThreadsController.prototype, "fork", null);
|
|
2534
|
-
|
|
2535
|
-
(0,
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2827
|
+
_ts_decorate16([
|
|
2828
|
+
(0, import_common16.Patch)(":id"),
|
|
2829
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2830
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2831
|
+
_ts_param14(2, (0, import_common16.Body)()),
|
|
2832
|
+
_ts_metadata15("design:type", Function),
|
|
2833
|
+
_ts_metadata15("design:paramtypes", [
|
|
2541
2834
|
typeof Request === "undefined" ? Object : Request,
|
|
2542
2835
|
String,
|
|
2543
2836
|
typeof UpdateThreadBody === "undefined" ? Object : UpdateThreadBody
|
|
2544
2837
|
]),
|
|
2545
|
-
|
|
2838
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2546
2839
|
], ThreadsController.prototype, "update", null);
|
|
2547
|
-
|
|
2548
|
-
(0,
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2840
|
+
_ts_decorate16([
|
|
2841
|
+
(0, import_common16.Post)(":id/promote"),
|
|
2842
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2843
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2844
|
+
_ts_metadata15("design:type", Function),
|
|
2845
|
+
_ts_metadata15("design:paramtypes", [
|
|
2553
2846
|
typeof Request === "undefined" ? Object : Request,
|
|
2554
2847
|
String
|
|
2555
2848
|
]),
|
|
2556
|
-
|
|
2849
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2557
2850
|
], ThreadsController.prototype, "promote", null);
|
|
2558
|
-
|
|
2559
|
-
(0,
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2851
|
+
_ts_decorate16([
|
|
2852
|
+
(0, import_common16.Delete)(":id/from/:messageId"),
|
|
2853
|
+
_ts_param14(0, (0, import_common16.Req)()),
|
|
2854
|
+
_ts_param14(1, (0, import_common16.Param)("id")),
|
|
2855
|
+
_ts_param14(2, (0, import_common16.Param)("messageId")),
|
|
2856
|
+
_ts_metadata15("design:type", Function),
|
|
2857
|
+
_ts_metadata15("design:paramtypes", [
|
|
2565
2858
|
typeof Request === "undefined" ? Object : Request,
|
|
2566
2859
|
String,
|
|
2567
2860
|
String
|
|
2568
2861
|
]),
|
|
2569
|
-
|
|
2862
|
+
_ts_metadata15("design:returntype", Promise)
|
|
2570
2863
|
], ThreadsController.prototype, "truncateFrom", null);
|
|
2571
|
-
ThreadsController =
|
|
2572
|
-
(0,
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2864
|
+
ThreadsController = _ts_decorate16([
|
|
2865
|
+
(0, import_common16.Controller)("threads"),
|
|
2866
|
+
_ts_param14(1, (0, import_common16.Inject)(import_nestjs_agent_core17.AGENT_ACTOR_RESOLVER)),
|
|
2867
|
+
_ts_metadata15("design:type", Function),
|
|
2868
|
+
_ts_metadata15("design:paramtypes", [
|
|
2576
2869
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2577
2870
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2578
2871
|
])
|
|
2579
2872
|
], ThreadsController);
|
|
2580
2873
|
|
|
2581
2874
|
// src/controller/tool-call.controller.ts
|
|
2582
|
-
var
|
|
2583
|
-
var
|
|
2584
|
-
function
|
|
2875
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
2876
|
+
var import_common17 = require("@nestjs/common");
|
|
2877
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2585
2878
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2586
2879
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2587
2880
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2594,19 +2887,19 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2594
2887
|
}
|
|
2595
2888
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2596
2889
|
}
|
|
2597
|
-
__name(
|
|
2598
|
-
function
|
|
2890
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2891
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2599
2892
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2600
2893
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2601
2894
|
}
|
|
2602
2895
|
}
|
|
2603
|
-
__name(
|
|
2604
|
-
function
|
|
2896
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2897
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2605
2898
|
return function(target, key) {
|
|
2606
2899
|
decorator(target, key, paramIndex);
|
|
2607
2900
|
};
|
|
2608
2901
|
}
|
|
2609
|
-
__name(
|
|
2902
|
+
__name(_ts_param15, "_ts_param");
|
|
2610
2903
|
var MAX_ANSWERED_QUESTIONS = 100;
|
|
2611
2904
|
var MAX_VALUES_PER_QUESTION = 100;
|
|
2612
2905
|
var MAX_ANSWER_VALUE_LENGTH = 4096;
|
|
@@ -2615,7 +2908,7 @@ var MAX_VIA_LENGTH = 64;
|
|
|
2615
2908
|
var DEFAULT_VIA = "web";
|
|
2616
2909
|
function toolCallId(claimed) {
|
|
2617
2910
|
if (typeof claimed !== "string" || claimed.length === 0) {
|
|
2618
|
-
throw new
|
|
2911
|
+
throw new import_common17.BadRequestException("toolCallId must be a non-empty string");
|
|
2619
2912
|
}
|
|
2620
2913
|
return claimed;
|
|
2621
2914
|
}
|
|
@@ -2625,10 +2918,10 @@ function rejectReason(claimed) {
|
|
|
2625
2918
|
return void 0;
|
|
2626
2919
|
}
|
|
2627
2920
|
if (typeof claimed !== "string") {
|
|
2628
|
-
throw new
|
|
2921
|
+
throw new import_common17.BadRequestException("reason must be a string");
|
|
2629
2922
|
}
|
|
2630
2923
|
if (claimed.length > MAX_REJECT_REASON_LENGTH) {
|
|
2631
|
-
throw new
|
|
2924
|
+
throw new import_common17.BadRequestException(`reason must be at most ${MAX_REJECT_REASON_LENGTH} characters`);
|
|
2632
2925
|
}
|
|
2633
2926
|
return claimed;
|
|
2634
2927
|
}
|
|
@@ -2638,7 +2931,7 @@ function remember(claimed) {
|
|
|
2638
2931
|
return false;
|
|
2639
2932
|
}
|
|
2640
2933
|
if (typeof claimed !== "boolean") {
|
|
2641
|
-
throw new
|
|
2934
|
+
throw new import_common17.BadRequestException("remember must be a boolean");
|
|
2642
2935
|
}
|
|
2643
2936
|
return claimed;
|
|
2644
2937
|
}
|
|
@@ -2648,7 +2941,7 @@ function via(claimed) {
|
|
|
2648
2941
|
return DEFAULT_VIA;
|
|
2649
2942
|
}
|
|
2650
2943
|
if (typeof claimed !== "string" || claimed.length === 0 || claimed.length > MAX_VIA_LENGTH) {
|
|
2651
|
-
throw new
|
|
2944
|
+
throw new import_common17.BadRequestException(`via must be a string of 1-${MAX_VIA_LENGTH} characters`);
|
|
2652
2945
|
}
|
|
2653
2946
|
return claimed;
|
|
2654
2947
|
}
|
|
@@ -2658,26 +2951,26 @@ function answers(claimed) {
|
|
|
2658
2951
|
return void 0;
|
|
2659
2952
|
}
|
|
2660
2953
|
if (typeof claimed !== "object" || claimed === null || Array.isArray(claimed)) {
|
|
2661
|
-
throw new
|
|
2954
|
+
throw new import_common17.BadRequestException("answers must be an object of questionId \u2192 chosen values");
|
|
2662
2955
|
}
|
|
2663
2956
|
const entries = Object.entries(claimed);
|
|
2664
2957
|
if (entries.length > MAX_ANSWERED_QUESTIONS) {
|
|
2665
|
-
throw new
|
|
2958
|
+
throw new import_common17.BadRequestException(`answers may cover at most ${MAX_ANSWERED_QUESTIONS} questions`);
|
|
2666
2959
|
}
|
|
2667
2960
|
const validated = /* @__PURE__ */ Object.create(null);
|
|
2668
2961
|
for (const [questionId, values] of entries) {
|
|
2669
2962
|
if (!Array.isArray(values)) {
|
|
2670
|
-
throw new
|
|
2963
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] must be an array of chosen values`);
|
|
2671
2964
|
}
|
|
2672
2965
|
if (values.length > MAX_VALUES_PER_QUESTION) {
|
|
2673
|
-
throw new
|
|
2966
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] may carry at most ${MAX_VALUES_PER_QUESTION} values`);
|
|
2674
2967
|
}
|
|
2675
2968
|
for (const value of values) {
|
|
2676
2969
|
if (typeof value !== "string") {
|
|
2677
|
-
throw new
|
|
2970
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] must contain only strings`);
|
|
2678
2971
|
}
|
|
2679
2972
|
if (value.length > MAX_ANSWER_VALUE_LENGTH) {
|
|
2680
|
-
throw new
|
|
2973
|
+
throw new import_common17.BadRequestException(`answers["${questionId}"] values must be at most ${MAX_ANSWER_VALUE_LENGTH} characters`);
|
|
2681
2974
|
}
|
|
2682
2975
|
}
|
|
2683
2976
|
validated[questionId] = values;
|
|
@@ -2735,64 +3028,64 @@ var ToolCallController = class {
|
|
|
2735
3028
|
};
|
|
2736
3029
|
}
|
|
2737
3030
|
};
|
|
2738
|
-
|
|
2739
|
-
(0,
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
3031
|
+
_ts_decorate17([
|
|
3032
|
+
(0, import_common17.Post)("approve"),
|
|
3033
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3034
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3035
|
+
_ts_metadata16("design:type", Function),
|
|
3036
|
+
_ts_metadata16("design:paramtypes", [
|
|
2744
3037
|
typeof Request === "undefined" ? Object : Request,
|
|
2745
3038
|
typeof ApproveBody === "undefined" ? Object : ApproveBody
|
|
2746
3039
|
]),
|
|
2747
|
-
|
|
3040
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2748
3041
|
], ToolCallController.prototype, "approve", null);
|
|
2749
|
-
|
|
2750
|
-
(0,
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
3042
|
+
_ts_decorate17([
|
|
3043
|
+
(0, import_common17.Post)("reject"),
|
|
3044
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3045
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3046
|
+
_ts_metadata16("design:type", Function),
|
|
3047
|
+
_ts_metadata16("design:paramtypes", [
|
|
2755
3048
|
typeof Request === "undefined" ? Object : Request,
|
|
2756
3049
|
typeof RejectBody === "undefined" ? Object : RejectBody
|
|
2757
3050
|
]),
|
|
2758
|
-
|
|
3051
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2759
3052
|
], ToolCallController.prototype, "reject", null);
|
|
2760
|
-
|
|
2761
|
-
(0,
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
3053
|
+
_ts_decorate17([
|
|
3054
|
+
(0, import_common17.Post)("answer"),
|
|
3055
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3056
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3057
|
+
_ts_metadata16("design:type", Function),
|
|
3058
|
+
_ts_metadata16("design:paramtypes", [
|
|
2766
3059
|
typeof Request === "undefined" ? Object : Request,
|
|
2767
3060
|
typeof AnswerBody === "undefined" ? Object : AnswerBody
|
|
2768
3061
|
]),
|
|
2769
|
-
|
|
3062
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2770
3063
|
], ToolCallController.prototype, "answer", null);
|
|
2771
|
-
|
|
2772
|
-
(0,
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
3064
|
+
_ts_decorate17([
|
|
3065
|
+
(0, import_common17.Post)("skip"),
|
|
3066
|
+
_ts_param15(0, (0, import_common17.Req)()),
|
|
3067
|
+
_ts_param15(1, (0, import_common17.Body)()),
|
|
3068
|
+
_ts_metadata16("design:type", Function),
|
|
3069
|
+
_ts_metadata16("design:paramtypes", [
|
|
2777
3070
|
typeof Request === "undefined" ? Object : Request,
|
|
2778
3071
|
Object
|
|
2779
3072
|
]),
|
|
2780
|
-
|
|
3073
|
+
_ts_metadata16("design:returntype", Promise)
|
|
2781
3074
|
], ToolCallController.prototype, "skip", null);
|
|
2782
|
-
ToolCallController =
|
|
2783
|
-
(0,
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
3075
|
+
ToolCallController = _ts_decorate17([
|
|
3076
|
+
(0, import_common17.Controller)("tool-call"),
|
|
3077
|
+
_ts_param15(1, (0, import_common17.Inject)(import_nestjs_agent_core18.AGENT_ACTOR_RESOLVER)),
|
|
3078
|
+
_ts_metadata16("design:type", Function),
|
|
3079
|
+
_ts_metadata16("design:paramtypes", [
|
|
2787
3080
|
typeof AgentService === "undefined" ? Object : AgentService,
|
|
2788
3081
|
typeof ActorResolver === "undefined" ? Object : ActorResolver
|
|
2789
3082
|
])
|
|
2790
3083
|
], ToolCallController);
|
|
2791
3084
|
|
|
2792
3085
|
// src/controller/tools.controller.ts
|
|
2793
|
-
var
|
|
2794
|
-
var
|
|
2795
|
-
function
|
|
3086
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
3087
|
+
var import_common18 = require("@nestjs/common");
|
|
3088
|
+
function _ts_decorate18(decorators, target, key, desc) {
|
|
2796
3089
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2797
3090
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2798
3091
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2805,19 +3098,19 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2805
3098
|
}
|
|
2806
3099
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2807
3100
|
}
|
|
2808
|
-
__name(
|
|
2809
|
-
function
|
|
3101
|
+
__name(_ts_decorate18, "_ts_decorate");
|
|
3102
|
+
function _ts_metadata17(metadataKey, metadataValue) {
|
|
2810
3103
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2811
3104
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2812
3105
|
}
|
|
2813
3106
|
}
|
|
2814
|
-
__name(
|
|
2815
|
-
function
|
|
3107
|
+
__name(_ts_metadata17, "_ts_metadata");
|
|
3108
|
+
function _ts_param16(paramIndex, decorator) {
|
|
2816
3109
|
return function(target, key) {
|
|
2817
3110
|
decorator(target, key, paramIndex);
|
|
2818
3111
|
};
|
|
2819
3112
|
}
|
|
2820
|
-
__name(
|
|
3113
|
+
__name(_ts_param16, "_ts_param");
|
|
2821
3114
|
var ToolsController = class {
|
|
2822
3115
|
static {
|
|
2823
3116
|
__name(this, "ToolsController");
|
|
@@ -2832,7 +3125,7 @@ var ToolsController = class {
|
|
|
2832
3125
|
}
|
|
2833
3126
|
async list(req, agent) {
|
|
2834
3127
|
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
2835
|
-
throw new
|
|
3128
|
+
throw new import_common18.NotFoundException(`No agent named "${agent}"`);
|
|
2836
3129
|
}
|
|
2837
3130
|
const actor = await this.actorResolver.resolve(req);
|
|
2838
3131
|
const deps = this.depsFactory.forAgent(agent);
|
|
@@ -2846,33 +3139,33 @@ var ToolsController = class {
|
|
|
2846
3139
|
}));
|
|
2847
3140
|
}
|
|
2848
3141
|
};
|
|
2849
|
-
|
|
2850
|
-
(0,
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
3142
|
+
_ts_decorate18([
|
|
3143
|
+
(0, import_common18.Get)(),
|
|
3144
|
+
_ts_param16(0, (0, import_common18.Req)()),
|
|
3145
|
+
_ts_param16(1, (0, import_common18.Query)("agent")),
|
|
3146
|
+
_ts_metadata17("design:type", Function),
|
|
3147
|
+
_ts_metadata17("design:paramtypes", [
|
|
2855
3148
|
typeof Request === "undefined" ? Object : Request,
|
|
2856
3149
|
String
|
|
2857
3150
|
]),
|
|
2858
|
-
|
|
3151
|
+
_ts_metadata17("design:returntype", Promise)
|
|
2859
3152
|
], ToolsController.prototype, "list", null);
|
|
2860
|
-
ToolsController =
|
|
2861
|
-
(0,
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
3153
|
+
ToolsController = _ts_decorate18([
|
|
3154
|
+
(0, import_common18.Controller)("tools"),
|
|
3155
|
+
_ts_param16(0, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_ACTOR_RESOLVER)),
|
|
3156
|
+
_ts_param16(1, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_DEPS_FACTORY)),
|
|
3157
|
+
_ts_param16(2, (0, import_common18.Inject)(import_nestjs_agent_core19.AGENT_REGISTRY)),
|
|
3158
|
+
_ts_metadata17("design:type", Function),
|
|
3159
|
+
_ts_metadata17("design:paramtypes", [
|
|
2867
3160
|
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2868
3161
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2869
|
-
typeof
|
|
3162
|
+
typeof import_nestjs_agent_core19.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core19.AgentRegistry
|
|
2870
3163
|
])
|
|
2871
3164
|
], ToolsController);
|
|
2872
3165
|
|
|
2873
3166
|
// src/discovery/agent-discovery.service.ts
|
|
2874
|
-
var
|
|
2875
|
-
var
|
|
3167
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
3168
|
+
var import_common19 = require("@nestjs/common");
|
|
2876
3169
|
var import_core = require("@nestjs/core");
|
|
2877
3170
|
|
|
2878
3171
|
// src/decorator/agent.decorator.ts
|
|
@@ -2889,7 +3182,7 @@ var SYSTEM_PROMPT_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:
|
|
|
2889
3182
|
var SYSTEM_PROMPT_CONTRIBUTOR_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:system-prompt-contributor");
|
|
2890
3183
|
|
|
2891
3184
|
// src/discovery/agent-discovery.service.ts
|
|
2892
|
-
function
|
|
3185
|
+
function _ts_decorate19(decorators, target, key, desc) {
|
|
2893
3186
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2894
3187
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2895
3188
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2902,19 +3195,19 @@ function _ts_decorate17(decorators, target, key, desc) {
|
|
|
2902
3195
|
}
|
|
2903
3196
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2904
3197
|
}
|
|
2905
|
-
__name(
|
|
2906
|
-
function
|
|
3198
|
+
__name(_ts_decorate19, "_ts_decorate");
|
|
3199
|
+
function _ts_metadata18(metadataKey, metadataValue) {
|
|
2907
3200
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2908
3201
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2909
3202
|
}
|
|
2910
3203
|
}
|
|
2911
|
-
__name(
|
|
2912
|
-
function
|
|
3204
|
+
__name(_ts_metadata18, "_ts_metadata");
|
|
3205
|
+
function _ts_param17(paramIndex, decorator) {
|
|
2913
3206
|
return function(target, key) {
|
|
2914
3207
|
decorator(target, key, paramIndex);
|
|
2915
3208
|
};
|
|
2916
3209
|
}
|
|
2917
|
-
__name(
|
|
3210
|
+
__name(_ts_param17, "_ts_param");
|
|
2918
3211
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
2919
3212
|
static {
|
|
2920
3213
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2923,7 +3216,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2923
3216
|
scanner;
|
|
2924
3217
|
registry;
|
|
2925
3218
|
contributors;
|
|
2926
|
-
logger = new
|
|
3219
|
+
logger = new import_common19.Logger(_AgentDiscoveryService.name);
|
|
2927
3220
|
constructor(discovery, scanner, registry, contributors) {
|
|
2928
3221
|
this.discovery = discovery;
|
|
2929
3222
|
this.scanner = scanner;
|
|
@@ -3041,22 +3334,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
3041
3334
|
return (ctx) => candidate.call(instance, ctx);
|
|
3042
3335
|
}
|
|
3043
3336
|
};
|
|
3044
|
-
AgentDiscoveryService =
|
|
3045
|
-
(0,
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3337
|
+
AgentDiscoveryService = _ts_decorate19([
|
|
3338
|
+
(0, import_common19.Injectable)(),
|
|
3339
|
+
_ts_param17(2, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_REGISTRY)),
|
|
3340
|
+
_ts_param17(3, (0, import_common19.Inject)(import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS)),
|
|
3341
|
+
_ts_metadata18("design:type", Function),
|
|
3342
|
+
_ts_metadata18("design:paramtypes", [
|
|
3050
3343
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
3051
3344
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
3052
|
-
typeof
|
|
3345
|
+
typeof import_nestjs_agent_core20.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core20.AgentRegistry,
|
|
3053
3346
|
Array
|
|
3054
3347
|
])
|
|
3055
3348
|
], AgentDiscoveryService);
|
|
3056
3349
|
|
|
3057
3350
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3058
|
-
var
|
|
3059
|
-
var
|
|
3351
|
+
var import_nestjs_agent_core21 = require("@dudousxd/nestjs-agent-core");
|
|
3352
|
+
var import_common20 = require("@nestjs/common");
|
|
3060
3353
|
var import_core2 = require("@nestjs/core");
|
|
3061
3354
|
var import_zod = require("zod");
|
|
3062
3355
|
|
|
@@ -3076,7 +3369,7 @@ function isBrandedFunctionalTool(value) {
|
|
|
3076
3369
|
__name(isBrandedFunctionalTool, "isBrandedFunctionalTool");
|
|
3077
3370
|
|
|
3078
3371
|
// src/discovery/ai-tool-discovery.service.ts
|
|
3079
|
-
function
|
|
3372
|
+
function _ts_decorate20(decorators, target, key, desc) {
|
|
3080
3373
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3081
3374
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3082
3375
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3089,19 +3382,19 @@ function _ts_decorate18(decorators, target, key, desc) {
|
|
|
3089
3382
|
}
|
|
3090
3383
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3091
3384
|
}
|
|
3092
|
-
__name(
|
|
3093
|
-
function
|
|
3385
|
+
__name(_ts_decorate20, "_ts_decorate");
|
|
3386
|
+
function _ts_metadata19(metadataKey, metadataValue) {
|
|
3094
3387
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3095
3388
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3096
3389
|
}
|
|
3097
3390
|
}
|
|
3098
|
-
__name(
|
|
3099
|
-
function
|
|
3391
|
+
__name(_ts_metadata19, "_ts_metadata");
|
|
3392
|
+
function _ts_param18(paramIndex, decorator) {
|
|
3100
3393
|
return function(target, key) {
|
|
3101
3394
|
decorator(target, key, paramIndex);
|
|
3102
3395
|
};
|
|
3103
3396
|
}
|
|
3104
|
-
__name(
|
|
3397
|
+
__name(_ts_param18, "_ts_param");
|
|
3105
3398
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
3106
3399
|
static {
|
|
3107
3400
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -3110,7 +3403,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3110
3403
|
registry;
|
|
3111
3404
|
agents;
|
|
3112
3405
|
options;
|
|
3113
|
-
logger = new
|
|
3406
|
+
logger = new import_common20.Logger(_AiToolDiscoveryService.name);
|
|
3114
3407
|
constructor(discovery, registry, agents, options) {
|
|
3115
3408
|
this.discovery = discovery;
|
|
3116
3409
|
this.registry = registry;
|
|
@@ -3184,7 +3477,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3184
3477
|
let delegates = 0;
|
|
3185
3478
|
for (const definition of this.agents.list()) {
|
|
3186
3479
|
for (const edge of definition.delegatesTo ?? []) {
|
|
3187
|
-
const { agent: target, detached } = (0,
|
|
3480
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core21.normalizeDelegation)(edge);
|
|
3188
3481
|
const targetDefinition = this.agents.get(target);
|
|
3189
3482
|
if (targetDefinition === void 0) {
|
|
3190
3483
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -3234,13 +3527,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
3234
3527
|
return true;
|
|
3235
3528
|
}
|
|
3236
3529
|
};
|
|
3237
|
-
AiToolDiscoveryService =
|
|
3238
|
-
(0,
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3530
|
+
AiToolDiscoveryService = _ts_decorate20([
|
|
3531
|
+
(0, import_common20.Injectable)(),
|
|
3532
|
+
_ts_param18(1, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_TOOL_REGISTRY)),
|
|
3533
|
+
_ts_param18(2, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_REGISTRY)),
|
|
3534
|
+
_ts_param18(3, (0, import_common20.Inject)(import_nestjs_agent_core21.AGENT_OPTIONS)),
|
|
3535
|
+
_ts_metadata19("design:type", Function),
|
|
3536
|
+
_ts_metadata19("design:paramtypes", [
|
|
3244
3537
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
3245
3538
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
3246
3539
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -3249,25 +3542,25 @@ AiToolDiscoveryService = _ts_decorate18([
|
|
|
3249
3542
|
], AiToolDiscoveryService);
|
|
3250
3543
|
|
|
3251
3544
|
// src/discovery/skill-discovery.service.ts
|
|
3252
|
-
var
|
|
3253
|
-
var
|
|
3545
|
+
var import_nestjs_agent_core23 = require("@dudousxd/nestjs-agent-core");
|
|
3546
|
+
var import_common21 = require("@nestjs/common");
|
|
3254
3547
|
var import_core3 = require("@nestjs/core");
|
|
3255
3548
|
|
|
3256
3549
|
// src/decorator/skill.decorator.ts
|
|
3257
3550
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
3258
|
-
var
|
|
3551
|
+
var import_nestjs_agent_core22 = require("@dudousxd/nestjs-agent-core");
|
|
3259
3552
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
3260
3553
|
function readSkillMetadata(target) {
|
|
3261
3554
|
return Reflect.getMetadata(SKILL_METADATA, target);
|
|
3262
3555
|
}
|
|
3263
3556
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
3264
3557
|
function skillScope(options) {
|
|
3265
|
-
return options.scope ??
|
|
3558
|
+
return options.scope ?? import_nestjs_agent_core22.GLOBAL_SCOPE;
|
|
3266
3559
|
}
|
|
3267
3560
|
__name(skillScope, "skillScope");
|
|
3268
3561
|
|
|
3269
3562
|
// src/discovery/skill-discovery.service.ts
|
|
3270
|
-
function
|
|
3563
|
+
function _ts_decorate21(decorators, target, key, desc) {
|
|
3271
3564
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3272
3565
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3273
3566
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3280,26 +3573,26 @@ function _ts_decorate19(decorators, target, key, desc) {
|
|
|
3280
3573
|
}
|
|
3281
3574
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3282
3575
|
}
|
|
3283
|
-
__name(
|
|
3284
|
-
function
|
|
3576
|
+
__name(_ts_decorate21, "_ts_decorate");
|
|
3577
|
+
function _ts_metadata20(metadataKey, metadataValue) {
|
|
3285
3578
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3286
3579
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3287
3580
|
}
|
|
3288
3581
|
}
|
|
3289
|
-
__name(
|
|
3290
|
-
function
|
|
3582
|
+
__name(_ts_metadata20, "_ts_metadata");
|
|
3583
|
+
function _ts_param19(paramIndex, decorator) {
|
|
3291
3584
|
return function(target, key) {
|
|
3292
3585
|
decorator(target, key, paramIndex);
|
|
3293
3586
|
};
|
|
3294
3587
|
}
|
|
3295
|
-
__name(
|
|
3588
|
+
__name(_ts_param19, "_ts_param");
|
|
3296
3589
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
3297
3590
|
static {
|
|
3298
3591
|
__name(this, "SkillDiscoveryService");
|
|
3299
3592
|
}
|
|
3300
3593
|
discovery;
|
|
3301
3594
|
declared;
|
|
3302
|
-
logger = new
|
|
3595
|
+
logger = new import_common21.Logger(_SkillDiscoveryService.name);
|
|
3303
3596
|
constructor(discovery, declared) {
|
|
3304
3597
|
this.discovery = discovery;
|
|
3305
3598
|
this.declared = declared;
|
|
@@ -3336,11 +3629,11 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
3336
3629
|
return flat === void 0 ? void 0 : () => flat;
|
|
3337
3630
|
}
|
|
3338
3631
|
};
|
|
3339
|
-
SkillDiscoveryService =
|
|
3340
|
-
(0,
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3632
|
+
SkillDiscoveryService = _ts_decorate21([
|
|
3633
|
+
(0, import_common21.Injectable)(),
|
|
3634
|
+
_ts_param19(1, (0, import_common21.Inject)(import_nestjs_agent_core23.AGENT_SKILL_SOURCES)),
|
|
3635
|
+
_ts_metadata20("design:type", Function),
|
|
3636
|
+
_ts_metadata20("design:paramtypes", [
|
|
3344
3637
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
3345
3638
|
Array
|
|
3346
3639
|
])
|
|
@@ -3370,9 +3663,9 @@ var LedgerQuotaStore = class {
|
|
|
3370
3663
|
};
|
|
3371
3664
|
|
|
3372
3665
|
// src/runner/inline-agent-runner.ts
|
|
3373
|
-
var
|
|
3374
|
-
var
|
|
3375
|
-
function
|
|
3666
|
+
var import_nestjs_agent_core24 = require("@dudousxd/nestjs-agent-core");
|
|
3667
|
+
var import_common22 = require("@nestjs/common");
|
|
3668
|
+
function _ts_decorate22(decorators, target, key, desc) {
|
|
3376
3669
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3377
3670
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3378
3671
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3385,26 +3678,26 @@ function _ts_decorate20(decorators, target, key, desc) {
|
|
|
3385
3678
|
}
|
|
3386
3679
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3387
3680
|
}
|
|
3388
|
-
__name(
|
|
3389
|
-
function
|
|
3681
|
+
__name(_ts_decorate22, "_ts_decorate");
|
|
3682
|
+
function _ts_metadata21(metadataKey, metadataValue) {
|
|
3390
3683
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3391
3684
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3392
3685
|
}
|
|
3393
3686
|
}
|
|
3394
|
-
__name(
|
|
3395
|
-
function
|
|
3687
|
+
__name(_ts_metadata21, "_ts_metadata");
|
|
3688
|
+
function _ts_param20(paramIndex, decorator) {
|
|
3396
3689
|
return function(target, key) {
|
|
3397
3690
|
decorator(target, key, paramIndex);
|
|
3398
3691
|
};
|
|
3399
3692
|
}
|
|
3400
|
-
__name(
|
|
3693
|
+
__name(_ts_param20, "_ts_param");
|
|
3401
3694
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
3402
3695
|
static {
|
|
3403
3696
|
__name(this, "InlineAgentRunner");
|
|
3404
3697
|
}
|
|
3405
3698
|
factory;
|
|
3406
3699
|
store;
|
|
3407
|
-
logger = new
|
|
3700
|
+
logger = new import_common22.Logger(_InlineAgentRunner.name);
|
|
3408
3701
|
pending = /* @__PURE__ */ new Map();
|
|
3409
3702
|
/**
|
|
3410
3703
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -3433,18 +3726,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3433
3726
|
] : []
|
|
3434
3727
|
]
|
|
3435
3728
|
});
|
|
3436
|
-
void (0,
|
|
3729
|
+
void (0, import_nestjs_agent_core24.runAgentLoop)({
|
|
3437
3730
|
...deps,
|
|
3438
3731
|
day
|
|
3439
3732
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
3440
|
-
if (error instanceof
|
|
3733
|
+
if (error instanceof import_nestjs_agent_core24.RunCancelledError) {
|
|
3441
3734
|
await this.settleCancelled(runId, input.threadId, deps);
|
|
3442
3735
|
return;
|
|
3443
3736
|
}
|
|
3444
3737
|
const message = error instanceof Error ? error.message : String(error);
|
|
3445
|
-
const code = (0,
|
|
3738
|
+
const code = (0, import_nestjs_agent_core24.agentFailureCode)(error);
|
|
3446
3739
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
3447
|
-
(0,
|
|
3740
|
+
(0, import_nestjs_agent_core24.publishAgentRunFailed)({
|
|
3448
3741
|
runId,
|
|
3449
3742
|
code,
|
|
3450
3743
|
message
|
|
@@ -3493,7 +3786,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3493
3786
|
for (const [key, waiter] of this.pending) {
|
|
3494
3787
|
if (key.startsWith(`${runId}:`)) {
|
|
3495
3788
|
this.pending.delete(key);
|
|
3496
|
-
waiter.reject(new
|
|
3789
|
+
waiter.reject(new import_nestjs_agent_core24.RunCancelledError());
|
|
3497
3790
|
}
|
|
3498
3791
|
}
|
|
3499
3792
|
await Promise.resolve();
|
|
@@ -3508,7 +3801,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3508
3801
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
3509
3802
|
await this.store.setActiveStream(threadId, null);
|
|
3510
3803
|
const writer = await deps.sink.open(runId);
|
|
3511
|
-
await writer.write((0,
|
|
3804
|
+
await writer.write((0, import_nestjs_agent_core24.encodeStreamEvent)({
|
|
3512
3805
|
kind: "cancelled"
|
|
3513
3806
|
}));
|
|
3514
3807
|
await writer.end();
|
|
@@ -3569,7 +3862,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3569
3862
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3570
3863
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3571
3864
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3572
|
-
parallel:
|
|
3865
|
+
parallel: import_nestjs_agent_core24.settleAll,
|
|
3573
3866
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3574
3867
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
3575
3868
|
agentName,
|
|
@@ -3620,7 +3913,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3620
3913
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3621
3914
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3622
3915
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3623
|
-
parallel:
|
|
3916
|
+
parallel: import_nestjs_agent_core24.settleAll,
|
|
3624
3917
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
3625
3918
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
3626
3919
|
agentName: childName,
|
|
@@ -3653,7 +3946,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3653
3946
|
}
|
|
3654
3947
|
}), "startAgent")
|
|
3655
3948
|
};
|
|
3656
|
-
void (0,
|
|
3949
|
+
void (0, import_nestjs_agent_core24.runAgentLoop)({
|
|
3657
3950
|
...deps,
|
|
3658
3951
|
day
|
|
3659
3952
|
}, {
|
|
@@ -3667,13 +3960,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3667
3960
|
parentRunId,
|
|
3668
3961
|
deliverTo
|
|
3669
3962
|
}, hooks).catch(async (error) => {
|
|
3670
|
-
const cancelled = error instanceof
|
|
3963
|
+
const cancelled = error instanceof import_nestjs_agent_core24.RunCancelledError;
|
|
3671
3964
|
const message = error instanceof Error ? error.message : String(error);
|
|
3672
3965
|
if (!cancelled) {
|
|
3673
3966
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
3674
|
-
(0,
|
|
3967
|
+
(0, import_nestjs_agent_core24.publishAgentRunFailed)({
|
|
3675
3968
|
runId,
|
|
3676
|
-
code: (0,
|
|
3969
|
+
code: (0, import_nestjs_agent_core24.agentFailureCode)(error),
|
|
3677
3970
|
message
|
|
3678
3971
|
});
|
|
3679
3972
|
}
|
|
@@ -3681,11 +3974,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3681
3974
|
runId,
|
|
3682
3975
|
status: cancelled ? "cancelled" : "failed",
|
|
3683
3976
|
...cancelled ? {} : {
|
|
3684
|
-
errorCode: (0,
|
|
3977
|
+
errorCode: (0, import_nestjs_agent_core24.agentFailureCode)(error),
|
|
3685
3978
|
errorMessage: message
|
|
3686
3979
|
}
|
|
3687
3980
|
});
|
|
3688
|
-
await (0,
|
|
3981
|
+
await (0, import_nestjs_agent_core24.settleUnsettledDelegation)({
|
|
3689
3982
|
store: this.store,
|
|
3690
3983
|
delivery: deliverTo,
|
|
3691
3984
|
agent: agentName,
|
|
@@ -3724,7 +4017,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3724
4017
|
awaitApproval: /* @__PURE__ */ __name((call, _ctx, opts) => this.parkApproval(runId, call.id, opts?.timeoutMs), "awaitApproval"),
|
|
3725
4018
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
3726
4019
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
3727
|
-
parallel:
|
|
4020
|
+
parallel: import_nestjs_agent_core24.settleAll,
|
|
3728
4021
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
3729
4022
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
3730
4023
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -3759,7 +4052,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3759
4052
|
}), "startAgent")
|
|
3760
4053
|
};
|
|
3761
4054
|
try {
|
|
3762
|
-
return await (0,
|
|
4055
|
+
return await (0, import_nestjs_agent_core24.runAgentLoop)({
|
|
3763
4056
|
...deps,
|
|
3764
4057
|
day
|
|
3765
4058
|
}, {
|
|
@@ -3778,19 +4071,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
3778
4071
|
}
|
|
3779
4072
|
}
|
|
3780
4073
|
};
|
|
3781
|
-
InlineAgentRunner =
|
|
3782
|
-
(0,
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
4074
|
+
InlineAgentRunner = _ts_decorate22([
|
|
4075
|
+
(0, import_common22.Injectable)(),
|
|
4076
|
+
_ts_param20(0, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_DEPS_FACTORY)),
|
|
4077
|
+
_ts_param20(1, (0, import_common22.Inject)(import_nestjs_agent_core24.AGENT_STORE)),
|
|
4078
|
+
_ts_metadata21("design:type", Function),
|
|
4079
|
+
_ts_metadata21("design:paramtypes", [
|
|
3787
4080
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
3788
4081
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
3789
4082
|
])
|
|
3790
4083
|
], InlineAgentRunner);
|
|
3791
4084
|
|
|
3792
4085
|
// src/skills-config.ts
|
|
3793
|
-
var
|
|
4086
|
+
var import_nestjs_agent_core25 = require("@dudousxd/nestjs-agent-core");
|
|
3794
4087
|
function declaredSkillProvider(declared) {
|
|
3795
4088
|
return {
|
|
3796
4089
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -3816,7 +4109,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3816
4109
|
declaredSkillProvider(declared)
|
|
3817
4110
|
];
|
|
3818
4111
|
return {
|
|
3819
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
4112
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core25.compositeSkillProvider)(providers),
|
|
3820
4113
|
...options.scopes !== void 0 ? {
|
|
3821
4114
|
scopes: options.scopes
|
|
3822
4115
|
} : {},
|
|
@@ -3828,7 +4121,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
3828
4121
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
3829
4122
|
|
|
3830
4123
|
// src/agent.module.ts
|
|
3831
|
-
function
|
|
4124
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
3832
4125
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3833
4126
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3834
4127
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3841,92 +4134,99 @@ function _ts_decorate21(decorators, target, key, desc) {
|
|
|
3841
4134
|
}
|
|
3842
4135
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3843
4136
|
}
|
|
3844
|
-
__name(
|
|
4137
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
3845
4138
|
var DEFAULT_PATH = "agent";
|
|
3846
4139
|
function sharedProviders(durable, includeStore) {
|
|
3847
4140
|
const providers = [
|
|
3848
4141
|
{
|
|
3849
|
-
provide:
|
|
3850
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
4142
|
+
provide: import_nestjs_agent_core26.AGENT_TOOL_REGISTRY,
|
|
4143
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core26.ToolRegistry(), "useFactory")
|
|
3851
4144
|
},
|
|
3852
4145
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
3853
4146
|
{
|
|
3854
|
-
provide:
|
|
3855
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
4147
|
+
provide: import_nestjs_agent_core26.AGENT_REGISTRY,
|
|
4148
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core26.AgentRegistry(), "useFactory")
|
|
3856
4149
|
},
|
|
3857
4150
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
3858
4151
|
{
|
|
3859
|
-
provide:
|
|
4152
|
+
provide: import_nestjs_agent_core26.AGENT_PROMPT_CONTRIBUTORS,
|
|
3860
4153
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3861
4154
|
},
|
|
3862
4155
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
3863
4156
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
3864
4157
|
{
|
|
3865
|
-
provide:
|
|
4158
|
+
provide: import_nestjs_agent_core26.AGENT_SKILL_SOURCES,
|
|
3866
4159
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3867
4160
|
},
|
|
3868
4161
|
{
|
|
3869
4162
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
3870
4163
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
3871
4164
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
3872
|
-
provide:
|
|
4165
|
+
provide: import_nestjs_agent_core26.AGENT_SKILLS,
|
|
3873
4166
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3874
4167
|
inject: [
|
|
3875
|
-
|
|
3876
|
-
|
|
4168
|
+
import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4169
|
+
import_nestjs_agent_core26.AGENT_SKILL_SOURCES
|
|
3877
4170
|
]
|
|
3878
4171
|
},
|
|
3879
4172
|
{
|
|
3880
4173
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
3881
4174
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
3882
|
-
provide:
|
|
4175
|
+
provide: import_nestjs_agent_core26.AGENT_MEMORY,
|
|
3883
4176
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3884
4177
|
inject: [
|
|
3885
|
-
|
|
4178
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3886
4179
|
]
|
|
3887
4180
|
},
|
|
3888
4181
|
{
|
|
3889
|
-
provide:
|
|
4182
|
+
provide: import_nestjs_agent_core26.AGENT_SINK,
|
|
3890
4183
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3891
4184
|
inject: [
|
|
3892
|
-
|
|
4185
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3893
4186
|
]
|
|
3894
4187
|
},
|
|
3895
4188
|
{
|
|
3896
|
-
provide:
|
|
3897
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
4189
|
+
provide: import_nestjs_agent_core26.AGENT_ROLES_POLICY,
|
|
4190
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core26.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3898
4191
|
inject: [
|
|
3899
|
-
|
|
4192
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3900
4193
|
]
|
|
3901
4194
|
},
|
|
3902
4195
|
{
|
|
3903
|
-
provide:
|
|
4196
|
+
provide: import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER,
|
|
3904
4197
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
3905
4198
|
inject: [
|
|
3906
|
-
|
|
4199
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3907
4200
|
]
|
|
3908
4201
|
},
|
|
3909
4202
|
{
|
|
3910
|
-
provide:
|
|
4203
|
+
provide: import_nestjs_agent_core26.AGENT_MODEL,
|
|
3911
4204
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3912
4205
|
inject: [
|
|
3913
|
-
|
|
4206
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3914
4207
|
]
|
|
3915
4208
|
},
|
|
3916
4209
|
{
|
|
3917
4210
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
3918
4211
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
3919
4212
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
3920
|
-
provide:
|
|
4213
|
+
provide: import_nestjs_agent_core26.AGENT_QUOTA_STORE,
|
|
3921
4214
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3922
4215
|
inject: [
|
|
3923
|
-
|
|
3924
|
-
|
|
4216
|
+
import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4217
|
+
import_nestjs_agent_core26.AGENT_STORE
|
|
4218
|
+
]
|
|
4219
|
+
},
|
|
4220
|
+
{
|
|
4221
|
+
provide: import_nestjs_agent_core26.AGENT_MODEL_CATALOG,
|
|
4222
|
+
useFactory: /* @__PURE__ */ __name((o) => o.models, "useFactory"),
|
|
4223
|
+
inject: [
|
|
4224
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3925
4225
|
]
|
|
3926
4226
|
},
|
|
3927
4227
|
AgentDepsFactory2,
|
|
3928
4228
|
{
|
|
3929
|
-
provide:
|
|
4229
|
+
provide: import_nestjs_agent_core26.AGENT_DEPS_FACTORY,
|
|
3930
4230
|
useExisting: AgentDepsFactory2
|
|
3931
4231
|
},
|
|
3932
4232
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -3940,22 +4240,22 @@ function sharedProviders(durable, includeStore) {
|
|
|
3940
4240
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
3941
4241
|
AgentApprovalPortAdapter,
|
|
3942
4242
|
{
|
|
3943
|
-
provide:
|
|
4243
|
+
provide: import_nestjs_agent_core26.AGENT_APPROVAL_PORT,
|
|
3944
4244
|
useExisting: AgentApprovalPortAdapter
|
|
3945
4245
|
}
|
|
3946
4246
|
];
|
|
3947
4247
|
if (includeStore) {
|
|
3948
4248
|
providers.push({
|
|
3949
|
-
provide:
|
|
4249
|
+
provide: import_nestjs_agent_core26.AGENT_STORE,
|
|
3950
4250
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
3951
4251
|
inject: [
|
|
3952
|
-
|
|
4252
|
+
import_nestjs_agent_core26.AGENT_OPTIONS
|
|
3953
4253
|
]
|
|
3954
4254
|
});
|
|
3955
4255
|
}
|
|
3956
4256
|
if (durable) {
|
|
3957
4257
|
providers.push({
|
|
3958
|
-
provide:
|
|
4258
|
+
provide: import_nestjs_agent_core26.AGENT_RUNNER,
|
|
3959
4259
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
3960
4260
|
if (durableRunner === void 0) {
|
|
3961
4261
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -3964,14 +4264,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
3964
4264
|
}, "useFactory"),
|
|
3965
4265
|
inject: [
|
|
3966
4266
|
{
|
|
3967
|
-
token:
|
|
4267
|
+
token: import_nestjs_agent_core26.AGENT_DURABLE_RUNNER,
|
|
3968
4268
|
optional: true
|
|
3969
4269
|
}
|
|
3970
4270
|
]
|
|
3971
4271
|
});
|
|
3972
4272
|
} else {
|
|
3973
4273
|
providers.push({
|
|
3974
|
-
provide:
|
|
4274
|
+
provide: import_nestjs_agent_core26.AGENT_RUNNER,
|
|
3975
4275
|
useExisting: InlineAgentRunner
|
|
3976
4276
|
});
|
|
3977
4277
|
}
|
|
@@ -3980,25 +4280,26 @@ function sharedProviders(durable, includeStore) {
|
|
|
3980
4280
|
__name(sharedProviders, "sharedProviders");
|
|
3981
4281
|
function exportsFor(includeStore) {
|
|
3982
4282
|
return [
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4283
|
+
import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4284
|
+
import_nestjs_agent_core26.AGENT_TOOL_REGISTRY,
|
|
4285
|
+
import_nestjs_agent_core26.AGENT_REGISTRY,
|
|
4286
|
+
import_nestjs_agent_core26.AGENT_SINK,
|
|
4287
|
+
import_nestjs_agent_core26.AGENT_ROLES_POLICY,
|
|
4288
|
+
import_nestjs_agent_core26.AGENT_ACTOR_RESOLVER,
|
|
4289
|
+
import_nestjs_agent_core26.AGENT_MODEL,
|
|
3990
4290
|
...includeStore ? [
|
|
3991
|
-
|
|
4291
|
+
import_nestjs_agent_core26.AGENT_STORE
|
|
3992
4292
|
] : [],
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
4293
|
+
import_nestjs_agent_core26.AGENT_QUOTA_STORE,
|
|
4294
|
+
import_nestjs_agent_core26.AGENT_MODEL_CATALOG,
|
|
4295
|
+
import_nestjs_agent_core26.AGENT_PROMPT_CONTRIBUTORS,
|
|
4296
|
+
import_nestjs_agent_core26.AGENT_SKILLS,
|
|
4297
|
+
import_nestjs_agent_core26.AGENT_MEMORY,
|
|
4298
|
+
import_nestjs_agent_core26.AGENT_DEPS_FACTORY,
|
|
3998
4299
|
AgentDepsFactory2,
|
|
3999
4300
|
AgentService,
|
|
4000
4301
|
InlineAgentRunner,
|
|
4001
|
-
|
|
4302
|
+
import_nestjs_agent_core26.AGENT_APPROVAL_PORT
|
|
4002
4303
|
];
|
|
4003
4304
|
}
|
|
4004
4305
|
__name(exportsFor, "exportsFor");
|
|
@@ -4010,7 +4311,9 @@ var BASE_CONTROLLERS = [
|
|
|
4010
4311
|
AgentsController,
|
|
4011
4312
|
SkillsController,
|
|
4012
4313
|
MemoriesController,
|
|
4013
|
-
ToolsController
|
|
4314
|
+
ToolsController,
|
|
4315
|
+
MessagesController,
|
|
4316
|
+
ModelsController
|
|
4014
4317
|
];
|
|
4015
4318
|
var GUARDABLE_CONTROLLERS = [
|
|
4016
4319
|
...BASE_CONTROLLERS,
|
|
@@ -4068,7 +4371,7 @@ var AgentModule = class _AgentModule {
|
|
|
4068
4371
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
4069
4372
|
providers: [
|
|
4070
4373
|
{
|
|
4071
|
-
provide:
|
|
4374
|
+
provide: import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4072
4375
|
useValue: options
|
|
4073
4376
|
},
|
|
4074
4377
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -4092,7 +4395,7 @@ var AgentModule = class _AgentModule {
|
|
|
4092
4395
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
4093
4396
|
providers: [
|
|
4094
4397
|
{
|
|
4095
|
-
provide:
|
|
4398
|
+
provide: import_nestjs_agent_core26.AGENT_OPTIONS,
|
|
4096
4399
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
4097
4400
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
4098
4401
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -4113,9 +4416,9 @@ var AgentModule = class _AgentModule {
|
|
|
4113
4416
|
};
|
|
4114
4417
|
}
|
|
4115
4418
|
};
|
|
4116
|
-
AgentModule =
|
|
4117
|
-
(0,
|
|
4118
|
-
(0,
|
|
4419
|
+
AgentModule = _ts_decorate23([
|
|
4420
|
+
(0, import_common23.Global)(),
|
|
4421
|
+
(0, import_common23.Module)({})
|
|
4119
4422
|
], AgentModule);
|
|
4120
4423
|
|
|
4121
4424
|
// src/durable/agent-durable.ts
|