@dudousxd/nestjs-agent 1.25.0 → 1.25.1
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.d.cts
CHANGED
|
@@ -112,6 +112,8 @@ type ChatSendResult = {
|
|
|
112
112
|
text: string;
|
|
113
113
|
queued?: undefined;
|
|
114
114
|
};
|
|
115
|
+
/** The code of the `400` a send with nothing to answer gets (also AG-UI's, for the same case). */
|
|
116
|
+
declare const NO_USER_MESSAGE_CODE = "no_user_message";
|
|
115
117
|
interface ChatParams {
|
|
116
118
|
uiCapabilities?: UiCapabilities;
|
|
117
119
|
actor: Actor;
|
|
@@ -291,7 +293,7 @@ declare class AgentService {
|
|
|
291
293
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
292
294
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
293
295
|
*/
|
|
294
|
-
send(
|
|
296
|
+
send(claimed: ChatParams, sendOptions?: {
|
|
295
297
|
textDecisions?: boolean;
|
|
296
298
|
}): Promise<ChatSendResult>;
|
|
297
299
|
/**
|
|
@@ -1536,4 +1538,4 @@ declare class ActionProposalWorkerService implements OnModuleInit, OnModuleDestr
|
|
|
1536
1538
|
onModuleDestroy(): Promise<void>;
|
|
1537
1539
|
}
|
|
1538
1540
|
|
|
1539
|
-
export { AGENT_CHAT_QUEUE, AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, ActionProposalController, ActionProposalService, type ActionProposalSettledListener, ActionProposalWorkerService, type AgUiAdapterOptions, AgUiRunHandler, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentProtocolAdapter, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, type AnonymousActorOptions, AnonymousActorResolver, type AttachmentLimits, AttachmentsController, type ChatParams, ChatQueueService, type ChatSendMode, type ChatSendResult, ConfigController, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, MAX_ATTACHMENTS_PER_MESSAGE, MemoriesController, MessagesController, ModelsController, QueueController, type QueuedSend, type RequestUserMapper, type ResolvedAiToolOptions, RunNotActiveException, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, type ThreadPersonaReader, ToolsController, agUiAdapter, attachmentLimits, declaredSkillProvider, defaultRequestUserMapper, readAgentMetadata, readAiToolMetadata, readSkillMetadata, requestUserActorResolver, resolveSkillsConfig, skillScope, threadPersona, toolNameFromClass };
|
|
1541
|
+
export { AGENT_CHAT_QUEUE, AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, ActionProposalController, ActionProposalService, type ActionProposalSettledListener, ActionProposalWorkerService, type AgUiAdapterOptions, AgUiRunHandler, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentProtocolAdapter, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, type AnonymousActorOptions, AnonymousActorResolver, type AttachmentLimits, AttachmentsController, type ChatParams, ChatQueueService, type ChatSendMode, type ChatSendResult, ConfigController, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, MAX_ATTACHMENTS_PER_MESSAGE, MemoriesController, MessagesController, ModelsController, NO_USER_MESSAGE_CODE, QueueController, type QueuedSend, type RequestUserMapper, type ResolvedAiToolOptions, RunNotActiveException, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, type ThreadPersonaReader, ToolsController, agUiAdapter, attachmentLimits, declaredSkillProvider, defaultRequestUserMapper, readAgentMetadata, readAiToolMetadata, readSkillMetadata, requestUserActorResolver, resolveSkillsConfig, skillScope, threadPersona, toolNameFromClass };
|
package/dist/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ type ChatSendResult = {
|
|
|
112
112
|
text: string;
|
|
113
113
|
queued?: undefined;
|
|
114
114
|
};
|
|
115
|
+
/** The code of the `400` a send with nothing to answer gets (also AG-UI's, for the same case). */
|
|
116
|
+
declare const NO_USER_MESSAGE_CODE = "no_user_message";
|
|
115
117
|
interface ChatParams {
|
|
116
118
|
uiCapabilities?: UiCapabilities;
|
|
117
119
|
actor: Actor;
|
|
@@ -291,7 +293,7 @@ declare class AgentService {
|
|
|
291
293
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
292
294
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
293
295
|
*/
|
|
294
|
-
send(
|
|
296
|
+
send(claimed: ChatParams, sendOptions?: {
|
|
295
297
|
textDecisions?: boolean;
|
|
296
298
|
}): Promise<ChatSendResult>;
|
|
297
299
|
/**
|
|
@@ -1536,4 +1538,4 @@ declare class ActionProposalWorkerService implements OnModuleInit, OnModuleDestr
|
|
|
1536
1538
|
onModuleDestroy(): Promise<void>;
|
|
1537
1539
|
}
|
|
1538
1540
|
|
|
1539
|
-
export { AGENT_CHAT_QUEUE, AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, ActionProposalController, ActionProposalService, type ActionProposalSettledListener, ActionProposalWorkerService, type AgUiAdapterOptions, AgUiRunHandler, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentProtocolAdapter, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, type AnonymousActorOptions, AnonymousActorResolver, type AttachmentLimits, AttachmentsController, type ChatParams, ChatQueueService, type ChatSendMode, type ChatSendResult, ConfigController, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, MAX_ATTACHMENTS_PER_MESSAGE, MemoriesController, MessagesController, ModelsController, QueueController, type QueuedSend, type RequestUserMapper, type ResolvedAiToolOptions, RunNotActiveException, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, type ThreadPersonaReader, ToolsController, agUiAdapter, attachmentLimits, declaredSkillProvider, defaultRequestUserMapper, readAgentMetadata, readAiToolMetadata, readSkillMetadata, requestUserActorResolver, resolveSkillsConfig, skillScope, threadPersona, toolNameFromClass };
|
|
1541
|
+
export { AGENT_CHAT_QUEUE, AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, ActionProposalController, ActionProposalService, type ActionProposalSettledListener, ActionProposalWorkerService, type AgUiAdapterOptions, AgUiRunHandler, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentProtocolAdapter, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, type AnonymousActorOptions, AnonymousActorResolver, type AttachmentLimits, AttachmentsController, type ChatParams, ChatQueueService, type ChatSendMode, type ChatSendResult, ConfigController, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, MAX_ATTACHMENTS_PER_MESSAGE, MemoriesController, MessagesController, ModelsController, NO_USER_MESSAGE_CODE, QueueController, type QueuedSend, type RequestUserMapper, type ResolvedAiToolOptions, RunNotActiveException, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, type ThreadPersonaReader, ToolsController, agUiAdapter, attachmentLimits, declaredSkillProvider, defaultRequestUserMapper, readAgentMetadata, readAiToolMetadata, readSkillMetadata, requestUserActorResolver, resolveSkillsConfig, skillScope, threadPersona, toolNameFromClass };
|
package/dist/index.js
CHANGED
|
@@ -1369,6 +1369,30 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
1369
1369
|
};
|
|
1370
1370
|
}
|
|
1371
1371
|
__name(_ts_param4, "_ts_param");
|
|
1372
|
+
var NO_USER_MESSAGE_CODE = "no_user_message";
|
|
1373
|
+
function sendableParams(params) {
|
|
1374
|
+
const message = params.message;
|
|
1375
|
+
if (message !== void 0 && message !== null && typeof message !== "string") {
|
|
1376
|
+
throw new BadRequestException2({
|
|
1377
|
+
statusCode: 400,
|
|
1378
|
+
code: "invalid_message",
|
|
1379
|
+
message: "message must be a string"
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
const text = typeof message === "string" ? message : "";
|
|
1383
|
+
if (text.trim().length === 0 && (params.attachments?.length ?? 0) === 0 && params.regenerate !== true) {
|
|
1384
|
+
throw new BadRequestException2({
|
|
1385
|
+
statusCode: 400,
|
|
1386
|
+
code: NO_USER_MESSAGE_CODE,
|
|
1387
|
+
message: "nothing to answer: send a non-empty message, an attachment, or regenerate"
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
return text === message ? params : {
|
|
1391
|
+
...params,
|
|
1392
|
+
message: text
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
__name(sendableParams, "sendableParams");
|
|
1372
1396
|
var AgentService = class {
|
|
1373
1397
|
static {
|
|
1374
1398
|
__name(this, "AgentService");
|
|
@@ -1637,7 +1661,8 @@ var AgentService = class {
|
|
|
1637
1661
|
* Send a message: start a turn, or — when its thread already has one running — queue the message
|
|
1638
1662
|
* to run after it (see {@link ChatSendMode}). What `POST <base>/chat` calls.
|
|
1639
1663
|
*/
|
|
1640
|
-
async send(
|
|
1664
|
+
async send(claimed, sendOptions = {}) {
|
|
1665
|
+
const params = sendableParams(claimed);
|
|
1641
1666
|
if (sendOptions.textDecisions !== false && this.options?.actionApprovalMode === "independent" && params.threadId !== void 0 && params.regenerate !== true && this.proposals) {
|
|
1642
1667
|
const decision = await this.proposals.handleTextDecision(params.threadId, params.actor, params.message);
|
|
1643
1668
|
if ("proposalDecision" in decision) return decision;
|
|
@@ -6492,7 +6517,7 @@ var AgUiRunHandler = class {
|
|
|
6492
6517
|
}
|
|
6493
6518
|
const turn = readUserTurn(input.messages);
|
|
6494
6519
|
if (turn === null) {
|
|
6495
|
-
throw invalid(
|
|
6520
|
+
throw invalid(NO_USER_MESSAGE_CODE, "messages carries no user message to answer");
|
|
6496
6521
|
}
|
|
6497
6522
|
warnings.push(...turn.dropped);
|
|
6498
6523
|
const owner = await this.agent.threadOwner(input.threadId);
|
|
@@ -6518,8 +6543,8 @@ var AgUiRunHandler = class {
|
|
|
6518
6543
|
}
|
|
6519
6544
|
}
|
|
6520
6545
|
const refs = await this.stage(actor, turn.media, warnings, turn.staged);
|
|
6521
|
-
if (turn.text.trim().length === 0 && refs.length === 0) {
|
|
6522
|
-
throw invalid(
|
|
6546
|
+
if (turn.text.trim().length === 0 && refs.length === 0 && forwarded.regenerate !== true) {
|
|
6547
|
+
throw invalid(NO_USER_MESSAGE_CODE, "the user message to answer is empty");
|
|
6523
6548
|
}
|
|
6524
6549
|
const context = readContext(input.context);
|
|
6525
6550
|
const pageContext = forwarded.pageContext !== void 0 || context !== void 0 ? {
|
|
@@ -6908,6 +6933,7 @@ export {
|
|
|
6908
6933
|
MemoriesController,
|
|
6909
6934
|
MessagesController,
|
|
6910
6935
|
ModelsController,
|
|
6936
|
+
NO_USER_MESSAGE_CODE,
|
|
6911
6937
|
QueueController,
|
|
6912
6938
|
RunNotActiveException,
|
|
6913
6939
|
SKILL_METADATA,
|