Bind Cursor typed-error constructor outside the native turn scope

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-09-29 09:44:37 -05:00
1 parent f49907f42c
commit 4eec13c06b
6 files changed
+24 -16

No files matched your search

@@ -5,7 +5,7 @@
"darwin-arm64": {
"url": "https://downloads.cursor.com/lab/2026.09.26-dd393fe/darwin/arm64/agent-cli-package.tar.gz",
"archiveSha256": "538827d96a779bab854a865c8e42859e8e87db34b5f69770261b90fc8cfff191",
"closureSha256": "89e28235685ab31d78779eccd5b6a7b2d9fec20181c439535f2fe492c5cd24da",
"closureSha256": "8a22016ca832ef8c8e6a83b955208d74c63f2c8dbe1dd688cbf27b81ad01886a",
"executable": "node",
"entrypoint": "index.js",
"vendorClosureSha256": "77394184a89b0e7384971181da19c3c82d83a399b04e7944b3f94fe3d7e62b25"
@@ -13,7 +13,7 @@
"darwin-x64": {
"url": "https://downloads.cursor.com/lab/2026.09.26-dd393fe/darwin/x64/agent-cli-package.tar.gz",
"archiveSha256": "ed1771c44cbf0f8059c67cac0d939e6a60eb730bd066d7dc4cbb14de314cfb6e",
"closureSha256": "6729c65acb6b2f56690ebe54e63659f4dc31b2b5814aff8d59740767ab43ad17",
"closureSha256": "2c461f48feb274f8e7aabd6da67d1e9aefbe6e0b232fc0a111dce874378afcc8",
"executable": "node",
"entrypoint": "index.js",
"vendorClosureSha256": "7c8775160af74e5fb8d25a30e8412c1a6476b0661529078a686e5118fd1c5e5f"
@@ -21,7 +21,7 @@
"linux-x64": {
"url": "https://downloads.cursor.com/lab/2026.09.26-dd393fe/linux/x64/agent-cli-package.tar.gz",
"archiveSha256": "8085fd120f5c71f4eae7fea26a043718e5644e3071e4fab3220a0e58c51f9593",
"closureSha256": "591623da24add49fc6572e6eba3039e21b40893024efc65fc547802e00cfec17",
"closureSha256": "4fe9461c19d1aec0cbbe4189159291fe62ef6910732a05fc5a25923afb1ce2c7",
"executable": "node",
"entrypoint": "index.js",
"vendorClosureSha256": "bf04ef8ea6a63191067a6b3e15139aa2c793d8419daab246aa3f0a012e1bbcd9"
@@ -6,9 +6,9 @@ import { join } from "node:path";
// Cursor adapter and the vendor's interactive CLI are not changed.
export const CURSOR_RUNTIME_PATCH_VERSION = "paperclip-cursor-isolation-v1";
export const CURSOR_RUNTIME_PATCH_PINS = Object.freeze({
"darwin-arm64": { file: "5672.index.js", before: "7784c8b16d4e639814c13b12be2a687f5dc2cd98cbf29ed0a10820778ab1bf62", after: "db997911906014ec9c522b48b6748bb39001e44d9a10730a433ab1e135aa0432" },
"darwin-x64": { file: "9841.index.js", before: "3c0aaf6ecc4fceb0f95e1731deec75384984570d14d0871cecec11972b948ac4", after: "713aecb34c994d83ce46942f6b15bff173eb7b605f15a4653b24b9cc46dd3b5a" },
"linux-x64": { file: "1699.index.js", before: "2de420f1b31e70ca74b083a1ce5b519c2abffa5789d71cc06e84d2c38acb7c07", after: "27e6e048b30afbf722c36cc3ef8ac4350957963291d15c34fdaea355d110ea2a" },
"darwin-arm64": { file: "5672.index.js", before: "7784c8b16d4e639814c13b12be2a687f5dc2cd98cbf29ed0a10820778ab1bf62", after: "c9e627bde091bd2559a45840f488d05dd7273100fa3ee3c32df1871e0357c0d4" },
"darwin-x64": { file: "9841.index.js", before: "3c0aaf6ecc4fceb0f95e1731deec75384984570d14d0871cecec11972b948ac4", after: "360ee9a5ad74a7b7a2e880d642a22f6b8841967bb1660654b6cd2b90313de988" },
"linux-x64": { file: "1699.index.js", before: "2de420f1b31e70ca74b083a1ce5b519c2abffa5789d71cc06e84d2c38acb7c07", after: "32f44c4981f5a26765e5101b389e3fcdb6e885b31a7ac876b68fd97afe078553" },
});
const digest = value => createHash("sha256").update(value).digest("hex");
@@ -38,7 +38,11 @@ export function patchCursorRuntimeSource(source, platform) {
// Use the exact SDK module already present in this verified vendor chunk.
const sdk = [...source.matchAll(/n\("([^"\n]+@agentclientprotocol\/sdk\/dist\/acp\.js)"\)/g)].map(match => match[1]);
if (new Set(sdk).size !== 1) throw new Error("Cursor runtime patch SDK identity is ambiguous");
const errorType = `n(${JSON.stringify(sdk[0])}).GI`;
const errorType = "paperclipCursorResponseError";
// processPrompt(e,t,n) shadows the webpack require name n. Bind the SDK
// constructor at module scope rather than invoking that turn-ID argument.
const sessionClass = platform === "darwin-arm64" ? "B" : "z";
replace(`n.d(t,{m:()=>${sessionClass}});var s=n("node:fs/promises")`, `n.d(t,{m:()=>${sessionClass}});const ${errorType}=n(${JSON.stringify(sdk[0])}).GI;var s=n("node:fs/promises")`);
const oldAction = 'if(e instanceof r.ao){const t=null!==(u={login:"Please sign in to continue",upgrade:"Upgrade your plan to continue",payment:"Add a payment method to continue",config:"Check your settings to continue"}[e.action])&&void 0!==u?u:e.message;return void(yield this.sendAgentMessageChunk(`\\n\\n${t}`))}';
const newAction = `if(e instanceof r.ao){const action=["login","upgrade","payment","config"].includes(e.action)?e.action:"unknown";throw new (${errorType})(action==="login"?-32000:-32603,"Cursor provider action required: "+action,{schema:"paperclip.cursor.provider-error.v1",kind:"action_required",action})}`;
replace(oldAction, newAction);
@@ -67,7 +67,9 @@ export async function qualifyCursorRuntimePatch(vendorRoot) {
class ActionRequired extends Error { constructor(action) { super("private provider detail"); this.action = action; } }
class ConnectError extends Error { constructor() { super("private auth detail"); this.code = 16; } }
class ResponseError extends Error { constructor(code, message, data) { super(message); this.code = code; this.data = data; } }
const evaluate = error => runInNewContext(`(function(){${errors}})()`, { e: error, r: { ao: ActionRequired }, g: { T: ConnectError }, m: { C: { Unauthenticated: 16 } }, f: { C: { Unauthenticated: 16 } }, n: () => ({ GI: ResponseError }) });
const binding = segment(source, "const paperclipCursorResponseError=", ";var s=");
assert.equal(runInNewContext(`${binding};paperclipCursorResponseError`, { n: () => ({ GI: ResponseError }) }), ResponseError);
const evaluate = error => runInNewContext(`(function(){${errors}})()`, { e: error, r: { ao: ActionRequired }, g: { T: ConnectError }, m: { C: { Unauthenticated: 16 } }, f: { C: { Unauthenticated: 16 } }, n: 123, paperclipCursorResponseError: ResponseError });
for (const action of ["login", "upgrade", "payment", "config", "other"]) {
assert.throws(() => evaluate(new ActionRequired(action)), error => error instanceof ResponseError
&& error.code === (action === "login" ? -32000 : -32603)
@@ -8,9 +8,9 @@ import { resolveRunnerProviderAssetsRoot } from "./provider-assets-root.js";
export const CURSOR_PINNED_VERSION = "2026.09.26-dd393fe";
const CLOSURE_PINS = Object.freeze({
"darwin-arm64": "89e28235685ab31d78779eccd5b6a7b2d9fec20181c439535f2fe492c5cd24da",
"darwin-x64": "6729c65acb6b2f56690ebe54e63659f4dc31b2b5814aff8d59740767ab43ad17",
"linux-x64": "591623da24add49fc6572e6eba3039e21b40893024efc65fc547802e00cfec17",
"darwin-arm64": "8a22016ca832ef8c8e6a83b955208d74c63f2c8dbe1dd688cbf27b81ad01886a",
"darwin-x64": "2c461f48feb274f8e7aabd6da67d1e9aefbe6e0b232fc0a111dce874378afcc8",
"linux-x64": "4fe9461c19d1aec0cbbe4189159291fe62ef6910732a05fc5a25923afb1ce2c7",
});
/** Trusted package assets only: no workspace, PATH, executable override or env root. */
@@ -14,7 +14,8 @@
"protocolVersion": 1,
"exitCode": 143,
"signal": null,
"error": ""
"error": "",
"closureSha256": "8a22016ca832ef8c8e6a83b955208d74c63f2c8dbe1dd688cbf27b81ad01886a"
},
{
"platform": "darwin-x64",
@@ -23,7 +24,8 @@
"protocolVersion": 1,
"exitCode": 143,
"signal": null,
"error": ""
"error": "",
"closureSha256": "2c461f48feb274f8e7aabd6da67d1e9aefbe6e0b232fc0a111dce874378afcc8"
}
]
}
@@ -8,7 +8,7 @@
"platform": "darwin-arm64",
"file": "5672.index.js",
"sourceSha256": "7784c8b16d4e639814c13b12be2a687f5dc2cd98cbf29ed0a10820778ab1bf62",
"patchedSha256": "db997911906014ec9c522b48b6748bb39001e44d9a10730a433ab1e135aa0432",
"patchedSha256": "c9e627bde091bd2559a45840f488d05dd7273100fa3ee3c32df1871e0357c0d4",
"driftRejected": true,
"fullChunkCompiles": true,
"ambientMcpAccesses": 0,
@@ -22,7 +22,7 @@
"platform": "darwin-x64",
"file": "9841.index.js",
"sourceSha256": "3c0aaf6ecc4fceb0f95e1731deec75384984570d14d0871cecec11972b948ac4",
"patchedSha256": "713aecb34c994d83ce46942f6b15bff173eb7b605f15a4653b24b9cc46dd3b5a",
"patchedSha256": "360ee9a5ad74a7b7a2e880d642a22f6b8841967bb1660654b6cd2b90313de988",
"driftRejected": true,
"fullChunkCompiles": true,
"ambientMcpAccesses": 0,
@@ -36,7 +36,7 @@
"platform": "linux-x64",
"file": "1699.index.js",
"sourceSha256": "2de420f1b31e70ca74b083a1ce5b519c2abffa5789d71cc06e84d2c38acb7c07",
"patchedSha256": "27e6e048b30afbf722c36cc3ef8ac4350957963291d15c34fdaea355d110ea2a",
"patchedSha256": "32f44c4981f5a26765e5101b389e3fcdb6e885b31a7ac876b68fd97afe078553",
"driftRejected": true,
"fullChunkCompiles": true,
"ambientMcpAccesses": 0,