@space3-npm/cybersoul-client 1.0.2 → 1.0.4

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.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CyberSoulClientConfig, InteractParams, DispatcherIntent, InteractResponse, CharacterState, ImageGenerationParams, VoiceGenerationParams } from "./types";
1
+ import { CyberSoulClientConfig, InteractParams, DispatcherIntent, InteractResponse, CharacterState, ImageGenerationParams, VoiceGenerationParams } from "./types.js";
2
2
  export declare class CyberSoulClient {
3
3
  private config;
4
4
  private llm;
@@ -44,5 +44,6 @@ export declare class CyberSoulClient {
44
44
  private fetchRemoteState;
45
45
  private _updateDynamicContextInternal;
46
46
  private generatePrimitive;
47
+ private normalizeRequestTypes;
47
48
  interact(params: InteractParams): Promise<InteractResponse>;
48
49
  }
package/dist/client.js CHANGED
@@ -1,5 +1,6 @@
1
- import { robustJsonParse } from "./utils/json.utils";
2
- import { MinimaxProvider } from "./providers/minimax.provider";
1
+ import { InteractRequestType } from "./types.js";
2
+ import { robustJsonParse } from "./utils/json.utils.js";
3
+ import { MinimaxProvider } from "./providers/minimax.provider.js";
3
4
  export class CyberSoulClient {
4
5
  config;
5
6
  llm;
@@ -123,13 +124,24 @@ export class CyberSoulClient {
123
124
  throw new Error(`Failed to generate ${type}`);
124
125
  return res.json();
125
126
  }
127
+ normalizeRequestTypes(requestTypes) {
128
+ if (!requestTypes || requestTypes.length === 0) {
129
+ return [InteractRequestType.AUTO];
130
+ }
131
+ const validRequestTypes = new Set(Object.values(InteractRequestType));
132
+ const invalidRequestTypes = requestTypes.filter((type) => !validRequestTypes.has(type));
133
+ if (invalidRequestTypes.length > 0) {
134
+ throw new Error(`Invalid requestTypes: ${invalidRequestTypes.join(", ")}. Allowed values: ${Object.values(InteractRequestType).join(", ")}`);
135
+ }
136
+ return requestTypes;
137
+ }
126
138
  async interact(params) {
127
139
  try {
128
140
  // 1. Sync remote context
129
141
  const state = await this.fetchRemoteState();
130
142
  // 2. Build local Prompt
131
- const types = params.requestTypes && params.requestTypes.length > 0 ? params.requestTypes : ["auto"];
132
- const isAuto = types.includes("auto");
143
+ const types = this.normalizeRequestTypes(params.requestTypes);
144
+ const isAuto = types.includes(InteractRequestType.AUTO);
133
145
  // Combine state info into a clean descriptive context
134
146
  const contextParts = [];
135
147
  if (state.active_event) {
@@ -169,7 +181,7 @@ ${isAuto
169
181
  - Always include 'textResponse'.
170
182
  - If the user explicitly asks to see a photo, look at you, or describing an action that warrants a photo, include 'imageParams'.
171
183
  - If the user wants to hear you, or if appropriate for a voice message, include 'voiceArgs'.`
172
- : `Requested types to fulfill: ${(params.requestTypes ?? []).join(", ")}`}
184
+ : `Requested types to fulfill: ${types.join(", ")}`}
173
185
  If the user's message shifts the emotional mood, establishes new nicknames, or warrants a relationship temperature change, you MUST include a 'stateUpdate' block. Temperature goes from 0 (cold/angry) to 100 (obsessively in love).
174
186
 
175
187
  Output JSON Schema:
@@ -229,7 +241,7 @@ Note: If "imageParams", "voiceArgs", or "stateUpdate" are not needed, set their
229
241
  let finalImageUrl = undefined;
230
242
  let finalAudioUrl = undefined;
231
243
  let finalDurationSec = undefined;
232
- const shouldGenerateImage = types.includes("image") || (isAuto && !!parsedIntent.imageParams);
244
+ const shouldGenerateImage = types.includes(InteractRequestType.IMAGE) || (isAuto && !!parsedIntent.imageParams);
233
245
  if (shouldGenerateImage) {
234
246
  mediaTasks.push(this.generatePrimitive("image", {
235
247
  ...parsedIntent.imageParams,
@@ -238,12 +250,12 @@ Note: If "imageParams", "voiceArgs", or "stateUpdate" are not needed, set their
238
250
  finalImageUrl = res.image_url;
239
251
  }));
240
252
  }
241
- const shouldGenerateVoice = types.includes("voice") || (isAuto && !!parsedIntent.voiceArgs);
253
+ const shouldGenerateVoice = types.includes(InteractRequestType.VOICE) || (isAuto && !!parsedIntent.voiceArgs);
242
254
  if (shouldGenerateVoice) {
243
- const dynamicArgs = { ...(parsedIntent.voiceArgs || {}) };
244
- if (params.voiceStyleOverride) {
245
- dynamicArgs.style_instruction = params.voiceStyleOverride;
246
- }
255
+ const dynamicArgs = {
256
+ ...(parsedIntent.voiceArgs || {}),
257
+ ...(params.voiceOverrides || {})
258
+ };
247
259
  mediaTasks.push(this.generatePrimitive("voice", {
248
260
  text: parsedIntent.textResponse,
249
261
  dynamicArgs,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './types';
2
- export * from './client';
3
- export * from './providers/minimax.provider';
1
+ export * from './types.js';
2
+ export * from './client.js';
3
+ export * from './providers/minimax.provider.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './types';
2
- export * from './client';
3
- export * from './providers/minimax.provider';
1
+ export * from './types.js';
2
+ export * from './client.js';
3
+ export * from './providers/minimax.provider.js';
@@ -1,4 +1,4 @@
1
- import { LLMConfig, BaseLLMProvider } from '../types';
1
+ import { LLMConfig, BaseLLMProvider } from '../types.js';
2
2
  export declare class MinimaxProvider implements BaseLLMProvider {
3
3
  private config;
4
4
  constructor(config: LLMConfig);
package/dist/types.d.ts CHANGED
@@ -8,16 +8,22 @@ export interface CyberSoulClientConfig {
8
8
  backendUrl: string;
9
9
  llmConfig: LLMConfig;
10
10
  }
11
+ export declare enum InteractRequestType {
12
+ AUTO = "auto",
13
+ TEXT = "text",
14
+ IMAGE = "image",
15
+ VOICE = "voice"
16
+ }
11
17
  export interface InteractParams {
12
18
  userMessage: string;
13
19
  localContext?: string;
14
- requestTypes?: string[];
20
+ requestTypes?: InteractRequestType[];
15
21
  history?: {
16
22
  role: string;
17
23
  content: string;
18
24
  }[];
19
- imageOverrides?: any;
20
- voiceStyleOverride?: string;
25
+ imageOverrides?: Partial<ImageGenerationParams>;
26
+ voiceOverrides?: Partial<VoiceGenerationParams['dynamicArgs']>;
21
27
  onTextReady?: (textResponse: string) => void;
22
28
  }
23
29
  export interface InteractResponse {
package/dist/types.js CHANGED
@@ -1 +1,7 @@
1
- export {};
1
+ export var InteractRequestType;
2
+ (function (InteractRequestType) {
3
+ InteractRequestType["AUTO"] = "auto";
4
+ InteractRequestType["TEXT"] = "text";
5
+ InteractRequestType["IMAGE"] = "image";
6
+ InteractRequestType["VOICE"] = "voice";
7
+ })(InteractRequestType || (InteractRequestType = {}));
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@space3-npm/cybersoul-client",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
8
14
  "files": [
9
15
  "dist"
10
16
  ],