@space3-npm/cybersoul-client 1.4.21 → 1.4.23
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 +5 -0
- package/dist/client.js +49 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export declare class CyberSoulClient {
|
|
|
29
29
|
private _updateDynamicContextInternal;
|
|
30
30
|
private normalizeRequestTypes;
|
|
31
31
|
private getElapsedTimeInfo;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate time period from a timestamp.
|
|
34
|
+
* Pre-computes morning/afternoon/evening to reduce LLM cognitive load.
|
|
35
|
+
*/
|
|
36
|
+
private getTimePeriodInfo;
|
|
32
37
|
private buildStateContextPrompt;
|
|
33
38
|
private normalizeOngoingSceneState;
|
|
34
39
|
private getImageSchemaParams;
|
package/dist/client.js
CHANGED
|
@@ -258,6 +258,41 @@ export class CyberSoulClient {
|
|
|
258
258
|
displayStr = `${Math.floor(elapsedMins)} mins`;
|
|
259
259
|
return { elapsedMs, elapsedMins, elapsedHours, elapsedDays, elapsedYears, displayStr };
|
|
260
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Calculate time period from a timestamp.
|
|
263
|
+
* Pre-computes morning/afternoon/evening to reduce LLM cognitive load.
|
|
264
|
+
*/
|
|
265
|
+
getTimePeriodInfo(timeMs) {
|
|
266
|
+
const date = new Date(timeMs);
|
|
267
|
+
const hour = parseInt(date.toLocaleString("zh-CN", {
|
|
268
|
+
timeZone: "Asia/Shanghai",
|
|
269
|
+
hour: "2-digit",
|
|
270
|
+
hour12: false,
|
|
271
|
+
}).split(":")[0]);
|
|
272
|
+
let period;
|
|
273
|
+
if (hour >= 6 && hour < 9) {
|
|
274
|
+
period = "Early Morning";
|
|
275
|
+
}
|
|
276
|
+
else if (hour >= 9 && hour < 12) {
|
|
277
|
+
period = "Late Morning";
|
|
278
|
+
}
|
|
279
|
+
else if (hour >= 12 && hour < 13) {
|
|
280
|
+
period = "Noon";
|
|
281
|
+
}
|
|
282
|
+
else if (hour >= 13 && hour < 18) {
|
|
283
|
+
period = "Afternoon";
|
|
284
|
+
}
|
|
285
|
+
else if (hour >= 18 && hour < 19) {
|
|
286
|
+
period = "Evening";
|
|
287
|
+
}
|
|
288
|
+
else if (hour >= 19 && hour < 23) {
|
|
289
|
+
period = "Night";
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
period = "Late Night";
|
|
293
|
+
}
|
|
294
|
+
return { hour, period };
|
|
295
|
+
}
|
|
261
296
|
buildStateContextPrompt(state, isProactive = false) {
|
|
262
297
|
const dyn = state.dynamic_context || {};
|
|
263
298
|
const stage = state.relationship_stage || "NEUTRAL";
|
|
@@ -275,8 +310,21 @@ Communication Style: ${state.communication_style || "None"}
|
|
|
275
310
|
Interaction Boundaries: ${state.interaction_boundaries || "None"}`);
|
|
276
311
|
// [2] SITUATIONAL CONTEXT
|
|
277
312
|
const currentTimeMs = state.current_time ? new Date(state.current_time).getTime() : Date.now();
|
|
313
|
+
const timePeriod = this.getTimePeriodInfo(currentTimeMs);
|
|
314
|
+
const currentDate = new Date(currentTimeMs);
|
|
315
|
+
const timeStr = currentDate.toLocaleString("en-US", {
|
|
316
|
+
timeZone: "Asia/Shanghai",
|
|
317
|
+
weekday: "long",
|
|
318
|
+
year: "numeric",
|
|
319
|
+
month: "long",
|
|
320
|
+
day: "numeric",
|
|
321
|
+
hour: "2-digit",
|
|
322
|
+
minute: "2-digit",
|
|
323
|
+
second: "2-digit",
|
|
324
|
+
hour12: false,
|
|
325
|
+
});
|
|
278
326
|
contextParts.push(`\n[SITUATIONAL CONTEXT]
|
|
279
|
-
Current time: ${
|
|
327
|
+
Current time: ${timeStr} (${timePeriod.period})`);
|
|
280
328
|
if (dyn.lastInteractionAt) {
|
|
281
329
|
contextParts.push(`Last interaction at: ${new Date(dyn.lastInteractionAt).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" })}`);
|
|
282
330
|
}
|