evo360-types 1.3.711 → 1.3.715

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zCsqAppointmentEventKindSchema = exports.zCsqTriageDecisionSchema = exports.zCsqTriageReasonSchema = exports.zCsqTriageModeSchema = exports.zCsqReviewSchema = exports.zCsqReviewCriterionDisagreementSchema = exports.zCsqReviewMissedAlertSchema = exports.zCsqDataQualitySchema = exports.zCsqCoverageSchema = exports.zCsqContributorSchema = exports.zCsqEvaluationSchema = exports.zCsqPillarScoreSchema = exports.zCsqPillarCoverageSchema = exports.zCsqCriterionScoreSchema = exports.zCsqCrossCheckSchema = exports.zCsqClaimTypeSchema = exports.zCsqClaimSchema = exports.zCsqClaimPriceInformedSchema = exports.zCsqClaimPatientStatusSchema = exports.zCsqClaimFirstConcreteOfferSchema = exports.zCsqClaimQuestionRequiresAnswerSchema = exports.zCsqClaimOutcomeSchema = exports.zCsqClaimRequiredDataSchema = exports.zCsqClaimDataCollectedSchema = exports.zCsqClaimPromiseSchema = exports.zCsqClaimAppointmentInformedSchema = exports.zCsqLeadStateSchema = exports.zCsqLeadStateListFieldSchema = exports.zCsqLeadStateFieldSchema = exports.zCsqIndicatorsSchema = exports.zCsqIndicatorsSetSchema = exports.zCsqAlertSchema = exports.zCsqEvidenceSchema = exports.zCsqAlertSubtypeSchema = exports.zCsqAlertCodeSchema = exports.zCsqPillarCodeSchema = exports.zCsqCriterionScoreValueSchema = exports.zCsqAuthorKindSchema = exports.zCsqReviewVerdictSchema = exports.zCsqLlmConnectionSourceSchema = exports.zCsqPhaseSchema = exports.zCsqRunStatusSchema = exports.zCsqVerificationStateSchema = exports.zCsqAlertResolvedReasonSchema = exports.zCsqAlertLifecycleSchema = exports.zCsqAlertScopeSchema = exports.zCsqAlertSourceSchema = exports.zCsqSeveritySchema = exports.zCsqStatusSchema = exports.zCsqModeSchema = void 0;
4
- exports.zCsqLeadReportSchema = exports.zCsqRunSchema = exports.zCsqAlertCountsSchema = exports.zCsqEligibilitySchema = exports.zCsqEvaluatedForSchema = exports.zCsqReportHeaderSchema = exports.zCsqReportAttendantSchema = exports.zCsqReportPatientSchema = exports.zCsqReportLeadSchema = exports.zCsqSystemFactsSchema = exports.zCsqBillingFactSchema = exports.zCsqPreviousTicketFactSchema = exports.zCsqOverlapFactSchema = exports.zCsqOverlapFamilyHintsSchema = exports.zCsqOverlapAppointmentFactSchema = exports.zCsqAppointmentFactSchema = exports.zCsqJudgeOutputSchema = exports.zCsqJudgeResolvedAlertSchema = exports.zCsqJudgeRevalidationSchema = exports.zCsqLlmUsageSchema = exports.zCsqTranscriptMessageSchema = exports.zCsqTicketSummarySchema = exports.zCsqTrailEntrySchema = exports.zCsqPromptBlockUsageSchema = exports.zCsqDetectorReportSchema = exports.zCsqDetectorLlmSchema = exports.zCsqDetectorModeSchema = exports.zCsqAppointmentEventSchema = void 0;
3
+ exports.zCsqTriageDecisionSchema = exports.zCsqTriageReasonSchema = exports.zCsqTriageModeSchema = exports.zCsqReviewSchema = exports.zCsqReviewCriterionDisagreementSchema = exports.zCsqReviewMissedAlertSchema = exports.zCsqDataQualitySchema = exports.zCsqCoverageSchema = exports.zCsqContributorSchema = exports.zCsqEvaluationSchema = exports.zCsqPillarScoreSchema = exports.zCsqPillarCoverageSchema = exports.zCsqCriterionScoreSchema = exports.zCsqCrossCheckSchema = exports.zCsqClaimTypeSchema = exports.zCsqClaimSchema = exports.zCsqClaimPriceInformedSchema = exports.zCsqClaimPatientStatusSchema = exports.zCsqClaimFirstConcreteOfferSchema = exports.zCsqClaimQuestionRequiresAnswerSchema = exports.zCsqClaimOutcomeSchema = exports.zCsqClaimRequiredDataSchema = exports.zCsqClaimDataCollectedSchema = exports.zCsqClaimPromiseSchema = exports.zCsqClaimAppointmentInformedSchema = exports.zCsqLeadStateSchema = exports.zCsqLeadStateListFieldSchema = exports.zCsqLeadStateFieldSchema = exports.zCsqIndicatorsSchema = exports.zCsqIndicatorsSetSchema = exports.zCsqAlertSchema = exports.zCsqEvidenceSchema = exports.zCsqAlertSubtypeSchema = exports.zCsqAlertCodeSchema = exports.zCsqPillarCodeSchema = exports.zCsqCriterionScoreValueSchema = exports.zCsqAuthorKindSchema = exports.zCsqReviewSourceSchema = exports.zCsqReviewVerdictSchema = exports.zCsqLlmConnectionSourceSchema = exports.zCsqPhaseSchema = exports.zCsqRunStatusSchema = exports.zCsqVerificationStateSchema = exports.zCsqAlertResolvedReasonSchema = exports.zCsqAlertLifecycleSchema = exports.zCsqAlertScopeSchema = exports.zCsqAlertSourceSchema = exports.zCsqSeveritySchema = exports.zCsqStatusSchema = exports.zCsqModeSchema = void 0;
4
+ exports.zCsqDryRunResultSchema = exports.zCsqDryRunRequestSchema = exports.zCsqLeadReportSchema = exports.zCsqRunSchema = exports.zCsqAlertCountsSchema = exports.zCsqEligibilitySchema = exports.zCsqEvaluatedForSchema = exports.zCsqReportHeaderSchema = exports.zCsqReportAttendantSchema = exports.zCsqReportPatientSchema = exports.zCsqReportLeadSchema = exports.zCsqSystemFactsSchema = exports.zCsqBillingFactSchema = exports.zCsqPreviousTicketFactSchema = exports.zCsqOverlapFactSchema = exports.zCsqOverlapFamilyHintsSchema = exports.zCsqOverlapAppointmentFactSchema = exports.zCsqAppointmentFactSchema = exports.zCsqJudgeOutputSchema = exports.zCsqJudgeResolvedAlertSchema = exports.zCsqJudgeRevalidationSchema = exports.zCsqLlmUsageSchema = exports.zCsqTranscriptMessageSchema = exports.zCsqTicketSummarySchema = exports.zCsqTrailEntrySchema = exports.zCsqPromptBlockUsageSchema = exports.zCsqDetectorReportSchema = exports.zCsqDetectorLlmSchema = exports.zCsqPlatformLlmConfigPatchSchema = exports.zCsqPlatformLlmConfigPatchFieldsSchema = exports.zCsqPlatformLlmConfigSchema = exports.zCsqTransportKillSwitchSchema = exports.zCsqDetectorModeSchema = exports.zCsqAppointmentEventSchema = exports.zCsqAppointmentEventKindSchema = void 0;
5
5
  const zod_1 = require("zod");
