hume 0.12.0 → 0.12.2

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 (171) hide show
  1. package/.mock/definition/empathic-voice/__package__.yml +170 -75
  2. package/.mock/definition/empathic-voice/configs.yml +10 -4
  3. package/.mock/definition/tts/__package__.yml +7 -38
  4. package/api/resources/empathicVoice/client/index.d.ts +1 -0
  5. package/api/resources/empathicVoice/client/index.js +15 -0
  6. package/api/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.d.ts +12 -0
  7. package/api/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.js +5 -0
  8. package/api/resources/empathicVoice/client/requests/index.d.ts +1 -0
  9. package/api/resources/empathicVoice/client/requests/index.js +2 -0
  10. package/api/resources/empathicVoice/errors/UnprocessableEntityError.d.ts +9 -0
  11. package/{core/form-data-utils/toReadableStream.js → api/resources/empathicVoice/errors/UnprocessableEntityError.js} +16 -14
  12. package/api/resources/empathicVoice/errors/index.d.ts +1 -0
  13. package/api/resources/empathicVoice/errors/index.js +1 -0
  14. package/api/resources/empathicVoice/resources/chatGroups/client/index.d.ts +1 -0
  15. package/api/resources/empathicVoice/resources/chats/client/index.d.ts +1 -0
  16. package/api/resources/empathicVoice/resources/configs/client/index.d.ts +1 -0
  17. package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +5 -1
  18. package/api/resources/empathicVoice/resources/prompts/client/index.d.ts +1 -0
  19. package/api/resources/empathicVoice/resources/tools/client/index.d.ts +1 -0
  20. package/api/resources/empathicVoice/types/JsonMessage.d.ts +1 -1
  21. package/api/resources/empathicVoice/types/LanguageModelType.d.ts +17 -1
  22. package/api/resources/empathicVoice/types/LanguageModelType.js +16 -0
  23. package/api/resources/empathicVoice/types/ModelProviderEnum.d.ts +4 -1
  24. package/api/resources/empathicVoice/types/ModelProviderEnum.js +3 -0
  25. package/api/resources/empathicVoice/types/ReturnChatEvent.d.ts +12 -17
  26. package/api/resources/empathicVoice/types/ReturnChatEventRole.d.ts +0 -4
  27. package/api/resources/empathicVoice/types/ReturnChatEventType.d.ts +22 -18
  28. package/api/resources/empathicVoice/types/ReturnChatEventType.js +9 -4
  29. package/api/resources/empathicVoice/types/ReturnConfig.d.ts +21 -17
  30. package/api/resources/empathicVoice/types/ReturnPrompt.d.ts +2 -2
  31. package/api/resources/empathicVoice/types/SupportsToolUse.d.ts +7 -0
  32. package/api/resources/empathicVoice/types/SupportsToolUse.js +5 -0
  33. package/api/resources/empathicVoice/types/UserMessage.d.ts +8 -1
  34. package/api/resources/empathicVoice/types/index.d.ts +1 -0
  35. package/api/resources/empathicVoice/types/index.js +1 -0
  36. package/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +2 -4
  37. package/api/resources/expressionMeasurement/resources/batch/client/Client.js +1 -1
  38. package/api/resources/expressionMeasurement/resources/batch/client/index.d.ts +1 -0
  39. package/api/resources/tts/client/index.d.ts +1 -0
  40. package/api/resources/tts/resources/voices/client/index.d.ts +1 -0
  41. package/api/resources/tts/types/PostedUtterance.d.ts +1 -1
  42. package/api/resources/tts/types/SnippetAudioChunk.d.ts +0 -16
  43. package/core/fetcher/BinaryResponse.d.ts +17 -0
  44. package/core/fetcher/BinaryResponse.js +14 -0
  45. package/core/fetcher/Fetcher.d.ts +1 -1
  46. package/core/fetcher/ResponseWithBody.d.ts +4 -0
  47. package/core/fetcher/ResponseWithBody.js +6 -0
  48. package/core/fetcher/getFetchFn.js +3 -3
  49. package/core/fetcher/getResponseBody.js +33 -32
  50. package/core/fetcher/index.d.ts +1 -0
  51. package/core/file.d.ts +1 -0
  52. package/core/file.js +2 -0
  53. package/core/form-data-utils/FormDataWrapper.d.ts +5 -52
  54. package/core/form-data-utils/FormDataWrapper.js +104 -124
  55. package/core/index.d.ts +1 -0
  56. package/core/index.js +1 -0
  57. package/dist/api/resources/empathicVoice/client/index.d.ts +1 -0
  58. package/dist/api/resources/empathicVoice/client/index.js +15 -0
  59. package/dist/api/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.d.ts +12 -0
  60. package/dist/api/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.js +5 -0
  61. package/dist/api/resources/empathicVoice/client/requests/index.d.ts +1 -0
  62. package/dist/api/resources/empathicVoice/client/requests/index.js +2 -0
  63. package/dist/api/resources/empathicVoice/errors/UnprocessableEntityError.d.ts +9 -0
  64. package/dist/{core/form-data-utils/toReadableStream.js → api/resources/empathicVoice/errors/UnprocessableEntityError.js} +16 -14
  65. package/dist/api/resources/empathicVoice/errors/index.d.ts +1 -0
  66. package/dist/api/resources/empathicVoice/errors/index.js +1 -0
  67. package/dist/api/resources/empathicVoice/resources/chatGroups/client/index.d.ts +1 -0
  68. package/dist/api/resources/empathicVoice/resources/chats/client/index.d.ts +1 -0
  69. package/dist/api/resources/empathicVoice/resources/configs/client/index.d.ts +1 -0
  70. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +5 -1
  71. package/dist/api/resources/empathicVoice/resources/prompts/client/index.d.ts +1 -0
  72. package/dist/api/resources/empathicVoice/resources/tools/client/index.d.ts +1 -0
  73. package/dist/api/resources/empathicVoice/types/JsonMessage.d.ts +1 -1
  74. package/dist/api/resources/empathicVoice/types/LanguageModelType.d.ts +17 -1
  75. package/dist/api/resources/empathicVoice/types/LanguageModelType.js +16 -0
  76. package/dist/api/resources/empathicVoice/types/ModelProviderEnum.d.ts +4 -1
  77. package/dist/api/resources/empathicVoice/types/ModelProviderEnum.js +3 -0
  78. package/dist/api/resources/empathicVoice/types/ReturnChatEvent.d.ts +12 -17
  79. package/dist/api/resources/empathicVoice/types/ReturnChatEventRole.d.ts +0 -4
  80. package/dist/api/resources/empathicVoice/types/ReturnChatEventType.d.ts +22 -18
  81. package/dist/api/resources/empathicVoice/types/ReturnChatEventType.js +9 -4
  82. package/dist/api/resources/empathicVoice/types/ReturnConfig.d.ts +21 -17
  83. package/dist/api/resources/empathicVoice/types/ReturnPrompt.d.ts +2 -2
  84. package/dist/api/resources/empathicVoice/types/SupportsToolUse.d.ts +7 -0
  85. package/dist/api/resources/empathicVoice/types/SupportsToolUse.js +5 -0
  86. package/dist/api/resources/empathicVoice/types/UserMessage.d.ts +8 -1
  87. package/dist/api/resources/empathicVoice/types/index.d.ts +1 -0
  88. package/dist/api/resources/empathicVoice/types/index.js +1 -0
  89. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +2 -4
  90. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +1 -1
  91. package/dist/api/resources/expressionMeasurement/resources/batch/client/index.d.ts +1 -0
  92. package/dist/api/resources/tts/client/index.d.ts +1 -0
  93. package/dist/api/resources/tts/resources/voices/client/index.d.ts +1 -0
  94. package/dist/api/resources/tts/types/PostedUtterance.d.ts +1 -1
  95. package/dist/api/resources/tts/types/SnippetAudioChunk.d.ts +0 -16
  96. package/dist/core/fetcher/BinaryResponse.d.ts +17 -0
  97. package/dist/core/fetcher/BinaryResponse.js +14 -0
  98. package/dist/core/fetcher/Fetcher.d.ts +1 -1
  99. package/dist/core/fetcher/ResponseWithBody.d.ts +4 -0
  100. package/dist/core/fetcher/ResponseWithBody.js +6 -0
  101. package/dist/core/fetcher/getFetchFn.js +3 -3
  102. package/dist/core/fetcher/getResponseBody.js +33 -32
  103. package/dist/core/fetcher/index.d.ts +1 -0
  104. package/dist/core/file.d.ts +1 -0
  105. package/dist/core/file.js +2 -0
  106. package/dist/core/form-data-utils/FormDataWrapper.d.ts +5 -52
  107. package/dist/core/form-data-utils/FormDataWrapper.js +104 -124
  108. package/dist/core/index.d.ts +1 -0
  109. package/dist/core/index.js +1 -0
  110. package/dist/serialization/resources/empathicVoice/client/index.d.ts +1 -0
  111. package/dist/serialization/resources/empathicVoice/client/index.js +17 -0
  112. package/dist/serialization/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.d.ts +12 -0
  113. package/dist/serialization/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.js +43 -0
  114. package/dist/serialization/resources/empathicVoice/client/requests/index.d.ts +1 -0
  115. package/dist/serialization/resources/empathicVoice/client/requests/index.js +5 -0
  116. package/dist/serialization/resources/empathicVoice/index.d.ts +1 -0
  117. package/dist/serialization/resources/empathicVoice/index.js +1 -0
  118. package/dist/serialization/resources/empathicVoice/types/JsonMessage.d.ts +2 -1
  119. package/dist/serialization/resources/empathicVoice/types/JsonMessage.js +2 -0
  120. package/dist/serialization/resources/empathicVoice/types/LanguageModelType.d.ts +1 -1
  121. package/dist/serialization/resources/empathicVoice/types/LanguageModelType.js +16 -0
  122. package/dist/serialization/resources/empathicVoice/types/ModelProviderEnum.d.ts +1 -1
  123. package/dist/serialization/resources/empathicVoice/types/ModelProviderEnum.js +3 -0
  124. package/dist/serialization/resources/empathicVoice/types/ReturnChatEventType.d.ts +1 -1
  125. package/dist/serialization/resources/empathicVoice/types/ReturnChatEventType.js +9 -4
  126. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +13 -13
  127. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.js +13 -13
  128. package/dist/serialization/resources/empathicVoice/types/ReturnPrompt.d.ts +1 -1
  129. package/dist/serialization/resources/empathicVoice/types/ReturnPrompt.js +1 -1
  130. package/dist/serialization/resources/empathicVoice/types/SupportsToolUse.d.ts +13 -0
  131. package/dist/serialization/resources/empathicVoice/types/SupportsToolUse.js +44 -0
  132. package/dist/serialization/resources/empathicVoice/types/index.d.ts +1 -0
  133. package/dist/serialization/resources/empathicVoice/types/index.js +1 -0
  134. package/dist/serialization/resources/tts/types/SnippetAudioChunk.d.ts +0 -8
  135. package/dist/serialization/resources/tts/types/SnippetAudioChunk.js +1 -10
  136. package/dist/version.d.ts +1 -1
  137. package/dist/version.js +1 -1
  138. package/jest.browser.config.mjs +10 -0
  139. package/jest.config.mjs +1 -0
  140. package/package.json +6 -7
  141. package/reference.md +53 -1
  142. package/serialization/resources/empathicVoice/client/index.d.ts +1 -0
  143. package/serialization/resources/empathicVoice/client/index.js +17 -0
  144. package/serialization/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.d.ts +12 -0
  145. package/serialization/resources/empathicVoice/client/requests/BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost.js +43 -0
  146. package/serialization/resources/empathicVoice/client/requests/index.d.ts +1 -0
  147. package/serialization/resources/empathicVoice/client/requests/index.js +5 -0
  148. package/serialization/resources/empathicVoice/index.d.ts +1 -0
  149. package/serialization/resources/empathicVoice/index.js +1 -0
  150. package/serialization/resources/empathicVoice/types/JsonMessage.d.ts +2 -1
  151. package/serialization/resources/empathicVoice/types/JsonMessage.js +2 -0
  152. package/serialization/resources/empathicVoice/types/LanguageModelType.d.ts +1 -1
  153. package/serialization/resources/empathicVoice/types/LanguageModelType.js +16 -0
  154. package/serialization/resources/empathicVoice/types/ModelProviderEnum.d.ts +1 -1
  155. package/serialization/resources/empathicVoice/types/ModelProviderEnum.js +3 -0
  156. package/serialization/resources/empathicVoice/types/ReturnChatEventType.d.ts +1 -1
  157. package/serialization/resources/empathicVoice/types/ReturnChatEventType.js +9 -4
  158. package/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +13 -13
  159. package/serialization/resources/empathicVoice/types/ReturnConfig.js +13 -13
  160. package/serialization/resources/empathicVoice/types/ReturnPrompt.d.ts +1 -1
  161. package/serialization/resources/empathicVoice/types/ReturnPrompt.js +1 -1
  162. package/serialization/resources/empathicVoice/types/SupportsToolUse.d.ts +13 -0
  163. package/serialization/resources/empathicVoice/types/SupportsToolUse.js +44 -0
  164. package/serialization/resources/empathicVoice/types/index.d.ts +1 -0
  165. package/serialization/resources/empathicVoice/types/index.js +1 -0
  166. package/serialization/resources/tts/types/SnippetAudioChunk.d.ts +0 -8
  167. package/serialization/resources/tts/types/SnippetAudioChunk.js +1 -10
  168. package/version.d.ts +1 -1
  169. package/version.js +1 -1
  170. package/core/form-data-utils/toReadableStream.d.ts +0 -1
  171. package/dist/core/form-data-utils/toReadableStream.d.ts +0 -1
