fix: 1.1.45 地区闸门不再因单个 CDN 噪声 IP 误拦第二轮。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-10-02 02:35:24 +08:00
1 parent 11aa390cc3
commit 8ba88623a0
4 files changed
+69 -4

No files matched your search

+40
View File
@@ -3750,6 +3750,46 @@ const NEW_TOOL_PATCHES = [
],
markers: ["[dsh-purge] guard undefined messages"],
},
{
id: 68,
name: "SYSTEM_NODES_CONTENT_GUARD",
layer: "代码",
layer_en: "Code",
desc: "systemNodes/derive 对缺 content 兜底,避免回退后第二轮 gateway/internal / guard missing message content",
file: ["agent-loop", "session"],
replacements: [
{
pattern:
"function textOf(message) {\n" +
"\tconst [block] = message.content;\n" +
"\treturn message.content.length === 1 && block?.type === \"text\" ? block.text : void 0;\n" +
"}",
replace:
"function textOf(message) {\n" +
"\tconst content = Array.isArray(message?.content) ? message.content : [];\n" +
"\tconst [block] = content;\n" +
"\treturn content.length === 1 && block?.type === \"text\" ? block.text : void 0; // [dsh-purge] guard undefined content\n" +
"}",
},
{
pattern: "\t\t\tconst text = event.data.message.content.length === 0 ? \"\" : textOf(event.data.message);",
replace:
"\t\t\tconst content = event.data?.message?.content;\n" +
"\t\t\tconst text = !Array.isArray(content) || content.length === 0 ? \"\" : textOf(event.data.message); // [dsh-purge] guard undefined content",
},
{
pattern: "\t\t\tif (event.data.message.content.length === 0) return null;",
replace:
"\t\t\tif (!Array.isArray(event.data?.message?.content) || event.data.message.content.length === 0) return null; // [dsh-purge] guard undefined content",
},
{
pattern: "\t\t\tif (firstAttempt) for (const message of decision.messages) this.session.append(\"user/message\", message, { surfaceOp: \"append\" });",
replace:
"\t\t\tif (firstAttempt) for (const message of (Array.isArray(decision.messages) ? decision.messages : [])) this.session.append(\"user/message\", message, { surfaceOp: \"append\" }); // [dsh-purge] guard undefined messages",
},
],
markers: ["[dsh-purge] guard undefined content"],
},
{
id: 56,
name: "REWIND_HIDE_CUT_ONLY",
+18 -3
View File
@@ -518,6 +518,23 @@ function taskHit(label, kind) {
return { label, kind };
}
/** 多地址域名:不能只因其中一个解析到受控地区就整站拦死(CDN/多线常见)。 */
function rangeHitFromAddresses(addresses) {
const pub = [];
for (const raw of addresses || []) {
const address = String(raw || "").trim();
if (!address || isOwnNetwork(address)) continue;
pub.push(address);
}
if (pub.length === 0) return false;
let blocked = 0;
for (const address of pub) {
if (regionOfIp(address)) blocked += 1;
}
// 严格过半才按地区命中;1/14、1/2 这种 CDN/多线噪声放过。
return blocked * 2 > pub.length;
}
/** 纯判断:后缀优先,Cloudflare 只放过还没被后缀命中的名字。厂商看 NS,也看地址的反向名字。 */
export function decisionFromLookup({ host, addresses = [], nameservers = [], pointers = [] } = {}) {
const name = hostOf(host);
@@ -525,9 +542,7 @@ export function decisionFromLookup({ host, addresses = [], nameservers = [], poi
if (regionOfSuffix(name)) return taskHit(name, "domain");
if (isIp(name)) return regionOfIp(name) ? taskHit(name, "range") : null;
if (coveredByCloudflare(addresses, nameservers)) return null;
for (const address of addresses) {
if (regionOfIp(address)) return taskHit(name, "range");
}
if (rangeHitFromAddresses(addresses)) return taskHit(name, "range");
if (nsHit(nameservers, VENDOR_NS) || nsHit(pointers, VENDOR_NS)) return taskHit(name, "server");
return null;
}
+7 -1
View File
@@ -340,7 +340,13 @@ export function wrapSessionDeriveMessages(session) {
if (!session || typeof session.deriveMessages !== "function" || session.__dshPurgeRewindDerive) return session;
const orig = session.deriveMessages.bind(session);
session.deriveMessages = function deriveMessagesWithoutRewind() {
const messages = orig();
let messages;
try {
messages = orig();
} catch {
// 回退后偶发 event.data.message.content 为空,官方 derive 读 .length 会直接炸掉。
return [];
}
if (!Array.isArray(messages)) return [];
return messages.filter((message) => !isRewindDerivedMessage(message));
};
+4
View File
@@ -8,6 +8,8 @@
- 进模型前剥掉外层 ChatML / `<project_instructions>` 壳,避免模型把真实 system 注入当成项目说明。
- 组装后的系统提示段统一保证 `text` 为字符串;不再会话钉死整段 sections,避免第二轮 `renderPrompt` 读 `undefined.length` 直接死掉并报 `(gateway/internal)`。
- `agent/pre-step` 始终把 `decision.messages` 规范成数组,避免第二轮发送时读空 messages 炸掉。
- 地区闸门:多地址域名不能只因其中一个解析到受控地区就整站拦死(CDN/多线噪声 IP)。
- 回退后 `deriveMessages` / `systemNodes` 对缺 `content` 做兜底,避免回退再发送时 `(gateway/internal)`。
- 清洗进度:未定位宿主时不再显示吓人的 `0/63`;本机不需要或组件未装的项计入已就绪,避免假的 `48/63`。
- 点「应用」就会写入默认提示词并注入,框空时用内置默认,不必先点保存。
- 更新并重新加密默认提示词。
@@ -21,6 +23,8 @@
- Strip outer ChatML / `<project_instructions>` wrappers before the text reaches the model, so a real system inject is not read as project instructions.
- Sanitize assembled system-prompt sections so `text` is always a string; stop pinning full sections for a session, which could make the second turn crash in `renderPrompt` on `undefined.length` with `(gateway/internal)`.
- Always normalize `decision.messages` to an array in `agent/pre-step`, so a second send does not die on a missing messages list.
- Region gate: multi-address hosts are no longer blocked just because one resolved IP is in a controlled region (CDN/noise).
- After rewind, `deriveMessages` / `systemNodes` tolerate missing `content`, so resend no longer fails with `(gateway/internal)`.
- Clean progress: do not show a scary `0/63` before the host is located; items not needed on this install count as ready, so a fake `48/63` no longer appears.
- Apply writes and injects the default prompt; an empty box uses the bundled default, so a separate Save is not required.
- Refresh and re-encrypt the bundled default prompt.