tychat-contracts 1.0.38 → 1.0.40

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.
Files changed (33) hide show
  1. package/dist/ai/agent-response.dto.d.ts +1 -0
  2. package/dist/ai/agent-response.dto.d.ts.map +1 -1
  3. package/dist/ai/agent-response.dto.js +9 -0
  4. package/dist/ai/ai-action.dto.d.ts +27 -0
  5. package/dist/ai/ai-action.dto.d.ts.map +1 -0
  6. package/dist/ai/ai-action.dto.js +212 -0
  7. package/dist/ai/ai-integration-request.dto.d.ts +4 -2
  8. package/dist/ai/ai-integration-request.dto.d.ts.map +1 -1
  9. package/dist/ai/ai-integration-request.dto.js +25 -4
  10. package/dist/ai/ai-integration-response.dto.d.ts +3 -1
  11. package/dist/ai/ai-integration-response.dto.d.ts.map +1 -1
  12. package/dist/ai/ai-integration-response.dto.js +15 -1
  13. package/dist/ai/create-agent.dto.d.ts +1 -0
  14. package/dist/ai/create-agent.dto.d.ts.map +1 -1
  15. package/dist/ai/create-agent.dto.js +10 -0
  16. package/dist/ai/index.d.ts +2 -0
  17. package/dist/ai/index.d.ts.map +1 -1
  18. package/dist/ai/index.js +2 -0
  19. package/dist/ai/list-models.dto.d.ts +10 -0
  20. package/dist/ai/list-models.dto.d.ts.map +1 -0
  21. package/dist/ai/list-models.dto.js +62 -0
  22. package/dist/ai/update-agent.dto.d.ts +1 -0
  23. package/dist/ai/update-agent.dto.d.ts.map +1 -1
  24. package/dist/ai/update-agent.dto.js +11 -0
  25. package/package.json +2 -1
  26. package/src/ai/agent-response.dto.ts +7 -0
  27. package/src/ai/ai-action.dto.ts +176 -0
  28. package/src/ai/ai-integration-request.dto.ts +20 -3
  29. package/src/ai/ai-integration-response.dto.ts +15 -3
  30. package/src/ai/create-agent.dto.ts +19 -1
  31. package/src/ai/index.ts +2 -0
  32. package/src/ai/list-models.dto.ts +41 -0
  33. package/src/ai/update-agent.dto.ts +10 -0
