@voice-ai-labs/web-sdk 0.2.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/LICENSE +21 -0
- package/README.md +219 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +13 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/client/agents.d.ts +202 -0
- package/dist/client/agents.d.ts.map +1 -0
- package/dist/client/agents.js +233 -0
- package/dist/client/agents.js.map +1 -0
- package/dist/client/analytics.d.ts +77 -0
- package/dist/client/analytics.d.ts.map +1 -0
- package/dist/client/analytics.js +95 -0
- package/dist/client/analytics.js.map +1 -0
- package/dist/client/base.d.ts +69 -0
- package/dist/client/base.d.ts.map +1 -0
- package/dist/client/base.js +210 -0
- package/dist/client/base.js.map +1 -0
- package/dist/client/index.d.ts +71 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +73 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/knowledge-base.d.ts +110 -0
- package/dist/client/knowledge-base.d.ts.map +1 -0
- package/dist/client/knowledge-base.js +126 -0
- package/dist/client/knowledge-base.js.map +1 -0
- package/dist/client/phone-numbers.d.ts +116 -0
- package/dist/client/phone-numbers.d.ts.map +1 -0
- package/dist/client/phone-numbers.js +143 -0
- package/dist/client/phone-numbers.js.map +1 -0
- package/dist/components/VoiceAgentWidget.d.ts +80 -0
- package/dist/components/VoiceAgentWidget.d.ts.map +1 -0
- package/dist/components/VoiceAgentWidget.js +407 -0
- package/dist/components/VoiceAgentWidget.js.map +1 -0
- package/dist/components/index.d.ts +14 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +13 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +28724 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +28732 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +453 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Base Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods for:
|
|
5
|
+
* - Creating and managing knowledge bases
|
|
6
|
+
* - Listing and retrieving knowledge base details
|
|
7
|
+
* - Updating and deleting knowledge bases
|
|
8
|
+
*/
|
|
9
|
+
import { BaseClient, BaseClientConfig } from './base';
|
|
10
|
+
import type { KnowledgeBaseResponse, KnowledgeBaseWithDocuments, CreateKnowledgeBaseRequest, UpdateKnowledgeBaseRequest, PaginatedKnowledgeBaseResponse, PaginationOptions } from '../types';
|
|
11
|
+
/**
|
|
12
|
+
* Client for Knowledge Base operations
|
|
13
|
+
*/
|
|
14
|
+
export declare class KnowledgeBaseClient extends BaseClient {
|
|
15
|
+
constructor(config: BaseClientConfig);
|
|
16
|
+
/**
|
|
17
|
+
* List knowledge bases
|
|
18
|
+
*
|
|
19
|
+
* @param options - Pagination options
|
|
20
|
+
* @returns Paginated list of knowledge bases or array
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const result = await client.knowledgeBase.list({ page: 1, limit: 10 });
|
|
25
|
+
*
|
|
26
|
+
* if ('items' in result) {
|
|
27
|
+
* for (const kb of result.items) {
|
|
28
|
+
* console.log(`${kb.name}: ${kb.document_count} documents`);
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
list(options?: PaginationOptions): Promise<PaginatedKnowledgeBaseResponse | KnowledgeBaseResponse[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new knowledge base
|
|
36
|
+
*
|
|
37
|
+
* @param options - Knowledge base creation options
|
|
38
|
+
* @returns Created knowledge base
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const kb = await client.knowledgeBase.create({
|
|
43
|
+
* name: 'Product FAQ',
|
|
44
|
+
* description: 'Frequently asked questions about our products',
|
|
45
|
+
* documents: [
|
|
46
|
+
* { content: 'Q: What is the return policy? A: 30 days...' },
|
|
47
|
+
* { content: 'Q: How do I track my order? A: Use the tracking link...' }
|
|
48
|
+
* ]
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* console.log('Created KB:', kb.kb_id);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
create(options: CreateKnowledgeBaseRequest): Promise<KnowledgeBaseResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Get knowledge base details with documents
|
|
57
|
+
*
|
|
58
|
+
* @param kbId - The knowledge base ID
|
|
59
|
+
* @returns Knowledge base with documents
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const kb = await client.knowledgeBase.getById(42);
|
|
64
|
+
*
|
|
65
|
+
* console.log('Documents:', kb.documents.length);
|
|
66
|
+
* for (const doc of kb.documents) {
|
|
67
|
+
* console.log('- ', doc.content.substring(0, 50));
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
getById(kbId: number): Promise<KnowledgeBaseWithDocuments>;
|
|
72
|
+
/**
|
|
73
|
+
* Update a knowledge base
|
|
74
|
+
*
|
|
75
|
+
* If documents are provided, they replace ALL existing documents.
|
|
76
|
+
*
|
|
77
|
+
* @param kbId - The knowledge base ID
|
|
78
|
+
* @param options - Fields to update
|
|
79
|
+
* @returns Updated knowledge base with documents
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* // Update name only
|
|
84
|
+
* const updated = await client.knowledgeBase.update(42, {
|
|
85
|
+
* name: 'Updated FAQ'
|
|
86
|
+
* });
|
|
87
|
+
*
|
|
88
|
+
* // Replace all documents
|
|
89
|
+
* const replaced = await client.knowledgeBase.update(42, {
|
|
90
|
+
* documents: [
|
|
91
|
+
* { content: 'New document content...' }
|
|
92
|
+
* ]
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
update(kbId: number, options: UpdateKnowledgeBaseRequest): Promise<KnowledgeBaseWithDocuments>;
|
|
97
|
+
/**
|
|
98
|
+
* Delete a knowledge base
|
|
99
|
+
*
|
|
100
|
+
* @param kbId - The knowledge base ID
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* await client.knowledgeBase.remove(42);
|
|
105
|
+
* console.log('Knowledge base deleted');
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
remove(kbId: number): Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=knowledge-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../../src/client/knowledge-base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;gBACrC,MAAM,EAAE,gBAAgB;IAIpC;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,8BAA8B,GAAG,qBAAqB,EAAE,CAAC;IAS1G;;;;;;;;;;;;;;;;;;;OAmBG;IACG,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIjF;;;;;;;;;;;;;;;OAeG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIhE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIpG;;;;;;;;;;OAUG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Base Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods for:
|
|
5
|
+
* - Creating and managing knowledge bases
|
|
6
|
+
* - Listing and retrieving knowledge base details
|
|
7
|
+
* - Updating and deleting knowledge bases
|
|
8
|
+
*/
|
|
9
|
+
import { BaseClient } from './base';
|
|
10
|
+
/**
|
|
11
|
+
* Client for Knowledge Base operations
|
|
12
|
+
*/
|
|
13
|
+
export class KnowledgeBaseClient extends BaseClient {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super(config);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* List knowledge bases
|
|
19
|
+
*
|
|
20
|
+
* @param options - Pagination options
|
|
21
|
+
* @returns Paginated list of knowledge bases or array
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const result = await client.knowledgeBase.list({ page: 1, limit: 10 });
|
|
26
|
+
*
|
|
27
|
+
* if ('items' in result) {
|
|
28
|
+
* for (const kb of result.items) {
|
|
29
|
+
* console.log(`${kb.name}: ${kb.document_count} documents`);
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
async list(options) {
|
|
35
|
+
const params = {};
|
|
36
|
+
if (options?.page !== undefined)
|
|
37
|
+
params.page = options.page;
|
|
38
|
+
if (options?.limit !== undefined)
|
|
39
|
+
params.limit = options.limit;
|
|
40
|
+
return super.get('/knowledge-base/', params);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a new knowledge base
|
|
44
|
+
*
|
|
45
|
+
* @param options - Knowledge base creation options
|
|
46
|
+
* @returns Created knowledge base
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const kb = await client.knowledgeBase.create({
|
|
51
|
+
* name: 'Product FAQ',
|
|
52
|
+
* description: 'Frequently asked questions about our products',
|
|
53
|
+
* documents: [
|
|
54
|
+
* { content: 'Q: What is the return policy? A: 30 days...' },
|
|
55
|
+
* { content: 'Q: How do I track my order? A: Use the tracking link...' }
|
|
56
|
+
* ]
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* console.log('Created KB:', kb.kb_id);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
async create(options) {
|
|
63
|
+
return this.post('/knowledge-base/', options);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get knowledge base details with documents
|
|
67
|
+
*
|
|
68
|
+
* @param kbId - The knowledge base ID
|
|
69
|
+
* @returns Knowledge base with documents
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const kb = await client.knowledgeBase.getById(42);
|
|
74
|
+
*
|
|
75
|
+
* console.log('Documents:', kb.documents.length);
|
|
76
|
+
* for (const doc of kb.documents) {
|
|
77
|
+
* console.log('- ', doc.content.substring(0, 50));
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
async getById(kbId) {
|
|
82
|
+
return super.get(`/knowledge-base/${kbId}`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Update a knowledge base
|
|
86
|
+
*
|
|
87
|
+
* If documents are provided, they replace ALL existing documents.
|
|
88
|
+
*
|
|
89
|
+
* @param kbId - The knowledge base ID
|
|
90
|
+
* @param options - Fields to update
|
|
91
|
+
* @returns Updated knowledge base with documents
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Update name only
|
|
96
|
+
* const updated = await client.knowledgeBase.update(42, {
|
|
97
|
+
* name: 'Updated FAQ'
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // Replace all documents
|
|
101
|
+
* const replaced = await client.knowledgeBase.update(42, {
|
|
102
|
+
* documents: [
|
|
103
|
+
* { content: 'New document content...' }
|
|
104
|
+
* ]
|
|
105
|
+
* });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
async update(kbId, options) {
|
|
109
|
+
return this.put(`/knowledge-base/${kbId}`, options);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Delete a knowledge base
|
|
113
|
+
*
|
|
114
|
+
* @param kbId - The knowledge base ID
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* await client.knowledgeBase.remove(42);
|
|
119
|
+
* console.log('Knowledge base deleted');
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
async remove(kbId) {
|
|
123
|
+
await super.delete(`/knowledge-base/${kbId}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=knowledge-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-base.js","sourceRoot":"","sources":["../../src/client/knowledge-base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAoB,MAAM,QAAQ,CAAC;AAUtD;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,UAAU;IACjD,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,IAAI,CAAC,OAA2B;QACpC,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,IAAI,OAAO,EAAE,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC5D,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE/D,OAAO,KAAK,CAAC,GAAG,CAA2D,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACzG,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,MAAM,CAAC,OAAmC;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAwB,kBAAkB,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,OAAO,CAAC,IAAY;QACxB,OAAO,KAAK,CAAC,GAAG,CAA6B,mBAAmB,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,OAAmC;QAC5D,OAAO,IAAI,CAAC,GAAG,CAA6B,mBAAmB,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY;QACvB,MAAM,KAAK,CAAC,MAAM,CAAO,mBAAmB,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phone Number Management Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods for:
|
|
5
|
+
* - Listing owned phone numbers
|
|
6
|
+
* - Searching available numbers
|
|
7
|
+
* - Selecting (provisioning) phone numbers
|
|
8
|
+
* - Releasing phone numbers
|
|
9
|
+
*/
|
|
10
|
+
import { BaseClient, BaseClientConfig } from './base';
|
|
11
|
+
import type { SearchPhoneNumbersRequest, SearchPhoneNumbersResponse, PurchasePhoneNumberResponse, AllPhoneNumbersResponse, PaginatedPhoneNumberResponse, PaginatedAllPhoneNumbersResponse, PaginationOptions } from '../types';
|
|
12
|
+
/**
|
|
13
|
+
* Client for phone number management operations
|
|
14
|
+
*/
|
|
15
|
+
export declare class PhoneNumberClient extends BaseClient {
|
|
16
|
+
constructor(config: BaseClientConfig);
|
|
17
|
+
/**
|
|
18
|
+
* List all owned phone numbers with details
|
|
19
|
+
*
|
|
20
|
+
* @param options - Pagination options
|
|
21
|
+
* @returns Phone numbers with assignment info
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const result = await client.phoneNumbers.list({ page: 1, limit: 10 });
|
|
26
|
+
*
|
|
27
|
+
* if ('items' in result) {
|
|
28
|
+
* for (const phone of result.items) {
|
|
29
|
+
* console.log(`${phone.phone_number}: ${phone.status}`);
|
|
30
|
+
* if (phone.assigned_to_agent_name) {
|
|
31
|
+
* console.log(` Assigned to: ${phone.assigned_to_agent_name}`);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
list(options?: PaginationOptions): Promise<AllPhoneNumbersResponse | PaginatedAllPhoneNumbersResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* List available (unassigned) phone numbers
|
|
40
|
+
*
|
|
41
|
+
* @param options - Pagination options
|
|
42
|
+
* @returns Available phone numbers
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const result = await client.phoneNumbers.listAvailable();
|
|
47
|
+
*
|
|
48
|
+
* if ('items' in result) {
|
|
49
|
+
* console.log('Available numbers:', result.items.length);
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
listAvailable(options?: PaginationOptions): Promise<Record<string, any> | PaginatedPhoneNumberResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Search for available phone numbers to select
|
|
56
|
+
*
|
|
57
|
+
* @param options - Search filters
|
|
58
|
+
* @returns Search results with available numbers
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Search for US numbers in area code 415
|
|
63
|
+
* const results = await client.phoneNumbers.search({
|
|
64
|
+
* country_code: 'US',
|
|
65
|
+
* area_code: '415',
|
|
66
|
+
* provider: 'twilio'
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* console.log('Found:', results.total_results);
|
|
70
|
+
* for (const num of results.results) {
|
|
71
|
+
* console.log(`${num.phone_number} - ${num.locality}, ${num.region}`);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
search(options: SearchPhoneNumbersRequest): Promise<SearchPhoneNumbersResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Select (provision) a phone number from your plan's allowance
|
|
78
|
+
*
|
|
79
|
+
* Phone numbers consume a slot from your plan's included allowance.
|
|
80
|
+
* If you've reached your plan limit, you'll need to upgrade your plan
|
|
81
|
+
* or release an existing number.
|
|
82
|
+
*
|
|
83
|
+
* @param phoneNumber - The phone number to select (e.g., '+15551234567')
|
|
84
|
+
* @param provider - Provider: 'twilio' or 'telnyx' (default: 'twilio')
|
|
85
|
+
* @returns Selection response
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const result = await client.phoneNumbers.select('+15551234567', 'twilio');
|
|
90
|
+
* console.log('Selected:', result.phone_number, result.status);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
select(phoneNumber: string, provider?: string): Promise<PurchasePhoneNumberResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Release an owned phone number
|
|
96
|
+
*
|
|
97
|
+
* Phone numbers attached to deployed agents cannot be released.
|
|
98
|
+
* You must first pause your agent.
|
|
99
|
+
*
|
|
100
|
+
* @param phoneNumber - The phone number to release
|
|
101
|
+
* @param provider - Provider: 'twilio' or 'telnyx' (default: 'twilio')
|
|
102
|
+
* @returns Release response
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* // First pause any agent using this number
|
|
107
|
+
* await client.agents.pause('agent-123');
|
|
108
|
+
*
|
|
109
|
+
* // Then release the number
|
|
110
|
+
* const result = await client.phoneNumbers.release('+15551234567');
|
|
111
|
+
* console.log('Released:', result.phone_number);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
release(phoneNumber: string, provider?: string): Promise<PurchasePhoneNumberResponse>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=phone-numbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-numbers.d.ts","sourceRoot":"","sources":["../../src/client/phone-numbers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EAGV,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;gBACnC,MAAM,EAAE,gBAAgB;IAIpC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,uBAAuB,GAAG,gCAAgC,CAAC;IAS5G;;;;;;;;;;;;;;OAcG;IACG,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,4BAA4B,CAAC;IAS7G;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIrF;;;;;;;;;;;;;;;;OAgBG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAOpG;;;;;;;;;;;;;;;;;;;OAmBG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAMtG"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phone Number Management Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods for:
|
|
5
|
+
* - Listing owned phone numbers
|
|
6
|
+
* - Searching available numbers
|
|
7
|
+
* - Selecting (provisioning) phone numbers
|
|
8
|
+
* - Releasing phone numbers
|
|
9
|
+
*/
|
|
10
|
+
import { BaseClient } from './base';
|
|
11
|
+
/**
|
|
12
|
+
* Client for phone number management operations
|
|
13
|
+
*/
|
|
14
|
+
export class PhoneNumberClient extends BaseClient {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* List all owned phone numbers with details
|
|
20
|
+
*
|
|
21
|
+
* @param options - Pagination options
|
|
22
|
+
* @returns Phone numbers with assignment info
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const result = await client.phoneNumbers.list({ page: 1, limit: 10 });
|
|
27
|
+
*
|
|
28
|
+
* if ('items' in result) {
|
|
29
|
+
* for (const phone of result.items) {
|
|
30
|
+
* console.log(`${phone.phone_number}: ${phone.status}`);
|
|
31
|
+
* if (phone.assigned_to_agent_name) {
|
|
32
|
+
* console.log(` Assigned to: ${phone.assigned_to_agent_name}`);
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
async list(options) {
|
|
39
|
+
const params = {};
|
|
40
|
+
if (options?.page !== undefined)
|
|
41
|
+
params.page = options.page;
|
|
42
|
+
if (options?.limit !== undefined)
|
|
43
|
+
params.limit = options.limit;
|
|
44
|
+
return this.get('/agent/phone-numbers', params);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* List available (unassigned) phone numbers
|
|
48
|
+
*
|
|
49
|
+
* @param options - Pagination options
|
|
50
|
+
* @returns Available phone numbers
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const result = await client.phoneNumbers.listAvailable();
|
|
55
|
+
*
|
|
56
|
+
* if ('items' in result) {
|
|
57
|
+
* console.log('Available numbers:', result.items.length);
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
async listAvailable(options) {
|
|
62
|
+
const params = {};
|
|
63
|
+
if (options?.page !== undefined)
|
|
64
|
+
params.page = options.page;
|
|
65
|
+
if (options?.limit !== undefined)
|
|
66
|
+
params.limit = options.limit;
|
|
67
|
+
return this.get('/agent/available-phone-numbers', params);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Search for available phone numbers to select
|
|
71
|
+
*
|
|
72
|
+
* @param options - Search filters
|
|
73
|
+
* @returns Search results with available numbers
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // Search for US numbers in area code 415
|
|
78
|
+
* const results = await client.phoneNumbers.search({
|
|
79
|
+
* country_code: 'US',
|
|
80
|
+
* area_code: '415',
|
|
81
|
+
* provider: 'twilio'
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* console.log('Found:', results.total_results);
|
|
85
|
+
* for (const num of results.results) {
|
|
86
|
+
* console.log(`${num.phone_number} - ${num.locality}, ${num.region}`);
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
async search(options) {
|
|
91
|
+
return this.post('/agent/search-phone-numbers', options);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Select (provision) a phone number from your plan's allowance
|
|
95
|
+
*
|
|
96
|
+
* Phone numbers consume a slot from your plan's included allowance.
|
|
97
|
+
* If you've reached your plan limit, you'll need to upgrade your plan
|
|
98
|
+
* or release an existing number.
|
|
99
|
+
*
|
|
100
|
+
* @param phoneNumber - The phone number to select (e.g., '+15551234567')
|
|
101
|
+
* @param provider - Provider: 'twilio' or 'telnyx' (default: 'twilio')
|
|
102
|
+
* @returns Selection response
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const result = await client.phoneNumbers.select('+15551234567', 'twilio');
|
|
107
|
+
* console.log('Selected:', result.phone_number, result.status);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
async select(phoneNumber, provider = 'twilio') {
|
|
111
|
+
return this.post('/agent/select-phone-number', {
|
|
112
|
+
phone_number: phoneNumber,
|
|
113
|
+
provider,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Release an owned phone number
|
|
118
|
+
*
|
|
119
|
+
* Phone numbers attached to deployed agents cannot be released.
|
|
120
|
+
* You must first pause your agent.
|
|
121
|
+
*
|
|
122
|
+
* @param phoneNumber - The phone number to release
|
|
123
|
+
* @param provider - Provider: 'twilio' or 'telnyx' (default: 'twilio')
|
|
124
|
+
* @returns Release response
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* // First pause any agent using this number
|
|
129
|
+
* await client.agents.pause('agent-123');
|
|
130
|
+
*
|
|
131
|
+
* // Then release the number
|
|
132
|
+
* const result = await client.phoneNumbers.release('+15551234567');
|
|
133
|
+
* console.log('Released:', result.phone_number);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
async release(phoneNumber, provider = 'twilio') {
|
|
137
|
+
return this.post('/agent/release-phone-number', {
|
|
138
|
+
phone_number: phoneNumber,
|
|
139
|
+
provider,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=phone-numbers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone-numbers.js","sourceR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B,QAAQ;QAC3D,OAAO,IAAI,CAAC,IAAI,CAA8B,4BAA4B,EAAE;YAC1E,YAAY,EAAE,WAAW;YACzB,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,OAAO,CAAC,WAAmB,EAAE,WAAmB,QAAQ;QAC5D,OAAO,IAAI,CAAC,IAAI,CAA8B,6BAA6B,EAAE;YAC3E,YAAY,EAAE,WAAW;YACzB,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VoiceAgentWidget - UI widget for Voice.AI
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Click to connect/disconnect
|
|
6
|
+
* - Shape morphs based on state (circle/square)
|
|
7
|
+
* - Audio bars react to agent speech
|
|
8
|
+
* - Expandable transcript panel with text input
|
|
9
|
+
*/
|
|
10
|
+
import VoiceAI from '../index';
|
|
11
|
+
import type { ConnectionOptions } from '../types';
|
|
12
|
+
export interface VoiceAgentWidgetTheme {
|
|
13
|
+
primaryColor?: string;
|
|
14
|
+
backgroundColor?: string;
|
|
15
|
+
borderColor?: string;
|
|
16
|
+
barColor?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VoiceAgentWidgetOptions {
|
|
19
|
+
sdk: VoiceAI;
|
|
20
|
+
connectionOptions: ConnectionOptions;
|
|
21
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
22
|
+
container?: HTMLElement;
|
|
23
|
+
theme?: VoiceAgentWidgetTheme;
|
|
24
|
+
size?: number;
|
|
25
|
+
/** Enable transcript panel (default: true) */
|
|
26
|
+
showTranscript?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare class VoiceAgentWidget {
|
|
29
|
+
private sdk;
|
|
30
|
+
private connectionOptions;
|
|
31
|
+
private position;
|
|
32
|
+
private container;
|
|
33
|
+
private theme;
|
|
34
|
+
private size;
|
|
35
|
+
private showTranscript;
|
|
36
|
+
private widgetElement;
|
|
37
|
+
private buttonElement;
|
|
38
|
+
private buttonShape;
|
|
39
|
+
private glowElement;
|
|
40
|
+
private endButton;
|
|
41
|
+
private bars;
|
|
42
|
+
private panelElement;
|
|
43
|
+
private messagesContainer;
|
|
44
|
+
private inputElement;
|
|
45
|
+
private isPanelOpen;
|
|
46
|
+
private messages;
|
|
47
|
+
private isConnected;
|
|
48
|
+
private isConnecting;
|
|
49
|
+
private agentState;
|
|
50
|
+
private audioLevel;
|
|
51
|
+
private animationFrame;
|
|
52
|
+
private unsubscribeStatus;
|
|
53
|
+
private unsubscribeAgentState;
|
|
54
|
+
private unsubscribeAudioLevel;
|
|
55
|
+
private unsubscribeError;
|
|
56
|
+
private unsubscribeTranscription;
|
|
57
|
+
private static readonly DEFAULT_THEME;
|
|
58
|
+
constructor(options: VoiceAgentWidgetOptions);
|
|
59
|
+
private init;
|
|
60
|
+
private createWidget;
|
|
61
|
+
private createTranscriptPanel;
|
|
62
|
+
private setupEventListeners;
|
|
63
|
+
private addMessage;
|
|
64
|
+
private updateOrAddMessage;
|
|
65
|
+
private updateMessageElement;
|
|
66
|
+
private appendMessageElement;
|
|
67
|
+
private renderMessages;
|
|
68
|
+
private sendTextMessage;
|
|
69
|
+
private togglePanel;
|
|
70
|
+
private startAnimationLoop;
|
|
71
|
+
private handleClick;
|
|
72
|
+
private handleConnect;
|
|
73
|
+
private handleDisconnect;
|
|
74
|
+
private updateUI;
|
|
75
|
+
private applyButtonTheme;
|
|
76
|
+
private applyGlowTheme;
|
|
77
|
+
setTheme(theme: Partial<VoiceAgentWidgetTheme>): void;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=VoiceAgentWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceAgentWidget.d.ts","sourceRoot":"","sources":["../../src/components/VoiceAgentWidget.ts"],"names":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