rapida-partner 3.7.0 → 4.1.0
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/package.json
CHANGED
|
@@ -14,13 +14,23 @@ export interface IAiAgentConfig {
|
|
|
14
14
|
// Example: "## Identidade\n\nVocê é a ...". When non-empty it is
|
|
15
15
|
// written verbatim to prompts/system.template.md. When empty (""), the
|
|
16
16
|
// code generator emits a default prompt scaffold including a tools
|
|
17
|
-
// table built from the fixed tools and the exposedContracts.
|
|
17
|
+
// table built from the active fixed tools and the exposedContracts.
|
|
18
|
+
//
|
|
19
|
+
// Placeholders (plain text, not JS interpolation):
|
|
20
|
+
// - {{ASSISTANT_NAME}}: agentIdentity.name, replaced at runtime;
|
|
21
|
+
// - {{CURRENT_DATE}}: current date/time (pt-BR), replaced at runtime;
|
|
22
|
+
// - {{USER_NAME}}: the user's name from the session, replaced at runtime;
|
|
23
|
+
// - {{TOOLS_TABLE}}: replaced at generation time by the table of the
|
|
24
|
+
// tools actually generated (active fixed tools + exposedContracts).
|
|
25
|
+
// Prefer it over a hand-written tool list, which goes stale silently.
|
|
26
|
+
// The generator warns when a literal prompt cites a tool that does not
|
|
27
|
+
// exist, or (without {{TOOLS_TABLE}}) omits a generated tool.
|
|
18
28
|
systemPromptTemplate: string;
|
|
19
29
|
|
|
20
30
|
// Relative path (inside the generated agent) where the knowledge
|
|
21
|
-
// base markdown file is written and read from
|
|
22
|
-
// "data/knowledge.md"
|
|
23
|
-
knowledgeBaseFile
|
|
31
|
+
// base markdown file is written and read from. Defaults to
|
|
32
|
+
// "data/knowledge.md".
|
|
33
|
+
knowledgeBaseFile?: string;
|
|
24
34
|
|
|
25
35
|
// Optional brand/company name used by the default prompt scaffold.
|
|
26
36
|
// Falls back to the project title when omitted.
|
|
@@ -52,7 +62,10 @@ export interface IAiAgentConfig {
|
|
|
52
62
|
};
|
|
53
63
|
|
|
54
64
|
businessContext: {
|
|
55
|
-
|
|
65
|
+
// Not used by the code generator today (kept only for compatibility).
|
|
66
|
+
// Contracts come from this project's modules and, optionally, from
|
|
67
|
+
// targetBackendDefinitionFile.
|
|
68
|
+
targetBackendProjectId?: string;
|
|
56
69
|
|
|
57
70
|
// Optional path to an ALREADY COMPILED rapidaObject.json of the target
|
|
58
71
|
// backend project (NOT the .ts source — the loader parses it as JSON),
|
|
@@ -66,14 +79,16 @@ export interface IAiAgentConfig {
|
|
|
66
79
|
targetBackendDefinitionFile?: string;
|
|
67
80
|
|
|
68
81
|
// exposedContracts only covers *additional* domain actions. The agent
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
82
|
+
// ships fixed tools according to `capabilities` (identity → /people,
|
|
83
|
+
// scheduling → /appointments and /availability-schedules, knowledge base,
|
|
84
|
+
// media) plus the handoff tool when humanHandoff has contacts. Their names
|
|
85
|
+
// are reserved — a binding with one of them fails code generation, as does
|
|
86
|
+
// a toolName repeated between bindings: cadastrar_usuario,
|
|
87
|
+
// atualizar_status_usuario, atualizar_telefone_usuario,
|
|
88
|
+
// atualizar_email_usuario, atualizar_genero_usuario,
|
|
89
|
+
// checar_disponibilidade, criar_evento, meus_agendamentos,
|
|
90
|
+
// cancelar_agendamento, consultar_base_conhecimento, mostrar_imagem,
|
|
91
|
+
// escalar_para_humano. Also note: for "update"/"getById"/
|
|
77
92
|
// "softDelete"/"hardDelete" actions the generator already injects a
|
|
78
93
|
// generic required "id" tool parameter — do not add your own id/_id
|
|
79
94
|
// entry to formFields, it will create a duplicate, unused parameter.
|
|
@@ -100,6 +115,24 @@ export interface IAiAgentConfig {
|
|
|
100
115
|
};
|
|
101
116
|
};
|
|
102
117
|
|
|
118
|
+
// Groups of fixed tools the agent ships. Each one defaults to true when
|
|
119
|
+
// omitted, so leaving the block out keeps every fixed tool. A disabled
|
|
120
|
+
// group is not generated, not offered to the LLM, left out of the default
|
|
121
|
+
// prompt and of the endpoint check.
|
|
122
|
+
// - identity: cadastrar_usuario and atualizar_*_usuario (/people), plus
|
|
123
|
+
// recognizing a returning user by WhatsApp id;
|
|
124
|
+
// - scheduling: checar_disponibilidade, criar_evento, meus_agendamentos,
|
|
125
|
+
// cancelar_agendamento (/appointments, /availability-schedules) and the
|
|
126
|
+
// appointment reminder job (needs identity);
|
|
127
|
+
// - knowledgeBase: consultar_base_conhecimento and the knowledge file;
|
|
128
|
+
// - media: mostrar_imagem.
|
|
129
|
+
capabilities?: {
|
|
130
|
+
identity?: boolean;
|
|
131
|
+
scheduling?: boolean;
|
|
132
|
+
knowledgeBase?: boolean;
|
|
133
|
+
media?: boolean;
|
|
134
|
+
};
|
|
135
|
+
|
|
103
136
|
// Optional human handoff: when present with at least one contact, the
|
|
104
137
|
// code generator adds a fixed tool ("escalar_para_humano") that sends a
|
|
105
138
|
// WhatsApp text message (summary generated by the LLM itself + the name/
|
|
@@ -108,7 +141,11 @@ export interface IAiAgentConfig {
|
|
|
108
141
|
// phone number) to one of the configured contacts' whatsappPhoneNumber.
|
|
109
142
|
// The agent keeps responding the original user normally after the
|
|
110
143
|
// handoff — this is a parallel notification to a human, not a channel
|
|
111
|
-
// switch/handover of the conversation itself.
|
|
144
|
+
// switch/handover of the conversation itself. The notification always goes
|
|
145
|
+
// through the WhatsApp messenger (it must be active), whatever channel the
|
|
146
|
+
// conversation came from. Meta only delivers it if the contact messaged the
|
|
147
|
+
// agent's number in the last 24 h (same rule as the reminder; a template is
|
|
148
|
+
// not supported here yet).
|
|
112
149
|
humanHandoff?: {
|
|
113
150
|
contacts: IHumanHandoffContact[];
|
|
114
151
|
};
|
|
@@ -128,29 +165,64 @@ export interface IAiAgentConfig {
|
|
|
128
165
|
|
|
129
166
|
// Optional background jobs configuration. Values become the generated
|
|
130
167
|
// defaults of the agent's job services and can still be overridden at
|
|
131
|
-
// runtime through
|
|
168
|
+
// runtime through config/rules.json.
|
|
132
169
|
jobs?: {
|
|
170
|
+
// Appointment reminder sent through WhatsApp. Frequency and timezone live
|
|
171
|
+
// in IBackend.scheduledJobs (id "aiAgentAppointmentReminder"), per
|
|
172
|
+
// environment; the timezone is also the one appointment times are stored
|
|
173
|
+
// in.
|
|
133
174
|
reminder?: {
|
|
134
175
|
// Defaults to true. The reminder job is only generated when the
|
|
135
176
|
// whatsapp messenger is active.
|
|
136
177
|
enabled?: boolean;
|
|
137
|
-
// Cron expression. Defaults to "*/2 * * * *".
|
|
138
|
-
cronInterval?: string;
|
|
139
178
|
// How many minutes ahead of the appointment the reminder fires.
|
|
140
179
|
// Defaults to 1440 (24 hours).
|
|
141
180
|
minutesAhead?: number;
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
|
|
181
|
+
// Who gets the reminder: the person who booked ("client",
|
|
182
|
+
// appointment.personId) and/or the professional ("professional",
|
|
183
|
+
// first of appointment.involvedPeopleId). Defaults to both.
|
|
184
|
+
recipients?: TAppointmentReminderRecipient[];
|
|
185
|
+
// WhatsApp message templates approved in Meta's WhatsApp Manager, one
|
|
186
|
+
// per recipient. Meta only delivers free text up to 24 h after the
|
|
187
|
+
// recipient's last message to this number; outside that window only an
|
|
188
|
+
// approved template is delivered. Without a template the agent sends
|
|
189
|
+
// free text (and the code generator warns).
|
|
190
|
+
whatsappTemplates?: {
|
|
191
|
+
// Body parameters, in order: {{1}} client name, {{2}} date
|
|
192
|
+
// (dd/mm/aaaa), {{3}} time (HH:mm), {{4}} professional name.
|
|
193
|
+
client?: IWhatsappMessageTemplate;
|
|
194
|
+
// Body parameters, in order: {{1}} professional name, {{2}} date
|
|
195
|
+
// (dd/mm/aaaa), {{3}} time (HH:mm), {{4}} client name, {{5}} client
|
|
196
|
+
// phone.
|
|
197
|
+
professional?: IWhatsappMessageTemplate;
|
|
198
|
+
};
|
|
145
199
|
};
|
|
146
200
|
};
|
|
147
201
|
}
|
|
148
202
|
|
|
203
|
+
export type TAppointmentReminderRecipient = "client" | "professional";
|
|
204
|
+
|
|
205
|
+
export interface IWhatsappMessageTemplate {
|
|
206
|
+
// Template name exactly as approved in WhatsApp Manager.
|
|
207
|
+
name: string;
|
|
208
|
+
// Template language code. Defaults to "pt_BR".
|
|
209
|
+
languageCode?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
149
212
|
export interface IAgentContractBinding {
|
|
150
213
|
contractId: string;
|
|
151
214
|
|
|
152
215
|
toolName: string;
|
|
153
216
|
|
|
217
|
+
// Text the LLM reads to decide when to call this tool. Takes precedence
|
|
218
|
+
// over the contract's userStory; the generator warns when neither exists.
|
|
219
|
+
description?: string;
|
|
220
|
+
|
|
221
|
+
// For getById/update/softDelete/hardDelete: where the LLM gets the record
|
|
222
|
+
// id from (e.g. "use o id retornado por consultar_reserva, nunca o CPF").
|
|
223
|
+
// Without it the tool only says "Identificador único do registro alvo".
|
|
224
|
+
idPrompt?: string;
|
|
225
|
+
|
|
154
226
|
action: "create" | "get" | "getById" | "update" | "softDelete" | "hardDelete";
|
|
155
227
|
|
|
156
228
|
intentMapping: {
|
|
@@ -190,6 +262,6 @@ export interface IHumanHandoffContact {
|
|
|
190
262
|
useCase: string;
|
|
191
263
|
|
|
192
264
|
// E.164 phone number (e.g. "+558296539080") that receives the
|
|
193
|
-
// WhatsApp text message on handoff.
|
|
265
|
+
// WhatsApp text message on handoff. Validated by the schema.
|
|
194
266
|
whatsappPhoneNumber: string;
|
|
195
267
|
}
|
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
* - "referralPriceSnapshot": captura de preços dos anúncios do skeleton
|
|
4
4
|
* "referralCommerce" (base de `IReferralPriceBaseline`). Respeite o limite
|
|
5
5
|
* de requisições das APIs de afiliado ao escolher a frequência.
|
|
6
|
+
* - "aiAgentAppointmentReminder": lembrete de agendamento do agente de IA
|
|
7
|
+
* (`IAiAgentConfig.jobs.reminder`). Roda no processo do agente, não no
|
|
8
|
+
* backend Nest. O `timezone` também é o fuso em que os horários dos
|
|
9
|
+
* agendamentos estão gravados. Sem entrada, o agente usa "*\/2 * * * *" e
|
|
10
|
+
* "America/Sao_Paulo".
|
|
6
11
|
*/
|
|
7
|
-
export type TScheduledJobId =
|
|
12
|
+
export type TScheduledJobId =
|
|
13
|
+
| "referralPriceSnapshot"
|
|
14
|
+
| "aiAgentAppointmentReminder";
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
17
|
* Job agendado do backend gerado (`IBackend.scheduledJobs`), por ambiente.
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"type": "string"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"required": ["name", "systemPromptTemplate"
|
|
29
|
+
"required": ["name", "systemPromptTemplate"],
|
|
30
30
|
"additionalProperties": false
|
|
31
31
|
},
|
|
32
32
|
"infrastructure": {
|
|
@@ -72,6 +72,14 @@
|
|
|
72
72
|
"toolName": {
|
|
73
73
|
"type": "string"
|
|
74
74
|
},
|
|
75
|
+
"description": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"minLength": 1
|
|
78
|
+
},
|
|
79
|
+
"idPrompt": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"minLength": 1
|
|
82
|
+
},
|
|
75
83
|
"action": {
|
|
76
84
|
"type": "string",
|
|
77
85
|
"enum": [
|
|
@@ -159,7 +167,17 @@
|
|
|
159
167
|
"additionalProperties": false
|
|
160
168
|
}
|
|
161
169
|
},
|
|
162
|
-
"required": ["
|
|
170
|
+
"required": ["exposedContracts"],
|
|
171
|
+
"additionalProperties": false
|
|
172
|
+
},
|
|
173
|
+
"capabilities": {
|
|
174
|
+
"type": "object",
|
|
175
|
+
"properties": {
|
|
176
|
+
"identity": { "type": "boolean" },
|
|
177
|
+
"scheduling": { "type": "boolean" },
|
|
178
|
+
"knowledgeBase": { "type": "boolean" },
|
|
179
|
+
"media": { "type": "boolean" }
|
|
180
|
+
},
|
|
163
181
|
"additionalProperties": false
|
|
164
182
|
},
|
|
165
183
|
"humanHandoff": {
|
|
@@ -177,7 +195,8 @@
|
|
|
177
195
|
"type": "string"
|
|
178
196
|
},
|
|
179
197
|
"whatsappPhoneNumber": {
|
|
180
|
-
"type": "string"
|
|
198
|
+
"type": "string",
|
|
199
|
+
"pattern": "^\\+[1-9][0-9]{7,14}$"
|
|
181
200
|
}
|
|
182
201
|
},
|
|
183
202
|
"required": ["name", "useCase", "whatsappPhoneNumber"],
|
|
@@ -211,14 +230,39 @@
|
|
|
211
230
|
"enabled": {
|
|
212
231
|
"type": "boolean"
|
|
213
232
|
},
|
|
214
|
-
"cronInterval": {
|
|
215
|
-
"type": "string"
|
|
216
|
-
},
|
|
217
233
|
"minutesAhead": {
|
|
218
|
-
"type": "number"
|
|
234
|
+
"type": "number",
|
|
235
|
+
"minimum": 1
|
|
219
236
|
},
|
|
220
|
-
"
|
|
221
|
-
"type": "
|
|
237
|
+
"recipients": {
|
|
238
|
+
"type": "array",
|
|
239
|
+
"minItems": 1,
|
|
240
|
+
"uniqueItems": true,
|
|
241
|
+
"items": { "type": "string", "enum": ["client", "professional"] }
|
|
242
|
+
},
|
|
243
|
+
"whatsappTemplates": {
|
|
244
|
+
"type": "object",
|
|
245
|
+
"properties": {
|
|
246
|
+
"client": {
|
|
247
|
+
"type": "object",
|
|
248
|
+
"properties": {
|
|
249
|
+
"name": { "type": "string", "minLength": 1 },
|
|
250
|
+
"languageCode": { "type": "string", "minLength": 2 }
|
|
251
|
+
},
|
|
252
|
+
"required": ["name"],
|
|
253
|
+
"additionalProperties": false
|
|
254
|
+
},
|
|
255
|
+
"professional": {
|
|
256
|
+
"type": "object",
|
|
257
|
+
"properties": {
|
|
258
|
+
"name": { "type": "string", "minLength": 1 },
|
|
259
|
+
"languageCode": { "type": "string", "minLength": 2 }
|
|
260
|
+
},
|
|
261
|
+
"required": ["name"],
|
|
262
|
+
"additionalProperties": false
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"additionalProperties": false
|
|
222
266
|
}
|
|
223
267
|
},
|
|
224
268
|
"additionalProperties": false
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
-
"id": { "type": "string", "enum": ["referralPriceSnapshot"] },
|
|
6
|
+
"id": { "type": "string", "enum": ["referralPriceSnapshot", "aiAgentAppointmentReminder"] },
|
|
7
7
|
"cron": { "type": "string", "minLength": 1 },
|
|
8
8
|
"timezone": { "type": "string" }
|
|
9
9
|
},
|