rapida-partner 4.0.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapida-partner",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "index.ts",
6
6
  "files": [
@@ -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 (e.g.
22
- // "data/knowledge.md").
23
- knowledgeBaseFile: string;
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
- targetBackendProjectId: string;
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
- // always ships fixed tools (identity + appointment/agenda + knowledge
70
- // base) that hit hardcoded endpoints (/people, /appointments,
71
- // /availability-schedules) regardless of what is declared here — do not
72
- // redeclare a binding with the same toolName as a fixed tool
73
- // (cadastrar_usuario, atualizar_status_usuario, atualizar_telefone_usuario,
74
- // atualizar_email_usuario, atualizar_genero_usuario, checar_disponibilidade,
75
- // criar_evento, meus_agendamentos, cancelar_agendamento,
76
- // consultar_base_conhecimento). Also note: for "update"/"getById"/
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
  };
@@ -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", "knowledgeBaseFile"],
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": ["targetBackendProjectId", "exposedContracts"],
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"],