evo360-types 1.3.775 → 1.3.778

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.
@@ -274,10 +274,13 @@ export declare const zNexusModuleFinancePermissionsSchema: z.ZodObject<{
274
274
  */
275
275
  export declare const zNexusModuleToolsPermissionsSchema: z.ZodObject<{
276
276
  forms: z.ZodOptional<z.ZodBoolean>;
277
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
277
278
  }, "strip", z.ZodTypeAny, {
278
279
  forms?: boolean | undefined;
280
+ "hubia-n8n"?: boolean | undefined;
279
281
  }, {
280
282
  forms?: boolean | undefined;
283
+ "hubia-n8n"?: boolean | undefined;
281
284
  }>;
282
285
  /**
283
286
  * Schema for INexusModules
@@ -326,10 +329,13 @@ export declare const zNexusModulesSchema: z.ZodObject<{
326
329
  integrations: z.ZodOptional<z.ZodBoolean>;
327
330
  tools: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
328
331
  forms: z.ZodOptional<z.ZodBoolean>;
332
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
329
333
  }, "strip", z.ZodTypeAny, {
330
334
  forms?: boolean | undefined;
335
+ "hubia-n8n"?: boolean | undefined;
331
336
  }, {
332
337
  forms?: boolean | undefined;
338
+ "hubia-n8n"?: boolean | undefined;
333
339
  }>, z.ZodBoolean]>>;
334
340
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
335
341
  chat: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -375,10 +381,13 @@ export declare const zNexusModulesSchema: z.ZodObject<{
375
381
  integrations: z.ZodOptional<z.ZodBoolean>;
376
382
  tools: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
377
383
  forms: z.ZodOptional<z.ZodBoolean>;
384
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
378
385
  }, "strip", z.ZodTypeAny, {
379
386
  forms?: boolean | undefined;
387
+ "hubia-n8n"?: boolean | undefined;
380
388
  }, {
381
389
  forms?: boolean | undefined;
390
+ "hubia-n8n"?: boolean | undefined;
382
391
  }>, z.ZodBoolean]>>;
383
392
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
384
393
  chat: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -424,10 +433,13 @@ export declare const zNexusModulesSchema: z.ZodObject<{
424
433
  integrations: z.ZodOptional<z.ZodBoolean>;
425
434
  tools: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
426
435
  forms: z.ZodOptional<z.ZodBoolean>;
436
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
427
437
  }, "strip", z.ZodTypeAny, {
428
438
  forms?: boolean | undefined;
439
+ "hubia-n8n"?: boolean | undefined;
429
440
  }, {
430
441
  forms?: boolean | undefined;
442
+ "hubia-n8n"?: boolean | undefined;
431
443
  }>, z.ZodBoolean]>>;
432
444
  }, z.ZodTypeAny, "passthrough">>;
433
445
  /**
@@ -479,10 +491,13 @@ export declare const zNexusClaimsSchema: z.ZodObject<{
479
491
  integrations: z.ZodOptional<z.ZodBoolean>;
480
492
  tools: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
481
493
  forms: z.ZodOptional<z.ZodBoolean>;
494
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
482
495
  }, "strip", z.ZodTypeAny, {
483
496
  forms?: boolean | undefined;
497
+ "hubia-n8n"?: boolean | undefined;
484
498
  }, {
485
499
  forms?: boolean | undefined;
500
+ "hubia-n8n"?: boolean | undefined;
486
501
  }>, z.ZodBoolean]>>;
487
502
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
488
503
  chat: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -528,10 +543,13 @@ export declare const zNexusClaimsSchema: z.ZodObject<{
528
543
  integrations: z.ZodOptional<z.ZodBoolean>;
529
544
  tools: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
530
545
  forms: z.ZodOptional<z.ZodBoolean>;
546
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
531
547
  }, "strip", z.ZodTypeAny, {
532
548
  forms?: boolean | undefined;
549
+ "hubia-n8n"?: boolean | undefined;
533
550
  }, {
534
551
  forms?: boolean | undefined;
552
+ "hubia-n8n"?: boolean | undefined;
535
553
  }>, z.ZodBoolean]>>;
536
554
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
537
555
  chat: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -577,10 +595,13 @@ export declare const zNexusClaimsSchema: z.ZodObject<{
577
595
  integrations: z.ZodOptional<z.ZodBoolean>;
578
596
  tools: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
579
597
  forms: z.ZodOptional<z.ZodBoolean>;
598
+ "hubia-n8n": z.ZodOptional<z.ZodBoolean>;
580
599
  }, "strip", z.ZodTypeAny, {
581
600
  forms?: boolean | undefined;
601
+ "hubia-n8n"?: boolean | undefined;
582
602
  }, {
583
603
  forms?: boolean | undefined;
604
+ "hubia-n8n"?: boolean | undefined;
584
605
  }>, z.ZodBoolean]>>;
585
606
  }, z.ZodTypeAny, "passthrough">>;
586
607
  }, "strip", z.ZodTypeAny, {
@@ -606,6 +627,7 @@ export declare const zNexusClaimsSchema: z.ZodObject<{
606
627
  webhooks?: boolean | undefined;
607
628
  tools?: boolean | {
608
629
  forms?: boolean | undefined;
630
+ "hubia-n8n"?: boolean | undefined;
609
631
  } | undefined;
610
632
  } & {
611
633
  [k: string]: unknown;
@@ -633,6 +655,7 @@ export declare const zNexusClaimsSchema: z.ZodObject<{
633
655
  webhooks?: boolean | undefined;
634
656
  tools?: boolean | {
635
657
  forms?: boolean | undefined;
658
+ "hubia-n8n"?: boolean | undefined;
636
659
  } | undefined;
637
660
  } & {
638
661
  [k: string]: unknown;
@@ -118,6 +118,7 @@ exports.zNexusModuleFinancePermissionsSchema = zod_1.z.object({
118
118
  */
119
119
  exports.zNexusModuleToolsPermissionsSchema = zod_1.z.object({
120
120
  forms: zod_1.z.boolean().optional(),
121
+ "hubia-n8n": zod_1.z.boolean().optional(),
121
122
  });
122
123
  /**
123
124
  * Schema for INexusModules
@@ -130,6 +130,7 @@ export const zNexusModuleFinancePermissionsSchema = z.object({
130
130
  */
131
131
  export const zNexusModuleToolsPermissionsSchema = z.object({
132
132
  forms: z.boolean().optional(),
133
+ "hubia-n8n": z.boolean().optional(),
133
134
  });
134
135
 
135
136
  /**
@@ -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
+ });
@@ -0,0 +1,150 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * feat-324 — workflows n8n acionados pela HubIA (LLM), pela equipe no Omni
5
+ * (manual) ou pela aprovação de uma proposta do modo híbrido.
6
+ *
7
+ * - Catálogo (plataforma): `/platform/evo-hubia-workflows/workflows/{id}`.
8
+ * - Habilitação (tenant): `tenants/{t}/apps/evo-hubia-v1/workflows/{id}` (id = id do workflow).
9
+ * - Protocolo: `hubia-workflow/1` (envelope + resposta abaixo), assinado por JWT HS256
10
+ * com claim `body_sha256`.
11
+ */
12
+
13
+ export const HUBIA_WORKFLOWS_PLATFORM_DOC = "evo-hubia-workflows";
14
+ export const HUBIA_WORKFLOWS_COLLECTION = "workflows";
15
+ export const HUBIA_WORKFLOW_PROTOCOL = "hubia-workflow/1";
16
+ export const HUBIA_WORKFLOW_MAX_TIMEOUT_MS = 30000;
17
+
18
+ export const zHubiaWorkflowCodeSchema = 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
+
22
+ export const zHubiaWorkflowParamTypeSchema = z.enum(["string", "number", "boolean", "date", "enum"]);
23
+
24
+ export const zHubiaWorkflowParamSchema = z
25
+ .object({
26
+ name: z.string().regex(/^[a-z][a-z0-9_]{0,39}$/),
27
+ /** Rótulo do campo no diálogo manual do Omni. */
28
+ label: z.string().min(1).max(80),
29
+ type: zHubiaWorkflowParamTypeSchema,
30
+ required: z.boolean().default(false),
31
+ /** Como o LLM deve preencher o campo (HubIA no turno e pré-preenchimento do diálogo). */
32
+ description: z.string().min(1).max(400),
33
+ enum_values: z.array(z.string().min(1).max(80)).min(1).max(30).optional(),
34
+ })
35
+ .superRefine((p, ctx) => {
36
+ if (p.type === "enum" && !p.enum_values) {
37
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "enum_values é obrigatório para type=enum" });
38
+ }
39
+ });
40
+
41
+ export const zHubiaWorkflowModeSchema = z.enum(["ai_only", "hybrid_assist"]);
42
+
43
+ export const zHubiaWorkflowInvocationSchema = z
44
+ .object({
45
+ /** A IA pode acionar (aparece no catálogo do prompt). */
46
+ llm: z.boolean(),
47
+ /** A equipe pode acionar pelo botão "Workflows" do Omni. */
48
+ manual: z.boolean(),
49
+ })
50
+ .refine((v) => v.llm || v.manual, { message: "habilite ao menos uma via (llm ou manual)" });
51
+
52
+ /** Campos editáveis no Nexus (o servidor cuida de version/auditoria). */
53
+ export const zHubiaWorkflowInputSchema = z.object({
54
+ code: zHubiaWorkflowCodeSchema,
55
+ name: z.string().min(1).max(80),
56
+ status: z.enum(["active", "inactive"]),
57
+ llm_instructions: z.string().min(1).max(1500),
58
+ input_schema: z.array(zHubiaWorkflowParamSchema).max(15),
59
+ output_hint: z.string().max(500).default(""),
60
+ kind: z.enum(["read", "action"]),
61
+ invocation: zHubiaWorkflowInvocationSchema,
62
+ allowed_modes: z.array(zHubiaWorkflowModeSchema).min(1),
63
+ /** Híbrido: `execute` roda direto (resultado entra na sugestão); `propose` só sugere a execução. */
64
+ hybrid_behavior: z.enum(["execute", "propose"]),
65
+ timeout_ms: z.number().int().min(1000).max(HUBIA_WORKFLOW_MAX_TIMEOUT_MS),
66
+ endpoint_url: z.string().url().startsWith("https://"),
67
+ });
68
+
69
+ export const zHubiaWorkflowDocSchema = zHubiaWorkflowInputSchema.extend({
70
+ id: z.string(),
71
+ version: z.number().int().min(1),
72
+ /** Nome do segredo no Secret Manager (`hubia-workflow-<code>`). */
73
+ secret_name: z.string().nullable().default(null),
74
+ model_ver: z.number().default(1),
75
+ created_at: z.coerce.date().nullable().optional(),
76
+ created_by: z.string().nullable().optional(),
77
+ updated_at: z.coerce.date().nullable().optional(),
78
+ updated_by: z.string().nullable().optional(),
79
+ deleted_at: z.coerce.date().nullable().optional(),
80
+ });
81
+
82
+ export const zHubiaWorkflowTenantParamValueSchema = z.union([z.string().max(500), z.number(), z.boolean()]);
83
+
84
+ export const zHubiaWorkflowGrantInputSchema = z.object({
85
+ enabled: z.boolean(),
86
+ /** Parâmetros fixos do tenant, enviados no envelope; a IA não vê nem escolhe. */
87
+ tenant_params: z.record(zHubiaWorkflowTenantParamValueSchema).default({}),
88
+ instructions_extra: z.string().max(500).default(""),
89
+ });
90
+
91
+ export const zHubiaWorkflowGrantDocSchema = zHubiaWorkflowGrantInputSchema.extend({
92
+ id: z.string(),
93
+ workflow_id: z.string(),
94
+ code: zHubiaWorkflowCodeSchema,
95
+ tenant: z.string(),
96
+ model_ver: z.number().default(1),
97
+ enabled_by: z.string().nullable().optional(),
98
+ enabled_at: z.coerce.date().nullable().optional(),
99
+ updated_at: z.coerce.date().nullable().optional(),
100
+ });
101
+
102
+ export const zHubiaWorkflowSourceSchema = z.enum(["llm", "proposal", "manual", "nexus_test"]);
103
+
104
+ export const zHubiaWorkflowActorSchema = z.discriminatedUnion("type", [
105
+ z.object({ type: z.literal("hubia") }),
106
+ z.object({ type: z.literal("user"), uid: z.string().min(1) }),
107
+ ]);
108
+
109
+ /** Envelope `hubia-workflow/1` enviado ao n8n. */
110
+ export const zHubiaWorkflowCallV1Schema = z.object({
111
+ protocol: z.literal(HUBIA_WORKFLOW_PROTOCOL),
112
+ workflow: z.object({ code: zHubiaWorkflowCodeSchema, version: z.number().int() }),
113
+ call_id: z.string().min(1),
114
+ source: zHubiaWorkflowSourceSchema,
115
+ actor: zHubiaWorkflowActorSchema,
116
+ tenant: z.string().min(1),
117
+ context: z.object({
118
+ execution_id: z.string().nullable(),
119
+ ticket_id: z.string().nullable(),
120
+ conversation_id: z.string().nullable(),
121
+ contact_id: z.string().nullable(),
122
+ lead_id: z.string().nullable(),
123
+ patient_id: z.string().nullable(),
124
+ department_id: z.string().nullable(),
125
+ }),
126
+ tenant_params: z.record(zHubiaWorkflowTenantParamValueSchema),
127
+ parametros: z.record(z.unknown()),
128
+ });
129
+
130
+ /** Resposta `hubia-workflow/1` do n8n. */
131
+ export const zHubiaWorkflowResponseV1Schema = z.object({
132
+ ok: z.boolean(),
133
+ data: z.unknown().optional(),
134
+ /** Texto curto para o LLM interpretar o resultado. */
135
+ message_for_llm: z.string().max(500).optional(),
136
+ /** Texto que o Omni exibe para a equipe (balão do evento / diálogo). */
137
+ message_for_human: z.string().max(2000).optional(),
138
+ error_code: z.string().max(80).optional(),
139
+ n8n_execution_id: z.string().optional(),
140
+ });
141
+
142
+ export type HubiaWorkflowParam = z.infer<typeof zHubiaWorkflowParamSchema>;
143
+ export type HubiaWorkflowInput = z.infer<typeof zHubiaWorkflowInputSchema>;
144
+ export type HubiaWorkflowDoc = z.infer<typeof zHubiaWorkflowDocSchema>;
145
+ export type HubiaWorkflowGrantInput = z.infer<typeof zHubiaWorkflowGrantInputSchema>;
146
+ export type HubiaWorkflowGrantDoc = z.infer<typeof zHubiaWorkflowGrantDocSchema>;
147
+ export type HubiaWorkflowSource = z.infer<typeof zHubiaWorkflowSourceSchema>;
148
+ export type HubiaWorkflowActor = z.infer<typeof zHubiaWorkflowActorSchema>;
149
+ export type HubiaWorkflowCallV1 = z.infer<typeof zHubiaWorkflowCallV1Schema>;
150
+ export type HubiaWorkflowResponseV1 = z.infer<typeof zHubiaWorkflowResponseV1Schema>;
package/dist/index.d.ts CHANGED
@@ -65,6 +65,7 @@ export * from "./apps/evo-chat/forward/zod-schemas";
65
65
  export * from "./apps/evo-hub-ia/channel/zod-schemas";
