phonic 0.31.6 → 0.31.7

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 (67) hide show
  1. package/README.md +34 -11
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/Client.d.ts +12 -0
  4. package/dist/cjs/Client.js +74 -0
  5. package/dist/cjs/api/resources/conversations/client/Client.d.ts +4 -1
  6. package/dist/cjs/api/resources/conversations/client/Client.js +14 -8
  7. package/dist/cjs/api/resources/conversations/client/Socket.d.ts +3 -2
  8. package/dist/cjs/api/resources/conversations/client/Socket.js +6 -2
  9. package/dist/cjs/api/resources/conversations/client/requests/ConversationsGetRequest.d.ts +9 -0
  10. package/dist/cjs/api/resources/conversations/client/requests/ConversationsGetRequest.js +3 -0
  11. package/dist/cjs/api/resources/conversations/client/requests/ConversationsListRequest.d.ts +3 -0
  12. package/dist/cjs/api/resources/conversations/client/requests/index.d.ts +1 -0
  13. package/dist/cjs/api/resources/conversations/exports.d.ts +1 -0
  14. package/dist/cjs/api/resources/conversations/exports.js +3 -1
  15. package/dist/cjs/api/resources/conversations/types/ConversationsGetRequestAudioContainer.d.ts +5 -0
  16. package/dist/cjs/api/resources/conversations/types/ConversationsGetRequestAudioContainer.js +8 -0
  17. package/dist/cjs/api/resources/conversations/types/ConversationsListRequestAudioContainer.d.ts +5 -0
  18. package/dist/cjs/api/resources/conversations/types/ConversationsListRequestAudioContainer.js +8 -0
  19. package/dist/cjs/api/resources/conversations/types/index.d.ts +2 -0
  20. package/dist/cjs/api/resources/conversations/types/index.js +2 -0
  21. package/dist/cjs/api/types/SayPayload.d.ts +7 -0
  22. package/dist/cjs/api/types/SayPayload.js +3 -0
  23. package/dist/cjs/api/types/index.d.ts +1 -0
  24. package/dist/cjs/api/types/index.js +1 -0
  25. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
  26. package/dist/cjs/core/fetcher/index.d.ts +2 -0
  27. package/dist/cjs/core/fetcher/index.js +3 -1
  28. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  29. package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
  30. package/dist/cjs/core/websocket/ws.d.ts +10 -1
  31. package/dist/cjs/core/websocket/ws.js +17 -5
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/BaseClient.mjs +2 -2
  35. package/dist/esm/Client.d.mts +12 -0
  36. package/dist/esm/Client.mjs +41 -0
  37. package/dist/esm/api/resources/conversations/client/Client.d.mts +4 -1
  38. package/dist/esm/api/resources/conversations/client/Client.mjs +14 -8
  39. package/dist/esm/api/resources/conversations/client/Socket.d.mts +3 -2
  40. package/dist/esm/api/resources/conversations/client/Socket.mjs +6 -2
  41. package/dist/esm/api/resources/conversations/client/requests/ConversationsGetRequest.d.mts +9 -0
  42. package/dist/esm/api/resources/conversations/client/requests/ConversationsGetRequest.mjs +2 -0
  43. package/dist/esm/api/resources/conversations/client/requests/ConversationsListRequest.d.mts +3 -0
  44. package/dist/esm/api/resources/conversations/client/requests/index.d.mts +1 -0
  45. package/dist/esm/api/resources/conversations/exports.d.mts +1 -0
  46. package/dist/esm/api/resources/conversations/exports.mjs +1 -0
  47. package/dist/esm/api/resources/conversations/types/ConversationsGetRequestAudioContainer.d.mts +5 -0
  48. package/dist/esm/api/resources/conversations/types/ConversationsGetRequestAudioContainer.mjs +5 -0
  49. package/dist/esm/api/resources/conversations/types/ConversationsListRequestAudioContainer.d.mts +5 -0
  50. package/dist/esm/api/resources/conversations/types/ConversationsListRequestAudioContainer.mjs +5 -0
  51. package/dist/esm/api/resources/conversations/types/index.d.mts +2 -0
  52. package/dist/esm/api/resources/conversations/types/index.mjs +2 -0
  53. package/dist/esm/api/types/SayPayload.d.mts +7 -0
  54. package/dist/esm/api/types/SayPayload.mjs +2 -0
  55. package/dist/esm/api/types/index.d.mts +1 -0
  56. package/dist/esm/api/types/index.mjs +1 -0
  57. package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
  58. package/dist/esm/core/fetcher/index.d.mts +2 -0
  59. package/dist/esm/core/fetcher/index.mjs +1 -0
  60. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  61. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
  62. package/dist/esm/core/websocket/ws.d.mts +10 -1
  63. package/dist/esm/core/websocket/ws.mjs +17 -5
  64. package/dist/esm/version.d.mts +1 -1
  65. package/dist/esm/version.mjs +1 -1
  66. package/package.json +1 -1
  67. package/reference.md +9 -1
