chore: rebuild release package
This commit is contained in:
72
server.js
72
server.js
@@ -86,7 +86,6 @@ const LOGS_DIR = process.env.CC_WEB_LOGS_DIR || path.join(APP_DIR, 'logs');
|
||||
const ATTACHMENTS_DIR = path.join(SESSIONS_DIR, '_attachments');
|
||||
const ATTACHMENT_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
||||
const MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024;
|
||||
const MAX_MESSAGE_ATTACHMENTS = 4;
|
||||
const FILE_BROWSER_MAX_LIST_ENTRIES = 400;
|
||||
const FILE_BROWSER_MAX_PREVIEW_BYTES = 200 * 1024;
|
||||
const COMPOSER_SUGGESTION_LIMIT = 20;
|
||||
@@ -8021,7 +8020,7 @@ function handleMessage(ws, msg, options = {}) {
|
||||
};
|
||||
const textValue = typeof text === 'string' ? text : '';
|
||||
let runtimeTextValue = typeof options.runtimeText === 'string' ? options.runtimeText : textValue;
|
||||
const attachments = Array.isArray(msg.attachments) ? msg.attachments.slice(0, MAX_MESSAGE_ATTACHMENTS) : [];
|
||||
const attachments = Array.isArray(msg.attachments) ? msg.attachments : [];
|
||||
const normalizedText = textValue.trim();
|
||||
let normalizedRuntimeText = runtimeTextValue.trim();
|
||||
const resolvedAttachments = resolveMessageAttachments(attachments);
|
||||
@@ -8704,6 +8703,47 @@ function ccwebMcpChildPublicState(child = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function isCcwebMcpCollabToolCall(tool = {}) {
|
||||
if (!tool || typeof tool !== 'object') return false;
|
||||
const kind = String(tool.kind || tool.meta?.kind || '').trim();
|
||||
if (kind) return kind === 'collab_agent_tool_call';
|
||||
const input = parseMaybeJsonObject(tool.input) || (tool.input && typeof tool.input === 'object' ? tool.input : {});
|
||||
const result = parseMaybeJsonObject(tool.result) || (tool.result && typeof tool.result === 'object' ? tool.result : {});
|
||||
const action = codexAppCollabToolName(input.tool || result.tool || tool.tool || tool.name || tool.meta?.title || '');
|
||||
return ['spawn_agent', 'wait_agent', 'close_agent', 'send_input', 'resume_agent'].includes(action);
|
||||
}
|
||||
|
||||
function findExactCcwebMcpChildToolInToolCalls(toolCalls = [], spawnToolId = '') {
|
||||
const targetId = String(spawnToolId || '').trim();
|
||||
if (!targetId || !Array.isArray(toolCalls)) return null;
|
||||
return toolCalls.find((item) => item?.id === targetId && isCcwebMcpCollabToolCall(item)) || null;
|
||||
}
|
||||
|
||||
function findLatestCcwebMcpCollabToolInToolCalls(toolCalls = []) {
|
||||
if (!Array.isArray(toolCalls)) return null;
|
||||
for (let i = toolCalls.length - 1; i >= 0; i -= 1) {
|
||||
if (isCcwebMcpCollabToolCall(toolCalls[i])) return toolCalls[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function findCcwebMcpChildTargetToolInToolCalls(toolCalls = [], spawnToolId = '') {
|
||||
return findExactCcwebMcpChildToolInToolCalls(toolCalls, spawnToolId)
|
||||
|| findLatestCcwebMcpCollabToolInToolCalls(toolCalls);
|
||||
}
|
||||
|
||||
function findCcwebMcpChildTargetToolInMessages(messages = [], spawnToolId = '') {
|
||||
if (!Array.isArray(messages)) return null;
|
||||
let latestCollabTool = null;
|
||||
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
||||
const toolCalls = Array.isArray(messages[i]?.toolCalls) ? messages[i].toolCalls : [];
|
||||
const exactTool = findExactCcwebMcpChildToolInToolCalls(toolCalls, spawnToolId);
|
||||
if (exactTool) return exactTool;
|
||||
if (!latestCollabTool) latestCollabTool = findLatestCcwebMcpCollabToolInToolCalls(toolCalls);
|
||||
}
|
||||
return latestCollabTool;
|
||||
}
|
||||
|
||||
function mergeCcwebMcpChildIntoTool(tool, child) {
|
||||
if (!tool) return null;
|
||||
const candidateResult = child.finalMessage || child.candidateResult || '';
|
||||
@@ -8721,11 +8761,24 @@ function mergeCcwebMcpChildIntoTool(tool, child) {
|
||||
...(result.agentsStates && typeof result.agentsStates === 'object' ? result.agentsStates : {}),
|
||||
...(result.agents_states && typeof result.agents_states === 'object' ? result.agents_states : {}),
|
||||
};
|
||||
const previousState = agentsStates[child.threadId] && typeof agentsStates[child.threadId] === 'object' ? agentsStates[child.threadId] : {};
|
||||
const taskDescription = child.taskDescription
|
||||
|| child.task_description
|
||||
|| child.taskPrompt
|
||||
|| child.task_prompt
|
||||
|| child.prompt
|
||||
|| previousState.taskDescription
|
||||
|| previousState.task_description
|
||||
|| input.prompt
|
||||
|| result.prompt
|
||||
|| '';
|
||||
agentsStates[child.threadId] = {
|
||||
...(agentsStates[child.threadId] && typeof agentsStates[child.threadId] === 'object' ? agentsStates[child.threadId] : {}),
|
||||
...previousState,
|
||||
title: child.title || child.label || previousState.title || '',
|
||||
name: child.label || agentsStates[child.threadId]?.name || child.threadId,
|
||||
role: child.role || agentsStates[child.threadId]?.role || '',
|
||||
status: child.status || 'running',
|
||||
taskDescription,
|
||||
summary: ccwebMcpChildSummary(child),
|
||||
candidateResult,
|
||||
finalMessage: child.finalMessage || '',
|
||||
@@ -8755,15 +8808,12 @@ function mergeCcwebMcpChildIntoTool(tool, child) {
|
||||
|
||||
function updateCcwebMcpChildToolState(sessionId, child) {
|
||||
const entry = activeCodexAppTurns.get(sessionId) || null;
|
||||
let tool = entry?.toolCalls?.find((item) => item.id === child.spawnToolId) || null;
|
||||
let tool = findCcwebMcpChildTargetToolInToolCalls(entry?.toolCalls, child.spawnToolId);
|
||||
|
||||
if (!tool) {
|
||||
const session = loadSession(sessionId);
|
||||
const messages = Array.isArray(session?.messages) ? session.messages : [];
|
||||
for (let i = messages.length - 1; i >= 0 && !tool; i -= 1) {
|
||||
const list = Array.isArray(messages[i]?.toolCalls) ? messages[i].toolCalls : [];
|
||||
tool = list.find((item) => item.id === child.spawnToolId) || null;
|
||||
}
|
||||
tool = findCcwebMcpChildTargetToolInMessages(messages, child.spawnToolId);
|
||||
}
|
||||
return mergeCcwebMcpChildIntoTool(tool, child);
|
||||
}
|
||||
@@ -8771,11 +8821,7 @@ function updateCcwebMcpChildToolState(sessionId, child) {
|
||||
function updatePersistedCcwebMcpChildTool(sessionId, child) {
|
||||
const session = loadSession(sessionId);
|
||||
if (!session || !Array.isArray(session.messages)) return null;
|
||||
let targetTool = null;
|
||||
for (let i = session.messages.length - 1; i >= 0 && !targetTool; i -= 1) {
|
||||
const list = Array.isArray(session.messages[i]?.toolCalls) ? session.messages[i].toolCalls : [];
|
||||
targetTool = list.find((item) => item.id === child.spawnToolId) || null;
|
||||
}
|
||||
const targetTool = findCcwebMcpChildTargetToolInMessages(session.messages, child.spawnToolId);
|
||||
if (!mergeCcwebMcpChildIntoTool(targetTool, child)) return null;
|
||||
session.updated = new Date().toISOString();
|
||||
if (!findViewingSessionWs(sessionId)) session.hasUnread = true;
|
||||
|
||||
Reference in New Issue
Block a user