@adatechnology/meta-whatsapp-module 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,9 +2,10 @@ import { PreviewInboundCommand, PreviewPayloadEnvelope } from '@adatechnology/me
2
2
  import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
3
3
  import { PgAsyncDatabase, PgQueryResultHKT } from 'drizzle-orm/pg-core';
4
4
  import * as _adatechnology_meta_whatsapp_contracts from '@adatechnology/meta-whatsapp-contracts';
5
- import { TranscriptionMode, SessionState, SessionMode, ConversationSummary, MessageDirection, MessageSender, MessageStatus, WhatsAppStatusError, CacheInterface, FlowGraphData, FlowGraphSummary, LiveFlowPosition, WhatsAppSettings, RealtimeNotifierInterface, ChannelAdapterInterface, ObjectStorageInterface, InteractiveMessage, MetaWhatsAppHooks, FlowActionKind, FlowActionHandler, ConversationSession, FlowNodeData, FlowAnswerRejection, FlowDateLocale, BusinessHours, InterpolateFlowTextOptions, DynamicChoiceProvider, WhatsAppMessage, WhatsAppStatus, SubjectResolverInterface, CatalogPort, SendChannelMediaParams, ChannelInteractiveListParams, ChannelInteractiveButtonsParams, FlowClock } from '@adatechnology/meta-whatsapp-contracts';
5
+ import { TranscriptionMode, SessionState, SessionMode, ConversationSummary, MessageDirection, MessageSender, MessageStatus, WhatsAppStatusError, CacheInterface, FlowGraphData, FlowGraphSummary, LiveFlowPosition, WhatsAppSettings, RealtimeNotifierInterface, ChannelAdapterInterface, ObjectStorageInterface, InteractiveMessage, MetaWhatsAppHooks, WhatsAppQuickReplyInput, ListWhatsAppQuickRepliesQuery, WhatsAppQuickReply, FlowActionKind, FlowActionHandler, ConversationSession, FlowNodeData, FlowAnswerRejection, FlowDateLocale, BusinessHours, InterpolateFlowTextOptions, DynamicChoiceProvider, WhatsAppMessage, WhatsAppStatus, SubjectResolverInterface, CatalogPort, SendChannelMediaParams, ChannelInteractiveListParams, ChannelInteractiveButtonsParams, FlowClock } from '@adatechnology/meta-whatsapp-contracts';
6
6
  export { PREVIEW_MEDIA_ID_PREFIX, TranscriptionMode, resolvePreviewUploadId, toPreviewMediaId } from '@adatechnology/meta-whatsapp-contracts';
7
7
  import { WhatsAppMessageProvider } from '@adatechnology/meta-whatsapp-provider';
8
+ import { ModuleRouteTable } from '@adatechnology/module-http';
8
9
  export { WEBHOOK_CLAIM_TTL_SECONDS, WEBHOOK_NONCE_TTL_SECONDS } from '@adatechnology/meta-graph-core';
9
10
 
10
11
  type QueryBuilderMethod = (...args: never[]) => unknown;
@@ -963,6 +964,36 @@ declare const flowGraphs: drizzle_orm_pg_core.PgTableWithColumns<{
963
964
  identity: undefined;
964
965
  generated: undefined;
965
966
  }>;
967
+ origin: drizzle_orm_pg_core.PgBuildColumn<"flow_graphs", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgVarcharBuilder<[string, ...string[]]>>>, {
968
+ name: string;
969
+ tableName: "flow_graphs";
970
+ dataType: "string";
971
+ data: string;
972
+ driverParam: string;
973
+ notNull: true;
974
+ hasDefault: true;
975
+ isPrimaryKey: false;
976
+ isAutoincrement: false;
977
+ hasRuntimeDefault: false;
978
+ enumValues: undefined;
979
+ identity: undefined;
980
+ generated: undefined;
981
+ }>;
982
+ seedVersion: drizzle_orm_pg_core.PgBuildColumn<"flow_graphs", drizzle_orm_pg_core.PgVarcharBuilder<[string, ...string[]]>, {
983
+ name: string;
984
+ tableName: "flow_graphs";
985
+ dataType: "string";
986
+ data: string;
987
+ driverParam: string;
988
+ notNull: false;
989
+ hasDefault: false;
990
+ isPrimaryKey: false;
991
+ isAutoincrement: false;
992
+ hasRuntimeDefault: false;
993
+ enumValues: undefined;
994
+ identity: undefined;
995
+ generated: undefined;
996
+ }>;
966
997
  createdAt: drizzle_orm_pg_core.PgBuildColumn<"flow_graphs", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTimestampBuilder>>, {
967
998
  name: string;
968
999
  tableName: "flow_graphs";
@@ -1226,6 +1257,139 @@ declare const flowMedia: drizzle_orm_pg_core.PgTableWithColumns<{
1226
1257
  };
1227
1258
  dialect: "pg";
1228
1259
  }>;
