feat: manually mirror opencoze's code from bytedance
Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
107
frontend/packages/arch/bot-env-adapter/src/base.ts
Normal file
107
frontend/packages/arch/bot-env-adapter/src/base.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getCurrentBranch } from './utils/current-branch';
|
||||
|
||||
const processEnvs = {
|
||||
BUILD_TYPE: (process.env.BUILD_TYPE || 'local') as
|
||||
| 'online'
|
||||
| 'offline'
|
||||
| 'test'
|
||||
| 'local',
|
||||
CUSTOM_VERSION: (process.env.CUSTOM_VERSION || 'inhouse') as
|
||||
| 'release'
|
||||
| 'inhouse',
|
||||
BUILD_BRANCH: (process.env.BUILD_BRANCH || getCurrentBranch()) as string,
|
||||
REGION: (process.env.REGION || 'cn') as 'cn' | 'sg' | 'va',
|
||||
NODE_ENV: process.env.NODE_ENV as 'production' | 'development' | 'test',
|
||||
CDN_PATH_PREFIX: (process.env.CDN_PATH_PREFIX ?? '/') as string,
|
||||
// vmok 生产者使用,用来将生产者的 sourcemap 文件上传至对应的消费者版本下面
|
||||
CONSUMER_BUILD_VERSION: (process.env.CONSUMER_BUILD_VERSION ?? '') as string,
|
||||
};
|
||||
|
||||
const IS_OVERSEA = Boolean(process.env.REGION) && process.env.REGION !== 'cn';
|
||||
const IS_CN_REGION = process.env.REGION === 'cn';
|
||||
const IS_VA_REGION = process.env.REGION === 'va';
|
||||
const IS_RELEASE_VERSION = processEnvs.CUSTOM_VERSION === 'release'; // 为 ture 表示对外版本
|
||||
const IS_OVERSEA_RELEASE = IS_OVERSEA && IS_RELEASE_VERSION;
|
||||
const IS_PROD =
|
||||
processEnvs.BUILD_TYPE === 'online' ||
|
||||
process.env.CUSTOM_BUILD_TYPE === 'online'; // 是否是线上
|
||||
const IS_BOE = processEnvs.BUILD_TYPE === 'offline';
|
||||
const IS_DEV_MODE = processEnvs.NODE_ENV === 'development'; // 本地开发
|
||||
const IS_BOT_OP = false; // 是否是 bot 运营平台,默认都是 false,从运营平台构建会设置成 true
|
||||
const IS_OPEN_SOURCE = (process.env.IS_OPEN_SOURCE ?? 'false') === 'true';
|
||||
|
||||
const judgements = {
|
||||
IS_OVERSEA,
|
||||
IS_CN_REGION,
|
||||
IS_VA_REGION,
|
||||
IS_BOE,
|
||||
IS_RELEASE_VERSION,
|
||||
IS_OVERSEA_RELEASE,
|
||||
IS_DEV_MODE,
|
||||
IS_PROD,
|
||||
IS_BOT_OP,
|
||||
IS_OPEN_SOURCE,
|
||||
};
|
||||
|
||||
const getInnerCDN = () =>
|
||||
process.env[`CDN_INNER_${processEnvs.REGION.toUpperCase()}`];
|
||||
|
||||
const getOuterCDN = () =>
|
||||
process.env[`CDN_OUTER_${processEnvs.REGION.toUpperCase()}`];
|
||||
|
||||
const getCDN = () => {
|
||||
if (IS_DEV_MODE) {
|
||||
if (IS_RELEASE_VERSION) {
|
||||
return '';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
if (IS_RELEASE_VERSION && processEnvs.BUILD_TYPE === 'online') {
|
||||
// 海外正式版使用独立业务线
|
||||
return getOuterCDN();
|
||||
} else {
|
||||
return getInnerCDN();
|
||||
}
|
||||
};
|
||||
|
||||
/** 对应CDN资源上传平台上的CDN地址 */
|
||||
const getUploadCDN = () => {
|
||||
const uploadCDNPrefixes = {
|
||||
UPLOAD_CDN_CN: '',
|
||||
UPLOAD_CDN_SG: '',
|
||||
UPLOAD_CDN_VA: '',
|
||||
};
|
||||
|
||||
const currentKey = `UPLOAD_CDN_${processEnvs.REGION.toUpperCase() as string}`;
|
||||
|
||||
return {
|
||||
UPLOAD_CDN: uploadCDNPrefixes[currentKey as keyof typeof uploadCDNPrefixes],
|
||||
...(IS_DEV_MODE ? uploadCDNPrefixes : {}),
|
||||
};
|
||||
};
|
||||
|
||||
export const base = {
|
||||
...processEnvs,
|
||||
...judgements,
|
||||
CDN: getCDN(),
|
||||
// release 环境下外部静态域名
|
||||
OUTER_CDN: getOuterCDN(),
|
||||
...getUploadCDN(),
|
||||
};
|
||||
673
frontend/packages/arch/bot-env-adapter/src/configs.ts
Normal file
673
frontend/packages/arch/bot-env-adapter/src/configs.ts
Normal file
@@ -0,0 +1,673 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable max-lines -- 待拆分 */
|
||||
|
||||
import { extractEnvValue } from './utils/config-helper';
|
||||
import { volcanoConfigs } from './configs/volcano';
|
||||
|
||||
const domainMap = {
|
||||
DOMAIN_RELEASE_CN: 'www.coze.cn',
|
||||
DOMAIN_RELEASE_OVERSEA: 'www.coze.com',
|
||||
};
|
||||
|
||||
const APP_ID = extractEnvValue<number>({
|
||||
cn: {
|
||||
boe: 0,
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
sg: {
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
va: {
|
||||
release: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const APP_KEY = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const FLOW_BRAND_NAME = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '豆包',
|
||||
inhouse: '豆包',
|
||||
release: '豆包',
|
||||
},
|
||||
sg: {
|
||||
inhouse: 'Cici',
|
||||
release: 'Cici',
|
||||
},
|
||||
va: {
|
||||
release: 'Cici',
|
||||
},
|
||||
});
|
||||
|
||||
const BOT_BRAND_NAME = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '扣子',
|
||||
inhouse: '扣子',
|
||||
release: '扣子',
|
||||
},
|
||||
sg: {
|
||||
inhouse: 'Coze',
|
||||
release: 'Coze',
|
||||
},
|
||||
va: {
|
||||
release: 'Coze',
|
||||
},
|
||||
});
|
||||
|
||||
const appMeta = {
|
||||
APP_ID,
|
||||
APP_KEY,
|
||||
FLOW_BRAND_NAME,
|
||||
BOT_BRAND_NAME,
|
||||
} as const;
|
||||
|
||||
const SEC_SDK_ASSERT_URL = extractEnvValue<string | null>({
|
||||
cn: {
|
||||
boe: null,
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
sg: {
|
||||
// 非 release 环境使用默认内网公用 SCM, tos 无上传权限,也无脱敏需要,直接使用风控提供的 tos 地址
|
||||
inhouse: '',
|
||||
// release 上传至独立 SCM CDN
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const FLOW_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '489823',
|
||||
release: '489823',
|
||||
},
|
||||
va: {
|
||||
release: '489823',
|
||||
},
|
||||
});
|
||||
|
||||
const FEISHU_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const LARK_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const REDDIT_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const JUEJIN_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const OBRIC_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const MYAI_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const DISCORD_PUBLISH_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const BYTE_UPLOADER_REGION = extractEnvValue<
|
||||
| 'cn-north-1'
|
||||
| 'us-east-1'
|
||||
| 'ap-singapore-1'
|
||||
| 'us-east-red'
|
||||
| 'boe'
|
||||
| 'boei18n'
|
||||
| 'US-TTP'
|
||||
| 'gcp'
|
||||
>({
|
||||
cn: {
|
||||
// TODO 确认下这里
|
||||
boe: 'boe',
|
||||
inhouse: 'cn-north-1',
|
||||
release: 'cn-north-1',
|
||||
},
|
||||
sg: {
|
||||
inhouse: 'ap-singapore-1',
|
||||
release: 'ap-singapore-1',
|
||||
},
|
||||
va: {
|
||||
release: 'us-east-1',
|
||||
},
|
||||
});
|
||||
|
||||
const IMAGE_FALLBACK_HOST = extractEnvValue<string>({
|
||||
cn: {
|
||||
// TODO 确认下这里
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const GOOGLE_CLIENT_ID = extractEnvValue<null | string>({
|
||||
cn: {
|
||||
boe: null,
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const GOOGLE_PLATFORM_ID = extractEnvValue<null | number>({
|
||||
cn: {
|
||||
boe: null,
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
sg: {
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
va: {
|
||||
release: 0,
|
||||
},
|
||||
});
|
||||
|
||||
// 曾经计划 facebook 登录 然后需求变动后没有了
|
||||
const FACEBOOK_APP_ID = extractEnvValue<null | string>({
|
||||
cn: {
|
||||
boe: null,
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const AWEME_PLATFORM_ID = extractEnvValue<number>({
|
||||
cn: {
|
||||
boe: 0,
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
sg: {
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
va: {
|
||||
release: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const AWEME_PLATFORM_APP_KEY = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const AWEME_ORIGIN = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const SAMI_APP_KEY = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const SAMI_WS_ORIGIN = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const COZE_API_TTS_BASE_URL = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const SAMI_CHAT_WS_URL = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const COZE_FEISHU_APP = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
export const COZE_LARK_APP = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const legalEnvs = {
|
||||
TERMS_OF_SERVICE:
|
||||
'https://www.coze.com/docs/guides/terms_of_service?_lang=en',
|
||||
PRIVATE_POLICY: 'https://www.coze.com/docs/guides/policy?_lang=en',
|
||||
CN_TERMS_OF_SERVICE: 'https://www.coze.cn/docs/guides/terms-of-service',
|
||||
CN_PRIVATE_POLICY: 'https://www.coze.cn/docs/guides/privacy',
|
||||
VOLC_TERMS_OF_SERVICE: 'https://www.volcengine.com/docs/6256/64903',
|
||||
VOLC_PRIVATE_POLICY: 'https://www.volcengine.com/docs/6256/64902',
|
||||
};
|
||||
|
||||
const MONACO_EDITOR_PUBLIC_PATH = '/';
|
||||
|
||||
const FEEL_GOOD_HOST = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: 'survey.coze.com',
|
||||
release: 'survey.coze.com',
|
||||
},
|
||||
va: {
|
||||
release: 'survey.coze.com',
|
||||
},
|
||||
});
|
||||
const feelGoodEnvs = {
|
||||
FEEL_GOOD_PID: '',
|
||||
FEEL_GOOD_HOST,
|
||||
} as const;
|
||||
|
||||
const CARD_BUILDER_ENV_STR = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: 'boe',
|
||||
inhouse: 'cn-inhouse',
|
||||
release: 'cn-release',
|
||||
},
|
||||
sg: {
|
||||
inhouse: 'sg-inhouse',
|
||||
release: 'sg-release',
|
||||
},
|
||||
va: {
|
||||
release: 'va-release',
|
||||
},
|
||||
});
|
||||
|
||||
const OPEN_WEB_SDK_BOT_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const OPEN_DOCS_APP_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const CUSTOM_PLAT_APPLY_PUBLIC_PLAT_FORM_LINK = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const OPEN_DOCS_LIB_ID = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const PLUGIN_IDE_EDITION = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: 'cn-internal-boe',
|
||||
inhouse: 'cn-internal-prod',
|
||||
release: 'cn-public-prod',
|
||||
},
|
||||
sg: {
|
||||
inhouse: 'sg-internal-prod',
|
||||
release: 'sg-public-prod',
|
||||
},
|
||||
va: {
|
||||
release: 'va-public-prod',
|
||||
},
|
||||
});
|
||||
const EMBEDDED_PAGE_URL = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
va: {
|
||||
release: '',
|
||||
},
|
||||
});
|
||||
|
||||
const SOCIAL_SCENE_FRONTIER_SERVICE_KEY = extractEnvValue<number>({
|
||||
cn: {
|
||||
boe: 0,
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
sg: {
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
va: {
|
||||
release: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const FORNAX_DOMAIN = extractEnvValue<string | null>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: null,
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
va: {
|
||||
release: null,
|
||||
},
|
||||
});
|
||||
|
||||
const COZE_DOMAIN = extractEnvValue<string | null>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: 'www.coze.cn',
|
||||
},
|
||||
sg: {
|
||||
inhouse: '',
|
||||
release: 'www.coze.com',
|
||||
},
|
||||
va: {
|
||||
release: 'www.coze.com',
|
||||
},
|
||||
});
|
||||
|
||||
export const configs = {
|
||||
...appMeta,
|
||||
...feelGoodEnvs,
|
||||
...legalEnvs,
|
||||
...domainMap,
|
||||
...volcanoConfigs,
|
||||
FLOW_PUBLISH_ID,
|
||||
FEISHU_PUBLISH_ID,
|
||||
LARK_PUBLISH_ID,
|
||||
REDDIT_PUBLISH_ID,
|
||||
JUEJIN_PUBLISH_ID,
|
||||
OBRIC_PUBLISH_ID,
|
||||
MYAI_PUBLISH_ID,
|
||||
DISCORD_PUBLISH_ID,
|
||||
SEC_SDK_ASSERT_URL,
|
||||
BYTE_UPLOADER_REGION,
|
||||
IMAGE_FALLBACK_HOST,
|
||||
GOOGLE_CLIENT_ID,
|
||||
GOOGLE_PLATFORM_ID,
|
||||
FACEBOOK_APP_ID,
|
||||
AWEME_ORIGIN,
|
||||
AWEME_PLATFORM_APP_KEY,
|
||||
AWEME_PLATFORM_ID,
|
||||
SAMI_APP_KEY,
|
||||
SAMI_WS_ORIGIN,
|
||||
SAMI_CHAT_WS_URL,
|
||||
CARD_BUILDER_ENV_STR,
|
||||
MONACO_EDITOR_PUBLIC_PATH,
|
||||
OPEN_WEB_SDK_BOT_ID,
|
||||
OPEN_DOCS_APP_ID,
|
||||
OPEN_DOCS_LIB_ID,
|
||||
COZE_FEISHU_APP,
|
||||
COZE_LARK_APP,
|
||||
PLUGIN_IDE_EDITION,
|
||||
EMBEDDED_PAGE_URL,
|
||||
SOCIAL_SCENE_FRONTIER_SERVICE_KEY,
|
||||
CUSTOM_PLAT_APPLY_PUBLIC_PLAT_FORM_LINK,
|
||||
COZE_API_TTS_BASE_URL,
|
||||
FORNAX_DOMAIN,
|
||||
COZE_DOMAIN,
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { extractEnvValue } from '../utils/config-helper';
|
||||
|
||||
const VOLCANO_PLATFORM_ID = extractEnvValue<number | null>({
|
||||
cn: {
|
||||
boe: 0,
|
||||
inhouse: 0,
|
||||
release: 0,
|
||||
},
|
||||
sg: {
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
va: {
|
||||
release: null,
|
||||
},
|
||||
});
|
||||
|
||||
const VOLCANO_PLATFORM_APP_KEY = extractEnvValue<string | null>({
|
||||
cn: {
|
||||
boe: '0',
|
||||
inhouse: '0',
|
||||
release: '0',
|
||||
},
|
||||
sg: {
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
va: {
|
||||
release: null,
|
||||
},
|
||||
});
|
||||
|
||||
const VOLCANO_IDENTITY_DOMAIN = extractEnvValue<string | null>({
|
||||
cn: {
|
||||
boe: '',
|
||||
inhouse: '',
|
||||
release: '',
|
||||
},
|
||||
sg: {
|
||||
inhouse: null,
|
||||
release: null,
|
||||
},
|
||||
va: {
|
||||
release: null,
|
||||
},
|
||||
});
|
||||
|
||||
export const volcanoConfigs = {
|
||||
VOLCANO_PLATFORM_ID,
|
||||
VOLCANO_PLATFORM_APP_KEY,
|
||||
VOLCANO_IDENTITY_DOMAIN,
|
||||
};
|
||||
74
frontend/packages/arch/bot-env-adapter/src/features.ts
Normal file
74
frontend/packages/arch/bot-env-adapter/src/features.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { base } from './base';
|
||||
const { IS_RELEASE_VERSION, IS_OVERSEA, IS_BOE } = base;
|
||||
export const features = {
|
||||
// 与志强&产品沟通后,下掉boe环境的sso
|
||||
FEATURE_ENABLE_SSO: !IS_RELEASE_VERSION && !IS_BOE,
|
||||
FEATURE_ENABLE_APP_GUIDE: !IS_RELEASE_VERSION || IS_OVERSEA,
|
||||
FEATURE_ENABLE_FEEDBACK_MAILTO: IS_RELEASE_VERSION,
|
||||
FEATURE_ENABLE_MSG_DEBUG: !IS_RELEASE_VERSION,
|
||||
FEATURE_ENABLE_TABLE_VARIABLE: IS_OVERSEA || !IS_RELEASE_VERSION,
|
||||
FEATURE_ENABLE_TABLE_MEMORY: true,
|
||||
// FEATURE_ENABLE_RUYI_CARD: false,
|
||||
FEATURE_ENABLE_VARIABLE: false,
|
||||
/**
|
||||
* 是否开启新的注销流程,目前只有cn开启
|
||||
*/
|
||||
FEATURE_ENABLE_NEW_DELETE_ACCOUNT: !IS_OVERSEA,
|
||||
FEATURE_AWEME_LOGIN: !IS_OVERSEA,
|
||||
FEATURE_GOOGLE_LOGIN: IS_OVERSEA,
|
||||
|
||||
/**
|
||||
* @description 只在boe环境和inhouse-cn环境支持 workflow code 节点编辑 python 代码
|
||||
*/
|
||||
FEATURE_ENABLE_CODE_PYTHON: !IS_OVERSEA && !IS_RELEASE_VERSION,
|
||||
|
||||
/**
|
||||
* 暂时隐藏banner,后续可能用于运营位置
|
||||
*/
|
||||
FEATURE_ENABLE_BANNER: false,
|
||||
|
||||
/**
|
||||
* Database tooltip示例区分图海外和国内
|
||||
*/
|
||||
FEATURE_ENABLE_DATABASE_TABLE: !IS_OVERSEA,
|
||||
|
||||
/**
|
||||
* bot市场中国区入口
|
||||
*/
|
||||
FEATURE_ENABLE_BOT_STORE: true,
|
||||
/**
|
||||
* workflow llm 计费只在海外或者 in-house 显示
|
||||
*/
|
||||
FEATURE_ENABLE_WORKFLOW_LLM_PAYMENT: IS_OVERSEA || !IS_RELEASE_VERSION,
|
||||
|
||||
/**
|
||||
* 豆包 cici 特殊需求,只在inhouse上线
|
||||
*/
|
||||
FEATURE_ENABLE_QUERY_ENTRY: !IS_RELEASE_VERSION,
|
||||
/**
|
||||
* coze接入审核增加,用于发布机审弹窗提前、版本历史Publish类审核结果展示。目前仅CN生效。
|
||||
*/
|
||||
FEATURE_ENABLE_TCS: !IS_OVERSEA,
|
||||
|
||||
/**
|
||||
* Tea 上报数据增加 UG 线索回传参数,仅 cn release 需要
|
||||
*
|
||||
*/
|
||||
FEATURE_ENABLE_TEA_UG: IS_RELEASE_VERSION && !IS_OVERSEA,
|
||||
};
|
||||
47
frontend/packages/arch/bot-env-adapter/src/index.ts
Normal file
47
frontend/packages/arch/bot-env-adapter/src/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { features } from './features';
|
||||
import { configs } from './configs';
|
||||
import { base } from './base';
|
||||
|
||||
const envs = {
|
||||
...base,
|
||||
...configs,
|
||||
...features,
|
||||
};
|
||||
|
||||
const COMMON_NULLABLE_VARS = ['CUSTOM_ENV_NAME', 'OUTER_CDN'];
|
||||
const NULLABLE_VARS =
|
||||
envs.BUILD_TYPE === 'local'
|
||||
? ['CDN', ...COMMON_NULLABLE_VARS]
|
||||
: [...COMMON_NULLABLE_VARS];
|
||||
|
||||
if (process.env.VERBOSE === 'true') {
|
||||
console.info(JSON.stringify(envs, null, 2));
|
||||
}
|
||||
const emptyVars = Object.entries({
|
||||
...base,
|
||||
...features,
|
||||
}).filter(
|
||||
([key, value]) => value === undefined && !NULLABLE_VARS.includes(key),
|
||||
);
|
||||
|
||||
if (emptyVars.length) {
|
||||
throw Error(`以下环境变量值为空:${emptyVars.join('、')}`);
|
||||
}
|
||||
|
||||
export { envs as GLOBAL_ENVS };
|
||||
23
frontend/packages/arch/bot-env-adapter/src/runtime/index.ts
Normal file
23
frontend/packages/arch/bot-env-adapter/src/runtime/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class Env {
|
||||
get isPPE() {
|
||||
return IS_PROD;
|
||||
}
|
||||
}
|
||||
|
||||
export const runtimeEnv = new Env();
|
||||
111
frontend/packages/arch/bot-env-adapter/src/typings.d.ts
vendored
Normal file
111
frontend/packages/arch/bot-env-adapter/src/typings.d.ts
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// 基于src/index.ts自动生成,请勿手动修改
|
||||
declare const APP_ID: number;
|
||||
declare const APP_KEY: string;
|
||||
declare const AWEME_ORIGIN: string;
|
||||
declare const AWEME_PLATFORM_APP_KEY: string;
|
||||
declare const AWEME_PLATFORM_ID: number;
|
||||
declare const BOT_BRAND_NAME: string;
|
||||
declare const BUILD_BRANCH: string;
|
||||
declare const BUILD_TYPE: 'local' | 'online' | 'offline' | 'test';
|
||||
declare const BYTE_UPLOADER_REGION: 'cn-north-1' | 'us-east-1' | 'ap-singapore-1' | 'us-east-red' | 'boe' | 'boei18n' | 'US-TTP' | 'gcp';
|
||||
declare const CARD_BUILDER_ENV_STR: string;
|
||||
declare const CDN: string | undefined;
|
||||
declare const CDN_PATH_PREFIX: string;
|
||||
declare const CN_PRIVATE_POLICY: string;
|
||||
declare const CN_TERMS_OF_SERVICE: string;
|
||||
declare const CONSUMER_BUILD_VERSION: string;
|
||||
declare const COZE_API_TTS_BASE_URL: string;
|
||||
declare const COZE_DOMAIN: string | null;
|
||||
declare const COZE_FEISHU_APP: string;
|
||||
declare const COZE_LARK_APP: string;
|
||||
declare const CUSTOM_PLAT_APPLY_PUBLIC_PLAT_FORM_LINK: string;
|
||||
declare const CUSTOM_VERSION: 'inhouse' | 'release';
|
||||
declare const DISCORD_PUBLISH_ID: string;
|
||||
declare const DOMAIN_RELEASE_CN: string;
|
||||
declare const DOMAIN_RELEASE_OVERSEA: string;
|
||||
declare const EMBEDDED_PAGE_URL: string;
|
||||
declare const FACEBOOK_APP_ID: string | null;
|
||||
declare const FEATURE_AWEME_LOGIN: boolean;
|
||||
declare const FEATURE_ENABLE_APP_GUIDE: boolean;
|
||||
declare const FEATURE_ENABLE_BANNER: boolean;
|
||||
declare const FEATURE_ENABLE_BOT_STORE: boolean;
|
||||
declare const FEATURE_ENABLE_CODE_PYTHON: boolean;
|
||||
declare const FEATURE_ENABLE_DATABASE_TABLE: boolean;
|
||||
declare const FEATURE_ENABLE_FEEDBACK_MAILTO: boolean;
|
||||
declare const FEATURE_ENABLE_MSG_DEBUG: boolean;
|
||||
declare const FEATURE_ENABLE_NEW_DELETE_ACCOUNT: boolean;
|
||||
declare const FEATURE_ENABLE_QUERY_ENTRY: boolean;
|
||||
declare const FEATURE_ENABLE_SSO: boolean;
|
||||
declare const FEATURE_ENABLE_TABLE_MEMORY: boolean;
|
||||
declare const FEATURE_ENABLE_TABLE_VARIABLE: boolean;
|
||||
declare const FEATURE_ENABLE_TCS: boolean;
|
||||
declare const FEATURE_ENABLE_TEA_UG: boolean;
|
||||
declare const FEATURE_ENABLE_VARIABLE: boolean;
|
||||
declare const FEATURE_ENABLE_WORKFLOW_LLM_PAYMENT: boolean;
|
||||
declare const FEATURE_GOOGLE_LOGIN: boolean;
|
||||
declare const FEEL_GOOD_HOST: string;
|
||||
declare const FEEL_GOOD_PID: '';
|
||||
declare const FEISHU_PUBLISH_ID: string;
|
||||
declare const FLOW_BRAND_NAME: string;
|
||||
declare const FLOW_PUBLISH_ID: string;
|
||||
declare const FORNAX_DOMAIN: string | null;
|
||||
declare const GOOGLE_CLIENT_ID: string | null;
|
||||
declare const GOOGLE_PLATFORM_ID: number | null;
|
||||
declare const IMAGE_FALLBACK_HOST: string;
|
||||
declare const IS_BOE: boolean;
|
||||
declare const IS_BOT_OP: boolean;
|
||||
declare const IS_CN_REGION: boolean;
|
||||
declare const IS_DEV_MODE: boolean;
|
||||
declare const IS_OPEN_SOURCE: boolean;
|
||||
declare const IS_OVERSEA: boolean;
|
||||
declare const IS_OVERSEA_RELEASE: boolean;
|
||||
declare const IS_PROD: boolean;
|
||||
declare const IS_RELEASE_VERSION: boolean;
|
||||
declare const IS_VA_REGION: boolean;
|
||||
declare const JUEJIN_PUBLISH_ID: string;
|
||||
declare const LARK_PUBLISH_ID: string;
|
||||
declare const MONACO_EDITOR_PUBLIC_PATH: string;
|
||||
declare const MYAI_PUBLISH_ID: string;
|
||||
declare const NODE_ENV: 'test' | 'production' | 'development';
|
||||
declare const OBRIC_PUBLISH_ID: string;
|
||||
declare const OPEN_DOCS_APP_ID: string;
|
||||
declare const OPEN_DOCS_LIB_ID: string;
|
||||
declare const OPEN_WEB_SDK_BOT_ID: string;
|
||||
declare const OUTER_CDN: string | undefined;
|
||||
declare const PLUGIN_IDE_EDITION: string;
|
||||
declare const PRIVATE_POLICY: string;
|
||||
declare const REDDIT_PUBLISH_ID: string;
|
||||
declare const REGION: 'cn' | 'sg' | 'va';
|
||||
declare const SAMI_APP_KEY: string;
|
||||
declare const SAMI_CHAT_WS_URL: string;
|
||||
declare const SAMI_WS_ORIGIN: string;
|
||||
declare const SEC_SDK_ASSERT_URL: string | null;
|
||||
declare const SOCIAL_SCENE_FRONTIER_SERVICE_KEY: number;
|
||||
declare const TERMS_OF_SERVICE: string;
|
||||
declare const UPLOAD_CDN: string;
|
||||
declare const UPLOAD_CDN_CN: string;
|
||||
declare const UPLOAD_CDN_SG: string;
|
||||
declare const UPLOAD_CDN_VA: string;
|
||||
declare const VOLCANO_IDENTITY_DOMAIN: string | null;
|
||||
declare const VOLCANO_PLATFORM_APP_KEY: string | null;
|
||||
declare const VOLCANO_PLATFORM_ID: number | null;
|
||||
declare const VOLC_PRIVATE_POLICY: string;
|
||||
declare const VOLC_TERMS_OF_SERVICE: string;
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
/* tslint:disable */
|
||||
// @ts-nocheck
|
||||
import { base } from '../base';
|
||||
|
||||
const { REGION, IS_RELEASE_VERSION, IS_BOE } = base;
|
||||
|
||||
type TValue = string | number | boolean | null;
|
||||
|
||||
export interface TConfigEnv<TVal extends TValue = TValue> {
|
||||
cn: {
|
||||
boe: TVal;
|
||||
inhouse: TVal;
|
||||
release: TVal;
|
||||
};
|
||||
sg: {
|
||||
inhouse: TVal;
|
||||
release: TVal;
|
||||
};
|
||||
va: {
|
||||
release: TVal;
|
||||
};
|
||||
}
|
||||
|
||||
export const extractEnvValue = <TConfigValue extends TValue = TValue>(
|
||||
config: TConfigEnv<TConfigValue>,
|
||||
): TConfigValue => {
|
||||
let key: string;
|
||||
switch (REGION) {
|
||||
case 'cn': {
|
||||
key = IS_BOE ? 'boe' : IS_RELEASE_VERSION ? 'release' : 'inhouse';
|
||||
break;
|
||||
}
|
||||
case 'sg': {
|
||||
key = IS_RELEASE_VERSION ? 'release' : 'inhouse';
|
||||
break;
|
||||
}
|
||||
case 'va': {
|
||||
key = 'release';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return config[REGION][key] as TConfigValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* template
|
||||
const NAME = extractEnvValue<string>({
|
||||
cn: {
|
||||
boe: ,
|
||||
inhouse: ,
|
||||
},
|
||||
sg: {
|
||||
inhouse: ,
|
||||
release: ,
|
||||
},
|
||||
va: {
|
||||
release: ,
|
||||
},
|
||||
});
|
||||
*/
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
/**
|
||||
* 获取当前 git 分支名称
|
||||
* @returns 当前分支名称,如果不在 git 仓库中或发生错误则返回 undefined
|
||||
*/
|
||||
export function getCurrentBranch(): string | undefined {
|
||||
try {
|
||||
// 使用 git rev-parse 获取当前分支名
|
||||
// --abbrev-ref 参数返回分支名而不是 commit hash
|
||||
// HEAD 表示当前位置
|
||||
const branch = execSync('git rev-parse --abbrev-ref HEAD', {
|
||||
encoding: 'utf-8',
|
||||
}).trim();
|
||||
|
||||
// 如果在 detached HEAD 状态,返回 undefined
|
||||
if (branch === 'HEAD') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return branch;
|
||||
} catch (error) {
|
||||
// 如果执行出错(比如不在 git 仓库中),返回 undefined
|
||||
return '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user