@deepgram/sdk 5.3.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/browser/index.global.js +474 -18
  2. package/dist/cjs/BaseClient.d.ts +3 -0
  3. package/dist/cjs/BaseClient.js +20 -2
  4. package/dist/cjs/CustomClient.d.ts +75 -6
  5. package/dist/cjs/CustomClient.js +421 -15
  6. package/dist/cjs/api/errors/BadRequestError.js +1 -1
  7. package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.ts +7 -3
  8. package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.js +1 -7
  9. package/dist/cjs/api/resources/listen/resources/v1/client/Client.d.ts +1 -0
  10. package/dist/cjs/api/resources/listen/resources/v1/client/Client.js +2 -1
  11. package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.ts +2 -2
  12. package/dist/cjs/api/resources/listen/resources/v1/resources/media/client/requests/MediaTranscribeRequestOctetStream.d.ts +2 -2
  13. package/dist/cjs/api/resources/listen/resources/v1/types/DiarizeModel.d.ts +5 -0
  14. package/dist/cjs/api/{types/CreateKeyV1RequestOne.js → resources/listen/resources/v1/types/DiarizeModel.js} +5 -0
  15. package/dist/cjs/api/resources/listen/resources/v1/types/index.d.ts +1 -0
  16. package/dist/cjs/api/resources/listen/resources/v1/types/index.js +1 -0
  17. package/dist/cjs/api/resources/listen/resources/v2/client/Client.d.ts +1 -0
  18. package/dist/cjs/api/resources/listen/resources/v2/client/Client.js +2 -1
  19. package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.ts +2 -1
  20. package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.js +5 -1
  21. package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.ts +4 -0
  22. package/dist/cjs/api/types/DeepgramListenProviderV2.d.ts +7 -1
  23. package/dist/cjs/api/types/ListenV1Diarize.d.ts +1 -1
  24. package/dist/cjs/api/types/ListenV1Diarize.js +1 -1
  25. package/dist/cjs/api/types/ListenV2ProfanityFilter.d.ts +6 -0
  26. package/dist/cjs/api/types/ListenV2ProfanityFilter.js +9 -0
  27. package/dist/cjs/api/types/index.d.ts +1 -0
  28. package/dist/cjs/api/types/index.js +1 -0
  29. package/dist/cjs/auth/HeaderAuthProvider.js +2 -1
  30. package/dist/cjs/core/auth/AuthProvider.d.ts +1 -0
  31. package/dist/cjs/core/auth/AuthProvider.js +7 -0
  32. package/dist/cjs/core/auth/index.d.ts +1 -1
  33. package/dist/cjs/core/auth/index.js +3 -1
  34. package/dist/cjs/core/fetcher/getResponseBody.js +11 -0
  35. package/dist/cjs/core/fetcher/requestWithRetries.js +4 -1
  36. package/dist/cjs/core/fetcher/signals.js +9 -1
  37. package/dist/cjs/errors/DeepgramError.js +1 -1
  38. package/dist/cjs/errors/DeepgramTimeoutError.js +1 -1
  39. package/dist/cjs/index.d.ts +2 -0
  40. package/dist/cjs/index.js +1 -0
  41. package/dist/cjs/version.d.ts +1 -1
  42. package/dist/cjs/version.js +1 -1
  43. package/dist/esm/BaseClient.d.mts +3 -0
  44. package/dist/esm/BaseClient.mjs +20 -2
  45. package/dist/esm/CustomClient.d.mts +75 -6
  46. package/dist/esm/CustomClient.mjs +421 -15
  47. package/dist/esm/api/errors/BadRequestError.mjs +1 -1
  48. package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.mts +7 -3
  49. package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.mjs +1 -7
  50. package/dist/esm/api/resources/listen/resources/v1/client/Client.d.mts +1 -0
  51. package/dist/esm/api/resources/listen/resources/v1/client/Client.mjs +2 -1
  52. package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/ListenV1RequestUrl.d.mts +2 -2
  53. package/dist/esm/api/resources/listen/resources/v1/resources/media/client/requests/MediaTranscribeRequestOctetStream.d.mts +2 -2
  54. package/dist/esm/api/resources/listen/resources/v1/types/DiarizeModel.d.mts +5 -0
  55. package/dist/esm/api/resources/listen/resources/v1/types/DiarizeModel.mjs +5 -0
  56. package/dist/esm/api/resources/listen/resources/v1/types/index.d.mts +1 -0
  57. package/dist/esm/api/resources/listen/resources/v1/types/index.mjs +1 -0
  58. package/dist/esm/api/resources/listen/resources/v2/client/Client.d.mts +1 -0
  59. package/dist/esm/api/resources/listen/resources/v2/client/Client.mjs +2 -1
  60. package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.mts +2 -1
  61. package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.mjs +5 -1
  62. package/dist/esm/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.mts +4 -0
  63. package/dist/esm/api/types/DeepgramListenProviderV2.d.mts +7 -1
  64. package/dist/esm/api/types/ListenV1Diarize.d.mts +1 -1
  65. package/dist/esm/api/types/ListenV1Diarize.mjs +1 -1
  66. package/dist/esm/api/types/ListenV2ProfanityFilter.d.mts +6 -0
  67. package/dist/esm/api/types/ListenV2ProfanityFilter.mjs +6 -0
  68. package/dist/esm/api/types/index.d.mts +1 -0
  69. package/dist/esm/api/types/index.mjs +1 -0
  70. package/dist/esm/auth/HeaderAuthProvider.mjs +2 -1
  71. package/dist/esm/core/auth/AuthProvider.d.mts +1 -0
  72. package/dist/esm/core/auth/AuthProvider.mjs +6 -1
  73. package/dist/esm/core/auth/index.d.mts +1 -1
  74. package/dist/esm/core/auth/index.mjs +1 -0
  75. package/dist/esm/core/fetcher/getResponseBody.mjs +11 -0
  76. package/dist/esm/core/fetcher/requestWithRetries.mjs +4 -1
  77. package/dist/esm/core/fetcher/signals.mjs +9 -1
  78. package/dist/esm/errors/DeepgramError.mjs +1 -1
  79. package/dist/esm/errors/DeepgramTimeoutError.mjs +1 -1
  80. package/dist/esm/index.d.mts +2 -0
  81. package/dist/esm/index.mjs +1 -0
  82. package/dist/esm/version.d.mts +1 -1
  83. package/dist/esm/version.mjs +1 -1
  84. package/package.json +1 -1
  85. package/dist/cjs/api/types/CreateKeyV1RequestOne.d.ts +0 -1
  86. package/dist/esm/api/types/CreateKeyV1RequestOne.d.mts +0 -1
  87. package/dist/esm/api/types/CreateKeyV1RequestOne.mjs +0 -2
