@cursorpool-dev/cli 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cursor-pool.mjs +9 -0
- package/bin/cursor-pool.ts +169 -0
- package/node_modules/@cursor-pool/extension/dist/extension.js +2910 -0
- package/node_modules/@cursor-pool/extension/package.json +64 -0
- package/node_modules/@cursor-pool/extension/resources/cursor-pool.svg +6 -0
- package/node_modules/@cursor-pool/extension/src/api.ts +545 -0
- package/node_modules/@cursor-pool/extension/src/extension.ts +104 -0
- package/node_modules/@cursor-pool/extension/src/index.ts +1 -0
- package/node_modules/@cursor-pool/extension/src/panel.ts +569 -0
- package/node_modules/@cursor-pool/extension/src/runtime.ts +22 -0
- package/node_modules/@cursor-pool/extension/test/panel.test.ts +1785 -0
- package/node_modules/@cursor-pool/patcher/package.json +17 -0
- package/node_modules/@cursor-pool/patcher/src/alwaysLocalMarker.ts +86 -0
- package/node_modules/@cursor-pool/patcher/src/hash.ts +7 -0
- package/node_modules/@cursor-pool/patcher/src/index.ts +55 -0
- package/node_modules/@cursor-pool/patcher/src/marker.ts +159 -0
- package/node_modules/@cursor-pool/patcher/src/patchCursorAgentExec.ts +154 -0
- package/node_modules/@cursor-pool/patcher/src/patchCursorAlwaysLocal.ts +142 -0
- package/node_modules/@cursor-pool/patcher/src/patchCursorWorkbenchAuthGate.ts +140 -0
- package/node_modules/@cursor-pool/patcher/src/restoreCursorAgentExec.ts +52 -0
- package/node_modules/@cursor-pool/patcher/src/restoreCursorAlwaysLocal.ts +52 -0
- package/node_modules/@cursor-pool/patcher/src/restoreCursorWorkbenchAuthGate.ts +70 -0
- package/node_modules/@cursor-pool/patcher/src/workbenchAuthGateMarker.ts +243 -0
- package/node_modules/@cursor-pool/patcher/test/patchCursorAgentExec.test.ts +630 -0
- package/node_modules/@cursor-pool/patcher/test/patchCursorAlwaysLocal.test.ts +144 -0
- package/node_modules/@cursor-pool/patcher/test/patchCursorWorkbench.test.ts +770 -0
- package/node_modules/@cursor-pool/patcher/test/restoreCursorAgentExec.test.ts +139 -0
- package/node_modules/@cursor-pool/service/package.json +17 -0
- package/node_modules/@cursor-pool/service/src/canary.ts +61 -0
- package/node_modules/@cursor-pool/service/src/diagnostics.ts +385 -0
- package/node_modules/@cursor-pool/service/src/entry.ts +161 -0
- package/node_modules/@cursor-pool/service/src/health.ts +10 -0
- package/node_modules/@cursor-pool/service/src/index.ts +29 -0
- package/node_modules/@cursor-pool/service/src/metadata.ts +22 -0
- package/node_modules/@cursor-pool/service/src/platformSession.ts +1178 -0
- package/node_modules/@cursor-pool/service/src/requestCheck.ts +81 -0
- package/node_modules/@cursor-pool/service/src/requestGate.ts +100 -0
- package/node_modules/@cursor-pool/service/src/requestGateway.ts +441 -0
- package/node_modules/@cursor-pool/service/src/runtime.ts +48 -0
- package/node_modules/@cursor-pool/service/src/server.ts +939 -0
- package/node_modules/@cursor-pool/service/src/takeover.ts +111 -0
- package/node_modules/@cursor-pool/service/test/canary.test.ts +140 -0
- package/node_modules/@cursor-pool/service/test/diagnostics.test.ts +506 -0
- package/node_modules/@cursor-pool/service/test/metadata.test.ts +63 -0
- package/node_modules/@cursor-pool/service/test/platformSession.test.ts +2428 -0
- package/node_modules/@cursor-pool/service/test/requestCheck.test.ts +152 -0
- package/node_modules/@cursor-pool/service/test/requestGate.test.ts +207 -0
- package/node_modules/@cursor-pool/service/test/requestGateway.test.ts +466 -0
- package/node_modules/@cursor-pool/service/test/runtime.test.ts +47 -0
- package/node_modules/@cursor-pool/service/test/server.test.ts +2570 -0
- package/node_modules/@cursor-pool/shared/package.json +17 -0
- package/node_modules/@cursor-pool/shared/src/clientConfig.ts +49 -0
- package/node_modules/@cursor-pool/shared/src/index.ts +14 -0
- package/node_modules/@cursor-pool/shared/src/manifest.ts +36 -0
- package/node_modules/@cursor-pool/shared/src/metadata.ts +19 -0
- package/node_modules/@cursor-pool/shared/src/paths.ts +5 -0
- package/node_modules/@cursor-pool/shared/src/runtime.ts +3 -0
- package/node_modules/@cursor-pool/shared/test/index.test.ts +56 -0
- package/node_modules/@cursor-pool/shared/test/manifest.test.ts +65 -0
- package/node_modules/@cursor-pool/shared/test/metadata.test.ts +25 -0
- package/node_modules/@cursor-pool/shared/test/runtime.test.ts +8 -0
- package/package.json +28 -0
- package/src/adHocResign.ts +65 -0
- package/src/autostart.ts +240 -0
- package/src/compat.ts +282 -0
- package/src/confirm.ts +76 -0
- package/src/cursor.ts +94 -0
- package/src/diagnostics.ts +558 -0
- package/src/environment.ts +18 -0
- package/src/extensionBundle.ts +111 -0
- package/src/extensionLink.ts +168 -0
- package/src/index.ts +23 -0
- package/src/install.ts +614 -0
- package/src/installRecord.ts +105 -0
- package/src/launch.ts +182 -0
- package/src/patchSet.ts +182 -0
- package/src/platform.ts +132 -0
- package/src/repair.ts +383 -0
- package/src/restore.ts +153 -0
- package/src/serviceCommands.ts +79 -0
- package/src/serviceProcess.ts +188 -0
- package/src/status.ts +241 -0
- package/src/target.ts +37 -0
- package/src/trial.ts +133 -0
- package/src/uninstall.ts +213 -0
- package/test/autostart.test.ts +151 -0
- package/test/compat.test.ts +192 -0
- package/test/confirm.test.ts +114 -0
- package/test/cursor-pool-bin.test.ts +658 -0
- package/test/cursor.test.ts +20 -0
- package/test/diagnostics.test.ts +709 -0
- package/test/e2e-install.test.ts +773 -0
- package/test/extensionBundle.test.ts +161 -0
- package/test/extensionLink.test.ts +209 -0
- package/test/install.test.ts +862 -0
- package/test/installRecord.test.ts +107 -0
- package/test/launch.test.ts +138 -0
- package/test/platform.test.ts +226 -0
- package/test/repair.test.ts +575 -0
- package/test/restore.test.ts +211 -0
- package/test/serviceCommands.test.ts +135 -0
- package/test/serviceProcess.test.ts +280 -0
- package/test/status.test.ts +615 -0
- package/test/target.test.ts +49 -0
- package/test/trial.test.ts +146 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { basename, dirname, join } from 'node:path';
|
|
5
|
+
import { joinCursorAppPath } from '@cursor-pool/shared/paths';
|
|
6
|
+
import { DEFAULT_RUNTIME_DIR } from '@cursor-pool/shared/runtime';
|
|
7
|
+
import { sha256File } from './hash';
|
|
8
|
+
import {
|
|
9
|
+
containsAnyCursorWorkbenchAuthGateMarkerText,
|
|
10
|
+
containsCursorWorkbenchAuthGateMarker,
|
|
11
|
+
injectCursorWorkbenchAuthGatePatch,
|
|
12
|
+
} from './workbenchAuthGateMarker';
|
|
13
|
+
|
|
14
|
+
export const CURSOR_WORKBENCH_RELATIVE_PATH =
|
|
15
|
+
'Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js';
|
|
16
|
+
|
|
17
|
+
export type PatchCursorWorkbenchAuthGateOptions = {
|
|
18
|
+
backupDir?: string;
|
|
19
|
+
patchContent?: (content: string) => string;
|
|
20
|
+
targetRelativePath?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type PatchCursorWorkbenchAuthGateResult = {
|
|
24
|
+
targetPath: string;
|
|
25
|
+
backupPath: string;
|
|
26
|
+
beforeHash: string;
|
|
27
|
+
afterHash: string;
|
|
28
|
+
markerPresent: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function resolveHomePath(path: string) {
|
|
32
|
+
if (path.startsWith('~/')) {
|
|
33
|
+
return join(homedir(), path.slice(2));
|
|
34
|
+
}
|
|
35
|
+
return path;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function resolveBackupDir(backupDir = join(DEFAULT_RUNTIME_DIR, 'backups')) {
|
|
39
|
+
return resolveHomePath(backupDir);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function resolveCursorWorkbenchPath(
|
|
43
|
+
appPath: string,
|
|
44
|
+
targetRelativePath = CURSOR_WORKBENCH_RELATIVE_PATH,
|
|
45
|
+
) {
|
|
46
|
+
return joinCursorAppPath(appPath, targetRelativePath);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function backupPathForCursorWorkbenchAuthGate(
|
|
50
|
+
appPath: string,
|
|
51
|
+
targetPath = resolveCursorWorkbenchPath(appPath),
|
|
52
|
+
backupDir?: string,
|
|
53
|
+
) {
|
|
54
|
+
const appPathHash = createHash('sha256').update(appPath).digest('hex').slice(0, 16);
|
|
55
|
+
const targetPathHash = createHash('sha256')
|
|
56
|
+
.update(targetPath)
|
|
57
|
+
.digest('hex')
|
|
58
|
+
.slice(0, 16);
|
|
59
|
+
return join(
|
|
60
|
+
resolveBackupDir(backupDir),
|
|
61
|
+
`${basename(appPath).replaceAll('/', '_')}-${appPathHash}-${targetPathHash}.workbench.desktop.main.js.bak`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function readBackupContent(backupPath: string) {
|
|
66
|
+
try {
|
|
67
|
+
return await readFile(backupPath, 'utf8');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
70
|
+
throw new Error(`Workbench auth gate patch backup is missing: ${backupPath}`);
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function validateUnpatchedBackup(backupPath: string) {
|
|
77
|
+
const backupContent = await readBackupContent(backupPath);
|
|
78
|
+
if (containsAnyCursorWorkbenchAuthGateMarkerText(backupContent)) {
|
|
79
|
+
throw new Error(`Workbench auth gate patch backup contains patch marker and is unsafe: ${backupPath}`);
|
|
80
|
+
}
|
|
81
|
+
return backupContent;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function patchCursorWorkbenchAuthGate(
|
|
85
|
+
appPath: string,
|
|
86
|
+
options: PatchCursorWorkbenchAuthGateOptions = {},
|
|
87
|
+
): Promise<PatchCursorWorkbenchAuthGateResult> {
|
|
88
|
+
const targetPath = resolveCursorWorkbenchPath(appPath, options.targetRelativePath);
|
|
89
|
+
const beforeHash = await sha256File(targetPath);
|
|
90
|
+
const backupPath = await backupPathForCursorWorkbenchAuthGate(
|
|
91
|
+
appPath,
|
|
92
|
+
targetPath,
|
|
93
|
+
options.backupDir,
|
|
94
|
+
);
|
|
95
|
+
const content = await readFile(targetPath, 'utf8');
|
|
96
|
+
|
|
97
|
+
if (containsCursorWorkbenchAuthGateMarker(content)) {
|
|
98
|
+
await validateUnpatchedBackup(backupPath);
|
|
99
|
+
return {
|
|
100
|
+
targetPath,
|
|
101
|
+
backupPath,
|
|
102
|
+
beforeHash,
|
|
103
|
+
afterHash: beforeHash,
|
|
104
|
+
markerPresent: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
await mkdir(dirname(backupPath), { recursive: true });
|
|
109
|
+
const isLegacyPatched = containsAnyCursorWorkbenchAuthGateMarkerText(content);
|
|
110
|
+
if (isLegacyPatched) {
|
|
111
|
+
await validateUnpatchedBackup(backupPath);
|
|
112
|
+
} else {
|
|
113
|
+
await copyFile(targetPath, backupPath);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const patchBaseContent = isLegacyPatched ? await readBackupContent(backupPath) : content;
|
|
118
|
+
const patchedContent = (options.patchContent ?? injectCursorWorkbenchAuthGatePatch)(patchBaseContent);
|
|
119
|
+
await writeFile(targetPath, patchedContent, 'utf8');
|
|
120
|
+
|
|
121
|
+
const afterHash = await sha256File(targetPath);
|
|
122
|
+
const markerPresent = containsCursorWorkbenchAuthGateMarker(
|
|
123
|
+
await readFile(targetPath, 'utf8'),
|
|
124
|
+
);
|
|
125
|
+
if (!markerPresent) {
|
|
126
|
+
throw new Error('Workbench auth gate patch did not write a valid patch marker pair.');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
targetPath,
|
|
131
|
+
backupPath,
|
|
132
|
+
beforeHash,
|
|
133
|
+
afterHash,
|
|
134
|
+
markerPresent,
|
|
135
|
+
};
|
|
136
|
+
} catch (error) {
|
|
137
|
+
await copyFile(backupPath, targetPath);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { copyFile, readFile } from 'node:fs/promises';
|
|
2
|
+
import { sha256File } from './hash';
|
|
3
|
+
import {
|
|
4
|
+
containsAnyCursorPoolMarkerText,
|
|
5
|
+
containsCursorPoolMarker,
|
|
6
|
+
} from './marker';
|
|
7
|
+
import {
|
|
8
|
+
backupPathForCursorAgentExec,
|
|
9
|
+
resolveCursorAgentExecPath,
|
|
10
|
+
validateUnpatchedBackup,
|
|
11
|
+
type PatchCursorAgentExecOptions,
|
|
12
|
+
} from './patchCursorAgentExec';
|
|
13
|
+
|
|
14
|
+
export type RestoreCursorAgentExecResult = {
|
|
15
|
+
targetPath: string;
|
|
16
|
+
backupPath: string;
|
|
17
|
+
beforeHash: string;
|
|
18
|
+
afterHash: string;
|
|
19
|
+
markerPresent: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export async function restoreCursorAgentExec(
|
|
23
|
+
appPath: string,
|
|
24
|
+
options: Pick<PatchCursorAgentExecOptions, 'backupDir' | 'targetRelativePath'> = {},
|
|
25
|
+
): Promise<RestoreCursorAgentExecResult> {
|
|
26
|
+
const targetPath = resolveCursorAgentExecPath(appPath, options.targetRelativePath);
|
|
27
|
+
const beforeHash = await sha256File(targetPath);
|
|
28
|
+
const backupPath = await backupPathForCursorAgentExec(
|
|
29
|
+
appPath,
|
|
30
|
+
targetPath,
|
|
31
|
+
options.backupDir,
|
|
32
|
+
);
|
|
33
|
+
await validateUnpatchedBackup(backupPath);
|
|
34
|
+
|
|
35
|
+
await copyFile(backupPath, targetPath);
|
|
36
|
+
|
|
37
|
+
const afterHash = await sha256File(targetPath);
|
|
38
|
+
const restoredContent = await readFile(targetPath, 'utf8');
|
|
39
|
+
const markerPresent = containsCursorPoolMarker(restoredContent);
|
|
40
|
+
|
|
41
|
+
if (containsAnyCursorPoolMarkerText(restoredContent)) {
|
|
42
|
+
throw new Error('Restore result still contains patch marker text.');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
targetPath,
|
|
47
|
+
backupPath,
|
|
48
|
+
beforeHash,
|
|
49
|
+
afterHash,
|
|
50
|
+
markerPresent,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { copyFile, readFile } from 'node:fs/promises';
|
|
2
|
+
import {
|
|
3
|
+
containsAnyCursorAlwaysLocalTakeoverMarkerText,
|
|
4
|
+
containsCursorAlwaysLocalTakeoverMarker,
|
|
5
|
+
} from './alwaysLocalMarker';
|
|
6
|
+
import { sha256File } from './hash';
|
|
7
|
+
import {
|
|
8
|
+
backupPathForCursorAlwaysLocal,
|
|
9
|
+
resolveCursorAlwaysLocalPath,
|
|
10
|
+
validateUnpatchedAlwaysLocalBackup,
|
|
11
|
+
type PatchCursorAlwaysLocalOptions,
|
|
12
|
+
} from './patchCursorAlwaysLocal';
|
|
13
|
+
|
|
14
|
+
export type RestoreCursorAlwaysLocalResult = {
|
|
15
|
+
targetPath: string;
|
|
16
|
+
backupPath: string;
|
|
17
|
+
beforeHash: string;
|
|
18
|
+
afterHash: string;
|
|
19
|
+
markerPresent: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export async function restoreCursorAlwaysLocal(
|
|
23
|
+
appPath: string,
|
|
24
|
+
options: Pick<PatchCursorAlwaysLocalOptions, 'backupDir' | 'targetRelativePath'> = {},
|
|
25
|
+
): Promise<RestoreCursorAlwaysLocalResult> {
|
|
26
|
+
const targetPath = resolveCursorAlwaysLocalPath(appPath, options.targetRelativePath);
|
|
27
|
+
const beforeHash = await sha256File(targetPath);
|
|
28
|
+
const backupPath = await backupPathForCursorAlwaysLocal(
|
|
29
|
+
appPath,
|
|
30
|
+
targetPath,
|
|
31
|
+
options.backupDir,
|
|
32
|
+
);
|
|
33
|
+
await validateUnpatchedAlwaysLocalBackup(backupPath);
|
|
34
|
+
|
|
35
|
+
await copyFile(backupPath, targetPath);
|
|
36
|
+
|
|
37
|
+
const afterHash = await sha256File(targetPath);
|
|
38
|
+
const restoredContent = await readFile(targetPath, 'utf8');
|
|
39
|
+
const markerPresent = containsCursorAlwaysLocalTakeoverMarker(restoredContent);
|
|
40
|
+
|
|
41
|
+
if (containsAnyCursorAlwaysLocalTakeoverMarkerText(restoredContent)) {
|
|
42
|
+
throw new Error('Restore result still contains patch marker text.');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
targetPath,
|
|
47
|
+
backupPath,
|
|
48
|
+
beforeHash,
|
|
49
|
+
afterHash,
|
|
50
|
+
markerPresent,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { copyFile, readFile } from 'node:fs/promises';
|
|
2
|
+
import { sha256File } from './hash';
|
|
3
|
+
import {
|
|
4
|
+
backupPathForCursorWorkbenchAuthGate,
|
|
5
|
+
resolveCursorWorkbenchPath,
|
|
6
|
+
type PatchCursorWorkbenchAuthGateOptions,
|
|
7
|
+
} from './patchCursorWorkbenchAuthGate';
|
|
8
|
+
import {
|
|
9
|
+
containsAnyCursorWorkbenchAuthGateMarkerText,
|
|
10
|
+
containsCursorWorkbenchAuthGateMarker,
|
|
11
|
+
} from './workbenchAuthGateMarker';
|
|
12
|
+
|
|
13
|
+
export type RestoreCursorWorkbenchAuthGateResult = {
|
|
14
|
+
targetPath: string;
|
|
15
|
+
backupPath: string;
|
|
16
|
+
beforeHash: string;
|
|
17
|
+
afterHash: string;
|
|
18
|
+
markerPresent: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
async function readBackupContent(backupPath: string) {
|
|
22
|
+
try {
|
|
23
|
+
return await readFile(backupPath, 'utf8');
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
26
|
+
throw new Error(`Workbench auth gate patch backup is missing: ${backupPath}`);
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function validateUnpatchedWorkbenchBackup(backupPath: string) {
|
|
33
|
+
const backupContent = await readBackupContent(backupPath);
|
|
34
|
+
if (containsAnyCursorWorkbenchAuthGateMarkerText(backupContent)) {
|
|
35
|
+
throw new Error(`Workbench auth gate patch backup contains patch marker and is unsafe: ${backupPath}`);
|
|
36
|
+
}
|
|
37
|
+
return backupContent;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function restoreCursorWorkbenchAuthGate(
|
|
41
|
+
appPath: string,
|
|
42
|
+
options: Pick<PatchCursorWorkbenchAuthGateOptions, 'backupDir' | 'targetRelativePath'> = {},
|
|
43
|
+
): Promise<RestoreCursorWorkbenchAuthGateResult> {
|
|
44
|
+
const targetPath = resolveCursorWorkbenchPath(appPath, options.targetRelativePath);
|
|
45
|
+
const beforeHash = await sha256File(targetPath);
|
|
46
|
+
const backupPath = await backupPathForCursorWorkbenchAuthGate(
|
|
47
|
+
appPath,
|
|
48
|
+
targetPath,
|
|
49
|
+
options.backupDir,
|
|
50
|
+
);
|
|
51
|
+
await validateUnpatchedWorkbenchBackup(backupPath);
|
|
52
|
+
|
|
53
|
+
await copyFile(backupPath, targetPath);
|
|
54
|
+
|
|
55
|
+
const afterHash = await sha256File(targetPath);
|
|
56
|
+
const restoredContent = await readFile(targetPath, 'utf8');
|
|
57
|
+
const markerPresent = containsCursorWorkbenchAuthGateMarker(restoredContent);
|
|
58
|
+
|
|
59
|
+
if (containsAnyCursorWorkbenchAuthGateMarkerText(restoredContent)) {
|
|
60
|
+
throw new Error('Workbench auth gate restore result still contains patch marker text.');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
targetPath,
|
|
65
|
+
backupPath,
|
|
66
|
+
beforeHash,
|
|
67
|
+
afterHash,
|
|
68
|
+
markerPresent,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
export const CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER =
|
|
2
|
+
'CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V17_PLATFORM_PREFLIGHT';
|
|
3
|
+
export const CURSOR_POOL_WORKBENCH_AUTH_GATE_BEGIN_MARKER =
|
|
4
|
+
`/* ${CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER}: begin */`;
|
|
5
|
+
export const CURSOR_POOL_WORKBENCH_AUTH_GATE_END_MARKER =
|
|
6
|
+
`/* ${CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER}: end */`;
|
|
7
|
+
export const CURSOR_POOL_WORKBENCH_AUTH_GATE_SIGNATURE =
|
|
8
|
+
'__cursorPoolWorkbenchAuthGateBypass';
|
|
9
|
+
export const CURSOR_POOL_WORKBENCH_SUBMIT_GATE_SIGNATURE =
|
|
10
|
+
'__cursorPoolWorkbenchSubmitGateBypass';
|
|
11
|
+
export const CURSOR_POOL_WORKBENCH_AGENT_LOOP_SIGNATURE =
|
|
12
|
+
'__cursorPoolWorkbenchAgentLoopFetchTakeover';
|
|
13
|
+
export const CURSOR_POOL_WORKBENCH_NATIVE_LOCAL_AGENT_SIGNATURE =
|
|
14
|
+
'__cursorPoolWorkbenchNativeLocalAgent';
|
|
15
|
+
export const CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE =
|
|
16
|
+
'__cursorPoolWorkbenchAgentEditorSendButton';
|
|
17
|
+
export const CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE =
|
|
18
|
+
'__cursorPoolWorkbenchAgentEditorSubmit';
|
|
19
|
+
export const CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE =
|
|
20
|
+
'__cursorPoolWorkbenchRuntimeBaseUrl';
|
|
21
|
+
export const CURSOR_POOL_WORKBENCH_PREFLIGHT_SIGNATURE =
|
|
22
|
+
'__cursorPoolWorkbenchPlatformModePreflight';
|
|
23
|
+
|
|
24
|
+
export const CURSOR_WORKBENCH_COMPOSER_AUTH_GATE_ANCHOR =
|
|
25
|
+
'get when(){return p()&&!fzC},get fallback(){return he(DGC,{})}';
|
|
26
|
+
export const CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR =
|
|
27
|
+
'if(!p()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(wV,"general");return}';
|
|
28
|
+
export const CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_LINUX_3_6 =
|
|
29
|
+
'if(!h()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(P5,"general");return}';
|
|
30
|
+
export const CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6 =
|
|
31
|
+
'get when(){return t()},get fallback(){return(()=>{var R=x81();return fe(R,ie(lo,{keybinding:" \\u23CE",onClick:E,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),R})()},get children(){return';
|
|
32
|
+
export const CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_AUTH_GATE_ANCHOR =
|
|
33
|
+
'get when(){return t()},get fallback(){return(()=>{var D=avx();return Pe(D,he(sl,{keybinding:" \\u23CE",onClick:T,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),D})()},get children(){return';
|
|
34
|
+
export const CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_LOGIN_ANCHOR =
|
|
35
|
+
'if(!t()){e.cursorAuthenticationService.login();return}';
|
|
36
|
+
export const CURSOR_WORKBENCH_AGENT_LOOP_RUN_ANCHOR =
|
|
37
|
+
'await this.agentClientService.run(te,H,$e,Ne,Ce,T,ze,me,we,[],ct)';
|
|
38
|
+
export const CURSOR_WORKBENCH_BUILD_FLAGS_LOCAL_MODE_ANCHOR = 'localMode:!1';
|
|
39
|
+
export const CURSOR_WORKBENCH_LOCAL_PROVIDER_CONFIG_START_ANCHOR =
|
|
40
|
+
'async getLocalAgentProviderConfig(';
|
|
41
|
+
export const CURSOR_WORKBENCH_LOCAL_PROVIDER_CONFIG_END_ANCHOR =
|
|
42
|
+
'createDefaultLocalModel(';
|
|
43
|
+
export const CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR =
|
|
44
|
+
'if(L0.localMode){try{g.onNetworkPhaseStart?.()}catch(b){this.logService.warn("[AgentClientService] onNetworkPhaseStart callback failed in local mode",b)}return this.runLocalAgentInExtensionHost(e,t,i,r,s,a,d,h,g)}return this.client.run(e,t,i,r,s,o,a,u,d,h,g)';
|
|
45
|
+
export const CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_LINUX_3_6 =
|
|
46
|
+
'if(uv.localMode){try{h.onNetworkPhaseStart?.()}catch(f){this.logService.warn("[AgentClientService] onNetworkPhaseStart callback failed in local mode",f)}return this.runLocalAgentInExtensionHost(n,e,t,i,r,o,c,d,h)}return this.client.run(n,e,t,i,r,s,o,a,c,d,h)';
|
|
47
|
+
|
|
48
|
+
function buildPlatformModeGuardBootstrapExpression() {
|
|
49
|
+
return '((globalThis.__cursorPoolEnsurePlatformModeGuard||(globalThis.__cursorPoolEnsurePlatformModeGuard=()=>{try{if(globalThis.__cursorPoolPlatformModeGuardReady)return;globalThis.__cursorPoolPlatformModeGuardReady=!0;globalThis.__cursorPoolRuntimeBaseUrl=()=>{try{const e="http://127.0.0.1:56393";if(typeof require!="function")return e;const t=require("node:fs"),r=require("node:os"),o=require("node:path"),n=process?.env?.CURSOR_POOL_RUNTIME_FILE||o.join(r.homedir(),".cursor-pool","runtime.json");if(!t.existsSync(n))return e;const i=JSON.parse(t.readFileSync(n,"utf8"));return i?.host==="127.0.0.1"&&Number.isInteger(i?.port)&&i.port>0&&i.port<65536?`http://127.0.0.1:${i.port}`:e}catch{return "http://127.0.0.1:56393"}};globalThis.__cursorPoolReadVerifiedPlatformModeCache=()=>{try{const e=Number(globalThis.localStorage?.getItem("cursorPoolPlatformModeCheckedAt")||"0");return Date.now()-e<3e5?globalThis.localStorage?.getItem("cursorPoolPlatformModeActive")==="1":!1}catch{return!1}};globalThis.__cursorPoolReadSessionPlatformModeActive=()=>{try{if(typeof require!="function")return null;const e=require("node:fs"),t=require("node:os"),r=require("node:path"),o=process?.env?.CURSOR_POOL_PLATFORM_SESSION_FILE||r.join(t.homedir(),".cursor-pool","session.json");if(!e.existsSync(o))return null;const n=JSON.parse(e.readFileSync(o,"utf8")),i=n?.session;return n?.device?.status==="active"&&n?.platformMode==="active"&&typeof n?.activeProductId==="string"&&typeof n?.platformModeStartedAt==="string"||i?.device?.status==="active"&&i?.mode?.state==="active"}catch{return null}};globalThis.__cursorPoolReadPlatformModeActive=()=>{try{return globalThis.__cursorPoolReadSessionPlatformModeActive?.()===!0||globalThis.__cursorPoolReadVerifiedPlatformModeCache?.()===!0}catch{return!1}};globalThis.__cursorPoolPlatformModeActiveCache=globalThis.__cursorPoolReadPlatformModeActive(),globalThis.__cursorPoolRefreshPlatformModeActive=()=>{try{if(globalThis.__cursorPoolPlatformModeRefreshInFlight||typeof globalThis.fetch!="function")return;const e=globalThis.__cursorPoolRuntimeBaseUrl?.();if(!e)return;globalThis.__cursorPoolPlatformModeRefreshInFlight=!0,globalThis.fetch(`${e}/platform/status`).then(e=>e.ok?e.json():null).then(e=>{const t=e?.mode?.state==="active",r=globalThis.__cursorPoolPlatformModeActiveCache===!0;globalThis.__cursorPoolPlatformModeActiveCache=t;try{globalThis.localStorage?.setItem("cursorPoolPlatformModeActive",t?"1":"0"),globalThis.localStorage?.setItem("cursorPoolPlatformModeCheckedAt",String(Date.now()))}catch{}t!==r&&typeof globalThis.setTimeout=="function"&&globalThis.setTimeout(()=>globalThis.location?.reload?.(),50)}).catch(()=>{const e=globalThis.__cursorPoolPlatformModeActiveCache===!0;globalThis.__cursorPoolPlatformModeActiveCache=globalThis.__cursorPoolReadPlatformModeActive?.()===!0;try{globalThis.localStorage?.setItem("cursorPoolPlatformModeActive",globalThis.__cursorPoolPlatformModeActiveCache?"1":"0")}catch{}e!==globalThis.__cursorPoolPlatformModeActiveCache&&typeof globalThis.setTimeout=="function"&&globalThis.setTimeout(()=>globalThis.location?.reload?.(),50)}).finally(()=>{globalThis.__cursorPoolPlatformModeRefreshInFlight=!1})}catch{}},globalThis.__cursorPoolIsPlatformModeActive=()=>{try{globalThis.__cursorPoolEnsurePlatformModeGuard?.();return globalThis.__cursorPoolPlatformModeActiveCache===!0}catch{return!1}},globalThis.__cursorPoolRefreshPlatformModeActive(),globalThis.__cursorPoolPlatformModeRefreshTimer||typeof globalThis.setInterval!="function"||(globalThis.__cursorPoolPlatformModeRefreshTimer=globalThis.setInterval(globalThis.__cursorPoolRefreshPlatformModeActive,1e3))}catch{}}))(),globalThis.__cursorPoolIsPlatformModeActive?.()===true)';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION =
|
|
53
|
+
buildPlatformModeGuardBootstrapExpression();
|
|
54
|
+
|
|
55
|
+
export function containsCursorWorkbenchAuthGateMarker(content: string) {
|
|
56
|
+
const beginIndex = content.indexOf(CURSOR_POOL_WORKBENCH_AUTH_GATE_BEGIN_MARKER);
|
|
57
|
+
const endIndex = content.indexOf(CURSOR_POOL_WORKBENCH_AUTH_GATE_END_MARKER);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
beginIndex >= 0 &&
|
|
61
|
+
endIndex > beginIndex &&
|
|
62
|
+
content.slice(beginIndex, endIndex).includes(CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER) &&
|
|
63
|
+
content.slice(beginIndex, endIndex).includes(CURSOR_POOL_WORKBENCH_AUTH_GATE_SIGNATURE) &&
|
|
64
|
+
content.slice(beginIndex, endIndex).includes(CURSOR_POOL_WORKBENCH_SUBMIT_GATE_SIGNATURE) &&
|
|
65
|
+
content.slice(beginIndex, endIndex).includes(CURSOR_POOL_WORKBENCH_AGENT_LOOP_SIGNATURE) &&
|
|
66
|
+
content.slice(beginIndex, endIndex).includes(CURSOR_POOL_WORKBENCH_NATIVE_LOCAL_AGENT_SIGNATURE) &&
|
|
67
|
+
content
|
|
68
|
+
.slice(beginIndex, endIndex)
|
|
69
|
+
.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE) &&
|
|
70
|
+
content
|
|
71
|
+
.slice(beginIndex, endIndex)
|
|
72
|
+
.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE) &&
|
|
73
|
+
content
|
|
74
|
+
.slice(beginIndex, endIndex)
|
|
75
|
+
.includes(CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function containsAnyCursorWorkbenchAuthGateMarkerText(content: string) {
|
|
80
|
+
return (
|
|
81
|
+
content.includes(CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER) ||
|
|
82
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V16_SELF_BOOTSTRAP_PLATFORM_GUARD') ||
|
|
83
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V15_RENDERER_STORAGE_GUARD') ||
|
|
84
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V14_EXPLICIT_TAKEOVER_SWITCH') ||
|
|
85
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V13_ACTIVE_ONLY_FULL_TAKEOVER') ||
|
|
86
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V12_SUBMIT_ONLY_AUTH_GATE') ||
|
|
87
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V11_ACTIVE_SESSION_AUTH_GATE') ||
|
|
88
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V10_ACTIVE_SESSION_LOCAL') ||
|
|
89
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V9_ALWAYS_NATIVE_LOCAL') ||
|
|
90
|
+
content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH') ||
|
|
91
|
+
content.includes(CURSOR_POOL_WORKBENCH_AUTH_GATE_SIGNATURE) ||
|
|
92
|
+
content.includes(CURSOR_POOL_WORKBENCH_SUBMIT_GATE_SIGNATURE) ||
|
|
93
|
+
content.includes(CURSOR_POOL_WORKBENCH_AGENT_LOOP_SIGNATURE) ||
|
|
94
|
+
content.includes(CURSOR_POOL_WORKBENCH_NATIVE_LOCAL_AGENT_SIGNATURE) ||
|
|
95
|
+
content.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE) ||
|
|
96
|
+
content.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE) ||
|
|
97
|
+
content.includes(CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function buildCursorWorkbenchAuthGatePatchSnippet() {
|
|
102
|
+
return `${CURSOR_POOL_WORKBENCH_AUTH_GATE_BEGIN_MARKER}
|
|
103
|
+
["${CURSOR_POOL_WORKBENCH_AUTH_GATE_SIGNATURE}"]:(globalThis.${CURSOR_POOL_WORKBENCH_AUTH_GATE_SIGNATURE}=true,void 0),
|
|
104
|
+
["${CURSOR_POOL_WORKBENCH_SUBMIT_GATE_SIGNATURE}"]:true,
|
|
105
|
+
["${CURSOR_POOL_WORKBENCH_AGENT_LOOP_SIGNATURE}"]:true,
|
|
106
|
+
["${CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE}"]:true,
|
|
107
|
+
["${CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE}"]:true,
|
|
108
|
+
["${CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE}"]:true,
|
|
109
|
+
["${CURSOR_POOL_WORKBENCH_NATIVE_LOCAL_AGENT_SIGNATURE}"]:(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION},void 0),
|
|
110
|
+
${CURSOR_POOL_WORKBENCH_AUTH_GATE_END_MARKER}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function buildPlatformModePreflightSnippet() {
|
|
114
|
+
return `/* ${CURSOR_POOL_WORKBENCH_PREFLIGHT_SIGNATURE}: begin */
|
|
115
|
+
try{const e="http://127.0.0.1:56393/platform/status",t=await Promise.race([fetch(e).then(e=>e.ok?e.json():null),new Promise(e=>setTimeout(()=>e(null),500))]),r=t?.mode?.state==="active";localStorage?.setItem("cursorPoolPlatformModeActive",r?"1":"0"),localStorage?.setItem("cursorPoolPlatformModeCheckedAt",String(Date.now()))}catch{}
|
|
116
|
+
/* ${CURSOR_POOL_WORKBENCH_PREFLIGHT_SIGNATURE}: end */
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function buildAgentLoopTakeoverReplacement() {
|
|
121
|
+
return CURSOR_WORKBENCH_AGENT_LOOP_RUN_ANCHOR;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function buildLocalProviderConfigReplacement() {
|
|
125
|
+
return 'async getLocalAgentProviderConfig(e){const t="[AgentClientService][getLocalAgentProviderConfig]",r=globalThis.__cursorPoolRuntimeBaseUrl?.()||"http://127.0.0.1:56393",i={baseUrl:r,apiKey:"cursor-pool-local"};try{this.logService.info(`${t} resolved`,{apiKeySource:"cursor-pool-local",hasApiKey:!0,baseUrlSource:"cursor-pool-runtime",normalizedBaseUrl:i.baseUrl,normalizationChangedUrl:!1})}catch{}return i}';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function forceNativeLocalAgentMode(content: string) {
|
|
129
|
+
if (!content.includes(CURSOR_WORKBENCH_BUILD_FLAGS_LOCAL_MODE_ANCHOR)) {
|
|
130
|
+
throw new Error('Cursor Workbench localMode build flag anchor was not found.');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const providerConfigStart = content.indexOf(
|
|
134
|
+
CURSOR_WORKBENCH_LOCAL_PROVIDER_CONFIG_START_ANCHOR,
|
|
135
|
+
);
|
|
136
|
+
const providerConfigEnd = providerConfigStart >= 0
|
|
137
|
+
? content.indexOf(CURSOR_WORKBENCH_LOCAL_PROVIDER_CONFIG_END_ANCHOR, providerConfigStart)
|
|
138
|
+
: -1;
|
|
139
|
+
if (providerConfigStart < 0 || providerConfigEnd < 0) {
|
|
140
|
+
throw new Error('Cursor Workbench local provider config anchor was not found.');
|
|
141
|
+
}
|
|
142
|
+
const withProviderConfig = `${content.slice(0, providerConfigStart)}${buildLocalProviderConfigReplacement()}${content.slice(providerConfigEnd)}`;
|
|
143
|
+
|
|
144
|
+
const runBranchAnchor = [
|
|
145
|
+
CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR,
|
|
146
|
+
CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_LINUX_3_6,
|
|
147
|
+
].find((anchor) => withProviderConfig.includes(anchor));
|
|
148
|
+
const runBranchIndex = runBranchAnchor
|
|
149
|
+
? withProviderConfig.indexOf(runBranchAnchor)
|
|
150
|
+
: -1;
|
|
151
|
+
if (runBranchIndex < 0) {
|
|
152
|
+
throw new Error('Cursor Workbench agent client run localMode anchor was not found.');
|
|
153
|
+
}
|
|
154
|
+
const runBranchReplacement = runBranchAnchor!.replace(
|
|
155
|
+
runBranchAnchor!.startsWith('if(uv.localMode)') ? 'if(uv.localMode)' : 'if(L0.localMode)',
|
|
156
|
+
runBranchAnchor!.startsWith('if(uv.localMode)')
|
|
157
|
+
? `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||uv.localMode)`
|
|
158
|
+
: `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||L0.localMode)`,
|
|
159
|
+
);
|
|
160
|
+
return `${withProviderConfig.slice(0, runBranchIndex)}${runBranchReplacement}${withProviderConfig.slice(
|
|
161
|
+
runBranchIndex + runBranchAnchor!.length,
|
|
162
|
+
)}`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function injectCursorWorkbenchAuthGatePatch(content: string) {
|
|
166
|
+
if (containsCursorWorkbenchAuthGateMarker(content)) {
|
|
167
|
+
return content;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const anchorIndex = content.indexOf(CURSOR_WORKBENCH_COMPOSER_AUTH_GATE_ANCHOR);
|
|
171
|
+
const linux36GateIndex = content.indexOf(
|
|
172
|
+
CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6,
|
|
173
|
+
);
|
|
174
|
+
if (anchorIndex < 0 && linux36GateIndex < 0) {
|
|
175
|
+
throw new Error('Cursor Workbench composer auth gate anchor was not found.');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const preflight = buildPlatformModePreflightSnippet();
|
|
179
|
+
const contentWithPreflight = content.startsWith(preflight) || content.includes(CURSOR_POOL_WORKBENCH_PREFLIGHT_SIGNATURE)
|
|
180
|
+
? content
|
|
181
|
+
: `${preflight}${content}`;
|
|
182
|
+
|
|
183
|
+
const anchorIndexWithPreflight = contentWithPreflight.indexOf(CURSOR_WORKBENCH_COMPOSER_AUTH_GATE_ANCHOR);
|
|
184
|
+
const linux36GateIndexWithPreflight = contentWithPreflight.indexOf(
|
|
185
|
+
CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const withUiGate = anchorIndexWithPreflight >= 0
|
|
189
|
+
? `${contentWithPreflight.slice(0, anchorIndexWithPreflight)}get when(){return (p()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION})&&!fzC},${buildCursorWorkbenchAuthGatePatchSnippet()}get fallback(){return he(DGC,{})}${contentWithPreflight.slice(
|
|
190
|
+
anchorIndexWithPreflight + CURSOR_WORKBENCH_COMPOSER_AUTH_GATE_ANCHOR.length,
|
|
191
|
+
)}`
|
|
192
|
+
: `${contentWithPreflight.slice(0, linux36GateIndexWithPreflight)}get when(){return h()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}},${buildCursorWorkbenchAuthGatePatchSnippet()}get fallback(){return(()=>{var R=x81();return fe(R,ie(lo,{keybinding:" \\u23CE",onClick:E,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),R})()},get children(){return${contentWithPreflight.slice(
|
|
193
|
+
linux36GateIndexWithPreflight + CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6.length,
|
|
194
|
+
)}`;
|
|
195
|
+
|
|
196
|
+
const withAgentEditorSendButtonGate = withUiGate.includes(
|
|
197
|
+
CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_AUTH_GATE_ANCHOR,
|
|
198
|
+
)
|
|
199
|
+
? withUiGate.replace(
|
|
200
|
+
CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_AUTH_GATE_ANCHOR,
|
|
201
|
+
`get when(){return t()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}},get fallback(){return(()=>{var D=avx();return Pe(D,he(sl,{keybinding:" \\u23CE",onClick:T,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),D})()},get children(){return`,
|
|
202
|
+
)
|
|
203
|
+
: withUiGate;
|
|
204
|
+
|
|
205
|
+
const withAgentEditorSubmitGate = withAgentEditorSendButtonGate.includes(
|
|
206
|
+
CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_LOGIN_ANCHOR,
|
|
207
|
+
)
|
|
208
|
+
? withAgentEditorSendButtonGate.replace(
|
|
209
|
+
CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_LOGIN_ANCHOR,
|
|
210
|
+
`if(!t()&&!${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}){e.cursorAuthenticationService.login();return}`,
|
|
211
|
+
)
|
|
212
|
+
: withAgentEditorSendButtonGate;
|
|
213
|
+
|
|
214
|
+
const submitGateAnchor = [
|
|
215
|
+
CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR,
|
|
216
|
+
CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_LINUX_3_6,
|
|
217
|
+
].find((anchor) => withAgentEditorSubmitGate.includes(anchor));
|
|
218
|
+
const submitGateIndex = submitGateAnchor ? withAgentEditorSubmitGate.indexOf(submitGateAnchor) : -1;
|
|
219
|
+
if (submitGateIndex < 0) {
|
|
220
|
+
throw new Error('Cursor Workbench composer submit auth gate anchor was not found.');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const submitGateReplacement = submitGateAnchor === CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_LINUX_3_6
|
|
224
|
+
? 'if(!h()&&!globalThis.__cursorPoolIsPlatformModeActive?.()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(P5,"general");return}'
|
|
225
|
+
: 'if(!p()&&!globalThis.__cursorPoolIsPlatformModeActive?.()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(wV,"general");return}';
|
|
226
|
+
const withSubmitGate = `${withAgentEditorSubmitGate.slice(0, submitGateIndex)}${submitGateReplacement}${withAgentEditorSubmitGate.slice(
|
|
227
|
+
submitGateIndex + submitGateAnchor!.length,
|
|
228
|
+
)}`;
|
|
229
|
+
|
|
230
|
+
const agentLoopIndex = withSubmitGate.indexOf(CURSOR_WORKBENCH_AGENT_LOOP_RUN_ANCHOR);
|
|
231
|
+
if (
|
|
232
|
+
agentLoopIndex < 0 &&
|
|
233
|
+
withSubmitGate.includes(CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR)
|
|
234
|
+
) {
|
|
235
|
+
throw new Error('Cursor Workbench agent loop run anchor was not found.');
|
|
236
|
+
}
|
|
237
|
+
const withNativeAgentLoop = agentLoopIndex >= 0
|
|
238
|
+
? `${withSubmitGate.slice(0, agentLoopIndex)}${buildAgentLoopTakeoverReplacement()}${withSubmitGate.slice(
|
|
239
|
+
agentLoopIndex + CURSOR_WORKBENCH_AGENT_LOOP_RUN_ANCHOR.length,
|
|
240
|
+
)}`
|
|
241
|
+
: withSubmitGate;
|
|
242
|
+
return forceNativeLocalAgentMode(withNativeAgentLoop);
|
|
243
|
+
}
|