chore: rebuild release package

This commit is contained in:
shiyue
2026-07-24 08:00:31 +08:00
parent e5059e97c4
commit 4ab02ae33b
15 changed files with 778 additions and 73 deletions

View File

@@ -24,6 +24,12 @@ const RUNTIME_TRUNCATED_HEAD = '[cc-web: 前文过长,已保留尾部以保护
const RUNTIME_TRUNCATED_TAIL = '\n[cc-web: 内容过长,已截断以保护服务稳定性]';
const CODEX_APP_PLAN_ITEM_TYPES = new Set(['plan', 'plan_list', 'planlist', 'todo', 'todo_list', 'todolist', 'task_list']);
const CODEX_APP_PLAN_TOOL_NAMES = new Set(['update_plan', 'plan', 'plan_list', 'todo_list', 'updateplan', 'todolist']);
const CODEX_APP_PLAN_UPDATE_METHODS = new Set([
'plan/updated',
'turn/plan/updated',
'item/plan/updated',
'item/todoList/updated',
]);
function createCodexAppRuntime(deps = {}) {
const {
@@ -208,8 +214,7 @@ function createCodexAppRuntime(deps = {}) {
};
}
function normalizeTodoListFromPlanItem(item) {
if (!isPlanLikeItem(item)) return null;
function planEntriesFromItem(item) {
const candidates = [
item.arguments,
item.input,
@@ -225,7 +230,13 @@ function createCodexAppRuntime(deps = {}) {
entries = extractPlanEntries(candidate);
if (entries) break;
}
if (!Array.isArray(entries)) return null;
return Array.isArray(entries) ? entries : null;
}
function normalizeTodoListFromPlanItem(item) {
if (!isPlanLikeItem(item)) return null;
const entries = planEntriesFromItem(item);
if (!entries) return null;
const items = entries
.map((entry) => {
const text = truncateEnd(planEntryText(entry), RUNTIME_TOOL_INPUT_MAX_CHARS);
@@ -244,6 +255,15 @@ function createCodexAppRuntime(deps = {}) {
};
}
function currentPlanStep(entries) {
const activeEntry = (Array.isArray(entries) ? entries : []).find((entry) => {
if (!entry || typeof entry !== 'object') return false;
const status = normalizeIdentifier(entry.status || entry.state);
return ['inprogress', 'in_progress', 'active', 'running', 'working'].includes(status);
});
return truncateEnd(planEntryText(activeEntry), RUNTIME_TOOL_INPUT_MAX_CHARS);
}
function isTodoListPlanDone(item, todoList) {
const status = normalizeIdentifier(item?.status || item?.state);
if (['completed', 'complete', 'done', 'success', 'succeeded', 'failed', 'error', 'cancelled', 'canceled'].includes(status)) {
@@ -272,6 +292,20 @@ function createCodexAppRuntime(deps = {}) {
};
}
function planUpdateFromNotification(notification = {}) {
if (!CODEX_APP_PLAN_UPDATE_METHODS.has(notification?.method)) return null;
const item = planUpdateItemFromParams(notification.params || {});
const todoList = normalizeTodoListFromPlanItem(item);
if (!todoList) return null;
return {
item,
todoList,
progress: todoList.progress,
currentStep: currentPlanStep(planEntriesFromItem(item)),
done: isTodoListPlanDone(item, todoList),
};
}
function cleanRuntimeText(value) {
return value == null ? '' : String(value).trim();
}
@@ -891,10 +925,10 @@ function createCodexAppRuntime(deps = {}) {
case 'turn/plan/updated':
case 'item/plan/updated':
case 'item/todoList/updated': {
const item = planUpdateItemFromParams(params);
const todoList = normalizeTodoListFromPlanItem(item);
if (!todoList) return { done: false };
updateToolResult(entry, sessionId, todoList.id, JSON.stringify(todoList, null, 2), isTodoListPlanDone(item, todoList), {
const planUpdate = planUpdateFromNotification(notification);
if (!planUpdate) return { done: false };
const { item, todoList } = planUpdate;
updateToolResult(entry, sessionId, todoList.id, JSON.stringify(todoList, null, 2), planUpdate.done, {
name: 'PlanList',
kind: 'todo_list',
input: todoList,
@@ -1000,6 +1034,7 @@ function createCodexAppRuntime(deps = {}) {
}
return {
planUpdateFromNotification,
processCodexAppNotification,
updateUsage,
};