phonic 0.28.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 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 agentsResult = await phonic.agents.list({ project: "main" });
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 agentResult = await phonic.agents.get("chris", { project: "main" });
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 createAgentResult = await phonic.agents.create({
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 updateAgentResult = await phonic.agents.update("chris", {
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 upsertAgentResult = await phonic.agents.upsert({
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 deleteAgentResult = await phonic.agents.delete("chris", {
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 toolsResult = await phonic.tools.list();
196
+ const result = await phonic.tools.list();
189
197
  ```
190
198
 
191
199
  ### Get tool
192
200
 
193
- Gets a tool by its ID or name.
201
+ Returns a tool by name or ID.
194
202
 
195
203
  ```ts
196
- const toolResult = await phonic.tools.get("next_invoice");
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 createWebhookToolResult = await phonic.tools.create({
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 createWebSocketToolResult = await phonic.tools.create({
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 agent = await phonic.agents.create({
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 updateWebhookToolResult = await phonic.tools.update("next_invoice", {
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 updateWebSocketToolResult = await phonic.tools.update("get_product_recommendations", {
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 deleteToolResult = await phonic.tools.delete("next_invoice");
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 voicesResult = await phonic.voices.list({ model: "merritt" });
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 voiceResult = await phonic.voices.get("grant");
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 conversationsResult = await phonic.conversations.list({
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 conversationResult = await phonic.conversations.get("conv_b1804883-5be4-42fe-b1cf-aa84450d5c84");
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 conversationResult = await phonic.conversations.getByExternalId({
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 outboundCallResult = await phonic.conversations.outboundCall("+19189396241", {
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 twilioOutboundCallResult = await phonic.conversations.twilio.outboundCall(
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.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.28.0";
38
+ var version = "0.28.1";
39
39
 
40
40
  // src/agents/index.ts
41
41
  var Agents = class {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.28.0";
2
+ var version = "0.28.1";
3
3
 
4
4
  // src/agents/index.ts
5
5
  var Agents = class {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.28.0",
3
+ "version": "0.28.1",
4
4
  "description": "Phonic Node.js SDK",
5
5
  "scripts": {
6
6
  "build": "tsup",