package/README.md CHANGED
@@ -21,6 +21,8 @@ The Phonic TypeScript library provides convenient access to the Phonic APIs from
21
21
  - [Aborting Requests](#aborting-requests)
22
22
  - [Access Raw Response Data](#access-raw-response-data)
23
23
  - [Logging](#logging)
24
+ - [Custom Fetch](#custom-fetch)
25
+ - [Custom Fetcher](#custom-fetcher)
24
26
  - [Runtime Compatibility](#runtime-compatibility)
25
27
  - [Contributing](#contributing)
26
28
 
@@ -274,21 +276,27 @@ const logger: logging.ILogger = {
274
276
  </details>
275
277
 
276
278
 
277
- ### Runtime Compatibility
278
-
279
-
280
- The SDK works in the following runtimes:
279
+ ### Custom Fetch
281
280
 
281
+ The SDK provides a low-level `fetch` method for making custom HTTP requests while still
282
+ benefiting from SDK-level configuration like authentication, retries, timeouts, and logging.
283
+ This is useful for calling API endpoints not yet supported in the SDK.
282
284
 
285
+ ```typescript
286
+ const response = await client.fetch("/v1/custom/endpoint", {
287
+ method: "GET",
288
+ }, {
289
+ timeoutInSeconds: 30,
290
+ maxRetries: 3,
291
+ headers: {
292
+ "X-Custom-Header": "custom-value",
293
+ },
294
+ });
283
295
 
284
- - Node.js 18+
285
- - Vercel
286
- - Cloudflare Workers
287
- - Deno v1.25+
288
- - Bun 1.0+
289
- - React Native
296
+ const data = await response.json();
297
+ ```
290
298
 
291
- ### Customizing Fetch Client
299
+ ### Custom Fetcher
292
300
 
293
301
  The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
294
302
  unsupported environment, this provides a way for you to break glass and ensure the SDK works.
@@ -302,6 +310,21 @@ const client = new PhonicClient({
302
310
  });
303
311
  ```
304
312
 
313
+ ### Runtime Compatibility
314
+
315
+
316
+ The SDK works in the following runtimes:
317
+
318
+
319
+
320
+ - Node.js 18+
321
+ - Vercel
322
+ - Cloudflare Workers
323
+ - Deno v1.25+
324
+ - Bun 1.0+
325
+ - React Native
326
+
327
+
305
328
  ## Contributing
306
329
 
307
330
  While we value open-source contributions to this SDK, this library is generated programmatically.
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "phonic",
46
- "X-Fern-SDK-Version": "0.31.4",
47
- "User-Agent": "phonic/0.31.4",
46
+ "X-Fern-SDK-Version": "0.31.7",
47
+ "User-Agent": "phonic/0.31.7",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -7,6 +7,7 @@ import { ToolsClient } from "./api/resources/tools/client/Client.js";
7
7
  import { VoicesClient } from "./api/resources/voices/client/Client.js";
8
8
  import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
9
9
  import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
10
+ import * as core from "./core/index.js";
10
11
  export declare namespace PhonicClient {
11
12
  type Options = BaseClientOptions;
12
13
  interface RequestOptions extends BaseRequestOptions {
@@ -29,4 +30,15 @@ export declare class PhonicClient {
29
30
  get conversations(): ConversationsClient;
30
31
  get auth(): AuthClient;
31
32
  get projects(): ProjectsClient;
33
+ /**
34
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
35
+ * This is useful for making requests to endpoints not yet supported in the SDK.
36
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
37
+ *
38
+ * @param {Request | string | URL} input - The URL, path, or Request object.
39
+ * @param {RequestInit} init - Standard fetch RequestInit options.
40
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
41
+ * @returns {Promise<Response>} A standard Response object.
42
+ */
43
+ fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
32
44
  }
@@ -1,5 +1,47 @@
1
1
  "use strict";
2
2
  // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
3
45
  Object.defineProperty(exports, "__esModule", { value: true });
4
46
  exports.PhonicClient = void 0;
5
47
  const Client_js_1 = require("./api/resources/agents/client/Client.js");
@@ -10,6 +52,8 @@ const Client_js_5 = require("./api/resources/projects/client/Client.js");
10
52
  const Client_js_6 = require("./api/resources/tools/client/Client.js");
11
53
  const Client_js_7 = require("./api/resources/voices/client/Client.js");
12
54
  const BaseClient_js_1 = require("./BaseClient.js");
55
+ const core = __importStar(require("./core/index.js"));
56
+ const environments = __importStar(require("./environments.js"));
13
57
  class PhonicClient {
14
58
  constructor(options = {}) {
15
59
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
@@ -42,5 +86,35 @@ class PhonicClient {
42
86
  var _a;
43
87
  return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new Client_js_5.ProjectsClient(this._options)));
44
88
  }
89
+ /**
90
+ * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
91
+ * This is useful for making requests to endpoints not yet supported in the SDK.
92
+ * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
93
+ *
94
+ * @param {Request | string | URL} input - The URL, path, or Request object.
95
+ * @param {RequestInit} init - Standard fetch RequestInit options.
96
+ * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
97
+ * @returns {Promise<Response>} A standard Response object.
98
+ */
99
+ fetch(input, init, requestOptions) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ var _a;
102
+ return core.makePassthroughRequest(input, init, {
103
+ baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : (() => __awaiter(this, void 0, void 0, function* () {
104
+ var _a;
105
+ const env = yield core.Supplier.get(this._options.environment);
106
+ return typeof env === "string"
107
+ ? env
108
+ : ((_a = env === null || env === void 0 ? void 0 : env.base) !== null && _a !== void 0 ? _a : environments.PhonicEnvironment.Default.base);
109
+ })),
110
+ headers: this._options.headers,
111
+ timeoutInSeconds: this._options.timeoutInSeconds,
112
+ maxRetries: this._options.maxRetries,
113
+ fetch: this._options.fetch,
114
+ logging: this._options.logging,
115
+ getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }),
116
+ }, requestOptions);
117
+ });
118
+ }
45
119
  }
46
120
  exports.PhonicClient = PhonicClient;
@@ -9,6 +9,8 @@ export declare namespace ConversationsClient {
9
9
  }
10
10
  interface ConnectArgs {
11
11
  downstream_websocket_url?: string;
12
+ /** WebSocket subprotocols to use for the connection. */
13
+ protocols?: string | string[];
12
14
  /** Additional query parameters to send with the websocket connect request. */
13
15
  queryParams?: Record<string, unknown>;
14
16
  /** Arbitrary headers to send with the websocket connect request. */
@@ -47,6 +49,7 @@ export declare class ConversationsClient {
47
49
  * Returns a conversation by ID.
48
50
  *
49
51
  * @param {string} id - The ID of the conversation to get.
52
+ * @param {Phonic.ConversationsGetRequest} request
50
53
  * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
51
54
  *
52
55
  * @throws {@link Phonic.UnauthorizedError}
@@ -57,7 +60,7 @@ export declare class ConversationsClient {
57
60
  * @example
58
61
  * await client.conversations.get("id")
59
62
  */
60
- get(id: string, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsGetResponse>;
63
+ get(id: string, request?: Phonic.ConversationsGetRequest, requestOptions?: ConversationsClient.RequestOptions): core.HttpResponsePromise<Phonic.ConversationsGetResponse>;
61
64
  private __get;
62
65
  /**
63
66
  * Cancels an active conversation.
@@ -88,7 +88,7 @@ class ConversationsClient {
88
88
  __list() {
89
89
  return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
90
90
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
91
- const { project, external_id: externalId, duration_min: durationMin, duration_max: durationMax, started_at_min: startedAtMin, started_at_max: startedAtMax, before, after, limit, } = request;
91
+ const { project, external_id: externalId, duration_min: durationMin, duration_max: durationMax, started_at_min: startedAtMin, started_at_max: startedAtMax, before, after, limit, audio_container: audioContainer, } = request;
92
92
  const _queryParams = {
93
93
  project,
94
94
  external_id: externalId,
@@ -99,6 +99,7 @@ class ConversationsClient {
99
99
  before,
100
100
  after,
101
101
  limit,
102
+ audio_container: audioContainer != null ? audioContainer : undefined,
102
103
  };
103
104
  const _authRequest = yield this._options.authProvider.getAuthRequest();
104
105
  const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
@@ -144,6 +145,7 @@ class ConversationsClient {
144
145
  * Returns a conversation by ID.
145
146
  *
146
147
  * @param {string} id - The ID of the conversation to get.
148
+ * @param {Phonic.ConversationsGetRequest} request
147
149
  * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration.
148
150
  *
149
151
  * @throws {@link Phonic.UnauthorizedError}
@@ -154,12 +156,16 @@ class ConversationsClient {
154
156
  * @example
155
157
  * await client.conversations.get("id")
156
158
  */
157
- get(id, requestOptions) {
158
- return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions));
159
+ get(id, request = {}, requestOptions) {
160
+ return core.HttpResponsePromise.fromPromise(this.__get(id, request, requestOptions));
159
161
  }
160
- __get(id, requestOptions) {
161
- return __awaiter(this, void 0, void 0, function* () {
162
+ __get(id_1) {
163
+ return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) {
162
164
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
165
+ const { audio_container: audioContainer } = request;
166
+ const _queryParams = {
167
+ audio_container: audioContainer != null ? audioContainer : undefined,
168
+ };
163
169
  const _authRequest = yield this._options.authProvider.getAuthRequest();
164
170
  const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
165
171
  const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
@@ -167,7 +173,7 @@ class ConversationsClient {
167
173
  .base, `conversations/${core.url.encodePathParam(id)}`),
168
174
  method: "GET",
169
175
  headers: _headers,
170
- queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
176
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
171
177
  timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
172
178
  maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
173
179
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
@@ -740,7 +746,7 @@ class ConversationsClient {
740
746
  connect() {
741
747
  return __awaiter(this, arguments, void 0, function* (args = {}) {
742
748
  var _a, _b;
743
- const { downstream_websocket_url: downstreamWebsocketUrl, queryParams, headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal, } = args;
749
+ const { downstream_websocket_url: downstreamWebsocketUrl, protocols, queryParams, headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal, } = args;
744
750
  const _queryParams = {
745
751
  downstream_websocket_url: downstreamWebsocketUrl,
746
752
  };
@@ -748,7 +754,7 @@ class ConversationsClient {
748
754
  const socket = new core.ReconnectingWebSocket({
749
755
  url: core.url.join((_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : ((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PhonicEnvironment.Default)
750
756
  .production, "/v1/sts/ws"),
751
- protocols: [],
757
+ protocols: protocols !== null && protocols !== void 0 ? protocols : [],
752
758
  queryParameters: Object.assign(Object.assign({}, _queryParams), queryParams),
753
759
  headers: _headers,
754
760
  options: {
@@ -21,7 +21,7 @@ export declare class ConversationsSocket {
21
21
  private handleError;
22
22
  constructor(args: ConversationsSocket.Args);
23
23
  /** The current state of the connection; this is one of the readyState constants. */
24
- get readyState(): number;
24
+ get readyState(): core.ReconnectingWebSocket.ReadyState;
25
25
  /**
26
26
  * @param event - The event to attach to.
27
27
  * @param callback - The callback to run when the event is triggered.
@@ -40,6 +40,7 @@ export declare class ConversationsSocket {
40
40
  sendSetExternalId(message: Phonic.SetExternalIdPayload): void;
41
41
  sendToolCallOutput(message: Phonic.ToolCallOutputPayload): void;
42
42
  sendGenerateReply(message: Phonic.GenerateReplyPayload): void;
43
+ sendSay(message: Phonic.SayPayload): void;
43
44
  /** Connect to the websocket and register event handlers. */
44
45
  connect(): ConversationsSocket;
45
46
  /** Close the websocket and unregister event handlers. */
@@ -51,5 +52,5 @@ export declare class ConversationsSocket {
51
52
  /** Send a binary payload to the websocket. */
52
53
  protected sendBinary(payload: ArrayBufferLike | Blob | ArrayBufferView): void;
53
54
  /** Send a JSON payload to the websocket. */
54
- protected sendJson(payload: Phonic.ConfigPayload | Phonic.AudioChunkPayload | Phonic.UpdateSystemPromptPayload | Phonic.AddSystemMessagePayload | Phonic.SetExternalIdPayload | Phonic.ToolCallOutputPayload | Phonic.GenerateReplyPayload): void;
55
+ protected sendJson(payload: Phonic.ConfigPayload | Phonic.AudioChunkPayload | Phonic.UpdateSystemPromptPayload | Phonic.AddSystemMessagePayload | Phonic.SetExternalIdPayload | Phonic.ToolCallOutputPayload | Phonic.GenerateReplyPayload | Phonic.SayPayload): void;
55
56
  }
@@ -118,6 +118,10 @@ class ConversationsSocket {
118
118
  this.assertSocketIsOpen();
119
119
  this.sendJson(message);
120
120
  }
121
+ sendSay(message) {
122
+ this.assertSocketIsOpen();
123
+ this.sendJson(message);
124
+ }
121
125
  /** Connect to the websocket and register event handlers. */
122
126
  connect() {
123
127
  this.socket.reconnect();
@@ -139,7 +143,7 @@ class ConversationsSocket {
139
143
  /** Returns a promise that resolves when the websocket is open. */
140
144
  waitForOpen() {
141
145
  return __awaiter(this, void 0, void 0, function* () {
142
- if (this.socket.readyState === core.ReconnectingWebSocket.OPEN) {
146
+ if (this.socket.readyState === core.ReconnectingWebSocket.ReadyState.OPEN) {
143
147
  return this.socket;
144
148
  }
145
149
  return new Promise((resolve, reject) => {
@@ -157,7 +161,7 @@ class ConversationsSocket {
157
161
  if (!this.socket) {
158
162
  throw new Error("Socket is not connected.");
159
163
  }
160
- if (this.socket.readyState !== core.ReconnectingWebSocket.OPEN) {
164
+ if (this.socket.readyState !== core.ReconnectingWebSocket.ReadyState.OPEN) {
161
165
  throw new Error("Socket is not open.");
162
166
  }
163
167
  }
@@ -0,0 +1,9 @@
1
+ import type * as Phonic from "../../../../index.js";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface ConversationsGetRequest {
7
+ /** Format of the presigned `audio_url` in the response. */
8
+ audio_container?: Phonic.ConversationsGetRequestAudioContainer;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ import type * as Phonic from "../../../../index.js";
1
2
  /**
2
3
  * @example
3
4
  * {}
@@ -21,4 +22,6 @@ export interface ConversationsListRequest {
21
22
  after?: string;
22
23
  /** Maximum number of conversations to return per page. */
23
24
  limit?: number;
25
+ /** Format of the presigned `audio_url` in each conversation in the response. */
26
+ audio_container?: Phonic.ConversationsListRequestAudioContainer;
24
27
  }
@@ -1,3 +1,4 @@
1
+ export type { ConversationsGetRequest } from "./ConversationsGetRequest.js";
1
2
  export type { ConversationsListRequest } from "./ConversationsListRequest.js";
2
3
  export type { ConversationsSipOutboundCallRequest } from "./ConversationsSipOutboundCallRequest.js";
3
4
  export type { EvaluateConversationRequest } from "./EvaluateConversationRequest.js";
@@ -1,2 +1,3 @@
1
1
  export { ConversationsClient } from "./client/Client.js";
2
2
  export * from "./client/index.js";
3
+ export { ConversationsSocket } from "./client/Socket.js";
@@ -15,7 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ConversationsClient = void 0;
18
+ exports.ConversationsSocket = exports.ConversationsClient = void 0;
19
19
  var Client_js_1 = require("./client/Client.js");
20
20
  Object.defineProperty(exports, "ConversationsClient", { enumerable: true, get: function () { return Client_js_1.ConversationsClient; } });
21
21
  __exportStar(require("./client/index.js"), exports);
22
+ var Socket_js_1 = require("./client/Socket.js");
23
+ Object.defineProperty(exports, "ConversationsSocket", { enumerable: true, get: function () { return Socket_js_1.ConversationsSocket; } });
@@ -0,0 +1,5 @@
1
+ export declare const ConversationsGetRequestAudioContainer: {
2
+ readonly WavGz: "wav.gz";
3
+ readonly Wav: "wav";
4
+ };
5
+ export type ConversationsGetRequestAudioContainer = (typeof ConversationsGetRequestAudioContainer)[keyof typeof ConversationsGetRequestAudioContainer];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ConversationsGetRequestAudioContainer = void 0;
5
+ exports.ConversationsGetRequestAudioContainer = {
6
+ WavGz: "wav.gz",
7
+ Wav: "wav",
8
+ };
@@ -0,0 +1,5 @@
1
+ export declare const ConversationsListRequestAudioContainer: {
2
+ readonly WavGz: "wav.gz";
3
+ readonly Wav: "wav";
4
+ };
5
+ export type ConversationsListRequestAudioContainer = (typeof ConversationsListRequestAudioContainer)[keyof typeof ConversationsListRequestAudioContainer];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ConversationsListRequestAudioContainer = void 0;
5
+ exports.ConversationsListRequestAudioContainer = {
6
+ WavGz: "wav.gz",
7
+ Wav: "wav",
8
+ };
@@ -1,9 +1,11 @@
1
1
  export * from "./ConversationsCancelResponse.js";
2
2
  export * from "./ConversationsExtractDataResponse.js";
3
3
  export * from "./ConversationsGetAnalysisResponse.js";
4
+ export * from "./ConversationsGetRequestAudioContainer.js";
4
5
  export * from "./ConversationsGetResponse.js";
5
6
  export * from "./ConversationsListEvaluationsResponse.js";
6
7
  export * from "./ConversationsListExtractionsResponse.js";
8
+ export * from "./ConversationsListRequestAudioContainer.js";
7
9
  export * from "./ConversationsListResponse.js";
8
10
  export * from "./ConversationsOutboundCallResponse.js";
9
11
  export * from "./ConversationsSipOutboundCallResponse.js";
@@ -17,9 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ConversationsCancelResponse.js"), exports);
18
18
  __exportStar(require("./ConversationsExtractDataResponse.js"), exports);
19
19
  __exportStar(require("./ConversationsGetAnalysisResponse.js"), exports);
20
+ __exportStar(require("./ConversationsGetRequestAudioContainer.js"), exports);
20
21
  __exportStar(require("./ConversationsGetResponse.js"), exports);
21
22
  __exportStar(require("./ConversationsListEvaluationsResponse.js"), exports);
22
23
  __exportStar(require("./ConversationsListExtractionsResponse.js"), exports);
24
+ __exportStar(require("./ConversationsListRequestAudioContainer.js"), exports);
23
25
  __exportStar(require("./ConversationsListResponse.js"), exports);
24
26
  __exportStar(require("./ConversationsOutboundCallResponse.js"), exports);
25
27
  __exportStar(require("./ConversationsSipOutboundCallResponse.js"), exports);
@@ -0,0 +1,7 @@
1
+ export interface SayPayload {
2
+ type: "say";
3
+ /** The text for the assistant to say */
4
+ text: string;
5
+ /** Optional configuration to make the turn interruptible or not interruptible */
6
+ interruptible?: boolean | undefined;
7
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,6 +31,7 @@ export * from "./LanguageCode.js";
31
31
  export * from "./OutboundCallConfig.js";
32
32
  export * from "./Project.js";
33
33
  export * from "./ReadyToStartConversationPayload.js";
34
+ export * from "./SayPayload.js";
34
35
  export * from "./SetExternalIdPayload.js";
35
36
  export * from "./Task.js";
36
37
  export * from "./Tool.js";
@@ -47,6 +47,7 @@ __exportStar(require("./LanguageCode.js"), exports);
47
47
  __exportStar(require("./OutboundCallConfig.js"), exports);
48
48
  __exportStar(require("./Project.js"), exports);
49
49
  __exportStar(require("./ReadyToStartConversationPayload.js"), exports);
50
+ __exportStar(require("./SayPayload.js"), exports);
50
51
  __exportStar(require("./SetExternalIdPayload.js"), exports);
51
52
  __exportStar(require("./Task.js"), exports);
52
53
  __exportStar(require("./Tool.js"), exports);
@@ -14,6 +14,6 @@ export type BinaryResponse = {
14
14
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
15
15
  * Some versions of the Fetch API may not support this method.
16
16
  */
17
- bytes?(): ReturnType<Response["bytes"]>;
17
+ bytes?(): Promise<Uint8Array>;
18
18
  };
19
19
  export declare function getBinaryResponse(response: Response): BinaryResponse;
@@ -6,6 +6,8 @@ export type { Fetcher, FetchFunction } from "./Fetcher.js";
6
6
  export { fetcher } from "./Fetcher.js";
7
7
  export { getHeader } from "./getHeader.js";
8
8
  export { HttpResponsePromise } from "./HttpResponsePromise.js";
9
+ export type { PassthroughRequest } from "./makePassthroughRequest.js";
10
+ export { makePassthroughRequest } from "./makePassthroughRequest.js";
9
11
  export type { RawResponse, WithRawResponse } from "./RawResponse.js";
10
12
  export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
11
13
  export { Supplier } from "./Supplier.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
3
+ exports.Supplier = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.makePassthroughRequest = exports.HttpResponsePromise = exports.getHeader = exports.fetcher = exports.EndpointSupplier = void 0;
4
4
  var EndpointSupplier_js_1 = require("./EndpointSupplier.js");
5
5
  Object.defineProperty(exports, "EndpointSupplier", { enumerable: true, get: function () { return EndpointSupplier_js_1.EndpointSupplier; } });
6
6
  var Fetcher_js_1 = require("./Fetcher.js");
@@ -9,6 +9,8 @@ var getHeader_js_1 = require("./getHeader.js");
9
9
  Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_js_1.getHeader; } });
10
10
  var HttpResponsePromise_js_1 = require("./HttpResponsePromise.js");
11
11
  Object.defineProperty(exports, "HttpResponsePromise", { enumerable: true, get: function () { return HttpResponsePromise_js_1.HttpResponsePromise; } });
12
+ var makePassthroughRequest_js_1 = require("./makePassthroughRequest.js");
13
+ Object.defineProperty(exports, "makePassthroughRequest", { enumerable: true, get: function () { return makePassthroughRequest_js_1.makePassthroughRequest; } });
12
14
  var RawResponse_js_1 = require("./RawResponse.js");
13
15
  Object.defineProperty(exports, "abortRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.abortRawResponse; } });
14
16
  Object.defineProperty(exports, "toRawResponse", { enumerable: true, get: function () { return RawResponse_js_1.toRawResponse; } });
@@ -0,0 +1,49 @@
1
+ import { type LogConfig, type Logger } from "../logging/logger.js";
2
+ import { Supplier } from "./Supplier.js";
3
+ export declare namespace PassthroughRequest {
4
+ /**
5
+ * Per-request options that can override the SDK client defaults.
6
+ */
7
+ interface RequestOptions {
8
+ /** Override the default timeout for this request (in seconds). */
9
+ timeoutInSeconds?: number;
10
+ /** Override the default number of retries for this request. */
11
+ maxRetries?: number;
12
+ /** Additional headers to include in this request. */
13
+ headers?: Record<string, string>;
14
+ /** Abort signal for this request. */
15
+ abortSignal?: AbortSignal;
16
+ }
17
+ /**
18
+ * SDK client configuration used by the passthrough fetch method.
19
+ */
20
+ interface ClientOptions {
21
+ /** The base URL or environment for the client. */
22
+ environment?: Supplier<string>;
23
+ /** Override the base URL. */
24
+ baseUrl?: Supplier<string>;
25
+ /** Default headers to include in requests. */
26
+ headers?: Record<string, unknown>;
27
+ /** Default maximum time to wait for a response in seconds. */
28
+ timeoutInSeconds?: number;
29
+ /** Default number of times to retry the request. Defaults to 2. */
30
+ maxRetries?: number;
31
+ /** A custom fetch function. */
32
+ fetch?: typeof fetch;
33
+ /** Logging configuration. */
34
+ logging?: LogConfig | Logger;
35
+ /** A function that returns auth headers. */
36
+ getAuthHeaders?: () => Promise<Record<string, string>>;
37
+ }
38
+ }
39
+ /**
40
+ * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
41
+ * while mimicking the standard `fetch` API.
42
+ *
43
+ * @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
44
+ * @param init - Standard RequestInit options (method, headers, body, signal, etc.)
45
+ * @param clientOptions - SDK client options (auth, default headers, logging, etc.)
46
+ * @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
47
+ * @returns A standard Response object.
48
+ */
49
+ export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;