@@ -1,3 +1,4 @@
1
+ export * from "./DiarizeModel.js";
1
2
  export * from "./ListenV1CloseStream.js";
2
3
  export * from "./ListenV1Finalize.js";
3
4
  export * from "./ListenV1KeepAlive.js";
@@ -14,6 +14,7 @@ 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("./DiarizeModel.js"), exports);
17
18
  __exportStar(require("./ListenV1CloseStream.js"), exports);
18
19
  __exportStar(require("./ListenV1Finalize.js"), exports);
19
20
  __exportStar(require("./ListenV1KeepAlive.js"), exports);
@@ -13,6 +13,7 @@ export declare namespace V2Client {
13
13
  eot_timeout_ms?: Deepgram.ListenV2EotTimeoutMs | undefined;
14
14
  keyterm?: Deepgram.ListenV2Keyterm;
15
15
  language_hint?: Deepgram.ListenV2LanguageHint;
16
+ profanity_filter?: Deepgram.ListenV2ProfanityFilter;
16
17
  mip_opt_out?: Deepgram.ListenV2MipOptOut | undefined;
17
18
  tag?: Deepgram.ListenV2Tag | undefined;
18
19
  Authorization: string;
@@ -57,7 +57,7 @@ class V2Client {
57
57
  connect(args) {
58
58
  return __awaiter(this, void 0, void 0, function* () {
59
59
  var _a, _b, _c;
60
- const { model, encoding, sample_rate: sampleRate, eager_eot_threshold: eagerEotThreshold, eot_threshold: eotThreshold, eot_timeout_ms: eotTimeoutMs, keyterm, language_hint: languageHint, mip_opt_out: mipOptOut, tag, protocols, queryParams, headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal, } = args;
60
+ const { model, encoding, sample_rate: sampleRate, eager_eot_threshold: eagerEotThreshold, eot_threshold: eotThreshold, eot_timeout_ms: eotTimeoutMs, keyterm, language_hint: languageHint, profanity_filter: profanityFilter, mip_opt_out: mipOptOut, tag, protocols, queryParams, headers, debug, reconnectAttempts, connectionTimeoutInSeconds, abortSignal, } = args;
61
61
  const _queryParams = {
62
62
  model,
63
63
  encoding: encoding != null ? encoding : undefined,
@@ -91,6 +91,7 @@ class V2Client {
91
91
  ? languageHint
92
92
  : (0, json_js_1.toJson)(languageHint)
93
93
  : undefined,
94
+ profanity_filter: profanityFilter != null ? profanityFilter : undefined,
94
95
  mip_opt_out: mipOptOut != null ? (typeof mipOptOut === "string" ? mipOptOut : (0, json_js_1.toJson)(mipOptOut)) : undefined,
95
96
  tag: tag != null ? (typeof tag === "string" ? tag : (0, json_js_1.toJson)(tag)) : undefined,
96
97
  };
@@ -3,10 +3,11 @@ export interface ListenV2CloseStream {
3
3
  type: ListenV2CloseStream.Type;
4
4
  }
5
5
  export declare namespace ListenV2CloseStream {
6
- /** Message type identifier */
7
6
  const Type: {
7
+ /** @deprecated Use "CloseStream". Retained for backward compatibility. */
8
8
  readonly Finalize: "Finalize";
9
9
  readonly CloseStream: "CloseStream";
10
+ /** @deprecated Use "CloseStream". Retained for backward compatibility. */
10
11
  readonly KeepAlive: "KeepAlive";
11
12
  };
12
13
  type Type = (typeof Type)[keyof typeof Type] | string;
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ListenV2CloseStream = void 0;
5
5
  var ListenV2CloseStream;
6
6
  (function (ListenV2CloseStream) {
7
- /** Message type identifier */
7
+ // A CloseStream message's `type` is always "CloseStream". `Finalize`/`KeepAlive` are
8
+ // deprecated and retained only for backward compatibility; they will be removed in the
9
+ // next major. Frozen in .fernignore.
8
10
  ListenV2CloseStream.Type = {
11
+ /** @deprecated Use "CloseStream". Retained for backward compatibility. */
9
12
  Finalize: "Finalize",
10
13
  CloseStream: "CloseStream",
14
+ /** @deprecated Use "CloseStream". Retained for backward compatibility. */
11
15
  KeepAlive: "KeepAlive",
12
16
  };
13
17
  })(ListenV2CloseStream || (exports.ListenV2CloseStream = ListenV2CloseStream = {}));
@@ -66,6 +66,10 @@ export declare namespace ListenV2TurnInfo {
66
66
  word: string;
67
67
  /** Confidence that this word was transcribed correctly */
68
68
  confidence: number;
69
+ /** The start time of the word */
70
+ start?: number | undefined;
71
+ /** The end time of the word */
72
+ end?: number | undefined;
69
73
  }
70
74
  }
71
75
  }
@@ -5,7 +5,13 @@ export interface DeepgramListenProviderV2 {
5
5
  version?: "v2" | undefined;
6
6
  /** Model to use for speech to text using the V2 API (e.g. flux-general-en, flux-general-multi) */
7
7
  model: string;
8
- /** One or more BCP-47 language codes to bias the model toward specific languages. Only supported when model is flux-general-multi. Without hints, the model auto-detects the spoken language. See the Language Prompting guide for details. */
8
+ /** An array of one or more BCP-47 language codes to bias the model toward specific languages. Only supported when model is flux-general-multi. Without hints, the model auto-detects the spoken language. See the Language Prompting guide for details. */
9
+ language_hints?: string[] | undefined;
10
+ /**
11
+ * @deprecated Use `language_hints` instead. Backward-compat shim: the 2026-06-16 regen
12
+ * renamed this field to `language_hints`. The singular `language_hint` was never honored
13
+ * by the API, so this is kept only so existing call sites keep compiling; prefer `language_hints`.
14
+ */
9
15
  language_hint?: DeepgramListenProviderV2.LanguageHint | undefined;
10
16
  /** Prompt keyterm recognition to improve Keyword Recall Rate */
11
17
  keyterms?: string[] | undefined;
@@ -1,4 +1,4 @@
1
- /** Defaults to `false`. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0 */
1
+ /** Deprecated. Use `diarize_model` instead. Defaults to `false`. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0 */
2
2
  export declare const ListenV1Diarize: {
3
3
  readonly True: "true";
4
4
  readonly False: "false";
@@ -2,7 +2,7 @@
2
2
  // This file was auto-generated by Fern from our API Definition.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ListenV1Diarize = void 0;
5
- /** Defaults to `false`. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0 */
5
+ /** Deprecated. Use `diarize_model` instead. Defaults to `false`. Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0 */
6
6
  exports.ListenV1Diarize = {
7
7
  True: "true",
8
8
  False: "false",
@@ -0,0 +1,6 @@
1
+ /** Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely. */
2
+ export declare const ListenV2ProfanityFilter: {
3
+ readonly True: "true";
4
+ readonly False: "false";
5
+ };
6
+ export type ListenV2ProfanityFilter = (typeof ListenV2ProfanityFilter)[keyof typeof ListenV2ProfanityFilter] | string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ListenV2ProfanityFilter = void 0;
5
+ /** Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely. */
6
+ exports.ListenV2ProfanityFilter = {
7
+ True: "true",
8
+ False: "false",
9
+ };
@@ -84,6 +84,7 @@ export * from "./ListenV2Keyterm.js";
84
84
  export * from "./ListenV2LanguageHint.js";
85
85
  export * from "./ListenV2MipOptOut.js";
86
86
  export * from "./ListenV2Model.js";
87
+ export * from "./ListenV2ProfanityFilter.js";
87
88
  export * from "./ListenV2SampleRate.js";
88
89
  export * from "./ListenV2Tag.js";
89
90
  export * from "./ListModelsV1Response.js";
@@ -100,6 +100,7 @@ __exportStar(require("./ListenV2Keyterm.js"), exports);
100
100
  __exportStar(require("./ListenV2LanguageHint.js"), exports);
101
101
  __exportStar(require("./ListenV2MipOptOut.js"), exports);
102
102
  __exportStar(require("./ListenV2Model.js"), exports);
103
+ __exportStar(require("./ListenV2ProfanityFilter.js"), exports);
103
104
  __exportStar(require("./ListenV2SampleRate.js"), exports);
104
105
  __exportStar(require("./ListenV2Tag.js"), exports);
105
106
  __exportStar(require("./ListModelsV1Response.js"), exports);
@@ -49,6 +49,7 @@ const errors = __importStar(require("../errors/index.js"));
49
49
  const PARAM_KEY = "apiKey";
50
50
  const ENV_HEADER_KEY = "DEEPGRAM_API_KEY";
51
51
  const HEADER_NAME = "Authorization";
52
+ const HEADER_PREFIX = "Token ";
52
53
  class HeaderAuthProvider {
53
54
  constructor(options) {
54
55
  this.options = options;
@@ -67,7 +68,7 @@ class HeaderAuthProvider {
67
68
  });
68
69
  }
69
70
  return {
70
- headers: { [HEADER_NAME]: headerValue },
71
+ headers: { [HEADER_NAME]: `${HEADER_PREFIX}${headerValue}` },
71
72
  };
72
73
  });
73
74
  }
@@ -5,3 +5,4 @@ export interface AuthProvider {
5
5
  endpointMetadata?: EndpointMetadata;
6
6
  }): Promise<AuthRequest>;
7
7
  }
8
+ export declare function isAuthProvider(value: unknown): value is AuthProvider;
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAuthProvider = isAuthProvider;
4
+ function isAuthProvider(value) {
5
+ return (typeof value === "object" &&
6
+ value !== null &&
7
+ "getAuthRequest" in value &&
8
+ typeof value.getAuthRequest === "function");
9
+ }
@@ -1,4 +1,4 @@
1
- export type { AuthProvider } from "./AuthProvider.js";
1
+ export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";
2
2
  export type { AuthRequest } from "./AuthRequest.js";
3
3
  export { BasicAuth } from "./BasicAuth.js";
4
4
  export { BearerToken } from "./BearerToken.js";
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = void 0;
3
+ exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = exports.isAuthProvider = void 0;
4
+ var AuthProvider_js_1 = require("./AuthProvider.js");
5
+ Object.defineProperty(exports, "isAuthProvider", { enumerable: true, get: function () { return AuthProvider_js_1.isAuthProvider; } });
4
6
  var BasicAuth_js_1 = require("./BasicAuth.js");
5
7
  Object.defineProperty(exports, "BasicAuth", { enumerable: true, get: function () { return BasicAuth_js_1.BasicAuth; } });
6
8
  var BearerToken_js_1 = require("./BearerToken.js");
@@ -12,6 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getResponseBody = getResponseBody;
13
13
  const json_js_1 = require("../json.js");
14
14
  const BinaryResponse_js_1 = require("./BinaryResponse.js");
15
+ // Pins the upstream Response so undici's FinalizationRegistry can't GC it and cancel the body stream.
16
+ function retainResponse(target, response) {
17
+ Object.defineProperty(target, "__fern_response_ref", {
18
+ value: response,
19
+ enumerable: false,
20
+ configurable: true,
21
+ writable: false,
22
+ });
23
+ }
15
24
  function getResponseBody(response, responseType) {
16
25
  return __awaiter(this, void 0, void 0, function* () {
17
26
  switch (responseType) {
@@ -31,6 +40,7 @@ function getResponseBody(response, responseType) {
31
40
  },
32
41
  };
33
42
  }
43
+ retainResponse(response.body, response);
34
44
  return response.body;
35
45
  case "streaming":
36
46
  if (response.body == null) {
@@ -42,6 +52,7 @@ function getResponseBody(response, responseType) {
42
52
  },
43
53
  };
44
54
  }
55
+ retainResponse(response.body, response);
45
56
  return response.body;
46
57
  case "text":
47
58
  return yield response.text();
@@ -14,6 +14,9 @@ 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 isRetryableStatusCode(statusCode) {
18
+ return [408, 429].includes(statusCode) || statusCode >= 500;
19
+ }
17
20
  function addPositiveJitter(delay) {
18
21
  const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
19
22
  return delay * jitterMultiplier;
@@ -53,7 +56,7 @@ function requestWithRetries(requestFn_1) {
53
56
  return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
54
57
  let response = yield requestFn();
55
58
  for (let i = 0; i < maxRetries; ++i) {
56
- if ([408, 429].includes(response.status) || response.status >= 500) {
59
+ if (isRetryableStatusCode(response.status)) {
57
60
  const delay = getRetryDelayFromHeaders(response, i);
58
61
  yield new Promise((resolve) => setTimeout(resolve, delay));
59
62
  response = yield requestFn();
@@ -14,11 +14,19 @@ function anySignal(...args) {
14
14
  for (const signal of signals) {
15
15
  if (signal.aborted) {
16
16
  controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
17
- break;
17
+ return controller.signal;
18
18
  }
19
19
  signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
20
20
  signal: controller.signal,
21
21
  });
22
+ // Re-check after adding listener: the signal may have aborted
23
+ // between the initial `signal.aborted` check and the `addEventListener`
24
+ // call above. If it did, the abort event was already dispatched and
25
+ // the listener will never fire — we must manually abort.
26
+ if (signal.aborted) {
27
+ controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
28
+ return controller.signal;
29
+ }
22
30
  }
23
31
  return controller.signal;
24
32
  }
@@ -10,7 +10,7 @@ class DeepgramError extends Error {
10
10
  if (Error.captureStackTrace) {
11
11
  Error.captureStackTrace(this, this.constructor);
12
12
  }
13
- this.name = this.constructor.name;
13
+ this.name = "DeepgramError";
14
14
  this.statusCode = statusCode;
15
15
  this.body = body;
16
16
  this.rawResponse = rawResponse;
@@ -9,7 +9,7 @@ class DeepgramTimeoutError extends Error {
9
9
  if (Error.captureStackTrace) {
10
10
  Error.captureStackTrace(this, this.constructor);
11
11
  }
12
- this.name = this.constructor.name;
12
+ this.name = "DeepgramTimeoutError";
13
13
  if ((opts === null || opts === void 0 ? void 0 : opts.cause) != null) {
14
14
  this.cause = opts.cause;
15
15
  }
@@ -4,6 +4,8 @@ export * from "./api/resources/index.js";
4
4
  export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
5
5
  export { DeepgramClient as DefaultDeepgramClient } from "./Client.js";
6
6
  export { CustomDeepgramClient as DeepgramClient } from "./CustomClient.js";
7
+ export type { CustomDeepgramClientOptions } from "./CustomClient.js";
7
8
  export { DeepgramEnvironment, type DeepgramEnvironmentUrls } from "./environments.js";
8
9
  export { DeepgramError, DeepgramTimeoutError } from "./errors/index.js";
10
+ export * from "./transport.js";
9
11
  export * from "./exports.js";
package/dist/cjs/index.js CHANGED
@@ -53,4 +53,5 @@ Object.defineProperty(exports, "DeepgramEnvironment", { enumerable: true, get: f
53
53
  var index_js_1 = require("./errors/index.js");
54
54
  Object.defineProperty(exports, "DeepgramError", { enumerable: true, get: function () { return index_js_1.DeepgramError; } });
55
55
  Object.defineProperty(exports, "DeepgramTimeoutError", { enumerable: true, get: function () { return index_js_1.DeepgramTimeoutError; } });
56
+ __exportStar(require("./transport.js"), exports);
56
57
  __exportStar(require("./exports.js"), exports);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "5.2.1";
1
+ export declare const SDK_VERSION = "5.5.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "5.2.1";
4
+ exports.SDK_VERSION = "5.5.0"; // x-release-please-version
@@ -1,6 +1,7 @@
1
1
  import { HeaderAuthProvider } from "./auth/HeaderAuthProvider.mjs";
2
2
  import * as core from "./core/index.mjs";
3
3
  import type * as environments from "./environments.mjs";
4
+ export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | HeaderAuthProvider.AuthOptions;
4
5
  export type BaseClientOptions = {
5
6
  environment?: core.Supplier<environments.DeepgramEnvironment | environments.DeepgramEnvironmentUrls>;
6
7
  /** Specify a custom URL to connect the client to. */
@@ -16,6 +17,8 @@ export type BaseClientOptions = {
16
17
  fetcher?: core.FetchFunction;
17
18
  /** Configure logging for the client. */
18
19
  logging?: core.logging.LogConfig | core.logging.Logger;
20
+ /** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
21
+ auth?: AuthOption;
19
22
  } & HeaderAuthProvider.AuthOptions;
20
23
  export interface BaseRequestOptions {
21
24
  /** The maximum time to wait for a response in seconds. */
@@ -2,12 +2,15 @@
2
2
  import { HeaderAuthProvider } from "./auth/HeaderAuthProvider.mjs";
3
3
  import { mergeHeaders } from "./core/headers.mjs";
4
4
  import * as core from "./core/index.mjs";
5
+ // Derive the SDK version from the single source of truth (src/version.ts), which
6
+ // carries the release-please marker. Avoids a second hardcoded version that drifts.
7
+ import { SDK_VERSION } from "./version.mjs";
5
8
  export function normalizeClientOptions(options) {
6
9
  const headers = mergeHeaders({
7
10
  "X-Fern-Language": "JavaScript",
8
11
  "X-Fern-SDK-Name": "@deepgram/sdk",
9
- "X-Fern-SDK-Version": "5.2.1",
10
- "User-Agent": "@deepgram/sdk/5.2.1",
12
+ "X-Fern-SDK-Version": SDK_VERSION,
13
+ "User-Agent": `@deepgram/sdk/${SDK_VERSION}`,
11
14
  "X-Fern-Runtime": core.RUNTIME.type,
12
15
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
16
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -16,6 +19,21 @@ export function normalizeClientOptions(options) {
16
19
  export function normalizeClientOptionsWithAuth(options) {
17
20
  var _a;
18
21
  const normalized = normalizeClientOptions(options);
22
+ if (options.auth === false) {
23
+ normalized.authProvider = new core.NoOpAuthProvider();
24
+ return normalized;
25
+ }
26
+ if (options.auth != null) {
27
+ if (typeof options.auth === "function") {
28
+ normalized.authProvider = { getAuthRequest: options.auth };
29
+ return normalized;
30
+ }
31
+ if (core.isAuthProvider(options.auth)) {
32
+ normalized.authProvider = options.auth;
33
+ return normalized;
34
+ }
35
+ Object.assign(normalized, options.auth);
36
+ }
19
37
  const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
20
38
  (_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = new HeaderAuthProvider(normalizedWithNoOpAuthProvider));
21
39
  return normalized;
@@ -2,36 +2,105 @@ import { DeepgramClient } from "./Client.mjs";
2
2
  import type { AgentClient } from "./api/resources/agent/client/Client.mjs";
3
3
  import type { ListenClient } from "./api/resources/listen/client/Client.mjs";
4
4
  import type { SpeakClient } from "./api/resources/speak/client/Client.mjs";
5
+ import { V1Client as AgentV1Client } from "./api/resources/agent/resources/v1/client/Client.mjs";
6
+ import { V1Client as ListenV1Client } from "./api/resources/listen/resources/v1/client/Client.mjs";
7
+ import { V2Client as ListenV2Client } from "./api/resources/listen/resources/v2/client/Client.mjs";
8
+ import { V1Client as SpeakV1Client } from "./api/resources/speak/resources/v1/client/Client.mjs";
9
+ import { V1Socket as AgentV1Socket } from "./api/resources/agent/resources/v1/client/Socket.mjs";
10
+ import { V1Socket as ListenV1Socket } from "./api/resources/listen/resources/v1/client/Socket.mjs";
11
+ import { V2Socket as ListenV2Socket } from "./api/resources/listen/resources/v2/client/Socket.mjs";
12
+ import { V1Socket as SpeakV1Socket } from "./api/resources/speak/resources/v1/client/Socket.mjs";
5
13
  import * as core from "./core/index.mjs";
14
+ import type { DeepgramTransportFactory } from "./transport.mjs";
15
+ export type AgentV1ConnectionArgs = Omit<AgentV1Client.ConnectArgs, "Authorization"> & {
16
+ Authorization?: string;
17
+ };
18
+ export type ListenV1ConnectionArgs = Omit<ListenV1Client.ConnectArgs, "Authorization"> & {
19
+ Authorization?: string;
20
+ };
21
+ export type ListenV2ConnectionArgs = Omit<ListenV2Client.ConnectArgs, "Authorization" | "keyterm"> & {
22
+ Authorization?: string;
23
+ keyterm?: string | string[];
24
+ };
25
+ export type SpeakV1ConnectionArgs = Omit<SpeakV1Client.ConnectArgs, "Authorization"> & {
26
+ Authorization?: string;
27
+ };
28
+ export interface AgentV1ClientWithWebSocket extends AgentV1Client {
29
+ connect(args?: AgentV1ConnectionArgs): Promise<AgentV1Socket>;
30
+ createConnection(args?: AgentV1ConnectionArgs): Promise<AgentV1Socket>;
31
+ }
32
+ export interface ListenV1ClientWithWebSocket extends ListenV1Client {
33
+ connect(args: ListenV1ConnectionArgs): Promise<ListenV1Socket>;
34
+ createConnection(args: ListenV1ConnectionArgs): Promise<ListenV1Socket>;
35
+ }
36
+ export interface ListenV2ClientWithWebSocket extends ListenV2Client {
37
+ connect(args: ListenV2ConnectionArgs): Promise<ListenV2Socket>;
38
+ createConnection(args: ListenV2ConnectionArgs): Promise<ListenV2Socket>;
39
+ }
40
+ export interface SpeakV1ClientWithWebSocket extends SpeakV1Client {
41
+ connect(args: SpeakV1ConnectionArgs): Promise<SpeakV1Socket>;
42
+ createConnection(args: SpeakV1ConnectionArgs): Promise<SpeakV1Socket>;
43
+ }
44
+ export interface AgentClientWithWebSockets extends AgentClient {
45
+ readonly v1: AgentV1ClientWithWebSocket;
46
+ }
47
+ export interface ListenClientWithWebSockets extends ListenClient {
48
+ readonly v1: ListenV1ClientWithWebSocket;
49
+ readonly v2: ListenV2ClientWithWebSocket;
50
+ }
51
+ export interface SpeakClientWithWebSockets extends SpeakClient {
52
+ readonly v1: SpeakV1ClientWithWebSocket;
53
+ }
6
54
  /**
7
55
  * Custom wrapper around DeepgramClient that ensures the custom websocket implementation
8
56
  * from ws.ts is always used, even if the auto-generated code changes.
9
57
  */
58
+ export interface CustomDeepgramClientOptions extends DeepgramClient.Options {
59
+ accessToken?: core.Supplier<string | undefined>;
60
+ transportFactory?: DeepgramTransportFactory;
61
+ /**
62
+ * Whether the SDK should retry streaming connections at the wrapper level
63
+ * after a transport failure. Defaults to `true` for native websocket
64
+ * connections. When a `transportFactory` is provided, this is auto-set to
65
+ * `false` because custom transports own their own retry/reconnect lifecycle
66
+ * — wrapping a self-retrying transport in another retry layer creates
67
+ * double-retry storms under burst load. Pass `reconnect: true` together
68
+ * with `transportFactory` to opt back into wrapper-level retries.
69
+ */
70
+ reconnect?: boolean;
71
+ }
10
72
  export declare class CustomDeepgramClient extends DeepgramClient {
11
73
  private _customAgent;
12
74
  private _customListen;
13
75
  private _customSpeak;
14
76
  private readonly _sessionId;
15
- constructor(options?: DeepgramClient.Options & {
16
- accessToken?: core.Supplier<string | undefined>;
17
- });
77
+ private readonly _reconnect;
78
+ constructor(options?: CustomDeepgramClientOptions);
18
79
  /**
19
80
  * Get the session ID that was generated for this client instance.
20
81
  */
21
82
  get sessionId(): string;
83
+ /**
84
+ * Whether the SDK will retry streaming connections at the wrapper level
85
+ * after a transport-side failure. Returns `false` when a `transportFactory`
86
+ * was supplied without an explicit `reconnect: true` override, signalling
87
+ * that the custom transport is expected to manage its own reconnect
88
+ * lifecycle.
89
+ */
90
+ get reconnect(): boolean;
22
91
  /**
23
92
  * Override the agent getter to return a wrapped client that ensures
24
93
  * the custom websocket implementation is used.
25
94
  */
26
- get agent(): AgentClient;
95
+ get agent(): AgentClientWithWebSockets;
27
96
  /**
28
97
  * Override the listen getter to return a wrapped client that ensures
29
98
  * the custom websocket implementation is used.
30
99
  */
31
- get listen(): ListenClient;
100
+ get listen(): ListenClientWithWebSockets;
32
101
  /**
33
102
  * Override the speak getter to return a wrapped client that ensures
34
103
  * the custom websocket implementation is used.
35
104
  */
36
- get speak(): SpeakClient;
105
+ get speak(): SpeakClientWithWebSockets;
37
106
  }