66
66
  export * from "./apps/evo-hub-ia/v1/zod-schemas";
67
67
  export * from "./apps/evo-hub-ia/v1/adapter-tool-registry";
68
+ export * from "./apps/evo-hub-ia/workflows/zod-schemas";
68
69
  export * from "./apps/evo-csq/zod-schemas";
69
70
  export * from "./apps/evo-med/calendar/zod-schemas";
70
71
  export * from "./apps/evo-med/appointment/zod-schemas";
package/dist/index.js CHANGED
@@ -83,6 +83,7 @@ __exportStar(require("./apps/evo-chat/forward/zod-schemas"), exports);
83
83
  __exportStar(require("./apps/evo-hub-ia/channel/zod-schemas"), exports);
84
84
  __exportStar(require("./apps/evo-hub-ia/v1/zod-schemas"), exports);
85
85
  __exportStar(require("./apps/evo-hub-ia/v1/adapter-tool-registry"), exports);
86
+ __exportStar(require("./apps/evo-hub-ia/workflows/zod-schemas"), exports);
86
87
  __exportStar(require("./apps/evo-csq/zod-schemas"), exports);
87
88
  __exportStar(require("./apps/evo-med/calendar/zod-schemas"), exports);
88
89
  __exportStar(require("./apps/evo-med/appointment/zod-schemas"), exports);
