@space3-npm/cybersoul-client 1.4.16 → 1.4.18

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 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,
@@ -605,7 +616,14 @@ ${isProactive
605
616
  - 'textResponse' is ALWAYS REQUIRED.
606
617
  - The modalities you are ALLOWED to dynamically include: ${requestedOthers.length > 0 ? requestedOthers.join(", ") : "None (Only text is allowed)"}. Do not include other modalities.`;
607
618
  if (requestedOthers.includes(InteractRequestType.IMAGE)) {
608
- modalitiesInstruction += `\n - Include 'imageParams' for visual/photo requests or key visual moments during active events; explicitly describe current clothing/exposure in image fields. CRITICAL POLICY: Guard your privacy! If the user feels like a stranger (low Familiarity) AND your Mood/Temperature is cool/distant (< 50), ALWAYS set 'imageParams' to null and naturally decline. If your Temperature is warm/high (>= 50), you may choose to share a picture if requested or if it fits naturally, even if you just met.`;
619
+ modalitiesInstruction += `\n - IMAGE POLICY: The DEFAULT is to set 'imageParams' to null. Sending a picture is the EXCEPTION, not the norm. Real people do not send a photo every time they reply.
620
+ Only set 'imageParams' to a non-null object when AT LEAST ONE of these triggers fires for the VERY LAST USER MESSAGE:
621
+ (a) The user EXPLICITLY asks for a photo / selfie / picture this turn.
622
+ (b) A genuine NEW visual moment just happened this turn — i.e. a clearly new scene, new location, new outfit, or a distinctly new physical pose/expression that was NOT already shown in any previous turn's image.
623
+ (c) An active event JUST started or just hit a visually distinct new beat.
624
+ REPETITION GATE (hard): Prior assistant turns that already carried a picture are tagged with a [Sent Image] marker in '[CHAT HISTORY]'. If at least one prior assistant turn has a [Sent Image] marker AND the current scene/outfit/pose matches the 'Last Known Scene' line (i.e. nothing visually new has happened since), set 'imageParams' to null. Do NOT send near-duplicate pictures just because mood is high — high Temperature is NOT a trigger by itself.
625
+ PRIVACY GATE: Even when a trigger fires, if the user feels like a stranger (low Familiarity) AND your Mood/Temperature is cool/distant (< 50), set 'imageParams' to null and naturally decline. Temperature and Familiarity only GATE permission when a trigger has already fired; they never justify an image on their own.
626
+ When you do include 'imageParams', explicitly describe current clothing/exposure in the image fields.`;
609
627
  }
610
628
  else {
611
629
  modalitiesInstruction += `\n - ALWAYS set 'imageParams' to null. If the user explicitly asks for a picture, FIRMLY decline naturally in your 'textResponse' (e.g., say you absolutely cannot right now). NEVER pretend to send one, and NEVER give in no matter how many times they ask.`;
@@ -785,7 +803,8 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
785
803
  if (!(e instanceof CyberSoulError))
786
804
  return;
787
805
  if (!(e instanceof CyberSoulInsufficientPointsError) &&
788
- !(e instanceof CyberSoulWalletError)) {
806
+ !(e instanceof CyberSoulWalletError) &&
807
+ !(e instanceof CyberSoulSensitiveContentError)) {
789
808
  return;
790
809
  }
791
810
  if (!mediaErrorAffected.includes(modality)) {
@@ -842,7 +861,8 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
842
861
  })
843
862
  .catch((e) => {
844
863
  if (!(e instanceof CyberSoulInsufficientPointsError) &&
845
- !(e instanceof CyberSoulWalletError)) {
864
+ !(e instanceof CyberSoulWalletError) &&
865
+ !(e instanceof CyberSoulSensitiveContentError)) {
846
866
  console.error("[CyberSoulClient] Image generation failed:", e);
847
867
  }
848
868
  captureMediaError("image", e);
@@ -882,7 +902,8 @@ Note: Always include "isEndTurn". If "imageParams", "voiceArgs", "triggerEvent",
882
902
  })
883
903
  .catch((e) => {
884
904
  if (!(e instanceof CyberSoulInsufficientPointsError) &&
885
- !(e instanceof CyberSoulWalletError)) {
905
+ !(e instanceof CyberSoulWalletError) &&
906
+ !(e instanceof CyberSoulSensitiveContentError)) {
886
907
  console.error("[CyberSoulClient] Voice generation failed:", e);
887
908
  }
888
909
  captureMediaError("voice", e);
@@ -1197,7 +1218,8 @@ If "shouldSkipProactive" is false, "textResponse" is required and "stateUpdate"
1197
1218
  }
1198
1219
  catch (e) {
1199
1220
  if (e instanceof CyberSoulInsufficientPointsError ||
1200
- e instanceof CyberSoulWalletError) {
1221
+ e instanceof CyberSoulWalletError ||
1222
+ e instanceof CyberSoulSensitiveContentError) {
1201
1223
  proactiveMediaError = e;
1202
1224
  proactiveAffected.push("image");
1203
1225
  }
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. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@space3-npm/cybersoul-client",
3
- "version": "1.4.16",
3
+ "version": "1.4.18",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",