@guava-ai/guava-sdk 0.23.0 → 0.25.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/help-desk.js +22 -8
- package/dist/examples/help-desk.js.map +1 -1
- 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/property-insurance.js +14 -3
- package/dist/examples/property-insurance.js.map +1 -1
- package/dist/examples/restaurant-waitlist.js +9 -1
- package/dist/examples/restaurant-waitlist.js.map +1 -1
- package/dist/examples/scheduling-outbound.js +5 -6
- package/dist/examples/scheduling-outbound.js.map +1 -1
- package/dist/src/action-item.d.ts +4 -4
- package/dist/src/action-item.js +1 -1
- package/dist/src/action-item.js.map +1 -1
- package/dist/src/agent.d.ts +31 -11
- package/dist/src/agent.js +278 -135
- package/dist/src/agent.js.map +1 -1
- package/dist/src/call.d.ts +12 -1
- package/dist/src/call.js +87 -24
- 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 +37 -9
- package/dist/src/commands.js +13 -3
- package/dist/src/commands.js.map +1 -1
- package/dist/src/events.d.ts +28 -1
- package/dist/src/events.js +10 -2
- package/dist/src/events.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/health.d.ts +35 -0
- package/dist/src/health.js +99 -0
- package/dist/src/health.js.map +1 -0
- package/dist/src/helpers/index.d.ts +1 -0
- package/dist/src/helpers/index.js +9 -0
- package/dist/src/helpers/index.js.map +1 -0
- package/dist/src/helpers/llm.d.ts +43 -1
- package/dist/src/helpers/llm.js +247 -0
- package/dist/src/helpers/llm.js.map +1 -1
- package/dist/src/helpers/server-rag.d.ts +25 -0
- package/dist/src/helpers/server-rag.js +119 -0
- package/dist/src/helpers/server-rag.js.map +1 -0
- 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/socket/protocol.d.ts +4 -4
- package/dist/src/testing/mocks.d.ts +6 -0
- package/dist/src/testing/mocks.js +12 -0
- package/dist/src/testing/mocks.js.map +1 -1
- 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/{example.test.ts → agent-testing.test.ts} +1 -1
- package/examples/help-desk.ts +21 -12
- package/examples/multiple-agents.ts +18 -0
- package/examples/property-insurance.ts +15 -3
- package/examples/restaurant-waitlist.ts +10 -1
- package/examples/scheduling-outbound.ts +5 -6
- package/package.json +9 -1
- package/src/action-item.ts +1 -1
- package/src/agent.ts +273 -147
- package/src/call.ts +115 -24
- package/src/client.ts +7 -0
- package/src/commands.ts +16 -2
- package/src/events.ts +11 -1
- package/src/example-utils.ts +87 -0
- package/src/health.ts +120 -0
- package/src/helpers/index.ts +2 -0
- package/src/helpers/llm.ts +170 -1
- package/src/helpers/server-rag.ts +132 -0
- package/src/index.ts +3 -1
- package/src/runner.ts +39 -0
- package/src/testing/mocks.ts +17 -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,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;IAC/B,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;IAClC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE;IACtC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;IAChC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;CAClC,CAAC;AAKF,6GAA6G;AAC7G,iCAA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AAG,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":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,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"}
|
|
@@ -36,23 +36,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.agent = void 0;
|
|
37
37
|
exports.run = run;
|
|
38
38
|
const guava = __importStar(require("@guava-ai/guava-sdk"));
|
|
39
|
-
const
|
|
39
|
+
const helpers_1 = require("@guava-ai/guava-sdk/helpers");
|
|
40
|
+
const helpers_2 = require("@guava-ai/guava-sdk/helpers");
|
|
40
41
|
const example_data_1 = require("@guava-ai/guava-sdk/example-data");
|
|
41
|
-
const guava_sdk_1 = require("@guava-ai/guava-sdk");
|
|
42
42
|
exports.agent = new guava.Agent({
|
|
43
43
|
name: "Nova",
|
|
44
44
|
organization: "Clearfield Home & Living",
|
|
45
45
|
purpose: "Answer questions and route callers to the appropriate department.",
|
|
46
46
|
});
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const documentQA = new helpers_1.DocumentQA({
|
|
48
|
+
documents: example_data_1.FURNITURE_RETAILER_QA,
|
|
49
|
+
namespace: "clearfield-home-living-qa",
|
|
50
|
+
});
|
|
51
|
+
const intentRecognizer = new helpers_2.IntentRecognizer([
|
|
52
|
+
"sales",
|
|
53
|
+
"delivery-and-returns",
|
|
54
|
+
"account-management",
|
|
55
|
+
"other",
|
|
56
|
+
]);
|
|
50
57
|
exports.agent.onQuestion(async (_call, question) => {
|
|
51
58
|
return await documentQA.ask(question);
|
|
52
59
|
});
|
|
53
60
|
exports.agent.onActionRequest(async (_call, request) => {
|
|
54
|
-
|
|
55
|
-
return { key };
|
|
61
|
+
return await intentRecognizer.classify(request);
|
|
56
62
|
});
|
|
57
63
|
exports.agent.onAction("sales", async (call) => {
|
|
58
64
|
call.transfer("+15555555555", "Notify the caller that you will be transferring them to the Sales department.");
|
|
@@ -73,6 +79,14 @@ async function run(args) {
|
|
|
73
79
|
else if (args.includes("--phone")) {
|
|
74
80
|
exports.agent.listenPhone(process.env.GUAVA_AGENT_NUMBER);
|
|
75
81
|
}
|
|
82
|
+
else if (args.includes("--sip")) {
|
|
83
|
+
const sipCode = args[args.indexOf("--sip") + 1];
|
|
84
|
+
if (!sipCode) {
|
|
85
|
+
console.error("Error: --sip requires a SIP code argument.");
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
await exports.agent.listenSip(sipCode);
|
|
89
|
+
}
|
|
76
90
|
else if (args.includes("--local")) {
|
|
77
91
|
await exports.agent.callLocal();
|
|
78
92
|
}
|
|
@@ -80,7 +94,7 @@ async function run(args) {
|
|
|
80
94
|
await exports.agent.chat();
|
|
81
95
|
}
|
|
82
96
|
else {
|
|
83
|
-
console.error("Usage: guava-example help-desk --phone | --webrtc | --local | --chat");
|
|
97
|
+
console.error("Usage: guava-example help-desk --phone | --webrtc | --sip | --local | --chat");
|
|
84
98
|
process.exit(1);
|
|
85
99
|
}
|
|
86
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-desk.js","sourceRoot":"","sources":["../../examples/help-desk.ts"],"names":[],"mappings":";;;;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,IAAI,EAAE,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAC9F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,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"}
|
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.run = run;
|
|
37
37
|
const guava = __importStar(require("@guava-ai/guava-sdk"));
|
|
38
|
-
const
|
|
38
|
+
const helpers_1 = require("@guava-ai/guava-sdk/helpers");
|
|
39
39
|
const example_data_1 = require("@guava-ai/guava-sdk/example-data");
|
|
40
40
|
const agent = new guava.Agent({
|
|
41
41
|
organization: "Harper Valley Property Insurance",
|
|
@@ -43,7 +43,10 @@ const agent = new guava.Agent({
|
|
|
43
43
|
});
|
|
44
44
|
// This is a built-in knowledge base helper that we will use for this example.
|
|
45
45
|
// You can use any RAG system you prefer.
|
|
46
|
-
const documentQA = new
|
|
46
|
+
const documentQA = new helpers_1.DocumentQA({
|
|
47
|
+
documents: example_data_1.PROPERTY_INSURANCE_POLICY,
|
|
48
|
+
namespace: "harper-valley-property-insurance",
|
|
49
|
+
});
|
|
47
50
|
// When the Agent is asked a question that it cannot answer, it will invoke the on_question callback.
|
|
48
51
|
agent.onQuestion(async (call, question) => {
|
|
49
52
|
// Forward the Agent's question to the knowledge base and return the answer.
|
|
@@ -57,6 +60,14 @@ async function run(args) {
|
|
|
57
60
|
else if (args.includes("--phone")) {
|
|
58
61
|
agent.listenPhone(process.env.GUAVA_AGENT_NUMBER);
|
|
59
62
|
}
|
|
63
|
+
else if (args.includes("--sip")) {
|
|
64
|
+
const sipCode = args[args.indexOf("--sip") + 1];
|
|
65
|
+
if (!sipCode) {
|
|
66
|
+
console.error("Error: --sip requires a SIP code argument.");
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
await agent.listenSip(sipCode);
|
|
70
|
+
}
|
|
60
71
|
else if (args.includes("--local")) {
|
|
61
72
|
await agent.callLocal();
|
|
62
73
|
}
|
|
@@ -64,7 +75,7 @@ async function run(args) {
|
|
|
64
75
|
await agent.chat();
|
|
65
76
|
}
|
|
66
77
|
else {
|
|
67
|
-
console.error("Usage: guava-example property-insurance --phone | --webrtc | --local | --chat");
|
|
78
|
+
console.error("Usage: guava-example property-insurance --phone | --webrtc | --sip | --local | --chat");
|
|
68
79
|
process.exit(1);
|
|
69
80
|
}
|
|
70
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-insurance.js","sourceRoot":"","sources":["../../examples/property-insurance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"property-insurance.js","sourceRoot":"","sources":["../../examples/property-insurance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,kBAsBC;AA7CD,2DAA6C;AAC7C,yDAAyD;AACzD,mEAA6E;AAE7E,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,YAAY,EAAE,kCAAkC;IAChD,OAAO,EAAE,wFAAwF;CAClG,CAAC,CAAC;AAEH,8EAA8E;AAC9E,yCAAyC;AACzC,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC;IAChC,SAAS,EAAE,wCAAyB;IACpC,SAAS,EAAE,kCAAkC;CAC9C,CAAC,CAAC;AAEH,qGAAqG;AACrG,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,IAAgB,EAAE,QAAgB,EAAE,EAAE;IAC5D,4EAA4E;IAC5E,2DAA2D;IAC3D,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC;AAEI,KAAK,UAAU,GAAG,CAAC,IAAc;IACtC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,CAAC,YAAY,EAAE,CAAC;IAC7B,CAAC;SAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,CAAC,CAAC;IACrD,CAAC;SAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;SAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACpC,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;SAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CACX,uFAAuF,CACxF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -75,6 +75,14 @@ async function run(args) {
|
|
|
75
75
|
else if (args.includes("--phone")) {
|
|
76
76
|
agent.listenPhone(process.env.GUAVA_AGENT_NUMBER);
|
|
77
77
|
}
|
|
78
|
+
else if (args.includes("--sip")) {
|
|
79
|
+
const sipCode = args[args.indexOf("--sip") + 1];
|
|
80
|
+
if (!sipCode) {
|
|
81
|
+
console.error("Error: --sip requires a SIP code argument.");
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
await agent.listenSip(sipCode);
|
|
85
|
+
}
|
|
78
86
|
else if (args.includes("--local")) {
|
|
79
87
|
await agent.callLocal();
|
|
80
88
|
}
|
|
@@ -82,7 +90,7 @@ async function run(args) {
|
|
|
82
90
|
await agent.chat();
|
|
83
91
|
}
|
|
84
92
|
else {
|
|
85
|
-
console.error("Usage: guava-example restaurant-waitlist --phone | --webrtc | --local | --chat");
|
|
93
|
+
console.error("Usage: guava-example restaurant-waitlist --phone | --webrtc | --sip | --local | --chat");
|
|
86
94
|
process.exit(1);
|
|
87
95
|
}
|
|
88
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restaurant-waitlist.js","sourceRoot":"","sources":["../../examples/restaurant-waitlist.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,
|
|
1
|
+
{"version":3,"file":"restaurant-waitlist.js","sourceRoot":"","sources":["../../examples/restaurant-waitlist.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,kBAsBC;AAlED,2DAA6C;AAC7C,mDAAuD;AAEvD,MAAM,MAAM,GAAG,IAAA,4BAAgB,GAAE,CAAC;AAElC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,IAAI,EAAE,KAAK;IACX,YAAY,EAAE,aAAa;IAC3B,OAAO,EAAE,8CAA8C;CACxD,CAAC,CAAC;AAEH,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,SAAyB,EAAE,EAAE;IACvD,6FAA6F;IAC7F,8FAA8F;IAC9F,uBAAuB;IACvB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,IAAgB,EAAE,EAAE;IAC3C,MAAM,IAAI,CAAC,OAAO,CAAC;QACjB,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,2EAA2E;QACtF,SAAS,EAAE;YACT,KAAK,CAAC,KA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