yymaxapi 1.0.63 → 1.0.64
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/bin/yymaxapi.js +20 -8
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -716,7 +716,7 @@ function writeCodexConfig(baseUrl, apiKey) {
|
|
|
716
716
|
} catch { /* 非关键,静默失败 */ }
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
-
function writeOpencodeConfig(
|
|
719
|
+
function writeOpencodeConfig(claudeBaseUrl, codexBaseUrl, apiKey, modelId) {
|
|
720
720
|
const home = os.homedir();
|
|
721
721
|
const configDir = process.platform === 'win32'
|
|
722
722
|
? path.join(process.env.APPDATA || path.join(home, 'AppData', 'Roaming'), 'opencode')
|
|
@@ -724,12 +724,18 @@ function writeOpencodeConfig(baseUrl, apiKey, modelId) {
|
|
|
724
724
|
const configPath = path.join(configDir, 'config.json');
|
|
725
725
|
try {
|
|
726
726
|
if (!fs.existsSync(configDir)) fs.mkdirSync(configDir, { recursive: true });
|
|
727
|
-
const
|
|
727
|
+
const cleanClaudeUrl = claudeBaseUrl.replace(/\/+$/, '');
|
|
728
|
+
let cleanCodexUrl = (codexBaseUrl || '').replace(/\/+$/, '');
|
|
729
|
+
if (cleanCodexUrl && !cleanCodexUrl.endsWith('/v1')) cleanCodexUrl += '/v1';
|
|
728
730
|
const config = {
|
|
729
731
|
provider: {
|
|
730
732
|
anthropic: {
|
|
731
733
|
apiKey: apiKey,
|
|
732
|
-
baseURL:
|
|
734
|
+
baseURL: cleanClaudeUrl
|
|
735
|
+
},
|
|
736
|
+
openai: {
|
|
737
|
+
apiKey: apiKey,
|
|
738
|
+
baseURL: cleanCodexUrl || cleanClaudeUrl
|
|
733
739
|
}
|
|
734
740
|
},
|
|
735
741
|
model: modelId || 'claude-sonnet-4-6'
|
|
@@ -741,7 +747,7 @@ function writeOpencodeConfig(baseUrl, apiKey, modelId) {
|
|
|
741
747
|
}
|
|
742
748
|
}
|
|
743
749
|
|
|
744
|
-
function syncExternalTools(type, baseUrl, apiKey) {
|
|
750
|
+
function syncExternalTools(type, baseUrl, apiKey, extra = {}) {
|
|
745
751
|
const synced = [];
|
|
746
752
|
try {
|
|
747
753
|
if (type === 'claude') {
|
|
@@ -751,6 +757,10 @@ function syncExternalTools(type, baseUrl, apiKey) {
|
|
|
751
757
|
writeCodexConfig(baseUrl, apiKey);
|
|
752
758
|
synced.push('Codex CLI config');
|
|
753
759
|
}
|
|
760
|
+
if (type === 'claude' && extra.codexBaseUrl) {
|
|
761
|
+
writeOpencodeConfig(baseUrl, extra.codexBaseUrl, apiKey);
|
|
762
|
+
synced.push('Opencode config');
|
|
763
|
+
}
|
|
754
764
|
} catch { /* ignore */ }
|
|
755
765
|
return synced;
|
|
756
766
|
}
|
|
@@ -2745,7 +2755,7 @@ async function autoActivate(paths, args = {}) {
|
|
|
2745
2755
|
updateAuthProfiles(paths.authProfiles, claudeProviderName, apiKey);
|
|
2746
2756
|
updateAuthProfiles(paths.authProfiles, codexProviderName, apiKey);
|
|
2747
2757
|
const extSynced = [];
|
|
2748
|
-
try { syncExternalTools('claude', claudeBaseUrl, apiKey); extSynced.push('Claude Code settings'); } catch { /* ignore */ }
|
|
2758
|
+
try { syncExternalTools('claude', claudeBaseUrl, apiKey, { codexBaseUrl }); extSynced.push('Claude Code settings'); } catch { /* ignore */ }
|
|
2749
2759
|
try { syncExternalTools('codex', codexBaseUrl, apiKey); extSynced.push('Codex CLI config'); } catch { /* ignore */ }
|
|
2750
2760
|
writeSpinner.succeed('配置写入完成');
|
|
2751
2761
|
|
|
@@ -2927,13 +2937,15 @@ async function activateOpencode(paths, args = {}) {
|
|
|
2927
2937
|
|
|
2928
2938
|
// ---- 写入配置 ----
|
|
2929
2939
|
const claudeBaseUrl = buildFullUrl(selectedEndpoint.url, 'claude');
|
|
2940
|
+
const codexBaseUrl = buildFullUrl(selectedEndpoint.url, 'codex');
|
|
2930
2941
|
const modelId = 'claude-sonnet-4-6';
|
|
2931
2942
|
const writeSpinner = ora({ text: '正在写入 Opencode 配置...', spinner: 'dots' }).start();
|
|
2932
|
-
const configPath = writeOpencodeConfig(claudeBaseUrl, apiKey, modelId);
|
|
2943
|
+
const configPath = writeOpencodeConfig(claudeBaseUrl, codexBaseUrl, apiKey, modelId);
|
|
2933
2944
|
writeSpinner.succeed('Opencode 配置写入完成');
|
|
2934
2945
|
|
|
2935
2946
|
console.log(chalk.green('\n✅ Opencode 配置完成!'));
|
|
2936
|
-
console.log(chalk.cyan(`
|
|
2947
|
+
console.log(chalk.cyan(` Claude: ${claudeBaseUrl}`));
|
|
2948
|
+
console.log(chalk.cyan(` Codex: ${codexBaseUrl}`));
|
|
2937
2949
|
console.log(chalk.gray(` 模型: ${modelId}`));
|
|
2938
2950
|
console.log(chalk.gray(' API Key: 已设置'));
|
|
2939
2951
|
if (configPath) {
|
|
@@ -3083,7 +3095,7 @@ async function yycodeQuickSetup(paths) {
|
|
|
3083
3095
|
writeConfigWithSync(paths, config);
|
|
3084
3096
|
updateAuthProfiles(paths.authProfiles, claudeProviderName, apiKey);
|
|
3085
3097
|
updateAuthProfiles(paths.authProfiles, codexProviderName, apiKey);
|
|
3086
|
-
try { syncExternalTools('claude', claudeBaseUrl, apiKey); } catch { /* ignore */ }
|
|
3098
|
+
try { syncExternalTools('claude', claudeBaseUrl, apiKey, { codexBaseUrl }); } catch { /* ignore */ }
|
|
3087
3099
|
try { syncExternalTools('codex', codexBaseUrl, apiKey); } catch { /* ignore */ }
|
|
3088
3100
|
writeSpinner.succeed('配置写入完成');
|
|
3089
3101
|
|