@guava-ai/guava-sdk 0.1.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.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ const exampleName = process.argv[2];
4
+ if (!exampleName) {
5
+ console.error("Usage: guava-example <example-name> <example-args>");
6
+ process.exit(1);
7
+ }
8
+
9
+ const run = async () => {
10
+ try {
11
+ // ESM dynamic import works in both ESM packages and CJS CLI files in modern Node
12
+ const exampleModule = await import(new URL(`../dist/examples/${exampleName}.js`, import.meta.url));
13
+ exampleModule.run(process.argv.slice(3))
14
+ } catch (err) {
15
+ if (err.code === "ERR_MODULE_NOT_FOUND") {
16
+ console.error(`Couldn't find example: ${exampleName}`)
17
+ } else {
18
+ console.error(err);
19
+ }
20
+ process.exit(1);
21
+ }
22
+ };
23
+
24
+ run();
@@ -0,0 +1 @@
1
+ export declare function run(args: string[]): void;
@@ -0,0 +1,41 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as guava from "../src/index.js";
11
+ import { DocumentQA } from "../src/helpers/openai.js";
12
+ import { PROPERTY_INSURANCE_POLICY } from "../src/example_data.js";
13
+ class InsuranceCallController extends guava.CallController {
14
+ constructor(logger) {
15
+ super(logger);
16
+ this.documentQA = new DocumentQA("harper-valley-property-insurance", PROPERTY_INSURANCE_POLICY, logger);
17
+ }
18
+ onCallStart() {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ yield this.setPersona("Harper Valley Property Insurance");
21
+ yield this.setTask("You are making an outbound call to a potential customer. Your task is to answer questions regarding property insurance policy until there are no more questions.");
22
+ });
23
+ }
24
+ onQuestion(question) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return yield this.documentQA.ask(question);
27
+ });
28
+ }
29
+ }
30
+ export function run(args) {
31
+ const [phone] = args;
32
+ if (!phone) {
33
+ console.error("Usage: guava-example property-insurance <phone>");
34
+ process.exit(1);
35
+ }
36
+ new guava.Client().createOutbound(process.env.GUAVA_AGENT_NUMBER, phone, (logger) => new InsuranceCallController(logger));
37
+ }
38
+ if (import.meta.main) {
39
+ run(process.argv.slice(2));
40
+ }
41
+ //# sourceMappingURL=property-insurance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-insurance.js","sourceRoot":"","sources":["../../examples/property-insurance.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;AAEjE,MAAM,uBAAwB,SAAQ,KAAK,CAAC,cAAc;IAExD,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAC9B,kCAAkC,EAClC,yBAAyB,EACzB,MAAM,CACP,CAAC;IACJ,CAAC;IACc,WAAW;;YACxB,MAAM,IAAI,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC;YAC1D,MAAM,IAAI,CAAC,OAAO,CAChB,kKAAkK,CACnK,CAAC;QACJ,CAAC;KAAA;IAEc,UAAU,CAAC,QAAgB;;YACxC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;KAAA;CACF;AAED,MAAM,UAAU,GAAG,CAAC,IAAc;IAChC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAErB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,cAAc,CAC/B,OAAO,CAAC,GAAG,CAAC,kBAAmB,EAC/B,KAAK,EACL,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAChD,CAAC;AACJ,CAAC;AAED,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@guava-ai/guava-sdk",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "devDependencies": {
8
+ "@biomejs/biome": "2.3.11",
9
+ "@types/node": "^25.0.7",
10
+ "@types/ws": "^8.18.1",
11
+ "typescript": "^5.9.3"
12
+ },
13
+ "bin": {
14
+ "guava-example": "./bin/example-runner.js"
15
+ },
16
+ "dependencies": {
17
+ "openai": "^6.16.0",
18
+ "ws": "^8.19.0",
19
+ "zod": "^4.3.5"
20
+ },
21
+ "scripts": {
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "biome lint",
24
+ "format": "biome format --write ./src",
25
+ "format-ex": "biome format --write ./examples",
26
+ "check": "npm run typecheck && npm audit",
27
+ "clean": "rm -rf ./dist",
28
+ "build": "tsc",
29
+ "prepublishOnly": "npm run clean && npm run build"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "files": [
35
+ "/src",
36
+ "/dist",
37
+ "/examples",
38
+ "/bin"
39
+ ]
40
+ }
@@ -0,0 +1,41 @@
1
+ import * as z from "zod";
2
+ export declare const fieldItemType: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
3
+ export type FieldItemType = z.input<typeof fieldItemType>;
4
+ export declare const fieldItem: z.ZodObject<{
5
+ item_type: z.ZodLiteral<"field">;
6
+ key: z.ZodString;
7
+ description: z.ZodString;
8
+ field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
9
+ required: z.ZodDefault<z.ZodBoolean>;
10
+ choices: z.ZodArray<z.ZodString>;
11
+ }, z.core.$strip>;
12
+ export type Field = z.input<typeof fieldItem>;
13
+ export declare const sayItem: z.ZodObject<{
14
+ item_type: z.ZodLiteral<"say">;
15
+ statement: z.ZodString;
16
+ key: z.ZodDefault<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ export type Say = z.input<typeof sayItem>;
19
+ export declare const todoItem: z.ZodObject<{
20
+ item_type: z.ZodLiteral<"todo">;
21
+ description: z.ZodString;
22
+ key: z.ZodDefault<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ export type Todo = z.input<typeof todoItem>;
25
+ export declare const actionItem: z.ZodUnion<readonly [z.ZodObject<{
26
+ item_type: z.ZodLiteral<"field">;
27
+ key: z.ZodString;
28
+ description: z.ZodString;
29
+ field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
30
+ required: z.ZodDefault<z.ZodBoolean>;
31
+ choices: z.ZodArray<z.ZodString>;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ item_type: z.ZodLiteral<"say">;
34
+ statement: z.ZodString;
35
+ key: z.ZodDefault<z.ZodString>;
36
+ }, z.core.$strip>, z.ZodObject<{
37
+ item_type: z.ZodLiteral<"todo">;
38
+ description: z.ZodString;
39
+ key: z.ZodDefault<z.ZodString>;
40
+ }, z.core.$strip>]>;
41
+ export type ActionItem = z.input<typeof actionItem>;
@@ -0,0 +1,29 @@
1
+ import * as z from "zod";
2
+ export const fieldItemType = z.union(["text", "date", "datetime", "integer", "multiple_choice"].map((val) => z.literal(val)));
3
+ export const fieldItem = z
4
+ .object({
5
+ item_type: z.literal("field"),
6
+ key: z.string(),
7
+ description: z.string(),
8
+ field_type: fieldItemType,
9
+ required: z.boolean().default(true),
10
+ choices: z.array(z.string()),
11
+ })
12
+ .refine((field) => {
13
+ if (field.field_type == "multiple_choice" && field.choices.length > 10) {
14
+ process.emitWarning("Performance degrades with large number of choices for multiple choice field.", "ACTION_ITEM");
15
+ }
16
+ return true;
17
+ });
18
+ export const sayItem = z.object({
19
+ item_type: z.literal("say"),
20
+ statement: z.string(),
21
+ key: z.string().default(() => Math.random().toString(16).substring(2, 6)),
22
+ });
23
+ export const todoItem = z.object({
24
+ item_type: z.literal("todo"),
25
+ description: z.string(),
26
+ key: z.string().default(() => Math.random().toString(16).substring(2, 6)),
27
+ });
28
+ export const actionItem = z.union([fieldItem, sayItem, todoItem]);
29
+ //# sourceMappingURL=action_item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action_item.js","sourceRoot":"","sources":["../../src/action_item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CACjC,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,CAAW,CAAC,GAAG,CACvE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CACxB,CACF,CAAC;AAGF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,CAAC,CAAC,O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@ -0,0 +1,181 @@
1
+ import * as z from "zod";
2
+ export declare const startOutboundCallCommand: z.ZodObject<{
3
+ command_type: z.ZodLiteral<"start-outbound">;
4
+ from_number: z.ZodOptional<z.ZodE164>;
5
+ to_number: z.ZodE164;
6
+ }, z.core.$strict>;
7
+ export type StartOutboundCallCommand = z.input<typeof startOutboundCallCommand>;
8
+ export declare const listenInboundCommand: z.ZodObject<{
9
+ command_type: z.ZodLiteral<"listen-inbound">;
10
+ agent_number: z.ZodOptional<z.ZodE164>;
11
+ webrtc_code: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strict>;
13
+ export type ListenInboundCommand = z.input<typeof listenInboundCommand>;
14
+ export declare const rejectInboundCallCommand: z.ZodObject<{
15
+ command_type: z.ZodLiteral<"reject-inbound">;
16
+ }, z.core.$strict>;
17
+ export type RejectInboundCallCommand = z.input<typeof rejectInboundCallCommand>;
18
+ export declare const acceptInboundCallCommand: z.ZodObject<{
19
+ command_type: z.ZodLiteral<"accept-inbound">;
20
+ }, z.core.$strict>;
21
+ export type AcceptInboundCallCommand = z.input<typeof acceptInboundCallCommand>;
22
+ export declare const setTaskCommand: z.ZodObject<{
23
+ command_type: z.ZodLiteral<"set-task">;
24
+ task_id: z.ZodString;
25
+ objective: z.ZodString;
26
+ action_items: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
27
+ item_type: z.ZodLiteral<"field">;
28
+ key: z.ZodString;
29
+ description: z.ZodString;
30
+ field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
31
+ required: z.ZodDefault<z.ZodBoolean>;
32
+ choices: z.ZodArray<z.ZodString>;
33
+ }, z.core.$strip>, z.ZodObject<{
34
+ item_type: z.ZodLiteral<"say">;
35
+ statement: z.ZodString;
36
+ key: z.ZodDefault<z.ZodString>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ item_type: z.ZodLiteral<"todo">;
39
+ description: z.ZodString;
40
+ key: z.ZodDefault<z.ZodString>;
41
+ }, z.core.$strip>]>>;
42
+ }, z.core.$strict>;
43
+ export type SetTaskCommand = z.input<typeof setTaskCommand>;
44
+ export declare const readScriptCommand: z.ZodObject<{
45
+ command_type: z.ZodLiteral<"read-script">;
46
+ script: z.ZodString;
47
+ }, z.core.$strict>;
48
+ export type ReadScriptCommand = z.input<typeof readScriptCommand>;
49
+ export declare const answerQuestionCommand: z.ZodObject<{
50
+ command_type: z.ZodLiteral<"answer-question">;
51
+ question_id: z.ZodString;
52
+ answer: z.ZodString;
53
+ }, z.core.$strict>;
54
+ export type AnswerQuestionCommand = z.input<typeof answerQuestionCommand>;
55
+ export declare const setPersona: z.ZodObject<{
56
+ command_type: z.ZodLiteral<"set-persona">;
57
+ agent_name: z.ZodOptional<z.ZodString>;
58
+ organization_name: z.ZodOptional<z.ZodString>;
59
+ agent_purpose: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strict>;
61
+ export type SetPersona = z.input<typeof setPersona>;
62
+ export declare const sendInstructionCommand: z.ZodObject<{
63
+ command_type: z.ZodLiteral<"send-instruction">;
64
+ instruction: z.ZodString;
65
+ }, z.core.$strict>;
66
+ export type SendInstructionCommand = z.input<typeof sendInstructionCommand>;
67
+ export declare const transferCommand: z.ZodObject<{
68
+ command_type: z.ZodLiteral<"transfer-call">;
69
+ transfer_message: z.ZodString;
70
+ to_number: z.ZodString;
71
+ }, z.core.$strict>;
72
+ export type TransferCommand = z.input<typeof transferCommand>;
73
+ export declare const anyCommand: z.ZodUnion<readonly [z.ZodObject<{
74
+ command_type: z.ZodLiteral<"start-outbound">;
75
+ from_number: z.ZodOptional<z.ZodE164>;
76
+ to_number: z.ZodE164;
77
+ }, z.core.$strict>, z.ZodObject<{
78
+ command_type: z.ZodLiteral<"listen-inbound">;
79
+ agent_number: z.ZodOptional<z.ZodE164>;
80
+ webrtc_code: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strict>, z.ZodObject<{
82
+ command_type: z.ZodLiteral<"reject-inbound">;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ command_type: z.ZodLiteral<"accept-inbound">;
85
+ }, z.core.$strict>, z.ZodObject<{
86
+ command_type: z.ZodLiteral<"set-task">;
87
+ task_id: z.ZodString;
88
+ objective: z.ZodString;
89
+ action_items: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
90
+ item_type: z.ZodLiteral<"field">;
91
+ key: z.ZodString;
92
+ description: z.ZodString;
93
+ field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
94
+ required: z.ZodDefault<z.ZodBoolean>;
95
+ choices: z.ZodArray<z.ZodString>;
96
+ }, z.core.$strip>, z.ZodObject<{
97
+ item_type: z.ZodLiteral<"say">;
98
+ statement: z.ZodString;
99
+ key: z.ZodDefault<z.ZodString>;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ item_type: z.ZodLiteral<"todo">;
102
+ description: z.ZodString;
103
+ key: z.ZodDefault<z.ZodString>;
104
+ }, z.core.$strip>]>>;
105
+ }, z.core.$strict>, z.ZodObject<{
106
+ command_type: z.ZodLiteral<"read-script">;
107
+ script: z.ZodString;
108
+ }, z.core.$strict>, z.ZodObject<{
109
+ command_type: z.ZodLiteral<"answer-question">;
110
+ question_id: z.ZodString;
111
+ answer: z.ZodString;
112
+ }, z.core.$strict>, z.ZodObject<{
113
+ command_type: z.ZodLiteral<"set-persona">;
114
+ agent_name: z.ZodOptional<z.ZodString>;
115
+ organization_name: z.ZodOptional<z.ZodString>;
116
+ agent_purpose: z.ZodOptional<z.ZodString>;
117
+ }, z.core.$strict>, z.ZodObject<{
118
+ command_type: z.ZodLiteral<"send-instruction">;
119
+ instruction: z.ZodString;
120
+ }, z.core.$strict>, z.ZodObject<{
121
+ command_type: z.ZodLiteral<"transfer-call">;
122
+ transfer_message: z.ZodString;
123
+ to_number: z.ZodString;
124
+ }, z.core.$strict>]>;
125
+ export type Command = z.input<typeof anyCommand>;
126
+ export declare const inboundTunnelCommand: z.ZodObject<{
127
+ call_id: z.ZodString;
128
+ command: z.ZodUnion<readonly [z.ZodObject<{
129
+ command_type: z.ZodLiteral<"start-outbound">;
130
+ from_number: z.ZodOptional<z.ZodE164>;
131
+ to_number: z.ZodE164;
132
+ }, z.core.$strict>, z.ZodObject<{
133
+ command_type: z.ZodLiteral<"listen-inbound">;
134
+ agent_number: z.ZodOptional<z.ZodE164>;
135
+ webrtc_code: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strict>, z.ZodObject<{
137
+ command_type: z.ZodLiteral<"reject-inbound">;
138
+ }, z.core.$strict>, z.ZodObject<{
139
+ command_type: z.ZodLiteral<"accept-inbound">;
140
+ }, z.core.$strict>, z.ZodObject<{
141
+ command_type: z.ZodLiteral<"set-task">;
142
+ task_id: z.ZodString;
143
+ objective: z.ZodString;
144
+ action_items: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
145
+ item_type: z.ZodLiteral<"field">;
146
+ key: z.ZodString;
147
+ description: z.ZodString;
148
+ field_type: z.ZodUnion<z.ZodLiteral<"text" | "integer" | "date" | "datetime" | "multiple_choice">[]>;
149
+ required: z.ZodDefault<z.ZodBoolean>;
150
+ choices: z.ZodArray<z.ZodString>;
151
+ }, z.core.$strip>, z.ZodObject<{
152
+ item_type: z.ZodLiteral<"say">;
153
+ statement: z.ZodString;
154
+ key: z.ZodDefault<z.ZodString>;
155
+ }, z.core.$strip>, z.ZodObject<{
156
+ item_type: z.ZodLiteral<"todo">;
157
+ description: z.ZodString;
158
+ key: z.ZodDefault<z.ZodString>;
159
+ }, z.core.$strip>]>>;
160
+ }, z.core.$strict>, z.ZodObject<{
161
+ command_type: z.ZodLiteral<"read-script">;
162
+ script: z.ZodString;
163
+ }, z.core.$strict>, z.ZodObject<{
164
+ command_type: z.ZodLiteral<"answer-question">;
165
+ question_id: z.ZodString;
166
+ answer: z.ZodString;
167
+ }, z.core.$strict>, z.ZodObject<{
168
+ command_type: z.ZodLiteral<"set-persona">;
169
+ agent_name: z.ZodOptional<z.ZodString>;
170
+ organization_name: z.ZodOptional<z.ZodString>;
171
+ agent_purpose: z.ZodOptional<z.ZodString>;
172
+ }, z.core.$strict>, z.ZodObject<{
173
+ command_type: z.ZodLiteral<"send-instruction">;
174
+ instruction: z.ZodString;
175
+ }, z.core.$strict>, z.ZodObject<{
176
+ command_type: z.ZodLiteral<"transfer-call">;
177
+ transfer_message: z.ZodString;
178
+ to_number: z.ZodString;
179
+ }, z.core.$strict>]>;
180
+ }, z.core.$strict>;
181
+ export type InboundTunnelCommand = z.input<typeof inboundTunnelCommand>;
@@ -0,0 +1,69 @@
1
+ import * as z from "zod";
2
+ import { actionItem } from "./action_item.js";
3
+ export const startOutboundCallCommand = z.strictObject({
4
+ command_type: z.literal("start-outbound"),
5
+ from_number: z.e164().optional(),
6
+ to_number: z.e164(),
7
+ });
8
+ export const listenInboundCommand = z
9
+ .strictObject({
10
+ command_type: z.literal("listen-inbound"),
11
+ agent_number: z.e164().optional(),
12
+ webrtc_code: z.string().optional(),
13
+ })
14
+ .refine((obj) => {
15
+ !!obj.agent_number || !!obj.webrtc_code;
16
+ });
17
+ export const rejectInboundCallCommand = z.strictObject({
18
+ command_type: z.literal("reject-inbound"),
19
+ });
20
+ export const acceptInboundCallCommand = z.strictObject({
21
+ command_type: z.literal("accept-inbound"),
22
+ });
23
+ export const setTaskCommand = z.strictObject({
24
+ command_type: z.literal("set-task"),
25
+ task_id: z.string(),
26
+ objective: z.string(),
27
+ action_items: z.array(actionItem),
28
+ });
29
+ export const readScriptCommand = z.strictObject({
30
+ command_type: z.literal("read-script"),
31
+ script: z.string(),
32
+ });
33
+ export const answerQuestionCommand = z.strictObject({
34
+ command_type: z.literal("answer-question"),
35
+ question_id: z.string(),
36
+ answer: z.string(),
37
+ });
38
+ export const setPersona = z.strictObject({
39
+ command_type: z.literal("set-persona"),
40
+ agent_name: z.string().optional(),
41
+ organization_name: z.string().optional(),
42
+ agent_purpose: z.string().optional(),
43
+ });
44
+ export const sendInstructionCommand = z.strictObject({
45
+ command_type: z.literal("send-instruction"),
46
+ instruction: z.string(),
47
+ });
48
+ export const transferCommand = z.strictObject({
49
+ command_type: z.literal("transfer-call"),
50
+ transfer_message: z.string(),
51
+ to_number: z.string(),
52
+ });
53
+ export const anyCommand = z.union([
54
+ startOutboundCallCommand,
55
+ listenInboundCommand,
56
+ rejectInboundCallCommand,
57
+ acceptInboundCallCommand,
58
+ setTaskCommand,
59
+ readScriptCommand,
60
+ answerQuestionCommand,
61
+ setPersona,
62
+ sendInstructionCommand,
63
+ transferCommand,
64
+ ]);
65
+ export const inboundTunnelCommand = z.strictObject({
66
+ call_id: z.string(),
67
+ command: anyCommand,
68
+ });
69
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,YAAY,CAAC;IACrD,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAEzC,WAAW,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE;CACpB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,YAAY,CAAC;IACZ,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IAEzC,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC;KACD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;IACd,CAAC,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,WAAW,CAA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E,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,YAAY,CAAC;IACnD,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAC3C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5C,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IACxC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC;IAChC,wBAAwB;IACxB,oBAAoB;IACpB,wBAAwB;IACxB,wBAAwB;IACxB,cAAc;IACd,iBAAiB;IACjB,qBAAqB;IACrB,UAAU;IACV,sBAAsB;IACtB,eAAe;CAChB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,UAAU;CACpB,CAAC,CAAC"}
@@ -0,0 +1,170 @@
1
+ import * as z from "zod";
2
+ export declare const sessionStartedEvent: z.ZodObject<{
3
+ event_type: z.ZodLiteral<"session-started">;
4
+ session_id: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export type SessionStartedEvent = z.input<typeof sessionStartedEvent>;
7
+ export declare const inboundCallEvent: z.ZodObject<{
8
+ event_type: z.ZodLiteral<"inbound-call">;
9
+ caller_number: z.ZodOptional<z.ZodE164>;
10
+ agent_number: z.ZodOptional<z.ZodE164>;
11
+ }, z.core.$strip>;
12
+ export type InboundCallEvent = z.input<typeof inboundCallEvent>;
13
+ /**
14
+ * @description The caller has said something.
15
+ */
16
+ export declare const callerSpeechEvent: z.ZodObject<{
17
+ event_type: z.ZodLiteral<"caller-speech">;
18
+ utterance: z.ZodString;
19
+ }, z.core.$strip>;
20
+ export type CallerSpeechEvent = z.input<typeof callerSpeechEvent>;
21
+ /**
22
+ * @description The agent has said something.
23
+ */
24
+ export declare const agentSpeechEvent: z.ZodObject<{
25
+ event_type: z.ZodLiteral<"agent-speech">;
26
+ utterance: z.ZodString;
27
+ interrupted: z.ZodDefault<z.ZodBoolean>;
28
+ }, z.core.$strip>;
29
+ export type AgentSpeechEvent = z.input<typeof agentSpeechEvent>;
30
+ export declare const errorEvent: z.ZodObject<{
31
+ event_type: z.ZodLiteral<"error">;
32
+ content: z.ZodString;
33
+ }, z.core.$strip>;
34
+ export type ErrorEvent = z.input<typeof errorEvent>;
35
+ export declare const warningEvent: z.ZodObject<{
36
+ event_type: z.ZodLiteral<"warning">;
37
+ content: z.ZodString;
38
+ }, z.core.$strip>;
39
+ export type WarningEvent = z.input<typeof warningEvent>;
40
+ export declare const agentQuestionEvent: z.ZodObject<{
41
+ event_type: z.ZodLiteral<"agent-question">;
42
+ question_id: z.ZodString;
43
+ question: z.ZodString;
44
+ }, z.core.$strip>;
45
+ export type AgentQuestionEvent = z.input<typeof agentQuestionEvent>;
46
+ export declare const intentEvent: z.ZodObject<{
47
+ event_type: z.ZodLiteral<"intent">;
48
+ intent_id: z.ZodString;
49
+ intent_summary: z.ZodString;
50
+ }, z.core.$strip>;
51
+ export type IntentEvent = z.input<typeof intentEvent>;
52
+ export declare const actionItemCompletedEvent: z.ZodObject<{
53
+ event_type: z.ZodLiteral<"action-item-done">;
54
+ key: z.ZodString;
55
+ payload: z.ZodUnknown;
56
+ }, z.core.$strip>;
57
+ export type ActionItemCompletedEvent = z.input<typeof actionItemCompletedEvent>;
58
+ export declare const taskCompletedEvent: z.ZodObject<{
59
+ event_type: z.ZodLiteral<"task-done">;
60
+ task_id: z.ZodString;
61
+ }, z.core.$strip>;
62
+ export type TaskCompletedEvent = z.input<typeof taskCompletedEvent>;
63
+ export declare const outboundCallConnected: z.ZodObject<{
64
+ event_type: z.ZodLiteral<"outbound-call-connected">;
65
+ }, z.core.$strip>;
66
+ export type OutboundCallConnected = z.input<typeof outboundCallConnected>;
67
+ export declare const outboundCallFailed: z.ZodObject<{
68
+ event_type: z.ZodLiteral<"outbound-call-failed">;
69
+ error_code: z.ZodInt;
70
+ error_reason: z.ZodString;
71
+ }, z.core.$strip>;
72
+ export type OutboundCallFailed = z.input<typeof outboundCallFailed>;
73
+ export declare const botSessionEnded: z.ZodObject<{
74
+ event_type: z.ZodLiteral<"bot-session-ended">;
75
+ }, z.core.$strip>;
76
+ export type BotSessionEnded = z.input<typeof botSessionEnded>;
77
+ export declare const anyEvent: z.ZodUnion<readonly [z.ZodObject<{
78
+ event_type: z.ZodLiteral<"session-started">;
79
+ session_id: z.ZodString;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ event_type: z.ZodLiteral<"inbound-call">;
82
+ caller_number: z.ZodOptional<z.ZodE164>;
83
+ agent_number: z.ZodOptional<z.ZodE164>;
84
+ }, z.core.$strip>, z.ZodObject<{
85
+ event_type: z.ZodLiteral<"caller-speech">;
86
+ utterance: z.ZodString;
87
+ }, z.core.$strip>, z.ZodObject<{
88
+ event_type: z.ZodLiteral<"agent-speech">;
89
+ utterance: z.ZodString;
90
+ interrupted: z.ZodDefault<z.ZodBoolean>;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ event_type: z.ZodLiteral<"error">;
93
+ content: z.ZodString;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ event_type: z.ZodLiteral<"warning">;
96
+ content: z.ZodString;
97
+ }, z.core.$strip>, z.ZodObject<{
98
+ event_type: z.ZodLiteral<"agent-question">;
99
+ question_id: z.ZodString;
100
+ question: z.ZodString;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ event_type: z.ZodLiteral<"intent">;
103
+ intent_id: z.ZodString;
104
+ intent_summary: z.ZodString;
105
+ }, z.core.$strip>, z.ZodObject<{
106
+ event_type: z.ZodLiteral<"action-item-done">;
107
+ key: z.ZodString;
108
+ payload: z.ZodUnknown;
109
+ }, z.core.$strip>, z.ZodObject<{
110
+ event_type: z.ZodLiteral<"task-done">;
111
+ task_id: z.ZodString;
112
+ }, z.core.$strip>, z.ZodObject<{
113
+ event_type: z.ZodLiteral<"outbound-call-connected">;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ event_type: z.ZodLiteral<"outbound-call-failed">;
116
+ error_code: z.ZodInt;
117
+ error_reason: z.ZodString;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ event_type: z.ZodLiteral<"bot-session-ended">;
120
+ }, z.core.$strip>]>;
121
+ export type GuavaEvent = z.input<typeof anyEvent>;
122
+ export declare function decodeEvent(serialized_event: string | ArrayBuffer | Buffer | Buffer[]): GuavaEvent | null;
123
+ export declare const inboundTunnelEvent: z.ZodObject<{
124
+ call_id: z.ZodString;
125
+ event: z.ZodUnion<readonly [z.ZodObject<{
126
+ event_type: z.ZodLiteral<"session-started">;
127
+ session_id: z.ZodString;
128
+ }, z.core.$strip>, z.ZodObject<{
129
+ event_type: z.ZodLiteral<"inbound-call">;
130
+ caller_number: z.ZodOptional<z.ZodE164>;
131
+ agent_number: z.ZodOptional<z.ZodE164>;
132
+ }, z.core.$strip>, z.ZodObject<{
133
+ event_type: z.ZodLiteral<"caller-speech">;
134
+ utterance: z.ZodString;
135
+ }, z.core.$strip>, z.ZodObject<{
136
+ event_type: z.ZodLiteral<"agent-speech">;
137
+ utterance: z.ZodString;
138
+ interrupted: z.ZodDefault<z.ZodBoolean>;
139
+ }, z.core.$strip>, z.ZodObject<{
140
+ event_type: z.ZodLiteral<"error">;
141
+ content: z.ZodString;
142
+ }, z.core.$strip>, z.ZodObject<{
143
+ event_type: z.ZodLiteral<"warning">;
144
+ content: z.ZodString;
145
+ }, z.core.$strip>, z.ZodObject<{
146
+ event_type: z.ZodLiteral<"agent-question">;
147
+ question_id: z.ZodString;
148
+ question: z.ZodString;
149
+ }, z.core.$strip>, z.ZodObject<{
150
+ event_type: z.ZodLiteral<"intent">;
151
+ intent_id: z.ZodString;
152
+ intent_summary: z.ZodString;
153
+ }, z.core.$strip>, z.ZodObject<{
154
+ event_type: z.ZodLiteral<"action-item-done">;
155
+ key: z.ZodString;
156
+ payload: z.ZodUnknown;
157
+ }, z.core.$strip>, z.ZodObject<{
158
+ event_type: z.ZodLiteral<"task-done">;
159
+ task_id: z.ZodString;
160
+ }, z.core.$strip>, z.ZodObject<{
161
+ event_type: z.ZodLiteral<"outbound-call-connected">;
162
+ }, z.core.$strip>, z.ZodObject<{
163
+ event_type: z.ZodLiteral<"outbound-call-failed">;
164
+ error_code: z.ZodInt;
165
+ error_reason: z.ZodString;
166
+ }, z.core.$strip>, z.ZodObject<{
167
+ event_type: z.ZodLiteral<"bot-session-ended">;
168
+ }, z.core.$strip>]>;
169
+ }, z.core.$strip>;
170
+ export type inboundTunnelEvent = z.input<typeof inboundTunnelEvent>;