hedgequantx 2.7.60 → 2.7.62
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-ui.js +53 -42
- package/src/pages/ai-agents.js +2 -19
package/package.json
CHANGED
|
@@ -85,29 +85,68 @@ const draw2ColRowCentered = (leftText, rightText, W) => {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
* Draw providers table
|
|
88
|
+
* Draw providers table with vertically aligned columns
|
|
89
89
|
* @param {Array} providers - List of AI providers
|
|
90
90
|
* @param {Object} config - Current config
|
|
91
91
|
* @param {number} boxWidth - Box width
|
|
92
92
|
*/
|
|
93
93
|
const drawProvidersTable = (providers, config, boxWidth) => {
|
|
94
94
|
const W = boxWidth - 2;
|
|
95
|
+
const colWidth = Math.floor(W / 2);
|
|
95
96
|
|
|
96
97
|
// New rectangle (banner is always closed)
|
|
97
98
|
console.log(chalk.cyan('╔' + '═'.repeat(W) + '╗'));
|
|
98
99
|
console.log(chalk.cyan('║') + chalk.yellow.bold(centerText('AI AGENTS CONFIGURATION', W)) + chalk.cyan('║'));
|
|
99
100
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
100
101
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const rows = Math.ceil(providers.length / 2);
|
|
103
|
+
|
|
104
|
+
// Find max name length across ALL providers for consistent alignment
|
|
105
|
+
const maxNameLen = Math.max(...providers.map(p => p.name.length));
|
|
106
|
+
|
|
107
|
+
// Fixed format: "[N] NAME" where N is always same width, NAME padded to maxNameLen
|
|
108
|
+
// Total content width = 3 ([N]) + 1 (space) + maxNameLen + 2 (possible " ●")
|
|
109
|
+
const contentWidth = 3 + 1 + maxNameLen + 2;
|
|
110
|
+
const leftPad = Math.floor((colWidth - contentWidth) / 2);
|
|
111
|
+
const rightPad = Math.floor(((W - colWidth) - contentWidth) / 2);
|
|
105
112
|
|
|
106
|
-
const rows = Math.ceil(items.length / 2);
|
|
107
113
|
for (let row = 0; row < rows; row++) {
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
|
|
114
|
+
const leftP = providers[row];
|
|
115
|
+
const rightP = providers[row + rows];
|
|
116
|
+
|
|
117
|
+
// Left column
|
|
118
|
+
let leftCol = '';
|
|
119
|
+
if (leftP) {
|
|
120
|
+
const num = row + 1;
|
|
121
|
+
const status = config.providers[leftP.id]?.active ? chalk.green(' ●') : ' ';
|
|
122
|
+
const statusRaw = config.providers[leftP.id]?.active ? ' ●' : ' ';
|
|
123
|
+
const name = leftP.provider ? leftP.provider.name : leftP.name;
|
|
124
|
+
const namePadded = name.toUpperCase().padEnd(maxNameLen);
|
|
125
|
+
const content = chalk.cyan(`[${num}]`) + ' ' + chalk[leftP.color](namePadded) + status;
|
|
126
|
+
const contentLen = 3 + 1 + maxNameLen + 2;
|
|
127
|
+
const padR = colWidth - leftPad - contentLen;
|
|
128
|
+
leftCol = ' '.repeat(leftPad) + content + ' '.repeat(Math.max(0, padR));
|
|
129
|
+
} else {
|
|
130
|
+
leftCol = ' '.repeat(colWidth);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Right column
|
|
134
|
+
let rightCol = '';
|
|
135
|
+
const rightColWidth = W - colWidth;
|
|
136
|
+
if (rightP) {
|
|
137
|
+
const num = row + rows + 1;
|
|
138
|
+
const status = config.providers[rightP.id]?.active ? chalk.green(' ●') : ' ';
|
|
139
|
+
const name = rightP.provider ? rightP.provider.name : rightP.name;
|
|
140
|
+
const namePadded = name.toUpperCase().padEnd(maxNameLen);
|
|
141
|
+
const content = chalk.cyan(`[${num}]`) + ' ' + chalk[rightP.color](namePadded) + status;
|
|
142
|
+
const contentLen = 3 + 1 + maxNameLen + 2;
|
|
143
|
+
const padR2 = rightColWidth - rightPad - contentLen;
|
|
144
|
+
rightCol = ' '.repeat(rightPad) + content + ' '.repeat(Math.max(0, padR2));
|
|
145
|
+
} else {
|
|
146
|
+
rightCol = ' '.repeat(rightColWidth);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
console.log(chalk.cyan('║') + leftCol + rightCol + chalk.cyan('║'));
|
|
111
150
|
}
|
|
112
151
|
|
|
113
152
|
console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
|
|
@@ -144,18 +183,12 @@ const drawProviderWindow = (provider, config, boxWidth) => {
|
|
|
144
183
|
console.log(chalk.cyan('║') + chalk[provider.color].bold(centerText(provider.name.toUpperCase(), W)) + chalk.cyan('║'));
|
|
145
184
|
console.log(chalk.cyan('╠' + '═'.repeat(W) + '╣'));
|
|
146
185
|
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// Options in 2 columns
|
|
151
|
-
const opt1Title = '[1] CONNECT VIA PAID PLAN';
|
|
152
|
-
const opt1Desc = 'USES CLIPROXY - NO API KEY NEEDED';
|
|
153
|
-
const opt2Title = '[2] CONNECT VIA API KEY';
|
|
154
|
-
const opt2Desc = 'ENTER YOUR OWN API KEY';
|
|
186
|
+
// Options in 2 columns (centered)
|
|
187
|
+
const opt1 = '[1] CONNECT VIA PAID PLAN';
|
|
188
|
+
const opt2 = '[2] CONNECT VIA API KEY';
|
|
155
189
|
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
const right1 = chalk.yellow(opt2Title);
|
|
190
|
+
const left1 = chalk.green(opt1);
|
|
191
|
+
const right1 = chalk.yellow(opt2);
|
|
159
192
|
const left1Len = visibleLength(left1);
|
|
160
193
|
const right1Len = visibleLength(right1);
|
|
161
194
|
const left1PadTotal = col1Width - left1Len;
|
|
@@ -172,28 +205,6 @@ const drawProviderWindow = (provider, config, boxWidth) => {
|
|
|
172
205
|
chalk.cyan('║')
|
|
173
206
|
);
|
|
174
207
|
|
|
175
|
-
// Row 2: Descriptions
|
|
176
|
-
const left2 = chalk.gray(opt1Desc);
|
|
177
|
-
const right2 = chalk.gray(opt2Desc);
|
|
178
|
-
const left2Len = visibleLength(left2);
|
|
179
|
-
const right2Len = visibleLength(right2);
|
|
180
|
-
const left2PadTotal = col1Width - left2Len;
|
|
181
|
-
const left2PadL = Math.floor(left2PadTotal / 2);
|
|
182
|
-
const left2PadR = left2PadTotal - left2PadL;
|
|
183
|
-
const right2PadTotal = col2Width - right2Len;
|
|
184
|
-
const right2PadL = Math.floor(right2PadTotal / 2);
|
|
185
|
-
const right2PadR = right2PadTotal - right2PadL;
|
|
186
|
-
|
|
187
|
-
console.log(
|
|
188
|
-
chalk.cyan('║') +
|
|
189
|
-
' '.repeat(left2PadL) + left2 + ' '.repeat(left2PadR) +
|
|
190
|
-
' '.repeat(right2PadL) + right2 + ' '.repeat(right2PadR) +
|
|
191
|
-
chalk.cyan('║')
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
// Empty line
|
|
195
|
-
console.log(chalk.cyan('║') + ' '.repeat(W) + chalk.cyan('║'));
|
|
196
|
-
|
|
197
208
|
// Status bar
|
|
198
209
|
console.log(chalk.cyan('╠' + '─'.repeat(W) + '╣'));
|
|
199
210
|
|
package/src/pages/ai-agents.js
CHANGED
|
@@ -237,26 +237,9 @@ const handleCliProxyConnection = async (provider, config, boxWidth) => {
|
|
|
237
237
|
try { loginResult.childProcess.kill(); } catch (e) { /* ignore */ }
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
//
|
|
241
|
-
const restartSpinner = ora({ text: 'RESTARTING CLIPROXY...', color: 'yellow' }).start();
|
|
242
|
-
await cliproxy.stop();
|
|
243
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
244
|
-
await cliproxy.start();
|
|
245
|
-
await new Promise(r => setTimeout(r, 2000));
|
|
246
|
-
restartSpinner.stop();
|
|
247
|
-
|
|
248
|
-
// Fetch models from CLIProxy (retry a few times if needed)
|
|
249
|
-
let modelsResult = { success: false, models: [] };
|
|
240
|
+
// Fetch models from CLIProxy
|
|
250
241
|
const spinner = ora({ text: 'LOADING MODELS...', color: 'yellow' }).start();
|
|
251
|
-
|
|
252
|
-
for (let i = 0; i < 10; i++) {
|
|
253
|
-
modelsResult = await cliproxy.fetchProviderModels(provider.id);
|
|
254
|
-
if (modelsResult.success && modelsResult.models.length > 0) {
|
|
255
|
-
spinner.stop();
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
259
|
-
}
|
|
242
|
+
const modelsResult = await cliproxy.fetchProviderModels(provider.id);
|
|
260
243
|
spinner.stop();
|
|
261
244
|
|
|
262
245
|
if (modelsResult.success && modelsResult.models.length > 0) {
|