Extract shared MiniMax provider logic into minimax-shared.js factory module used by both minimax-coding-plan and minimax-cn-coding-plan as thin wrappers. Endpoint fallback: - Try /v1/token_plan/remains (M3/Token Plan) first - Fall back to legacy /v1/api/openplatform/coding_plan/remains - fetchEndpoint wrapped in try/catch so network/parse errors return null instead of throwing, ensuring fallback always runs Model selection (pickChatModel): - Prefer MiniMax-M* entries with non-zero total_count (Token Plan M3) - Fall back to general/chat/text model names (legacy Coding Plan) - Fall back to any entry with current_interval_remaining_percent - Ultimate fallback to model_remains[0] Usage calculation: - token_plan endpoint: usage_count = remaining, so used = total - remaining - coding_plan endpoint: usage_count = consumed (legacy behavior) - Prefer current_interval_remaining_percent when count fields are zero (legacy Coding Plan accounts with percentage-based quotas) - remains_time used as fallback for window duration (in milliseconds, confirmed via live API: 9664502ms = 2.68h in 5h window) Window status: - Respect current_weekly_status field: status 3 means the window is not applicable for the current plan tier (e.g. legacy plans without weekly limits). These windows are omitted from the result. - Default to active when status field is absent (backward compatible). Fixes #759 (percentage showing empty/null for legacy Coding Plan accounts and incorrect percentages for M3/Token Plan accounts).
16 lines
637 B
JavaScript
16 lines
637 B
JavaScript
import { createMiniMaxCodingPlanProvider } from './minimax-shared.js';
|
|
|
|
const provider = createMiniMaxCodingPlanProvider({
|
|
providerId: 'minimax-coding-plan',
|
|
providerName: 'MiniMax Coding Plan (minimax.io)',
|
|
aliases: ['minimax-coding-plan'],
|
|
tokenPlanUrl: 'https://api.minimax.io/v1/token_plan/remains',
|
|
codingPlanUrl: 'https://api.minimax.io/v1/api/openplatform/coding_plan/remains',
|
|
});
|
|
|
|
export const providerId = provider.providerId;
|
|
export const providerName = provider.providerName;
|
|
export const aliases = provider.aliases;
|
|
export const isConfigured = provider.isConfigured;
|
|
export const fetchQuota = provider.fetchQuota;
|