phonic 0.30.10 → 0.30.12

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.
Files changed (68) hide show
  1. package/dist/cjs/Client.d.ts +2 -2
  2. package/dist/cjs/Client.js +2 -2
  3. package/dist/cjs/api/resources/agents/client/Client.d.ts +2 -2
  4. package/dist/cjs/api/resources/agents/client/requests/AgentsCreateRequest.d.ts +2 -0
  5. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.d.ts +11 -0
  6. package/dist/cjs/api/resources/agents/client/requests/UpdateAgentRequest.js +5 -0
  7. package/dist/cjs/api/resources/conversations/client/Client.d.ts +2 -2
  8. package/dist/cjs/api/resources/extractionSchemas/client/Client.d.ts +2 -2
  9. package/dist/cjs/api/resources/projects/client/Client.d.ts +2 -2
  10. package/dist/cjs/api/resources/tools/client/Client.d.ts +6 -4
  11. package/dist/cjs/api/resources/tools/client/Client.js +4 -2
  12. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.d.ts +20 -5
  13. package/dist/cjs/api/resources/tools/client/requests/CreateToolRequest.js +4 -0
  14. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.d.ts +16 -2
  15. package/dist/cjs/api/resources/tools/client/requests/UpdateToolRequest.js +4 -0
  16. package/dist/cjs/api/resources/voices/client/Client.d.ts +2 -2
  17. package/dist/cjs/api/types/Agent.d.ts +11 -0
  18. package/dist/cjs/api/types/Agent.js +5 -0
  19. package/dist/cjs/api/types/ConfigPayload.d.ts +11 -0
  20. package/dist/cjs/api/types/ConfigPayload.js +5 -0
  21. package/dist/cjs/api/types/Conversation.d.ts +11 -0
  22. package/dist/cjs/api/types/Conversation.js +5 -0
  23. package/dist/cjs/api/types/CreateAgentRequest.d.ts +11 -0
  24. package/dist/cjs/api/types/CreateAgentRequest.js +5 -0
  25. package/dist/cjs/api/types/Tool.d.ts +9 -1
  26. package/dist/cjs/api/types/Tool.js +4 -0
  27. package/dist/cjs/api/types/ToolParameter.d.ts +20 -0
  28. package/dist/cjs/api/types/ToolParameter.js +4 -0
  29. package/dist/cjs/core/fetcher/Fetcher.d.ts +1 -1
  30. package/dist/cjs/core/fetcher/requestWithRetries.js +44 -8
  31. package/dist/cjs/core/headers.d.ts +2 -2
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/Client.d.mts +2 -2
  35. package/dist/esm/Client.mjs +2 -2
  36. package/dist/esm/api/resources/agents/client/Client.d.mts +2 -2
  37. package/dist/esm/api/resources/agents/client/requests/AgentsCreateRequest.d.mts +2 -0
  38. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.d.mts +11 -0
  39. package/dist/esm/api/resources/agents/client/requests/UpdateAgentRequest.mjs +5 -0
  40. package/dist/esm/api/resources/conversations/client/Client.d.mts +2 -2
  41. package/dist/esm/api/resources/extractionSchemas/client/Client.d.mts +2 -2
  42. package/dist/esm/api/resources/projects/client/Client.d.mts +2 -2
  43. package/dist/esm/api/resources/tools/client/Client.d.mts +6 -4
  44. package/dist/esm/api/resources/tools/client/Client.mjs +4 -2
  45. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.d.mts +20 -5
  46. package/dist/esm/api/resources/tools/client/requests/CreateToolRequest.mjs +4 -0
  47. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.d.mts +16 -2
  48. package/dist/esm/api/resources/tools/client/requests/UpdateToolRequest.mjs +4 -0
  49. package/dist/esm/api/resources/voices/client/Client.d.mts +2 -2
  50. package/dist/esm/api/types/Agent.d.mts +11 -0
  51. package/dist/esm/api/types/Agent.mjs +5 -0
  52. package/dist/esm/api/types/ConfigPayload.d.mts +11 -0
  53. package/dist/esm/api/types/ConfigPayload.mjs +5 -0
  54. package/dist/esm/api/types/Conversation.d.mts +11 -0
  55. package/dist/esm/api/types/Conversation.mjs +5 -0
  56. package/dist/esm/api/types/CreateAgentRequest.d.mts +11 -0
  57. package/dist/esm/api/types/CreateAgentRequest.mjs +5 -0
  58. package/dist/esm/api/types/Tool.d.mts +9 -1
  59. package/dist/esm/api/types/Tool.mjs +4 -0
  60. package/dist/esm/api/types/ToolParameter.d.mts +20 -0
  61. package/dist/esm/api/types/ToolParameter.mjs +4 -0
  62. package/dist/esm/core/fetcher/Fetcher.d.mts +1 -1
  63. package/dist/esm/core/fetcher/requestWithRetries.mjs +44 -8
  64. package/dist/esm/core/headers.d.mts +2 -2
  65. package/dist/esm/version.d.mts +1 -1
  66. package/dist/esm/version.mjs +1 -1
  67. package/package.json +1 -1
  68. package/reference.md +2 -0
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.30.10";
4
+ exports.SDK_VERSION = "0.30.12";
@@ -16,7 +16,7 @@ export declare namespace PhonicClient {
16
16
  baseUrl?: core.Supplier<string>;
17
17
  apiKey?: core.Supplier<core.BearerToken | undefined>;
18
18
  /** Additional headers to include in requests. */
19
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
19
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
20
20
  fetcher?: core.FetchFunction;
21
21
  }