1260
+ /**
1261
+ * Respostas rápidas por empresa — o texto pronto que o atendente chama com `/atalho` no composer.
1262
+ *
1263
+ * Só texto: anexos de resposta rápida não existem aqui. O atalho é único por empresa, e a lista
1264
+ * volta inteira (teto em `QUICK_REPLY_LIMITS.MAX_PER_COMPANY`), ordenada por `sortOrder`.
1265
+ */
1266
+ declare const quickReplies: drizzle_orm_pg_core.PgTableWithColumns<{
1267
+ name: "quick_replies";
1268
+ schema: "meta_whatsapp";
1269
+ columns: {
1270
+ id: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetIsPrimaryKey<drizzle_orm_pg_core.PgUUIDBuilder>>, {
1271
+ name: string;
1272
+ tableName: "quick_replies";
1273
+ dataType: "string uuid";
1274
+ data: string;
1275
+ driverParam: string;
1276
+ notNull: true;
1277
+ hasDefault: true;
1278
+ isPrimaryKey: false;
1279
+ isAutoincrement: false;
1280
+ hasRuntimeDefault: false;
1281
+ enumValues: undefined;
1282
+ identity: undefined;
1283
+ generated: undefined;
1284
+ }>;
1285
+ companyId: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgUUIDBuilder>, {
1286
+ name: string;
1287
+ tableName: "quick_replies";
1288
+ dataType: "string uuid";
1289
+ data: string;
1290
+ driverParam: string;
1291
+ notNull: true;
1292
+ hasDefault: false;
1293
+ isPrimaryKey: false;
1294
+ isAutoincrement: false;
1295
+ hasRuntimeDefault: false;
1296
+ enumValues: undefined;
1297
+ identity: undefined;
1298
+ generated: undefined;
1299
+ }>;
1300
+ title: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgVarcharBuilder<[string, ...string[]]>>, {
1301
+ name: string;
1302
+ tableName: "quick_replies";
1303
+ dataType: "string";
1304
+ data: string;
1305
+ driverParam: string;
1306
+ notNull: true;
1307
+ hasDefault: false;
1308
+ isPrimaryKey: false;
1309
+ isAutoincrement: false;
1310
+ hasRuntimeDefault: false;
1311
+ enumValues: undefined;
1312
+ identity: undefined;
1313
+ generated: undefined;
1314
+ }>;
1315
+ shortcut: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgVarcharBuilder<[string, ...string[]]>>, {
1316
+ name: string;
1317
+ tableName: "quick_replies";
1318
+ dataType: "string";
1319
+ data: string;
1320
+ driverParam: string;
1321
+ notNull: true;
1322
+ hasDefault: false;
1323
+ isPrimaryKey: false;
1324
+ isAutoincrement: false;
1325
+ hasRuntimeDefault: false;
1326
+ enumValues: undefined;
1327
+ identity: undefined;
1328
+ generated: undefined;
1329
+ }>;
1330
+ body: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgVarcharBuilder<[string, ...string[]]>>, {
1331
+ name: string;
1332
+ tableName: "quick_replies";
1333
+ dataType: "string";
1334
+ data: string;
1335
+ driverParam: string;
1336
+ notNull: true;
1337
+ hasDefault: false;
1338
+ isPrimaryKey: false;
1339
+ isAutoincrement: false;
1340
+ hasRuntimeDefault: false;
1341
+ enumValues: undefined;
1342
+ identity: undefined;
1343
+ generated: undefined;
1344
+ }>;
1345
+ sortOrder: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgIntegerBuilder>>, {
1346
+ name: string;
1347
+ tableName: "quick_replies";
1348
+ dataType: "number int32";
1349
+ data: number;
1350
+ driverParam: string | number;
1351
+ notNull: true;
1352
+ hasDefault: true;
1353
+ isPrimaryKey: false;
1354
+ isAutoincrement: false;
1355
+ hasRuntimeDefault: false;
1356
+ enumValues: undefined;
1357
+ identity: undefined;
1358
+ generated: undefined;
1359
+ }>;
1360
+ createdAt: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTimestampBuilder>>, {
1361
+ name: string;
1362
+ tableName: "quick_replies";
1363
+ dataType: "object date";
1364
+ data: Date;
1365
+ driverParam: string;
1366
+ notNull: true;
1367
+ hasDefault: true;
1368
+ isPrimaryKey: false;
1369
+ isAutoincrement: false;
1370
+ hasRuntimeDefault: false;
1371
+ enumValues: undefined;
1372
+ identity: undefined;
1373
+ generated: undefined;
1374
+ }>;
1375
+ updatedAt: drizzle_orm_pg_core.PgBuildColumn<"quick_replies", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTimestampBuilder>>, {
1376
+ name: string;
1377
+ tableName: "quick_replies";
1378
+ dataType: "object date";
1379
+ data: Date;
1380
+ driverParam: string;
1381
+ notNull: true;
1382
+ hasDefault: true;
1383
+ isPrimaryKey: false;
1384
+ isAutoincrement: false;
1385
+ hasRuntimeDefault: false;
1386
+ enumValues: undefined;
1387
+ identity: undefined;
1388
+ generated: undefined;
1389
+ }>;
1390
+ };
1391
+ dialect: "pg";
1392
+ }>;
1229
1393
  declare const settings: drizzle_orm_pg_core.PgTableWithColumns<{
1230
1394
  name: "settings";
1231
1395
  schema: "meta_whatsapp";
@@ -1395,6 +1559,8 @@ type DocumentRow = typeof documents.$inferSelect;
1395
1559
  type NewDocumentRow = typeof documents.$inferInsert;
1396
1560
  type FlowMediaRow = typeof flowMedia.$inferSelect;
1397
1561
  type NewFlowMediaRow = typeof flowMedia.$inferInsert;
1562
+ type QuickReplyRow = typeof quickReplies.$inferSelect;
1563
+ type NewQuickReplyRow = typeof quickReplies.$inferInsert;
1398
1564
 
1399
1565
  interface ListConversationsFilters {
1400
1566
  page?: number;
@@ -1632,6 +1798,22 @@ declare class InvalidFlowGraphError extends Error {
1632
1798
  readonly validationMessage: string;
1633
1799
  constructor(key: string, validationMessage: string);
1634
1800
  }
1801
+ type ReseedFlowGraphParams = {
1802
+ readonly companyId: string;
1803
+ readonly key: string;
1804
+ readonly seedVersion: string;
1805
+ readonly content: Pick<FlowGraphData, 'label' | 'startNodeId' | 'nodes'>;
1806
+ };
1807
+ /**
1808
+ * `updated`: o grafo era seed de outra versão e foi substituído. `current`: já está nessa versão do seed.
1809
+ * `edited`: alguém mexeu pelo editor (ou o grafo é anterior ao campo) — intocado. `missing`: não existe.
1810
+ */
1811
+ type ReseedFlowGraphResult = {
1812
+ readonly status: 'updated';
1813
+ readonly graph: FlowGraphData;
1814
+ } | {
1815
+ readonly status: 'current' | 'edited' | 'missing';
1816
+ };
1635
1817
  declare class OptimisticLockError extends Error {
1636
1818
  constructor(key: string);
1637
1819
  }
@@ -1642,11 +1824,17 @@ declare class FlowGraphRepository {
1642
1824
  get(companyId: string, key: string): Promise<FlowGraphData | undefined>;
1643
1825
  list(companyId: string): Promise<FlowGraphSummary[]>;
1644
1826
  private assertValidNodes;
1645
- create(companyId: string, graph: Omit<FlowGraphData, 'version'> & {
1827
+ create(companyId: string, graph: Omit<FlowGraphData, 'version' | 'origin'> & {
1646
1828
  showInMenu?: boolean;
1647
1829
  menuOptionLabel?: string;
1648
1830
  }): Promise<FlowGraphData>;
1649
1831
  save(companyId: string, graph: FlowGraphData, expectedVersion: number): Promise<FlowGraphData>;
1832
+ /**
1833
+ * Atualiza um grafo semeado que ninguém editou. A condição `origin = 'seed'` vai no próprio UPDATE:
1834
+ * se uma pessoa salvar pelo editor entre a leitura e a escrita, o grafo vira `edited` e este update
1835
+ * não casa nenhuma linha — a edição nunca é sobrescrita. Idempotente por `seedVersion`.
1836
+ */
1837
+ reseed(params: ReseedFlowGraphParams): Promise<ReseedFlowGraphResult>;
1650
1838
  delete(companyId: string, key: string): Promise<void>;
1651
1839
  getLiveFlowPositions(companyId: string): Promise<LiveFlowPosition[]>;
1652
1840
  }
@@ -2097,6 +2285,62 @@ declare class RedactInboundLocationsUseCase {
2097
2285
  execute(params: RedactInboundLocationsParams): Promise<RedactInboundLocationsResult>;
2098
2286
  }
2099
2287
 
2288
+ type ListQuickRepliesParams$1 = {
2289
+ companyId: string;
2290
+ search?: string;
2291
+ };
2292
+ type CreateQuickReplyParams = WhatsAppQuickReplyInput & {
2293
+ companyId: string;
2294
+ };
2295
+ type UpdateQuickReplyParams$1 = WhatsAppQuickReplyInput & {
2296
+ companyId: string;
2297
+ id: string;
2298
+ };
2299
+ declare class QuickReplyRepository {
2300
+ private readonly db;
2301
+ constructor(db: MetaWhatsAppDatabase);
2302
+ list(params: ListQuickRepliesParams$1): Promise<QuickReplyRow[]>;
2303
+ get(companyId: string, id: string): Promise<QuickReplyRow | undefined>;
2304
+ create(params: CreateQuickReplyParams): Promise<QuickReplyRow>;
2305
+ update(params: UpdateQuickReplyParams$1): Promise<QuickReplyRow>;
2306
+ delete(companyId: string, id: string): Promise<boolean>;
2307
+ }
2308
+
2309
+ declare function toQuickReplyView(row: QuickReplyRow): WhatsAppQuickReply;
2310
+ type ListQuickRepliesParams = ListWhatsAppQuickRepliesQuery & {
2311
+ companyId: string;
2312
+ };
2313
+ type SaveQuickReplyParams = WhatsAppQuickReplyInput & {
2314
+ companyId: string;
2315
+ };
2316
+ type UpdateQuickReplyParams = SaveQuickReplyParams & {
2317
+ id: string;
2318
+ };
2319
+ type DeleteQuickReplyParams = {
2320
+ companyId: string;
2321
+ id: string;
2322
+ };
2323
+ declare class ListQuickRepliesUseCase {
2324
+ private readonly repository;
2325
+ constructor(repository: QuickReplyRepository);
2326
+ execute(params: ListQuickRepliesParams): Promise<WhatsAppQuickReply[]>;
2327
+ }
2328
+ declare class CreateQuickReplyUseCase {
2329
+ private readonly repository;
2330
+ constructor(repository: QuickReplyRepository);
2331
+ execute(params: SaveQuickReplyParams): Promise<WhatsAppQuickReply>;
2332
+ }
2333
+ declare class UpdateQuickReplyUseCase {
2334
+ private readonly repository;
2335
+ constructor(repository: QuickReplyRepository);
2336
+ execute(params: UpdateQuickReplyParams): Promise<WhatsAppQuickReply>;
2337
+ }
2338
+ declare class DeleteQuickReplyUseCase {
2339
+ private readonly repository;
2340
+ constructor(repository: QuickReplyRepository);
2341
+ execute(params: DeleteQuickReplyParams): Promise<void>;
2342
+ }
2343
+
2100
2344
  type ExportConversationParams = {
2101
2345
  companyId: string;
2102
2346
  whatsappNumber: string;
@@ -2134,6 +2378,8 @@ type CreateFlowGraphParams = {
2134
2378
  nodes: FlowGraphData['nodes'];
2135
2379
  showInMenu?: boolean;
2136
2380
  menuOptionLabel?: string;
2381
+ /** Só o produto semeando informa: marca o grafo como `seed` dessa versão (ver `ReseedFlowGraphUseCase`). */
2382
+ seedVersion?: string;
2137
2383
  };
2138
2384
  declare class CreateFlowGraphUseCase {
2139
2385
  private readonly flowGraphRepository;
@@ -2150,6 +2396,15 @@ declare class SaveFlowGraphUseCase {
2150
2396
  constructor(flowGraphRepository: FlowGraphRepository);
2151
2397
  execute(params: SaveFlowGraphParams): Promise<FlowGraphData>;
2152
2398
  }
2399
+ /**
2400
+ * Atualiza grafos semeados que o dono nunca editou quando o seed do produto muda, sem apagar à mão.
2401
+ * Grafo editado pelo painel (ou anterior ao campo `origin`) nunca é tocado.
2402
+ */
2403
+ declare class ReseedFlowGraphUseCase {
2404
+ private readonly flowGraphRepository;
2405
+ constructor(flowGraphRepository: FlowGraphRepository);
2406
+ execute(params: ReseedFlowGraphParams): Promise<ReseedFlowGraphResult>;
2407
+ }
2153
2408
  declare class DeleteFlowGraphUseCase {
2154
2409
  private readonly flowGraphRepository;
2155
2410
  constructor(flowGraphRepository: FlowGraphRepository);
@@ -2306,6 +2561,23 @@ type FlowVariablesResolver = (params: {
2306
2561
  readonly session: ConversationSession;
2307
2562
  readonly profileName?: string;
2308
2563
  }) => Promise<Readonly<Record<string, unknown>>>;
2564
+ /**
2565
+ * Retentativa do envio de saída do robô (cada mensagem do turno, uma a uma). Só repete falha em que a
2566
+ * mensagem não chegou à Meta (ver `isTransientSendError`); vale a pena porque o turno já foi
2567
+ * reivindicado e o cliente, sem isto, ficaria sem resposta até escrever de novo.
2568
+ */
2569
+ type FlowSendRetryConfig = {
2570
+ /** Tentativas por mensagem, contando a primeira. Padrão 3; 1 desliga a retentativa. */
2571
+ readonly maxAttempts?: number;
2572
+ /** Espera antes da 2ª tentativa; dobra a cada falha. Padrão 500 ms. */
2573
+ readonly baseDelayMs?: number;
2574
+ /** Teto da espera. Padrão 5000 ms. */
2575
+ readonly maxDelayMs?: number;
2576
+ /** Decide se a falha vale outra tentativa. Padrão: falha de rede (`isTransientSendError`). */
2577
+ readonly shouldRetry?: (error: unknown) => boolean;
2578
+ /** Espera injetável para teste. */
2579
+ readonly sleep?: (milliseconds: number) => Promise<void>;
2580
+ };
2309
2581
  type FlowRunnerConfig = {
2310
2582
  /** Fluxo de quem chega sem conversa em andamento. Padrão `main`. */
2311
2583
  readonly startFlowKey?: string;
@@ -2318,6 +2590,7 @@ type FlowRunnerConfig = {
2318
2590
  readonly rejectionMessages?: Partial<Record<FlowAnswerRejection, FlowConfigText>>;
2319
2591
  /** Corpo de escolha quando o nó não tem `question` (a Meta exige corpo). */
2320
2592
  readonly choicePrompt?: string;
2593
+ /** Texto do botão que abre a lista; aceita `{{chave}}`, como o título das opções. Acima de 20 caracteres a escolha sai numerada. */
2321
2594
  readonly listButtonLabel?: string;
2322
2595
  /** Rótulo da linha que pede a próxima página de um `dynamic_choice`. */
2323
2596
  readonly seeMoreLabel?: string;
@@ -2346,6 +2619,8 @@ type FlowRunnerConfig = {
2346
2619
  readonly dynamicChoiceProviders?: Readonly<Record<string, DynamicChoiceProvider>>;
2347
2620
  /** Saltos `flow:` seguidos numa mesma mensagem antes de desistir (protege de ciclo entre fluxos). Padrão 5. */
2348
2621
  readonly maxCrossFlowJumps?: number;
2622
+ /** Retentativa do envio de saída. Ausente, valem os padrões de `FlowSendRetryConfig`. */
2623
+ readonly sendRetry?: FlowSendRetryConfig;
2349
2624
  /** Relógio injetável para teste. */
2350
2625
  readonly now?: () => Date;
2351
2626
  };
@@ -2472,6 +2747,7 @@ declare class FlowRunner {
2472
2747
  private readonly renderer;
2473
2748
  private readonly timeZone;
2474
2749
  private readonly turnVariables;
2750
+ private readonly sendFailures;
2475
2751
  constructor(dependencies: FlowRunnerDependencies);
2476
2752
  registerDynamicChoiceProvider(key: string, provider: DynamicChoiceProvider): void;
2477
2753
  /**
@@ -2523,6 +2799,10 @@ declare class FlowRunner {
2523
2799
  /** Grava a posição no nó e pergunta. Para `dynamic_choice`, busca a página antes de gravar. */
2524
2800
  private awaitAnswer;
2525
2801
  private say;
2802
+ /**
2803
+ * Cada mensagem é retentada sozinha (ver `sendWithRetry`): o que já saiu neste turno não é reenviado.
2804
+ * Esgotadas as tentativas, o erro original sobe como antes e o `report` ganha `details.send`.
2805
+ */
2526
2806
  private send;
2527
2807
  private save;
2528
2808
  private reportMissingFlow;
@@ -3125,6 +3405,18 @@ declare function createMetaWhatsAppModule(params: CreateMetaWhatsAppModuleParams
3125
3405
  resolvePolicy: (companyId: string) => Promise<TranscriptionPolicy>;
3126
3406
  } | undefined;
3127
3407
  settings: SettingsRepository;
3408
+ /**
3409
+ * Respostas rápidas por empresa (o `/atalho` do composer). Só texto. As rotas HTTP saem de
3410
+ * `createMetaWhatsAppQuickReplyRoutes({ module })`; o host que prefere as próprias usa os
3411
+ * casos de uso daqui.
3412
+ */
3413
+ quickReplies: {
3414
+ list: ListQuickRepliesUseCase;
3415
+ create: CreateQuickReplyUseCase;
3416
+ update: UpdateQuickReplyUseCase;
3417
+ delete: DeleteQuickReplyUseCase;
3418
+ repository: QuickReplyRepository;
3419
+ };
3128
3420
  /**
3129
3421
  * `undefined` quando o recurso não está ligado (ou falta storage legível). O host consulta a
3130
3422
  * ausência para não registrar a rota de upload — e o preview, sem a rota, esconde o microfone.
@@ -3282,6 +3574,7 @@ declare function createMetaWhatsAppModule(params: CreateMetaWhatsAppModuleParams
3282
3574
  list: ListFlowGraphsUseCase;
3283
3575
  create: CreateFlowGraphUseCase;
3284
3576
  save: SaveFlowGraphUseCase;
3577
+ reseed: ReseedFlowGraphUseCase;
3285
3578
  delete: DeleteFlowGraphUseCase;
3286
3579
  livePositions: GetLiveFlowPositionsUseCase;
3287
3580
  repository: FlowGraphRepository;
@@ -3427,6 +3720,24 @@ declare function redeemSseTicket(store: TicketStoreInterface, ticket: string): P
3427
3720
  whatsappNumber: string;
3428
3721
  } | null>;
3429
3722
 
3723
+ /**
3724
+ * Copyright (c) 2026 Ada Technology. MIT License.
3725
+ *
3726
+ * Retentativa de UM envio de saída do robô, com limite e backoff exponencial.
3727
+ *
3728
+ * Cada mensagem do turno é retentada sozinha: se a segunda falha, a primeira (já entregue) não sai de
3729
+ * novo. Só se repete falha em que a Meta nunca recebeu a mensagem; o resto (recusa da Meta, erro de
3730
+ * banco depois do envio, janela expirada) sobe na primeira vez — repetir duplicaria ou falharia igual.
3731
+ */
3732
+
3733
+ /**
3734
+ * Padrão de `FlowSendRetryConfig.shouldRetry`: falha de rede antes de a requisição ser entregue.
3735
+ * Timeout fica de fora de propósito: a Meta pode ter aceitado a mensagem e a Cloud API não tem chave
3736
+ * de idempotência, então repetir arriscaria mandar duas vezes. O host que prefere repetir passa o
3737
+ * próprio `shouldRetry`.
3738
+ */
3739
+ declare function isTransientSendError(error: unknown): boolean;
3740
+
3430
3741
  /**
3431
3742
  * Copyright (c) 2026 Ada Technology. MIT License.
3432
3743
  *
@@ -3685,4 +3996,35 @@ declare class FlowMediaIdRepository implements FlowMediaIdStore {
3685
3996
  }): Promise<void>;
3686
3997
  }
3687
3998
 
3688
- export { type AttachFlowMediaParams, type AudioTranscriber, type BuildFlowChoiceMessageParams, type CompanyDocumentView, type CompanyDocumentsPage, type ConversationDocumentView, type ConversationDocumentsPage, type CountInboundLocationsParams, type CountInboundLocationsResult, CountInboundLocationsUseCase, type CreateFlowGraphParams, CreateFlowGraphUseCase, type CreateMetaWhatsAppModuleParams, type CreateSendMediaActionParams, type CreateSendProductListActionParams, DEFAULT_FALLBACK_LIST_LABEL, DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS, DEFAULT_FLOW_TEXT, DEFAULT_MAX_INVALID_ANSWERS, DEFAULT_START_FLOW_KEY, DYNAMIC_CHOICE_MORE_ID, type DeleteConversationParams, type DeleteConversationResult, DeleteConversationUseCase, DeleteFlowGraphUseCase, DocumentRepository, type DocumentRow, type DrizzleMigrateFunction, type ExportConversationParams, type ExportConversationResult, ExportConversationUseCase, FLOW_RUNTIME_CONTEXT_KEY, type FlowAnswerDecision, type FlowAnswerValidator, type FlowAnswerValidatorResult, type FlowChoiceOption, type FlowConfigText, type FlowGlobalKeyword, type FlowGlobalKeywordMatch, type FlowGlobalKeywordTarget, FlowGraphCache, FlowGraphRepository, type FlowGraphRow, FlowHandoff, type FlowHandoffConfig, type FlowHandoffDependencies, type FlowInbound, FlowInterpreter, type FlowMediaIdCache, FlowMediaIdRepository, type FlowMediaIdStore, type FlowMediaLocation, FlowMediaRepository, type FlowMediaRow, type FlowMediaTranscriptLogger, type FlowOutboundMessage, type FlowRunOptions, type FlowRunResult, FlowRunner, type FlowRunnerConfig, type FlowRunnerDependencies, type FlowRunnerOutcome, type FlowStepInput, type FlowStepResult, type FlowTextContext, type FlowTextKind, type FlowTextResolver, type FlowTurnLockInterface, type FlowTurnLockKey, type FlowVariablesResolver, GetFlowGraphUseCase, GetLiveFlowPositionsUseCase, type HandleFlowMessageParams, INBOUND_LOCATION_CONTENT, InProcessFlowTurnLock, type InboundDispatchJob, type InboundDispatchQueueInterface, InboundEffectsDispatcher, type InboundMediaDescriptor, type InboundMessageEffectsJob, type InboundStatusEffectsJob, type IngestInboundMediaParams, type IngestInboundMediaResult, IngestInboundMediaUseCase, type IngestTranscriptionOptions, type InsertMessageParams, InvalidFlowGraphError, type LinkDocumentParams, type ListCompanyDocumentsParams, ListCompanyDocumentsUseCase, type ListConversationDocumentsParams, ListConversationDocumentsUseCase, type ListConversationsFilters, type ListConversationsParams, ListConversationsUseCase, type ListDocumentsParams, type ListDocumentsResult, ListFlowGraphsUseCase, type ListMessagesParams, ListMessagesUseCase, type LogMessageParams, LogMessageUseCase, META_WHATSAPP_MIGRATIONS_TABLE, type MessageModerator, MessageRepository, type MessageRow, type MetaWhatsAppDatabase, type MetaWhatsAppDatabaseFor, type MetaWhatsAppDatabaseShape, type MetaWhatsAppMigrationsFolderParams, type MetaWhatsAppMigrationsLayout, type MetaWhatsAppModule, type MetaWhatsAppModuleConfig, type MetaWhatsAppModuleFeatures, type MetaWhatsAppModuleProviders, type MetaWhatsAppTranscriptionConfig, type NewDocumentRow, type NewFlowGraphRow, type NewFlowMediaRow, type NewMessageRow, type NewSessionRow, type NewSettingsRow, type NonceStoreInterface, OptimisticLockError, PRODUCT_LIST_LIMIT, PostgresAdvisoryFlowTurnLock, type PreviewContactsSupport, type PreviewMediaSupport, ProcessInboundDispatchUseCase, type PurgeExpiredDocumentsParams, type PurgeExpiredDocumentsResult, PurgeExpiredDocumentsUseCase, type RealtimeRelay, type ReceiveWebhookParams, type ReceiveWebhookResult, ReceiveWebhookUseCase, type RedactInboundLocationsParams, type RedactInboundLocationsResult, RedactInboundLocationsUseCase, type ReleaseConversationParams, ReleaseConversationUseCase, type ListMessagesParams$1 as RepositoryListMessagesParams, type RequestFlowHandoffParams, type RequestHumanConversationParams, RequestHumanConversationUseCase, type ResolveFlowAnswerParams, type ResolveTranscriptionPolicyDependencies, type RunMetaWhatsAppMigrationsParams, type SaveFlowGraphParams, SaveFlowGraphUseCase, type SaveTranscriptionByWaMessageIdParams, type SaveTranscriptionParams, type SendInteractiveParams, type SendMediaParams, SendMessageUseCase, type SendTemplateParams, type SendTextParams, SessionRepository, type SessionRow, SettingsRepository, type SettingsRow, SseHub, type SseListener, type StartFlowParams, type StorePreviewMediaParams, type StorePreviewMediaResult, StorePreviewMediaUseCase, TRANSCRIPTION_MODE, TRANSCRIPTION_STATUS, type TakeoverConversationParams, TakeoverConversationUseCase, type TicketStoreInterface, type TranscribeAudioDependencies, type TranscribeAudioParams, type TranscribeAudioResult, TranscribeAudioUseCase, type TranscriptionPolicy, type TranscriptionPolicyDefaults, type TranscriptionPolicyResolver, type TranscriptionStatus, type UpdateFlowMediaParams, WhatsAppChannelAdapter, buildFlowChoiceMessage, buildInboundJobId, claimWebhookDelivery, confirmWebhookDelivery, createMetaWhatsAppModule, createSendMediaAction, createSendProductListAction, createTranscriptionPolicyResolver, documents, extractMediaDescriptor, flowGraphs, flowMedia, isAudioMimeType, isChoiceNode, isRetriableTranscriptionError, isUnsupportedTranscriptionError, issueSseTicket, messages, metaWhatsAppMigrationsFolder, metaWhatsAppSchema, readFlowInbound, redeemSseTicket, resolveFailureStatus, resolveFlowAnswer, resolveFlowConfigText, resolveFlowTimeZone, runMetaWhatsAppMigrations, sessions, settings, toSessionContract, transcriptionRetryAfterSeconds, verifyWebhookChallenge, verifyWebhookSignature };
3999
+ /**
4000
+ * Escopo padrão da escrita de respostas rápidas (criar, editar, apagar). A leitura é de qualquer
4001
+ * agente autenticado — o seletor do composer precisa dela —, então não tem escopo padrão. O host
4002
+ * troca o vocabulário em `createMetaWhatsAppQuickReplyRoutes({ scopes })` se o dele for outro.
4003
+ */
4004
+ declare const QUICK_REPLY_SCOPE: {
4005
+ readonly WRITE: "quick-replies:write";
4006
+ };
4007
+ type QuickReplyRouteScopes = {
4008
+ /** Escopos que liberam criar, editar e apagar. Basta um. Padrão: `quick-replies:write`. */
4009
+ readonly write?: readonly string[];
4010
+ /** Exige escopo também na leitura. Ausente, basta estar autenticado como agente. */
4011
+ readonly read?: readonly string[];
4012
+ };
4013
+ declare const DEFAULT_QUICK_REPLY_WRITE_SCOPES: readonly string[];
4014
+
4015
+ type CreateMetaWhatsAppQuickReplyRoutesParams = {
4016
+ readonly module: Pick<MetaWhatsAppModule, 'quickReplies'>;
4017
+ readonly scopes?: QuickReplyRouteScopes;
4018
+ };
4019
+ /**
4020
+ * Tabela de rotas de respostas rápidas (`module-http`). O host escolhe o adaptador (`fetch` ou
4021
+ * uWebSockets) e o prefixo; o `companyId` vem sempre da identidade, nunca do corpo.
4022
+ *
4023
+ * - `GET /quick-replies` agente autenticado; `?search=` filtra título, atalho e texto
4024
+ * - `POST /quick-replies` escopo de escrita; `201`
4025
+ * - `PUT /quick-replies/:id` escopo de escrita; troca título, atalho e texto
4026
+ * - `DELETE /quick-replies/:id` escopo de escrita; `204`
4027
+ */
4028
+ declare function createMetaWhatsAppQuickReplyRoutes(params: CreateMetaWhatsAppQuickReplyRoutesParams): ModuleRouteTable;
4029
+
4030
+ export { type AttachFlowMediaParams, type AudioTranscriber, type BuildFlowChoiceMessageParams, type CompanyDocumentView, type CompanyDocumentsPage, type ConversationDocumentView, type ConversationDocumentsPage, type CountInboundLocationsParams, type CountInboundLocationsResult, CountInboundLocationsUseCase, type CreateFlowGraphParams, CreateFlowGraphUseCase, type CreateMetaWhatsAppModuleParams, type CreateMetaWhatsAppQuickReplyRoutesParams, type CreateQuickReplyParams as CreateQuickReplyRowParams, CreateQuickReplyUseCase, type CreateSendMediaActionParams, type CreateSendProductListActionParams, DEFAULT_FALLBACK_LIST_LABEL, DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS, DEFAULT_FLOW_TEXT, DEFAULT_MAX_INVALID_ANSWERS, DEFAULT_QUICK_REPLY_WRITE_SCOPES, DEFAULT_START_FLOW_KEY, DYNAMIC_CHOICE_MORE_ID, type DeleteConversationParams, type DeleteConversationResult, DeleteConversationUseCase, DeleteFlowGraphUseCase, type DeleteQuickReplyParams, DeleteQuickReplyUseCase, DocumentRepository, type DocumentRow, type DrizzleMigrateFunction, type ExportConversationParams, type ExportConversationResult, ExportConversationUseCase, FLOW_RUNTIME_CONTEXT_KEY, type FlowAnswerDecision, type FlowAnswerValidator, type FlowAnswerValidatorResult, type FlowChoiceOption, type FlowConfigText, type FlowGlobalKeyword, type FlowGlobalKeywordMatch, type FlowGlobalKeywordTarget, FlowGraphCache, FlowGraphRepository, type FlowGraphRow, FlowHandoff, type FlowHandoffConfig, type FlowHandoffDependencies, type FlowInbound, FlowInterpreter, type FlowMediaIdCache, FlowMediaIdRepository, type FlowMediaIdStore, type FlowMediaLocation, FlowMediaRepository, type FlowMediaRow, type FlowMediaTranscriptLogger, type FlowOutboundMessage, type FlowRunOptions, type FlowRunResult, FlowRunner, type FlowRunnerConfig, type FlowRunnerDependencies, type FlowRunnerOutcome, type FlowSendRetryConfig, type FlowStepInput, type FlowStepResult, type FlowTextContext, type FlowTextKind, type FlowTextResolver, type FlowTurnLockInterface, type FlowTurnLockKey, type FlowVariablesResolver, GetFlowGraphUseCase, GetLiveFlowPositionsUseCase, type HandleFlowMessageParams, INBOUND_LOCATION_CONTENT, InProcessFlowTurnLock, type InboundDispatchJob, type InboundDispatchQueueInterface, InboundEffectsDispatcher, type InboundMediaDescriptor, type InboundMessageEffectsJob, type InboundStatusEffectsJob, type IngestInboundMediaParams, type IngestInboundMediaResult, IngestInboundMediaUseCase, type IngestTranscriptionOptions, type InsertMessageParams, InvalidFlowGraphError, type LinkDocumentParams, type ListCompanyDocumentsParams, ListCompanyDocumentsUseCase, type ListConversationDocumentsParams, ListConversationDocumentsUseCase, type ListConversationsFilters, type ListConversationsParams, ListConversationsUseCase, type ListDocumentsParams, type ListDocumentsResult, ListFlowGraphsUseCase, type ListMessagesParams, ListMessagesUseCase, type ListQuickRepliesParams, ListQuickRepliesUseCase, type ListQuickRepliesParams$1 as ListQuickReplyRowsParams, type LogMessageParams, LogMessageUseCase, META_WHATSAPP_MIGRATIONS_TABLE, type MessageModerator, MessageRepository, type MessageRow, type MetaWhatsAppDatabase, type MetaWhatsAppDatabaseFor, type MetaWhatsAppDatabaseShape, type MetaWhatsAppMigrationsFolderParams, type MetaWhatsAppMigrationsLayout, type MetaWhatsAppModule, type MetaWhatsAppModuleConfig, type MetaWhatsAppModuleFeatures, type MetaWhatsAppModuleProviders, type MetaWhatsAppTranscriptionConfig, type NewDocumentRow, type NewFlowGraphRow, type NewFlowMediaRow, type NewMessageRow, type NewQuickReplyRow, type NewSessionRow, type NewSettingsRow, type NonceStoreInterface, OptimisticLockError, PRODUCT_LIST_LIMIT, PostgresAdvisoryFlowTurnLock, type PreviewContactsSupport, type PreviewMediaSupport, ProcessInboundDispatchUseCase, type PurgeExpiredDocumentsParams, type PurgeExpiredDocumentsResult, PurgeExpiredDocumentsUseCase, QUICK_REPLY_SCOPE, QuickReplyRepository, type QuickReplyRouteScopes, type QuickReplyRow, type RealtimeRelay, type ReceiveWebhookParams, type ReceiveWebhookResult, ReceiveWebhookUseCase, type RedactInboundLocationsParams, type RedactInboundLocationsResult, RedactInboundLocationsUseCase, type ReleaseConversationParams, ReleaseConversationUseCase, type ListMessagesParams$1 as RepositoryListMessagesParams, type RequestFlowHandoffParams, type RequestHumanConversationParams, RequestHumanConversationUseCase, type ReseedFlowGraphParams, type ReseedFlowGraphResult, ReseedFlowGraphUseCase, type ResolveFlowAnswerParams, type ResolveTranscriptionPolicyDependencies, type RunMetaWhatsAppMigrationsParams, type SaveFlowGraphParams, SaveFlowGraphUseCase, type SaveQuickReplyParams, type SaveTranscriptionByWaMessageIdParams, type SaveTranscriptionParams, type SendInteractiveParams, type SendMediaParams, SendMessageUseCase, type SendTemplateParams, type SendTextParams, SessionRepository, type SessionRow, SettingsRepository, type SettingsRow, SseHub, type SseListener, type StartFlowParams, type StorePreviewMediaParams, type StorePreviewMediaResult, StorePreviewMediaUseCase, TRANSCRIPTION_MODE, TRANSCRIPTION_STATUS, type TakeoverConversationParams, TakeoverConversationUseCase, type TicketStoreInterface, type TranscribeAudioDependencies, type TranscribeAudioParams, type TranscribeAudioResult, TranscribeAudioUseCase, type TranscriptionPolicy, type TranscriptionPolicyDefaults, type TranscriptionPolicyResolver, type TranscriptionStatus, type UpdateFlowMediaParams, type UpdateQuickReplyParams, type UpdateQuickReplyParams$1 as UpdateQuickReplyRowParams, UpdateQuickReplyUseCase, WhatsAppChannelAdapter, buildFlowChoiceMessage, buildInboundJobId, claimWebhookDelivery, confirmWebhookDelivery, createMetaWhatsAppModule, createMetaWhatsAppQuickReplyRoutes, createSendMediaAction, createSendProductListAction, createTranscriptionPolicyResolver, documents, extractMediaDescriptor, flowGraphs, flowMedia, isAudioMimeType, isChoiceNode, isRetriableTranscriptionError, isTransientSendError, isUnsupportedTranscriptionError, issueSseTicket, messages, metaWhatsAppMigrationsFolder, metaWhatsAppSchema, quickReplies, readFlowInbound, redeemSseTicket, resolveFailureStatus, resolveFlowAnswer, resolveFlowConfigText, resolveFlowTimeZone, runMetaWhatsAppMigrations, sessions, settings, toQuickReplyView, toSessionContract, transcriptionRetryAfterSeconds, verifyWebhookChallenge, verifyWebhookSignature };