@2api-store/activate 0.2.0 → 0.2.1
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/activate.mjs +23 -2
- package/package.json +1 -1
package/activate.mjs
CHANGED
|
@@ -110,6 +110,23 @@ function classifyCredential(cred) {
|
|
|
110
110
|
return 'unknown'
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* 从模型 ID 列表推断平台集合(与端点 inferPlatforms 对应,脚本兜底过滤)。
|
|
115
|
+
* 即使生产端点尚未部署过滤(0.314.0),脚本也按 key 分组实际可用模型平台过滤 configs,
|
|
116
|
+
* 避免给 codex key 列出 gemini/claude 等。
|
|
117
|
+
*/
|
|
118
|
+
function inferModelPlatforms(models) {
|
|
119
|
+
const set = new Set()
|
|
120
|
+
for (const m of models || []) {
|
|
121
|
+
const id = (typeof m === 'string' ? m : m?.id || '').toLowerCase()
|
|
122
|
+
if (/^(gpt|o1|o3|codex|glm|minimax|deepseek)/.test(id)) set.add('openai')
|
|
123
|
+
else if (id.startsWith('claude')) set.add('anthropic')
|
|
124
|
+
else if (id.startsWith('gemini')) set.add('gemini')
|
|
125
|
+
else if (id.startsWith('grok')) set.add('grok')
|
|
126
|
+
}
|
|
127
|
+
return [...set]
|
|
128
|
+
}
|
|
129
|
+
|
|
113
130
|
async function main() {
|
|
114
131
|
const args = parseArgs(process.argv.slice(2))
|
|
115
132
|
if (args.help) {
|
|
@@ -192,10 +209,14 @@ async function main() {
|
|
|
192
209
|
}
|
|
193
210
|
console.log()
|
|
194
211
|
|
|
195
|
-
// === 5. 按 os_type
|
|
212
|
+
// === 5. 按 os_type + key 分组平台过滤、展示可用 CLI ===
|
|
213
|
+
const allowedPlatforms = inferModelPlatforms(bundle.models || [])
|
|
214
|
+
if (args.platform) allowedPlatforms.push(args.platform)
|
|
196
215
|
let osConfigs = (bundle.configs || []).filter((c) => {
|
|
197
216
|
if (!c) return false
|
|
198
|
-
//
|
|
217
|
+
// 按 key 分组可用模型平台过滤(兜底,与端点 inferPlatforms 一致;codex key 只列 openai)
|
|
218
|
+
if (allowedPlatforms.length > 0 && !allowedPlatforms.includes(c.platform)) return false
|
|
219
|
+
// 客户端 --platform 二次过滤(防御性)
|
|
199
220
|
if (args.platform && c.platform !== args.platform) return false
|
|
200
221
|
if (env.os.isWindows) {
|
|
201
222
|
return c.os_type === 'windows' || c.os_type === 'all'
|