22
22
  interface RequestOptions {
@@ -29,7 +29,7 @@ export declare namespace PhonicClient {
29
29
  /** Additional query string parameters to include in the request. */
30
30
  queryParams?: Record<string, unknown>;
31
31
  /** Additional headers to include in the request. */
32
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
32
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
33
33
  }
34
34
  }
35
35
  export declare class PhonicClient {
@@ -14,8 +14,8 @@ export class PhonicClient {
14
14
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
15
15
  "X-Fern-Language": "JavaScript",
16
16
  "X-Fern-SDK-Name": "phonic",
17
- "X-Fern-SDK-Version": "0.30.10",
18
- "User-Agent": "phonic/0.30.10",
17
+ "X-Fern-SDK-Version": "0.30.12",
18
+ "User-Agent": "phonic/0.30.12",
19
19
  "X-Fern-Runtime": core.RUNTIME.type,
20
20
  "X-Fern-Runtime-Version": core.RUNTIME.version,
21
21
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -11,7 +11,7 @@ export declare namespace Agents {
11
11
  baseUrl?: core.Supplier<string>;
12
12
  apiKey?: core.Supplier<core.BearerToken | undefined>;
13
13
  /** Additional headers to include in requests. */
14
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
15
  fetcher?: core.FetchFunction;
16
16
  }
17
17
  interface RequestOptions {
@@ -24,7 +24,7 @@ export declare namespace Agents {
24
24
  /** Additional query string parameters to include in the request. */
25
25
  queryParams?: Record<string, unknown>;
26
26
  /** Additional headers to include in the request. */
27
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
28
  }
29
29
  }
30
30
  export declare class Agents {
@@ -52,6 +52,8 @@ export interface AgentsCreateRequest {
52
52
  audio_speed?: number;
53
53
  /** The background noise level of the agent. */
54
54
  background_noise_level?: number;
55
+ /** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */
56
+ background_noise?: Phonic.CreateAgentRequest.BackgroundNoise | null;
55
57
  /** Message to play when the conversation starts. Can contain template variables like `{{customer_name}}`. */
56
58
  welcome_message?: string;
57
59
  /** Instructions for the conversation. Can contain template variables like `{{subject}}`. */
@@ -52,6 +52,8 @@ export interface UpdateAgentRequest {
52
52
  audio_speed?: number;
53
53
  /** The background noise level of the agent. */
54
54
  background_noise_level?: number;
55
+ /** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */
56
+ background_noise?: UpdateAgentRequest.BackgroundNoise | null;
55
57
  /** Message to play when the conversation starts. Can contain template variables like `{{customer_name}}`. */
56
58
  welcome_message?: string;
57
59
  /** Instructions for the conversation. Can contain template variables like `{{subject}}`. */
@@ -86,6 +88,15 @@ export declare namespace UpdateAgentRequest {
86
88
  readonly Pcm8000: "pcm_8000";
87
89
  readonly Mulaw8000: "mulaw_8000";
88
90
  };
91
+ /**
92
+ * The background noise type. Can be "office", "call-center", "coffee-shop", or null.
93
+ */
94
+ type BackgroundNoise = "office" | "call-center" | "coffee-shop";
95
+ const BackgroundNoise: {
96
+ readonly Office: "office";
97
+ readonly CallCenter: "call-center";
98
+ readonly CoffeeShop: "coffee-shop";
99
+ };
89
100
  namespace TemplateVariables {
90
101
  interface Value {
91
102
  default_value: string | null;
@@ -9,4 +9,9 @@ export var UpdateAgentRequest;
9
9
  Pcm8000: "pcm_8000",
10
10
  Mulaw8000: "mulaw_8000",
11
11
  };
12
+ UpdateAgentRequest.BackgroundNoise = {
13
+ Office: "office",
14
+ CallCenter: "call-center",
15
+ CoffeeShop: "coffee-shop",
16
+ };
12
17
  })(UpdateAgentRequest || (UpdateAgentRequest = {}));
@@ -12,7 +12,7 @@ export declare namespace Conversations {
12
12
  baseUrl?: core.Supplier<string>;
13
13
  apiKey?: core.Supplier<core.BearerToken | undefined>;
14
14
  /** Additional headers to include in requests. */
15
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
15
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
16
16
  fetcher?: core.FetchFunction;
17
17
  }
18
18
  interface RequestOptions {
@@ -25,7 +25,7 @@ export declare namespace Conversations {
25
25
  /** Additional query string parameters to include in the request. */
26
26
  queryParams?: Record<string, unknown>;
27
27
  /** Additional headers to include in the request. */
28
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
28
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
29
29
  }
30
30
  interface ConnectArgs {
31
31
  downstream_websocket_url?: string | undefined;
@@ -11,7 +11,7 @@ export declare namespace ExtractionSchemas {
11
11
  baseUrl?: core.Supplier<string>;
12
12
  apiKey?: core.Supplier<core.BearerToken | undefined>;
13
13
  /** Additional headers to include in requests. */
14
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
15
  fetcher?: core.FetchFunction;
16
16
  }
17
17
  interface RequestOptions {
@@ -24,7 +24,7 @@ export declare namespace ExtractionSchemas {
24
24
  /** Additional query string parameters to include in the request. */
25
25
  queryParams?: Record<string, unknown>;
26
26
  /** Additional headers to include in the request. */
27
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
28
  }
29
29
  }
30
30
  export declare class ExtractionSchemas {
@@ -11,7 +11,7 @@ export declare namespace Projects {
11
11
  baseUrl?: core.Supplier<string>;
12
12
  apiKey?: core.Supplier<core.BearerToken | undefined>;
13
13
  /** Additional headers to include in requests. */
14
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
15
  fetcher?: core.FetchFunction;
16
16
  }
17
17
  interface RequestOptions {
@@ -24,7 +24,7 @@ export declare namespace Projects {
24
24
  /** Additional query string parameters to include in the request. */
25
25
  queryParams?: Record<string, unknown>;
26
26
  /** Additional headers to include in the request. */
27
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
28
  }
29
29
  }
30
30
  export declare class Projects {
@@ -11,7 +11,7 @@ export declare namespace Tools {
11
11
  baseUrl?: core.Supplier<string>;
12
12
  apiKey?: core.Supplier<core.BearerToken | undefined>;
13
13
  /** Additional headers to include in requests. */
14
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
15
  fetcher?: core.FetchFunction;
16
16
  }
17
17
  interface RequestOptions {
@@ -24,7 +24,7 @@ export declare namespace Tools {
24
24
  /** Additional query string parameters to include in the request. */
25
25
  queryParams?: Record<string, unknown>;
26
26
  /** Additional headers to include in the request. */
27
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
28
  }
29
29
  }
30
30
  export declare class Tools {
@@ -66,12 +66,14 @@ export declare class Tools {
66
66
  * type: "string",
67
67
  * name: "date",
68
68
  * description: "The date for the appointment in YYYY-MM-DD format",
69
- * is_required: true
69
+ * is_required: true,
70
+ * location: "request_body"
70
71
  * }, {
71
72
  * type: "string",
72
73
  * name: "time",
73
74
  * description: "The time for the appointment in HH:MM format",
74
- * is_required: true
75
+ * is_required: true,
76
+ * location: "request_body"
75
77
  * }],
76
78
  * endpoint_method: "POST",
77
79
  * endpoint_url: "https://api.example.com/book-appointment",
@@ -118,12 +118,14 @@ export class Tools {
118
118
  * type: "string",
119
119
  * name: "date",
120
120
  * description: "The date for the appointment in YYYY-MM-DD format",
121
- * is_required: true
121
+ * is_required: true,
122
+ * location: "request_body"
122
123
  * }, {
123
124
  * type: "string",
124
125
  * name: "time",
125
126
  * description: "The time for the appointment in HH:MM format",
126
- * is_required: true
127
+ * is_required: true,
128
+ * location: "request_body"
127
129
  * }],
128
130
  * endpoint_method: "POST",
129
131
  * endpoint_url: "https://api.example.com/book-appointment",
@@ -14,12 +14,14 @@ import * as Phonic from "../../../../index.mjs";
14
14
  * type: "string",
15
15
  * name: "date",
16
16
  * description: "The date for the appointment in YYYY-MM-DD format",
17
- * is_required: true
17
+ * is_required: true,
18
+ * location: "request_body"
18
19
  * }, {
19
20
  * type: "string",
20
21
  * name: "time",
21
22
  * description: "The time for the appointment in HH:MM format",
22
- * is_required: true
23
+ * is_required: true,
24
+ * location: "request_body"
23
25
  * }],
24
26
  * endpoint_method: "POST",
25
27
  * endpoint_url: "https://api.example.com/book-appointment",
@@ -67,10 +69,15 @@ export interface CreateToolRequest {
67
69
  type: CreateToolRequest.Type;
68
70
  /** Mode of operation. */
69
71
  execution_mode: CreateToolRequest.ExecutionMode;
70
- /** Array of parameter definitions. */
72
+ /**
73
+ * Array of parameter definitions.
74
+ * For `custom_webhook` tools with POST method, each parameter must include a `location` field.
75
+ * For `custom_webhook` tools with GET method, `location` defaults to `"query_string"` if not specified.
76
+ * For `custom_websocket` and `built_in_transfer_to_phone_number` tools, `location` must not be specified.
77
+ */
71
78
  parameters?: Phonic.ToolParameter[];
72
- /** Required for webhook tools. */
73
- endpoint_method?: "POST";
79
+ /** Required for webhook tools. HTTP method for the webhook endpoint. */
80
+ endpoint_method?: CreateToolRequest.EndpointMethod;
74
81
  /** Required for webhook tools. */
75
82
  endpoint_url?: string;
76
83
  /** Optional headers for webhook tools. */
@@ -100,4 +107,12 @@ export declare namespace CreateToolRequest {
100
107
  readonly Sync: "sync";
101
108
  readonly Async: "async";
102
109
  };
110
+ /**
111
+ * Required for webhook tools. HTTP method for the webhook endpoint.
112
+ */
113
+ type EndpointMethod = "GET" | "POST";
114
+ const EndpointMethod: {
115
+ readonly Get: "GET";
116
+ readonly Post: "POST";
117
+ };
103
118
  }
@@ -12,4 +12,8 @@ export var CreateToolRequest;
12
12
  Sync: "sync",
13
13
  Async: "async",
14
14
  };
15
+ CreateToolRequest.EndpointMethod = {
16
+ Get: "GET",
17
+ Post: "POST",
18
+ };
15
19
  })(CreateToolRequest || (CreateToolRequest = {}));
@@ -24,9 +24,15 @@ export interface UpdateToolRequest {
24
24
  type?: UpdateToolRequest.Type;
25
25
  /** Mode of operation. */
26
26
  execution_mode?: UpdateToolRequest.ExecutionMode;
27
- /** Array of parameter definitions. */
27
+ /**
28
+ * Array of parameter definitions.
29
+ * When updating `type` or `endpoint_method`, all parameters must include explicit `location` values.
30
+ * For `custom_webhook` tools: `location` is required for POST, defaults to `"query_string"` for GET.
31
+ * For `custom_websocket` and `built_in_transfer_to_phone_number` tools: `location` must not be specified.
32
+ */
28
33
  parameters?: Phonic.ToolParameter[];
29
- endpoint_method?: "POST";
34
+ /** HTTP method for webhook tools. When changing this value, all parameters must include explicit `location` values. */
35
+ endpoint_method?: UpdateToolRequest.EndpointMethod;
30
36
  endpoint_url?: string;
31
37
  endpoint_headers?: Record<string, string>;
32
38
  endpoint_timeout_ms?: number;
@@ -52,4 +58,12 @@ export declare namespace UpdateToolRequest {
52
58
  readonly Sync: "sync";
53
59
  readonly Async: "async";
54
60
  };
61
+ /**
62
+ * HTTP method for webhook tools. When changing this value, all parameters must include explicit `location` values.
63
+ */
64
+ type EndpointMethod = "GET" | "POST";
65
+ const EndpointMethod: {
66
+ readonly Get: "GET";
67
+ readonly Post: "POST";
68
+ };
55
69
  }
@@ -12,4 +12,8 @@ export var UpdateToolRequest;
12
12
  Sync: "sync",
13
13
  Async: "async",
14
14
  };
15
+ UpdateToolRequest.EndpointMethod = {
16
+ Get: "GET",
17
+ Post: "POST",
18
+ };
15
19
  })(UpdateToolRequest || (UpdateToolRequest = {}));