6
6
  const zod_schemas_1 = require("../shared/zod-schemas");
7
7
  // Schemas zod do CSQ 2.0 (feat-154). As interfaces TS equivalentes ficam em
@@ -54,6 +54,8 @@ exports.zCsqLlmConnectionSourceSchema = zod_1.z.enum([
54
54
  "kill_switch",
55
55
  ]);
56
56
  exports.zCsqReviewVerdictSchema = zod_1.z.enum(["agree", "disagree"]);
57
+ /** feat-280: origem da revisao (espelho de `CSQ_REVIEW_SOURCES`). */
58
+ exports.zCsqReviewSourceSchema = zod_1.z.enum(["nexus", "mcp"]);
57
59
  exports.zCsqAuthorKindSchema = zod_1.z.enum([
58
60
  "lead",
59
61
  "human",
@@ -381,6 +383,10 @@ exports.zCsqReviewSchema = zod_1.z.object({
381
383
  .optional(),
382
384
  reviewer_login_id: zod_1.z.string(),
383
385
  reviewed_at: zod_schemas_1.zFirestoreDateSchema,
386
+ /** feat-280: ausente = `nexus` (revisoes anteriores). */
387
+ source: exports.zCsqReviewSourceSchema.optional(),
388
+ /** feat-280: `client_id` OAuth quando `source = 'mcp'`. */
389
+ client_id: zod_1.z.string().optional(),
384
390
  });
385
391
  // ───────── Trilha e denormalizacao ─────────
386
392
  // ───────── Triagem sem LLM (feat-206 F1) ─────────
@@ -419,6 +425,34 @@ exports.zCsqAppointmentEventSchema = zod_1.z.object({
419
425
  supersedes: zod_1.z.string().optional(),
420
426
  });
421
427
  exports.zCsqDetectorModeSchema = zod_1.z.enum(["off", "shadow", "on"]);
428
+ exports.zCsqTransportKillSwitchSchema = zod_1.z.enum([
429
+ "vertex",
430
+ "anthropic_direct",
431
+ ]);
432
+ /** feat-280: `/platform/evo-csq.llm` como lido (todos opcionais/nulos). */
433
+ exports.zCsqPlatformLlmConfigSchema = zod_1.z.object({
434
+ default_connection_id: zod_1.z.string().nullable().optional(),
435
+ extractor_connection_id: zod_1.z.string().nullable().optional(),
436
+ detector_mode: exports.zCsqDetectorModeSchema.nullable().optional(),
437
+ transport_kill_switch: exports.zCsqTransportKillSwitchSchema.nullable().optional(),
438
+ service_account: zod_1.z.string().nullable().optional(),
439
+ });
440
+ /**
441
+ * feat-280: patch da config de plataforma gravado pelo MCP do Nexus
442
+ * (`chat.csq_admin`). `null` = apagar o campo (volta ao default do pacote).
443
+ * `service_account` NAO entra (so leitura): `.strict()` recusa a chave.
444
+ */
445
+ exports.zCsqPlatformLlmConfigPatchFieldsSchema = zod_1.z
446
+ .object({
447
+ default_connection_id: zod_1.z.string().min(1).nullable().optional(),
448
+ extractor_connection_id: zod_1.z.string().min(1).nullable().optional(),
449
+ detector_mode: exports.zCsqDetectorModeSchema.nullable().optional(),
450
+ transport_kill_switch: exports.zCsqTransportKillSwitchSchema.nullable().optional(),
451
+ })
452
+ .strict();
453
+ /** Patch completo: campos acima + "ao menos um campo". Para `inputSchema` de
454
+ * tool MCP use `zCsqPlatformLlmConfigPatchFieldsSchema.shape`. */
455
+ exports.zCsqPlatformLlmConfigPatchSchema = exports.zCsqPlatformLlmConfigPatchFieldsSchema.refine((v) => Object.keys(v).some((k) => v[k] !== undefined), { message: "Informe ao menos um campo da config de plataforma." });
422
456
  exports.zCsqDetectorLlmSchema = zod_1.z.object({
423
457
  provider: zod_1.z.string(),
424
458
  model: zod_1.z.string(),
@@ -714,3 +748,40 @@ exports.zCsqLeadReportSchema = zod_schemas_1.zFireDocSchema
714
748
  detector: exports.zCsqDetectorReportSchema.optional(),
715
749
  })
716
750
  .passthrough();
751
+ // ───────── Reavaliacao sob demanda (feat-280 F4) ─────────
752
+ /** Contrato nexus -> hubia (`hubia_csq_dry_run`). Ids sem `/` (viram caminho de doc). */
753
+ const zCsqDryRunIdSchema = zod_1.z
754
+ .string()
755
+ .min(1)
756
+ .max(200)
757
+ .refine((v) => v.indexOf("/") < 0, { message: "id nao pode conter /" });
758
+ exports.zCsqDryRunRequestSchema = zod_1.z
759
+ .object({
760
+ tenant: zCsqDryRunIdSchema,
761
+ ticket_id: zCsqDryRunIdSchema,
762
+ channel_id: zCsqDryRunIdSchema.nullable().optional(),
763
+ lead_id: zCsqDryRunIdSchema.nullable().optional(),
764
+ connection_id: zCsqDryRunIdSchema.nullable().optional(),
765
+ force_review: zod_1.z.boolean().optional(),
766
+ requested_by: zod_1.z
767
+ .object({ login_id: zod_1.z.string().min(1), client_id: zod_1.z.string().nullable().optional() })
768
+ .nullable()
769
+ .optional(),
770
+ })
771
+ .strict();
772
+ exports.zCsqDryRunResultSchema = zod_1.z.object({
773
+ outcome: zod_1.z.string(),
774
+ detail: zod_1.z.string().nullable(),
775
+ evaluation_id: zod_1.z.string().nullable(),
776
+ lead_id: zod_1.z.string().nullable(),
777
+ channel_id: zod_1.z.string(),
778
+ report: zod_1.z.record(zod_1.z.unknown()).nullable(),
779
+ detector: exports.zCsqDetectorReportSchema.passthrough().nullable(),
780
+ model: zod_1.z.string().nullable(),
781
+ llm_provider: zod_1.z.string().nullable(),
782
+ llm_connection_id: zod_1.z.string().nullable(),
783
+ llm_connection_source: exports.zCsqLlmConnectionSourceSchema.nullable(),
784
+ triage_mode: exports.zCsqTriageModeSchema.nullable(),
785
+ cost_usd_est: zod_1.z.number().nullable(),
786
+ duration_ms: zod_1.z.number(),
787
+ });
@@ -66,6 +66,9 @@ export const zCsqLlmConnectionSourceSchema = z.enum([
66
66
 
67
67
  export const zCsqReviewVerdictSchema = z.enum(["agree", "disagree"]);
68
68
 
69
+ /** feat-280: origem da revisao (espelho de `CSQ_REVIEW_SOURCES`). */
70
+ export const zCsqReviewSourceSchema = z.enum(["nexus", "mcp"]);
71
+
69
72
  export const zCsqAuthorKindSchema = z.enum([
70
73
  "lead",
71
74
  "human",
@@ -434,6 +437,10 @@ export const zCsqReviewSchema = z.object({
434
437
  .optional(),
435
438
  reviewer_login_id: z.string(),
436
439
  reviewed_at: zFirestoreDateSchema,
440
+ /** feat-280: ausente = `nexus` (revisoes anteriores). */
441
+ source: zCsqReviewSourceSchema.optional(),
442
+ /** feat-280: `client_id` OAuth quando `source = 'mcp'`. */
443
+ client_id: z.string().optional(),
437
444
  });
438
445
 
439
446
  // ───────── Trilha e denormalizacao ─────────
@@ -482,6 +489,45 @@ export const zCsqAppointmentEventSchema = z.object({
482
489
 
483
490
  export const zCsqDetectorModeSchema = z.enum(["off", "shadow", "on"]);
484
491
 
492
+ export const zCsqTransportKillSwitchSchema = z.enum([
493
+ "vertex",
494
+ "anthropic_direct",
495
+ ]);
496
+
497
+ /** feat-280: `/platform/evo-csq.llm` como lido (todos opcionais/nulos). */
498
+ export const zCsqPlatformLlmConfigSchema = z.object({
499
+ default_connection_id: z.string().nullable().optional(),
500
+ extractor_connection_id: z.string().nullable().optional(),
501
+ detector_mode: zCsqDetectorModeSchema.nullable().optional(),
502
+ transport_kill_switch: zCsqTransportKillSwitchSchema.nullable().optional(),
503
+ service_account: z.string().nullable().optional(),
504
+ });
505
+
506
+ /**
507
+ * feat-280: patch da config de plataforma gravado pelo MCP do Nexus
508
+ * (`chat.csq_admin`). `null` = apagar o campo (volta ao default do pacote).
509
+ * `service_account` NAO entra (so leitura): `.strict()` recusa a chave.
510
+ */
511
+ export const zCsqPlatformLlmConfigPatchFieldsSchema = z
512
+ .object({
513
+ default_connection_id: z.string().min(1).nullable().optional(),
514
+ extractor_connection_id: z.string().min(1).nullable().optional(),
515
+ detector_mode: zCsqDetectorModeSchema.nullable().optional(),
516
+ transport_kill_switch: zCsqTransportKillSwitchSchema.nullable().optional(),
517
+ })
518
+ .strict();
519
+
520
+ /** Patch completo: campos acima + "ao menos um campo". Para `inputSchema` de
521
+ * tool MCP use `zCsqPlatformLlmConfigPatchFieldsSchema.shape`. */
522
+ export const zCsqPlatformLlmConfigPatchSchema =
523
+ zCsqPlatformLlmConfigPatchFieldsSchema.refine(
524
+ (v) =>
525
+ Object.keys(v).some(
526
+ (k) => (v as Record<string, unknown>)[k] !== undefined,
527
+ ),
528
+ { message: "Informe ao menos um campo da config de plataforma." },
529
+ );
530
+
485
531
  export const zCsqDetectorLlmSchema = z.object({
486
532
  provider: z.string(),
487
533
  model: z.string(),
@@ -814,3 +860,44 @@ export const zCsqLeadReportSchema = zFireDocSchema
814
860
  detector: zCsqDetectorReportSchema.optional(),
815
861
  })
816
862
  .passthrough();
863
+
864
+ // ───────── Reavaliacao sob demanda (feat-280 F4) ─────────
865
+
866
+ /** Contrato nexus -> hubia (`hubia_csq_dry_run`). Ids sem `/` (viram caminho de doc). */
867
+ const zCsqDryRunIdSchema = z
868
+ .string()
869
+ .min(1)
870
+ .max(200)
871
+ .refine((v) => v.indexOf("/") < 0, { message: "id nao pode conter /" });
872
+
873
+ export const zCsqDryRunRequestSchema = z
874
+ .object({
875
+ tenant: zCsqDryRunIdSchema,
876
+ ticket_id: zCsqDryRunIdSchema,
877
+ channel_id: zCsqDryRunIdSchema.nullable().optional(),
878
+ lead_id: zCsqDryRunIdSchema.nullable().optional(),
879
+ connection_id: zCsqDryRunIdSchema.nullable().optional(),
880
+ force_review: z.boolean().optional(),
881
+ requested_by: z
882
+ .object({ login_id: z.string().min(1), client_id: z.string().nullable().optional() })
883
+ .nullable()
884
+ .optional(),
885
+ })
886
+ .strict();
887
+
888
+ export const zCsqDryRunResultSchema = z.object({
889
+ outcome: z.string(),
890
+ detail: z.string().nullable(),
891
+ evaluation_id: z.string().nullable(),
892
+ lead_id: z.string().nullable(),
893
+ channel_id: z.string(),
894
+ report: z.record(z.unknown()).nullable(),
895
+ detector: zCsqDetectorReportSchema.passthrough().nullable(),
896
+ model: z.string().nullable(),
897
+ llm_provider: z.string().nullable(),
898
+ llm_connection_id: z.string().nullable(),
899
+ llm_connection_source: zCsqLlmConnectionSourceSchema.nullable(),
900
+ triage_mode: zCsqTriageModeSchema.nullable(),
901
+ cost_usd_est: z.number().nullable(),
902
+ duration_ms: z.number(),
903
+ });
package/dist/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export * from "./types/evo-telemedicine";
39
39
  export * from "./types/evo-modules";
40
40
  export * from "./apps/shared/zod-schemas";
41
41
  export * from "./apps/evo-core/zod-schemas";
42
+ export * from "./apps/evo-core/nexus-claims";
42
43
  export * from "./apps/evo-tenant/zod-schemas";
43
44
  export * from "./apps/evo-activity/zod-schemas";
44
45
  export * from "./apps/evo-people/zod-schemas";
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ __exportStar(require("./types/evo-modules"), exports);
57
57
  // zod schemas
58
58
  __exportStar(require("./apps/shared/zod-schemas"), exports);
59
59
  __exportStar(require("./apps/evo-core/zod-schemas"), exports);
60
+ __exportStar(require("./apps/evo-core/nexus-claims"), exports);
60
61
  __exportStar(require("./apps/evo-tenant/zod-schemas"), exports);
61
62
  __exportStar(require("./apps/evo-activity/zod-schemas"), exports);
62
63
  __exportStar(require("./apps/evo-people/zod-schemas"), exports);
package/dist/index.ts CHANGED
@@ -42,6 +42,7 @@ export * from "./types/evo-modules";
42
42
  // zod schemas
43
43
  export * from "./apps/shared/zod-schemas";
44
44
  export * from "./apps/evo-core/zod-schemas";
45
+ export * from "./apps/evo-core/nexus-claims";
45
46
  export * from "./apps/evo-tenant/zod-schemas";
46
47
  export * from "./apps/evo-activity/zod-schemas";
47
48
  export * from "./apps/evo-people/zod-schemas";
@@ -227,7 +227,18 @@ export interface ICampaignChannelCounters {
227
227
  failed?: number;
228
228
  clicked?: number;
229
229
  replied?: number;
230
+ /**
231
+ * Ticket outcome of sends whose policy asked to close the ticket (F6). Recorded by
232
+ * the hub-omni at the moment it decides. `kept_open` is the RULE (patient already had
233
+ * an open ticket — the campaign never ends a live attendance); `close_failed` is a
234
+ * defect (close attempted, did not happen).
235
+ */
236
+ ticket_closed?: number;
237
+ ticket_kept_open?: number;
238
+ ticket_close_failed?: number;
230
239
  }
240
+ /** What happened to the ticket of a campaign send that asked to close it (F6). */
241
+ export type CampaignTicketOutcome = "closed" | "kept_open" | "close_failed";
231
242
  export interface ICampaignCounters {
232
243
  raw?: number;
233
244
  unique?: number;
@@ -330,6 +341,26 @@ export interface ICampaign extends IFireDoc {
330
341
  finished_at?: Date | null;
331
342
  cancel_reason?: string | null;
332
343
  error_reason?: string | null;
344
+ /**
345
+ * Why the campaign is paused, when the SYSTEM paused it (F6 circuit breaker).
346
+ * `null`/absent on an operator pause and cleared on resume — its presence is what
347
+ * tells the screen "the platform stopped this, here is the cause".
348
+ */
349
+ pause_reason?: ICampaignPauseReason | null;
350
+ }
351
+ /**
352
+ * System pause (F6). A provider error that fails EVERY recipient the same way
353
+ * (account payment, account restricted, template paused/disabled, broken media)
354
+ * stops the dispatch instead of burning the rest of the list.
355
+ */
356
+ export interface ICampaignPauseReason {
357
+ kind: "provider_systemic_error";
358
+ channel: CampaignChannel;
359
+ error_code: string;
360
+ error_message?: string | null;
361
+ /** Recipient whose failure tripped the breaker — the operator can open it. */
362
+ recipient_id?: string | null;
363
+ at: Date;
333
364
  }
334
365
  export type CampaignBucketSourceType = "leads" | "patients" | "appointments" | "csv";
335
366
  export interface ICampaignBucketCsvFile {
@@ -417,6 +448,16 @@ export interface ICampaignRecipientChannelState {
417
448
  failed_at?: Date | null;
418
449
  /** Provider error text that accompanies `failed_at`. */
419
450
  error?: string | null;
451
+ /**
452
+ * Provider error CODE that accompanies `failed_at` (F6). Kept apart from `error`
453
+ * because the code is what the operator-facing breakdown groups by and what the
454
+ * circuit breaker decides on; parsing it back out of the text would be guessing.
455
+ * String, not number: providers other than Meta do not promise numeric codes.
456
+ */
457
+ error_code?: string | null;
458
+ /** Ticket outcome when the policy asked to close it (F6) — see ICampaignChannelCounters. */
459
+ ticket_outcome?: CampaignTicketOutcome | null;
460
+ ticket_id?: string | null;
420
461
  }
421
462
  /**
422
463
  * Why a recipient was kept out. Closed union: every value here HAS a writer in
@@ -304,8 +304,20 @@ export interface ICampaignChannelCounters {
304
304
  failed?: number;
305
305
  clicked?: number;
306
306
  replied?: number;
307
+ /**
308
+ * Ticket outcome of sends whose policy asked to close the ticket (F6). Recorded by
309
+ * the hub-omni at the moment it decides. `kept_open` is the RULE (patient already had
310
+ * an open ticket — the campaign never ends a live attendance); `close_failed` is a
311
+ * defect (close attempted, did not happen).
312
+ */
313
+ ticket_closed?: number;
314
+ ticket_kept_open?: number;
315
+ ticket_close_failed?: number;
307
316
  }
308
317
 
318
+ /** What happened to the ticket of a campaign send that asked to close it (F6). */
319
+ export type CampaignTicketOutcome = "closed" | "kept_open" | "close_failed";
320
+
309
321
  export interface ICampaignCounters {
310
322
  raw?: number;
311
323
  unique?: number;
@@ -422,6 +434,27 @@ export interface ICampaign extends IFireDoc {
422
434
  finished_at?: Date | null;
423
435
  cancel_reason?: string | null;
424
436
  error_reason?: string | null;
437
+ /**
438
+ * Why the campaign is paused, when the SYSTEM paused it (F6 circuit breaker).
439
+ * `null`/absent on an operator pause and cleared on resume — its presence is what
440
+ * tells the screen "the platform stopped this, here is the cause".
441
+ */
442
+ pause_reason?: ICampaignPauseReason | null;
443
+ }
444
+
445
+ /**
446
+ * System pause (F6). A provider error that fails EVERY recipient the same way
447
+ * (account payment, account restricted, template paused/disabled, broken media)
448
+ * stops the dispatch instead of burning the rest of the list.
449
+ */
450
+ export interface ICampaignPauseReason {
451
+ kind: "provider_systemic_error";
452
+ channel: CampaignChannel;
453
+ error_code: string;
454
+ error_message?: string | null;
455
+ /** Recipient whose failure tripped the breaker — the operator can open it. */
456
+ recipient_id?: string | null;
457
+ at: Date;
425
458
  }
426
459
 
427
460
  // ----- Bucket ---------------------------------------------------------------
@@ -550,6 +583,16 @@ export interface ICampaignRecipientChannelState {
550
583
  failed_at?: Date | null;
551
584
  /** Provider error text that accompanies `failed_at`. */
552
585
  error?: string | null;
586
+ /**
587
+ * Provider error CODE that accompanies `failed_at` (F6). Kept apart from `error`
588
+ * because the code is what the operator-facing breakdown groups by and what the
589
+ * circuit breaker decides on; parsing it back out of the text would be guessing.
590
+ * String, not number: providers other than Meta do not promise numeric codes.
591
+ */
592
+ error_code?: string | null;
593
+ /** Ticket outcome when the policy asked to close it (F6) — see ICampaignChannelCounters. */
594
+ ticket_outcome?: CampaignTicketOutcome | null;
595
+ ticket_id?: string | null;
553
596
  }
554
597
 
555
598
  /**
@@ -51,6 +51,9 @@ export interface INexusModuleChatPermissions {
51
51
  supervision?: boolean;
52
52
  /** Supervisão 2.0 (CSQ). Gate da fila e do laudo do evo-csq no Nexus. */
53
53
  csq?: boolean;
54
+ /** feat-280: administração do CSQ (config de LLM da plataforma e
55
+ * reavaliação sob demanda). Só reconhecida pelo MCP do Nexus. */
56
+ csq_admin?: boolean;
54
57
  }
55
58
  export interface INexusReports {
56
59
  }
@@ -62,6 +62,9 @@ export interface INexusModuleChatPermissions {
62
62
  supervision?: boolean;
63
63
  /** Supervisão 2.0 (CSQ). Gate da fila e do laudo do evo-csq no Nexus. */
64
64
  csq?: boolean;
65
+ /** feat-280: administração do CSQ (config de LLM da plataforma e
66
+ * reavaliação sob demanda). Só reconhecida pelo MCP do Nexus. */
67
+ csq_admin?: boolean;
65
68
  }
66
69
 
67
70
  export interface INexusReports {}
@@ -55,6 +55,11 @@ export type CsqRunStatus = "running" | "done" | "failed" | "quarantined";
55
55
  export type CsqCriterionScore = 0 | 50 | 100 | "NA";
56
56
  /** Veredito humano sobre o laudo (adendo §D / Q9=A). */
57
57
  export type CsqReviewVerdict = "agree" | "disagree";
58
+ /** feat-280 (Q6): por onde a revisao entrou. `nexus` = tela Supervisao 2.0;
59
+ * `mcp` = conector MCP do Nexus (claude.ai/ChatGPT). Ausente = `nexus` legado.
60
+ * A calibracao do juiz pode filtrar por origem. */
61
+ export declare const CSQ_REVIEW_SOURCES: readonly ["nexus", "mcp"];
62
+ export type CsqReviewSource = (typeof CSQ_REVIEW_SOURCES)[number];
58
63
  /** Fase do pipeline: `f0` = so indicadores + alertas deterministicos;
59
64
  * `f1` = com o juiz LLM. */
60
65
  export type CsqPhase = "f0" | "f1";
@@ -462,6 +467,10 @@ export interface ICsqReview {
462
467
  criteria_disagreements?: ICsqReviewCriterionDisagreement[];
463
468
  reviewer_login_id: string;
464
469
  reviewed_at: Date;
470
+ /** feat-280: origem da revisao. Ausente = `nexus` (revisoes anteriores). */
471
+ source?: CsqReviewSource;
472
+ /** feat-280: `client_id` OAuth do cliente MCP quando `source = 'mcp'`. */
473
+ client_id?: string;
465
474
  }
466
475
  /** Alerta que faltou no laudo, segundo o supervisor (feat-206 F5). */
467
476
  export interface ICsqReviewMissedAlert {
@@ -530,6 +539,25 @@ export interface ICsqAppointmentEvent {
530
539
  /** `off`: nao roda; `shadow`: roda e registra em `report.detector`, sem mexer
531
540
  * nos claims; `on`: os claims do detector entram na verificacao. */
532
541
  export type CsqDetectorMode = "off" | "shadow" | "on";
542
+ /** Transporte forcado do juiz (`/platform/evo-csq.llm.transport_kill_switch`). */
543
+ export type CsqTransportKillSwitch = "vertex" | "anthropic_direct";
544
+ /**
545
+ * Config de LLM da plataforma: `/platform/evo-csq` -> campo `llm` (feat-191,
546
+ * feat-206 F3). Espelho de `CsqPlatformLlmConfig` do `@evo/csq`. Campo ausente
547
+ * ou `null` = constante do pacote (conexao) / `off` (detector) / ADC (SA).
548
+ * feat-280: gravavel pelo MCP do Nexus (claim `chat.csq_admin`), exceto
549
+ * `service_account` (so leitura).
550
+ */
551
+ export interface ICsqPlatformLlmConfig {
552
+ default_connection_id?: string | null;
553
+ extractor_connection_id?: string | null;
554
+ detector_mode?: CsqDetectorMode | null;
555
+ transport_kill_switch?: CsqTransportKillSwitch | null;
556
+ /** SA que a SA de runtime impersona no Vertex. So leitura pelo MCP. */
557
+ service_account?: string | null;
558
+ }
559
+ /** Campos de `ICsqPlatformLlmConfig` que o MCP pode gravar. */
560
+ export type ICsqPlatformLlmConfigPatch = Partial<Omit<ICsqPlatformLlmConfig, "service_account">>;
533
561
  /** Como terminou a extracao por LLM do detector. */
534
562
  export type CsqDetectorOutcome = "no_signal" | "ok" | "failed" | "skipped";
535
563
  /** Uso do LLM do extrator (so quando houve chamada). */
@@ -896,3 +924,44 @@ export interface ICsqLeadReport extends IFireDoc {
896
924
  * Ausente quando o detector esta `off` ou o laudo e anterior a F3. */
897
925
  detector?: ICsqDetectorReport;
898
926
  }
927
+ /**
928
+ * Pedido de reavaliacao (dry-run) do nex-mcp para o `hubia_csq_dry_run`.
929
+ * Roda o pipeline com o juiz REAL e grava NADA (laudo, runs, BQ, evo_log do
930
+ * pipeline, notificacao, rechecagem, `ticket.csq`).
931
+ */
932
+ export interface ICsqDryRunRequest {
933
+ tenant: string;
934
+ ticket_id: string;
935
+ /** Canal evo-chat do ticket. Ausente = `channel_id` do laudo atual do lead. */
936
+ channel_id?: string | null;
937
+ /** Ausente = `lead_id` do ticket. */
938
+ lead_id?: string | null;
939
+ /** Conexao do juiz (`llm-connections/{id}`). Ausente = resolucao da producao. */
940
+ connection_id?: string | null;
941
+ /** Ignora a triagem sem LLM (`full_review` com motivo `forced`). Default true. */
942
+ force_review?: boolean;
943
+ /** Quem pediu (so log/auditoria do lado do hubia). */
944
+ requested_by?: {
945
+ login_id: string;
946
+ client_id?: string | null;
947
+ } | null;
948
+ }
949
+ /** Resposta do dry-run. `report` vem serializado (datas em ISO). */
950
+ export interface ICsqDryRunResult {
951
+ /** `CsqRunResult.outcome` do pipeline (ex.: `evaluated`, `skipped_*`). */
952
+ outcome: string;
953
+ detail: string | null;
954
+ evaluation_id: string | null;
955
+ lead_id: string | null;
956
+ channel_id: string;
957
+ /** Laudo capturado (NAO gravado); null quando o pipeline nao chegou a montar. */
958
+ report: Record<string, unknown> | null;
959
+ detector: ICsqDetectorReport | null;
960
+ model: string | null;
961
+ llm_provider: string | null;
962
+ llm_connection_id: string | null;
963
+ llm_connection_source: CsqLlmConnectionSource | null;
964
+ triage_mode: CsqTriageMode | null;
965
+ cost_usd_est: number | null;
966
+ duration_ms: number;
967
+ }
@@ -22,7 +22,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
22
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.CSQ_REVIEW_LIMITS = exports.CSQ_DEFAULTS = exports.CSQ_RUBRIC_V1 = exports.CSQ_AUTO_FAIL_POLICY_SUBTYPES = exports.CSQ_AUTO_FAIL_ALERT_CODES = exports.CSQ_SALES_FLOW_SUBTYPES = exports.CSQ_POLICY_VIOLATION_SUBTYPES = exports.CSQ_ALERT_CODES = exports.CSQ_RUBRIC_VERSION = void 0;
25
+ exports.CSQ_REVIEW_LIMITS = exports.CSQ_DEFAULTS = exports.CSQ_RUBRIC_V1 = exports.CSQ_AUTO_FAIL_POLICY_SUBTYPES = exports.CSQ_AUTO_FAIL_ALERT_CODES = exports.CSQ_SALES_FLOW_SUBTYPES = exports.CSQ_POLICY_VIOLATION_SUBTYPES = exports.CSQ_ALERT_CODES = exports.CSQ_REVIEW_SOURCES = exports.CSQ_RUBRIC_VERSION = void 0;
26
26
  __exportStar(require("./fb_collections"), exports);
27
27
  // ───────── Versao da rubrica ─────────
28
28
  /** Versao da rubrica da plataforma gravada em cada avaliacao. Pesos e criterios
@@ -39,6 +39,10 @@ __exportStar(require("./fb_collections"), exports);
39
39
  * regra generica; familia em horarios vizinhos e esperada; `retorno_apos_vou_verificar` e
40
40
  * `nomes_corretos` com ponderacao) e a SAIDA do juiz ganha `revalidations` e `resolved_alerts`. */
41
41
  exports.CSQ_RUBRIC_VERSION = "v1.3";
42
+ /** feat-280 (Q6): por onde a revisao entrou. `nexus` = tela Supervisao 2.0;
43
+ * `mcp` = conector MCP do Nexus (claude.ai/ChatGPT). Ausente = `nexus` legado.
44
+ * A calibracao do juiz pode filtrar por origem. */
45
+ exports.CSQ_REVIEW_SOURCES = ["nexus", "mcp"];
42
46
  // ───────── Catalogo de alertas (report-spec §6) ─────────
43
47
  /** Codigos de alerta v1. Os subtipos de `POLITICA_VIOLADA` e
44
48
  * `FLUXO_VENDA_NAO_SEGUIDO` vivem em `ICsqAlert.subtype`, nao como codigos. */
@@ -98,6 +98,12 @@ export type CsqCriterionScore = 0 | 50 | 100 | "NA";
98
98
  /** Veredito humano sobre o laudo (adendo §D / Q9=A). */
99
99
  export type CsqReviewVerdict = "agree" | "disagree";
100
100
 
101
+ /** feat-280 (Q6): por onde a revisao entrou. `nexus` = tela Supervisao 2.0;
102
+ * `mcp` = conector MCP do Nexus (claude.ai/ChatGPT). Ausente = `nexus` legado.
103
+ * A calibracao do juiz pode filtrar por origem. */
104
+ export const CSQ_REVIEW_SOURCES = ["nexus", "mcp"] as const;
105
+ export type CsqReviewSource = (typeof CSQ_REVIEW_SOURCES)[number];
106
+
101
107
  /** Fase do pipeline: `f0` = so indicadores + alertas deterministicos;
102
108
  * `f1` = com o juiz LLM. */
103
109
  export type CsqPhase = "f0" | "f1";
@@ -717,6 +723,10 @@ export interface ICsqReview {
717
723
  criteria_disagreements?: ICsqReviewCriterionDisagreement[];
718
724
  reviewer_login_id: string;
719
725
  reviewed_at: Date;
726
+ /** feat-280: origem da revisao. Ausente = `nexus` (revisoes anteriores). */
727
+ source?: CsqReviewSource;
728
+ /** feat-280: `client_id` OAuth do cliente MCP quando `source = 'mcp'`. */
729
+ client_id?: string;
720
730
  }
721
731
 
722
732
  /** Alerta que faltou no laudo, segundo o supervisor (feat-206 F5). */
@@ -813,6 +823,30 @@ export interface ICsqAppointmentEvent {
813
823
  * nos claims; `on`: os claims do detector entram na verificacao. */
814
824
  export type CsqDetectorMode = "off" | "shadow" | "on";
815
825
 
826
+ /** Transporte forcado do juiz (`/platform/evo-csq.llm.transport_kill_switch`). */
827
+ export type CsqTransportKillSwitch = "vertex" | "anthropic_direct";
828
+
829
+ /**
830
+ * Config de LLM da plataforma: `/platform/evo-csq` -> campo `llm` (feat-191,
831
+ * feat-206 F3). Espelho de `CsqPlatformLlmConfig` do `@evo/csq`. Campo ausente
832
+ * ou `null` = constante do pacote (conexao) / `off` (detector) / ADC (SA).
833
+ * feat-280: gravavel pelo MCP do Nexus (claim `chat.csq_admin`), exceto
834
+ * `service_account` (so leitura).
835
+ */
836
+ export interface ICsqPlatformLlmConfig {
837
+ default_connection_id?: string | null;
838
+ extractor_connection_id?: string | null;
839
+ detector_mode?: CsqDetectorMode | null;
840
+ transport_kill_switch?: CsqTransportKillSwitch | null;
841
+ /** SA que a SA de runtime impersona no Vertex. So leitura pelo MCP. */
842
+ service_account?: string | null;
843
+ }
844
+
845
+ /** Campos de `ICsqPlatformLlmConfig` que o MCP pode gravar. */
846
+ export type ICsqPlatformLlmConfigPatch = Partial<
847
+ Omit<ICsqPlatformLlmConfig, "service_account">
848
+ >;
849
+
816
850
  /** Como terminou a extracao por LLM do detector. */
817
851
  export type CsqDetectorOutcome = "no_signal" | "ok" | "failed" | "skipped";
818
852
 
@@ -1220,3 +1254,45 @@ export interface ICsqLeadReport extends IFireDoc {
1220
1254
  * Ausente quando o detector esta `off` ou o laudo e anterior a F3. */
1221
1255
  detector?: ICsqDetectorReport;
1222
1256
  }
1257
+
1258
+ // ───────── Reavaliacao sob demanda (feat-280 F4) ─────────
1259
+
1260
+ /**
1261
+ * Pedido de reavaliacao (dry-run) do nex-mcp para o `hubia_csq_dry_run`.
1262
+ * Roda o pipeline com o juiz REAL e grava NADA (laudo, runs, BQ, evo_log do
1263
+ * pipeline, notificacao, rechecagem, `ticket.csq`).
1264
+ */
1265
+ export interface ICsqDryRunRequest {
1266
+ tenant: string;
1267
+ ticket_id: string;
1268
+ /** Canal evo-chat do ticket. Ausente = `channel_id` do laudo atual do lead. */
1269
+ channel_id?: string | null;
1270
+ /** Ausente = `lead_id` do ticket. */
1271
+ lead_id?: string | null;
1272
+ /** Conexao do juiz (`llm-connections/{id}`). Ausente = resolucao da producao. */
1273
+ connection_id?: string | null;
1274
+ /** Ignora a triagem sem LLM (`full_review` com motivo `forced`). Default true. */
1275
+ force_review?: boolean;
1276
+ /** Quem pediu (so log/auditoria do lado do hubia). */
1277
+ requested_by?: { login_id: string; client_id?: string | null } | null;
1278
+ }
1279
+
1280
+ /** Resposta do dry-run. `report` vem serializado (datas em ISO). */
1281
+ export interface ICsqDryRunResult {
1282
+ /** `CsqRunResult.outcome` do pipeline (ex.: `evaluated`, `skipped_*`). */
1283
+ outcome: string;
1284
+ detail: string | null;
1285
+ evaluation_id: string | null;
1286
+ lead_id: string | null;
1287
+ channel_id: string;
1288
+ /** Laudo capturado (NAO gravado); null quando o pipeline nao chegou a montar. */
1289
+ report: Record<string, unknown> | null;
1290
+ detector: ICsqDetectorReport | null;
1291
+ model: string | null;
1292
+ llm_provider: string | null;
1293
+ llm_connection_id: string | null;
1294
+ llm_connection_source: CsqLlmConnectionSource | null;
1295
+ triage_mode: CsqTriageMode | null;
1296
+ cost_usd_est: number | null;
1297
+ duration_ms: number;
1298
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evo360-types",
3
- "version": "1.3.711",
3
+ "version": "1.3.715",
4
4
  "description": "HREVO360 Shared Types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",