yymaxapi 1.0.98 → 1.0.100
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
CHANGED
|
@@ -108,7 +108,11 @@ const DEFAULT_CLAUDE_MODELS = [
|
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
"id": "claude-opus-4-6",
|
|
111
|
-
"name": "Claude Opus 4.6
|
|
111
|
+
"name": "Claude Opus 4.6"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "claude-opus-4-6-thinking",
|
|
115
|
+
"name": "Claude Opus 4.6 Thinking"
|
|
112
116
|
}
|
|
113
117
|
];
|
|
114
118
|
|
|
@@ -1936,7 +1940,7 @@ const YYMAXAPI_OPENCLAW_GPT_FALLBACK = `${YYMAXAPI_OPENCLAW_GPT_PROVIDER}/gpt-5.
|
|
|
1936
1940
|
const YYMAXAPI_MANAGED_MAIN_NAMES = new Set(['Claude', 'claude', 'yunyi-claude', 'claude-yunyi']);
|
|
1937
1941
|
const YYMAXAPI_MANAGED_GPT_NAMES = new Set(['GPT', 'Codex', 'gpt', 'yunyi-gpt', 'yunyi-codex']);
|
|
1938
1942
|
const YYMAXAPI_MANAGED_MULTIMODAL_MODELS = {
|
|
1939
|
-
claude: new Set(['claude-sonnet-4-6', 'claude-opus-4-6']),
|
|
1943
|
+
claude: new Set(['claude-sonnet-4-6', 'claude-opus-4-6', 'claude-opus-4-6-thinking']),
|
|
1940
1944
|
codex: new Set(['gpt-5.4', 'gpt-5.3-codex'])
|
|
1941
1945
|
};
|
|
1942
1946
|
|
|
@@ -1972,15 +1976,9 @@ function stripManagedYunyiSuffix(baseUrl) {
|
|
|
1972
1976
|
|
|
1973
1977
|
function getManagedYunyiModelCatalog(type) {
|
|
1974
1978
|
if (type === 'claude') {
|
|
1975
|
-
return
|
|
1976
|
-
{ id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6' },
|
|
1977
|
-
{ id: 'claude-opus-4-6', name: 'Claude Opus 4.6' }
|
|
1978
|
-
];
|
|
1979
|
+
return CLAUDE_MODELS;
|
|
1979
1980
|
}
|
|
1980
|
-
return
|
|
1981
|
-
{ id: 'gpt-5.4', name: 'GPT 5.4' },
|
|
1982
|
-
{ id: 'gpt-5.3-codex', name: 'GPT 5.3 Codex' }
|
|
1983
|
-
];
|
|
1981
|
+
return CODEX_MODELS;
|
|
1984
1982
|
}
|
|
1985
1983
|
|
|
1986
1984
|
function resolveManagedYunyiModelName(type, modelId, fallbackName) {
|
|
@@ -2038,15 +2036,29 @@ function canonicalizeManagedYunyiModelKey(modelKey, preferredType = '') {
|
|
|
2038
2036
|
return text;
|
|
2039
2037
|
}
|
|
2040
2038
|
|
|
2039
|
+
function getManagedYunyiProviderName(type) {
|
|
2040
|
+
return type === 'claude' ? YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER : YYMAXAPI_OPENCLAW_GPT_PROVIDER;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
function getManagedYunyiDefaultPrimaryModelKey(type) {
|
|
2044
|
+
return type === 'claude' ? YYMAXAPI_OPENCLAW_CLAUDE_PRIMARY : YYMAXAPI_OPENCLAW_GPT_PRIMARY;
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2041
2047
|
function getManagedYunyiKnownModelKeys(type) {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2048
|
+
const providerName = getManagedYunyiProviderName(type);
|
|
2049
|
+
return getManagedYunyiModelCatalog(type).map(model => `${providerName}/${model.id}`);
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
function getManagedYunyiModelAliasEntries() {
|
|
2053
|
+
return {
|
|
2054
|
+
...Object.fromEntries(getManagedYunyiKnownModelKeys('claude').map(modelKey => [modelKey, YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER])),
|
|
2055
|
+
...Object.fromEntries(getManagedYunyiKnownModelKeys('codex').map(modelKey => [modelKey, YYMAXAPI_OPENCLAW_GPT_PROVIDER]))
|
|
2056
|
+
};
|
|
2045
2057
|
}
|
|
2046
2058
|
|
|
2047
2059
|
function normalizeManagedYunyiModelState(type, modelState = {}, options = {}) {
|
|
2048
2060
|
const knownKeys = getManagedYunyiKnownModelKeys(type);
|
|
2049
|
-
const fallbackPrimary = knownKeys[0];
|
|
2061
|
+
const fallbackPrimary = knownKeys[0] || getManagedYunyiDefaultPrimaryModelKey(type);
|
|
2050
2062
|
const currentPrimary = canonicalizeManagedYunyiModelKey(modelState.primary || '', type);
|
|
2051
2063
|
const canPreserve = !options.force && currentPrimary && knownKeys.includes(currentPrimary);
|
|
2052
2064
|
const primary = canPreserve ? currentPrimary : fallbackPrimary;
|
|
@@ -2103,9 +2115,146 @@ function getManagedClaudeAgentId(config) {
|
|
|
2103
2115
|
return mainAgent ? YYMAXAPI_OPENCLAW_MAIN_AGENT_ID : (sideAgent ? YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID : null);
|
|
2104
2116
|
}
|
|
2105
2117
|
|
|
2118
|
+
function getManagedYunyiActiveType(config) {
|
|
2119
|
+
const defaultsPrimary = canonicalizeManagedYunyiModelKey(String(config?.agents?.defaults?.model?.primary || '').trim());
|
|
2120
|
+
if (isManagedYunyiClaudeModelKey(defaultsPrimary)) return 'claude';
|
|
2121
|
+
if (isManagedYunyiGptModelKey(defaultsPrimary)) return 'codex';
|
|
2122
|
+
|
|
2123
|
+
const mainState = getAgentModelState(findAgentById(config, YYMAXAPI_OPENCLAW_MAIN_AGENT_ID));
|
|
2124
|
+
const mainPrimary = canonicalizeManagedYunyiModelKey(mainState.primary || '');
|
|
2125
|
+
if (isManagedYunyiClaudeModelKey(mainPrimary)) return 'claude';
|
|
2126
|
+
if (isManagedYunyiGptModelKey(mainPrimary)) return 'codex';
|
|
2127
|
+
|
|
2128
|
+
return 'claude';
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
function findManagedYunyiAgentState(config, type) {
|
|
2132
|
+
const candidateIds = type === 'claude'
|
|
2133
|
+
? [YYMAXAPI_OPENCLAW_MAIN_AGENT_ID, YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID]
|
|
2134
|
+
: [YYMAXAPI_OPENCLAW_MAIN_AGENT_ID, YYMAXAPI_OPENCLAW_GPT_AGENT_ID, ...YYMAXAPI_OPENCLAW_LEGACY_GPT_AGENT_IDS];
|
|
2135
|
+
|
|
2136
|
+
const matcher = type === 'claude' ? isManagedYunyiClaudeModelKey : isManagedYunyiGptModelKey;
|
|
2137
|
+
|
|
2138
|
+
for (const agentId of candidateIds) {
|
|
2139
|
+
const state = getAgentModelState(findAgentById(config, agentId));
|
|
2140
|
+
const primary = canonicalizeManagedYunyiModelKey(state.primary || '', type);
|
|
2141
|
+
if (matcher(primary)) return state;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
return {};
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
function getManagedYunyiDesiredPrimaryModelKey(config, type, explicitModelKey = '') {
|
|
2148
|
+
const explicitPrimary = canonicalizeManagedYunyiModelKey(explicitModelKey, type);
|
|
2149
|
+
if (type === 'claude' ? isManagedYunyiClaudeModelKey(explicitPrimary) : isManagedYunyiGptModelKey(explicitPrimary)) {
|
|
2150
|
+
return explicitPrimary;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
const defaultsPrimary = canonicalizeManagedYunyiModelKey(String(config?.agents?.defaults?.model?.primary || '').trim(), type);
|
|
2154
|
+
if (type === 'claude' ? isManagedYunyiClaudeModelKey(defaultsPrimary) : isManagedYunyiGptModelKey(defaultsPrimary)) {
|
|
2155
|
+
return defaultsPrimary;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
return '';
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
function resolveManagedYunyiAgentAssignments(config, preferredType = '') {
|
|
2162
|
+
const mainAgent = findAgentById(config, YYMAXAPI_OPENCLAW_MAIN_AGENT_ID);
|
|
2163
|
+
const preservedMain = Boolean(mainAgent) && !isManagedMainAgent(mainAgent);
|
|
2164
|
+
const activeType = preferredType || getManagedYunyiActiveType(config);
|
|
2165
|
+
|
|
2166
|
+
if (preservedMain) {
|
|
2167
|
+
return {
|
|
2168
|
+
preservedMain: true,
|
|
2169
|
+
activeType,
|
|
2170
|
+
mainAgentType: '',
|
|
2171
|
+
claudeAgentId: YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID,
|
|
2172
|
+
gptAgentId: YYMAXAPI_OPENCLAW_GPT_AGENT_ID
|
|
2173
|
+
};
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
return activeType === 'codex'
|
|
2177
|
+
? {
|
|
2178
|
+
preservedMain: false,
|
|
2179
|
+
activeType,
|
|
2180
|
+
mainAgentType: 'codex',
|
|
2181
|
+
claudeAgentId: YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID,
|
|
2182
|
+
gptAgentId: YYMAXAPI_OPENCLAW_MAIN_AGENT_ID
|
|
2183
|
+
}
|
|
2184
|
+
: {
|
|
2185
|
+
preservedMain: false,
|
|
2186
|
+
activeType: 'claude',
|
|
2187
|
+
mainAgentType: 'claude',
|
|
2188
|
+
claudeAgentId: YYMAXAPI_OPENCLAW_MAIN_AGENT_ID,
|
|
2189
|
+
gptAgentId: YYMAXAPI_OPENCLAW_GPT_AGENT_ID
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
function syncManagedYunyiAgents(config, options = {}) {
|
|
2194
|
+
ensureConfigStructure(config);
|
|
2195
|
+
|
|
2196
|
+
const assignments = resolveManagedYunyiAgentAssignments(config, options.preferredType);
|
|
2197
|
+
const agentList = ensureAgentList(config);
|
|
2198
|
+
const claudeDesiredPrimary = getManagedYunyiDesiredPrimaryModelKey(config, 'claude', options.selectedModelKey);
|
|
2199
|
+
const gptDesiredPrimary = getManagedYunyiDesiredPrimaryModelKey(config, 'codex', options.selectedModelKey);
|
|
2200
|
+
const claudeState = normalizeManagedYunyiModelState('claude', {
|
|
2201
|
+
...findManagedYunyiAgentState(config, 'claude'),
|
|
2202
|
+
...(claudeDesiredPrimary ? { primary: claudeDesiredPrimary } : {})
|
|
2203
|
+
}, options);
|
|
2204
|
+
const gptState = normalizeManagedYunyiModelState('codex', {
|
|
2205
|
+
...findManagedYunyiAgentState(config, 'codex'),
|
|
2206
|
+
...(gptDesiredPrimary ? { primary: gptDesiredPrimary } : {})
|
|
2207
|
+
}, options);
|
|
2208
|
+
let changed = false;
|
|
2209
|
+
|
|
2210
|
+
if (!assignments.preservedMain) {
|
|
2211
|
+
const mainType = assignments.mainAgentType === 'codex' ? 'codex' : 'claude';
|
|
2212
|
+
const mainState = mainType === 'codex' ? gptState : claudeState;
|
|
2213
|
+
const mainResult = upsertManagedAgent(agentList, {
|
|
2214
|
+
id: YYMAXAPI_OPENCLAW_MAIN_AGENT_ID,
|
|
2215
|
+
default: true,
|
|
2216
|
+
name: mainType === 'codex' ? 'yunyi-gpt' : 'yunyi-claude',
|
|
2217
|
+
model: mainState
|
|
2218
|
+
}, isManagedMainAgent);
|
|
2219
|
+
if (mainResult.changed) changed = true;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
if (assignments.claudeAgentId === YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID) {
|
|
2223
|
+
const sideClaudeResult = upsertManagedAgent(agentList, {
|
|
2224
|
+
id: YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID,
|
|
2225
|
+
default: false,
|
|
2226
|
+
name: 'yunyi-claude',
|
|
2227
|
+
model: claudeState
|
|
2228
|
+
}, isManagedClaudeSideAgent);
|
|
2229
|
+
if (sideClaudeResult.changed) changed = true;
|
|
2230
|
+
} else if (removeManagedAgent(agentList, YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID, isManagedClaudeSideAgent)) {
|
|
2231
|
+
changed = true;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
if (assignments.gptAgentId === YYMAXAPI_OPENCLAW_GPT_AGENT_ID) {
|
|
2235
|
+
const gptResult = upsertManagedAgent(agentList, {
|
|
2236
|
+
id: YYMAXAPI_OPENCLAW_GPT_AGENT_ID,
|
|
2237
|
+
default: false,
|
|
2238
|
+
name: 'yunyi-gpt',
|
|
2239
|
+
model: gptState
|
|
2240
|
+
}, isManagedGptAgent);
|
|
2241
|
+
if (gptResult.changed) changed = true;
|
|
2242
|
+
} else if (removeManagedAgent(agentList, YYMAXAPI_OPENCLAW_GPT_AGENT_ID, isManagedGptAgent)) {
|
|
2243
|
+
changed = true;
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
for (const legacyAgentId of YYMAXAPI_OPENCLAW_LEGACY_GPT_AGENT_IDS) {
|
|
2247
|
+
if (legacyAgentId === YYMAXAPI_OPENCLAW_GPT_AGENT_ID) continue;
|
|
2248
|
+
if (removeManagedAgent(agentList, legacyAgentId, isManagedGptAgent)) changed = true;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
return { changed, ...assignments };
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2106
2254
|
function inferManagedYunyiAgentIdForModelKey(config, modelKey) {
|
|
2107
|
-
|
|
2108
|
-
if (
|
|
2255
|
+
const assignments = resolveManagedYunyiAgentAssignments(config);
|
|
2256
|
+
if (isManagedYunyiGptModelKey(modelKey)) return assignments.gptAgentId;
|
|
2257
|
+
if (isManagedYunyiClaudeModelKey(modelKey)) return assignments.claudeAgentId || getManagedClaudeAgentId(config);
|
|
2109
2258
|
return null;
|
|
2110
2259
|
}
|
|
2111
2260
|
|
|
@@ -2136,12 +2285,7 @@ function applyManagedYunyiModelSelection(config, selectedModelKey) {
|
|
|
2136
2285
|
changed = true;
|
|
2137
2286
|
}
|
|
2138
2287
|
|
|
2139
|
-
const managedModelAliases =
|
|
2140
|
-
[YYMAXAPI_OPENCLAW_CLAUDE_PRIMARY]: YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER,
|
|
2141
|
-
[YYMAXAPI_OPENCLAW_CLAUDE_FALLBACK]: YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER,
|
|
2142
|
-
[YYMAXAPI_OPENCLAW_GPT_PRIMARY]: YYMAXAPI_OPENCLAW_GPT_PROVIDER,
|
|
2143
|
-
[YYMAXAPI_OPENCLAW_GPT_FALLBACK]: YYMAXAPI_OPENCLAW_GPT_PROVIDER
|
|
2144
|
-
};
|
|
2288
|
+
const managedModelAliases = getManagedYunyiModelAliasEntries();
|
|
2145
2289
|
for (const [modelKey, alias] of Object.entries(managedModelAliases)) {
|
|
2146
2290
|
const nextEntry = { alias };
|
|
2147
2291
|
if (JSON.stringify(config.agents.defaults.models[modelKey] || {}) !== JSON.stringify(nextEntry)) {
|
|
@@ -2150,20 +2294,15 @@ function applyManagedYunyiModelSelection(config, selectedModelKey) {
|
|
|
2150
2294
|
}
|
|
2151
2295
|
}
|
|
2152
2296
|
|
|
2153
|
-
const
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
const shouldManage = selectedType === 'codex'
|
|
2163
|
-
? isManagedGptAgent
|
|
2164
|
-
: (agentId === YYMAXAPI_OPENCLAW_MAIN_AGENT_ID ? isManagedMainAgent : isManagedClaudeSideAgent);
|
|
2165
|
-
const updateResult = upsertManagedAgent(agentList, nextAgent, shouldManage);
|
|
2166
|
-
if (updateResult.changed) changed = true;
|
|
2297
|
+
const syncResult = syncManagedYunyiAgents(config, {
|
|
2298
|
+
preferredType: selectedType,
|
|
2299
|
+
selectedModelKey: normalizedSelected
|
|
2300
|
+
});
|
|
2301
|
+
if (syncResult.changed) changed = true;
|
|
2302
|
+
|
|
2303
|
+
const agentId = selectedType === 'codex'
|
|
2304
|
+
? syncResult.gptAgentId
|
|
2305
|
+
: syncResult.claudeAgentId;
|
|
2167
2306
|
|
|
2168
2307
|
return { changed, selectedModelKey: normalizedSelected, agentId };
|
|
2169
2308
|
}
|
|
@@ -2528,12 +2667,7 @@ function applyManagedYunyiOpenClawLayout(config, options = {}) {
|
|
|
2528
2667
|
}
|
|
2529
2668
|
|
|
2530
2669
|
const defaultsModels = config.agents.defaults.models;
|
|
2531
|
-
const managedModelAliases =
|
|
2532
|
-
[YYMAXAPI_OPENCLAW_CLAUDE_PRIMARY]: YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER,
|
|
2533
|
-
[YYMAXAPI_OPENCLAW_CLAUDE_FALLBACK]: YYMAXAPI_OPENCLAW_CLAUDE_PROVIDER,
|
|
2534
|
-
[YYMAXAPI_OPENCLAW_GPT_PRIMARY]: YYMAXAPI_OPENCLAW_GPT_PROVIDER,
|
|
2535
|
-
[YYMAXAPI_OPENCLAW_GPT_FALLBACK]: YYMAXAPI_OPENCLAW_GPT_PROVIDER
|
|
2536
|
-
};
|
|
2670
|
+
const managedModelAliases = getManagedYunyiModelAliasEntries();
|
|
2537
2671
|
for (const [modelKey, alias] of Object.entries(managedModelAliases)) {
|
|
2538
2672
|
const nextEntry = { alias };
|
|
2539
2673
|
if (JSON.stringify(defaultsModels[modelKey] || {}) !== JSON.stringify(nextEntry)) {
|
|
@@ -2542,45 +2676,6 @@ function applyManagedYunyiOpenClawLayout(config, options = {}) {
|
|
|
2542
2676
|
}
|
|
2543
2677
|
}
|
|
2544
2678
|
|
|
2545
|
-
const agentList = ensureAgentList(config);
|
|
2546
|
-
const currentMainAgentState = getAgentModelState(findAgentById(config, YYMAXAPI_OPENCLAW_MAIN_AGENT_ID));
|
|
2547
|
-
const mainAgentResult = upsertManagedAgent(agentList, {
|
|
2548
|
-
id: YYMAXAPI_OPENCLAW_MAIN_AGENT_ID,
|
|
2549
|
-
default: true,
|
|
2550
|
-
name: 'yunyi-claude',
|
|
2551
|
-
model: normalizeManagedYunyiModelState('claude', currentMainAgentState, options)
|
|
2552
|
-
}, isManagedMainAgent);
|
|
2553
|
-
if (mainAgentResult.changed) changed = true;
|
|
2554
|
-
|
|
2555
|
-
let claudeAgentId = YYMAXAPI_OPENCLAW_MAIN_AGENT_ID;
|
|
2556
|
-
let preservedMain = !mainAgentResult.managed;
|
|
2557
|
-
if (!mainAgentResult.managed) {
|
|
2558
|
-
const currentClaudeSideState = getAgentModelState(findAgentById(config, YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID));
|
|
2559
|
-
const fallbackClaudeAgentResult = upsertManagedAgent(agentList, {
|
|
2560
|
-
id: YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID,
|
|
2561
|
-
default: false,
|
|
2562
|
-
name: 'yunyi-claude',
|
|
2563
|
-
model: normalizeManagedYunyiModelState('claude', currentClaudeSideState, options)
|
|
2564
|
-
}, isManagedClaudeSideAgent);
|
|
2565
|
-
if (fallbackClaudeAgentResult.changed) changed = true;
|
|
2566
|
-
claudeAgentId = fallbackClaudeAgentResult.managed ? YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID : null;
|
|
2567
|
-
} else if (removeManagedAgent(agentList, YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID, isManagedClaudeSideAgent)) {
|
|
2568
|
-
changed = true;
|
|
2569
|
-
}
|
|
2570
|
-
|
|
2571
|
-
const currentGptAgentState = getAgentModelState(findAgentById(config, YYMAXAPI_OPENCLAW_GPT_AGENT_ID));
|
|
2572
|
-
const gptAgentResult = upsertManagedAgent(agentList, {
|
|
2573
|
-
id: YYMAXAPI_OPENCLAW_GPT_AGENT_ID,
|
|
2574
|
-
default: false,
|
|
2575
|
-
name: 'yunyi-gpt',
|
|
2576
|
-
model: normalizeManagedYunyiModelState('codex', currentGptAgentState, options)
|
|
2577
|
-
}, isManagedGptAgent);
|
|
2578
|
-
if (gptAgentResult.changed) changed = true;
|
|
2579
|
-
for (const legacyAgentId of YYMAXAPI_OPENCLAW_LEGACY_GPT_AGENT_IDS) {
|
|
2580
|
-
if (legacyAgentId === YYMAXAPI_OPENCLAW_GPT_AGENT_ID) continue;
|
|
2581
|
-
if (removeManagedAgent(agentList, legacyAgentId, isManagedGptAgent)) changed = true;
|
|
2582
|
-
}
|
|
2583
|
-
|
|
2584
2679
|
if (shouldManageYunyiDefaults(config)) {
|
|
2585
2680
|
const nextDefaultsModel = normalizeManagedYunyiDefaultsModel(config.agents.defaults.model, options);
|
|
2586
2681
|
if (JSON.stringify(config.agents.defaults.model) !== JSON.stringify(nextDefaultsModel)) {
|
|
@@ -2602,14 +2697,26 @@ function applyManagedYunyiOpenClawLayout(config, options = {}) {
|
|
|
2602
2697
|
changed = true;
|
|
2603
2698
|
}
|
|
2604
2699
|
|
|
2605
|
-
|
|
2700
|
+
const syncResult = syncManagedYunyiAgents(config, options);
|
|
2701
|
+
if (syncResult.changed) changed = true;
|
|
2702
|
+
|
|
2703
|
+
return {
|
|
2704
|
+
changed,
|
|
2705
|
+
applied: true,
|
|
2706
|
+
claudeAgentId: syncResult.claudeAgentId,
|
|
2707
|
+
gptAgentId: syncResult.gptAgentId,
|
|
2708
|
+
preservedMain: syncResult.preservedMain,
|
|
2709
|
+
mainAgentType: syncResult.mainAgentType
|
|
2710
|
+
};
|
|
2606
2711
|
}
|
|
2607
2712
|
|
|
2608
2713
|
function printYunyiOpenClawSwitchHint(result = {}) {
|
|
2609
2714
|
if (!result?.applied) return;
|
|
2610
2715
|
const summary = result.preservedMain && result.claudeAgentId === YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID
|
|
2611
2716
|
? 'OpenClaw: main 已保留, Claude=yunyi-claude, GPT=yunyi-gpt'
|
|
2612
|
-
:
|
|
2717
|
+
: (result.mainAgentType === 'codex'
|
|
2718
|
+
? 'OpenClaw: main=yunyi-gpt, Claude=yunyi-claude'
|
|
2719
|
+
: 'OpenClaw: main=yunyi-claude, GPT=yunyi-gpt');
|
|
2613
2720
|
console.log(chalk.cyan(` ${summary}`));
|
|
2614
2721
|
}
|
|
2615
2722
|
|
|
@@ -4626,7 +4733,10 @@ async function autoActivate(paths, args = {}) {
|
|
|
4626
4733
|
endpointUrl: selectedEndpoint.url,
|
|
4627
4734
|
apiKey
|
|
4628
4735
|
});
|
|
4629
|
-
applyManagedYunyiModelSelection(config, primaryModelKey);
|
|
4736
|
+
const selectionResult = applyManagedYunyiModelSelection(config, primaryModelKey);
|
|
4737
|
+
const finalYunyiLayoutResult = yunyiLayoutResult.applied
|
|
4738
|
+
? { ...yunyiLayoutResult, ...resolveManagedYunyiAgentAssignments(config, selectedType), applied: true }
|
|
4739
|
+
: yunyiLayoutResult;
|
|
4630
4740
|
|
|
4631
4741
|
// ---- 写入配置 ----
|
|
4632
4742
|
const writeSpinner = ora({ text: '正在写入配置...', spinner: 'dots' }).start();
|
|
@@ -4639,10 +4749,10 @@ async function autoActivate(paths, args = {}) {
|
|
|
4639
4749
|
if (yunyiLayoutResult.applied) {
|
|
4640
4750
|
syncManagedYunyiAuthProfiles(paths, config);
|
|
4641
4751
|
}
|
|
4642
|
-
if (
|
|
4643
|
-
const resetResult = resetManagedAgentSessionsWithSync(paths,
|
|
4752
|
+
if (selectionResult.agentId) {
|
|
4753
|
+
const resetResult = resetManagedAgentSessionsWithSync(paths, selectionResult.agentId);
|
|
4644
4754
|
if (resetResult.changed) {
|
|
4645
|
-
console.log(chalk.gray(` 已重置 ${
|
|
4755
|
+
console.log(chalk.gray(` 已重置 ${selectionResult.agentId} 的活动会话映射`));
|
|
4646
4756
|
}
|
|
4647
4757
|
}
|
|
4648
4758
|
const opencodeDefaultModelKey = isClaudePrimary ? `yunyi-claude/${claudeModelId}` : `yunyi-codex/${codexModelId}`;
|
|
@@ -4654,7 +4764,7 @@ async function autoActivate(paths, args = {}) {
|
|
|
4654
4764
|
const selectedModel = isClaudePrimary ? claudeModel : codexModel;
|
|
4655
4765
|
console.log(chalk.green('\n✅ 配置完成!'));
|
|
4656
4766
|
console.log(chalk.cyan(` 外部工具默认: ${selectedModel.name}`));
|
|
4657
|
-
printYunyiOpenClawSwitchHint(
|
|
4767
|
+
printYunyiOpenClawSwitchHint(finalYunyiLayoutResult);
|
|
4658
4768
|
|
|
4659
4769
|
const gwPort = config.gateway?.port || 18789;
|
|
4660
4770
|
const gwToken = config.gateway?.auth?.token;
|
|
@@ -4675,9 +4785,10 @@ async function autoActivate(paths, args = {}) {
|
|
|
4675
4785
|
}]);
|
|
4676
4786
|
|
|
4677
4787
|
if (nextAction === 'test') {
|
|
4678
|
-
const selectedOpenClawAgentId =
|
|
4679
|
-
|
|
4680
|
-
|
|
4788
|
+
const selectedOpenClawAgentId = selectionResult.agentId
|
|
4789
|
+
|| (isClaudePrimary
|
|
4790
|
+
? (finalYunyiLayoutResult.claudeAgentId || YYMAXAPI_OPENCLAW_MAIN_AGENT_ID)
|
|
4791
|
+
: (finalYunyiLayoutResult.gptAgentId || YYMAXAPI_OPENCLAW_GPT_AGENT_ID));
|
|
4681
4792
|
await testConnection(paths, { ...args, agent: selectedOpenClawAgentId });
|
|
4682
4793
|
} else {
|
|
4683
4794
|
console.log(chalk.cyan('👋 再见!\n'));
|
|
@@ -5617,7 +5728,7 @@ async function switchModel(paths) {
|
|
|
5617
5728
|
primary = finalSelected;
|
|
5618
5729
|
ensureGatewaySettings(config);
|
|
5619
5730
|
writeConfigWithSync(paths, config);
|
|
5620
|
-
if (selectedAgentId
|
|
5731
|
+
if (selectedAgentId && [YYMAXAPI_OPENCLAW_MAIN_AGENT_ID, YYMAXAPI_OPENCLAW_ALT_CLAUDE_AGENT_ID, YYMAXAPI_OPENCLAW_GPT_AGENT_ID].includes(selectedAgentId)) {
|
|
5621
5732
|
const resetResult = resetManagedAgentSessionsWithSync(paths, selectedAgentId);
|
|
5622
5733
|
if (resetResult.changed) {
|
|
5623
5734
|
console.log(chalk.gray(` 已重置 ${selectedAgentId} 的活动会话映射`));
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"models": {
|
|
26
26
|
"claude": [
|
|
27
27
|
{ "id": "claude-sonnet-4-6", "name": "Claude Sonnet 4.6" },
|
|
28
|
-
{ "id": "claude-opus-4-6", "name": "Claude Opus 4.6
|
|
28
|
+
{ "id": "claude-opus-4-6", "name": "Claude Opus 4.6" },
|
|
29
|
+
{ "id": "claude-opus-4-6-thinking", "name": "Claude Opus 4.6 Thinking" }
|
|
29
30
|
],
|
|
30
31
|
"codex": [
|
|
31
32
|
{ "id": "gpt-5.4", "name": "GPT 5.4" },
|
|
@@ -103,7 +104,7 @@ npx yymaxapi@latest
|
|
|
103
104
|
|
|
104
105
|
**注意事项:**
|
|
105
106
|
- `base_url` 不要加 `/v1`,平台会自动拼接路径
|
|
106
|
-
- Claude 可用模型:`claude-sonnet-4-6`、`claude-opus-4-6`
|
|
107
|
+
- Claude 可用模型:`claude-sonnet-4-6`、`claude-opus-4-6`、`claude-opus-4-6-thinking`
|
|
107
108
|
- GPT 可用模型:`gpt-5.4`
|
|
108
109
|
- 已验证环境:腾讯云 OpenCloudOS,OpenClaw `2026.2.3-1`
|
|
109
110
|
- 参考文档:https://cloud.tencent.com/developer/article/2624003
|