chore: rebuild release package and commit updates

This commit is contained in:
shiyue
2026-07-13 10:13:04 +08:00
parent dd466a69b5
commit 141a266f34
19 changed files with 1066 additions and 35 deletions

View File

@@ -6470,12 +6470,111 @@
}
}
function cleanCollabAgentText(value) {
return value == null ? '' : String(value).trim().replace(/\s+/g, ' ');
}
function summarizePrompt(prompt) {
const text = typeof prompt === 'string' ? prompt.trim().replace(/\s+/g, ' ') : '';
const text = cleanCollabAgentText(prompt);
if (!text) return '';
return text.length > 140 ? `${text.slice(0, 140)}` : text;
}
function isThreadLikeCollabAgentLabel(label, id) {
const value = cleanCollabAgentText(label);
if (!value) return false;
if (id && value === String(id)) return true;
const shortId = id ? shortChildAgentId(id) : '';
if (shortId && (value === shortId || value === `ID ${shortId}`)) return true;
const compact = value.toLowerCase();
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(compact)) return true;
if (/^(thread|child-thread|agent-thread|codex-thread)[-_:][a-z0-9][a-z0-9_.:-]{5,}$/i.test(value)) return true;
return !/\s/.test(value) && value.length >= 18 && /thread/i.test(value);
}
function isGenericCollabAgentLabel(label, id) {
const value = cleanCollabAgentText(label);
if (!value) return true;
if (/^子代理\s*\d*$/i.test(value)) return true;
if (/^(sub[-_\s]*agent|agent)\s*\d*$/i.test(value)) return true;
return isThreadLikeCollabAgentLabel(value, id);
}
function collabAgentTitleFromPrompt(prompt) {
const text = cleanCollabAgentText(prompt)
.replace(/^#+\s*/, '')
.replace(/^(任务|目标|请|请你|请帮我|帮我|负责|实现|处理)[:,\s]*/i, '')
.trim();
if (!text) return '';
const firstSegment = text.split(/[。.!?;:\n]/).find(Boolean) || text;
const title = firstSegment.trim();
if (!title) return '';
return title.length > 36 ? `${title.slice(0, 36)}` : title;
}
function collabAgentTaskDescription(state = {}, fallbackPrompt = '') {
return cleanCollabAgentText(
state.taskDescription
|| state.task_description
|| state.taskPrompt
|| state.task_prompt
|| state.prompt
|| state.inputPrompt
|| state.input_prompt
|| fallbackPrompt
);
}
function pickCollabAgentTitle(state, id, index) {
const taskDescription = cleanCollabAgentText(state?.taskDescription || state?.prompt || '');
const titleCandidates = [
state.label,
state.title,
state.nickname,
state.name,
];
for (const value of titleCandidates) {
const candidate = cleanCollabAgentText(value);
if (candidate && !isGenericCollabAgentLabel(candidate, id)) return candidate;
}
const promptTitle = collabAgentTitleFromPrompt(taskDescription);
if (promptTitle) return promptTitle;
return id ? `ID ${shortChildAgentId(id)}` : `子代理 ${index + 1}`;
}
function hasReadableCollabAgentTitle(state = {}, id = '') {
return [state.label, state.title, state.nickname, state.name].some((value) => {
const candidate = cleanCollabAgentText(value);
return candidate && !isGenericCollabAgentLabel(candidate, id);
});
}
function mergeCollabAgentTaskState(previousState = {}, incomingState = {}, fallbackPrompt = '', id = '', index = 0) {
const taskDescription = collabAgentTaskDescription(incomingState, fallbackPrompt)
|| cleanCollabAgentText(previousState.taskDescription);
const nextState = {
...previousState,
...incomingState,
taskDescription,
};
const incomingHasReadableSourceTitle = incomingState.hasReadableSourceTitle == null
? hasReadableCollabAgentTitle(incomingState, id)
: incomingState.hasReadableSourceTitle === true;
if (incomingHasReadableSourceTitle) {
nextState.label = pickCollabAgentTitle(incomingState, id, index);
} else {
['label', 'title', 'nickname', 'name'].forEach((key) => {
const previousValue = cleanCollabAgentText(previousState[key]);
if (previousValue && !isGenericCollabAgentLabel(previousValue, id)) nextState[key] = previousValue;
});
}
return {
...nextState,
label: pickCollabAgentTitle(nextState, id, index),
taskDescription,
};
}
function normalizeCollabAgentAction(value) {
const raw = String(value || '').trim();
if (!raw) return '';
@@ -6521,12 +6620,24 @@
if (!states || typeof states !== 'object') return [];
return Object.entries(states).map(([id, value], index) => {
const state = value && typeof value === 'object' ? value : { status: value };
const label = String(state.label || state.title || state.nickname || state.name || `子代理 ${index + 1}`);
const role = String(state.role || state.agent || state.agentType || '').trim();
let status = String(state.status || state.state || 'pending').trim() || 'pending';
const taskDescription = collabAgentTaskDescription(state, data?.prompt || '');
const label = pickCollabAgentTitle({ ...state, taskDescription }, id, index);
const role = cleanCollabAgentText(state.role || state.agent || state.agentType || '');
let status = cleanCollabAgentText(state.status || state.state || 'pending') || 'pending';
if (state.closedAt && collabStateTone(status) !== 'closed') status = 'closed';
const detail = String(state.candidateResult || state.finalMessage || state.summary || state.message || state.lastMessage || state.step || state.description || '').trim();
return { id, label, role, status, detail };
const detail = cleanCollabAgentText(state.candidateResult || state.finalMessage || state.result || state.output || state.summary || state.message || state.lastMessage || state.step || state.description || '');
return {
id,
label,
title: cleanCollabAgentText(state.title || ''),
nickname: cleanCollabAgentText(state.nickname || ''),
name: cleanCollabAgentText(state.name || ''),
role,
status,
detail,
taskDescription,
hasReadableSourceTitle: hasReadableCollabAgentTitle(state, id),
};
});
}
@@ -6604,13 +6715,6 @@
getClosedCollabAgentIdsFromTool(tool).forEach((id) => closedCollabAgentIds.add(id));
}
function isGenericCollabAgentLabel(label, id) {
const value = String(label || '').trim();
if (!value) return true;
if (/^子代理\s*\d+$/i.test(value)) return true;
return !!id && value === String(id);
}
function mergeCollabAgentTools(tools, options = {}) {
const list = Array.isArray(tools) ? tools.filter((tool) => toolKind(tool) === 'collab_agent_tool_call') : [];
if (list.length === 0) return null;
@@ -6639,9 +6743,15 @@
collabAgentStateEntries(data).forEach((entry) => {
if (!entry.id) return;
const nextState = mergeCollabAgentTaskState(
states[entry.id],
entry,
data.prompt,
entry.id,
receiverThreadIds.indexOf(entry.id)
);
states[entry.id] = {
...(states[entry.id] || {}),
...entry,
...nextState,
status: isCloseAction || localClosedIds.has(entry.id) ? 'closed' : entry.status,
};
if (collabStateTone(states[entry.id].status) === 'closed') localClosedIds.add(entry.id);
@@ -6649,9 +6759,15 @@
getCollabAgentIdsFromTool(tool).forEach((id) => {
if (!receiverThreadIds.includes(id)) receiverThreadIds.push(id);
const nextState = mergeCollabAgentTaskState(
states[id],
{},
data.prompt,
id,
receiverThreadIds.indexOf(id)
);
states[id] = {
...(states[id] || {}),
label: states[id]?.label || `子代理 ${receiverThreadIds.length}`,
...nextState,
status: isCloseAction || localClosedIds.has(id)
? 'closed'
: (data.status || states[id]?.status || (tool.done ? 'completed' : 'running')),
@@ -6662,7 +6778,7 @@
const fallbackId = tool.id || `tool-${toolIndex + 1}`;
receiverThreadIds.push(fallbackId);
states[fallbackId] = {
label: '子代理',
...mergeCollabAgentTaskState({}, { label: '子代理' }, data.prompt, fallbackId, toolIndex),
status: isCloseAction ? 'closed' : (data.status || (tool.done ? 'completed' : 'running')),
};
}
@@ -6670,8 +6786,7 @@
receiverThreadIds.forEach((id, index) => {
states[id] = {
...(states[id] || {}),
label: states[id]?.label || `子代理 ${index + 1}`,
...mergeCollabAgentTaskState(states[id], {}, '', id, index),
status: localClosedIds.has(id) ? 'closed' : (states[id]?.status || 'pending'),
};
});
@@ -6773,10 +6888,12 @@
list.className = 'collab-agent-list';
stateEntries.forEach((entry, index) => {
const tone = collabStateTone(entry.status);
const displayTitle = pickCollabAgentTitle(entry, entry.id, index);
const descriptionText = summarizePrompt(entry.taskDescription);
const item = document.createElement('div');
item.className = 'collab-agent-item';
item.title = [
entry.label || `子代理 ${index + 1}`,
displayTitle,
entry.role ? `角色: ${entry.role}` : '',
entry.detail ? `结果: ${entry.detail}` : '',
entry.id ? `ID: ${entry.id}` : '',
@@ -6800,9 +6917,7 @@
const label = document.createElement('div');
label.className = 'collab-agent-item-label';
label.textContent = !isGenericCollabAgentLabel(entry.label, entry.id)
? entry.label
: `ID ${shortChildAgentId(entry.id || '')}`;
label.textContent = pickCollabAgentTitle(entry, entry.id, index);
row.appendChild(label);
const chip = document.createElement('span');
@@ -6830,6 +6945,14 @@
}
item.appendChild(row);
if (descriptionText) {
const description = document.createElement('div');
description.className = 'collab-agent-item-description';
description.textContent = descriptionText;
description.title = entry.taskDescription;
item.appendChild(description);
}
if (entry.id || entry.role) {
const footer = document.createElement('div');
footer.className = 'collab-agent-item-footer';

View File

@@ -5629,10 +5629,12 @@ html[data-theme='coolvibe'] .settings-back:hover {
.collab-agent-item {
appearance: none;
max-width: 100%;
min-width: 0;
min-height: 40px;
flex: 1 1 220px;
display: inline-flex;
flex-direction: row;
align-items: center;
flex-direction: column;
align-items: stretch;
gap: 4px;
padding: 5px 10px;
border: 1px solid rgba(91, 126, 161, 0.16);
@@ -5646,11 +5648,13 @@ html[data-theme='coolvibe'] .settings-back:hover {
.collab-agent-item-row {
display: flex;
align-items: center;
min-width: 0;
gap: 4px;
}
.collab-agent-item-label {
flex: 1 1 auto;
min-width: 0;
max-width: 150px;
max-width: 220px;
font-size: 13px;
font-weight: 700;
color: var(--text-primary);
@@ -5669,6 +5673,17 @@ html[data-theme='coolvibe'] .settings-back:hover {
color: var(--text-secondary);
line-height: 1.55;
}
.collab-agent-item-description {
min-width: 0;
font-size: 12px;
line-height: 1.35;
color: var(--text-muted);
overflow: hidden;
overflow-wrap: anywhere;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.collab-agent-item-footer {
font-size: 11px;
color: var(--text-muted);
@@ -5766,12 +5781,19 @@ html[data-theme='coolvibe'] .settings-back:hover {
.collab-agent-header {
align-items: flex-start;
}
.collab-agent-list {
min-width: 0;
}
.collab-agent-title-wrap {
flex-wrap: wrap;
}
.collab-agent-actions {
margin-left: auto;
}
.collab-agent-item {
min-width: 0;
flex: 1 1 min(100%, 180px);
}
.collab-agent-item-label {
max-width: 96px;
}