@space3-npm/cybersoul-client 1.1.2 → 1.1.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.js +17 -7
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -10,7 +10,7 @@ export class CyberSoulClient {
|
|
|
10
10
|
maxRetries;
|
|
11
11
|
constructor(config) {
|
|
12
12
|
this.config = config;
|
|
13
|
-
this.requestTimeoutMs = config.requestTimeoutMs ??
|
|
13
|
+
this.requestTimeoutMs = config.requestTimeoutMs ?? 120000;
|
|
14
14
|
this.maxRetries = Math.max(0, config.maxRetries ?? 1);
|
|
15
15
|
// Setup Provider
|
|
16
16
|
if (config.llmConfig.provider === "minimax") {
|
|
@@ -50,9 +50,14 @@ export class CyberSoulClient {
|
|
|
50
50
|
return response;
|
|
51
51
|
}
|
|
52
52
|
catch (error) {
|
|
53
|
-
|
|
53
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
54
|
+
lastError = new Error(`Request timed out after ${this.requestTimeoutMs}ms: ${method} ${endpoint}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
lastError = error;
|
|
58
|
+
}
|
|
54
59
|
if (attempt >= retryLimit) {
|
|
55
|
-
throw
|
|
60
|
+
throw lastError;
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
finally {
|
|
@@ -226,15 +231,17 @@ You MUST output ONLY a valid JSON object matching this exact structure:
|
|
|
226
231
|
"acceptEvent": true,
|
|
227
232
|
"reason": "string (Why you accepted or declined, speaking in character)",
|
|
228
233
|
"requiresOutfitChange": false,
|
|
229
|
-
"selectedOutfitId": null
|
|
234
|
+
"selectedOutfitId": null,
|
|
235
|
+
"scheduledStartTimeStr": "HH:MM (Optional, 24-hour format if a specific time today is agreed upon, e.g., '14:30', otherwise null)"
|
|
230
236
|
}
|
|
231
237
|
|
|
232
238
|
Example Valid Answer:
|
|
233
239
|
{
|
|
234
240
|
"acceptEvent": true,
|
|
235
|
-
"reason": "Sure, I'd love to go to the cafe. It sounds relaxing.",
|
|
241
|
+
"reason": "Sure, I'd love to go to the cafe at 2:30 PM. It sounds relaxing.",
|
|
236
242
|
"requiresOutfitChange": false,
|
|
237
|
-
"selectedOutfitId": null
|
|
243
|
+
"selectedOutfitId": null,
|
|
244
|
+
"scheduledStartTimeStr": "14:30"
|
|
238
245
|
}
|
|
239
246
|
|
|
240
247
|
CRITICAL: Output MUST be ONLY valid JSON with no markdown block wrappers. Do NOT wrap the JSON in \`\`\`json or add conversational text.`;
|
|
@@ -265,6 +272,7 @@ CRITICAL: Output MUST be ONLY valid JSON with no markdown block wrappers. Do NOT
|
|
|
265
272
|
eventDescription: params.eventDescription,
|
|
266
273
|
durationMins: params.durationMins || 60,
|
|
267
274
|
outfitId: decisionData.requiresOutfitChange ? decisionData.selectedOutfitId : undefined,
|
|
275
|
+
scheduledStartTimeStr: decisionData.scheduledStartTimeStr || undefined,
|
|
268
276
|
};
|
|
269
277
|
const backendRes = await this.apiFetch("/api/v1/cyber-soul/characters/ondemand-event", {
|
|
270
278
|
method: "POST",
|
|
@@ -280,6 +288,7 @@ CRITICAL: Output MUST be ONLY valid JSON with no markdown block wrappers. Do NOT
|
|
|
280
288
|
reason: decisionData.reason,
|
|
281
289
|
requiresOutfitChange: decisionData.requiresOutfitChange,
|
|
282
290
|
selectedOutfitId: decisionData.selectedOutfitId,
|
|
291
|
+
scheduledStartTimeStr: decisionData.scheduledStartTimeStr || undefined,
|
|
283
292
|
};
|
|
284
293
|
}
|
|
285
294
|
catch (error) {
|
|
@@ -524,7 +533,7 @@ Output JSON Schema:
|
|
|
524
533
|
"textResponse": "The direct spoken dialogue in Chinese",
|
|
525
534
|
"stateUpdate": { "temperatureDelta": 1, "userNickname": "What you now call the user", "agentNickname": "What the user calls you", "talkingStyle": "Current mood/style of talking" },
|
|
526
535
|
"userAnalysis": { "newFactsLearned": [{ "category": "occupation", "value": "Software Engineer" }] },
|
|
527
|
-
"triggerEvent": { "eventDescription": "Going to a cafe", "durationMins": 60, "outfitId": "optional wardrobe ID to change into if appropriate" },
|
|
536
|
+
"triggerEvent": { "eventDescription": "Going to a cafe", "durationMins": 60, "outfitId": "optional wardrobe ID to change into if appropriate", "scheduledStartTimeStr": "HH:MM (Optional, 24-hour format if a specific time today is agreed upon, e.g., '14:30', otherwise null)" },
|
|
528
537
|
${this.getImageSchemaParams()},
|
|
529
538
|
${this.getVoiceSchemaFromState(state)}
|
|
530
539
|
}
|
|
@@ -578,6 +587,7 @@ Note: If "imageParams", "voiceArgs", "triggerEvent", or "userAnalysis" are not n
|
|
|
578
587
|
eventDescription: parsedIntent.triggerEvent.eventDescription,
|
|
579
588
|
durationMins: parsedIntent.triggerEvent.durationMins || 60,
|
|
580
589
|
outfitId: parsedIntent.triggerEvent.outfitId || undefined,
|
|
590
|
+
scheduledStartTimeStr: parsedIntent.triggerEvent.scheduledStartTimeStr || undefined,
|
|
581
591
|
}),
|
|
582
592
|
}).catch(e => console.error("[CyberSoulClient] Auto-triggered ondemandEvent failed:", e)));
|
|
583
593
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface OndemandEventResponse {
|
|
|
37
37
|
reason?: string;
|
|
38
38
|
requiresOutfitChange?: boolean;
|
|
39
39
|
selectedOutfitId?: string;
|
|
40
|
+
scheduledStartTimeStr?: string;
|
|
40
41
|
error?: string;
|
|
41
42
|
}
|
|
42
43
|
export interface WardrobeItem {
|
|
@@ -80,6 +81,7 @@ export interface DispatcherIntent {
|
|
|
80
81
|
eventDescription: string;
|
|
81
82
|
durationMins?: number;
|
|
82
83
|
outfitId?: string | null;
|
|
84
|
+
scheduledStartTimeStr?: string | null;
|
|
83
85
|
} | null;
|
|
84
86
|
}
|
|
85
87
|
export interface CoreMemory {
|