@pinecall/protocol 0.1.0 → 0.3.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/fixtures/call-log-golden.json +1 -1
- package/dist/generated/events.d.ts +5 -2
- package/dist/generated/events.js +5 -2
- package/dist/generated/registry.d.ts +1 -0
- package/dist/generated/rest.d.ts +490 -1
- package/dist/generated/rest.js +326 -1
- package/dist/reduce.js +13 -1
- package/package.json +1 -1
|
@@ -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
|
]
|
|
@@ -52,8 +52,10 @@ export declare const AgentStateChangedSchema: z.ZodObject<{
|
|
|
52
52
|
}, z.core.$strict>;
|
|
53
53
|
export type AgentStateChanged = z.infer<typeof AgentStateChangedSchema>;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
55
|
+
* One delta of the reply the agent is giving, never the reply so far: in a voice call one word, as
|
|
56
|
+
* the voice plays it, with the seconds it was aligned to; in a written call one model token. The
|
|
57
|
+
* reply so far is every delta of the same speech_id since the last turn.agent, joined; turn.agent
|
|
58
|
+
* carries the whole reply and closes it. Interim entries are ephemeral.
|
|
57
59
|
*/
|
|
58
60
|
export declare const AgentTranscriptSchema: z.ZodObject<{
|
|
59
61
|
speech_id: z.ZodString;
|
|
@@ -84,6 +86,7 @@ export declare const CallDialingSchema: z.ZodObject<{
|
|
|
84
86
|
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
85
87
|
}, z.core.$strict>>;
|
|
86
88
|
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
89
|
+
asked_by: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
87
90
|
}, z.core.$strict>;
|
|
88
91
|
export type CallDialing = z.infer<typeof CallDialingSchema>;
|
|
89
92
|
/** The call is over. Nothing about the conversation follows; call.summary still does. */
|
package/dist/generated/events.js
CHANGED
|
@@ -32,8 +32,10 @@ export const AgentStateChangedSchema = z.strictObject({
|
|
|
32
32
|
state: AgentStateSchema,
|
|
33
33
|
});
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
35
|
+
* One delta of the reply the agent is giving, never the reply so far: in a voice call one word, as
|
|
36
|
+
* the voice plays it, with the seconds it was aligned to; in a written call one model token. The
|
|
37
|
+
* reply so far is every delta of the same speech_id since the last turn.agent, joined; turn.agent
|
|
38
|
+
* carries the whole reply and closes it. Interim entries are ephemeral.
|
|
37
39
|
*/
|
|
38
40
|
export const AgentTranscriptSchema = z.strictObject({
|
|
39
41
|
speech_id: z.string(),
|
|
@@ -53,6 +55,7 @@ export const CallDialingSchema = z.strictObject({
|
|
|
53
55
|
run: z.string().nullable().nullish(),
|
|
54
56
|
caller: ContactSchema.nullable(),
|
|
55
57
|
external_id: z.string().nullish(),
|
|
58
|
+
asked_by: z.string().nullish(),
|
|
56
59
|
});
|
|
57
60
|
/** The call is over. Nothing about the conversation follows; call.summary still does. */
|
|
58
61
|
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<{
|
package/dist/generated/rest.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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,413 @@ 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
|
+
* GET and PUT /v1/ops/mail: the SMTP account the BOX posts its letters through — what the operator
|
|
996
|
+
* stored, or the environment's two variables — how the last one went, and never the password. An
|
|
997
|
+
* org's own account (OrgMail) still wins over both.
|
|
998
|
+
*/
|
|
999
|
+
export declare const BoxMailSchema: z.ZodObject<{
|
|
1000
|
+
configured: z.ZodBoolean;
|
|
1001
|
+
source: z.ZodNullable<z.ZodString>;
|
|
1002
|
+
host: z.ZodNullable<z.ZodString>;
|
|
1003
|
+
port: z.ZodNullable<z.ZodInt>;
|
|
1004
|
+
security: z.ZodNullable<z.ZodString>;
|
|
1005
|
+
username: z.ZodNullable<z.ZodString>;
|
|
1006
|
+
from: z.ZodNullable<z.ZodString>;
|
|
1007
|
+
verified_at: z.ZodNullable<z.ZodString>;
|
|
1008
|
+
last_error: z.ZodNullable<z.ZodString>;
|
|
1009
|
+
}, z.core.$strict>;
|
|
1010
|
+
export type BoxMail = z.infer<typeof BoxMailSchema>;
|
|
1011
|
+
/**
|
|
1012
|
+
* GET and PUT /v1/ops/brand, and `brand` on GET /.well-known/pinecall: what this box's letters and
|
|
1013
|
+
* its sign-in page are called and painted with. Pinecall, its accent and no logo until the
|
|
1014
|
+
* operator says.
|
|
1015
|
+
*/
|
|
1016
|
+
export declare const BoxBrandSchema: z.ZodObject<{
|
|
1017
|
+
name: z.ZodString;
|
|
1018
|
+
logo_url: z.ZodNullable<z.ZodString>;
|
|
1019
|
+
accent: z.ZodString;
|
|
1020
|
+
}, z.core.$strict>;
|
|
1021
|
+
export type BoxBrand = z.infer<typeof BoxBrandSchema>;
|
|
1022
|
+
/**
|
|
1023
|
+
* PUT /v1/ops/brand, the body. A field left out keeps what it had; an empty string goes back to
|
|
1024
|
+
* the default — which for the logo is none at all, the only way to clear one.
|
|
1025
|
+
*/
|
|
1026
|
+
export declare const BoxBrandWantedSchema: z.ZodObject<{
|
|
1027
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
|
|
1028
|
+
logo_url: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
|
|
1029
|
+
accent: z.ZodOptional<z.ZodNullable<z.ZodNullable<z.ZodString>>>;
|
|
1030
|
+
}, z.core.$strict>;
|
|
1031
|
+
export type BoxBrandWanted = z.infer<typeof BoxBrandWantedSchema>;
|
|
1032
|
+
/**
|
|
1033
|
+
* One box-wide identity provider as the operator reads it: whether it is usable, the client this
|
|
1034
|
+
* gateway is at it, and the URI to register there. Never the secret.
|
|
1035
|
+
*/
|
|
1036
|
+
export declare const BoxProviderSchema: z.ZodObject<{
|
|
1037
|
+
configured: z.ZodBoolean;
|
|
1038
|
+
client_id: z.ZodNullable<z.ZodString>;
|
|
1039
|
+
redirect_uri: z.ZodString;
|
|
1040
|
+
}, z.core.$strict>;
|
|
1041
|
+
export type BoxProvider = z.infer<typeof BoxProviderSchema>;
|
|
1042
|
+
/**
|
|
1043
|
+
* GET /v1/ops/signin: every provider this box can offer every org's people, wired or not, one key
|
|
1044
|
+
* each. Only `google` today; a second is a key here and a row on the box.
|
|
1045
|
+
*/
|
|
1046
|
+
export declare const BoxSignInSchema: z.ZodObject<{
|
|
1047
|
+
google: z.ZodObject<{
|
|
1048
|
+
configured: z.ZodBoolean;
|
|
1049
|
+
client_id: z.ZodNullable<z.ZodString>;
|
|
1050
|
+
redirect_uri: z.ZodString;
|
|
1051
|
+
}, z.core.$strict>;
|
|
1052
|
+
}, z.core.$strict>;
|
|
1053
|
+
export type BoxSignIn = z.infer<typeof BoxSignInSchema>;
|
|
1054
|
+
/**
|
|
1055
|
+
* PUT /v1/ops/signin/google, the body: the OAuth client the operator made at Google for this
|
|
1056
|
+
* gateway. Replaced whole, the secret write-only; the issuer is Google's own and is not a field.
|
|
1057
|
+
*/
|
|
1058
|
+
export declare const BoxProviderWantedSchema: z.ZodObject<{
|
|
1059
|
+
client_id: z.ZodString;
|
|
1060
|
+
client_secret: z.ZodString;
|
|
1061
|
+
}, z.core.$strict>;
|
|
1062
|
+
export type BoxProviderWanted = z.infer<typeof BoxProviderWantedSchema>;
|
|
1063
|
+
/**
|
|
1064
|
+
* POST /v1/org/mail/test: one letter, waited for — the only door of this runtime that waits for a
|
|
1065
|
+
* mail server, because it is the one a person is watching.
|
|
1066
|
+
*/
|
|
1067
|
+
export declare const MailSentSchema: z.ZodObject<{
|
|
1068
|
+
sent: z.ZodBoolean;
|
|
1069
|
+
error: z.ZodNullable<z.ZodString>;
|
|
1070
|
+
}, z.core.$strict>;
|
|
1071
|
+
export type MailSent = z.infer<typeof MailSentSchema>;
|
|
1072
|
+
/**
|
|
1073
|
+
* One org a sign-in page may send somebody to, named — and nothing about whether anybody answers
|
|
1074
|
+
* to the address that asked.
|
|
1075
|
+
*/
|
|
1076
|
+
export declare const SsoOrgSchema: z.ZodObject<{
|
|
1077
|
+
org: z.ZodString;
|
|
1078
|
+
slug: z.ZodString;
|
|
1079
|
+
name: z.ZodString;
|
|
1080
|
+
}, z.core.$strict>;
|
|
1081
|
+
export type SsoOrg = z.infer<typeof SsoOrgSchema>;
|
|
1082
|
+
/**
|
|
1083
|
+
* POST /v1/login/sso/discover: the orgs whose domains match an address's and that wired a
|
|
1084
|
+
* provider. Empty is the answer for a domain nobody wired, and for a box that keeps no provider at
|
|
1085
|
+
* all.
|
|
1086
|
+
*/
|
|
1087
|
+
export declare const SsoDiscoverySchema: z.ZodObject<{
|
|
1088
|
+
orgs: z.ZodArray<z.ZodObject<{
|
|
1089
|
+
org: z.ZodString;
|
|
1090
|
+
slug: z.ZodString;
|
|
1091
|
+
name: z.ZodString;
|
|
1092
|
+
}, z.core.$strict>>;
|
|
1093
|
+
}, z.core.$strict>;
|
|
1094
|
+
export type SsoDiscovery = z.infer<typeof SsoDiscoverySchema>;
|
|
655
1095
|
/** One corner of a world holding an agent: the member whose it is, named so a person can read it. */
|
|
656
1096
|
export declare const LineHolderSchema: z.ZodObject<{
|
|
657
1097
|
holder: z.ZodNullable<z.ZodString>;
|
|
@@ -1029,3 +1469,52 @@ export declare const RememberedSchema: z.ZodObject<{
|
|
|
1029
1469
|
took_ms: z.ZodNumber;
|
|
1030
1470
|
}, z.core.$strict>;
|
|
1031
1471
|
export type Remembered = z.infer<typeof RememberedSchema>;
|
|
1472
|
+
/**
|
|
1473
|
+
* POST /v1/agents/{slug}/dial, the answer: the call a dial became, accepted before the far end has
|
|
1474
|
+
* heard anything ring.
|
|
1475
|
+
*/
|
|
1476
|
+
export declare const DialledSchema: z.ZodObject<{
|
|
1477
|
+
call: z.ZodString;
|
|
1478
|
+
agent: z.ZodString;
|
|
1479
|
+
to: z.ZodString;
|
|
1480
|
+
from: z.ZodString;
|
|
1481
|
+
env: z.ZodEnum<{
|
|
1482
|
+
production: "production";
|
|
1483
|
+
sandbox: "sandbox";
|
|
1484
|
+
}>;
|
|
1485
|
+
}, z.core.$strict>;
|
|
1486
|
+
export type Dialled = z.infer<typeof DialledSchema>;
|
|
1487
|
+
/** GET /v1/carrier/outbound, the guards: what this org may dial and how often. */
|
|
1488
|
+
export declare const DialGuardsSchema: z.ZodObject<{
|
|
1489
|
+
dial_anywhere: z.ZodBoolean;
|
|
1490
|
+
per_minute: z.ZodInt;
|
|
1491
|
+
per_day: z.ZodInt;
|
|
1492
|
+
max_duration_s: z.ZodInt;
|
|
1493
|
+
}, z.core.$strict>;
|
|
1494
|
+
export type DialGuards = z.infer<typeof DialGuardsSchema>;
|
|
1495
|
+
/**
|
|
1496
|
+
* GET /v1/carrier/outbound, the answer: whether this org can place a call yet, and what is
|
|
1497
|
+
* missing.
|
|
1498
|
+
*/
|
|
1499
|
+
export declare const CarrierOutboundSchema: z.ZodObject<{
|
|
1500
|
+
ready: z.ZodBoolean;
|
|
1501
|
+
kind: z.ZodNullable<z.ZodString>;
|
|
1502
|
+
from_numbers: z.ZodArray<z.ZodString>;
|
|
1503
|
+
steps_missing: z.ZodArray<z.ZodString>;
|
|
1504
|
+
guards: z.ZodObject<{
|
|
1505
|
+
dial_anywhere: z.ZodBoolean;
|
|
1506
|
+
per_minute: z.ZodInt;
|
|
1507
|
+
per_day: z.ZodInt;
|
|
1508
|
+
max_duration_s: z.ZodInt;
|
|
1509
|
+
}, z.core.$strict>;
|
|
1510
|
+
}, z.core.$strict>;
|
|
1511
|
+
export type CarrierOutbound = z.infer<typeof CarrierOutboundSchema>;
|
|
1512
|
+
/** POST /v1/carrier/outbound, the answer: the plan, and whether it was carried out. */
|
|
1513
|
+
export declare const OutboundProvisionedSchema: z.ZodObject<{
|
|
1514
|
+
steps: z.ZodArray<z.ZodString>;
|
|
1515
|
+
dry_run: z.ZodBoolean;
|
|
1516
|
+
ready: z.ZodBoolean;
|
|
1517
|
+
trunk: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1518
|
+
address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1519
|
+
}, z.core.$strict>;
|
|
1520
|
+
export type OutboundProvisioned = z.infer<typeof OutboundProvisionedSchema>;
|
package/dist/generated/rest.js
CHANGED
|
@@ -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,282 @@ 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
|
-
/**
|
|
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
|
+
* GET and PUT /v1/ops/mail: the SMTP account the BOX posts its letters through — what the operator
|
|
246
|
+
* stored, or the environment's two variables — how the last one went, and never the password. An
|
|
247
|
+
* org's own account (OrgMail) still wins over both.
|
|
248
|
+
*/
|
|
249
|
+
export const BoxMailSchema = z.strictObject({
|
|
250
|
+
configured: z.boolean(),
|
|
251
|
+
source: z.string().nullable(),
|
|
252
|
+
host: z.string().nullable(),
|
|
253
|
+
port: z.int().nullable(),
|
|
254
|
+
security: z.string().nullable(),
|
|
255
|
+
username: z.string().nullable(),
|
|
256
|
+
from: z.string().nullable(),
|
|
257
|
+
verified_at: z.string().nullable(),
|
|
258
|
+
last_error: z.string().nullable(),
|
|
259
|
+
});
|
|
260
|
+
/**
|
|
261
|
+
* GET and PUT /v1/ops/brand, and `brand` on GET /.well-known/pinecall: what this box's letters and
|
|
262
|
+
* its sign-in page are called and painted with. Pinecall, its accent and no logo until the
|
|
263
|
+
* operator says.
|
|
264
|
+
*/
|
|
265
|
+
export const BoxBrandSchema = z.strictObject({
|
|
266
|
+
name: z.string(),
|
|
267
|
+
logo_url: z.string().nullable(),
|
|
268
|
+
accent: z.string(),
|
|
269
|
+
});
|
|
270
|
+
/**
|
|
271
|
+
* PUT /v1/ops/brand, the body. A field left out keeps what it had; an empty string goes back to
|
|
272
|
+
* the default — which for the logo is none at all, the only way to clear one.
|
|
273
|
+
*/
|
|
274
|
+
export const BoxBrandWantedSchema = z.strictObject({
|
|
275
|
+
name: z.string().nullable().nullish(),
|
|
276
|
+
logo_url: z.string().nullable().nullish(),
|
|
277
|
+
accent: z.string().nullable().nullish(),
|
|
278
|
+
});
|
|
279
|
+
/**
|
|
280
|
+
* One box-wide identity provider as the operator reads it: whether it is usable, the client this
|
|
281
|
+
* gateway is at it, and the URI to register there. Never the secret.
|
|
282
|
+
*/
|
|
283
|
+
export const BoxProviderSchema = z.strictObject({
|
|
284
|
+
configured: z.boolean(),
|
|
285
|
+
client_id: z.string().nullable(),
|
|
286
|
+
redirect_uri: z.string(),
|
|
287
|
+
});
|
|
288
|
+
/**
|
|
289
|
+
* GET /v1/ops/signin: every provider this box can offer every org's people, wired or not, one key
|
|
290
|
+
* each. Only `google` today; a second is a key here and a row on the box.
|
|
291
|
+
*/
|
|
292
|
+
export const BoxSignInSchema = z.strictObject({
|
|
293
|
+
google: BoxProviderSchema,
|
|
294
|
+
});
|
|
295
|
+
/**
|
|
296
|
+
* PUT /v1/ops/signin/google, the body: the OAuth client the operator made at Google for this
|
|
297
|
+
* gateway. Replaced whole, the secret write-only; the issuer is Google's own and is not a field.
|
|
298
|
+
*/
|
|
299
|
+
export const BoxProviderWantedSchema = z.strictObject({
|
|
300
|
+
client_id: z.string(),
|
|
301
|
+
client_secret: z.string(),
|
|
302
|
+
});
|
|
303
|
+
/**
|
|
304
|
+
* POST /v1/org/mail/test: one letter, waited for — the only door of this runtime that waits for a
|
|
305
|
+
* mail server, because it is the one a person is watching.
|
|
306
|
+
*/
|
|
307
|
+
export const MailSentSchema = z.strictObject({
|
|
308
|
+
sent: z.boolean(),
|
|
309
|
+
error: z.string().nullable(),
|
|
310
|
+
});
|
|
311
|
+
/**
|
|
312
|
+
* One org a sign-in page may send somebody to, named — and nothing about whether anybody answers
|
|
313
|
+
* to the address that asked.
|
|
314
|
+
*/
|
|
315
|
+
export const SsoOrgSchema = z.strictObject({
|
|
316
|
+
org: z.string(),
|
|
317
|
+
slug: z.string(),
|
|
318
|
+
name: z.string(),
|
|
319
|
+
});
|
|
320
|
+
/**
|
|
321
|
+
* POST /v1/login/sso/discover: the orgs whose domains match an address's and that wired a
|
|
322
|
+
* provider. Empty is the answer for a domain nobody wired, and for a box that keeps no provider at
|
|
323
|
+
* all.
|
|
324
|
+
*/
|
|
325
|
+
export const SsoDiscoverySchema = z.strictObject({
|
|
326
|
+
orgs: z.array(SsoOrgSchema),
|
|
39
327
|
});
|
|
40
328
|
/** One corner of a world holding an agent: the member whose it is, named so a person can read it. */
|
|
41
329
|
export const LineHolderSchema = z.strictObject({
|
|
@@ -289,3 +577,40 @@ export const RememberedSchema = z.strictObject({
|
|
|
289
577
|
ops: z.int(),
|
|
290
578
|
took_ms: z.number(),
|
|
291
579
|
});
|
|
580
|
+
/**
|
|
581
|
+
* POST /v1/agents/{slug}/dial, the answer: the call a dial became, accepted before the far end has
|
|
582
|
+
* heard anything ring.
|
|
583
|
+
*/
|
|
584
|
+
export const DialledSchema = z.strictObject({
|
|
585
|
+
call: z.string(),
|
|
586
|
+
agent: z.string(),
|
|
587
|
+
to: z.string(),
|
|
588
|
+
from: z.string(),
|
|
589
|
+
env: EnvSchema,
|
|
590
|
+
});
|
|
591
|
+
/** GET /v1/carrier/outbound, the guards: what this org may dial and how often. */
|
|
592
|
+
export const DialGuardsSchema = z.strictObject({
|
|
593
|
+
dial_anywhere: z.boolean(),
|
|
594
|
+
per_minute: z.int(),
|
|
595
|
+
per_day: z.int(),
|
|
596
|
+
max_duration_s: z.int(),
|
|
597
|
+
});
|
|
598
|
+
/**
|
|
599
|
+
* GET /v1/carrier/outbound, the answer: whether this org can place a call yet, and what is
|
|
600
|
+
* missing.
|
|
601
|
+
*/
|
|
602
|
+
export const CarrierOutboundSchema = z.strictObject({
|
|
603
|
+
ready: z.boolean(),
|
|
604
|
+
kind: z.string().nullable(),
|
|
605
|
+
from_numbers: z.array(z.string()),
|
|
606
|
+
steps_missing: z.array(z.string()),
|
|
607
|
+
guards: DialGuardsSchema,
|
|
608
|
+
});
|
|
609
|
+
/** POST /v1/carrier/outbound, the answer: the plan, and whether it was carried out. */
|
|
610
|
+
export const OutboundProvisionedSchema = z.strictObject({
|
|
611
|
+
steps: z.array(z.string()),
|
|
612
|
+
dry_run: z.boolean(),
|
|
613
|
+
ready: z.boolean(),
|
|
614
|
+
trunk: z.string().nullish(),
|
|
615
|
+
address: z.string().nullish(),
|
|
616
|
+
});
|
package/dist/reduce.js
CHANGED
|
@@ -151,7 +151,8 @@ function applyEvent(state, entry, event) {
|
|
|
151
151
|
state.live.user = event.data.final ? null : event.data.text;
|
|
152
152
|
return;
|
|
153
153
|
case "agent.transcript":
|
|
154
|
-
|
|
154
|
+
// A delta, not the reply so far: one word of a spoken reply, one token of a written one.
|
|
155
|
+
state.live.agent = event.data.final ? null : saidSoFar(state.live.agent, event.data);
|
|
155
156
|
return;
|
|
156
157
|
case "turn.user":
|
|
157
158
|
state.turns.push({ role: "user", ...event.data });
|
|
@@ -350,3 +351,14 @@ function lastIndex(items, matches) {
|
|
|
350
351
|
}
|
|
351
352
|
return -1;
|
|
352
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* The reply in flight with one more delta. A word the voice aligned arrives bare and is set a
|
|
356
|
+
* space apart; a token of a written reply carries its own spacing, and a space glued between
|
|
357
|
+
* "clean" and "ing" would be a word nobody said.
|
|
358
|
+
*/
|
|
359
|
+
function saidSoFar(soFar, delta) {
|
|
360
|
+
if (soFar === null || soFar === "")
|
|
361
|
+
return delta.text;
|
|
362
|
+
const apart = /\s$/.test(soFar) || /^\s/.test(delta.text);
|
|
363
|
+
return delta.start != null && !apart ? `${soFar} ${delta.text}` : `${soFar}${delta.text}`;
|
|
364
|
+
}
|
package/package.json
CHANGED