@adminide-stack/clock-tik-browser 12.0.34 → 12.0.35
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/lib/pages/Home/__tests__/calls.test.d.ts +2 -0
- package/lib/pages/Home/__tests__/calls.test.d.ts.map +1 -0
- package/lib/pages/Home/__tests__/queue.test.d.ts +2 -0
- package/lib/pages/Home/__tests__/queue.test.d.ts.map +1 -0
- package/lib/pages/Home/__tests__/results.test.d.ts +2 -0
- package/lib/pages/Home/__tests__/results.test.d.ts.map +1 -0
- package/lib/pages/Home/__tests__/surfaces.test.d.ts +2 -0
- package/lib/pages/Home/__tests__/surfaces.test.d.ts.map +1 -0
- package/lib/pages/Home/chat/CallsCard.d.ts +22 -0
- package/lib/pages/Home/chat/CallsCard.d.ts.map +1 -0
- package/lib/pages/Home/chat/CallsCard.js +352 -0
- package/lib/pages/Home/chat/CallsCard.js.map +1 -0
- package/lib/pages/Home/chat/ChoresChat.d.ts.map +1 -1
- package/lib/pages/Home/chat/ChoresChat.js +293 -58
- package/lib/pages/Home/chat/ChoresChat.js.map +1 -1
- package/lib/pages/Home/chat/ChoresPanel.d.ts.map +1 -1
- package/lib/pages/Home/chat/ChoresPanel.js +4 -2
- package/lib/pages/Home/chat/ChoresPanel.js.map +1 -1
- package/lib/pages/Home/chat/ResultCards.d.ts +16 -0
- package/lib/pages/Home/chat/ResultCards.d.ts.map +1 -0
- package/lib/pages/Home/chat/ResultCards.js +509 -0
- package/lib/pages/Home/chat/ResultCards.js.map +1 -0
- package/lib/pages/Home/chat/calls.d.ts +124 -0
- package/lib/pages/Home/chat/calls.d.ts.map +1 -0
- package/lib/pages/Home/chat/calls.js +278 -0
- package/lib/pages/Home/chat/calls.js.map +1 -0
- package/lib/pages/Home/chat/callsApi.d.ts +10 -0
- package/lib/pages/Home/chat/callsApi.d.ts.map +1 -0
- package/lib/pages/Home/chat/callsApi.js +31 -0
- package/lib/pages/Home/chat/callsApi.js.map +1 -0
- package/lib/pages/Home/chat/chatTheme.d.ts.map +1 -1
- package/lib/pages/Home/chat/chatTheme.js +746 -1
- package/lib/pages/Home/chat/chatTheme.js.map +1 -1
- package/lib/pages/Home/chat/chores.d.ts +10 -3
- package/lib/pages/Home/chat/chores.d.ts.map +1 -1
- package/lib/pages/Home/chat/chores.js +22 -5
- package/lib/pages/Home/chat/chores.js.map +1 -1
- package/lib/pages/Home/chat/queue.d.ts +94 -0
- package/lib/pages/Home/chat/queue.d.ts.map +1 -0
- package/lib/pages/Home/chat/queue.js +88 -0
- package/lib/pages/Home/chat/queue.js.map +1 -0
- package/lib/pages/Home/chat/results.d.ts +207 -0
- package/lib/pages/Home/chat/results.d.ts.map +1 -0
- package/lib/pages/Home/chat/results.js +823 -0
- package/lib/pages/Home/chat/results.js.map +1 -0
- package/lib/pages/Home/chat/stop.d.ts +7 -6
- package/lib/pages/Home/chat/stop.d.ts.map +1 -1
- package/lib/pages/Home/chat/stop.js +7 -6
- package/lib/pages/Home/chat/stop.js.map +1 -1
- package/lib/pages/Home/chat/surfaces.d.ts +34 -0
- package/lib/pages/Home/chat/surfaces.d.ts.map +1 -0
- package/lib/pages/Home/chat/surfaces.js +165 -0
- package/lib/pages/Home/chat/surfaces.js.map +1 -0
- package/lib/pages/Home/chat/thread.d.ts +7 -3
- package/lib/pages/Home/chat/thread.d.ts.map +1 -1
- package/lib/pages/Home/chat/thread.js +11 -3
- package/lib/pages/Home/chat/thread.js.map +1 -1
- package/lib/pages/Home/chat/useCallLog.d.ts +17 -0
- package/lib/pages/Home/chat/useCallLog.d.ts.map +1 -0
- package/lib/pages/Home/chat/useCallLog.js +85 -0
- package/lib/pages/Home/chat/useCallLog.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lucy's phone calls, as the chat shows them: a card under the reply that placed them (CallsCard),
|
|
3
|
+
* live while a call goes on. The calls are the person's call log on the `yantra-phone-calls`
|
|
4
|
+
* connector, the one the Phone Calls surface reads (yantra-surface packages/phone-calls: these are
|
|
5
|
+
* its wire shapes, its words, and its call ids). Run on Lucy's agent like any connector (callsApi).
|
|
6
|
+
*
|
|
7
|
+
* A marker names no call. The calls a card shows are the ones that started while its turn ran:
|
|
8
|
+
* Lucy places them from inside the turn, and the connector answers at once with the call going out.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CALLS_CONNECTOR = "yantra-phone-calls";
|
|
11
|
+
export declare const CALLS_ACTIONS: {
|
|
12
|
+
readonly LOG: "YANTRA_PHONE_CALLS_LOG";
|
|
13
|
+
readonly GET: "YANTRA_PHONE_CALLS_GET";
|
|
14
|
+
readonly END: "YANTRA_PHONE_CALLS_END";
|
|
15
|
+
};
|
|
16
|
+
/** Going on, how it ended, or `ended` when no outcome came back. */
|
|
17
|
+
export type CallStatus = 'live' | 'answered' | 'voicemail' | 'busy' | 'no-answer' | 'failed' | 'ended';
|
|
18
|
+
export interface CallRow {
|
|
19
|
+
id: string;
|
|
20
|
+
businessName: string;
|
|
21
|
+
/** As people read it (`+1 415-555-0123`). */
|
|
22
|
+
to: string;
|
|
23
|
+
/** What the call is for. */
|
|
24
|
+
goal: string;
|
|
25
|
+
/** The voice's name on the call. */
|
|
26
|
+
assistantName: string;
|
|
27
|
+
/** Unix ms, the connector's clock. */
|
|
28
|
+
startedAt: number;
|
|
29
|
+
status: CallStatus;
|
|
30
|
+
durationSecs?: number;
|
|
31
|
+
/** What came of it, in the voice's words. */
|
|
32
|
+
summary?: string;
|
|
33
|
+
/** Why it did not go through, in the phone service's words. */
|
|
34
|
+
reason?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TranscriptLine {
|
|
37
|
+
speaker: 'assistant' | 'them';
|
|
38
|
+
text: string;
|
|
39
|
+
}
|
|
40
|
+
/** The connector's `{ successful, data, error }` -> its data, or a thrown error with its message. */
|
|
41
|
+
export declare function unwrapConnector(result: unknown, label: string): Record<string, unknown>;
|
|
42
|
+
/** A row of the log, as the connector writes it (snake_case); null for one that is not a call. */
|
|
43
|
+
export declare function toCallRow(raw: unknown): CallRow | null;
|
|
44
|
+
export interface CallLog {
|
|
45
|
+
calls: CallRow[];
|
|
46
|
+
/** False where no call is kept once it ends: only the ones going on are listed. */
|
|
47
|
+
kept: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** `YANTRA_PHONE_CALLS_LOG`'s data -> its calls, and whether ended ones are kept. */
|
|
50
|
+
export declare function readCallLog(data: Record<string, unknown>): CallLog;
|
|
51
|
+
/** `YANTRA_PHONE_CALLS_GET`'s data -> what was said, in order. */
|
|
52
|
+
export declare function readTranscript(data: Record<string, unknown>): TranscriptLine[];
|
|
53
|
+
/** How far the browser's clock may be off the connector's. */
|
|
54
|
+
export declare const CLOCK_SLACK_MS = 60000;
|
|
55
|
+
/** The longest a call goes on: an hour, when it waits on hold or the person joins (LiveKit ends it). */
|
|
56
|
+
export declare const LONGEST_CALL_MS: number;
|
|
57
|
+
/** A message of the thread, as the cards need it. */
|
|
58
|
+
export interface CardMessage {
|
|
59
|
+
id: string;
|
|
60
|
+
role: string;
|
|
61
|
+
/** ISO time. */
|
|
62
|
+
createdAt?: string;
|
|
63
|
+
/** The turn it belongs to: its chore task. */
|
|
64
|
+
task?: string;
|
|
65
|
+
/** It names the phone-calls surface. */
|
|
66
|
+
callsMarker: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** A turn's times, from its chore task (useChores). */
|
|
69
|
+
export interface TurnTimes {
|
|
70
|
+
/** When it was sent. */
|
|
71
|
+
createdAt: number;
|
|
72
|
+
/** When it ended, once it is over. */
|
|
73
|
+
endedAt?: number;
|
|
74
|
+
running: boolean;
|
|
75
|
+
/** Past this, a turn still running has stopped responding. */
|
|
76
|
+
deadlineAt?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface CallsCardPlace {
|
|
79
|
+
/** The reply the card goes under. */
|
|
80
|
+
message: string;
|
|
81
|
+
/** Calls that started from here... */
|
|
82
|
+
from: number;
|
|
83
|
+
/** ...up to here (Unix ms, the browser's clock). NaN for a reply with no time. */
|
|
84
|
+
to: number;
|
|
85
|
+
/** Lucy may place more until then (Unix ms): her turn is running. 0 once it is over. */
|
|
86
|
+
openUntil: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Where the calls cards go, and when each card's calls started: under the first reply of a turn
|
|
90
|
+
* that names the phone-calls surface, one card per turn, for the calls placed while that turn ran.
|
|
91
|
+
*
|
|
92
|
+
* A turn runs from when the person sent it - or, sent while Lucy was on another, from when that
|
|
93
|
+
* one ended, since the agent runs one turn at a time - to its end. While it runs, or once its
|
|
94
|
+
* record is gone from this browser, it is given its whole budget, the next turn's start ending a
|
|
95
|
+
* gone one sooner. Between two turns the line falls halfway from one's end to the next one's
|
|
96
|
+
* start. The outer edges get a minute's slack for the two clocks.
|
|
97
|
+
*/
|
|
98
|
+
export declare function placeCallsCards(messages: readonly CardMessage[], turnTimes: (task: string) => TurnTimes | undefined, turnBudgetMs: number): CallsCardPlace[];
|
|
99
|
+
/**
|
|
100
|
+
* Each call under one card: the first in the thread whose turn it started in. While a turn runs, one
|
|
101
|
+
* sent meanwhile waits its turn, so a call in both windows is the earlier turn's. Under a card, the
|
|
102
|
+
* calls go in the order Lucy placed them.
|
|
103
|
+
*/
|
|
104
|
+
export declare function callsByCard(cards: readonly CallsCardPlace[], calls: readonly CallRow[]): Map<string, CallRow[]>;
|
|
105
|
+
/** Going on now: live in the log, and not past the longest a call can go on. */
|
|
106
|
+
export declare const isGoingOn: (call: CallRow, now: number) => boolean;
|
|
107
|
+
/** Whether the log is worth reading again soon: a card's call is going on, or its turn may place one. */
|
|
108
|
+
export declare function watchCalls(cards: readonly CallsCardPlace[], byCard: ReadonlyMap<string, readonly CallRow[]>, now: number): boolean;
|
|
109
|
+
export type CallTone = 'live' | 'success' | 'attention' | 'danger' | 'quiet';
|
|
110
|
+
export declare const callStatus: (status: CallStatus) => {
|
|
111
|
+
label: string;
|
|
112
|
+
tone: CallTone;
|
|
113
|
+
};
|
|
114
|
+
/** What came of the call, in a line: the summary, else why it did not happen. */
|
|
115
|
+
export declare function outcomeLine(call: CallRow): string;
|
|
116
|
+
/** Whether there was a conversation to read back. */
|
|
117
|
+
export declare const hasTranscript: (call: CallRow) => boolean;
|
|
118
|
+
/** `45 s`, `2 min`, `2 min 10 s`, `1 h 4 min`. */
|
|
119
|
+
export declare function formatDuration(secs: number | undefined): string | undefined;
|
|
120
|
+
/** A running call's clock: `0:42`, `12:05`, `1:02:09`. */
|
|
121
|
+
export declare function formatClock(ms: number): string;
|
|
122
|
+
/** The Phone Calls page (`origin`), opened at one call when its id is one; '' without an origin. */
|
|
123
|
+
export declare function callPageUrl(origin: string, callId?: string): string;
|
|
124
|
+
//# sourceMappingURL=calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../../src/pages/Home/chat/calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEvG,MAAM,WAAW,OAAO;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,MAAM,CAAC,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,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAS3E;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAO9C;AAKD,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUnE"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lucy's phone calls, as the chat shows them: a card under the reply that placed them (CallsCard),
|
|
3
|
+
* live while a call goes on. The calls are the person's call log on the `yantra-phone-calls`
|
|
4
|
+
* connector, the one the Phone Calls surface reads (yantra-surface packages/phone-calls: these are
|
|
5
|
+
* its wire shapes, its words, and its call ids). Run on Lucy's agent like any connector (callsApi).
|
|
6
|
+
*
|
|
7
|
+
* A marker names no call. The calls a card shows are the ones that started while its turn ran:
|
|
8
|
+
* Lucy places them from inside the turn, and the connector answers at once with the call going out.
|
|
9
|
+
*/
|
|
10
|
+
const CALLS_CONNECTOR = 'yantra-phone-calls';
|
|
11
|
+
const CALLS_ACTIONS = {
|
|
12
|
+
LOG: 'YANTRA_PHONE_CALLS_LOG',
|
|
13
|
+
GET: 'YANTRA_PHONE_CALLS_GET',
|
|
14
|
+
END: 'YANTRA_PHONE_CALLS_END'
|
|
15
|
+
};
|
|
16
|
+
/** The connector's `{ successful, data, error }` -> its data, or a thrown error with its message. */
|
|
17
|
+
function unwrapConnector(result, label) {
|
|
18
|
+
if (!result || typeof result !== 'object') return {};
|
|
19
|
+
const envelope = result;
|
|
20
|
+
if (!('successful' in envelope) && !('success' in envelope)) return result;
|
|
21
|
+
if (!(envelope.successful ?? envelope.success)) {
|
|
22
|
+
throw new Error(typeof envelope.error === 'string' && envelope.error ? envelope.error : `${label} failed`);
|
|
23
|
+
}
|
|
24
|
+
return envelope.data && typeof envelope.data === 'object' ? envelope.data : {};
|
|
25
|
+
}
|
|
26
|
+
const str = v => typeof v === 'string' && v.trim() ? v.trim() : undefined;
|
|
27
|
+
const STATUSES = new Set(['live', 'answered', 'voicemail', 'busy', 'no-answer', 'failed', 'ended']);
|
|
28
|
+
/** A row of the log, as the connector writes it (snake_case); null for one that is not a call. */
|
|
29
|
+
function toCallRow(raw) {
|
|
30
|
+
const r = raw ?? {};
|
|
31
|
+
const id = str(r.call_id);
|
|
32
|
+
const startedAt = Date.parse(str(r.started_at) ?? '');
|
|
33
|
+
if (!id || !Number.isFinite(startedAt)) return null;
|
|
34
|
+
const durationSecs = typeof r.duration_secs === 'number' && r.duration_secs > 0 ? r.duration_secs : undefined;
|
|
35
|
+
const summary = str(r.summary);
|
|
36
|
+
const reason = str(r.reason);
|
|
37
|
+
return {
|
|
38
|
+
id,
|
|
39
|
+
businessName: str(r.business_name) ?? 'the business',
|
|
40
|
+
to: str(r.to) ?? '',
|
|
41
|
+
goal: str(r.goal) ?? '',
|
|
42
|
+
assistantName: str(r.assistant_name) ?? 'Lucy',
|
|
43
|
+
startedAt,
|
|
44
|
+
status: STATUSES.has(r.status) ? r.status : 'ended',
|
|
45
|
+
...(durationSecs ? {
|
|
46
|
+
durationSecs
|
|
47
|
+
} : {}),
|
|
48
|
+
...(summary ? {
|
|
49
|
+
summary
|
|
50
|
+
} : {}),
|
|
51
|
+
...(reason ? {
|
|
52
|
+
reason
|
|
53
|
+
} : {})
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** `YANTRA_PHONE_CALLS_LOG`'s data -> its calls, and whether ended ones are kept. */
|
|
57
|
+
function readCallLog(data) {
|
|
58
|
+
const calls = (Array.isArray(data.calls) ? data.calls : []).flatMap(raw => {
|
|
59
|
+
const row = toCallRow(raw);
|
|
60
|
+
return row ? [row] : [];
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
calls,
|
|
64
|
+
kept: data.kept !== false
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** `YANTRA_PHONE_CALLS_GET`'s data -> what was said, in order. */
|
|
68
|
+
function readTranscript(data) {
|
|
69
|
+
return (Array.isArray(data.transcript) ? data.transcript : []).flatMap(line => {
|
|
70
|
+
const l = line ?? {};
|
|
71
|
+
const text = str(l.text);
|
|
72
|
+
return text ? [{
|
|
73
|
+
speaker: l.speaker === 'assistant' ? 'assistant' : 'them',
|
|
74
|
+
text
|
|
75
|
+
}] : [];
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// ---- Which calls go under which reply ----
|
|
79
|
+
/** How far the browser's clock may be off the connector's. */
|
|
80
|
+
const CLOCK_SLACK_MS = 60_000;
|
|
81
|
+
/** The longest a call goes on: an hour, when it waits on hold or the person joins (LiveKit ends it). */
|
|
82
|
+
const LONGEST_CALL_MS = 60 * 60_000;
|
|
83
|
+
/**
|
|
84
|
+
* Where the calls cards go, and when each card's calls started: under the first reply of a turn
|
|
85
|
+
* that names the phone-calls surface, one card per turn, for the calls placed while that turn ran.
|
|
86
|
+
*
|
|
87
|
+
* A turn runs from when the person sent it - or, sent while Lucy was on another, from when that
|
|
88
|
+
* one ended, since the agent runs one turn at a time - to its end. While it runs, or once its
|
|
89
|
+
* record is gone from this browser, it is given its whole budget, the next turn's start ending a
|
|
90
|
+
* gone one sooner. Between two turns the line falls halfway from one's end to the next one's
|
|
91
|
+
* start. The outer edges get a minute's slack for the two clocks.
|
|
92
|
+
*/
|
|
93
|
+
function placeCallsCards(messages, turnTimes, turnBudgetMs) {
|
|
94
|
+
// The thread's turns in order (a message of no turn is one of its own): when each went out,
|
|
95
|
+
// and the reply its card would go under.
|
|
96
|
+
const keys = [];
|
|
97
|
+
const sent = new Map();
|
|
98
|
+
for (const m of messages) {
|
|
99
|
+
const key = m.task || m.id;
|
|
100
|
+
let turn = sent.get(key);
|
|
101
|
+
if (!turn) {
|
|
102
|
+
turn = {
|
|
103
|
+
...(m.task ? {
|
|
104
|
+
task: m.task
|
|
105
|
+
} : {}),
|
|
106
|
+
at: NaN
|
|
107
|
+
};
|
|
108
|
+
sent.set(key, turn);
|
|
109
|
+
keys.push(key);
|
|
110
|
+
}
|
|
111
|
+
const at = Date.parse(m.createdAt ?? '');
|
|
112
|
+
if (Number.isFinite(at) && !(turn.at <= at)) turn.at = at;
|
|
113
|
+
if (m.role === 'assistant' && m.callsMarker && !turn.card) turn.card = m.id;
|
|
114
|
+
}
|
|
115
|
+
const turns = keys.map(key => {
|
|
116
|
+
const {
|
|
117
|
+
task,
|
|
118
|
+
at,
|
|
119
|
+
card
|
|
120
|
+
} = sent.get(key);
|
|
121
|
+
const times = task ? turnTimes(task) : undefined;
|
|
122
|
+
const start = times?.createdAt ?? at;
|
|
123
|
+
return {
|
|
124
|
+
start,
|
|
125
|
+
...(times && !times.running && times.endedAt ? {
|
|
126
|
+
end: times.endedAt
|
|
127
|
+
} : {}),
|
|
128
|
+
openUntil: times?.running ? times.deadlineAt ?? start + turnBudgetMs : 0,
|
|
129
|
+
...(card ? {
|
|
130
|
+
card
|
|
131
|
+
} : {})
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
const cards = [];
|
|
135
|
+
turns.forEach((turn, i) => {
|
|
136
|
+
if (!turn.card) return;
|
|
137
|
+
if (!Number.isFinite(turn.start)) {
|
|
138
|
+
cards.push({
|
|
139
|
+
message: turn.card,
|
|
140
|
+
from: NaN,
|
|
141
|
+
to: NaN,
|
|
142
|
+
openUntil: turn.openUntil
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const prev = turns[i - 1];
|
|
147
|
+
const next = turns[i + 1];
|
|
148
|
+
let begin = turn.start;
|
|
149
|
+
let from = turn.start - CLOCK_SLACK_MS;
|
|
150
|
+
if (prev?.end !== undefined) {
|
|
151
|
+
if (prev.end >= turn.start) {
|
|
152
|
+
begin = prev.end;
|
|
153
|
+
from = prev.end;
|
|
154
|
+
} else {
|
|
155
|
+
from = Math.max(from, (prev.end + turn.start) / 2);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
let to = turn.end !== undefined ? turn.end + CLOCK_SLACK_MS : begin + turnBudgetMs + CLOCK_SLACK_MS;
|
|
159
|
+
if (next && Number.isFinite(next.start)) {
|
|
160
|
+
if (turn.end !== undefined) {
|
|
161
|
+
to = Math.min(to, next.start > turn.end ? (turn.end + next.start) / 2 : turn.end);
|
|
162
|
+
} else if (!turn.openUntil) {
|
|
163
|
+
to = Math.min(to, next.start);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
cards.push({
|
|
167
|
+
message: turn.card,
|
|
168
|
+
from,
|
|
169
|
+
to,
|
|
170
|
+
openUntil: turn.openUntil
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return cards;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Each call under one card: the first in the thread whose turn it started in. While a turn runs, one
|
|
177
|
+
* sent meanwhile waits its turn, so a call in both windows is the earlier turn's. Under a card, the
|
|
178
|
+
* calls go in the order Lucy placed them.
|
|
179
|
+
*/
|
|
180
|
+
function callsByCard(cards, calls) {
|
|
181
|
+
const byCard = new Map(cards.map(card => [card.message, []]));
|
|
182
|
+
for (const call of [...calls].sort((a, b) => a.startedAt - b.startedAt)) {
|
|
183
|
+
const card = cards.find(c => call.startedAt >= c.from && call.startedAt < c.to);
|
|
184
|
+
if (card) byCard.get(card.message)?.push(call);
|
|
185
|
+
}
|
|
186
|
+
return byCard;
|
|
187
|
+
}
|
|
188
|
+
/** Going on now: live in the log, and not past the longest a call can go on. */
|
|
189
|
+
const isGoingOn = (call, now) => call.status === 'live' && now - call.startedAt < LONGEST_CALL_MS + CLOCK_SLACK_MS;
|
|
190
|
+
/** Whether the log is worth reading again soon: a card's call is going on, or its turn may place one. */
|
|
191
|
+
function watchCalls(cards, byCard, now) {
|
|
192
|
+
return cards.some(card => card.openUntil > now || (byCard.get(card.message) ?? []).some(call => isGoingOn(call, now)));
|
|
193
|
+
}
|
|
194
|
+
const STATUS = {
|
|
195
|
+
live: {
|
|
196
|
+
label: 'On the call',
|
|
197
|
+
tone: 'live'
|
|
198
|
+
},
|
|
199
|
+
answered: {
|
|
200
|
+
label: 'Answered',
|
|
201
|
+
tone: 'success'
|
|
202
|
+
},
|
|
203
|
+
voicemail: {
|
|
204
|
+
label: 'Voicemail',
|
|
205
|
+
tone: 'attention'
|
|
206
|
+
},
|
|
207
|
+
busy: {
|
|
208
|
+
label: 'Busy',
|
|
209
|
+
tone: 'attention'
|
|
210
|
+
},
|
|
211
|
+
'no-answer': {
|
|
212
|
+
label: 'No answer',
|
|
213
|
+
tone: 'attention'
|
|
214
|
+
},
|
|
215
|
+
failed: {
|
|
216
|
+
label: 'Did not go through',
|
|
217
|
+
tone: 'danger'
|
|
218
|
+
},
|
|
219
|
+
ended: {
|
|
220
|
+
label: 'No outcome',
|
|
221
|
+
tone: 'quiet'
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const callStatus = status => STATUS[status];
|
|
225
|
+
/** What came of the call, in a line: the summary, else why it did not happen. */
|
|
226
|
+
function outcomeLine(call) {
|
|
227
|
+
if (call.summary) return call.summary;
|
|
228
|
+
switch (call.status) {
|
|
229
|
+
case 'live':
|
|
230
|
+
return call.goal || 'Calling now.';
|
|
231
|
+
case 'voicemail':
|
|
232
|
+
return 'Reached voicemail; no message was left.';
|
|
233
|
+
case 'busy':
|
|
234
|
+
return 'The line was busy.';
|
|
235
|
+
case 'no-answer':
|
|
236
|
+
return 'Nobody answered.';
|
|
237
|
+
case 'failed':
|
|
238
|
+
return call.reason ? `The call did not go through (${call.reason}).` : 'The call did not go through.';
|
|
239
|
+
default:
|
|
240
|
+
return 'The call ended without an outcome.';
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** Whether there was a conversation to read back. */
|
|
244
|
+
const hasTranscript = call => call.status === 'answered' || call.status === 'voicemail' || call.status === 'ended';
|
|
245
|
+
/** `45 s`, `2 min`, `2 min 10 s`, `1 h 4 min`. */
|
|
246
|
+
function formatDuration(secs) {
|
|
247
|
+
if (typeof secs !== 'number' || !Number.isFinite(secs) || secs <= 0) return undefined;
|
|
248
|
+
const whole = Math.round(secs);
|
|
249
|
+
const hours = Math.floor(whole / 3600);
|
|
250
|
+
const minutes = Math.floor(whole % 3600 / 60);
|
|
251
|
+
const seconds = whole % 60;
|
|
252
|
+
if (hours) return minutes ? `${hours} h ${minutes} min` : `${hours} h`;
|
|
253
|
+
if (!minutes) return `${seconds} s`;
|
|
254
|
+
return seconds ? `${minutes} min ${seconds} s` : `${minutes} min`;
|
|
255
|
+
}
|
|
256
|
+
/** A running call's clock: `0:42`, `12:05`, `1:02:09`. */
|
|
257
|
+
function formatClock(ms) {
|
|
258
|
+
const total = Math.max(0, Math.floor(ms / 1000));
|
|
259
|
+
const h = Math.floor(total / 3600);
|
|
260
|
+
const m = Math.floor(total % 3600 / 60);
|
|
261
|
+
const s = total % 60;
|
|
262
|
+
const two = n => String(n).padStart(2, '0');
|
|
263
|
+
return h ? `${h}:${two(m)}:${two(s)}` : `${m}:${two(s)}`;
|
|
264
|
+
}
|
|
265
|
+
/** A call id as the connector makes them: the Phone Calls page ignores any other in `?call=`. */
|
|
266
|
+
const CALL_ID = /^[A-Za-z0-9]{8,64}$/;
|
|
267
|
+
/** The Phone Calls page (`origin`), opened at one call when its id is one; '' without an origin. */
|
|
268
|
+
function callPageUrl(origin, callId) {
|
|
269
|
+
if (!origin) return '';
|
|
270
|
+
try {
|
|
271
|
+
const url = new URL('/', origin);
|
|
272
|
+
if (url.protocol !== 'https:') return '';
|
|
273
|
+
if (callId && CALL_ID.test(callId)) url.searchParams.set('call', callId);
|
|
274
|
+
return url.toString();
|
|
275
|
+
} catch {
|
|
276
|
+
return '';
|
|
277
|
+
}
|
|
278
|
+
}export{CALLS_ACTIONS,CALLS_CONNECTOR,CLOCK_SLACK_MS,LONGEST_CALL_MS,callPageUrl,callStatus,callsByCard,formatClock,formatDuration,hasTranscript,isGoingOn,outcomeLine,placeCallsCards,readCallLog,readTranscript,toCallRow,unwrapConnector,watchCalls};//# sourceMappingURL=calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calls.js","sources":["../../../../src/pages/Home/chat/calls.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;AAQG;AAEI,MAAM,eAAe,GAAG;AAElB,MAAA,aAAa,GAAG;AACzB,EAAA,GAAA,EAAG,wBAA0B;AAC7B,EAAA,GAAA,EAAG,wBAA0B;AAC7B,EAAA,GAAA,EAAG;;AAgCP;AACgB,SAAA,eAAe,CAAC,MAAe,EAAE,KAAa,EAAA;AAC1D,EAAA,IAAA,CAAA,MAAW,IAAA,OAAW,MAAA,aAAmB,EAAA,OAAA,EAAA;AAAE,EAAA,MAAA,WAAU,MAAA;MAC/C,EAAA,YAAW,IAAA,QAAmB,CAAA,IAAA,EAAA,SAAA,IAAA,QAAA,CAAA,EAAA,OAAA,MAAA;AACpC,EAAA,IAAA,EAAI,QAAc,CAAA,UAAY,IAAA,QAAK,CAAC,OAAC,CAAA,EAAS;AAAe,IAAA,MAAA,IAAA,aAAyC,QAAA,CAAA,KAAA,KAAA,QAAA,IAAA,QAAA,CAAA,KAAA,GAAA,QAAA,CAAA,KAAA,GAAA,CAAA,EAAA,KAAA,CAAA,OAAA,CAAA,CAAA;;SAE5F,QAAA,CAAI,IAAK,IAAQ,OAAA,QAAS,CAAA,IAAU,KAAA,QAAY,GAAA,QAAQ,CAAC,IAAA,GAAO,EAAS;;MAE5E,GAAA,GAAC,YAAS,CAAI,KAAW,QAAA,IAAA,CAAA,CAAQ,IAAC,EAAS,GAAA,CAAA,CAAA,IAAA,EAAA,GAAU,SAAS;AACzE,MAAC,QAAA,GAAA,IAAA,GAAA,CAAA,CAAA,MAAA,EAAA,UAAA,EAAA,WAAA,EAAA,MAAA,EAAA,WAAA,EAAA,QAAA,EAAA,OAAA,CAAA,CAAA;AAED;AAEM,kBAA+B,CAAC,GAAA,EAAA;AAEtC,EAAkG,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AAA;AAED,IAA0D,IAAA,EAAA;AAC1D,GAAM;AACF,EAAA,MAAA,EAAM;IACN,KAAM,EAAC,oBAAmB;AAC1B,IAAA,IAAA,EAAM;AACN,GAAA;AACA,EAAA,KAAA,EAAA;AACA,IAAA,KAAA,EAAO,YAAY;AACvB,IAAC,IAAA,EAAA;AAED;AACA,CAAM;AAE8F,MAAA,UAAA,GAAA,MAAA,IAAA,MAAA,CAAA,MAAA;AACpG;AACI,SAAW,WAAA,CAAA,IAAA,EAAA;AAAE,EAAA,IAAA,IAAA,CAAA,OAAU,EAAA,OAAA,IAAA,CAAA,OAAA;AACvB,EAAA,QAAK,IAAA,CAAA,MAAA;SACK,MAAA;AACN,MAAA,OAAO,IAAS,CAAA,IAAA,IAAA,cAAa;AAAE,IAAA,KAAA;AAC/B,MAAA,gDAAkC;eAAK;AACvC,MAAA,OAAA,oBAAsB;IAC1B,KAAC,WAAA;AAAC,MAAA,OAAO,kBAAA;AACL,IAAA,KAAA,QAAS;MACZ,OAAA,IAAA,CAAA,MAAA,GAAA,CAAA,6BAAA,EAAA,IAAA,CAAA,MAAA,CAAA,EAAA,CAAA,GAAA,8BAAA;AACL,IAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CallLog, type TranscriptLine } from './calls';
|
|
2
|
+
/** The person's calls, newest first: as many as the cards in a thread could want. */
|
|
3
|
+
export declare function readCalls(): Promise<CallLog>;
|
|
4
|
+
/** What was said on one call. */
|
|
5
|
+
export declare function readCallTranscript(callId: string): Promise<TranscriptLine[]>;
|
|
6
|
+
/** Hang one up, for everyone on it. */
|
|
7
|
+
export declare function endCall(callId: string): Promise<void>;
|
|
8
|
+
/** A surface of this environment (`https://<host>.<env>`), '' where the page cannot tell which. */
|
|
9
|
+
export declare const surfaceUrl: (host: string, path?: string) => string;
|
|
10
|
+
//# sourceMappingURL=callsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsApi.d.ts","sourceRoot":"","sources":["../../../../src/pages/Home/chat/callsApi.ts"],"names":[],"mappings":"AAQA,OAAO,EAMH,KAAK,OAAO,EACZ,KAAK,cAAc,EACtB,MAAM,SAAS,CAAC;AAYjB,qFAAqF;AACrF,wBAAsB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAElD;AAED,iCAAiC;AACjC,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAElF;AAED,uCAAuC;AACvC,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3D;AAED,mGAAmG;AACnG,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,aAAS,KAAG,MAAwC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {postExecStream,execBody}from'@yantra/surface-kit/agent-exec';import {platformServiceUrl}from'@yantra/surface-kit/auth';import {readCallLog,unwrapConnector,CALLS_CONNECTOR,CALLS_ACTIONS,readTranscript}from'./calls.js';/**
|
|
2
|
+
* Lucy's phone calls, read and ended the way the Phone Calls surface does it: the
|
|
3
|
+
* `yantra-phone-calls` connector, run through the kit's exec lane on the person's own sign-in.
|
|
4
|
+
* That lane goes to the same agent with the same token as the chat itself (agentBaseUrl), so
|
|
5
|
+
* nothing new is set up for it.
|
|
6
|
+
*/
|
|
7
|
+
/** How long one action may take on the agent: the Phone Calls surface's own. */
|
|
8
|
+
const ACTION_TIMEOUT_MS = 45_000;
|
|
9
|
+
async function run(action, params) {
|
|
10
|
+
return unwrapConnector(await postExecStream(execBody(CALLS_CONNECTOR, action, params, ACTION_TIMEOUT_MS), action), action);
|
|
11
|
+
}
|
|
12
|
+
/** The person's calls, newest first: as many as the cards in a thread could want. */
|
|
13
|
+
async function readCalls() {
|
|
14
|
+
return readCallLog(await run(CALLS_ACTIONS.LOG, {
|
|
15
|
+
limit: 50
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
/** What was said on one call. */
|
|
19
|
+
async function readCallTranscript(callId) {
|
|
20
|
+
return readTranscript(await run(CALLS_ACTIONS.GET, {
|
|
21
|
+
call_id: callId
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
/** Hang one up, for everyone on it. */
|
|
25
|
+
async function endCall(callId) {
|
|
26
|
+
await run(CALLS_ACTIONS.END, {
|
|
27
|
+
call_id: callId
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** A surface of this environment (`https://<host>.<env>`), '' where the page cannot tell which. */
|
|
31
|
+
const surfaceUrl = (host, path = '') => platformServiceUrl(host, path);export{endCall,readCallTranscript,readCalls,surfaceUrl};//# sourceMappingURL=callsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsApi.js","sources":["../../../../src/pages/Home/chat/callsApi.ts"],"sourcesContent":[null],"names":[],"mappings":"iOAAA;;;;;AAKG;AAaH;AACA,MAAM,iBAAiB,GAAG,MAAM;AAEhC,eAAe,GAAG,CAAC,MAAc,EAAE,MAA+B,EAAA;SACvD,eAAA,CAAA,MACG,cAAA,CAAA,QAAuB,CAAA,iBAAgB,MAAE,EAAM,MAAQ,EAAA,oBAAoB,SAAS,MACpF,CAAA;AAEd;AAEA;AACO,eAAe,SAAS,GAAA;AAC3B,EAAA,OAAA,kBAAmB,GAAS,CAAA,iBAAe,EAAG;AAClD,IAAC,KAAA,EAAA;AAED,GAAiC,CAAA,CAAA;AACjC;AACI;AACH,eAAA,kBAAA,CAAA,MAAA,EAAA;AAED,EAAuC,OAAA,cAAA,CAAA,MAAA,GAAA,CAAA,aAAA,CAAA,GAAA,EAAA;AACvC,IAAA,OAAO,EAAe;AAClB,GAAA,CAAA,CAAA;AACJ;AAEA;AACO,eAAM,OAAc,CAAA,MAAkB,EAAA;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatTheme.d.ts","sourceRoot":"","sources":["../../../../src/pages/Home/chat/chatTheme.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"chatTheme.d.ts","sourceRoot":"","sources":["../../../../src/pages/Home/chat/chatTheme.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAmgD1B,wBAAgB,SAAS,sBAGxB"}
|