@pinecall/protocol 0.1.0 → 0.2.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.
@@ -122,6 +122,6 @@
122
122
  {"seq": 122, "ts": 1786537552.4, "call": "CA_8f4a2c", "agent": "clinica-norte", "type": "call.ended", "ephemeral": false, "data": {"reason": "caller_hung_up", "ended_by": "caller", "ended_at": 1786537552.4, "duration_s": 51.988}},
123
123
  {"seq": 123, "ts": 1786537552.81, "call": "CA_8f4a2c", "agent": "clinica-norte", "type": "memory.ops", "ephemeral": false, "data": {"ops": [{"op": "remember", "contact": "ct_7d1e", "facts": [{"id": "mem_03", "text": "Cita de revisión con la Dra. Vidal el 2026-08-13 a las 09:30 (BK-5521)", "source": "CA_8f4a2c"}], "took_ms": 410}]}},
124
124
  {"seq": 124, "ts": 1786537553.46, "call": "CA_8f4a2c", "agent": "clinica-norte", "type": "call.summary", "ephemeral": false, "data": {"reason": "caller_hung_up", "outcome": "booked BK-5521: revisión Dra. Vidal, jueves 13 a las 09:30", "duration_s": 51.988, "turns": 11, "usage": [{"type": "llm_usage", "provider": "anthropic", "model": "claude-haiku-4-5", "input_tokens": 14963, "input_cached_tokens": 13145, "input_cache_creation_tokens": 562, "input_audio_tokens": 0, "input_cached_audio_tokens": 0, "input_text_tokens": 0, "input_cached_text_tokens": 0, "input_image_tokens": 0, "input_cached_image_tokens": 0, "output_tokens": 281, "output_audio_tokens": 0, "output_text_tokens": 0, "output_reasoning_tokens": 0, "session_duration": 0.0}, {"type": "tts_usage", "provider": "elevenlabs", "model": "eleven_flash_v2_5", "input_tokens": 0, "output_tokens": 0, "characters_count": 397, "audio_duration": 25.6}, {"type": "stt_usage", "provider": "soniox", "model": "stt-rt-v5", "input_tokens": 0, "output_tokens": 0, "audio_duration": 12.1}, {"type": "interruption_usage", "provider": "livekit", "model": "adaptive", "total_requests": 12}, {"type": "eot_usage", "provider": "livekit", "model": "turn-detector-v1", "total_requests": 5}], "cost": {"eur": 0.022937, "rate": {"currency": "EUR", "usd_to_eur": 0.92, "as_of": "2026-08-12"}, "rows": [{"provider": "anthropic", "model": "claude-haiku-4-5", "unit": "input_tokens", "quantity": 1256, "unit_price_usd": 1e-06, "eur": 0.001156}, {"provider": "anthropic", "model": "claude-haiku-4-5", "unit": "cached_input_tokens", "quantity": 13145, "unit_price_usd": 1e-07, "eur": 0.001209}, {"provider": "anthropic", "model": "claude-haiku-4-5", "unit": "cache_creation_tokens", "quantity": 562, "unit_price_usd": 1.25e-06, "eur": 0.000646}, {"provider": "anthropic", "model": "claude-haiku-4-5", "unit": "output_tokens", "quantity": 281, "unit_price_usd": 5e-06, "eur": 0.001293}, {"provider": "elevenlabs", "model": "eleven_flash_v2_5", "unit": "characters", "quantity": 397, "unit_price_usd": 5e-05, "eur": 0.018262}, {"provider": "soniox", "model": "stt-rt-v5", "unit": "audio_seconds", "quantity": 12.1, "unit_price_usd": 3.33e-05, "eur": 0.000371}], "unpriced": [{"provider": "livekit", "model": "adaptive"}, {"provider": "livekit", "model": "turn-detector-v1"}]}, "recording": "recordings/2026/08/12/CA_8f4a2c.ogg"}},
125
- {"seq": 125, "ts": 1786537553.102, "call": "CA_8f4a2c", "agent": "clinica-norte", "type": "call.score", "ephemeral": false, "data": {"passed": false, "judges": [{"name": "consent", "verdict": "broken", "criteria": "Every irreversible tool call in this conversation ran after a confirm.granted for the same tool call and the same audience.", "reason": "book_slot ran at seq 79, before its confirm.granted at seq 93", "evidence": {"seqs": [79, 93], "said": "Sí, confirmo."}}], "panel": ["consent", "grounded"], "judge_calls": 0}},
125
+ {"seq": 125, "ts": 1786537553.102, "call": "CA_8f4a2c", "agent": "clinica-norte", "type": "call.score", "ephemeral": false, "data": {"passed": false, "judges": [{"name": "consent", "verdict": "broken", "criteria": "Every irreversible tool call in this conversation ran after a confirm.granted for the same tool call and the same audience.", "reason": "book_slot ran at seq 79, before its confirm.granted at seq 93", "evidence": {"seqs": [79, 93], "said": "Sí, confirmo."}}], "panel": ["consent", "grounded", "promises"], "judge_calls": 0}},
126
126
  {"seq": 125, "ts": 1786537553.461, "call": "CA_8f4a2c", "agent": "clinica-norte", "type": "log.caught_up", "ephemeral": true, "data": {"seq": 125}}
127
127
  ]
