@purpleschool/gptbot 0.13.13 → 0.13.14

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.
@@ -0,0 +1,5 @@
1
+ export const AGENT_STATISTICS_CONTROLLER_PRIVATE = 'private/agents-statistics' as const;
2
+
3
+ export const AGENT_STATISTICS_ROUTES = {
4
+ GET: (agentId: string) => `${agentId}`,
5
+ } as const;
@@ -7,5 +7,6 @@ export const AGENT_TEMPLATE_ROUTES = {
7
7
  TEMPLATES: 'templates',
8
8
  TEMPLATE: (id: string) => `templates/${id}`,
9
9
  INSTRUCTIONS: (templateId: string) => `${templateId}/instructions`,
10
+ INSTRUCTIONS_BY_TEMPLATE: (templateId: string) => `${templateId}/instructions/by-template`,
10
11
  INSTRUCTION: (templateId: string, id: string) => `${templateId}/instructions/${id}`,
11
12
  } as const;
@@ -7,3 +7,4 @@ export * from './agent-tool';
7
7
  export * from './agent-document';
8
8
  export * from './agent-template';
9
9
  export * from './agent';
10
+ export * from './agent-statistics';
package/api/routes.ts CHANGED
@@ -171,6 +171,10 @@ export const REST_API = {
171
171
  GET_BY_ID: (id: string): string =>
172
172
  `${ROOT}/${CONTROLLERS.AGENT_LEAD_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_LEAD_ROUTES.GET_BY_ID(id)}`,
173
173
  },
