@dudousxd/nestjs-agent 1.25.0 → 1.25.2
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 +6 -0
- package/dist/durable/index.cjs +26 -1
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +26 -1
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +31 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
MemoriesController: () => MemoriesController,
|
|
54
54
|
MessagesController: () => MessagesController,
|
|
55
55
|
ModelsController: () => ModelsController,
|
|
56
|
+
NO_USER_MESSAGE_CODE: () => NO_USER_MESSAGE_CODE,
|
|
56
57
|
QueueController: () => QueueController,
|
|
57
58
|
RunNotActiveException: () => RunNotActiveException,
|
|
58
59
|
SKILL_METADATA: () => SKILL_METADATA,
|
|
@@ -1452,6 +1453,30 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
1452
1453
|
};
|
|
1453
1454
|
}
|
|
1454
1455
|
__name(_ts_param4, "_ts_param");
|
|
1456
|
+
var NO_USER_MESSAGE_CODE = "no_user_message";
|
|
1457
|
+
function sendableParams(params) {
|
|
1458
|
+
const message = params.message;
|
|
1459
|
+
if (message !== void 0 && message !== null && typeof message !== "string") {
|
|
1460
|
+
throw new import_common6.BadRequestException({
|
|
1461
|
+
statusCode: 400,
|
|
1462
|
+
code: "invalid_message",
|
|
1463
|
+
message: "message must be a string"
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
const text = typeof message === "string" ? message : "";
|
|
1467
|
+
if (text.trim().length === 0 && (params.attachments?.length ?? 0) === 0 && params.regenerate !== true) {
|
|
1468
|
+
throw new import_common6.BadRequestException({
|
|
1469
|
+
statusCode: 400,
|
|
1470
|
+
code: NO_USER_MESSAGE_CODE,
|
|
1471
|
+
message: "nothing to answer: send a non-empty message, an attachment, or regenerate"
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
return text === message ? params : {
|
|
1475
|
+
...params,
|
|
1476
|
+
message: text
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
__name(sendableParams, "sendableParams");
|
|
1455
1480
|
var AgentService = class {
|
|
1456
1481
|
static {
|
|
1457
1482
|
__name(this, "AgentService");
|
|
@@ -1720,7 +1745,8 @@ var AgentService = class {
|
|
|
1720
1745
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
1721
1746
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
1722
1747
|
*/
|
|
1723
|
-
async send(
|
|
1748
|
+
async send(claimed, sendOptions = {}) {
|
|
1749
|
+
const params = sendableParams(claimed);
|
|
1724
1750
|
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
1725
1751
|
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
1726
1752
|
if ("proposalDecision" in decision) return decision;
|
|
@@ -6575,7 +6601,7 @@ var AgUiRunHandler = class {
|
|
|
6575
6601
|
}
|
|
6576
6602
|
const turn = (0, import_ag_ui.readUserTurn)(input.messages);
|
|
6577
6603
|
if (turn === null) {
|
|
6578
|
-
throw invalid(
|
|
6604
|
+
throw invalid(NO_USER_MESSAGE_CODE, "messages carries no user message to answer");
|
|
6579
6605
|
}
|
|
6580
6606
|
warnings.push(...turn.dropped);
|
|
6581
6607
|
const owner = await this.agent.threadOwner(input.threadId);
|
|
@@ -6601,8 +6627,8 @@ var AgUiRunHandler = class {
|
|
|
6601
6627
|
}
|
|
6602
6628
|
}
|
|
6603
6629
|
const refs = await this.stage(actor, turn.media, warnings, turn.staged);
|
|
6604
|
-
if (turn.text.trim().length === 0 && refs.length === 0) {
|
|
6605
|
-
throw invalid(
|
|
6630
|
+
if (turn.text.trim().length === 0 && refs.length === 0 && forwarded.regenerate !== true) {
|
|
6631
|
+
throw invalid(NO_USER_MESSAGE_CODE, "the user message to answer is empty");
|
|
6606
6632
|
}
|
|
6607
6633
|
const context = (0, import_ag_ui.readContext)(input.context);
|
|
6608
6634
|
const pageContext = forwarded.pageContext !== void 0 || context !== void 0 ? {
|
|
@@ -6992,6 +7018,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
6992
7018
|
MemoriesController,
|
|
6993
7019
|
MessagesController,
|
|
6994
7020
|
ModelsController,
|
|
7021
|
+
NO_USER_MESSAGE_CODE,
|
|
6995
7022
|
QueueController,
|
|
6996
7023
|
RunNotActiveException,
|
|
6997
7024
|
SKILL_METADATA,
|