sub-bridge 1.0.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.
Files changed (163) hide show
  1. package/.cursor/commands/mcp-only.md +1 -0
  2. package/.github/workflows/npm-publish.yml +33 -0
  3. package/.github/workflows/pages.yml +40 -0
  4. package/.github/workflows/release-please.yml +21 -0
  5. package/.release-please-manifest.json +3 -0
  6. package/CHANGELOG.md +8 -0
  7. package/DEVELOPMENT.md +31 -0
  8. package/LICENSE +21 -0
  9. package/README.md +87 -0
  10. package/api/index.ts +12 -0
  11. package/bun.lock +102 -0
  12. package/dist/auth/oauth-flow.d.ts +24 -0
  13. package/dist/auth/oauth-flow.d.ts.map +1 -0
  14. package/dist/auth/oauth-flow.js +184 -0
  15. package/dist/auth/oauth-flow.js.map +1 -0
  16. package/dist/auth/oauth-manager.d.ts +13 -0
  17. package/dist/auth/oauth-manager.d.ts.map +1 -0
  18. package/dist/auth/oauth-manager.js +25 -0
  19. package/dist/auth/oauth-manager.js.map +1 -0
  20. package/dist/auth/provider.d.ts +42 -0
  21. package/dist/auth/provider.d.ts.map +1 -0
  22. package/dist/auth/provider.js +270 -0
  23. package/dist/auth/provider.js.map +1 -0
  24. package/dist/cli.d.ts +3 -0
  25. package/dist/cli.d.ts.map +1 -0
  26. package/dist/cli.js +91 -0
  27. package/dist/cli.js.map +1 -0
  28. package/dist/mcp/proxy.d.ts +16 -0
  29. package/dist/mcp/proxy.d.ts.map +1 -0
  30. package/dist/mcp/proxy.js +85 -0
  31. package/dist/mcp/proxy.js.map +1 -0
  32. package/dist/mcp.d.ts +3 -0
  33. package/dist/mcp.d.ts.map +1 -0
  34. package/dist/mcp.js +50 -0
  35. package/dist/mcp.js.map +1 -0
  36. package/dist/routes/auth.d.ts +6 -0
  37. package/dist/routes/auth.d.ts.map +1 -0
  38. package/dist/routes/auth.js +149 -0
  39. package/dist/routes/auth.js.map +1 -0
  40. package/dist/routes/chat.d.ts +6 -0
  41. package/dist/routes/chat.d.ts.map +1 -0
  42. package/dist/routes/chat.js +808 -0
  43. package/dist/routes/chat.js.map +1 -0
  44. package/dist/routes/tunnels.d.ts +7 -0
  45. package/dist/routes/tunnels.d.ts.map +1 -0
  46. package/dist/routes/tunnels.js +44 -0
  47. package/dist/routes/tunnels.js.map +1 -0
  48. package/dist/server.d.ts +25 -0
  49. package/dist/server.d.ts.map +1 -0
  50. package/dist/server.js +157 -0
  51. package/dist/server.js.map +1 -0
  52. package/dist/tunnel/providers/cloudflare.d.ts +9 -0
  53. package/dist/tunnel/providers/cloudflare.d.ts.map +1 -0
  54. package/dist/tunnel/providers/cloudflare.js +47 -0
  55. package/dist/tunnel/providers/cloudflare.js.map +1 -0
  56. package/dist/tunnel/providers/index.d.ts +4 -0
  57. package/dist/tunnel/providers/index.d.ts.map +1 -0
  58. package/dist/tunnel/providers/index.js +13 -0
  59. package/dist/tunnel/providers/index.js.map +1 -0
  60. package/dist/tunnel/providers/ngrok.d.ts +10 -0
  61. package/dist/tunnel/providers/ngrok.d.ts.map +1 -0
  62. package/dist/tunnel/providers/ngrok.js +52 -0
  63. package/dist/tunnel/providers/ngrok.js.map +1 -0
  64. package/dist/tunnel/providers/tailscale.d.ts +10 -0
  65. package/dist/tunnel/providers/tailscale.d.ts.map +1 -0
  66. package/dist/tunnel/providers/tailscale.js +48 -0
  67. package/dist/tunnel/providers/tailscale.js.map +1 -0
  68. package/dist/tunnel/registry.d.ts +14 -0
  69. package/dist/tunnel/registry.d.ts.map +1 -0
  70. package/dist/tunnel/registry.js +86 -0
  71. package/dist/tunnel/registry.js.map +1 -0
  72. package/dist/tunnel/types.d.ts +26 -0
  73. package/dist/tunnel/types.d.ts.map +1 -0
  74. package/dist/tunnel/types.js +6 -0
  75. package/dist/tunnel/types.js.map +1 -0
  76. package/dist/tunnel/utils.d.ts +18 -0
  77. package/dist/tunnel/utils.d.ts.map +1 -0
  78. package/dist/tunnel/utils.js +57 -0
  79. package/dist/tunnel/utils.js.map +1 -0
  80. package/dist/types.d.ts +52 -0
  81. package/dist/types.d.ts.map +1 -0
  82. package/dist/types.js +4 -0
  83. package/dist/types.js.map +1 -0
  84. package/dist/utils/anthropic-to-openai-converter.d.ts +103 -0
  85. package/dist/utils/anthropic-to-openai-converter.d.ts.map +1 -0
  86. package/dist/utils/anthropic-to-openai-converter.js +376 -0
  87. package/dist/utils/anthropic-to-openai-converter.js.map +1 -0
  88. package/dist/utils/chat-to-responses.d.ts +59 -0
  89. package/dist/utils/chat-to-responses.d.ts.map +1 -0
  90. package/dist/utils/chat-to-responses.js +395 -0
  91. package/dist/utils/chat-to-responses.js.map +1 -0
  92. package/dist/utils/chatgpt-instructions.d.ts +3 -0
  93. package/dist/utils/chatgpt-instructions.d.ts.map +1 -0
  94. package/dist/utils/chatgpt-instructions.js +12 -0
  95. package/dist/utils/chatgpt-instructions.js.map +1 -0
  96. package/dist/utils/cli-args.d.ts +3 -0
  97. package/dist/utils/cli-args.d.ts.map +1 -0
  98. package/dist/utils/cli-args.js +10 -0
  99. package/dist/utils/cli-args.js.map +1 -0
  100. package/dist/utils/cors-bypass.d.ts +4 -0
  101. package/dist/utils/cors-bypass.d.ts.map +1 -0
  102. package/dist/utils/cors-bypass.js +30 -0
  103. package/dist/utils/cors-bypass.js.map +1 -0
  104. package/dist/utils/cursor-byok-bypass.d.ts +37 -0
  105. package/dist/utils/cursor-byok-bypass.d.ts.map +1 -0
  106. package/dist/utils/cursor-byok-bypass.js +53 -0
  107. package/dist/utils/cursor-byok-bypass.js.map +1 -0
  108. package/dist/utils/logger.d.ts +19 -0
  109. package/dist/utils/logger.d.ts.map +1 -0
  110. package/dist/utils/logger.js +192 -0
  111. package/dist/utils/logger.js.map +1 -0
  112. package/dist/utils/port.d.ts +27 -0
  113. package/dist/utils/port.d.ts.map +1 -0
  114. package/dist/utils/port.js +78 -0
  115. package/dist/utils/port.js.map +1 -0
  116. package/dist/utils/setup-instructions.d.ts +10 -0
  117. package/dist/utils/setup-instructions.d.ts.map +1 -0
  118. package/dist/utils/setup-instructions.js +49 -0
  119. package/dist/utils/setup-instructions.js.map +1 -0
  120. package/env.example +25 -0
  121. package/index.html +992 -0
  122. package/package.json +57 -0
  123. package/public/.nojekyll +0 -0
  124. package/public/assets/chat.png +0 -0
  125. package/public/assets/demo.gif +0 -0
  126. package/public/assets/demo.mp4 +0 -0
  127. package/public/assets/setup.png +0 -0
  128. package/public/assets/ui.png +0 -0
  129. package/public/index.html +292 -0
  130. package/release-please-config.json +10 -0
  131. package/src/auth/provider.ts +412 -0
  132. package/src/cli.ts +97 -0
  133. package/src/mcp/proxy.ts +64 -0
  134. package/src/mcp.ts +56 -0
  135. package/src/oauth/authorize.ts +270 -0
  136. package/src/oauth/crypto.ts +198 -0
  137. package/src/oauth/dcr.ts +129 -0
  138. package/src/oauth/metadata.ts +40 -0
  139. package/src/oauth/token.ts +173 -0
  140. package/src/routes/auth.ts +149 -0
  141. package/src/routes/chat.ts +983 -0
  142. package/src/routes/oauth.ts +220 -0
  143. package/src/routes/tunnels.ts +45 -0
  144. package/src/server.ts +204 -0
  145. package/src/tunnel/providers/cloudflare.ts +50 -0
  146. package/src/tunnel/providers/index.ts +7 -0
  147. package/src/tunnel/providers/ngrok.ts +56 -0
  148. package/src/tunnel/providers/tailscale.ts +50 -0
  149. package/src/tunnel/registry.ts +96 -0
  150. package/src/tunnel/types.ts +32 -0
  151. package/src/tunnel/utils.ts +59 -0
  152. package/src/types.ts +55 -0
  153. package/src/utils/anthropic-to-openai-converter.ts +578 -0
  154. package/src/utils/chat-to-responses.ts +512 -0
  155. package/src/utils/chatgpt-instructions.ts +7 -0
  156. package/src/utils/cli-args.ts +8 -0
  157. package/src/utils/cors-bypass.ts +39 -0
  158. package/src/utils/cursor-byok-bypass.ts +56 -0
  159. package/src/utils/logger.ts +174 -0
  160. package/src/utils/port.ts +99 -0
  161. package/src/utils/setup-instructions.ts +59 -0
  162. package/tsconfig.json +22 -0
  163. package/vercel.json +20 -0
