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
@@ -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 {
@@ -50,8 +50,8 @@ class PhonicClient {
50
50
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
51
51
  "X-Fern-Language": "JavaScript",
52
52
  "X-Fern-SDK-Name": "phonic",
53
- "X-Fern-SDK-Version": "0.30.10",
54
- "User-Agent": "phonic/0.30.10",
53
+ "X-Fern-SDK-Version": "0.30.12",
54
+ "User-Agent": "phonic/0.30.12",
55
55
  "X-Fern-Runtime": core.RUNTIME.type,
56
56
  "X-Fern-Runtime-Version": core.RUNTIME.version,
57
57
  }, _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;
@@ -12,4 +12,9 @@ var UpdateAgentRequest;
12
12
  Pcm8000: "pcm_8000",
13
13
  Mulaw8000: "mulaw_8000",
14
14
  };
15
+ UpdateAgentRequest.BackgroundNoise = {
16
+ Office: "office",
17
+ CallCenter: "call-center",
18
+ CoffeeShop: "coffee-shop",
19
+ };
15
20
  })(UpdateAgentRequest || (exports.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",
@@ -154,12 +154,14 @@ class Tools {
154
154
  * type: "string",
155
155
  * name: "date",
156
156
  * description: "The date for the appointment in YYYY-MM-DD format",
157
- * is_required: true
157
+ * is_required: true,
158
+ * location: "request_body"
158
159
  * }, {
159
160
  * type: "string",
160
161
  * name: "time",
161
162
  * description: "The time for the appointment in HH:MM format",
162
- * is_required: true
163
+ * is_required: true,
164
+ * location: "request_body"
163
165
  * }],
164
166
  * endpoint_method: "POST",
165
167
  * endpoint_url: "https://api.example.com/book-appointment",
@@ -14,12 +14,14 @@ import * as Phonic from "../../../../index.js";
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
  }
@@ -15,4 +15,8 @@ var CreateToolRequest;
15
15
  Sync: "sync",
16
16
  Async: "async",
17
17
  };
18
+ CreateToolRequest.EndpointMethod = {
19
+ Get: "GET",
20
+ Post: "POST",
21
+ };
18
22
  })(CreateToolRequest || (exports.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
  }
@@ -15,4 +15,8 @@ var UpdateToolRequest;
15
15
  Sync: "sync",
16
16
  Async: "async",
17
17
  };