@@ -10,45 +10,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getResponseBody = getResponseBody;
13
+ const BinaryResponse_1 = require("./BinaryResponse");
14
+ const ResponseWithBody_1 = require("./ResponseWithBody");
13
15
  const chooseStreamWrapper_1 = require("./stream-wrappers/chooseStreamWrapper");
14
16
  function getResponseBody(response, responseType) {
15
17
  return __awaiter(this, void 0, void 0, function* () {
16
- if (response.body != null && responseType === "blob") {
17
- return yield response.blob();
18
+ if (!(0, ResponseWithBody_1.isResponseWithBody)(response)) {
19
+ return undefined;
18
20
  }
19
- else if (response.body != null && responseType === "arrayBuffer") {
20
- return yield response.arrayBuffer();
21
+ switch (responseType) {
22
+ case "binary-response":
23
+ return (0, BinaryResponse_1.getBinaryResponse)(response);
24
+ case "blob":
25
+ return yield response.blob();
26
+ case "arrayBuffer":
27
+ return yield response.arrayBuffer();
28
+ case "sse":
29
+ return response.body;
30
+ case "streaming":
31
+ return (0, chooseStreamWrapper_1.chooseStreamWrapper)(response.body);
32
+ case "text":
33
+ return yield response.text();
21
34
  }
22
- else if (response.body != null && responseType === "sse") {
23
- return response.body;
24
- }
25
- else if (response.body != null && responseType === "streaming") {
26
- return (0, chooseStreamWrapper_1.chooseStreamWrapper)(response.body);
27
- }
28
- else if (response.body != null && responseType === "text") {
29
- return yield response.text();
30
- }
31
- else {
32
- const text = yield response.text();
33
- if (text.length > 0) {
34
- try {
35
- let responseBody = JSON.parse(text);
36
- return responseBody;
37
- }
38
- catch (err) {
39
- return {
40
- ok: false,
41
- error: {
42
- reason: "non-json",
43
- statusCode: response.status,
44
- rawBody: text,
45
- },
46
- };
47
- }
35
+ // if responseType is "json" or not specified, try to parse as JSON
36
+ const text = yield response.text();
37
+ if (text.length > 0) {
38
+ try {
39
+ let responseBody = JSON.parse(text);
40
+ return responseBody;
48
41
  }
49
- else {
50
- return undefined;
42
+ catch (err) {
43
+ return {
44
+ ok: false,
45
+ error: {
46
+ reason: "non-json",
47
+ statusCode: response.status,
48
+ rawBody: text,
49
+ },
50
+ };
51
51
  }
52
52
  }
53
+ return undefined;
53
54
  });
54
55
  }
@@ -6,3 +6,4 @@ export { Supplier } from "./Supplier";
6
6
  export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse";
7
7
  export type { RawResponse, WithRawResponse } from "./RawResponse";
8
8
  export { HttpResponsePromise } from "./HttpResponsePromise";
9
+ export { BinaryResponse } from "./BinaryResponse";
package/core/file.d.ts ADDED
@@ -0,0 +1 @@
1
+ export type FileLike = ArrayBuffer | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
package/core/file.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,63 +1,16 @@
1
- export type MaybePromise<T> = Promise<T> | T;
2
1
  interface FormDataRequest<Body> {
3
2
  body: Body;
4
3
  headers: Record<string, string>;
5
4
  duplex?: "half";
6
5
  }
7
- export interface CrossPlatformFormData {
8
- setup(): Promise<void>;
9
- append(key: string, value: unknown): void;
10
- appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
11
- getRequest(): MaybePromise<FormDataRequest<unknown>>;
12
- }
13
- export declare function newFormData(): Promise<CrossPlatformFormData>;
14
- export type Node18FormDataFd = {
15
- append(name: string, value: unknown, fileName?: string): void;
16
- } | undefined;
17
- /**
18
- * Form Data Implementation for Node.js 18+
19
- */
20
- export declare class Node18FormData implements CrossPlatformFormData {
6
+ export declare function newFormData(): Promise<FormDataWrapper>;
7
+ export declare class FormDataWrapper {
21
8
  private fd;
22
9
  setup(): Promise<void>;
23
- append(key: string, value: any): void;
24
- private getFileName;
25
- appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
26
- getRequest(): Promise<FormDataRequest<unknown>>;
27
- }
28
- export type Node16FormDataFd = {
29
- append(name: string, value: unknown, options?: string | {
30
- header?: string | Headers;
31
- knownLength?: number;
32
- filename?: string;
33
- filepath?: string;
34
- contentType?: string;
35
- }): void;
36
- getHeaders(): Record<string, string>;
37
- } | undefined;
38
- /**
39
- * Form Data Implementation for Node.js 16-18
40
- */
41
- export declare class Node16FormData implements CrossPlatformFormData {
42
- private fd;
43
- setup(): Promise<void>;
44
- append(key: string, value: any): void;
10
+ append(key: string, value: unknown): void;
45
11
  private getFileName;
12
+ private convertToBlob;
46
13
  appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
47
- getRequest(): FormDataRequest<Node16FormDataFd>;
48
- }
49
- export type WebFormDataFd = {
50
- append(name: string, value: string | Blob, fileName?: string): void;
51
- } | undefined;
52
- /**
53
- * Form Data Implementation for Web
54
- */
55
- export declare class WebFormData implements CrossPlatformFormData {
56
- protected fd: WebFormDataFd;
57
- setup(): Promise<void>;
58
- append(key: string, value: any): void;
59
- private getFileName;
60
- appendFile(key: string, value: any, fileName?: string): Promise<void>;
61
- getRequest(): FormDataRequest<WebFormDataFd>;
14
+ getRequest(): FormDataRequest<FormData>;
62
15
  }
63
16
  export {};
@@ -41,51 +41,110 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
42
  });
43
43
  };
44
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
45
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
46
+ var m = o[Symbol.asyncIterator], i;
47
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
48
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
49
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
50
+ };
44
51
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.WebFormData = exports.Node16FormData = exports.Node18FormData = void 0;
52
+ exports.FormDataWrapper = void 0;
46
53
  exports.newFormData = newFormData;
54
+ const json_js_1 = require("../../core/json.js");
47
55
  const index_js_1 = require("../runtime/index.js");
48
- const toReadableStream_js_1 = require("./toReadableStream.js");
49
56
  function isNamedValue(value) {
50
57
  return typeof value === "object" && value != null && "name" in value;
51
58
  }
52
59
  function isPathedValue(value) {
53
60
  return typeof value === "object" && value != null && "path" in value;
54
61
  }
62
+ function isStreamLike(value) {
63
+ return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
64
+ }
65
+ function isReadableStream(value) {
66
+ return typeof value === "object" && value != null && "getReader" in value;
67
+ }
68
+ function isBuffer(value) {
69
+ return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
70
+ }
71
+ function isArrayBufferView(value) {
72
+ return ArrayBuffer.isView(value);
73
+ }
55
74
  function getLastPathSegment(pathStr) {
56
75
  const lastForwardSlash = pathStr.lastIndexOf("/");
57
76
  const lastBackSlash = pathStr.lastIndexOf("\\");
58
77
  const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
59
78
  return lastSlashIndex >= 0 ? pathStr.substring(lastSlashIndex + 1) : pathStr;
60
79
  }
61
- function newFormData() {
80
+ function streamToBuffer(stream) {
62
81
  return __awaiter(this, void 0, void 0, function* () {
63
- let formdata;
64
- if (index_js_1.RUNTIME.type === "node" && index_js_1.RUNTIME.parsedVersion != null && index_js_1.RUNTIME.parsedVersion >= 18) {
65
- formdata = new Node18FormData();
66
- }
67
- else if (index_js_1.RUNTIME.type === "node") {
68
- formdata = new Node16FormData();
82
+ var _a, stream_1, stream_1_1;
83
+ var _b, e_1, _c, _d;
84
+ if (index_js_1.RUNTIME.type === "node") {
85
+ const { Readable } = yield Promise.resolve().then(() => __importStar(require("stream")));
86
+ if (stream instanceof Readable) {
87
+ const chunks = [];
88
+ try {
89
+ for (_a = true, stream_1 = __asyncValues(stream); stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _a = true) {
90
+ _d = stream_1_1.value;
91
+ _a = false;
92
+ const chunk = _d;
93
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
94
+ }
95
+ }
96
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
97
+ finally {
98
+ try {
99
+ if (!_a && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
100
+ }
101
+ finally { if (e_1) throw e_1.error; }
102
+ }
103
+ return Buffer.concat(chunks);
104
+ }
69
105
  }
70
- else {
71
- formdata = new WebFormData();
106
+ if (isReadableStream(stream)) {
107
+ const reader = stream.getReader();
108
+ const chunks = [];
109
+ try {
110
+ while (true) {
111
+ const { done, value } = yield reader.read();
112
+ if (done)
113
+ break;
114
+ chunks.push(value);
115
+ }
116
+ }
117
+ finally {
118
+ reader.releaseLock();
119
+ }
120
+ const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
121
+ const result = new Uint8Array(totalLength);
122
+ let offset = 0;
123
+ for (const chunk of chunks) {
124
+ result.set(chunk, offset);
125
+ offset += chunk.length;
126
+ }
127
+ return Buffer.from(result);
72
128
  }
73
- yield formdata.setup();
74
- return formdata;
129
+ throw new Error("Unsupported stream type: " + typeof stream + ". Expected Node.js Readable stream or Web ReadableStream.");
130
+ });
131
+ }
132
+ function newFormData() {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ return new FormDataWrapper();
75
135
  });
76
136
  }
77
- /**
78
- * Form Data Implementation for Node.js 18+
79
- */
80
- class Node18FormData {
137
+ class FormDataWrapper {
138
+ constructor() {
139
+ this.fd = new FormData();
140
+ }
81
141
  setup() {
82
142
  return __awaiter(this, void 0, void 0, function* () {
83
- this.fd = new (yield Promise.resolve().then(() => __importStar(require("formdata-node")))).FormData();
143
+ // noop
84
144
  });
85
145
  }
86
146
  append(key, value) {
87
- var _a;
88
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
147
+ this.fd.append(key, String(value));
89
148
  }
90
149
  getFileName(value, filename) {
91
150
  if (filename != null) {
@@ -99,130 +158,51 @@ class Node18FormData {
99
158
  }
100
159
  return undefined;
101
160
  }
102
- appendFile(key, value, fileName) {
161
+ convertToBlob(value) {
103
162
  return __awaiter(this, void 0, void 0, function* () {
104
- var _a, _b;
105
- fileName = this.getFileName(value, fileName);
163
+ if (isStreamLike(value) || isReadableStream(value)) {
164
+ const buffer = yield streamToBuffer(value);
165
+ return new Blob([buffer]);
166
+ }
106
167
  if (value instanceof Blob) {
107
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value, fileName);
168
+ return value;
108
169
  }
109
- else {
110
- (_b = this.fd) === null || _b === void 0 ? void 0 : _b.append(key, {
111
- type: undefined,
112
- name: fileName,
113
- [Symbol.toStringTag]: "File",
114
- stream() {
115
- return value;
116
- },
117
- });
170
+ if (isBuffer(value)) {
171
+ return new Blob([value]);
118
172
  }
119
- });
120
- }
121
- getRequest() {
122
- return __awaiter(this, void 0, void 0, function* () {
123
- const encoder = new (yield Promise.resolve().then(() => __importStar(require("form-data-encoder")))).FormDataEncoder(this.fd);
124
- return {
125
- body: yield (0, toReadableStream_js_1.toReadableStream)(encoder),
126
- headers: encoder.headers,
127
- duplex: "half",
128
- };
129
- });
130
- }
131
- }
132
- exports.Node18FormData = Node18FormData;
133
- /**
134
- * Form Data Implementation for Node.js 16-18
135
- */
136
- class Node16FormData {
137
- setup() {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- this.fd = new (yield Promise.resolve().then(() => __importStar(require("form-data")))).default();
140
- });
141
- }
142
- append(key, value) {
143
- var _a;
144
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
145
- }
146
- getFileName(value, filename) {
147
- if (filename != null) {
148
- return filename;
149
- }
150
- if (isNamedValue(value)) {
151
- return value.name;
152
- }
153
- if (isPathedValue(value) && value.path) {
154
- return getLastPathSegment(value.path.toString());
155
- }
156
- return undefined;
157
- }
158
- appendFile(key, value, fileName) {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- var _a, _b;
161
- fileName = this.getFileName(value, fileName);
162
- let bufferedValue;
163
- if (value instanceof Blob) {
164
- bufferedValue = Buffer.from(yield value.arrayBuffer());
173
+ if (value instanceof ArrayBuffer) {
174
+ return new Blob([value]);
165
175
  }
166
- else {
167
- bufferedValue = value;
176
+ if (isArrayBufferView(value)) {
177
+ return new Blob([value]);
168
178
  }
169
- if (fileName == null) {
170
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, bufferedValue);
179
+ if (typeof value === "string") {
180
+ return new Blob([value]);
171
181
  }
172
- else {
173
- (_b = this.fd) === null || _b === void 0 ? void 0 : _b.append(key, bufferedValue, { filename: fileName });
182
+ if (typeof value === "object" && value !== null) {
183
+ return new Blob([(0, json_js_1.toJson)(value)], { type: "application/json" });
174
184
  }
185
+ return new Blob([String(value)]);
175
186
  });
176
187
  }
177
- getRequest() {
178
- return {
179
- body: this.fd,
180
- headers: this.fd ? this.fd.getHeaders() : {},
181
- };
182
- }
183
- }
184
- exports.Node16FormData = Node16FormData;
185
- /**
186
- * Form Data Implementation for Web
187
- */
188
- class WebFormData {
189
- setup() {
190
- return __awaiter(this, void 0, void 0, function* () {
191
- this.fd = new FormData();
192
- });
193
- }
194
- append(key, value) {
195
- var _a;
196
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
197
- }
198
- getFileName(value, filename) {
199
- if (filename != null) {
200
- return filename;
201
- }
202
- if (isNamedValue(value)) {
203
- return value.name;
204
- }
205
- if (isPathedValue(value) && value.path) {
206
- return getLastPathSegment(value.path.toString());
207
- }
208
- return undefined;
209
- }
210
188
  appendFile(key, value, fileName) {
211
189
  return __awaiter(this, void 0, void 0, function* () {
212
- var _a, _b;
213
190
  fileName = this.getFileName(value, fileName);
214
- if (value instanceof Blob) {
215
- (_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value, fileName);
216
- return;
191
+ const blob = yield this.convertToBlob(value);
192
+ if (fileName) {
193
+ this.fd.append(key, blob, fileName);
194
+ }
195
+ else {
196
+ this.fd.append(key, blob);
217
197
  }
218
- (_b = this.fd) === null || _b === void 0 ? void 0 : _b.append(key, new Blob([value]), fileName);
219
198
  });
220
199
  }
221
200
  getRequest() {
222
201
  return {
223
202
  body: this.fd,
224
203
  headers: {},
204
+ duplex: "half",
225
205
  };
226
206
  }
227
207
  }
228
- exports.WebFormData = WebFormData;
208
+ exports.FormDataWrapper = FormDataWrapper;
package/core/index.d.ts CHANGED
@@ -5,5 +5,6 @@ export * from "./stream";
5
5
  export * from "./utils";
6
6
  export * from "./pagination";
7
7
  export * from "./form-data-utils";
8
+ export * from "./file";
8
9
  export * as serialization from "./schemas";
9
10
  export * from "./websocket";
package/core/index.js CHANGED
@@ -44,6 +44,7 @@ __exportStar(require("./stream"), exports);
44
44
  __exportStar(require("./utils"), exports);
45
45
  __exportStar(require("./pagination"), exports);
46
46
  __exportStar(require("./form-data-utils"), exports);
47
+ __exportStar(require("./file"), exports);
47
48
  exports.serialization = __importStar(require("./schemas"));
48
49
  // This one is manually added
49
50
  __exportStar(require("./websocket"), exports);
@@ -1 +1,2 @@
1
1
  export {};
2
+ export * from "./requests";
@@ -1,2 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests"), exports);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * modelResource: "model_resource"
8
+ * }
9
+ */
10
+ export interface BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost {
11
+ modelResource: string;
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost } from "./BodyCustomLanguageModelSupportsToolUseV0EviCustomLanguageModelSupportsToolUsePost";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as errors from "../../../../errors/index";
5
+ import * as Hume from "../../../index";
6
+ import * as core from "../../../../core";
7
+ export declare class UnprocessableEntityError extends errors.HumeError {
8
+ constructor(body: Hume.empathicVoice.HttpValidationError, rawResponse?: core.RawResponse);
9
+ }
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
2
5
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
6
  if (k2 === undefined) k2 = k;
4
7
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -32,19 +35,18 @@ var __importStar = (this && this.__importStar) || (function () {
32
35
  return result;
33
36
  };
34
37
  })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
38
  Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.toReadableStream = toReadableStream;
46
- function toReadableStream(encoder) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- return (yield Promise.resolve().then(() => __importStar(require("readable-stream")))).Readable.from(encoder);
49
- });
39
+ exports.UnprocessableEntityError = void 0;
40
+ const errors = __importStar(require("../../../../errors/index"));
41
+ class UnprocessableEntityError extends errors.HumeError {
42
+ constructor(body, rawResponse) {
43
+ super({
44
+ message: "UnprocessableEntityError",
45
+ statusCode: 422,
46
+ body: body,
47
+ rawResponse: rawResponse,
48
+ });
49
+ Object.setPrototypeOf(this, UnprocessableEntityError.prototype);
50
+ }
50
51
  }
52
+ exports.UnprocessableEntityError = UnprocessableEntityError;
@@ -1 +1,2 @@
1
+ export * from "./UnprocessableEntityError";
1
2
  export * from "./BadRequestError";
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./UnprocessableEntityError"), exports);
17
18
  __exportStar(require("./BadRequestError"), exports);
@@ -1 +1,2 @@
1
+ export {};
1
2
  export * from "./requests";
@@ -1 +1,2 @@
1
+ export {};
1
2
  export * from "./requests";
@@ -1 +1,2 @@
1
+ export {};
1
2
  export * from "./requests";
@@ -37,7 +37,11 @@ import * as Hume from "../../../../../../index";
37
37
  * }
38
38
  */
39
39
  export interface PostedConfig {
40
- /** Specifies the EVI version to use. Use `"1"` for version 1, or `"2"` for the latest enhanced version. For a detailed comparison of the two versions, refer to our [guide](/docs/speech-to-speech-evi/configuration/evi-version). */
40
+ /**
41
+ * Specifies the EVI version to use. See our [EVI Version Guide](/docs/speech-to-speech-evi/configuration/evi-version) for differences between versions.
42
+ *
43
+ * **We're officially sunsetting EVI versions 1 and 2 on August 30, 2025**. To keep things running smoothly, be sure to [migrate to EVI 3](/docs/speech-to-speech-evi/configuration/evi-version#migrating-to-evi-3) before then.
44
+ */
41
45
  eviVersion: string;
42
46
  /** Name applied to all versions of a particular Config. */
43
47
  name: string;
@@ -1 +1,2 @@
1
+ export {};
1
2
  export * from "./requests";
@@ -1 +1,2 @@
1
+ export {};
1
2
  export * from "./requests";
@@ -2,4 +2,4 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as Hume from "../../../index";
5
- export type JsonMessage = Hume.empathicVoice.AssistantEnd | Hume.empathicVoice.AssistantMessage | Hume.empathicVoice.ChatMetadata | Hume.empathicVoice.WebSocketError | Hume.empathicVoice.UserInterruption | Hume.empathicVoice.UserMessage | Hume.empathicVoice.ToolCallMessage | Hume.empathicVoice.ToolResponseMessage | Hume.empathicVoice.ToolErrorMessage;
5
+ export type JsonMessage = Hume.empathicVoice.AssistantEnd | Hume.empathicVoice.AssistantMessage | Hume.empathicVoice.ChatMetadata | Hume.empathicVoice.WebSocketError | Hume.empathicVoice.UserInterruption | Hume.empathicVoice.UserMessage | Hume.empathicVoice.ToolCallMessage | Hume.empathicVoice.ToolResponseMessage | Hume.empathicVoice.ToolErrorMessage | Hume.empathicVoice.AssistantProsody;