@guava-ai/guava-sdk 0.36.0 → 0.37.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/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/socket/call-info.d.ts +16 -9
- package/dist/src/socket/call-info.js +43 -4
- package/dist/src/socket/call-info.js.map +1 -1
- package/dist/src/socket/listen-inbound.d.ts +14 -4
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +4 -1
- package/src/index.ts +1 -0
- package/src/socket/call-info.ts +50 -8
- package/src/version.ts +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { Contact, CampaignStatus, UploadContactsResult, UploadContactsOptio
|
|
|
6
6
|
export { Say, Field } from "./action-item.ts";
|
|
7
7
|
export { Logger, getConsoleLogger, getDefaultLogger } from "./logging.ts";
|
|
8
8
|
export { Agent, CallInfo } from "./agent.ts";
|
|
9
|
+
export { SIPCallInfo } from "./socket/call-info.ts";
|
|
9
10
|
export { Call, DEFAULT_REACH_PERSON_OUTCOMES } from "./call.ts";
|
|
10
11
|
export type { ReachPersonOutcome } from "./call.ts";
|
|
11
12
|
export type { SpeedPreset, Language } from "./commands.ts";
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockCall = exports.TestSession = exports.DEFAULT_REACH_PERSON_OUTCOMES = exports.Call = exports.Agent = exports.getDefaultLogger = exports.getConsoleLogger = exports.Field = exports.Say = exports.Campaign = exports.Runner = exports.Client = void 0;
|
|
3
|
+
exports.MockCall = exports.TestSession = exports.DEFAULT_REACH_PERSON_OUTCOMES = exports.Call = exports.SIPCallInfo = exports.Agent = exports.getDefaultLogger = exports.getConsoleLogger = exports.Field = exports.Say = exports.Campaign = exports.Runner = exports.Client = void 0;
|
|
4
4
|
var client_ts_1 = require("./client.js");
|
|
5
5
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_ts_1.Client; } });
|
|
6
6
|
var runner_ts_1 = require("./runner.js");
|
|
@@ -15,6 +15,8 @@ Object.defineProperty(exports, "getConsoleLogger", { enumerable: true, get: func
|
|
|
15
15
|
Object.defineProperty(exports, "getDefaultLogger", { enumerable: true, get: function () { return logging_ts_1.getDefaultLogger; } });
|
|
16
16
|
var agent_ts_1 = require("./agent.js");
|
|
17
17
|
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return agent_ts_1.Agent; } });
|
|
18
|
+
var call_info_ts_1 = require("./socket/call-info.js");
|
|
19
|
+
Object.defineProperty(exports, "SIPCallInfo", { enumerable: true, get: function () { return call_info_ts_1.SIPCallInfo; } });
|
|
18
20
|
var call_ts_1 = require("./call.js");
|
|
19
21
|
Object.defineProperty(exports, "Call", { enumerable: true, get: function () { return call_ts_1.Call; } });
|
|
20
22
|
Object.defineProperty(exports, "DEFAULT_REACH_PERSON_OUTCOMES", { enumerable: true, get: function () { return call_ts_1.DEFAULT_REACH_PERSON_OUTCOMES; } });
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA6D;AAApD,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AAEf,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAQjB,mDAA8C;AAArC,qGAAA,GAAG,OAAA;AAAE,uGAAA,KAAK,OAAA;AACnB,2CAA0E;AAAzD,8GAAA,gBAAgB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACnD,uCAA6C;AAApC,iGAAA,KAAK,OAAA;AACd,qCAAgE;AAAvD,+FAAA,IAAI,OAAA;AAAE,wHAAA,6BAA6B,OAAA;AAW5C,mDAAmD;AAA1C,yGAAA,WAAW,OAAA;AACpB,+CAA8C;AAArC,oGAAA,QAAQ,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAA6D;AAApD,mGAAA,MAAM,OAAA;AACf,yCAAqC;AAA5B,mGAAA,MAAM,OAAA;AAEf,+CAA0C;AAAjC,wGAAA,QAAQ,OAAA;AAQjB,mDAA8C;AAArC,qGAAA,GAAG,OAAA;AAAE,uGAAA,KAAK,OAAA;AACnB,2CAA0E;AAAzD,8GAAA,gBAAgB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AACnD,uCAA6C;AAApC,iGAAA,KAAK,OAAA;AACd,sDAAoD;AAA3C,2GAAA,WAAW,OAAA;AACpB,qCAAgE;AAAvD,+FAAA,IAAI,OAAA;AAAE,wHAAA,6BAA6B,OAAA;AAW5C,mDAAmD;AAA1C,yGAAA,WAAW,OAAA;AACpB,+CAA8C;AAArC,oGAAA,QAAQ,OAAA"}
|
|
@@ -11,13 +11,15 @@ export declare const WebRTCCallInfo: z.ZodObject<{
|
|
|
11
11
|
webrtc_code: z.ZodString;
|
|
12
12
|
}, z.core.$strip>;
|
|
13
13
|
export type WebRTCCallInfo = z.infer<typeof WebRTCCallInfo>;
|
|
14
|
-
export declare
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
export declare class SIPCallInfo {
|
|
15
|
+
readonly from_aor: string;
|
|
16
|
+
readonly sip_code?: string | undefined;
|
|
17
|
+
readonly sip_headers: Record<string, string>;
|
|
18
|
+
readonly call_type: "sip";
|
|
19
|
+
constructor(from_aor: string, sip_code?: string | undefined, sip_headers?: Record<string, string>);
|
|
20
|
+
/** The from URI. */
|
|
21
|
+
get fromUri(): string;
|
|
22
|
+
}
|
|
21
23
|
export declare const CallInfo: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
22
24
|
call_type: z.ZodLiteral<"pstn">;
|
|
23
25
|
from_number: z.ZodNullable<z.ZodString>;
|
|
@@ -26,10 +28,15 @@ export declare const CallInfo: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
26
28
|
}, z.core.$strip>, z.ZodObject<{
|
|
27
29
|
call_type: z.ZodLiteral<"webrtc">;
|
|
28
30
|
webrtc_code: z.ZodString;
|
|
29
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
31
|
+
}, z.core.$strip>, z.ZodPipe<z.ZodObject<{
|
|
30
32
|
call_type: z.ZodLiteral<"sip">;
|
|
31
33
|
from_aor: z.ZodString;
|
|
32
34
|
sip_code: z.ZodOptional<z.ZodString>;
|
|
33
35
|
sip_headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
34
|
-
}, z.core.$strip
|
|
36
|
+
}, z.core.$strip>, z.ZodTransform<SIPCallInfo, {
|
|
37
|
+
call_type: "sip";
|
|
38
|
+
from_aor: string;
|
|
39
|
+
sip_headers: Record<string, string>;
|
|
40
|
+
sip_code?: string | undefined;
|
|
41
|
+
}>>], "call_type">;
|
|
35
42
|
export type CallInfo = z.infer<typeof CallInfo>;
|
|
@@ -45,15 +45,54 @@ exports.WebRTCCallInfo = z.object({
|
|
|
45
45
|
call_type: z.literal("webrtc"),
|
|
46
46
|
webrtc_code: z.string(),
|
|
47
47
|
});
|
|
48
|
-
|
|
48
|
+
const SIPCallInfoSchema = z
|
|
49
|
+
.object({
|
|
49
50
|
call_type: z.literal("sip"),
|
|
50
|
-
from_aor: z
|
|
51
|
+
from_aor: z
|
|
52
|
+
.string()
|
|
53
|
+
.describe('Despite the name, this field contains the entire SIP from-spec value, not just the AOR. Example: `"Display Name" <sip:user@example.com:5060>;tag=abc123`.'),
|
|
51
54
|
sip_code: z.string().optional(),
|
|
52
55
|
sip_headers: z.record(z.string(), z.string()).default({}),
|
|
53
|
-
})
|
|
56
|
+
})
|
|
57
|
+
.transform((data) => new SIPCallInfo(data.from_aor, data.sip_code, data.sip_headers));
|
|
58
|
+
class SIPCallInfo {
|
|
59
|
+
from_aor;
|
|
60
|
+
sip_code;
|
|
61
|
+
sip_headers;
|
|
62
|
+
call_type = "sip";
|
|
63
|
+
constructor(from_aor, sip_code, sip_headers = {}) {
|
|
64
|
+
this.from_aor = from_aor;
|
|
65
|
+
this.sip_code = sip_code;
|
|
66
|
+
this.sip_headers = sip_headers;
|
|
67
|
+
}
|
|
68
|
+
/** The from URI. */
|
|
69
|
+
get fromUri() {
|
|
70
|
+
const value = this.from_aor.trim();
|
|
71
|
+
// Skip a quoted display name, which may contain '<', '>' or escaped quotes.
|
|
72
|
+
let i = 0;
|
|
73
|
+
if (value.startsWith('"')) {
|
|
74
|
+
i = 1;
|
|
75
|
+
while (i < value.length && value[i] !== '"') {
|
|
76
|
+
i += value[i] === "\\" ? 2 : 1;
|
|
77
|
+
}
|
|
78
|
+
i += 1;
|
|
79
|
+
}
|
|
80
|
+
// A '<' after the first ';' is inside a header param, not the URI's bracket.
|
|
81
|
+
const start = value.indexOf("<", i);
|
|
82
|
+
const semi = value.indexOf(";", i);
|
|
83
|
+
if (start !== -1 && (semi === -1 || start < semi)) {
|
|
84
|
+
const end = value.indexOf(">", start);
|
|
85
|
+
if (end !== -1) {
|
|
86
|
+
return value.slice(start + 1, end).trim();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return value.split(";", 1)[0].trim();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.SIPCallInfo = SIPCallInfo;
|
|
54
93
|
exports.CallInfo = z.discriminatedUnion("call_type", [
|
|
55
94
|
exports.PSTNCallInfo,
|
|
56
95
|
exports.WebRTCCallInfo,
|
|
57
|
-
|
|
96
|
+
SIPCallInfoSchema,
|
|
58
97
|
]);
|
|
59
98
|
//# sourceMappingURL=call-info.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-info.js","sourceRoot":"","sources":["../../../src/socket/call-info.ts"],"names":[],"mappings":";;;;;;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AAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC;YAClD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACtC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,CAAC;CACF;AAnCD,kCAmCC;AAEY,QAAA,QAAQ,GAAG,CAAC,CAAC,kBAAkB,CAAC,WAAW,EAAE;IACxD,oBAAY;IACZ,sBAAc;IACd,iBAAiB;CAClB,CAAC,CAAC"}
|
|
@@ -21,12 +21,17 @@ export declare const AssignCall: z.ZodObject<{
|
|
|
21
21
|
}, z.core.$strip>, z.ZodObject<{
|
|
22
22
|
call_type: z.ZodLiteral<"webrtc">;
|
|
23
23
|
webrtc_code: z.ZodString;
|
|
24
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
24
|
+
}, z.core.$strip>, z.ZodPipe<z.ZodObject<{
|
|
25
25
|
call_type: z.ZodLiteral<"sip">;
|
|
26
26
|
from_aor: z.ZodString;
|
|
27
27
|
sip_code: z.ZodOptional<z.ZodString>;
|
|
28
28
|
sip_headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
-
}, z.core.$strip
|
|
29
|
+
}, z.core.$strip>, z.ZodTransform<import("./call-info.ts").SIPCallInfo, {
|
|
30
|
+
call_type: "sip";
|
|
31
|
+
from_aor: string;
|
|
32
|
+
sip_headers: Record<string, string>;
|
|
33
|
+
sip_code?: string | undefined;
|
|
34
|
+
}>>], "call_type">;
|
|
30
35
|
}, z.core.$strip>;
|
|
31
36
|
export type AssignCall = z.infer<typeof AssignCall>;
|
|
32
37
|
export declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -46,12 +51,17 @@ export declare const ServerMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
46
51
|
}, z.core.$strip>, z.ZodObject<{
|
|
47
52
|
call_type: z.ZodLiteral<"webrtc">;
|
|
48
53
|
webrtc_code: z.ZodString;
|
|
49
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
54
|
+
}, z.core.$strip>, z.ZodPipe<z.ZodObject<{
|
|
50
55
|
call_type: z.ZodLiteral<"sip">;
|
|
51
56
|
from_aor: z.ZodString;
|
|
52
57
|
sip_code: z.ZodOptional<z.ZodString>;
|
|
53
58
|
sip_headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
54
|
-
}, z.core.$strip
|
|
59
|
+
}, z.core.$strip>, z.ZodTransform<import("./call-info.ts").SIPCallInfo, {
|
|
60
|
+
call_type: "sip";
|
|
61
|
+
from_aor: string;
|
|
62
|
+
sip_headers: Record<string, string>;
|
|
63
|
+
sip_code?: string | undefined;
|
|
64
|
+
}>>], "call_type">;
|
|
55
65
|
}, z.core.$strip>], "message_type">;
|
|
56
66
|
export type ServerMessage = z.infer<typeof ServerMessage>;
|
|
57
67
|
export declare const ClaimCall: z.ZodObject<{
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.37.0";
|
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@guava-ai/guava-sdk",
|
|
3
3
|
"description": "The official TypeScript SDK for building Guava voice agents.",
|
|
4
4
|
"homepage": "https://docs.goguava.ai/typescript-sdk/",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.37.0",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"types": "dist/src/index.d.ts",
|
|
@@ -77,6 +77,9 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=20"
|
|
82
|
+
},
|
|
80
83
|
"files": [
|
|
81
84
|
"/src",
|
|
82
85
|
"/dist",
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type {
|
|
|
12
12
|
export { Say, Field } from "./action-item.ts";
|
|
13
13
|
export { Logger, getConsoleLogger, getDefaultLogger } from "./logging.ts";
|
|
14
14
|
export { Agent, CallInfo } from "./agent.ts";
|
|
15
|
+
export { SIPCallInfo } from "./socket/call-info.ts";
|
|
15
16
|
export { Call, DEFAULT_REACH_PERSON_OUTCOMES } from "./call.ts";
|
|
16
17
|
export type { ReachPersonOutcome } from "./call.ts";
|
|
17
18
|
export type { SpeedPreset, Language } from "./commands.ts";
|
package/src/socket/call-info.ts
CHANGED
|
@@ -14,17 +14,59 @@ export const WebRTCCallInfo = z.object({
|
|
|
14
14
|
});
|
|
15
15
|
export type WebRTCCallInfo = z.infer<typeof WebRTCCallInfo>;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const SIPCallInfoSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
call_type: z.literal("sip"),
|
|
20
|
+
from_aor: z
|
|
21
|
+
.string()
|
|
22
|
+
.describe(
|
|
23
|
+
'Despite the name, this field contains the entire SIP from-spec value, not just the AOR. Example: `"Display Name" <sip:user@example.com:5060>;tag=abc123`.',
|
|
24
|
+
),
|
|
25
|
+
sip_code: z.string().optional(),
|
|
26
|
+
sip_headers: z.record(z.string(), z.string()).default({}),
|
|
27
|
+
})
|
|
28
|
+
.transform((data) => new SIPCallInfo(data.from_aor, data.sip_code, data.sip_headers));
|
|
29
|
+
|
|
30
|
+
export class SIPCallInfo {
|
|
31
|
+
readonly call_type = "sip" as const;
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
readonly from_aor: string,
|
|
35
|
+
readonly sip_code?: string,
|
|
36
|
+
readonly sip_headers: Record<string, string> = {},
|
|
37
|
+
) {}
|
|
38
|
+
|
|
39
|
+
/** The from URI. */
|
|
40
|
+
get fromUri(): string {
|
|
41
|
+
const value = this.from_aor.trim();
|
|
42
|
+
|
|
43
|
+
// Skip a quoted display name, which may contain '<', '>' or escaped quotes.
|
|
44
|
+
let i = 0;
|
|
45
|
+
if (value.startsWith('"')) {
|
|
46
|
+
i = 1;
|
|
47
|
+
while (i < value.length && value[i] !== '"') {
|
|
48
|
+
i += value[i] === "\\" ? 2 : 1;
|
|
49
|
+
}
|
|
50
|
+
i += 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// A '<' after the first ';' is inside a header param, not the URI's bracket.
|
|
54
|
+
const start = value.indexOf("<", i);
|
|
55
|
+
const semi = value.indexOf(";", i);
|
|
56
|
+
if (start !== -1 && (semi === -1 || start < semi)) {
|
|
57
|
+
const end = value.indexOf(">", start);
|
|
58
|
+
if (end !== -1) {
|
|
59
|
+
return value.slice(start + 1, end).trim();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return value.split(";", 1)[0].trim();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
24
66
|
|
|
25
67
|
export const CallInfo = z.discriminatedUnion("call_type", [
|
|
26
68
|
PSTNCallInfo,
|
|
27
69
|
WebRTCCallInfo,
|
|
28
|
-
|
|
70
|
+
SIPCallInfoSchema,
|
|
29
71
|
]);
|
|
30
72
|
export type CallInfo = z.infer<typeof CallInfo>;
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.37.0";
|