chore: rebuild CentOS7 release package
This commit is contained in:
@@ -23,6 +23,32 @@ function createAgentRuntime(deps) {
|
||||
getRuntimeSessionId,
|
||||
} = deps;
|
||||
|
||||
function readRuntimePositiveIntEnv(name, fallback, options = {}) {
|
||||
const raw = Number.parseInt(String(processEnv?.[name] || ''), 10);
|
||||
const min = Number.isFinite(options.min) ? options.min : 1;
|
||||
const max = Number.isFinite(options.max) ? options.max : Number.MAX_SAFE_INTEGER;
|
||||
if (!Number.isFinite(raw) || raw <= 0) return fallback;
|
||||
return Math.max(min, Math.min(max, raw));
|
||||
}
|
||||
|
||||
const RUNTIME_FULL_TEXT_MAX_CHARS = readRuntimePositiveIntEnv(
|
||||
'CC_WEB_RUNTIME_FULL_TEXT_MAX_CHARS',
|
||||
256 * 1024,
|
||||
{ min: 4096 },
|
||||
);
|
||||
const RUNTIME_TRUNCATED_HEAD = '[cc-web: 前文过长,已保留尾部以保护服务稳定性]\n';
|
||||
|
||||
function keepTail(value, maxLen) {
|
||||
const text = String(value || '');
|
||||
if (!Number.isFinite(maxLen) || maxLen <= 0 || text.length <= maxLen) return text;
|
||||
const keep = Math.max(0, maxLen - RUNTIME_TRUNCATED_HEAD.length);
|
||||
return `${RUNTIME_TRUNCATED_HEAD}${text.slice(-keep)}`;
|
||||
}
|
||||
|
||||
function appendCappedText(current, addition, maxLen = RUNTIME_FULL_TEXT_MAX_CHARS) {
|
||||
return keepTail(`${String(current || '')}${String(addition || '')}`, maxLen);
|
||||
}
|
||||
|
||||
function tomlString(value) {
|
||||
return JSON.stringify(String(value || ''));
|
||||
}
|
||||
@@ -330,7 +356,7 @@ function createAgentRuntime(deps) {
|
||||
? (/\n\s*$/.test(currentText) ? `\n${createAgentMessageDivider()}\n\n` : `\n\n${createAgentMessageDivider()}\n\n`)
|
||||
: '';
|
||||
const chunk = separator + nextText;
|
||||
entry.fullText += chunk;
|
||||
entry.fullText = appendCappedText(entry.fullText || '', chunk);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@@ -383,7 +409,7 @@ function createAgentRuntime(deps) {
|
||||
|
||||
for (const block of content) {
|
||||
if (block.type === 'text' && block.text) {
|
||||
entry.fullText += block.text;
|
||||
entry.fullText = appendCappedText(entry.fullText || '', block.text);
|
||||
sendRuntime(entry, sessionId, { type: 'text_delta', text: block.text });
|
||||
} else if (block.type === 'tool_use') {
|
||||
const toolInput = sanitizeToolInput(block.name, block.input);
|
||||
|
||||
Reference in New Issue
Block a user