phonic 0.27.0 → 0.28.1
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 +69 -25
- package/dist/index.d.mts +49 -6
- package/dist/index.d.ts +49 -6
- package/dist/index.js +56 -13
- package/dist/index.mjs +56 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,12 @@ Node.js library for the Phonic API.
|
|
|
28
28
|
- [Outbound call using own Twilio account](#outbound-call-using-own-twilio-account)
|
|
29
29
|
- [STS via WebSocket](#sts-via-websocket)
|
|
30
30
|
- [Messages that Phonic sends back to you](#messages-that-phonic-sends-back-to-you)
|
|
31
|
+
- [Projects](#projects)
|
|
32
|
+
- [List projects](#list-projects)
|
|
33
|
+
- [Get project](#get-project)
|
|
34
|
+
- [Create project](#create-project)
|
|
35
|
+
- [Update project](#update-project)
|
|
36
|
+
- [Delete project](#delete-project)
|
|
31
37
|
- [License](#license)
|
|
32
38
|
|
|
33
39
|
## Installation
|
|
@@ -51,19 +57,21 @@ const phonic = new Phonic("ph_...");
|
|
|
51
57
|
### List agents
|
|
52
58
|
|
|
53
59
|
```ts
|
|
54
|
-
const
|
|
60
|
+
const result = await phonic.agents.list({ project: "main" });
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
### Get agent
|
|
58
64
|
|
|
65
|
+
Returns an agent by name or ID.
|
|
66
|
+
|
|
59
67
|
```ts
|
|
60
|
-
const
|
|
68
|
+
const result = await phonic.agents.get("chris", { project: "main" });
|
|
61
69
|
```
|
|
62
70
|
|
|
63
71
|
### Create agent
|
|
64
72
|
|
|
65
73
|
```ts
|
|
66
|
-
const
|
|
74
|
+
const result = await phonic.agents.create({
|
|
67
75
|
name: "chris",
|
|
68
76
|
|
|
69
77
|
// Optional fields
|
|
@@ -100,7 +108,7 @@ const createAgentResult = await phonic.agents.create({
|
|
|
100
108
|
### Update agent
|
|
101
109
|
|
|
102
110
|
```ts
|
|
103
|
-
const
|
|
111
|
+
const result = await phonic.agents.update("chris", {
|
|
104
112
|
name: "chris",
|
|
105
113
|
|
|
106
114
|
// Optional fields
|
|
@@ -137,7 +145,7 @@ const updateAgentResult = await phonic.agents.update("chris", {
|
|
|
137
145
|
### Upsert agent
|
|
138
146
|
|
|
139
147
|
```ts
|
|
140
|
-
const
|
|
148
|
+
const result = await phonic.agents.upsert({
|
|
141
149
|
name: "chris",
|
|
142
150
|
|
|
143
151
|
// Optional fields
|
|
@@ -174,7 +182,7 @@ const upsertAgentResult = await phonic.agents.upsert({
|
|
|
174
182
|
### Delete agent
|
|
175
183
|
|
|
176
184
|
```ts
|
|
177
|
-
const
|
|
185
|
+
const result = await phonic.agents.delete("chris", {
|
|
178
186
|
// Optional fields
|
|
179
187
|
project: "main",
|
|
180
188
|
});
|
|
@@ -185,26 +193,23 @@ const deleteAgentResult = await phonic.agents.delete("chris", {
|
|
|
185
193
|
### List tools
|
|
186
194
|
|
|
187
195
|
```ts
|
|
188
|
-
const
|
|
196
|
+
const result = await phonic.tools.list();
|
|
189
197
|
```
|
|
190
198
|
|
|
191
199
|
### Get tool
|
|
192
200
|
|
|
193
|
-
|
|
201
|
+
Returns a tool by name or ID.
|
|
194
202
|
|
|
195
203
|
```ts
|
|
196
|
-
const
|
|
197
|
-
const toolByIdResult = await phonic.tools.get("tool_12cf6e88-c254-4d3e-a149-ddf1bdd2254c");
|
|
204
|
+
const result = await phonic.tools.get("next_invoice");
|
|
198
205
|
```
|
|
199
206
|
|
|
200
207
|
### Create tool
|
|
201
208
|
|
|
202
|
-
Tools can be either webhook-based (HTTP endpoints) or WebSocket-based.
|
|
203
|
-
|
|
204
209
|
#### Create webhook tool
|
|
205
210
|
|
|
206
211
|
```ts
|
|
207
|
-
const
|
|
212
|
+
const result = await phonic.tools.create({
|
|
208
213
|
name: "next_invoice",
|
|
209
214
|
description: "Returns the next invoice of the given user",
|
|
210
215
|
type: "custom_webhook",
|
|
@@ -244,7 +249,7 @@ const createWebhookToolResult = await phonic.tools.create({
|
|
|
244
249
|
WebSocket tools allow you to handle tool execution through the WebSocket connection. When the agent calls a WebSocket tool, you'll receive a `tool_call` message and must respond with a `tool_call_output` message that contains the tool result.
|
|
245
250
|
|
|
246
251
|
```ts
|
|
247
|
-
const
|
|
252
|
+
const result = await phonic.tools.create({
|
|
248
253
|
name: "get_product_recommendations",
|
|
249
254
|
description: "Gets personalized product recommendations",
|
|
250
255
|
type: "custom_websocket",
|
|
@@ -265,7 +270,7 @@ To use this tool in a conversation, add it to your agent or config:
|
|
|
265
270
|
|
|
266
271
|
```ts
|
|
267
272
|
// When creating an agent
|
|
268
|
-
const
|
|
273
|
+
const result = await phonic.agents.create({
|
|
269
274
|
name: "shopping-assistant",
|
|
270
275
|
tools: ["get_product_recommendations"],
|
|
271
276
|
// ... other config
|
|
@@ -303,7 +308,7 @@ phonicWebSocket.onMessage(async (message) => {
|
|
|
303
308
|
Updates a tool by ID or name. All fields are optional - only provided fields will be updated.
|
|
304
309
|
|
|
305
310
|
```ts
|
|
306
|
-
const
|
|
311
|
+
const result = await phonic.tools.update("next_invoice", {
|
|
307
312
|
name: "next_invoice_updated",
|
|
308
313
|
description: "Updated description.",
|
|
309
314
|
type: "custom_webhook",
|
|
@@ -341,7 +346,7 @@ const updateWebhookToolResult = await phonic.tools.update("next_invoice", {
|
|
|
341
346
|
For WebSocket tools, you would use `toolCallOutputTimeoutMs` instead of the endpoint fields:
|
|
342
347
|
|
|
343
348
|
```ts
|
|
344
|
-
const
|
|
349
|
+
const result = await phonic.tools.update("get_product_recommendations", {
|
|
345
350
|
description: "Updated product recommendation tool",
|
|
346
351
|
toolCallOutputTimeoutMs: 7000
|
|
347
352
|
});
|
|
@@ -352,7 +357,7 @@ const updateWebSocketToolResult = await phonic.tools.update("get_product_recomme
|
|
|
352
357
|
Deletes a tool by ID or name.
|
|
353
358
|
|
|
354
359
|
```ts
|
|
355
|
-
const
|
|
360
|
+
const result = await phonic.tools.delete("next_invoice");
|
|
356
361
|
```
|
|
357
362
|
|
|
358
363
|
|
|
@@ -361,14 +366,14 @@ const deleteToolResult = await phonic.tools.delete("next_invoice");
|
|
|
361
366
|
### List voices
|
|
362
367
|
|
|
363
368
|
```ts
|
|
364
|
-
const
|
|
369
|
+
const result = await phonic.voices.list({ model: "merritt" });
|
|
365
370
|
```
|
|
366
371
|
|
|
367
372
|
|
|
368
373
|
### Get voice
|
|
369
374
|
|
|
370
375
|
```ts
|
|
371
|
-
const
|
|
376
|
+
const result = await phonic.voices.get("grant");
|
|
372
377
|
```
|
|
373
378
|
|
|
374
379
|
## Conversations
|
|
@@ -376,7 +381,7 @@ const voiceResult = await phonic.voices.get("grant");
|
|
|
376
381
|
### List conversations
|
|
377
382
|
|
|
378
383
|
```ts
|
|
379
|
-
const
|
|
384
|
+
const result = await phonic.conversations.list({
|
|
380
385
|
project: "main",
|
|
381
386
|
durationMin: 10, // sec
|
|
382
387
|
durationMax: 20, // sec
|
|
@@ -389,13 +394,13 @@ const conversationsResult = await phonic.conversations.list({
|
|
|
389
394
|
### Get conversation by id
|
|
390
395
|
|
|
391
396
|
```ts
|
|
392
|
-
const
|
|
397
|
+
const result = await phonic.conversations.get("conv_b1804883-5be4-42fe-b1cf-aa84450d5c84");
|
|
393
398
|
```
|
|
394
399
|
|
|
395
400
|
### Get conversation by external id
|
|
396
401
|
|
|
397
402
|
```ts
|
|
398
|
-
const
|
|
403
|
+
const result = await phonic.conversations.getByExternalId({
|
|
399
404
|
project: "main",
|
|
400
405
|
externalId: "CAdb9c032c809fec7feb932ea4c96d71e1"
|
|
401
406
|
});
|
|
@@ -404,7 +409,7 @@ const conversationResult = await phonic.conversations.getByExternalId({
|
|
|
404
409
|
### Outbound call
|
|
405
410
|
|
|
406
411
|
```ts
|
|
407
|
-
const
|
|
412
|
+
const result = await phonic.conversations.outboundCall("+19189396241", {
|
|
408
413
|
// Optional fields
|
|
409
414
|
agent: "chris",
|
|
410
415
|
template_variables: {
|
|
@@ -419,7 +424,7 @@ const outboundCallResult = await phonic.conversations.outboundCall("+19189396241
|
|
|
419
424
|
In Twilio, create a restricted API key with the following permissions: `voice -> calls -> read` and `voice -> calls -> create`.
|
|
420
425
|
|
|
421
426
|
```ts
|
|
422
|
-
const
|
|
427
|
+
const result = await phonic.conversations.twilio.outboundCall(
|
|
423
428
|
{
|
|
424
429
|
account_sid: "AC...",
|
|
425
430
|
api_key_sid: "SK...",
|
|
@@ -753,6 +758,45 @@ If the conversation is not a phone call, `call_info` will be `null`. If it is a
|
|
|
753
758
|
|
|
754
759
|
Sent when an error occurs during the conversation.
|
|
755
760
|
|
|
761
|
+
## Projects
|
|
762
|
+
|
|
763
|
+
### List projects
|
|
764
|
+
|
|
765
|
+
```ts
|
|
766
|
+
const result = await phonic.projects.list();
|
|
767
|
+
```
|
|
768
|
+
|
|
769
|
+
### Get project
|
|
770
|
+
|
|
771
|
+
Returns a project by name or ID.
|
|
772
|
+
|
|
773
|
+
```ts
|
|
774
|
+
const result = await phonic.projects.get("main");
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
### Create project
|
|
778
|
+
|
|
779
|
+
```ts
|
|
780
|
+
const result = await phonic.projects.create({
|
|
781
|
+
name: "customer-support",
|
|
782
|
+
});
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
### Update project
|
|
786
|
+
|
|
787
|
+
```ts
|
|
788
|
+
const result = await phonic.projects.update("customer-support", {
|
|
789
|
+
name: "updated-customer-support",
|
|
790
|
+
defaultAgent: "another-agent"
|
|
791
|
+
});
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
### Delete project
|
|
795
|
+
|
|
796
|
+
```ts
|
|
797
|
+
const result = await phonic.projects.delete("customer-support");
|
|
798
|
+
```
|
|
799
|
+
|
|
756
800
|
## License
|
|
757
801
|
|
|
758
802
|
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -284,11 +284,11 @@ declare class Agents {
|
|
|
284
284
|
private getTemplateVariablesForBody;
|
|
285
285
|
private getConfigurationEndpointForBody;
|
|
286
286
|
list(params?: ListAgentsParams): DataOrError<ListAgentsSuccessResponse>;
|
|
287
|
-
get(
|
|
287
|
+
get(nameOrId: string, params?: GetAgentParams): DataOrError<GetAgentSuccessResponse>;
|
|
288
288
|
create(params: CreateAgentParams): DataOrError<CreateAgentSuccessResponse>;
|
|
289
|
-
update(
|
|
289
|
+
update(nameOrId: string, params: UpdateAgentParams): DataOrError<UpdateAgentSuccessResponse>;
|
|
290
290
|
upsert(params: UpsertAgentParams): DataOrError<UpsertAgentSuccessResponse>;
|
|
291
|
-
delete(
|
|
291
|
+
delete(nameOrId: string, params?: DeleteAgentParams): DataOrError<DeleteAgentSuccessResponse>;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
type ISODateTime = `${string}Z`;
|
|
@@ -369,6 +369,48 @@ declare class Conversations {
|
|
|
369
369
|
outboundCall(toPhoneNumber: string, config: OutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
type Project = {
|
|
373
|
+
id: string;
|
|
374
|
+
name: string;
|
|
375
|
+
default_agent: {
|
|
376
|
+
id: string;
|
|
377
|
+
name: string;
|
|
378
|
+
} | null;
|
|
379
|
+
};
|
|
380
|
+
type ListProjectsSuccessResponse = {
|
|
381
|
+
projects: Array<Project>;
|
|
382
|
+
};
|
|
383
|
+
type GetProjectSuccessResponse = {
|
|
384
|
+
project: Project;
|
|
385
|
+
};
|
|
386
|
+
type CreateProjectParams = {
|
|
387
|
+
name: string;
|
|
388
|
+
};
|
|
389
|
+
type CreateProjectSuccessResponse = {
|
|
390
|
+
id: string;
|
|
391
|
+
name: string;
|
|
392
|
+
};
|
|
393
|
+
type UpdateProjectParams = {
|
|
394
|
+
name?: string;
|
|
395
|
+
defaultAgent?: string;
|
|
396
|
+
};
|
|
397
|
+
type UpdateProjectSuccessResponse = {
|
|
398
|
+
success: true;
|
|
399
|
+
};
|
|
400
|
+
type DeleteProjectSuccessResponse = {
|
|
401
|
+
success: true;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
declare class Projects {
|
|
405
|
+
private readonly phonic;
|
|
406
|
+
constructor(phonic: Phonic);
|
|
407
|
+
list(): DataOrError<ListProjectsSuccessResponse>;
|
|
408
|
+
get(nameOrId: string): DataOrError<GetProjectSuccessResponse>;
|
|
409
|
+
create(params: CreateProjectParams): DataOrError<CreateProjectSuccessResponse>;
|
|
410
|
+
update(nameOrId: string, params: UpdateProjectParams): DataOrError<UpdateProjectSuccessResponse>;
|
|
411
|
+
delete(nameOrId: string): DataOrError<DeleteProjectSuccessResponse>;
|
|
412
|
+
}
|
|
413
|
+
|
|
372
414
|
declare class PhonicSTSWebSocket {
|
|
373
415
|
private readonly ws;
|
|
374
416
|
private readonly config;
|
|
@@ -489,10 +531,10 @@ declare class Tools {
|
|
|
489
531
|
constructor(phonic: Phonic);
|
|
490
532
|
private getParametersForBody;
|
|
491
533
|
list(): DataOrError<ListToolsSuccessResponse>;
|
|
492
|
-
get(
|
|
534
|
+
get(nameOrId: string): DataOrError<GetToolSuccessResponse>;
|
|
493
535
|
create(params: CreateToolParams): DataOrError<CreateToolSuccessResponse>;
|
|
494
|
-
update(
|
|
495
|
-
delete(
|
|
536
|
+
update(nameOrId: string, params: UpdateToolParams): DataOrError<UpdateToolSuccessResponse>;
|
|
537
|
+
delete(nameOrId: string): DataOrError<DeleteToolSuccessResponse>;
|
|
496
538
|
}
|
|
497
539
|
|
|
498
540
|
type Voice = {
|
|
@@ -522,6 +564,7 @@ declare class Phonic {
|
|
|
522
564
|
readonly headers: Record<string, string>;
|
|
523
565
|
readonly agents: Agents;
|
|
524
566
|
readonly conversations: Conversations;
|
|
567
|
+
readonly projects: Projects;
|
|
525
568
|
readonly tools: Tools;
|
|
526
569
|
readonly voices: Voices;
|
|
527
570
|
readonly sts: SpeechToSpeech;
|
package/dist/index.d.ts
CHANGED
|
@@ -284,11 +284,11 @@ declare class Agents {
|
|
|
284
284
|
private getTemplateVariablesForBody;
|
|
285
285
|
private getConfigurationEndpointForBody;
|
|
286
286
|
list(params?: ListAgentsParams): DataOrError<ListAgentsSuccessResponse>;
|
|
287
|
-
get(
|
|
287
|
+
get(nameOrId: string, params?: GetAgentParams): DataOrError<GetAgentSuccessResponse>;
|
|
288
288
|
create(params: CreateAgentParams): DataOrError<CreateAgentSuccessResponse>;
|
|
289
|
-
update(
|
|
289
|
+
update(nameOrId: string, params: UpdateAgentParams): DataOrError<UpdateAgentSuccessResponse>;
|
|
290
290
|
upsert(params: UpsertAgentParams): DataOrError<UpsertAgentSuccessResponse>;
|
|
291
|
-
delete(
|
|
291
|
+
delete(nameOrId: string, params?: DeleteAgentParams): DataOrError<DeleteAgentSuccessResponse>;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
type ISODateTime = `${string}Z`;
|
|
@@ -369,6 +369,48 @@ declare class Conversations {
|
|
|
369
369
|
outboundCall(toPhoneNumber: string, config: OutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
+
type Project = {
|
|
373
|
+
id: string;
|
|
374
|
+
name: string;
|
|
375
|
+
default_agent: {
|
|
376
|
+
id: string;
|
|
377
|
+
name: string;
|
|
378
|
+
} | null;
|
|
379
|
+
};
|
|
380
|
+
type ListProjectsSuccessResponse = {
|
|
381
|
+
projects: Array<Project>;
|
|
382
|
+
};
|
|
383
|
+
type GetProjectSuccessResponse = {
|
|
384
|
+
project: Project;
|
|
385
|
+
};
|
|
386
|
+
type CreateProjectParams = {
|
|
387
|
+
name: string;
|
|
388
|
+
};
|
|
389
|
+
type CreateProjectSuccessResponse = {
|
|
390
|
+
id: string;
|
|
391
|
+
name: string;
|
|
392
|
+
};
|
|
393
|
+
type UpdateProjectParams = {
|
|
394
|
+
name?: string;
|
|
395
|
+
defaultAgent?: string;
|
|
396
|
+
};
|
|
397
|
+
type UpdateProjectSuccessResponse = {
|
|
398
|
+
success: true;
|
|
399
|
+
};
|
|
400
|
+
type DeleteProjectSuccessResponse = {
|
|
401
|
+
success: true;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
declare class Projects {
|
|
405
|
+
private readonly phonic;
|
|
406
|
+
constructor(phonic: Phonic);
|
|
407
|
+
list(): DataOrError<ListProjectsSuccessResponse>;
|
|
408
|
+
get(nameOrId: string): DataOrError<GetProjectSuccessResponse>;
|
|
409
|
+
create(params: CreateProjectParams): DataOrError<CreateProjectSuccessResponse>;
|
|
410
|
+
update(nameOrId: string, params: UpdateProjectParams): DataOrError<UpdateProjectSuccessResponse>;
|
|
411
|
+
delete(nameOrId: string): DataOrError<DeleteProjectSuccessResponse>;
|
|
412
|
+
}
|
|
413
|
+
|
|
372
414
|
declare class PhonicSTSWebSocket {
|
|
373
415
|
private readonly ws;
|
|
374
416
|
private readonly config;
|
|
@@ -489,10 +531,10 @@ declare class Tools {
|
|
|
489
531
|
constructor(phonic: Phonic);
|
|
490
532
|
private getParametersForBody;
|
|
491
533
|
list(): DataOrError<ListToolsSuccessResponse>;
|
|
492
|
-
get(
|
|
534
|
+
get(nameOrId: string): DataOrError<GetToolSuccessResponse>;
|
|
493
535
|
create(params: CreateToolParams): DataOrError<CreateToolSuccessResponse>;
|
|
494
|
-
update(
|
|
495
|
-
delete(
|
|
536
|
+
update(nameOrId: string, params: UpdateToolParams): DataOrError<UpdateToolSuccessResponse>;
|
|
537
|
+
delete(nameOrId: string): DataOrError<DeleteToolSuccessResponse>;
|
|
496
538
|
}
|
|
497
539
|
|
|
498
540
|
type Voice = {
|
|
@@ -522,6 +564,7 @@ declare class Phonic {
|
|
|
522
564
|
readonly headers: Record<string, string>;
|
|
523
565
|
readonly agents: Agents;
|
|
524
566
|
readonly conversations: Conversations;
|
|
567
|
+
readonly projects: Projects;
|
|
525
568
|
readonly tools: Tools;
|
|
526
569
|
readonly voices: Voices;
|
|
527
570
|
readonly sts: SpeechToSpeech;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "0.
|
|
38
|
+
var version = "0.28.1";
|
|
39
39
|
|
|
40
40
|
// src/agents/index.ts
|
|
41
41
|
var Agents = class {
|
|
@@ -78,9 +78,9 @@ var Agents = class {
|
|
|
78
78
|
);
|
|
79
79
|
return response;
|
|
80
80
|
}
|
|
81
|
-
async get(
|
|
81
|
+
async get(nameOrId, params) {
|
|
82
82
|
const response = await this.phonic.get(
|
|
83
|
-
`/agents/${
|
|
83
|
+
`/agents/${nameOrId}?${this.getQueryString(params)}`
|
|
84
84
|
);
|
|
85
85
|
return response;
|
|
86
86
|
}
|
|
@@ -110,9 +110,9 @@ var Agents = class {
|
|
|
110
110
|
);
|
|
111
111
|
return response;
|
|
112
112
|
}
|
|
113
|
-
async update(
|
|
113
|
+
async update(nameOrId, params) {
|
|
114
114
|
const response = await this.phonic.patch(
|
|
115
|
-
`/agents/${
|
|
115
|
+
`/agents/${nameOrId}?${this.getQueryString(params)}`,
|
|
116
116
|
{
|
|
117
117
|
name: params.name,
|
|
118
118
|
phone_number: params.phoneNumber,
|
|
@@ -162,9 +162,9 @@ var Agents = class {
|
|
|
162
162
|
);
|
|
163
163
|
return response;
|
|
164
164
|
}
|
|
165
|
-
async delete(
|
|
165
|
+
async delete(nameOrId, params) {
|
|
166
166
|
const response = await this.phonic.delete(
|
|
167
|
-
`/agents/${
|
|
167
|
+
`/agents/${nameOrId}?${this.getQueryString(params)}`
|
|
168
168
|
);
|
|
169
169
|
return response;
|
|
170
170
|
}
|
|
@@ -250,6 +250,48 @@ var Conversations = class {
|
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
+
// src/projects/index.ts
|
|
254
|
+
var Projects = class {
|
|
255
|
+
constructor(phonic) {
|
|
256
|
+
this.phonic = phonic;
|
|
257
|
+
}
|
|
258
|
+
async list() {
|
|
259
|
+
const response = await this.phonic.get("/projects");
|
|
260
|
+
return response;
|
|
261
|
+
}
|
|
262
|
+
async get(nameOrId) {
|
|
263
|
+
const response = await this.phonic.get(
|
|
264
|
+
`/projects/${nameOrId}`
|
|
265
|
+
);
|
|
266
|
+
return response;
|
|
267
|
+
}
|
|
268
|
+
async create(params) {
|
|
269
|
+
const response = await this.phonic.post(
|
|
270
|
+
"/projects",
|
|
271
|
+
{
|
|
272
|
+
name: params.name
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
return response;
|
|
276
|
+
}
|
|
277
|
+
async update(nameOrId, params) {
|
|
278
|
+
const response = await this.phonic.patch(
|
|
279
|
+
`/projects/${nameOrId}`,
|
|
280
|
+
{
|
|
281
|
+
name: params.name,
|
|
282
|
+
default_agent: params.defaultAgent
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
return response;
|
|
286
|
+
}
|
|
287
|
+
async delete(nameOrId) {
|
|
288
|
+
const response = await this.phonic.delete(
|
|
289
|
+
`/projects/${nameOrId}`
|
|
290
|
+
);
|
|
291
|
+
return response;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
253
295
|
// src/sts/index.ts
|
|
254
296
|
var import_ws = __toESM(require("ws"));
|
|
255
297
|
|
|
@@ -403,9 +445,9 @@ var Tools = class {
|
|
|
403
445
|
const response = await this.phonic.get("/tools");
|
|
404
446
|
return response;
|
|
405
447
|
}
|
|
406
|
-
async get(
|
|
448
|
+
async get(nameOrId) {
|
|
407
449
|
const response = await this.phonic.get(
|
|
408
|
-
`/tools/${
|
|
450
|
+
`/tools/${nameOrId}`
|
|
409
451
|
);
|
|
410
452
|
return response;
|
|
411
453
|
}
|
|
@@ -432,9 +474,9 @@ var Tools = class {
|
|
|
432
474
|
);
|
|
433
475
|
return response;
|
|
434
476
|
}
|
|
435
|
-
async update(
|
|
477
|
+
async update(nameOrId, params) {
|
|
436
478
|
const response = await this.phonic.patch(
|
|
437
|
-
`/tools/${
|
|
479
|
+
`/tools/${nameOrId}`,
|
|
438
480
|
{
|
|
439
481
|
name: params.name,
|
|
440
482
|
description: params.description,
|
|
@@ -450,9 +492,9 @@ var Tools = class {
|
|
|
450
492
|
);
|
|
451
493
|
return response;
|
|
452
494
|
}
|
|
453
|
-
async delete(
|
|
495
|
+
async delete(nameOrId) {
|
|
454
496
|
const response = await this.phonic.delete(
|
|
455
|
-
`/tools/${
|
|
497
|
+
`/tools/${nameOrId}`
|
|
456
498
|
);
|
|
457
499
|
return response;
|
|
458
500
|
}
|
|
@@ -507,6 +549,7 @@ var Phonic = class {
|
|
|
507
549
|
headers;
|
|
508
550
|
agents = new Agents(this);
|
|
509
551
|
conversations = new Conversations(this);
|
|
552
|
+
projects = new Projects(this);
|
|
510
553
|
tools = new Tools(this);
|
|
511
554
|
voices = new Voices(this);
|
|
512
555
|
sts = new SpeechToSpeech(this);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.28.1";
|
|
3
3
|
|
|
4
4
|
// src/agents/index.ts
|
|
5
5
|
var Agents = class {
|
|
@@ -42,9 +42,9 @@ var Agents = class {
|
|
|
42
42
|
);
|
|
43
43
|
return response;
|
|
44
44
|
}
|
|
45
|
-
async get(
|
|
45
|
+
async get(nameOrId, params) {
|
|
46
46
|
const response = await this.phonic.get(
|
|
47
|
-
`/agents/${
|
|
47
|
+
`/agents/${nameOrId}?${this.getQueryString(params)}`
|
|
48
48
|
);
|
|
49
49
|
return response;
|
|
50
50
|
}
|
|
@@ -74,9 +74,9 @@ var Agents = class {
|
|
|
74
74
|
);
|
|
75
75
|
return response;
|
|
76
76
|
}
|
|
77
|
-
async update(
|
|
77
|
+
async update(nameOrId, params) {
|
|
78
78
|
const response = await this.phonic.patch(
|
|
79
|
-
`/agents/${
|
|
79
|
+
`/agents/${nameOrId}?${this.getQueryString(params)}`,
|
|
80
80
|
{
|
|
81
81
|
name: params.name,
|
|
82
82
|
phone_number: params.phoneNumber,
|
|
@@ -126,9 +126,9 @@ var Agents = class {
|
|
|
126
126
|
);
|
|
127
127
|
return response;
|
|
128
128
|
}
|
|
129
|
-
async delete(
|
|
129
|
+
async delete(nameOrId, params) {
|
|
130
130
|
const response = await this.phonic.delete(
|
|
131
|
-
`/agents/${
|
|
131
|
+
`/agents/${nameOrId}?${this.getQueryString(params)}`
|
|
132
132
|
);
|
|
133
133
|
return response;
|
|
134
134
|
}
|
|
@@ -214,6 +214,48 @@ var Conversations = class {
|
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
|
|
217
|
+
// src/projects/index.ts
|
|
218
|
+
var Projects = class {
|
|
219
|
+
constructor(phonic) {
|
|
220
|
+
this.phonic = phonic;
|
|
221
|
+
}
|
|
222
|
+
async list() {
|
|
223
|
+
const response = await this.phonic.get("/projects");
|
|
224
|
+
return response;
|
|
225
|
+
}
|
|
226
|
+
async get(nameOrId) {
|
|
227
|
+
const response = await this.phonic.get(
|
|
228
|
+
`/projects/${nameOrId}`
|
|
229
|
+
);
|
|
230
|
+
return response;
|
|
231
|
+
}
|
|
232
|
+
async create(params) {
|
|
233
|
+
const response = await this.phonic.post(
|
|
234
|
+
"/projects",
|
|
235
|
+
{
|
|
236
|
+
name: params.name
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
return response;
|
|
240
|
+
}
|
|
241
|
+
async update(nameOrId, params) {
|
|
242
|
+
const response = await this.phonic.patch(
|
|
243
|
+
`/projects/${nameOrId}`,
|
|
244
|
+
{
|
|
245
|
+
name: params.name,
|
|
246
|
+
default_agent: params.defaultAgent
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
return response;
|
|
250
|
+
}
|
|
251
|
+
async delete(nameOrId) {
|
|
252
|
+
const response = await this.phonic.delete(
|
|
253
|
+
`/projects/${nameOrId}`
|
|
254
|
+
);
|
|
255
|
+
return response;
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
217
259
|
// src/sts/index.ts
|
|
218
260
|
import WebSocket from "ws";
|
|
219
261
|
|
|
@@ -367,9 +409,9 @@ var Tools = class {
|
|
|
367
409
|
const response = await this.phonic.get("/tools");
|
|
368
410
|
return response;
|
|
369
411
|
}
|
|
370
|
-
async get(
|
|
412
|
+
async get(nameOrId) {
|
|
371
413
|
const response = await this.phonic.get(
|
|
372
|
-
`/tools/${
|
|
414
|
+
`/tools/${nameOrId}`
|
|
373
415
|
);
|
|
374
416
|
return response;
|
|
375
417
|
}
|
|
@@ -396,9 +438,9 @@ var Tools = class {
|
|
|
396
438
|
);
|
|
397
439
|
return response;
|
|
398
440
|
}
|
|
399
|
-
async update(
|
|
441
|
+
async update(nameOrId, params) {
|
|
400
442
|
const response = await this.phonic.patch(
|
|
401
|
-
`/tools/${
|
|
443
|
+
`/tools/${nameOrId}`,
|
|
402
444
|
{
|
|
403
445
|
name: params.name,
|
|
404
446
|
description: params.description,
|
|
@@ -414,9 +456,9 @@ var Tools = class {
|
|
|
414
456
|
);
|
|
415
457
|
return response;
|
|
416
458
|
}
|
|
417
|
-
async delete(
|
|
459
|
+
async delete(nameOrId) {
|
|
418
460
|
const response = await this.phonic.delete(
|
|
419
|
-
`/tools/${
|
|
461
|
+
`/tools/${nameOrId}`
|
|
420
462
|
);
|
|
421
463
|
return response;
|
|
422
464
|
}
|
|
@@ -471,6 +513,7 @@ var Phonic = class {
|
|
|
471
513
|
headers;
|
|
472
514
|
agents = new Agents(this);
|
|
473
515
|
conversations = new Conversations(this);
|
|
516
|
+
projects = new Projects(this);
|
|
474
517
|
tools = new Tools(this);
|
|
475
518
|
voices = new Voices(this);
|
|
476
519
|
sts = new SpeechToSpeech(this);
|