@yakumoryo/minimax-plan-usage 0.2.6 → 0.2.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/package.json +1 -1
- package/query.js +31 -5
package/package.json
CHANGED
package/query.js
CHANGED
|
@@ -27,23 +27,30 @@ function saveSettings(settings) {
|
|
|
27
27
|
writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function setup(token) {
|
|
30
|
+
function setup(token, url) {
|
|
31
31
|
if (!token || !token.startsWith('sk-cp-')) {
|
|
32
32
|
console.error('Error: Invalid token format. Token should start with "sk-cp-"');
|
|
33
33
|
console.error('');
|
|
34
|
-
console.error('Usage: npx @yakumoryo/minimax-plan-usage setup <your-token>');
|
|
34
|
+
console.error('Usage: npx @yakumoryo/minimax-plan-usage setup <your-token> [api-url]');
|
|
35
35
|
console.error('');
|
|
36
|
-
console.error('
|
|
36
|
+
console.error('Examples:');
|
|
37
37
|
console.error(' npx @yakumoryo/minimax-plan-usage setup sk-cp-YOUR_TOKEN_HERE');
|
|
38
|
+
console.error(' npx @yakumoryo/minimax-plan-usage setup sk-cp-YOUR_TOKEN_HERE https://api.minimaxi.com/anthropic');
|
|
38
39
|
process.exit(1);
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
// Validate URL if provided
|
|
43
|
+
let apiUrl = url || `${API_HOST}/anthropic`;
|
|
44
|
+
if (url && !url.startsWith('http')) {
|
|
45
|
+
apiUrl = `https://${url}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
const settings = getSettings();
|
|
42
49
|
|
|
43
50
|
if (!settings.env) settings.env = {};
|
|
44
51
|
|
|
45
52
|
settings.env.ANTHROPIC_AUTH_TOKEN = token;
|
|
46
|
-
settings.env.ANTHROPIC_BASE_URL =
|
|
53
|
+
settings.env.ANTHROPIC_BASE_URL = apiUrl;
|
|
47
54
|
|
|
48
55
|
if (!settings.env.ANTHROPIC_MODEL) settings.env.ANTHROPIC_MODEL = 'MiniMax-M2.7';
|
|
49
56
|
if (!settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL) settings.env.ANTHROPIC_DEFAULT_HAIKU_MODEL = 'MiniMax-M2.7';
|
|
@@ -190,7 +197,26 @@ const command = process.argv[2];
|
|
|
190
197
|
|
|
191
198
|
if (command === 'setup') {
|
|
192
199
|
const token = process.argv[3];
|
|
193
|
-
|
|
200
|
+
const url = process.argv[4];
|
|
201
|
+
setup(token, url);
|
|
202
|
+
} else if (command === 'setup-url') {
|
|
203
|
+
const url = process.argv[3];
|
|
204
|
+
if (!url) {
|
|
205
|
+
console.error('Error: URL required');
|
|
206
|
+
console.error('Usage: npx @yakumoryo/minimax-plan-usage setup-url <api-url>');
|
|
207
|
+
console.error('Example:');
|
|
208
|
+
console.error(' npx @yakumoryo/minimax-plan-usage setup-url https://api.minimaxi.com/anthropic');
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
let apiUrl = url.startsWith('http') ? url : `https://${url}`;
|
|
212
|
+
const settings = getSettings();
|
|
213
|
+
if (!settings.env) settings.env = {};
|
|
214
|
+
settings.env.ANTHROPIC_BASE_URL = apiUrl;
|
|
215
|
+
saveSettings(settings);
|
|
216
|
+
console.log('');
|
|
217
|
+
console.log('✅ API URL configured successfully!');
|
|
218
|
+
console.log(` ANTHROPIC_BASE_URL: ${apiUrl}`);
|
|
219
|
+
console.log('');
|
|
194
220
|
} else if (command === 'query') {
|
|
195
221
|
console.log('MiniMax API Host:', API_HOST);
|
|
196
222
|
queryUsage()
|