opencode-studio-server 1.0.6 → 1.0.7
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/index.js +20 -23
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -850,34 +850,31 @@ app.get('/api/auth', (req, res) => {
|
|
|
850
850
|
res.json({ credentials, authFile, hasGeminiAuthPlugin });
|
|
851
851
|
});
|
|
852
852
|
|
|
853
|
-
app.post('/api/auth/login', (req, res) => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
if (!provider) {
|
|
857
|
-
return res.status(400).json({ error: 'Provider is required' });
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
if (!PROVIDER_DISPLAY_NAMES[provider]) {
|
|
861
|
-
return res.status(400).json({ error: 'Invalid provider' });
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
// Run opencode auth login - this opens browser
|
|
853
|
+
app.post('/api/auth/login', (req, res) => {
|
|
854
|
+
// opencode auth login is interactive and requires a terminal
|
|
855
|
+
// Open a new terminal window with the command
|
|
865
856
|
const isWindows = process.platform === 'win32';
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
|
|
857
|
+
const isMac = process.platform === 'darwin';
|
|
858
|
+
|
|
859
|
+
let command;
|
|
860
|
+
if (isWindows) {
|
|
861
|
+
command = 'start cmd /k "opencode auth login"';
|
|
862
|
+
} else if (isMac) {
|
|
863
|
+
command = 'osascript -e \'tell app "Terminal" to do script "opencode auth login"\'';
|
|
864
|
+
} else {
|
|
865
|
+
command = 'x-terminal-emulator -e "opencode auth login" || gnome-terminal -- opencode auth login || xterm -e "opencode auth login"';
|
|
866
|
+
}
|
|
869
867
|
|
|
870
868
|
exec(command, (err) => {
|
|
871
|
-
if (err) console.error('Failed to
|
|
869
|
+
if (err) console.error('Failed to open terminal:', err);
|
|
872
870
|
});
|
|
873
871
|
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
});
|
|
872
|
+
res.json({
|
|
873
|
+
success: true,
|
|
874
|
+
message: 'Opening terminal for authentication...',
|
|
875
|
+
note: 'Complete authentication in the terminal window, then refresh this page.'
|
|
876
|
+
});
|
|
877
|
+
});
|
|
881
878
|
|
|
882
879
|
app.delete('/api/auth/:provider', (req, res) => {
|
|
883
880
|
const provider = req.params.provider;
|