@cursorpool-dev/cli 0.5.6 → 0.5.9

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.
Files changed (93) hide show
  1. package/node_modules/@cursor-pool/extension/dist/extension.js +1 -1
  2. package/node_modules/@cursor-pool/extension/package.json +3 -3
  3. package/node_modules/@cursor-pool/extension/src/api.ts +1 -1
  4. package/node_modules/@cursor-pool/extension/test/panel.test.ts +1 -1
  5. package/node_modules/@cursor-pool/patcher/package.json +2 -2
  6. package/node_modules/@cursor-pool/patcher/src/marker.ts +72 -3
  7. package/node_modules/@cursor-pool/patcher/src/workbenchAuthGateMarker.ts +128 -14
  8. package/node_modules/@cursor-pool/patcher/test/patchCursorAgentExec.test.ts +102 -7
  9. package/node_modules/@cursor-pool/patcher/test/patchCursorWorkbench.test.ts +193 -0
  10. package/node_modules/@cursor-pool/service/package.json +2 -2
  11. package/node_modules/@cursor-pool/service/src/server.ts +1 -0
  12. package/node_modules/@cursor-pool/service/test/server.test.ts +1 -0
  13. package/node_modules/@cursor-pool/shared/package.json +1 -1
  14. package/node_modules/@cursor-pool/shared/test/manifest.test.ts +6 -6
  15. package/node_modules/@esbuild/linux-x64/README.md +3 -0
  16. package/node_modules/@esbuild/linux-x64/bin/esbuild +0 -0
  17. package/node_modules/@esbuild/linux-x64/package.json +20 -0
  18. package/node_modules/esbuild/LICENSE.md +21 -0
  19. package/node_modules/esbuild/README.md +3 -0
  20. package/node_modules/esbuild/bin/esbuild +223 -0
  21. package/node_modules/esbuild/install.js +300 -0
  22. package/node_modules/esbuild/lib/main.d.ts +716 -0
  23. package/node_modules/esbuild/lib/main.js +2532 -0
  24. package/node_modules/esbuild/package.json +74 -0
  25. package/node_modules/tsx/LICENSE +21 -0
  26. package/node_modules/tsx/README.md +32 -0
  27. package/node_modules/tsx/dist/cjs/api/index.cjs +1 -0
  28. package/node_modules/tsx/dist/cjs/api/index.d.cts +35 -0
  29. package/node_modules/tsx/dist/cjs/api/index.d.mts +35 -0
  30. package/node_modules/tsx/dist/cjs/api/index.mjs +1 -0
  31. package/node_modules/tsx/dist/cjs/index.cjs +1 -0
  32. package/node_modules/tsx/dist/cjs/index.mjs +1 -0
  33. package/node_modules/tsx/dist/cli.cjs +54 -0
  34. package/node_modules/tsx/dist/cli.mjs +55 -0
  35. package/node_modules/tsx/dist/client-D3mGB526.cjs +1 -0
  36. package/node_modules/tsx/dist/client-D_mPDF5S.mjs +1 -0
  37. package/node_modules/tsx/dist/esm/api/index.cjs +1 -0
  38. package/node_modules/tsx/dist/esm/api/index.d.cts +35 -0
  39. package/node_modules/tsx/dist/esm/api/index.d.mts +35 -0
  40. package/node_modules/tsx/dist/esm/api/index.mjs +1 -0
  41. package/node_modules/tsx/dist/esm/index.cjs +1 -0
  42. package/node_modules/tsx/dist/esm/index.mjs +1 -0
  43. package/node_modules/tsx/dist/get-pipe-path-D4YM6rQt.cjs +1 -0
  44. package/node_modules/tsx/dist/get-pipe-path-_tAJyU_v.mjs +1 -0
  45. package/node_modules/tsx/dist/index-BWFBUo6r.cjs +1 -0
  46. package/node_modules/tsx/dist/index-D9F1FXzN.cjs +14 -0
  47. package/node_modules/tsx/dist/index-XurvG3JN.mjs +14 -0
  48. package/node_modules/tsx/dist/index-gbaejti9.mjs +1 -0
  49. package/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +3 -0
  50. package/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +3 -0
  51. package/node_modules/tsx/dist/loader.cjs +1 -0
  52. package/node_modules/tsx/dist/loader.mjs +1 -0
  53. package/node_modules/tsx/dist/node-features-B9BBLzwu.mjs +1 -0
  54. package/node_modules/tsx/dist/node-features-CQLdkVE6.cjs +1 -0
  55. package/node_modules/tsx/dist/package-CGdS2_oX.cjs +1 -0
  56. package/node_modules/tsx/dist/package-DyJMwVU5.mjs +1 -0
  57. package/node_modules/tsx/dist/patch-repl.cjs +1 -0
  58. package/node_modules/tsx/dist/patch-repl.mjs +1 -0
  59. package/node_modules/tsx/dist/preflight.cjs +1 -0
  60. package/node_modules/tsx/dist/preflight.mjs +1 -0
  61. package/node_modules/tsx/dist/register-BOkp8V6j.cjs +10 -0
  62. package/node_modules/tsx/dist/register-BnTWPeIB.mjs +10 -0
  63. package/node_modules/tsx/dist/register-CHVGxKtC.cjs +2 -0
  64. package/node_modules/tsx/dist/register-D_B8UL5H.mjs +2 -0
  65. package/node_modules/tsx/dist/repl.cjs +3 -0
  66. package/node_modules/tsx/dist/repl.mjs +3 -0
  67. package/node_modules/tsx/dist/require-CjvaJWEr.cjs +1 -0
  68. package/node_modules/tsx/dist/require-DzmC1hVr.mjs +1 -0
  69. package/node_modules/tsx/dist/suppress-warnings.cjs +1 -0
  70. package/node_modules/tsx/dist/suppress-warnings.mjs +1 -0
  71. package/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +1 -0
  72. package/node_modules/tsx/dist/temporary-directory-BDDVQOvU.mjs +1 -0
  73. package/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +5 -0
  74. package/node_modules/tsx/package.json +67 -0
  75. package/package.json +9 -6
  76. package/src/autostart.ts +5 -1
  77. package/src/compat.ts +103 -29
  78. package/src/cursor.ts +59 -3
  79. package/src/extensionBundle.ts +1 -1
  80. package/src/extensionLink.ts +3 -3
  81. package/src/install.ts +118 -19
  82. package/src/platform.ts +3 -3
  83. package/src/repair.ts +2 -1
  84. package/src/serviceProcess.ts +2 -1
  85. package/src/trial.ts +2 -2
  86. package/test/autostart.test.ts +23 -2
  87. package/test/compat.test.ts +108 -9
  88. package/test/cursor-pool-bin.test.ts +1 -0
  89. package/test/cursor.test.ts +60 -1
  90. package/test/extensionLink.test.ts +24 -1
  91. package/test/install.test.ts +127 -2
  92. package/test/serviceProcess.test.ts +10 -1
  93. package/test/trial.test.ts +15 -1
