@purpleschool/gptbot 0.13.15 → 0.13.17
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/api/controllers/http/agents/agent.ts +6 -0
- package/build/api/controllers/http/agents/agent.js +3 -0
- package/build/commands/agents/agent-dialog/get-cabinet-price-preview.command.js +26 -0
- package/build/commands/agents/agent-dialog/get-dialog-context-length.command.js +30 -0
- package/build/commands/agents/agent-dialog/index.js +3 -0
- package/build/commands/agents/agent-dialog/send-cabinet-message.command.js +4 -4
- package/build/commands/agents/agent-dialog/stop-cabinet-stream.command.js +15 -0
- package/build/commands/agents/agent-lead/find-agent-leads.command.js +2 -4
- package/build/models/agents/index.js +1 -0
- package/build/models/agents/message-attachment.schema.js +21 -0
- package/commands/agents/agent-dialog/get-cabinet-price-preview.command.ts +28 -0
- package/commands/agents/agent-dialog/get-dialog-context-length.command.ts +33 -0
- package/commands/agents/agent-dialog/index.ts +3 -0
- package/commands/agents/agent-dialog/send-cabinet-message.command.ts +18 -10
- package/commands/agents/agent-dialog/stop-cabinet-stream.command.ts +15 -0
- package/commands/agents/agent-lead/find-agent-leads.command.ts +2 -4
- package/models/agents/index.ts +1 -0
- package/models/agents/message-attachment.schema.ts +22 -0
- package/package.json +1 -1
|
@@ -13,6 +13,12 @@ export const AGENT_ROUTES = {
|
|
|
13
13
|
CABINET_START_DIALOG: (agentId: string) => `${agentId}/dialogs/cabinet/start`,
|
|
14
14
|
CABINET_SEND_MESSAGE: (agentId: string, dialogId: string) =>
|
|
15
15
|
`${agentId}/dialogs/${dialogId}/cabinet/messages`,
|
|
16
|
+
CABINET_SEND_MESSAGE_STREAM: (agentId: string, dialogId: string) =>
|
|
17
|
+
`${agentId}/dialogs/${dialogId}/cabinet/messages/stream`,
|
|
18
|
+
STOP_CABINET_STREAM: (agentId: string, dialogId: string, messageId: string) =>
|
|
19
|
+
`${agentId}/dialogs/${dialogId}/cabinet/messages/${messageId}/stop`,
|
|
20
|
+
CABINET_PRICE_PREVIEW: (agentId: string, dialogId: string) =>
|
|
21
|
+
`${agentId}/dialogs/${dialogId}/cabinet/price-preview`,
|
|
16
22
|
} as const;
|
|
17
23
|
|
|
18
24
|
export const AGENT_PUBLIC_ROUTES = {
|
|
@@ -14,6 +14,9 @@ exports.AGENT_ROUTES = {
|
|
|
14
14
|
DELETE: (id) => `${id}`,
|
|
15
15
|
CABINET_START_DIALOG: (agentId) => `${agentId}/dialogs/cabinet/start`,
|
|
16
16
|
CABINET_SEND_MESSAGE: (agentId, dialogId) => `${agentId}/dialogs/${dialogId}/cabinet/messages`,
|
|
17
|
+
CABINET_SEND_MESSAGE_STREAM: (agentId, dialogId) => `${agentId}/dialogs/${dialogId}/cabinet/messages/stream`,
|
|
18
|
+
STOP_CABINET_STREAM: (agentId, dialogId, messageId) => `${agentId}/dialogs/${dialogId}/cabinet/messages/${messageId}/stop`,
|
|
19
|
+
CABINET_PRICE_PREVIEW: (agentId, dialogId) => `${agentId}/dialogs/${dialogId}/cabinet/price-preview`,
|
|
17
20
|
};
|
|
18
21
|
exports.AGENT_PUBLIC_ROUTES = {
|
|
19
22
|
PUBLIC_INFO: (id) => `${id}/public-info`,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetCabinetPricePreviewCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var GetCabinetPricePreviewCommand;
|
|
6
|
+
(function (GetCabinetPricePreviewCommand) {
|
|
7
|
+
GetCabinetPricePreviewCommand.RequestParamsSchema = zod_1.z.object({
|
|
8
|
+
agentId: zod_1.z.string().uuid(),
|
|
9
|
+
dialogId: zod_1.z.string().uuid(),
|
|
10
|
+
});
|
|
11
|
+
GetCabinetPricePreviewCommand.RequestBodySchema = zod_1.z.object({
|
|
12
|
+
inputLength: zod_1.z.number().int().min(0),
|
|
13
|
+
fileIds: zod_1.z.array(zod_1.z.string().uuid()).optional(),
|
|
14
|
+
useWebSearch: zod_1.z.boolean().optional(),
|
|
15
|
+
});
|
|
16
|
+
GetCabinetPricePreviewCommand.ResponseSchema = zod_1.z.object({
|
|
17
|
+
data: zod_1.z.object({
|
|
18
|
+
price: zod_1.z.number().int().min(0),
|
|
19
|
+
breakdown: zod_1.z.object({
|
|
20
|
+
textCost: zod_1.z.number().int().min(0),
|
|
21
|
+
attachmentsCost: zod_1.z.number().int().min(0),
|
|
22
|
+
webSearchCost: zod_1.z.number().int().min(0),
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
})(GetCabinetPricePreviewCommand || (exports.GetCabinetPricePreviewCommand = GetCabinetPricePreviewCommand = {}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetDialogContextLengthCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const message_attachment_schema_1 = require("../../../models/agents/message-attachment.schema");
|
|
6
|
+
var GetDialogContextLengthCommand;
|
|
7
|
+
(function (GetDialogContextLengthCommand) {
|
|
8
|
+
GetDialogContextLengthCommand.RequestSchema = zod_1.z.object({
|
|
9
|
+
teamAccountId: zod_1.z.string().uuid(),
|
|
10
|
+
dialogId: zod_1.z.string().uuid(),
|
|
11
|
+
inputLength: zod_1.z.number().int().min(0),
|
|
12
|
+
attachments: zod_1.z
|
|
13
|
+
.array(zod_1.z.object({
|
|
14
|
+
type: message_attachment_schema_1.MessageAttachmentTypeEnum,
|
|
15
|
+
contentLength: zod_1.z.number().int().optional(),
|
|
16
|
+
}))
|
|
17
|
+
.default([]),
|
|
18
|
+
});
|
|
19
|
+
GetDialogContextLengthCommand.ResponseSchema = zod_1.z.object({
|
|
20
|
+
isSuccess: zod_1.z.literal(true),
|
|
21
|
+
data: zod_1.z.object({
|
|
22
|
+
historyChars: zod_1.z.number().int().min(0),
|
|
23
|
+
totalInputChars: zod_1.z.number().int().min(0),
|
|
24
|
+
modelPricing: zod_1.z.object({
|
|
25
|
+
inputPrice: zod_1.z.number(),
|
|
26
|
+
outputPrice: zod_1.z.number(),
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
})(GetDialogContextLengthCommand || (exports.GetDialogContextLengthCommand = GetDialogContextLengthCommand = {}));
|
|
@@ -21,3 +21,6 @@ __exportStar(require("./clear-agent-dialog-history.command"), exports);
|
|
|
21
21
|
__exportStar(require("./send-agent-dialog-admin-reply.command"), exports);
|
|
22
22
|
__exportStar(require("./start-cabinet-dialog.command"), exports);
|
|
23
23
|
__exportStar(require("./send-cabinet-message.command"), exports);
|
|
24
|
+
__exportStar(require("./get-dialog-context-length.command"), exports);
|
|
25
|
+
__exportStar(require("./get-cabinet-price-preview.command"), exports);
|
|
26
|
+
__exportStar(require("./stop-cabinet-stream.command"), exports);
|
|
@@ -11,11 +11,11 @@ var SendCabinetMessageCommand;
|
|
|
11
11
|
SendCabinetMessageCommand.RequestBodySchema = zod_1.z
|
|
12
12
|
.object({
|
|
13
13
|
text: zod_1.z.string().optional(),
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
fileIds: zod_1.z.array(zod_1.z.string().uuid()).optional(),
|
|
15
|
+
useWebSearch: zod_1.z.boolean().optional(),
|
|
16
16
|
})
|
|
17
|
-
.refine((data) => { var _a, _b
|
|
18
|
-
message: 'Message must contain text
|
|
17
|
+
.refine((data) => { var _a, _b; return data.text || ((_b = (_a = data.fileIds) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0; }, {
|
|
18
|
+
message: 'Message must contain text or file attachments',
|
|
19
19
|
path: ['text'],
|
|
20
20
|
});
|
|
21
21
|
SendCabinetMessageCommand.ResponseSchema = zod_1.z.object({
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StopCabinetStreamCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
var StopCabinetStreamCommand;
|
|
6
|
+
(function (StopCabinetStreamCommand) {
|
|
7
|
+
StopCabinetStreamCommand.RequestParamsSchema = zod_1.z.object({
|
|
8
|
+
agentId: zod_1.z.string().uuid(),
|
|
9
|
+
dialogId: zod_1.z.string().uuid(),
|
|
10
|
+
messageId: zod_1.z.string().uuid(),
|
|
11
|
+
});
|
|
12
|
+
StopCabinetStreamCommand.ResponseSchema = zod_1.z.object({
|
|
13
|
+
stopped: zod_1.z.boolean(),
|
|
14
|
+
});
|
|
15
|
+
})(StopCabinetStreamCommand || (exports.StopCabinetStreamCommand = StopCabinetStreamCommand = {}));
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FindAgentLeadsCommand = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const agent_lead_schema_1 = require("../../../models/agents/agent-lead.schema");
|
|
6
6
|
var FindAgentLeadsCommand;
|
|
7
7
|
(function (FindAgentLeadsCommand) {
|
|
8
8
|
FindAgentLeadsCommand.RequestQuerySchema = zod_1.z.object({
|
|
9
9
|
dialogId: zod_1.z.string().uuid().optional(),
|
|
10
|
-
limit: zod_1.z.coerce.number().optional(),
|
|
11
|
-
offset: zod_1.z.coerce.number().optional(),
|
|
12
10
|
});
|
|
13
11
|
FindAgentLeadsCommand.ResponseSchema = zod_1.z.object({
|
|
14
|
-
data:
|
|
12
|
+
data: zod_1.z.array(agent_lead_schema_1.AgentLeadSchema),
|
|
15
13
|
});
|
|
16
14
|
})(FindAgentLeadsCommand || (exports.FindAgentLeadsCommand = FindAgentLeadsCommand = {}));
|
|
@@ -40,3 +40,4 @@ __exportStar(require("./agent.schema"), exports);
|
|
|
40
40
|
__exportStar(require("./agent-aggregate.schema"), exports);
|
|
41
41
|
__exportStar(require("./agent-statistics.schema"), exports);
|
|
42
42
|
__exportStar(require("./channel.schema"), exports);
|
|
43
|
+
__exportStar(require("./message-attachment.schema"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageAttachmentInputSchema = exports.MessageAttachmentTypeEnum = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.MessageAttachmentTypeEnum = zod_1.z.enum([
|
|
6
|
+
'image',
|
|
7
|
+
'document',
|
|
8
|
+
'text',
|
|
9
|
+
'audio',
|
|
10
|
+
'video',
|
|
11
|
+
'other',
|
|
12
|
+
]);
|
|
13
|
+
exports.MessageAttachmentInputSchema = zod_1.z.object({
|
|
14
|
+
fileId: zod_1.z.string().uuid().optional(),
|
|
15
|
+
url: zod_1.z.string(),
|
|
16
|
+
mimeType: zod_1.z.string(),
|
|
17
|
+
type: exports.MessageAttachmentTypeEnum,
|
|
18
|
+
originalName: zod_1.z.string().optional(),
|
|
19
|
+
content: zod_1.z.string().optional(),
|
|
20
|
+
contentLength: zod_1.z.number().int().optional(),
|
|
21
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace GetCabinetPricePreviewCommand {
|
|
4
|
+
export const RequestParamsSchema = z.object({
|
|
5
|
+
agentId: z.string().uuid(),
|
|
6
|
+
dialogId: z.string().uuid(),
|
|
7
|
+
});
|
|
8
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
9
|
+
|
|
10
|
+
export const RequestBodySchema = z.object({
|
|
11
|
+
inputLength: z.number().int().min(0),
|
|
12
|
+
fileIds: z.array(z.string().uuid()).optional(),
|
|
13
|
+
useWebSearch: z.boolean().optional(),
|
|
14
|
+
});
|
|
15
|
+
export type RequestBody = z.infer<typeof RequestBodySchema>;
|
|
16
|
+
|
|
17
|
+
export const ResponseSchema = z.object({
|
|
18
|
+
data: z.object({
|
|
19
|
+
price: z.number().int().min(0),
|
|
20
|
+
breakdown: z.object({
|
|
21
|
+
textCost: z.number().int().min(0),
|
|
22
|
+
attachmentsCost: z.number().int().min(0),
|
|
23
|
+
webSearchCost: z.number().int().min(0),
|
|
24
|
+
}),
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MessageAttachmentTypeEnum } from '../../../models/agents/message-attachment.schema';
|
|
3
|
+
|
|
4
|
+
export namespace GetDialogContextLengthCommand {
|
|
5
|
+
export const RequestSchema = z.object({
|
|
6
|
+
teamAccountId: z.string().uuid(),
|
|
7
|
+
dialogId: z.string().uuid(),
|
|
8
|
+
inputLength: z.number().int().min(0),
|
|
9
|
+
attachments: z
|
|
10
|
+
.array(
|
|
11
|
+
z.object({
|
|
12
|
+
type: MessageAttachmentTypeEnum,
|
|
13
|
+
contentLength: z.number().int().optional(),
|
|
14
|
+
}),
|
|
15
|
+
)
|
|
16
|
+
.default([]),
|
|
17
|
+
});
|
|
18
|
+
export type Request = z.infer<typeof RequestSchema>;
|
|
19
|
+
|
|
20
|
+
export const ResponseSchema = z.object({
|
|
21
|
+
isSuccess: z.literal(true),
|
|
22
|
+
data: z.object({
|
|
23
|
+
historyChars: z.number().int().min(0),
|
|
24
|
+
totalInputChars: z.number().int().min(0),
|
|
25
|
+
modelPricing: z.object({
|
|
26
|
+
inputPrice: z.number(),
|
|
27
|
+
outputPrice: z.number(),
|
|
28
|
+
}),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
32
|
+
export type ResponseData = z.infer<typeof ResponseSchema>['data'];
|
|
33
|
+
}
|
|
@@ -5,3 +5,6 @@ export * from './clear-agent-dialog-history.command';
|
|
|
5
5
|
export * from './send-agent-dialog-admin-reply.command';
|
|
6
6
|
export * from './start-cabinet-dialog.command';
|
|
7
7
|
export * from './send-cabinet-message.command';
|
|
8
|
+
export * from './get-dialog-context-length.command';
|
|
9
|
+
export * from './get-cabinet-price-preview.command';
|
|
10
|
+
export * from './stop-cabinet-stream.command';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { MessageAttachmentInputSchema } from '../../../models/agents/message-attachment.schema';
|
|
2
3
|
|
|
3
4
|
export namespace SendCabinetMessageCommand {
|
|
4
5
|
export const RequestParamsSchema = z.object({
|
|
@@ -10,17 +11,13 @@ export namespace SendCabinetMessageCommand {
|
|
|
10
11
|
export const RequestBodySchema = z
|
|
11
12
|
.object({
|
|
12
13
|
text: z.string().optional(),
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
fileIds: z.array(z.string().uuid()).optional(),
|
|
15
|
+
useWebSearch: z.boolean().optional(),
|
|
15
16
|
})
|
|
16
|
-
.refine(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
message: 'Message must contain text, images, or attachments',
|
|
21
|
-
path: ['text'],
|
|
22
|
-
},
|
|
23
|
-
);
|
|
17
|
+
.refine((data) => data.text || (data.fileIds?.length ?? 0) > 0, {
|
|
18
|
+
message: 'Message must contain text or file attachments',
|
|
19
|
+
path: ['text'],
|
|
20
|
+
});
|
|
24
21
|
export type RequestBody = z.infer<typeof RequestBodySchema>;
|
|
25
22
|
|
|
26
23
|
export const ResponseSchema = z.object({
|
|
@@ -31,4 +28,15 @@ export namespace SendCabinetMessageCommand {
|
|
|
31
28
|
}),
|
|
32
29
|
});
|
|
33
30
|
export type Response = z.infer<typeof ResponseSchema>;
|
|
31
|
+
|
|
32
|
+
// RMQ payload sent to rugpt-agents (new format with resolved attachments)
|
|
33
|
+
export type RmqRequest = {
|
|
34
|
+
teamAccountId: string;
|
|
35
|
+
userId: string;
|
|
36
|
+
teamMemberRole?: string;
|
|
37
|
+
dialogId: string;
|
|
38
|
+
text?: string;
|
|
39
|
+
attachments: z.infer<typeof MessageAttachmentInputSchema>[];
|
|
40
|
+
useWebSearch?: boolean;
|
|
41
|
+
};
|
|
34
42
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export namespace StopCabinetStreamCommand {
|
|
4
|
+
export const RequestParamsSchema = z.object({
|
|
5
|
+
agentId: z.string().uuid(),
|
|
6
|
+
dialogId: z.string().uuid(),
|
|
7
|
+
messageId: z.string().uuid(),
|
|
8
|
+
});
|
|
9
|
+
export type RequestParams = z.infer<typeof RequestParamsSchema>;
|
|
10
|
+
|
|
11
|
+
export const ResponseSchema = z.object({
|
|
12
|
+
stopped: z.boolean(),
|
|
13
|
+
});
|
|
14
|
+
export type Response = z.infer<typeof ResponseSchema>;
|
|
15
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { AgentLeadSchema } from '../../../models/agents/agent-lead.schema';
|
|
3
3
|
|
|
4
4
|
export namespace FindAgentLeadsCommand {
|
|
5
5
|
export const RequestQuerySchema = z.object({
|
|
6
6
|
dialogId: z.string().uuid().optional(),
|
|
7
|
-
limit: z.coerce.number().optional(),
|
|
8
|
-
offset: z.coerce.number().optional(),
|
|
9
7
|
});
|
|
10
8
|
export type RequestQuery = z.infer<typeof RequestQuerySchema>;
|
|
11
9
|
|
|
12
10
|
export const ResponseSchema = z.object({
|
|
13
|
-
data:
|
|
11
|
+
data: z.array(AgentLeadSchema),
|
|
14
12
|
});
|
|
15
13
|
export type Response = z.infer<typeof ResponseSchema>;
|
|
16
14
|
}
|
package/models/agents/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const MessageAttachmentTypeEnum = z.enum([
|
|
4
|
+
'image',
|
|
5
|
+
'document',
|
|
6
|
+
'text',
|
|
7
|
+
'audio',
|
|
8
|
+
'video',
|
|
9
|
+
'other',
|
|
10
|
+
]);
|
|
11
|
+
export type MessageAttachmentType = z.infer<typeof MessageAttachmentTypeEnum>;
|
|
12
|
+
|
|
13
|
+
export const MessageAttachmentInputSchema = z.object({
|
|
14
|
+
fileId: z.string().uuid().optional(),
|
|
15
|
+
url: z.string(),
|
|
16
|
+
mimeType: z.string(),
|
|
17
|
+
type: MessageAttachmentTypeEnum,
|
|
18
|
+
originalName: z.string().optional(),
|
|
19
|
+
content: z.string().optional(),
|
|
20
|
+
contentLength: z.number().int().optional(),
|
|
21
|
+
});
|
|
22
|
+
export type MessageAttachmentInput = z.infer<typeof MessageAttachmentInputSchema>;
|