@@ -84,6 +84,7 @@ export declare const CallDialingSchema: z.ZodObject<{
84
84
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
85
85
  }, z.core.$strict>>;
86
86
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
+ asked_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
88
  }, z.core.$strict>;
88
89
  export type CallDialing = z.infer<typeof CallDialingSchema>;
89
90
  /** The call is over. Nothing about the conversation follows; call.summary still does. */
@@ -53,6 +53,7 @@ export const CallDialingSchema = z.strictObject({
53
53
  run: z.string().nullable().nullish(),
54
54
  caller: ContactSchema.nullable(),
55
55
  external_id: z.string().nullish(),
56
+ asked_by: z.string().nullish(),
56
57
  });
57
58
  /** The call is over. Nothing about the conversation follows; call.summary still does. */
58
59
  export const CallEndedSchema = z.strictObject({
@@ -61,6 +61,7 @@ export declare const EVENT_SCHEMAS: {
61
61
  external_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
62
62
  }, import("zod/v4/core").$strict>>;
63
63
  external_id: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
64
+ asked_by: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
64
65
  }, import("zod/v4/core").$strict>;
65
66
  readonly "call.ended": import("zod").ZodObject<{
66
67
  reason: import("zod").ZodEnum<{
@@ -494,6 +494,28 @@ export declare const LogPageSchema: z.ZodObject<{
494
494
  next: z.ZodNullable<z.ZodInt>;
495
495
  }, z.core.$strict>;
496
496
  export type LogPage = z.infer<typeof LogPageSchema>;
497
+ /**
498
+ * One call's call.score as a list draws it: how many judges held of how many answered, and why the
499
+ * first one that broke did.
500
+ */
501
+ export declare const SessionScoreSchema: z.ZodObject<{
502
+ held: z.ZodInt;
503
+ judged: z.ZodInt;
504
+ passed: z.ZodBoolean;
505
+ reason: z.ZodNullable<z.ZodString>;
506
+ }, z.core.$strict>;
507
+ export type SessionScore = z.infer<typeof SessionScoreSchema>;
508
+ /**
509
+ * escalated: a person took part — a transfer, a supervisor taking the line, saying something, or
510
+ * ending the call. low_score: a judge answered broken. promise: the promises judge found the agent
511
+ * committing the business to something no tool call records.
512
+ */
513
+ export declare const SessionFlagSchema: z.ZodEnum<{
514
+ promise: "promise";
515
+ escalated: "escalated";
516
+ low_score: "low_score";
517
+ }>;
518
+ export type SessionFlag = z.infer<typeof SessionFlagSchema>;
497
519
  /** One call as a list draws it: which call, how far the log got, and the state's own fields. */
498
520
  export declare const SessionLineSchema: z.ZodObject<{
499
521
  call: z.ZodString;
@@ -570,9 +592,23 @@ export declare const SessionLineSchema: z.ZodObject<{
570
592
  model: z.ZodString;
571
593
  }, z.core.$strict>>;
572
594
  }, z.core.$strict>>;
595
+ score: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
596
+ held: z.ZodInt;
597
+ judged: z.ZodInt;
598
+ passed: z.ZodBoolean;
599
+ reason: z.ZodNullable<z.ZodString>;
600
+ }, z.core.$strict>>>>;
601
+ flags: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
602
+ promise: "promise";
603
+ escalated: "escalated";
604
+ low_score: "low_score";
605
+ }>>>>;
573
606
  }, z.core.$strict>;
574
607
  export type SessionLine = z.infer<typeof SessionLineSchema>;
575
- /** GET /v1/agents/{slug}/sessions: which calls that agent handled, newest first. */
608
+ /**
609
+ * GET /v1/agents/{slug}/sessions and GET /v1/sessions: the calls that match, newest first, a page
610
+ * at a time.
611
+ */
576
612
  export declare const SessionListSchema: z.ZodObject<{
577
613
  calls: z.ZodArray<z.ZodObject<{
578
614
  call: z.ZodString;
@@ -649,9 +685,344 @@ export declare const SessionListSchema: z.ZodObject<{
649
685
  model: z.ZodString;
650
686
  }, z.core.$strict>>;
651
687
  }, z.core.$strict>>;
688
+ score: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodObject<{
689
+ held: z.ZodInt;
690
+ judged: z.ZodInt;
691
+ passed: z.ZodBoolean;
692
+ reason: z.ZodNullable<z.ZodString>;
693
+ }, z.core.$strict>>>>;
694
+ flags: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
695
+ promise: "promise";
696
+ escalated: "escalated";
697
+ low_score: "low_score";
698
+ }>>>>;
652
699
  }, z.core.$strict>>;
700
+ total: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodInt>>>;
701
+ next: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
653
702
  }, z.core.$strict>;
654
703
  export type SessionList = z.infer<typeof SessionListSchema>;
