@cloudbase/cli 2.8.24 → 2.8.26
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/.env.local +1 -1
- package/dist/standalone/cli.js +86 -44
- package/lib/utils/ai/config.js +3 -0
- package/lib/utils/ai/const.js +2 -1
- package/lib/utils/ai/env.js +13 -6
- package/lib/utils/ai/router.js +10 -10
- package/lib/utils/ai/setup.js +40 -4
- package/package.json +5 -3
- package/types/utils/ai/const.d.ts +6 -0
- package/types/utils/ai/env.d.ts +1 -1
package/.env.local
CHANGED
package/dist/standalone/cli.js
CHANGED
|
@@ -19429,6 +19429,9 @@ class AIConfigManager {
|
|
|
19429
19429
|
if (config.apiKey) {
|
|
19430
19430
|
yield this.updateConfig('ai.agents.claude.apiKey', config.apiKey, 'AI_CLAUDE_API_KEY');
|
|
19431
19431
|
}
|
|
19432
|
+
if (config.model) {
|
|
19433
|
+
yield this.updateConfig('ai.agents.claude.model', config.model, 'ANTHROPIC_MODEL');
|
|
19434
|
+
}
|
|
19432
19435
|
}
|
|
19433
19436
|
else if (type === 'cloudbase') {
|
|
19434
19437
|
if (config.provider) {
|
|
@@ -19573,7 +19576,8 @@ exports.CLAUDE = {
|
|
|
19573
19576
|
v3_1.default.object({
|
|
19574
19577
|
type: v3_1.default.literal('custom'),
|
|
19575
19578
|
baseUrl: v3_1.default.string(),
|
|
19576
|
-
apiKey: v3_1.default.string()
|
|
19579
|
+
apiKey: v3_1.default.string(),
|
|
19580
|
+
model: v3_1.default.string()
|
|
19577
19581
|
}),
|
|
19578
19582
|
v3_1.default.object({
|
|
19579
19583
|
type: v3_1.default.literal('cloudbase'),
|
|
@@ -19758,18 +19762,25 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
19758
19762
|
exports.ensureValidEnv = void 0;
|
|
19759
19763
|
const env_1 = __webpack_require__(90337);
|
|
19760
19764
|
const constants_1 = __webpack_require__(34409);
|
|
19761
|
-
|
|
19765
|
+
const utils_1 = __webpack_require__(75213);
|
|
19766
|
+
const config_1 = __webpack_require__(96614);
|
|
19767
|
+
function ensureValidEnv(_envId, log) {
|
|
19762
19768
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19763
19769
|
const envs = yield (0, env_1.listEnvs)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
19764
|
-
const validEnv = envs.find((env) => env.EnvId ===
|
|
19770
|
+
const validEnv = envs.find((env) => env.EnvId === _envId);
|
|
19765
19771
|
if (!validEnv) {
|
|
19766
|
-
log.error(`❌ 环境 ${
|
|
19767
|
-
|
|
19772
|
+
log.error(`❌ 环境 ${_envId} 与当前账号不匹配,请重新选择`);
|
|
19773
|
+
const envId = yield (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
19774
|
+
new config_1.AIConfigManager().updateEnvId(envId);
|
|
19775
|
+
return envId;
|
|
19768
19776
|
}
|
|
19769
19777
|
if (validEnv.Status !== constants_1.EnvStatus.NORMAL) {
|
|
19770
|
-
log.error(`❌ 环境 ${
|
|
19771
|
-
|
|
19778
|
+
log.error(`❌ 环境 ${_envId} 不可用,请重新选择`);
|
|
19779
|
+
const envId = yield (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
19780
|
+
new config_1.AIConfigManager().updateEnvId(envId);
|
|
19781
|
+
return envId;
|
|
19772
19782
|
}
|
|
19783
|
+
return _envId;
|
|
19773
19784
|
});
|
|
19774
19785
|
}
|
|
19775
19786
|
exports.ensureValidEnv = ensureValidEnv;
|
|
@@ -20442,11 +20453,11 @@ class AICommandRouter {
|
|
|
20442
20453
|
}
|
|
20443
20454
|
});
|
|
20444
20455
|
}
|
|
20445
|
-
executeClaudeAgent({ apiKey, baseUrl }, additionalArgs, log) {
|
|
20456
|
+
executeClaudeAgent({ apiKey, baseUrl, model }, additionalArgs, log) {
|
|
20446
20457
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20447
20458
|
(0, nodeVersion_1.ensureNodeVersion)('v18.0.0', log);
|
|
20448
20459
|
yield this.ensureClaudeCode(log);
|
|
20449
|
-
yield this.executeCommand('claude', additionalArgs, Object.assign(Object.assign({}, process.env), { ANTHROPIC_AUTH_TOKEN: apiKey, ANTHROPIC_BASE_URL: baseUrl }), log);
|
|
20460
|
+
yield this.executeCommand('claude', additionalArgs, Object.assign(Object.assign({}, process.env), { ANTHROPIC_AUTH_TOKEN: apiKey, ANTHROPIC_BASE_URL: baseUrl, ANTHROPIC_MODEL: model }), log);
|
|
20450
20461
|
});
|
|
20451
20462
|
}
|
|
20452
20463
|
executeNoneClaudeAgent(additionalArgs, log) {
|
|
@@ -20472,10 +20483,10 @@ class AICommandRouter {
|
|
|
20472
20483
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20473
20484
|
(0, nodeVersion_1.ensureNodeVersion)('v20.0.0', log);
|
|
20474
20485
|
yield this.ensureQwenCode(log);
|
|
20475
|
-
const
|
|
20486
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
20476
20487
|
yield (0, auth_1.checkLogin)();
|
|
20477
20488
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
20478
|
-
yield (0, env_1.ensureValidEnv)(
|
|
20489
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
20479
20490
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
20480
20491
|
envId,
|
|
20481
20492
|
secretId: credential.secretId,
|
|
@@ -20552,10 +20563,10 @@ class AICommandRouter {
|
|
|
20552
20563
|
configureClaudeCodeRouter(provider, model, transformer, log) {
|
|
20553
20564
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20554
20565
|
const fs = yield Promise.resolve().then(() => __importStar(__webpack_require__(21605)));
|
|
20555
|
-
const
|
|
20566
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
20556
20567
|
yield (0, auth_1.checkLogin)();
|
|
20557
20568
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
20558
|
-
yield (0, env_1.ensureValidEnv)(
|
|
20569
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
20559
20570
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
20560
20571
|
envId,
|
|
20561
20572
|
secretId: credential.secretId,
|
|
@@ -20771,10 +20782,10 @@ class AICommandRouter {
|
|
|
20771
20782
|
executeCodexCloudbaseAgent({ provider, model }, additionalArgs, log) {
|
|
20772
20783
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20773
20784
|
yield this.ensureCodexCode(log);
|
|
20774
|
-
const
|
|
20785
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
20775
20786
|
yield (0, auth_1.checkLogin)();
|
|
20776
20787
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
20777
|
-
yield (0, env_1.ensureValidEnv)(
|
|
20788
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
20778
20789
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
20779
20790
|
envId,
|
|
20780
20791
|
secretId: credential.secretId,
|
|
@@ -20871,10 +20882,10 @@ class AICommandRouter {
|
|
|
20871
20882
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20872
20883
|
yield this.ensureAider(log);
|
|
20873
20884
|
const { provider, model } = config;
|
|
20874
|
-
const
|
|
20885
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
20875
20886
|
yield (0, auth_1.checkLogin)();
|
|
20876
20887
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
20877
|
-
yield (0, env_1.ensureValidEnv)(
|
|
20888
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
20878
20889
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
20879
20890
|
envId,
|
|
20880
20891
|
secretId: credential.secretId,
|
|
@@ -21367,7 +21378,10 @@ class AISetupWizard {
|
|
|
21367
21378
|
message: `选择配置方式: ${const_1.LIST_HINT}`,
|
|
21368
21379
|
choices: [
|
|
21369
21380
|
{ name: '使用 CloudBase 服务,一键登录,无需配置', value: 'cloudbase' },
|
|
21370
|
-
{
|
|
21381
|
+
{
|
|
21382
|
+
name: '自配置 API KEY 和 Base URL,需要支持 Anthropic 协议的大模型',
|
|
21383
|
+
value: 'custom'
|
|
21384
|
+
},
|
|
21371
21385
|
{ name: '暂不配置,使用 Claude Code 内置鉴权方式(如 OAuth)', value: 'none' }
|
|
21372
21386
|
],
|
|
21373
21387
|
default: 'cloudbase'
|
|
@@ -21418,15 +21432,41 @@ class AISetupWizard {
|
|
|
21418
21432
|
else {
|
|
21419
21433
|
baseUrl = baseUrlChoice;
|
|
21420
21434
|
}
|
|
21421
|
-
const {
|
|
21435
|
+
const { apiKey } = yield inquirer_1.default.prompt([
|
|
21422
21436
|
{
|
|
21423
21437
|
type: 'password',
|
|
21424
|
-
name: '
|
|
21438
|
+
name: 'apiKey',
|
|
21425
21439
|
message: 'Claude Auth Token:',
|
|
21426
21440
|
validate: (input) => input.length > 0 || '请输入有效的 Auth Token'
|
|
21427
21441
|
}
|
|
21428
21442
|
]);
|
|
21429
|
-
|
|
21443
|
+
let defaultModel;
|
|
21444
|
+
if (baseUrl === 'https://api.anthropic.com') {
|
|
21445
|
+
defaultModel = 'sonnet';
|
|
21446
|
+
}
|
|
21447
|
+
else if (baseUrl === 'https://api.moonshot.cn/anthropic') {
|
|
21448
|
+
defaultModel = 'kimi-k2-turbo-preview';
|
|
21449
|
+
}
|
|
21450
|
+
else if (baseUrl === 'https://open.bigmodel.cn/api/anthropic') {
|
|
21451
|
+
defaultModel = 'glm-4.5';
|
|
21452
|
+
}
|
|
21453
|
+
else {
|
|
21454
|
+
defaultModel = '';
|
|
21455
|
+
}
|
|
21456
|
+
const { model } = yield inquirer_1.default.prompt([
|
|
21457
|
+
{
|
|
21458
|
+
type: 'input',
|
|
21459
|
+
name: 'model',
|
|
21460
|
+
message: '模型名称:',
|
|
21461
|
+
default: defaultModel,
|
|
21462
|
+
validate: (input) => input.trim().length > 0 || '请输入有效的模型名称'
|
|
21463
|
+
}
|
|
21464
|
+
]);
|
|
21465
|
+
yield this.aiConfigManager.updateClaudeConfig('custom', {
|
|
21466
|
+
baseUrl,
|
|
21467
|
+
apiKey,
|
|
21468
|
+
model
|
|
21469
|
+
});
|
|
21430
21470
|
}
|
|
21431
21471
|
else {
|
|
21432
21472
|
yield this.aiConfigManager.updateClaudeConfig('none', {});
|
|
@@ -23773,26 +23813,27 @@ class BeaconAction {
|
|
|
23773
23813
|
report(eventCode, eventData = {}) {
|
|
23774
23814
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23775
23815
|
const now = Date.now();
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
|
|
23780
|
-
|
|
23781
|
-
|
|
23782
|
-
|
|
23783
|
-
|
|
23784
|
-
|
|
23785
|
-
|
|
23786
|
-
|
|
23787
|
-
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23792
|
-
|
|
23793
|
-
|
|
23794
|
-
|
|
23795
|
-
}
|
|
23816
|
+
return (0, net_1.postFetch)('https://otheve.beacon.qq.com/analytics/v2_upload', {
|
|
23817
|
+
appVersion: '',
|
|
23818
|
+
sdkId: 'js',
|
|
23819
|
+
sdkVersion: '4.5.14-web',
|
|
23820
|
+
mainAppKey: '0WEB0AD0GM4PUUU1',
|
|
23821
|
+
platformId: 3,
|
|
23822
|
+
common: {
|
|
23823
|
+
A2: this.deviceId,
|
|
23824
|
+
A101: this.userAgent,
|
|
23825
|
+
from: 'tcb-cli',
|
|
23826
|
+
xDeployEnv: "production"
|
|
23827
|
+
},
|
|
23828
|
+
events: [
|
|
23829
|
+
{
|
|
23830
|
+
eventCode,
|
|
23831
|
+
eventTime: String(now),
|
|
23832
|
+
mapValue: Object.assign(Object.assign({}, eventData), this.additionalParams)
|
|
23833
|
+
}
|
|
23834
|
+
]
|
|
23835
|
+
}).catch((e) => {
|
|
23836
|
+
});
|
|
23796
23837
|
});
|
|
23797
23838
|
}
|
|
23798
23839
|
addAdditionalParams(params) {
|
|
@@ -193444,7 +193485,7 @@ function resolveCredential(data) {
|
|
|
193444
193485
|
}
|
|
193445
193486
|
exports.resolveCredential = resolveCredential;
|
|
193446
193487
|
function resolveWebCredential(credential) {
|
|
193447
|
-
const { secretId, secretKey, token, accessTokenExpired, expired, authTime, refreshToken, uin, hash } = credential;
|
|
193488
|
+
const { secretId, secretKey, token, accessTokenExpired, expired, authTime, refreshToken, uin, hash, envId } = credential;
|
|
193448
193489
|
const webCredential = {
|
|
193449
193490
|
tmpSecretId: secretId,
|
|
193450
193491
|
tmpSecretKey: secretKey,
|
|
@@ -193454,7 +193495,8 @@ function resolveWebCredential(credential) {
|
|
|
193454
193495
|
authTime,
|
|
193455
193496
|
refreshToken,
|
|
193456
193497
|
uin,
|
|
193457
|
-
hash
|
|
193498
|
+
hash,
|
|
193499
|
+
envId
|
|
193458
193500
|
};
|
|
193459
193501
|
return webCredential;
|
|
193460
193502
|
}
|
|
@@ -617799,7 +617841,7 @@ module.exports = {"version":"3.13.1"};
|
|
|
617799
617841
|
/***/ ((module) => {
|
|
617800
617842
|
|
|
617801
617843
|
"use strict";
|
|
617802
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.8.
|
|
617844
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@cloudbase/cli","version":"2.8.25","description":"cli tool for cloudbase","main":"lib/index.js","scripts":{"build":"rimraf lib types && tsc --resolveJsonModule && cpx \\"src/**/*.html\\" lib","watch":"rimraf lib types && tsc -w","dev":"rimraf lib types && cpx \\"src/**/*.html\\" lib && tsc -w","eslint":"eslint \\"./**/*.ts\\"","test":"node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000","tsc":"tsc","pkg":"pkg ./bin/cloudbase.js --out-path ./pkg","postinstall":"node ./post-install.js || exit 0 && patch-package","prepublishOnly":"npm run build","debug":"bin/tcb.js lowcode watch","build:bundle":"webpack --config build/webpack/cli.cjs && webpack --config build/webpack/ccr.cjs","package:darwin-arm64":"OS=darwin ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:darwin-x64":"OS=darwin ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-arm64":"OS=linux ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:linux-x64":"OS=linux ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:all":"bash build/scripts/build-all.sh","node:fetch:one":"node -e \\"require(\'child_process\').execSync(\'bash build/scripts/fetch-node.sh\',{stdio:\'inherit\'})\\"","node:fetch:all":"NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh --all","node:fetch:win-x64":"OS=windows ARCH=x64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","node:fetch:win-arm64":"OS=windows ARCH=arm64 NODE_VERSION=22.18.0 bash build/scripts/fetch-node.sh","package:windows-x64":"OS=windows ARCH=x64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-arm64":"OS=windows ARCH=arm64 VERSION= node -e \\"require(\'child_process\').execSync(\'bash build/scripts/package.sh\',{stdio:\'inherit\'})\\"","package:windows-all":"npm run -s node:fetch:win-x64 && npm run -s node:fetch:win-arm64 && npm run -s package:windows-x64 && npm run -s package:windows-arm64","out:prune":"bash build/scripts/prune-out.sh"},"repository":{"type":"git","url":"https://github.com/TencentCloudBase/cloud-base-cli.git"},"bin":{"cloudbase":"bin/cloudbase.js","cloudbase-mcp":"bin/cloudbase-mcp.cjs","tcb":"bin/tcb.js","ccr":"bin/ccr.js"},"husky":{"hooks":{"pre-commit":"npm run build"}},"author":"cwuyiqing@gmail.com","license":"ISC","dependencies":{"@cloudbase/cloud-api":"^0.5.5","@cloudbase/cloudbase-mcp":"^1.8.35","@cloudbase/framework-core":"^1.9.7","@cloudbase/functions-framework":"1.16.0","@cloudbase/iac-core":"0.0.3-alpha.11","@cloudbase/lowcode-cli":"^0.22.2","@cloudbase/manager-node":"4.4.4","@cloudbase/toolbox":"^0.7.8","@dotenvx/dotenvx":"^1.48.3","@musistudio/claude-code-router":"1.0.36","address":"^1.1.2","camelcase-keys":"^7.0.2","chalk":"^2.4.2","cli-table3":"^0.5.1","commander":"7","del":"^5.1.0","didyoumean":"^1.2.2","enquirer":"^2.3.6","execa":"^4.0.3","figlet":"^1.7.0","fs-extra":"^8.1.0","gradient-string":"^2.0.2","https-proxy-agent":"^5.0.1","inquirer":"^6.5.0","json-schema-to-typescript":"^14.0.5","lodash":"^4.17.21","log-symbols":"^3.0.0","lowdb":"^1.0.0","make-dir":"^3.0.0","node-fetch":"^2.6.0","nodemon":"^3.1.4","open":"^7.0.0","ora":"^4.0.2","patch-package":"^8.0.0","portfinder":"^1.0.28","progress":"^2.0.3","query-string":"^6.8.1","reflect-metadata":"^0.1.13","semver":"^7.3.7","tar-fs":"^2.0.1","terminal-link":"^2.1.1","toml":"^3.0.0","unzipper":"^0.10.10","update-notifier":"^4.0.0","xdg-basedir":"^4.0.0","yargs":"^16.2.0","yargs-parser":"^21.0.1","zod":"^4.0.13"},"devDependencies":{"@types/fs-extra":"^11.0.4","@types/jest":"^27","@types/koa__router":"^8.0.11","@types/lodash":"^4.14.182","@types/node":"^12.12.38","@types/node-fetch":"^2.5.4","@types/react":"^17.0.37","@types/semver":"^7.3.9","@types/unzipper":"^0.10.11","@types/webpack-dev-server":"^3.11.1","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","cpx":"^1.5.0","eslint":"^7.14.0","eslint-config-alloy":"^3.8.2","husky":"^3.0.9","jest":"^27","rimraf":"^3.0.2","ts-jest":"^27","typescript":"^4.7.2","webpack":"^5.92.0","webpack-cli":"^5.1.4"},"packageManager":"yarn@3.6.2+sha512.2c2f8b9615e6659773f65cdec7cf92ef773a98a99e611579601f61c7a91ec94c89c929aac86f1cee819421a9b0db7acfd53ec3ebb95af44f77f77634b08b9557"}');
|
|
617803
617845
|
|
|
617804
617846
|
/***/ })
|
|
617805
617847
|
|
package/lib/utils/ai/config.js
CHANGED
|
@@ -156,6 +156,9 @@ class AIConfigManager {
|
|
|
156
156
|
if (config.apiKey) {
|
|
157
157
|
yield this.updateConfig('ai.agents.claude.apiKey', config.apiKey, 'AI_CLAUDE_API_KEY');
|
|
158
158
|
}
|
|
159
|
+
if (config.model) {
|
|
160
|
+
yield this.updateConfig('ai.agents.claude.model', config.model, 'ANTHROPIC_MODEL');
|
|
161
|
+
}
|
|
159
162
|
}
|
|
160
163
|
else if (type === 'cloudbase') {
|
|
161
164
|
if (config.provider) {
|
package/lib/utils/ai/const.js
CHANGED
|
@@ -26,7 +26,8 @@ exports.CLAUDE = {
|
|
|
26
26
|
v3_1.default.object({
|
|
27
27
|
type: v3_1.default.literal('custom'),
|
|
28
28
|
baseUrl: v3_1.default.string(),
|
|
29
|
-
apiKey: v3_1.default.string()
|
|
29
|
+
apiKey: v3_1.default.string(),
|
|
30
|
+
model: v3_1.default.string()
|
|
30
31
|
}),
|
|
31
32
|
v3_1.default.object({
|
|
32
33
|
type: v3_1.default.literal('cloudbase'),
|
package/lib/utils/ai/env.js
CHANGED
|
@@ -12,18 +12,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ensureValidEnv = void 0;
|
|
13
13
|
const env_1 = require("../../env");
|
|
14
14
|
const constants_1 = require("../../commands/constants");
|
|
15
|
-
|
|
15
|
+
const utils_1 = require("../../commands/utils");
|
|
16
|
+
const config_1 = require("./config");
|
|
17
|
+
function ensureValidEnv(_envId, log) {
|
|
16
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
19
|
const envs = yield (0, env_1.listEnvs)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
18
|
-
const validEnv = envs.find((env) => env.EnvId ===
|
|
20
|
+
const validEnv = envs.find((env) => env.EnvId === _envId);
|
|
19
21
|
if (!validEnv) {
|
|
20
|
-
log.error(`❌ 环境 ${
|
|
21
|
-
|
|
22
|
+
log.error(`❌ 环境 ${_envId} 与当前账号不匹配,请重新选择`);
|
|
23
|
+
const envId = yield (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
24
|
+
new config_1.AIConfigManager().updateEnvId(envId);
|
|
25
|
+
return envId;
|
|
22
26
|
}
|
|
23
27
|
if (validEnv.Status !== constants_1.EnvStatus.NORMAL) {
|
|
24
|
-
log.error(`❌ 环境 ${
|
|
25
|
-
|
|
28
|
+
log.error(`❌ 环境 ${_envId} 不可用,请重新选择`);
|
|
29
|
+
const envId = yield (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
30
|
+
new config_1.AIConfigManager().updateEnvId(envId);
|
|
31
|
+
return envId;
|
|
26
32
|
}
|
|
33
|
+
return _envId;
|
|
27
34
|
});
|
|
28
35
|
}
|
|
29
36
|
exports.ensureValidEnv = ensureValidEnv;
|
package/lib/utils/ai/router.js
CHANGED
|
@@ -484,11 +484,11 @@ class AICommandRouter {
|
|
|
484
484
|
}
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
executeClaudeAgent({ apiKey, baseUrl }, additionalArgs, log) {
|
|
487
|
+
executeClaudeAgent({ apiKey, baseUrl, model }, additionalArgs, log) {
|
|
488
488
|
return __awaiter(this, void 0, void 0, function* () {
|
|
489
489
|
(0, nodeVersion_1.ensureNodeVersion)('v18.0.0', log);
|
|
490
490
|
yield this.ensureClaudeCode(log);
|
|
491
|
-
yield this.executeCommand('claude', additionalArgs, Object.assign(Object.assign({}, process.env), { ANTHROPIC_AUTH_TOKEN: apiKey, ANTHROPIC_BASE_URL: baseUrl }), log);
|
|
491
|
+
yield this.executeCommand('claude', additionalArgs, Object.assign(Object.assign({}, process.env), { ANTHROPIC_AUTH_TOKEN: apiKey, ANTHROPIC_BASE_URL: baseUrl, ANTHROPIC_MODEL: model }), log);
|
|
492
492
|
});
|
|
493
493
|
}
|
|
494
494
|
executeNoneClaudeAgent(additionalArgs, log) {
|
|
@@ -514,10 +514,10 @@ class AICommandRouter {
|
|
|
514
514
|
return __awaiter(this, void 0, void 0, function* () {
|
|
515
515
|
(0, nodeVersion_1.ensureNodeVersion)('v20.0.0', log);
|
|
516
516
|
yield this.ensureQwenCode(log);
|
|
517
|
-
const
|
|
517
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
518
518
|
yield (0, auth_1.checkLogin)();
|
|
519
519
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
520
|
-
yield (0, env_1.ensureValidEnv)(
|
|
520
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
521
521
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
522
522
|
envId,
|
|
523
523
|
secretId: credential.secretId,
|
|
@@ -594,10 +594,10 @@ class AICommandRouter {
|
|
|
594
594
|
configureClaudeCodeRouter(provider, model, transformer, log) {
|
|
595
595
|
return __awaiter(this, void 0, void 0, function* () {
|
|
596
596
|
const fs = yield Promise.resolve().then(() => __importStar(require('fs-extra')));
|
|
597
|
-
const
|
|
597
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
598
598
|
yield (0, auth_1.checkLogin)();
|
|
599
599
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
600
|
-
yield (0, env_1.ensureValidEnv)(
|
|
600
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
601
601
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
602
602
|
envId,
|
|
603
603
|
secretId: credential.secretId,
|
|
@@ -813,10 +813,10 @@ class AICommandRouter {
|
|
|
813
813
|
executeCodexCloudbaseAgent({ provider, model }, additionalArgs, log) {
|
|
814
814
|
return __awaiter(this, void 0, void 0, function* () {
|
|
815
815
|
yield this.ensureCodexCode(log);
|
|
816
|
-
const
|
|
816
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
817
817
|
yield (0, auth_1.checkLogin)();
|
|
818
818
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
819
|
-
yield (0, env_1.ensureValidEnv)(
|
|
819
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
820
820
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
821
821
|
envId,
|
|
822
822
|
secretId: credential.secretId,
|
|
@@ -913,10 +913,10 @@ class AICommandRouter {
|
|
|
913
913
|
return __awaiter(this, void 0, void 0, function* () {
|
|
914
914
|
yield this.ensureAider(log);
|
|
915
915
|
const { provider, model } = config;
|
|
916
|
-
const
|
|
916
|
+
const _envId = yield (0, config_1.createConfigParser)().get('envId');
|
|
917
917
|
yield (0, auth_1.checkLogin)();
|
|
918
918
|
const credential = yield (0, utils_1.getCredential)({}, {});
|
|
919
|
-
yield (0, env_1.ensureValidEnv)(
|
|
919
|
+
const envId = yield (0, env_1.ensureValidEnv)(_envId, log);
|
|
920
920
|
const accessToken = yield (0, utils_1.rawFetchAccessToken)({
|
|
921
921
|
envId,
|
|
922
922
|
secretId: credential.secretId,
|
package/lib/utils/ai/setup.js
CHANGED
|
@@ -231,7 +231,10 @@ class AISetupWizard {
|
|
|
231
231
|
message: `选择配置方式: ${const_1.LIST_HINT}`,
|
|
232
232
|
choices: [
|
|
233
233
|
{ name: '使用 CloudBase 服务,一键登录,无需配置', value: 'cloudbase' },
|
|
234
|
-
{
|
|
234
|
+
{
|
|
235
|
+
name: '自配置 API KEY 和 Base URL,需要支持 Anthropic 协议的大模型',
|
|
236
|
+
value: 'custom'
|
|
237
|
+
},
|
|
235
238
|
{ name: '暂不配置,使用 Claude Code 内置鉴权方式(如 OAuth)', value: 'none' }
|
|
236
239
|
],
|
|
237
240
|
default: 'cloudbase'
|
|
@@ -262,6 +265,10 @@ class AISetupWizard {
|
|
|
262
265
|
name: 'Anthropic - https://api.anthropic.com',
|
|
263
266
|
value: 'https://api.anthropic.com'
|
|
264
267
|
},
|
|
268
|
+
{
|
|
269
|
+
name: 'DeepSeek - https://api.deepseek.com/anthropic',
|
|
270
|
+
value: 'https://api.deepseek.com/anthropic'
|
|
271
|
+
},
|
|
265
272
|
{ name: '🛠️ 自定义 URL', value: 'custom' }
|
|
266
273
|
],
|
|
267
274
|
default: 'https://api.moonshot.cn/anthropic'
|
|
@@ -282,15 +289,44 @@ class AISetupWizard {
|
|
|
282
289
|
else {
|
|
283
290
|
baseUrl = baseUrlChoice;
|
|
284
291
|
}
|
|
285
|
-
const {
|
|
292
|
+
const { apiKey } = yield inquirer_1.default.prompt([
|
|
286
293
|
{
|
|
287
294
|
type: 'password',
|
|
288
|
-
name: '
|
|
295
|
+
name: 'apiKey',
|
|
289
296
|
message: 'Claude Auth Token:',
|
|
290
297
|
validate: (input) => input.length > 0 || '请输入有效的 Auth Token'
|
|
291
298
|
}
|
|
292
299
|
]);
|
|
293
|
-
|
|
300
|
+
let defaultModel;
|
|
301
|
+
if (baseUrl === 'https://api.anthropic.com') {
|
|
302
|
+
defaultModel = 'sonnet';
|
|
303
|
+
}
|
|
304
|
+
else if (baseUrl === 'https://api.moonshot.cn/anthropic') {
|
|
305
|
+
defaultModel = 'kimi-k2-turbo-preview';
|
|
306
|
+
}
|
|
307
|
+
else if (baseUrl === 'https://open.bigmodel.cn/api/anthropic') {
|
|
308
|
+
defaultModel = 'glm-4.5';
|
|
309
|
+
}
|
|
310
|
+
else if (baseUrl === 'https://api.deepseek.com/anthropic') {
|
|
311
|
+
defaultModel = 'deepseek-chat';
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
defaultModel = '';
|
|
315
|
+
}
|
|
316
|
+
const { model } = yield inquirer_1.default.prompt([
|
|
317
|
+
{
|
|
318
|
+
type: 'input',
|
|
319
|
+
name: 'model',
|
|
320
|
+
message: '模型名称:',
|
|
321
|
+
default: defaultModel,
|
|
322
|
+
validate: (input) => input.trim().length > 0 || '请输入有效的模型名称'
|
|
323
|
+
}
|
|
324
|
+
]);
|
|
325
|
+
yield this.aiConfigManager.updateClaudeConfig('custom', {
|
|
326
|
+
baseUrl,
|
|
327
|
+
apiKey,
|
|
328
|
+
model
|
|
329
|
+
});
|
|
294
330
|
}
|
|
295
331
|
else {
|
|
296
332
|
yield this.aiConfigManager.updateClaudeConfig('none', {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.26",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"license": "ISC",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@cloudbase/cloud-api": "^0.5.5",
|
|
51
|
-
"@cloudbase/cloudbase-mcp": "^1.8.
|
|
51
|
+
"@cloudbase/cloudbase-mcp": "^1.8.37",
|
|
52
52
|
"@cloudbase/framework-core": "^1.9.7",
|
|
53
53
|
"@cloudbase/functions-framework": "1.16.0",
|
|
54
54
|
"@cloudbase/iac-core": "0.0.3-alpha.11",
|
|
55
55
|
"@cloudbase/lowcode-cli": "^0.22.2",
|
|
56
56
|
"@cloudbase/manager-node": "4.4.4",
|
|
57
|
-
"@cloudbase/toolbox": "^0.7.
|
|
57
|
+
"@cloudbase/toolbox": "^0.7.9",
|
|
58
58
|
"@dotenvx/dotenvx": "^1.48.3",
|
|
59
59
|
"@musistudio/claude-code-router": "1.0.36",
|
|
60
60
|
"address": "^1.1.2",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"fs-extra": "^8.1.0",
|
|
71
71
|
"gradient-string": "^2.0.2",
|
|
72
72
|
"https-proxy-agent": "^5.0.1",
|
|
73
|
+
"i": "^0.3.7",
|
|
73
74
|
"inquirer": "^6.5.0",
|
|
74
75
|
"json-schema-to-typescript": "^14.0.5",
|
|
75
76
|
"lodash": "^4.17.21",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
"make-dir": "^3.0.0",
|
|
79
80
|
"node-fetch": "^2.6.0",
|
|
80
81
|
"nodemon": "^3.1.4",
|
|
82
|
+
"npm": "^11.5.2",
|
|
81
83
|
"open": "^7.0.0",
|
|
82
84
|
"ora": "^4.0.2",
|
|
83
85
|
"patch-package": "^8.0.0",
|
|
@@ -19,13 +19,16 @@ export declare const CLAUDE: {
|
|
|
19
19
|
type: z.ZodLiteral<"custom">;
|
|
20
20
|
baseUrl: z.ZodString;
|
|
21
21
|
apiKey: z.ZodString;
|
|
22
|
+
model: z.ZodString;
|
|
22
23
|
}, "strip", z.ZodTypeAny, {
|
|
23
24
|
type?: "custom";
|
|
24
25
|
apiKey?: string;
|
|
26
|
+
model?: string;
|
|
25
27
|
baseUrl?: string;
|
|
26
28
|
}, {
|
|
27
29
|
type?: "custom";
|
|
28
30
|
apiKey?: string;
|
|
31
|
+
model?: string;
|
|
29
32
|
baseUrl?: string;
|
|
30
33
|
}>, z.ZodObject<{
|
|
31
34
|
type: z.ZodLiteral<"cloudbase">;
|
|
@@ -180,13 +183,16 @@ export declare const AGENTS: readonly [{
|
|
|
180
183
|
type: z.ZodLiteral<"custom">;
|
|
181
184
|
baseUrl: z.ZodString;
|
|
182
185
|
apiKey: z.ZodString;
|
|
186
|
+
model: z.ZodString;
|
|
183
187
|
}, "strip", z.ZodTypeAny, {
|
|
184
188
|
type?: "custom";
|
|
185
189
|
apiKey?: string;
|
|
190
|
+
model?: string;
|
|
186
191
|
baseUrl?: string;
|
|
187
192
|
}, {
|
|
188
193
|
type?: "custom";
|
|
189
194
|
apiKey?: string;
|
|
195
|
+
model?: string;
|
|
190
196
|
baseUrl?: string;
|
|
191
197
|
}>, z.ZodObject<{
|
|
192
198
|
type: z.ZodLiteral<"cloudbase">;
|
package/types/utils/ai/env.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Logger } from '../log';
|
|
2
|
-
export declare function ensureValidEnv(
|
|
2
|
+
export declare function ensureValidEnv(_envId: string, log: Logger): Promise<string>;
|