@space3-npm/cybersoul-client 1.4.16 → 1.4.17
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.js +20 -5
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +13 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InteractRequestType, } from "./types.js";
|
|
2
2
|
import { robustJsonParse } from "./utils/json.utils.js";
|
|
3
3
|
import { GenericLLMProvider } from "./llm.provider.js";
|
|
4
|
-
import { CyberSoulApiError, CyberSoulAuthError, CyberSoulError, CyberSoulInsufficientPointsError, CyberSoulNetworkError, CyberSoulTimeoutError, CyberSoulWalletError, } from "./errors.js";
|
|
4
|
+
import { CyberSoulApiError, CyberSoulAuthError, CyberSoulError, CyberSoulInsufficientPointsError, CyberSoulNetworkError, CyberSoulSensitiveContentError, CyberSoulTimeoutError, CyberSoulWalletError, } from "./errors.js";
|
|
5
5
|
export class CyberSoulClient {
|
|
6
6
|
config;
|
|
7
7
|
llm;
|
|
@@ -146,6 +146,9 @@ export class CyberSoulClient {
|
|
|
146
146
|
if (code === "WALLET_DEDUCTION_ERROR") {
|
|
147
147
|
throw new CyberSoulWalletError(endpoint, "POST", res.status, detailedMessage, errData, code);
|
|
148
148
|
}
|
|
149
|
+
if (code === "E005") {
|
|
150
|
+
throw new CyberSoulSensitiveContentError(endpoint, "POST", res.status, detailedMessage, errData, code);
|
|
151
|
+
}
|
|
149
152
|
if (res.status === 401 || res.status === 403) {
|
|
150
153
|
throw new CyberSoulAuthError(endpoint, "POST", res.status, detailedMessage, errData);
|
|
151
154
|
}
|
|
@@ -542,6 +545,14 @@ ${isProactive
|
|
|
542
545
|
affected,
|
|
543
546
|
};
|
|
544
547
|
}
|
|
548
|
+
if (err instanceof CyberSoulSensitiveContentError) {
|
|
549
|
+
return {
|
|
550
|
+
kind: "sensitive-content",
|
|
551
|
+
code: err.code,
|
|
552
|
+
message: err.message,
|
|
553
|
+
affected,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
545
556
|
return {
|
|
546
557
|
kind: "unknown",
|
|
547
558
|
message: err.message,
|
|
@@ -785,7 +796,8 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
|
|
|
785
796
|
if (!(e instanceof CyberSoulError))
|
|
786
797
|
return;
|
|
787
798
|
if (!(e instanceof CyberSoulInsufficientPointsError) &&
|
|
788
|
-
!(e instanceof CyberSoulWalletError)
|
|
799
|
+
!(e instanceof CyberSoulWalletError) &&
|
|
800
|
+
!(e instanceof CyberSoulSensitiveContentError)) {
|
|
789
801
|
return;
|
|
790
802
|
}
|
|
791
803
|
if (!mediaErrorAffected.includes(modality)) {
|
|
@@ -842,7 +854,8 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
|
|
|
842
854
|
})
|
|
843
855
|
.catch((e) => {
|
|
844
856
|
if (!(e instanceof CyberSoulInsufficientPointsError) &&
|
|
845
|
-
!(e instanceof CyberSoulWalletError)
|
|
857
|
+
!(e instanceof CyberSoulWalletError) &&
|
|
858
|
+
!(e instanceof CyberSoulSensitiveContentError)) {
|
|
846
859
|
console.error("[CyberSoulClient] Image generation failed:", e);
|
|
847
860
|
}
|
|
848
861
|
captureMediaError("image", e);
|
|
@@ -882,7 +895,8 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
|
|
|
882
895
|
})
|
|
883
896
|
.catch((e) => {
|
|
884
897
|
if (!(e instanceof CyberSoulInsufficientPointsError) &&
|
|
885
|
-
!(e instanceof CyberSoulWalletError)
|
|
898
|
+
!(e instanceof CyberSoulWalletError) &&
|
|
899
|
+
!(e instanceof CyberSoulSensitiveContentError)) {
|
|
886
900
|
console.error("[CyberSoulClient] Voice generation failed:", e);
|
|
887
901
|
}
|
|
888
902
|
captureMediaError("voice", e);
|
|
@@ -1197,7 +1211,8 @@ If "shouldSkipProactive" is false, "textResponse" is required and "stateUpdate"
|
|
|
1197
1211
|
}
|
|
1198
1212
|
catch (e) {
|
|
1199
1213
|
if (e instanceof CyberSoulInsufficientPointsError ||
|
|
1200
|
-
e instanceof CyberSoulWalletError
|
|
1214
|
+
e instanceof CyberSoulWalletError ||
|
|
1215
|
+
e instanceof CyberSoulSensitiveContentError) {
|
|
1201
1216
|
proactiveMediaError = e;
|
|
1202
1217
|
proactiveAffected.push("image");
|
|
1203
1218
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -80,3 +80,13 @@ export declare class CyberSoulWalletError extends CyberSoulApiError {
|
|
|
80
80
|
readonly code: string;
|
|
81
81
|
constructor(endpoint: string, method: string, status: number, message: string, body?: unknown, code?: string);
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* The backend rejected an image/voice generation request because the
|
|
85
|
+
* prompt (or the model's output) was flagged as sensitive / unsafe
|
|
86
|
+
* (backend code `E005`). The user can recover by sending a different
|
|
87
|
+
* prompt — there's nothing to retry automatically.
|
|
88
|
+
*/
|
|
89
|
+
export declare class CyberSoulSensitiveContentError extends CyberSoulApiError {
|
|
90
|
+
readonly code: string;
|
|
91
|
+
constructor(endpoint: string, method: string, status: number, message: string, body?: unknown, code?: string);
|
|
92
|
+
}
|
package/dist/errors.js
CHANGED
|
@@ -108,3 +108,16 @@ export class CyberSoulWalletError extends CyberSoulApiError {
|
|
|
108
108
|
this.code = code;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The backend rejected an image/voice generation request because the
|
|
113
|
+
* prompt (or the model's output) was flagged as sensitive / unsafe
|
|
114
|
+
* (backend code `E005`). The user can recover by sending a different
|
|
115
|
+
* prompt — there's nothing to retry automatically.
|
|
116
|
+
*/
|
|
117
|
+
export class CyberSoulSensitiveContentError extends CyberSoulApiError {
|
|
118
|
+
code;
|
|
119
|
+
constructor(endpoint, method, status, message, body, code = "E005") {
|
|
120
|
+
super(endpoint, method, status, message, body, "sensitive-content");
|
|
121
|
+
this.code = code;
|
|
122
|
+
}
|
|
123
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -191,7 +191,7 @@ export interface InteractResponse {
|
|
|
191
191
|
*/
|
|
192
192
|
export interface InteractMediaError {
|
|
193
193
|
/** Coarse kind so UIs can map to a single user-facing message. */
|
|
194
|
-
kind: "insufficient-points" | "wallet" | "unknown";
|
|
194
|
+
kind: "insufficient-points" | "wallet" | "sensitive-content" | "unknown";
|
|
195
195
|
/** Backend machine code when available (e.g. "INSUFFICIENT_POINTS"). */
|
|
196
196
|
code?: string;
|
|
197
197
|
/** Raw error message, for logs / diagnostics. */
|