704
+ /** How many calls started on the day, and on the day before it. */
705
+ export declare const InsightsConversationsSchema: z.ZodObject<{
706
+ today: z.ZodInt;
707
+ yesterday: z.ZodInt;
708
+ }, z.core.$strict>;
709
+ export type InsightsConversations = z.infer<typeof InsightsConversationsSchema>;
710
+ /** The day's calls by the door they came in by. */
711
+ export declare const InsightsChannelsSchema: z.ZodObject<{
712
+ phone: z.ZodInt;
713
+ web: z.ZodInt;
714
+ whatsapp: z.ZodInt;
715
+ }, z.core.$strict>;
716
+ export type InsightsChannels = z.infer<typeof InsightsChannelsSchema>;
717
+ /** One agent's day. */
718
+ export declare const InsightsAgentSchema: z.ZodObject<{
719
+ slug: z.ZodString;
720
+ today: z.ZodInt;
721
+ score: z.ZodNullable<z.ZodNumber>;
722
+ }, z.core.$strict>;
723
+ export type InsightsAgent = z.infer<typeof InsightsAgentSchema>;
724
+ /** What the org may spend in a month and what it has spent so far, both worlds together. */
725
+ export declare const InsightsBudgetSchema: z.ZodObject<{
726
+ limit_eur: z.ZodNullable<z.ZodNumber>;
727
+ spent_eur_month: z.ZodNumber;
728
+ }, z.core.$strict>;
729
+ export type InsightsBudget = z.infer<typeof InsightsBudgetSchema>;
730
+ /**
731
+ * GET /v1/insights: one day of the key's world and corner at a glance, counted off the call index
732
+ * and never off a log.
733
+ */
734
+ export declare const InsightsSchema: z.ZodObject<{
735
+ day: z.ZodString;
736
+ timezone: z.ZodString;
737
+ conversations: z.ZodObject<{
738
+ today: z.ZodInt;
739
+ yesterday: z.ZodInt;
740
+ }, z.core.$strict>;
741
+ resolved_rate: z.ZodNullable<z.ZodNumber>;
742
+ median_e2e_s: z.ZodNullable<z.ZodNumber>;
743
+ spend_eur: z.ZodNumber;
744
+ channels: z.ZodObject<{
745
+ phone: z.ZodInt;
746
+ web: z.ZodInt;
747
+ whatsapp: z.ZodInt;
748
+ }, z.core.$strict>;
749
+ sessions_total: z.ZodInt;
750
+ live: z.ZodInt;
751
+ agents: z.ZodArray<z.ZodObject<{
752
+ slug: z.ZodString;
753
+ today: z.ZodInt;
754
+ score: z.ZodNullable<z.ZodNumber>;
755
+ }, z.core.$strict>>;
756
+ budget: z.ZodObject<{
757
+ limit_eur: z.ZodNullable<z.ZodNumber>;
758
+ spent_eur_month: z.ZodNumber;
759
+ }, z.core.$strict>;
760
+ }, z.core.$strict>;
761
+ export type Insights = z.infer<typeof InsightsSchema>;
762
+ /**
763
+ * GET and PUT /v1/org/judging: whether the org's calls are judged at hang-up, and what judging one
764
+ * may spend on a model.
765
+ */
766
+ export declare const JudgingSchema: z.ZodObject<{
767
+ on: z.ZodBoolean;
768
+ ceiling_eur: z.ZodNullable<z.ZodNumber>;
769
+ }, z.core.$strict>;
770
+ export type Judging = z.infer<typeof JudgingSchema>;
771
+ /** PUT /v1/org/judging, the body. */
772
+ export declare const JudgingWantedSchema: z.ZodObject<{
773
+ on: z.ZodBoolean;
774
+ }, z.core.$strict>;
775
+ export type JudgingWanted = z.infer<typeof JudgingWantedSchema>;
776
+ /**
777
+ * in: the contact wrote it. out: the agent, or a person as the agent, did. call: a spoken call,
778
+ * drawn as one pill.
779
+ */
780
+ export declare const ThreadKindSchema: z.ZodEnum<{
781
+ call: "call";
782
+ out: "out";
783
+ in: "in";
784
+ }>;
785
+ export type ThreadKind = z.infer<typeof ThreadKindSchema>;
786
+ /** The newest thing on a contact's thread. */
787
+ export declare const ThreadLastSchema: z.ZodObject<{
788
+ text: z.ZodNullable<z.ZodString>;
789
+ at: z.ZodNumber;
790
+ kind: z.ZodEnum<{
791
+ call: "call";
792
+ out: "out";
793
+ in: "in";
794
+ }>;
795
+ }, z.core.$strict>;
796
+ export type ThreadLast = z.infer<typeof ThreadLastSchema>;
797
+ /** One contact of an agent's inbox: every call of theirs, folded into one line. */
798
+ export declare const ThreadLineSchema: z.ZodObject<{
799
+ contact: z.ZodString;
800
+ name: z.ZodNullable<z.ZodString>;
801
+ channel_last: z.ZodEnum<{
802
+ phone: "phone";
803
+ web: "web";
804
+ whatsapp: "whatsapp";
805
+ }>;
806
+ last: z.ZodObject<{
807
+ text: z.ZodNullable<z.ZodString>;
808
+ at: z.ZodNumber;
809
+ kind: z.ZodEnum<{
810
+ call: "call";
811
+ out: "out";
812
+ in: "in";
813
+ }>;
814
+ }, z.core.$strict>;
815
+ unread: z.ZodInt;
816
+ calls: z.ZodInt;
817
+ }, z.core.$strict>;
818
+ export type ThreadLine = z.infer<typeof ThreadLineSchema>;
819
+ /** GET /v1/agents/{slug}/threads: the agent's contacts, the newest thread first. */
820
+ export declare const ThreadListSchema: z.ZodObject<{
821
+ threads: z.ZodArray<z.ZodObject<{
822
+ contact: z.ZodString;
823
+ name: z.ZodNullable<z.ZodString>;
824
+ channel_last: z.ZodEnum<{
825
+ phone: "phone";
826
+ web: "web";
827
+ whatsapp: "whatsapp";
828
+ }>;
829
+ last: z.ZodObject<{
830
+ text: z.ZodNullable<z.ZodString>;
831
+ at: z.ZodNumber;
832
+ kind: z.ZodEnum<{
833
+ call: "call";
834
+ out: "out";
835
+ in: "in";
836
+ }>;
837
+ }, z.core.$strict>;
838
+ unread: z.ZodInt;
839
+ calls: z.ZodInt;
840
+ }, z.core.$strict>>;
841
+ next: z.ZodNullable<z.ZodString>;
842
+ }, z.core.$strict>;
843
+ export type ThreadList = z.infer<typeof ThreadListSchema>;
844
+ /** One message of a thread, or one spoken call drawn as a pill. */
845
+ export declare const ThreadMessageSchema: z.ZodObject<{
846
+ kind: z.ZodEnum<{
847
+ call: "call";
848
+ out: "out";
849
+ in: "in";
850
+ }>;
851
+ text: z.ZodNullable<z.ZodString>;
852
+ at: z.ZodNumber;
853
+ call: z.ZodString;
854
+ channel: z.ZodEnum<{
855
+ phone: "phone";
856
+ web: "web";
857
+ whatsapp: "whatsapp";
858
+ }>;
859
+ duration_s: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodNumber>>>;
860
+ answered: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
861
+ }, z.core.$strict>;
862
+ export type ThreadMessage = z.infer<typeof ThreadMessageSchema>;
863
+ /** GET /v1/agents/{slug}/threads/{contact}: every call of one contact, merged, oldest first. */
864
+ export declare const ThreadSchema: z.ZodObject<{
865
+ contact: z.ZodString;
866
+ name: z.ZodNullable<z.ZodString>;
867
+ messages: z.ZodArray<z.ZodObject<{
868
+ kind: z.ZodEnum<{
869
+ call: "call";
870
+ out: "out";
871
+ in: "in";
872
+ }>;
873
+ text: z.ZodNullable<z.ZodString>;
874
+ at: z.ZodNumber;
875
+ call: z.ZodString;
876
+ channel: z.ZodEnum<{
877
+ phone: "phone";
878
+ web: "web";
879
+ whatsapp: "whatsapp";
880
+ }>;
881
+ duration_s: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodNumber>>>;
882
+ answered: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
883
+ }, z.core.$strict>>;
884
+ }, z.core.$strict>;
885
+ export type Thread = z.infer<typeof ThreadSchema>;
886
+ /** POST /v1/agents/{slug}/threads/{contact}/messages, the body. */
887
+ export declare const ThreadSaySchema: z.ZodObject<{
888
+ text: z.ZodString;
889
+ }, z.core.$strict>;
890
+ export type ThreadSay = z.infer<typeof ThreadSaySchema>;
891
+ /**
892
+ * POST /v1/agents/{slug}/threads/{contact}/messages, the answer: the call it was said on. The
893
+ * turn.agent it lands as is on that call's log.
894
+ */
895
+ export declare const ThreadSaidSchema: z.ZodObject<{
896
+ contact: z.ZodString;
897
+ call: z.ZodString;
898
+ }, z.core.$strict>;
899
+ export type ThreadSaid = z.infer<typeof ThreadSaidSchema>;
900
+ /** One current fact memory holds, across the contacts an agent's calls taught. */
901
+ export declare const AgentFactSchema: z.ZodObject<{
902
+ id: z.ZodString;
903
+ contact: z.ZodString;
904
+ text: z.ZodString;
905
+ category: z.ZodNullable<z.ZodString>;
906
+ written_at: z.ZodNumber;
907
+ }, z.core.$strict>;
908
+ export type AgentFact = z.infer<typeof AgentFactSchema>;
909
+ /** GET /v1/agents/{slug}/memory: the current facts the agent's calls taught, newest first. */
910
+ export declare const AgentMemorySchema: z.ZodObject<{
911
+ facts: z.ZodArray<z.ZodObject<{
912
+ id: z.ZodString;
913
+ contact: z.ZodString;
914
+ text: z.ZodString;
915
+ category: z.ZodNullable<z.ZodString>;
916
+ written_at: z.ZodNumber;
917
+ }, z.core.$strict>>;
918
+ next: z.ZodNullable<z.ZodString>;
919
+ }, z.core.$strict>;
920
+ export type AgentMemory = z.infer<typeof AgentMemorySchema>;
921
+ /**
922
+ * GET and PUT /v1/agents/{slug}/widget: how the widget presents this agent, kept per org, world
923
+ * and agent. PUT takes the whole set.
924
+ */
925
+ export declare const WidgetSettingsSchema: z.ZodObject<{
926
+ title: z.ZodNullable<z.ZodString>;
927
+ tagline: z.ZodNullable<z.ZodString>;
928
+ greeting: z.ZodNullable<z.ZodString>;
929
+ accent: z.ZodNullable<z.ZodString>;
930
+ autostart: z.ZodBoolean;
931
+ }, z.core.$strict>;
932
+ export type WidgetSettings = z.infer<typeof WidgetSettingsSchema>;
933
+ /**
934
+ * GET and PUT /v1/org/sso: the OpenID Connect provider this org's people sign in at, and never the
935
+ * client secret it was wired with.
936
+ */
937
+ export declare const OrgSsoSchema: z.ZodObject<{
938
+ configured: z.ZodBoolean;
939
+ issuer: z.ZodNullable<z.ZodString>;
940
+ client_id: z.ZodNullable<z.ZodString>;
941
+ domains: z.ZodArray<z.ZodString>;
942
+ role: z.ZodNullable<z.ZodString>;
943
+ required: z.ZodBoolean;
944
+ redirect_uri: z.ZodString;
945
+ }, z.core.$strict>;
946
+ export type OrgSso = z.infer<typeof OrgSsoSchema>;
947
+ /**
948
+ * PUT /v1/org/sso, the body. The configuration is replaced whole, the client secret included: it
949
+ * is write-only, so a change of anything else carries it again.
950
+ */
951
+ export declare const OrgSsoWantedSchema: z.ZodObject<{
952
+ issuer: z.ZodString;
953
+ client_id: z.ZodString;
954
+ client_secret: z.ZodString;
955
+ domains: z.ZodArray<z.ZodString>;
956
+ role: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
957
+ required: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
958
+ }, z.core.$strict>;
959
+ export type OrgSsoWanted = z.infer<typeof OrgSsoWantedSchema>;
960
+ /**
961
+ * GET and PUT /v1/org/mail: the SMTP account this org's letters go out through, how the last one
962
+ * went, and never the password it was wired with. An org that wired none sends through the box's
963
+ * own mail, or through nothing.
964
+ */
965
+ export declare const OrgMailSchema: z.ZodObject<{
966
+ configured: z.ZodBoolean;
967
+ host: z.ZodNullable<z.ZodString>;
968
+ port: z.ZodNullable<z.ZodInt>;
969
+ security: z.ZodNullable<z.ZodString>;
970
+ username: z.ZodNullable<z.ZodString>;
971
+ from: z.ZodNullable<z.ZodString>;
972
+ verified_at: z.ZodNullable<z.ZodString>;
973
+ last_error: z.ZodNullable<z.ZodString>;
974
+ }, z.core.$strict>;
975
+ export type OrgMail = z.infer<typeof OrgMailSchema>;
976
+ /**
977
+ * PUT /v1/org/mail, the body. The account is replaced whole, the password included: it is write-
978
+ * only, so a change of anything else carries it again — and the standing is reset with it, since
979
+ * what a server said about the old password is not news about a new one.
980
+ */
981
+ export declare const OrgMailWantedSchema: z.ZodObject<{
982
+ host: z.ZodString;
983
+ port: z.ZodInt;
984
+ security: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
985
+ starttls: "starttls";
986
+ tls: "tls";
987
+ none: "none";
988
+ }>>>;
989
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
990
+ password: z.ZodOptional<z.ZodNullable<z.ZodString>>;
991
+ from: z.ZodString;
992
+ }, z.core.$strict>;
993
+ export type OrgMailWanted = z.infer<typeof OrgMailWantedSchema>;
994
+ /**
995
+ * POST /v1/org/mail/test: one letter, waited for — the only door of this runtime that waits for a
996
+ * mail server, because it is the one a person is watching.
997
+ */
998
+ export declare const MailSentSchema: z.ZodObject<{
999
+ sent: z.ZodBoolean;
1000
+ error: z.ZodNullable<z.ZodString>;
1001
+ }, z.core.$strict>;
1002
+ export type MailSent = z.infer<typeof MailSentSchema>;
1003
+ /**
1004
+ * One org a sign-in page may send somebody to, named — and nothing about whether anybody answers
1005
+ * to the address that asked.
1006
+ */
1007
+ export declare const SsoOrgSchema: z.ZodObject<{
1008
+ org: z.ZodString;
1009
+ slug: z.ZodString;
1010
+ name: z.ZodString;
1011
+ }, z.core.$strict>;
1012
+ export type SsoOrg = z.infer<typeof SsoOrgSchema>;
1013
+ /**
1014
+ * POST /v1/login/sso/discover: the orgs whose domains match an address's and that wired a
1015
+ * provider. Empty is the answer for a domain nobody wired, and for a box that keeps no provider at
1016
+ * all.
1017
+ */
1018
+ export declare const SsoDiscoverySchema: z.ZodObject<{
1019
+ orgs: z.ZodArray<z.ZodObject<{
1020
+ org: z.ZodString;
1021
+ slug: z.ZodString;
1022
+ name: z.ZodString;
1023
+ }, z.core.$strict>>;
1024
+ }, z.core.$strict>;
1025
+ export type SsoDiscovery = z.infer<typeof SsoDiscoverySchema>;
655
1026
  /** One corner of a world holding an agent: the member whose it is, named so a person can read it. */