package/dist/index.ts CHANGED
@@ -68,6 +68,7 @@ export * from "./apps/evo-chat/forward/zod-schemas";
68
68
  export * from "./apps/evo-hub-ia/channel/zod-schemas";
69
69
  export * from "./apps/evo-hub-ia/v1/zod-schemas";
70
70
  export * from "./apps/evo-hub-ia/v1/adapter-tool-registry";
71
+ export * from "./apps/evo-hub-ia/workflows/zod-schemas";
71
72
  export * from "./apps/evo-csq/zod-schemas";
72
73
  export * from "./apps/evo-med/calendar/zod-schemas";
73
74
  export * from "./apps/evo-med/appointment/zod-schemas";
@@ -23,5 +23,7 @@ export declare const EvoChatPermissions: {
23
23
  readonly TicketTransfer: "evo_chat_ticket_transfer";
24
24
  /** feat-254 B2: baixar anexo de e-mail bloqueado pela política (quarentena). Sem papel padrão. */
25
25
  readonly QuarantineRead: "evo_chat_quarantine_read";
26
+ /** feat-324: executar workflow n8n da HubIA pelo Omni (manual ou aprovando proposta). */
27
+ readonly WorkflowRun: "evo_hubia_workflow_run";
26
28
  };
27
29
  export type EvoChatPermissions = (typeof EvoChatPermissions)[keyof typeof EvoChatPermissions];