174
+ AGENT_STATISTICS_PRIVATE: {
175
+ GET: (agentId: string): string =>
176
+ `${ROOT}/${CONTROLLERS.AGENT_STATISTICS_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_STATISTICS_ROUTES.GET(agentId)}`,
177
+ },
174
178
  AGENT_TOOL_PRIVATE: {
175
179
  CATALOG: `${ROOT}/${CONTROLLERS.AGENT_TOOL_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_TOOL_ROUTES.CATALOG}`,
176
180
  LIST_AGENT_TOOLS: (agentId: string): string =>
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AGENT_STATISTICS_ROUTES = exports.AGENT_STATISTICS_CONTROLLER_PRIVATE = void 0;
4
+ exports.AGENT_STATISTICS_CONTROLLER_PRIVATE = 'private/agents-statistics';
5
+ exports.AGENT_STATISTICS_ROUTES = {
6
+ GET: (agentId) => `${agentId}`,
7
+ };
@@ -9,5 +9,6 @@ exports.AGENT_TEMPLATE_ROUTES = {
9
9
  TEMPLATES: 'templates',
10
10
  TEMPLATE: (id) => `templates/${id}`,
11
11
  INSTRUCTIONS: (templateId) => `${templateId}/instructions`,
12
+ INSTRUCTIONS_BY_TEMPLATE: (templateId) => `${templateId}/instructions/by-template`,
12
13
  INSTRUCTION: (templateId, id) => `${templateId}/instructions/${id}`,
13
14
  };
@@ -23,3 +23,4 @@ __exportStar(require("./agent-tool"), exports);
23
23
  __exportStar(require("./agent-document"), exports);
24
24
  __exportStar(require("./agent-template"), exports);
25
25
  __exportStar(require("./agent"), exports);
26
+ __exportStar(require("./agent-statistics"), exports);
@@ -166,6 +166,9 @@ exports.REST_API = {
166
166
  LIST: `${exports.ROOT}/${CONTROLLERS.AGENT_LEAD_CONTROLLER_PRIVATE}`,
167
167
  GET_BY_ID: (id) => `${exports.ROOT}/${CONTROLLERS.AGENT_LEAD_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_LEAD_ROUTES.GET_BY_ID(id)}`,
168
168
  },
169
+ AGENT_STATISTICS_PRIVATE: {
170
+ GET: (agentId) => `${exports.ROOT}/${CONTROLLERS.AGENT_STATISTICS_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_STATISTICS_ROUTES.GET(agentId)}`,
171
+ },
169
172
  AGENT_TOOL_PRIVATE: {
170
173
  CATALOG: `${exports.ROOT}/${CONTROLLERS.AGENT_TOOL_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_TOOL_ROUTES.CATALOG}`,
171
174
  LIST_AGENT_TOOLS: (agentId) => `${exports.ROOT}/${CONTROLLERS.AGENT_TOOL_CONTROLLER_PRIVATE}/${CONTROLLERS.AGENT_TOOL_ROUTES.LIST_AGENT_TOOLS(agentId)}`,
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAgentTemplateInstructionsByTemplateCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const agent_template_instruction_schema_1 = require("../../../models/agents/agent-template-instruction.schema");
6
+ var GetAgentTemplateInstructionsByTemplateCommand;
7
+ (function (GetAgentTemplateInstructionsByTemplateCommand) {
8
+ GetAgentTemplateInstructionsByTemplateCommand.RequestParamsSchema = zod_1.z.object({
9
+ templateId: zod_1.z.string().uuid(),
10
+ });
11
+ GetAgentTemplateInstructionsByTemplateCommand.ResponseSchema = zod_1.z.object({
12
+ data: zod_1.z.array(agent_template_instruction_schema_1.AgentTemplateInstructionSchema),
13
+ });
14
+ })(GetAgentTemplateInstructionsByTemplateCommand || (exports.GetAgentTemplateInstructionsByTemplateCommand = GetAgentTemplateInstructionsByTemplateCommand = {}));
@@ -24,6 +24,7 @@ __exportStar(require("./find-agent-template-catalog.command"), exports);
24
24
  __exportStar(require("./find-agent-template-categories.command"), exports);
25
25
  __exportStar(require("./find-agent-template-instructions.command"), exports);
26
26
  __exportStar(require("./find-agent-templates.command"), exports);
27
+ __exportStar(require("./get-agent-template-instructions-by-template.command"), exports);
27
28
  __exportStar(require("./update-agent-template-category.command"), exports);
28
29
  __exportStar(require("./update-agent-template-instruction.command"), exports);
29
30
  __exportStar(require("./update-agent-template.command"), exports);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetAgentStatisticsCommand = void 0;
4
+ const zod_1 = require("zod");
5
+ const agent_statistics_schema_1 = require("../../../models/agents/agent-statistics.schema");
6
+ var GetAgentStatisticsCommand;
7
+ (function (GetAgentStatisticsCommand) {
8
+ GetAgentStatisticsCommand.RequestQuerySchema = zod_1.z.object({
9
+ from: zod_1.z.string().datetime().optional(),
10
+ to: zod_1.z.string().datetime().optional(),
11
+ granularity: zod_1.z.enum(['day', 'week', 'month']).optional().default('day'),
12
+ source: zod_1.z.string().optional(),
13
+ });
14
+ GetAgentStatisticsCommand.RequestParamsSchema = zod_1.z.object({
15
+ agentId: zod_1.z.string().uuid(),
16
+ });
17
+ GetAgentStatisticsCommand.ResponseSchema = zod_1.z.object({
18
+ data: agent_statistics_schema_1.AgentStatisticsDataSchema,
19
+ });
20
+ })(GetAgentStatisticsCommand || (exports.GetAgentStatisticsCommand = GetAgentStatisticsCommand = {}));
@@ -23,3 +23,4 @@ __exportStar(require("./get-agent-aggregate.command"), exports);
23
23
  __exportStar(require("./activate-agent.command"), exports);
24
24
  __exportStar(require("./stop-agent.command"), exports);
25
25
  __exportStar(require("./update-agent.command"), exports);
26
+ __exportStar(require("./get-agent-statistics.command"), exports);
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentStatisticsDataSchema = exports.AgentStatisticsBucketSchema = exports.AgentStatisticsTotalsSchema = exports.AgentStatisticsRangeSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.AgentStatisticsRangeSchema = zod_1.z.object({
6
+ from: zod_1.z.string().datetime(),
7
+ to: zod_1.z.string().datetime(),
8
+ granularity: zod_1.z.enum(['day', 'week', 'month']),
9
+ });
10
+ exports.AgentStatisticsTotalsSchema = zod_1.z.object({
11
+ dialogs: zod_1.z.number().int().min(0),
12
+ leads: zod_1.z.number().int().min(0),
13
+ messagesIncoming: zod_1.z.number().int().min(0),
14
+ messagesOutgoing: zod_1.z.number().int().min(0),
15
+ starsSpent: zod_1.z.number().int().min(0),
16
+ conversionToLeadPercent: zod_1.z.number().min(0),
17
+ conversionToDialogPercent: zod_1.z.number().min(0),
18
+ agentActivations: zod_1.z.number().int().min(0),
19
+ });
20
+ exports.AgentStatisticsBucketSchema = zod_1.z.object({
21
+ start: zod_1.z.string().datetime(),
22
+ dialogs: zod_1.z.number().int().min(0),
23
+ leads: zod_1.z.number().int().min(0),
24
+ launches: zod_1.z.number().int().min(0),
25
+ starsSpent: zod_1.z.number().int().min(0),
26
+ });
27
+ exports.AgentStatisticsDataSchema = zod_1.z.object({
28
+ range: exports.AgentStatisticsRangeSchema,
29
+ totals: exports.AgentStatisticsTotalsSchema,
30
+ chart: zod_1.z.object({
31
+ buckets: zod_1.z.array(exports.AgentStatisticsBucketSchema),
32
+ }),
33
+ });
@@ -38,4 +38,5 @@ __exportStar(require("./agent-document-find-result.schema"), exports);
38
38
  __exportStar(require("./agent-document-chunk.schema"), exports);
39
39
  __exportStar(require("./agent.schema"), exports);
40
40
  __exportStar(require("./agent-aggregate.schema"), exports);
41
+ __exportStar(require("./agent-statistics.schema"), exports);
41
42
  __exportStar(require("./channel.schema"), exports);
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { AgentTemplateInstructionSchema } from '../../../models/agents/agent-template-instruction.schema';
3
+
4
+ export namespace GetAgentTemplateInstructionsByTemplateCommand {
5
+ export const RequestParamsSchema = z.object({
6
+ templateId: z.string().uuid(),
7
+ });
8
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
9
+
10
+ export const ResponseSchema = z.object({
11
+ data: z.array(AgentTemplateInstructionSchema),
12
+ });
13
+ export type Response = z.infer<typeof ResponseSchema>;
14
+ }
@@ -8,6 +8,7 @@ export * from './find-agent-template-catalog.command';
8
8
  export * from './find-agent-template-categories.command';
9
9
  export * from './find-agent-template-instructions.command';
10
10
  export * from './find-agent-templates.command';
11
+ export * from './get-agent-template-instructions-by-template.command';
11
12
  export * from './update-agent-template-category.command';
12
13
  export * from './update-agent-template-instruction.command';
13
14
  export * from './update-agent-template.command';
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { AgentStatisticsDataSchema } from '../../../models/agents/agent-statistics.schema';
3
+
4
+ export namespace GetAgentStatisticsCommand {
5
+ export const RequestQuerySchema = z.object({
6
+ from: z.string().datetime().optional(),
7
+ to: z.string().datetime().optional(),
8
+ granularity: z.enum(['day', 'week', 'month']).optional().default('day'),
9
+ source: z.string().optional(),
10
+ });
11
+ export type RequestQuery = z.infer<typeof RequestQuerySchema>;
12
+
13
+ export const RequestParamsSchema = z.object({
14
+ agentId: z.string().uuid(),
15
+ });
16
+ export type RequestParams = z.infer<typeof RequestParamsSchema>;
17
+
18
+ export const ResponseSchema = z.object({
19
+ data: AgentStatisticsDataSchema,
20
+ });
21
+ export type Response = z.infer<typeof ResponseSchema>;
22
+
23
+ // Internal RMQ envelope — not part of the HTTP contract
24
+ export type RmqResponse = {
25
+ isSuccess: true;
26
+ data: z.infer<typeof AgentStatisticsDataSchema>;
27
+ };
28
+ }
@@ -7,3 +7,4 @@ export * from './get-agent-aggregate.command';
7
7
  export * from './activate-agent.command';
8
8
  export * from './stop-agent.command';
9
9
  export * from './update-agent.command';
10
+ export * from './get-agent-statistics.command';
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+
3
+ export const AgentStatisticsRangeSchema = z.object({
4
+ from: z.string().datetime(),
5
+ to: z.string().datetime(),
6
+ granularity: z.enum(['day', 'week', 'month']),
7
+ });
8
+ export type AgentStatisticsRange = z.infer<typeof AgentStatisticsRangeSchema>;
9
+
10
+ export const AgentStatisticsTotalsSchema = z.object({
11
+ dialogs: z.number().int().min(0),
12
+ leads: z.number().int().min(0),
13
+ messagesIncoming: z.number().int().min(0),
14
+ messagesOutgoing: z.number().int().min(0),
15
+ starsSpent: z.number().int().min(0),
16
+ conversionToLeadPercent: z.number().min(0),
17
+ conversionToDialogPercent: z.number().min(0),
18
+ agentActivations: z.number().int().min(0),
19
+ });
20
+ export type AgentStatisticsTotals = z.infer<typeof AgentStatisticsTotalsSchema>;
21
+
22
+ export const AgentStatisticsBucketSchema = z.object({
23
+ start: z.string().datetime(),
24
+ dialogs: z.number().int().min(0),
25
+ leads: z.number().int().min(0),
26
+ launches: z.number().int().min(0),
27
+ starsSpent: z.number().int().min(0),
28
+ });
29
+ export type AgentStatisticsBucket = z.infer<typeof AgentStatisticsBucketSchema>;
30
+
31
+ export const AgentStatisticsDataSchema = z.object({
32
+ range: AgentStatisticsRangeSchema,
33
+ totals: AgentStatisticsTotalsSchema,
34
+ chart: z.object({
35
+ buckets: z.array(AgentStatisticsBucketSchema),
36
+ }),
37
+ });
38
+ export type AgentStatisticsData = z.infer<typeof AgentStatisticsDataSchema>;
@@ -22,4 +22,5 @@ export * from './agent-document-find-result.schema';
22
22
  export * from './agent-document-chunk.schema';
23
23
  export * from './agent.schema';
24
24
  export * from './agent-aggregate.schema';
25
+ export * from './agent-statistics.schema';
25
26
  export * from './channel.schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purpleschool/gptbot",
3
- "version": "0.13.13",
3
+ "version": "0.13.14",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",