@ai-matrx/desktop-protocol 0.17.0 → 0.17.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.
package/dist/client.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BackoffOptions } from '@ai-matrx/realtime';
2
2
  export { RECONNECT_ALARM_ATTEMPTS } from '@ai-matrx/realtime';
3
3
  import { z } from 'zod';
4
- import { W as Welcome, D as DesktopProtocolError, C as CloseOutcome, O as OpName, a as OpParams, b as OpResult, c as OPS, S as StreamMeta, E as EndReason, d as EVENTS, e as ClientType, M as ModelsTranscribeResult, T as TranscriptionModelId, f as MlProgress } from './models-Dj_B9wHj.cjs';
5
- export { i as isDesktopProtocolError } from './models-Dj_B9wHj.cjs';
4
+ import { W as Welcome, D as DesktopProtocolError, C as CloseOutcome, O as OpName, a as OpParams, b as OpResult, c as OPS, S as StreamMeta, E as EndReason, d as EVENTS, e as ClientType, M as ModelsTranscribeResult, T as TranscriptionModelId, f as MlProgress } from './models-QWCUcQuU.cjs';
5
+ export { i as isDesktopProtocolError } from './models-QWCUcQuU.cjs';
6
6
  import { FrameHeader } from './frame.cjs';
7
7
 
8
8
  /** The subset of the WHATWG WebSocket the client uses — browser, React Native, `ws` and Workers all fit. */
package/dist/client.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BackoffOptions } from '@ai-matrx/realtime';
2
2
  export { RECONNECT_ALARM_ATTEMPTS } from '@ai-matrx/realtime';
3
3
  import { z } from 'zod';
4
- import { W as Welcome, D as DesktopProtocolError, C as CloseOutcome, O as OpName, a as OpParams, b as OpResult, c as OPS, S as StreamMeta, E as EndReason, d as EVENTS, e as ClientType, M as ModelsTranscribeResult, T as TranscriptionModelId, f as MlProgress } from './models-Dj_B9wHj.js';
5
- export { i as isDesktopProtocolError } from './models-Dj_B9wHj.js';
4
+ import { W as Welcome, D as DesktopProtocolError, C as CloseOutcome, O as OpName, a as OpParams, b as OpResult, c as OPS, S as StreamMeta, E as EndReason, d as EVENTS, e as ClientType, M as ModelsTranscribeResult, T as TranscriptionModelId, f as MlProgress } from './models-QWCUcQuU.js';
5
+ export { i as isDesktopProtocolError } from './models-QWCUcQuU.js';
6
6
  import { FrameHeader } from './frame.js';
7
7
 
8
8
  /** The subset of the WHATWG WebSocket the client uses — browser, React Native, `ws` and Workers all fit. */
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { RECONNECT_ALARM_ATTEMPTS, createBackoff } from "@ai-matrx/realtime";
3
3
 
4
4
  // src/error.ts
5
- var DesktopProtocolError = class extends Error {
5
+ var DesktopProtocolError = class _DesktopProtocolError extends Error {
6
6
  code;
7
7
  retryable;
8
8
  data;
@@ -13,6 +13,23 @@ var DesktopProtocolError = class extends Error {
13
13
  this.retryable = options.retryable ?? false;
14
14
  this.data = options.data;
15
15
  }
16
+ /**
17
+ * Any thrown value as a DesktopProtocolError, keeping its code, message and data. Each built entry
18
+ * (`.`, `./client`, `./react`) carries its own copy of this class, so `instanceof` alone misses an
19
+ * error thrown by a sibling entry and reports a real NOT_FOUND as INTERNAL; this checks the shape.
20
+ */
21
+ static from(caught) {
22
+ if (caught instanceof _DesktopProtocolError) return caught;
23
+ const e = caught;
24
+ if (e && typeof e === "object" && e.name === "DesktopProtocolError" && typeof e.code === "string") {
25
+ return new _DesktopProtocolError(e.code, typeof e.message === "string" ? e.message : String(e.code), {
26
+ retryable: e.retryable === true,
27
+ ...e.data && typeof e.data === "object" ? { data: e.data } : {},
28
+ cause: caught
29
+ });
30
+ }
31
+ return new _DesktopProtocolError("INTERNAL", caught instanceof Error ? caught.message : String(caught), { cause: caught });
32
+ }
16
33
  /** The wire body (ProtocolErrorBody) — what a core or relay sends for this error. */
17
34
  toBody() {
18
35
  return this.data === void 0 ? { code: this.code, message: this.message, retryable: this.retryable } : { code: this.code, message: this.message, retryable: this.retryable, data: this.data };