656
1027
  export declare const LineHolderSchema: z.ZodObject<{
657
1028
  holder: z.ZodNullable<z.ZodString>;
@@ -1029,3 +1400,54 @@ export declare const RememberedSchema: z.ZodObject<{
1029
1400
  took_ms: z.ZodNumber;
1030
1401
  }, z.core.$strict>;
1031
1402
  export type Remembered = z.infer<typeof RememberedSchema>;
1403
+ /**
1404
+ * POST /v1/agents/{slug}/dial, the answer: the call a dial became, accepted before the far end has
1405
+ * heard anything ring.
1406
+ */
1407
+ export declare const DialledSchema: z.ZodObject<{
1408
+ call: z.ZodString;
1409
+ agent: z.ZodString;
1410
+ to: z.ZodString;
1411
+ from: z.ZodString;
1412
+ env: z.ZodEnum<{
1413
+ production: "production";
1414
+ sandbox: "sandbox";
1415
+ }>;
1416
+ }, z.core.$strict>;
1417
+ export type Dialled = z.infer<typeof DialledSchema>;
1418
+ /** GET /v1/carrier/outbound, the guards: what this org may dial and how often. */
1419
+ export declare const DialGuardsSchema: z.ZodObject<{
1420
+ dial_anywhere: z.ZodBoolean;
1421
+ per_minute: z.ZodInt;
1422
+ per_day: z.ZodInt;
1423
+ countries: z.ZodArray<z.ZodString>;
1424
+ max_duration_s: z.ZodInt;
1425
+ }, z.core.$strict>;
1426
+ export type DialGuards = z.infer<typeof DialGuardsSchema>;
1427
+ /**
1428
+ * GET /v1/carrier/outbound, the answer: whether this org can place a call yet, and what is
1429
+ * missing.
1430
+ */
1431
+ export declare const CarrierOutboundSchema: z.ZodObject<{
1432
+ ready: z.ZodBoolean;
1433
+ kind: z.ZodNullable<z.ZodString>;
1434
+ from_numbers: z.ZodArray<z.ZodString>;
1435
+ steps_missing: z.ZodArray<z.ZodString>;
1436
+ guards: z.ZodObject<{
1437
+ dial_anywhere: z.ZodBoolean;
1438
+ per_minute: z.ZodInt;
1439
+ per_day: z.ZodInt;
1440
+ countries: z.ZodArray<z.ZodString>;
1441
+ max_duration_s: z.ZodInt;
1442
+ }, z.core.$strict>;
1443
+ }, z.core.$strict>;
1444
+ export type CarrierOutbound = z.infer<typeof CarrierOutboundSchema>;
1445
+ /** POST /v1/carrier/outbound, the answer: the plan, and whether it was carried out. */
1446
+ export declare const OutboundProvisionedSchema: z.ZodObject<{
1447
+ steps: z.ZodArray<z.ZodString>;
1448
+ dry_run: z.ZodBoolean;
1449
+ ready: z.ZodBoolean;
1450
+ trunk: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1451
+ address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1452
+ }, z.core.$strict>;
1453
+ export type OutboundProvisioned = z.infer<typeof OutboundProvisionedSchema>;
@@ -15,6 +15,22 @@ export const LogPageSchema = z.strictObject({
15
15
  live: z.boolean(),
16
16
  next: z.int().nullable(),
17
17
  });
18
+ /**
19
+ * One call's call.score as a list draws it: how many judges held of how many answered, and why the
20
+ * first one that broke did.
21
+ */
22
+ export const SessionScoreSchema = z.strictObject({
23
+ held: z.int(),
24
+ judged: z.int(),
25
+ passed: z.boolean(),
26
+ reason: z.string().nullable(),
27
+ });
28
+ /**
29
+ * escalated: a person took part — a transfer, a supervisor taking the line, saying something, or
30
+ * ending the call. low_score: a judge answered broken. promise: the promises judge found the agent
31
+ * committing the business to something no tool call records.
32
+ */
33
+ export const SessionFlagSchema = z.enum(["escalated", "low_score", "promise"]);
18
34
  /** One call as a list draws it: which call, how far the log got, and the state's own fields. */
19
35
  export const SessionLineSchema = z.strictObject({
20
36
  call: z.string(),
@@ -32,10 +48,223 @@ export const SessionLineSchema = z.strictObject({
32
48
  end_reason: EndReasonSchema.nullable(),
33
49
  outcome: z.string().nullable(),
34
50
  cost: CostSchema.nullable(),
51
+ score: SessionScoreSchema.nullable().nullish(),
52
+ flags: z.array(SessionFlagSchema).nullish(),
35
53
  });
36
- /** GET /v1/agents/{slug}/sessions: which calls that agent handled, newest first. */
54
+ /**
55
+ * GET /v1/agents/{slug}/sessions and GET /v1/sessions: the calls that match, newest first, a page
56
+ * at a time.
57
+ */
37
58
  export const SessionListSchema = z.strictObject({
38
59
  calls: z.array(SessionLineSchema),
60
+ total: z.int().nullable().nullish(),
61
+ next: z.string().nullable().nullish(),
62
+ });
63
+ /** How many calls started on the day, and on the day before it. */
64
+ export const InsightsConversationsSchema = z.strictObject({
65
+ today: z.int(),
66
+ yesterday: z.int(),
67
+ });
68
+ /** The day's calls by the door they came in by. */
69
+ export const InsightsChannelsSchema = z.strictObject({
70
+ phone: z.int(),
71
+ web: z.int(),
72
+ whatsapp: z.int(),
73
+ });
74
+ /** One agent's day. */
75
+ export const InsightsAgentSchema = z.strictObject({
76
+ slug: z.string(),
77
+ today: z.int(),
78
+ score: z.number().nullable(),
79
+ });
80
+ /** What the org may spend in a month and what it has spent so far, both worlds together. */
81
+ export const InsightsBudgetSchema = z.strictObject({
82
+ limit_eur: z.number().nullable(),
83
+ spent_eur_month: z.number(),
84
+ });
85
+ /**
86
+ * GET /v1/insights: one day of the key's world and corner at a glance, counted off the call index
87
+ * and never off a log.
88
+ */
89
+ export const InsightsSchema = z.strictObject({
90
+ day: z.string(),
91
+ timezone: z.string(),
92
+ conversations: InsightsConversationsSchema,
93
+ resolved_rate: z.number().nullable(),
94
+ median_e2e_s: z.number().nullable(),
95
+ spend_eur: z.number(),
96
+ channels: InsightsChannelsSchema,
97
+ sessions_total: z.int(),
98
+ live: z.int(),
99
+ agents: z.array(InsightsAgentSchema),
100
+ budget: InsightsBudgetSchema,
101
+ });
102
+ /**
103
+ * GET and PUT /v1/org/judging: whether the org's calls are judged at hang-up, and what judging one
104
+ * may spend on a model.
105
+ */
106
+ export const JudgingSchema = z.strictObject({
107
+ on: z.boolean(),
108
+ ceiling_eur: z.number().nullable(),
109
+ });
110
+ /** PUT /v1/org/judging, the body. */
111
+ export const JudgingWantedSchema = z.strictObject({
112
+ on: z.boolean(),
113
+ });
114
+ /**
115
+ * in: the contact wrote it. out: the agent, or a person as the agent, did. call: a spoken call,
116
+ * drawn as one pill.
117
+ */
118
+ export const ThreadKindSchema = z.enum(["in", "out", "call"]);
119
+ /** The newest thing on a contact's thread. */
120
+ export const ThreadLastSchema = z.strictObject({
121
+ text: z.string().nullable(),
122
+ at: z.number(),
123
+ kind: ThreadKindSchema,
124
+ });
125
+ /** One contact of an agent's inbox: every call of theirs, folded into one line. */
126
+ export const ThreadLineSchema = z.strictObject({
127
+ contact: z.string(),
128
+ name: z.string().nullable(),
129
+ channel_last: ChannelSchema,
130
+ last: ThreadLastSchema,
131
+ unread: z.int(),
132
+ calls: z.int(),
133
+ });
134
+ /** GET /v1/agents/{slug}/threads: the agent's contacts, the newest thread first. */
135
+ export const ThreadListSchema = z.strictObject({
136
+ threads: z.array(ThreadLineSchema),
137
+ next: z.string().nullable(),
138
+ });
139
+ /** One message of a thread, or one spoken call drawn as a pill. */
140
+ export const ThreadMessageSchema = z.strictObject({
141
+ kind: ThreadKindSchema,
142
+ text: z.string().nullable(),
143
+ at: z.number(),
144
+ call: z.string(),
145
+ channel: ChannelSchema,
146
+ duration_s: z.number().nullable().nullish(),
147
+ answered: z.boolean().nullish(),
148
+ });
149
+ /** GET /v1/agents/{slug}/threads/{contact}: every call of one contact, merged, oldest first. */
150
+ export const ThreadSchema = z.strictObject({
151
+ contact: z.string(),
152
+ name: z.string().nullable(),
153
+ messages: z.array(ThreadMessageSchema),
154
+ });
155
+ /** POST /v1/agents/{slug}/threads/{contact}/messages, the body. */
156
+ export const ThreadSaySchema = z.strictObject({
157
+ text: z.string(),
158
+ });
159
+ /**
160
+ * POST /v1/agents/{slug}/threads/{contact}/messages, the answer: the call it was said on. The
161
+ * turn.agent it lands as is on that call's log.
162
+ */
163
+ export const ThreadSaidSchema = z.strictObject({
164
+ contact: z.string(),
165
+ call: z.string(),
166
+ });
167
+ /** One current fact memory holds, across the contacts an agent's calls taught. */
168
+ export const AgentFactSchema = z.strictObject({
169
+ id: z.string(),
170
+ contact: z.string(),
171
+ text: z.string(),
172
+ category: z.string().nullable(),
173
+ written_at: z.number(),
174
+ });
175
+ /** GET /v1/agents/{slug}/memory: the current facts the agent's calls taught, newest first. */
176
+ export const AgentMemorySchema = z.strictObject({
177
+ facts: z.array(AgentFactSchema),
178
+ next: z.string().nullable(),
179
+ });
180
+ /**
181
+ * GET and PUT /v1/agents/{slug}/widget: how the widget presents this agent, kept per org, world
182
+ * and agent. PUT takes the whole set.
183
+ */
184
+ export const WidgetSettingsSchema = z.strictObject({
185
+ title: z.string().nullable(),
186
+ tagline: z.string().nullable(),
187
+ greeting: z.string().nullable(),
188
+ accent: z.string().nullable(),
189
+ autostart: z.boolean(),
190
+ });
191
+ /**
192
+ * GET and PUT /v1/org/sso: the OpenID Connect provider this org's people sign in at, and never the
193
+ * client secret it was wired with.
194
+ */
195
+ export const OrgSsoSchema = z.strictObject({
196
+ configured: z.boolean(),
197
+ issuer: z.string().nullable(),
198
+ client_id: z.string().nullable(),
199
+ domains: z.array(z.string()),
200
+ role: z.string().nullable(),
201
+ required: z.boolean(),
202
+ redirect_uri: z.string(),
203
+ });
204
+ /**
205
+ * PUT /v1/org/sso, the body. The configuration is replaced whole, the client secret included: it
206
+ * is write-only, so a change of anything else carries it again.
207
+ */
208
+ export const OrgSsoWantedSchema = z.strictObject({
209
+ issuer: z.string(),
210
+ client_id: z.string(),
211
+ client_secret: z.string(),
212
+ domains: z.array(z.string()),
213
+ role: z.string().nullable().nullish(),
214
+ required: z.boolean().nullish(),
215
+ });
216
+ /**
217
+ * GET and PUT /v1/org/mail: the SMTP account this org's letters go out through, how the last one
218
+ * went, and never the password it was wired with. An org that wired none sends through the box's
219
+ * own mail, or through nothing.
220
+ */
221
+ export const OrgMailSchema = z.strictObject({
222
+ configured: z.boolean(),
223
+ host: z.string().nullable(),
224
+ port: z.int().nullable(),
225
+ security: z.string().nullable(),
226
+ username: z.string().nullable(),
227
+ from: z.string().nullable(),
228
+ verified_at: z.string().nullable(),
229
+ last_error: z.string().nullable(),
230
+ });
231
+ /**
232
+ * PUT /v1/org/mail, the body. The account is replaced whole, the password included: it is write-
233
+ * only, so a change of anything else carries it again — and the standing is reset with it, since
234
+ * what a server said about the old password is not news about a new one.
235
+ */
236
+ export const OrgMailWantedSchema = z.strictObject({
237
+ host: z.string(),
238
+ port: z.int(),
239
+ security: z.enum(["starttls", "tls", "none"]).nullish(),
240
+ username: z.string().nullish(),
241
+ password: z.string().nullish(),
242
+ from: z.string(),
243
+ });
244
+ /**
245
+ * POST /v1/org/mail/test: one letter, waited for — the only door of this runtime that waits for a
246
+ * mail server, because it is the one a person is watching.
247
+ */
248
+ export const MailSentSchema = z.strictObject({
249
+ sent: z.boolean(),
250
+ error: z.string().nullable(),
251
+ });
252
+ /**
253
+ * One org a sign-in page may send somebody to, named — and nothing about whether anybody answers
254
+ * to the address that asked.
255
+ */
256
+ export const SsoOrgSchema = z.strictObject({
257
+ org: z.string(),
258
+ slug: z.string(),
259
+ name: z.string(),
260
+ });
261
+ /**
262
+ * POST /v1/login/sso/discover: the orgs whose domains match an address's and that wired a
263
+ * provider. Empty is the answer for a domain nobody wired, and for a box that keeps no provider at
264
+ * all.
265
+ */
266
+ export const SsoDiscoverySchema = z.strictObject({
267
+ orgs: z.array(SsoOrgSchema),
39
268
  });
40
269
  /** One corner of a world holding an agent: the member whose it is, named so a person can read it. */
41
270
  export const LineHolderSchema = z.strictObject({
@@ -289,3 +518,41 @@ export const RememberedSchema = z.strictObject({
289
518
  ops: z.int(),
290
519
  took_ms: z.number(),
291
520
  });
521
+ /**
522
+ * POST /v1/agents/{slug}/dial, the answer: the call a dial became, accepted before the far end has
523
+ * heard anything ring.
524
+ */
525
+ export const DialledSchema = z.strictObject({
526
+ call: z.string(),
527
+ agent: z.string(),
528
+ to: z.string(),
529
+ from: z.string(),
530
+ env: EnvSchema,
531
+ });
532
+ /** GET /v1/carrier/outbound, the guards: what this org may dial and how often. */
533
+ export const DialGuardsSchema = z.strictObject({
534
+ dial_anywhere: z.boolean(),
535
+ per_minute: z.int(),
536
+ per_day: z.int(),
537
+ countries: z.array(z.string()),
538
+ max_duration_s: z.int(),
539
+ });
540
+ /**
541
+ * GET /v1/carrier/outbound, the answer: whether this org can place a call yet, and what is
542
+ * missing.
543
+ */
544
+ export const CarrierOutboundSchema = z.strictObject({
545
+ ready: z.boolean(),
546
+ kind: z.string().nullable(),
547
+ from_numbers: z.array(z.string()),
548
+ steps_missing: z.array(z.string()),
549
+ guards: DialGuardsSchema,
550
+ });
551
+ /** POST /v1/carrier/outbound, the answer: the plan, and whether it was carried out. */
552
+ export const OutboundProvisionedSchema = z.strictObject({
553
+ steps: z.array(z.string()),
554
+ dry_run: z.boolean(),
555
+ ready: z.boolean(),
556
+ trunk: z.string().nullish(),
557
+ address: z.string().nullish(),
558
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinecall/protocol",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The Pinecall wire: zod schemas and types generated from the protocol schema, and the log reducer",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Pinecall <hello@pinecall.io>",