phonic 0.28.1 → 0.29.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/README.md CHANGED
@@ -193,7 +193,9 @@ const result = await phonic.agents.delete("chris", {
193
193
  ### List tools
194
194
 
195
195
  ```ts
196
- const result = await phonic.tools.list();
196
+ const result = await phonic.tools.list({
197
+ project: "customer-support" // Optional. Defaults to "main".
198
+ });
197
199
  ```
198
200
 
199
201
  ### Get tool
@@ -201,7 +203,9 @@ const result = await phonic.tools.list();
201
203
  Returns a tool by name or ID.
202
204
 
203
205
  ```ts
204
- const result = await phonic.tools.get("next_invoice");
206
+ const result = await phonic.tools.get("next_invoice", {
207
+ project: "customer-support" // Optional. Defaults to "main".
208
+ });
205
209
  ```
206
210
 
207
211
  ### Create tool
@@ -210,6 +214,7 @@ const result = await phonic.tools.get("next_invoice");
210
214
 
211
215
  ```ts
212
216
  const result = await phonic.tools.create({
217
+ project: "customer-support", // Optional. Defaults to "main".
213
218
  name: "next_invoice",
214
219
  description: "Returns the next invoice of the given user",
215
220
  type: "custom_webhook",
@@ -250,6 +255,7 @@ WebSocket tools allow you to handle tool execution through the WebSocket connect
250
255
 
251
256
  ```ts
252
257
  const result = await phonic.tools.create({
258
+ project: "customer-support", // Optional. Defaults to "main".
253
259
  name: "get_product_recommendations",
254
260
  description: "Gets personalized product recommendations",
255
261
  type: "custom_websocket",
@@ -309,6 +315,7 @@ Updates a tool by ID or name. All fields are optional - only provided fields wil
309
315
 
310
316
  ```ts
311
317
  const result = await phonic.tools.update("next_invoice", {
318
+ project: "customer-support", // Optional. Defaults to "main".
312
319
  name: "next_invoice_updated",
313
320
  description: "Updated description.",
314
321
  type: "custom_webhook",
@@ -357,10 +364,11 @@ const result = await phonic.tools.update("get_product_recommendations", {
357
364
  Deletes a tool by ID or name.
358
365
 
359
366
  ```ts
360
- const result = await phonic.tools.delete("next_invoice");
367
+ const result = await phonic.tools.delete("next_invoice", {
368
+ project: "customer-support" // Optional. Defaults to "main".
369
+ });
361
370
  ```
362
371
 
363
-
364
372
  ## Voices
365
373
 
366
374
  ### List voices
package/dist/index.d.mts CHANGED
@@ -479,13 +479,20 @@ interface WebSocketTool extends ToolBase {
479
479
  tool_call_output_timeout_ms: number;
480
480
  }
481
481
  type Tool = WebhookTool | WebSocketTool;
482
+ type ListToolsParams = {
483
+ project?: string;
484
+ };
482
485
  type ListToolsSuccessResponse = DataOrError<{
483
486
  tools: Array<Tool>;
484
487
  }>;
488
+ type GetToolParams = {
489
+ project?: string;
490
+ };
485
491
  type GetToolSuccessResponse = DataOrError<{
486
492
  tool: Tool;
487
493
  }>;
488
494
  interface CreateToolParamsBase {
495
+ project?: string;
489
496
  name: string;
490
497
  description: string;
491
498
  executionMode: ExecutionMode;
@@ -508,6 +515,7 @@ type CreateToolSuccessResponse = {
508
515
  name: string;
509
516
  };
510
517
  type UpdateToolParams = {
518
+ project?: string;
511
519
  name?: string;
512
520
  description?: string;
513
521
  type?: "custom_webhook" | "custom_websocket";
@@ -522,6 +530,9 @@ type UpdateToolParams = {
522
530
  type UpdateToolSuccessResponse = {
523
531
  success: true;
524
532
  };
533
+ type DeleteToolParams = {
534
+ project?: string;
535
+ };
525
536
  type DeleteToolSuccessResponse = {
526
537
  success: true;
527
538
  };
@@ -529,12 +540,13 @@ type DeleteToolSuccessResponse = {
529
540
  declare class Tools {
530
541
  private readonly phonic;
531
542
  constructor(phonic: Phonic);
543
+ private getQueryString;
532
544
  private getParametersForBody;
533
- list(): DataOrError<ListToolsSuccessResponse>;
534
- get(nameOrId: string): DataOrError<GetToolSuccessResponse>;
545
+ list(params?: ListToolsParams): DataOrError<ListToolsSuccessResponse>;
546
+ get(nameOrId: string, params?: GetToolParams): DataOrError<GetToolSuccessResponse>;
535
547
  create(params: CreateToolParams): DataOrError<CreateToolSuccessResponse>;
536
548
  update(nameOrId: string, params: UpdateToolParams): DataOrError<UpdateToolSuccessResponse>;
537
- delete(nameOrId: string): DataOrError<DeleteToolSuccessResponse>;
549
+ delete(nameOrId: string, params?: DeleteToolParams): DataOrError<DeleteToolSuccessResponse>;
538
550
  }
539
551
 
540
552
  type Voice = {
package/dist/index.d.ts CHANGED
@@ -479,13 +479,20 @@ interface WebSocketTool extends ToolBase {
479
479
  tool_call_output_timeout_ms: number;
480
480
  }
481
481
  type Tool = WebhookTool | WebSocketTool;
482
+ type ListToolsParams = {
483
+ project?: string;
484
+ };
482
485
  type ListToolsSuccessResponse = DataOrError<{
483
486
  tools: Array<Tool>;
484
487
  }>;
488
+ type GetToolParams = {
489
+ project?: string;
490
+ };
485
491
  type GetToolSuccessResponse = DataOrError<{
486
492
  tool: Tool;
487
493
  }>;
488
494
  interface CreateToolParamsBase {
495
+ project?: string;
489
496
  name: string;
490
497
  description: string;
491
498
  executionMode: ExecutionMode;
@@ -508,6 +515,7 @@ type CreateToolSuccessResponse = {
508
515
  name: string;
509
516
  };
510
517
  type UpdateToolParams = {
518
+ project?: string;
511
519
  name?: string;
512
520
  description?: string;
513
521
  type?: "custom_webhook" | "custom_websocket";
@@ -522,6 +530,9 @@ type UpdateToolParams = {
522
530
  type UpdateToolSuccessResponse = {
523
531
  success: true;
524
532
  };
533
+ type DeleteToolParams = {
534
+ project?: string;
535
+ };
525
536
  type DeleteToolSuccessResponse = {
526
537
  success: true;
527
538
  };
@@ -529,12 +540,13 @@ type DeleteToolSuccessResponse = {
529
540
  declare class Tools {
530
541
  private readonly phonic;
531
542
  constructor(phonic: Phonic);
543
+ private getQueryString;
532
544
  private getParametersForBody;
533
- list(): DataOrError<ListToolsSuccessResponse>;
534
- get(nameOrId: string): DataOrError<GetToolSuccessResponse>;
545
+ list(params?: ListToolsParams): DataOrError<ListToolsSuccessResponse>;
546
+ get(nameOrId: string, params?: GetToolParams): DataOrError<GetToolSuccessResponse>;
535
547
  create(params: CreateToolParams): DataOrError<CreateToolSuccessResponse>;
536
548
  update(nameOrId: string, params: UpdateToolParams): DataOrError<UpdateToolSuccessResponse>;
537
- delete(nameOrId: string): DataOrError<DeleteToolSuccessResponse>;
549
+ delete(nameOrId: string, params?: DeleteToolParams): DataOrError<DeleteToolSuccessResponse>;
538
550
  }
539
551
 
540
552
  type Voice = {
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.1";
38
+ var version = "0.29.0";
39
39
 
40
40
  // src/agents/index.ts
41
41
  var Agents = class {
@@ -425,6 +425,13 @@ var Tools = class {
425
425
  constructor(phonic) {
426
426
  this.phonic = phonic;
427
427
  }
428
+ getQueryString(params) {
429
+ const project = params?.project;
430
+ const queryString = new URLSearchParams({
431
+ ...project !== void 0 && { project }
432
+ }).toString();
433
+ return queryString;
434
+ }
428
435
  getParametersForBody(parameters) {
429
436
  if (parameters === void 0) {
430
437
  return void 0;
@@ -441,13 +448,15 @@ var Tools = class {
441
448
  };
442
449
  });
443
450
  }
444
- async list() {
445
- const response = await this.phonic.get("/tools");
451
+ async list(params) {
452
+ const response = await this.phonic.get(
453
+ `/tools?${this.getQueryString(params)}`
454
+ );
446
455
  return response;
447
456
  }
448
- async get(nameOrId) {
457
+ async get(nameOrId, params) {
449
458
  const response = await this.phonic.get(
450
- `/tools/${nameOrId}`
459
+ `/tools/${nameOrId}?${this.getQueryString(params)}`
451
460
  );
452
461
  return response;
453
462
  }
@@ -469,14 +478,14 @@ var Tools = class {
469
478
  body.tool_call_output_timeout_ms = params.toolCallOutputTimeoutMs;
470
479
  }
471
480
  const response = await this.phonic.post(
472
- "/tools",
481
+ `/tools?${this.getQueryString(params)}`,
473
482
  body
474
483
  );
475
484
  return response;
476
485
  }
477
486
  async update(nameOrId, params) {
478
487
  const response = await this.phonic.patch(
479
- `/tools/${nameOrId}`,
488
+ `/tools/${nameOrId}?${this.getQueryString(params)}`,
480
489
  {
481
490
  name: params.name,
482
491
  description: params.description,
@@ -492,9 +501,9 @@ var Tools = class {
492
501
  );
493
502
  return response;
494
503
  }
495
- async delete(nameOrId) {
504
+ async delete(nameOrId, params) {
496
505
  const response = await this.phonic.delete(
497
- `/tools/${nameOrId}`
506
+ `/tools/${nameOrId}?${this.getQueryString(params)}`
498
507
  );
499
508
  return response;
500
509
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.28.1";
2
+ var version = "0.29.0";
3
3
 
4
4
  // src/agents/index.ts
5
5
  var Agents = class {
@@ -389,6 +389,13 @@ var Tools = class {
389
389
  constructor(phonic) {
390
390
  this.phonic = phonic;
391
391
  }
392
+ getQueryString(params) {
393
+ const project = params?.project;
394
+ const queryString = new URLSearchParams({
395
+ ...project !== void 0 && { project }
396
+ }).toString();
397
+ return queryString;
398
+ }
392
399
  getParametersForBody(parameters) {
393
400
  if (parameters === void 0) {
394
401
  return void 0;
@@ -405,13 +412,15 @@ var Tools = class {
405
412
  };
406
413
  });
407
414
  }
408
- async list() {
409
- const response = await this.phonic.get("/tools");
415
+ async list(params) {
416
+ const response = await this.phonic.get(
417
+ `/tools?${this.getQueryString(params)}`
418
+ );
410
419
  return response;
411
420
  }
412
- async get(nameOrId) {
421
+ async get(nameOrId, params) {
413
422
  const response = await this.phonic.get(
414
- `/tools/${nameOrId}`
423
+ `/tools/${nameOrId}?${this.getQueryString(params)}`
415
424
  );
416
425
  return response;
417
426
  }
@@ -433,14 +442,14 @@ var Tools = class {
433
442
  body.tool_call_output_timeout_ms = params.toolCallOutputTimeoutMs;
434
443
  }
435
444
  const response = await this.phonic.post(
436
- "/tools",
445
+ `/tools?${this.getQueryString(params)}`,
437
446
  body
438
447
  );
439
448
  return response;
440
449
  }
441
450
  async update(nameOrId, params) {
442
451
  const response = await this.phonic.patch(
443
- `/tools/${nameOrId}`,
452
+ `/tools/${nameOrId}?${this.getQueryString(params)}`,
444
453
  {
445
454
  name: params.name,
446
455
  description: params.description,
@@ -456,9 +465,9 @@ var Tools = class {
456
465
  );
457
466
  return response;
458
467
  }
459
- async delete(nameOrId) {
468
+ async delete(nameOrId, params) {
460
469
  const response = await this.phonic.delete(
461
- `/tools/${nameOrId}`
470
+ `/tools/${nameOrId}?${this.getQueryString(params)}`
462
471
  );
463
472
  return response;
464
473
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonic",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "description": "Phonic Node.js SDK",
5
5
  "scripts": {
6
6
  "build": "tsup",