@@ -41,4 +41,6 @@ exports.EvoChatPermissions = {
41
41
  TicketTransfer: "evo_chat_ticket_transfer",
42
42
  /** feat-254 B2: baixar anexo de e-mail bloqueado pela política (quarentena). Sem papel padrão. */
43
43
  QuarantineRead: "evo_chat_quarantine_read",
44
+ /** feat-324: executar workflow n8n da HubIA pelo Omni (manual ou aprovando proposta). */
45
+ WorkflowRun: "evo_hubia_workflow_run",
44
46
  };
@@ -25,6 +25,8 @@ export const EvoChatPermissions = {
25
25
  TicketTransfer: "evo_chat_ticket_transfer",
26
26
  /** feat-254 B2: baixar anexo de e-mail bloqueado pela política (quarentena). Sem papel padrão. */
27
27
  QuarantineRead: "evo_chat_quarantine_read",
28
+ /** feat-324: executar workflow n8n da HubIA pelo Omni (manual ou aprovando proposta). */
29
+ WorkflowRun: "evo_hubia_workflow_run",
28
30
  } as const;
29
31
 
30
32
  export type EvoChatPermissions =
@@ -69,6 +69,8 @@ export interface INexusModuleFinancePermissions {
69
69
  /** feat-310 — ferramentas que só existem no Nexus (grupo `tools`). */
70
70
  export interface INexusModuleToolsPermissions {
71
71
  forms?: boolean;
72
+ /** feat-324 — cadastro e habilitação de workflows n8n da HubIA. */
73
+ "hubia-n8n"?: boolean;
72
74
  }
73
75
  export interface INexusModules {
74
76
  chat?: INexusModuleChatPermissions | boolean;
@@ -82,6 +82,8 @@ export interface INexusModuleFinancePermissions {
82
82
  /** feat-310 — ferramentas que só existem no Nexus (grupo `tools`). */
83
83
  export interface INexusModuleToolsPermissions {
84
84
  forms?: boolean;
85
+ /** feat-324 — cadastro e habilitação de workflows n8n da HubIA. */
86
+ "hubia-n8n"?: boolean;
85
87
  }
86
88
 
87
89
  export interface INexusModules {
@@ -5,11 +5,6 @@ export declare const EVO_EMR_APP = "evo-emr";
5
5
  * Sem hífen: `MODULE_KEY_PATTERN` só aceita `[a-z][a-z0-9_]`.
6
6
  */
7
7
  export declare const EVO_EMR_MODULE_KEY = "emr";
8
- /**
9
- * Id do banco Firestore nomeado (criado com CMEK, D-004). O dado clínico NUNCA
10
- * vai para o `(default)`; o backend abre um cliente próprio com este id.
11
- */
12
- export declare const EVO_EMR_DATABASE_ID = "evo-emr";
13
8
  export declare const EvoEmrPermissions: {
14
9
  /** Abrir o módulo e as instâncias de que o usuário é membro. */
15
10
  readonly Access: "evo_emr_access";
@@ -2,12 +2,13 @@
2
2
  // evo-emr — prontuário eletrônico (feat-156).
3
3
  //
4
4
  // Só o "plumbing" de plataforma vive aqui (exceção explícita da D-019): id do
5
- // app, chave do módulo no catálogo evo-modules, id do banco Firestore nomeado e
6
- // as duas permissões tenant-level que o RBAC materializa em `perms`. Os
7
- // contratos da API e do dado clínico NÃO entram neste pacote público; nascem em
8
- // `@hubmedica/emr-contracts` (GitLab, privado).
5
+ // app, chave do módulo no catálogo evo-modules e as duas permissões tenant-level
6
+ // que o RBAC materializa em `perms`. Os contratos da API e do dado clínico NÃO
7
+ // entram neste pacote público; nascem em `@hubmedica/emr-contracts` (GitLab,
8
+ // privado). O EMR grava no banco `(default)` em coleções `tenants/{t}/emr-*`
9
+ // (D-020, 2026-11-02): não há mais id de banco nomeado aqui.
9
10
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.EvoEmrPermissions = exports.EVO_EMR_DATABASE_ID = exports.EVO_EMR_MODULE_KEY = exports.EVO_EMR_APP = void 0;
11
+ exports.EvoEmrPermissions = exports.EVO_EMR_MODULE_KEY = exports.EVO_EMR_APP = void 0;
11
12
  /** App do Firestore / namespace do módulo. */
12
13
  exports.EVO_EMR_APP = "evo-emr";
13
14
  /**
@@ -15,11 +16,6 @@ exports.EVO_EMR_APP = "evo-emr";
15
16
  * Sem hífen: `MODULE_KEY_PATTERN` só aceita `[a-z][a-z0-9_]`.
16
17
  */
17
18
  exports.EVO_EMR_MODULE_KEY = "emr";
18
- /**
19
- * Id do banco Firestore nomeado (criado com CMEK, D-004). O dado clínico NUNCA
20
- * vai para o `(default)`; o backend abre um cliente próprio com este id.
21
- */
22
- exports.EVO_EMR_DATABASE_ID = "evo-emr";
23
19
  // ----- Permissões tenant-level (grupo RBAC global `core/rbac/groups/evo-emr`)
24
20
  exports.EvoEmrPermissions = {
25
21
  /** Abrir o módulo e as instâncias de que o usuário é membro. */
@@ -1,10 +1,11 @@
1
1
  // evo-emr — prontuário eletrônico (feat-156).
2
2
  //
3
3
  // Só o "plumbing" de plataforma vive aqui (exceção explícita da D-019): id do
4
- // app, chave do módulo no catálogo evo-modules, id do banco Firestore nomeado e
5
- // as duas permissões tenant-level que o RBAC materializa em `perms`. Os
6
- // contratos da API e do dado clínico NÃO entram neste pacote público; nascem em
7
- // `@hubmedica/emr-contracts` (GitLab, privado).
4
+ // app, chave do módulo no catálogo evo-modules e as duas permissões tenant-level
5
+ // que o RBAC materializa em `perms`. Os contratos da API e do dado clínico NÃO
6
+ // entram neste pacote público; nascem em `@hubmedica/emr-contracts` (GitLab,
7
+ // privado). O EMR grava no banco `(default)` em coleções `tenants/{t}/emr-*`
8
+ // (D-020, 2026-11-02): não há mais id de banco nomeado aqui.
8
9
 
9
10
  /** App do Firestore / namespace do módulo. */
10
11
  export const EVO_EMR_APP = "evo-emr";
@@ -15,12 +16,6 @@ export const EVO_EMR_APP = "evo-emr";
15
16
  */
16
17
  export const EVO_EMR_MODULE_KEY = "emr";
17
18
 
18
- /**
19
- * Id do banco Firestore nomeado (criado com CMEK, D-004). O dado clínico NUNCA
20
- * vai para o `(default)`; o backend abre um cliente próprio com este id.
21
- */
22
- export const EVO_EMR_DATABASE_ID = "evo-emr";
23
-
24
19
  // ----- Permissões tenant-level (grupo RBAC global `core/rbac/groups/evo-emr`)
25
20
  export const EvoEmrPermissions = {
26
21
  /** Abrir o módulo e as instâncias de que o usuário é membro. */
@@ -126,8 +126,9 @@ export interface IUsageLlm {
126
126
  * - `human_audio_synthesis`: "Enviar como áudio" do atendente (TTS; 1 linha por áudio enviado).
127
127
  * - `message_generation`: mensagem gerada por IA nas saídas do hub-automation
128
128
  * (feat-311: aniversário; envio e "Testar prompt").
129
+ * - `workflow_prefill`: pré-preenchimento do diálogo de workflow n8n no Omni (feat-324).
129
130
  */
130
- export type UsageAiCategory = "hubia" | "attachment_analysis" | "audio_synthesis" | "human_audio_synthesis" | "message_generation";
131
+ export type UsageAiCategory = "hubia" | "attachment_analysis" | "audio_synthesis" | "human_audio_synthesis" | "message_generation" | "workflow_prefill";
131
132
  export interface IUsageLlmCategory {
132
133
  /** Chamadas ao LLM nesta categoria (execuções/análises, dedup por evento). */
133
134
  turnos: number;
@@ -147,13 +147,15 @@ export interface IUsageLlm {
147
147
  * - `human_audio_synthesis`: "Enviar como áudio" do atendente (TTS; 1 linha por áudio enviado).
148
148
  * - `message_generation`: mensagem gerada por IA nas saídas do hub-automation
149
149
  * (feat-311: aniversário; envio e "Testar prompt").
150
+ * - `workflow_prefill`: pré-preenchimento do diálogo de workflow n8n no Omni (feat-324).
150
151
  */
151
152
  export type UsageAiCategory =
152
153
  | "hubia"
153
154
  | "attachment_analysis"
154
155
  | "audio_synthesis"
155
156
  | "human_audio_synthesis"
156
- | "message_generation";
157
+ | "message_generation"
158
+ | "workflow_prefill";
157
159
 
158
160
  export interface IUsageLlmCategory {
159
161
  /** Chamadas ao LLM nesta categoria (execuções/análises, dedup por evento). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evo360-types",
3
- "version": "1.3.775",
3
+ "version": "1.3.778",
4
4
  "description": "HREVO360 Shared Types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",