evo360-types 1.3.353 → 1.3.355
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/dist/apps/evo-chat/chatbee/zod-schemas.d.ts +1080 -0
- package/dist/apps/evo-chat/chatbee/zod-schemas.js +73 -1
- package/dist/apps/evo-chat/chatbee/zod-schemas.ts +80 -0
- package/dist/apps/evo-hub-ia/v1/adapter-tool-registry.d.ts +46 -0
- package/dist/apps/evo-hub-ia/v1/adapter-tool-registry.js +16 -0
- package/dist/apps/evo-hub-ia/v1/adapter-tool-registry.ts +55 -0
- package/dist/apps/evo-hub-ia/v1/zod-schemas.d.ts +452 -6
- package/dist/apps/evo-hub-ia/v1/zod-schemas.js +70 -2
- package/dist/apps/evo-hub-ia/v1/zod-schemas.ts +77 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zSendMessageResponseSchema = exports.zSendMessageRequestSchema = exports.zSendTemplateMessageRequestSchema = exports.zSendTextMessageRequestSchema = exports.zTemplateHeaderMediaSchema = exports.zTemplateButtonPayloadSchema = exports.zTemplateVariableSchema = exports.zChatbeeContactHistorySchema = exports.zChatbeeContactHistoryPayloadClosedSchema = exports.zChatbeeContactHistoryPayloadCreatedSchema = exports.zChatbeeContactSchema = exports.zChatbeeStatusSchema = exports.zChatbeeDepartmentSchema = exports.zChatbeeChannelSchema = exports.zChatBeeChannelConfigSchema = void 0;
|
|
3
|
+
exports.zChatbeeNormalizedMessageSchema = exports.zChatbeeNormalizedInnerMessageSchema = exports.zChatbeeNormalizedMediaSchema = exports.zSendMessageResponseSchema = exports.zSendMessageRequestSchema = exports.zSendTemplateMessageRequestSchema = exports.zSendTextMessageRequestSchema = exports.zTemplateHeaderMediaSchema = exports.zTemplateButtonPayloadSchema = exports.zTemplateVariableSchema = exports.zChatbeeContactHistorySchema = exports.zChatbeeContactHistoryPayloadClosedSchema = exports.zChatbeeContactHistoryPayloadCreatedSchema = exports.zChatbeeContactSchema = exports.zChatbeeStatusSchema = exports.zChatbeeDepartmentSchema = exports.zChatbeeChannelSchema = exports.zChatBeeChannelConfigSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const zod_schemas_1 = require("../../shared/zod-schemas");
|
|
6
6
|
const zod_schemas_2 = require("../../evo-hub-ia/channel/zod-schemas");
|
|
@@ -147,3 +147,75 @@ exports.zSendMessageResponseSchema = zod_1.z.object({
|
|
|
147
147
|
message_id: zod_1.z.string().optional(),
|
|
148
148
|
data: zod_1.z.any().optional(),
|
|
149
149
|
});
|
|
150
|
+
// ───────── ChatBee Normalized Message (input do tópico chatbee-messages-normalized) ─────────
|
|
151
|
+
//
|
|
152
|
+
// Publisher: Cloud Run `message-normalizer` em google-chat-functions/.
|
|
153
|
+
// Consumer atual: BQ sink (`hr-evo360.chatbee.msgs_raw`).
|
|
154
|
+
// Consumer futuro (S4): adapter `chatbee_inbound_to_hubia` em functions-chatbee.
|
|
155
|
+
//
|
|
156
|
+
// Validação confirmada com 12 amostras reais lidas do BQ em 2026-05-05.
|
|
157
|
+
/** Tipo da mídia do Chatbee (se message.type !== 'text'). */
|
|
158
|
+
exports.zChatbeeNormalizedMediaSchema = zod_1.z.object({
|
|
159
|
+
/** Bucket GCS onde o normalizer reuploadou a mídia. Confirmado em prod: `hr-evo360-evo-chat`. */
|
|
160
|
+
bucket: zod_1.z.string(),
|
|
161
|
+
/** Path no bucket (ex.: `tenants/{tenant}/{channel_uuid}/{contact_id}/document_{msg_id}.pdf`). */
|
|
162
|
+
path: zod_1.z.string(),
|
|
163
|
+
type: zod_1.z.string(),
|
|
164
|
+
}).passthrough();
|
|
165
|
+
/** Inner message do payload Chatbee normalizado. */
|
|
166
|
+
exports.zChatbeeNormalizedInnerMessageSchema = zod_1.z.object({
|
|
167
|
+
/** ID Chatbee da mensagem (ex.: "249199900"). String mas formato numérico. */
|
|
168
|
+
id: zod_1.z.string(),
|
|
169
|
+
/** Texto OU URL signed do GCS para mídia. */
|
|
170
|
+
content: zod_1.z.string().default(""),
|
|
171
|
+
/** Direção semântica do payload. FILTRO ESSENCIAL no adapter — 'out' = eco. */
|
|
172
|
+
event: zod_1.z.enum(["in", "out"]),
|
|
173
|
+
type: zod_1.z.enum([
|
|
174
|
+
"text",
|
|
175
|
+
"audio",
|
|
176
|
+
"image",
|
|
177
|
+
"document",
|
|
178
|
+
"template",
|
|
179
|
+
"ptt",
|
|
180
|
+
"sticker",
|
|
181
|
+
"story_mention",
|
|
182
|
+
"video",
|
|
183
|
+
"vcard",
|
|
184
|
+
]),
|
|
185
|
+
media: exports.zChatbeeNormalizedMediaSchema.optional(),
|
|
186
|
+
}).passthrough();
|
|
187
|
+
/** Mensagem completa publicada no tópico `chatbee-messages-normalized`. */
|
|
188
|
+
exports.zChatbeeNormalizedMessageSchema = zod_1.z.object({
|
|
189
|
+
type: zod_1.z.literal("MESSAGE"),
|
|
190
|
+
channel: zod_1.z.object({
|
|
191
|
+
/** ID Chatbee — INTEGER em origem, mas castado para STRING na borda do adapter (DA-4). */
|
|
192
|
+
id: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).transform(v => String(v)),
|
|
193
|
+
/** Tenant slug — premissa P6 confiável (drabanzoli, clinica-moema, ...). */
|
|
194
|
+
external_id: zod_1.z.string(),
|
|
195
|
+
name: zod_1.z.string().optional(),
|
|
196
|
+
}).passthrough(),
|
|
197
|
+
contact: zod_1.z.object({
|
|
198
|
+
id: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).transform(v => String(v)),
|
|
199
|
+
name: zod_1.z.string().optional().default(""),
|
|
200
|
+
address: zod_1.z.string().optional().default(""),
|
|
201
|
+
type: zod_1.z.string().optional(),
|
|
202
|
+
external_id: zod_1.z.string().nullable().optional(),
|
|
203
|
+
is_group: zod_1.z.boolean().optional(),
|
|
204
|
+
}).passthrough(),
|
|
205
|
+
history: zod_1.z.object({
|
|
206
|
+
id: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).transform(v => String(v)),
|
|
207
|
+
channel_id: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).transform(v => String(v)),
|
|
208
|
+
is_out_of_office_hours: zod_1.z.boolean().optional(),
|
|
209
|
+
automatic: zod_1.z.boolean().optional(),
|
|
210
|
+
}).passthrough().optional(),
|
|
211
|
+
/** Populado quando operador humano envia (event=out + user.id) — sinal de presença para handoff (DA-10). */
|
|
212
|
+
user: zod_1.z.object({
|
|
213
|
+
id: zod_1.z.union([zod_1.z.number(), zod_1.z.string()]).transform(v => String(v)),
|
|
214
|
+
name: zod_1.z.string().optional(),
|
|
215
|
+
external_id: zod_1.z.string().nullable().optional(),
|
|
216
|
+
}).passthrough().optional(),
|
|
217
|
+
payload: zod_1.z.object({
|
|
218
|
+
message: exports.zChatbeeNormalizedInnerMessageSchema,
|
|
219
|
+
}).passthrough(),
|
|
220
|
+
timestamp: zod_1.z.string().optional(),
|
|
221
|
+
}).passthrough();
|
|
@@ -157,3 +157,83 @@ export const zSendMessageResponseSchema = z.object({
|
|
|
157
157
|
message_id: z.string().optional(),
|
|
158
158
|
data: z.any().optional(),
|
|
159
159
|
});
|
|
160
|
+
|
|
161
|
+
// ───────── ChatBee Normalized Message (input do tópico chatbee-messages-normalized) ─────────
|
|
162
|
+
//
|
|
163
|
+
// Publisher: Cloud Run `message-normalizer` em google-chat-functions/.
|
|
164
|
+
// Consumer atual: BQ sink (`hr-evo360.chatbee.msgs_raw`).
|
|
165
|
+
// Consumer futuro (S4): adapter `chatbee_inbound_to_hubia` em functions-chatbee.
|
|
166
|
+
//
|
|
167
|
+
// Validação confirmada com 12 amostras reais lidas do BQ em 2026-05-05.
|
|
168
|
+
|
|
169
|
+
/** Tipo da mídia do Chatbee (se message.type !== 'text'). */
|
|
170
|
+
export const zChatbeeNormalizedMediaSchema = z.object({
|
|
171
|
+
/** Bucket GCS onde o normalizer reuploadou a mídia. Confirmado em prod: `hr-evo360-evo-chat`. */
|
|
172
|
+
bucket: z.string(),
|
|
173
|
+
/** Path no bucket (ex.: `tenants/{tenant}/{channel_uuid}/{contact_id}/document_{msg_id}.pdf`). */
|
|
174
|
+
path: z.string(),
|
|
175
|
+
type: z.string(),
|
|
176
|
+
}).passthrough();
|
|
177
|
+
|
|
178
|
+
/** Inner message do payload Chatbee normalizado. */
|
|
179
|
+
export const zChatbeeNormalizedInnerMessageSchema = z.object({
|
|
180
|
+
/** ID Chatbee da mensagem (ex.: "249199900"). String mas formato numérico. */
|
|
181
|
+
id: z.string(),
|
|
182
|
+
/** Texto OU URL signed do GCS para mídia. */
|
|
183
|
+
content: z.string().default(""),
|
|
184
|
+
/** Direção semântica do payload. FILTRO ESSENCIAL no adapter — 'out' = eco. */
|
|
185
|
+
event: z.enum(["in", "out"]),
|
|
186
|
+
type: z.enum([
|
|
187
|
+
"text",
|
|
188
|
+
"audio",
|
|
189
|
+
"image",
|
|
190
|
+
"document",
|
|
191
|
+
"template",
|
|
192
|
+
"ptt",
|
|
193
|
+
"sticker",
|
|
194
|
+
"story_mention",
|
|
195
|
+
"video",
|
|
196
|
+
"vcard",
|
|
197
|
+
]),
|
|
198
|
+
media: zChatbeeNormalizedMediaSchema.optional(),
|
|
199
|
+
}).passthrough();
|
|
200
|
+
|
|
201
|
+
/** Mensagem completa publicada no tópico `chatbee-messages-normalized`. */
|
|
202
|
+
export const zChatbeeNormalizedMessageSchema = z.object({
|
|
203
|
+
type: z.literal("MESSAGE"),
|
|
204
|
+
channel: z.object({
|
|
205
|
+
/** ID Chatbee — INTEGER em origem, mas castado para STRING na borda do adapter (DA-4). */
|
|
206
|
+
id: z.union([z.number(), z.string()]).transform(v => String(v)),
|
|
207
|
+
/** Tenant slug — premissa P6 confiável (drabanzoli, clinica-moema, ...). */
|
|
208
|
+
external_id: z.string(),
|
|
209
|
+
name: z.string().optional(),
|
|
210
|
+
}).passthrough(),
|
|
211
|
+
contact: z.object({
|
|
212
|
+
id: z.union([z.number(), z.string()]).transform(v => String(v)),
|
|
213
|
+
name: z.string().optional().default(""),
|
|
214
|
+
address: z.string().optional().default(""),
|
|
215
|
+
type: z.string().optional(),
|
|
216
|
+
external_id: z.string().nullable().optional(),
|
|
217
|
+
is_group: z.boolean().optional(),
|
|
218
|
+
}).passthrough(),
|
|
219
|
+
history: z.object({
|
|
220
|
+
id: z.union([z.number(), z.string()]).transform(v => String(v)),
|
|
221
|
+
channel_id: z.union([z.number(), z.string()]).transform(v => String(v)),
|
|
222
|
+
is_out_of_office_hours: z.boolean().optional(),
|
|
223
|
+
automatic: z.boolean().optional(),
|
|
224
|
+
}).passthrough().optional(),
|
|
225
|
+
/** Populado quando operador humano envia (event=out + user.id) — sinal de presença para handoff (DA-10). */
|
|
226
|
+
user: z.object({
|
|
227
|
+
id: z.union([z.number(), z.string()]).transform(v => String(v)),
|
|
228
|
+
name: z.string().optional(),
|
|
229
|
+
external_id: z.string().nullable().optional(),
|
|
230
|
+
}).passthrough().optional(),
|
|
231
|
+
payload: z.object({
|
|
232
|
+
message: zChatbeeNormalizedInnerMessageSchema,
|
|
233
|
+
}).passthrough(),
|
|
234
|
+
timestamp: z.string().optional(),
|
|
235
|
+
}).passthrough();
|
|
236
|
+
|
|
237
|
+
export type IChatbeeNormalizedMessage = z.infer<typeof zChatbeeNormalizedMessageSchema>;
|
|
238
|
+
export type IChatbeeNormalizedInnerMessage = z.infer<typeof zChatbeeNormalizedInnerMessageSchema>;
|
|
239
|
+
export type IChatbeeNormalizedMedia = z.infer<typeof zChatbeeNormalizedMediaSchema>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Tool Registry — DA-7 do plano hubia-chatbee.
|
|
3
|
+
*
|
|
4
|
+
* Tools com mesmo schema podem ter executores diferentes por provider:
|
|
5
|
+
* - handoff_to_human (hub-waba escreve ticket v3; chatbee escreve em conversations/{X}.mode)
|
|
6
|
+
* - transfer_to_department (idem)
|
|
7
|
+
* - get_conversation_history (hub-waba lê threads v3; chatbee lê apps/evo-chatbee-adapter)
|
|
8
|
+
*
|
|
9
|
+
* Tools shared (get_lead, get_contact, schedule_*, etc.) operam em coleções neutras
|
|
10
|
+
* (evo-people, evo-crm, evo-cale) e ficam fora do registry — são sempre disponíveis.
|
|
11
|
+
*
|
|
12
|
+
* Interfaces puramente TS (não-zod) — executors são funções callable em runtime,
|
|
13
|
+
* não há shape estável para validação JSON.
|
|
14
|
+
*/
|
|
15
|
+
import type { IHubiaV1ChannelConfig } from "./zod-schemas";
|
|
16
|
+
export type IAdapterProvider = "chatbee" | "hub-waba";
|
|
17
|
+
export interface IAdapterToolDefinition {
|
|
18
|
+
/** Nome da tool conforme exposto ao Claude. Mesma string para tools compartilháveis entre adapters. */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Descrição em inglês ou pt-BR — visível para o LLM. */
|
|
21
|
+
description: string;
|
|
22
|
+
/** JSON Schema Anthropic-compatible (objeto, properties, required, ...). */
|
|
23
|
+
input_schema: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface IToolExecutionContext {
|
|
26
|
+
tenant: string;
|
|
27
|
+
/** ID da conversation v3 (hub-waba) ou cb_<contactId> (chatbee). */
|
|
28
|
+
conversationId?: string;
|
|
29
|
+
contactId?: string;
|
|
30
|
+
channelId?: string;
|
|
31
|
+
threadId?: string;
|
|
32
|
+
ticketId?: string;
|
|
33
|
+
executionId?: string;
|
|
34
|
+
/** Snapshot da config hubia do canal — útil para tools provider-aware. */
|
|
35
|
+
cfg?: Partial<IHubiaV1ChannelConfig>;
|
|
36
|
+
}
|
|
37
|
+
export interface IToolExecutor {
|
|
38
|
+
execute(input: Record<string, unknown>, ctx: IToolExecutionContext): Promise<unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface IAdapterToolRegistry {
|
|
41
|
+
provider: IAdapterProvider;
|
|
42
|
+
/** Tools provider-specific definidas neste adapter. */
|
|
43
|
+
tools: IAdapterToolDefinition[];
|
|
44
|
+
/** Executores indexados por `tool.name`. */
|
|
45
|
+
executors: Record<string, IToolExecutor>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Adapter Tool Registry — DA-7 do plano hubia-chatbee.
|
|
4
|
+
*
|
|
5
|
+
* Tools com mesmo schema podem ter executores diferentes por provider:
|
|
6
|
+
* - handoff_to_human (hub-waba escreve ticket v3; chatbee escreve em conversations/{X}.mode)
|
|
7
|
+
* - transfer_to_department (idem)
|
|
8
|
+
* - get_conversation_history (hub-waba lê threads v3; chatbee lê apps/evo-chatbee-adapter)
|
|
9
|
+
*
|
|
10
|
+
* Tools shared (get_lead, get_contact, schedule_*, etc.) operam em coleções neutras
|
|
11
|
+
* (evo-people, evo-crm, evo-cale) e ficam fora do registry — são sempre disponíveis.
|
|
12
|
+
*
|
|
13
|
+
* Interfaces puramente TS (não-zod) — executors são funções callable em runtime,
|
|
14
|
+
* não há shape estável para validação JSON.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Tool Registry — DA-7 do plano hubia-chatbee.
|
|
3
|
+
*
|
|
4
|
+
* Tools com mesmo schema podem ter executores diferentes por provider:
|
|
5
|
+
* - handoff_to_human (hub-waba escreve ticket v3; chatbee escreve em conversations/{X}.mode)
|
|
6
|
+
* - transfer_to_department (idem)
|
|
7
|
+
* - get_conversation_history (hub-waba lê threads v3; chatbee lê apps/evo-chatbee-adapter)
|
|
8
|
+
*
|
|
9
|
+
* Tools shared (get_lead, get_contact, schedule_*, etc.) operam em coleções neutras
|
|
10
|
+
* (evo-people, evo-crm, evo-cale) e ficam fora do registry — são sempre disponíveis.
|
|
11
|
+
*
|
|
12
|
+
* Interfaces puramente TS (não-zod) — executors são funções callable em runtime,
|
|
13
|
+
* não há shape estável para validação JSON.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { IHubiaV1ChannelConfig } from "./zod-schemas";
|
|
17
|
+
|
|
18
|
+
export type IAdapterProvider = "chatbee" | "hub-waba";
|
|
19
|
+
|
|
20
|
+
export interface IAdapterToolDefinition {
|
|
21
|
+
/** Nome da tool conforme exposto ao Claude. Mesma string para tools compartilháveis entre adapters. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Descrição em inglês ou pt-BR — visível para o LLM. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** JSON Schema Anthropic-compatible (objeto, properties, required, ...). */
|
|
26
|
+
input_schema: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IToolExecutionContext {
|
|
30
|
+
tenant: string;
|
|
31
|
+
/** ID da conversation v3 (hub-waba) ou cb_<contactId> (chatbee). */
|
|
32
|
+
conversationId?: string;
|
|
33
|
+
contactId?: string;
|
|
34
|
+
channelId?: string;
|
|
35
|
+
threadId?: string;
|
|
36
|
+
ticketId?: string;
|
|
37
|
+
executionId?: string;
|
|
38
|
+
/** Snapshot da config hubia do canal — útil para tools provider-aware. */
|
|
39
|
+
cfg?: Partial<IHubiaV1ChannelConfig>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface IToolExecutor {
|
|
43
|
+
execute(
|
|
44
|
+
input: Record<string, unknown>,
|
|
45
|
+
ctx: IToolExecutionContext,
|
|
46
|
+
): Promise<unknown>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IAdapterToolRegistry {
|
|
50
|
+
provider: IAdapterProvider;
|
|
51
|
+
/** Tools provider-specific definidas neste adapter. */
|
|
52
|
+
tools: IAdapterToolDefinition[];
|
|
53
|
+
/** Executores indexados por `tool.name`. */
|
|
54
|
+
executors: Record<string, IToolExecutor>;
|
|
55
|
+
}
|