@@ -11,7 +11,7 @@ export declare namespace Voices {
11
11
  baseUrl?: core.Supplier<string>;
12
12
  apiKey?: core.Supplier<core.BearerToken | undefined>;
13
13
  /** Additional headers to include in requests. */
14
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
14
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
15
15
  fetcher?: core.FetchFunction;
16
16
  }
17
17
  interface RequestOptions {
@@ -24,7 +24,7 @@ export declare namespace Voices {
24
24
  /** Additional query string parameters to include in the request. */
25
25
  queryParams?: Record<string, unknown>;
26
26
  /** Additional headers to include in the request. */
27
- headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
28
  }
29
29
  }
30
30
  export declare class Voices {
@@ -21,6 +21,8 @@ export interface Agent {
21
21
  audio_speed: number;
22
22
  /** The background noise level of the agent. Must be between 0 and 1. */
23
23
  background_noise_level: number;
24
+ /** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */
25
+ background_noise: Agent.BackgroundNoise | null;
24
26
  /** Message to play when the conversation starts. */
25
27
  welcome_message: string | null;
26
28
  /** Instructions for the conversation. */
@@ -62,6 +64,15 @@ export declare namespace Agent {
62
64
  readonly Pcm8000: "pcm_8000";
63
65
  readonly Mulaw8000: "mulaw_8000";
64
66
  };
67
+ /**
68
+ * The background noise type. Can be "office", "call-center", "coffee-shop", or null.
69
+ */
70
+ type BackgroundNoise = "office" | "call-center" | "coffee-shop";
71
+ const BackgroundNoise: {
72
+ readonly Office: "office";
73
+ readonly CallCenter: "call-center";
74
+ readonly CoffeeShop: "coffee-shop";
75
+ };
65
76
  namespace TemplateVariables {
66
77
  interface Value {
67
78
  default_value: string | null;
@@ -9,4 +9,9 @@ export var Agent;
9
9
  Pcm8000: "pcm_8000",
10
10
  Mulaw8000: "mulaw_8000",
11
11
  };
12
+ Agent.BackgroundNoise = {
13
+ Office: "office",
14
+ CallCenter: "call-center",
15
+ CoffeeShop: "coffee-shop",
16
+ };
12
17
  })(Agent || (Agent = {}));
@@ -15,6 +15,8 @@ export interface ConfigPayload {
15
15
  audio_speed?: number;
16
16
  /** Background noise level for the conversation */
17
17
  background_noise_level?: number;
18
+ /** Background noise type for the conversation */
19
+ background_noise?: ConfigPayload.BackgroundNoise | null;
18
20
  /** Message to play when conversation starts */
19
21
  welcome_message?: string | null;
20
22
  /** Voice ID to use for speech synthesis */
@@ -51,6 +53,15 @@ export interface ConfigPayload {
51
53
  template_variables?: Record<string, string>;
52
54
  }
53
55
  export declare namespace ConfigPayload {
56
+ /**
57
+ * Background noise type for the conversation
58
+ */
59
+ type BackgroundNoise = "office" | "call-center" | "coffee-shop";
60
+ const BackgroundNoise: {
61
+ readonly Office: "office";
62
+ readonly CallCenter: "call-center";
63
+ readonly CoffeeShop: "coffee-shop";
64
+ };
54
65
  /**
55
66
  * Audio input format
56
67
  */
@@ -3,6 +3,11 @@
3
3
  */
4
4
  export var ConfigPayload;
5
5
  (function (ConfigPayload) {
6
+ ConfigPayload.BackgroundNoise = {
7
+ Office: "office",
8
+ CallCenter: "call-center",
9
+ CoffeeShop: "coffee-shop",
10
+ };
6
11
  ConfigPayload.InputFormat = {
7
12
  Pcm44100: "pcm_44100",
8
13
  Pcm16000: "pcm_16000",
@@ -25,6 +25,8 @@ export interface Conversation {
25
25
  output_format: string;
26
26
  /** Background noise level used in the conversation. */
27
27
  background_noise_level: number;
28
+ /** The background noise type used in the conversation. */
29
+ background_noise: Conversation.BackgroundNoise | null;
28
30
  /** Live transcript of the conversation. */
29
31
  live_transcript: string;
30
32
  /** Post-call processed transcript. */
@@ -75,6 +77,15 @@ export declare namespace Conversation {
75
77
  /** The name of the project. */
76
78
  name: string;
77
79
  }
80
+ /**
81
+ * The background noise type used in the conversation.
82
+ */
83
+ type BackgroundNoise = "office" | "call-center" | "coffee-shop";
84
+ const BackgroundNoise: {
85
+ readonly Office: "office";
86
+ readonly CallCenter: "call-center";
87
+ readonly CoffeeShop: "coffee-shop";
88
+ };
78
89
  /**
79
90
  * Who or what ended the conversation.
80
91
  */
@@ -3,6 +3,11 @@
3
3
  */
4
4
  export var Conversation;
5
5
  (function (Conversation) {
6
+ Conversation.BackgroundNoise = {
7
+ Office: "office",
8
+ CallCenter: "call-center",
9
+ CoffeeShop: "coffee-shop",
10
+ };
6
11
  Conversation.EndedBy = {
7
12
  User: "user",
8
13
  UserCanceled: "user_canceled",
@@ -16,6 +16,8 @@ export interface CreateAgentRequest {
16
16
  audio_speed?: number;
17
17
  /** The background noise level of the agent. */
18
18
  background_noise_level?: number;
19
+ /** The background noise type. Can be "office", "call-center", "coffee-shop", or null. */
20
+ background_noise?: CreateAgentRequest.BackgroundNoise | null;
19
21
  /** Message to play when the conversation starts. Can contain template variables like `{{customer_name}}`. */
20
22
  welcome_message?: string;
21
23
  /** Instructions for the conversation. Can contain template variables like `{{subject}}`. */
@@ -50,6 +52,15 @@ export declare namespace CreateAgentRequest {
50
52
  readonly Pcm8000: "pcm_8000";
51
53
  readonly Mulaw8000: "mulaw_8000";
52
54
  };
55
+ /**
56
+ * The background noise type. Can be "office", "call-center", "coffee-shop", or null.
57
+ */
58
+ type BackgroundNoise = "office" | "call-center" | "coffee-shop";
59
+ const BackgroundNoise: {
60
+ readonly Office: "office";
61
+ readonly CallCenter: "call-center";
62
+ readonly CoffeeShop: "coffee-shop";
63
+ };
53
64
  namespace TemplateVariables {
54
65
  interface Value {
55
66
  default_value: string | null;
@@ -9,4 +9,9 @@ export var CreateAgentRequest;
9
9
  Pcm8000: "pcm_8000",
10
10
  Mulaw8000: "mulaw_8000",
11
11
  };
12
+ CreateAgentRequest.BackgroundNoise = {
13
+ Office: "office",
14
+ CallCenter: "call-center",
15
+ CoffeeShop: "coffee-shop",
16
+ };
12
17
  })(CreateAgentRequest || (CreateAgentRequest = {}));
@@ -17,7 +17,7 @@ export interface Tool {
17
17
  /** Array of parameter definitions for the tool. */
18
18
  parameters: Phonic.ToolParameter[];
19
19
  /** HTTP method for webhook tools. */
20
- endpoint_method?: "POST";
20
+ endpoint_method?: Tool.EndpointMethod;
21
21
  /** URL for webhook tools. */
22
22
  endpoint_url?: string;
23
23
  /** Headers for webhook tools. */
@@ -51,4 +51,12 @@ export declare namespace Tool {
51
51
  readonly Sync: "sync";
52
52
  readonly Async: "async";
53
53
  };
54
+ /**
55
+ * HTTP method for webhook tools.
56
+ */
57
+ type EndpointMethod = "GET" | "POST";
58
+ const EndpointMethod: {
59
+ readonly Get: "GET";
60
+ readonly Post: "POST";
61
+ };
54
62
  }
@@ -12,4 +12,8 @@ export var Tool;
12
12
  Sync: "sync",
13
13
  Async: "async",
14
14
  };
15
+ Tool.EndpointMethod = {
16
+ Get: "GET",
17
+ Post: "POST",
18
+ };
15
19
  })(Tool || (Tool = {}));
@@ -12,6 +12,14 @@ export interface ToolParameter {
12
12
  description: string;
13
13
  /** Whether the parameter is required. */
14
14
  is_required: boolean;
15
+ /**
16
+ * Only applicable for `custom_webhook` tools. Specifies where the parameter should be sent in the webhook request.
17
+ * - For GET webhooks: defaults to `"query_string"` and `"request_body"` is not allowed.
18
+ * - For POST webhooks: required, can be either `"request_body"` or `"query_string"`.
19
+ * - Not allowed for `custom_websocket` or `built_in_transfer_to_phone_number` tools.
20
+ * When updating a tool's type or endpoint_method, all parameters must include explicit `location` values.
21
+ */
22
+ location?: ToolParameter.Location;
15
23
  }
16
24
  export declare namespace ToolParameter {
17
25
  /**
@@ -35,4 +43,16 @@ export declare namespace ToolParameter {
35
43
  readonly Number: "number";
36
44
  readonly Boolean: "boolean";
37
45
  };
46
+ /**
47
+ * Only applicable for `custom_webhook` tools. Specifies where the parameter should be sent in the webhook request.
48
+ * - For GET webhooks: defaults to `"query_string"` and `"request_body"` is not allowed.
49
+ * - For POST webhooks: required, can be either `"request_body"` or `"query_string"`.
50
+ * - Not allowed for `custom_websocket` or `built_in_transfer_to_phone_number` tools.
51
+ * When updating a tool's type or endpoint_method, all parameters must include explicit `location` values.
52
+ */
53
+ type Location = "request_body" | "query_string";
54
+ const Location: {
55
+ readonly RequestBody: "request_body";
56
+ readonly QueryString: "query_string";
57
+ };
38
58
  }
@@ -16,4 +16,8 @@ export var ToolParameter;
16
16
  Number: "number",
17
17
  Boolean: "boolean",
18
18
  };
19
+ ToolParameter.Location = {
20
+ RequestBody: "request_body",
21
+ QueryString: "query_string",
22
+ };
19
23
  })(ToolParameter || (ToolParameter = {}));
@@ -6,7 +6,7 @@ export declare namespace Fetcher {
6
6
  url: string;
7
7
  method: string;
8
8
  contentType?: string;
9
- headers?: Record<string, string | Supplier<string | undefined> | undefined>;
9
+ headers?: Record<string, string | Supplier<string | null | undefined> | null | undefined>;
10
10
  queryParameters?: Record<string, unknown>;
11
11
  body?: unknown;
12
12
  timeoutMs?: number;
@@ -11,21 +11,57 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
11
11
  const MAX_RETRY_DELAY = 60000; // in milliseconds
12
12
  const DEFAULT_MAX_RETRIES = 2;
13
13
  const JITTER_FACTOR = 0.2; // 20% random jitter
14
- function addJitter(delay) {
15
- // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR
16
- const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
14
+ function addPositiveJitter(delay) {
15
+ // Generate a random value between 0 and +JITTER_FACTOR
16
+ const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
17
17
  return delay * jitterMultiplier;
18
18
  }
19
+ function addSymmetricJitter(delay) {
20
+ // Generate a random value in a JITTER_FACTOR-sized percentage range around delay
21
+ const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
22
+ return delay * jitterMultiplier;
23
+ }
24
+ function getRetryDelayFromHeaders(response, retryAttempt) {
25
+ // Check for Retry-After header first (RFC 7231), with no jitter
26
+ const retryAfter = response.headers.get("Retry-After");
27
+ if (retryAfter) {
28
+ // Parse as number of seconds...
29
+ const retryAfterSeconds = parseInt(retryAfter, 10);
30
+ if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
31
+ return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
32
+ }
33
+ // ...or as an HTTP date; both are valid
34
+ const retryAfterDate = new Date(retryAfter);
35
+ if (!isNaN(retryAfterDate.getTime())) {
36
+ const delay = retryAfterDate.getTime() - Date.now();
37
+ if (delay > 0) {
38
+ return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
39
+ }
40
+ }
41
+ }
42
+ // Then check for industry-standard X-RateLimit-Reset header, with positive jitter
43
+ const rateLimitReset = response.headers.get("X-RateLimit-Reset");
44
+ if (rateLimitReset) {
45
+ const resetTime = parseInt(rateLimitReset, 10);
46
+ if (!isNaN(resetTime)) {
47
+ // Assume Unix timestamp in epoch seconds
48
+ const delay = resetTime * 1000 - Date.now();
49
+ if (delay > 0) {
50
+ return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
51
+ }
52
+ }
53
+ }
54
+ // Fall back to exponential backoff, with symmetric jitter
55
+ return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
56
+ }
19
57
  export function requestWithRetries(requestFn_1) {
20
58
  return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
21
59
  let response = yield requestFn();
22
60
  for (let i = 0; i < maxRetries; ++i) {
23
61
  if ([408, 429].includes(response.status) || response.status >= 500) {
24
- // Calculate base delay using exponential backoff (in milliseconds)
25
- const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
26
- // Add jitter to the delay
27
- const delayWithJitter = addJitter(baseDelay);
28
- yield new Promise((resolve) => setTimeout(resolve, delayWithJitter));
62
+ // Get delay with appropriate jitter applied
63
+ const delay = getRetryDelayFromHeaders(response, i);
64
+ yield new Promise((resolve) => setTimeout(resolve, delay));
29
65
  response = yield requestFn();
30
66
  }
31
67
  else {
@@ -1,3 +1,3 @@
1
1
  import * as core from "./index.mjs";
2
- export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
3
- export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
2
+ export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | null | undefined> | null | undefined> | null | undefined)[]): Record<string, string | core.Supplier<string | null | undefined>>;
3
+ export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | null | undefined> | null | undefined> | null | undefined)[]): Record<string, string | core.Supplier<string | null | undefined>>;