@guava-ai/guava-sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/example-runner.js +16 -7
- package/dist/examples/credit-card-activation.js +94 -112
- package/dist/examples/credit-card-activation.js.map +1 -1
- package/dist/examples/property-insurance.js +12 -26
- package/dist/examples/property-insurance.js.map +1 -1
- package/dist/examples/scheduling-outbound.d.ts +1 -0
- package/dist/examples/scheduling-outbound.js +62 -0
- package/dist/examples/scheduling-outbound.js.map +1 -0
- package/dist/examples/thai-palace.js +25 -43
- package/dist/examples/thai-palace.js.map +1 -1
- package/dist/package.json +7 -5
- package/dist/src/action_item.d.ts +34 -12
- package/dist/src/action_item.js +34 -7
- package/dist/src/action_item.js.map +1 -1
- package/dist/src/call-controller.d.ts +137 -0
- package/dist/src/call-controller.js +433 -0
- package/dist/src/call-controller.js.map +1 -0
- package/dist/src/commands.d.ts +67 -27
- package/dist/src/commands.js +41 -27
- package/dist/src/commands.js.map +1 -1
- package/dist/src/events.d.ts +47 -30
- package/dist/src/events.js +42 -36
- package/dist/src/events.js.map +1 -1
- package/dist/src/example_data.d.ts +1 -0
- package/dist/src/example_data.js +33 -0
- package/dist/src/example_data.js.map +1 -1
- package/dist/src/helpers/openai.d.ts +12 -1
- package/dist/src/helpers/openai.js +168 -68
- package/dist/src/helpers/openai.js.map +1 -1
- package/dist/src/index.d.ts +6 -121
- package/dist/src/index.js +249 -483
- package/dist/src/index.js.map +1 -1
- package/dist/src/logging.d.ts +2 -1
- package/dist/src/logging.js +32 -7
- package/dist/src/logging.js.map +1 -1
- package/dist/src/telemetry.d.ts +23 -0
- package/dist/src/telemetry.js +98 -0
- package/dist/src/telemetry.js.map +1 -0
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.js +28 -0
- package/dist/src/utils.js.map +1 -0
- package/examples/biome.json +5 -0
- package/examples/credit-card-activation.ts +20 -26
- package/examples/property-insurance.ts +6 -16
- package/examples/scheduling-outbound.ts +80 -0
- package/examples/thai-palace.ts +10 -13
- package/package.json +7 -5
- package/src/action_item.ts +53 -13
- package/src/call-controller.ts +451 -0
- package/src/commands.ts +58 -42
- package/src/events.ts +66 -51
- package/src/example_data.ts +42 -0
- package/src/helpers/openai.ts +73 -18
- package/src/index.ts +81 -403
- package/src/logging.ts +39 -7
- package/src/telemetry.ts +125 -0
- package/src/utils.ts +32 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
import { getDefaultLogger } from "./logging.js";
|
|
36
|
+
import { AcceptInboundCallCommand, SetPersona, SetTaskCommand, AnswerQuestionCommand, SendInstructionCommand, ReadScriptCommand, RejectInboundCallCommand, TransferCommand, ChoiceResultCommand, } from "./commands.js";
|
|
37
|
+
import { Say, } from "./action_item.js";
|
|
38
|
+
import { telemetryClient } from "./telemetry.js";
|
|
39
|
+
/**
|
|
40
|
+
* Interface between Guava services and user-supplied code
|
|
41
|
+
*/
|
|
42
|
+
let CallController = (() => {
|
|
43
|
+
let _classDecorators = [telemetryClient.trackClass()];
|
|
44
|
+
let _classDescriptor;
|
|
45
|
+
let _classExtraInitializers = [];
|
|
46
|
+
let _classThis;
|
|
47
|
+
var CallController = class {
|
|
48
|
+
static { _classThis = this; }
|
|
49
|
+
static {
|
|
50
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
51
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
52
|
+
CallController = _classThis = _classDescriptor.value;
|
|
53
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
54
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
55
|
+
}
|
|
56
|
+
_commandQueue = [];
|
|
57
|
+
_on_complete_current_task;
|
|
58
|
+
// private _field_values: Record<string, any>;
|
|
59
|
+
_current_task_id;
|
|
60
|
+
/**
|
|
61
|
+
* @protected
|
|
62
|
+
* @description logger used to emit diagnostics
|
|
63
|
+
*/
|
|
64
|
+
logger;
|
|
65
|
+
// drain functions are expected to cleanup
|
|
66
|
+
// the part of the queue that is successfully sent from its
|
|
67
|
+
// input (mutating it) (i.e. _drain should use Array.splice)
|
|
68
|
+
_drain;
|
|
69
|
+
_fieldValues = {};
|
|
70
|
+
_searchFunctionsByKey = {};
|
|
71
|
+
constructor(logger = getDefaultLogger()) {
|
|
72
|
+
// Set up the default logger.
|
|
73
|
+
this.logger = logger;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @description Supply a function used to consume commands from the internal command queue.
|
|
77
|
+
*
|
|
78
|
+
* The function is expected to remove from the argument array commands that it has handled (iterating
|
|
79
|
+
* through the result of `Array.splice(0)` is sufficient)
|
|
80
|
+
*/
|
|
81
|
+
setDrain(newDrain) {
|
|
82
|
+
this._drain = newDrain;
|
|
83
|
+
this.flush();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @description [inbound] receive a call, and process further.
|
|
87
|
+
*/
|
|
88
|
+
async acceptCall() {
|
|
89
|
+
await this.sendCommand(AcceptInboundCallCommand, {
|
|
90
|
+
command_type: "accept-inbound",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @description read a span of text verbatim
|
|
95
|
+
*/
|
|
96
|
+
async readScript(script) {
|
|
97
|
+
await this.sendCommand(ReadScriptCommand, {
|
|
98
|
+
command_type: "read-script",
|
|
99
|
+
script: script,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @description [inbound] reject a call
|
|
104
|
+
*/
|
|
105
|
+
async rejectCall() {
|
|
106
|
+
await this.sendCommand(RejectInboundCallCommand, {
|
|
107
|
+
command_type: "reject-inbound",
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async addInfo(_info) {
|
|
111
|
+
throw new Error("not implemeneted");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @description read a span of text non-verbatim
|
|
115
|
+
*/
|
|
116
|
+
async sendInstruction(instruction) {
|
|
117
|
+
await this.sendCommand(SendInstructionCommand, {
|
|
118
|
+
command_type: "send-instruction",
|
|
119
|
+
instruction: instruction,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @description provide identifiers the agent will use to identify the virtual agent
|
|
124
|
+
*/
|
|
125
|
+
async setPersona(args) {
|
|
126
|
+
await this.sendCommand(SetPersona, {
|
|
127
|
+
command_type: "set-persona",
|
|
128
|
+
organization_name: args.organizationName,
|
|
129
|
+
agent_name: args.agentName,
|
|
130
|
+
agent_purpose: args.agentPurpose,
|
|
131
|
+
voice: args.voice,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @description direct the agent to collect information
|
|
136
|
+
* @param goal {} an objective string and/or a checklist of information to collect
|
|
137
|
+
* @param on_complete {} a callback to call once the information is available from the agent
|
|
138
|
+
* @param args {} arguments to pass through to the `on_complete` callback
|
|
139
|
+
*/
|
|
140
|
+
setTask(goal, on_complete = () => { }, ...args) {
|
|
141
|
+
this._current_task_id = Math.random().toString(16).substring(2, 8);
|
|
142
|
+
this._on_complete_current_task = on_complete.bind(this, ...args);
|
|
143
|
+
if (!("checklist" in goal)) {
|
|
144
|
+
this.sendCommand(SetTaskCommand, {
|
|
145
|
+
command_type: "set-task",
|
|
146
|
+
task_id: this._current_task_id,
|
|
147
|
+
objective: goal.objective,
|
|
148
|
+
action_items: [],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const action_items = goal.checklist.map((item) => {
|
|
153
|
+
if (typeof item === "string") {
|
|
154
|
+
return { item_type: "todo", description: item };
|
|
155
|
+
}
|
|
156
|
+
if (item.item_type === "field" && item.choiceGenerator) {
|
|
157
|
+
this._searchFunctionsByKey[item.key] = item.choiceGenerator;
|
|
158
|
+
const { choiceGenerator: _, ...fieldData } = item;
|
|
159
|
+
return {
|
|
160
|
+
...fieldData,
|
|
161
|
+
is_search_field: true,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return item;
|
|
165
|
+
});
|
|
166
|
+
this.sendCommand(SetTaskCommand, {
|
|
167
|
+
command_type: "set-task",
|
|
168
|
+
task_id: this._current_task_id,
|
|
169
|
+
objective: goal.objective ?? "",
|
|
170
|
+
action_items,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @description direct the agent to collect information, continuing execution once the agent has collected the information
|
|
176
|
+
* @param goal {} an objective string and/or a checklist of information to collect
|
|
177
|
+
*/
|
|
178
|
+
async awaitTask(goal) {
|
|
179
|
+
return new Promise((resolve) => {
|
|
180
|
+
this.setTask(goal, (_args) => {
|
|
181
|
+
resolve();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @description retrieve a piece of information that the agent has collected
|
|
187
|
+
* @param key {string} key of the field checklist item
|
|
188
|
+
*/
|
|
189
|
+
getField(key) {
|
|
190
|
+
if (key in this._fieldValues) {
|
|
191
|
+
return this._fieldValues[key];
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @description [inbound] hang up an accepted call
|
|
199
|
+
*/
|
|
200
|
+
async hangup(final_instructions = "") {
|
|
201
|
+
let instructions;
|
|
202
|
+
if (final_instructions) {
|
|
203
|
+
instructions = `Start ending the conversation. Here are your final instructions: ${final_instructions} Once you've completed the final instructions, naturally end the conversation and hang up the call.`;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
instructions = "Naturally end the conversation and hang up the call.";
|
|
207
|
+
}
|
|
208
|
+
this.sendInstruction(instructions);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @description helper for reaching a specific contact on an outbound call and recording their availability.
|
|
212
|
+
*/
|
|
213
|
+
reachPerson(contactFullName, options) {
|
|
214
|
+
let outcomes;
|
|
215
|
+
if ("outcomes" in options) {
|
|
216
|
+
outcomes = options.outcomes;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
outcomes = [
|
|
220
|
+
{
|
|
221
|
+
key: "contact_available",
|
|
222
|
+
onOutcome: options.onSuccess,
|
|
223
|
+
description: "The contact is available to speak.",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
key: "contact_unavailable",
|
|
227
|
+
onOutcome: options.onFailure,
|
|
228
|
+
description: "The contact is not available to speak. This includes reaching a wrong number.",
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
const outcomeHandlers = Object.fromEntries(outcomes.map((o) => [o.key, o.onOutcome]));
|
|
233
|
+
const initialGreeting = options.greeting !== undefined
|
|
234
|
+
? Say(options.greeting)
|
|
235
|
+
: `Greet the person who answered the phone. Notify them who you are calling on behalf of and the purpose of the call. Ask to speak with ${contactFullName}`;
|
|
236
|
+
const availabilityDescription = `The availability of ${contactFullName}` +
|
|
237
|
+
(outcomes.some((o) => o.description)
|
|
238
|
+
? "\nDetailed descriptions of each choice:\n" +
|
|
239
|
+
outcomes
|
|
240
|
+
.filter((o) => o.description)
|
|
241
|
+
.map((o) => ` - ${o.key}: ${o.description}`)
|
|
242
|
+
.join("\n")
|
|
243
|
+
: "");
|
|
244
|
+
const nextActionLines = outcomes
|
|
245
|
+
.filter((o) => o.nextActionPreview)
|
|
246
|
+
.map((o) => `- ${o.key} → ${o.nextActionPreview}`);
|
|
247
|
+
const checklist = [
|
|
248
|
+
initialGreeting,
|
|
249
|
+
{
|
|
250
|
+
item_type: "field",
|
|
251
|
+
key: "contact_availability",
|
|
252
|
+
field_type: "multiple_choice",
|
|
253
|
+
description: availabilityDescription,
|
|
254
|
+
choices: outcomes.map((o) => o.key),
|
|
255
|
+
},
|
|
256
|
+
];
|
|
257
|
+
if (nextActionLines.length > 0) {
|
|
258
|
+
checklist.push("If a next action is defined below for the value of `contact_availability`, briefly ask the contact to wait just a second while you perform it.\n" +
|
|
259
|
+
nextActionLines.join("\n"));
|
|
260
|
+
}
|
|
261
|
+
const objective = `\
|
|
262
|
+
OBJECTIVE:
|
|
263
|
+
Your goal is to reach ${contactFullName} and determine their availability to proceed with this call.
|
|
264
|
+
|
|
265
|
+
RULES:
|
|
266
|
+
1. If the initial respondent is NOT ${contactFullName}:
|
|
267
|
+
- Politely ask to speak with ${contactFullName}
|
|
268
|
+
- Wait to be transferred or for ${contactFullName} to come to the phone
|
|
269
|
+
2. Once you have ${contactFullName} on the line:
|
|
270
|
+
- Briefly restate who you are and the purpose of your call
|
|
271
|
+
- Determine and record their current availability status
|
|
272
|
+
3. DO NOT hang up the call under any circumstances, unless it's a wrong number.
|
|
273
|
+
|
|
274
|
+
TASK COMPLETION REQUIREMENTS:
|
|
275
|
+
- The availability of ${contactFullName} must be recorded in \`contact_availability\`.`;
|
|
276
|
+
this.setTask({ objective, checklist }, () => {
|
|
277
|
+
const availability = this.getField("contact_availability");
|
|
278
|
+
const handler = outcomeHandlers[availability];
|
|
279
|
+
if (!handler) {
|
|
280
|
+
this.logger.error(`Unhandled contact_availability value: ${availability}`);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
this.logger.info(`Contact availability recorded: ${availability}`);
|
|
284
|
+
handler();
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @description transfer an accepted call
|
|
289
|
+
*/
|
|
290
|
+
transfer(to_number, transfer_message) {
|
|
291
|
+
const message = transfer_message ?? "I'm transferring you now";
|
|
292
|
+
this.sendCommand(TransferCommand, {
|
|
293
|
+
command_type: "transfer-call",
|
|
294
|
+
transfer_message: message,
|
|
295
|
+
to_number: to_number,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async sendCommand(schema, data) {
|
|
299
|
+
const command = schema.parse(data);
|
|
300
|
+
this._commandQueue.push(command);
|
|
301
|
+
await this.flush();
|
|
302
|
+
}
|
|
303
|
+
async flush() {
|
|
304
|
+
await this._drain?.call(this, this._commandQueue);
|
|
305
|
+
}
|
|
306
|
+
async onEvent(event) {
|
|
307
|
+
this.logger.debug(`Event received: ${JSON.stringify(event)}`);
|
|
308
|
+
if (event.event_type === "caller-speech") {
|
|
309
|
+
this.onCallerSpeech(event);
|
|
310
|
+
}
|
|
311
|
+
else if (event.event_type === "agent-speech") {
|
|
312
|
+
this.onAgentSpeech(event);
|
|
313
|
+
}
|
|
314
|
+
else if (event.event_type === "agent-question") {
|
|
315
|
+
try {
|
|
316
|
+
this.logger.info(`Received question from bot: ${event.question}`);
|
|
317
|
+
const answer = await this.onQuestion(event.question);
|
|
318
|
+
await this.sendCommand(AnswerQuestionCommand, {
|
|
319
|
+
command_type: "answer-question",
|
|
320
|
+
question_id: event.question_id,
|
|
321
|
+
answer: answer,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
catch (e) {
|
|
325
|
+
this.logger.error("Error occured while answering question.");
|
|
326
|
+
await this.sendCommand(AnswerQuestionCommand, {
|
|
327
|
+
command_type: "answer-question",
|
|
328
|
+
question_id: event.question_id,
|
|
329
|
+
answer: "An error occured and the question could not be answered.",
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else if (event.event_type === "intent") {
|
|
334
|
+
this.logger.info(`Received intent ${event.intent_id} from bot: ${event.intent_summary}`);
|
|
335
|
+
const intent_response = await this.onIntent(event.intent_summary);
|
|
336
|
+
if (intent_response) {
|
|
337
|
+
const response_str = `Responding to intent ${event.intent_id}: ${intent_response}`;
|
|
338
|
+
this.logger.info(response_str);
|
|
339
|
+
this.sendInstruction(intent_response);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else if (event.event_type === "task-done") {
|
|
343
|
+
// ignore obsolete task_completed events
|
|
344
|
+
if (event.task_id === this._current_task_id) {
|
|
345
|
+
// assertion is implied
|
|
346
|
+
const on_complete = this._on_complete_current_task;
|
|
347
|
+
this._on_complete_current_task = undefined;
|
|
348
|
+
if (on_complete) {
|
|
349
|
+
on_complete();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else if (event.event_type === "choice-query") {
|
|
354
|
+
this.logger.info(`Received choice query for field ${event.field_key}: ${event.query}`);
|
|
355
|
+
const choiceGenerator = this._searchFunctionsByKey[event.field_key];
|
|
356
|
+
if (!choiceGenerator) {
|
|
357
|
+
this.logger.warn(`Choice query for field '${event.field_key}' arrived but has no choice generator attached.`);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
const [matchedChoices, otherChoices] = await choiceGenerator(event.query);
|
|
361
|
+
await this.sendCommand(ChoiceResultCommand, {
|
|
362
|
+
command_type: "choice-query-result",
|
|
363
|
+
field_key: event.field_key,
|
|
364
|
+
query_id: event.query_id,
|
|
365
|
+
matched_choices: matchedChoices,
|
|
366
|
+
other_choices: otherChoices,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else if (event.event_type === "action-item-done") {
|
|
371
|
+
this._fieldValues[event.key] = event.payload;
|
|
372
|
+
if (event.key && event.payload) {
|
|
373
|
+
this.logger.info(`Field ${event.key} updated with value: ${event.payload}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else if (event.event_type === "inbound-call") {
|
|
377
|
+
this.onIncomingCall(event.caller_number);
|
|
378
|
+
}
|
|
379
|
+
else if (event.event_type === "bot-session-ended") {
|
|
380
|
+
this.onSessionDone();
|
|
381
|
+
}
|
|
382
|
+
else if (event.event_type === "outbound-call-connected") {
|
|
383
|
+
// no-op, don't warn
|
|
384
|
+
}
|
|
385
|
+
else if (event.event_type === "error") {
|
|
386
|
+
this.logger.error(`The Guava agent reported an error: ${event.content}`);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.logger.warn(`Unhandled event: ${JSON.stringify(event)}`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// callbacks
|
|
393
|
+
/**
|
|
394
|
+
* @description called when an inbound call is received. The overriding function must start
|
|
395
|
+
* with `await super.onIncomingCall(from_number)`
|
|
396
|
+
*/
|
|
397
|
+
async onIncomingCall(from_number) {
|
|
398
|
+
await this.onCallStart();
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* @description called when a call is connected by the API, whether inbound or outbound
|
|
402
|
+
*/
|
|
403
|
+
async onCallStart() { }
|
|
404
|
+
/**
|
|
405
|
+
* @description called when the caller speaks to the agent.
|
|
406
|
+
*/
|
|
407
|
+
async onCallerSpeech(event) { }
|
|
408
|
+
/**
|
|
409
|
+
* @description called when the agent speaks to the caller.
|
|
410
|
+
*/
|
|
411
|
+
async onAgentSpeech(event) { }
|
|
412
|
+
/**
|
|
413
|
+
* @description called when the caller expresses a task they wish to execute
|
|
414
|
+
*/
|
|
415
|
+
async onIntent(intent) {
|
|
416
|
+
return "Unfortunately I'm not able to help with that.";
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* @description called when the agent needs to respond to a question that it doesn't know
|
|
420
|
+
* the answer to.
|
|
421
|
+
*/
|
|
422
|
+
async onQuestion(question) {
|
|
423
|
+
return "I don't have an answer to that question.";
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* @description called when the bot session has ended.
|
|
427
|
+
*/
|
|
428
|
+
onSessionDone() { }
|
|
429
|
+
};
|
|
430
|
+
return CallController = _classThis;
|
|
431
|
+
})();
|
|
432
|
+
export { CallController };
|
|
433
|
+
//# sourceMappingURL=call-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-controller.js","sourceRoot":"","sources":["../../src/call-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;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CAAC;QAErC;;WAEG;QACH,KAAK,CAAC,cAAc,CAAC,KAAwB,IAAG,CAAC;QACjD;;WAEG;QACH,KAAK,CAAC,aAAa,CAAC,KAAuB,IAAG,CAAC;QAC/C;;WAEG;QACH,KAAK,CAAC,QAAQ,CAAC,MAAc;YAC3B,OAAO,+CAA+C,CAAC;QACzD,CAAC;QACD;;;WAGG;QACH,KAAK,CAAC,UAAU,CAAC,QAAgB;YAC/B,OAAO,0CAA0C,CAAC;QACpD,CAAC;QAED;;WAEG;QACH,aAAa,KAAU,CAAC;;;;SApZb,cAAc"}
|
package/dist/src/commands.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const StartOutboundCallCommand: z.ZodObject<{
|
|
3
3
|
command_type: z.ZodLiteral<"start-outbound">;
|
|
4
4
|
from_number: z.ZodOptional<z.ZodE164>;
|
|
5
5
|
to_number: z.ZodE164;
|
|
6
6
|
}, z.core.$strict>;
|
|
7
|
-
export type StartOutboundCallCommand = z.input<typeof
|
|
8
|
-
export declare const
|
|
7
|
+
export type StartOutboundCallCommand = z.input<typeof StartOutboundCallCommand>;
|
|
8
|
+
export declare const ListenInboundCommand: z.ZodObject<{
|
|
9
9
|
command_type: z.ZodLiteral<"listen-inbound">;
|
|
10
10
|
agent_number: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodE164>>>;
|
|
11
11
|
webrtc_code: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
12
12
|
}, z.core.$strict>;
|
|
13
|
-
export type ListenInboundCommand = z.input<typeof
|
|
14
|
-
export declare const
|
|
13
|
+
export type ListenInboundCommand = z.input<typeof ListenInboundCommand>;
|
|
14
|
+
export declare const RejectInboundCallCommand: z.ZodObject<{
|
|
15
15
|
command_type: z.ZodLiteral<"reject-inbound">;
|
|
16
16
|
}, z.core.$strict>;
|
|
17
|
-
export type RejectInboundCallCommand = z.input<typeof
|
|
18
|
-
export declare const
|
|
17
|
+
export type RejectInboundCallCommand = z.input<typeof RejectInboundCallCommand>;
|
|
18
|
+
export declare const AcceptInboundCallCommand: z.ZodObject<{
|
|
19
19
|
command_type: z.ZodLiteral<"accept-inbound">;
|
|
20
20
|
}, z.core.$strict>;
|
|
21
|
-
export type AcceptInboundCallCommand = z.input<typeof
|
|
22
|
-
export declare const
|
|
21
|
+
export type AcceptInboundCallCommand = z.input<typeof AcceptInboundCallCommand>;
|
|
22
|
+
export declare const SetTaskCommand: z.ZodObject<{
|
|
23
23
|
command_type: z.ZodLiteral<"set-task">;
|
|
24
24
|
task_id: z.ZodString;
|
|
25
25
|
objective: z.ZodString;
|
|
@@ -27,9 +27,10 @@ export declare const setTaskCommand: z.ZodObject<{
|
|
|
27
27
|
item_type: z.ZodLiteral<"field">;
|
|
28
28
|
key: z.ZodString;
|
|
29
29
|
description: z.ZodString;
|
|
30
|
-
field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
|
|
30
|
+
field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice" | "calendar_slot">[]>;
|
|
31
31
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
32
32
|
choices: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
33
|
+
is_search_field: z.ZodDefault<z.ZodBoolean>;
|
|
33
34
|
}, z.core.$strip>, z.ZodObject<{
|
|
34
35
|
item_type: z.ZodLiteral<"say">;
|
|
35
36
|
statement: z.ZodString;
|
|
@@ -40,37 +41,52 @@ export declare const setTaskCommand: z.ZodObject<{
|
|
|
40
41
|
key: z.ZodDefault<z.ZodString>;
|
|
41
42
|
}, z.core.$strip>]>>;
|
|
42
43
|
}, z.core.$strict>;
|
|
43
|
-
export type SetTaskCommand = z.input<typeof
|
|
44
|
-
export declare const
|
|
44
|
+
export type SetTaskCommand = z.input<typeof SetTaskCommand>;
|
|
45
|
+
export declare const ReadScriptCommand: z.ZodObject<{
|
|
45
46
|
command_type: z.ZodLiteral<"read-script">;
|
|
46
47
|
script: z.ZodString;
|
|
47
48
|
}, z.core.$strict>;
|
|
48
|
-
export type ReadScriptCommand = z.input<typeof
|
|
49
|
-
export declare const
|
|
49
|
+
export type ReadScriptCommand = z.input<typeof ReadScriptCommand>;
|
|
50
|
+
export declare const AnswerQuestionCommand: z.ZodObject<{
|
|
50
51
|
command_type: z.ZodLiteral<"answer-question">;
|
|
51
52
|
question_id: z.ZodString;
|
|
52
53
|
answer: z.ZodString;
|
|
53
54
|
}, z.core.$strict>;
|
|
54
|
-
export type AnswerQuestionCommand = z.input<typeof
|
|
55
|
-
export declare const
|
|
55
|
+
export type AnswerQuestionCommand = z.input<typeof AnswerQuestionCommand>;
|
|
56
|
+
export declare const SetPersona: z.ZodObject<{
|
|
56
57
|
command_type: z.ZodLiteral<"set-persona">;
|
|
57
58
|
agent_name: z.ZodOptional<z.ZodString>;
|
|
58
59
|
organization_name: z.ZodOptional<z.ZodString>;
|
|
59
60
|
agent_purpose: z.ZodOptional<z.ZodString>;
|
|
61
|
+
voice: z.ZodOptional<z.ZodString>;
|
|
60
62
|
}, z.core.$strict>;
|
|
61
|
-
export type SetPersona = z.input<typeof
|
|
62
|
-
export declare const
|
|
63
|
+
export type SetPersona = z.input<typeof SetPersona>;
|
|
64
|
+
export declare const SendInstructionCommand: z.ZodObject<{
|
|
63
65
|
command_type: z.ZodLiteral<"send-instruction">;
|
|
64
66
|
instruction: z.ZodString;
|
|
65
67
|
}, z.core.$strict>;
|
|
66
|
-
export type SendInstructionCommand = z.input<typeof
|
|
67
|
-
export declare const
|
|
68
|
+
export type SendInstructionCommand = z.input<typeof SendInstructionCommand>;
|
|
69
|
+
export declare const TransferCommand: z.ZodObject<{
|
|
68
70
|
command_type: z.ZodLiteral<"transfer-call">;
|
|
69
71
|
transfer_message: z.ZodString;
|
|
70
72
|
to_number: z.ZodString;
|
|
71
73
|
}, z.core.$strict>;
|
|
72
|
-
export type TransferCommand = z.input<typeof
|
|
73
|
-
export declare const
|
|
74
|
+
export type TransferCommand = z.input<typeof TransferCommand>;
|
|
75
|
+
export declare const RegisteredHooksCommand: z.ZodObject<{
|
|
76
|
+
command_type: z.ZodLiteral<"registered-hooks">;
|
|
77
|
+
has_on_question: z.ZodBoolean;
|
|
78
|
+
has_on_intent: z.ZodBoolean;
|
|
79
|
+
}, z.core.$strict>;
|
|
80
|
+
export type RegisteredHooksCommand = z.input<typeof RegisteredHooksCommand>;
|
|
81
|
+
export declare const ChoiceResultCommand: z.ZodObject<{
|
|
82
|
+
command_type: z.ZodLiteral<"choice-query-result">;
|
|
83
|
+
field_key: z.ZodString;
|
|
84
|
+
query_id: z.ZodString;
|
|
85
|
+
matched_choices: z.ZodArray<z.ZodString>;
|
|
86
|
+
other_choices: z.ZodArray<z.ZodString>;
|
|
87
|
+
}, z.core.$strict>;
|
|
88
|
+
export type ChoiceResultCommand = z.input<typeof ChoiceResultCommand>;
|
|
89
|
+
export declare const AnyCommand: z.ZodUnion<readonly [z.ZodObject<{
|
|
74
90
|
command_type: z.ZodLiteral<"start-outbound">;
|
|
75
91
|
from_number: z.ZodOptional<z.ZodE164>;
|
|
76
92
|
to_number: z.ZodE164;
|
|
@@ -90,9 +106,10 @@ export declare const anyCommand: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
90
106
|
item_type: z.ZodLiteral<"field">;
|
|
91
107
|
key: z.ZodString;
|
|
92
108
|
description: z.ZodString;
|
|
93
|
-
field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
|
|
109
|
+
field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice" | "calendar_slot">[]>;
|
|
94
110
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
95
111
|
choices: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
112
|
+
is_search_field: z.ZodDefault<z.ZodBoolean>;
|
|
96
113
|
}, z.core.$strip>, z.ZodObject<{
|
|
97
114
|
item_type: z.ZodLiteral<"say">;
|
|
98
115
|
statement: z.ZodString;
|
|
@@ -114,6 +131,7 @@ export declare const anyCommand: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
114
131
|
agent_name: z.ZodOptional<z.ZodString>;
|
|
115
132
|
organization_name: z.ZodOptional<z.ZodString>;
|
|
116
133
|
agent_purpose: z.ZodOptional<z.ZodString>;
|
|
134
|
+
voice: z.ZodOptional<z.ZodString>;
|
|
117
135
|
}, z.core.$strict>, z.ZodObject<{
|
|
118
136
|
command_type: z.ZodLiteral<"send-instruction">;
|
|
119
137
|
instruction: z.ZodString;
|
|
@@ -121,9 +139,19 @@ export declare const anyCommand: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
121
139
|
command_type: z.ZodLiteral<"transfer-call">;
|
|
122
140
|
transfer_message: z.ZodString;
|
|
123
141
|
to_number: z.ZodString;
|
|
142
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
143
|
+
command_type: z.ZodLiteral<"registered-hooks">;
|
|
144
|
+
has_on_question: z.ZodBoolean;
|
|
145
|
+
has_on_intent: z.ZodBoolean;
|
|
146
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
147
|
+
command_type: z.ZodLiteral<"choice-query-result">;
|
|
148
|
+
field_key: z.ZodString;
|
|
149
|
+
query_id: z.ZodString;
|
|
150
|
+
matched_choices: z.ZodArray<z.ZodString>;
|
|
151
|
+
other_choices: z.ZodArray<z.ZodString>;
|
|
124
152
|
}, z.core.$strict>]>;
|
|
125
|
-
export type Command = z.input<typeof
|
|
126
|
-
export declare const
|
|
153
|
+
export type Command = z.input<typeof AnyCommand>;
|
|
154
|
+
export declare const InboundTunnelCommand: z.ZodObject<{
|
|
127
155
|
call_id: z.ZodString;
|
|
128
156
|
command: z.ZodUnion<readonly [z.ZodObject<{
|
|
129
157
|
command_type: z.ZodLiteral<"start-outbound">;
|
|
@@ -145,9 +173,10 @@ export declare const inboundTunnelCommand: z.ZodObject<{
|
|
|
145
173
|
item_type: z.ZodLiteral<"field">;
|
|
146
174
|
key: z.ZodString;
|
|
147
175
|
description: z.ZodString;
|
|
148
|
-
field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
|
|
176
|
+
field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice" | "calendar_slot">[]>;
|
|
149
177
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
150
178
|
choices: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
179
|
+
is_search_field: z.ZodDefault<z.ZodBoolean>;
|
|
151
180
|
}, z.core.$strip>, z.ZodObject<{
|
|
152
181
|
item_type: z.ZodLiteral<"say">;
|
|
153
182
|
statement: z.ZodString;
|
|
@@ -169,6 +198,7 @@ export declare const inboundTunnelCommand: z.ZodObject<{
|
|
|
169
198
|
agent_name: z.ZodOptional<z.ZodString>;
|
|
170
199
|
organization_name: z.ZodOptional<z.ZodString>;
|
|
171
200
|
agent_purpose: z.ZodOptional<z.ZodString>;
|
|
201
|
+
voice: z.ZodOptional<z.ZodString>;
|
|
172
202
|
}, z.core.$strict>, z.ZodObject<{
|
|
173
203
|
command_type: z.ZodLiteral<"send-instruction">;
|
|
174
204
|
instruction: z.ZodString;
|
|
@@ -176,6 +206,16 @@ export declare const inboundTunnelCommand: z.ZodObject<{
|
|
|
176
206
|
command_type: z.ZodLiteral<"transfer-call">;
|
|
177
207
|
transfer_message: z.ZodString;
|
|
178
208
|
to_number: z.ZodString;
|
|
209
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
210
|
+
command_type: z.ZodLiteral<"registered-hooks">;
|
|
211
|
+
has_on_question: z.ZodBoolean;
|
|
212
|
+
has_on_intent: z.ZodBoolean;
|
|
213
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
214
|
+
command_type: z.ZodLiteral<"choice-query-result">;
|
|
215
|
+
field_key: z.ZodString;
|
|
216
|
+
query_id: z.ZodString;
|
|
217
|
+
matched_choices: z.ZodArray<z.ZodString>;
|
|
218
|
+
other_choices: z.ZodArray<z.ZodString>;
|
|
179
219
|
}, z.core.$strict>]>;
|
|
180
220
|
}, z.core.$strict>;
|
|
181
|
-
export type InboundTunnelCommand = z.input<typeof
|
|
221
|
+
export type InboundTunnelCommand = z.input<typeof InboundTunnelCommand>;
|