@@ -2,6 +2,7 @@ import { AiIntegrationDto } from './integration-provider.dto';
2
2
  export declare class AgentResponseDto {
3
3
  id: string;
4
4
  tenant: string;
5
+ unitId: number;
5
6
  integration: AiIntegrationDto;
6
7
  model: string;
7
8
  systemPrompt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/agent-response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,gBAAgB;IAM3B,EAAE,EAAE,MAAM,CAAC;IAQX,MAAM,EAAE,MAAM,CAAC;IAQf,WAAW,EAAE,gBAAgB,CAAC;IAO9B,KAAK,EAAE,MAAM,CAAC;IAOd,YAAY,EAAE,MAAM,CAAC;IAOrB,WAAW,EAAE,MAAM,CAAC;IAOpB,MAAM,EAAE,OAAO,CAAC;IAQhB,YAAY,CAAC,EAAE,MAAM,CAAC;IAQtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAOtB,SAAS,EAAE,MAAM,CAAC;IAOlB,SAAS,EAAE,MAAM,CAAC;CACnB"}
1
+ {"version":3,"file":"agent-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/agent-response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,gBAAgB;IAM3B,EAAE,EAAE,MAAM,CAAC;IAQX,MAAM,EAAE,MAAM,CAAC;IAOf,MAAM,EAAE,MAAM,CAAC;IAQf,WAAW,EAAE,gBAAgB,CAAC;IAO9B,KAAK,EAAE,MAAM,CAAC;IAOd,YAAY,EAAE,MAAM,CAAC;IAOrB,WAAW,EAAE,MAAM,CAAC;IAOpB,MAAM,EAAE,OAAO,CAAC;IAQhB,YAAY,CAAC,EAAE,MAAM,CAAC;IAQtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAOtB,SAAS,EAAE,MAAM,CAAC;IAOlB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -16,6 +16,7 @@ const integration_provider_dto_1 = require("./integration-provider.dto");
16
16
  class AgentResponseDto {
17
17
  id;
18
18
  tenant;
19
+ unitId;
19
20
  integration;
20
21
  model;
21
22
  systemPrompt;
@@ -44,6 +45,14 @@ __decorate([
44
45
  (0, class_validator_1.IsNotEmpty)(),
45
46
  __metadata("design:type", String)
46
47
  ], AgentResponseDto.prototype, "tenant", void 0);
48
+ __decorate([
49
+ (0, swagger_1.ApiProperty)({
50
+ description: 'Tenant unit id where this agent will be used',
51
+ example: 1,
52
+ }),
53
+ (0, class_validator_1.IsNumber)(),
54
+ __metadata("design:type", Number)
55
+ ], AgentResponseDto.prototype, "unitId", void 0);
47
56
  __decorate([
48
57
  (0, swagger_1.ApiProperty)({
49
58
  description: 'Integration provider used by the agent',
@@ -0,0 +1,27 @@
1
+ export declare const AI_RESPONSE_TYPES: readonly ["message", "action"];
2
+ export type AiResponseTypeDto = (typeof AI_RESPONSE_TYPES)[number];
3
+ export declare const AI_ACTION_TYPES: readonly ["create_patient", "create_appointment", "cancel_appointment"];
4
+ export type AiActionTypeDto = (typeof AI_ACTION_TYPES)[number];
5
+ export declare class AiActionDataDto {
6
+ patientId?: string;
7
+ name?: string;
8
+ cpf?: string;
9
+ birthDate?: string;
10
+ hasDisability?: boolean;
11
+ disabilityDescription?: string;
12
+ initialObservation?: string;
13
+ observation?: string;
14
+ procedureIds?: string[];
15
+ userId?: string;
16
+ date?: string;
17
+ appointmentId?: string;
18
+ reason?: string;
19
+ missingFields?: string[];
20
+ }
21
+ export declare class AiStructuredResponseDto {
22
+ type: AiResponseTypeDto;
23
+ actionType?: AiActionTypeDto;
24
+ message?: string;
25
+ data?: AiActionDataDto;
26
+ }
27
+ //# sourceMappingURL=ai-action.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-action.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-action.dto.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,iBAAiB,gCAAiC,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,eAAO,MAAM,eAAe,yEAIlB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,qBAAa,eAAe;IAO1B,SAAS,CAAC,EAAE,MAAM,CAAC;IASnB,IAAI,CAAC,EAAE,MAAM,CAAC;IASd,GAAG,CAAC,EAAE,MAAM,CAAC;IAQb,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,aAAa,CAAC,EAAE,OAAO,CAAC;IAQxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAQ/B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAQ5B,WAAW,CAAC,EAAE,MAAM,CAAC;IAUrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAQxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,IAAI,CAAC,EAAE,MAAM,CAAC;IAQd,aAAa,CAAC,EAAE,MAAM,CAAC;IAQvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAUhB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,qBAAa,uBAAuB;IAOlC,IAAI,EAAE,iBAAiB,CAAC;IASxB,UAAU,CAAC,EAAE,eAAe,CAAC;IAQ7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAOjB,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB"}
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AiStructuredResponseDto = exports.AiActionDataDto = exports.AI_ACTION_TYPES = exports.AI_RESPONSE_TYPES = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ exports.AI_RESPONSE_TYPES = ['message', 'action'];
16
+ exports.AI_ACTION_TYPES = [
17
+ 'create_patient',
18
+ 'create_appointment',
19
+ 'cancel_appointment',
20
+ ];
21
+ class AiActionDataDto {
22
+ patientId;
23
+ name;
24
+ cpf;
25
+ birthDate;
26
+ hasDisability;
27
+ disabilityDescription;
28
+ initialObservation;
29
+ observation;
30
+ procedureIds;
31
+ userId;
32
+ date;
33
+ appointmentId;
34
+ reason;
35
+ missingFields;
36
+ }
37
+ exports.AiActionDataDto = AiActionDataDto;
38
+ __decorate([
39
+ (0, swagger_1.ApiPropertyOptional)({
40
+ description: 'Suggested patient id when the patient already exists',
41
+ example: '550e8400-e29b-41d4-a716-446655440000',
42
+ }),
43
+ (0, class_validator_1.IsOptional)(),
44
+ (0, class_validator_1.IsUUID)('4'),
45
+ __metadata("design:type", String)
46
+ ], AiActionDataDto.prototype, "patientId", void 0);
47
+ __decorate([
48
+ (0, swagger_1.ApiPropertyOptional)({
49
+ description: 'Patient full name',
50
+ example: 'Joao da Silva',
51
+ }),
52
+ (0, class_validator_1.IsOptional)(),
53
+ (0, class_validator_1.IsString)(),
54
+ (0, class_validator_1.IsNotEmpty)(),
55
+ __metadata("design:type", String)
56
+ ], AiActionDataDto.prototype, "name", void 0);
57
+ __decorate([
58
+ (0, swagger_1.ApiPropertyOptional)({
59
+ description: 'Patient CPF with 11 digits',
60
+ example: '12345678909',
61
+ }),
62
+ (0, class_validator_1.IsOptional)(),
63
+ (0, class_validator_1.IsString)(),
64
+ (0, class_validator_1.Length)(11, 11),
65
+ __metadata("design:type", String)
66
+ ], AiActionDataDto.prototype, "cpf", void 0);
67
+ __decorate([
68
+ (0, swagger_1.ApiPropertyOptional)({
69
+ description: 'Patient birth date in ISO format (YYYY-MM-DD)',
70
+ example: '1990-01-01',
71
+ }),
72
+ (0, class_validator_1.IsOptional)(),
73
+ (0, class_validator_1.IsDateString)(),
74
+ __metadata("design:type", String)
75
+ ], AiActionDataDto.prototype, "birthDate", void 0);
76
+ __decorate([
77
+ (0, swagger_1.ApiPropertyOptional)({
78
+ description: 'Indicates whether the patient has a disability',
79
+ example: false,
80
+ }),
81
+ (0, class_validator_1.IsOptional)(),
82
+ (0, class_validator_1.IsBoolean)(),
83
+ __metadata("design:type", Boolean)
84
+ ], AiActionDataDto.prototype, "hasDisability", void 0);
85
+ __decorate([
86
+ (0, swagger_1.ApiPropertyOptional)({
87
+ description: 'Disability description when applicable',
88
+ example: 'Visual impairment',
89
+ }),
90
+ (0, class_validator_1.IsOptional)(),
91
+ (0, class_validator_1.IsString)(),
92
+ __metadata("design:type", String)
93
+ ], AiActionDataDto.prototype, "disabilityDescription", void 0);
94
+ __decorate([
95
+ (0, swagger_1.ApiPropertyOptional)({
96
+ description: 'Initial patient observation',
97
+ example: 'Patient has back pain for two weeks',
98
+ }),
99
+ (0, class_validator_1.IsOptional)(),
100
+ (0, class_validator_1.IsString)(),
101
+ __metadata("design:type", String)
102
+ ], AiActionDataDto.prototype, "initialObservation", void 0);
103
+ __decorate([
104
+ (0, swagger_1.ApiPropertyOptional)({
105
+ description: 'Optional observation for history',
106
+ example: 'Patient is allergic to penicillin',
107
+ }),
108
+ (0, class_validator_1.IsOptional)(),
109
+ (0, class_validator_1.IsString)(),
110
+ __metadata("design:type", String)
111
+ ], AiActionDataDto.prototype, "observation", void 0);
112
+ __decorate([
113
+ (0, swagger_1.ApiPropertyOptional)({
114
+ description: 'Procedure ids selected by the user',
115
+ type: [String],
116
+ example: ['550e8400-e29b-41d4-a716-446655440010'],
117
+ }),
118
+ (0, class_validator_1.IsOptional)(),
119
+ (0, class_validator_1.IsArray)(),
120
+ (0, class_validator_1.IsUUID)('4', { each: true }),
121
+ __metadata("design:type", Array)
122
+ ], AiActionDataDto.prototype, "procedureIds", void 0);
123
+ __decorate([
124
+ (0, swagger_1.ApiPropertyOptional)({
125
+ description: 'Professional user id selected by the user',
126
+ example: '550e8400-e29b-41d4-a716-446655440001',
127
+ }),
128
+ (0, class_validator_1.IsOptional)(),
129
+ (0, class_validator_1.IsUUID)('4'),
130
+ __metadata("design:type", String)
131
+ ], AiActionDataDto.prototype, "userId", void 0);
132
+ __decorate([
133
+ (0, swagger_1.ApiPropertyOptional)({
134
+ description: 'Requested appointment date/time in ISO format',
135
+ example: '2026-03-15T14:00:00.000Z',
136
+ }),
137
+ (0, class_validator_1.IsOptional)(),
138
+ (0, class_validator_1.IsDateString)(),
139
+ __metadata("design:type", String)
140
+ ], AiActionDataDto.prototype, "date", void 0);
141
+ __decorate([
142
+ (0, swagger_1.ApiPropertyOptional)({
143
+ description: 'Existing appointment id for cancellation',
144
+ example: '550e8400-e29b-41d4-a716-446655440002',
145
+ }),
146
+ (0, class_validator_1.IsOptional)(),
147
+ (0, class_validator_1.IsUUID)('4'),
148
+ __metadata("design:type", String)
149
+ ], AiActionDataDto.prototype, "appointmentId", void 0);
150
+ __decorate([
151
+ (0, swagger_1.ApiPropertyOptional)({
152
+ description: 'Optional human-readable reason or assistant notes',
153
+ example: 'User asked to cancel due to travel',
154
+ }),
155
+ (0, class_validator_1.IsOptional)(),
156
+ (0, class_validator_1.IsString)(),
157
+ __metadata("design:type", String)
158
+ ], AiActionDataDto.prototype, "reason", void 0);
159
+ __decorate([
160
+ (0, swagger_1.ApiPropertyOptional)({
161
+ description: 'Fields still required to complete the action',
162
+ type: [String],
163
+ example: ['cpf', 'birthDate'],
164
+ }),
165
+ (0, class_validator_1.IsOptional)(),
166
+ (0, class_validator_1.IsArray)(),
167
+ (0, class_validator_1.IsString)({ each: true }),
168
+ __metadata("design:type", Array)
169
+ ], AiActionDataDto.prototype, "missingFields", void 0);
170
+ class AiStructuredResponseDto {
171
+ type;
172
+ actionType;
173
+ message;
174
+ data;
175
+ }
176
+ exports.AiStructuredResponseDto = AiStructuredResponseDto;
177
+ __decorate([
178
+ (0, swagger_1.ApiProperty)({
179
+ description: 'Response type returned by AI',
180
+ enum: exports.AI_RESPONSE_TYPES,
181
+ example: 'action',
182
+ }),
183
+ (0, class_validator_1.IsEnum)(exports.AI_RESPONSE_TYPES),
184
+ __metadata("design:type", String)
185
+ ], AiStructuredResponseDto.prototype, "type", void 0);
186
+ __decorate([
187
+ (0, swagger_1.ApiPropertyOptional)({
188
+ description: 'Action type when the response type is action',
189
+ enum: exports.AI_ACTION_TYPES,
190
+ example: 'create_patient',
191
+ }),
192
+ (0, class_validator_1.IsOptional)(),
193
+ (0, class_validator_1.IsEnum)(exports.AI_ACTION_TYPES),
194
+ __metadata("design:type", String)
195
+ ], AiStructuredResponseDto.prototype, "actionType", void 0);
196
+ __decorate([
197
+ (0, swagger_1.ApiPropertyOptional)({
198
+ description: 'Message returned to the user',
199
+ example: 'I need your CPF and birth date to create the patient.',
200
+ }),
201
+ (0, class_validator_1.IsOptional)(),
202
+ (0, class_validator_1.IsString)(),
203
+ __metadata("design:type", String)
204
+ ], AiStructuredResponseDto.prototype, "message", void 0);
205
+ __decorate([
206
+ (0, swagger_1.ApiPropertyOptional)({
207
+ description: 'Structured payload extracted from the conversation',
208
+ type: AiActionDataDto,
209
+ }),
210
+ (0, class_validator_1.IsOptional)(),
211
+ __metadata("design:type", AiActionDataDto)
212
+ ], AiStructuredResponseDto.prototype, "data", void 0);
@@ -1,7 +1,9 @@
1
1
  export declare class AiIntegrationRequestDto {
2
2
  tenant: string;
3
+ unitId?: number;
3
4
  message: string;
4
- isDocument: boolean;
5
- documentsUrl?: string[];
5
+ id: string;
6
+ is_document: boolean;
7
+ documents_url?: string[];
6
8
  }
7
9
  //# sourceMappingURL=ai-integration-request.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-integration-request.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-integration-request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,uBAAuB;IAOlC,MAAM,EAAE,MAAM,CAAC;IAQf,OAAO,EAAE,MAAM,CAAC;IAOhB,UAAU,EAAE,OAAO,CAAC;IAUpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
1
+ {"version":3,"file":"ai-integration-request.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-integration-request.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,uBAAuB;IAOlC,MAAM,EAAE,MAAM,CAAC;IASf,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,OAAO,EAAE,MAAM,CAAC;IAQhB,EAAE,EAAE,MAAM,CAAC;IAOX,WAAW,EAAE,OAAO,CAAC;IAUrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B"}
@@ -14,9 +14,11 @@ const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  class AiIntegrationRequestDto {
16
16
  tenant;
17
+ unitId;
17
18
  message;
18
- isDocument;
19
- documentsUrl;
19
+ id;
20
+ is_document;
21
+ documents_url;
20
22
  }
21
23
  exports.AiIntegrationRequestDto = AiIntegrationRequestDto;
22
24
  __decorate([
@@ -28,6 +30,16 @@ __decorate([
28
30
  (0, class_validator_1.IsNotEmpty)(),
29
31
  __metadata("design:type", String)
30
32
  ], AiIntegrationRequestDto.prototype, "tenant", void 0);
33
+ __decorate([
34
+ (0, swagger_1.ApiPropertyOptional)({
35
+ description: 'Tenant unit id used to select the active agent',
36
+ example: 1,
37
+ }),
38
+ (0, class_validator_1.IsOptional)(),
39
+ (0, class_validator_1.IsInt)(),
40
+ (0, class_validator_1.Min)(1),
41
+ __metadata("design:type", Number)
42
+ ], AiIntegrationRequestDto.prototype, "unitId", void 0);
31
43
  __decorate([
32
44
  (0, swagger_1.ApiProperty)({
33
45
  description: 'User message used as model input',
@@ -37,6 +49,15 @@ __decorate([
37
49
  (0, class_validator_1.IsNotEmpty)(),
38
50
  __metadata("design:type", String)
39
51
  ], AiIntegrationRequestDto.prototype, "message", void 0);
52
+ __decorate([
53
+ (0, swagger_1.ApiProperty)({
54
+ description: 'Conversation identifier used for context isolation',
55
+ example: '5511999999999',
56
+ }),
57
+ (0, class_validator_1.IsString)(),
58
+ (0, class_validator_1.IsNotEmpty)(),
59
+ __metadata("design:type", String)
60
+ ], AiIntegrationRequestDto.prototype, "id", void 0);
40
61
  __decorate([
41
62
  (0, swagger_1.ApiProperty)({
42
63
  description: 'Indicates whether the input is document-based',
@@ -44,7 +65,7 @@ __decorate([
44
65
  }),
45
66
  (0, class_validator_1.IsBoolean)(),
46
67
  __metadata("design:type", Boolean)
47
- ], AiIntegrationRequestDto.prototype, "isDocument", void 0);
68
+ ], AiIntegrationRequestDto.prototype, "is_document", void 0);
48
69
  __decorate([
49
70
  (0, swagger_1.ApiPropertyOptional)({
50
71
  description: 'Document URLs used as additional context',
@@ -55,4 +76,4 @@ __decorate([
55
76
  (0, class_validator_1.IsArray)(),
56
77
  (0, class_validator_1.IsString)({ each: true }),
57
78
  __metadata("design:type", Array)
58
- ], AiIntegrationRequestDto.prototype, "documentsUrl", void 0);
79
+ ], AiIntegrationRequestDto.prototype, "documents_url", void 0);
@@ -1,5 +1,7 @@
1
+ import { AiStructuredResponseDto } from './ai-action.dto';
1
2
  export declare class AiIntegrationResponseDto {
2
3
  tenant: string;
3
- output: string;
4
+ response: AiStructuredResponseDto;
5
+ output?: string;
4
6
  }
5
7
  //# sourceMappingURL=ai-integration-response.dto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-integration-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-integration-response.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,wBAAwB;IAOnC,MAAM,EAAE,MAAM,CAAC;IAQf,MAAM,EAAE,MAAM,CAAC;CAChB"}
1
+ {"version":3,"file":"ai-integration-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-integration-response.dto.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,qBAAa,wBAAwB;IAOnC,MAAM,EAAE,MAAM,CAAC;IAQf,QAAQ,EAAE,uBAAuB,CAAC;IAUlC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -11,9 +11,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AiIntegrationResponseDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
+ const class_transformer_1 = require("class-transformer");
14
15
  const class_validator_1 = require("class-validator");
16
+ const ai_action_dto_1 = require("./ai-action.dto");
15
17
  class AiIntegrationResponseDto {
16
18
  tenant;
19
+ response;
17
20
  output;
18
21
  }
19
22
  exports.AiIntegrationResponseDto = AiIntegrationResponseDto;
@@ -28,9 +31,20 @@ __decorate([
28
31
  ], AiIntegrationResponseDto.prototype, "tenant", void 0);
29
32
  __decorate([
30
33
  (0, swagger_1.ApiProperty)({
31
- description: 'Model output content',
34
+ description: 'Structured AI response',
35
+ type: ai_action_dto_1.AiStructuredResponseDto,
36
+ }),
37
+ (0, class_validator_1.ValidateNested)(),
38
+ (0, class_transformer_1.Type)(() => ai_action_dto_1.AiStructuredResponseDto),
39
+ __metadata("design:type", ai_action_dto_1.AiStructuredResponseDto)
40
+ ], AiIntegrationResponseDto.prototype, "response", void 0);
41
+ __decorate([
42
+ (0, swagger_1.ApiProperty)({
43
+ description: 'Model output content (legacy field, use response.message)',
32
44
  example: 'Sure, I can help you reschedule your appointment.',
45
+ required: false,
33
46
  }),
47
+ (0, class_validator_1.IsOptional)(),
34
48
  (0, class_validator_1.IsString)(),
35
49
  (0, class_validator_1.IsNotEmpty)(),
36
50
  __metadata("design:type", String)
@@ -1,6 +1,7 @@
1
1
  import { AiIntegrationDto } from './integration-provider.dto';
2
2
  export declare class CreateAgentDto {
3
3
  tenant: string;
4
+ unitId: number;
4
5
  integration: AiIntegrationDto;
5
6
  model: string;
6
7
  systemPrompt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-agent.dto.d.ts","sourceRoot":"","sources":["../../src/ai/create-agent.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,cAAc;IAOzB,MAAM,EAAE,MAAM,CAAC;IAQf,WAAW,EAAE,gBAAgB,CAAC;IAQ9B,KAAK,EAAE,MAAM,CAAC;IAQd,YAAY,EAAE,MAAM,CAAC;IAWrB,WAAW,EAAE,MAAM,CAAC;IAOpB,MAAM,EAAE,OAAO,CAAC;IAShB,YAAY,CAAC,EAAE,MAAM,CAAC;IAStB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"create-agent.dto.d.ts","sourceRoot":"","sources":["../../src/ai/create-agent.dto.ts"],"names":[],"mappings":"AAYA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,cAAc;IAOzB,MAAM,EAAE,MAAM,CAAC;IAQf,MAAM,EAAE,MAAM,CAAC;IAQf,WAAW,EAAE,gBAAgB,CAAC;IAQ9B,KAAK,EAAE,MAAM,CAAC;IAQd,YAAY,EAAE,MAAM,CAAC;IAWrB,WAAW,EAAE,MAAM,CAAC;IAOpB,MAAM,EAAE,OAAO,CAAC;IAShB,YAAY,CAAC,EAAE,MAAM,CAAC;IAStB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -15,6 +15,7 @@ const class_validator_1 = require("class-validator");
15
15
  const integration_provider_dto_1 = require("./integration-provider.dto");
16
16
  class CreateAgentDto {
17
17
  tenant;
18
+ unitId;
18
19
  integration;
19
20
  model;
20
21
  systemPrompt;
@@ -33,6 +34,15 @@ __decorate([
33
34
  (0, class_validator_1.IsNotEmpty)(),
34
35
  __metadata("design:type", String)
35
36
  ], CreateAgentDto.prototype, "tenant", void 0);
37
+ __decorate([
38
+ (0, swagger_1.ApiProperty)({
39
+ description: 'Tenant unit id where this agent will be used',
40
+ example: 1,
41
+ }),
42
+ (0, class_validator_1.IsInt)(),
43
+ (0, class_validator_1.Min)(1),
44
+ __metadata("design:type", Number)
45
+ ], CreateAgentDto.prototype, "unitId", void 0);
36
46
  __decorate([
37
47
  (0, swagger_1.ApiProperty)({
38
48
  description: 'Integration provider used by the agent',
@@ -4,4 +4,6 @@ export * from './update-agent.dto';
4
4
  export * from './agent-response.dto';
5
5
  export * from './ai-integration-request.dto';
6
6
  export * from './ai-integration-response.dto';
7
+ export * from './list-models.dto';
8
+ export * from './ai-action.dto';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
package/dist/ai/index.js CHANGED
@@ -20,3 +20,5 @@ __exportStar(require("./update-agent.dto"), exports);
20
20
  __exportStar(require("./agent-response.dto"), exports);
21
21
  __exportStar(require("./ai-integration-request.dto"), exports);
22
22
  __exportStar(require("./ai-integration-response.dto"), exports);
23
+ __exportStar(require("./list-models.dto"), exports);
24
+ __exportStar(require("./ai-action.dto"), exports);
@@ -0,0 +1,10 @@
1
+ import { AiIntegrationDto } from './integration-provider.dto';
2
+ export declare class ListAiModelsRequestDto {
3
+ integration: AiIntegrationDto;
4
+ apiKey?: string;
5
+ }
6
+ export declare class ListAiModelsResponseDto {
7
+ integration: AiIntegrationDto;
8
+ models: string[];
9
+ }
10
+ //# sourceMappingURL=list-models.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-models.dto.d.ts","sourceRoot":"","sources":["../../src/ai/list-models.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,sBAAsB;IAOjC,WAAW,EAAE,gBAAgB,CAAC;IAS9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,uBAAuB;IAOlC,WAAW,EAAE,gBAAgB,CAAC;IAS9B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ListAiModelsResponseDto = exports.ListAiModelsRequestDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const integration_provider_dto_1 = require("./integration-provider.dto");
16
+ class ListAiModelsRequestDto {
17
+ integration;
18
+ apiKey;
19
+ }
20
+ exports.ListAiModelsRequestDto = ListAiModelsRequestDto;
21
+ __decorate([
22
+ (0, swagger_1.ApiProperty)({
23
+ description: 'Integration provider to list available models',
24
+ enum: integration_provider_dto_1.AI_INTEGRATIONS,
25
+ example: 'OPENAI',
26
+ }),
27
+ (0, class_validator_1.IsEnum)(integration_provider_dto_1.AI_INTEGRATIONS),
28
+ __metadata("design:type", String)
29
+ ], ListAiModelsRequestDto.prototype, "integration", void 0);
30
+ __decorate([
31
+ (0, swagger_1.ApiPropertyOptional)({
32
+ description: 'Optional provider API key used to list models. Falls back to env key when omitted.',
33
+ example: 'sk-****',
34
+ }),
35
+ (0, class_validator_1.IsOptional)(),
36
+ (0, class_validator_1.IsString)(),
37
+ __metadata("design:type", String)
38
+ ], ListAiModelsRequestDto.prototype, "apiKey", void 0);
39
+ class ListAiModelsResponseDto {
40
+ integration;
41
+ models;
42
+ }
43
+ exports.ListAiModelsResponseDto = ListAiModelsResponseDto;
44
+ __decorate([
45
+ (0, swagger_1.ApiProperty)({
46
+ description: 'Integration provider',
47
+ enum: integration_provider_dto_1.AI_INTEGRATIONS,
48
+ example: 'GEMINI',
49
+ }),
50
+ (0, class_validator_1.IsEnum)(integration_provider_dto_1.AI_INTEGRATIONS),
51
+ __metadata("design:type", String)
52
+ ], ListAiModelsResponseDto.prototype, "integration", void 0);
53
+ __decorate([
54
+ (0, swagger_1.ApiProperty)({
55
+ description: 'Available model ids for the selected integration',
56
+ type: [String],
57
+ example: ['gpt-4.1-mini', 'gpt-4o-mini'],
58
+ }),
59
+ (0, class_validator_1.IsArray)(),
60
+ (0, class_validator_1.IsString)({ each: true }),
61
+ __metadata("design:type", Array)
62
+ ], ListAiModelsResponseDto.prototype, "models", void 0);
@@ -1,5 +1,6 @@
1
1
  import { AiIntegrationDto } from './integration-provider.dto';
2
2
  export declare class UpdateAgentDto {
3
+ unitId?: number;
3
4
  integration?: AiIntegrationDto;
4
5
  model?: string;
5
6
  systemPrompt?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"update-agent.dto.d.ts","sourceRoot":"","sources":["../../src/ai/update-agent.dto.ts"],"names":[],"mappings":"AAWA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,cAAc;IAQzB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAS/B,KAAK,CAAC,EAAE,MAAM,CAAC;IASf,YAAY,CAAC,EAAE,MAAM,CAAC;IAYtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,MAAM,CAAC,EAAE,OAAO,CAAC;IASjB,YAAY,CAAC,EAAE,MAAM,CAAC;IAStB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"update-agent.dto.d.ts","sourceRoot":"","sources":["../../src/ai/update-agent.dto.ts"],"names":[],"mappings":"AAYA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,qBAAa,cAAc;IAQzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAShB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAS/B,KAAK,CAAC,EAAE,MAAM,CAAC;IASf,YAAY,CAAC,EAAE,MAAM,CAAC;IAYtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,MAAM,CAAC,EAAE,OAAO,CAAC;IASjB,YAAY,CAAC,EAAE,MAAM,CAAC;IAStB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -14,6 +14,7 @@ const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const integration_provider_dto_1 = require("./integration-provider.dto");
16
16
  class UpdateAgentDto {
17
+ unitId;
17
18
  integration;
18
19
  model;
19
20
  systemPrompt;
@@ -23,6 +24,16 @@ class UpdateAgentDto {
23
24
  geminiApiKey;
24
25
  }
25
26
  exports.UpdateAgentDto = UpdateAgentDto;
27
+ __decorate([
28
+ (0, swagger_1.ApiPropertyOptional)({
29
+ description: 'Tenant unit id where this agent will be used',
30
+ example: 1,
31
+ }),
32
+ (0, class_validator_1.IsOptional)(),
33
+ (0, class_validator_1.IsInt)(),
34
+ (0, class_validator_1.Min)(1),
35
+ __metadata("design:type", Number)
36
+ ], UpdateAgentDto.prototype, "unitId", void 0);
26
37
  __decorate([
27
38
  (0, swagger_1.ApiPropertyOptional)({
28
39
  description: 'Integration provider used by the agent',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tychat-contracts",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "DTOs compartilhados com class-validator (API e microserviços)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "dependencies": {
13
13
  "class-transformer": "^0.5.1",
14
14
  "class-validator": "^0.14.1",
15
+ "ioredis": "^5.10.0",
15
16
  "reflect-metadata": "*"
16
17
  },
17
18
  "devDependencies": {
@@ -18,6 +18,13 @@ export class AgentResponseDto {
18
18
  @IsNotEmpty()
19
19
  tenant: string;
20
20
 
21
+ @ApiProperty({
22
+ description: 'Tenant unit id where this agent will be used',
23
+ example: 1,
24
+ })
25
+ @IsNumber()
26
+ unitId: number;
27
+
21
28
  @ApiProperty({
22
29
  description: 'Integration provider used by the agent',
23
30
  enum: AI_INTEGRATIONS,
@@ -0,0 +1,176 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import {
3
+ IsArray,
4
+ IsBoolean,
5
+ IsDateString,
6
+ IsEnum,
7
+ IsNotEmpty,
8
+ IsOptional,
9
+ IsString,
10
+ IsUUID,
11
+ Length,
12
+ } from 'class-validator';
13
+
14
+ export const AI_RESPONSE_TYPES = ['message', 'action'] as const;
15
+ export type AiResponseTypeDto = (typeof AI_RESPONSE_TYPES)[number];
16
+
17
+ export const AI_ACTION_TYPES = [
18
+ 'create_patient',
19
+ 'create_appointment',
20
+ 'cancel_appointment',
21
+ ] as const;
22
+ export type AiActionTypeDto = (typeof AI_ACTION_TYPES)[number];
23
+
24
+ export class AiActionDataDto {
25
+ @ApiPropertyOptional({
26
+ description: 'Suggested patient id when the patient already exists',
27
+ example: '550e8400-e29b-41d4-a716-446655440000',
28
+ })
29
+ @IsOptional()
30
+ @IsUUID('4')
31
+ patientId?: string;
32
+
33
+ @ApiPropertyOptional({
34
+ description: 'Patient full name',
35
+ example: 'Joao da Silva',
36
+ })
37
+ @IsOptional()
38
+ @IsString()
39
+ @IsNotEmpty()
40
+ name?: string;
41
+
42
+ @ApiPropertyOptional({
43
+ description: 'Patient CPF with 11 digits',
44
+ example: '12345678909',
45
+ })
46
+ @IsOptional()
47
+ @IsString()
48
+ @Length(11, 11)
49
+ cpf?: string;
50
+
51
+ @ApiPropertyOptional({
52
+ description: 'Patient birth date in ISO format (YYYY-MM-DD)',
53
+ example: '1990-01-01',
54
+ })
55
+ @IsOptional()
56
+ @IsDateString()
57
+ birthDate?: string;
58
+
59
+ @ApiPropertyOptional({
60
+ description: 'Indicates whether the patient has a disability',
61
+ example: false,
62
+ })
63
+ @IsOptional()
64
+ @IsBoolean()
65
+ hasDisability?: boolean;
66
+
67
+ @ApiPropertyOptional({
68
+ description: 'Disability description when applicable',
69
+ example: 'Visual impairment',
70
+ })
71
+ @IsOptional()
72
+ @IsString()
73
+ disabilityDescription?: string;
74
+
75
+ @ApiPropertyOptional({
76
+ description: 'Initial patient observation',
77
+ example: 'Patient has back pain for two weeks',
78
+ })
79
+ @IsOptional()
80
+ @IsString()
81
+ initialObservation?: string;
82
+
83
+ @ApiPropertyOptional({
84
+ description: 'Optional observation for history',
85
+ example: 'Patient is allergic to penicillin',
86
+ })
87
+ @IsOptional()
88
+ @IsString()
89
+ observation?: string;
90
+
91
+ @ApiPropertyOptional({
92
+ description: 'Procedure ids selected by the user',
93
+ type: [String],
94
+ example: ['550e8400-e29b-41d4-a716-446655440010'],
95
+ })
96
+ @IsOptional()
97
+ @IsArray()
98
+ @IsUUID('4', { each: true })
99
+ procedureIds?: string[];
100
+
101
+ @ApiPropertyOptional({
102
+ description: 'Professional user id selected by the user',
103
+ example: '550e8400-e29b-41d4-a716-446655440001',
104
+ })
105
+ @IsOptional()
106
+ @IsUUID('4')
107
+ userId?: string;
108
+
109
+ @ApiPropertyOptional({
110
+ description: 'Requested appointment date/time in ISO format',
111
+ example: '2026-03-15T14:00:00.000Z',
112
+ })
113
+ @IsOptional()
114
+ @IsDateString()
115
+ date?: string;
116
+
117
+ @ApiPropertyOptional({
118
+ description: 'Existing appointment id for cancellation',
119
+ example: '550e8400-e29b-41d4-a716-446655440002',
120
+ })
121
+ @IsOptional()
122
+ @IsUUID('4')
123
+ appointmentId?: string;
124
+
125
+ @ApiPropertyOptional({
126
+ description: 'Optional human-readable reason or assistant notes',
127
+ example: 'User asked to cancel due to travel',
128
+ })
129
+ @IsOptional()
130
+ @IsString()
131
+ reason?: string;
132
+
133
+ @ApiPropertyOptional({
134
+ description: 'Fields still required to complete the action',
135
+ type: [String],
136
+ example: ['cpf', 'birthDate'],
137
+ })
138
+ @IsOptional()
139
+ @IsArray()
140
+ @IsString({ each: true })
141
+ missingFields?: string[];
142
+ }
143
+
144
+ export class AiStructuredResponseDto {
145
+ @ApiProperty({
146
+ description: 'Response type returned by AI',
147
+ enum: AI_RESPONSE_TYPES,
148
+ example: 'action',
149
+ })
150
+ @IsEnum(AI_RESPONSE_TYPES)
151
+ type: AiResponseTypeDto;
152
+
153
+ @ApiPropertyOptional({
154
+ description: 'Action type when the response type is action',
155
+ enum: AI_ACTION_TYPES,
156
+ example: 'create_patient',
157
+ })
158
+ @IsOptional()
159
+ @IsEnum(AI_ACTION_TYPES)
160
+ actionType?: AiActionTypeDto;
161
+
162
+ @ApiPropertyOptional({
163
+ description: 'Message returned to the user',
164
+ example: 'I need your CPF and birth date to create the patient.',
165
+ })
166
+ @IsOptional()
167
+ @IsString()
168
+ message?: string;
169
+
170
+ @ApiPropertyOptional({
171
+ description: 'Structured payload extracted from the conversation',
172
+ type: AiActionDataDto,
173
+ })
174
+ @IsOptional()
175
+ data?: AiActionDataDto;
176
+ }
@@ -1,5 +1,5 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
- import { IsArray, IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator';
2
+ import { IsArray, IsBoolean, IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
3
3
 
4
4
  export class AiIntegrationRequestDto {
5
5
  @ApiProperty({
@@ -10,6 +10,15 @@ export class AiIntegrationRequestDto {
10
10
  @IsNotEmpty()
11
11
  tenant: string;
12
12
 
13
+ @ApiPropertyOptional({
14
+ description: 'Tenant unit id used to select the active agent',
15
+ example: 1,
16
+ })
17
+ @IsOptional()
18
+ @IsInt()
19
+ @Min(1)
20
+ unitId?: number;
21
+
13
22
  @ApiProperty({
14
23
  description: 'User message used as model input',
15
24
  example: 'Hello, how can I reschedule my appointment?',
@@ -18,12 +27,20 @@ export class AiIntegrationRequestDto {
18
27
  @IsNotEmpty()
19
28
  message: string;
20
29
 
30
+ @ApiProperty({
31
+ description: 'Conversation identifier used for context isolation',
32
+ example: '5511999999999',
33
+ })
34
+ @IsString()
35
+ @IsNotEmpty()
36
+ id: string;
37
+
21
38
  @ApiProperty({
22
39
  description: 'Indicates whether the input is document-based',
23
40
  example: false,
24
41
  })
25
42
  @IsBoolean()
26
- isDocument: boolean;
43
+ is_document: boolean;
27
44
 
28
45
  @ApiPropertyOptional({
29
46
  description: 'Document URLs used as additional context',
@@ -33,5 +50,5 @@ export class AiIntegrationRequestDto {
33
50
  @IsOptional()
34
51
  @IsArray()
35
52
  @IsString({ each: true })
36
- documentsUrl?: string[];
53
+ documents_url?: string[];
37
54
  }
@@ -1,5 +1,7 @@
1
1
  import { ApiProperty } from '@nestjs/swagger';
2
- import { IsNotEmpty, IsString } from 'class-validator';
2
+ import { Type } from 'class-transformer';
3
+ import { IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator';
4
+ import { AiStructuredResponseDto } from './ai-action.dto';
3
5
 
4
6
  export class AiIntegrationResponseDto {
5
7
  @ApiProperty({
@@ -11,10 +13,20 @@ export class AiIntegrationResponseDto {
11
13
  tenant: string;
12
14
 
13
15
  @ApiProperty({
14
- description: 'Model output content',
16
+ description: 'Structured AI response',
17
+ type: AiStructuredResponseDto,
18
+ })
19
+ @ValidateNested()
20
+ @Type(() => AiStructuredResponseDto)
21
+ response: AiStructuredResponseDto;
22
+
23
+ @ApiProperty({
24
+ description: 'Model output content (legacy field, use response.message)',
15
25
  example: 'Sure, I can help you reschedule your appointment.',
26
+ required: false,
16
27
  })
28
+ @IsOptional()
17
29
  @IsString()
18
30
  @IsNotEmpty()
19
- output: string;
31
+ output?: string;
20
32
  }
@@ -1,5 +1,15 @@
1
1
  import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
- import { IsBoolean, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator';
2
+ import {
3
+ IsBoolean,
4
+ IsEnum,
5
+ IsInt,
6
+ IsNotEmpty,
7
+ IsNumber,
8
+ IsOptional,
9
+ IsString,
10
+ Max,
11
+ Min,
12
+ } from 'class-validator';
3
13
  import { AI_INTEGRATIONS, AiIntegrationDto } from './integration-provider.dto';
4
14
 
5
15
  export class CreateAgentDto {
@@ -11,6 +21,14 @@ export class CreateAgentDto {
11
21
  @IsNotEmpty()
12
22
  tenant: string;
13
23
 
24
+ @ApiProperty({
25
+ description: 'Tenant unit id where this agent will be used',
26
+ example: 1,
27
+ })
28
+ @IsInt()
29
+ @Min(1)
30
+ unitId: number;
31
+
14
32
  @ApiProperty({
15
33
  description: 'Integration provider used by the agent',
16
34
  enum: AI_INTEGRATIONS,
package/src/ai/index.ts CHANGED
@@ -4,3 +4,5 @@ export * from './update-agent.dto';
4
4
  export * from './agent-response.dto';
5
5
  export * from './ai-integration-request.dto';
6
6
  export * from './ai-integration-response.dto';
7
+ export * from './list-models.dto';
8
+ export * from './ai-action.dto';
@@ -0,0 +1,41 @@
1
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2
+ import { IsArray, IsEnum, IsOptional, IsString } from 'class-validator';
3
+ import { AI_INTEGRATIONS, AiIntegrationDto } from './integration-provider.dto';
4
+
5
+ export class ListAiModelsRequestDto {
6
+ @ApiProperty({
7
+ description: 'Integration provider to list available models',
8
+ enum: AI_INTEGRATIONS,
9
+ example: 'OPENAI',
10
+ })
11
+ @IsEnum(AI_INTEGRATIONS)
12
+ integration: AiIntegrationDto;
13
+
14
+ @ApiPropertyOptional({
15
+ description:
16
+ 'Optional provider API key used to list models. Falls back to env key when omitted.',
17
+ example: 'sk-****',
18
+ })
19
+ @IsOptional()
20
+ @IsString()
21
+ apiKey?: string;
22
+ }
23
+
24
+ export class ListAiModelsResponseDto {
25
+ @ApiProperty({
26
+ description: 'Integration provider',
27
+ enum: AI_INTEGRATIONS,
28
+ example: 'GEMINI',
29
+ })
30
+ @IsEnum(AI_INTEGRATIONS)
31
+ integration: AiIntegrationDto;
32
+
33
+ @ApiProperty({
34
+ description: 'Available model ids for the selected integration',
35
+ type: [String],
36
+ example: ['gpt-4.1-mini', 'gpt-4o-mini'],
37
+ })
38
+ @IsArray()
39
+ @IsString({ each: true })
40
+ models: string[];
41
+ }
@@ -2,6 +2,7 @@ import { ApiPropertyOptional } from '@nestjs/swagger';
2
2
  import {
3
3
  IsBoolean,
4
4
  IsEnum,
5
+ IsInt,
5
6
  IsNotEmpty,
6
7
  IsNumber,
7
8
  IsOptional,
@@ -12,6 +13,15 @@ import {
12
13
  import { AI_INTEGRATIONS, AiIntegrationDto } from './integration-provider.dto';
13
14
 
14
15
  export class UpdateAgentDto {
16
+ @ApiPropertyOptional({
17
+ description: 'Tenant unit id where this agent will be used',
18
+ example: 1,
19
+ })
20
+ @IsOptional()
21
+ @IsInt()
22
+ @Min(1)
23
+ unitId?: number;
24
+
15
25
  @ApiPropertyOptional({
16
26
  description: 'Integration provider used by the agent',
17
27
  enum: AI_INTEGRATIONS,