chore: rebuild CentOS 7 release package

This commit is contained in:
shiyue
2026-08-16 22:20:00 +08:00
parent 93641df1ad
commit 6ed8c7d30b
21 changed files with 2137 additions and 45 deletions

View File

@@ -7961,7 +7961,7 @@ function formatCodexGoalStatus(status) {
return normalized || 'updated';
}
function formatCodexGoalUsage(goal) {
function formatCodexGoalUsage(goal, options = {}) {
const normalized = normalizeCodexThreadGoal(goal);
if (!normalized) return 'Goal updated';
const parts = [`Goal ${formatCodexGoalStatus(normalized.status)}`];
@@ -7970,10 +7970,45 @@ function formatCodexGoalUsage(goal) {
} else if (normalized.tokensUsed > 0) {
parts.push(`${normalized.tokensUsed} tokens`);
}
const objective = normalized.objective ? `\n目标: ${normalized.objective}` : '';
const objective = options.includeObjective === false || !normalized.objective
? ''
: `\n目标: ${normalized.objective}`;
return `${parts.join(' · ')}${objective}`;
}
function persistCodexAppGoalDisplayMessage(session, command, source = {}) {
if (!session || command?.action !== 'set' || !command.objective) {
return { message: null, created: false, duplicate: false };
}
const messageId = goalString(source.clientMessageId || source.requestId) || crypto.randomUUID();
session.messages = Array.isArray(session.messages) ? session.messages : [];
const existing = session.messages.find((message) => message?.id === messageId);
if (existing) {
if (existing.ccwebGoalCommand?.action === 'set') {
return { message: existing, created: false, duplicate: true };
}
throw new Error(`Goal 展示消息 ID 冲突: ${messageId}`);
}
const timestamp = new Date().toISOString();
const message = {
id: messageId,
role: 'user',
content: command.objective,
attachments: [],
timestamp,
ccwebDisplayOnly: true,
ccwebGoalCommand: {
action: 'set',
requestId: goalString(source.requestId) || messageId,
},
};
session.messages.push(message);
session.updated = timestamp;
saveSession(session);
return { message, created: true, duplicate: false };
}
async function ensureCodexAppGoalThread(session) {
const clientResult = getCodexAppClient();
if (clientResult.error) throw new Error(clientResult.error);
@@ -8061,15 +8096,47 @@ async function handleCodexAppGoalSlashCommand(ws, text, session, source = {}) {
return;
}
let goalDisplayMessage = null;
if (command.action === 'set') {
try {
const persisted = persistCodexAppGoalDisplayMessage(session, command, source);
if (persisted.duplicate) {
sendGoalSystemMessage(ws, 'Goal 设置请求已处理。', {
sessionId: session.id,
tone: 'info',
transient: true,
autoDismissMs: 4000,
});
sendSessionList(ws);
return;
}
goalDisplayMessage = persisted.message;
sendGoalResponse(ws, {
type: 'session_message',
sessionId: session.id,
message: goalDisplayMessage,
});
} catch (err) {
sendGoalSystemMessage(ws, `Goal failed: ${err?.message || err}`, { sessionId: session.id }, { preserveComposerDraft: true });
return;
}
}
const activeGoalCommand = {
id: crypto.randomUUID(),
ws,
action: command.action,
goalMessageId: goalDisplayMessage?.id || null,
cancelled: false,
startedAt: new Date().toISOString(),
};
activeCodexAppGoalCommands.set(session.id, activeGoalCommand);
sendGoalSystemMessage(ws, '正在同步 Goal...', { sessionId: session.id });
sendGoalSystemMessage(ws, '正在同步 Goal...', {
sessionId: session.id,
tone: 'info',
transient: true,
autoDismissMs: 5000,
});
broadcastSessionList();
try {
@@ -8089,7 +8156,12 @@ async function handleCodexAppGoalSlashCommand(ws, text, session, source = {}) {
const response = await client.request('thread/goal/clear', { threadId }, 30000);
if (!isCurrentCodexAppGoalCommand(session.id, activeGoalCommand)) return;
const targetWs = activeGoalCommand.ws || ws;
sendGoalSystemMessage(targetWs, response?.cleared ? 'Goal cleared' : 'No goal to clear', { sessionId: session.id });
sendGoalSystemMessage(targetWs, response?.cleared ? 'Goal cleared' : 'No goal to clear', {
sessionId: session.id,
tone: 'info',
transient: true,
autoDismissMs: 4000,
});
sendSessionList(targetWs);
return;
}
@@ -8102,14 +8174,24 @@ async function handleCodexAppGoalSlashCommand(ws, text, session, source = {}) {
if (!isCurrentCodexAppGoalCommand(session.id, activeGoalCommand)) return;
const goal = normalizeCodexThreadGoal(response?.goal, threadId);
const targetWs = activeGoalCommand.ws || ws;
sendGoalSystemMessage(targetWs, goal ? formatCodexGoalUsage(goal) : 'Goal updated', { sessionId: session.id });
sendGoalSystemMessage(targetWs, goal ? formatCodexGoalUsage(goal, { includeObjective: false }) : 'Goal updated', {
sessionId: session.id,
tone: 'info',
transient: true,
autoDismissMs: 5000,
});
sendSessionList(targetWs);
} catch (err) {
const message = isCodexGoalUnsupportedError(err)
? '当前 Codex app-server 不支持 /goal请升级 Codex 或启用 goals feature。'
: `Goal failed: ${err?.message || err}`;
if (isCurrentCodexAppGoalCommand(session.id, activeGoalCommand)) {
sendGoalSystemMessage(activeGoalCommand.ws || ws, message, { sessionId: session.id }, { preserveComposerDraft: true });
sendGoalSystemMessage(activeGoalCommand.ws || ws, message, {
sessionId: session.id,
tone: 'danger',
transient: true,
autoDismissMs: 7000,
}, { preserveComposerDraft: !goalDisplayMessage });
}
} finally {
finishCodexAppGoalCommand(session.id, activeGoalCommand);