chore: rebuild release package

This commit is contained in:
shiyue
2026-07-17 11:29:51 +08:00
parent 5c3401292d
commit fa15b54469
8 changed files with 448 additions and 7 deletions

View File

@@ -364,6 +364,47 @@ function completeTurn(thread, turnId, text, status = 'completed') {
thread.steers = [];
}
function completeTurnWithoutTerminalNotification(thread, turnId, text) {
if (thread.activeTurnId !== turnId) return;
const responseText = `Codex App stale turn output: ${text}`;
send({
method: 'item/agentMessage/delta',
params: {
threadId: thread.id,
turnId,
itemId: 'agent-msg',
delta: responseText,
},
});
send({
method: 'item/completed',
params: {
threadId: thread.id,
turnId,
completedAtMs: Date.now(),
item: {
id: 'agent-msg',
type: 'agentMessage',
content: [{ type: 'text', text: responseText }],
status: 'completed',
},
},
});
send({
method: 'thread/tokenUsage/updated',
params: {
threadId: thread.id,
turnId,
tokenUsage: tokenUsage(text),
},
});
// 模拟 app-server 已结束内部 turn但终态通知在传输中丢失。
thread.activeTurnId = null;
thread.timer = null;
thread.steers = [];
}
function completeGoalBackgroundTurn(thread, objective) {
const turnId = `goal-turn-${crypto.randomUUID()}`;
const text = `Goal background output: ${objective}`;
@@ -685,6 +726,26 @@ function startTurn(params) {
},
});
if (/^codexapp stale running first$/i.test(text)) {
completeTurnWithoutTerminalNotification(thread, turnId, text);
return { turn: { id: turnId, status: 'running', items: [] } };
}
if (/^codexapp expected turn mismatch first$/i.test(text)) {
send({
method: 'item/agentMessage/delta',
params: {
threadId: thread.id,
turnId,
itemId: 'agent-msg',
delta: `Codex App expected turn mismatch fixture: ${text}`,
},
});
// 保留一个不同的活动 turn确保 steer 返回“不匹配”而不是“无活动 turn”。
thread.activeTurnId = `app-turn-mismatch-${crypto.randomUUID()}`;
return { turn: { id: turnId, status: 'running', items: [] } };
}
if (/runtime warning/i.test(text)) {
const message = 'Heads up: Long threads and multiple compactions can cause the model to be less accurate. Start a new thread when possible to keep threads small and targeted.';
for (let i = 0; i < 2; i += 1) {
@@ -819,7 +880,15 @@ function interruptTurn(params) {
function steerTurn(params) {
const thread = ensureThread(params.threadId, params);
if (!thread.activeTurnId || thread.activeTurnId !== params.expectedTurnId) {
if (!thread.activeTurnId) {
return {
error: {
code: -32001,
message: 'no active turn to steer',
},
};
}
if (thread.activeTurnId !== params.expectedTurnId) {
return {
error: {
code: -32001,