18
+ UpdateToolRequest.EndpointMethod = {
19
+ Get: "GET",
20
+ Post: "POST",
21
+ };
18
22
  })(UpdateToolRequest || (exports.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;
@@ -12,4 +12,9 @@ var Agent;
12
12
  Pcm8000: "pcm_8000",
13
13
  Mulaw8000: "mulaw_8000",
14
14
  };
15
+ Agent.BackgroundNoise = {
16
+ Office: "office",
17
+ CallCenter: "call-center",
18
+ CoffeeShop: "coffee-shop",
19
+ };
15
20
  })(Agent || (exports.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
  */
@@ -6,6 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfigPayload = void 0;
7
7
  var ConfigPayload;
8
8
  (function (ConfigPayload) {
9
+ ConfigPayload.BackgroundNoise = {
10
+ Office: "office",
11
+ CallCenter: "call-center",
12
+ CoffeeShop: "coffee-shop",
13
+ };
9
14
  ConfigPayload.InputFormat = {
10
15
  Pcm44100: "pcm_44100",
11
16
  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
  */
@@ -6,6 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Conversation = void 0;
7
7
  var Conversation;
8
8
  (function (Conversation) {
9
+ Conversation.BackgroundNoise = {
10
+ Office: "office",
11
+ CallCenter: "call-center",
12
+ CoffeeShop: "coffee-shop",
13
+ };
9
14
  Conversation.EndedBy = {
10
15
  User: "user",
11
16
  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;
@@ -12,4 +12,9 @@ var CreateAgentRequest;
12
12
  Pcm8000: "pcm_8000",
13
13
  Mulaw8000: "mulaw_8000",
14
14
  };
15
+ CreateAgentRequest.BackgroundNoise = {
16
+ Office: "office",
17
+ CallCenter: "call-center",
18
+ CoffeeShop: "coffee-shop",
19
+ };
15
20
  })(CreateAgentRequest || (exports.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
  }
@@ -15,4 +15,8 @@ var Tool;
15
15
  Sync: "sync",
16
16
  Async: "async",
17
17
  };
18
+ Tool.EndpointMethod = {
19
+ Get: "GET",
20
+ Post: "POST",
21
+ };
18
22
  })(Tool || (exports.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
  }
@@ -19,4 +19,8 @@ var ToolParameter;
19
19
  Number: "number",
20
20
  Boolean: "boolean",
21
21
  };
22
+ ToolParameter.Location = {
23
+ RequestBody: "request_body",
24
+ QueryString: "query_string",
25
+ };
22
26
  })(ToolParameter || (exports.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;
@@ -14,21 +14,57 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
14
14
  const MAX_RETRY_DELAY = 60000; // in milliseconds
15
15
  const DEFAULT_MAX_RETRIES = 2;
16
16
  const JITTER_FACTOR = 0.2; // 20% random jitter
17
- function addJitter(delay) {
18
- // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR
19
- const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
17
+ function addPositiveJitter(delay) {
18
+ // Generate a random value between 0 and +JITTER_FACTOR
19
+ const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
20
20
  return delay * jitterMultiplier;
21
21
  }
22
+ function addSymmetricJitter(delay) {
23
+ // Generate a random value in a JITTER_FACTOR-sized percentage range around delay
24
+ const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
25
+ return delay * jitterMultiplier;
26
+ }
27
+ function getRetryDelayFromHeaders(response, retryAttempt) {
28
+ // Check for Retry-After header first (RFC 7231), with no jitter
29
+ const retryAfter = response.headers.get("Retry-After");
30
+ if (retryAfter) {
31
+ // Parse as number of seconds...
32
+ const retryAfterSeconds = parseInt(retryAfter, 10);
33
+ if (!isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
34
+ return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
35
+ }
36
+ // ...or as an HTTP date; both are valid
37
+ const retryAfterDate = new Date(retryAfter);
38
+ if (!isNaN(retryAfterDate.getTime())) {
39
+ const delay = retryAfterDate.getTime() - Date.now();
40
+ if (delay > 0) {
41
+ return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
42
+ }
43
+ }
44
+ }
45
+ // Then check for industry-standard X-RateLimit-Reset header, with positive jitter
46
+ const rateLimitReset = response.headers.get("X-RateLimit-Reset");
47
+ if (rateLimitReset) {
48
+ const resetTime = parseInt(rateLimitReset, 10);
49
+ if (!isNaN(resetTime)) {
50
+ // Assume Unix timestamp in epoch seconds
51
+ const delay = resetTime * 1000 - Date.now();
52
+ if (delay > 0) {
53
+ return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
54
+ }
55
+ }
56
+ }
57
+ // Fall back to exponential backoff, with symmetric jitter
58
+ return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * Math.pow(2, retryAttempt), MAX_RETRY_DELAY));
59
+ }
22
60
  function requestWithRetries(requestFn_1) {
23
61
  return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
24
62
  let response = yield requestFn();
25
63
  for (let i = 0; i < maxRetries; ++i) {
26
64
  if ([408, 429].includes(response.status) || response.status >= 500) {
27
- // Calculate base delay using exponential backoff (in milliseconds)
28
- const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
29
- // Add jitter to the delay
30
- const delayWithJitter = addJitter(baseDelay);
31
- yield new Promise((resolve) => setTimeout(resolve, delayWithJitter));
65
+ // Get delay with appropriate jitter applied
66
+ const delay = getRetryDelayFromHeaders(response, i);
67
+ yield new Promise((resolve) => setTimeout(resolve, delay));
32
68
  response = yield requestFn();
33
69
  }
34
70
  else {
@@ -1,3 +1,3 @@
1
1
  import * as core from "./index.js";
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>>;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.30.10";
1
+ export declare const SDK_VERSION = "0.30.12";