hedgequantx 2.7.32 → 2.7.33
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/package.json +1 -1
- package/src/pages/ai-agents.js +35 -12
- package/src/services/cliproxy/index.js +7 -1
package/package.json
CHANGED
package/src/pages/ai-agents.js
CHANGED
|
@@ -187,12 +187,15 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
187
187
|
|
|
188
188
|
// Different flow for VPS/headless vs local
|
|
189
189
|
if (loginResult.isHeadless) {
|
|
190
|
-
console.log(chalk.magenta('
|
|
190
|
+
console.log(chalk.magenta(' ══════════════════════════════════════════════════════════'));
|
|
191
191
|
console.log(chalk.magenta(' VPS/SSH DETECTED - MANUAL CALLBACK REQUIRED'));
|
|
192
|
-
console.log(chalk.magenta('
|
|
193
|
-
console.log(chalk.white('
|
|
194
|
-
console.log(chalk.white('
|
|
195
|
-
console.log(chalk.white('
|
|
192
|
+
console.log(chalk.magenta(' ══════════════════════════════════════════════════════════\n'));
|
|
193
|
+
console.log(chalk.white(' 1. OPEN THE URL ABOVE IN YOUR LOCAL BROWSER'));
|
|
194
|
+
console.log(chalk.white(' 2. AUTHORIZE THE APPLICATION'));
|
|
195
|
+
console.log(chalk.white(' 3. YOU WILL SEE A BLANK PAGE - THIS IS NORMAL'));
|
|
196
|
+
console.log(chalk.white(' 4. COPY THE FULL URL FROM YOUR BROWSER ADDRESS BAR'));
|
|
197
|
+
console.log(chalk.white(' (IT STARTS WITH: http://localhost:' + cliproxy.CALLBACK_PORT + '/...)'));
|
|
198
|
+
console.log(chalk.white(' 5. PASTE IT BELOW:\n'));
|
|
196
199
|
|
|
197
200
|
const callbackUrl = await prompts.textInput(chalk.cyan(' CALLBACK URL: '));
|
|
198
201
|
|
|
@@ -203,21 +206,30 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
203
206
|
return false;
|
|
204
207
|
}
|
|
205
208
|
|
|
206
|
-
// Process the callback
|
|
209
|
+
// Process the callback - send to the login process listening on CALLBACK_PORT
|
|
207
210
|
const spinner = ora({ text: 'PROCESSING CALLBACK...', color: 'yellow' }).start();
|
|
208
|
-
const callbackResult = await cliproxy.processCallback(callbackUrl.trim());
|
|
209
211
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
try {
|
|
213
|
+
const callbackResult = await cliproxy.processCallback(callbackUrl.trim());
|
|
214
|
+
|
|
215
|
+
if (!callbackResult.success) {
|
|
216
|
+
spinner.fail(`CALLBACK FAILED: ${callbackResult.error}`);
|
|
217
|
+
if (loginResult.childProcess) loginResult.childProcess.kill();
|
|
218
|
+
await prompts.waitForEnter();
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
spinner.succeed('AUTHENTICATION SUCCESSFUL!');
|
|
223
|
+
} catch (err) {
|
|
224
|
+
spinner.fail(`ERROR: ${err.message}`);
|
|
212
225
|
if (loginResult.childProcess) loginResult.childProcess.kill();
|
|
213
226
|
await prompts.waitForEnter();
|
|
214
227
|
return false;
|
|
215
228
|
}
|
|
216
229
|
|
|
217
|
-
|
|
230
|
+
// Wait for token to be saved
|
|
231
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
218
232
|
|
|
219
|
-
// Wait for CLIProxyAPI to process the token
|
|
220
|
-
await new Promise(r => setTimeout(r, 2000));
|
|
221
233
|
} else {
|
|
222
234
|
console.log(chalk.gray(' AFTER AUTHENTICATING, PRESS ENTER TO CONTINUE...'));
|
|
223
235
|
await prompts.waitForEnter();
|
|
@@ -228,10 +240,20 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
228
240
|
try { loginResult.childProcess.kill(); } catch (e) { /* ignore */ }
|
|
229
241
|
}
|
|
230
242
|
|
|
243
|
+
// Restart CLIProxyAPI to load new tokens
|
|
244
|
+
console.log(chalk.gray(' RESTARTING CLIPROXYAPI...'));
|
|
245
|
+
await cliproxy.stop();
|
|
246
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
247
|
+
await cliproxy.start();
|
|
248
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
249
|
+
|
|
231
250
|
// Try to fetch models after auth
|
|
251
|
+
const modelSpinner = ora({ text: 'FETCHING AVAILABLE MODELS...', color: 'yellow' }).start();
|
|
232
252
|
const modelsResult = await cliproxy.fetchProviderModels(provider.id);
|
|
233
253
|
|
|
234
254
|
if (modelsResult.success && modelsResult.models.length > 0) {
|
|
255
|
+
modelSpinner.succeed(`FOUND ${modelsResult.models.length} MODELS`);
|
|
256
|
+
|
|
235
257
|
const selectedModel = await selectModelFromList(provider, modelsResult.models, boxWidth);
|
|
236
258
|
if (selectedModel) {
|
|
237
259
|
activateProvider(config, provider.id, {
|
|
@@ -245,6 +267,7 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
245
267
|
}
|
|
246
268
|
}
|
|
247
269
|
} else {
|
|
270
|
+
modelSpinner.warn('NO MODELS FOUND - USING AUTO MODE');
|
|
248
271
|
// No models but auth might have worked
|
|
249
272
|
activateProvider(config, provider.id, {
|
|
250
273
|
connectionType: 'cliproxy',
|
|
@@ -14,13 +14,16 @@ const {
|
|
|
14
14
|
INSTALL_DIR,
|
|
15
15
|
AUTH_DIR,
|
|
16
16
|
DEFAULT_PORT,
|
|
17
|
+
CALLBACK_PORT,
|
|
17
18
|
isInstalled,
|
|
19
|
+
isHeadless,
|
|
18
20
|
install,
|
|
19
21
|
isRunning,
|
|
20
22
|
start,
|
|
21
23
|
stop,
|
|
22
24
|
ensureRunning,
|
|
23
|
-
getLoginUrl
|
|
25
|
+
getLoginUrl,
|
|
26
|
+
processCallback
|
|
24
27
|
} = manager;
|
|
25
28
|
|
|
26
29
|
// Internal API key (must match config.yaml)
|
|
@@ -174,13 +177,16 @@ module.exports = {
|
|
|
174
177
|
INSTALL_DIR,
|
|
175
178
|
AUTH_DIR,
|
|
176
179
|
DEFAULT_PORT,
|
|
180
|
+
CALLBACK_PORT,
|
|
177
181
|
isInstalled,
|
|
182
|
+
isHeadless,
|
|
178
183
|
install,
|
|
179
184
|
isRunning,
|
|
180
185
|
start,
|
|
181
186
|
stop,
|
|
182
187
|
ensureRunning,
|
|
183
188
|
getLoginUrl,
|
|
189
|
+
processCallback,
|
|
184
190
|
|
|
185
191
|
// API
|
|
186
192
|
fetchLocal,
|