@guava-ai/guava-sdk 0.24.0 → 0.26.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/README.md +13 -3
- package/bin/example-runner.ts +138 -11
- package/dist/bin/example-runner.d.ts +23 -6
- package/dist/bin/example-runner.js +112 -9
- package/dist/bin/example-runner.js.map +1 -1
- package/dist/examples/{example.test.js → agent-testing.test.js} +2 -2
- package/dist/examples/agent-testing.test.js.map +1 -0
- package/dist/examples/multiple-agents.d.ts +1 -0
- package/dist/examples/multiple-agents.js +52 -0
- package/dist/examples/multiple-agents.js.map +1 -0
- package/dist/examples/scheduling-outbound.js +3 -2
- package/dist/examples/scheduling-outbound.js.map +1 -1
- package/dist/src/agent.d.ts +17 -6
- package/dist/src/agent.js +106 -41
- package/dist/src/agent.js.map +1 -1
- package/dist/src/call.d.ts +3 -0
- package/dist/src/call.js +63 -23
- package/dist/src/call.js.map +1 -1
- package/dist/src/client.d.ts +3 -0
- package/dist/src/client.js +6 -0
- package/dist/src/client.js.map +1 -1
- package/dist/src/commands.d.ts +11 -0
- package/dist/src/commands.js +6 -1
- package/dist/src/commands.js.map +1 -1
- package/dist/src/example-utils.d.ts +2 -0
- package/dist/src/example-utils.js +115 -0
- package/dist/src/example-utils.js.map +1 -0
- package/dist/src/helpers/llm.d.ts +10 -0
- package/dist/src/helpers/llm.js +54 -27
- package/dist/src/helpers/llm.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/runner.d.ts +10 -0
- package/dist/src/runner.js +101 -0
- package/dist/src/runner.js.map +1 -0
- package/dist/src/testing/session.d.ts +7 -0
- package/dist/src/testing/session.js +3 -22
- package/dist/src/testing/session.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/examples/README.md +7 -6
- package/examples/{example.test.ts → agent-testing.test.ts} +1 -1
- package/examples/multiple-agents.ts +18 -0
- package/examples/scheduling-outbound.ts +3 -2
- package/package.json +5 -1
- package/src/agent.ts +130 -47
- package/src/call.ts +78 -23
- package/src/client.ts +7 -0
- package/src/commands.ts +7 -0
- package/src/example-utils.ts +87 -0
- package/src/helpers/llm.ts +23 -31
- package/src/index.ts +3 -1
- package/src/runner.ts +39 -0
- package/src/testing/session.ts +2 -22
- package/src/version.ts +1 -1
- package/dist/examples/example.test.js.map +0 -1
- /package/dist/examples/{example.test.d.ts → agent-testing.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -7,15 +7,25 @@ This library allows you to build Guava voice agents using TypeScript or Javascri
|
|
|
7
7
|
|
|
8
8
|
Full documentation for the TypeScript SDK can be found at [https://goguava.ai/docs/](https://goguava.ai/docs/). SDK examples can be found under [./examples/](https://github.com/goguava-ai/typescript-sdk/tree/main/examples).
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Authentication
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Log in using the [Guava CLI](https://goguava.ai/docs/quickstart):
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
guava login
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Alternatively, provide an API key through an environment variable.
|
|
19
|
+
|
|
20
|
+
```shell
|
|
14
21
|
$ export GUAVA_API_KEY="..." # Your API key for authentication.
|
|
15
22
|
$ export GUAVA_AGENT_NUMBER="..." # A phone number for your agent to use.
|
|
16
23
|
```
|
|
17
24
|
|
|
25
|
+
## Try an Example
|
|
26
|
+
|
|
18
27
|
Run an outbound phone call example using `npx`. Replace the phone number with your own and your agent will call you.
|
|
28
|
+
|
|
19
29
|
```bash
|
|
20
30
|
$ npx @guava-ai/guava-sdk@latest scheduling-outbound +15556667777 # Your agent will call this number.
|
|
21
31
|
```
|
package/bin/example-runner.ts
CHANGED
|
@@ -1,26 +1,153 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const USE_COLOR = process.stdout.isTTY === true && !process.env.NO_COLOR;
|
|
4
|
+
const c = {
|
|
5
|
+
reset: USE_COLOR ? "\x1b[0m" : "",
|
|
6
|
+
dim: USE_COLOR ? "\x1b[2m" : "",
|
|
7
|
+
green: USE_COLOR ? "\x1b[32m" : "",
|
|
8
|
+
red: USE_COLOR ? "\x1b[38;5;196m" : "",
|
|
9
|
+
bold: USE_COLOR ? "\x1b[1m" : "",
|
|
10
|
+
cyan: USE_COLOR ? "\x1b[36m" : "",
|
|
9
11
|
};
|
|
10
12
|
|
|
13
|
+
type TestFn = () => Promise<void> | void;
|
|
14
|
+
type Registered = { suite: string; name: string; fn: TestFn };
|
|
15
|
+
|
|
16
|
+
// This is a minimal in-process implementation of a Jest-like test runnner to allow the agent testing example
|
|
17
|
+
// to be run from example runner.
|
|
18
|
+
async function runAgentTesting(_args: string[]): Promise<void> {
|
|
19
|
+
const registered: Registered[] = [];
|
|
20
|
+
let currentSuite = "";
|
|
21
|
+
|
|
22
|
+
(global as any).describe = (name: string, fn: () => void) => {
|
|
23
|
+
currentSuite = name;
|
|
24
|
+
fn();
|
|
25
|
+
currentSuite = "";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
(global as any).test = (name: string, fn: TestFn) => {
|
|
29
|
+
registered.push({ suite: currentSuite, name, fn });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
(global as any).expect = (received: unknown) => ({
|
|
33
|
+
toBe(expected: unknown) {
|
|
34
|
+
if (received !== expected)
|
|
35
|
+
throw new Error(`Expected ${JSON.stringify(received)} to be ${JSON.stringify(expected)}`);
|
|
36
|
+
},
|
|
37
|
+
toContain(expected: unknown) {
|
|
38
|
+
if (!Array.isArray(received) || !received.includes(expected))
|
|
39
|
+
throw new Error(`Expected array to contain ${JSON.stringify(expected)}`);
|
|
40
|
+
},
|
|
41
|
+
toContainEqual(expected: unknown) {
|
|
42
|
+
if (
|
|
43
|
+
!Array.isArray(received) ||
|
|
44
|
+
!received.some(
|
|
45
|
+
(item) => JSON.stringify(item) === JSON.stringify(expected),
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
throw new Error(`Expected array to contain equal to ${JSON.stringify(expected)}`);
|
|
49
|
+
},
|
|
50
|
+
toHaveProperty(key: string, expected?: unknown) {
|
|
51
|
+
const obj = received as Record<string, unknown>;
|
|
52
|
+
if (!(key in obj))
|
|
53
|
+
throw new Error(`Expected object to have property "${key}"`);
|
|
54
|
+
if (expected !== undefined && obj[key] !== expected)
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Expected property "${key}" to be ${JSON.stringify(expected)}, got ${JSON.stringify(obj[key])}`,
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const prevLogLevel = process.env.LOG_LEVEL;
|
|
62
|
+
process.env.LOG_LEVEL = "off";
|
|
63
|
+
await import("../examples/agent-testing.test");
|
|
64
|
+
|
|
65
|
+
let passed = 0,
|
|
66
|
+
failed = 0;
|
|
67
|
+
for (const { suite, name, fn } of registered) {
|
|
68
|
+
process.stdout.write(`${c.dim}${suite} › ${name}${c.reset} `);
|
|
69
|
+
try {
|
|
70
|
+
await fn();
|
|
71
|
+
process.stdout.write(`${c.green}✓ passed${c.reset}\n`);
|
|
72
|
+
passed++;
|
|
73
|
+
} catch (e: any) {
|
|
74
|
+
process.stdout.write(`${c.red}✗ FAILED${c.reset}\n`);
|
|
75
|
+
console.error(` ${c.red}${e.message}${c.reset}`);
|
|
76
|
+
failed++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
process.env.LOG_LEVEL = prevLogLevel ?? "";
|
|
81
|
+
|
|
82
|
+
const summary =
|
|
83
|
+
failed > 0
|
|
84
|
+
? `${c.bold}${c.green}${passed} passed${c.reset}, ${c.bold}${c.red}${failed} failed${c.reset}`
|
|
85
|
+
: `${c.bold}${c.green}${passed} passed${c.reset}`;
|
|
86
|
+
console.log(`\n${summary}`);
|
|
87
|
+
if (failed > 0) process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type ExampleEntry = {
|
|
91
|
+
description: string;
|
|
92
|
+
load: () => Promise<{ run: (args: string[]) => Promise<void> }>;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const EXAMPLES: Record<string, ExampleEntry> = {
|
|
96
|
+
"scheduling-outbound": {
|
|
97
|
+
description: "Outbound scheduling agent",
|
|
98
|
+
load: () => import("../examples/scheduling-outbound"),
|
|
99
|
+
},
|
|
100
|
+
"property-insurance": {
|
|
101
|
+
description: "Inbound property insurance Q&A agent",
|
|
102
|
+
load: () => import("../examples/property-insurance"),
|
|
103
|
+
},
|
|
104
|
+
"restaurant-waitlist": {
|
|
105
|
+
description: "Inbound restaurant waitlist agent",
|
|
106
|
+
load: () => import("../examples/restaurant-waitlist"),
|
|
107
|
+
},
|
|
108
|
+
"help-desk": {
|
|
109
|
+
description: "Inbound customer support routing and FAQ agent",
|
|
110
|
+
load: () => import("../examples/help-desk"),
|
|
111
|
+
},
|
|
112
|
+
"polling-campaign": {
|
|
113
|
+
description: "Attach a polling agent to a Guava campaign",
|
|
114
|
+
load: () => import("../examples/polling-campaign"),
|
|
115
|
+
},
|
|
116
|
+
"multiple-agents": {
|
|
117
|
+
description: "Run two agents simultaneously using Runner",
|
|
118
|
+
load: () => import("../examples/multiple-agents"),
|
|
119
|
+
},
|
|
120
|
+
"agent-testing": {
|
|
121
|
+
description: "Run agent unit tests and conversation simulations",
|
|
122
|
+
load: async () => ({ run: runAgentTesting }),
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
function printUsage(message?: string): void {
|
|
127
|
+
const colWidth = Math.max(...Object.keys(EXAMPLES).map((k) => k.length)) + 3;
|
|
128
|
+
if (message) {
|
|
129
|
+
console.error(`${c.red}${message}${c.reset}\n`);
|
|
130
|
+
}
|
|
131
|
+
console.error(`${c.bold}Usage:${c.reset} guava-example <example-name> [args...]\n`);
|
|
132
|
+
console.error(`${c.bold}Examples:${c.reset}`);
|
|
133
|
+
for (const [name, { description }] of Object.entries(EXAMPLES)) {
|
|
134
|
+
const padded = name.padEnd(colWidth);
|
|
135
|
+
console.error(` ${c.cyan}${padded}${c.reset}${c.dim}${description}${c.reset}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
11
139
|
const exampleName = process.argv[2];
|
|
12
140
|
if (!exampleName) {
|
|
13
|
-
|
|
14
|
-
console.error("Available examples:", Object.keys(EXAMPLES).join(", "));
|
|
141
|
+
printUsage();
|
|
15
142
|
process.exit(1);
|
|
16
143
|
}
|
|
17
144
|
|
|
18
145
|
if (!(exampleName in EXAMPLES)) {
|
|
19
|
-
|
|
146
|
+
printUsage(`Unknown example "${exampleName}".`);
|
|
20
147
|
process.exit(1);
|
|
21
148
|
}
|
|
22
149
|
|
|
23
150
|
(async () => {
|
|
24
|
-
const mod = await EXAMPLES[exampleName
|
|
151
|
+
const mod = await EXAMPLES[exampleName].load();
|
|
25
152
|
await mod.run(process.argv.slice(3));
|
|
26
|
-
})();
|
|
153
|
+
})();
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
declare const USE_COLOR: boolean;
|
|
3
|
+
declare const c: {
|
|
4
|
+
reset: string;
|
|
5
|
+
dim: string;
|
|
6
|
+
green: string;
|
|
7
|
+
red: string;
|
|
8
|
+
bold: string;
|
|
9
|
+
cyan: string;
|
|
8
10
|
};
|
|
11
|
+
type TestFn = () => Promise<void> | void;
|
|
12
|
+
type Registered = {
|
|
13
|
+
suite: string;
|
|
14
|
+
name: string;
|
|
15
|
+
fn: TestFn;
|
|
16
|
+
};
|
|
17
|
+
declare function runAgentTesting(_args: string[]): Promise<void>;
|
|
18
|
+
type ExampleEntry = {
|
|
19
|
+
description: string;
|
|
20
|
+
load: () => Promise<{
|
|
21
|
+
run: (args: string[]) => Promise<void>;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
declare const EXAMPLES: Record<string, ExampleEntry>;
|
|
25
|
+
declare function printUsage(message?: string): void;
|
|
9
26
|
declare const exampleName: string;
|
|
@@ -32,25 +32,128 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
const USE_COLOR = process.stdout.isTTY === true && !process.env.NO_COLOR;
|
|
36
|
+
const c = {
|
|
37
|
+
reset: USE_COLOR ? "\x1b[0m" : "",
|
|
38
|
+
dim: USE_COLOR ? "\x1b[2m" : "",
|
|
39
|
+
green: USE_COLOR ? "\x1b[32m" : "",
|
|
40
|
+
red: USE_COLOR ? "\x1b[38;5;196m" : "",
|
|
41
|
+
bold: USE_COLOR ? "\x1b[1m" : "",
|
|
42
|
+
cyan: USE_COLOR ? "\x1b[36m" : "",
|
|
43
|
+
};
|
|
44
|
+
// This is a minimal in-process implementation of a Jest-like test runnner to allow the agent testing example
|
|
45
|
+
// to be run from example runner.
|
|
46
|
+
async function runAgentTesting(_args) {
|
|
47
|
+
const registered = [];
|
|
48
|
+
let currentSuite = "";
|
|
49
|
+
global.describe = (name, fn) => {
|
|
50
|
+
currentSuite = name;
|
|
51
|
+
fn();
|
|
52
|
+
currentSuite = "";
|
|
53
|
+
};
|
|
54
|
+
global.test = (name, fn) => {
|
|
55
|
+
registered.push({ suite: currentSuite, name, fn });
|
|
56
|
+
};
|
|
57
|
+
global.expect = (received) => ({
|
|
58
|
+
toBe(expected) {
|
|
59
|
+
if (received !== expected)
|
|
60
|
+
throw new Error(`Expected ${JSON.stringify(received)} to be ${JSON.stringify(expected)}`);
|
|
61
|
+
},
|
|
62
|
+
toContain(expected) {
|
|
63
|
+
if (!Array.isArray(received) || !received.includes(expected))
|
|
64
|
+
throw new Error(`Expected array to contain ${JSON.stringify(expected)}`);
|
|
65
|
+
},
|
|
66
|
+
toContainEqual(expected) {
|
|
67
|
+
if (!Array.isArray(received) ||
|
|
68
|
+
!received.some((item) => JSON.stringify(item) === JSON.stringify(expected)))
|
|
69
|
+
throw new Error(`Expected array to contain equal to ${JSON.stringify(expected)}`);
|
|
70
|
+
},
|
|
71
|
+
toHaveProperty(key, expected) {
|
|
72
|
+
const obj = received;
|
|
73
|
+
if (!(key in obj))
|
|
74
|
+
throw new Error(`Expected object to have property "${key}"`);
|
|
75
|
+
if (expected !== undefined && obj[key] !== expected)
|
|
76
|
+
throw new Error(`Expected property "${key}" to be ${JSON.stringify(expected)}, got ${JSON.stringify(obj[key])}`);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
const prevLogLevel = process.env.LOG_LEVEL;
|
|
80
|
+
process.env.LOG_LEVEL = "off";
|
|
81
|
+
await Promise.resolve().then(() => __importStar(require("../examples/agent-testing.test")));
|
|
82
|
+
let passed = 0, failed = 0;
|
|
83
|
+
for (const { suite, name, fn } of registered) {
|
|
84
|
+
process.stdout.write(`${c.dim}${suite} › ${name}${c.reset} `);
|
|
85
|
+
try {
|
|
86
|
+
await fn();
|
|
87
|
+
process.stdout.write(`${c.green}✓ passed${c.reset}\n`);
|
|
88
|
+
passed++;
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
process.stdout.write(`${c.red}✗ FAILED${c.reset}\n`);
|
|
92
|
+
console.error(` ${c.red}${e.message}${c.reset}`);
|
|
93
|
+
failed++;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
process.env.LOG_LEVEL = prevLogLevel ?? "";
|
|
97
|
+
const summary = failed > 0
|
|
98
|
+
? `${c.bold}${c.green}${passed} passed${c.reset}, ${c.bold}${c.red}${failed} failed${c.reset}`
|
|
99
|
+
: `${c.bold}${c.green}${passed} passed${c.reset}`;
|
|
100
|
+
console.log(`\n${summary}`);
|
|
101
|
+
if (failed > 0)
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
35
104
|
const EXAMPLES = {
|
|
36
|
-
"scheduling-outbound":
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
105
|
+
"scheduling-outbound": {
|
|
106
|
+
description: "Outbound scheduling agent",
|
|
107
|
+
load: () => Promise.resolve().then(() => __importStar(require("../examples/scheduling-outbound"))),
|
|
108
|
+
},
|
|
109
|
+
"property-insurance": {
|
|
110
|
+
description: "Inbound property insurance Q&A agent",
|
|
111
|
+
load: () => Promise.resolve().then(() => __importStar(require("../examples/property-insurance"))),
|
|
112
|
+
},
|
|
113
|
+
"restaurant-waitlist": {
|
|
114
|
+
description: "Inbound restaurant waitlist agent",
|
|
115
|
+
load: () => Promise.resolve().then(() => __importStar(require("../examples/restaurant-waitlist"))),
|
|
116
|
+
},
|
|
117
|
+
"help-desk": {
|
|
118
|
+
description: "Inbound customer support routing and FAQ agent",
|
|
119
|
+
load: () => Promise.resolve().then(() => __importStar(require("../examples/help-desk"))),
|
|
120
|
+
},
|
|
121
|
+
"polling-campaign": {
|
|
122
|
+
description: "Attach a polling agent to a Guava campaign",
|
|
123
|
+
load: () => Promise.resolve().then(() => __importStar(require("../examples/polling-campaign"))),
|
|
124
|
+
},
|
|
125
|
+
"multiple-agents": {
|
|
126
|
+
description: "Run two agents simultaneously using Runner",
|
|
127
|
+
load: () => Promise.resolve().then(() => __importStar(require("../examples/multiple-agents"))),
|
|
128
|
+
},
|
|
129
|
+
"agent-testing": {
|
|
130
|
+
description: "Run agent unit tests and conversation simulations",
|
|
131
|
+
load: async () => ({ run: runAgentTesting }),
|
|
132
|
+
},
|
|
41
133
|
};
|
|
134
|
+
function printUsage(message) {
|
|
135
|
+
const colWidth = Math.max(...Object.keys(EXAMPLES).map((k) => k.length)) + 3;
|
|
136
|
+
if (message) {
|
|
137
|
+
console.error(`${c.red}${message}${c.reset}\n`);
|
|
138
|
+
}
|
|
139
|
+
console.error(`${c.bold}Usage:${c.reset} guava-example <example-name> [args...]\n`);
|
|
140
|
+
console.error(`${c.bold}Examples:${c.reset}`);
|
|
141
|
+
for (const [name, { description }] of Object.entries(EXAMPLES)) {
|
|
142
|
+
const padded = name.padEnd(colWidth);
|
|
143
|
+
console.error(` ${c.cyan}${padded}${c.reset}${c.dim}${description}${c.reset}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
42
146
|
const exampleName = process.argv[2];
|
|
43
147
|
if (!exampleName) {
|
|
44
|
-
|
|
45
|
-
console.error("Available examples:", Object.keys(EXAMPLES).join(", "));
|
|
148
|
+
printUsage();
|
|
46
149
|
process.exit(1);
|
|
47
150
|
}
|
|
48
151
|
if (!(exampleName in EXAMPLES)) {
|
|
49
|
-
|
|
152
|
+
printUsage(`Unknown example "${exampleName}".`);
|
|
50
153
|
process.exit(1);
|
|
51
154
|
}
|
|
52
155
|
(async () => {
|
|
53
|
-
const mod = await EXAMPLES[exampleName]();
|
|
156
|
+
const mod = await EXAMPLES[exampleName].load();
|
|
54
157
|
await mod.run(process.argv.slice(3));
|
|
55
158
|
})();
|
|
56
159
|
//# sourceMappingURL=example-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example-runner.js","sourceRoot":"","sources":["../../bin/example-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,QAAQ,GAAG;
|
|
1
|
+
{"version":3,"file":"example-runner.js","sourceRoot":"","sources":["../../bin/example-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACzE,MAAM,CAAC,GAAG;IACR,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;IACjC,GAAG,EAAE,SAAS,CAAC,C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AAC,GAAG,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,WAAW,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpC,IAAI,CAAC,WAAW,EAAE,CAAC;IACjB,UAAU,EAAE,CAAC;IACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,CAAC,WAAW,IAAI,QAAQ,CAAC,EAAE,CAAC;IAC/B,UAAU,CAAC,oBAAoB,WAAW,IAAI,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/C,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -9,7 +9,7 @@ const help_desk_1 = require("@guava-ai/guava-sdk/examples/help-desk");
|
|
|
9
9
|
describe("HelpDeskAgent", () => {
|
|
10
10
|
test("handler unit test - new purchase routes to sales", async () => {
|
|
11
11
|
const suggestion = await help_desk_1.agent.handlers.onActionRequest(new guava_sdk_1.MockCall(), "make a new purchase");
|
|
12
|
-
expect(suggestion).
|
|
12
|
+
expect(suggestion).toContainEqual({ key: "sales" });
|
|
13
13
|
});
|
|
14
14
|
test("new purchase routes to sales", async () => {
|
|
15
15
|
const session = await help_desk_1.agent.test(async (session) => {
|
|
@@ -43,4 +43,4 @@ describe("HelpDeskAgent", () => {
|
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=agent-testing.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-testing.test.js","sourceRoot":"","sources":["../../examples/agent-testing.test.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAGH,mDAA+C;AAC/C,sEAA+D;AAE/D,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,UAAU,GAAG,MAAM,iBAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,oBAAQ,EAAE,EAAE,qBAAqB,CAAC,CAAC;QAC/F,MAAM,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,OAAO,GAAG,MAAM,iBAAK,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACjD,iFAAiF;YACjF,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;YAEvD,6CAA6C;YAC7C,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,mEAAmE;QAEnE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAChD,mFAAmF;QACnF,MAAM,OAAO,GAAG,MAAM,iBAAK,CAAC,YAAY,CAAC,6CAA6C,CAAC,CAAC;QAExF,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACzD,4EAA4E;QAC5E,MAAM,OAAO,GAAG,iBAAK,CAAC,KAAK,EAAE,CAAC;QAE9B,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,IAAU,EAAE,EAAE;YAC7C,IAAI,CAAC,MAAM,CACT,8GAA8G,CAC/G,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,6CAA6C,CAAC,CAAC;QAE1F,8FAA8F;QAC9F,MAAM,OAAO,CAAC,QAAQ,CAAC;YACrB,YAAY,EAAE,CAAC,sEAAsE,CAAC;YACtF,YAAY,EAAE,CAAC,2DAA2D,CAAC;SAC5E,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function run(_args: string[]): Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.run = run;
|
|
37
|
+
const guava = __importStar(require("@guava-ai/guava-sdk"));
|
|
38
|
+
const agentA = new guava.Agent({
|
|
39
|
+
name: "Grace",
|
|
40
|
+
purpose: "You are a helpful voice agent.",
|
|
41
|
+
});
|
|
42
|
+
const agentB = new guava.Agent({
|
|
43
|
+
name: "Jordan",
|
|
44
|
+
purpose: "You are a helpful voice agent.",
|
|
45
|
+
});
|
|
46
|
+
async function run(_args) {
|
|
47
|
+
const runner = new guava.Runner();
|
|
48
|
+
runner.listenPhone(agentA, process.env.GUAVA_AGENT_NUMBER);
|
|
49
|
+
runner.listenWebrtc(agentB);
|
|
50
|
+
await runner.run();
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=multiple-agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiple-agents.js","sourceRoot":"","sources":["../../examples/multiple-agents.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,kBAKC;AAjBD,2DAA6C;AAE7C,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC7B,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,gCAAgC;CAC1C,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC7B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,gCAAgC;CAC1C,CAAC,CAAC;AAEI,KAAK,UAAU,GAAG,CAAC,KAAe;IACvC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAClC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAmB,CAAC,CAAC;IAC5D,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -37,6 +37,7 @@ exports.run = run;
|
|
|
37
37
|
const guava = __importStar(require("@guava-ai/guava-sdk"));
|
|
38
38
|
const helpers_1 = require("@guava-ai/guava-sdk/helpers");
|
|
39
39
|
const example_data_1 = require("@guava-ai/guava-sdk/example-data");
|
|
40
|
+
const example_utils_1 = require("@guava-ai/guava-sdk/example-utils");
|
|
40
41
|
const agent = new guava.Agent({
|
|
41
42
|
organization: "Bright Smile Dental",
|
|
42
43
|
purpose: "You are calling patients to help them schedule a dental appointment",
|
|
@@ -65,7 +66,7 @@ agent.onReachPerson(async (call, outcome) => {
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
else {
|
|
68
|
-
await call.hangup("
|
|
69
|
+
await call.hangup("Appropriately end the call.");
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
agent.onTaskComplete("schedule_appointment", async (call) => {
|
|
@@ -83,7 +84,7 @@ async function run(args) {
|
|
|
83
84
|
console.error(" guava-example scheduling-outbound --chat [name]");
|
|
84
85
|
process.exit(1);
|
|
85
86
|
}
|
|
86
|
-
agent.callPhone(
|
|
87
|
+
agent.callPhone(await (0, example_utils_1.getAgentNumber)(), toNumber, {
|
|
87
88
|
patientName: patientName,
|
|
88
89
|
});
|
|
89
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduling-outbound.js","sourceRoot":"","sources":["../../examples/scheduling-outbound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"scheduling-outbound.js","sourceRoot":"","sources":["../../examples/scheduling-outbound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,kBAkBC;AA9DD,2DAA6C;AAC7C,yDAA6D;AAC7D,mEAA6E;AAC7E,qEAAmE;AAEnE,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,YAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE,qEAAqE;CAC/E,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,wBAAc,CAAC,IAAA,wCAAyB,GAAE,CAAC,CAAC;AAEvE,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,IAAgB,EAAE,EAAE;IAC3C,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC;AAEH,KAAK,C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CAAC;IAE1D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QACzE,OAAO,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAM,IAAA,8BAAc,GAAE,EAAE,QAAQ,EAAE;QAChD,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/agent.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { type AgentSpeechEvent, type BotSessionEnded, type CallerSpeechEvent, type DTMFPressedEvent, type EscalateEvent } from "./events.ts";
|
|
1
|
+
import { type AgentSpeechEvent, type BotSessionEnded, type CallerSpeechEvent, type DTMFPressedEvent, type EscalateEvent, type OutboundCallFailed } from "./events.ts";
|
|
2
2
|
import { HealthContext } from "./health.ts";
|
|
3
|
-
import { Call } from "./index.ts";
|
|
3
|
+
import { Call, Client } from "./index.ts";
|
|
4
4
|
import type { CallInfo } from "./socket/call-info.ts";
|
|
5
5
|
import { TestSession } from "./testing/session.ts";
|
|
6
|
+
import * as z from "zod";
|
|
7
|
+
export declare const _roleplayActionSchema: z.ZodObject<{
|
|
8
|
+
action: z.ZodEnum<{
|
|
9
|
+
hangup: "hangup";
|
|
10
|
+
speak: "speak";
|
|
11
|
+
}>;
|
|
12
|
+
utterance: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
6
14
|
export type { CallInfo } from "./socket/call-info.ts";
|
|
7
15
|
export type IncomingCallAction = {
|
|
8
16
|
action: "accept";
|
|
@@ -27,7 +35,7 @@ export declare class Agent {
|
|
|
27
35
|
private _voice?;
|
|
28
36
|
private _acceptDtmfForNumbers;
|
|
29
37
|
private _logger;
|
|
30
|
-
|
|
38
|
+
_client: Client;
|
|
31
39
|
private _onCallReceived;
|
|
32
40
|
private _onCallStart?;
|
|
33
41
|
private _onCallerSpeech?;
|
|
@@ -43,6 +51,7 @@ export declare class Agent {
|
|
|
43
51
|
private _onSessionEnd?;
|
|
44
52
|
private _onEscalate?;
|
|
45
53
|
private _onDtmf?;
|
|
54
|
+
private _onOutboundFailed?;
|
|
46
55
|
constructor(args?: {
|
|
47
56
|
name?: string;
|
|
48
57
|
organization?: string;
|
|
@@ -65,6 +74,7 @@ export declare class Agent {
|
|
|
65
74
|
onSessionEnd(callback: (call: Call, event: BotSessionEnded) => Promise<void>): void;
|
|
66
75
|
onEscalate(callback: (call: Call, event: EscalateEvent) => Promise<void>): void;
|
|
67
76
|
onDtmf(callback: (call: Call, event: DTMFPressedEvent) => Promise<void>): void;
|
|
77
|
+
onOutboundFailed(callback: (event: OutboundCallFailed) => Promise<void>): void;
|
|
68
78
|
get handlers(): {
|
|
69
79
|
onCallReceived: (callInfo: CallInfo) => Promise<IncomingCallAction>;
|
|
70
80
|
onCallStart: (call: Call) => Promise<void>;
|
|
@@ -82,6 +92,7 @@ export declare class Agent {
|
|
|
82
92
|
listenWebrtc(webrtcCode?: string): Promise<void>;
|
|
83
93
|
listenSip(sipCode: string): Promise<void>;
|
|
84
94
|
callLocal(): Promise<void>;
|
|
95
|
+
private _invokeHandler;
|
|
85
96
|
private _dispatchEvent;
|
|
86
97
|
_initCall(callId: string, callInfo: CallInfo, variables?: Record<string, any>): Promise<Call>;
|
|
87
98
|
_attachToCall(callId: string, callInfo: CallInfo, initialVariables?: Record<string, any>, testSession?: TestSession, route?: string): Promise<void>;
|
|
@@ -90,7 +101,7 @@ export declare class Agent {
|
|
|
90
101
|
/**
|
|
91
102
|
* @description use the Guava API to call out to a number
|
|
92
103
|
*/
|
|
93
|
-
callPhone(fromNumber: string
|
|
104
|
+
callPhone(fromNumber: string, toNumber: string, variables?: Record<string, any>): Promise<void>;
|
|
94
105
|
/**
|
|
95
106
|
* Run the agent against a live test session.
|
|
96
107
|
*
|
|
@@ -152,7 +163,7 @@ export declare class Agent {
|
|
|
152
163
|
* affecting the original agent.
|
|
153
164
|
*/
|
|
154
165
|
patch(): Agent;
|
|
155
|
-
|
|
166
|
+
_serveCampaign(healthCtx: HealthContext, campaignCode: string): Promise<void>;
|
|
156
167
|
/**
|
|
157
168
|
* Attach this agent to an active Guava campaign and handle outbound calls.
|
|
158
169
|
*
|
|
@@ -168,5 +179,5 @@ export declare class Agent {
|
|
|
168
179
|
/** @deprecated Use {@link listenPhone} instead. */
|
|
169
180
|
inboundPhone(phoneNumber: string): Promise<void>;
|
|
170
181
|
/** @deprecated Use {@link callPhone} instead. */
|
|
171
|
-
outboundPhone(fromNumber: string
|
|
182
|
+
outboundPhone(fromNumber: string, toNumber: string, variables?: Record<string, any>): Promise<void>;
|
|
172
183
|
}
|