yymaxapi 1.0.64 → 1.0.65
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 +24 -13
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -721,26 +721,37 @@ function writeOpencodeConfig(claudeBaseUrl, codexBaseUrl, apiKey, modelId) {
|
|
|
721
721
|
const configDir = process.platform === 'win32'
|
|
722
722
|
? path.join(process.env.APPDATA || path.join(home, 'AppData', 'Roaming'), 'opencode')
|
|
723
723
|
: path.join(home, '.config', 'opencode');
|
|
724
|
-
const configPath = path.join(configDir, '
|
|
724
|
+
const configPath = path.join(configDir, 'opencode.json');
|
|
725
725
|
try {
|
|
726
726
|
if (!fs.existsSync(configDir)) fs.mkdirSync(configDir, { recursive: true });
|
|
727
|
+
let existing = {};
|
|
728
|
+
if (fs.existsSync(configPath)) {
|
|
729
|
+
try { existing = JSON.parse(fs.readFileSync(configPath, 'utf8')); } catch { existing = {}; }
|
|
730
|
+
}
|
|
727
731
|
const cleanClaudeUrl = claudeBaseUrl.replace(/\/+$/, '');
|
|
728
732
|
let cleanCodexUrl = (codexBaseUrl || '').replace(/\/+$/, '');
|
|
729
733
|
if (cleanCodexUrl && !cleanCodexUrl.endsWith('/v1')) cleanCodexUrl += '/v1';
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
734
|
+
if (!existing.provider) existing.provider = {};
|
|
735
|
+
existing.provider.anthropic = {
|
|
736
|
+
options: {
|
|
737
|
+
apiKey: apiKey,
|
|
738
|
+
baseURL: cleanClaudeUrl
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
if (cleanCodexUrl) {
|
|
742
|
+
existing.provider.openai = {
|
|
743
|
+
options: {
|
|
737
744
|
apiKey: apiKey,
|
|
738
|
-
baseURL: cleanCodexUrl
|
|
745
|
+
baseURL: cleanCodexUrl
|
|
739
746
|
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
const rawModelId = modelId || 'claude-sonnet-4-6';
|
|
750
|
+
existing.model = rawModelId.startsWith('anthropic/') || rawModelId.startsWith('openai/')
|
|
751
|
+
? rawModelId
|
|
752
|
+
: `anthropic/${rawModelId}`;
|
|
753
|
+
if (!existing.$schema) existing.$schema = 'https://opencode.ai/config.json';
|
|
754
|
+
fs.writeFileSync(configPath, JSON.stringify(existing, null, 2), 'utf8');
|
|
744
755
|
return configPath;
|
|
745
756
|
} catch {
|
|
746
757
|
return null;
|