opencode-windsurf-codeium 0.1.0

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/README.md ADDED
@@ -0,0 +1,272 @@
1
+ # opencode-windsurf-codeium
2
+
3
+ OpenCode plugin for Windsurf/Codeium authentication - use Windsurf models in OpenCode.
4
+
5
+ ## Overview
6
+
7
+ This plugin enables OpenCode users to access Windsurf/Codeium models by leveraging their existing Windsurf installation. It communicates directly with the **local Windsurf language server** via gRPC - no network traffic capture or OAuth flows required.
8
+
9
+ ### How It Works
10
+
11
+ 1. **Credential Discovery**: Extracts CSRF token and port from the running `language_server_macos` process
12
+ 2. **API Key**: Reads from `~/.codeium/config.json`
13
+ 3. **gRPC Communication**: Sends requests to `localhost:{port}` using HTTP/2 gRPC protocol
14
+ 4. **Response Transformation**: Converts gRPC responses to OpenAI-compatible SSE format
15
+
16
+ ### Supported Models (90+)
17
+
18
+ | Category | Models |
19
+ |----------|--------|
20
+ | **SWE** | `swe-1.5`, `swe-1.5-thinking` |
21
+ | **Claude** | `claude-3.5-sonnet`, `claude-3.7-sonnet`, `claude-4-opus`, `claude-4-sonnet`, `claude-4.5-sonnet`, `claude-4.5-opus`, `claude-code` |
22
+ | **GPT** | `gpt-4o`, `gpt-4.5`, `gpt-4.1`, `gpt-5`, `gpt-5.2`, `gpt-5-codex` |
23
+ | **O-Series** | `o1`, `o3`, `o3-mini`, `o3-pro`, `o4-mini` |
24
+ | **Gemini** | `gemini-2.5-flash`, `gemini-2.5-pro`, `gemini-3.0-pro` |
25
+ | **DeepSeek** | `deepseek-v3`, `deepseek-r1`, `deepseek-r1-fast` |
26
+ | **Llama** | `llama-3.1-8b`, `llama-3.1-70b`, `llama-3.1-405b`, `llama-3.3-70b` |
27
+ | **Qwen** | `qwen-2.5-72b`, `qwen-3-235b`, `qwen-3-coder-480b` |
28
+ | **Grok** | `grok-2`, `grok-3`, `grok-code-fast` |
29
+ | **Other** | `mistral-7b`, `kimi-k2`, `glm-4.5`, `minimax-m2` |
30
+
31
+ ## Prerequisites
32
+
33
+ 1. **Windsurf IDE installed** - Download from [windsurf.com](https://windsurf.com)
34
+ 2. **Windsurf running** - The plugin communicates with the local language server
35
+ 3. **Logged into Windsurf** - Provides API key in `~/.codeium/config.json`
36
+ 4. **Active Windsurf subscription** - Model access depends on your plan
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ bun add opencode-windsurf-codeium
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ Add to your OpenCode configuration (`~/.config/opencode/opencode.json`):
47
+
48
+ ```json
49
+ {
50
+ "plugin": ["opencode-windsurf-codeium"],
51
+ "provider": {
52
+ "windsurf": {
53
+ "models": {
54
+ "claude-4.5-sonnet": {
55
+ "name": "Claude 4.5 Sonnet (Windsurf)",
56
+ "limit": { "context": 200000, "output": 64000 }
57
+ },
58
+ "swe-1.5": {
59
+ "name": "SWE 1.5 (Windsurf)",
60
+ "limit": { "context": 128000, "output": 32000 }
61
+ },
62
+ "gpt-5": {
63
+ "name": "GPT-5 (Windsurf)",
64
+ "limit": { "context": 128000, "output": 32000 }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ Then run:
73
+
74
+ ```bash
75
+ opencode run "Hello" --model=windsurf/claude-4.5-sonnet
76
+ ```
77
+
78
+ ## Testing Inside OpenCode
79
+
80
+ 1. **Build and install the plugin locally**
81
+ ```bash
82
+ bun run build
83
+ bun add -g /path/to/opencode-windsurf-codeium
84
+ ```
85
+ Installing globally makes the package resolvable when OpenCode loads npm plugins.
86
+
87
+ 2. **Update your OpenCode config** (`~/.config/opencode/opencode.json`):
88
+ ```json
89
+ {
90
+ "$schema": "https://opencode.ai/config.json",
91
+ "plugin": ["opencode-windsurf-codeium"],
92
+ "provider": {
93
+ "windsurf": {
94
+ "models": {
95
+ "claude-4.5-sonnet": { "name": "Claude 4.5 Sonnet (Windsurf)" },
96
+ "swe-1.5": { "name": "SWE 1.5 (Windsurf)" },
97
+ "gpt-5": { "name": "GPT-5 (Windsurf)" }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ ```
103
+ Adding the package name to the `plugin` array tells OpenCode to load this plugin at startup, while the `provider.windsurf.models` block exposes friendly names and limits inside the TUI.
104
+
105
+ 3. **Verify the plugin is active**
106
+ ```bash
107
+ opencode doctor # confirms plugin load + provider wiring
108
+ opencode models list # should show windsurf/* models
109
+ opencode chat --model=windsurf/claude-4.5-sonnet "Test message"
110
+ ```
111
+ Run these commands while Windsurf is running and logged-in so the plugin can discover credentials from the local language server.
112
+
113
+ ## Verification
114
+
115
+ To verify the plugin can communicate with Windsurf:
116
+
117
+ ```bash
118
+ # 1. Check Windsurf is running
119
+ ps aux | grep language_server_macos
120
+
121
+ # 2. Extract credentials manually
122
+ ps aux | grep language_server_macos | grep -oE '\-\-csrf_token\s+[a-f0-9-]+'
123
+ ps aux | grep language_server_macos | grep -oE '\-\-extension_server_port\s+[0-9]+'
124
+ cat ~/.codeium/config.json | grep apiKey
125
+
126
+ # 3. Test gRPC endpoint (port = extension_server_port + 2)
127
+ curl -X POST http://localhost:{port}/exa.language_server_pb.LanguageServerService/RawGetChatMessage \
128
+ -H "content-type: application/grpc" \
129
+ -H "te: trailers" \
130
+ -H "x-codeium-csrf-token: YOUR_TOKEN" \
131
+ --data-binary ""
132
+ ```
133
+
134
+ ## Architecture
135
+
136
+ ```
137
+ ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐
138
+ │ OpenCode │────▶│ Windsurf Plugin │────▶│ language_server │
139
+ │ (requests) │ │ (transform) │ │ (local gRPC) │
140
+ └─────────────────┘ └──────────────────┘ └─────────────────────┘
141
+
142
+
143
+ ┌──────────────────┐
144
+ │ ~/.codeium/ │
145
+ │ config.json │
146
+ │ (API key) │
147
+ └──────────────────┘
148
+ ```
149
+
150
+ ### File Structure
151
+
152
+ ```
153
+ src/
154
+ ├── plugin.ts # Main plugin, OpenAI-compatible fetch handler
155
+ ├── constants.ts # Plugin ID, gRPC service names
156
+ └── plugin/
157
+ ├── auth.ts # Credential discovery from process args
158
+ ├── grpc-client.ts # HTTP/2 gRPC client with protobuf encoding
159
+ ├── models.ts # Model name → enum mappings
160
+ └── types.ts # TypeScript types, ModelEnum values
161
+ ```
162
+
163
+ ## Development
164
+
165
+ ```bash
166
+ # Install dependencies
167
+ bun install
168
+
169
+ # Build
170
+ bun run build
171
+
172
+ # Type check
173
+ bun run typecheck
174
+
175
+ # Run tests
176
+ bun test
177
+ ```
178
+
179
+ ## Publishing (beta tag)
180
+
181
+ To release the plugin as `opencode-windsurf-codeium@beta` using Bun:
182
+
183
+ 1. **Bump the version** – update `package.json` with the new semantic version (e.g., `0.2.0-beta.1`).
184
+ 2. **Login once** – run `npm login` (Bun reuses the credentials in `~/.npmrc`).
185
+ 3. **Build & verify** – `bun run build && bun test` to ensure `dist/` is fresh.
186
+ 4. **Publish with tag** –
187
+ ```bash
188
+ bun publish --tag beta --access public
189
+ ```
190
+ This creates the `opencode-windsurf-codeium@beta` dist-tag so OpenCode users can install the beta specifically via `bun add opencode-windsurf-codeium@beta`.
191
+
192
+ For stable releases, rerun `bun publish` without `--tag beta` (or with `--tag latest`).
193
+
194
+ ## How It Works (Technical Details)
195
+
196
+ ### 1. Credential Discovery
197
+
198
+ The plugin discovers credentials from the running Windsurf process:
199
+
200
+ ```bash
201
+ # Process args contain:
202
+ --csrf_token abc123-def456-...
203
+ --extension_server_port 42100
204
+ --windsurf_version 1.13.104
205
+ ```
206
+
207
+ The gRPC port is `extension_server_port + 2`.
208
+
209
+ ### 2. Protobuf Encoding
210
+
211
+ Requests are manually encoded to protobuf format (no protobuf library needed):
212
+
213
+ ```typescript
214
+ // Encode a string field (wire type 2)
215
+ function encodeString(fieldNum: number, str: string): number[] {
216
+ const strBytes = Buffer.from(str, 'utf8');
217
+ return [(fieldNum << 3) | 2, ...encodeVarint(strBytes.length), ...strBytes];
218
+ }
219
+ ```
220
+
221
+ ### 3. Model Enum Values
222
+
223
+ Model names are mapped to protobuf enum values extracted from Windsurf's `extension.js`:
224
+
225
+ ```typescript
226
+ const ModelEnum = {
227
+ CLAUDE_4_5_SONNET: 353,
228
+ CLAUDE_4_5_OPUS: 391,
229
+ GPT_5: 340,
230
+ SWE_1_5: 359,
231
+ // ... 80+ more
232
+ };
233
+ ```
234
+
235
+ ### 4. gRPC Service
236
+
237
+ Requests go to the local language server:
238
+
239
+ ```
240
+ POST http://localhost:{port}/exa.language_server_pb.LanguageServerService/RawGetChatMessage
241
+ Headers:
242
+ content-type: application/grpc
243
+ te: trailers
244
+ x-codeium-csrf-token: {csrf_token}
245
+ ```
246
+
247
+ ## Reverse Engineering Notes
248
+
249
+ The model enum values were extracted from:
250
+ ```
251
+ /Applications/Windsurf.app/Contents/Resources/app/extensions/windsurf/dist/extension.js
252
+ ```
253
+
254
+ To discover new models:
255
+ ```bash
256
+ grep -oE '[A-Z0-9_]+\s*=\s*[0-9]+' extension.js | grep -E 'CLAUDE|GPT|GEMINI|DEEPSEEK'
257
+ ```
258
+
259
+ ## Known Limitations
260
+
261
+ - **Windsurf must be running** - The plugin communicates with the local language server
262
+ - **macOS focus** - Linux/Windows paths need verification
263
+ - **Response parsing** - Uses heuristic text extraction from protobuf (may miss edge cases)
264
+ - **No tool calling yet** - Basic chat completion only
265
+
266
+ ## Related Projects
267
+
268
+ - [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) - Similar plugin for Google's Antigravity API
269
+
270
+ ## License
271
+
272
+ MIT
@@ -0,0 +1,30 @@
1
+ /**
2
+ * OpenCode Windsurf Auth Plugin
3
+ *
4
+ * Enables using Windsurf/Codeium models through OpenCode by leveraging
5
+ * Windsurf's local language server and authentication.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { WindsurfPlugin } from 'opencode-windsurf-codeium';
10
+ *
11
+ * // Use in OpenCode configuration
12
+ * export default {
13
+ * plugins: [WindsurfPlugin],
14
+ * };
15
+ * ```
16
+ *
17
+ * Requirements:
18
+ * - Windsurf must be installed and running
19
+ * - User must be logged into Windsurf
20
+ */
21
+ export { createWindsurfPlugin, WindsurfPlugin, CodeiumPlugin } from './src/plugin.js';
22
+ export { getCredentials, getCSRFToken, getPort, getApiKey, getWindsurfVersion, isWindsurfRunning, isWindsurfInstalled, validateCredentials, WindsurfError, WindsurfErrorCode, } from './src/plugin/auth.js';
23
+ export type { WindsurfCredentials } from './src/plugin/auth.js';
24
+ export { streamChat, streamChatGenerator } from './src/plugin/grpc-client.js';
25
+ export type { ChatMessage, StreamChatOptions } from './src/plugin/grpc-client.js';
26
+ export { modelNameToEnum, enumToModelName, getSupportedModels, isModelSupported, getDefaultModel, getDefaultModelEnum, getCanonicalModels, } from './src/plugin/models.js';
27
+ export { PLUGIN_ID, GRPC_SERVICES, GRPC_METHODS, } from './src/constants.js';
28
+ export { ModelEnum, ChatMessageSource } from './src/plugin/types.js';
29
+ export type { ModelEnumValue, ChatMessageSourceValue } from './src/plugin/types.js';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,aAAa,EACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,OAAO,EACL,UAAU,EACV,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGlF,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,SAAS,EACT,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,cAAc,EACd,sBAAsB,EACvB,MAAM,uBAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * OpenCode Windsurf Auth Plugin
3
+ *
4
+ * Enables using Windsurf/Codeium models through OpenCode by leveraging
5
+ * Windsurf's local language server and authentication.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { WindsurfPlugin } from 'opencode-windsurf-codeium';
10
+ *
11
+ * // Use in OpenCode configuration
12
+ * export default {
13
+ * plugins: [WindsurfPlugin],
14
+ * };
15
+ * ```
16
+ *
17
+ * Requirements:
18
+ * - Windsurf must be installed and running
19
+ * - User must be logged into Windsurf
20
+ */
21
+ // Main plugin exports
22
+ export { createWindsurfPlugin, WindsurfPlugin, CodeiumPlugin } from './src/plugin.js';
23
+ // Auth/credential utilities
24
+ export { getCredentials, getCSRFToken, getPort, getApiKey, getWindsurfVersion, isWindsurfRunning, isWindsurfInstalled, validateCredentials, WindsurfError, WindsurfErrorCode, } from './src/plugin/auth.js';
25
+ // gRPC client
26
+ export { streamChat, streamChatGenerator } from './src/plugin/grpc-client.js';
27
+ // Model utilities
28
+ export { modelNameToEnum, enumToModelName, getSupportedModels, isModelSupported, getDefaultModel, getDefaultModelEnum, getCanonicalModels, } from './src/plugin/models.js';
29
+ // Constants
30
+ export { PLUGIN_ID, GRPC_SERVICES, GRPC_METHODS, } from './src/constants.js';
31
+ // Types
32
+ export { ModelEnum, ChatMessageSource } from './src/plugin/types.js';
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,sBAAsB;AACtB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,4BAA4B;AAC5B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,OAAO,EACP,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAI9B,cAAc;AACd,OAAO,EACL,UAAU,EACV,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AAIrC,kBAAkB;AAClB,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,YAAY;AACZ,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,QAAQ;AACR,OAAO,EACL,SAAS,EACT,iBAAiB,EAClB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Windsurf/Codeium API Constants
3
+ *
4
+ * Based on reverse-engineering of Windsurf extension.js
5
+ * These endpoints and configurations may change with Windsurf updates.
6
+ */
7
+ /** Primary Codeium API server */
8
+ export declare const CODEIUM_API_SERVER = "https://server.codeium.com";
9
+ /** Inference API server */
10
+ export declare const CODEIUM_INFERENCE_SERVER = "https://inference.codeium.com";
11
+ /** User registration server */
12
+ export declare const WINDSURF_REGISTER_SERVER = "https://register.windsurf.com";
13
+ /** Feature flags (Unleash) */
14
+ export declare const CODEIUM_UNLEASH_SERVER = "https://unleash.codeium.com/api";
15
+ /** EU region endpoint */
16
+ export declare const WINDSURF_EU_SERVER = "https://eu.windsurf.com/_route/api_server";
17
+ /** FedStart (government) endpoint */
18
+ export declare const WINDSURF_FEDSTART_SERVER = "https://windsurf.fedstart.com/_route/api_server";
19
+ /** gRPC-web content types */
20
+ export declare const GRPC_CONTENT_TYPES: {
21
+ readonly PROTO: "application/grpc-web+proto";
22
+ readonly JSON: "application/grpc-web+json";
23
+ readonly NATIVE: "application/grpc+proto";
24
+ };
25
+ /** Known gRPC service namespaces (from extension analysis) */
26
+ export declare const GRPC_SERVICES: {
27
+ readonly LANGUAGE_SERVER: "exa.language_server_pb.LanguageServerService";
28
+ readonly API_SERVER: "exa.api_server_pb.ApiServerService";
29
+ readonly SEAT_MANAGEMENT: "exa.seat_management_pb.SeatManagementService";
30
+ readonly EXTENSION_SERVER: "exa.extension_server_pb.ExtensionServerService";
31
+ };
32
+ /** Key gRPC methods for inference */
33
+ export declare const GRPC_METHODS: {
34
+ readonly GET_CHAT_MESSAGE: "GetChatMessage";
35
+ readonly GET_CHAT_COMPLETIONS: "GetChatCompletions";
36
+ readonly SEND_USER_CASCADE_MESSAGE: "SendUserCascadeMessage";
37
+ readonly START_CASCADE: "StartCascade";
38
+ readonly STREAM_CASCADE_REACTIVE_UPDATES: "StreamCascadeReactiveUpdates";
39
+ readonly GET_AUTH_TOKEN: "GetAuthToken";
40
+ readonly GET_USER_STATUS: "GetUserStatus";
41
+ readonly REGISTER_USER: "RegisterUser";
42
+ readonly START_DEVICE_FLOW: "StartDeviceFlow";
43
+ readonly GET_DEVICE_FLOW_STATE: "GetDeviceFlowState";
44
+ readonly GET_COMPLETIONS: "GetCompletions";
45
+ readonly GET_STREAMING_COMPLETIONS: "GetStreamingCompletions";
46
+ };
47
+ /** Windsurf internal model identifiers */
48
+ export declare const WINDSURF_MODELS: {
49
+ readonly SWE_1: "swe-1-model-id";
50
+ readonly SWE_1_5: "cognition-swe-1.5";
51
+ readonly SWE_1_LITE: "swe-1-lite-model-id";
52
+ readonly VISTA: "vista-model-id";
53
+ readonly SHAMU: "shamu-model-id";
54
+ readonly CLAUDE_3_5_SONNET: "CLAUDE_3_5_SONNET_20241022";
55
+ readonly CLAUDE_3_7_SONNET: "CLAUDE_3_7_SONNET_20250219";
56
+ readonly CLAUDE_3_7_SONNET_THINKING: "CLAUDE_3_7_SONNET_20250219_THINKING";
57
+ readonly CLAUDE_4_OPUS: "CLAUDE_4_OPUS";
58
+ readonly CLAUDE_4_OPUS_THINKING: "CLAUDE_4_OPUS_THINKING";
59
+ readonly CLAUDE_4_SONNET: "CLAUDE_4_SONNET";
60
+ readonly CLAUDE_4_SONNET_THINKING: "CLAUDE_4_SONNET_THINKING";
61
+ readonly CLAUDE_4_5_SONNET: "CLAUDE_4_5_SONNET";
62
+ readonly CLAUDE_4_5_SONNET_THINKING: "CLAUDE_4_5_SONNET_THINKING";
63
+ readonly CLAUDE_4_5_OPUS: "CLAUDE_4_5_OPUS";
64
+ readonly CLAUDE_4_5_OPUS_THINKING: "CLAUDE_4_5_OPUS_THINKING";
65
+ readonly GEMINI_2_5_FLASH: "GEMINI_2_5_FLASH";
66
+ readonly GEMINI_2_5_PRO: "GEMINI_2_5_PRO";
67
+ readonly GEMINI_3_0_FLASH_HIGH: "GEMINI_3_0_FLASH_HIGH";
68
+ readonly GEMINI_3_0_PRO_HIGH: "GEMINI_3_0_PRO_HIGH";
69
+ readonly GPT_4O: "GPT_4O_2024_08_06";
70
+ readonly GPT_4_1: "GPT_4_1";
71
+ readonly GPT_4_5: "GPT_4_5";
72
+ readonly O1: "O1";
73
+ readonly O1_MINI: "O1_MINI";
74
+ };
75
+ /** Model name mapping: OpenCode model names -> Windsurf model IDs */
76
+ export declare const MODEL_NAME_MAP: Record<string, string>;
77
+ /** macOS Keychain service name for Windsurf credentials */
78
+ export declare const KEYCHAIN_SERVICE = "Windsurf Safe Storage";
79
+ /** Keychain account name */
80
+ export declare const KEYCHAIN_ACCOUNT = "Windsurf Key";
81
+ /** Windsurf config directories */
82
+ export declare const WINDSURF_CONFIG_PATHS: {
83
+ /** Primary config directory */
84
+ readonly CODEIUM: "~/.codeium/windsurf";
85
+ /** macOS Application Support */
86
+ readonly APP_SUPPORT: "~/Library/Application Support/Windsurf";
87
+ /** Linux config */
88
+ readonly LINUX_CONFIG: "~/.config/Windsurf";
89
+ };
90
+ /** Installation ID file path */
91
+ export declare const INSTALLATION_ID_PATH = "~/.codeium/windsurf/installation_id";
92
+ /** Default local language server port (0 = dynamic) */
93
+ export declare const DEFAULT_LANGUAGE_SERVER_PORT = 0;
94
+ /** Language server binary path (macOS ARM) */
95
+ export declare const LANGUAGE_SERVER_BINARY = "/Applications/Windsurf.app/Contents/Resources/app/extensions/windsurf/bin/language_server_macos_arm";
96
+ /** Plugin identifier */
97
+ export declare const PLUGIN_ID = "windsurf";
98
+ /** Storage file name */
99
+ export declare const ACCOUNTS_FILE = "windsurf-accounts.json";
100
+ /** User agent for requests */
101
+ export declare const USER_AGENT = "opencode-windsurf-auth/0.1.0";
102
+ /** Headers to include in requests */
103
+ export declare const DEFAULT_HEADERS: {
104
+ readonly 'User-Agent': "opencode-windsurf-auth/0.1.0";
105
+ readonly 'X-Codeium-Csrf-Token': "";
106
+ };
107
+ /** Rate limit backoff configuration */
108
+ export declare const RATE_LIMIT_CONFIG: {
109
+ /** Initial backoff in ms */
110
+ readonly INITIAL_BACKOFF_MS: 1000;
111
+ /** Maximum backoff in ms */
112
+ readonly MAX_BACKOFF_MS: 60000;
113
+ /** Backoff multiplier */
114
+ readonly BACKOFF_MULTIPLIER: 2;
115
+ /** Maximum retry attempts */
116
+ readonly MAX_RETRIES: 5;
117
+ };
118
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,+BAA+B,CAAC;AAE/D,2BAA2B;AAC3B,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,+BAA+B;AAC/B,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,8BAA8B;AAC9B,eAAO,MAAM,sBAAsB,oCAAoC,CAAC;AAExE,yBAAyB;A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*
4
+ * Based on reverse-engineering of Windsurf extension.js
5
+ * These endpoints and configurations may change with Windsurf updates.
6
+ */
7
+ // ============================================================================
8
+ // API Endpoints
9
+ // ============================================================================
10
+ /** Primary Codeium API server */
11
+ export const CODEIUM_API_SERVER = 'https://server.codeium.com';
12
+ /** Inference API server */
13
+ export const CODEIUM_INFERENCE_SERVER = 'https://inference.codeium.com';
14
+ /** User registration server */
15
+ export const WINDSURF_REGISTER_SERVER = 'https://register.windsurf.com';
16
+ /** Feature flags (Unleash) */
17
+ export const CODEIUM_UNLEASH_SERVER = 'https://unleash.codeium.com/api';
18
+ /** EU region endpoint */
19
+ export const WINDSURF_EU_SERVER = 'https://eu.windsurf.com/_route/api_server';
20
+ /** FedStart (government) endpoint */
21
+ export const WINDSURF_FEDSTART_SERVER = 'https://windsurf.fedstart.com/_route/api_server';
22
+ // ============================================================================
23
+ // gRPC Service Paths
24
+ // ============================================================================
25
+ /** gRPC-web content types */
26
+ export const GRPC_CONTENT_TYPES = {
27
+ PROTO: 'application/grpc-web+proto',
28
+ JSON: 'application/grpc-web+json',
29
+ NATIVE: 'application/grpc+proto',
30
+ };
31
+ /** Known gRPC service namespaces (from extension analysis) */
32
+ export const GRPC_SERVICES = {
33
+ LANGUAGE_SERVER: 'exa.language_server_pb.LanguageServerService',
34
+ API_SERVER: 'exa.api_server_pb.ApiServerService',
35
+ SEAT_MANAGEMENT: 'exa.seat_management_pb.SeatManagementService',
36
+ EXTENSION_SERVER: 'exa.extension_server_pb.ExtensionServerService',
37
+ };
38
+ /** Key gRPC methods for inference */
39
+ export const GRPC_METHODS = {
40
+ // Chat/Cascade methods
41
+ GET_CHAT_MESSAGE: 'GetChatMessage',
42
+ GET_CHAT_COMPLETIONS: 'GetChatCompletions',
43
+ SEND_USER_CASCADE_MESSAGE: 'SendUserCascadeMessage',
44
+ START_CASCADE: 'StartCascade',
45
+ STREAM_CASCADE_REACTIVE_UPDATES: 'StreamCascadeReactiveUpdates',
46
+ // Auth methods
47
+ GET_AUTH_TOKEN: 'GetAuthToken',
48
+ GET_USER_STATUS: 'GetUserStatus',
49
+ REGISTER_USER: 'RegisterUser',
50
+ START_DEVICE_FLOW: 'StartDeviceFlow',
51
+ GET_DEVICE_FLOW_STATE: 'GetDeviceFlowState',
52
+ // Completions
53
+ GET_COMPLETIONS: 'GetCompletions',
54
+ GET_STREAMING_COMPLETIONS: 'GetStreamingCompletions',
55
+ };
56
+ // ============================================================================
57
+ // Model Identifiers
58
+ // ============================================================================
59
+ /** Windsurf internal model identifiers */
60
+ export const WINDSURF_MODELS = {
61
+ // SWE models (Windsurf's proprietary)
62
+ SWE_1: 'swe-1-model-id',
63
+ SWE_1_5: 'cognition-swe-1.5',
64
+ SWE_1_LITE: 'swe-1-lite-model-id',
65
+ VISTA: 'vista-model-id',
66
+ SHAMU: 'shamu-model-id',
67
+ // Claude models
68
+ CLAUDE_3_5_SONNET: 'CLAUDE_3_5_SONNET_20241022',
69
+ CLAUDE_3_7_SONNET: 'CLAUDE_3_7_SONNET_20250219',
70
+ CLAUDE_3_7_SONNET_THINKING: 'CLAUDE_3_7_SONNET_20250219_THINKING',
71
+ CLAUDE_4_OPUS: 'CLAUDE_4_OPUS',
72
+ CLAUDE_4_OPUS_THINKING: 'CLAUDE_4_OPUS_THINKING',
73
+ CLAUDE_4_SONNET: 'CLAUDE_4_SONNET',
74
+ CLAUDE_4_SONNET_THINKING: 'CLAUDE_4_SONNET_THINKING',
75
+ CLAUDE_4_5_SONNET: 'CLAUDE_4_5_SONNET',
76
+ CLAUDE_4_5_SONNET_THINKING: 'CLAUDE_4_5_SONNET_THINKING',
77
+ CLAUDE_4_5_OPUS: 'CLAUDE_4_5_OPUS',
78
+ CLAUDE_4_5_OPUS_THINKING: 'CLAUDE_4_5_OPUS_THINKING',
79
+ // Gemini models
80
+ GEMINI_2_5_FLASH: 'GEMINI_2_5_FLASH',
81
+ GEMINI_2_5_PRO: 'GEMINI_2_5_PRO',
82
+ GEMINI_3_0_FLASH_HIGH: 'GEMINI_3_0_FLASH_HIGH',
83
+ GEMINI_3_0_PRO_HIGH: 'GEMINI_3_0_PRO_HIGH',
84
+ // OpenAI models
85
+ GPT_4O: 'GPT_4O_2024_08_06',
86
+ GPT_4_1: 'GPT_4_1',
87
+ GPT_4_5: 'GPT_4_5',
88
+ O1: 'O1',
89
+ O1_MINI: 'O1_MINI',
90
+ };
91
+ /** Model name mapping: OpenCode model names -> Windsurf model IDs */
92
+ export const MODEL_NAME_MAP = {
93
+ // SWE models
94
+ 'swe-1': WINDSURF_MODELS.SWE_1,
95
+ 'swe-1.5': WINDSURF_MODELS.SWE_1_5,
96
+ 'swe-1-lite': WINDSURF_MODELS.SWE_1_LITE,
97
+ // Claude models
98
+ 'claude-3.5-sonnet': WINDSURF_MODELS.CLAUDE_3_5_SONNET,
99
+ 'claude-3.7-sonnet': WINDSURF_MODELS.CLAUDE_3_7_SONNET,
100
+ 'claude-3.7-sonnet-thinking': WINDSURF_MODELS.CLAUDE_3_7_SONNET_THINKING,
101
+ 'claude-4-opus': WINDSURF_MODELS.CLAUDE_4_OPUS,
102
+ 'claude-4-opus-thinking': WINDSURF_MODELS.CLAUDE_4_OPUS_THINKING,
103
+ 'claude-4-sonnet': WINDSURF_MODELS.CLAUDE_4_SONNET,
104
+ 'claude-4-sonnet-thinking': WINDSURF_MODELS.CLAUDE_4_SONNET_THINKING,
105
+ 'claude-4.5-sonnet': WINDSURF_MODELS.CLAUDE_4_5_SONNET,
106
+ 'claude-4.5-sonnet-thinking': WINDSURF_MODELS.CLAUDE_4_5_SONNET_THINKING,
107
+ 'claude-4.5-opus': WINDSURF_MODELS.CLAUDE_4_5_OPUS,
108
+ 'claude-4.5-opus-thinking': WINDSURF_MODELS.CLAUDE_4_5_OPUS_THINKING,
109
+ // Gemini models
110
+ 'gemini-2.5-flash': WINDSURF_MODELS.GEMINI_2_5_FLASH,
111
+ 'gemini-2.5-pro': WINDSURF_MODELS.GEMINI_2_5_PRO,
112
+ 'gemini-3-flash': WINDSURF_MODELS.GEMINI_3_0_FLASH_HIGH,
113
+ 'gemini-3-pro': WINDSURF_MODELS.GEMINI_3_0_PRO_HIGH,
114
+ // OpenAI models
115
+ 'gpt-4o': WINDSURF_MODELS.GPT_4O,
116
+ 'gpt-4.1': WINDSURF_MODELS.GPT_4_1,
117
+ 'gpt-4.5': WINDSURF_MODELS.GPT_4_5,
118
+ 'o1': WINDSURF_MODELS.O1,
119
+ 'o1-mini': WINDSURF_MODELS.O1_MINI,
120
+ };
121
+ // ============================================================================
122
+ // Authentication
123
+ // ============================================================================
124
+ /** macOS Keychain service name for Windsurf credentials */
125
+ export const KEYCHAIN_SERVICE = 'Windsurf Safe Storage';
126
+ /** Keychain account name */
127
+ export const KEYCHAIN_ACCOUNT = 'Windsurf Key';
128
+ /** Windsurf config directories */
129
+ export const WINDSURF_CONFIG_PATHS = {
130
+ /** Primary config directory */
131
+ CODEIUM: '~/.codeium/windsurf',
132
+ /** macOS Application Support */
133
+ APP_SUPPORT: '~/Library/Application Support/Windsurf',
134
+ /** Linux config */
135
+ LINUX_CONFIG: '~/.config/Windsurf',
136
+ };
137
+ /** Installation ID file path */
138
+ export const INSTALLATION_ID_PATH = '~/.codeium/windsurf/installation_id';
139
+ // ============================================================================
140
+ // Plugin Configuration
141
+ // ============================================================================
142
+ /** Default local language server port (0 = dynamic) */
143
+ export const DEFAULT_LANGUAGE_SERVER_PORT = 0;
144
+ /** Language server binary path (macOS ARM) */
145
+ export const LANGUAGE_SERVER_BINARY = '/Applications/Windsurf.app/Contents/Resources/app/extensions/windsurf/bin/language_server_macos_arm';
146
+ /** Plugin identifier */
147
+ export const PLUGIN_ID = 'windsurf';
148
+ /** Storage file name */
149
+ export const ACCOUNTS_FILE = 'windsurf-accounts.json';
150
+ /** User agent for requests */
151
+ export const USER_AGENT = 'opencode-windsurf-auth/0.1.0';
152
+ // ============================================================================
153
+ // Headers
154
+ // ============================================================================
155
+ /** Headers to include in requests */
156
+ export const DEFAULT_HEADERS = {
157
+ 'User-Agent': USER_AGENT,
158
+ 'X-Codeium-Csrf-Token': '', // Populated at runtime
159
+ };
160
+ // ============================================================================
161
+ // Rate Limiting
162
+ // ============================================================================
163
+ /** Rate limit backoff configuration */
164
+ export const RATE_LIMIT_CONFIG = {
165
+ /** Initial backoff in ms */
166
+ INITIAL_BACKOFF_MS: 1000,
167
+ /** Maximum backoff in ms */
168
+ MAX_BACKOFF_MS: 60000,
169
+ /** Backoff multiplier */
170
+ BACKOFF_MULTIPLIER: 2,
171
+ /** Maximum retry attempts */
172
+ MAX_RETRIES: 5,
173
+ };
174
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,iCAAiC;AACjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAE/D,2BAA2B;AAC3B,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CAAC;AAExE,+BAA+B;AAC/B,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CAAC;AAExE,8BAA8B;AAC9B,MAAM,CAAC,MAAM,sBAAsB,GAAG,iCAAiC,CAAC;AAExE,yBAAyB;AACzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AAE9E,qCAAqC;AACrC,MAAM,CAAC,MAAM,wBAAwB,GAAG,iDAAiD,CAAC;AAE1F,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,6BAA6B;AAC7B,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,4BAA4B;IACnC,IAAI,EAAE,2BAA2B;IACjC,MAAM,EAAE,wBAAwB;CACxB,CAAC;AAEX,8DAA8D;AAC9D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,eAAe,EAAE,8CAA8C;IAC/D,UAAU,EAA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