@@ -0,0 +1,395 @@
1
+ "use strict";
2
+ /**
3
+ * Converts OpenAI Chat Completions format to Responses API format
4
+ *
5
+ * This ensures no data is lost during conversion between the two formats.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.convertMessagesToInput = convertMessagesToInput;
9
+ exports.convertToResponsesFormat = convertToResponsesFormat;
10
+ /**
11
+ * Convert a single content part from Chat Completions to Responses format
12
+ */
13
+ function convertContentPart(part, role) {
14
+ // String content
15
+ if (typeof part === 'string') {
16
+ return {
17
+ type: role === 'assistant' ? 'output_text' : 'input_text',
18
+ text: part,
19
+ };
20
+ }
21
+ // Text content block
22
+ if (part.type === 'text') {
23
+ return {
24
+ type: role === 'assistant' ? 'output_text' : 'input_text',
25
+ text: part.text,
26
+ };
27
+ }
28
+ // Image content block
29
+ if (part.type === 'image_url') {
30
+ const url = typeof part.image_url === 'string'
31
+ ? part.image_url
32
+ : part.image_url?.url;
33
+ if (url) {
34
+ return {
35
+ type: 'input_image',
36
+ image_url: url,
37
+ detail: typeof part.image_url === 'object' ? part.image_url.detail : undefined,
38
+ };
39
+ }
40
+ }
41
+ // Input audio (transcribe to text if available)
42
+ if (part.type === 'input_audio' && 'input_audio' in part) {
43
+ const audio = part.input_audio;
44
+ // Audio data can't be directly converted, but we preserve it as a note
45
+ return {
46
+ type: 'input_text',
47
+ text: `[Audio input: format=${audio?.format || 'unknown'}]`,
48
+ };
49
+ }
50
+ // File content (if present)
51
+ if (part.type === 'file' && 'file' in part) {
52
+ const file = part.file;
53
+ return {
54
+ type: 'input_file',
55
+ file_id: file?.file_id,
56
+ filename: file?.filename,
57
+ };
58
+ }
59
+ // Unknown content type - preserve as text description
60
+ console.warn(`Unknown content part type: ${part.type}`);
61
+ return {
62
+ type: 'input_text',
63
+ text: `[Unknown content type: ${JSON.stringify(part)}]`,
64
+ };
65
+ }
66
+ /**
67
+ * Convert message content (string or array) to Responses format
68
+ */
69
+ function convertContent(content, role) {
70
+ if (content === null || content === undefined) {
71
+ return [];
72
+ }
73
+ if (typeof content === 'string') {
74
+ if (!content.trim())
75
+ return [];
76
+ return [{
77
+ type: role === 'assistant' ? 'output_text' : 'input_text',
78
+ text: content,
79
+ }];
80
+ }
81
+ if (Array.isArray(content)) {
82
+ const parts = [];
83
+ for (const part of content) {
84
+ const converted = convertContentPart(part, role);
85
+ if (converted) {
86
+ parts.push(converted);
87
+ }
88
+ }
89
+ return parts;
90
+ }
91
+ // Fallback for unexpected content format
92
+ console.warn(`Unexpected content format: ${typeof content}`);
93
+ return [{
94
+ type: 'input_text',
95
+ text: JSON.stringify(content),
96
+ }];
97
+ }
98
+ /**
99
+ * Convert a single Chat Completions message to Responses API input items
100
+ * Returns an array because one message can become multiple items (e.g., message + function_calls)
101
+ */
102
+ function convertMessage(msg) {
103
+ const items = [];
104
+ if (!msg || typeof msg !== 'object') {
105
+ console.warn('Invalid message:', msg);
106
+ return items;
107
+ }
108
+ const role = msg.role;
109
+ // System message -> developer role
110
+ if (role === 'system') {
111
+ const content = 'content' in msg ? msg.content : null;
112
+ const contentParts = convertContent(content, 'user');
113
+ if (contentParts.length > 0) {
114
+ items.push({
115
+ type: 'message',
116
+ role: 'developer',
117
+ content: contentParts,
118
+ });
119
+ }
120
+ return items;
121
+ }
122
+ // User message
123
+ if (role === 'user') {
124
+ const content = 'content' in msg ? msg.content : null;
125
+ const contentParts = convertContent(content, 'user');
126
+ if (contentParts.length > 0) {
127
+ items.push({
128
+ type: 'message',
129
+ role: 'user',
130
+ content: contentParts,
131
+ });
132
+ }
133
+ return items;
134
+ }
135
+ // Assistant message (may have content and/or tool_calls)
136
+ if (role === 'assistant') {
137
+ const assistantMsg = msg;
138
+ // Add text content if present
139
+ const content = assistantMsg.content;
140
+ const contentParts = convertContent(content, 'assistant');
141
+ if (contentParts.length > 0) {
142
+ items.push({
143
+ type: 'message',
144
+ role: 'assistant',
145
+ content: contentParts,
146
+ });
147
+ }
148
+ // Add tool calls as separate function_call items
149
+ if (assistantMsg.tool_calls && Array.isArray(assistantMsg.tool_calls)) {
150
+ for (const toolCall of assistantMsg.tool_calls) {
151
+ const args = toolCall.type === 'function' ? toolCall.function.arguments : toolCall.custom.input;
152
+ const name = toolCall.type === 'function' ? toolCall.function.name : toolCall.custom.name;
153
+ items.push({
154
+ type: 'function_call',
155
+ name: name || 'unknown',
156
+ arguments: typeof args === 'string' ? args : JSON.stringify(args || {}),
157
+ call_id: toolCall.id || `call_${Date.now()}_${Math.random().toString(36).slice(2)}`,
158
+ });
159
+ }
160
+ }
161
+ // Handle legacy function_call field (deprecated but still used)
162
+ // Use function name as call_id for backwards compatibility with legacy function role
163
+ if ('function_call' in assistantMsg && assistantMsg.function_call) {
164
+ const fc = assistantMsg.function_call;
165
+ const funcName = fc.name || 'unknown';
166
+ items.push({
167
+ type: 'function_call',
168
+ name: funcName,
169
+ arguments: fc.arguments || '{}',
170
+ call_id: funcName, // Use name as call_id to match legacy function role output
171
+ });
172
+ }
173
+ return items;
174
+ }
175
+ // Tool message -> function_call_output
176
+ if (role === 'tool') {
177
+ const toolMsg = msg;
178
+ const callId = toolMsg.tool_call_id;
179
+ const content = toolMsg.content;
180
+ if (callId) {
181
+ items.push({
182
+ type: 'function_call_output',
183
+ call_id: callId,
184
+ output: typeof content === 'string' ? content : JSON.stringify(content ?? ''),
185
+ });
186
+ }
187
+ return items;
188
+ }
189
+ // Function role (legacy, deprecated)
190
+ if (role === 'function') {
191
+ const funcMsg = msg;
192
+ items.push({
193
+ type: 'function_call_output',
194
+ call_id: funcMsg.name || `func_${Date.now()}`,
195
+ output: typeof funcMsg.content === 'string' ? funcMsg.content : JSON.stringify(funcMsg.content ?? ''),
196
+ });
197
+ return items;
198
+ }
199
+ // Developer role (pass through)
200
+ if (role === 'developer') {
201
+ const content = 'content' in msg ? msg.content : null;
202
+ const contentParts = convertContent(content, 'user');
203
+ if (contentParts.length > 0) {
204
+ items.push({
205
+ type: 'message',
206
+ role: 'developer',
207
+ content: contentParts,
208
+ });
209
+ }
210
+ return items;
211
+ }
212
+ // Unknown role - try to preserve as user message
213
+ console.warn(`Unknown message role: ${role}`);
214
+ const content = 'content' in msg ? msg.content : null;
215
+ if (content) {
216
+ const contentParts = convertContent(content, 'user');
217
+ if (contentParts.length > 0) {
218
+ items.push({
219
+ type: 'message',
220
+ role: 'user',
221
+ content: contentParts,
222
+ });
223
+ }
224
+ }
225
+ return items;
226
+ }
227
+ /**
228
+ * Handle items that are already in Responses API format (passthrough)
229
+ */
230
+ function isResponsesApiItem(item) {
231
+ if (!item || typeof item !== 'object')
232
+ return false;
233
+ // Check for Responses API item types
234
+ if (item.type === 'message' && item.role && item.content !== undefined) {
235
+ return true;
236
+ }
237
+ if (item.type === 'function_call' && item.name !== undefined) {
238
+ return true;
239
+ }
240
+ if (item.type === 'function_call_output' && item.call_id !== undefined) {
241
+ return true;
242
+ }
243
+ return false;
244
+ }
245
+ /**
246
+ * Convert Responses API content to ensure proper format
247
+ */
248
+ function normalizeResponsesContent(content, role) {
249
+ if (typeof content === 'string') {
250
+ return [{
251
+ type: role === 'assistant' ? 'output_text' : 'input_text',
252
+ text: content,
253
+ }];
254
+ }
255
+ if (!Array.isArray(content)) {
256
+ return [{
257
+ type: 'input_text',
258
+ text: JSON.stringify(content),
259
+ }];
260
+ }
261
+ const parts = [];
262
+ for (const block of content) {
263
+ if (!block)
264
+ continue;
265
+ // Already proper format
266
+ if (block.type === 'input_text' || block.type === 'output_text') {
267
+ if (typeof block.text === 'string') {
268
+ parts.push(block);
269
+ }
270
+ continue;
271
+ }
272
+ // Handle 'text' type (Chat Completions format in Responses wrapper)
273
+ if (block.type === 'text' && typeof block.text === 'string') {
274
+ parts.push({
275
+ type: role === 'assistant' ? 'output_text' : 'input_text',
276
+ text: block.text,
277
+ });
278
+ continue;
279
+ }
280
+ // Image
281
+ if (block.type === 'input_image' || block.type === 'image_url') {
282
+ const url = block.image_url || block.url;
283
+ if (url) {
284
+ parts.push({
285
+ type: 'input_image',
286
+ image_url: typeof url === 'string' ? url : url.url,
287
+ });
288
+ }
289
+ continue;
290
+ }
291
+ // File
292
+ if (block.type === 'input_file') {
293
+ parts.push(block);
294
+ continue;
295
+ }
296
+ // Unknown - preserve as text
297
+ console.warn(`Unknown content block type: ${block.type}`);
298
+ parts.push({
299
+ type: 'input_text',
300
+ text: `[${block.type}: ${JSON.stringify(block)}]`,
301
+ });
302
+ }
303
+ return parts;
304
+ }
305
+ /**
306
+ * Convert a Responses API item to ensure proper format
307
+ */
308
+ function normalizeResponsesApiItem(item) {
309
+ if (item.type === 'message') {
310
+ const normalizedContent = normalizeResponsesContent(item.content, item.role);
311
+ if (normalizedContent.length === 0)
312
+ return null;
313
+ return {
314
+ type: 'message',
315
+ role: item.role,
316
+ content: normalizedContent,
317
+ };
318
+ }
319
+ if (item.type === 'function_call') {
320
+ return {
321
+ type: 'function_call',
322
+ name: item.name || 'unknown',
323
+ arguments: typeof item.arguments === 'string' ? item.arguments : JSON.stringify(item.arguments || {}),
324
+ call_id: item.call_id || item.id || `call_${Date.now()}`,
325
+ };
326
+ }
327
+ if (item.type === 'function_call_output') {
328
+ return {
329
+ type: 'function_call_output',
330
+ call_id: item.call_id || item.id,
331
+ output: typeof item.output === 'string' ? item.output : JSON.stringify(item.output ?? ''),
332
+ };
333
+ }
334
+ return null;
335
+ }
336
+ /**
337
+ * Main conversion function: Chat Completions messages array to Responses API input array
338
+ */
339
+ function convertMessagesToInput(messages) {
340
+ const input = [];
341
+ for (const item of messages) {
342
+ if (!item)
343
+ continue;
344
+ // Check if it's already in Responses API format
345
+ if (isResponsesApiItem(item)) {
346
+ const normalized = normalizeResponsesApiItem(item);
347
+ if (normalized) {
348
+ input.push(normalized);
349
+ }
350
+ continue;
351
+ }
352
+ // Convert from Chat Completions format
353
+ const converted = convertMessage(item);
354
+ input.push(...converted);
355
+ }
356
+ return input;
357
+ }
358
+ /**
359
+ * Extract system/developer messages and return separate instructions + input
360
+ */
361
+ function convertToResponsesFormat(body) {
362
+ // Use messages or input array
363
+ const items = body.messages || body.input || [];
364
+ const input = [];
365
+ const developerMessages = [];
366
+ for (const item of items) {
367
+ if (!item)
368
+ continue;
369
+ // Check if it's already in Responses API format
370
+ if (isResponsesApiItem(item)) {
371
+ const normalized = normalizeResponsesApiItem(item);
372
+ if (normalized) {
373
+ if (normalized.type === 'message' && (normalized.role === 'developer' || normalized.role === 'system')) {
374
+ developerMessages.push(normalized);
375
+ }
376
+ else {
377
+ input.push(normalized);
378
+ }
379
+ }
380
+ continue;
381
+ }
382
+ // Convert from Chat Completions format
383
+ const converted = convertMessage(item);
384
+ for (const conv of converted) {
385
+ if (conv.type === 'message' && conv.role === 'developer') {
386
+ developerMessages.push(conv);
387
+ }
388
+ else {
389
+ input.push(conv);
390
+ }
391
+ }
392
+ }
393
+ return { input, developerMessages };
394
+ }
395
+ //# sourceMappingURL=chat-to-responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-to-responses.js","sourceRoot":"","sources":["../../src/utils/chat-to-responses.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAsbH,wDAqBC;AAKD,4DA2CC;AA5bD;;GAEG;AACH,SAAS,kBAAkB,CACzB,IAAwC,EACxC,IAA0B;IAE1B,iBAAiB;IACjB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO;YACL,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY;YACzD,IAAI,EAAE,IAAI;SACX,CAAA;IACH,CAAC;IAED,qBAAqB;IACrB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,OAAO;YACL,IAAI,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY;YACzD,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;IACH,CAAC;IAED,sBAAsB;IACtB,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC9B,MAAM,GA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I,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACzD,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAA;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_CHATGPT_INSTRUCTIONS = "[Proxied via Sub Bridge - user's ChatGPT subscription]\n\nYou are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI on a user's computer.\n\n## General\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n\n## Editing constraints\n\n- Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.\n- Add succinct code comments that explain what is going on if code is not self-explanatory. You should not add comments like \"Assigns the value to the variable\", but a brief comment might be useful ahead of a complex code block that the user would otherwise have to spend time parsing out. Usage of these comments should be rare.\n- Try to use apply_patch for single file edits, but it is fine to explore other options to make the edit if it does not work well. Do not use apply_patch for changes that are auto-generated (i.e. generating package.json or running a lint or format command like gofmt) or when scripting is more efficient (such as search and replacing a string across a codebase).\n- You may be in a dirty git worktree.\n * NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.\n * If asked to make a commit or code edits and there are unrelated changes to your work or changes that you didn't make in those files, don't revert those changes.\n * If the changes are in files you've touched recently, you should read carefully and understand how you can work with the changes rather than reverting them.\n * If the changes are in unrelated files, just ignore them and don't revert them.\n- Do not amend a commit unless explicitly requested to do so.\n- While you are working, you might notice unexpected changes that you didn't make. If this happens, STOP IMMEDIATELY and ask the user how they would like to proceed.\n- **NEVER** use destructive commands like `git reset --hard` or `git checkout --` unless specifically requested or approved by the user.\n\n## Plan tool\n\nWhen using the planning tool:\n- Skip using the planning tool for straightforward tasks (roughly the easiest 25%).\n- Do not make single-step plans.\n- When you made a plan, update it after having performed one of the sub-tasks that you shared on the plan.\n\n## Codex CLI harness, sandboxing, and approvals\n\nThe Codex CLI harness supports several different configurations for sandboxing and escalation approvals that the user can choose from.\n\nFilesystem sandboxing defines which files can be read or written. The options for `sandbox_mode` are:\n- **read-only**: The sandbox only permits reading files.\n- **workspace-write**: The sandbox permits reading files, and editing files in `cwd` and `writable_roots`. Editing files in other directories requires approval.\n- **danger-full-access**: No filesystem sandboxing - all commands are permitted.\n\nNetwork sandboxing defines whether network can be accessed without approval. Options for `network_access` are:\n- **restricted**: Requires approval\n- **enabled**: No approval needed\n\nApprovals are your mechanism to get user consent to run shell commands without the sandbox. Possible configuration options for `approval_policy` are\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is paired with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with `approval_policy == on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /var)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval. ALWAYS proceed to use the `sandbox_permissions` and `justification` parameters - do not message the user before requesting approval for the command.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (for all of these, you should weigh alternative paths that do not require approval)\n\nWhen `sandbox_mode` is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing enabled, and approval on-failure.\n\nAlthough they introduce friction to the user because your work is paused until the user responds, you should leverage them when necessary to accomplish important work. If the completing the task requires escalated permissions, Do not let these settings or the sandbox deter you from attempting to accomplish the user's task unless it is set to \"never\", in which case never ask for approvals.\n\nWhen requesting approval to execute a command that will require escalated privileges:\n - Provide the `sandbox_permissions` parameter with the value `\"require_escalated\"`\n - Include a short, 1 sentence explanation for why you need escalated permissions in the justification parameter\n\n## Special user requests\n\n- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as `date`), you should do so.\n- If the user asks for a \"review\", default to a code review mindset: prioritise identifying bugs, risks, behavioural regressions, and missing tests. Findings must be the primary focus of the response - keep summaries or overviews brief and only after enumerating the issues. Present findings first (ordered by severity with file/line references), follow with open questions or assumptions, and offer a change-summary only as a secondary detail. If no findings are discovered, state that explicitly and mention any residual risks or testing gaps.\n\n## Frontend tasks\nWhen doing frontend design tasks, avoid collapsing into \"AI slop\" or safe, average-looking layouts.\nAim for interfaces that feel intentional, bold, and a bit surprising.\n- Typography: Use expressive, purposeful fonts and avoid default stacks (Inter, Roboto, Arial, system).\n- Color & Look: Choose a clear visual direction; define CSS variables; avoid purple-on-white defaults. No purple bias or dark mode bias.\n- Motion: Use a few meaningful animations (page-load, staggered reveals) instead of generic micro-motions.\n- Background: Don't rely on flat, single-color backgrounds; use gradients, shapes, or subtle patterns to build atmosphere.\n- Overall: Avoid boilerplate layouts and interchangeable UI patterns. Vary themes, type families, and visual languages across outputs.\n- Ensure the page loads properly on both desktop and mobile\n\nException: If working within an existing website or design system, preserve the established patterns, structure, and visual language.\n\n## Presenting your work and final message\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n- Default: be very concise; friendly coding teammate tone.\n- Ask only when needed; suggest ideas; mirror the user's style.\n- For substantial work, summarize clearly; follow final-answer formatting.\n- Skip heavy formatting for simple confirmations.\n- Don't dump large files you've written; reference paths only.\n- No \"save/copy this file\" - User is on the same machine.\n- Offer logical next steps (tests, commits, build) briefly; add verify steps if you couldn't do something.\n- For code changes:\n * Lead with a quick explanation of the change, and then give more details on the context covering where and why a change was made. Do not start this explanation with \"summary\", just jump right in.\n * If there are natural next steps the user may want to take, suggest them at the end of your response. Do not make suggestions if there are no natural next steps.\n * When suggesting multiple options, use numeric lists for the suggestions so the user can quickly respond with a single number.\n- The user does not command execution outputs. When asked to show the output of a command (e.g. `git show`), relay the important details in your answer or summarize the key lines so the user understands the result.\n\n### Final answer structure and style guidelines\n\n- Plain text; CLI handles styling. Use structure only when it helps scanability.\n- Headers: optional; short Title Case (1-3 words) wrapped in **...**; no blank line before the first bullet; add only if they truly help.\n- Bullets: use - ; merge related points; keep to one line when possible; 4-6 per list ordered by importance; keep phrasing consistent.\n- Monospace: backticks for commands/paths/env vars/code ids and inline examples; use for literal keyword bullets; never combine with **.\n- Code samples or multi-line snippets should be wrapped in fenced code blocks; include an info string as often as possible.\n- Structure: group related bullets; order sections general -> specific -> supporting; for subsections, start with a bolded keyword bullet, then items; match complexity to the task.\n- Tone: collaborative, concise, factual; present tense, active voice; self-contained; no \"above/below\"; parallel wording.\n- Don'ts: no nested bullets/hierarchies; no ANSI codes; don't cram unrelated keywords; keep keyword lists short-wrap/reformat if long; avoid naming formatting styles in answers.\n- Adaptation: code explanations -> precise, structured with code refs; simple tasks -> lead with outcome; big changes -> logical walkthrough + rationale + next actions; casual one-offs -> plain sentences, no headers/bullets.\n- File References: When referencing files in your response follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace-relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Optionally include line/column (1-based): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n";
2
+ export declare function getChatGptInstructions(): string;
3
+ //# sourceMappingURL=chatgpt-instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatgpt-instructions.d.ts","sourceRoot":"","sources":["../../src/utils/chatgpt-instructions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,8nXAA8nX,CAAA;AAEvqX,wBAAgB,sBAAsB,IAAI,MAAM,CAI/C"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CHATGPT_INSTRUCTIONS = void 0;
4
+ exports.getChatGptInstructions = getChatGptInstructions;
5
+ exports.DEFAULT_CHATGPT_INSTRUCTIONS = "[Proxied via Sub Bridge - user's ChatGPT subscription]\n\nYou are Codex, based on GPT-5. You are running as a coding agent in the Codex CLI on a user's computer.\n\n## General\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n\n## Editing constraints\n\n- Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.\n- Add succinct code comments that explain what is going on if code is not self-explanatory. You should not add comments like \"Assigns the value to the variable\", but a brief comment might be useful ahead of a complex code block that the user would otherwise have to spend time parsing out. Usage of these comments should be rare.\n- Try to use apply_patch for single file edits, but it is fine to explore other options to make the edit if it does not work well. Do not use apply_patch for changes that are auto-generated (i.e. generating package.json or running a lint or format command like gofmt) or when scripting is more efficient (such as search and replacing a string across a codebase).\n- You may be in a dirty git worktree.\n * NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.\n * If asked to make a commit or code edits and there are unrelated changes to your work or changes that you didn't make in those files, don't revert those changes.\n * If the changes are in files you've touched recently, you should read carefully and understand how you can work with the changes rather than reverting them.\n * If the changes are in unrelated files, just ignore them and don't revert them.\n- Do not amend a commit unless explicitly requested to do so.\n- While you are working, you might notice unexpected changes that you didn't make. If this happens, STOP IMMEDIATELY and ask the user how they would like to proceed.\n- **NEVER** use destructive commands like `git reset --hard` or `git checkout --` unless specifically requested or approved by the user.\n\n## Plan tool\n\nWhen using the planning tool:\n- Skip using the planning tool for straightforward tasks (roughly the easiest 25%).\n- Do not make single-step plans.\n- When you made a plan, update it after having performed one of the sub-tasks that you shared on the plan.\n\n## Codex CLI harness, sandboxing, and approvals\n\nThe Codex CLI harness supports several different configurations for sandboxing and escalation approvals that the user can choose from.\n\nFilesystem sandboxing defines which files can be read or written. The options for `sandbox_mode` are:\n- **read-only**: The sandbox only permits reading files.\n- **workspace-write**: The sandbox permits reading files, and editing files in `cwd` and `writable_roots`. Editing files in other directories requires approval.\n- **danger-full-access**: No filesystem sandboxing - all commands are permitted.\n\nNetwork sandboxing defines whether network can be accessed without approval. Options for `network_access` are:\n- **restricted**: Requires approval\n- **enabled**: No approval needed\n\nApprovals are your mechanism to get user consent to run shell commands without the sandbox. Possible configuration options for `approval_policy` are\n- **untrusted**: The harness will escalate most commands for user approval, apart from a limited allowlist of safe \"read\" commands.\n- **on-failure**: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox.\n- **on-request**: Commands will be run in the sandbox by default, and you can specify in your tool call if you want to escalate a command to run without sandboxing. (Note that this mode is not always available. If it is, you'll see parameters for it in the `shell` command description.)\n- **never**: This is a non-interactive mode where you may NEVER ask the user for approval to run commands. Instead, you must always persist and work around constraints to solve the task for the user. You MUST do your utmost best to finish the task and validate your work before yielding. If this mode is paired with `danger-full-access`, take advantage of it to deliver the best outcome for the user. Further, in this mode, your default testing philosophy is overridden: Even if you don't see local patterns for testing, you may add tests and scripts to validate your work. Just remove them before yielding.\n\nWhen you are running with `approval_policy == on-request`, and sandboxing enabled, here are scenarios where you'll need to request approval:\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /var)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- You are running sandboxed and need to run a command that requires network access (e.g. installing packages)\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing, rerun the command with approval. ALWAYS proceed to use the `sandbox_permissions` and `justification` parameters - do not message the user before requesting approval for the command.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for\n- (for all of these, you should weigh alternative paths that do not require approval)\n\nWhen `sandbox_mode` is set to read-only, you'll need to request approval for any command that isn't a read.\n\nYou will be told what filesystem sandboxing, network sandboxing, and approval mode are active in a developer or user message. If you are not told about this, assume that you are running with workspace-write, network sandboxing enabled, and approval on-failure.\n\nAlthough they introduce friction to the user because your work is paused until the user responds, you should leverage them when necessary to accomplish important work. If the completing the task requires escalated permissions, Do not let these settings or the sandbox deter you from attempting to accomplish the user's task unless it is set to \"never\", in which case never ask for approvals.\n\nWhen requesting approval to execute a command that will require escalated privileges:\n - Provide the `sandbox_permissions` parameter with the value `\"require_escalated\"`\n - Include a short, 1 sentence explanation for why you need escalated permissions in the justification parameter\n\n## Special user requests\n\n- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as `date`), you should do so.\n- If the user asks for a \"review\", default to a code review mindset: prioritise identifying bugs, risks, behavioural regressions, and missing tests. Findings must be the primary focus of the response - keep summaries or overviews brief and only after enumerating the issues. Present findings first (ordered by severity with file/line references), follow with open questions or assumptions, and offer a change-summary only as a secondary detail. If no findings are discovered, state that explicitly and mention any residual risks or testing gaps.\n\n## Frontend tasks\nWhen doing frontend design tasks, avoid collapsing into \"AI slop\" or safe, average-looking layouts.\nAim for interfaces that feel intentional, bold, and a bit surprising.\n- Typography: Use expressive, purposeful fonts and avoid default stacks (Inter, Roboto, Arial, system).\n- Color & Look: Choose a clear visual direction; define CSS variables; avoid purple-on-white defaults. No purple bias or dark mode bias.\n- Motion: Use a few meaningful animations (page-load, staggered reveals) instead of generic micro-motions.\n- Background: Don't rely on flat, single-color backgrounds; use gradients, shapes, or subtle patterns to build atmosphere.\n- Overall: Avoid boilerplate layouts and interchangeable UI patterns. Vary themes, type families, and visual languages across outputs.\n- Ensure the page loads properly on both desktop and mobile\n\nException: If working within an existing website or design system, preserve the established patterns, structure, and visual language.\n\n## Presenting your work and final message\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n- Default: be very concise; friendly coding teammate tone.\n- Ask only when needed; suggest ideas; mirror the user's style.\n- For substantial work, summarize clearly; follow final-answer formatting.\n- Skip heavy formatting for simple confirmations.\n- Don't dump large files you've written; reference paths only.\n- No \"save/copy this file\" - User is on the same machine.\n- Offer logical next steps (tests, commits, build) briefly; add verify steps if you couldn't do something.\n- For code changes:\n * Lead with a quick explanation of the change, and then give more details on the context covering where and why a change was made. Do not start this explanation with \"summary\", just jump right in.\n * If there are natural next steps the user may want to take, suggest them at the end of your response. Do not make suggestions if there are no natural next steps.\n * When suggesting multiple options, use numeric lists for the suggestions so the user can quickly respond with a single number.\n- The user does not command execution outputs. When asked to show the output of a command (e.g. `git show`), relay the important details in your answer or summarize the key lines so the user understands the result.\n\n### Final answer structure and style guidelines\n\n- Plain text; CLI handles styling. Use structure only when it helps scanability.\n- Headers: optional; short Title Case (1-3 words) wrapped in **...**; no blank line before the first bullet; add only if they truly help.\n- Bullets: use - ; merge related points; keep to one line when possible; 4-6 per list ordered by importance; keep phrasing consistent.\n- Monospace: backticks for commands/paths/env vars/code ids and inline examples; use for literal keyword bullets; never combine with **.\n- Code samples or multi-line snippets should be wrapped in fenced code blocks; include an info string as often as possible.\n- Structure: group related bullets; order sections general -> specific -> supporting; for subsections, start with a bolded keyword bullet, then items; match complexity to the task.\n- Tone: collaborative, concise, factual; present tense, active voice; self-contained; no \"above/below\"; parallel wording.\n- Don'ts: no nested bullets/hierarchies; no ANSI codes; don't cram unrelated keywords; keep keyword lists short-wrap/reformat if long; avoid naming formatting styles in answers.\n- Adaptation: code explanations -> precise, structured with code refs; simple tasks -> lead with outcome; big changes -> logical walkthrough + rationale + next actions; casual one-offs -> plain sentences, no headers/bullets.\n- File References: When referencing files in your response follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace-relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Optionally include line/column (1-based): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n";
6
+ function getChatGptInstructions() {
7
+ const env = process.env.CHATGPT_INSTRUCTIONS;
8
+ if (env && env.trim())
9
+ return env.trim();
10
+ return exports.DEFAULT_CHATGPT_INSTRUCTIONS;
11
+ }
12
+ //# sourceMappingURL=chatgpt-instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatgpt-instructions.js","sourceRoot":"","sources":["../../src/utils/chatgpt-instructions.ts"],"names":[],"mappings":";;;AAEA,wDAIC;AANY,QAAA,4BAA4B,GAAG,2nXAA2nX,CAAA;AAEvqX,SAAgB,sBAAsB;IACpC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;IAC5C,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;IACxC,OAAO,oCAA4B,CAAA;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function addSharedOptions(program: Command): Command;
3
+ //# sourceMappingURL=cli-args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/utils/cli-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,WAKhD"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSharedOptions = addSharedOptions;
4
+ function addSharedOptions(program) {
5
+ return program
6
+ .option('-p, --port <number>', 'Local proxy port (default: 8787 or next available)')
7
+ .option('--tunnel <url>', 'Existing tunnel URL (e.g., local.buremba.com)')
8
+ .option('--verbose', 'Show full messages and tools without truncation');
9
+ }
10
+ //# sourceMappingURL=cli-args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-args.js","sourceRoot":"","sources":["../../src/utils/cli-args.ts"],"names":[],"mappings":";;AAEA,4CAKC;AALD,SAAgB,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,OAAO;SACX,MAAM,CAAC,qBAAqB,EAAE,oDAAoD,CAAC;SACnF,MAAM,CAAC,gBAAgB,EAAE,+CAA+C,CAAC;SACzE,MAAM,CAAC,WAAW,EAAE,iDAAiD,CAAC,CAAA;AAC3E,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Context } from 'hono';
2
+ export declare const corsPreflightHandler: (c: Context) => Response & import("hono").TypedResponse<null, 204, "body">;
3
+ export declare const corsMiddleware: (c: Context, next: () => Promise<void>) => Promise<void>;
4
+ //# sourceMappingURL=cors-bypass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors-bypass.d.ts","sourceRoot":"","sources":["../../src/utils/cors-bypass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,eAAO,MAAM,oBAAoB,GAAI,GAAG,OAAO,+DAqB9C,CAAA;AAGD,eAAO,MAAM,cAAc,GAAU,GAAG,OAAO,EAAE,MAAM,MAAM,OAAO,CAAC,IAAI,CAAC,kBAWzE,CAAA"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.corsMiddleware = exports.corsPreflightHandler = void 0;
4
+ // Handle CORS preflight requests for all routes
5
+ const corsPreflightHandler = (c) => {
6
+ // Allow all origins (you can restrict this to specific origins if needed)
7
+ c.header('Access-Control-Allow-Origin', '*');
8
+ // Allow all HTTP methods
9
+ c.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD');
10
+ // Allow all headers
11
+ c.header('Access-Control-Allow-Headers', '*');
12
+ // Allow credentials
13
+ c.header('Access-Control-Allow-Credentials', 'true');
14
+ // Max age for preflight cache (24 hours)
15
+ c.header('Access-Control-Max-Age', '86400');
16
+ // Return 204 No Content for OPTIONS requests
17
+ return c.body(null, 204);
18
+ };
19
+ exports.corsPreflightHandler = corsPreflightHandler;
20
+ // Middleware to add CORS headers to all responses
21
+ const corsMiddleware = async (c, next) => {
22
+ await next();
23
+ // Add CORS headers to all responses
24
+ c.header('Access-Control-Allow-Origin', '*');
25
+ c.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD');
26
+ c.header('Access-Control-Allow-Headers', '*');
27
+ c.header('Access-Control-Allow-Credentials', 'true');
28
+ };
29
+ exports.corsMiddleware = corsMiddleware;
30
+ //# sourceMappingURL=cors-bypass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors-bypass.js","sourceRoot":"","sources":["../../src/utils/cors-bypass.ts"],"names":[],"mappings":";;;AAEA,gDAAgD;AACzC,MAAM,oBAAoB,GAAG,CAAC,CAAU,EAAE,EAAE;IACjD,0EAA0E;IAC1E,CAAC,CAAC,MAAM,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;IAE5C,yBAAyB;IACzB,CAAC,CAAC,MAAM,CACN,8BAA8B,EAC9B,8CAA8C,CAC/C,CAAA;IAED,oBAAoB;IACpB,CAAC,CAAC,MAAM,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;IAE7C,oBAAoB;IACpB,CAAC,CAAC,MAAM,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAA;IAEpD,yCAAyC;IACzC,CAAC,CAAC,MAAM,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAA;IAE3C,6CAA6C;IAC7C,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC1B,CAAC,CAAA;AArBY,QAAA,oBAAoB,wBAqBhC;AAED,kDAAkD;AAC3C,MAAM,cAAc,GAAG,KAAK,EAAE,CAAU,EAAE,IAAyB,EAAE,EAAE;IAC5E,MAAM,IAAI,EAAE,CAAA;IAEZ,oCAAoC;IACpC,CAAC,CAAC,MAAM,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,MAAM,CACN,8BAA8B,EAC9B,8CAA8C,CAC/C,CAAA;IACD,CAAC,CAAC,MAAM,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;IAC7C,CAAC,CAAC,MAAM,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAA;AACtD,CAAC,CAAA;AAXY,QAAA,cAAc,kBAW1B"}
@@ -0,0 +1,37 @@
1
+ import { AnthropicRequestBody } from "../types";
2
+ export declare function createCursorBypassResponse(): {
3
+ choices: {
4
+ finish_reason: string;
5
+ index: number;
6
+ logprobs: null;
7
+ message: {
8
+ annotations: never[];
9
+ content: string;
10
+ refusal: null;
11
+ role: string;
12
+ };
13
+ }[];
14
+ created: number;
15
+ id: string;
16
+ model: string;
17
+ object: string;
18
+ service_tier: string;
19
+ system_fingerprint: string;
20
+ usage: {
21
+ completion_tokens: number;
22
+ completion_tokens_details: {
23
+ accepted_prediction_tokens: number;
24
+ audio_tokens: number;
25
+ reasoning_tokens: number;
26
+ rejected_prediction_tokens: number;
27
+ };
28
+ prompt_tokens: number;
29
+ prompt_tokens_details: {
30
+ audio_tokens: number;
31
+ cached_tokens: number;
32
+ };
33
+ total_tokens: number;
34
+ };
35
+ };
36
+ export declare function isCursorKeyCheck(body: AnthropicRequestBody): boolean;
37
+ //# sourceMappingURL=cursor-byok-bypass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-byok-bypass.d.ts","sourceRoot":"","sources":["../../src/utils/cursor-byok-bypass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCzC;AAID,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAWpE"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCursorBypassResponse = createCursorBypassResponse;
4
+ exports.isCursorKeyCheck = isCursorKeyCheck;
5
+ // Bypass cursor enable openai key check
6
+ function createCursorBypassResponse() {
7
+ return {
8
+ choices: [
9
+ {
10
+ finish_reason: 'length',
11
+ index: 0,
12
+ logprobs: null,
13
+ message: {
14
+ annotations: [],
15
+ content: 'Of course! Please provide me with the text or',
16
+ refusal: null,
17
+ role: 'assistant',
18
+ },
19
+ },
20
+ ],
21
+ created: 1751755415,
22
+ id: 'chatcmpl-Bq5tXYkUOGxyRInJljhsBrlLP1066',
23
+ model: 'gpt-4o-2024-08-06',
24
+ object: 'chat.completion',
25
+ service_tier: 'default',
26
+ system_fingerprint: 'fp_a288987b44',
27
+ usage: {
28
+ completion_tokens: 10,
29
+ completion_tokens_details: {
30
+ accepted_prediction_tokens: 0,
31
+ audio_tokens: 0,
32
+ reasoning_tokens: 0,
33
+ rejected_prediction_tokens: 0,
34
+ },
35
+ prompt_tokens: 28,
36
+ prompt_tokens_details: {
37
+ audio_tokens: 0,
38
+ cached_tokens: 0,
39
+ },
40
+ total_tokens: 38,
41
+ },
42
+ };
43
+ }
44
+ // Check if the request is from Cursor trying to validate OpenAI key
45
+ // This is a specific check pattern Cursor uses, not all gpt-4o requests
46
+ function isCursorKeyCheck(body) {
47
+ // Only match the specific Cursor key validation test prompts
48
+ return (body.messages &&
49
+ body.messages.some((m) => m.content === 'Test prompt using gpt-3.5-turbo' ||
50
+ m.content === 'Test prompt using gpt-4o' ||
51
+ (typeof m.content === 'string' && m.content.startsWith('Test prompt using ')))) || false;
52
+ }
53
+ //# sourceMappingURL=cursor-byok-bypass.js.map