evo360-types 1.3.775 → 1.3.780

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 (35) hide show
  1. package/dist/apps/evo-chat/waba-template/zod-schemas.d.ts +161 -0
  2. package/dist/apps/evo-chat/waba-template/zod-schemas.js +18 -1
  3. package/dist/apps/evo-chat/waba-template/zod-schemas.ts +19 -1
  4. package/dist/apps/evo-core/zod-schemas.d.ts +23 -0
  5. package/dist/apps/evo-core/zod-schemas.js +1 -0
  6. package/dist/apps/evo-core/zod-schemas.ts +1 -0
  7. package/dist/apps/evo-hub-ia/workflows/zod-schemas.d.ts +550 -0
  8. package/dist/apps/evo-hub-ia/workflows/zod-schemas.js +127 -0
  9. package/dist/apps/evo-hub-ia/workflows/zod-schemas.ts +150 -0
  10. package/dist/apps/evo-tenant/zod-schemas.d.ts +2 -2
  11. package/dist/apps/shared/zod-schemas.d.ts +88 -0
  12. package/dist/apps/shared/zod-schemas.js +36 -1
  13. package/dist/apps/shared/zod-schemas.ts +42 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/index.ts +1 -0
  17. package/dist/types/evo-chat/index.d.ts +2 -0
  18. package/dist/types/evo-chat/index.js +2 -0
  19. package/dist/types/evo-chat/index.ts +2 -0
  20. package/dist/types/evo-core/index.d.ts +2 -0
  21. package/dist/types/evo-core/index.ts +2 -0
  22. package/dist/types/evo-emr/index.d.ts +0 -5
  23. package/dist/types/evo-emr/index.js +6 -10
  24. package/dist/types/evo-emr/index.ts +5 -10
  25. package/dist/types/evo-notifications/index.d.ts +6 -2
  26. package/dist/types/evo-notifications/index.ts +6 -2
  27. package/dist/types/evo-reports/index.d.ts +2 -1
  28. package/dist/types/evo-reports/index.ts +3 -1
  29. package/dist/types/shared/index.d.ts +1 -0
  30. package/dist/types/shared/index.js +1 -0
  31. package/dist/types/shared/index.ts +1 -0
  32. package/dist/types/shared/template-profile.d.ts +41 -0
  33. package/dist/types/shared/template-profile.js +25 -0
  34. package/dist/types/shared/template-profile.ts +57 -0
  35. package/package.json +1 -1
