evo360-types 1.3.376 → 1.3.377

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.
@@ -471,9 +471,16 @@ export declare const zHubiaConversationModeSchema: z.ZodEnum<["ai_only", "hybrid
471
471
  export type IHubiaConversationMode = z.infer<typeof zHubiaConversationModeSchema>;
472
472
  /** Fase de avaliação. Tipos TS em src/types/evo-hub-ia/v1/. */
473
473
  export declare const zHubiaRulePhaseSchema: z.ZodEnum<["pre_llm", "post_llm"]>;
474
- export declare const zHubiaRuleTriggerSchema: z.ZodEnum<["inbound_message", "llm_completed"]>;
474
+ export declare const zHubiaRuleTriggerSchema: z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>;
475
475
  export declare const zHubiaRuleOutcomeSchema: z.ZodEnum<["stop", "to_llm", "to_llm_with_context"]>;
476
476
  export declare const zHubiaRuleAppliesToSchema: z.ZodEnum<["real_message", "kickoff", "any"]>;
477
+ /** Filtro por origem da mensagem outbound (apenas `when=outbound_message`).
478
+ * - `all` : qualquer origem dispara a regra.
479
+ * - `llm_only` : só mensagens geradas pelo LLM.
480
+ * - `non_system` : exclui mensagens sintéticas do sistema.
481
+ * - `all_except_kickoff` : default — exclui apenas msgs de kickoff de
482
+ * transferência (proteção contra loop). */
483
+ export declare const zHubiaOutboundSourceSchema: z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>;
477
484
  export declare const zHubiaConditionOpSchema: z.ZodEnum<["exists", "not_exists", "is_empty", "is_not_empty", "eq", "neq", "in", "not_in", "contains", "not_contains", "matches", "gt", "gte", "lt", "lte", "in_schedule", "not_in_schedule"]>;
478
485
  /** Uma janela individual: dia da semana (0=dom..6=sáb) + intervalo HH:MM. */
479
486
  export declare const zHubiaScheduleWindowSchema: z.ZodEffects<z.ZodObject<{
@@ -668,12 +675,15 @@ export declare const zHubiaConditionGroupSchema: z.ZodEffects<z.ZodObject<{
668
675
  export declare const zHubiaRuleScopeSchema: z.ZodObject<{
669
676
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
670
677
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
678
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
671
679
  }, "strip", z.ZodTypeAny, {
672
680
  provider?: "chatbee" | "hub-waba" | undefined;
673
681
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
682
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
674
683
  }, {
675
684
  provider?: "chatbee" | "hub-waba" | undefined;
676
685
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
686
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
677
687
  }>;
678
688
  /** Uma ação a executar via ToolRegistry. `input` aceita templating
679
689
  * `{{fact.path}}` resolvido em runtime pelo facts provider. */
@@ -704,16 +714,19 @@ export declare const zHubiaRuleSchema: z.ZodEffects<z.ZodObject<{
704
714
  /** Menor avalia primeiro (first-match). */
705
715
  priority: z.ZodDefault<z.ZodNumber>;
706
716
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
707
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
717
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
708
718
  scope: z.ZodOptional<z.ZodObject<{
709
719
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
710
720
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
721
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
711
722
  }, "strip", z.ZodTypeAny, {
712
723
  provider?: "chatbee" | "hub-waba" | undefined;
713
724
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
725
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
714
726
  }, {
715
727
  provider?: "chatbee" | "hub-waba" | undefined;
716
728
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
729
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
717
730
  }>>;
718
731
  conditions: z.ZodEffects<z.ZodObject<{
719
732
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -836,16 +849,19 @@ export declare const zHubiaRuleSchema: z.ZodEffects<z.ZodObject<{
836
849
  /** Menor avalia primeiro (first-match). */
837
850
  priority: z.ZodDefault<z.ZodNumber>;
838
851
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
839
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
852
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
840
853
  scope: z.ZodOptional<z.ZodObject<{
841
854
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
842
855
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
856
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
843
857
  }, "strip", z.ZodTypeAny, {
844
858
  provider?: "chatbee" | "hub-waba" | undefined;
845
859
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
860
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
846
861
  }, {
847
862
  provider?: "chatbee" | "hub-waba" | undefined;
848
863
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
864
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
849
865
  }>>;
850
866
  conditions: z.ZodEffects<z.ZodObject<{
851
867
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -968,16 +984,19 @@ export declare const zHubiaRuleSchema: z.ZodEffects<z.ZodObject<{
968
984
  /** Menor avalia primeiro (first-match). */
969
985
  priority: z.ZodDefault<z.ZodNumber>;
970
986
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
971
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
987
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
972
988
  scope: z.ZodOptional<z.ZodObject<{
973
989
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
974
990
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
991
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
975
992
  }, "strip", z.ZodTypeAny, {
976
993
  provider?: "chatbee" | "hub-waba" | undefined;
977
994
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
995
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
978
996
  }, {
979
997
  provider?: "chatbee" | "hub-waba" | undefined;
980
998
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
999
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
981
1000
  }>>;
982
1001
  conditions: z.ZodEffects<z.ZodObject<{
983
1002
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1100,16 +1119,19 @@ export declare const zHubiaRuleSchema: z.ZodEffects<z.ZodObject<{
1100
1119
  /** Menor avalia primeiro (first-match). */
1101
1120
  priority: z.ZodDefault<z.ZodNumber>;
1102
1121
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1103
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1122
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1104
1123
  scope: z.ZodOptional<z.ZodObject<{
1105
1124
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1106
1125
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1126
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1107
1127
  }, "strip", z.ZodTypeAny, {
1108
1128
  provider?: "chatbee" | "hub-waba" | undefined;
1109
1129
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1130
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1110
1131
  }, {
1111
1132
  provider?: "chatbee" | "hub-waba" | undefined;
1112
1133
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1134
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1113
1135
  }>>;
1114
1136
  conditions: z.ZodEffects<z.ZodObject<{
1115
1137
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1232,16 +1254,19 @@ export declare const zHubiaRuleSchema: z.ZodEffects<z.ZodObject<{
1232
1254
  /** Menor avalia primeiro (first-match). */
1233
1255
  priority: z.ZodDefault<z.ZodNumber>;
1234
1256
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1235
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1257
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1236
1258
  scope: z.ZodOptional<z.ZodObject<{
1237
1259
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1238
1260
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1261
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1239
1262
  }, "strip", z.ZodTypeAny, {
1240
1263
  provider?: "chatbee" | "hub-waba" | undefined;
1241
1264
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1265
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1242
1266
  }, {
1243
1267
  provider?: "chatbee" | "hub-waba" | undefined;
1244
1268
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1269
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1245
1270
  }>>;
1246
1271
  conditions: z.ZodEffects<z.ZodObject<{
1247
1272
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1423,16 +1448,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
1423
1448
  /** Menor avalia primeiro (first-match). */
1424
1449
  priority: z.ZodDefault<z.ZodNumber>;
1425
1450
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1426
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1451
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1427
1452
  scope: z.ZodOptional<z.ZodObject<{
1428
1453
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1429
1454
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1455
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1430
1456
  }, "strip", z.ZodTypeAny, {
1431
1457
  provider?: "chatbee" | "hub-waba" | undefined;
1432
1458
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1459
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1433
1460
  }, {
1434
1461
  provider?: "chatbee" | "hub-waba" | undefined;
1435
1462
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1463
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1436
1464
  }>>;
1437
1465
  conditions: z.ZodEffects<z.ZodObject<{
1438
1466
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1555,16 +1583,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
1555
1583
  /** Menor avalia primeiro (first-match). */
1556
1584
  priority: z.ZodDefault<z.ZodNumber>;
1557
1585
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1558
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1586
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1559
1587
  scope: z.ZodOptional<z.ZodObject<{
1560
1588
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1561
1589
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1590
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1562
1591
  }, "strip", z.ZodTypeAny, {
1563
1592
  provider?: "chatbee" | "hub-waba" | undefined;
1564
1593
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1594
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1565
1595
  }, {
1566
1596
  provider?: "chatbee" | "hub-waba" | undefined;
1567
1597
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1598
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1568
1599
  }>>;
1569
1600
  conditions: z.ZodEffects<z.ZodObject<{
1570
1601
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1687,16 +1718,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
1687
1718
  /** Menor avalia primeiro (first-match). */
1688
1719
  priority: z.ZodDefault<z.ZodNumber>;
1689
1720
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1690
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1721
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1691
1722
  scope: z.ZodOptional<z.ZodObject<{
1692
1723
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1693
1724
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1725
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1694
1726
  }, "strip", z.ZodTypeAny, {
1695
1727
  provider?: "chatbee" | "hub-waba" | undefined;
1696
1728
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1729
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1697
1730
  }, {
1698
1731
  provider?: "chatbee" | "hub-waba" | undefined;
1699
1732
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1733
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1700
1734
  }>>;
1701
1735
  conditions: z.ZodEffects<z.ZodObject<{
1702
1736
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1819,16 +1853,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
1819
1853
  /** Menor avalia primeiro (first-match). */
1820
1854
  priority: z.ZodDefault<z.ZodNumber>;
1821
1855
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1822
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1856
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1823
1857
  scope: z.ZodOptional<z.ZodObject<{
1824
1858
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1825
1859
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1860
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1826
1861
  }, "strip", z.ZodTypeAny, {
1827
1862
  provider?: "chatbee" | "hub-waba" | undefined;
1828
1863
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1864
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1829
1865
  }, {
1830
1866
  provider?: "chatbee" | "hub-waba" | undefined;
1831
1867
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1868
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1832
1869
  }>>;
1833
1870
  conditions: z.ZodEffects<z.ZodObject<{
1834
1871
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1951,16 +1988,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
1951
1988
  /** Menor avalia primeiro (first-match). */
1952
1989
  priority: z.ZodDefault<z.ZodNumber>;
1953
1990
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
1954
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
1991
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
1955
1992
  scope: z.ZodOptional<z.ZodObject<{
1956
1993
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
1957
1994
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
1995
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
1958
1996
  }, "strip", z.ZodTypeAny, {
1959
1997
  provider?: "chatbee" | "hub-waba" | undefined;
1960
1998
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
1999
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1961
2000
  }, {
1962
2001
  provider?: "chatbee" | "hub-waba" | undefined;
1963
2002
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2003
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
1964
2004
  }>>;
1965
2005
  conditions: z.ZodEffects<z.ZodObject<{
1966
2006
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -2146,16 +2186,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
2146
2186
  /** Menor avalia primeiro (first-match). */
2147
2187
  priority: z.ZodDefault<z.ZodNumber>;
2148
2188
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
2149
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
2189
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
2150
2190
  scope: z.ZodOptional<z.ZodObject<{
2151
2191
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
2152
2192
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
2193
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
2153
2194
  }, "strip", z.ZodTypeAny, {
2154
2195
  provider?: "chatbee" | "hub-waba" | undefined;
2155
2196
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2197
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2156
2198
  }, {
2157
2199
  provider?: "chatbee" | "hub-waba" | undefined;
2158
2200
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2201
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2159
2202
  }>>;
2160
2203
  conditions: z.ZodEffects<z.ZodObject<{
2161
2204
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -2278,16 +2321,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
2278
2321
  /** Menor avalia primeiro (first-match). */
2279
2322
  priority: z.ZodDefault<z.ZodNumber>;
2280
2323
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
2281
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
2324
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
2282
2325
  scope: z.ZodOptional<z.ZodObject<{
2283
2326
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
2284
2327
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
2328
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
2285
2329
  }, "strip", z.ZodTypeAny, {
2286
2330
  provider?: "chatbee" | "hub-waba" | undefined;
2287
2331
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2332
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2288
2333
  }, {
2289
2334
  provider?: "chatbee" | "hub-waba" | undefined;
2290
2335
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2336
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2291
2337
  }>>;
2292
2338
  conditions: z.ZodEffects<z.ZodObject<{
2293
2339
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -2410,16 +2456,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
2410
2456
  /** Menor avalia primeiro (first-match). */
2411
2457
  priority: z.ZodDefault<z.ZodNumber>;
2412
2458
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
2413
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
2459
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
2414
2460
  scope: z.ZodOptional<z.ZodObject<{
2415
2461
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
2416
2462
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
2463
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
2417
2464
  }, "strip", z.ZodTypeAny, {
2418
2465
  provider?: "chatbee" | "hub-waba" | undefined;
2419
2466
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2467
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2420
2468
  }, {
2421
2469
  provider?: "chatbee" | "hub-waba" | undefined;
2422
2470
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2471
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2423
2472
  }>>;
2424
2473
  conditions: z.ZodEffects<z.ZodObject<{
2425
2474
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -2542,16 +2591,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
2542
2591
  /** Menor avalia primeiro (first-match). */
2543
2592
  priority: z.ZodDefault<z.ZodNumber>;
2544
2593
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
2545
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
2594
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
2546
2595
  scope: z.ZodOptional<z.ZodObject<{
2547
2596
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
2548
2597
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
2598
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
2549
2599
  }, "strip", z.ZodTypeAny, {
2550
2600
  provider?: "chatbee" | "hub-waba" | undefined;
2551
2601
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2602
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2552
2603
  }, {
2553
2604
  provider?: "chatbee" | "hub-waba" | undefined;
2554
2605
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2606
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2555
2607
  }>>;
2556
2608
  conditions: z.ZodEffects<z.ZodObject<{
2557
2609
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -2674,16 +2726,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
2674
2726
  /** Menor avalia primeiro (first-match). */
2675
2727
  priority: z.ZodDefault<z.ZodNumber>;
2676
2728
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
2677
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
2729
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
2678
2730
  scope: z.ZodOptional<z.ZodObject<{
2679
2731
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
2680
2732
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
2733
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
2681
2734
  }, "strip", z.ZodTypeAny, {
2682
2735
  provider?: "chatbee" | "hub-waba" | undefined;
2683
2736
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2737
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2684
2738
  }, {
2685
2739
  provider?: "chatbee" | "hub-waba" | undefined;
2686
2740
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2741
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2687
2742
  }>>;
2688
2743
  conditions: z.ZodEffects<z.ZodObject<{
2689
2744
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -2869,16 +2924,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
2869
2924
  /** Menor avalia primeiro (first-match). */
2870
2925
  priority: z.ZodDefault<z.ZodNumber>;
2871
2926
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
2872
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
2927
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
2873
2928
  scope: z.ZodOptional<z.ZodObject<{
2874
2929
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
2875
2930
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
2931
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
2876
2932
  }, "strip", z.ZodTypeAny, {
2877
2933
  provider?: "chatbee" | "hub-waba" | undefined;
2878
2934
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2935
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2879
2936
  }, {
2880
2937
  provider?: "chatbee" | "hub-waba" | undefined;
2881
2938
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
2939
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
2882
2940
  }>>;
2883
2941
  conditions: z.ZodEffects<z.ZodObject<{
2884
2942
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -3001,16 +3059,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
3001
3059
  /** Menor avalia primeiro (first-match). */
3002
3060
  priority: z.ZodDefault<z.ZodNumber>;
3003
3061
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
3004
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
3062
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
3005
3063
  scope: z.ZodOptional<z.ZodObject<{
3006
3064
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
3007
3065
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
3066
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
3008
3067
  }, "strip", z.ZodTypeAny, {
3009
3068
  provider?: "chatbee" | "hub-waba" | undefined;
3010
3069
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3070
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3011
3071
  }, {
3012
3072
  provider?: "chatbee" | "hub-waba" | undefined;
3013
3073
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3074
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3014
3075
  }>>;
3015
3076
  conditions: z.ZodEffects<z.ZodObject<{
3016
3077
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -3133,16 +3194,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
3133
3194
  /** Menor avalia primeiro (first-match). */
3134
3195
  priority: z.ZodDefault<z.ZodNumber>;
3135
3196
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
3136
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
3197
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
3137
3198
  scope: z.ZodOptional<z.ZodObject<{
3138
3199
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
3139
3200
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
3201
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
3140
3202
  }, "strip", z.ZodTypeAny, {
3141
3203
  provider?: "chatbee" | "hub-waba" | undefined;
3142
3204
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3205
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3143
3206
  }, {
3144
3207
  provider?: "chatbee" | "hub-waba" | undefined;
3145
3208
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3209
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3146
3210
  }>>;
3147
3211
  conditions: z.ZodEffects<z.ZodObject<{
3148
3212
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -3265,16 +3329,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
3265
3329
  /** Menor avalia primeiro (first-match). */
3266
3330
  priority: z.ZodDefault<z.ZodNumber>;
3267
3331
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
3268
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
3332
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
3269
3333
  scope: z.ZodOptional<z.ZodObject<{
3270
3334
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
3271
3335
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
3336
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
3272
3337
  }, "strip", z.ZodTypeAny, {
3273
3338
  provider?: "chatbee" | "hub-waba" | undefined;
3274
3339
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3340
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3275
3341
  }, {
3276
3342
  provider?: "chatbee" | "hub-waba" | undefined;
3277
3343
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3344
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3278
3345
  }>>;
3279
3346
  conditions: z.ZodEffects<z.ZodObject<{
3280
3347
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -3397,16 +3464,19 @@ export declare const zAiBindingSchema: z.ZodObject<{
3397
3464
  /** Menor avalia primeiro (first-match). */
3398
3465
  priority: z.ZodDefault<z.ZodNumber>;
3399
3466
  phase: z.ZodDefault<z.ZodEnum<["pre_llm", "post_llm"]>>;
3400
- when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed"]>>;
3467
+ when: z.ZodDefault<z.ZodEnum<["inbound_message", "llm_completed", "outbound_message"]>>;
3401
3468
  scope: z.ZodOptional<z.ZodObject<{
3402
3469
  applies_to: z.ZodOptional<z.ZodOptional<z.ZodEnum<["real_message", "kickoff", "any"]>>>;
3403
3470
  provider: z.ZodOptional<z.ZodOptional<z.ZodEnum<["chatbee", "hub-waba"]>>>;
3471
+ outbound_source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["all", "llm_only", "non_system", "all_except_kickoff"]>>>;
3404
3472
  }, "strip", z.ZodTypeAny, {
3405
3473
  provider?: "chatbee" | "hub-waba" | undefined;
3406
3474
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3475
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3407
3476
  }, {
3408
3477
  provider?: "chatbee" | "hub-waba" | undefined;
3409
3478
  applies_to?: "real_message" | "kickoff" | "any" | undefined;
3479
+ outbound_source?: "all" | "llm_only" | "non_system" | "all_except_kickoff" | undefined;
3410
3480
  }>>;
3411
3481
  conditions: z.ZodEffects<z.ZodObject<{
3412
3482
  all: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zAiBindingSchema = exports.zHubiaRuleSchema = exports.zHubiaRulesModeSchema = exports.zHubiaRuleActionSchema = exports.zHubiaRuleScopeSchema = exports.zHubiaConditionGroupSchema = exports.zHubiaConditionSchema = exports.zHubiaScheduleSchema = exports.zHubiaScheduleWindowSchema = exports.zHubiaConditionOpSchema = exports.zHubiaRuleAppliesToSchema = exports.zHubiaRuleOutcomeSchema = exports.zHubiaRuleTriggerSchema = exports.zHubiaRulePhaseSchema = exports.zHubiaConversationModeSchema = exports.zHubiaConversationMessageSchema = exports.zHubiaV1ChannelConfigSchema = exports.zHubiaAttendanceModeSchema = void 0;
3
+ exports.zAiBindingSchema = exports.zHubiaRuleSchema = exports.zHubiaRulesModeSchema = exports.zHubiaRuleActionSchema = exports.zHubiaRuleScopeSchema = exports.zHubiaConditionGroupSchema = exports.zHubiaConditionSchema = exports.zHubiaScheduleSchema = exports.zHubiaScheduleWindowSchema = exports.zHubiaConditionOpSchema = exports.zHubiaOutboundSourceSchema = exports.zHubiaRuleAppliesToSchema = exports.zHubiaRuleOutcomeSchema = exports.zHubiaRuleTriggerSchema = exports.zHubiaRulePhaseSchema = exports.zHubiaConversationModeSchema = exports.zHubiaConversationMessageSchema = exports.zHubiaV1ChannelConfigSchema = exports.zHubiaAttendanceModeSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const zod_schemas_1 = require("../../shared/zod-schemas");
6
6
  // ───────── Attendance Mode (how AI operates on this channel) ─────────
@@ -84,24 +84,40 @@ exports.zHubiaConversationModeSchema = zod_1.z.enum(["ai_only", "hybrid_assist",
84
84
  // ───────── evo-hubia-rules (deterministic rule layer) ─────────
85
85
  //
86
86
  // Camada de regras determinísticas avaliada pelo motor `evo-hubia-rules`
87
- // (ver cloud-functions/docs/evo-hubia-rules/). Hooks suportados:
88
- // - `pre_llm` (v1.0) : avalia ANTES do orchestrator LLM rodar.
89
- // - `post_llm` (v1.1) : avalia DEPOIS do orchestrator e ANTES do envio
90
- // outbound; cobre safety/governance (content gate,
91
- // circuit breaker, salvaguarda pós-tool).
87
+ // (ver cloud-functions/docs/evo-hubia-rules/). A regra é identificada pela
88
+ // combinação ortogonal (trigger `when` × `phase`):
89
+ // - `when=inbound_message` + `phase=pre_llm` (v1.0) : avalia ANTES do
90
+ // orchestrator LLM rodar, na mensagem do paciente.
91
+ // - `when=llm_completed` + `phase=post_llm` (feat-026): avalia DEPOIS do
92
+ // orchestrator e ANTES do envio outbound; cobre
93
+ // safety/governance (content gate, circuit breaker).
94
+ // - `when=outbound_message` + `phase=pre_llm` (feat-027): avalia DEPOIS que
95
+ // uma mensagem outbound foi enviada ao paciente
96
+ // (reativo pós-fato, qualquer origem: LLM, operador,
97
+ // n8n, system). Executa side-effects; não muta a msg.
98
+ // - `when=outbound_message` + `phase=post_llm` : RESERVADO — habilitado
99
+ // quando "LLM em outbound" for liberado (fora de
100
+ // escopo na v1.0). Schema aceita, runtime não dispara.
92
101
  //
93
- // Matriz phase × outcome × when (enforced pelo superRefine de
94
- // `zHubiaRuleSchema` abaixo):
95
- // - pre_llm + when=inbound_message + outcome {stop,to_llm,to_llm_with_context}
96
- // - post_llm + when=llm_completed + outcome = stop
102
+ // Matriz when × outcome (enforced pelo superRefine de `zHubiaRuleSchema`):
103
+ // - inbound_message + outcome ∈ {stop, to_llm, to_llm_with_context}
104
+ // - llm_completed + outcome = stop
105
+ // - outbound_message + outcome = stop (to_llm reservado p/ LLM-em-outbound)
97
106
  //
98
107
  // As regras moram em `binding.rules[]` — o binding É o cruzamento canal⨯
99
108
  // departamento, então o escopo de departamento é implícito.
100
109
  /** Fase de avaliação. Tipos TS em src/types/evo-hub-ia/v1/. */
101
110
  exports.zHubiaRulePhaseSchema = zod_1.z.enum(["pre_llm", "post_llm"]);
102
- exports.zHubiaRuleTriggerSchema = zod_1.z.enum(["inbound_message", "llm_completed"]);
111
+ exports.zHubiaRuleTriggerSchema = zod_1.z.enum(["inbound_message", "llm_completed", "outbound_message"]);
103
112
  exports.zHubiaRuleOutcomeSchema = zod_1.z.enum(["stop", "to_llm", "to_llm_with_context"]);
104
113
  exports.zHubiaRuleAppliesToSchema = zod_1.z.enum(["real_message", "kickoff", "any"]);
114
+ /** Filtro por origem da mensagem outbound (apenas `when=outbound_message`).
115
+ * - `all` : qualquer origem dispara a regra.
116
+ * - `llm_only` : só mensagens geradas pelo LLM.
117
+ * - `non_system` : exclui mensagens sintéticas do sistema.
118
+ * - `all_except_kickoff` : default — exclui apenas msgs de kickoff de
119
+ * transferência (proteção contra loop). */
120
+ exports.zHubiaOutboundSourceSchema = zod_1.z.enum(["all", "llm_only", "non_system", "all_except_kickoff"]);
105
121
  exports.zHubiaConditionOpSchema = zod_1.z.enum([
106
122
  "exists", "not_exists",
107
123
  "is_empty", "is_not_empty",
@@ -178,6 +194,9 @@ exports.zHubiaConditionGroupSchema = zod_1.z.object({
178
194
  exports.zHubiaRuleScopeSchema = zod_1.z.object({
179
195
  applies_to: exports.zHubiaRuleAppliesToSchema.optional(),
180
196
  provider: zod_1.z.enum(["chatbee", "hub-waba"]).optional(),
197
+ /** Apenas `when=outbound_message`: filtra por origem da msg outbound.
198
+ * Default runtime quando ausente: `all_except_kickoff`. */
199
+ outbound_source: exports.zHubiaOutboundSourceSchema.optional(),
181
200
  }).partial();
182
201
  /** Uma ação a executar via ToolRegistry. `input` aceita templating
183
202
  * `{{fact.path}}` resolvido em runtime pelo facts provider. */
@@ -215,9 +234,12 @@ exports.zHubiaRuleSchema = zod_1.z.object({
215
234
  /** Aborta sequência de ações no primeiro erro. */
216
235
  stop_actions_on_error: zod_1.z.boolean().default(true),
217
236
  }).passthrough().superRefine((rule, ctx) => {
218
- // Matriz phase × outcome × when. pre_llm é permissivo (back-compat com
219
- // regras v1.0); post_llm é restrito a outcome=stop + when=llm_completed
220
- // (decisão C2 em features/feat-026-hubia-rules-v1-1/decisions.md).
237
+ // Matriz when × phase × outcome. inbound_message+pre_llm é permissivo
238
+ // (back-compat com regras v1.0); as demais combinações são restritas.
239
+ //
240
+ // - post_llm → outcome=stop + when=llm_completed (feat-026 C2)
241
+ // - outbound_message → outcome=stop (to_llm reservado p/ LLM-em-outbound,
242
+ // fora de escopo na feat-027)
221
243
  if (rule.phase === "post_llm") {
222
244
  if (rule.outcome !== "stop") {
223
245
  ctx.addIssue({
@@ -234,6 +256,13 @@ exports.zHubiaRuleSchema = zod_1.z.object({
234
256
  });
235
257
  }
236
258
  }
259
+ if (rule.when === "outbound_message" && rule.outcome !== "stop") {
260
+ ctx.addIssue({
261
+ code: zod_1.z.ZodIssueCode.custom,
262
+ path: ["outcome"],
263
+ message: "when=outbound_message aceita apenas outcome=stop (to_llm será habilitado quando LLM em outbound for liberado)",
264
+ });
265
+ }
237
266
  });
238
267
  // ───────── AI Binding (department → AI agent routing) ─────────
239
268
  const zHubiaCapabilitiesSchema = zod_1.z.object({
@@ -98,16 +98,25 @@ export type IHubiaConversationMode = z.infer<typeof zHubiaConversationModeSchema
98
98
  // ───────── evo-hubia-rules (deterministic rule layer) ─────────
99
99
  //
100
100
  // Camada de regras determinísticas avaliada pelo motor `evo-hubia-rules`
101
- // (ver cloud-functions/docs/evo-hubia-rules/). Hooks suportados:
102
- // - `pre_llm` (v1.0) : avalia ANTES do orchestrator LLM rodar.
103
- // - `post_llm` (v1.1) : avalia DEPOIS do orchestrator e ANTES do envio
104
- // outbound; cobre safety/governance (content gate,
105
- // circuit breaker, salvaguarda pós-tool).
101
+ // (ver cloud-functions/docs/evo-hubia-rules/). A regra é identificada pela
102
+ // combinação ortogonal (trigger `when` × `phase`):
103
+ // - `when=inbound_message` + `phase=pre_llm` (v1.0) : avalia ANTES do
104
+ // orchestrator LLM rodar, na mensagem do paciente.
105
+ // - `when=llm_completed` + `phase=post_llm` (feat-026): avalia DEPOIS do
106
+ // orchestrator e ANTES do envio outbound; cobre
107
+ // safety/governance (content gate, circuit breaker).
108
+ // - `when=outbound_message` + `phase=pre_llm` (feat-027): avalia DEPOIS que
109
+ // uma mensagem outbound foi enviada ao paciente
110
+ // (reativo pós-fato, qualquer origem: LLM, operador,
111
+ // n8n, system). Executa side-effects; não muta a msg.
112
+ // - `when=outbound_message` + `phase=post_llm` : RESERVADO — habilitado
113
+ // quando "LLM em outbound" for liberado (fora de
114
+ // escopo na v1.0). Schema aceita, runtime não dispara.
106
115
  //
107
- // Matriz phase × outcome × when (enforced pelo superRefine de
108
- // `zHubiaRuleSchema` abaixo):
109
- // - pre_llm + when=inbound_message + outcome {stop,to_llm,to_llm_with_context}
110
- // - post_llm + when=llm_completed + outcome = stop
116
+ // Matriz when × outcome (enforced pelo superRefine de `zHubiaRuleSchema`):
117
+ // - inbound_message + outcome ∈ {stop, to_llm, to_llm_with_context}
118
+ // - llm_completed + outcome = stop
119
+ // - outbound_message + outcome = stop (to_llm reservado p/ LLM-em-outbound)
111
120
  //
112
121
  // As regras moram em `binding.rules[]` — o binding É o cruzamento canal⨯
113
122
  // departamento, então o escopo de departamento é implícito.
@@ -115,12 +124,20 @@ export type IHubiaConversationMode = z.infer<typeof zHubiaConversationModeSchema
115
124
  /** Fase de avaliação. Tipos TS em src/types/evo-hub-ia/v1/. */
116
125
  export const zHubiaRulePhaseSchema = z.enum(["pre_llm", "post_llm"]);
117
126
 
118
- export const zHubiaRuleTriggerSchema = z.enum(["inbound_message", "llm_completed"]);
127
+ export const zHubiaRuleTriggerSchema = z.enum(["inbound_message", "llm_completed", "outbound_message"]);
119
128
 
120
129
  export const zHubiaRuleOutcomeSchema = z.enum(["stop", "to_llm", "to_llm_with_context"]);
121
130
 
122
131
  export const zHubiaRuleAppliesToSchema = z.enum(["real_message", "kickoff", "any"]);
123
132
 
133
+ /** Filtro por origem da mensagem outbound (apenas `when=outbound_message`).
134
+ * - `all` : qualquer origem dispara a regra.
135
+ * - `llm_only` : só mensagens geradas pelo LLM.
136
+ * - `non_system` : exclui mensagens sintéticas do sistema.
137
+ * - `all_except_kickoff` : default — exclui apenas msgs de kickoff de
138
+ * transferência (proteção contra loop). */
139
+ export const zHubiaOutboundSourceSchema = z.enum(["all", "llm_only", "non_system", "all_except_kickoff"]);
140
+
124
141
  export const zHubiaConditionOpSchema = z.enum([
125
142
  "exists", "not_exists",
126
143
  "is_empty", "is_not_empty",
@@ -206,6 +223,9 @@ export const zHubiaConditionGroupSchema = z.object({
206
223
  export const zHubiaRuleScopeSchema = z.object({
207
224
  applies_to: zHubiaRuleAppliesToSchema.optional(),
208
225
  provider: z.enum(["chatbee", "hub-waba"]).optional(),
226
+ /** Apenas `when=outbound_message`: filtra por origem da msg outbound.
227
+ * Default runtime quando ausente: `all_except_kickoff`. */
228
+ outbound_source: zHubiaOutboundSourceSchema.optional(),
209
229
  }).partial();
210
230
 
211
231
  /** Uma ação a executar via ToolRegistry. `input` aceita templating
@@ -250,9 +270,12 @@ export const zHubiaRuleSchema = z.object({
250
270
  /** Aborta sequência de ações no primeiro erro. */
251
271
  stop_actions_on_error: z.boolean().default(true),
252
272
  }).passthrough().superRefine((rule, ctx) => {
253
- // Matriz phase × outcome × when. pre_llm é permissivo (back-compat com
254
- // regras v1.0); post_llm é restrito a outcome=stop + when=llm_completed
255
- // (decisão C2 em features/feat-026-hubia-rules-v1-1/decisions.md).
273
+ // Matriz when × phase × outcome. inbound_message+pre_llm é permissivo
274
+ // (back-compat com regras v1.0); as demais combinações são restritas.
275
+ //
276
+ // - post_llm → outcome=stop + when=llm_completed (feat-026 C2)
277
+ // - outbound_message → outcome=stop (to_llm reservado p/ LLM-em-outbound,
278
+ // fora de escopo na feat-027)
256
279
  if (rule.phase === "post_llm") {
257
280
  if (rule.outcome !== "stop") {
258
281
  ctx.addIssue({
@@ -269,6 +292,13 @@ export const zHubiaRuleSchema = z.object({
269
292
  });
270
293
  }
271
294
  }
295
+ if (rule.when === "outbound_message" && rule.outcome !== "stop") {
296
+ ctx.addIssue({
297
+ code: z.ZodIssueCode.custom,
298
+ path: ["outcome"],
299
+ message: "when=outbound_message aceita apenas outcome=stop (to_llm será habilitado quando LLM em outbound for liberado)",
300
+ });
301
+ }
272
302
  });
273
303
 
274
304
  // ───────── AI Binding (department → AI agent routing) ─────────
@@ -30,8 +30,17 @@ export interface IMessageLocation {
30
30
  name?: string;
31
31
  address?: string;
32
32
  }
33
+ export type InteractiveMessageType = 'button_reply' | 'list_reply' | 'call_permission_reply' | 'call_permission_request';
34
+ /** Resposta do paciente a um pedido de permissão de ligação (WhatsApp Calling API). */
35
+ export interface ICallPermissionReply {
36
+ response?: 'accept' | 'reject';
37
+ is_permanent?: boolean;
38
+ /** Unix timestamp (segundos) — presente em permissões temporárias aceitas. */
39
+ expiration_timestamp?: number | string;
40
+ response_source?: 'user_action' | 'automatic';
41
+ }
33
42
  export interface IMessageInteractive {
34
- type: 'button_reply' | 'list_reply';
43
+ type: InteractiveMessageType | string;
35
44
  button_reply?: {
36
45
  id: string;
37
46
  title: string;
@@ -41,6 +50,7 @@ export interface IMessageInteractive {
41
50
  title: string;
42
51
  description?: string;
43
52
  };
53
+ call_permission_reply?: ICallPermissionReply;
44
54
  }
45
55
  export interface IMessageReaction {
46
56
  message_id: string;
@@ -48,10 +48,26 @@ export interface IMessageLocation {
48
48
 
49
49
  // ── Message interactive ──
50
50
 
51
+ export type InteractiveMessageType =
52
+ | 'button_reply'
53
+ | 'list_reply'
54
+ | 'call_permission_reply'
55
+ | 'call_permission_request';
56
+
57
+ /** Resposta do paciente a um pedido de permissão de ligação (WhatsApp Calling API). */
58
+ export interface ICallPermissionReply {
59
+ response?: 'accept' | 'reject';
60
+ is_permanent?: boolean;
61
+ /** Unix timestamp (segundos) — presente em permissões temporárias aceitas. */
62
+ expiration_timestamp?: number | string;
63
+ response_source?: 'user_action' | 'automatic';
64
+ }
65
+
51
66
  export interface IMessageInteractive {
52
- type: 'button_reply' | 'list_reply';
67
+ type: InteractiveMessageType | string;
53
68
  button_reply?: { id: string; title: string };
54
69
  list_reply?: { id: string; title: string; description?: string };
70
+ call_permission_reply?: ICallPermissionReply;
55
71
  }
56
72
 
57
73
  // ── Message reaction ──
@@ -1,26 +1,41 @@
1
1
  /** Fase de avaliação.
2
2
  * - `pre_llm` (v1.0) : avalia antes do orchestrator LLM.
3
3
  * - `post_llm` (v1.1) : avalia depois do orchestrator e antes do envio
4
- * outbound (safety/governance). */
4
+ * outbound (safety/governance).
5
+ * Ortogonal ao `when` (trigger): regras outbound (feat-027) usam
6
+ * `when=outbound_message + phase=pre_llm`. O par
7
+ * `outbound_message + post_llm` fica reservado p/ LLM-em-outbound futuro. */
5
8
  export type IHubiaRulePhase = "pre_llm" | "post_llm";
6
- /** Gatilho que dispara a avaliação. Correlacionado com `phase`:
7
- * pre_llm inbound_message; post_llm → llm_completed (validado pelo
8
- * superRefine de `zHubiaRuleSchema`). */
9
- export type IHubiaRuleTrigger = "inbound_message" | "llm_completed";
9
+ /** Gatilho que dispara a avaliação. Combinações válidas com `phase`
10
+ * (validado pelo superRefine de `zHubiaRuleSchema`):
11
+ * - `inbound_message` + pre_llm : mensagem do paciente (v1.0).
12
+ * - `llm_completed` + post_llm : turno do LLM concluído (feat-026).
13
+ * - `outbound_message` + pre_llm : mensagem enviada ao paciente, reativo
14
+ * pós-fato (feat-027). */
15
+ export type IHubiaRuleTrigger = "inbound_message" | "llm_completed" | "outbound_message";
10
16
  /** Desfecho do turno após a regra disparar:
11
17
  * - `stop` — finaliza turno; em pre_llm pula o LLM,
12
- * em post_llm bloqueia o envio outbound (único
13
- * outcome permitido em post_llm).
18
+ * em post_llm bloqueia o envio outbound, em
19
+ * outbound_message apenas registra trace + executa
20
+ * actions (msg já saiu). Único outcome permitido
21
+ * em post_llm e outbound_message.
14
22
  * - `to_llm` — segue para o orchestrator normalmente
15
- * (apenas pre_llm).
23
+ * (apenas inbound_message + pre_llm).
16
24
  * - `to_llm_with_context` — segue para o orchestrator com trace das ações
17
- * injetado como bloco de sistema (apenas pre_llm).
25
+ * injetado como bloco de sistema (apenas
26
+ * inbound_message + pre_llm).
18
27
  * Quando o LLM está desligado no binding (default_mode `human_only`/`blocked`),
19
28
  * `to_llm`/`to_llm_with_context` degradam para "cai pro humano". */
20
29
  export type IHubiaRuleOutcome = "stop" | "to_llm" | "to_llm_with_context";
21
30
  /** Tipo de batch ao qual a regra se aplica. `real_message` (default) ignora
22
31
  * a mensagem de kickoff do sistema — proteção contra loop de transferência. */
23
32
  export type IHubiaRuleAppliesTo = "real_message" | "kickoff" | "any";
33
+ /** Filtro por origem da mensagem outbound (apenas `when=outbound_message`).
34
+ * - `all` : qualquer origem dispara.
35
+ * - `llm_only` : só mensagens do LLM.
36
+ * - `non_system` : exclui mensagens sintéticas do sistema.
37
+ * - `all_except_kickoff` : default — exclui apenas kickoff de transferência. */
38
+ export type IHubiaOutboundSource = "all" | "llm_only" | "non_system" | "all_except_kickoff";
24
39
  /** Operadores suportados pelas condições.
25
40
  *
26
41
  * `in_schedule` / `not_in_schedule` esperam `value: IHubiaSchedule` e
@@ -79,6 +94,9 @@ export interface IHubiaConditionGroup {
79
94
  export interface IHubiaRuleScope {
80
95
  applies_to?: IHubiaRuleAppliesTo;
81
96
  provider?: "chatbee" | "hub-waba";
97
+ /** Apenas `when=outbound_message`: filtra por origem da msg outbound.
98
+ * Default runtime quando ausente: `all_except_kickoff`. */
99
+ outbound_source?: IHubiaOutboundSource;
82
100
  }
83
101
  /** Uma ação a executar via ToolRegistry. `input` aceita templating
84
102
  * `{{fact.path}}` resolvido em runtime pelo facts provider. */
@@ -10,22 +10,31 @@
10
10
  /** Fase de avaliação.
11
11
  * - `pre_llm` (v1.0) : avalia antes do orchestrator LLM.
12
12
  * - `post_llm` (v1.1) : avalia depois do orchestrator e antes do envio
13
- * outbound (safety/governance). */
13
+ * outbound (safety/governance).
14
+ * Ortogonal ao `when` (trigger): regras outbound (feat-027) usam
15
+ * `when=outbound_message + phase=pre_llm`. O par
16
+ * `outbound_message + post_llm` fica reservado p/ LLM-em-outbound futuro. */
14
17
  export type IHubiaRulePhase = "pre_llm" | "post_llm";
15
18
 
16
- /** Gatilho que dispara a avaliação. Correlacionado com `phase`:
17
- * pre_llm inbound_message; post_llm → llm_completed (validado pelo
18
- * superRefine de `zHubiaRuleSchema`). */
19
- export type IHubiaRuleTrigger = "inbound_message" | "llm_completed";
19
+ /** Gatilho que dispara a avaliação. Combinações válidas com `phase`
20
+ * (validado pelo superRefine de `zHubiaRuleSchema`):
21
+ * - `inbound_message` + pre_llm : mensagem do paciente (v1.0).
22
+ * - `llm_completed` + post_llm : turno do LLM concluído (feat-026).
23
+ * - `outbound_message` + pre_llm : mensagem enviada ao paciente, reativo
24
+ * pós-fato (feat-027). */
25
+ export type IHubiaRuleTrigger = "inbound_message" | "llm_completed" | "outbound_message";
20
26
 
21
27
  /** Desfecho do turno após a regra disparar:
22
28
  * - `stop` — finaliza turno; em pre_llm pula o LLM,
23
- * em post_llm bloqueia o envio outbound (único
24
- * outcome permitido em post_llm).
29
+ * em post_llm bloqueia o envio outbound, em
30
+ * outbound_message apenas registra trace + executa
31
+ * actions (msg já saiu). Único outcome permitido
32
+ * em post_llm e outbound_message.
25
33
  * - `to_llm` — segue para o orchestrator normalmente
26
- * (apenas pre_llm).
34
+ * (apenas inbound_message + pre_llm).
27
35
  * - `to_llm_with_context` — segue para o orchestrator com trace das ações
28
- * injetado como bloco de sistema (apenas pre_llm).
36
+ * injetado como bloco de sistema (apenas
37
+ * inbound_message + pre_llm).
29
38
  * Quando o LLM está desligado no binding (default_mode `human_only`/`blocked`),
30
39
  * `to_llm`/`to_llm_with_context` degradam para "cai pro humano". */
31
40
  export type IHubiaRuleOutcome = "stop" | "to_llm" | "to_llm_with_context";
@@ -34,6 +43,13 @@ export type IHubiaRuleOutcome = "stop" | "to_llm" | "to_llm_with_context";
34
43
  * a mensagem de kickoff do sistema — proteção contra loop de transferência. */
35
44
  export type IHubiaRuleAppliesTo = "real_message" | "kickoff" | "any";
36
45
 
46
+ /** Filtro por origem da mensagem outbound (apenas `when=outbound_message`).
47
+ * - `all` : qualquer origem dispara.
48
+ * - `llm_only` : só mensagens do LLM.
49
+ * - `non_system` : exclui mensagens sintéticas do sistema.
50
+ * - `all_except_kickoff` : default — exclui apenas kickoff de transferência. */
51
+ export type IHubiaOutboundSource = "all" | "llm_only" | "non_system" | "all_except_kickoff";
52
+
37
53
  /** Operadores suportados pelas condições.
38
54
  *
39
55
  * `in_schedule` / `not_in_schedule` esperam `value: IHubiaSchedule` e
@@ -117,6 +133,9 @@ export interface IHubiaConditionGroup {
117
133
  export interface IHubiaRuleScope {
118
134
  applies_to?: IHubiaRuleAppliesTo;
119
135
  provider?: "chatbee" | "hub-waba";
136
+ /** Apenas `when=outbound_message`: filtra por origem da msg outbound.
137
+ * Default runtime quando ausente: `all_except_kickoff`. */
138
+ outbound_source?: IHubiaOutboundSource;
120
139
  }
121
140
 
122
141
  /** Uma ação a executar via ToolRegistry. `input` aceita templating
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evo360-types",
3
- "version": "1.3.376",
3
+ "version": "1.3.377",
4
4
  "description": "HREVO360 Shared Types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",