mirror of
https://github.com/xmanrui/OpenClaw-bot-review.git
synced 2026-08-14 00:47:49 +00:00
Fix identity emoji placeholder parsing
This commit is contained in:
@@ -13,6 +13,22 @@ const SUBAGENT_MAX_ACTIVE_MS = 10 * 60 * 1000
|
||||
const SUBAGENT_ACTIVITY_EVENT_LIMIT = 6
|
||||
const SUBAGENT_ACTIVITY_TEXT_MAX_LEN = 80
|
||||
|
||||
function normalizeIdentityValue(rawValue: string): string | null {
|
||||
let value = rawValue.trim()
|
||||
if (!value) return null
|
||||
|
||||
const placeholder = /^[_*`~\s]*\((?:your|pick|choose|fill|todo|tbd|填写|选择|待)[^)]*\)[_*`~\s]*/iu
|
||||
while (placeholder.test(value)) {
|
||||
value = value.replace(placeholder, '').replace(/^[-::,,\s]+/, '').trim()
|
||||
}
|
||||
if (!value) return null
|
||||
|
||||
const wrapped = value.match(/^([_*`])(.+)\1$/)
|
||||
if (wrapped) value = wrapped[2].trim()
|
||||
|
||||
return value || null
|
||||
}
|
||||
|
||||
type SessionsIndex = Record<string, { sessionId?: string; updatedAt?: number }>
|
||||
type CronStoreJob = {
|
||||
id: string
|
||||
@@ -996,8 +1012,12 @@ export async function GET() {
|
||||
if (existsSync(identityPath)) {
|
||||
try {
|
||||
const identityRaw = await fs.readFile(identityPath, 'utf8')
|
||||
const m = identityRaw.match(/\*\*Emoji:\*\*\s*(\S+)/)
|
||||
if (m?.[1]) agentJsonEmoji = m[1]
|
||||
const emojiLine = identityRaw.split(/\r?\n/).find((line) => /\*\*Emoji:\*\*/.test(line))
|
||||
const m = emojiLine?.match(/\*\*Emoji:\*\*\s*(.*)$/)
|
||||
if (m) {
|
||||
const emoji = normalizeIdentityValue(m[1])
|
||||
if (emoji) agentJsonEmoji = emoji
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,8 +264,12 @@ function readIdentityEmoji(agentId: string, agentDir?: string, workspace?: strin
|
||||
for (const p of candidates) {
|
||||
try {
|
||||
const content = fs.readFileSync(p, "utf-8");
|
||||
const match = content.match(/\*\*Emoji:\*\*\s*(\S+)/);
|
||||
if (match?.[1]) return match[1].trim();
|
||||
const emojiLine = content.split(/\r?\n/).find((line) => /\*\*Emoji:\*\*/.test(line));
|
||||
const match = emojiLine?.match(/\*\*Emoji:\*\*\s*(.*)$/);
|
||||
if (match) {
|
||||
const emoji = normalizeIdentityName(match[1]);
|
||||
if (emoji) return emoji;
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user