@@ -0,0 +1,550 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * feat-324 — workflows n8n acionados pela HubIA (LLM), pela equipe no Omni
4
+ * (manual) ou pela aprovação de uma proposta do modo híbrido.
5
+ *
6
+ * - Catálogo (plataforma): `/platform/evo-hubia-workflows/workflows/{id}`.
7
+ * - Habilitação (tenant): `tenants/{t}/apps/evo-hubia-v1/workflows/{id}` (id = id do workflow).
8
+ * - Protocolo: `hubia-workflow/1` (envelope + resposta abaixo), assinado por JWT HS256
9
+ * com claim `body_sha256`.
10
+ */
11
+ export declare const HUBIA_WORKFLOWS_PLATFORM_DOC = "evo-hubia-workflows";
12
+ export declare const HUBIA_WORKFLOWS_COLLECTION = "workflows";
13
+ export declare const HUBIA_WORKFLOW_PROTOCOL = "hubia-workflow/1";
14
+ export declare const HUBIA_WORKFLOW_MAX_TIMEOUT_MS = 30000;
15
+ export declare const zHubiaWorkflowCodeSchema: z.ZodString;
16
+ export declare const zHubiaWorkflowParamTypeSchema: z.ZodEnum<["string", "number", "boolean", "date", "enum"]>;
17
+ export declare const zHubiaWorkflowParamSchema: z.ZodEffects<z.ZodObject<{
18
+ name: z.ZodString;
19
+ /** Rótulo do campo no diálogo manual do Omni. */
20
+ label: z.ZodString;
21
+ type: z.ZodEnum<["string", "number", "boolean", "date", "enum"]>;
22
+ required: z.ZodDefault<z.ZodBoolean>;
23
+ /** Como o LLM deve preencher o campo (HubIA no turno e pré-preenchimento do diálogo). */
24
+ description: z.ZodString;
25
+ enum_values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ name: string;
28
+ type: "string" | "number" | "boolean" | "date" | "enum";
29
+ label: string;
30
+ required: boolean;
31
+ description: string;
32
+ enum_values?: string[] | undefined;
33
+ }, {
34
+ name: string;
35
+ type: "string" | "number" | "boolean" | "date" | "enum";
36
+ label: string;
37
+ description: string;
38
+ required?: boolean | undefined;
39
+ enum_values?: string[] | undefined;
40
+ }>, {
41
+ name: string;
42
+ type: "string" | "number" | "boolean" | "date" | "enum";
43
+ label: string;
44
+ required: boolean;
45
+ description: string;
46
+ enum_values?: string[] | undefined;
47
+ }, {
48
+ name: string;
49
+ type: "string" | "number" | "boolean" | "date" | "enum";
50
+ label: string;
51
+ description: string;
52
+ required?: boolean | undefined;
53
+ enum_values?: string[] | undefined;
54
+ }>;
55
+ export declare const zHubiaWorkflowModeSchema: z.ZodEnum<["ai_only", "hybrid_assist"]>;
56
+ export declare const zHubiaWorkflowInvocationSchema: z.ZodEffects<z.ZodObject<{
57
+ /** A IA pode acionar (aparece no catálogo do prompt). */
58
+ llm: z.ZodBoolean;
59
+ /** A equipe pode acionar pelo botão "Workflows" do Omni. */
60
+ manual: z.ZodBoolean;
61
+ }, "strip", z.ZodTypeAny, {
62
+ manual: boolean;
63
+ llm: boolean;
64
+ }, {
65
+ manual: boolean;
66
+ llm: boolean;
67
+ }>, {
68
+ manual: boolean;
69
+ llm: boolean;
70
+ }, {
71
+ manual: boolean;
72
+ llm: boolean;
73
+ }>;
74
+ /** Campos editáveis no Nexus (o servidor cuida de version/auditoria). */
75
+ export declare const zHubiaWorkflowInputSchema: z.ZodObject<{
76
+ code: z.ZodString;
77
+ name: z.ZodString;
78
+ status: z.ZodEnum<["active", "inactive"]>;
79
+ llm_instructions: z.ZodString;
80
+ input_schema: z.ZodArray<z.ZodEffects<z.ZodObject<{
81
+ name: z.ZodString;
82
+ /** Rótulo do campo no diálogo manual do Omni. */
83
+ label: z.ZodString;
84
+ type: z.ZodEnum<["string", "number", "boolean", "date", "enum"]>;
85
+ required: z.ZodDefault<z.ZodBoolean>;
86
+ /** Como o LLM deve preencher o campo (HubIA no turno e pré-preenchimento do diálogo). */
87
+ description: z.ZodString;
88
+ enum_values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ name: string;
91
+ type: "string" | "number" | "boolean" | "date" | "enum";
92
+ label: string;
93
+ required: boolean;
94
+ description: string;
95
+ enum_values?: string[] | undefined;
96
+ }, {
97
+ name: string;
98
+ type: "string" | "number" | "boolean" | "date" | "enum";
99
+ label: string;
100
+ description: string;
101
+ required?: boolean | undefined;
102
+ enum_values?: string[] | undefined;
103
+ }>, {
104
+ name: string;
105
+ type: "string" | "number" | "boolean" | "date" | "enum";
106
+ label: string;
107
+ required: boolean;
108
+ description: string;
109
+ enum_values?: string[] | undefined;
110
+ }, {
111
+ name: string;
112
+ type: "string" | "number" | "boolean" | "date" | "enum";
113
+ label: string;
114
+ description: string;
115
+ required?: boolean | undefined;
116
+ enum_values?: string[] | undefined;
117
+ }>, "many">;
118
+ output_hint: z.ZodDefault<z.ZodString>;
119
+ kind: z.ZodEnum<["read", "action"]>;
120
+ invocation: z.ZodEffects<z.ZodObject<{
121
+ /** A IA pode acionar (aparece no catálogo do prompt). */
122
+ llm: z.ZodBoolean;
123
+ /** A equipe pode acionar pelo botão "Workflows" do Omni. */
124
+ manual: z.ZodBoolean;
125
+ }, "strip", z.ZodTypeAny, {
126
+ manual: boolean;
127
+ llm: boolean;
128
+ }, {
129
+ manual: boolean;
130
+ llm: boolean;
131
+ }>, {
132
+ manual: boolean;
133
+ llm: boolean;
134
+ }, {
135
+ manual: boolean;
136
+ llm: boolean;
137
+ }>;
138
+ allowed_modes: z.ZodArray<z.ZodEnum<["ai_only", "hybrid_assist"]>, "many">;
139
+ /** Híbrido: `execute` roda direto (resultado entra na sugestão); `propose` só sugere a execução. */
140
+ hybrid_behavior: z.ZodEnum<["execute", "propose"]>;
141
+ timeout_ms: z.ZodNumber;
142
+ endpoint_url: z.ZodString;
143
+ }, "strip", z.ZodTypeAny, {
144
+ code: string;
145
+ name: string;
146
+ kind: "read" | "action";
147
+ status: "active" | "inactive";
148
+ timeout_ms: number;
149
+ llm_instructions: string;
150
+ input_schema: {
151
+ name: string;
152
+ type: "string" | "number" | "boolean" | "date" | "enum";
153
+ label: string;
154
+ required: boolean;
155
+ description: string;
156
+ enum_values?: string[] | undefined;
157
+ }[];
158
+ output_hint: string;
159
+ invocation: {
160
+ manual: boolean;
161
+ llm: boolean;
162
+ };
163
+ allowed_modes: ("ai_only" | "hybrid_assist")[];
164
+ hybrid_behavior: "execute" | "propose";
165
+ endpoint_url: string;
166
+ }, {
167
+ code: string;
168
+ name: string;
169
+ kind: "read" | "action";
170
+ status: "active" | "inactive";
171
+ timeout_ms: number;
172
+ llm_instructions: string;
173
+ input_schema: {
174
+ name: string;
175
+ type: "string" | "number" | "boolean" | "date" | "enum";
176
+ label: string;
177
+ description: string;
178
+ required?: boolean | undefined;
179
+ enum_values?: string[] | undefined;
180
+ }[];
181
+ invocation: {
182
+ manual: boolean;
183
+ llm: boolean;
184
+ };
185
+ allowed_modes: ("ai_only" | "hybrid_assist")[];
186
+ hybrid_behavior: "execute" | "propose";
187
+ endpoint_url: string;
188
+ output_hint?: string | undefined;
189
+ }>;
190
+ export declare const zHubiaWorkflowDocSchema: z.ZodObject<{
191
+ code: z.ZodString;
192
+ name: z.ZodString;
193
+ status: z.ZodEnum<["active", "inactive"]>;
194
+ llm_instructions: z.ZodString;
195
+ input_schema: z.ZodArray<z.ZodEffects<z.ZodObject<{
196
+ name: z.ZodString;
197
+ /** Rótulo do campo no diálogo manual do Omni. */
198
+ label: z.ZodString;
199
+ type: z.ZodEnum<["string", "number", "boolean", "date", "enum"]>;
200
+ required: z.ZodDefault<z.ZodBoolean>;
201
+ /** Como o LLM deve preencher o campo (HubIA no turno e pré-preenchimento do diálogo). */
202
+ description: z.ZodString;
203
+ enum_values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
204
+ }, "strip", z.ZodTypeAny, {
205
+ name: string;
206
+ type: "string" | "number" | "boolean" | "date" | "enum";
207
+ label: string;
208
+ required: boolean;
209
+ description: string;
210
+ enum_values?: string[] | undefined;
211
+ }, {
212
+ name: string;
213
+ type: "string" | "number" | "boolean" | "date" | "enum";
214
+ label: string;
215
+ description: string;
216
+ required?: boolean | undefined;
217
+ enum_values?: string[] | undefined;
218
+ }>, {
219
+ name: string;
220
+ type: "string" | "number" | "boolean" | "date" | "enum";
221
+ label: string;
222
+ required: boolean;
223
+ description: string;
224
+ enum_values?: string[] | undefined;
225
+ }, {
226
+ name: string;
227
+ type: "string" | "number" | "boolean" | "date" | "enum";
228
+ label: string;
229
+ description: string;
230
+ required?: boolean | undefined;
231
+ enum_values?: string[] | undefined;
232
+ }>, "many">;
233
+ output_hint: z.ZodDefault<z.ZodString>;
234
+ kind: z.ZodEnum<["read", "action"]>;
235
+ invocation: z.ZodEffects<z.ZodObject<{
236
+ /** A IA pode acionar (aparece no catálogo do prompt). */
237
+ llm: z.ZodBoolean;
238
+ /** A equipe pode acionar pelo botão "Workflows" do Omni. */
239
+ manual: z.ZodBoolean;
240
+ }, "strip", z.ZodTypeAny, {
241
+ manual: boolean;
242
+ llm: boolean;
243
+ }, {
244
+ manual: boolean;
245
+ llm: boolean;
246
+ }>, {
247
+ manual: boolean;
248
+ llm: boolean;
249
+ }, {
250
+ manual: boolean;
251
+ llm: boolean;
252
+ }>;
253
+ allowed_modes: z.ZodArray<z.ZodEnum<["ai_only", "hybrid_assist"]>, "many">;
254
+ /** Híbrido: `execute` roda direto (resultado entra na sugestão); `propose` só sugere a execução. */
255
+ hybrid_behavior: z.ZodEnum<["execute", "propose"]>;
256
+ timeout_ms: z.ZodNumber;
257
+ endpoint_url: z.ZodString;
258
+ } & {
259
+ id: z.ZodString;
260
+ version: z.ZodNumber;
261
+ /** Nome do segredo no Secret Manager (`hubia-workflow-<code>`). */
262
+ secret_name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
263
+ model_ver: z.ZodDefault<z.ZodNumber>;
264
+ created_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
265
+ created_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
266
+ updated_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
267
+ updated_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
268
+ deleted_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
269
+ }, "strip", z.ZodTypeAny, {
270
+ code: string;
271
+ name: string;
272
+ id: string;
273
+ kind: "read" | "action";
274
+ status: "active" | "inactive";
275
+ model_ver: number;
276
+ version: number;
277
+ timeout_ms: number;
278
+ llm_instructions: string;
279
+ input_schema: {
280
+ name: string;
281
+ type: "string" | "number" | "boolean" | "date" | "enum";
282
+ label: string;
283
+ required: boolean;
284
+ description: string;
285
+ enum_values?: string[] | undefined;
286
+ }[];
287
+ output_hint: string;
288
+ invocation: {
289
+ manual: boolean;
290
+ llm: boolean;
291
+ };
292
+ allowed_modes: ("ai_only" | "hybrid_assist")[];
293
+ hybrid_behavior: "execute" | "propose";
294
+ endpoint_url: string;
295
+ secret_name: string | null;
296
+ created_by?: string | null | undefined;
297
+ created_at?: Date | null | undefined;
298
+ updated_at?: Date | null | undefined;
299
+ deleted_at?: Date | null | undefined;
300
+ updated_by?: string | null | undefined;
301
+ }, {
302
+ code: string;
303
+ name: string;
304
+ id: string;
305
+ kind: "read" | "action";
306
+ status: "active" | "inactive";
307
+ version: number;
308
+ timeout_ms: number;
309
+ llm_instructions: string;
310
+ input_schema: {
311
+ name: string;
312
+ type: "string" | "number" | "boolean" | "date" | "enum";
313
+ label: string;
314
+ description: string;
315
+ required?: boolean | undefined;
316
+ enum_values?: string[] | undefined;
317
+ }[];
318
+ invocation: {
319
+ manual: boolean;
320
+ llm: boolean;
321
+ };
322
+ allowed_modes: ("ai_only" | "hybrid_assist")[];
323
+ hybrid_behavior: "execute" | "propose";
324
+ endpoint_url: string;
325
+ created_by?: string | null | undefined;
326
+ created_at?: Date | null | undefined;
327
+ model_ver?: number | undefined;
328
+ updated_at?: Date | null | undefined;
329
+ deleted_at?: Date | null | undefined;
330
+ updated_by?: string | null | undefined;
331
+ output_hint?: string | undefined;
332
+ secret_name?: string | null | undefined;
333
+ }>;
334
+ export declare const zHubiaWorkflowTenantParamValueSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>;
335
+ export declare const zHubiaWorkflowGrantInputSchema: z.ZodObject<{
336
+ enabled: z.ZodBoolean;
337
+ /** Parâmetros fixos do tenant, enviados no envelope; a IA não vê nem escolhe. */
338
+ tenant_params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
339
+ instructions_extra: z.ZodDefault<z.ZodString>;
340
+ }, "strip", z.ZodTypeAny, {
341
+ enabled: boolean;
342
+ tenant_params: Record<string, string | number | boolean>;
343
+ instructions_extra: string;
344
+ }, {
345
+ enabled: boolean;
346
+ tenant_params?: Record<string, string | number | boolean> | undefined;
347
+ instructions_extra?: string | undefined;
348
+ }>;
349
+ export declare const zHubiaWorkflowGrantDocSchema: z.ZodObject<{
350
+ enabled: z.ZodBoolean;
351
+ /** Parâmetros fixos do tenant, enviados no envelope; a IA não vê nem escolhe. */
352
+ tenant_params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
353
+ instructions_extra: z.ZodDefault<z.ZodString>;
354
+ } & {
355
+ id: z.ZodString;
356
+ workflow_id: z.ZodString;
357
+ code: z.ZodString;
358
+ tenant: z.ZodString;
359
+ model_ver: z.ZodDefault<z.ZodNumber>;
360
+ enabled_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
361
+ enabled_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
362
+ updated_at: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
363
+ }, "strip", z.ZodTypeAny, {
364
+ code: string;
365
+ id: string;
366
+ tenant: string;
367
+ model_ver: number;
368
+ enabled: boolean;
369
+ workflow_id: string;
370
+ tenant_params: Record<string, string | number | boolean>;
371
+ instructions_extra: string;
372
+ updated_at?: Date | null | undefined;
373
+ enabled_by?: string | null | undefined;
374
+ enabled_at?: Date | null | undefined;
375
+ }, {
376
+ code: string;
377
+ id: string;
378
+ tenant: string;
379
+ enabled: boolean;
380
+ workflow_id: string;
381
+ model_ver?: number | undefined;
382
+ updated_at?: Date | null | undefined;
383
+ tenant_params?: Record<string, string | number | boolean> | undefined;
384
+ instructions_extra?: string | undefined;
385
+ enabled_by?: string | null | undefined;
386
+ enabled_at?: Date | null | undefined;
387
+ }>;
388
+ export declare const zHubiaWorkflowSourceSchema: z.ZodEnum<["llm", "proposal", "manual", "nexus_test"]>;
389
+ export declare const zHubiaWorkflowActorSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
390
+ type: z.ZodLiteral<"hubia">;
391
+ }, "strip", z.ZodTypeAny, {
392
+ type: "hubia";
393
+ }, {
394
+ type: "hubia";
395
+ }>, z.ZodObject<{
396
+ type: z.ZodLiteral<"user">;
397
+ uid: z.ZodString;
398
+ }, "strip", z.ZodTypeAny, {
399
+ type: "user";
400
+ uid: string;
401
+ }, {
402
+ type: "user";
403
+ uid: string;
404
+ }>]>;
405
+ /** Envelope `hubia-workflow/1` enviado ao n8n. */
406
+ export declare const zHubiaWorkflowCallV1Schema: z.ZodObject<{
407
+ protocol: z.ZodLiteral<"hubia-workflow/1">;
408
+ workflow: z.ZodObject<{
409
+ code: z.ZodString;
410
+ version: z.ZodNumber;
411
+ }, "strip", z.ZodTypeAny, {
412
+ code: string;
413
+ version: number;
414
+ }, {
415
+ code: string;
416
+ version: number;
417
+ }>;
418
+ call_id: z.ZodString;
419
+ source: z.ZodEnum<["llm", "proposal", "manual", "nexus_test"]>;
420
+ actor: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
421
+ type: z.ZodLiteral<"hubia">;
422
+ }, "strip", z.ZodTypeAny, {
423
+ type: "hubia";
424
+ }, {
425
+ type: "hubia";
426
+ }>, z.ZodObject<{
427
+ type: z.ZodLiteral<"user">;
428
+ uid: z.ZodString;
429
+ }, "strip", z.ZodTypeAny, {
430
+ type: "user";
431
+ uid: string;
432
+ }, {
433
+ type: "user";
434
+ uid: string;
435
+ }>]>;
436
+ tenant: z.ZodString;
437
+ context: z.ZodObject<{
438
+ execution_id: z.ZodNullable<z.ZodString>;
439
+ ticket_id: z.ZodNullable<z.ZodString>;
440
+ conversation_id: z.ZodNullable<z.ZodString>;
441
+ contact_id: z.ZodNullable<z.ZodString>;
442
+ lead_id: z.ZodNullable<z.ZodString>;
443
+ patient_id: z.ZodNullable<z.ZodString>;
444
+ department_id: z.ZodNullable<z.ZodString>;
445
+ }, "strip", z.ZodTypeAny, {
446
+ lead_id: string | null;
447
+ department_id: string | null;
448
+ contact_id: string | null;
449
+ ticket_id: string | null;
450
+ patient_id: string | null;
451
+ execution_id: string | null;
452
+ conversation_id: string | null;
453
+ }, {
454
+ lead_id: string | null;
455
+ department_id: string | null;
456
+ contact_id: string | null;
457
+ ticket_id: string | null;
458
+ patient_id: string | null;
459
+ execution_id: string | null;
460
+ conversation_id: string | null;
461
+ }>;
462
+ tenant_params: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
463
+ parametros: z.ZodRecord<z.ZodString, z.ZodUnknown>;
464
+ }, "strip", z.ZodTypeAny, {
465
+ tenant: string;
466
+ source: "manual" | "llm" | "proposal" | "nexus_test";
467
+ context: {
468
+ lead_id: string | null;
469
+ department_id: string | null;
470
+ contact_id: string | null;
471
+ ticket_id: string | null;
472
+ patient_id: string | null;
473
+ execution_id: string | null;
474
+ conversation_id: string | null;
475
+ };
476
+ actor: {
477
+ type: "hubia";
478
+ } | {
479
+ type: "user";
480
+ uid: string;
481
+ };
482
+ tenant_params: Record<string, string | number | boolean>;
483
+ protocol: "hubia-workflow/1";
484
+ workflow: {
485
+ code: string;
486
+ version: number;
487
+ };
488
+ call_id: string;
489
+ parametros: Record<string, unknown>;
490
+ }, {
491
+ tenant: string;
492
+ source: "manual" | "llm" | "proposal" | "nexus_test";
493
+ context: {
494
+ lead_id: string | null;
495
+ department_id: string | null;
496
+ contact_id: string | null;
497
+ ticket_id: string | null;
498
+ patient_id: string | null;
499
+ execution_id: string | null;
500
+ conversation_id: string | null;
501
+ };
502
+ actor: {
503
+ type: "hubia";
504
+ } | {
505
+ type: "user";
506
+ uid: string;
507
+ };
508
+ tenant_params: Record<string, string | number | boolean>;
509
+ protocol: "hubia-workflow/1";
510
+ workflow: {
511
+ code: string;
512
+ version: number;
513
+ };
514
+ call_id: string;
515
+ parametros: Record<string, unknown>;
516
+ }>;
517
+ /** Resposta `hubia-workflow/1` do n8n. */
518
+ export declare const zHubiaWorkflowResponseV1Schema: z.ZodObject<{
519
+ ok: z.ZodBoolean;
520
+ data: z.ZodOptional<z.ZodUnknown>;
521
+ /** Texto curto para o LLM interpretar o resultado. */
522
+ message_for_llm: z.ZodOptional<z.ZodString>;
523
+ /** Texto que o Omni exibe para a equipe (balão do evento / diálogo). */
524
+ message_for_human: z.ZodOptional<z.ZodString>;
525
+ error_code: z.ZodOptional<z.ZodString>;
526
+ n8n_execution_id: z.ZodOptional<z.ZodString>;
527
+ }, "strip", z.ZodTypeAny, {
528
+ ok: boolean;
529
+ data?: unknown;
530
+ error_code?: string | undefined;
531
+ message_for_llm?: string | undefined;
532
+ message_for_human?: string | undefined;
533
+ n8n_execution_id?: string | undefined;
534
+ }, {
535
+ ok: boolean;
536
+ data?: unknown;
537
+ error_code?: string | undefined;
538
+ message_for_llm?: string | undefined;
539
+ message_for_human?: string | undefined;
540
+ n8n_execution_id?: string | undefined;
541
+ }>;
542
+ export type HubiaWorkflowParam = z.infer<typeof zHubiaWorkflowParamSchema>;
543
+ export type HubiaWorkflowInput = z.infer<typeof zHubiaWorkflowInputSchema>;
544
+ export type HubiaWorkflowDoc = z.infer<typeof zHubiaWorkflowDocSchema>;
545
+ export type HubiaWorkflowGrantInput = z.infer<typeof zHubiaWorkflowGrantInputSchema>;
546
+ export type HubiaWorkflowGrantDoc = z.infer<typeof zHubiaWorkflowGrantDocSchema>;
547
+ export type HubiaWorkflowSource = z.infer<typeof zHubiaWorkflowSourceSchema>;
548
+ export type HubiaWorkflowActor = z.infer<typeof zHubiaWorkflowActorSchema>;
549
+ export type HubiaWorkflowCallV1 = z.infer<typeof zHubiaWorkflowCallV1Schema>;
550
+ export type HubiaWorkflowResponseV1 = z.infer<typeof zHubiaWorkflowResponseV1Schema>;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zHubiaWorkflowResponseV1Schema = exports.zHubiaWorkflowCallV1Schema = exports.zHubiaWorkflowActorSchema = exports.zHubiaWorkflowSourceSchema = exports.zHubiaWorkflowGrantDocSchema = exports.zHubiaWorkflowGrantInputSchema = exports.zHubiaWorkflowTenantParamValueSchema = exports.zHubiaWorkflowDocSchema = exports.zHubiaWorkflowInputSchema = exports.zHubiaWorkflowInvocationSchema = exports.zHubiaWorkflowModeSchema = exports.zHubiaWorkflowParamSchema = exports.zHubiaWorkflowParamTypeSchema = exports.zHubiaWorkflowCodeSchema = exports.HUBIA_WORKFLOW_MAX_TIMEOUT_MS = exports.HUBIA_WORKFLOW_PROTOCOL = exports.HUBIA_WORKFLOWS_COLLECTION = exports.HUBIA_WORKFLOWS_PLATFORM_DOC = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * feat-324 — workflows n8n acionados pela HubIA (LLM), pela equipe no Omni
7
+ * (manual) ou pela aprovação de uma proposta do modo híbrido.
8
+ *
9
+ * - Catálogo (plataforma): `/platform/evo-hubia-workflows/workflows/{id}`.
10
+ * - Habilitação (tenant): `tenants/{t}/apps/evo-hubia-v1/workflows/{id}` (id = id do workflow).
11
+ * - Protocolo: `hubia-workflow/1` (envelope + resposta abaixo), assinado por JWT HS256
12
+ * com claim `body_sha256`.
13
+ */
14
+ exports.HUBIA_WORKFLOWS_PLATFORM_DOC = "evo-hubia-workflows";
15
+ exports.HUBIA_WORKFLOWS_COLLECTION = "workflows";
16
+ exports.HUBIA_WORKFLOW_PROTOCOL = "hubia-workflow/1";
17
+ exports.HUBIA_WORKFLOW_MAX_TIMEOUT_MS = 30000;
18
+ exports.zHubiaWorkflowCodeSchema = zod_1.z
19
+ .string()
20
+ .regex(/^[a-z][a-z0-9_]{2,47}$/, "code: minúsculas, dígitos e _ (3–48), começando por letra");
21
+ exports.zHubiaWorkflowParamTypeSchema = zod_1.z.enum(["string", "number", "boolean", "date", "enum"]);
22
+ exports.zHubiaWorkflowParamSchema = zod_1.z
23
+ .object({
24
+ name: zod_1.z.string().regex(/^[a-z][a-z0-9_]{0,39}$/),
25
+ /** Rótulo do campo no diálogo manual do Omni. */
26
+ label: zod_1.z.string().min(1).max(80),
27
+ type: exports.zHubiaWorkflowParamTypeSchema,
28
+ required: zod_1.z.boolean().default(false),
29
+ /** Como o LLM deve preencher o campo (HubIA no turno e pré-preenchimento do diálogo). */
30
+ description: zod_1.z.string().min(1).max(400),
31
+ enum_values: zod_1.z.array(zod_1.z.string().min(1).max(80)).min(1).max(30).optional(),
32
+ })
33
+ .superRefine((p, ctx) => {
34
+ if (p.type === "enum" && !p.enum_values) {
35
+ ctx.addIssue({ code: zod_1.z.ZodIssueCode.custom, message: "enum_values é obrigatório para type=enum" });
36
+ }
37
+ });
38
+ exports.zHubiaWorkflowModeSchema = zod_1.z.enum(["ai_only", "hybrid_assist"]);
39
+ exports.zHubiaWorkflowInvocationSchema = zod_1.z
40
+ .object({
41
+ /** A IA pode acionar (aparece no catálogo do prompt). */
42
+ llm: zod_1.z.boolean(),
43
+ /** A equipe pode acionar pelo botão "Workflows" do Omni. */
44
+ manual: zod_1.z.boolean(),
45
+ })
46
+ .refine((v) => v.llm || v.manual, { message: "habilite ao menos uma via (llm ou manual)" });
47
+ /** Campos editáveis no Nexus (o servidor cuida de version/auditoria). */
48
+ exports.zHubiaWorkflowInputSchema = zod_1.z.object({
49
+ code: exports.zHubiaWorkflowCodeSchema,
50
+ name: zod_1.z.string().min(1).max(80),
51
+ status: zod_1.z.enum(["active", "inactive"]),
52
+ llm_instructions: zod_1.z.string().min(1).max(1500),
53
+ input_schema: zod_1.z.array(exports.zHubiaWorkflowParamSchema).max(15),
54
+ output_hint: zod_1.z.string().max(500).default(""),
55
+ kind: zod_1.z.enum(["read", "action"]),
56
+ invocation: exports.zHubiaWorkflowInvocationSchema,
57
+ allowed_modes: zod_1.z.array(exports.zHubiaWorkflowModeSchema).min(1),
58
+ /** Híbrido: `execute` roda direto (resultado entra na sugestão); `propose` só sugere a execução. */
59
+ hybrid_behavior: zod_1.z.enum(["execute", "propose"]),
60
+ timeout_ms: zod_1.z.number().int().min(1000).max(exports.HUBIA_WORKFLOW_MAX_TIMEOUT_MS),
61
+ endpoint_url: zod_1.z.string().url().startsWith("https://"),
62
+ });
63
+ exports.zHubiaWorkflowDocSchema = exports.zHubiaWorkflowInputSchema.extend({
64
+ id: zod_1.z.string(),
65
+ version: zod_1.z.number().int().min(1),
66
+ /** Nome do segredo no Secret Manager (`hubia-workflow-<code>`). */
67
+ secret_name: zod_1.z.string().nullable().default(null),
68
+ model_ver: zod_1.z.number().default(1),
69
+ created_at: zod_1.z.coerce.date().nullable().optional(),
70
+ created_by: zod_1.z.string().nullable().optional(),
71
+ updated_at: zod_1.z.coerce.date().nullable().optional(),
72
+ updated_by: zod_1.z.string().nullable().optional(),
73
+ deleted_at: zod_1.z.coerce.date().nullable().optional(),
74
+ });
75
+ exports.zHubiaWorkflowTenantParamValueSchema = zod_1.z.union([zod_1.z.string().max(500), zod_1.z.number(), zod_1.z.boolean()]);
76
+ exports.zHubiaWorkflowGrantInputSchema = zod_1.z.object({
77
+ enabled: zod_1.z.boolean(),
78
+ /** Parâmetros fixos do tenant, enviados no envelope; a IA não vê nem escolhe. */
79
+ tenant_params: zod_1.z.record(exports.zHubiaWorkflowTenantParamValueSchema).default({}),
80
+ instructions_extra: zod_1.z.string().max(500).default(""),
81
+ });
82
+ exports.zHubiaWorkflowGrantDocSchema = exports.zHubiaWorkflowGrantInputSchema.extend({
83
+ id: zod_1.z.string(),
84
+ workflow_id: zod_1.z.string(),
85
+ code: exports.zHubiaWorkflowCodeSchema,
86
+ tenant: zod_1.z.string(),
87
+ model_ver: zod_1.z.number().default(1),
88
+ enabled_by: zod_1.z.string().nullable().optional(),
89
+ enabled_at: zod_1.z.coerce.date().nullable().optional(),
90
+ updated_at: zod_1.z.coerce.date().nullable().optional(),
91
+ });
92
+ exports.zHubiaWorkflowSourceSchema = zod_1.z.enum(["llm", "proposal", "manual", "nexus_test"]);
93
+ exports.zHubiaWorkflowActorSchema = zod_1.z.discriminatedUnion("type", [
94
+ zod_1.z.object({ type: zod_1.z.literal("hubia") }),
95
+ zod_1.z.object({ type: zod_1.z.literal("user"), uid: zod_1.z.string().min(1) }),
96
+ ]);
97
+ /** Envelope `hubia-workflow/1` enviado ao n8n. */
98
+ exports.zHubiaWorkflowCallV1Schema = zod_1.z.object({
99
+ protocol: zod_1.z.literal(exports.HUBIA_WORKFLOW_PROTOCOL),
100
+ workflow: zod_1.z.object({ code: exports.zHubiaWorkflowCodeSchema, version: zod_1.z.number().int() }),
101
+ call_id: zod_1.z.string().min(1),
102
+ source: exports.zHubiaWorkflowSourceSchema,
103
+ actor: exports.zHubiaWorkflowActorSchema,
104
+ tenant: zod_1.z.string().min(1),
105
+ context: zod_1.z.object({
106
+ execution_id: zod_1.z.string().nullable(),
107
+ ticket_id: zod_1.z.string().nullable(),
108
+ conversation_id: zod_1.z.string().nullable(),
109
+ contact_id: zod_1.z.string().nullable(),
110
+ lead_id: zod_1.z.string().nullable(),
111
+ patient_id: zod_1.z.string().nullable(),
112
+ department_id: zod_1.z.string().nullable(),
113
+ }),
114
+ tenant_params: zod_1.z.record(exports.zHubiaWorkflowTenantParamValueSchema),
115
+ parametros: zod_1.z.record(zod_1.z.unknown()),
116
+ });
117
+ /** Resposta `hubia-workflow/1` do n8n. */
118
+ exports.zHubiaWorkflowResponseV1Schema = zod_1.z.object({
119
+ ok: zod_1.z.boolean(),
120
+ data: zod_1.z.unknown().optional(),
121
+ /** Texto curto para o LLM interpretar o resultado. */
122
+ message_for_llm: zod_1.z.string().max(500).optional(),
123
+ /** Texto que o Omni exibe para a equipe (balão do evento / diálogo). */
124
+ message_for_human: zod_1.z.string().max(2000).optional(),
125
+ error_code: zod_1.z.string().max(80).optional(),
126
+ n8n_execution_id: zod_1.z.string().optional(),
127
+ });