@mux/ai 0.14.0 → 0.15.1

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/index.d.ts CHANGED
@@ -9,7 +9,44 @@ import '@ai-sdk/anthropic';
9
9
  import '@ai-sdk/google';
10
10
  import '@ai-sdk/openai';
11
11
 
12
- var version = "0.14.0";
12
+ var version = "0.15.1";
13
+
14
+ type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error";
15
+ /**
16
+ * An error whose message is safe to surface verbatim to the customer.
17
+ *
18
+ * Uses a structural brand (`__robots_error = true`) so that downstream
19
+ * consumers can identify customer-safe errors via duck typing — no
20
+ * shared dependency required. Errors from @mux/ai that DON'T carry
21
+ * this brand (unexpected SDK failures, upstream provider errors, etc.)
22
+ * should be treated as internal and obfuscated.
23
+ *
24
+ * Own properties (`publicMessage`, `publicType`, `retryable`) survive
25
+ * JSON serialization across workflow step boundaries, unlike inherited
26
+ * `Error.message`.
27
+ */
28
+ declare class MuxAiError extends Error {
29
+ /** Structural brand for duck-type identification. */
30
+ readonly __robots_error = true;
31
+ /** Error category shown in the API response. */
32
+ readonly publicType: MuxAiErrorType;
33
+ /** Customer-facing message. Must be safe to show verbatim. */
34
+ readonly publicMessage: string;
35
+ /** Whether the customer should retry the job. */
36
+ readonly retryable: boolean;
37
+ constructor(message: string, opts?: {
38
+ type?: MuxAiErrorType;
39
+ retryable?: boolean;
40
+ });
41
+ }
42
+ /**
43
+ * Re-throws {@link MuxAiError} instances to preserve the structural brand,
44
+ * wraps everything else in a plain `Error` with a contextual message.
45
+ *
46
+ * Use this in catch blocks that re-throw so a customer-safe error from a
47
+ * callee isn't accidentally converted into an internal error.
48
+ */
49
+ declare function wrapError(error: unknown, message: string): never;
13
50
 
14
51
  /**
15
52
  * A function that returns workflow credentials, either synchronously or asynchronously.
@@ -45,4 +82,4 @@ declare class WorkflowStorageClient {
45
82
  }
46
83
  declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
47
84
 
48
- export { StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, setWorkflowCredentialsProvider, version };
85
+ export { MuxAiError, type MuxAiErrorType, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, setWorkflowCredentialsProvider, version, wrapError };