Merge branch 'master' into gitea/new_feature

This commit is contained in:
2026-07-30 23:14:05 +07:00
252 changed files with 20302 additions and 4337 deletions

View File

@@ -128,7 +128,8 @@ export function buildCursorHeaders(accessToken, machineId = null, ghostMode = tr
"x-amzn-trace-id": `Root=${crypto.randomUUID()}`,
"x-client-key": clientKey,
"x-cursor-checksum": checksum,
"x-cursor-client-version": "3.1.0",
"x-cursor-client-version": "3.12.17",
"x-cursor-client-commit": "0fb762053c34788bb7760d5673f8a6d4c8589d50",
"x-cursor-client-type": "ide",
"x-cursor-client-os": os,
"x-cursor-client-arch": arch,

View File

@@ -42,6 +42,14 @@ function findFirstUserIndex(history) {
return history.findIndex((item) => item?.userInputMessage);
}
function hasToolResults(message) {
return !!message?.userInputMessage?.userInputMessageContext?.toolResults?.length;
}
function canReplaceSessionStart(history, firstUserIndex) {
return firstUserIndex === 0 && !hasToolResults(history[firstUserIndex]);
}
function rememberSessionStart(key, entry) {
if (sessionStartStore.size >= MAX_SESSION_STARTS) {
sessionStartStore.delete(sessionStartStore.keys().next().value);
@@ -73,10 +81,13 @@ export function applyKiroSessionReplay({
existing.lastUsed = Date.now();
const firstUserIndex = findFirstUserIndex(baseHistory);
const sessionStart = ensureUserMessageModelId(clone(existing.sessionStart), modelId);
if (firstUserIndex >= 0) {
if (canReplaceSessionStart(baseHistory, firstUserIndex)) {
baseHistory[firstUserIndex] = sessionStart;
} else {
baseHistory.unshift(sessionStart);
if (baseHistory.length === 1) {
baseHistory.push({ assistantResponseMessage: { content: "..." } });
}
}
return {
history: ensureHistoryModelIds(baseHistory, modelId),
@@ -88,10 +99,18 @@ export function applyKiroSessionReplay({
const firstUserIndex = findFirstUserIndex(baseHistory);
let sessionStart;
let nextCurrent = ensureUserMessageModelId(baseCurrent, modelId);
if (firstUserIndex >= 0) {
if (canReplaceSessionStart(baseHistory, firstUserIndex)) {
sessionStart = prefixUserMessage(baseHistory[firstUserIndex], contentPrefix, modelId);
baseHistory[firstUserIndex] = clone(sessionStart);
nextCurrent = prefixUserMessage(baseCurrent, currentContentPrefix, modelId);
} else if (firstUserIndex >= 0) {
sessionStart = prefixUserMessage(
{ userInputMessage: { content: "", modelId } },
contentPrefix,
modelId
);
baseHistory.unshift(clone(sessionStart));
nextCurrent = prefixUserMessage(baseCurrent, currentContentPrefix, modelId);
} else {
sessionStart = prefixUserMessage(baseCurrent, contentPrefix, modelId);
nextCurrent = clone(sessionStart);