@botozap/sdk 0.3.1 → 0.4.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.cts CHANGED
@@ -87,6 +87,8 @@ interface BroadcastRecipient {
87
87
  interface Contact {
88
88
  id: string;
89
89
  wa_id?: string;
90
+ /** Contact tags (stored in metadata.tags); returned by servers with #498. */
91
+ tags?: string[];
90
92
  [key: string]: unknown;
91
93
  }
92
94
  interface Conversation {
@@ -110,6 +112,10 @@ interface Webhook {
110
112
  url: string;
111
113
  events?: string[];
112
114
  active?: boolean;
115
+ /** True quando o endpoint tem Authorization no Vault. O valor nunca é devolvido. */
116
+ has_authorization?: boolean;
117
+ /** Segredo HMAC; presente somente na resposta de criação. */
118
+ secret?: string;
113
119
  [key: string]: unknown;
114
120
  }
115
121
  interface PhoneNumber {
@@ -227,6 +233,3038 @@ interface SetupLink {
227
233
  [key: string]: unknown;
228
234
  }
229
235
 
236
+ /** Public /api/v1/ai contracts. Revisions are opaque strings unless the endpoint explicitly uses a number. */
237
+ type AiProvider = "anthropic" | "openai" | "google" | "openrouter" | "deepseek" | "xai";
238
+ /** Every BYOK purpose. #498 added granular purposes; without their own binding they inherit the Customer default. */
239
+ declare const AI_PURPOSES: readonly ["default", "agent_turn", "agent_operator", "router", "followup", "proposal", "transcription", "embedding", "guard", "evaluator", "classification", "compaction", "case_chat", "learning_judge", "learning_distiller", "vision", "commercial_proposal"];
240
+ type AiPurpose = (typeof AI_PURPOSES)[number];
241
+ /** Purposes bound in Providers; agent_turn/agent_operator/router come from the agent version or router. */
242
+ declare const AI_CONFIGURABLE_PURPOSES: ("default" | "followup" | "proposal" | "transcription" | "embedding" | "guard" | "evaluator" | "classification" | "compaction" | "case_chat" | "learning_judge" | "learning_distiller" | "vision" | "commercial_proposal")[];
243
+ type AiConfigurablePurpose = Exclude<AiPurpose, "agent_turn" | "agent_operator" | "router">;
244
+ type AiScope = {
245
+ customer_id: string;
246
+ };
247
+ type AiRevision = AiScope & {
248
+ expected_revision: string;
249
+ };
250
+ type AiRecord = Record<string, unknown>;
251
+ type AiPage = AiScope & {
252
+ page?: number;
253
+ per_page?: number;
254
+ };
255
+ type AiBindingTarget = {
256
+ provider: AiProvider;
257
+ model: string;
258
+ credential_id: string;
259
+ };
260
+ type AiBinding = AiBindingTarget & {
261
+ purpose: AiPurpose;
262
+ fallback: AiBindingTarget | null;
263
+ };
264
+ type AiCredential = {
265
+ id: string;
266
+ customer_id: string;
267
+ provider: AiProvider;
268
+ label: string;
269
+ last4: string;
270
+ revision: string;
271
+ active: boolean;
272
+ validation_status: "pending" | "valid" | "invalid";
273
+ validated_at: string | null;
274
+ last_error: string | null;
275
+ models: string[];
276
+ usage_count: number;
277
+ usages: {
278
+ kind: string;
279
+ id: string;
280
+ label: string;
281
+ }[];
282
+ };
283
+ type AiWindow = {
284
+ start: string;
285
+ end: string;
286
+ weekdays: number[];
287
+ };
288
+ type AiToolId = "contacts.read" | "contacts.update" | "conversations.read" | "conversations.note" | "crm.opportunities.read" | "crm.opportunities.write" | "crm.demands.read" | "crm.demands.write" | "crm.stages.read" | "crm.stages.write" | "agenda.availability" | "agenda.propose" | "agenda.appointments.read" | "agenda.appointments.reschedule" | "agenda.appointments.cancel" | "knowledge.search" | "memory.read" | "memory.propose" | "skills.read" | "followups.enroll" | "followups.pause" | "followups.cancel" | "cases.open" | "cases.update" | "followups.schedule" | "followups.list" | "handoff" | "alerts.create" | "contacts.search" | "contacts.get" | "contacts.propose_update" | "conversations.list" | "conversations.get" | "conversations.history" | "conversations.assign" | "team.members.read" | "inbox.queue.read" | "tags.read" | "tags.manage" | "saved_replies.read" | "saved_replies.render" | "automations.read" | "automations.runs.read" | "radar.read" | "radar.propose_reactivation" | "catalog.products.search" | "privacy.consent.read" | "knowledge.sources.read" | "proposals.read" | "cases.read" | "crm.search" | "agenda.schedule.read" | "agenda.appointments.confirm" | "cases.note" | "cases.close";
289
+ interface AiAgentConfig {
290
+ system_prompt?: string;
291
+ provider?: AiProvider;
292
+ model?: string;
293
+ credential_id?: string | null;
294
+ channel_account_id?: string | null;
295
+ tool_ids?: AiToolId[];
296
+ operator?: {
297
+ enabled?: boolean;
298
+ provider?: AiProvider | null;
299
+ model?: string | null;
300
+ credential_id?: string | null;
301
+ tool_ids?: AiToolId[];
302
+ };
303
+ trigger?: {
304
+ keywords?: string[];
305
+ match?: "any" | "all";
306
+ ignore_groups?: true;
307
+ ignore_self?: true;
308
+ };
309
+ time_zone?: string;
310
+ business_hours?: AiWindow | null;
311
+ outside_hours?: "respond" | "wait" | "handoff";
312
+ max_steps?: number;
313
+ token_budget?: number;
314
+ estimated_cost_limit_usd?: number | null;
315
+ history_message_window?: number;
316
+ history_token_window?: number;
317
+ handoff_keywords?: string[];
318
+ handoff_enabled?: boolean;
319
+ cases_enabled?: boolean;
320
+ split_messages?: boolean;
321
+ split_max_chars?: number;
322
+ crm_scopes?: ("contacts" | "opportunities" | "demands")[];
323
+ allowed_stage_ids?: string[];
324
+ knowledge_source_ids?: string[];
325
+ skill_ids?: string[];
326
+ /** Opt-in platform skills composed at runtime; Customer copies override them. */
327
+ platform_skills?: "none" | "all";
328
+ memory_enabled?: boolean;
329
+ /** Reading OTHER contacts/conversations is an explicit opt-in (contacts.search, radar.read, crm.search require it to publish). */
330
+ data_access?: {
331
+ other_contacts?: boolean;
332
+ };
333
+ /** Turn closing (promise declaration/checkpoint) and stage suggestion; each adds a BYOK inference per turn. */
334
+ accountability?: {
335
+ enabled?: boolean;
336
+ classification?: boolean;
337
+ };
338
+ media?: {
339
+ images_enabled?: boolean;
340
+ documents_enabled?: boolean;
341
+ video_frames_enabled?: boolean;
342
+ };
343
+ followup?: {
344
+ enabled?: boolean;
345
+ flow_ids?: string[];
346
+ send_window?: AiWindow | null;
347
+ };
348
+ safety?: {
349
+ disclose_ai?: boolean;
350
+ prohibited_claims?: string[];
351
+ escalation_instructions?: string;
352
+ /** Only adds rules above the mandatory platform policy. */
353
+ additional_rules?: string[];
354
+ disclosure_text?: string;
355
+ commercial_limits?: {
356
+ min_price_brl?: number | null;
357
+ max_discount_percent?: number | null;
358
+ max_installments?: number | null;
359
+ };
360
+ guard_sensitivity?: "standard" | "strict";
361
+ semantic_evaluator?: boolean;
362
+ };
363
+ style?: {
364
+ tone?: "professional" | "friendly" | "direct";
365
+ verbosity?: "concise" | "balanced" | "detailed";
366
+ use_emojis?: boolean;
367
+ instructions?: string;
368
+ };
369
+ }
370
+ type AiAgentInput = AiScope & {
371
+ name: string;
372
+ description?: string;
373
+ config?: AiAgentConfig;
374
+ };
375
+ type AiAgent = {
376
+ id: string;
377
+ customer_id: string;
378
+ name: string;
379
+ description: string;
380
+ operation_mode: "automatic" | "assisted";
381
+ operation_revision: string;
382
+ paused: boolean;
383
+ archived: boolean;
384
+ published_version_id: string | null;
385
+ updated_at: string;
386
+ };
387
+ type AiAgentVersion = {
388
+ id: string;
389
+ agent_id: string;
390
+ number: number;
391
+ revision: string;
392
+ status: "draft" | "published";
393
+ config: AiAgentConfig;
394
+ created_at: string;
395
+ published_at: string | null;
396
+ created_by: string | null;
397
+ };
398
+ type AiDraftResult = {
399
+ agent_id: string;
400
+ version_id: string;
401
+ revision: string;
402
+ };
403
+ type AiUsageTokens = {
404
+ input_tokens?: number;
405
+ output_tokens?: number;
406
+ cache_read_tokens?: number;
407
+ cache_write_tokens?: number;
408
+ reasoning_tokens?: number;
409
+ };
410
+ type AiExecution = {
411
+ id: string;
412
+ source: "preview" | "live" | "operator" | "assisted";
413
+ provider: string;
414
+ model: string;
415
+ latency_ms: number | null;
416
+ agent_id: string;
417
+ version_id: string;
418
+ mode: "preview" | "automatic" | "assisted";
419
+ status: "running" | "waiting" | "completed" | "awaiting_approval" | "failed" | "unknown" | "superseded" | "rejected";
420
+ reply: string | null;
421
+ tool_trace: {
422
+ call_id: string;
423
+ name: string;
424
+ [key: string]: unknown;
425
+ }[];
426
+ usage?: AiUsageTokens | null;
427
+ measurement_status: "measured" | "partial" | "unavailable";
428
+ finish_reason: string | null;
429
+ error_code: string | null;
430
+ created_at: string;
431
+ completed_at: string | null;
432
+ run_id: string | null;
433
+ conversation_id: string | null;
434
+ operator_execution?: AiExecution;
435
+ /** #498 protection trail without message text or keys; null when there is no record. */
436
+ security?: AiExecutionSecurity | null;
437
+ };
438
+ type AiExecutionSecurity = {
439
+ summary: {
440
+ hold: string | null;
441
+ guard: {
442
+ verdict: "pass" | "flagged" | "blocked" | "unavailable";
443
+ level: "none" | "low" | "high";
444
+ layer: "heuristic" | "model";
445
+ codes: string[];
446
+ } | null;
447
+ evaluation: {
448
+ verdict: "pass" | "vetoed" | "unavailable";
449
+ attempts: number;
450
+ codes: string[];
451
+ } | null;
452
+ disclosure_version: number | null;
453
+ } | null;
454
+ events: {
455
+ stage: "input_guard" | "before_send" | "checkpoint_policy" | "approval" | "style_adjustments" | "urgency_signal" | (string & {});
456
+ attempt: number;
457
+ verdict: string;
458
+ layer: string;
459
+ codes: string[];
460
+ /** Only reviewed keys (level, reason, versions, binding summary, …). */
461
+ detail: AiRecord;
462
+ policy_version: number;
463
+ created_at: string;
464
+ }[] | null;
465
+ /** The detailed trace could not be read; never means "no events". */
466
+ events_unavailable: boolean;
467
+ };
468
+ type AiSourceKind = "text" | "faq" | "document" | "catalog" | "conversation";
469
+ type AiKnowledgeSource = {
470
+ id: string;
471
+ name: string;
472
+ kind: AiSourceKind;
473
+ active: boolean;
474
+ revision: string;
475
+ status: "queued" | "indexing" | "ready" | "failed";
476
+ last_error: string | null;
477
+ active_version_id: string | null;
478
+ pending_version_id: string | null;
479
+ created_at: string;
480
+ updated_at: string;
481
+ };
482
+ type AiKnowledgeChunk = {
483
+ id: string;
484
+ source_id: string;
485
+ version_id: string;
486
+ ordinal: number;
487
+ content: string;
488
+ hash: string;
489
+ };
490
+ type AiMemory = {
491
+ enabled: boolean;
492
+ revision: string;
493
+ content: string;
494
+ version_id: string | null;
495
+ };
496
+ type AiMemoryEntry = {
497
+ id: string;
498
+ title: string;
499
+ body: string;
500
+ contact_id: string | null;
501
+ source: "manual" | "proposal";
502
+ proposal_id: string | null;
503
+ provenance: AiRecord;
504
+ status: "active" | "pending" | "archived";
505
+ revision: string;
506
+ };
507
+ type AiSkillInput = {
508
+ name: string;
509
+ description: string;
510
+ body: string;
511
+ matcher: {
512
+ any_keywords: string[];
513
+ probe_keywords?: string[];
514
+ };
515
+ active?: boolean;
516
+ };
517
+ type AiSkill = {
518
+ id: string;
519
+ name: string;
520
+ description: string;
521
+ active: boolean;
522
+ revision: string;
523
+ version_id: string | null;
524
+ };
525
+ type AiRouterConfig = {
526
+ name: string;
527
+ channel_account_id: string;
528
+ classifier: AiBindingTarget;
529
+ sticky?: boolean;
530
+ min_confidence?: number;
531
+ fallback_agent_id?: string | null;
532
+ members: {
533
+ agent_id: string;
534
+ intent_name: string;
535
+ intent_description: string;
536
+ examples?: string[];
537
+ position?: number;
538
+ }[];
539
+ };
540
+ type AiRouter = AiRouterConfig & {
541
+ id: string;
542
+ revision: string;
543
+ active: boolean;
544
+ archived: boolean;
545
+ channel_owner: {
546
+ kind: "agent" | "router";
547
+ id: string;
548
+ } | null;
549
+ created_at: string;
550
+ updated_at: string;
551
+ };
552
+ type AiFlowGraph = {
553
+ nodes: {
554
+ id: string;
555
+ type: string;
556
+ label: string;
557
+ position: {
558
+ x: number;
559
+ y: number;
560
+ };
561
+ config: AiRecord;
562
+ }[];
563
+ edges: {
564
+ id: string;
565
+ source: string;
566
+ target: string;
567
+ priority: number;
568
+ condition: AiRecord;
569
+ [key: string]: unknown;
570
+ }[];
571
+ };
572
+ type AiFlowSettings = {
573
+ trigger: ({
574
+ kind: "manual" | "webhook";
575
+ } | {
576
+ kind: "stage_change";
577
+ params: {
578
+ stage_id: string;
579
+ };
580
+ } | {
581
+ kind: "silence";
582
+ params: {
583
+ threshold_minutes: number;
584
+ segments?: string[];
585
+ };
586
+ } | {
587
+ kind: "case_opened";
588
+ params?: Record<string, never>;
589
+ } | {
590
+ kind: "appointment_no_show";
591
+ params?: {
592
+ event_type_ids?: string[];
593
+ };
594
+ }) & {
595
+ cancel_on_reply?: boolean;
596
+ };
597
+ handoff_policy: "pause" | "cancel" | "allow";
598
+ send_start_hour: number;
599
+ send_end_hour: number;
600
+ send_days: number[];
601
+ timezone: string;
602
+ purpose: "utility" | "marketing";
603
+ environment: "live" | "sandbox";
604
+ /** Agent responsible for automatic triggers when several enable the flow; omitted = the only eligible one. */
605
+ trigger_agent_id?: string | null;
606
+ };
607
+ type AiFlowInput = AiScope & {
608
+ name: string;
609
+ graph: AiFlowGraph;
610
+ settings: AiFlowSettings;
611
+ };
612
+ type AiFlow = AiRecord & {
613
+ id: string;
614
+ name: string;
615
+ revision: string;
616
+ status: "active" | "paused" | "archived";
617
+ graph: AiFlowGraph;
618
+ settings: AiFlowSettings;
619
+ };
620
+ type AiEnrollment = AiRecord & {
621
+ id: string;
622
+ revision: string;
623
+ status: string;
624
+ flow_id: string;
625
+ contact_id: string;
626
+ conversation_id: string;
627
+ };
628
+ type AiCase = {
629
+ id: string;
630
+ agent_id: string | null;
631
+ conversation_id: string;
632
+ contact_id: string;
633
+ title: string;
634
+ summary: string;
635
+ status: "open" | "waiting" | "resolved" | "closed";
636
+ assigned_user_id: string | null;
637
+ revision: number;
638
+ created_at: string;
639
+ updated_at: string;
640
+ resolved_at: string | null;
641
+ opened_operator_version: number | null;
642
+ last_human_action: "resolved" | "need_lead_info" | "escalate" | null;
643
+ last_human_body: string | null;
644
+ last_human_at: string | null;
645
+ last_human_revision: number | null;
646
+ reply_operator_version: number | null;
647
+ /** #498: subject, explicit blocker, origin and closing outcome (older rows: outro/null/agent). */
648
+ kind?: AiCaseKind;
649
+ blocker?: string | null;
650
+ source?: AiCaseSource;
651
+ outcome?: "resolved" | "no_action_needed" | "escalated" | "cancelled" | null;
652
+ last_action_at?: string;
653
+ stale_reminders?: number;
654
+ contact_name?: string | null;
655
+ };
656
+ type AiCaseKind = "agendamento" | "duvida" | "problema" | "financeiro" | "acesso" | "outro";
657
+ type AiCaseSource = "agent" | "guardrail" | "human" | "operator";
658
+ type AiCaseEvent = {
659
+ id: string;
660
+ case_id: string;
661
+ kind: string;
662
+ actor_kind: "agent" | "human" | "api_key" | "system" | "contact";
663
+ actor_user_id: string | null;
664
+ actor_api_key_id: string | null;
665
+ actor_agent_id: string | null;
666
+ body: string | null;
667
+ details: AiRecord;
668
+ created_at: string;
669
+ /** Lay label computed by the server next to the raw kind. */
670
+ label: string;
671
+ };
672
+ type AiAlert = {
673
+ id: string;
674
+ agent_id: string | null;
675
+ conversation_id: string | null;
676
+ case_id: string | null;
677
+ title: string;
678
+ detail: string;
679
+ severity: "info" | "warning" | "critical";
680
+ status: "open" | "acknowledged" | "resolved";
681
+ revision: number;
682
+ created_at: string;
683
+ resolved_at: string | null;
684
+ kind?: string;
685
+ reminder_count?: number;
686
+ last_reminded_at?: string | null;
687
+ case_status?: AiCase["status"] | null;
688
+ resolved_by?: string | null;
689
+ resolved_by_api_key?: string | null;
690
+ };
691
+ /** Alert list rows: cause label, guidance and destinations projected by the server from stored IDs. */
692
+ type AiAlertListItem = AiAlert & {
693
+ kind: string;
694
+ kind_label: string;
695
+ guidance: string;
696
+ links: {
697
+ href: string;
698
+ label: string;
699
+ }[];
700
+ };
701
+ type AiAlertBulkFilters = {
702
+ kind?: string;
703
+ severity?: AiAlert["severity"];
704
+ status?: "open" | "acknowledged";
705
+ };
706
+ type AiNoticeField = "case_title" | "case_summary" | "case_url" | "contact_name" | "agent_name";
707
+ type AiNoticeSettings = {
708
+ enabled: boolean;
709
+ contact_id: string | null;
710
+ template_id: string | null;
711
+ variable_map: Record<string, AiNoticeField>;
712
+ revision: number;
713
+ consent_confirmed_at: string | null;
714
+ updated_at: string | null;
715
+ };
716
+ type AiNoticeJob = {
717
+ id: string;
718
+ case_id: string | null;
719
+ kind: "case" | "test";
720
+ status: "pending" | "claimed" | "sent" | "failed" | "unknown" | "cancelled";
721
+ last_error: string | null;
722
+ created_at: string;
723
+ finished_at: string | null;
724
+ external_id: string | null;
725
+ destination_masked?: string | null;
726
+ case_title?: string | null;
727
+ case_status?: string | null;
728
+ };
729
+ type AiProposal = {
730
+ id: string;
731
+ agent_id: string;
732
+ execution_id: string;
733
+ base_version_id: string;
734
+ type: "playbook_bullet" | "memory_entry";
735
+ content: string;
736
+ reason: string;
737
+ evidence: string[];
738
+ status: "pending" | "applied" | "rejected";
739
+ revision: number;
740
+ created_at: string;
741
+ decided_at: string | null;
742
+ decision_reason: string | null;
743
+ applied_version_id: string | null;
744
+ memory_entry_id: string | null;
745
+ };
746
+ /** Customer-supplied transcription rates. Reservations are estimates, not provider token caps. */
747
+ type AiAudioPricing = {
748
+ unit: "tokens";
749
+ input_audio_usd_per_million: number;
750
+ input_text_usd_per_million: number;
751
+ output_text_usd_per_million: number;
752
+ max_input_tokens: number;
753
+ max_output_tokens: number;
754
+ } | {
755
+ unit: "duration";
756
+ usd_per_minute: number;
757
+ };
758
+ type AiRateInput = AiScope & {
759
+ provider: AiProvider;
760
+ model: string;
761
+ input_usd_per_million: number;
762
+ output_usd_per_million: number;
763
+ cache_read_usd_per_million: number;
764
+ cache_write_usd_per_million: number;
765
+ /** Omit to preserve the existing audio price; null explicitly removes it. */
766
+ audio_pricing?: AiAudioPricing | null;
767
+ expected_revision: number;
768
+ };
769
+ type AiBudgetInput = AiScope & {
770
+ monthly_limit_usd: number | null;
771
+ mode: "off" | "warn" | "block";
772
+ alarm_threshold_pct: number;
773
+ expected_revision: number;
774
+ };
775
+ type AiFlowVersion = {
776
+ id: string;
777
+ flow_id: string;
778
+ version: number;
779
+ graph: AiFlowGraph;
780
+ settings: AiFlowSettings;
781
+ created_at: string;
782
+ };
783
+ type AiFollowupEffect = {
784
+ id: string;
785
+ node_id: string;
786
+ purpose: "send_message" | "classify" | "plan_timing";
787
+ status: string;
788
+ reply: string | null;
789
+ template_id: string | null;
790
+ template_snapshot: {
791
+ name: string;
792
+ language: string;
793
+ components: unknown;
794
+ } | null;
795
+ classification: string | null;
796
+ timing_plan: AiRecord | null;
797
+ provider: string | null;
798
+ model: string | null;
799
+ measurement_status: string;
800
+ last_error: string | null;
801
+ created_at: string;
802
+ completed_at: string | null;
803
+ dispatch_id: string | null;
804
+ approved_by: string | null;
805
+ approved_by_api_key: string | null;
806
+ };
807
+ type AiFollowupEvent = {
808
+ id: string;
809
+ node_id: string | null;
810
+ type: string;
811
+ payload: AiRecord;
812
+ created_at: string;
813
+ };
814
+ type AiSkillVersion = {
815
+ id: string;
816
+ skill_id: string;
817
+ revision: string;
818
+ body: string;
819
+ matcher: AiSkillInput["matcher"];
820
+ manifest: {
821
+ path: string;
822
+ size: number;
823
+ sha256: string;
824
+ kind: "reference" | "asset";
825
+ }[];
826
+ created_at: string;
827
+ };
828
+ type AiRouterTest = {
829
+ id: string;
830
+ router_id: string;
831
+ revision: string;
832
+ status: "completed" | "failed" | "unknown" | "superseded";
833
+ agent_id: string | null;
834
+ intent_name: string | null;
835
+ confidence: number | null;
836
+ outcome: "classified" | "sticky" | "reclassified" | "fallback" | "session" | "no_match" | "classifier_failed";
837
+ error_code: string | null;
838
+ usage?: AiUsageTokens;
839
+ measurement_status: "measured" | "partial" | "unavailable";
840
+ created_at: string;
841
+ };
842
+ type AiProviderModel = {
843
+ id: string;
844
+ provider: AiProvider;
845
+ capabilities: ("text" | "embedding" | "transcription")[];
846
+ };
847
+ type AiUsageSummary = {
848
+ from: string;
849
+ to: string;
850
+ totals: {
851
+ calls: number;
852
+ input_audio_tokens: number | null;
853
+ input_text_tokens: number | null;
854
+ audio_seconds: number | null;
855
+ input_tokens: number | null;
856
+ output_tokens: number | null;
857
+ estimated_cost_usd: number | null;
858
+ reserved_usd: number | null;
859
+ unmeasured_calls: number;
860
+ failed_calls: number;
861
+ p50_latency_ms: number | null;
862
+ p95_latency_ms: number | null;
863
+ };
864
+ series: {
865
+ usage_day: string;
866
+ calls: number;
867
+ input_audio_tokens: number | null;
868
+ input_text_tokens: number | null;
869
+ audio_seconds: number | null;
870
+ input_tokens: number | null;
871
+ output_tokens: number | null;
872
+ estimated_cost_usd: number | null;
873
+ unmeasured_calls: number;
874
+ }[];
875
+ models: {
876
+ provider: string;
877
+ model: string;
878
+ calls: number;
879
+ input_audio_tokens: number | null;
880
+ input_text_tokens: number | null;
881
+ audio_seconds: number | null;
882
+ estimated_cost_usd: number | null;
883
+ unmeasured_calls: number;
884
+ }[];
885
+ purposes: {
886
+ purpose: string;
887
+ calls: number;
888
+ input_audio_tokens: number | null;
889
+ input_text_tokens: number | null;
890
+ audio_seconds: number | null;
891
+ estimated_cost_usd: number | null;
892
+ }[];
893
+ /** #498: per-agent breakdown and handoff rate (agent_id filter applies; purpose does not). */
894
+ agents?: {
895
+ agent_id: string | null;
896
+ calls: number;
897
+ estimated_cost_usd: number | null;
898
+ unmeasured_calls: number;
899
+ }[];
900
+ handoff?: {
901
+ conversations: number;
902
+ handoffs: number;
903
+ rate: number | null;
904
+ purpose_filter_applied: false;
905
+ agent_filter_applied: boolean;
906
+ };
907
+ };
908
+ type AiBudget = Omit<AiBudgetInput, "customer_id" | "expected_revision"> & {
909
+ revision: number;
910
+ updated_at: string | null;
911
+ };
912
+ type AiRate = Omit<AiRateInput, "customer_id" | "expected_revision" | "audio_pricing"> & {
913
+ audio_pricing: AiAudioPricing | null;
914
+ revision: number;
915
+ updated_at: string;
916
+ };
917
+ type AiCaseReplyInput = AiScope & {
918
+ id: string;
919
+ expected_revision: number;
920
+ operation_key: string;
921
+ action: "resolved" | "need_lead_info" | "escalate";
922
+ body: string;
923
+ };
924
+ type AiCaseReply = {
925
+ case_id: string;
926
+ revision: number;
927
+ status: AiCase["status"];
928
+ queued: boolean;
929
+ queue_reason: string | null;
930
+ run_id: string | null;
931
+ service_stale: boolean;
932
+ };
933
+ type AiCaseChat = {
934
+ id: string;
935
+ operation_key: string;
936
+ question: string;
937
+ reply: string | null;
938
+ status: "running" | "completed" | "failed" | "unknown";
939
+ actor_user_id: string | null;
940
+ actor_api_key_id: string | null;
941
+ persona: {
942
+ source: "case_agent" | "customer_default";
943
+ name: string | null;
944
+ reason: "no_agent" | "paused" | "archived" | "unpublished" | null;
945
+ agent_id: string | null;
946
+ version_id: string | null;
947
+ binding?: "purpose" | "customer_default" | null;
948
+ } | null;
949
+ usage: {
950
+ input_tokens: number | null;
951
+ output_tokens: number | null;
952
+ cache_read_tokens: number | null;
953
+ cache_write_tokens: number | null;
954
+ reasoning_tokens: number | null;
955
+ } | null;
956
+ measurement_status: "measured" | "partial" | "unavailable" | null;
957
+ provider: string | null;
958
+ model: string | null;
959
+ error_code: string | null;
960
+ created_at: string;
961
+ completed_at: string | null;
962
+ };
963
+ type AiCatalogProduct = {
964
+ id: string;
965
+ name: string | {
966
+ pt: string;
967
+ };
968
+ description?: string;
969
+ price?: string;
970
+ sku?: string;
971
+ permalink?: string;
972
+ variants?: {
973
+ price?: string;
974
+ sku?: string;
975
+ }[];
976
+ categories?: {
977
+ name: string | {
978
+ pt: string;
979
+ };
980
+ }[];
981
+ };
982
+ type AiKnowledgeImport = AiScope & {
983
+ name: string;
984
+ source_id?: string;
985
+ expected_revision?: string;
986
+ } & ({
987
+ kind: "services";
988
+ } | {
989
+ kind: "products";
990
+ products: AiCatalogProduct[];
991
+ } | {
992
+ kind: "conversation";
993
+ conversation_id: string;
994
+ permission_revision: string;
995
+ preview_hash: string;
996
+ reviewed: true;
997
+ });
998
+ type AiKnowledgeConversation = {
999
+ id: string;
1000
+ contact_name: string;
1001
+ closed_at: string;
1002
+ allowed: boolean;
1003
+ revision: string;
1004
+ source_id: string | null;
1005
+ };
1006
+ type AiKnowledgePreview = {
1007
+ conversation_id: string;
1008
+ permission_revision: string;
1009
+ preview_hash: string;
1010
+ source_fingerprint: string;
1011
+ text: string;
1012
+ message_count: number;
1013
+ redactions: Record<string, number>;
1014
+ review_required: boolean;
1015
+ };
1016
+ type AiPlatformSkill = {
1017
+ slug: string;
1018
+ version_id: string;
1019
+ version: number;
1020
+ name: string;
1021
+ description: string;
1022
+ body: string;
1023
+ matcher: AiSkillInput["matcher"];
1024
+ manifest: {
1025
+ path: string;
1026
+ size: number;
1027
+ sha256: string;
1028
+ kind: "reference" | "asset";
1029
+ }[];
1030
+ source: string;
1031
+ installed_skill_id: string | null;
1032
+ installed_version_id: string | null;
1033
+ };
1034
+ type AiArtifactUploadInput = AiScope & {
1035
+ kind: "knowledge" | "skill";
1036
+ file_name: string;
1037
+ mime_type: string;
1038
+ byte_size: number;
1039
+ sha256: string;
1040
+ name?: string;
1041
+ skill_id?: string;
1042
+ expected_revision?: string;
1043
+ };
1044
+ interface AiPreparedUpload {
1045
+ upload_id: string;
1046
+ upload_url: string;
1047
+ headers: {
1048
+ "Content-Type": string;
1049
+ };
1050
+ expires_at: string;
1051
+ }
1052
+ interface AiConversationCheckpoint {
1053
+ id: string;
1054
+ agent_id: string;
1055
+ conversation_id: string;
1056
+ execution_id: string;
1057
+ status: "ready" | "flush_started" | "flushed" | "summary_started" | "completed" | "failed" | "unknown";
1058
+ input_hash: string;
1059
+ summary: null | {
1060
+ rolling_summary: string;
1061
+ commitments: string[];
1062
+ objections: string[];
1063
+ personal_data: string[];
1064
+ stage: string | null;
1065
+ evidence: string[];
1066
+ };
1067
+ through_message_id: string;
1068
+ through_at: string;
1069
+ closed_at: string | null;
1070
+ message_count: number;
1071
+ flushed_entry_ids: string[];
1072
+ error_code: string | null;
1073
+ created_at: string;
1074
+ }
1075
+ type AiUploadReceiptCallback = (receipt: {
1076
+ upload_id: string;
1077
+ }) => void | Promise<void>;
1078
+ type AiCommercialEffect = {
1079
+ kind: "none";
1080
+ } | {
1081
+ kind: "schedule_follow_up";
1082
+ at: string;
1083
+ } | {
1084
+ kind: "move_stage";
1085
+ stage_id: string;
1086
+ } | {
1087
+ kind: "create_task";
1088
+ title: string;
1089
+ due_at: string | null;
1090
+ };
1091
+ type AiCommercialProposal = {
1092
+ id: string;
1093
+ opportunity_id: string;
1094
+ opportunity_title: string;
1095
+ opportunity_status: string;
1096
+ stage_id: string | null;
1097
+ stage_label: string | null;
1098
+ contact_id: string;
1099
+ contact_name: string | null;
1100
+ /** Optimistic lock echoed in `commercialProposals.decide`. */
1101
+ seq: number;
1102
+ status: "pending" | "approved" | "dismissed" | "superseded";
1103
+ next_action: string;
1104
+ rationale: string;
1105
+ evidence: string[];
1106
+ effect: AiCommercialEffect;
1107
+ effect_stage_label: string | null;
1108
+ provider: string;
1109
+ model: string;
1110
+ binding_source: string | null;
1111
+ created_at: string;
1112
+ decided_at: string | null;
1113
+ decided_by: string | null;
1114
+ decided_by_label: string | null;
1115
+ decided_by_api_key: string | null;
1116
+ decision_note: string | null;
1117
+ effect_applied: boolean | null;
1118
+ effect_result: AiRecord | null;
1119
+ };
1120
+ type AiCommercialJob = {
1121
+ id: string;
1122
+ opportunity_id: string;
1123
+ opportunity_title: string | null;
1124
+ reason: "manual" | "automatic";
1125
+ status: string;
1126
+ last_error: string | null;
1127
+ proposal_id: string | null;
1128
+ created_at: string;
1129
+ finished_at: string | null;
1130
+ };
1131
+ type AiCommercialRequest = {
1132
+ job_id: string;
1133
+ status: string;
1134
+ queued: boolean;
1135
+ replayed: boolean;
1136
+ };
1137
+ type AiCommercialDecision = {
1138
+ id: string;
1139
+ status: "approved" | "dismissed";
1140
+ seq: number;
1141
+ effect_applied: boolean | null;
1142
+ effect_result: AiRecord | null;
1143
+ replayed: boolean;
1144
+ };
1145
+ type AiCommercialSettings = {
1146
+ enabled: boolean;
1147
+ revision: number;
1148
+ updated_at: string | null;
1149
+ };
1150
+ type AiGateMode = "open" | "allowlist" | "pre_go_live";
1151
+ type AiChannelGate = {
1152
+ channel_account_id: string;
1153
+ channel_name: string;
1154
+ channel: string;
1155
+ mode: AiGateMode;
1156
+ /** "default" = not configured: closed channel (test numbers only, empty list). */
1157
+ origin: "default" | "legacy" | "user" | "api";
1158
+ test_phone_numbers: string[];
1159
+ revision: string;
1160
+ opened_at: string | null;
1161
+ updated_at: string | null;
1162
+ ai_owner: {
1163
+ kind: "agent" | "router";
1164
+ id: string;
1165
+ name: string;
1166
+ automatic: boolean;
1167
+ } | null;
1168
+ };
1169
+ type AiEligibilitySettings = {
1170
+ authorization_ttl_days: number;
1171
+ authorize_broadcast_replies: boolean;
1172
+ authorize_automation_replies: boolean;
1173
+ assignment_blocks_ai: boolean;
1174
+ revision: string;
1175
+ };
1176
+ type AiEligibilityOverview = {
1177
+ settings: AiEligibilitySettings;
1178
+ channels: AiChannelGate[];
1179
+ };
1180
+ type AiContactAuthorization = {
1181
+ id: string;
1182
+ channel_account_id: string;
1183
+ contact_id: string;
1184
+ /** null unless the key also has contacts:read. */
1185
+ contact_name: string | null;
1186
+ /** Full phone with contacts:read; otherwise masked as "••••1234" (or null). */
1187
+ contact_phone: string | null;
1188
+ kind: "broadcast_reply" | "journey_reply" | "followup_reply" | "manual_resume";
1189
+ reason: string;
1190
+ source_id: string | null;
1191
+ authorized_at: string;
1192
+ expires_at: string;
1193
+ status: "active" | "expired" | "revoked";
1194
+ revoked_at: string | null;
1195
+ revoked_reason: string | null;
1196
+ };
1197
+ type AiInferenceOutcome = "ok" | "failed" | "unknown" | "in_progress";
1198
+ type AiInferenceOrigin = "purpose" | "inherited_proposal" | "customer_default" | "fallback" | "agent_version" | "router_config" | "unrecorded";
1199
+ type AiInferenceExplanation = {
1200
+ point_label: string;
1201
+ origin_explanation: string;
1202
+ /** Present when the row has an error code. */
1203
+ cause?: string;
1204
+ consequence?: string;
1205
+ suggested_action?: string;
1206
+ };
1207
+ type AiInference = AiInferenceExplanation & {
1208
+ id: string;
1209
+ created_at: string;
1210
+ completed_at: string | null;
1211
+ purpose: string;
1212
+ point: string;
1213
+ provider: string;
1214
+ model: string;
1215
+ status: "started" | "completed" | "failed" | "unknown";
1216
+ outcome: AiInferenceOutcome;
1217
+ measurement_status: string;
1218
+ error_code: string | null;
1219
+ http_status: number | null;
1220
+ origin: AiInferenceOrigin;
1221
+ agent_id: string | null;
1222
+ execution_id: string | null;
1223
+ latency_ms: number | null;
1224
+ input_tokens: number | null;
1225
+ output_tokens: number | null;
1226
+ estimated_cost_usd: number | null;
1227
+ reserved_usd: number | null;
1228
+ };
1229
+ type AiInferenceSummary = {
1230
+ failures: (AiInferenceExplanation & {
1231
+ code: string;
1232
+ point: string;
1233
+ origin: AiInferenceOrigin;
1234
+ calls: number;
1235
+ last_at: string;
1236
+ })[];
1237
+ points: {
1238
+ point: string;
1239
+ point_label: string;
1240
+ calls: number;
1241
+ failed: number;
1242
+ unknown: number;
1243
+ in_progress: number;
1244
+ fallback_calls: number;
1245
+ estimated_cost_usd: number | null;
1246
+ unmeasured_calls: number;
1247
+ }[];
1248
+ };
1249
+ type AiKnowledgeHit = AiKnowledgeChunk & {
1250
+ source_name: string;
1251
+ similarity: number;
1252
+ };
1253
+ type AiKnowledgeSearchDiagnostics = {
1254
+ hits: AiKnowledgeHit[];
1255
+ diagnostics: {
1256
+ reason: "ok" | "below_threshold" | "not_indexed" | "inactive" | "no_candidates";
1257
+ explanation: string;
1258
+ threshold: number;
1259
+ best: {
1260
+ chunk_id: string;
1261
+ source_id: string;
1262
+ source_name: string;
1263
+ similarity: number;
1264
+ } | null;
1265
+ sources: {
1266
+ id: string;
1267
+ name: string;
1268
+ active: boolean;
1269
+ status: AiKnowledgeSource["status"];
1270
+ has_active_version: boolean;
1271
+ pending: boolean;
1272
+ chunk_count: number | null;
1273
+ last_error: string | null;
1274
+ }[];
1275
+ };
1276
+ };
1277
+ type AiCatalogItems = {
1278
+ items: {
1279
+ id: string;
1280
+ hash: string;
1281
+ updated_at: string;
1282
+ source_updated_at: string | null;
1283
+ }[];
1284
+ last_events: {
1285
+ event_key: string;
1286
+ integration: string;
1287
+ created_at: string;
1288
+ result: unknown;
1289
+ }[];
1290
+ };
1291
+ type AiCatalogSyncInput = AiScope & {
1292
+ /** Product source (import kind products). */
1293
+ id: string;
1294
+ /** Producer event id: retry the same body with the same key. */
1295
+ event_key: string;
1296
+ integration?: string;
1297
+ upserts?: (AiCatalogProduct & {
1298
+ updated_at?: string;
1299
+ })[];
1300
+ removals?: {
1301
+ id: string;
1302
+ updated_at?: string;
1303
+ }[];
1304
+ };
1305
+ type AiCatalogSyncResult = {
1306
+ source_id: string;
1307
+ revision: string;
1308
+ active: boolean;
1309
+ status: string;
1310
+ changed: number;
1311
+ removed: number;
1312
+ unchanged: number;
1313
+ stale: number;
1314
+ missing: number;
1315
+ items: number;
1316
+ reindex_queued: boolean;
1317
+ emptied: boolean;
1318
+ reactivated: boolean;
1319
+ replayed: boolean;
1320
+ };
1321
+ type AiKnowledgeCitation = {
1322
+ chunk_id: string;
1323
+ source_id: string;
1324
+ source_name: string;
1325
+ version_id?: string | null;
1326
+ ordinal?: number | null;
1327
+ snippet: string;
1328
+ score: number;
1329
+ query?: string | null;
1330
+ };
1331
+ type AiExecutionCitations = {
1332
+ execution_id: string;
1333
+ agent_id: string;
1334
+ conversation_id: string | null;
1335
+ citations: AiKnowledgeCitation[];
1336
+ updated_at: string;
1337
+ };
1338
+ type AiAgentCoverage = {
1339
+ sources: {
1340
+ id: string;
1341
+ name: string | null;
1342
+ status: AiKnowledgeSource["status"] | null;
1343
+ active: boolean;
1344
+ ready: boolean;
1345
+ issue: "missing" | "inactive" | "not_indexed" | "failed" | "reindexing" | null;
1346
+ }[];
1347
+ skills: {
1348
+ id: string;
1349
+ name: string | null;
1350
+ ready: boolean;
1351
+ issue: "missing" | "inactive" | null;
1352
+ }[];
1353
+ embedding_ready: boolean;
1354
+ funnel: {
1355
+ stages: {
1356
+ id: string;
1357
+ label: string;
1358
+ position: number;
1359
+ allowed: boolean;
1360
+ }[];
1361
+ allowed_count: number;
1362
+ total_count: number;
1363
+ can_move: boolean;
1364
+ mute: boolean;
1365
+ unknown_allowed_ids: string[];
1366
+ };
1367
+ issues: string[];
1368
+ };
1369
+ type AiMemoryEntryEvent = {
1370
+ id: string;
1371
+ action: "archived" | "reactivated" | "approved" | "status_changed";
1372
+ from_status: string;
1373
+ to_status: string;
1374
+ entry_revision: string;
1375
+ actor_user_id: string | null;
1376
+ actor_api_key_id: string | null;
1377
+ created_at: string;
1378
+ };
1379
+ type AiNoticeCheck = {
1380
+ id: string;
1381
+ status: "ok" | "warning" | "error";
1382
+ message: string;
1383
+ };
1384
+ type AiNoticeEffect = {
1385
+ days: number;
1386
+ sampled: number;
1387
+ total: number;
1388
+ with_notice: {
1389
+ cases: number;
1390
+ answered: number;
1391
+ median_minutes: number | null;
1392
+ };
1393
+ without_notice: {
1394
+ cases: number;
1395
+ answered: number;
1396
+ median_minutes: number | null;
1397
+ };
1398
+ median_to_notice_minutes: number | null;
1399
+ };
1400
+ type AiOperatorMetrics = {
1401
+ days: number;
1402
+ agents: {
1403
+ agent_id: string;
1404
+ turns: number;
1405
+ turns_absent: number;
1406
+ turns_with_promises: number;
1407
+ turns_not_delivered: number;
1408
+ promises: number;
1409
+ owned: number;
1410
+ owned_by_agent: number;
1411
+ owned_by_operator: number;
1412
+ owned_by_human: number;
1413
+ unowned: number;
1414
+ dismissed: number;
1415
+ pending: number;
1416
+ corrections: number;
1417
+ corrections_by_operator: number;
1418
+ corrections_by_human: number;
1419
+ unowned_reasons: Record<string, number>;
1420
+ ownership_rate: number | null;
1421
+ }[];
1422
+ };
1423
+ type AiTurnPromise = {
1424
+ id: string;
1425
+ declaration_id: string;
1426
+ agent_id: string;
1427
+ conversation_id: string | null;
1428
+ contact_id: string | null;
1429
+ description: string;
1430
+ due_at: string | null;
1431
+ due_text: string | null;
1432
+ status: "pending" | "owned" | "unowned" | "dismissed";
1433
+ owner_kind: string | null;
1434
+ owner_source: string | null;
1435
+ unowned_reason: string | null;
1436
+ corrected_by_kind: string | null;
1437
+ correction_note: string | null;
1438
+ revision: number;
1439
+ created_at: string;
1440
+ };
1441
+ type AiCatalogModel = {
1442
+ model: string;
1443
+ label: string | null;
1444
+ context_tokens: number | null;
1445
+ max_output_tokens: number | null;
1446
+ /** null = the provider catalog does not report it. */
1447
+ tools: boolean | null;
1448
+ vision: boolean | null;
1449
+ /** Suggestion only; never applied to tariffs automatically. */
1450
+ pricing: {
1451
+ input_usd_per_million: number;
1452
+ output_usd_per_million: number;
1453
+ cache_read_usd_per_million: number | null;
1454
+ cache_write_usd_per_million: number | null;
1455
+ notes: ("request_fee" | "long_context" | "image_input" | "variable")[];
1456
+ } | null;
1457
+ };
1458
+ type AiModelCatalogSnapshot = {
1459
+ id: string;
1460
+ credential_id: string;
1461
+ provider: string;
1462
+ version: number;
1463
+ credential_revision: string;
1464
+ model_count: number;
1465
+ fetched_at: string;
1466
+ models: AiCatalogModel[];
1467
+ };
1468
+ type AiModelCatalogSync = Omit<AiModelCatalogSnapshot, "credential_revision" | "models">;
1469
+ type AiSkillNearMiss = {
1470
+ id: string;
1471
+ skill_id: string;
1472
+ skill_name: string;
1473
+ skill_revision: string | null;
1474
+ probe: string;
1475
+ excerpt: string;
1476
+ occurrences: number;
1477
+ status: "pending" | "accepted" | "ignored";
1478
+ revision: string;
1479
+ agent_id: string | null;
1480
+ conversation_id: string | null;
1481
+ accepted_phrase: string | null;
1482
+ first_seen_at: string;
1483
+ last_seen_at: string;
1484
+ decided_at: string | null;
1485
+ };
1486
+ type AiPlatformSkillComposition = {
1487
+ slug: string;
1488
+ name: string;
1489
+ description: string;
1490
+ version: number;
1491
+ state: "available" | "overridden_by_copy" | "overridden_by_name";
1492
+ customer_skill_id: string | null;
1493
+ customer_skill_active: boolean | null;
1494
+ };
1495
+ type AiFollowupPromiseStatus = "scheduled" | "turn_enqueued" | "template_pending" | "template_dispatching" | "alerted" | "completed" | "skipped" | "failed" | "unknown" | "cancelled";
1496
+ /** Promised return: at due_at the responsible agent reopens the conversation. */
1497
+ type AiFollowupPromise = {
1498
+ id: string;
1499
+ contact_id: string;
1500
+ conversation_id: string;
1501
+ agent_id: string;
1502
+ source: "agent" | "human" | "api";
1503
+ reason: string;
1504
+ promise: string;
1505
+ context_snapshot: string | null;
1506
+ promised_at: string;
1507
+ /** promised_at adjusted to the agent's published service window. */
1508
+ due_at: string;
1509
+ time_zone: string;
1510
+ outside_window: "alert" | "template";
1511
+ template_id: string | null;
1512
+ status: AiFollowupPromiseStatus;
1513
+ revision: string;
1514
+ fired_at: string | null;
1515
+ fired_run_id: string | null;
1516
+ alert_id: string | null;
1517
+ outcome_reason: string | null;
1518
+ last_error: string | null;
1519
+ cancelled_at: string | null;
1520
+ cancel_reason: string | null;
1521
+ cancelled_by_kind: "user" | "api_key" | "agent" | null;
1522
+ created_by_kind: "user" | "api_key" | "agent";
1523
+ origin_run_id: string | null;
1524
+ external_id: string | null;
1525
+ completed_at: string | null;
1526
+ created_at: string;
1527
+ updated_at: string;
1528
+ };
1529
+ type AiFollowupPromiseDetail = AiFollowupPromise & {
1530
+ contact: {
1531
+ id: string;
1532
+ name: string | null;
1533
+ phone: string | null;
1534
+ };
1535
+ agent: {
1536
+ id: string;
1537
+ name: string;
1538
+ } | null;
1539
+ run: {
1540
+ id: string;
1541
+ status: string;
1542
+ skip_reason: string | null;
1543
+ execution_id: string | null;
1544
+ execution_status: string | null;
1545
+ } | null;
1546
+ alert: {
1547
+ id: string;
1548
+ status: string;
1549
+ } | null;
1550
+ };
1551
+ type AiFollowupQueueRow = {
1552
+ kind: "enrollment" | "promise";
1553
+ id: string;
1554
+ contact_id: string;
1555
+ contact_name: string | null;
1556
+ contact_phone: string | null;
1557
+ conversation_id: string;
1558
+ flow_id: string | null;
1559
+ flow_name: string | null;
1560
+ agent_id: string | null;
1561
+ agent_name: string | null;
1562
+ status: string;
1563
+ node_id: string | null;
1564
+ next_fire_at: string | null;
1565
+ reason: string | null;
1566
+ updated_at: string;
1567
+ created_at: string;
1568
+ last_error: string | null;
1569
+ };
1570
+ /** Cursor page: pass next_cursor back as cursor; null means the end. */
1571
+ type AiFollowupQueuePage = {
1572
+ data: AiFollowupQueueRow[];
1573
+ next_cursor: string | null;
1574
+ };
1575
+ type AiFollowupQueueFilters = {
1576
+ status?: string;
1577
+ q?: string;
1578
+ contact_id?: string;
1579
+ cursor?: string;
1580
+ limit?: number;
1581
+ };
1582
+ type AiCapabilitySignal = "only_failures" | "failing" | "outside_config" | "never_used" | "recently_enabled" | "test_only" | "healthy";
1583
+ type AiCapabilityUsageList = {
1584
+ summary: {
1585
+ uses: number;
1586
+ failures: number;
1587
+ needs_attention: number;
1588
+ };
1589
+ items: {
1590
+ tool: string;
1591
+ label: string;
1592
+ enabled: boolean;
1593
+ signal: AiCapabilitySignal;
1594
+ recommendation: string;
1595
+ total: number;
1596
+ failures: number;
1597
+ unknown: number;
1598
+ test: number;
1599
+ last_at: string | null;
1600
+ }[];
1601
+ };
1602
+ type AiCapabilityUsage = {
1603
+ agent_id: string;
1604
+ since: string;
1605
+ days: number;
1606
+ source: "published" | "draft";
1607
+ configured_at: string | null;
1608
+ agent: AiCapabilityUsageList;
1609
+ operator: AiCapabilityUsageList & {
1610
+ enabled: boolean;
1611
+ };
1612
+ };
1613
+ /** Each source reports its own status: an error is never shown as zero. */
1614
+ type AiEvolutionSource<T> = {
1615
+ status: "ok";
1616
+ data: T;
1617
+ error: null;
1618
+ } | {
1619
+ status: "error";
1620
+ data: null;
1621
+ error: string;
1622
+ };
1623
+ type AiSearchEvolution = {
1624
+ total: number;
1625
+ failures: number;
1626
+ empty: number;
1627
+ with_results: number;
1628
+ series: {
1629
+ day: string;
1630
+ total: number;
1631
+ empty: number;
1632
+ }[];
1633
+ empty_samples: {
1634
+ at: string;
1635
+ query: string | null;
1636
+ }[];
1637
+ by_name: Record<string, number> | null;
1638
+ sources: {
1639
+ ready: number;
1640
+ indexing: number;
1641
+ failed: number;
1642
+ inactive: number;
1643
+ } | null;
1644
+ };
1645
+ type AiEvolution = {
1646
+ from: string;
1647
+ to: string;
1648
+ days: 7 | 30 | 90;
1649
+ agent_id: string | null;
1650
+ sources: {
1651
+ learning: AiEvolutionSource<{
1652
+ memory: {
1653
+ created: number;
1654
+ created_manual: number;
1655
+ created_from_proposals: number;
1656
+ active: number;
1657
+ pending: number;
1658
+ archived: number;
1659
+ };
1660
+ proposals: {
1661
+ created: number;
1662
+ applied: number;
1663
+ rejected: number;
1664
+ pending: number;
1665
+ };
1666
+ skills: {
1667
+ updated: number;
1668
+ installed: number;
1669
+ };
1670
+ timeline: {
1671
+ at: string;
1672
+ kind: "memory" | "proposal" | "skill";
1673
+ title: string;
1674
+ }[];
1675
+ timeline_total: number;
1676
+ }>;
1677
+ knowledge: AiEvolutionSource<AiSearchEvolution>;
1678
+ skills: AiEvolutionSource<AiSearchEvolution>;
1679
+ routing: AiEvolutionSource<{
1680
+ total: number;
1681
+ by_outcome: Record<string, number>;
1682
+ by_intent: Record<string, number>;
1683
+ failed: number;
1684
+ no_match: number;
1685
+ }>;
1686
+ crm: AiEvolutionSource<{
1687
+ opportunities: {
1688
+ created: number;
1689
+ won: number;
1690
+ lost: number;
1691
+ open: number;
1692
+ };
1693
+ stage_moves: number;
1694
+ cases_opened: number;
1695
+ inbound_messages: number;
1696
+ executions: {
1697
+ live: number;
1698
+ completed: number;
1699
+ failed: number;
1700
+ unknown: number;
1701
+ preview: number;
1702
+ };
1703
+ }>;
1704
+ };
1705
+ };
1706
+ type AiStyleAdjustmentId = "sem_travessao_longo";
1707
+ type AiStyleAdjustment = {
1708
+ adjustment: AiStyleAdjustmentId;
1709
+ enabled: boolean;
1710
+ /** Opaque CAS revision; "0" when never saved. */
1711
+ revision: string;
1712
+ updated_at: string | null;
1713
+ updated_by: string | null;
1714
+ updated_by_api_key: string | null;
1715
+ };
1716
+
1717
+ interface AiField {
1718
+ type: string;
1719
+ optional: boolean;
1720
+ }
1721
+ interface AiOperation {
1722
+ group: string;
1723
+ name: string;
1724
+ method: string;
1725
+ path: string;
1726
+ shape: string;
1727
+ /** Required API scope when it differs from the method default (GET = read, others = write). */
1728
+ scope?: "agents:read" | "agents:write";
1729
+ description: string;
1730
+ fields: Record<string, AiField>;
1731
+ }
1732
+ /** Explicit public routes, checked against the API candidate. */
1733
+ declare const AI_OPERATIONS: readonly AiOperation[];
1734
+
1735
+ declare class AiAgentsResource {
1736
+ private readonly client;
1737
+ constructor(client: BotoZap);
1738
+ /** GET /ai/agents */
1739
+ list(input: AiPage): Promise<OffsetList<AiAgent>>;
1740
+ /** GET /ai/agents/:id */
1741
+ get(input: AiScope & {
1742
+ id: string;
1743
+ }): Promise<{
1744
+ agent: AiAgent;
1745
+ versions: AiAgentVersion[];
1746
+ }>;
1747
+ /** POST /ai/agents */
1748
+ create(input: AiAgentInput): Promise<AiDraftResult>;
1749
+ /** PUT /ai/agents/:id */
1750
+ saveDraft(input: AiAgentInput & {
1751
+ id: string;
1752
+ expected_revision?: string;
1753
+ }): Promise<AiDraftResult>;
1754
+ /** Publica versão e altera próximos atendimentos; confira a versão antes de executar. */
1755
+ publish(input: AiRevision & {
1756
+ id: string;
1757
+ } & {
1758
+ version_id: string;
1759
+ }): Promise<{
1760
+ version_id: string;
1761
+ number: number;
1762
+ }>;
1763
+ /** Restaura versão para edição; não ativa atendimento. */
1764
+ restore(input: AiScope & {
1765
+ id: string;
1766
+ } & {
1767
+ version_id: string;
1768
+ expected_draft_revision?: string;
1769
+ }): Promise<AiDraftResult>;
1770
+ /** POST /ai/agents/:id/duplicate */
1771
+ duplicate(input: AiScope & {
1772
+ id: string;
1773
+ } & {
1774
+ name: string;
1775
+ }): Promise<AiDraftResult>;
1776
+ /** Ativar automático pode enviar respostas; exige intenção explícita do usuário. */
1777
+ operation(input: AiRevision & {
1778
+ id: string;
1779
+ } & {
1780
+ mode: "automatic" | "assisted";
1781
+ paused: boolean;
1782
+ }): Promise<{
1783
+ revision: string;
1784
+ paused: boolean;
1785
+ mode: "automatic" | "assisted";
1786
+ }>;
1787
+ /** POST /ai/agents/:id/archive */
1788
+ archive(input: AiRevision & {
1789
+ id: string;
1790
+ } & {
1791
+ archived: boolean;
1792
+ }): Promise<{
1793
+ id: string;
1794
+ revision: string;
1795
+ archived: boolean;
1796
+ }>;
1797
+ /** Teste livre BYOK sem enviar ao WhatsApp; ferramentas simuladas. Preserve operation_key UUID em resultado incerto. */
1798
+ preview(input: AiScope & {
1799
+ id: string;
1800
+ } & {
1801
+ version_id: string;
1802
+ operation_key: string;
1803
+ messages: {
1804
+ role: "user" | "assistant";
1805
+ content: string;
1806
+ }[];
1807
+ }): Promise<AiExecution>;
1808
+ /** Uso real das ferramentas contra a configuração (days 1–90, padrão 30); falha de leitura é 503. */
1809
+ capabilityUsage(input: AiScope & {
1810
+ id: string;
1811
+ days?: number;
1812
+ }): Promise<AiCapabilityUsage>;
1813
+ }
1814
+ declare class AiCredentialsResource {
1815
+ private readonly client;
1816
+ constructor(client: BotoZap);
1817
+ /** GET /ai/credentials */
1818
+ list(input: AiScope): Promise<AiCredential[]>;
1819
+ /** GET /ai/credentials/:id */
1820
+ get(input: AiScope & {
1821
+ id: string;
1822
+ }): Promise<AiCredential>;
1823
+ /** Cria credencial própria no Vault; a resposta nunca contém a chave. */
1824
+ create(input: AiScope & {
1825
+ provider: AiProvider;
1826
+ label: string;
1827
+ key: string;
1828
+ }): Promise<AiCredential>;
1829
+ /** Rotação mantém ID; envie key sozinha ou label/active. CAS obrigatório. */
1830
+ update(input: AiRevision & {
1831
+ id: string;
1832
+ } & ({
1833
+ key: string;
1834
+ label?: never;
1835
+ active?: never;
1836
+ } | {
1837
+ key?: never;
1838
+ label?: string;
1839
+ active?: boolean;
1840
+ })): Promise<AiCredential>;
1841
+ /** POST /ai/credentials/:id/revalidate */
1842
+ revalidate(input: AiRevision & {
1843
+ id: string;
1844
+ }): Promise<AiCredential>;
1845
+ /** DELETE /ai/credentials/:id */
1846
+ remove(input: AiRevision & {
1847
+ id: string;
1848
+ }): Promise<void>;
1849
+ }
1850
+ declare class AiProvidersResource {
1851
+ private readonly client;
1852
+ constructor(client: BotoZap);
1853
+ /** GET /ai/providers */
1854
+ get(input: AiScope): Promise<{
1855
+ providers: AiRecord[];
1856
+ purposes: Record<string, string>;
1857
+ credentials: AiCredential[];
1858
+ bindings: AiBinding[];
1859
+ configurable_purposes: AiConfigurablePurpose[];
1860
+ configuration_sources: Record<"agent_turn" | "agent_operator" | "router", string>;
1861
+ }>;
1862
+ /** PUT /ai/providers */
1863
+ saveBinding(input: AiScope & AiBindingTarget & {
1864
+ purpose: AiConfigurablePurpose;
1865
+ fallback?: AiBindingTarget | null;
1866
+ }): Promise<AiBinding>;
1867
+ /** DELETE /ai/providers */
1868
+ removeBinding(input: AiScope & {
1869
+ purpose: AiConfigurablePurpose;
1870
+ }): Promise<void>;
1871
+ /** GET /ai/providers/:provider/models */
1872
+ models(input: AiScope & {
1873
+ provider: AiProvider;
1874
+ credential_id: string;
1875
+ }): Promise<AiProviderModel[]>;
1876
+ /** Último snapshot do catálogo por credencial; nunca contém chaves. */
1877
+ catalog(input: AiScope): Promise<AiModelCatalogSnapshot[]>;
1878
+ /** Consulta o catálogo com a chave própria na revisão informada. Nunca altera tarifas; 502 provider_* sem alteração. */
1879
+ syncCatalog(input: AiRevision & {
1880
+ credential_id: string;
1881
+ }): Promise<AiModelCatalogSync>;
1882
+ }
1883
+ declare class AiExecutionsResource {
1884
+ private readonly client;
1885
+ constructor(client: BotoZap);
1886
+ /** GET /ai/executions */
1887
+ list(input: AiPage & {
1888
+ agent_id?: string;
1889
+ status?: AiExecution["status"];
1890
+ }): Promise<OffsetList<AiExecution>>;
1891
+ /** GET /ai/executions/:id */
1892
+ get(input: AiScope & {
1893
+ id: string;
1894
+ } & {
1895
+ agent_id: string;
1896
+ }): Promise<AiExecution>;
1897
+ /** Aprova plano imutável e pode enviar resposta; confirme conteúdo com usuário. Operador executa ações sem enviar. Ator é a chave autenticada. */
1898
+ decide(input: AiScope & {
1899
+ id: string;
1900
+ } & {
1901
+ agent_id: string;
1902
+ decision: "approve" | "reject";
1903
+ }): Promise<AiExecution>;
1904
+ }
1905
+ declare class AiKnowledgeResource {
1906
+ private readonly client;
1907
+ importSource(input: AiKnowledgeImport): Promise<AiKnowledgeSource>;
1908
+ conversations(input: AiScope): Promise<AiKnowledgeConversation[]>;
1909
+ conversationPermission(input: AiScope & {
1910
+ id: string;
1911
+ expected_revision: string;
1912
+ allowed: boolean;
1913
+ }): Promise<{
1914
+ conversation_id: string;
1915
+ allowed: boolean;
1916
+ revision: string;
1917
+ }>;
1918
+ conversationPreview(input: AiScope & {
1919
+ id: string;
1920
+ }): Promise<AiKnowledgePreview>;
1921
+ constructor(client: BotoZap);
1922
+ /** GET /ai/knowledge */
1923
+ list(input: AiScope): Promise<AiKnowledgeSource[]>;
1924
+ /** GET /ai/knowledge/:id */
1925
+ get(input: AiScope & {
1926
+ id: string;
1927
+ }): Promise<{
1928
+ source: AiKnowledgeSource;
1929
+ text: string | null;
1930
+ file_name: string | null;
1931
+ versions: AiRecord[];
1932
+ usages: AiRecord[];
1933
+ }>;
1934
+ /** POST /ai/knowledge */
1935
+ create(input: AiScope & {
1936
+ name: string;
1937
+ kind: AiSourceKind;
1938
+ text: string;
1939
+ }): Promise<AiKnowledgeSource>;
1940
+ /** PATCH /ai/knowledge/:id */
1941
+ update(input: AiRevision & {
1942
+ id: string;
1943
+ } & {
1944
+ name?: string;
1945
+ active?: boolean;
1946
+ text?: string;
1947
+ }): Promise<AiKnowledgeSource>;
1948
+ /** DELETE /ai/knowledge/:id */
1949
+ remove(input: AiRevision & {
1950
+ id: string;
1951
+ }): Promise<void>;
1952
+ /** POST /ai/knowledge/:id/reindex */
1953
+ reindex(input: AiRevision & {
1954
+ id: string;
1955
+ }): Promise<AiKnowledgeSource>;
1956
+ /** GET /ai/knowledge/:id/chunks */
1957
+ chunks(input: AiScope & {
1958
+ id: string;
1959
+ }): Promise<AiKnowledgeChunk[]>;
1960
+ /** Busca somente nas fontes permitidas; pode chamar embeddings BYOK. */
1961
+ search(input: AiScope & {
1962
+ source_ids: string[];
1963
+ query: string;
1964
+ top_k?: number;
1965
+ threshold?: number;
1966
+ }): Promise<AiKnowledgeHit[]>;
1967
+ /** Mesma busca de `search` com motivo, melhor trecho abaixo do limiar e estado das fontes. */
1968
+ searchDiagnostics(input: AiScope & {
1969
+ source_ids: string[];
1970
+ query: string;
1971
+ top_k?: number;
1972
+ threshold?: number;
1973
+ }): Promise<AiKnowledgeSearchDiagnostics>;
1974
+ /** Itens atuais e últimos eventos da sincronização incremental de uma fonte de produtos. */
1975
+ catalogItems(input: AiScope & {
1976
+ id: string;
1977
+ }): Promise<AiCatalogItems>;
1978
+ /** Upserts/remoções por item; event_key idempotente (replayed não reaplica). */
1979
+ syncCatalog(input: AiCatalogSyncInput): Promise<AiCatalogSyncResult>;
1980
+ /** Fontes citadas nas respostas da IA (uso interno). Exatamente um filtro. */
1981
+ citations(input: AiScope & ({
1982
+ execution_id: string;
1983
+ conversation_id?: never;
1984
+ } | {
1985
+ conversation_id: string;
1986
+ execution_id?: never;
1987
+ })): Promise<AiExecutionCitations[]>;
1988
+ /** Prontidão das fontes, skills e etapas escolhidas para um agente; não altera nada. */
1989
+ coverage(input: AiScope & {
1990
+ knowledge_source_ids?: string[];
1991
+ skill_ids?: string[];
1992
+ allowed_stage_ids?: string[];
1993
+ tool_ids?: (AiToolId | (string & {}))[];
1994
+ }): Promise<AiAgentCoverage>;
1995
+ /** Upload de documento de até 20 MiB para indexação BYOK (direto ao armazenamento). */
1996
+ upload(input: AiScope & {
1997
+ name: string;
1998
+ file: Blob;
1999
+ file_name: string;
2000
+ onUploadPrepared?: AiUploadReceiptCallback;
2001
+ }): Promise<AiKnowledgeSource>;
2002
+ }
2003
+ declare class AiMemoryResource {
2004
+ private readonly client;
2005
+ checkpoints(input: AiScope & {
2006
+ agent_id?: string;
2007
+ conversation_id?: string;
2008
+ }): Promise<AiConversationCheckpoint[]>;
2009
+ constructor(client: BotoZap);
2010
+ /** GET /ai/memory */
2011
+ get(input: AiScope): Promise<AiMemory>;
2012
+ /** Publica nova memória de negócio versionada. */
2013
+ publish(input: AiRevision & {
2014
+ content: string;
2015
+ }): Promise<AiMemory>;
2016
+ /** PATCH /ai/memory */
2017
+ setEnabled(input: AiRevision & {
2018
+ enabled: boolean;
2019
+ }): Promise<AiMemory>;
2020
+ /** GET /ai/memory/versions */
2021
+ versions(input: AiScope): Promise<{
2022
+ id: string;
2023
+ revision: string;
2024
+ content: string;
2025
+ created_at: string;
2026
+ }[]>;
2027
+ /** GET /ai/memory/entries */
2028
+ entries(input: AiScope & {
2029
+ status?: "active" | "pending" | "archived";
2030
+ contact_id?: string;
2031
+ }): Promise<AiMemoryEntry[]>;
2032
+ /** POST /ai/memory/entries */
2033
+ createEntry(input: AiScope & {
2034
+ title: string;
2035
+ body: string;
2036
+ contact_id?: string;
2037
+ }): Promise<AiMemoryEntry>;
2038
+ /** PATCH /ai/memory/entries/:id */
2039
+ updateEntry(input: AiRevision & {
2040
+ id: string;
2041
+ } & {
2042
+ title: string;
2043
+ body: string;
2044
+ }): Promise<AiMemoryEntry>;
2045
+ /** DELETE /ai/memory/entries/:id */
2046
+ archiveEntry(input: AiRevision & {
2047
+ id: string;
2048
+ }): Promise<AiMemoryEntry>;
2049
+ /** Aprova memória pendente após revisão explícita; ator é chave autenticada de owner/admin atual. */
2050
+ approveEntry(input: AiRevision & {
2051
+ id: string;
2052
+ }): Promise<AiMemoryEntry>;
2053
+ /** Devolve memória arquivada ao contexto; é nova aprovação de owner/admin. */
2054
+ reactivateEntry(input: AiRevision & {
2055
+ id: string;
2056
+ }): Promise<AiMemoryEntry>;
2057
+ /** Auditoria das transições da entrada (até 50, mais recentes primeiro). */
2058
+ entryEvents(input: AiScope & {
2059
+ id: string;
2060
+ }): Promise<AiMemoryEntryEvent[]>;
2061
+ }
2062
+ declare class AiSkillsResource {
2063
+ private readonly client;
2064
+ catalog(input: AiScope): Promise<AiPlatformSkill[]>;
2065
+ install(input: AiScope & {
2066
+ slug: string;
2067
+ version_id: string;
2068
+ }): Promise<AiSkill>;
2069
+ constructor(client: BotoZap);
2070
+ /** GET /ai/skills */
2071
+ list(input: AiScope): Promise<AiSkill[]>;
2072
+ /** GET /ai/skills/:id */
2073
+ get(input: AiScope & {
2074
+ id: string;
2075
+ }): Promise<{
2076
+ skill: AiSkill;
2077
+ versions: AiSkillVersion[];
2078
+ usages: AiRecord[];
2079
+ }>;
2080
+ /** POST /ai/skills */
2081
+ create(input: AiScope & AiSkillInput): Promise<AiSkill>;
2082
+ /** PATCH /ai/skills/:id */
2083
+ update(input: AiRevision & {
2084
+ id: string;
2085
+ } & AiSkillInput): Promise<AiSkill>;
2086
+ /** DELETE /ai/skills/:id */
2087
+ remove(input: AiRevision & {
2088
+ id: string;
2089
+ }): Promise<void>;
2090
+ /** GET /ai/skills/:id/versions */
2091
+ versions(input: AiScope & {
2092
+ id: string;
2093
+ }): Promise<AiSkillVersion[]>;
2094
+ /** GET /ai/skills/:id/references */
2095
+ reference(input: AiScope & {
2096
+ id: string;
2097
+ } & {
2098
+ version_id: string;
2099
+ path: string;
2100
+ }): Promise<{
2101
+ content: string;
2102
+ }>;
2103
+ /** Importa pacote ZIP até 5 MiB; substituir exige id e expected_revision juntos. */
2104
+ importZip(input: AiScope & {
2105
+ id?: string;
2106
+ expected_revision?: string;
2107
+ file: Blob;
2108
+ file_name: string;
2109
+ onUploadPrepared?: AiUploadReceiptCallback;
2110
+ }): Promise<AiSkill>;
2111
+ /** Quase acionamentos por palavra de sondagem, para curadoria humana. */
2112
+ nearMisses(input: AiScope & {
2113
+ status?: AiSkillNearMiss["status"];
2114
+ skill_id?: string;
2115
+ }): Promise<AiSkillNearMiss[]>;
2116
+ /** accept cria nova versão da skill (CAS em skill_revision); ignore encerra. */
2117
+ decideNearMiss(input: AiRevision & {
2118
+ id: string;
2119
+ } & ({
2120
+ decision: "accept";
2121
+ phrase: string;
2122
+ skill_revision: string;
2123
+ } | {
2124
+ decision: "ignore";
2125
+ phrase?: never;
2126
+ skill_revision?: never;
2127
+ })): Promise<{
2128
+ near_miss: AiSkillNearMiss;
2129
+ skill: AiSkill | null;
2130
+ }>;
2131
+ /** Skills da plataforma e se o Cliente as substitui. */
2132
+ composition(input: AiScope): Promise<AiPlatformSkillComposition[]>;
2133
+ }
2134
+ declare class AiFollowupFlowsResource {
2135
+ private readonly client;
2136
+ constructor(client: BotoZap);
2137
+ /** GET /ai/followup-flows */
2138
+ list(input: AiScope): Promise<AiFlow[]>;
2139
+ /** GET /ai/followup-flows/:id */
2140
+ get(input: AiScope & {
2141
+ id: string;
2142
+ }): Promise<AiFlow>;
2143
+ /** POST /ai/followup-flows */
2144
+ create(input: AiFlowInput): Promise<AiFlow>;
2145
+ /** PUT /ai/followup-flows/:id */
2146
+ update(input: AiFlowInput & {
2147
+ id: string;
2148
+ expected_revision: string;
2149
+ }): Promise<AiFlow>;
2150
+ /** PATCH /ai/followup-flows/:id */
2151
+ control(input: AiRevision & {
2152
+ id: string;
2153
+ } & {
2154
+ status: "active" | "paused" | "archived";
2155
+ }): Promise<AiFlow>;
2156
+ /** Publica grafo validado; mensagens futuras respeitam consentimento, janelas e aprovação assistida. */
2157
+ publish(input: AiRevision & {
2158
+ id: string;
2159
+ }): Promise<AiFlow>;
2160
+ /** GET /ai/followup-flows/:id/versions */
2161
+ versions(input: AiScope & {
2162
+ id: string;
2163
+ }): Promise<AiFlowVersion[]>;
2164
+ /** Restaura e publica uma nova versão atomicamente; confirme substituição do rascunho. */
2165
+ rollback(input: AiRevision & {
2166
+ id: string;
2167
+ } & {
2168
+ version_id: string;
2169
+ }): Promise<AiFlow>;
2170
+ /** GET /ai/followup-flows/from-model */
2171
+ models(input?: Record<string, never>): Promise<AiRecord[]>;
2172
+ /** POST /ai/followup-flows/from-model */
2173
+ installModel(input: AiScope & {
2174
+ model_id: string;
2175
+ name?: string;
2176
+ stage_id?: string;
2177
+ }): Promise<AiFlow>;
2178
+ }
2179
+ declare class AiFollowupsResource {
2180
+ private readonly client;
2181
+ constructor(client: BotoZap);
2182
+ /** GET /ai/followups/enrollments */
2183
+ list(input: AiScope & {
2184
+ flow_id?: string;
2185
+ contact_id?: string;
2186
+ status?: string;
2187
+ limit?: number;
2188
+ }): Promise<AiEnrollment[]>;
2189
+ /** GET /ai/followups/enrollments/:id */
2190
+ get(input: AiScope & {
2191
+ id: string;
2192
+ }): Promise<{
2193
+ enrollment: AiEnrollment;
2194
+ events: AiFollowupEvent[];
2195
+ effects: AiFollowupEffect[];
2196
+ }>;
2197
+ /** Inicia acompanhamento que pode enviar mensagens; preserve operation_key UUID. */
2198
+ enroll(input: AiScope & {
2199
+ flow_id: string;
2200
+ contact_id: string;
2201
+ conversation_id: string;
2202
+ operation_key: string;
2203
+ agent_id?: string;
2204
+ appointment_id?: string;
2205
+ }): Promise<AiEnrollment>;
2206
+ /** POST /ai/followups/enrollments/:id/control */
2207
+ control(input: AiRevision & {
2208
+ id: string;
2209
+ } & {
2210
+ action: "pause" | "resume" | "postpone" | "skip" | "cancel";
2211
+ due_at?: string;
2212
+ branch_id?: string;
2213
+ note?: string;
2214
+ }): Promise<AiEnrollment>;
2215
+ /** Aprova/rejeita mensagem imutável após revisão. Não aceita texto substituto nem actor_id. */
2216
+ decideEffect(input: AiScope & {
2217
+ id: string;
2218
+ } & {
2219
+ approve: boolean;
2220
+ }): Promise<AiRecord>;
2221
+ /** Concilia resultado incerto com evidência. Sem dispatch só cancelled; sent exige wamid. Nunca reenvia unknown. */
2222
+ resolveEffect(input: AiScope & {
2223
+ id: string;
2224
+ } & {
2225
+ outcome: "sent" | "rejected" | "cancelled";
2226
+ note: string;
2227
+ wamid?: string;
2228
+ }): Promise<{
2229
+ resolved: true;
2230
+ }>;
2231
+ /** Fila unificada (inscrições e retornos avulsos) por cursor. */
2232
+ queue(input: AiScope & AiFollowupQueueFilters & {
2233
+ kind?: "enrollment" | "promise";
2234
+ flow_id?: string;
2235
+ }): Promise<AiFollowupQueuePage>;
2236
+ /** Retornos avulsos por cursor. */
2237
+ promises(input: AiScope & AiFollowupQueueFilters): Promise<AiFollowupQueuePage>;
2238
+ /** Marca retorno que reabre a conversa pelo agente; preserve operation_key UUID para repetir. */
2239
+ schedulePromise(input: AiScope & {
2240
+ contact_id: string;
2241
+ conversation_id: string;
2242
+ agent_id: string;
2243
+ operation_key: string;
2244
+ reason: string;
2245
+ promise: string;
2246
+ context_snapshot?: string;
2247
+ promised_at: string;
2248
+ outside_window?: "alert" | "template";
2249
+ template_id?: string;
2250
+ template_variables?: Record<string, string>;
2251
+ }): Promise<AiFollowupPromise>;
2252
+ getPromise(input: AiScope & {
2253
+ id: string;
2254
+ }): Promise<AiFollowupPromiseDetail>;
2255
+ /** Desmarca retorno não disparado; 409 quando já disparado ou cancelado. */
2256
+ cancelPromise(input: AiScope & {
2257
+ id: string;
2258
+ reason?: string;
2259
+ }): Promise<AiFollowupPromise>;
2260
+ /** Concilia template com resultado incerto; nunca reenvia. */
2261
+ resolvePromise(input: AiScope & {
2262
+ id: string;
2263
+ outcome: "sent" | "rejected";
2264
+ note: string;
2265
+ wamid?: string;
2266
+ }): Promise<{
2267
+ ok: boolean;
2268
+ status?: string;
2269
+ code?: string;
2270
+ }>;
2271
+ }
2272
+ declare class AiRoutersResource {
2273
+ private readonly client;
2274
+ constructor(client: BotoZap);
2275
+ /** GET /ai/routers */
2276
+ list(input: AiScope): Promise<AiRouter[]>;
2277
+ /** GET /ai/routers/:id */
2278
+ get(input: AiScope & {
2279
+ id: string;
2280
+ }): Promise<AiRouter>;
2281
+ /** POST /ai/routers */
2282
+ create(input: AiScope & {
2283
+ config: AiRouterConfig;
2284
+ }): Promise<AiRouter>;
2285
+ /** Edição de roteador ativo aplica imediatamente e invalida classificações da revisão anterior. */
2286
+ update(input: AiRevision & {
2287
+ id: string;
2288
+ } & {
2289
+ config: AiRouterConfig;
2290
+ }): Promise<AiRouter>;
2291
+ /** Desativa e arquiva preservando histórico; não ativa outro responsável. */
2292
+ archive(input: AiRevision & {
2293
+ id: string;
2294
+ }): Promise<{
2295
+ archived: true;
2296
+ }>;
2297
+ /** Tomar canal exige confirmação explícita, replace_current e CAS expected_owner_agent_id; não substitui outro roteador. */
2298
+ operation(input: AiRevision & {
2299
+ id: string;
2300
+ } & {
2301
+ active: boolean;
2302
+ replace_current?: boolean;
2303
+ expected_owner_agent_id?: string | null;
2304
+ }): Promise<AiRouter>;
2305
+ /** Classifica com BYOK sem encaminhar nem enviar; preserve UUID da tentativa. */
2306
+ test(input: AiScope & {
2307
+ id: string;
2308
+ } & {
2309
+ text: string;
2310
+ request_key: string;
2311
+ sticky_agent_id?: string | null;
2312
+ sticky_intent?: string | null;
2313
+ }): Promise<AiRouterTest>;
2314
+ /** Ativa membro sem criar vínculo direto com canal. */
2315
+ activateMember(input: AiRevision & {
2316
+ id: string;
2317
+ } & {
2318
+ agent_id: string;
2319
+ mode: "automatic" | "assisted";
2320
+ }): Promise<AiRecord>;
2321
+ }
2322
+ declare class AiCasesResource {
2323
+ private readonly client;
2324
+ reply(input: AiCaseReplyInput): Promise<AiCaseReply>;
2325
+ consult(input: AiScope & {
2326
+ id: string;
2327
+ operation_key: string;
2328
+ question: string;
2329
+ }): Promise<AiCaseChat>;
2330
+ chatHistory(input: AiPage & {
2331
+ id: string;
2332
+ }): Promise<OffsetList<AiCaseChat>>;
2333
+ constructor(client: BotoZap);
2334
+ /** GET /ai/cases */
2335
+ list(input: AiPage & {
2336
+ status?: AiCase["status"];
2337
+ kind?: AiCaseKind;
2338
+ source?: AiCaseSource;
2339
+ }): Promise<OffsetList<AiCase>>;
2340
+ /** Linha do tempo tipada, da mais antiga para a mais recente. */
2341
+ events(input: AiPage & {
2342
+ id: string;
2343
+ }): Promise<OffsetList<AiCaseEvent>>;
2344
+ /** GET /ai/cases/:id */
2345
+ get(input: AiScope & {
2346
+ id: string;
2347
+ }): Promise<AiCase>;
2348
+ /** GET /ai/cases/:id/messages */
2349
+ messages(input: AiPage & {
2350
+ id: string;
2351
+ }): Promise<OffsetList<{
2352
+ id: string;
2353
+ author_user_id: string | null;
2354
+ author_agent_id: string | null;
2355
+ body: string;
2356
+ created_at: string;
2357
+ }>>;
2358
+ /** Atualiza caso; resume_agent pode retomar automação e exige intenção explícita. */
2359
+ update(input: AiScope & {
2360
+ id: string;
2361
+ } & {
2362
+ expected_revision: number;
2363
+ status?: AiCase["status"];
2364
+ assigned_user_id?: string | null;
2365
+ message?: string;
2366
+ resume_agent?: boolean;
2367
+ }): Promise<AiCase>;
2368
+ }
2369
+ declare class AiAlertsResource {
2370
+ private readonly client;
2371
+ constructor(client: BotoZap);
2372
+ /** GET /ai/alerts */
2373
+ list(input: AiPage & {
2374
+ status?: AiAlert["status"];
2375
+ kind?: string;
2376
+ severity?: AiAlert["severity"];
2377
+ }): Promise<OffsetList<AiAlertListItem>>;
2378
+ /** Resolve em lote apenas alertas criados até created_before (até 500 por chamada). */
2379
+ resolveBulk(input: AiScope & {
2380
+ created_before: string;
2381
+ filters?: AiAlertBulkFilters;
2382
+ }): Promise<{
2383
+ resolved_count: number;
2384
+ remaining: number;
2385
+ }>;
2386
+ /** PATCH /ai/alerts/:id */
2387
+ update(input: AiScope & {
2388
+ id: string;
2389
+ } & {
2390
+ expected_revision: number;
2391
+ status: AiAlert["status"];
2392
+ }): Promise<AiAlert>;
2393
+ }
2394
+ declare class AiNoticesResource {
2395
+ private readonly client;
2396
+ constructor(client: BotoZap);
2397
+ /** GET /ai/notices */
2398
+ get(input: AiScope): Promise<AiNoticeSettings>;
2399
+ /** PATCH /ai/notices */
2400
+ update(input: AiScope & Omit<AiNoticeSettings, "revision" | "consent_confirmed_at" | "updated_at"> & {
2401
+ consent_confirmed: boolean;
2402
+ expected_revision: number;
2403
+ }): Promise<AiNoticeSettings>;
2404
+ /** GET /ai/notices/options */
2405
+ options(input: AiScope): Promise<AiRecord>;
2406
+ /** GET /ai/notices/jobs */
2407
+ jobs(input: AiPage): Promise<OffsetList<AiNoticeJob>>;
2408
+ /** Envia template real ao destinatário autorizado. Exige confirmação explícita e confirm_send:true. */
2409
+ test(input: AiScope & {
2410
+ operation_key: string;
2411
+ confirm_send: true;
2412
+ }): Promise<{
2413
+ id: string;
2414
+ }>;
2415
+ /** Reenfileira apenas falha confirmada; unknown não admite retry. */
2416
+ retry(input: AiScope & {
2417
+ id: string;
2418
+ }): Promise<{
2419
+ queued: true;
2420
+ }>;
2421
+ /** Checagens de destino, canal, conexão e template; não envia mensagem. */
2422
+ diagnostics(input: AiScope): Promise<AiNoticeCheck[]>;
2423
+ /** Efeito dos avisos no tempo de resposta (days 1–90, padrão 30). */
2424
+ effect(input: AiScope & {
2425
+ days?: number;
2426
+ }): Promise<AiNoticeEffect>;
2427
+ }
2428
+ declare class AiProposalsResource {
2429
+ private readonly client;
2430
+ constructor(client: BotoZap);
2431
+ /** GET /ai/proposals */
2432
+ list(input: AiPage & {
2433
+ agent_id?: string;
2434
+ status?: AiProposal["status"];
2435
+ }): Promise<OffsetList<AiProposal>>;
2436
+ /** Aplicar playbook publica NOVA versão atomicamente; memória entra na base. Revise conteúdo e evidência, obtenha confirmação antes de aplicar. */
2437
+ decide(input: AiScope & {
2438
+ id: string;
2439
+ } & {
2440
+ expected_revision: number;
2441
+ decision: "apply" | "reject";
2442
+ reason?: string;
2443
+ }): Promise<AiProposal>;
2444
+ /** Analisa execuções via BYOK e gera propostas pendentes, sem aprovação automática. */
2445
+ analyze(input: AiScope & {
2446
+ agent_id: string;
2447
+ limit?: number;
2448
+ }): Promise<AiRecord>;
2449
+ /** GET /ai/proposals/settings */
2450
+ settings(input: AiScope): Promise<{
2451
+ enabled: boolean;
2452
+ revision: number;
2453
+ }>;
2454
+ /** PATCH /ai/proposals/settings */
2455
+ saveSettings(input: AiScope & {
2456
+ enabled: boolean;
2457
+ expected_revision: number;
2458
+ }): Promise<{
2459
+ enabled: boolean;
2460
+ revision: number;
2461
+ }>;
2462
+ }
2463
+ declare class AiUsageResource {
2464
+ private readonly client;
2465
+ constructor(client: BotoZap);
2466
+ /** Medições e estimativas de consumo BYOK, sem cobrança ou crédito BotoZap. */
2467
+ get(input: AiScope & {
2468
+ from?: string;
2469
+ to?: string;
2470
+ agent_id?: string;
2471
+ purpose?: AiPurpose;
2472
+ }): Promise<AiRecord>;
2473
+ /** GET /ai/usage/budget */
2474
+ budget(input: AiScope): Promise<AiBudget>;
2475
+ /** PATCH /ai/usage/budget */
2476
+ saveBudget(input: AiBudgetInput): Promise<AiBudget>;
2477
+ /** GET /ai/usage/rates */
2478
+ rates(input: AiScope): Promise<AiRate[]>;
2479
+ /** PUT /ai/usage/rates */
2480
+ saveRate(input: AiRateInput): Promise<AiRate>;
2481
+ /** Aplica tarifa própria a medições sem preço; não gera cobrança BotoZap. Exige confirmação. */
2482
+ reprice(input: AiScope & {
2483
+ provider: AiProvider;
2484
+ model: string;
2485
+ expected_revision: number;
2486
+ confirm: true;
2487
+ }): Promise<{
2488
+ updated: number;
2489
+ }>;
2490
+ }
2491
+ declare class AiUploadsResource {
2492
+ private readonly client;
2493
+ constructor(client: BotoZap);
2494
+ prepare(input: AiArtifactUploadInput): Promise<AiPreparedUpload>;
2495
+ complete(input: AiScope & {
2496
+ id: string;
2497
+ }): Promise<AiKnowledgeSource | AiSkill>;
2498
+ }
2499
+ declare class AiCommercialProposalsResource {
2500
+ private readonly client;
2501
+ constructor(client: BotoZap);
2502
+ /** Propostas de próxima ação; status decided reúne approved e dismissed. */
2503
+ list(input: AiPage & {
2504
+ status?: AiCommercialProposal["status"] | "decided";
2505
+ opportunity_id?: string;
2506
+ }): Promise<OffsetList<AiCommercialProposal>>;
2507
+ /** Enfileira geração BYOK; reuse request_key ao repetir. Não altera o CRM. */
2508
+ request(input: AiScope & {
2509
+ opportunity_id: string;
2510
+ request_key: string;
2511
+ }): Promise<AiCommercialRequest>;
2512
+ /** approve aplica o efeito no CRM; seq é o lock (409 proposal_changed). Repetição devolve replayed. */
2513
+ decide(input: AiScope & {
2514
+ id: string;
2515
+ decision: "approve" | "dismiss";
2516
+ seq: number;
2517
+ note?: string;
2518
+ apply_effect?: boolean;
2519
+ }): Promise<AiCommercialDecision>;
2520
+ /** Últimas 50 gerações. */
2521
+ jobs(input: AiScope): Promise<AiCommercialJob[]>;
2522
+ settings(input: AiScope): Promise<AiCommercialSettings>;
2523
+ saveSettings(input: AiScope & {
2524
+ enabled: boolean;
2525
+ expected_revision: number;
2526
+ }): Promise<AiCommercialSettings & {
2527
+ updated_at: string;
2528
+ }>;
2529
+ }
2530
+ declare class AiEligibilityResource {
2531
+ private readonly client;
2532
+ constructor(client: BotoZap);
2533
+ /** Configurações e gate de cada canal. */
2534
+ get(input: AiScope): Promise<AiEligibilityOverview>;
2535
+ /** assignment_blocks_ai omitido preserva; false reduz a proteção. */
2536
+ saveSettings(input: AiRevision & {
2537
+ authorization_ttl_days: number;
2538
+ authorize_broadcast_replies: boolean;
2539
+ authorize_automation_replies: boolean;
2540
+ assignment_blocks_ai?: boolean;
2541
+ }): Promise<AiEligibilitySettings>;
2542
+ channel(input: AiScope & {
2543
+ id: string;
2544
+ }): Promise<AiChannelGate>;
2545
+ /** Substitui modo e lista inteira (CAS). Abrir para todos exige confirm_open_to_all: true após confirmação do usuário. */
2546
+ saveChannel(input: AiRevision & {
2547
+ id: string;
2548
+ mode: AiGateMode;
2549
+ test_phone_numbers: string[];
2550
+ confirm_open_to_all?: boolean;
2551
+ }): Promise<AiChannelGate>;
2552
+ authorizations(input: AiScope & {
2553
+ channel_account_id?: string;
2554
+ status?: "active" | "all";
2555
+ limit?: number;
2556
+ }): Promise<AiContactAuthorization[]>;
2557
+ /** Revoga já; resposta ainda não admitida para envio não sai. */
2558
+ revokeAuthorization(input: AiScope & {
2559
+ id: string;
2560
+ }): Promise<void>;
2561
+ }
2562
+ declare class AiInferencesResource {
2563
+ private readonly client;
2564
+ constructor(client: BotoZap);
2565
+ /** Chamadas de modelo do ledger BYOK; meta.summary agrega falhas e pontos do período. */
2566
+ list(input: AiPage & {
2567
+ from?: string;
2568
+ to?: string;
2569
+ purpose?: AiPurpose;
2570
+ point?: string;
2571
+ outcome?: AiInferenceOutcome;
2572
+ agent_id?: string;
2573
+ }): Promise<{
2574
+ data: AiInference[];
2575
+ meta: OffsetMeta & {
2576
+ summary: AiInferenceSummary;
2577
+ };
2578
+ }>;
2579
+ }
2580
+ declare class AiOperatorResource {
2581
+ private readonly client;
2582
+ constructor(client: BotoZap);
2583
+ /** Promessas por agente (days 1–90, padrão 30). */
2584
+ metrics(input: AiScope & {
2585
+ agent_id?: string;
2586
+ days?: number;
2587
+ }): Promise<AiOperatorMetrics>;
2588
+ /** Somente leitura; correções são feitas por uma pessoa no painel. */
2589
+ promises(input: AiScope & {
2590
+ agent_id?: string;
2591
+ status?: AiTurnPromise["status"];
2592
+ limit?: number;
2593
+ }): Promise<AiTurnPromise[]>;
2594
+ }
2595
+ declare class AiEvolutionResource {
2596
+ private readonly client;
2597
+ constructor(client: BotoZap);
2598
+ /** Cada fonte volta com status próprio; falha nunca vira zero. */
2599
+ get(input: AiScope & {
2600
+ days?: 7 | 30 | 90;
2601
+ agent_id?: string;
2602
+ }): Promise<AiEvolution>;
2603
+ }
2604
+ declare class AiStyleAdjustmentsResource {
2605
+ private readonly client;
2606
+ constructor(client: BotoZap);
2607
+ list(input: AiScope): Promise<{
2608
+ adjustments: AiStyleAdjustment[];
2609
+ }>;
2610
+ /** CAS por item: expected_revision é a revisão lida ("0" quando nunca salvo). */
2611
+ save(input: AiRevision & {
2612
+ adjustment: AiStyleAdjustmentId;
2613
+ enabled: boolean;
2614
+ }): Promise<AiStyleAdjustment>;
2615
+ }
2616
+ declare class Ai {
2617
+ private readonly client;
2618
+ readonly uploads: AiUploadsResource;
2619
+ readonly agents: AiAgentsResource;
2620
+ readonly credentials: AiCredentialsResource;
2621
+ readonly providers: AiProvidersResource;
2622
+ readonly executions: AiExecutionsResource;
2623
+ readonly knowledge: AiKnowledgeResource;
2624
+ readonly memory: AiMemoryResource;
2625
+ readonly skills: AiSkillsResource;
2626
+ readonly followupFlows: AiFollowupFlowsResource;
2627
+ readonly followups: AiFollowupsResource;
2628
+ readonly routers: AiRoutersResource;
2629
+ readonly cases: AiCasesResource;
2630
+ readonly alerts: AiAlertsResource;
2631
+ readonly notices: AiNoticesResource;
2632
+ readonly proposals: AiProposalsResource;
2633
+ readonly usage: AiUsageResource;
2634
+ readonly commercialProposals: AiCommercialProposalsResource;
2635
+ readonly eligibility: AiEligibilityResource;
2636
+ readonly inferences: AiInferencesResource;
2637
+ readonly operator: AiOperatorResource;
2638
+ readonly evolution: AiEvolutionResource;
2639
+ readonly styleAdjustments: AiStyleAdjustmentsResource;
2640
+ constructor(client: BotoZap);
2641
+ /** Executes only a declared operation. Prefer typed module methods in application code. */
2642
+ invoke(group: string, name: string, input: Record<string, unknown>): Promise<unknown>;
2643
+ }
2644
+
2645
+ type AppointmentStatus = "pending" | "confirmed" | "cancelled" | "completed" | "no_show";
2646
+ interface AppointmentFields {
2647
+ title?: string;
2648
+ scheduled_at: string;
2649
+ ends_at?: string;
2650
+ time_zone?: string;
2651
+ note?: string | null;
2652
+ service_id?: string | null;
2653
+ owner_user_id?: string | null;
2654
+ status?: AppointmentStatus;
2655
+ conversation_id?: string | null;
2656
+ opportunity_id?: string | null;
2657
+ demand_id?: string | null;
2658
+ cancellation_reason?: string | null;
2659
+ location?: string | null;
2660
+ meeting_requested?: boolean;
2661
+ }
2662
+ type CreateAppointment = AppointmentFields & {
2663
+ contact_id: string;
2664
+ };
2665
+ type UpdateAppointment = Partial<AppointmentFields> & {
2666
+ expected_revision?: number;
2667
+ };
2668
+ interface Appointment extends Required<AppointmentFields> {
2669
+ id: string;
2670
+ account_id: string;
2671
+ customer_id: string;
2672
+ contact_id: string;
2673
+ revision: number;
2674
+ meeting_url: string | null;
2675
+ google_sync_error: string | null;
2676
+ google_conflict: Record<string, unknown> | null;
2677
+ google_event_id: string | null;
2678
+ google_selection_id: string | null;
2679
+ google_etag: string | null;
2680
+ google_base_data: Record<string, unknown> | null;
2681
+ google_synced_revision: number | null;
2682
+ buffer_before_minutes: number;
2683
+ buffer_after_minutes: number;
2684
+ created_at: string;
2685
+ updated_at: string;
2686
+ }
2687
+ interface AppointmentQuery extends OffsetParams {
2688
+ customer_id?: string;
2689
+ contact_id?: string;
2690
+ owner_user_id?: string | "unassigned";
2691
+ service_id?: string;
2692
+ status?: AppointmentStatus;
2693
+ date?: string;
2694
+ from?: string;
2695
+ to?: string;
2696
+ }
2697
+ interface AppointmentServiceInput {
2698
+ customer_id: string;
2699
+ name: string;
2700
+ description?: string | null;
2701
+ duration_minutes: number;
2702
+ slot_minutes: number;
2703
+ buffer_before_minutes: number;
2704
+ buffer_after_minutes: number;
2705
+ minimum_notice_minutes: number;
2706
+ booking_horizon_days: number;
2707
+ active: boolean;
2708
+ }
2709
+ interface AppointmentScheduleInput {
2710
+ customer_id: string;
2711
+ owner_user_id: string;
2712
+ time_zone: string;
2713
+ windows: Array<{
2714
+ dow: number;
2715
+ start: string;
2716
+ end: string;
2717
+ }>;
2718
+ }
2719
+ interface AppointmentExceptionInput {
2720
+ customer_id: string;
2721
+ owner_user_id: string;
2722
+ local_date: string;
2723
+ start_minute: number;
2724
+ end_minute: number;
2725
+ kind: "available" | "busy";
2726
+ reason?: string | null;
2727
+ }
2728
+ type AgendaRecord<T> = T & {
2729
+ id: string;
2730
+ account_id: string;
2731
+ revision: number;
2732
+ };
2733
+ declare class AgendaConfiguration<T> {
2734
+ protected readonly client: BotoZap;
2735
+ private readonly kind;
2736
+ constructor(client: BotoZap, kind: "services" | "schedules" | "exceptions");
2737
+ list(params: {
2738
+ customer_id: string;
2739
+ page?: number;
2740
+ }): Promise<OffsetList<AgendaRecord<T>>>;
2741
+ create(input: T): Promise<AgendaRecord<T>>;
2742
+ /** Changes merge into the stored configuration and require its current revision. */
2743
+ update(id: string, input: Partial<T> & {
2744
+ expected_revision: number;
2745
+ }): Promise<AgendaRecord<T>>;
2746
+ }
2747
+ declare class AgendaExceptions extends AgendaConfiguration<AppointmentExceptionInput> {
2748
+ constructor(client: BotoZap);
2749
+ delete(id: string, expectedRevision: number): Promise<void>;
2750
+ }
2751
+ interface AvailabilityQuery {
2752
+ customer_id: string;
2753
+ owner_user_id: string;
2754
+ service_id: string;
2755
+ from: string;
2756
+ to: string;
2757
+ exclude_id?: string;
2758
+ }
2759
+ interface AppointmentAvailability {
2760
+ time_zone: string;
2761
+ slots: Array<{
2762
+ starts_at: string;
2763
+ ends_at: string;
2764
+ }>;
2765
+ schedule_published: boolean;
2766
+ }
2767
+ interface AppointmentHistory {
2768
+ id: string;
2769
+ appointment_id: string;
2770
+ event_type: string;
2771
+ created_at: string;
2772
+ [key: string]: unknown;
2773
+ }
2774
+ declare class Appointments {
2775
+ private readonly client;
2776
+ readonly services: AgendaConfiguration<AppointmentServiceInput>;
2777
+ readonly schedules: AgendaConfiguration<AppointmentScheduleInput>;
2778
+ readonly exceptions: AgendaExceptions;
2779
+ constructor(client: BotoZap);
2780
+ list(params?: AppointmentQuery): Promise<OffsetList<Appointment>>;
2781
+ get(id: string): Promise<Appointment>;
2782
+ create(input: CreateAppointment, options?: {
2783
+ idempotencyKey?: string;
2784
+ }): Promise<Appointment>;
2785
+ update(id: string, input: UpdateAppointment): Promise<Appointment>;
2786
+ delete(id: string): Promise<void>;
2787
+ history(id: string, params?: {
2788
+ page?: number;
2789
+ }): Promise<OffsetList<AppointmentHistory>>;
2790
+ availability(params: AvailabilityQuery): Promise<AppointmentAvailability>;
2791
+ }
2792
+
2793
+ interface CalendarConnection {
2794
+ id: string;
2795
+ owner_user_id: string;
2796
+ label: string;
2797
+ status: string;
2798
+ last_error: string | null;
2799
+ last_synced_at: string | null;
2800
+ created_at: string;
2801
+ }
2802
+ interface CalendarSelection {
2803
+ id: string;
2804
+ connection_id: string;
2805
+ external_calendar_id: string;
2806
+ summary: string;
2807
+ time_zone: string;
2808
+ access_role: string;
2809
+ destination: boolean;
2810
+ include_busy: boolean;
2811
+ conference_supported: boolean;
2812
+ synced_at: string | null;
2813
+ revision: number;
2814
+ }
2815
+ interface CalendarJob {
2816
+ id: string;
2817
+ connection_id: string;
2818
+ selection_id: string | null;
2819
+ appointment_id: string | null;
2820
+ kind: string;
2821
+ status: string;
2822
+ attempts: number;
2823
+ last_error: string | null;
2824
+ available_at: string;
2825
+ updated_at: string;
2826
+ }
2827
+ /** OAuth authorization is performed by a signed-in person in /calendarios, never impersonated by an account API key. */
2828
+ declare class Calendar {
2829
+ private readonly client;
2830
+ constructor(client: BotoZap);
2831
+ connections(params?: OffsetParams): Promise<OffsetList<CalendarConnection>>;
2832
+ disconnect(id: string): Promise<void>;
2833
+ calendars(connectionId: string): Promise<CalendarSelection[]>;
2834
+ refresh(connectionId: string): Promise<CalendarSelection[]>;
2835
+ select(id: string, input: {
2836
+ destination: boolean;
2837
+ include_busy: boolean;
2838
+ expected_revision: number;
2839
+ }): Promise<{
2840
+ updated: true;
2841
+ }>;
2842
+ jobs(params?: OffsetParams & {
2843
+ connection_id?: string;
2844
+ }): Promise<OffsetList<CalendarJob>>;
2845
+ retryJob(id: string): Promise<{
2846
+ queued: true;
2847
+ }>;
2848
+ resolveConflict(appointmentId: string, input: {
2849
+ expected_revision: number;
2850
+ choice: "local" | "remote";
2851
+ }): Promise<Appointment>;
2852
+ }
2853
+
2854
+ type StageColor = "zinc" | "green" | "amber" | "pink";
2855
+ interface ContactStage {
2856
+ id: string;
2857
+ key: string;
2858
+ label: string;
2859
+ color: StageColor;
2860
+ position: number;
2861
+ }
2862
+ interface ContactField {
2863
+ id: string;
2864
+ key: string;
2865
+ label: string;
2866
+ type: "text" | "number" | "boolean" | "date";
2867
+ position: number;
2868
+ created_at: string;
2869
+ }
2870
+ declare class ContactStages {
2871
+ private readonly client;
2872
+ constructor(client: BotoZap);
2873
+ list(params?: {
2874
+ customer_id?: string;
2875
+ }): Promise<ContactStage[]>;
2876
+ create(input: {
2877
+ customer_id?: string;
2878
+ label: string;
2879
+ color: StageColor;
2880
+ }): Promise<ContactStage>;
2881
+ update(id: string, input: {
2882
+ customer_id?: string;
2883
+ label?: string;
2884
+ color?: StageColor;
2885
+ position?: number;
2886
+ }): Promise<ContactStage>;
2887
+ delete(id: string, params?: {
2888
+ customer_id?: string;
2889
+ }): Promise<void>;
2890
+ reorder(input: {
2891
+ customer_id?: string;
2892
+ stage_ids: string[];
2893
+ }): Promise<ContactStage[]>;
2894
+ }
2895
+ declare class ContactFields {
2896
+ private readonly client;
2897
+ constructor(client: BotoZap);
2898
+ list(): Promise<ContactField[]>;
2899
+ create(input: {
2900
+ label: string;
2901
+ type?: ContactField["type"];
2902
+ key?: string;
2903
+ }): Promise<ContactField>;
2904
+ update(id: string, input: {
2905
+ label?: string;
2906
+ position?: number;
2907
+ }): Promise<ContactField>;
2908
+ delete(id: string): Promise<void>;
2909
+ }
2910
+
2911
+ interface JourneyStep {
2912
+ template_id: string;
2913
+ delay_minutes: number;
2914
+ variable_map?: Record<string, string>;
2915
+ }
2916
+ interface JourneyConfig {
2917
+ customer_id: string;
2918
+ name: string;
2919
+ status?: "active" | "paused";
2920
+ target_kind?: "contact" | "opportunity" | "demand";
2921
+ trigger_kind?: "contact_date" | "stage_entered" | "appointment" | "demand_status";
2922
+ date_field_key?: string | null;
2923
+ stage_id?: string | null;
2924
+ demand_status?: "open" | "in_progress" | "waiting_customer" | null;
2925
+ offset_days?: number;
2926
+ offset_hours?: number;
2927
+ yearly?: boolean;
2928
+ stop_on_reply?: boolean;
2929
+ stop_on_exit?: boolean;
2930
+ send_start_hour?: number;
2931
+ send_end_hour?: number;
2932
+ steps: JourneyStep[];
2933
+ }
2934
+ interface Journey extends Required<Omit<JourneyConfig, "steps">> {
2935
+ id: string;
2936
+ version: number;
2937
+ archived_at: string | null;
2938
+ pause_reason: string | null;
2939
+ environment: "live" | "sandbox";
2940
+ catalog_key?: string | null;
2941
+ created_at?: string;
2942
+ steps?: JourneyStep[];
2943
+ }
2944
+ interface JourneyRun {
2945
+ id: string;
2946
+ contact_id: string;
2947
+ occurrence_key: string;
2948
+ status: string;
2949
+ stop_reason: string | null;
2950
+ opportunity_id: string | null;
2951
+ demand_id: string | null;
2952
+ finished_at: string | null;
2953
+ created_at: string;
2954
+ steps?: Array<{
2955
+ id: string;
2956
+ position: number;
2957
+ due_at: string;
2958
+ status: string;
2959
+ error: string | null;
2960
+ skip_reason: string | null;
2961
+ external_id: string | null;
2962
+ message_id: string | null;
2963
+ delivered_at: string | null;
2964
+ read_at: string | null;
2965
+ snapshot: unknown;
2966
+ }>;
2967
+ [key: string]: unknown;
2968
+ }
2969
+ interface JourneyEnrollment {
2970
+ contact_id: string;
2971
+ occurrence_key: string;
2972
+ due_at?: string;
2973
+ opportunity_id?: string | null;
2974
+ demand_id?: string | null;
2975
+ appointment_id?: string | null;
2976
+ }
2977
+ interface JourneyQuery extends Pick<CursorParams, "limit" | "after"> {
2978
+ customer_id?: string;
2979
+ }
2980
+ declare class Journeys {
2981
+ private readonly client;
2982
+ constructor(client: BotoZap);
2983
+ list(params?: JourneyQuery): Promise<CursorList<Journey>>;
2984
+ get(id: string, params?: {
2985
+ customer_id?: string;
2986
+ }): Promise<Journey>;
2987
+ create(input: JourneyConfig): Promise<Journey>;
2988
+ update(id: string, input: JourneyConfig & {
2989
+ version: number;
2990
+ }): Promise<Journey>;
2991
+ /** Archives using CAS; this endpoint returns a record, not HTTP 204. */
2992
+ delete(id: string, version: number): Promise<Journey>;
2993
+ control(id: string, input: {
2994
+ action: "pause" | "resume" | "archive";
2995
+ version: number;
2996
+ }): Promise<Journey>;
2997
+ runs(id: string, params?: JourneyQuery): Promise<CursorList<JourneyRun>>;
2998
+ enroll(id: string, input: JourneyEnrollment): Promise<{
2999
+ id: string;
3000
+ }>;
3001
+ getRun(id: string): Promise<JourneyRun>;
3002
+ controlRun(id: string, input: {
3003
+ action: "stop";
3004
+ } | {
3005
+ action: "acknowledge";
3006
+ note: string;
3007
+ }): Promise<JourneyRun>;
3008
+ }
3009
+
3010
+ /** Only shared replies are exposed to account API keys. Personal replies stay in the authenticated dashboard. */
3011
+ interface SavedReply {
3012
+ id: string;
3013
+ customer_id: string | null;
3014
+ owner_user_id: null;
3015
+ title: string;
3016
+ body: string;
3017
+ shortcut: string | null;
3018
+ created_at: string;
3019
+ updated_at: string;
3020
+ }
3021
+ interface SavedReplyInput {
3022
+ title: string;
3023
+ body: string;
3024
+ shortcut?: string | null;
3025
+ customer_id?: string | null;
3026
+ }
3027
+ interface SavedReplyQuery extends OffsetParams {
3028
+ query?: string;
3029
+ customer_id?: string | "account";
3030
+ include_account?: boolean;
3031
+ }
3032
+ declare class SavedReplies {
3033
+ private readonly client;
3034
+ constructor(client: BotoZap);
3035
+ list(params?: SavedReplyQuery): Promise<OffsetList<SavedReply>>;
3036
+ get(id: string): Promise<SavedReply>;
3037
+ create(input: SavedReplyInput): Promise<SavedReply>;
3038
+ update(id: string, input: Partial<SavedReplyInput> & {
3039
+ expected_updated_at: string;
3040
+ }): Promise<SavedReply>;
3041
+ delete(id: string, input: {
3042
+ expected_updated_at: string;
3043
+ }): Promise<void>;
3044
+ }
3045
+
3046
+ interface ConversationNote {
3047
+ id: string;
3048
+ conversation_id: string;
3049
+ author_user_id: string | null;
3050
+ author_api_key_id: string | null;
3051
+ body: string;
3052
+ version: number;
3053
+ created_at: string;
3054
+ updated_at: string;
3055
+ deleted_at: string | null;
3056
+ }
3057
+ interface ConversationReminder {
3058
+ id: string;
3059
+ conversation_id: string;
3060
+ assigned_user_id: string | null;
3061
+ body: string;
3062
+ due_at: string;
3063
+ status: "pending" | "done" | "cancelled";
3064
+ completed_at: string | null;
3065
+ version: number;
3066
+ created_at: string;
3067
+ updated_at: string;
3068
+ }
3069
+ interface InboxState {
3070
+ id: string;
3071
+ archived_at: string | null;
3072
+ snoozed_until: string | null;
3073
+ operator_version: number;
3074
+ }
3075
+ interface InboxTools {
3076
+ state: InboxState;
3077
+ notes: ConversationNote[];
3078
+ reminders: ConversationReminder[];
3079
+ page: number;
3080
+ per_page: number;
3081
+ notes_total: number;
3082
+ reminders_total: number;
3083
+ }
3084
+ type InboxMutation = {
3085
+ operation: "archive" | "unarchive" | "unsnooze";
3086
+ expected_version: number;
3087
+ } | {
3088
+ operation: "snooze";
3089
+ expected_version: number;
3090
+ until: string;
3091
+ } | {
3092
+ operation: "note_create";
3093
+ body: string;
3094
+ } | {
3095
+ operation: "note_update";
3096
+ id: string;
3097
+ body: string;
3098
+ expected_version: number;
3099
+ } | {
3100
+ operation: "note_delete";
3101
+ id: string;
3102
+ expected_version: number;
3103
+ } | {
3104
+ operation: "reminder_create";
3105
+ body: string;
3106
+ due_at: string;
3107
+ assigned_user_id?: string | null;
3108
+ } | {
3109
+ operation: "reminder_update";
3110
+ id: string;
3111
+ expected_version: number;
3112
+ body?: string;
3113
+ due_at?: string;
3114
+ assigned_user_id?: string | null;
3115
+ status?: "pending" | "done" | "cancelled";
3116
+ };
3117
+ type InboxMutationResult = Omit<InboxState, "id"> | ConversationNote | ConversationReminder;
3118
+ /** Notes, reminders and operator state. Drafts are deliberately session-only. */
3119
+ declare class Inbox {
3120
+ private readonly client;
3121
+ constructor(client: BotoZap);
3122
+ get(conversationId: string, params?: OffsetParams): Promise<InboxTools>;
3123
+ mutate(conversationId: string, input: InboxMutation): Promise<InboxMutationResult>;
3124
+ }
3125
+
3126
+ type CrmMetadata = Record<string, string | number | boolean | null>;
3127
+ interface CrmFields {
3128
+ title: string;
3129
+ owner_user_id?: string | null;
3130
+ next_step?: string | null;
3131
+ next_step_at?: string | null;
3132
+ notes?: string | null;
3133
+ metadata?: CrmMetadata;
3134
+ }
3135
+ interface OpportunityFields extends CrmFields {
3136
+ stage_id?: string | null;
3137
+ status?: "open" | "won" | "lost";
3138
+ value_cents?: number;
3139
+ currency?: string;
3140
+ outcome_reason?: string | null;
3141
+ }
3142
+ interface DemandFields extends CrmFields {
3143
+ opportunity_id?: string | null;
3144
+ status?: "open" | "in_progress" | "waiting_customer" | "resolved" | "closed";
3145
+ due_at?: string | null;
3146
+ outcome?: "resolved" | "converted" | "not_applicable" | "customer_cancelled" | "lost" | "no_response" | null;
3147
+ }
3148
+ type CreateOpportunity = OpportunityFields & {
3149
+ customer_id: string;
3150
+ contact_id: string;
3151
+ };
3152
+ type CreateDemand = DemandFields & {
3153
+ customer_id: string;
3154
+ contact_id: string;
3155
+ };
3156
+ type CrmRecord<F> = Required<F> & {
3157
+ id: string;
3158
+ account_id: string;
3159
+ customer_id: string;
3160
+ contact_id: string;
3161
+ version: number;
3162
+ closed_at: string | null;
3163
+ created_at: string;
3164
+ updated_at: string;
3165
+ last_activity_at: string;
3166
+ };
3167
+ type Opportunity = CrmRecord<OpportunityFields> & {
3168
+ stage_entered_at: string;
3169
+ };
3170
+ type Demand = CrmRecord<DemandFields>;
3171
+ interface CrmQuery extends OffsetParams {
3172
+ customer_id: string;
3173
+ contact_id?: string;
3174
+ owner_user_id?: string | "unassigned";
3175
+ stage_id?: string | "none";
3176
+ status?: string;
3177
+ q?: string;
3178
+ }
3179
+ interface CrmActivity {
3180
+ id: string;
3181
+ event_type: string;
3182
+ actor_user_id: string | null;
3183
+ before_data: Record<string, unknown> | null;
3184
+ after_data: Record<string, unknown>;
3185
+ created_at: string;
3186
+ }
3187
+ interface CrmConversation {
3188
+ conversation_id: string;
3189
+ [key: string]: unknown;
3190
+ }
3191
+ declare class CrmResource<F extends CrmFields, R> {
3192
+ private readonly client;
3193
+ private readonly path;
3194
+ constructor(client: BotoZap, path: "/opportunities" | "/demands");
3195
+ list(params: CrmQuery): Promise<OffsetList<R>>;
3196
+ get(id: string): Promise<R>;
3197
+ create(input: F & {
3198
+ customer_id: string;
3199
+ contact_id: string;
3200
+ }): Promise<R>;
3201
+ update(id: string, input: Partial<F> & {
3202
+ expected_version: number;
3203
+ }): Promise<R>;
3204
+ activities(id: string, params?: Pick<OffsetParams, "page">): Promise<OffsetList<CrmActivity>>;
3205
+ conversations(id: string, params?: Pick<OffsetParams, "page">): Promise<OffsetList<CrmConversation>>;
3206
+ linkConversation(id: string, conversationId: string): Promise<{
3207
+ conversation_id: string;
3208
+ linked: boolean;
3209
+ }>;
3210
+ unlinkConversation(id: string, conversationId: string): Promise<{
3211
+ conversation_id: string;
3212
+ linked: boolean;
3213
+ }>;
3214
+ }
3215
+ interface RadarEntry {
3216
+ id: string;
3217
+ entity_type: "opportunity" | "demand" | "return" | "appointment";
3218
+ title: string;
3219
+ customer_id: string;
3220
+ contact_id: string;
3221
+ conversation_id: string | null;
3222
+ owner_user_id: string | null;
3223
+ stage_id: string | null;
3224
+ next_step: string | null;
3225
+ next_step_at: string | null;
3226
+ last_activity_at: string | null;
3227
+ bucket: "critical" | "at_risk" | "scheduled";
3228
+ reasons: string[];
3229
+ automation_due_at: string | null;
3230
+ automation_error: string | null;
3231
+ automation_run_id: string | null;
3232
+ automation_status: string | null;
3233
+ }
3234
+ interface StageRuleInput {
3235
+ customer_id: string;
3236
+ expected_version: number;
3237
+ cold_hours: number;
3238
+ critical_hours: number;
3239
+ require_owner: boolean;
3240
+ require_next_step: boolean;
3241
+ }
3242
+ interface StageRule extends Omit<StageRuleInput, "expected_version"> {
3243
+ account_id: string;
3244
+ stage_id: string;
3245
+ version: number;
3246
+ updated_at: string;
3247
+ }
3248
+ interface RadarQuery extends OffsetParams {
3249
+ customer_id: string;
3250
+ bucket?: RadarEntry["bucket"];
3251
+ entity_type?: RadarEntry["entity_type"];
3252
+ owner_user_id?: string | "unassigned";
3253
+ reason?: "unassigned" | "missing_next_step" | "overdue" | "stalled_stage" | "inactive" | "automation_failed" | "automation_overdue" | "automation_paused" | "automation_stopped" | "confirmation_pending" | "appointment_outcome_missing" | "calendar_conflict" | "calendar_sync_failed";
3254
+ }
3255
+ type RadarPage = OffsetList<RadarEntry> & {
3256
+ meta: {
3257
+ counts: Record<RadarEntry["bucket"], number>;
3258
+ };
3259
+ };
3260
+ declare class Radar {
3261
+ private readonly client;
3262
+ constructor(client: BotoZap);
3263
+ list(params: RadarQuery): Promise<RadarPage>;
3264
+ stageRules(customerId: string): Promise<StageRule[]>;
3265
+ configureStageRule(stageId: string, input: StageRuleInput): Promise<StageRule>;
3266
+ }
3267
+
230
3268
  /** Filtros de `messages.list` (paginação por cursor). Ver GET /v1/messages. */
231
3269
  interface ListMessagesParams extends CursorParams {
232
3270
  /** id da Meta OU uuid interno do número. */
@@ -484,6 +3522,24 @@ interface CreateContactParams {
484
3522
  /** wa_id canônico (BSUID "BR.1A2B…" ou dígitos E.164). */
485
3523
  wa_id: string;
486
3524
  phone_number_id?: string;
3525
+ /** Até 20 tags de 1–40 caracteres; o servidor apara e remove repetidas sem diferenciar maiúsculas. Não combine com metadata.tags. */
3526
+ tags?: string[];
3527
+ [key: string]: unknown;
3528
+ }
3529
+ /**
3530
+ * Campos do PATCH. `tags` substitui a lista inteira; `add_tags`/`remove_tags`
3531
+ * alteram a lista atual sem perder escrita concorrente. Não combine `tags` com
3532
+ * `add_tags`/`remove_tags`, nem com `metadata.tags` (422 invalid_tags).
3533
+ */
3534
+ interface UpdateContactParams {
3535
+ profile_name?: string;
3536
+ username?: string;
3537
+ notes?: string | null;
3538
+ stage_id?: string | null;
3539
+ metadata?: Record<string, unknown>;
3540
+ tags?: string[];
3541
+ add_tags?: string[];
3542
+ remove_tags?: string[];
487
3543
  [key: string]: unknown;
488
3544
  }
489
3545
  /** Contatos: listar, buscar, criar, atualizar, remover. */
@@ -494,7 +3550,7 @@ declare class Contacts {
494
3550
  list(params?: ListContactsParams): Promise<CursorList<Contact>>;
495
3551
  get(id: string): Promise<Contact>;
496
3552
  create(params: CreateContactParams): Promise<Contact>;
497
- update(id: string, params: Record<string, unknown>): Promise<Contact>;
3553
+ update(id: string, params: UpdateContactParams | Record<string, unknown>): Promise<Contact>;
498
3554
  /** Remove um contato. Responde 204 (sem corpo). */
499
3555
  delete(id: string): Promise<void>;
500
3556
  }
@@ -525,6 +3581,11 @@ interface ReplyConversationParams {
525
3581
  declare class Conversations {
526
3582
  private readonly client;
527
3583
  constructor(client: BotoZap);
3584
+ /** Pausa/retoma o agente nesta conversa. agents:write; retomar pode gerar respostas. */
3585
+ controlAgent(id: string, action: "pause" | "resume"): Promise<{
3586
+ conversation_id: string;
3587
+ paused: boolean;
3588
+ }>;
528
3589
  /** Lista as conversas da conta (paginação por cursor). */
529
3590
  list(params?: ListConversationsParams): Promise<CursorList<Conversation>>;
530
3591
  get(id: string): Promise<Conversation>;
@@ -542,11 +3603,29 @@ declare class Conversations {
542
3603
  updateAssignment(id: string, assignmentId: string, params: Record<string, unknown>): Promise<Assignment>;
543
3604
  }
544
3605
 
3606
+ /** Header extra aceito no endpoint. Só `Authorization`; o valor nunca volta na resposta. */
3607
+ interface WebhookAuthorizationHeaders {
3608
+ Authorization: string;
3609
+ }
545
3610
  interface CreateWebhookParams {
546
3611
  url: string;
547
3612
  events?: string[];
548
3613
  active?: boolean;
549
- [key: string]: unknown;
3614
+ secret?: string;
3615
+ /** `{ Authorization: "Bearer …" }` — persistido no Vault; ausente na resposta. */
3616
+ headers?: WebhookAuthorizationHeaders;
3617
+ }
3618
+ interface UpdateWebhookParams {
3619
+ url?: string;
3620
+ events?: string[];
3621
+ active?: boolean;
3622
+ /**
3623
+ * Omitido = não mexe. `{ Authorization: string }` cria/substitui.
3624
+ * `{ Authorization: null }` remove o header.
3625
+ */
3626
+ headers?: {
3627
+ Authorization?: string | null;
3628
+ };
550
3629
  }
551
3630
  /** Webhooks: endpoints assinados que recebem os eventos da conta. */
552
3631
  declare class Webhooks {
@@ -556,7 +3635,7 @@ declare class Webhooks {
556
3635
  list(params?: CursorParams): Promise<CursorList<Webhook>>;
557
3636
  get(id: string): Promise<Webhook>;
558
3637
  create(params: CreateWebhookParams): Promise<Webhook>;
559
- update(id: string, params: Record<string, unknown>): Promise<Webhook>;
3638
+ update(id: string, params: UpdateWebhookParams): Promise<Webhook>;
560
3639
  /** Remove um endpoint. Responde 204 (sem corpo). */
561
3640
  delete(id: string): Promise<void>;
562
3641
  /** Dispara um evento de teste para o endpoint. */
@@ -750,6 +3829,8 @@ interface BotoZapOptions {
750
3829
  fetch?: typeof fetch;
751
3830
  }
752
3831
  interface RequestOptions {
3832
+ /** Chave estável da operação para endpoints que suportam idempotência. */
3833
+ idempotencyKey?: string;
753
3834
  query?: Record<string, string | number | undefined>;
754
3835
  body?: unknown;
755
3836
  /** Cancela o I/O HTTP sem alterar o envelope de erro do SDK. */
@@ -772,6 +3853,17 @@ declare class BotoZap {
772
3853
  readonly conversations: Conversations;
773
3854
  readonly webhooks: Webhooks;
774
3855
  readonly phoneNumbers: PhoneNumbers;
3856
+ readonly contactStages: ContactStages;
3857
+ readonly contactFields: ContactFields;
3858
+ readonly calendar: Calendar;
3859
+ readonly ai: Ai;
3860
+ readonly appointments: Appointments;
3861
+ readonly journeys: Journeys;
3862
+ readonly savedReplies: SavedReplies;
3863
+ readonly inbox: Inbox;
3864
+ readonly opportunities: CrmResource<OpportunityFields, Opportunity>;
3865
+ readonly demands: CrmResource<DemandFields, Demand>;
3866
+ readonly radar: Radar;
775
3867
  readonly flows: Flows;
776
3868
  readonly media: Media;
777
3869
  readonly events: Events;
@@ -782,6 +3874,8 @@ declare class BotoZap {
782
3874
  private readonly baseUrl;
783
3875
  private readonly fetchImpl;
784
3876
  constructor(options: BotoZapOptions);
3877
+ /** PUT de artefato em URL assinada, sem token BotoZap nem cookies. Não segue redirecionamentos. */
3878
+ putArtifact(url: string, contentType: string, file: Blob): Promise<void>;
785
3879
  /** Faz uma requisição autenticada e devolve o corpo já parseado. */
786
3880
  request<T>(method: string, path: string, opts?: RequestOptions): Promise<T>;
787
3881
  /**
@@ -816,4 +3910,4 @@ declare class BotoZapError extends Error {
816
3910
  constructor(code: string, message: string, status: number, headers?: Record<string, string>);
817
3911
  }
818
3912
 
819
- export { type AddRecipientsResult, type ApiLog, type Assignment, BotoZap, BotoZapError, type BotoZapEvent, type BotoZapOptions, type Broadcast, type BroadcastRecipient, type Contact, type Conversation, type CreateAssignmentParams, type CreateBroadcastParams, type CreateContactParams, type CreateCustomerParams, type CreateFlowParams, type CreateFlowVersionParams, type CreateSetupLinkParams, type CreateTemplateParams, type CreateWebhookParams, type CursorList, type CursorPaging, type CursorParams, type Customer, type EventList, type EventPaging, type Flow, type FlowPhoneParams, type FlowVersion, type ListApiLogsParams, type ListBroadcastsParams, type ListContactsParams, type ListConversationsParams, type ListEventsParams, type ListFlowsParams, type ListMessagesParams, type ListPhoneNumbersParams, type ListRecipientsParams, type ListTemplatesParams, type ListWebhookDeliveriesParams, type MediaAsset, type MediaUploadResult, type Message, type MessageStatus, type OffsetList, type OffsetMeta, type OffsetParams, type PhoneNumber, type ReplyConversationParams, type RequestOptions, type ScheduleBroadcastParams, type SendAudioParams, type SendDocumentParams, type SendImageParams, type SendMediaParams, type SendResult, type SendTemplateParams, type SendTextParams, type SendVideoParams, type SetFlowDataEndpointParams, type SetupLink, type Template, type TemplatePayload, type UpdateBroadcastParams, type UpdateCustomerParams, type UpdateSetupLinkParams, type UploadMediaParams, type User, type Webhook, type WebhookDelivery };
3913
+ export { AI_CONFIGURABLE_PURPOSES, AI_OPERATIONS, AI_PURPOSES, type AddRecipientsResult, AgendaConfiguration, AgendaExceptions, type AgendaRecord, Ai, type AiAgent, type AiAgentConfig, type AiAgentCoverage, type AiAgentInput, type AiAgentVersion, AiAgentsResource, type AiAlert, type AiAlertBulkFilters, type AiAlertListItem, AiAlertsResource, type AiArtifactUploadInput, type AiAudioPricing, type AiBinding, type AiBindingTarget, type AiBudget, type AiBudgetInput, type AiCapabilitySignal, type AiCapabilityUsage, type AiCapabilityUsageList, type AiCase, type AiCaseChat, type AiCaseEvent, type AiCaseKind, type AiCaseReply, type AiCaseReplyInput, type AiCaseSource, AiCasesResource, type AiCatalogItems, type AiCatalogModel, type AiCatalogProduct, type AiCatalogSyncInput, type AiCatalogSyncResult, type AiChannelGate, type AiCommercialDecision, type AiCommercialEffect, type AiCommercialJob, type AiCommercialProposal, AiCommercialProposalsResource, type AiCommercialRequest, type AiCommercialSettings, type AiConfigurablePurpose, type AiContactAuthorization, type AiConversationCheckpoint, type AiCredential, AiCredentialsResource, type AiDraftResult, type AiEligibilityOverview, AiEligibilityResource, type AiEligibilitySettings, type AiEnrollment, type AiEvolution, AiEvolutionResource, type AiEvolutionSource, type AiExecution, type AiExecutionCitations, type AiExecutionSecurity, AiExecutionsResource, type AiField, type AiFlow, type AiFlowGraph, type AiFlowInput, type AiFlowSettings, type AiFlowVersion, type AiFollowupEffect, type AiFollowupEvent, AiFollowupFlowsResource, type AiFollowupPromise, type AiFollowupPromiseDetail, type AiFollowupPromiseStatus, type AiFollowupQueueFilters, type AiFollowupQueuePage, type AiFollowupQueueRow, AiFollowupsResource, type AiGateMode, type AiInference, type AiInferenceOrigin, type AiInferenceOutcome, type AiInferenceSummary, AiInferencesResource, type AiKnowledgeChunk, type AiKnowledgeCitation, type AiKnowledgeConversation, type AiKnowledgeHit, type AiKnowledgeImport, type AiKnowledgePreview, AiKnowledgeResource, type AiKnowledgeSearchDiagnostics, type AiKnowledgeSource, type AiMemory, type AiMemoryEntry, type AiMemoryEntryEvent, AiMemoryResource, type AiModelCatalogSnapshot, type AiModelCatalogSync, type AiNoticeCheck, type AiNoticeEffect, type AiNoticeField, type AiNoticeJob, type AiNoticeSettings, AiNoticesResource, type AiOperation, type AiOperatorMetrics, AiOperatorResource, type AiPage, type AiPlatformSkill, type AiPlatformSkillComposition, type AiPreparedUpload, type AiProposal, AiProposalsResource, type AiProvider, type AiProviderModel, AiProvidersResource, type AiPurpose, type AiRate, type AiRateInput, type AiRecord, type AiRevision, type AiRouter, type AiRouterConfig, type AiRouterTest, AiRoutersResource, type AiScope, type AiSkill, type AiSkillInput, type AiSkillNearMiss, type AiSkillVersion, AiSkillsResource, type AiSourceKind, type AiStyleAdjustment, type AiStyleAdjustmentId, AiStyleAdjustmentsResource, type AiToolId, type AiTurnPromise, type AiUploadReceiptCallback, AiUploadsResource, AiUsageResource, type AiUsageSummary, type AiUsageTokens, type AiWindow, type ApiLog, type Appointment, type AppointmentAvailability, type AppointmentExceptionInput, type AppointmentFields, type AppointmentHistory, type AppointmentQuery, type AppointmentScheduleInput, type AppointmentServiceInput, type AppointmentStatus, Appointments, type Assignment, type AvailabilityQuery, BotoZap, BotoZapError, type BotoZapEvent, type BotoZapOptions, type Broadcast, type BroadcastRecipient, Calendar, type CalendarConnection, type CalendarJob, type CalendarSelection, type Contact, type ContactField, ContactFields, type ContactStage, ContactStages, type Conversation, type ConversationNote, type ConversationReminder, type CreateAppointment, type CreateAssignmentParams, type CreateBroadcastParams, type CreateContactParams, type CreateCustomerParams, type CreateDemand, type CreateFlowParams, type CreateFlowVersionParams, type CreateOpportunity, type CreateSetupLinkParams, type CreateTemplateParams, type CreateWebhookParams, type CrmActivity, type CrmConversation, type CrmFields, type CrmMetadata, type CrmQuery, type CrmRecord, CrmResource, type CursorList, type CursorPaging, type CursorParams, type Customer, type Demand, type DemandFields, type EventList, type EventPaging, type Flow, type FlowPhoneParams, type FlowVersion, Inbox, type InboxMutation, type InboxMutationResult, type InboxState, type InboxTools, type Journey, type JourneyConfig, type JourneyEnrollment, type JourneyQuery, type JourneyRun, type JourneyStep, Journeys, type ListApiLogsParams, type ListBroadcastsParams, type ListContactsParams, type ListConversationsParams, type ListEventsParams, type ListFlowsParams, type ListMessagesParams, type ListPhoneNumbersParams, type ListRecipientsParams, type ListTemplatesParams, type ListWebhookDeliveriesParams, type MediaAsset, type MediaUploadResult, type Message, type MessageStatus, type OffsetList, type OffsetMeta, type OffsetParams, type Opportunity, type OpportunityFields, type PhoneNumber, Radar, type RadarEntry, type RadarPage, type RadarQuery, type ReplyConversationParams, type RequestOptions, SavedReplies, type SavedReply, type SavedReplyInput, type SavedReplyQuery, type ScheduleBroadcastParams, type SendAudioParams, type SendDocumentParams, type SendImageParams, type SendMediaParams, type SendResult, type SendTemplateParams, type SendTextParams, type SendVideoParams, type SetFlowDataEndpointParams, type SetupLink, type StageColor, type StageRule, type StageRuleInput, type Template, type TemplatePayload, type UpdateAppointment, type UpdateBroadcastParams, type UpdateContactParams, type UpdateCustomerParams, type UpdateSetupLinkParams, type UpdateWebhookParams, type UploadMediaParams, type User, type Webhook, type WebhookAuthorizationHeaders, type WebhookDelivery };