rapida-partner 4.0.0 → 5.0.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.
|
|
@@ -84,22 +99,40 @@ export interface IAiAgentConfig {
|
|
|
84
99
|
// usually whatsappModule from rapida-projects. Code generation fails
|
|
85
100
|
// without it.
|
|
86
101
|
//
|
|
87
|
-
// The
|
|
88
|
-
//
|
|
89
|
-
// flows.invitation.mainUserEmail and must be provisioned manually on the
|
|
90
|
-
// target backend.
|
|
102
|
+
// The agent authenticates on the backend with a dedicated service user
|
|
103
|
+
// (botCredentials below), separate from flows.invitation.mainUserEmail.
|
|
91
104
|
exposedContracts: IAgentContractBinding[];
|
|
92
105
|
|
|
93
|
-
// Credentials of the
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
|
|
106
|
+
// Credentials of the agent's service user (BOT_API_EMAIL/BOT_API_PASSWORD
|
|
107
|
+
// in the generated agent and backend .env). The generated Nest backend
|
|
108
|
+
// creates this user on startup — idempotently, aligning the password with
|
|
109
|
+
// the .env — inside the workspace of flows.invitation.mainUserEmail, with
|
|
110
|
+
// an "aiAgent" role limited to the entities the agent's tools use. Import
|
|
111
|
+
// the values from constants/secrets — never write them literally.
|
|
112
|
+
botCredentials: {
|
|
98
113
|
email: string;
|
|
99
114
|
password: string;
|
|
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
|
};
|
|
@@ -177,6 +214,15 @@ export interface IAgentContractBinding {
|
|
|
177
214
|
|
|
178
215
|
toolName: string;
|
|
179
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
|
+
|
|
180
226
|
action: "create" | "get" | "getById" | "update" | "softDelete" | "hardDelete";
|
|
181
227
|
|
|
182
228
|
intentMapping: {
|
|
@@ -216,6 +262,6 @@ export interface IHumanHandoffContact {
|
|
|
216
262
|
useCase: string;
|
|
217
263
|
|
|
218
264
|
// E.164 phone number (e.g. "+558296539080") that receives the
|
|
219
|
-
// WhatsApp text message on handoff.
|
|
265
|
+
// WhatsApp text message on handoff. Validated by the schema.
|
|
220
266
|
whatsappPhoneNumber: string;
|
|
221
267
|
}
|
|
@@ -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": [
|
|
@@ -149,17 +157,29 @@
|
|
|
149
157
|
"description": "Credentials of the dedicated bot user on the target backend (BOT_API_EMAIL/BOT_API_PASSWORD in the generated agent .env).",
|
|
150
158
|
"properties": {
|
|
151
159
|
"email": {
|
|
152
|
-
"type": "string"
|
|
160
|
+
"type": "string",
|
|
161
|
+
"minLength": 3
|
|
153
162
|
},
|
|
154
163
|
"password": {
|
|
155
|
-
"type": "string"
|
|
164
|
+
"type": "string",
|
|
165
|
+
"minLength": 8
|
|
156
166
|
}
|
|
157
167
|
},
|
|
158
168
|
"required": ["email", "password"],
|
|
159
169
|
"additionalProperties": false
|
|
160
170
|
}
|
|
161
171
|
},
|
|
162
|
-
"required": ["
|
|
172
|
+
"required": ["exposedContracts", "botCredentials"],
|
|
173
|
+
"additionalProperties": false
|
|
174
|
+
},
|
|
175
|
+
"capabilities": {
|
|
176
|
+
"type": "object",
|
|
177
|
+
"properties": {
|
|
178
|
+
"identity": { "type": "boolean" },
|
|
179
|
+
"scheduling": { "type": "boolean" },
|
|
180
|
+
"knowledgeBase": { "type": "boolean" },
|
|
181
|
+
"media": { "type": "boolean" }
|
|
182
|
+
},
|
|
163
183
|
"additionalProperties": false
|
|
164
184
|
},
|
|
165
185
|
"humanHandoff": {
|
|
@@ -177,7 +197,8 @@
|
|
|
177
197
|
"type": "string"
|
|
178
198
|
},
|
|
179
199
|
"whatsappPhoneNumber": {
|
|
180
|
-
"type": "string"
|
|
200
|
+
"type": "string",
|
|
201
|
+
"pattern": "^\\+[1-9][0-9]{7,14}$"
|
|
181
202
|
}
|
|
182
203
|
},
|
|
183
204
|
"required": ["name", "useCase", "whatsappPhoneNumber"],
|