@@ -2153,7 +2153,7 @@ function buildExtensionDeviceInfo() {
2153
2153
  name: hostname(),
2154
2154
  os: osPlatform(),
2155
2155
  arch: arch(),
2156
- extensionVersion: "0.5.6"
2156
+ extensionVersion: "0.5.9"
2157
2157
  };
2158
2158
  }
2159
2159
  function serviceUrl(runtime, path) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cursor-pool/extension",
3
- "version": "0.5.6",
3
+ "version": "0.5.9",
4
4
  "displayName": "Cursor Pool 平台模式",
5
5
  "publisher": "cursor-pool",
6
6
  "engines": {
@@ -21,8 +21,8 @@
21
21
  "./runtime": "./src/runtime.ts"
22
22
  },
23
23
  "dependencies": {
24
- "@cursor-pool/service": "0.5.6",
25
- "@cursor-pool/shared": "0.5.6"
24
+ "@cursor-pool/service": "0.5.9",
25
+ "@cursor-pool/shared": "0.5.9"
26
26
  },
27
27
  "contributes": {
28
28
  "viewsContainers": {
@@ -114,7 +114,7 @@ export function buildExtensionDeviceInfo() {
114
114
  name: hostname(),
115
115
  os: osPlatform(),
116
116
  arch: arch(),
117
- extensionVersion: '0.5.6',
117
+ extensionVersion: '0.5.9',
118
118
  };
119
119
  }
120
120
 
@@ -1655,7 +1655,7 @@ test('API can login and logout through local service platform routes', async ()
1655
1655
  assert.equal(typeof (requests[0]?.body.device as Record<string, unknown>).name, 'string');
1656
1656
  assert.equal(typeof (requests[0]?.body.device as Record<string, unknown>).os, 'string');
1657
1657
  assert.equal(typeof (requests[0]?.body.device as Record<string, unknown>).arch, 'string');
1658
- assert.equal((requests[0]?.body.device as Record<string, unknown>).extensionVersion, '0.5.6');
1658
+ assert.equal((requests[0]?.body.device as Record<string, unknown>).extensionVersion, '0.5.9');
1659
1659
  assert.equal(requests[1]?.method, 'POST');
1660
1660
  assert.equal(requests[1]?.url, '/platform/logout');
1661
1661
  } finally {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cursor-pool/patcher",
3
- "version": "0.5.6",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "exports": {
@@ -9,7 +9,7 @@
9
9
  "./marker": "./src/marker.ts"
10
10
  },
11
11
  "dependencies": {
12
- "@cursor-pool/shared": "0.5.6"
12
+ "@cursor-pool/shared": "0.5.9"
13
13
  },
14
14
  "scripts": {
15
15
  "test": "tsx --test test/*.test.ts"
@@ -8,8 +8,16 @@ export const CURSOR_POOL_AGENT_EXEC_PROVIDER_REGISTER_ANCHOR =
8
8
  'const ht=F.cursor.registerAgentExecProvider(mt);';
9
9
  export const CURSOR_POOL_AGENT_EXEC_PROVIDER_REGISTER_ANCHORS = [
10
10
  CURSOR_POOL_AGENT_EXEC_PROVIDER_REGISTER_ANCHOR,
11
+ 'const dt=D.cursor.registerAgentExecProvider(ut);',
11
12
  'const ht=c.cursor.registerAgentExecProvider(mt);',
13
+ 'const Et=c.cursor.registerAgentExecProvider(vt);',
12
14
  ];
15
+ const CURSOR_AGENT_EXEC_LOCAL_PROVIDER_KIND_ANCHOR =
16
+ 'this.options.localProvider).kind';
17
+ const CURSOR_AGENT_EXEC_LEGACY_LOCAL_CLIENT_OPTIONS =
18
+ 'new t({baseUrl:e.baseUrl,apiKey:e.apiKey,userAgent:e.userAgent,defaultModel:p,privacyMode:e.privacyMode})';
19
+ const CURSOR_AGENT_EXEC_LOCAL_PROVIDER_CLIENT_OPTIONS =
20
+ 'new t({localProvider:{kind:"http",baseUrl:e.baseUrl,apiKey:e.apiKey},userAgent:e.userAgent,defaultModel:p,privacyMode:e.privacyMode})';
13
21
 
14
22
  export function buildCursorAgentExecPatchSnippet() {
15
23
  return `
@@ -86,6 +94,47 @@ ${CURSOR_POOL_PATCH_BEGIN_MARKER}
86
94
  });
87
95
  request.end(body);
88
96
  });
97
+ const rememberTakeover = (takeover) => {
98
+ try {
99
+ if (globalThis.__cursorPoolAgentExecTakeover) {
100
+ globalThis.__cursorPoolAgentExecTakeover.lastTakeover = takeover;
101
+ }
102
+ } catch {}
103
+ };
104
+ const normalizeTakeoverContext = (context) => ({
105
+ requestId:
106
+ context?.requestId ||
107
+ context?.runOptions?.generationUUID ||
108
+ context?.generationUUID,
109
+ modelName:
110
+ context?.modelName ||
111
+ context?.modelDetails?.modelName ||
112
+ context?.modelDetails?.model ||
113
+ context?.defaultModel?.name ||
114
+ context?.defaultModel ||
115
+ 'unknown',
116
+ });
117
+ const wrapCursorPoolSession = (session) => {
118
+ if (!session || session.__cursorPoolWrappedAgentExecSession) {
119
+ return session;
120
+ }
121
+ const wrappedSession = Object.create(Object.getPrototypeOf(session));
122
+ Object.assign(wrappedSession, session);
123
+ if (typeof session.createStream === 'function') {
124
+ wrappedSession.createStream = function(context, requestBytes, abortSignal) {
125
+ const originalStreamFactory = session.createStream.call(session, context, requestBytes, abortSignal);
126
+ if (typeof originalStreamFactory !== 'function') {
127
+ return originalStreamFactory;
128
+ }
129
+ return async function* cursorPoolTakeoverStream(...args) {
130
+ rememberTakeover(await requestCursorPoolTakeover(normalizeTakeoverContext(context)));
131
+ yield* originalStreamFactory.apply(this, args);
132
+ };
133
+ };
134
+ }
135
+ wrappedSession.__cursorPoolWrappedAgentExecSession = true;
136
+ return wrappedSession;
137
+ };
89
138
  const wrapCursorPoolProvider = (provider) => {
90
139
  if (!provider || provider.__cursorPoolWrappedAgentExecProvider) {
91
140
  return provider;
@@ -93,10 +142,15 @@ ${CURSOR_POOL_PATCH_BEGIN_MARKER}
93
142
  const wrapped = Object.create(Object.getPrototypeOf(provider));
94
143
  Object.assign(wrapped, provider);
95
144
  if (typeof provider.runLocalAgent === 'function') {
96
- wrapped.runLocalAgent = provider.runLocalAgent.bind(provider);
145
+ wrapped.runLocalAgent = async function(...args) {
146
+ rememberTakeover(await requestCursorPoolTakeover(normalizeTakeoverContext(args[0])));
147
+ return provider.runLocalAgent.apply(provider, args);
148
+ };
97
149
  }
98
150
  if (typeof provider.createSession === 'function') {
99
- wrapped.createSession = provider.createSession.bind(provider);
151
+ wrapped.createSession = function(...args) {
152
+ return wrapCursorPoolSession(provider.createSession.apply(provider, args));
153
+ };
100
154
  }
101
155
  if (typeof provider.fetchLocalProviderModels === 'function') {
102
156
  wrapped.fetchLocalProviderModels = provider.fetchLocalProviderModels.bind(provider);
@@ -133,7 +187,22 @@ export function injectCursorAgentExecPatchSnippet(content: string) {
133
187
  if (anchorIndex < 0) {
134
188
  throw new Error('Cursor Agent Exec provider registration anchor was not found.');
135
189
  }
136
- return `${content.slice(0, anchorIndex)}${snippet}${content.slice(anchorIndex)}`;
190
+ const contentWithLocalProviderOptions = content.includes(CURSOR_AGENT_EXEC_LOCAL_PROVIDER_KIND_ANCHOR)
191
+ ? content.replace(
192
+ CURSOR_AGENT_EXEC_LEGACY_LOCAL_CLIENT_OPTIONS,
193
+ CURSOR_AGENT_EXEC_LOCAL_PROVIDER_CLIENT_OPTIONS,
194
+ )
195
+ : content;
196
+ const adjustedAnchorIndex = anchor
197
+ ? contentWithLocalProviderOptions.indexOf(anchor)
198
+ : -1;
199
+ if (
200
+ content.includes(CURSOR_AGENT_EXEC_LOCAL_PROVIDER_KIND_ANCHOR) &&
201
+ contentWithLocalProviderOptions === content
202
+ ) {
203
+ throw new Error('Cursor Agent Exec local provider client options anchor was not found.');
204
+ }
205
+ return `${contentWithLocalProviderOptions.slice(0, adjustedAnchorIndex)}${snippet}${contentWithLocalProviderOptions.slice(adjustedAnchorIndex)}`;
137
206
  }
138
207
 
139
208
  export function containsCursorPoolMarker(content: string) {
@@ -1,5 +1,5 @@
1
1
  export const CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER =
2
- 'CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V17_PLATFORM_PREFLIGHT';
2
+ 'CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V18_MAC34_BOTTOM_BAR';
3
3
  export const CURSOR_POOL_WORKBENCH_AUTH_GATE_BEGIN_MARKER =
4
4
  `/* ${CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER}: begin */`;
5
5
  export const CURSOR_POOL_WORKBENCH_AUTH_GATE_END_MARKER =
@@ -16,6 +16,8 @@ export const CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE =
16
16
  '__cursorPoolWorkbenchAgentEditorSendButton';
17
17
  export const CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE =
18
18
  '__cursorPoolWorkbenchAgentEditorSubmit';
19
+ export const CURSOR_POOL_WORKBENCH_AGENT_EDITOR_CURSOR_AI_LOGIN_SIGNATURE =
20
+ '__cursorPoolWorkbenchAgentEditorCursorAiLogin';
19
21
  export const CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE =
20
22
  '__cursorPoolWorkbenchRuntimeBaseUrl';
21
23
  export const CURSOR_POOL_WORKBENCH_PREFLIGHT_SIGNATURE =
@@ -27,12 +29,30 @@ export const CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR =
27
29
  'if(!p()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(wV,"general");return}';
28
30
  export const CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_LINUX_3_6 =
29
31
  'if(!h()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(P5,"general");return}';
32
+ export const CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_7 =
33
+ 'if(!h()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(a6,"general");return}';
34
+ export const CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4 =
35
+ 'if(!t()){e.cursorAuthenticationService.login();return}';
36
+ export const CURSOR_WORKBENCH_MAIN_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4 =
37
+ 'if(!v()){e.cursorAuthenticationService.login(),e.commandService.executeCommand($6,"general");return}';
30
38
  export const CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6 =
31
39
  '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';
40
+ export const CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_7 =
41
+ 'get when(){return t()},get fallback(){return(()=>{var R=Swx();return ge(R,ie(go,{keybinding:" \\u23CE",onClick:E,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),R})()},get children(){return';
42
+ export const CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_4 =
43
+ 'get when(){return t()},get fallback(){return(()=>{var R=npC();return ke(R,re(ea,{keybinding:" \\u23CE",onClick:E,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),R})()},get children(){return';
32
44
  export const CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_AUTH_GATE_ANCHOR =
33
45
  '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
46
  export const CURSOR_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_LOGIN_ANCHOR =
35
47
  'if(!t()){e.cursorAuthenticationService.login();return}';
48
+ export const CURSOR_WORKBENCH_AGENT_EDITOR_CURSOR_AI_LOGIN_BUTTON_ANCHOR_LINUX_3_6 =
49
+ 'return ie(lo,{get keybinding(){return e()},onClick:()=>{n.cursorAuthenticationService.login()},hintText:"Log in to use Cursor AI features",variant:"secondary",style:{"margin-left":"auto"},children:"Log in"})';
50
+ export const CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_LINUX_3_6 =
51
+ 'get when(){return h()&&!Xk1},get fallback(){return ie(X_1,{})},get children(){return ie(i01,';
52
+ export const CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_MAC_3_7 =
53
+ 'get when(){return h()&&!rYT},get fallback(){return ie(CzT,{})},get children(){return ie(AVT,';
54
+ export const CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_MAC_3_4 =
55
+ 'get when(){return v()&&!HG1},get fallback(){return re(s71,{})},get children(){return re(u$1,';
36
56
  export const CURSOR_WORKBENCH_AGENT_LOOP_RUN_ANCHOR =
37
57
  'await this.agentClientService.run(te,H,$e,Ne,Ce,T,ze,me,we,[],ct)';
38
58
  export const CURSOR_WORKBENCH_BUILD_FLAGS_LOCAL_MODE_ANCHOR = 'localMode:!1';
@@ -44,9 +64,13 @@ export const CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR =
44
64
  '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
65
  export const CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_LINUX_3_6 =
46
66
  '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)';
67
+ export const CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_MAC_3_7 =
68
+ 'if(wv.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)';
69
+ export const CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_MAC_3_4 =
70
+ 'if(U0.localMode){try{f.onNetworkPhaseStart?.()}catch(v){this.logService.warn("[AgentClientService] onNetworkPhaseStart callback failed in local mode",v)}return this.runLocalAgentInExtensionHost(e,t,i,r,s,a,u,d,f)}return this.client.run(e,t,i,r,s,o,a,l,u,d,f)';
47
71
 
48
72
  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)';
73
+ return '((globalThis.__cursorPoolEnsurePlatformModeGuard||(globalThis.__cursorPoolEnsurePlatformModeGuard=()=>{try{if(globalThis.__cursorPoolPlatformModeGuardReady)return;globalThis.__cursorPoolPlatformModeGuardReady=!0;globalThis.__cursorPoolRuntimeBaseUrl=()=>{try{const e="http://127.0.0.1:56393",t=process?.env?.CURSOR_POOL_RUNTIME_BASE_URL;if(typeof t=="string"&&/^http:\\/\\/127\\.0\\.0\\.1:[1-9][0-9]{0,4}$/.test(t)){const r=Number(t.slice(t.lastIndexOf(":")+1));if(r>0&&r<65536)return t}if(typeof require!="function")return e;const r=require("node:fs"),o=require("node:os"),n=require("node:path"),i=process?.env?.CURSOR_POOL_RUNTIME_FILE||n.join(o.homedir(),".cursor-pool","runtime.json");if(!r.existsSync(i))return e;const s=JSON.parse(r.readFileSync(i,"utf8"));return s?.host==="127.0.0.1"&&Number.isInteger(s?.port)&&s.port>0&&s.port<65536?`http://127.0.0.1:${s.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
74
  }
51
75
 
52
76
  const CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION =
@@ -70,6 +94,9 @@ export function containsCursorWorkbenchAuthGateMarker(content: string) {
70
94
  content
71
95
  .slice(beginIndex, endIndex)
72
96
  .includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE) &&
97
+ content
98
+ .slice(beginIndex, endIndex)
99
+ .includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_CURSOR_AI_LOGIN_SIGNATURE) &&
73
100
  content
74
101
  .slice(beginIndex, endIndex)
75
102
  .includes(CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE)
@@ -79,6 +106,7 @@ export function containsCursorWorkbenchAuthGateMarker(content: string) {
79
106
  export function containsAnyCursorWorkbenchAuthGateMarkerText(content: string) {
80
107
  return (
81
108
  content.includes(CURSOR_POOL_WORKBENCH_AUTH_GATE_MARKER) ||
109
+ content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V17_PLATFORM_PREFLIGHT') ||
82
110
  content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V16_SELF_BOOTSTRAP_PLATFORM_GUARD') ||
83
111
  content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V15_RENDERER_STORAGE_GUARD') ||
84
112
  content.includes('CURSOR_POOL_MVP1_WORKBENCH_AUTH_GATE_PATCH_V14_EXPLICIT_TAKEOVER_SWITCH') ||
@@ -94,6 +122,7 @@ export function containsAnyCursorWorkbenchAuthGateMarkerText(content: string) {
94
122
  content.includes(CURSOR_POOL_WORKBENCH_NATIVE_LOCAL_AGENT_SIGNATURE) ||
95
123
  content.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE) ||
96
124
  content.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE) ||
125
+ content.includes(CURSOR_POOL_WORKBENCH_AGENT_EDITOR_CURSOR_AI_LOGIN_SIGNATURE) ||
97
126
  content.includes(CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE)
98
127
  );
99
128
  }
@@ -105,6 +134,7 @@ export function buildCursorWorkbenchAuthGatePatchSnippet() {
105
134
  ["${CURSOR_POOL_WORKBENCH_AGENT_LOOP_SIGNATURE}"]:true,
106
135
  ["${CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SEND_BUTTON_SIGNATURE}"]:true,
107
136
  ["${CURSOR_POOL_WORKBENCH_AGENT_EDITOR_SUBMIT_SIGNATURE}"]:true,
137
+ ["${CURSOR_POOL_WORKBENCH_AGENT_EDITOR_CURSOR_AI_LOGIN_SIGNATURE}"]:true,
108
138
  ["${CURSOR_POOL_WORKBENCH_RUNTIME_BASE_URL_SIGNATURE}"]:true,
109
139
  ["${CURSOR_POOL_WORKBENCH_NATIVE_LOCAL_AGENT_SIGNATURE}"]:(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION},void 0),
110
140
  ${CURSOR_POOL_WORKBENCH_AUTH_GATE_END_MARKER}`;
@@ -125,6 +155,22 @@ function buildLocalProviderConfigReplacement() {
125
155
  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
156
  }
127
157
 
158
+ function buildComposerSubmitAuthGateReplacement(anchor: string) {
159
+ if (anchor === CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_LINUX_3_6) {
160
+ return 'if(!h()&&!globalThis.__cursorPoolIsPlatformModeActive?.()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(P5,"general");return}';
161
+ }
162
+ if (anchor === CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_7) {
163
+ return 'if(!h()&&!globalThis.__cursorPoolIsPlatformModeActive?.()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(a6,"general");return}';
164
+ }
165
+ if (anchor === CURSOR_WORKBENCH_MAIN_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4) {
166
+ return 'if(!v()&&!globalThis.__cursorPoolIsPlatformModeActive?.()){e.cursorAuthenticationService.login(),e.commandService.executeCommand($6,"general");return}';
167
+ }
168
+ if (anchor === CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4) {
169
+ return `if(!t()&&!${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}){e.cursorAuthenticationService.login();return}`;
170
+ }
171
+ return 'if(!p()&&!globalThis.__cursorPoolIsPlatformModeActive?.()){e.cursorAuthenticationService.login(),e.commandService.executeCommand(wV,"general");return}';
172
+ }
173
+
128
174
  function forceNativeLocalAgentMode(content: string) {
129
175
  if (!content.includes(CURSOR_WORKBENCH_BUILD_FLAGS_LOCAL_MODE_ANCHOR)) {
130
176
  throw new Error('Cursor Workbench localMode build flag anchor was not found.');
@@ -144,6 +190,8 @@ function forceNativeLocalAgentMode(content: string) {
144
190
  const runBranchAnchor = [
145
191
  CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR,
146
192
  CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_LINUX_3_6,
193
+ CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_MAC_3_7,
194
+ CURSOR_WORKBENCH_AGENT_CLIENT_RUN_LOCAL_MODE_ANCHOR_MAC_3_4,
147
195
  ].find((anchor) => withProviderConfig.includes(anchor));
148
196
  const runBranchIndex = runBranchAnchor
149
197
  ? withProviderConfig.indexOf(runBranchAnchor)
@@ -152,10 +200,20 @@ function forceNativeLocalAgentMode(content: string) {
152
200
  throw new Error('Cursor Workbench agent client run localMode anchor was not found.');
153
201
  }
154
202
  const runBranchReplacement = runBranchAnchor!.replace(
155
- runBranchAnchor!.startsWith('if(uv.localMode)') ? 'if(uv.localMode)' : 'if(L0.localMode)',
203
+ runBranchAnchor!.startsWith('if(uv.localMode)')
204
+ ? 'if(uv.localMode)'
205
+ : runBranchAnchor!.startsWith('if(wv.localMode)')
206
+ ? 'if(wv.localMode)'
207
+ : runBranchAnchor!.startsWith('if(U0.localMode)')
208
+ ? 'if(U0.localMode)'
209
+ : 'if(L0.localMode)',
156
210
  runBranchAnchor!.startsWith('if(uv.localMode)')
157
211
  ? `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||uv.localMode)`
158
- : `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||L0.localMode)`,
212
+ : runBranchAnchor!.startsWith('if(wv.localMode)')
213
+ ? `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||wv.localMode)`
214
+ : runBranchAnchor!.startsWith('if(U0.localMode)')
215
+ ? `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||U0.localMode)`
216
+ : `if(${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}||L0.localMode)`,
159
217
  );
160
218
  return `${withProviderConfig.slice(0, runBranchIndex)}${runBranchReplacement}${withProviderConfig.slice(
161
219
  runBranchIndex + runBranchAnchor!.length,
@@ -171,7 +229,13 @@ export function injectCursorWorkbenchAuthGatePatch(content: string) {
171
229
  const linux36GateIndex = content.indexOf(
172
230
  CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6,
173
231
  );
174
- if (anchorIndex < 0 && linux36GateIndex < 0) {
232
+ const mac37GateIndex = content.indexOf(
233
+ CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_7,
234
+ );
235
+ const mac34GateIndex = content.indexOf(
236
+ CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_4,
237
+ );
238
+ if (anchorIndex < 0 && linux36GateIndex < 0 && mac37GateIndex < 0 && mac34GateIndex < 0) {
175
239
  throw new Error('Cursor Workbench composer auth gate anchor was not found.');
176
240
  }
177
241
 
@@ -184,11 +248,25 @@ export function injectCursorWorkbenchAuthGatePatch(content: string) {
184
248
  const linux36GateIndexWithPreflight = contentWithPreflight.indexOf(
185
249
  CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6,
186
250
  );
251
+ const mac37GateIndexWithPreflight = contentWithPreflight.indexOf(
252
+ CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_7,
253
+ );
254
+ const mac34GateIndexWithPreflight = contentWithPreflight.indexOf(
255
+ CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_4,
256
+ );
187
257
 
188
258
  const withUiGate = anchorIndexWithPreflight >= 0
189
259
  ? `${contentWithPreflight.slice(0, anchorIndexWithPreflight)}get when(){return (p()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION})&&!fzC},${buildCursorWorkbenchAuthGatePatchSnippet()}get fallback(){return he(DGC,{})}${contentWithPreflight.slice(
190
260
  anchorIndexWithPreflight + CURSOR_WORKBENCH_COMPOSER_AUTH_GATE_ANCHOR.length,
191
261
  )}`
262
+ : mac37GateIndexWithPreflight >= 0
263
+ ? `${contentWithPreflight.slice(0, mac37GateIndexWithPreflight)}get when(){return t()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}},${buildCursorWorkbenchAuthGatePatchSnippet()}get fallback(){return(()=>{var R=Swx();return ge(R,ie(go,{keybinding:" \\u23CE",onClick:E,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),R})()},get children(){return${contentWithPreflight.slice(
264
+ mac37GateIndexWithPreflight + CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_7.length,
265
+ )}`
266
+ : mac34GateIndexWithPreflight >= 0
267
+ ? `${contentWithPreflight.slice(0, mac34GateIndexWithPreflight)}get when(){return t()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION}},${buildCursorWorkbenchAuthGatePatchSnippet()}get fallback(){return(()=>{var R=npC();return ke(R,re(ea,{keybinding:" \\u23CE",onClick:E,hintText:"Log in to use Cloud Agents",variant:"secondary",children:"Log in"})),R})()},get children(){return${contentWithPreflight.slice(
268
+ mac34GateIndexWithPreflight + CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_4.length,
269
+ )}`
192
270
  : `${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
271
  linux36GateIndexWithPreflight + CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_LINUX_3_6.length,
194
272
  )}`;
@@ -211,21 +289,57 @@ export function injectCursorWorkbenchAuthGatePatch(content: string) {
211
289
  )
212
290
  : withAgentEditorSendButtonGate;
213
291
 
292
+ const withAgentEditorCursorAiLoginGate = withAgentEditorSubmitGate.includes(
293
+ CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_LINUX_3_6,
294
+ )
295
+ ? withAgentEditorSubmitGate.replace(
296
+ CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_LINUX_3_6,
297
+ `get when(){return (h()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION})&&!Xk1},get fallback(){return ie(X_1,{})},get children(){return ie(i01,`,
298
+ )
299
+ : withAgentEditorSubmitGate.includes(
300
+ CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_MAC_3_7,
301
+ )
302
+ ? withAgentEditorSubmitGate.replace(
303
+ CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_MAC_3_7,
304
+ `get when(){return (h()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION})&&!rYT},get fallback(){return ie(CzT,{})},get children(){return ie(AVT,`,
305
+ )
306
+ : withAgentEditorSubmitGate.includes(
307
+ CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_MAC_3_4,
308
+ )
309
+ ? withAgentEditorSubmitGate.replace(
310
+ CURSOR_WORKBENCH_AGENT_EDITOR_BOTTOM_BAR_AUTH_GATE_ANCHOR_MAC_3_4,
311
+ `get when(){return (v()||${CURSOR_POOL_PLATFORM_MODE_GUARD_EXPRESSION})&&!HG1},get fallback(){return re(s71,{})},get children(){return re(u$1,`,
312
+ )
313
+ : withAgentEditorSubmitGate;
214
314
  const submitGateAnchor = [
215
315
  CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR,
216
316
  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) {
317
+ CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_7,
318
+ CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4,
319
+ CURSOR_WORKBENCH_MAIN_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4,
320
+ ].find((anchor) => withAgentEditorCursorAiLoginGate.includes(anchor));
321
+ const submitGateIndex = submitGateAnchor ? withAgentEditorCursorAiLoginGate.indexOf(submitGateAnchor) : -1;
322
+ const mac34SubmitReplacement = buildComposerSubmitAuthGateReplacement(
323
+ CURSOR_WORKBENCH_COMPOSER_SUBMIT_AUTH_GATE_ANCHOR_MAC_3_4,
324
+ );
325
+ const isMac34ComposerPatch = contentWithPreflight.includes(
326
+ CURSOR_WORKBENCH_COMPOSER_SEND_BUTTON_AUTH_GATE_ANCHOR_MAC_3_4,
327
+ );
328
+ if (
329
+ submitGateIndex < 0 &&
330
+ !(isMac34ComposerPatch && withAgentEditorCursorAiLoginGate.includes(mac34SubmitReplacement))
331
+ ) {
220
332
  throw new Error('Cursor Workbench composer submit auth gate anchor was not found.');
221
333
  }
222
334
 
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
- )}`;
335
+ const submitGateReplacement = submitGateAnchor
336
+ ? buildComposerSubmitAuthGateReplacement(submitGateAnchor)
337
+ : '';
338
+ const withSubmitGate = submitGateIndex >= 0
339
+ ? `${withAgentEditorCursorAiLoginGate.slice(0, submitGateIndex)}${submitGateReplacement}${withAgentEditorCursorAiLoginGate.slice(
340
+ submitGateIndex + submitGateAnchor!.length,
341
+ )}`
342
+ : withAgentEditorCursorAiLoginGate;
229
343
 
230
344
  const agentLoopIndex = withSubmitGate.indexOf(CURSOR_WORKBENCH_AGENT_LOOP_RUN_ANCHOR);
231
345
  if (
@@ -349,6 +349,16 @@ test('agent exec patch injects the wrapper before Cursor registers the provider'
349
349
  );
350
350
  });
351
351
 
352
+ test('agent exec patch supports the Cursor 3.4 registerAgentExecProvider anchor', () => {
353
+ const anchor = 'const dt=D.cursor.registerAgentExecProvider(ut);';
354
+ assert.equal(CURSOR_POOL_AGENT_EXEC_PROVIDER_REGISTER_ANCHORS.includes(anchor), true);
355
+
356
+ const patched = injectCursorAgentExecPatchSnippet(`before();${anchor}after();`);
357
+
358
+ assert.equal(patched.includes(CURSOR_POOL_PATCH_SIGNATURE), true);
359
+ assert.ok(patched.indexOf(CURSOR_POOL_PATCH_SIGNATURE) < patched.indexOf(anchor));
360
+ });
361
+
352
362
  test('agent exec patch supports the Cursor 3.6 registerAgentExecProvider anchor', () => {
353
363
  const anchor = 'const ht=c.cursor.registerAgentExecProvider(mt);';
354
364
  assert.equal(CURSOR_POOL_AGENT_EXEC_PROVIDER_REGISTER_ANCHORS.includes(anchor), true);
@@ -359,6 +369,41 @@ test('agent exec patch supports the Cursor 3.6 registerAgentExecProvider anchor'
359
369
  assert.ok(patched.indexOf(CURSOR_POOL_PATCH_SIGNATURE) < patched.indexOf(anchor));
360
370
  });
361
371
 
372
+ test('agent exec patch supports the Cursor 3.7 registerAgentExecProvider anchor', () => {
373
+ const anchor = 'const Et=c.cursor.registerAgentExecProvider(vt);';
374
+ assert.equal(CURSOR_POOL_AGENT_EXEC_PROVIDER_REGISTER_ANCHORS.includes(anchor), true);
375
+
376
+ const patched = injectCursorAgentExecPatchSnippet(`before();${anchor}after();`);
377
+
378
+ assert.equal(patched.includes(CURSOR_POOL_PATCH_SIGNATURE), true);
379
+ assert.ok(patched.indexOf(CURSOR_POOL_PATCH_SIGNATURE) < patched.indexOf(anchor));
380
+ });
381
+
382
+ test('agent exec patch normalizes Cursor 3.7 LocalAgentClient options to include a localProvider', () => {
383
+ const content = [
384
+ 'class E9{async run(e,t,n,r,s,o,i,a,l,c,u){',
385
+ 'const A="bedrock"===(y=this.options.localProvider).kind?`bedrock:${y.region}`:y.baseUrl;',
386
+ 'const{LocalAgentClient:t}=await Be(),r=new t({baseUrl:e.baseUrl,apiKey:e.apiKey,userAgent:e.userAgent,defaultModel:p,privacyMode:e.privacyMode});',
387
+ '}}',
388
+ 'const Et=c.cursor.registerAgentExecProvider(vt);',
389
+ ].join('');
390
+
391
+ const patched = injectCursorAgentExecPatchSnippet(content);
392
+
393
+ assert.equal(
394
+ patched.includes(
395
+ 'new t({localProvider:{kind:"http",baseUrl:e.baseUrl,apiKey:e.apiKey},userAgent:e.userAgent,defaultModel:p,privacyMode:e.privacyMode})',
396
+ ),
397
+ true,
398
+ );
399
+ assert.equal(
400
+ patched.includes(
401
+ 'new t({baseUrl:e.baseUrl,apiKey:e.apiKey,userAgent:e.userAgent,defaultModel:p,privacyMode:e.privacyMode})',
402
+ ),
403
+ false,
404
+ );
405
+ });
406
+
362
407
  test('agent exec provider wrapper works when Cursor API object is minified as c', async () => {
363
408
  const snippet = buildCursorAgentExecPatchSnippet();
364
409
  const registered: unknown[] = [];
@@ -388,7 +433,27 @@ const require = (specifier) => {
388
433
  return { join: (...parts) => parts.join('/') };
389
434
  }
390
435
  if (specifier === 'node:http') {
391
- return { request() { return { on() { return this; }, end() {}, destroy() {} }; } };
436
+ return {
437
+ request(_options, callback) {
438
+ return {
439
+ on() { return this; },
440
+ end() {
441
+ callback({
442
+ setEncoding() {},
443
+ on(event, handler) {
444
+ if (event === 'data') {
445
+ handler(JSON.stringify({ state: 'rejected', requestId: 'takeover-1', reason: 'invalid-session' }));
446
+ }
447
+ if (event === 'end') {
448
+ handler();
449
+ }
450
+ },
451
+ });
452
+ },
453
+ destroy() {},
454
+ };
455
+ },
456
+ };
392
457
  }
393
458
  throw new Error('unexpected require ' + specifier);
394
459
  };
@@ -413,7 +478,7 @@ return registered[0];`,
413
478
  assert.equal(await wrappedProvider.runLocalAgent(), 'ok');
414
479
  });
415
480
 
416
- test('agent exec provider wrapper preserves original runLocalAgent so Cursor local client can consume OpenAI endpoint', async () => {
481
+ test('agent exec provider wrapper records takeover before preserving original runLocalAgent', async () => {
417
482
  const snippet = buildCursorAgentExecPatchSnippet();
418
483
  const runtime = { host: '127.0.0.1', port: 32123, runtimeId: 'runtime-test' };
419
484
  const calls: string[] = [];
@@ -508,6 +573,8 @@ return registered[0];`,
508
573
  const wrappedProvider = registered[0] as typeof originalProvider;
509
574
  await wrappedProvider.runLocalAgent(
510
575
  {
576
+ requestId: 'agent-req-1',
577
+ modelName: 'gpt-test',
511
578
  runOptions: { generationUUID: 'req-1' },
512
579
  modelDetails: undefined,
513
580
  defaultModel: undefined,
@@ -515,11 +582,25 @@ return registered[0];`,
515
582
  {},
516
583
  );
517
584
 
518
- assert.deepEqual(calls, ['original-runLocalAgent']);
519
- assert.equal((sandbox.globalThis.__cursorPoolAgentExecTakeover as { lastAnswer?: unknown }).lastAnswer, undefined);
585
+ assert.equal(calls.length, 2);
586
+ assert.deepEqual(JSON.parse(calls[0]!), {
587
+ requestId: 'agent-req-1',
588
+ source: 'cursor-agent-exec',
589
+ model: 'gpt-test',
590
+ stream: true,
591
+ bodyShape: 'redacted',
592
+ });
593
+ assert.equal(calls[1], 'original-runLocalAgent');
594
+ assert.deepEqual((sandbox.globalThis.__cursorPoolAgentExecTakeover as { lastTakeover?: unknown }).lastTakeover, {
595
+ state: 'answered',
596
+ requestId: 'takeover-1',
597
+ source: 'cursor-agent-exec',
598
+ model: 'gpt-test',
599
+ content: '来自 Cursor Pool 本地测试 provider',
600
+ });
520
601
  });
521
602
 
522
- test('agent exec provider wrapper preserves original createStream so Cursor stream frames are not swallowed', async () => {
603
+ test('agent exec provider wrapper records takeover before preserving original createStream', async () => {
523
604
  const snippet = buildCursorAgentExecPatchSnippet();
524
605
  const runtime = { host: '127.0.0.1', port: 32123, runtimeId: 'runtime-test' };
525
606
  const calls: string[] = [];
@@ -624,7 +705,21 @@ return registered[0];`,
624
705
  frames.push(frame);
625
706
  }
626
707
 
627
- assert.deepEqual(calls, ['original-createStream']);
708
+ assert.equal(calls.length, 2);
709
+ assert.deepEqual(JSON.parse(calls[0]!), {
710
+ requestId: 'stream-1',
711
+ source: 'cursor-agent-exec',
712
+ model: 'gpt-test',
713
+ stream: true,
714
+ bodyShape: 'redacted',
715
+ });
716
+ assert.equal(calls[1], 'original-createStream');
628
717
  assert.deepEqual(frames, [originalFrame]);
629
- assert.equal((sandbox.globalThis.__cursorPoolAgentExecTakeover as { lastAnswer?: unknown }).lastAnswer, undefined);
718
+ assert.deepEqual((sandbox.globalThis.__cursorPoolAgentExecTakeover as { lastTakeover?: unknown }).lastTakeover, {
719
+ state: 'answered',
720
+ requestId: 'takeover-1',
721
+ source: 'cursor-agent-exec',
722
+ model: 'gpt-test',
723
+ content: '来自 Cursor Pool 本地测试 provider',
724
+ });
630
725
  });