Refine desktop setup and remove bundled app center apps
This commit is contained in:
@@ -13,7 +13,18 @@ const SHOULD_BUNDLE = process.env.YINIAN_BUNDLE_MODEL_AUTH === '1';
|
||||
const SOURCE_AUTH_PROFILES = process.env.YINIAN_MODEL_AUTH_SOURCE
|
||||
? resolve(process.env.YINIAN_MODEL_AUTH_SOURCE)
|
||||
: join(homedir(), '.openclaw', 'agents', 'main', 'agent', 'auth-profiles.json');
|
||||
const PROFILE_IDS = ['minimax:default', 'minimax:cn'];
|
||||
const MODEL_PROVIDER_KEY = (process.env.YINIAN_MODEL_PROVIDER_KEY || 'yinian-model').trim();
|
||||
const MODEL_ID = (process.env.YINIAN_MODEL_ID || '').trim();
|
||||
const MODEL_NAME = (process.env.YINIAN_MODEL_NAME || MODEL_ID).trim();
|
||||
const MODEL_BASE_URL = (process.env.YINIAN_MODEL_BASE_URL || '').trim();
|
||||
const MODEL_API = (process.env.YINIAN_MODEL_API || 'openai-completions').trim();
|
||||
const MODEL_AUTH_PROFILE_ID = (process.env.YINIAN_MODEL_AUTH_PROFILE_ID || `${MODEL_PROVIDER_KEY}:default`).trim();
|
||||
const SOURCE_PROFILE_ID = (process.env.YINIAN_MODEL_AUTH_SOURCE_PROFILE_ID || '').trim();
|
||||
const MODEL_FALLBACKS = (process.env.YINIAN_MODEL_FALLBACKS || '')
|
||||
.split(',')
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean);
|
||||
const LEGACY_SOURCE_PROFILE_IDS = ['minimax:default', 'minimax:cn'];
|
||||
|
||||
function log(message) {
|
||||
console.log(`[yinian-model-auth] ${message}`);
|
||||
@@ -44,7 +55,7 @@ if (!SHOULD_BUNDLE) {
|
||||
bundled: false,
|
||||
reason: 'YINIAN_BUNDLE_MODEL_AUTH is not enabled',
|
||||
});
|
||||
log('pilot model auth bundling disabled.');
|
||||
log('pilot model auth bundling disabled. Customer pilot installers must use package:pilot or set YINIAN_BUNDLE_MODEL_AUTH=1.');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@@ -52,26 +63,54 @@ if (!existsSync(SOURCE_AUTH_PROFILES)) {
|
||||
fail(`source auth profiles not found: ${SOURCE_AUTH_PROFILES}`);
|
||||
}
|
||||
|
||||
if (!MODEL_PROVIDER_KEY) {
|
||||
fail('YINIAN_MODEL_PROVIDER_KEY is required for model auth bundling.');
|
||||
}
|
||||
|
||||
if (!MODEL_ID) {
|
||||
fail('YINIAN_MODEL_ID is required for model auth bundling.');
|
||||
}
|
||||
|
||||
if (!MODEL_BASE_URL) {
|
||||
fail('YINIAN_MODEL_BASE_URL is required for model auth bundling.');
|
||||
}
|
||||
|
||||
const source = readJson(SOURCE_AUTH_PROFILES);
|
||||
const sourceProfiles = source && typeof source === 'object' && source.profiles && typeof source.profiles === 'object'
|
||||
? source.profiles
|
||||
: {};
|
||||
const profiles = {};
|
||||
const sourceProfileIds = [
|
||||
SOURCE_PROFILE_ID,
|
||||
MODEL_AUTH_PROFILE_ID,
|
||||
`${MODEL_PROVIDER_KEY}:default`,
|
||||
...LEGACY_SOURCE_PROFILE_IDS,
|
||||
].filter(Boolean);
|
||||
const candidateProfileIds = Array.from(new Set([
|
||||
...sourceProfileIds,
|
||||
...Object.keys(sourceProfiles),
|
||||
]));
|
||||
let bundledKey = '';
|
||||
|
||||
for (const profileId of PROFILE_IDS) {
|
||||
for (const profileId of candidateProfileIds) {
|
||||
const profile = sourceProfiles[profileId];
|
||||
if (!profile || typeof profile !== 'object') continue;
|
||||
if (profile.type !== 'api_key' || profile.provider !== 'minimax') continue;
|
||||
if (profile.type !== 'api_key') continue;
|
||||
if (typeof profile.key !== 'string' || profile.key.trim().length < 8) continue;
|
||||
profiles[profileId] = {
|
||||
bundledKey = profile.key.trim();
|
||||
break;
|
||||
}
|
||||
|
||||
if (bundledKey) {
|
||||
profiles[MODEL_AUTH_PROFILE_ID] = {
|
||||
type: 'api_key',
|
||||
provider: 'minimax',
|
||||
key: profile.key,
|
||||
provider: MODEL_PROVIDER_KEY,
|
||||
key: bundledKey,
|
||||
};
|
||||
}
|
||||
|
||||
if (!profiles['minimax:default']) {
|
||||
fail('minimax:default API key profile is required for pilot model auth bundling.');
|
||||
if (!profiles[MODEL_AUTH_PROFILE_ID]) {
|
||||
fail(`API key profile is required for pilot model auth bundling. Set YINIAN_MODEL_AUTH_SOURCE_PROFILE_ID or create ${MODEL_AUTH_PROFILE_ID}.`);
|
||||
}
|
||||
|
||||
writeManifest({
|
||||
@@ -79,14 +118,23 @@ writeManifest({
|
||||
purpose: 'internal-pilot-only',
|
||||
source: 'local-openclaw-auth-profiles',
|
||||
profileIds: Object.keys(profiles),
|
||||
model: {
|
||||
providerKey: MODEL_PROVIDER_KEY,
|
||||
modelId: MODEL_ID,
|
||||
modelName: MODEL_NAME || MODEL_ID,
|
||||
baseUrl: MODEL_BASE_URL,
|
||||
api: MODEL_API,
|
||||
authProfileId: MODEL_AUTH_PROFILE_ID,
|
||||
fallbackModelRefs: MODEL_FALLBACKS,
|
||||
},
|
||||
store: {
|
||||
version: 1,
|
||||
profiles,
|
||||
order: {
|
||||
minimax: Object.keys(profiles),
|
||||
[MODEL_PROVIDER_KEY]: Object.keys(profiles),
|
||||
},
|
||||
lastGood: {
|
||||
minimax: 'minimax:default',
|
||||
[MODEL_PROVIDER_KEY]: MODEL_AUTH_PROFILE_ID,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user