release: prepare 0629001 portal updates
This commit is contained in:
@@ -4,6 +4,7 @@ import { resolveUserAddressName } from './user-publish.mjs';
|
||||
|
||||
export const USER_MEMORY_PROFILE_FILENAME = '.tkmind-profile.json';
|
||||
export const USER_MEMORY_PROFILE_VERSION = 1;
|
||||
const DEFAULT_TIMEZONE = 'Asia/Shanghai';
|
||||
|
||||
export function buildInitialUserMemoryProfile({
|
||||
userId,
|
||||
@@ -148,14 +149,50 @@ export function renderStoredUserMemoriesForHarness(memories) {
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
function formatDateParts(now, timezone) {
|
||||
const formatter = new Intl.DateTimeFormat('en-CA', {
|
||||
timeZone: timezone,
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
});
|
||||
const parts = Object.fromEntries(
|
||||
formatter.formatToParts(new Date(now)).map((part) => [part.type, part.value]),
|
||||
);
|
||||
return {
|
||||
year: parts.year ?? '0000',
|
||||
month: parts.month ?? '01',
|
||||
day: parts.day ?? '01',
|
||||
};
|
||||
}
|
||||
|
||||
export function renderCurrentTimeAnchor({ now = Date.now(), timezone = DEFAULT_TIMEZONE } = {}) {
|
||||
const { year, month, day } = formatDateParts(now, timezone);
|
||||
const weekday = new Intl.DateTimeFormat('zh-CN', {
|
||||
timeZone: timezone,
|
||||
weekday: 'long',
|
||||
}).format(new Date(now));
|
||||
return [
|
||||
'## TKMind 当前时间基准',
|
||||
'',
|
||||
`- 当前时区:${timezone}`,
|
||||
`- 当前日期:${year}-${month}-${day}(${weekday})`,
|
||||
'- 回答中涉及“今天 / 明天 / 后天 / 周几”时,必须以上述日期为准继续推算,不要自行假设当前日期。',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
export function buildSessionMemoryEntries({
|
||||
workingDir,
|
||||
sessionPolicy,
|
||||
sandboxConstraints = null,
|
||||
userContext = null,
|
||||
userMemories = null,
|
||||
now = Date.now(),
|
||||
}) {
|
||||
const entries = [];
|
||||
const timezone = String(
|
||||
userContext?.timezone ?? process.env.H5_DEFAULT_TIMEZONE ?? DEFAULT_TIMEZONE,
|
||||
).trim() || DEFAULT_TIMEZONE;
|
||||
|
||||
if (sandboxConstraints?.trim()) {
|
||||
entries.push({
|
||||
@@ -172,6 +209,11 @@ export function buildSessionMemoryEntries({
|
||||
});
|
||||
}
|
||||
|
||||
entries.push({
|
||||
title: 'TKMind 当前时间基准',
|
||||
content: renderCurrentTimeAnchor({ now, timezone }),
|
||||
});
|
||||
|
||||
if (!hasMemoryStore(sessionPolicy)) {
|
||||
return entries;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user