@cloudbase/cloudbase-mcp 2.34.6 → 2.34.8
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/README.md +1 -1
- package/dist/cli.cjs +5 -5
- package/dist/index.cjs +1809 -102
- package/dist/index.js +1823 -104
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -199407,6 +199407,7 @@ exports.getLoginState = getLoginState;
|
|
|
199407
199407
|
exports.logout = logout;
|
|
199408
199408
|
const toolbox_1 = __webpack_require__(23233);
|
|
199409
199409
|
const logger_js_1 = __webpack_require__(40781);
|
|
199410
|
+
const project_config_js_1 = __webpack_require__(39175);
|
|
199410
199411
|
const site_map_js_1 = __webpack_require__(34533);
|
|
199411
199412
|
const auth = toolbox_1.AuthSupervisor.getInstance({});
|
|
199412
199413
|
const authProgressState = {
|
|
@@ -199811,8 +199812,7 @@ async function peekLoginState(options) {
|
|
|
199811
199812
|
if ('_type' in envVarLoginState && envVarLoginState._type === 'api_key') {
|
|
199812
199813
|
(0, logger_js_1.debug)("peekLoginState: detected CLOUDBASE_API_KEY env var");
|
|
199813
199814
|
try {
|
|
199814
|
-
|
|
199815
|
-
const projectCwd = process.env.WORKSPACE_FOLDER_PATHS || process.cwd();
|
|
199815
|
+
const projectCwd = (0, project_config_js_1.requireProjectRoot)();
|
|
199816
199816
|
// 换取网关按站点选型:显式 intl → ap-singapore;domestic/歧义 → toolbox 默认
|
|
199817
199817
|
// ap-shanghai(国内站多地域环境均经其全局路由,详见 resolveApiKeyExchangeRegion)
|
|
199818
199818
|
const exchangeRegion = (0, site_map_js_1.resolveApiKeyExchangeRegion)({
|
|
@@ -199969,7 +199969,7 @@ async function logout(options) {
|
|
|
199969
199969
|
await toolbox_1.authStore.set("credential", slotted);
|
|
199970
199970
|
}
|
|
199971
199971
|
else if (site === LEGACY_SITE) {
|
|
199972
|
-
const cwd =
|
|
199972
|
+
const cwd = (0, project_config_js_1.requireProjectRoot)();
|
|
199973
199973
|
await auth.logout({ cwd });
|
|
199974
199974
|
}
|
|
199975
199975
|
resetAuthProgressState();
|
|
@@ -200009,6 +200009,7 @@ const logger_js_1 = __webpack_require__(40781);
|
|
|
200009
200009
|
const tool_result_js_1 = __webpack_require__(69645);
|
|
200010
200010
|
const site_map_js_1 = __webpack_require__(34533);
|
|
200011
200011
|
const project_config_js_1 = __webpack_require__(39175);
|
|
200012
|
+
const local_endpoint_js_1 = __webpack_require__(16156);
|
|
200012
200013
|
// Timeout for envId auto-resolution flow.
|
|
200013
200014
|
// 10 minutes (600 seconds) - matches InteractiveServer timeout
|
|
200014
200015
|
const ENV_ID_TIMEOUT = 600000;
|
|
@@ -200170,7 +200171,7 @@ async function listAvailableEnvCandidates(options) {
|
|
|
200170
200171
|
}
|
|
200171
200172
|
// When CLOUDBASE_ENV_ID is set and credentials are not explicit, skip DescribeEnvs.
|
|
200172
200173
|
const hasExplicitCredentials = !!(cloudBaseOptions?.secretId && cloudBaseOptions?.secretKey);
|
|
200173
|
-
if (process.env.CLOUDBASE_ENV_ID && !hasExplicitCredentials) {
|
|
200174
|
+
if (process.env.CLOUDBASE_ENV_ID && !hasExplicitCredentials && !cloudBaseOptions?.requestFn && !process.env.CLOUDBASE_LOCAL_ENDPOINT) {
|
|
200174
200175
|
return [{
|
|
200175
200176
|
envId: process.env.CLOUDBASE_ENV_ID,
|
|
200176
200177
|
}];
|
|
@@ -200181,7 +200182,7 @@ async function listAvailableEnvCandidates(options) {
|
|
|
200181
200182
|
...(regionOverride ? { region: regionOverride } : {}),
|
|
200182
200183
|
}).region;
|
|
200183
200184
|
let cloudbase;
|
|
200184
|
-
if (cloudBaseOptions?.secretId && cloudBaseOptions?.secretKey) {
|
|
200185
|
+
if (cloudBaseOptions?.requestFn || (cloudBaseOptions?.secretId && cloudBaseOptions?.secretKey)) {
|
|
200185
200186
|
cloudbase = createCloudBaseManagerWithOptions({
|
|
200186
200187
|
...cloudBaseOptions,
|
|
200187
200188
|
region,
|
|
@@ -200364,6 +200365,14 @@ class EnvironmentManager {
|
|
|
200364
200365
|
this._setCachedEnvId(loginState.envId);
|
|
200365
200366
|
return loginState.envId;
|
|
200366
200367
|
}
|
|
200368
|
+
// 3.1 未登录必须交回 AUTH_REQUIRED,不能继续往下走「选环境」。
|
|
200369
|
+
// 未登录时拿不到任何环境候选,落到 throwEnvRequiredError 会输出
|
|
200370
|
+
// 「当前已登录,但还没有可用环境」——把「没登录」误诊成「登录了但缺环境」。
|
|
200371
|
+
// 调用方读到这句会去 set_env 选环境,而候选列表永远为空,只能原样重试。
|
|
200372
|
+
// 与 getCloudBaseManager 的登录态分流保持同构。
|
|
200373
|
+
if (!loginState) {
|
|
200374
|
+
throwAuthRequiredError();
|
|
200375
|
+
}
|
|
200367
200376
|
// 4. 单环境自动绑定;多环境时返回结构化引导,不再触发交互弹窗
|
|
200368
200377
|
const envCandidates = await listAvailableEnvCandidates({ loginState });
|
|
200369
200378
|
if (envCandidates.length === 1) {
|
|
@@ -200412,11 +200421,13 @@ const envManager = new EnvironmentManager();
|
|
|
200412
200421
|
exports.envManager = envManager;
|
|
200413
200422
|
// 导出环境ID获取函数
|
|
200414
200423
|
async function getEnvId(cloudBaseOptions) {
|
|
200415
|
-
// 如果传入了 cloudBaseOptions 且包含 envId,直接返回
|
|
200416
200424
|
if (cloudBaseOptions?.envId) {
|
|
200417
200425
|
(0, logger_js_1.debug)('使用传入的 envId:', { envId: cloudBaseOptions.envId });
|
|
200418
200426
|
return cloudBaseOptions.envId;
|
|
200419
200427
|
}
|
|
200428
|
+
if ((0, local_endpoint_js_1.resolveLocalEndpoint)()) {
|
|
200429
|
+
return 'local';
|
|
200430
|
+
}
|
|
200420
200431
|
const cachedEnvId = envManager.getCachedEnvId() || process.env.CLOUDBASE_ENV_ID;
|
|
200421
200432
|
if (cachedEnvId) {
|
|
200422
200433
|
(0, logger_js_1.debug)('使用缓存中的 envId:', { envId: cachedEnvId });
|
|
@@ -200521,7 +200532,16 @@ async function getDatabaseInstanceId(options) {
|
|
|
200521
200532
|
* 每次都实时获取最新的 token/secretId/secretKey
|
|
200522
200533
|
*/
|
|
200523
200534
|
async function getCloudBaseManager(options = {}) {
|
|
200524
|
-
const { requireEnvId = true,
|
|
200535
|
+
const { requireEnvId = true, authStrategy = 'fail_fast', } = options;
|
|
200536
|
+
let cloudBaseOptions = options.cloudBaseOptions;
|
|
200537
|
+
const localEndpoint = (0, local_endpoint_js_1.resolveLocalEndpoint)();
|
|
200538
|
+
if (localEndpoint && !cloudBaseOptions?.requestFn) {
|
|
200539
|
+
cloudBaseOptions = {
|
|
200540
|
+
...cloudBaseOptions,
|
|
200541
|
+
envId: cloudBaseOptions?.envId || 'local',
|
|
200542
|
+
requestFn: (0, local_endpoint_js_1.createLocalCloudApiRequestFn)(localEndpoint),
|
|
200543
|
+
};
|
|
200544
|
+
}
|
|
200525
200545
|
const hasDirectCredentials = !!(cloudBaseOptions?.secretId && cloudBaseOptions?.secretKey);
|
|
200526
200546
|
const hasRequestFn = !!(cloudBaseOptions?.requestFn);
|
|
200527
200547
|
// 如果传入了完整凭据或 requestFn,优先使用显式 CloudBase 配置
|
|
@@ -201626,6 +201646,7 @@ const msgPush_js_1 = __webpack_require__(26191);
|
|
|
201626
201646
|
const setup_js_1 = __webpack_require__(8707);
|
|
201627
201647
|
const envSetup_js_1 = __webpack_require__(57148);
|
|
201628
201648
|
const interactive_js_1 = __webpack_require__(91838);
|
|
201649
|
+
const feedback_js_1 = __webpack_require__(99391);
|
|
201629
201650
|
exports.en = {
|
|
201630
201651
|
env: env_js_1.env.en,
|
|
201631
201652
|
storage: storage_js_1.storage.en,
|
|
@@ -201655,6 +201676,7 @@ exports.en = {
|
|
|
201655
201676
|
setup: setup_js_1.setup.en,
|
|
201656
201677
|
envSetup: envSetup_js_1.envSetup.en,
|
|
201657
201678
|
interactive: interactive_js_1.interactive.en,
|
|
201679
|
+
feedback: feedback_js_1.feedback.en,
|
|
201658
201680
|
};
|
|
201659
201681
|
|
|
201660
201682
|
|
|
@@ -201797,7 +201819,7 @@ const types_js_1 = __webpack_require__(89921);
|
|
|
201797
201819
|
exports.apps = (0, types_js_1.defineModule)({
|
|
201798
201820
|
queryTitle: "查询 CloudBase 应用部署状态",
|
|
201799
201821
|
queryDescription: "查询 CloudBase 应用部署的应用和版本。可查应用列表/详情、版本列表/详情;部署后用 getAppVersion 按 buildId 轮询构建状态;getBuildLog 可查询构建日志用于诊断失败原因。\n" +
|
|
201800
|
-
"action=getUploadUrl(只读)可获取预签名上传 URL:无本地文件系统时(cloud mode),先拿到 uploadUrl 自行 PUT 代码 zip,再用返回的 unixTimestamp 调 manageApps(action=deployApp, cosTimestamp) 触发部署。",
|
|
201822
|
+
"action=getUploadUrl(只读)可获取预签名上传 URL:无本地文件系统时(cloud mode),先拿到 uploadUrl 自行 PUT 代码 zip,再用返回的 unixTimestamp 调 manageApps(action=deployApp, cosTimestamp) 触发部署。uploadUrl 是一次性上传凭据,不要外传或写进工单。",
|
|
201801
201823
|
manageTitle: "部署应用到 CloudBase(独立子域名)",
|
|
201802
201824
|
manageDescription: "部署 Web 应用到 CloudBase(构建前后端,部署到独立子域名)。\n" +
|
|
201803
201825
|
"云端上传通道(cloud mode,无本地文件系统):queryApps(action=getUploadUrl) 或 manageApps(action=getUploadUrl) 获取预签名上传 URL → agent 自行 PUT 代码 zip 到 uploadUrl(带 uploadHeaders 与 Content-Type: application/zip)→ 用返回的 unixTimestamp 作为 cosTimestamp 调 deployApp 触发部署。\n" +
|
|
@@ -201830,7 +201852,7 @@ exports.apps = (0, types_js_1.defineModule)({
|
|
|
201830
201852
|
uploadStep1: "1. 将代码打包为 zip(排除 node_modules/.git)",
|
|
201831
201853
|
uploadStep2: "2. 用 PUT 方法把 zip 上传到 uploadUrl,请求头带 Content-Type: application/zip 以及 uploadHeaders 中的每个 header",
|
|
201832
201854
|
uploadStep3: "3. 调用 manageApps(action=\"deployApp\", serviceName=\"{serviceName}\", cosTimestamp=<unixTimestamp>) 触发部署",
|
|
201833
|
-
getUploadUrlSuccess: "预签名上传 URL 获取成功。请将代码 zip PUT 上传到 uploadUrl(携带 uploadHeaders 与 Content-Type: application/zip),然后用返回的 unixTimestamp 作为 cosTimestamp 调用 manageApps(action=deployApp) 触发部署。",
|
|
201855
|
+
getUploadUrlSuccess: "预签名上传 URL 获取成功。请将代码 zip PUT 上传到 uploadUrl(携带 uploadHeaders 与 Content-Type: application/zip),然后用返回的 unixTimestamp 作为 cosTimestamp 调用 manageApps(action=deployApp) 触发部署。uploadUrl 是一次性上传凭据,不要外传或写进工单。",
|
|
201834
201856
|
getSuccess: "CloudBase 应用详情查询成功",
|
|
201835
201857
|
listVersionsSuccess: "CloudBase 应用版本列表查询成功",
|
|
201836
201858
|
buildIdRequired: "action=getBuildLog 时必须提供 buildId",
|
|
@@ -201893,7 +201915,7 @@ exports.apps = (0, types_js_1.defineModule)({
|
|
|
201893
201915
|
}, {
|
|
201894
201916
|
queryTitle: "Query CloudBase app deployment status",
|
|
201895
201917
|
queryDescription: "Query CloudBase deployed apps and versions. Supports app list/detail and version list/detail; after deployment, poll build status by buildId with getAppVersion; getBuildLog retrieves build logs to diagnose failures.\n" +
|
|
201896
|
-
"action=getUploadUrl (read-only) returns a pre-signed upload URL: without a local filesystem (cloud mode), fetch the uploadUrl, PUT the code zip yourself, then call manageApps(action=deployApp, cosTimestamp) with the returned unixTimestamp to trigger deployment.",
|
|
201918
|
+
"action=getUploadUrl (read-only) returns a pre-signed upload URL: without a local filesystem (cloud mode), fetch the uploadUrl, PUT the code zip yourself, then call manageApps(action=deployApp, cosTimestamp) with the returned unixTimestamp to trigger deployment. The uploadUrl is a one-time upload credential; do not forward it or paste it into tickets.",
|
|
201897
201919
|
manageTitle: "Deploy app to CloudBase (dedicated subdomain)",
|
|
201898
201920
|
manageDescription: "Deploy web apps to CloudBase (builds frontend and backend, deploys to a dedicated subdomain).\n" +
|
|
201899
201921
|
"Cloud upload channel (cloud mode, no local filesystem): queryApps(action=getUploadUrl) or manageApps(action=getUploadUrl) returns a pre-signed upload URL → agent PUTs the code zip to uploadUrl itself (with uploadHeaders and Content-Type: application/zip) → call deployApp with the returned unixTimestamp as cosTimestamp to trigger deployment.\n" +
|
|
@@ -201926,7 +201948,7 @@ exports.apps = (0, types_js_1.defineModule)({
|
|
|
201926
201948
|
uploadStep1: "1. Pack the code into a zip (exclude node_modules/.git)",
|
|
201927
201949
|
uploadStep2: "2. PUT the zip to uploadUrl with header Content-Type: application/zip and every header from uploadHeaders",
|
|
201928
201950
|
uploadStep3: "3. Call manageApps(action=\"deployApp\", serviceName=\"{serviceName}\", cosTimestamp=<unixTimestamp>) to trigger deployment",
|
|
201929
|
-
getUploadUrlSuccess: "Pre-signed upload URL obtained. PUT the code zip to uploadUrl (with uploadHeaders and Content-Type: application/zip), then call manageApps(action=deployApp) with the returned unixTimestamp as cosTimestamp to trigger deployment.",
|
|
201951
|
+
getUploadUrlSuccess: "Pre-signed upload URL obtained. PUT the code zip to uploadUrl (with uploadHeaders and Content-Type: application/zip), then call manageApps(action=deployApp) with the returned unixTimestamp as cosTimestamp to trigger deployment. The uploadUrl is a one-time upload credential; do not forward it or paste it into tickets.",
|
|
201930
201952
|
getSuccess: "CloudBase app details retrieved successfully",
|
|
201931
201953
|
listVersionsSuccess: "CloudBase app version list retrieved successfully",
|
|
201932
201954
|
buildIdRequired: "buildId is required when action=getBuildLog",
|
|
@@ -202008,7 +202030,7 @@ exports.capi = (0, types_js_1.defineModule)({
|
|
|
202008
202030
|
docGuidanceCloudbase: "优先查阅 CloudBase API 概览 {controlPlaneUrl} 与云开发依赖资源接口指引 {dependencyUrl}。",
|
|
202009
202031
|
docGuidanceMonitor: "请优先核对云监控(腾讯云可观测平台)官方 API 文档:API 概览 https://cloud.tencent.com/document/product/649/30343 ,单 Action 详细文档在 https://cloud.tencent.com/document/api/248/ 产品线下。",
|
|
202010
202032
|
docGuidanceGeneric: "请优先核对对应官方云 API 文档;若你的场景其实是通过 HTTP 协议直接集成 auth/functions/cloudrun/storage/mysqldb 等 CloudBase 业务 API,请优先使用 OpenAPI / Swagger 或 searchKnowledgeBase(mode=\"openapi\"),不要继续猜测管控面 Action。",
|
|
202011
|
-
camAuthGuidance: "
|
|
202033
|
+
camAuthGuidance: "这是 CAM 权限不足。先分清是谁缺权限,再决定怎么补:用 auth(action=\"status\") 看 credential_scope,用 callCloudApi(service=\"sts\", action=\"GetCallerIdentity\") 看实际调用者(Type=CAMRole 表示角色扮演身份,UserId 里带角色名)。若缺权限的是角色(如 TCB_QcsRole),补的是挂在**角色**上的策略 —— 给用户一条 cam/role/grant 一键授权链接,拼法与 principal 取值见 skill cloud-api-operations 的 §3.2;若是账号级身份本人,则由主账号给这个身份追加策略(用腾讯云 SecretId/SecretKey 登录时,调用者就是该身份)。环境级 API Key 只能访问绑定环境的数据面,跨产品调用需改用账号级凭据:auth(action=\"start_auth\", authMode=\"device\")。另请确认目标资源确实属于当前账号。",
|
|
202012
202034
|
errorInvalidAction: "Action `{action}` 可能不存在或不对外开放。请不要继续猜测 Action 名称,先确认 service=`{service}` 下该 Action 在当前 API 版本是否真实存在。",
|
|
202013
202035
|
errorSuggestedActions: "可能的 tcb Action:{candidates}。",
|
|
202014
202036
|
errorRegionParam: "Region 不是 Action body 参数。请使用 callCloudApi 顶层参数 region(例如 region=\"ap-singapore\"),对应 X-TC-Region。",
|
|
@@ -202042,7 +202064,7 @@ exports.capi = (0, types_js_1.defineModule)({
|
|
|
202042
202064
|
docGuidanceCloudbase: "Prefer the CloudBase API overview {controlPlaneUrl} and the dependent-resource API guide {dependencyUrl}.",
|
|
202043
202065
|
docGuidanceMonitor: "Check the official Cloud Monitor (Tencent Cloud Observability Platform) API docs first: API overview https://cloud.tencent.com/document/product/649/30343 , per-Action docs live under https://cloud.tencent.com/document/api/248/ .",
|
|
202044
202066
|
docGuidanceGeneric: "Check the corresponding official cloud API docs first; if your scenario is actually integrating CloudBase business APIs such as auth/functions/cloudrun/storage/mysqldb over HTTP, prefer OpenAPI / Swagger or searchKnowledgeBase(mode=\"openapi\") instead of guessing control-plane Actions.",
|
|
202045
|
-
camAuthGuidance: "This is
|
|
202067
|
+
camAuthGuidance: "This is a CAM permission gap. Work out who is missing it before choosing a fix: auth(action=\"status\") shows credential_scope, and callCloudApi(service=\"sts\", action=\"GetCallerIdentity\") shows the actual caller (Type=CAMRole means an assumed role; the UserId carries the role name). When the role is the one missing permission (e.g. TCB_QcsRole), the fix is a policy attached to that role — give the user a cam/role/grant authorization link, built as described in the cloud-api-operations skill, section 3.2. When an account-level identity is the caller, the main account attaches the policy to it (signing in with a Tencent Cloud SecretId/SecretKey makes the caller that identity). An environment-level API Key can only reach the bound environment's data plane; for cross-product calls switch to account-level credentials: auth(action=\"start_auth\", authMode=\"device\"). Also confirm the target resource belongs to the current account.",
|
|
202046
202068
|
errorInvalidAction: "Action `{action}` may not exist or is not publicly available. Do not keep guessing Action names; first confirm the Action actually exists under service=`{service}` in the current API version.",
|
|
202047
202069
|
errorSuggestedActions: "Possible tcb Actions: {candidates}.",
|
|
202048
202070
|
errorRegionParam: "Region is not an Action body parameter. Use the callCloudApi top-level region parameter (e.g. region=\"ap-singapore\"), which maps to X-TC-Region.",
|
|
@@ -202086,7 +202108,7 @@ exports.cloudrun = (0, types_js_1.defineModule)({
|
|
|
202086
202108
|
"manage.description": "管理云托管服务,按开发顺序支持:开通云托管环境(initEnv)、初始化项目(可从模板开始,模板列表可通过 queryCloudRun 查询)、下载服务代码、本地运行(仅函数型服务)、部署代码、仅更新配置(updateConfig,无需重新上传代码)、删除服务。deploy 支持两种方式:1) 源码构建(传入 targetPath,本地代码打包上传,默认路径);2) 已有镜像部署(传入 imageUrl,如 ccr.ccs.tencentyun.com/ns/img:v1,走 DeployType=image 容器型部署,targetPath 可省略)。deploy 语义为「触发部署 + 轻量等待任务注册」(最多约 45s;不需要 buildId 时可传 waitRegistration=false 跳过等待)。源码构建返回 buildId,用 getDeployLog 轮询构建进度后再 getProcessLog;镜像部署(imageUrl)BuildId 常为 0,跳过 getDeployLog,返回 runId/next_step 引导 getProcessLog(或先 getDeployRecords 取 RunId)。若用户明确指定镜像或无需重新构建,必须传 imageUrl,不要仅因本地有源码目录就回退到源码构建。deploy 对已存在服务会先读取远程配置再合并(保留 VpcConf/EnvParams/OpenAccessTypes)。updateConfig 对齐控制台服务设置页。删除操作需要确认,建议设置force=true。新环境首次部署前若提示未开通云托管,先调用 initEnv 开通(异步、幂等)。",
|
|
202087
202109
|
"error.managerInitFailed": "CloudBase Manager 初始化失败,请检查凭据与环境配置。",
|
|
202088
202110
|
"error.unsupportedAction": "不支持的操作:{action}",
|
|
202089
|
-
"error.pathOutsideCwd": "路径必须在当前工作目录内:{cwd}",
|
|
202111
|
+
"error.pathOutsideCwd": "路径必须在当前工作目录内:{cwd}。允许:`{cwd}` 下的路径,或传入项目目录的绝对路径(相对路径不能通过 `../` 逃逸 CWD)。收到的解析路径:{resolvedPath}。建议:将 targetPath 设为项目绝对路径(deploy/download/init)。",
|
|
202090
202112
|
"error.commonServiceQueryEnv": "当前 CloudBase Manager 不支持 commonService,无法查询云托管环境开通状态。",
|
|
202091
202113
|
"error.commonServiceInitEnv": "当前 CloudBase Manager 不支持 commonService,无法初始化云托管环境。",
|
|
202092
202114
|
"error.commonServiceSubmitDiff": "当前 CloudBase Manager 不支持 commonService,无法调用 SubmitServerConfigChangeDiff。",
|
|
@@ -202276,7 +202298,7 @@ exports.cloudrun = (0, types_js_1.defineModule)({
|
|
|
202276
202298
|
"manage.description": "Manage CloudRun services, in development order: provision the CloudRun env (initEnv), initialize a project (optionally from a template; list templates via queryCloudRun), download service code, run locally (function services only), deploy code, update config only (updateConfig, no code upload needed), and delete the service. deploy supports two modes: 1) source build (pass targetPath; local code is packaged and uploaded, the default); 2) existing image deploy (pass imageUrl, e.g. ccr.ccs.tencentyun.com/ns/img:v1; DeployType=image container deploy, targetPath optional). deploy means \"trigger deploy + lightweight wait for task registration\" (up to ~45s; pass waitRegistration=false to skip the wait when you don't need the buildId). Source builds return buildId — poll getDeployLog for build progress, then getProcessLog; image deploys (imageUrl) usually have BuildId=0 — getDeployLog is skipped, and runId/next_step guide you to getProcessLog (or getDeployRecords first for RunId). If the user explicitly specifies an image or no rebuild is needed, you must pass imageUrl instead of falling back to a source build just because a local source directory exists. For existing services, deploy reads the remote config first and merges (preserving VpcConf/EnvParams/OpenAccessTypes). updateConfig aligns with the console service settings page. Deletion requires confirmation; set force=true. If a new env reports CloudRun not provisioned before the first deploy, call initEnv first (async, idempotent).",
|
|
202277
202299
|
"error.managerInitFailed": "Failed to initialize CloudBase manager. Please check your credentials and environment configuration.",
|
|
202278
202300
|
"error.unsupportedAction": "Unsupported action: {action}",
|
|
202279
|
-
"error.pathOutsideCwd": "Path must be within current working directory: {cwd}",
|
|
202301
|
+
"error.pathOutsideCwd": "Path must be within current working directory: {cwd}. Allowed: paths under `{cwd}`, or pass an absolute path to the project directory (relative paths cannot escape CWD via `../`). Received resolved path: {resolvedPath}. Suggestion: set targetPath to the absolute project path (deploy/download/init).",
|
|
202280
202302
|
"error.commonServiceQueryEnv": "Current CloudBase Manager does not support commonService; cannot query CloudRun env status.",
|
|
202281
202303
|
"error.commonServiceInitEnv": "Current CloudBase Manager does not support commonService; cannot initialize CloudRun env.",
|
|
202282
202304
|
"error.commonServiceSubmitDiff": "Current CloudBase Manager does not support commonService; cannot call SubmitServerConfigChangeDiff.",
|
|
@@ -203215,11 +203237,28 @@ exports.databaseSQL = (0, types_js_1.defineModule)({
|
|
|
203215
203237
|
"gate.pgOnlyMode": "当前环境({envId})已开通 PostgreSQL,MySQL 不可用。请改用 managePgDatabase / queryPgDatabase,而不是 manageMysqlDatabase / queryMysqlDatabase。",
|
|
203216
203238
|
"gate.useManagePg": "请使用 managePgDatabase 执行 PostgreSQL 操作",
|
|
203217
203239
|
"queryMysqlDatabase.title": "查询 CloudBase MySQL 数据库状态或执行只读 SQL",
|
|
203218
|
-
"queryMysqlDatabase.description": "查询 CloudBase MySQL 数据库信息。支持执行只读 SQL、查询 MySQL 开通结果、查询 MySQL
|
|
203219
|
-
"schema.query.action": "runQuery=执行只读 SQL;describeCreateResult=查询 CreateMySQL 结果;describeTaskStatus=查询 MySQL 任务状态;getInstanceInfo=获取不含连接凭据的生命周期上下文;describeInstance=getInstanceInfo 的别名;getConnectionInfo=透传可能包含凭据的原始连接/集群载荷(仅限 TCP
|
|
203240
|
+
"queryMysqlDatabase.description": "查询 CloudBase MySQL 数据库信息。支持执行只读 SQL、查询 MySQL 开通结果、查询 MySQL 任务状态、获取当前实例生命周期上下文,以及查询实例慢查询/错误日志(对齐 Manager SDK describeInstanceSlowQueries / describeInstanceErrorLogs)。标准 getInstanceInfo/describeInstance 不返回连接凭据;仅 getConnectionInfo 透传原始连接/集群载荷(含可能的凭据),且仅用于显式 TCP 迁移。业务 CRUD 优先使用 SDK 或 runQuery/runStatement。",
|
|
203241
|
+
"schema.query.action": "runQuery=执行只读 SQL;describeCreateResult=查询 CreateMySQL 结果;describeTaskStatus=查询 MySQL 任务状态;getInstanceInfo=获取不含连接凭据的生命周期上下文;describeInstance=getInstanceInfo 的别名;getConnectionInfo=透传可能包含凭据的原始连接/集群载荷(仅限 TCP 迁移例外场景);describeInstanceSlowQueries=查询实例慢查询日志;describeInstanceErrorLogs=查询实例错误日志",
|
|
203220
203242
|
"schema.query.sql": "action=runQuery 使用的只读 SQL",
|
|
203221
|
-
"schema.query.request": "describeCreateResult/describeTaskStatus
|
|
203222
|
-
"schema.query.dbInstance": "runQuery
|
|
203243
|
+
"schema.query.request": "describeCreateResult/describeTaskStatus/describeInstanceSlowQueries/describeInstanceErrorLogs 使用的官方请求载荷(可含 InstanceId 等)",
|
|
203244
|
+
"schema.query.dbInstance": "runQuery / 慢查/错误日志可选的 SQL 数据库实例上下文",
|
|
203245
|
+
"schema.query.startTime": "慢查/错误日志查询开始时间(YYYY-MM-DD HH:mm:ss)",
|
|
203246
|
+
"schema.query.endTime": "慢查/错误日志查询结束时间(YYYY-MM-DD HH:mm:ss)",
|
|
203247
|
+
"schema.query.limit": "慢查/错误日志返回条数限制",
|
|
203248
|
+
"schema.query.offset": "慢查/错误日志分页偏移",
|
|
203249
|
+
"schema.query.username": "慢查过滤:用户名",
|
|
203250
|
+
"schema.query.host": "慢查过滤:客户端 host",
|
|
203251
|
+
"schema.query.database": "慢查过滤:数据库名",
|
|
203252
|
+
"schema.query.orderBy": "排序字段。慢查支持 QueryTime/LockTime/RowsExamined/RowsSent;错误日志支持 Timestamp",
|
|
203253
|
+
"schema.query.orderByType": "排序方向:asc/desc(大小写均可)",
|
|
203254
|
+
"schema.query.sqlText": "慢查过滤:SQL 文本片段",
|
|
203255
|
+
"schema.query.logLevels": "错误日志等级过滤,可选值:error / warning / note",
|
|
203256
|
+
"schema.query.keyWords": "错误日志关键字模糊搜索列表",
|
|
203257
|
+
"instanceLogs.notProvisioned": "MySQL 尚未开通,无法查询实例慢查/错误日志。",
|
|
203258
|
+
"instanceLogs.instanceIdRequired": "无法解析 CynosDB InstanceId。请先 getInstanceInfo,或通过 dbInstance.instanceId / request.InstanceId 传入。",
|
|
203259
|
+
"instanceLogs.resolveInstanceId": "先查询实例信息以获取可用的 InstanceId。",
|
|
203260
|
+
"instanceLogs.slowQueriesSuccess": "MySQL 实例慢查询日志检索成功。",
|
|
203261
|
+
"instanceLogs.errorLogsSuccess": "MySQL 实例错误日志检索成功。",
|
|
203223
203262
|
"manageMysqlDatabase.title": "管理 CloudBase MySQL 数据库生命周期或执行写入 SQL",
|
|
203224
203263
|
"manageMysqlDatabase.description": "管理 CloudBase MySQL 数据库资源。支持开通 MySQL、销毁 MySQL、执行写入 SQL/DDL,以及初始化数据库 Schema。注意:必须先开通 MySQL(action=provisionMySQL,confirm=true)才能执行 runStatement 或 initializeSchema。若 MySQL 尚未开通,工具会返回 MYSQL_NOT_CREATED 并给出开通的 nextAction 提示。",
|
|
203225
203264
|
"schema.manage.action": "provisionMySQL=创建 MySQL 实例;destroyMySQL=销毁 MySQL 实例;runStatement=执行写入 SQL 或 DDL;initializeSchema=按顺序执行 Schema 初始化语句",
|
|
@@ -203290,11 +203329,28 @@ exports.databaseSQL = (0, types_js_1.defineModule)({
|
|
|
203290
203329
|
"gate.pgOnlyMode": "This environment ({envId}) has PostgreSQL enabled but MySQL is NOT available. Use managePgDatabase / queryPgDatabase instead of manageMysqlDatabase / queryMysqlDatabase.",
|
|
203291
203330
|
"gate.useManagePg": "Use managePgDatabase for PostgreSQL operations",
|
|
203292
203331
|
"queryMysqlDatabase.title": "Query CloudBase MySQL database status or run read-only SQL",
|
|
203293
|
-
"queryMysqlDatabase.description": "Query CloudBase MySQL database information. Supports running read-only SQL, checking the MySQL provisioning result, querying MySQL task status,
|
|
203294
|
-
"schema.query.action": "runQuery=execute read-only SQL; describeCreateResult=query CreateMySQL result; describeTaskStatus=query MySQL task status; getInstanceInfo=get lifecycle context without connection credentials; describeInstance=alias of getInstanceInfo; getConnectionInfo=passthrough raw connection/cluster payload including possible credentials (TCP migration exception only)",
|
|
203332
|
+
"queryMysqlDatabase.description": "Query CloudBase MySQL database information. Supports running read-only SQL, checking the MySQL provisioning result, querying MySQL task status, getting the current instance lifecycle context, and querying instance slow queries / error logs (aligned with Manager SDK describeInstanceSlowQueries / describeInstanceErrorLogs). Standard getInstanceInfo/describeInstance never returns connection credentials; only getConnectionInfo passes through the raw connection/cluster payload (possibly including credentials), and only for explicit TCP migration. Prefer the SDK or runQuery/runStatement for business CRUD.",
|
|
203333
|
+
"schema.query.action": "runQuery=execute read-only SQL; describeCreateResult=query CreateMySQL result; describeTaskStatus=query MySQL task status; getInstanceInfo=get lifecycle context without connection credentials; describeInstance=alias of getInstanceInfo; getConnectionInfo=passthrough raw connection/cluster payload including possible credentials (TCP migration exception only); describeInstanceSlowQueries=query instance slow query logs; describeInstanceErrorLogs=query instance error logs",
|
|
203295
203334
|
"schema.query.sql": "Read-only SQL used by action=runQuery",
|
|
203296
|
-
"schema.query.request": "Official request payload used by describeCreateResult/describeTaskStatus",
|
|
203297
|
-
"schema.query.dbInstance": "Optional SQL database instance context for runQuery",
|
|
203335
|
+
"schema.query.request": "Official request payload used by describeCreateResult/describeTaskStatus/describeInstanceSlowQueries/describeInstanceErrorLogs (may include InstanceId, etc.)",
|
|
203336
|
+
"schema.query.dbInstance": "Optional SQL database instance context for runQuery / slow-query / error-log actions",
|
|
203337
|
+
"schema.query.startTime": "Slow-query / error-log query start time (YYYY-MM-DD HH:mm:ss)",
|
|
203338
|
+
"schema.query.endTime": "Slow-query / error-log query end time (YYYY-MM-DD HH:mm:ss)",
|
|
203339
|
+
"schema.query.limit": "Max rows for slow-query / error-log results",
|
|
203340
|
+
"schema.query.offset": "Pagination offset for slow-query / error-log results",
|
|
203341
|
+
"schema.query.username": "Slow-query filter: username",
|
|
203342
|
+
"schema.query.host": "Slow-query filter: client host",
|
|
203343
|
+
"schema.query.database": "Slow-query filter: database name",
|
|
203344
|
+
"schema.query.orderBy": "Sort field. Slow queries: QueryTime/LockTime/RowsExamined/RowsSent; error logs: Timestamp",
|
|
203345
|
+
"schema.query.orderByType": "Sort direction: asc/desc (case-insensitive)",
|
|
203346
|
+
"schema.query.sqlText": "Slow-query filter: SQL text fragment",
|
|
203347
|
+
"schema.query.logLevels": "Error log level filter. Allowed values: error / warning / note",
|
|
203348
|
+
"schema.query.keyWords": "Error log keyword fuzzy-search list",
|
|
203349
|
+
"instanceLogs.notProvisioned": "MySQL is not provisioned yet, so instance slow/error logs cannot be queried.",
|
|
203350
|
+
"instanceLogs.instanceIdRequired": "Unable to resolve CynosDB InstanceId. Call getInstanceInfo first, or pass dbInstance.instanceId / request.InstanceId.",
|
|
203351
|
+
"instanceLogs.resolveInstanceId": "Query instance info first to obtain a usable InstanceId.",
|
|
203352
|
+
"instanceLogs.slowQueriesSuccess": "MySQL instance slow query logs retrieved successfully.",
|
|
203353
|
+
"instanceLogs.errorLogsSuccess": "MySQL instance error logs retrieved successfully.",
|
|
203298
203354
|
"manageMysqlDatabase.title": "Manage CloudBase MySQL database lifecycle or run write SQL",
|
|
203299
203355
|
"manageMysqlDatabase.description": "Manage CloudBase MySQL database resources. Supports provisioning MySQL, destroying MySQL, running write SQL/DDL, and initializing the database schema. Note: MySQL must be provisioned first (action=provisionMySQL, confirm=true) before runStatement or initializeSchema can run. If MySQL is not provisioned, the tool returns MYSQL_NOT_CREATED with a provisioning nextAction hint.",
|
|
203300
203356
|
"schema.manage.action": "provisionMySQL=create MySQL instance; destroyMySQL=destroy MySQL instance; runStatement=execute write SQL or DDL; initializeSchema=run ordered schema initialization statements",
|
|
@@ -204104,6 +204160,49 @@ exports.envSetup = (0, types_js_1.defineModule)({
|
|
|
204104
204160
|
});
|
|
204105
204161
|
|
|
204106
204162
|
|
|
204163
|
+
/***/ },
|
|
204164
|
+
|
|
204165
|
+
/***/ 99391
|
|
204166
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
204167
|
+
|
|
204168
|
+
"use strict";
|
|
204169
|
+
|
|
204170
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
204171
|
+
exports.feedback = void 0;
|
|
204172
|
+
const types_js_1 = __webpack_require__(89921);
|
|
204173
|
+
exports.feedback = (0, types_js_1.defineModule)({
|
|
204174
|
+
title: "整理本次开发反馈",
|
|
204175
|
+
description: "把当前这次 CloudBase 开发整理成用户可以自己提交的反馈。" +
|
|
204176
|
+
"作品做出来了,用它生成案例,方便展示;开发不顺利,用它生成复盘,方便把卡点反馈给平台。" +
|
|
204177
|
+
"\n\n**什么时候用**:" +
|
|
204178
|
+
"\n- `channel=\"case\"`:部署或发布已经成功,用户愿意把作品放到案例墙时使用。返回案例草稿;用户确认后附上预填好的新建 issue 链接。" +
|
|
204179
|
+
"\n- `channel=\"retrospective\"`:用户表示这次开发不顺利、想反馈时使用。根据本会话里真实的工具调用失败生成复盘草稿;用户确认后同样附上预填链接。" +
|
|
204180
|
+
"\n\n**怎么用**:" +
|
|
204181
|
+
"\n- 第一次不要传 `confirmed`。先把返回的草稿全文给用户看。" +
|
|
204182
|
+
"\n- 用户明确同意后,再以 `confirmed=true` 调用。这时才会返回可打开的链接。" +
|
|
204183
|
+
"\n- 本工具不会替用户提交。链接里的正文就是本次返回的 draft,不要改写成另一份再让用户提交。" +
|
|
204184
|
+
"\n- 不采集对话轮次,不要编造轮次、作品名、简介或公网地址。" +
|
|
204185
|
+
"\n- 国际站是英文草稿和 GitHub 链接(body 参数)。国内站是中文草稿,链接指向 CNB 上公开的 CloudBase-AI-ToolKit 仓库,正文放在模板字段 session。若页面没自动填上,把 draft 粘贴到「本次会话记录」。",
|
|
204186
|
+
"schema.channel": "反馈用途:`case` 是把已完成的作品整理成案例;`retrospective` 是把这次不顺利的开发整理成复盘。",
|
|
204187
|
+
"schema.confirmed": "用户是否已经看过草稿全文并明确同意提交。省略或 false 时只返回草稿、不给链接。",
|
|
204188
|
+
}, {
|
|
204189
|
+
title: "Prepare feedback for this session",
|
|
204190
|
+
description: "Turn this CloudBase session into feedback the user can submit themselves. " +
|
|
204191
|
+
"Use it to showcase a finished work, or to report a session that was hard to finish." +
|
|
204192
|
+
"\n\n**When to use**:" +
|
|
204193
|
+
"\n- `channel=\"case\"`: the deploy or publish already succeeded and the user wants the work on the case wall. Returns a case draft, and a prefilled new-issue link after the user confirms." +
|
|
204194
|
+
"\n- `channel=\"retrospective\"`: the user says this session went badly and wants to report it. Builds the retrospective from tool failures that actually happened in this session, and adds a prefilled link after confirmation." +
|
|
204195
|
+
"\n\n**How to use**:" +
|
|
204196
|
+
"\n- Do not pass `confirmed` on the first call. Show the returned draft to the user in full." +
|
|
204197
|
+
"\n- Call again with `confirmed=true` only after the user explicitly agrees. That call returns the link." +
|
|
204198
|
+
"\n- This tool does not submit the issue. The link body is the draft in this response. Do not rewrite it and ask the user to submit the rewrite." +
|
|
204199
|
+
"\n- Conversation turns are not collected. Do not invent a turn count, title, summary, or public URL." +
|
|
204200
|
+
"\n- International site: English draft and a GitHub link (body parameter). China site: Chinese draft and a link to the public CloudBase-AI-ToolKit repo on CNB. The draft is placed in the template field id session. If the page does not fill it, paste the draft into that field.",
|
|
204201
|
+
"schema.channel": "What the feedback is for: `case` turns a finished work into a showcase entry; `retrospective` turns a difficult session into a write-up.",
|
|
204202
|
+
"schema.confirmed": "Whether the user has read the full draft and agreed to submit it. Omit or pass false to return the draft only, with no link.",
|
|
204203
|
+
});
|
|
204204
|
+
|
|
204205
|
+
|
|
204107
204206
|
/***/ },
|
|
204108
204207
|
|
|
204109
204208
|
/***/ 28015
|
|
@@ -204413,7 +204512,7 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204413
204512
|
"opErr.default": "请检查函数名、目录结构和环境中的函数状态后重试。",
|
|
204414
204513
|
"opErr.prefix": "[{operation}] {message}\n建议:",
|
|
204415
204514
|
confirmRequired: "{action} 是危险操作,请显式传入 confirm=true 后再执行",
|
|
204416
|
-
"cloudMode.localOnly": "{action} 在 cloud mode
|
|
204515
|
+
"cloudMode.localOnly": "{action} 在 cloud mode 下不可用,因为该操作依赖本地函数代码目录。可用出路:1) 使用镜像部署(runtime=CustomImage + imageConfig);2) 使用 ZIP 两段式部署:先 queryFunctions action=getFunctionUploadUrl 获取预签名上传地址,PUT 代码 zip 后通过 manageFunctions 的 code 入参部署(阶段 B 同样不依赖本地目录)。",
|
|
204417
204516
|
"cloudMode.contentPathUnsupported": "createLayerVersion 在 cloud mode 下不支持 contentPath,本地文件内容请改为 base64Content 或改用本地模式执行。",
|
|
204418
204517
|
offsetLimitTooLarge: "offset+limit 不能大于 10000",
|
|
204419
204518
|
startTimeInvalid: "startTime 格式错误: \"{value}\"。必须使用 YYYY-MM-DD HH:mm:ss 格式(如 2024-01-01 00:00:00)",
|
|
@@ -204426,6 +204525,9 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204426
204525
|
"deployStatus.cloudMode": "{action} 在 cloud mode 下不可用:异步部署任务只由 buildStrategy=cloud/local 的真实部署创建,而这两种策略的真实执行在 cloud mode 下都不支持(需要读取本地构建上下文或本地 Docker),因此不会存在任何 taskId。buildStrategy=image 走同步部署,直接在 manageFunctions 的返回里拿结果,也不需要查询部署状态。如需异步镜像构建部署,请改用本地 MCP 模式。",
|
|
204427
204526
|
deployTaskNotFound: "未找到部署任务 {taskId};部署任务不存在,可能已过期、不属于当前环境 {envId},或 MCP Server 已重启(任务仅保存在 MCP 进程内存中)。",
|
|
204428
204527
|
unsupportedAction: "不支持的操作类型: {action}",
|
|
204528
|
+
storageMissing: "当前环境没有可用的对象存储桶(DescribeEnvs 未返回 Storages),无法使用 COS 两段式部署。请检查环境存储配置,或改用本地模式部署。共享存储桶(ExternalStorage)环境同样不支持该通道。",
|
|
204529
|
+
credentialMissing: "当前凭据缺少 SecretId/SecretKey(如 IDE 代理模式),无法本地铸造 COS 预签名上传地址。请改用本地模式或包含永久密钥/临时密钥的登录方式。",
|
|
204530
|
+
uploadTargetNotFound: "代码包上传目标不在本进程的登记里:{objectName}。ZIP 两段式部署要求 code 三元组来自本进程刚返回的 getFunctionUploadUrl(同一个 MCP 进程、同一个环境);MCP Server 已重启、换了环境、或自行拼装 cosObjectName / cosBucketName 都会落到这里。请重新调用 queryFunctions action=getFunctionUploadUrl 取地址,按返回值上传代码包,再用返回的三元组调用本 action。",
|
|
204429
204531
|
// ---- nextActions reasons ----
|
|
204430
204532
|
"reason.continuePolling": "继续查询云函数部署状态",
|
|
204431
204533
|
"reason.getDetail": "查看单个函数详情",
|
|
@@ -204464,6 +204566,7 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204464
204566
|
"reason.imageFnReady": "确认镜像函数已就绪(Active)",
|
|
204465
204567
|
"reason.imageUpdateReady": "确认镜像更新后函数已就绪(Active)",
|
|
204466
204568
|
"reason.imageNextIteration": "后续迭代只需用新镜像 tag 调用 updateFunctionCode 更新镜像",
|
|
204569
|
+
"reason.cosCreate": "把 PUT 好的代码 zip 通过 code 入参部署为函数(两段式阶段 B)",
|
|
204467
204570
|
"reason.imageGatewayRoute": "如需通过 URL 访问镜像 HTTP 函数,显式创建 Domain/Route 访问入口并传 type=\"HTTP\"(映射 WEB_SCF)",
|
|
204468
204571
|
"reason.latestConfig": "确认最新函数配置",
|
|
204469
204572
|
"reason.publishVersion": "发布函数新版本(对齐 tcb fn publish-version)",
|
|
@@ -204483,12 +204586,15 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204483
204586
|
gotLayerVersionDetail: "已获取层 {layerName} 版本 {layerVersion} 的详情",
|
|
204484
204587
|
gotFunctionTriggers: "已获取函数 {fnName} 的触发器列表",
|
|
204485
204588
|
gotDownloadUrl: "已获取函数 {fnName} 的代码下载链接",
|
|
204589
|
+
gotUploadUrl: "已生成函数代码包上传地址({seconds} 秒内有效)。下一步:PUT 代码 zip 到 uploadUrl(uploadHeaders 非空时须随请求携带),再调用 manageFunctions createFunction/updateFunctionCode 并传入 code 三元组(cosBucketName/cosObjectName/cosBucketRegion)完成部署。该 uploadUrl 等同一次性上传凭据,不要外传或写进工单;若上传前已过期,重新调用 getFunctionUploadUrl 取新地址",
|
|
204486
204590
|
gotFunctionVersions: "已获取函数 {fnName} 的版本列表",
|
|
204487
204591
|
gotFunctionAlias: "已获取函数 {fnName} 的别名 {aliasName}",
|
|
204488
204592
|
publishedVersion: "已发布函数 {fnName} 的新版本 {version}",
|
|
204489
204593
|
updatedFunctionAlias: "已更新函数 {fnName} 别名 {aliasName}(主版本 {version})",
|
|
204490
204594
|
createdHttpFunctionMessage: "已创建 HTTP 函数 {fnName}。如果后续需要通过 URL 访问,请显式调用 manageGateway(action=\"createRoute\"),并把 upstreamResourceType=\"WEB_SCF\" 一起传入,再按实际路径和鉴权需求创建访问入口。评测或其他外部调用方可能会以匿名身份访问,而且失败后不一定会把 EXCEED_AUTHORITY 再反馈给 AI;交付前请主动确认访问路径和函数安全规则,若已出现 EXCEED_AUTHORITY,请先调用 queryPermissions(action=\"getResourcePermission\", resourceType=\"function\", resourceId=\"{fnName}\") 查看当前规则,再按需要使用 managePermissions(action=\"updateResourcePermission\") 调整权限。",
|
|
204491
204595
|
createdFunction: "已创建函数 {fnName}",
|
|
204596
|
+
cosCreatedMessage: "已基于环境 COS 桶中的代码包(deployMode=cos)创建函数 {fnName}。部署后可用 queryFunctions(action=\"getFunctionDetail\") 确认函数已就绪。",
|
|
204597
|
+
cosUpdatedMessage: "已用环境 COS 桶中的新代码包(deployMode=cos)更新函数 {fnName} 的代码。部署后可用 queryFunctions(action=\"getFunctionDetail\") 确认函数已就绪(Active)。",
|
|
204492
204598
|
imageCreatedMessage: "已基于镜像 {imageUri} 创建 HTTP 函数 {fnName}。请确认 TCR、SCF 与构建管道处于同一地域;如需通过 URL 访问,请显式调用 manageGateway(action=\"createRoute\", upstreamResourceType=\"WEB_SCF\") 并按需调整函数安全规则。部署后可用 queryFunctions(action=\"getFunctionDetail\") 确认函数已就绪。",
|
|
204493
204599
|
imageUpdatedMessage: "已将函数 {fnName} 的镜像更新为 {imageUri}。部署后可用 queryFunctions(action=\"getFunctionDetail\") 确认函数已就绪(Active)。",
|
|
204494
204600
|
updatedCode: "已更新函数 {fnName} 的代码",
|
|
@@ -204554,12 +204660,12 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204554
204660
|
"schema.create.layers": "Layer 配置",
|
|
204555
204661
|
"schema.manageLayer.name": "层名称",
|
|
204556
204662
|
"schema.manageLayer.version": "层版本号",
|
|
204557
|
-
"schema.query.action": "只读操作类型:\n- `listFunctions`: 列出所有 CloudBase 云函数\n- `getFunctionDetail`: 获取 CloudBase 云函数详情(需要 functionName)\n- `listFunctionLogs`: 查询 CloudBase 云函数执行日志(需要 functionName)\n- `getFunctionLogDetail`: 获取日志详情(需要 requestId)\n- `listFunctionLayers`: 列出函数绑定的层\n- `listLayers`: 列出所有层(账号级视图,含其他环境创建的层)\n- `listLayerVersions`: 列出层的版本(注意:是 Versions 不是 Version;账号级视图)\n- `getLayerVersionDetail`: 获取层版本详情(账号级视图)\n- `listFunctionTriggers`: 列出函数触发器(用于查看定时任务 / cron / timer 配置)\n- `getFunctionDownloadUrl`: 获取函数代码下载地址\n- `getFunctionDeployStatus`: 按 taskId 查询异步部署状态、阶段进度和最终结果。返回 data.build(构建子状态)、data.deploy(部署子状态)、data.progress(阶段事件);status=running 时 data.result 与 data.error 一律为 null,不得报告部署完成。调用方必须持续轮询直到 status=succeeded/failed;status=expired 表示任务超过最长保留时间(2 小时)被终结,云端可能仍在部署,需用 getFunctionDetail 确认。任务只保存在 MCP 进程内存中,过期或 MCP Server 重启后返回 errorCode=DEPLOY_TASK_NOT_FOUND;任务按环境隔离,只能查到当前环境自己发起的部署。cloud mode 下本 action 不可用:异步任务只由 buildStrategy=cloud/local 的真实部署创建,而这两种策略在 cloud mode 下都不支持真实执行,image 策略则走同步部署不产生 taskId。\n- `listVersionByFunction`: 列出函数已发布版本(对齐 tcb fn list-function-versions / SDK listVersionByFunction;需要 functionName)\n- `getFunctionAlias`: 查询函数别名与流量路由(对齐 tcb fn get-route / SDK getFunctionAlias;需要 functionName;aliasName 默认 $DEFAULT
|
|
204558
|
-
"schema.query.functionName": "CloudBase 云函数名称。`getFunctionDetail`、`listFunctionLogs`、`listFunctionLayers`、`listFunctionTriggers`、`getFunctionDownloadUrl`、`listVersionByFunction`、`getFunctionAlias`
|
|
204663
|
+
"schema.query.action": "只读操作类型:\n- `listFunctions`: 列出所有 CloudBase 云函数\n- `getFunctionDetail`: 获取 CloudBase 云函数详情(需要 functionName)\n- `listFunctionLogs`: 查询 CloudBase 云函数执行日志(需要 functionName)\n- `getFunctionLogDetail`: 获取日志详情(需要 requestId)\n- `listFunctionLayers`: 列出函数绑定的层\n- `listLayers`: 列出所有层(账号级视图,含其他环境创建的层)\n- `listLayerVersions`: 列出层的版本(注意:是 Versions 不是 Version;账号级视图)\n- `getLayerVersionDetail`: 获取层版本详情(账号级视图)\n- `listFunctionTriggers`: 列出函数触发器(用于查看定时任务 / cron / timer 配置)\n- `getFunctionDownloadUrl`: 获取函数代码下载地址\n- `getFunctionDeployStatus`: 按 taskId 查询异步部署状态、阶段进度和最终结果。返回 data.build(构建子状态)、data.deploy(部署子状态)、data.progress(阶段事件);status=running 时 data.result 与 data.error 一律为 null,不得报告部署完成。调用方必须持续轮询直到 status=succeeded/failed;status=expired 表示任务超过最长保留时间(2 小时)被终结,云端可能仍在部署,需用 getFunctionDetail 确认。任务只保存在 MCP 进程内存中,过期或 MCP Server 重启后返回 errorCode=DEPLOY_TASK_NOT_FOUND;任务按环境隔离,只能查到当前环境自己发起的部署。cloud mode 下本 action 不可用:异步任务只由 buildStrategy=cloud/local 的真实部署创建,而这两种策略在 cloud mode 下都不支持真实执行,image 策略则走同步部署不产生 taskId。\n- `listVersionByFunction`: 列出函数已发布版本(对齐 tcb fn list-function-versions / SDK listVersionByFunction;需要 functionName)\n- `getFunctionAlias`: 查询函数别名与流量路由(对齐 tcb fn get-route / SDK getFunctionAlias;需要 functionName;aliasName 默认 $DEFAULT)\n- `getFunctionUploadUrl`: 获取函数代码包的 COS 预签名上传地址(ZIP 两段式部署阶段 A):PUT 代码 zip 到 uploadUrl(uploadHeaders 非空时须随请求携带对应请求头),再调用 manageFunctions 的 createFunction/updateFunctionCode 并传 code 三元组(阶段 B)。functionName 可选,仅用于生成上传对象 key。返回的 uploadUrl 含凭据签名,不得写入日志或持久化;阶段 A 与阶段 B 必须落在同一个 MCP 进程(MCP Server 重启后需重新取地址并重新上传);地址默认 300 秒内有效",
|
|
204664
|
+
"schema.query.functionName": "CloudBase 云函数名称。`getFunctionDetail`、`listFunctionLogs`、`listFunctionLayers`、`listFunctionTriggers`、`getFunctionDownloadUrl`、`listVersionByFunction`、`getFunctionAlias` 时必填;`getFunctionUploadUrl` 可选(仅用于生成上传对象 key)",
|
|
204559
204665
|
"schema.query.limit": "分页数量(limit)。列表类 action 可选,默认值由后端决定",
|
|
204560
204666
|
"schema.query.offset": "分页偏移(offset)。列表类 action 可选,默认 0",
|
|
204561
204667
|
"schema.query.codeSecret": "代码保护密钥,用于解密函数代码",
|
|
204562
|
-
"schema.query.revealEnvValues": "getFunctionDetail / listFunctionTriggers 时是否返回环境变量明文值。默认 false:Value 脱敏为 ***,仅保留 Key 与 ValueLength,足以确认配置了哪些变量及变更是否生效;true 时返回明文,敏感变量会进入模型上下文,谨慎使用。如需查看明文,建议优先使用控制台或 CLI",
|
|
204668
|
+
"schema.query.revealEnvValues": "getFunctionDetail / listFunctionTriggers / listFunctionLayers 时是否返回环境变量明文值。默认 false:Value 脱敏为 ***,仅保留 Key 与 ValueLength,足以确认配置了哪些变量及变更是否生效;true 时返回明文,敏感变量会进入模型上下文,谨慎使用。如需查看明文,建议优先使用控制台或 CLI",
|
|
204563
204669
|
"schema.query.startTime": "日志查询开始时间,格式必须为 YYYY-MM-DD HH:mm:ss(如 2024-01-01 00:00:00)。与 endTime 间隔不能超过一天。不传时默认查询最近一天",
|
|
204564
204670
|
"schema.query.endTime": "日志查询结束时间,格式必须为 YYYY-MM-DD HH:mm:ss(如 2024-01-01 23:59:59)。与 startTime 间隔不能超过一天。不传时默认为当前时间",
|
|
204565
204671
|
"schema.query.requestId": "日志请求 ID。`getFunctionLogDetail` 操作必填,可从 `listFunctionLogs` 结果中获取",
|
|
@@ -204578,6 +204684,10 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204578
204684
|
"schema.manage.force": "createFunction 时是否覆盖",
|
|
204579
204685
|
"schema.manage.functionName": "目标函数名称(顶层)。updateFunctionCode / updateFunctionConfig / invokeFunction / publishVersion / updateFunctionAliasConfig 等 action 使用此字段。不要只写在 func.name:createFunction 用 func.name,其它 action 用顶层 functionName。若误传 func.name,也会被识别为 functionName。",
|
|
204580
204686
|
"schema.manage.zipFile": "仅兼容特殊场景:预先准备好的代码包 base64 编码。普通 createFunction/updateFunctionCode 默认不要先压缩 zip,优先使用 functionRootPath。",
|
|
204687
|
+
"schema.manage.code": "ZIP 两段式部署阶段 B:代码包已通过 queryFunctions action=getFunctionUploadUrl 上传到环境 COS 桶。三元组(cosBucketName/cosObjectName/cosBucketRegion)直接使用 getFunctionUploadUrl 返回值原样透传。传入 code 后 createFunction/updateFunctionCode 不再读取本地目录(functionRootPath/zipFile 均不需要),默认不触发云端依赖安装(可用 func.installDependency 覆盖)。code 三元组必须是同一个 MCP 进程的 getFunctionUploadUrl 刚返回的那一组(该 process 会在阶段 A 登记上传目标),自行拼装或跨环境复用会被拒绝并要求重新取地址。",
|
|
204688
|
+
"schema.code.cosBucketName": "环境存储桶短名(不含 -appid 后缀),直接使用 getFunctionUploadUrl 返回的 cosBucketName,不要自填",
|
|
204689
|
+
"schema.code.cosObjectName": "上传对象 key,直接使用 getFunctionUploadUrl 返回的 cosObjectName",
|
|
204690
|
+
"schema.code.cosBucketRegion": "存储桶地域,省略时自动使用当前环境存储桶地域",
|
|
204581
204691
|
"schema.manage.handler": "函数入口",
|
|
204582
204692
|
"schema.manage.timeout": "配置更新时的超时时间",
|
|
204583
204693
|
"schema.manage.envVariables": "配置更新时要合并的环境变量。若含 DATABASE_URL / MYSQL_* / POSTGRES_* / REDIS_* 等 TCP 连库变量,必须同时提供真实 vpc(或函数已绑定完整 VPC)。禁止猜测 vpcId/subnetId。",
|
|
@@ -204683,7 +204793,7 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204683
204793
|
"opErr.default": "Please check the function name, directory structure, and the function status in the environment, then retry.",
|
|
204684
204794
|
"opErr.prefix": "[{operation}] {message}\nSuggestions: ",
|
|
204685
204795
|
confirmRequired: "{action} is a dangerous operation; pass confirm=true explicitly before executing",
|
|
204686
|
-
"cloudMode.localOnly": "{action} is unavailable in cloud mode because the operation depends on a local function code directory.
|
|
204796
|
+
"cloudMode.localOnly": "{action} is unavailable in cloud mode because the operation depends on a local function code directory. Options: 1) use image deployment (runtime=CustomImage + imageConfig); 2) use two-phase ZIP deployment: first call queryFunctions action=getFunctionUploadUrl to get a presigned upload URL, PUT the code zip, then deploy via the manageFunctions code parameter (phase B also needs no local directory).",
|
|
204687
204797
|
"cloudMode.contentPathUnsupported": "createLayerVersion does not support contentPath in cloud mode; switch local file content to base64Content or run in local mode.",
|
|
204688
204798
|
offsetLimitTooLarge: "offset+limit must not be greater than 10000",
|
|
204689
204799
|
startTimeInvalid: "Invalid startTime: \"{value}\". It must use the YYYY-MM-DD HH:mm:ss format (e.g. 2024-01-01 00:00:00)",
|
|
@@ -204696,6 +204806,9 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204696
204806
|
"deployStatus.cloudMode": "{action} is unavailable in cloud mode: async deployment tasks are only created by real deployments with buildStrategy=cloud/local, and real execution of both strategies is unsupported in cloud mode (they need the local build context or local Docker), so no taskId can exist. buildStrategy=image uses synchronous deployment and returns the result directly from manageFunctions, so no deployment status query is needed. For async image build deployment, switch to local MCP mode.",
|
|
204697
204807
|
deployTaskNotFound: "Deployment task {taskId} not found; the task does not exist — it may have expired, belong to a different environment than {envId}, or the MCP Server was restarted (tasks are only kept in MCP process memory).",
|
|
204698
204808
|
unsupportedAction: "Unsupported action: {action}",
|
|
204809
|
+
storageMissing: "The current environment has no usable object storage bucket (DescribeEnvs returned no Storages), so COS two-phase deployment is unavailable. Check the environment storage configuration, or deploy in local mode. Environments with a shared bucket (ExternalStorage) are not supported either.",
|
|
204810
|
+
credentialMissing: "The current credential lacks SecretId/SecretKey (e.g. IDE proxy mode), so a COS presigned upload URL cannot be minted locally. Use local mode or a login method with permanent/temporary keys.",
|
|
204811
|
+
uploadTargetNotFound: "The code package upload target is not registered in this process: {objectName}. Two-phase ZIP deployment requires the code triplet to come from a getFunctionUploadUrl response minted by this same MCP process and environment; a restarted MCP Server, a different environment, or a hand-built cosObjectName / cosBucketName all land here. Call queryFunctions action=getFunctionUploadUrl again, upload the code package to the returned address, then call this action with the returned triplet.",
|
|
204699
204812
|
// ---- nextActions reasons ----
|
|
204700
204813
|
"reason.continuePolling": "Keep polling the cloud function deployment status",
|
|
204701
204814
|
"reason.getDetail": "View details of a single function",
|
|
@@ -204734,6 +204847,7 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204734
204847
|
"reason.imageFnReady": "Confirm the image function is ready (Active)",
|
|
204735
204848
|
"reason.imageUpdateReady": "Confirm the function is ready (Active) after the image update",
|
|
204736
204849
|
"reason.imageNextIteration": "For later iterations, just call updateFunctionCode with the new image tag to update the image",
|
|
204850
|
+
"reason.cosCreate": "Deploy the uploaded code zip as a function via the code parameter (two-phase deployment phase B)",
|
|
204737
204851
|
"reason.imageGatewayRoute": "To access the image HTTP function via URL, explicitly create a Domain/Route access entry and pass type=\"HTTP\" (mapped to WEB_SCF)",
|
|
204738
204852
|
"reason.latestConfig": "Confirm the latest function configuration",
|
|
204739
204853
|
"reason.publishVersion": "Publish a new function version (aligns with tcb fn publish-version)",
|
|
@@ -204753,12 +204867,15 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204753
204867
|
gotLayerVersionDetail: "Retrieved details of layer {layerName} version {layerVersion}",
|
|
204754
204868
|
gotFunctionTriggers: "Retrieved the trigger list of function {fnName}",
|
|
204755
204869
|
gotDownloadUrl: "Retrieved the code download URL of function {fnName}",
|
|
204870
|
+
gotUploadUrl: "Generated the code package upload URL (valid for {seconds} seconds). Next: PUT the code zip to uploadUrl (include the uploadHeaders when non-empty), then call manageFunctions createFunction/updateFunctionCode with the code triplet (cosBucketName/cosObjectName/cosBucketRegion) to deploy. Treat the uploadUrl as a one-time upload credential: do not forward it or paste it into tickets; if it expires before the upload, call getFunctionUploadUrl again for a fresh address",
|
|
204756
204871
|
gotFunctionVersions: "Retrieved the version list of function {fnName}",
|
|
204757
204872
|
gotFunctionAlias: "Retrieved alias {aliasName} of function {fnName}",
|
|
204758
204873
|
publishedVersion: "Published new version {version} of function {fnName}",
|
|
204759
204874
|
updatedFunctionAlias: "Updated alias {aliasName} of function {fnName} (primary version {version})",
|
|
204760
204875
|
createdHttpFunctionMessage: "Created HTTP function {fnName} from the image. If URL access is needed later, explicitly call manageGateway(action=\"createRoute\") with upstreamResourceType=\"WEB_SCF\", then create the access entry according to the actual path and auth requirements. Evaluators or other external callers may access anonymously, and failures may not feed EXCEED_AUTHORITY back to the AI; before delivery, proactively confirm the access path and the function security rules. If EXCEED_AUTHORITY has already appeared, first call queryPermissions(action=\"getResourcePermission\", resourceType=\"function\", resourceId=\"{fnName}\") to view the current rules, then adjust permissions with managePermissions(action=\"updateResourcePermission\") as needed.",
|
|
204761
204876
|
createdFunction: "Created function {fnName}",
|
|
204877
|
+
cosCreatedMessage: "Created function {fnName} from the code package in the environment COS bucket (deployMode=cos). Use queryFunctions(action=\"getFunctionDetail\") after deployment to confirm the function is ready.",
|
|
204878
|
+
cosUpdatedMessage: "Updated the code of function {fnName} with the new package in the environment COS bucket (deployMode=cos). Use queryFunctions(action=\"getFunctionDetail\") after deployment to confirm the function is ready (Active).",
|
|
204762
204879
|
imageCreatedMessage: "Created HTTP function {fnName} from image {imageUri}. Please confirm TCR, SCF, and the build pipeline are in the same region; for URL access, explicitly call manageGateway(action=\"createRoute\", upstreamResourceType=\"WEB_SCF\") and adjust the function security rules as needed. After deployment, use queryFunctions(action=\"getFunctionDetail\") to confirm the function is ready.",
|
|
204763
204880
|
imageUpdatedMessage: "Updated the image of function {fnName} to {imageUri}. After deployment, use queryFunctions(action=\"getFunctionDetail\") to confirm the function is ready (Active).",
|
|
204764
204881
|
updatedCode: "Updated the code of function {fnName}",
|
|
@@ -204824,12 +204941,12 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204824
204941
|
"schema.create.layers": "Layer configuration",
|
|
204825
204942
|
"schema.manageLayer.name": "Layer name",
|
|
204826
204943
|
"schema.manageLayer.version": "Layer version number",
|
|
204827
|
-
"schema.query.action": "Read-only action type:\n- `listFunctions`: list all CloudBase cloud functions\n- `getFunctionDetail`: get function details (requires functionName)\n- `listFunctionLogs`: query function execution logs (requires functionName)\n- `getFunctionLogDetail`: get log details (requires requestId)\n- `listFunctionLayers`: list layers bound to a function\n- `listLayers`: list all layers (account-level view, including layers from other environments)\n- `listLayerVersions`: list layer versions (Versions, not Version; account-level view)\n- `getLayerVersionDetail`: get layer version details (account-level view)\n- `listFunctionTriggers`: list function triggers (scheduled task / cron / timer configuration)\n- `getFunctionDownloadUrl`: get the function code download URL\n- `getFunctionDeployStatus`: query async deployment status, stage progress, and final result by taskId. Returns data.build, data.deploy, and data.progress. While status=running, data.result and data.error are null and deployment must not be reported as complete. Keep polling until status=succeeded/failed. status=expired means the task exceeded the 2-hour retention limit; cloud deployment may still be running, so confirm with getFunctionDetail. Tasks exist only in MCP process memory; expired tasks or a restarted MCP Server return errorCode=DEPLOY_TASK_NOT_FOUND. Tasks are isolated by environment. This action is unavailable in cloud mode because real cloud/local builds cannot run there, while image deployment is synchronous and creates no taskId.\n- `listVersionByFunction`: list published function versions (aligns with tcb fn list-function-versions / SDK listVersionByFunction; requires functionName)\n- `getFunctionAlias`: get function alias and traffic routing (aligns with tcb fn get-route / SDK getFunctionAlias; requires functionName; aliasName defaults to $DEFAULT)",
|
|
204828
|
-
"schema.query.functionName": "CloudBase cloud function name. Required for `getFunctionDetail`, `listFunctionLogs`, `listFunctionLayers`, `listFunctionTriggers`, `getFunctionDownloadUrl`, `listVersionByFunction`, and `getFunctionAlias`.",
|
|
204944
|
+
"schema.query.action": "Read-only action type:\n- `listFunctions`: list all CloudBase cloud functions\n- `getFunctionDetail`: get function details (requires functionName)\n- `listFunctionLogs`: query function execution logs (requires functionName)\n- `getFunctionLogDetail`: get log details (requires requestId)\n- `listFunctionLayers`: list layers bound to a function\n- `listLayers`: list all layers (account-level view, including layers from other environments)\n- `listLayerVersions`: list layer versions (Versions, not Version; account-level view)\n- `getLayerVersionDetail`: get layer version details (account-level view)\n- `listFunctionTriggers`: list function triggers (scheduled task / cron / timer configuration)\n- `getFunctionDownloadUrl`: get the function code download URL\n- `getFunctionDeployStatus`: query async deployment status, stage progress, and final result by taskId. Returns data.build, data.deploy, and data.progress. While status=running, data.result and data.error are null and deployment must not be reported as complete. Keep polling until status=succeeded/failed. status=expired means the task exceeded the 2-hour retention limit; cloud deployment may still be running, so confirm with getFunctionDetail. Tasks exist only in MCP process memory; expired tasks or a restarted MCP Server return errorCode=DEPLOY_TASK_NOT_FOUND. Tasks are isolated by environment. This action is unavailable in cloud mode because real cloud/local builds cannot run there, while image deployment is synchronous and creates no taskId.\n- `listVersionByFunction`: list published function versions (aligns with tcb fn list-function-versions / SDK listVersionByFunction; requires functionName)\n- `getFunctionAlias`: get function alias and traffic routing (aligns with tcb fn get-route / SDK getFunctionAlias; requires functionName; aliasName defaults to $DEFAULT)\n- `getFunctionUploadUrl`: get a COS presigned upload URL for a function code package (two-phase ZIP deployment phase A): PUT the code zip to uploadUrl (include the corresponding request headers when uploadHeaders is non-empty), then call manageFunctions createFunction/updateFunctionCode with the code triplet (phase B). functionName is optional and only shapes the upload object key. The uploadUrl carries credential-bound signatures; never log or persist it; phase A and phase B must run in the same MCP process (after an MCP Server restart, fetch a new address and upload again); the address is valid for 300 seconds by default",
|
|
204945
|
+
"schema.query.functionName": "CloudBase cloud function name. Required for `getFunctionDetail`, `listFunctionLogs`, `listFunctionLayers`, `listFunctionTriggers`, `getFunctionDownloadUrl`, `listVersionByFunction`, and `getFunctionAlias`. Optional for `getFunctionUploadUrl` (only used to generate the upload object key).",
|
|
204829
204946
|
"schema.query.limit": "Page size (limit). Optional for list actions; the backend determines the default.",
|
|
204830
204947
|
"schema.query.offset": "Pagination offset. Optional for list actions; defaults to 0.",
|
|
204831
204948
|
"schema.query.codeSecret": "Code protection secret used to decrypt function code.",
|
|
204832
|
-
"schema.query.revealEnvValues": "Whether `getFunctionDetail` / `listFunctionTriggers` returns plaintext environment variable values. Defaults to false: Value is masked as ***, while Key and ValueLength remain, which is sufficient to verify configured variables and changes. true returns plaintext and may expose secrets to the model context; use cautiously. Prefer the console or CLI for plaintext values.",
|
|
204949
|
+
"schema.query.revealEnvValues": "Whether `getFunctionDetail` / `listFunctionTriggers` / `listFunctionLayers` returns plaintext environment variable values. Defaults to false: Value is masked as ***, while Key and ValueLength remain, which is sufficient to verify configured variables and changes. true returns plaintext and may expose secrets to the model context; use cautiously. Prefer the console or CLI for plaintext values.",
|
|
204833
204950
|
"schema.query.startTime": "Log query start time in YYYY-MM-DD HH:mm:ss format (for example, 2024-01-01 00:00:00). The interval to endTime must not exceed one day. Defaults to the most recent day when omitted.",
|
|
204834
204951
|
"schema.query.endTime": "Log query end time in YYYY-MM-DD HH:mm:ss format (for example, 2024-01-01 23:59:59). The interval from startTime must not exceed one day. Defaults to the current time when omitted.",
|
|
204835
204952
|
"schema.query.requestId": "Log request ID. Required for `getFunctionLogDetail`; obtain it from `listFunctionLogs`.",
|
|
@@ -204848,6 +204965,10 @@ exports.functions = (0, types_js_1.defineModule)({
|
|
|
204848
204965
|
"schema.manage.force": "Whether createFunction overwrites an existing function.",
|
|
204849
204966
|
"schema.manage.functionName": "Target function name at the top level. Used by updateFunctionCode, updateFunctionConfig, invokeFunction, publishVersion, updateFunctionAliasConfig, and similar actions. createFunction uses func.name; other actions use top-level functionName. A mistakenly supplied func.name is also recognized as functionName.",
|
|
204850
204967
|
"schema.manage.zipFile": "Compatibility only: base64-encoded prebuilt code package. For ordinary createFunction/updateFunctionCode, do not create a ZIP first; prefer functionRootPath.",
|
|
204968
|
+
"schema.manage.code": "Two-phase ZIP deployment phase B: the code package has been uploaded to the environment COS bucket via queryFunctions action=getFunctionUploadUrl. Pass the triplet (cosBucketName/cosObjectName/cosBucketRegion) through unchanged from the getFunctionUploadUrl response. With code provided, createFunction/updateFunctionCode no longer reads local directories (functionRootPath/zipFile are unnecessary), and cloud dependency installation is skipped by default (override with func.installDependency). The code triplet must be the one just returned by getFunctionUploadUrl in the same MCP process (that process registers the upload target in phase A); hand-built triplets or cross-environment reuse are rejected and require fetching a new address.",
|
|
204969
|
+
"schema.code.cosBucketName": "Environment bucket short name (without the -appid suffix); pass through the cosBucketName returned by getFunctionUploadUrl, do not invent one",
|
|
204970
|
+
"schema.code.cosObjectName": "Uploaded object key; pass through the cosObjectName returned by getFunctionUploadUrl",
|
|
204971
|
+
"schema.code.cosBucketRegion": "Bucket region; defaults to the current environment bucket region when omitted",
|
|
204851
204972
|
"schema.manage.handler": "Function entry point",
|
|
204852
204973
|
"schema.manage.timeout": "Timeout used for configuration updates.",
|
|
204853
204974
|
"schema.manage.envVariables": "Environment variables to merge during a configuration update. If they contain TCP database variables such as DATABASE_URL, MYSQL_*, POSTGRES_*, or REDIS_*, also provide a real vpc (or ensure the function already has a complete VPC binding). Never guess vpcId/subnetId.",
|
|
@@ -205476,6 +205597,7 @@ exports.logs = (0, types_js_1.defineModule)({
|
|
|
205476
205597
|
"\n\n**重要区分**:" +
|
|
205477
205598
|
"\n- 查询云函数日志:使用 `queryFunctions(action=\"listFunctionLogs\", functionName=\"xxx\")`" +
|
|
205478
205599
|
"\n- 查询 CLS 日志(跨服务日志聚合):使用本工具 `queryLogs(action=\"searchLogs\")`" +
|
|
205600
|
+
"\n- 开通 CLS 日志服务:使用 `manageLogs(action=\"createLogService\", confirm=true)`" +
|
|
205479
205601
|
"\n\n**适用场景**:" +
|
|
205480
205602
|
"\n- 检查 CLS 日志服务是否开通:`action=\"checkLogService\"`" +
|
|
205481
205603
|
"\n- 跨服务日志搜索(如搜索所有 ERROR 日志):`action=\"searchLogs\"`" +
|
|
@@ -205521,12 +205643,28 @@ exports.logs = (0, types_js_1.defineModule)({
|
|
|
205521
205643
|
"schema.limit": "返回日志条数限制,默认 20",
|
|
205522
205644
|
"schema.context": "翻页上下文,用于继续上一次查询",
|
|
205523
205645
|
"schema.sort": "按时间排序:`asc` 升序,`desc` 降序",
|
|
205646
|
+
"manage.title": "管理 CloudBase 日志服务",
|
|
205647
|
+
"manage.description": "CloudBase 日志域写入入口。用于开通 CLS 日志服务(对齐 Manager SDK `log.createLogService` / CreateEnvResource Resources=['log'])。" +
|
|
205648
|
+
"\n\n**适用场景**:" +
|
|
205649
|
+
"\n- 开通 CLS 日志服务:`action=\"createLogService\", confirm=true`" +
|
|
205650
|
+
"\n\n开通为异步操作:接口成功不代表立即可用,请随后用 `queryLogs(action=\"checkLogService\")` 轮询确认。",
|
|
205651
|
+
"manage.schema.action": "操作类型:" +
|
|
205652
|
+
"\n- `createLogService`: 开通 CLS 日志服务(需 `confirm=true`)",
|
|
205653
|
+
"manage.schema.confirm": "开通日志服务前的显式确认。必须传 `confirm=true`;未传时返回 CONFIRM_REQUIRED。",
|
|
205654
|
+
"manage.create.confirmRequired": "开通日志服务会创建 CLS 日志资源。请使用 `confirm: true` 重新执行以继续。",
|
|
205655
|
+
"manage.create.needsConfirmation": "开通日志服务前需要显式确认。",
|
|
205656
|
+
"manage.create.alreadyEnabled": "当前环境日志服务已开通,无需重复开通。",
|
|
205657
|
+
"manage.create.submitted": "日志服务开通请求已提交。请使用 queryLogs(action=\"checkLogService\") 轮询直至 enabled=true。",
|
|
205658
|
+
"manage.create.nextCheck": "轮询日志服务是否已就绪。",
|
|
205659
|
+
"manage.create.nextSearch": "日志服务已就绪,可开始搜索 CLS 日志。",
|
|
205660
|
+
"manage.unsupportedAction": "不支持的日志管理 action:{action}",
|
|
205524
205661
|
}, {
|
|
205525
205662
|
title: "Query CloudBase log service",
|
|
205526
205663
|
description: "Unified read-only entry for the CloudBase logs domain. Supports checking log service status and searching CLS logs." +
|
|
205527
205664
|
"\n\n**Important distinction**:" +
|
|
205528
205665
|
"\n- Query cloud function logs: use `queryFunctions(action=\"listFunctionLogs\", functionName=\"xxx\")`" +
|
|
205529
205666
|
"\n- Query CLS logs (cross-service log aggregation): use this tool `queryLogs(action=\"searchLogs\")`" +
|
|
205667
|
+
"\n- Enable the CLS log service: use `manageLogs(action=\"createLogService\", confirm=true)`" +
|
|
205530
205668
|
"\n\n**Use cases**:" +
|
|
205531
205669
|
"\n- Check whether the CLS log service is enabled: `action=\"checkLogService\"`" +
|
|
205532
205670
|
"\n- Cross-service log search (e.g. find all ERROR logs): `action=\"searchLogs\"`" +
|
|
@@ -205572,6 +205710,21 @@ exports.logs = (0, types_js_1.defineModule)({
|
|
|
205572
205710
|
"schema.limit": "Maximum number of log entries to return; defaults to 20.",
|
|
205573
205711
|
"schema.context": "Pagination context used to continue the previous query.",
|
|
205574
205712
|
"schema.sort": "Time sort order: `asc` for ascending or `desc` for descending.",
|
|
205713
|
+
"manage.title": "Manage CloudBase log service",
|
|
205714
|
+
"manage.description": "Write entry for the CloudBase logs domain. Enables the CLS log service (aligned with Manager SDK `log.createLogService` / CreateEnvResource Resources=['log'])." +
|
|
205715
|
+
"\n\n**Use cases**:" +
|
|
205716
|
+
"\n- Enable CLS log service: `action=\"createLogService\", confirm=true`" +
|
|
205717
|
+
"\n\nProvisioning is asynchronous: API success does not mean the service is immediately ready. Poll with `queryLogs(action=\"checkLogService\")` afterward.",
|
|
205718
|
+
"manage.schema.action": "Operation type:" +
|
|
205719
|
+
"\n- `createLogService`: Enable the CLS log service (requires `confirm=true`)",
|
|
205720
|
+
"manage.schema.confirm": "Explicit confirmation before enabling the log service. Must pass `confirm=true`; omitting it returns CONFIRM_REQUIRED.",
|
|
205721
|
+
"manage.create.confirmRequired": "Enabling the log service creates CLS log resources. Re-run with `confirm: true` to continue.",
|
|
205722
|
+
"manage.create.needsConfirmation": "Explicit confirmation is required before enabling the log service.",
|
|
205723
|
+
"manage.create.alreadyEnabled": "The log service is already enabled for this environment; no need to enable again.",
|
|
205724
|
+
"manage.create.submitted": "Log service enablement request submitted. Poll with queryLogs(action=\"checkLogService\") until enabled=true.",
|
|
205725
|
+
"manage.create.nextCheck": "Poll whether the log service is ready.",
|
|
205726
|
+
"manage.create.nextSearch": "Log service is ready; you can start searching CLS logs.",
|
|
205727
|
+
"manage.unsupportedAction": "Unsupported log manage action: {action}",
|
|
205575
205728
|
});
|
|
205576
205729
|
|
|
205577
205730
|
|
|
@@ -205865,19 +206018,19 @@ exports.permissions = (0, types_js_1.defineModule)({
|
|
|
205865
206018
|
"或 securityRule='{\"invoke\":true}'(放通所有云函数)。" +
|
|
205866
206019
|
"底层错误:{message}",
|
|
205867
206020
|
mustBeArray: "{label} 必须是数组",
|
|
205868
|
-
roleLookupNote: "如果你需要 app-level admin override(例如 CMS 中 admin 可编辑所有文章,而 editor 只能编辑自己的文章),CUSTOM 规则通常是必要的。一个已验证可用的模式是:角色集合文档主键就是 auth.uid,并在文章权限里写 get(
|
|
205869
|
-
recommendedClientWritePattern: "对于 CMS 文章这类使用 app-level admin override 的 CUSTOM 规则,前端可继续使用 db.collection('{resourceId}').doc(id).update(...) / remove(...)。关键是安全规则要采用已验证模式:get(
|
|
206021
|
+
roleLookupNote: "如果你需要 app-level admin override(例如 CMS 中 admin 可编辑所有文章,而 editor 只能编辑自己的文章),CUSTOM 规则通常是必要的。一个已验证可用的模式是:角色集合文档主键就是 auth.uid,并在文章权限里写 get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid。若现有 schema 已经有 users / profiles / user_roles 其一,请复用已存在且能通过 _id == auth.uid 直接 get() 到的那一份;不要把 where({ uid }) 查询得到的集合误写成 get(`database.users.${auth.uid}`)。",
|
|
206022
|
+
recommendedClientWritePattern: "对于 CMS 文章这类使用 app-level admin override 的 CUSTOM 规则,前端可继续使用 db.collection('{resourceId}').doc(id).update(...) / remove(...)。关键是安全规则要采用已验证模式:get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid,并且文章文档中要真实写入 authorId。",
|
|
205870
206023
|
createRuleSummary: "create 规则不应引用 doc.*,因为 create 时文档尚未存在。",
|
|
205871
206024
|
createRuleDetail: "CloudBase 的 create 规则验证的是写入数据(request.data),此时文档尚不存在,doc.* 不可用。" +
|
|
205872
206025
|
"请将 create 规则改为仅使用 auth.* 检查(如 auth.uid != null && auth.loginType != 'ANONYMOUS')," +
|
|
205873
206026
|
"或在写入时将 owner 字段(如 _openid / authorId)写入 request.data,然后在 create 规则中用 request.data._openid == auth.openid 做校验。" +
|
|
205874
206027
|
"read / update / delete 规则可以使用 doc.* 引用已有文档字段,且客户端查询条件必须是规则约束的子集(如 _openid: '{openid}')。",
|
|
205875
206028
|
docIdWriteSummary: "当前安全规则在 document-id 写入场景下可能被后端直接拒绝。",
|
|
205876
|
-
docIdWriteDetail: "这类规则经常在 owner-only 集合里被写错,但对于 CMS 文章这种“admin 可编辑所有文章、editor 只能编辑自己的文章”的场景,已验证可用的做法是保留 doc.authorId,并通过独立角色集合做 admin override:get(
|
|
206029
|
+
docIdWriteDetail: "这类规则经常在 owner-only 集合里被写错,但对于 CMS 文章这种“admin 可编辑所有文章、editor 只能编辑自己的文章”的场景,已验证可用的做法是保留 doc.authorId,并通过独立角色集合做 admin override:get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid。不要默认改成 where(...),也不要把同集合 owner 判断重写成 ``get(`database.collection.${doc._id}`)``。",
|
|
205877
206030
|
invalidGetPathSummary: "get() 的 path 只应包含 collection 和 documentId,不应把字段名拼进 path 字符串。",
|
|
205878
|
-
invalidGetPathDetail: "请写成 get(
|
|
205879
|
-
templateLiteralSummary: "
|
|
205880
|
-
templateLiteralDetail: "
|
|
206031
|
+
invalidGetPathDetail: "请写成 ``get(`database.collection.${doc._id}`).fieldName``,而不是把字段名拼进 path。安全规则的表达式不支持用 + 拼接 get() 的 path 参数——形如 get('database.collection.' + doc._id) 的规则在保存时就会被判 rule invalid,请改用反引号模板字符串。但在 CMS 文章权限里,不要把同集合文档当成默认首选方案;更稳的模式是读取单独的角色集合:``get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid``。",
|
|
206032
|
+
templateLiteralSummary: "${...} 出现在引号字符串里也能被引擎识别,但官方形态是反引号模板字符串。",
|
|
206033
|
+
templateLiteralDetail: "推荐统一写成 ``get(`database.user_roles.${auth.uid}`).role == 'admin'``。真正会被拒绝的不是 ${...},而是另外两种写法:不含 ${...} 的裸引号字面量(如 get('database.admin_locks.article_lock'),请求时会返回 500),以及用 + 拼接的 get(`database.user_roles.${auth.uid}`)(保存规则时判 rule invalid)。对于 CMS 文章这类需要 app-level admin override 的规则,请优先使用 user_roles + doc.authorId 模式。",
|
|
205881
206034
|
bucketMissing: "存储 Bucket {bucket} 不存在",
|
|
205882
206035
|
bucketsMissing: "以下存储 Bucket 不存在: {buckets}",
|
|
205883
206036
|
paramRequired: "action={action} 时必须提供 {param}",
|
|
@@ -205946,19 +206099,19 @@ exports.permissions = (0, types_js_1.defineModule)({
|
|
|
205946
206099
|
"(package authz.user) or securityRule='{\"invoke\":true}' for public functions. " +
|
|
205947
206100
|
"Underlying error: {message}",
|
|
205948
206101
|
mustBeArray: "{label} must be an array",
|
|
205949
|
-
roleLookupNote: "If you need app-level admin override (e.g. in a CMS, admins can edit all articles while editors can only edit their own), a CUSTOM rule is usually required. A verified pattern is: make the role collection's document primary key auth.uid itself, and in the article permission write get(
|
|
205950
|
-
recommendedClientWritePattern: "For CMS articles using CUSTOM rules with app-level admin override, the frontend can keep using db.collection('{resourceId}').doc(id).update(...) / remove(...). The key is that the security rule uses the verified pattern: get(
|
|
206102
|
+
roleLookupNote: "If you need app-level admin override (e.g. in a CMS, admins can edit all articles while editors can only edit their own), a CUSTOM rule is usually required. A verified pattern is: make the role collection's document primary key auth.uid itself, and in the article permission write get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid. If the existing schema already has users / profiles / user_roles, reuse the one that exists and can be fetched directly via _id == auth.uid with get(); do not mistakenly write the collection obtained by a where({ uid }) query as get(`database.users.${auth.uid}`).",
|
|
206103
|
+
recommendedClientWritePattern: "For CMS articles using CUSTOM rules with app-level admin override, the frontend can keep using db.collection('{resourceId}').doc(id).update(...) / remove(...). The key is that the security rule uses the verified pattern: get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid, and the article document must actually contain the authorId field.",
|
|
205951
206104
|
createRuleSummary: "The create rule should not reference doc.*, because the document does not exist yet at create time.",
|
|
205952
206105
|
createRuleDetail: "CloudBase's create rule validates the written data (request.data); the document does not exist yet, so doc.* is unavailable. " +
|
|
205953
206106
|
"Change the create rule to use only auth.* checks (e.g. auth.uid != null && auth.loginType != 'ANONYMOUS'), " +
|
|
205954
206107
|
"or write the owner field (e.g. _openid / authorId) into request.data at write time, then validate with request.data._openid == auth.openid in the create rule. " +
|
|
205955
206108
|
"read / update / delete rules may use doc.* to reference existing document fields, and the client's query conditions must be a subset of the rule constraints (e.g. _openid: '{openid}').",
|
|
205956
206109
|
docIdWriteSummary: "The current security rule may be rejected by the backend in document-id write scenarios.",
|
|
205957
|
-
docIdWriteDetail: "Such rules are often written incorrectly in owner-only collections, but for the CMS article scenario where \"admins can edit all articles and editors can only edit their own\", the verified approach is to keep doc.authorId and do admin override through a separate role collection: get(
|
|
206110
|
+
docIdWriteDetail: "Such rules are often written incorrectly in owner-only collections, but for the CMS article scenario where \"admins can edit all articles and editors can only edit their own\", the verified approach is to keep doc.authorId and do admin override through a separate role collection: get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid. Do not default to where(...), and do not rewrite the same-collection owner check as ``get(`database.collection.${doc._id}`)``.",
|
|
205958
206111
|
invalidGetPathSummary: "The get() path should only contain the collection and documentId; do not concatenate field names into the path string.",
|
|
205959
|
-
invalidGetPathDetail: "Write get(
|
|
205960
|
-
templateLiteralSummary: "
|
|
205961
|
-
templateLiteralDetail: "
|
|
206112
|
+
invalidGetPathDetail: "Write ``get(`database.collection.${doc._id}`).fieldName`` instead of embedding the field name in the path. Security rule expressions do not support concatenating the get() path with +: a rule such as get('database.collection.' + doc._id) is rejected with rule invalid when the rule is saved, so use a backtick template literal. However, for CMS article permissions, do not treat a same-collection document as the default first choice; the more robust pattern is reading a separate role collection: ``get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid``.",
|
|
206113
|
+
templateLiteralSummary: "${...} inside a quoted string is understood by the engine, but the official form is a backtick template literal.",
|
|
206114
|
+
templateLiteralDetail: "Prefer ``get(`database.user_roles.${auth.uid}`).role == 'admin'``. What actually breaks is not ${...} but two other spellings: a bare quoted literal with no ${...} (e.g. get('database.admin_locks.article_lock'), which returns 500 at request time), and a concatenated path such as get(`database.user_roles.${auth.uid}`) (rejected with rule invalid when the rule is saved). For rules needing app-level admin override like CMS articles, prefer the user_roles + doc.authorId pattern.",
|
|
205962
206115
|
bucketMissing: "Storage bucket {bucket} does not exist",
|
|
205963
206116
|
bucketsMissing: "The following storage buckets do not exist: {buckets}",
|
|
205964
206117
|
paramRequired: "{param} is required when action={action}",
|
|
@@ -206209,6 +206362,7 @@ exports.setup = (0, types_js_1.defineModule)({
|
|
|
206209
206362
|
"schema.template": "要下载的模板类型",
|
|
206210
206363
|
"schema.ide": "指定要下载的IDE类型。",
|
|
206211
206364
|
"schema.overwrite": "是否覆盖已存在的文件,默认为false(不覆盖)",
|
|
206365
|
+
"projectRoot.hostConfigDir": "拒绝把 {dir} 当作项目根目录。这是宿主配置目录,不是项目。请由宿主设置 WORKSPACE_FOLDER_PATHS 为项目目录后再试。",
|
|
206212
206366
|
}, {
|
|
206213
206367
|
"downloadTemplate.title": "Download project template",
|
|
206214
206368
|
"downloadTemplate.description": "Automatically downloads and deploys CloudBase project templates.\n**Note**: Call this tool when the user requests to create a new project using a CloudBase template.\n\nSupported templates:\n- react: React + CloudBase full-stack app template\n- vue: Vue + CloudBase full-stack app template\n- miniprogram: WeChat Mini Program + CloudBase template\n- uniapp: UniApp + CloudBase cross-platform app template\n- rules: AI editor configuration files only (includes configurations for all mainstream editors such as Cursor, WindSurf, and CodeBuddy), suitable for adding AI editor configuration to an existing project\n\nSupported IDE types:\n- all: download configurations for all IDEs\n- cursor: Cursor AI editor\n- see the list below for other IDE types\n\nNote: if the ide parameter is not provided and the IDE cannot be detected from environment variables, an error will be returned asking for the ide parameter\n- windsurf: WindSurf AI editor\n- codebuddy: CodeBuddy AI editor\n- claude-code: Claude Code AI editor\n- cline: Cline AI editor\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI editor\n- qwen-code: Tongyi Lingma\n- baidu-comate: Baidu Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI editor\n- tongyi-lingma: Tongyi Lingma\n- trae: Trae AI editor\n- qoder: Qoder AI editor\n- antigravity: Google Antigravity AI editor\n- vscode: Visual Studio Code\n- kiro: Kiro AI editor\n- aider: Aider AI editor\n\nNotes:\n- the rules template automatically embeds the current MCP version for future maintenance and version tracking\n- when downloading the rules template, if a README.md file already exists in the project, the system protects it from being overwritten (unless overwrite=true is set)",
|
|
@@ -206273,6 +206427,7 @@ exports.setup = (0, types_js_1.defineModule)({
|
|
|
206273
206427
|
"schema.template": "The type of template to download",
|
|
206274
206428
|
"schema.ide": "The IDE type whose configuration should be downloaded.",
|
|
206275
206429
|
"schema.overwrite": "Whether to overwrite existing files. Defaults to false (do not overwrite).",
|
|
206430
|
+
"projectRoot.hostConfigDir": "Refusing to use {dir} as the project root. That directory belongs to the host, not a project. Set WORKSPACE_FOLDER_PATHS to the project directory and retry.",
|
|
206276
206431
|
});
|
|
206277
206432
|
|
|
206278
206433
|
|
|
@@ -206480,6 +206635,7 @@ const msgPush_js_1 = __webpack_require__(26191);
|
|
|
206480
206635
|
const setup_js_1 = __webpack_require__(8707);
|
|
206481
206636
|
const envSetup_js_1 = __webpack_require__(57148);
|
|
206482
206637
|
const interactive_js_1 = __webpack_require__(91838);
|
|
206638
|
+
const feedback_js_1 = __webpack_require__(99391);
|
|
206483
206639
|
exports.zh = {
|
|
206484
206640
|
env: env_js_1.env.zh,
|
|
206485
206641
|
storage: storage_js_1.storage.zh,
|
|
@@ -206509,6 +206665,7 @@ exports.zh = {
|
|
|
206509
206665
|
setup: setup_js_1.setup.zh,
|
|
206510
206666
|
envSetup: envSetup_js_1.envSetup.zh,
|
|
206511
206667
|
interactive: interactive_js_1.interactive.zh,
|
|
206668
|
+
feedback: feedback_js_1.feedback.zh,
|
|
206512
206669
|
};
|
|
206513
206670
|
|
|
206514
206671
|
|
|
@@ -206653,6 +206810,107 @@ async function getInteractiveServerAsync() {
|
|
|
206653
206810
|
}
|
|
206654
206811
|
|
|
206655
206812
|
|
|
206813
|
+
/***/ },
|
|
206814
|
+
|
|
206815
|
+
/***/ 16156
|
|
206816
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
206817
|
+
|
|
206818
|
+
"use strict";
|
|
206819
|
+
|
|
206820
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
206821
|
+
exports.assertLocalEndpoint = assertLocalEndpoint;
|
|
206822
|
+
exports.resolveLocalEndpoint = resolveLocalEndpoint;
|
|
206823
|
+
exports.createLocalCloudApiRequestFn = createLocalCloudApiRequestFn;
|
|
206824
|
+
const logger_js_1 = __webpack_require__(40781);
|
|
206825
|
+
/** Loopback hosts only. WHATWG URL keeps the brackets on IPv6 hostnames. */
|
|
206826
|
+
const ALLOWED_HOSTS = new Set(['127.0.0.1', '[::1]', 'localhost']);
|
|
206827
|
+
/** Upper bound for one cloud API call, so a hung endpoint cannot block a tool call forever. */
|
|
206828
|
+
const ENDPOINT_TIMEOUT_MS = 30_000;
|
|
206829
|
+
let announcedEndpoint;
|
|
206830
|
+
/**
|
|
206831
|
+
* Validate and normalise CLOUDBASE_LOCAL_ENDPOINT.
|
|
206832
|
+
*
|
|
206833
|
+
* Setting this variable makes cloud API calls skip the login and credential
|
|
206834
|
+
* checks, so it must never point off the local machine.
|
|
206835
|
+
*/
|
|
206836
|
+
function assertLocalEndpoint(endpoint) {
|
|
206837
|
+
let parsed;
|
|
206838
|
+
try {
|
|
206839
|
+
parsed = new URL(endpoint);
|
|
206840
|
+
}
|
|
206841
|
+
catch {
|
|
206842
|
+
throw new Error('CLOUDBASE_LOCAL_ENDPOINT is not a valid URL');
|
|
206843
|
+
}
|
|
206844
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
206845
|
+
throw new Error('CLOUDBASE_LOCAL_ENDPOINT must use http or https');
|
|
206846
|
+
}
|
|
206847
|
+
if (!ALLOWED_HOSTS.has(parsed.hostname)) {
|
|
206848
|
+
throw new Error('CLOUDBASE_LOCAL_ENDPOINT must point at a loopback host');
|
|
206849
|
+
}
|
|
206850
|
+
return endpoint.replace(/\/+$/, '');
|
|
206851
|
+
}
|
|
206852
|
+
/**
|
|
206853
|
+
* Read and validate CLOUDBASE_LOCAL_ENDPOINT. Returns undefined when unset.
|
|
206854
|
+
*
|
|
206855
|
+
* A malformed value throws instead of silently falling back, so a bad config
|
|
206856
|
+
* surfaces as a config error rather than looking like an auth failure.
|
|
206857
|
+
*/
|
|
206858
|
+
function resolveLocalEndpoint() {
|
|
206859
|
+
const raw = process.env.CLOUDBASE_LOCAL_ENDPOINT;
|
|
206860
|
+
if (!raw) {
|
|
206861
|
+
return undefined;
|
|
206862
|
+
}
|
|
206863
|
+
const base = assertLocalEndpoint(raw);
|
|
206864
|
+
if (announcedEndpoint !== base) {
|
|
206865
|
+
announcedEndpoint = base;
|
|
206866
|
+
(0, logger_js_1.warn)(`CLOUDBASE_LOCAL_ENDPOINT is set: cloud API calls go to ${base} and the login/credential check is skipped`);
|
|
206867
|
+
}
|
|
206868
|
+
return base;
|
|
206869
|
+
}
|
|
206870
|
+
/**
|
|
206871
|
+
* manager-node 5.8.8 routes both DatabaseService.executePGSql and
|
|
206872
|
+
* commonService().call through CloudService.request. That method delegates
|
|
206873
|
+
* to context.requestFn and skips TC3 when the function is set.
|
|
206874
|
+
*/
|
|
206875
|
+
function createLocalCloudApiRequestFn(endpoint) {
|
|
206876
|
+
const base = assertLocalEndpoint(endpoint);
|
|
206877
|
+
return async ({ service, action, version, region, payload }) => {
|
|
206878
|
+
const response = await fetch(`${base}/capi`, {
|
|
206879
|
+
method: 'POST',
|
|
206880
|
+
headers: {
|
|
206881
|
+
'content-type': 'application/json',
|
|
206882
|
+
'x-tc-action': action,
|
|
206883
|
+
'x-tc-version': version,
|
|
206884
|
+
'x-tc-region': region,
|
|
206885
|
+
'x-tc-service': service,
|
|
206886
|
+
},
|
|
206887
|
+
body: JSON.stringify(payload ?? {}),
|
|
206888
|
+
signal: AbortSignal.timeout(ENDPOINT_TIMEOUT_MS),
|
|
206889
|
+
redirect: 'manual',
|
|
206890
|
+
});
|
|
206891
|
+
// With redirect: 'manual' a 3xx comes back as an opaque redirect (status 0)
|
|
206892
|
+
// instead of being followed, so both shapes must be rejected explicitly.
|
|
206893
|
+
if (response.type === 'opaqueredirect' || (response.status >= 300 && response.status < 400)) {
|
|
206894
|
+
throw new Error('CLOUDBASE_LOCAL_ENDPOINT responded with a redirect; redirects are not followed');
|
|
206895
|
+
}
|
|
206896
|
+
const body = await response.json();
|
|
206897
|
+
const inner = body.Response;
|
|
206898
|
+
if (!inner) {
|
|
206899
|
+
const error = new Error('missing Response');
|
|
206900
|
+
error.code = 'InternalError';
|
|
206901
|
+
throw error;
|
|
206902
|
+
}
|
|
206903
|
+
const apiError = inner.Error;
|
|
206904
|
+
if (apiError) {
|
|
206905
|
+
const error = new Error(apiError.Message || apiError.Code || 'cloud api error');
|
|
206906
|
+
error.code = apiError.Code;
|
|
206907
|
+
throw error;
|
|
206908
|
+
}
|
|
206909
|
+
return inner;
|
|
206910
|
+
};
|
|
206911
|
+
}
|
|
206912
|
+
|
|
206913
|
+
|
|
206656
206914
|
/***/ },
|
|
206657
206915
|
|
|
206658
206916
|
/***/ 46324
|
|
@@ -206688,6 +206946,7 @@ const apps_js_1 = __webpack_require__(38267);
|
|
|
206688
206946
|
const logs_js_1 = __webpack_require__(61628);
|
|
206689
206947
|
const permissions_js_1 = __webpack_require__(52639);
|
|
206690
206948
|
const msg_push_js_1 = __webpack_require__(87707);
|
|
206949
|
+
const feedback_js_1 = __webpack_require__(6332);
|
|
206691
206950
|
const index_js_1 = __webpack_require__(24908);
|
|
206692
206951
|
const schema_js_1 = __webpack_require__(56273);
|
|
206693
206952
|
const cloud_mode_js_1 = __webpack_require__(88694);
|
|
@@ -206717,6 +206976,7 @@ const DEFAULT_PLUGINS = [
|
|
|
206717
206976
|
"logs",
|
|
206718
206977
|
"agents",
|
|
206719
206978
|
"capi",
|
|
206979
|
+
"feedback",
|
|
206720
206980
|
];
|
|
206721
206981
|
function registerDatabase(server) {
|
|
206722
206982
|
// NoSQL 数据库按站点能力集合注册(国际站默认不支持 NoSQL)
|
|
@@ -206766,6 +207026,7 @@ const AVAILABLE_PLUGINS = {
|
|
|
206766
207026
|
deploy: { name: "deploy", register: deploy_js_1.registerDeployTools },
|
|
206767
207027
|
capi: { name: "capi", register: capi_js_1.registerCapiTools },
|
|
206768
207028
|
"msg-push": { name: "msg-push", register: msg_push_js_1.registerMsgPushTools },
|
|
207029
|
+
feedback: { name: "feedback", register: feedback_js_1.registerFeedbackTools },
|
|
206769
207030
|
};
|
|
206770
207031
|
const PLUGIN_ALIASES = {
|
|
206771
207032
|
"access-control": "permissions",
|
|
@@ -209251,6 +209512,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
209251
209512
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
209252
209513
|
exports.CLOUDRUN_ENV_TYPE = exports.CLOUDRUN_DEPLOY_REGISTRATION_INTERVAL_MS = exports.CLOUDRUN_DEPLOY_REGISTRATION_MAX_WAIT_MS = exports.MASKED_CLOUDRUN_ENV_VALUE = exports.CLOUDRUN_PACKAGE_TYPES = exports.CLOUDRUN_ACCESS_TYPES = exports.CLOUDRUN_SERVICE_TYPES = void 0;
|
|
209253
209514
|
exports.maskCloudRunDetailEnvParams = maskCloudRunDetailEnvParams;
|
|
209515
|
+
exports.validateAndNormalizePath = validateAndNormalizePath;
|
|
209254
209516
|
exports.resolveCloudRunProjectDir = resolveCloudRunProjectDir;
|
|
209255
209517
|
exports.buildManageCloudRunErrorMessage = buildManageCloudRunErrorMessage;
|
|
209256
209518
|
exports.isValidCloudRunBuildId = isValidCloudRunBuildId;
|
|
@@ -209277,6 +209539,7 @@ const zod_1 = __webpack_require__(21504);
|
|
|
209277
209539
|
const cloudbase_manager_js_1 = __webpack_require__(33109);
|
|
209278
209540
|
const index_js_1 = __webpack_require__(24908);
|
|
209279
209541
|
const logger_js_1 = __webpack_require__(40781);
|
|
209542
|
+
const project_config_js_1 = __webpack_require__(39175);
|
|
209280
209543
|
const gateway_access_urls_js_1 = __webpack_require__(84173);
|
|
209281
209544
|
const notification_js_1 = __webpack_require__(4718);
|
|
209282
209545
|
const capi_js_1 = __webpack_require__(88900);
|
|
@@ -209481,31 +209744,20 @@ function checkIfAgentProject(projectPath) {
|
|
|
209481
209744
|
}
|
|
209482
209745
|
}
|
|
209483
209746
|
/**
|
|
209484
|
-
* Validate and normalize file path.
|
|
209485
|
-
*
|
|
209486
|
-
*
|
|
209487
|
-
* @param inputPath User provided path
|
|
209488
|
-
* @returns Absolute path
|
|
209747
|
+
* Validate and normalize a file path.
|
|
209748
|
+
* Absolute paths are accepted as-is. Relative paths resolve against the project
|
|
209749
|
+
* root and must stay inside it.
|
|
209489
209750
|
*/
|
|
209490
209751
|
function validateAndNormalizePath(inputPath) {
|
|
209491
|
-
|
|
209492
|
-
|
|
209493
|
-
|
|
209494
|
-
|
|
209495
|
-
|
|
209496
|
-
const
|
|
209497
|
-
|
|
209498
|
-
|
|
209499
|
-
|
|
209500
|
-
// Same filesystem root — ensure the resolved path is still inside CWD
|
|
209501
|
-
// (or is exactly CWD) to block "../" traversal.
|
|
209502
|
-
const prefix = cwd.endsWith(path_1.default.sep) ? cwd : cwd + path_1.default.sep;
|
|
209503
|
-
if (!normalizedPath.startsWith(prefix) && normalizedPath !== cwd) {
|
|
209504
|
-
throw new Error((0, index_js_1.t)("cloudrun.error.pathOutsideCwd", { cwd }));
|
|
209505
|
-
}
|
|
209506
|
-
}
|
|
209507
|
-
// Cross-root absolute paths (e.g. D:\ on Windows when CWD is C:\) are
|
|
209508
|
-
// allowed — the user own the machine and the path is explicitly absolute.
|
|
209752
|
+
if (path_1.default.isAbsolute(inputPath)) {
|
|
209753
|
+
return path_1.default.resolve(inputPath);
|
|
209754
|
+
}
|
|
209755
|
+
const projectRoot = (0, project_config_js_1.requireProjectRoot)();
|
|
209756
|
+
const normalizedPath = path_1.default.resolve(projectRoot, inputPath);
|
|
209757
|
+
const prefix = projectRoot.endsWith(path_1.default.sep) ? projectRoot : projectRoot + path_1.default.sep;
|
|
209758
|
+
if (!normalizedPath.startsWith(prefix) && normalizedPath !== projectRoot) {
|
|
209759
|
+
throw new Error((0, index_js_1.t)("cloudrun.error.pathOutsideCwd", { cwd: projectRoot, resolvedPath: normalizedPath }));
|
|
209760
|
+
}
|
|
209509
209761
|
return normalizedPath;
|
|
209510
209762
|
}
|
|
209511
209763
|
/**
|
|
@@ -213935,6 +214187,7 @@ const zod_1 = __webpack_require__(21504);
|
|
|
213935
214187
|
const cloudbase_manager_js_1 = __webpack_require__(33109);
|
|
213936
214188
|
const env_js_1 = __webpack_require__(56504);
|
|
213937
214189
|
const index_js_1 = __webpack_require__(24908);
|
|
214190
|
+
const project_config_js_1 = __webpack_require__(39175);
|
|
213938
214191
|
const tool_result_js_1 = __webpack_require__(69645);
|
|
213939
214192
|
const sql_risk_js_1 = __webpack_require__(29885);
|
|
213940
214193
|
const CATEGORY = "PostgreSQL database";
|
|
@@ -214219,19 +214472,7 @@ function validateMigrationName(name, actionLabel) {
|
|
|
214219
214472
|
return null;
|
|
214220
214473
|
}
|
|
214221
214474
|
function getMigrationProjectRoot() {
|
|
214222
|
-
|
|
214223
|
-
process.env.PROJECT_ROOT ||
|
|
214224
|
-
process.env.GITHUB_WORKSPACE ||
|
|
214225
|
-
process.env.CI_PROJECT_DIR ||
|
|
214226
|
-
process.env.BUILD_SOURCESDIRECTORY;
|
|
214227
|
-
if (fromEnv && fromEnv.trim()) {
|
|
214228
|
-
// IDEs may inject multiple folders separated by path.delimiter.
|
|
214229
|
-
const first = fromEnv.split(path.delimiter).map((p) => p.trim()).find(Boolean);
|
|
214230
|
-
if (first) {
|
|
214231
|
-
return first;
|
|
214232
|
-
}
|
|
214233
|
-
}
|
|
214234
|
-
return process.cwd();
|
|
214475
|
+
return (0, project_config_js_1.requireProjectRoot)();
|
|
214235
214476
|
}
|
|
214236
214477
|
function buildLocalMigrationFileName(version, name) {
|
|
214237
214478
|
return `${version}_${name}.sql`;
|
|
@@ -216606,7 +216847,17 @@ const QUERY_ACTIONS = [
|
|
|
216606
216847
|
"getInstanceInfo",
|
|
216607
216848
|
"describeInstance",
|
|
216608
216849
|
"getConnectionInfo",
|
|
216850
|
+
"describeInstanceSlowQueries",
|
|
216851
|
+
"describeInstanceErrorLogs",
|
|
216609
216852
|
];
|
|
216853
|
+
const SLOW_QUERY_ORDER_BY = [
|
|
216854
|
+
"QueryTime",
|
|
216855
|
+
"LockTime",
|
|
216856
|
+
"RowsExamined",
|
|
216857
|
+
"RowsSent",
|
|
216858
|
+
];
|
|
216859
|
+
const ERROR_LOG_LEVELS = ["error", "warning", "note"];
|
|
216860
|
+
const ORDER_BY_TYPE = ["asc", "desc", "ASC", "DESC"];
|
|
216610
216861
|
const MANAGE_ACTIONS = [
|
|
216611
216862
|
"provisionMySQL",
|
|
216612
216863
|
"destroyMySQL",
|
|
@@ -217113,6 +217364,138 @@ async function handleGetConnectionInfo(context) {
|
|
|
217113
217364
|
],
|
|
217114
217365
|
});
|
|
217115
217366
|
}
|
|
217367
|
+
function resolveMysqlInstanceId(instanceInfo, args) {
|
|
217368
|
+
const fromRequest = typeof args.request?.InstanceId === "string"
|
|
217369
|
+
? args.request.InstanceId
|
|
217370
|
+
: undefined;
|
|
217371
|
+
const fromDbInstance = args.dbInstance?.instanceId;
|
|
217372
|
+
const candidate = fromRequest || fromDbInstance || instanceInfo.instanceId;
|
|
217373
|
+
if (!candidate || candidate === "default") {
|
|
217374
|
+
return null;
|
|
217375
|
+
}
|
|
217376
|
+
return candidate;
|
|
217377
|
+
}
|
|
217378
|
+
async function requireReadyMysqlInstance(args, context) {
|
|
217379
|
+
const instanceInfo = await getSqlInstanceInfo(context);
|
|
217380
|
+
if (!instanceInfo.exists) {
|
|
217381
|
+
return {
|
|
217382
|
+
ok: false,
|
|
217383
|
+
payload: buildSqlToolResult({
|
|
217384
|
+
success: false,
|
|
217385
|
+
errorCode: "MYSQL_NOT_CREATED",
|
|
217386
|
+
data: sanitizeInstanceInfo(instanceInfo),
|
|
217387
|
+
message: (0, index_js_1.t)("databaseSQL.instanceLogs.notProvisioned"),
|
|
217388
|
+
nextActions: [
|
|
217389
|
+
buildNextAction(MANAGE_MYSQL_DATABASE, "provisionMySQL", (0, index_js_1.t)("databaseSQL.next.provisionBeforeSql"), { action: "provisionMySQL", confirm: true }),
|
|
217390
|
+
],
|
|
217391
|
+
}),
|
|
217392
|
+
};
|
|
217393
|
+
}
|
|
217394
|
+
const instanceId = resolveMysqlInstanceId(instanceInfo, args);
|
|
217395
|
+
if (!instanceId) {
|
|
217396
|
+
return {
|
|
217397
|
+
ok: false,
|
|
217398
|
+
payload: buildSqlToolResult({
|
|
217399
|
+
success: false,
|
|
217400
|
+
errorCode: "MYSQL_INSTANCE_ID_REQUIRED",
|
|
217401
|
+
data: sanitizeInstanceInfo(instanceInfo),
|
|
217402
|
+
message: (0, index_js_1.t)("databaseSQL.instanceLogs.instanceIdRequired"),
|
|
217403
|
+
nextActions: [
|
|
217404
|
+
buildNextAction(QUERY_MYSQL_DATABASE, "getInstanceInfo", (0, index_js_1.t)("databaseSQL.instanceLogs.resolveInstanceId"), { action: "getInstanceInfo" }),
|
|
217405
|
+
],
|
|
217406
|
+
}),
|
|
217407
|
+
};
|
|
217408
|
+
}
|
|
217409
|
+
return { ok: true, instanceInfo, instanceId };
|
|
217410
|
+
}
|
|
217411
|
+
async function handleDescribeInstanceSlowQueries(args, context) {
|
|
217412
|
+
const ready = await requireReadyMysqlInstance(args, context);
|
|
217413
|
+
if (!ready.ok) {
|
|
217414
|
+
return ready.payload;
|
|
217415
|
+
}
|
|
217416
|
+
const request = args.request || {};
|
|
217417
|
+
const cloudbase = await context.getManager();
|
|
217418
|
+
const result = await cloudbase.mysql.describeInstanceSlowQueries({
|
|
217419
|
+
InstanceId: ready.instanceId,
|
|
217420
|
+
StartTime: (typeof request.StartTime === "string" ? request.StartTime : undefined) ??
|
|
217421
|
+
args.startTime,
|
|
217422
|
+
EndTime: (typeof request.EndTime === "string" ? request.EndTime : undefined) ??
|
|
217423
|
+
args.endTime,
|
|
217424
|
+
Limit: (typeof request.Limit === "number" ? request.Limit : undefined) ??
|
|
217425
|
+
args.limit,
|
|
217426
|
+
Offset: (typeof request.Offset === "number" ? request.Offset : undefined) ??
|
|
217427
|
+
args.offset,
|
|
217428
|
+
Username: (typeof request.Username === "string" ? request.Username : undefined) ??
|
|
217429
|
+
args.username,
|
|
217430
|
+
Host: (typeof request.Host === "string" ? request.Host : undefined) ??
|
|
217431
|
+
args.host,
|
|
217432
|
+
Database: (typeof request.Database === "string" ? request.Database : undefined) ??
|
|
217433
|
+
args.database,
|
|
217434
|
+
OrderBy: (typeof request.OrderBy === "string" ? request.OrderBy : undefined) ??
|
|
217435
|
+
args.orderBy,
|
|
217436
|
+
OrderByType: (typeof request.OrderByType === "string"
|
|
217437
|
+
? request.OrderByType
|
|
217438
|
+
: undefined) ?? args.orderByType,
|
|
217439
|
+
SqlText: (typeof request.SqlText === "string" ? request.SqlText : undefined) ??
|
|
217440
|
+
args.sqlText,
|
|
217441
|
+
});
|
|
217442
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
|
|
217443
|
+
return buildSqlToolResult({
|
|
217444
|
+
success: true,
|
|
217445
|
+
data: {
|
|
217446
|
+
action: "describeInstanceSlowQueries",
|
|
217447
|
+
instanceId: ready.instanceId,
|
|
217448
|
+
totalCount: result.TotalCount ?? 0,
|
|
217449
|
+
slowQueries: result.SlowQueries ?? [],
|
|
217450
|
+
requestId: result.RequestId,
|
|
217451
|
+
raw: result,
|
|
217452
|
+
},
|
|
217453
|
+
message: (0, index_js_1.t)("databaseSQL.instanceLogs.slowQueriesSuccess"),
|
|
217454
|
+
});
|
|
217455
|
+
}
|
|
217456
|
+
async function handleDescribeInstanceErrorLogs(args, context) {
|
|
217457
|
+
const ready = await requireReadyMysqlInstance(args, context);
|
|
217458
|
+
if (!ready.ok) {
|
|
217459
|
+
return ready.payload;
|
|
217460
|
+
}
|
|
217461
|
+
const request = args.request || {};
|
|
217462
|
+
const cloudbase = await context.getManager();
|
|
217463
|
+
const result = await cloudbase.mysql.describeInstanceErrorLogs({
|
|
217464
|
+
InstanceId: ready.instanceId,
|
|
217465
|
+
Limit: (typeof request.Limit === "number" ? request.Limit : undefined) ??
|
|
217466
|
+
args.limit,
|
|
217467
|
+
Offset: (typeof request.Offset === "number" ? request.Offset : undefined) ??
|
|
217468
|
+
args.offset,
|
|
217469
|
+
StartTime: (typeof request.StartTime === "string" ? request.StartTime : undefined) ??
|
|
217470
|
+
args.startTime,
|
|
217471
|
+
EndTime: (typeof request.EndTime === "string" ? request.EndTime : undefined) ??
|
|
217472
|
+
args.endTime,
|
|
217473
|
+
OrderBy: (typeof request.OrderBy === "string" ? request.OrderBy : undefined) ??
|
|
217474
|
+
(args.orderBy === "Timestamp" ? args.orderBy : undefined),
|
|
217475
|
+
OrderByType: (typeof request.OrderByType === "string"
|
|
217476
|
+
? request.OrderByType
|
|
217477
|
+
: undefined) ?? args.orderByType,
|
|
217478
|
+
LogLevels: (Array.isArray(request.LogLevels)
|
|
217479
|
+
? request.LogLevels
|
|
217480
|
+
: undefined) ?? args.logLevels,
|
|
217481
|
+
KeyWords: (Array.isArray(request.KeyWords)
|
|
217482
|
+
? request.KeyWords
|
|
217483
|
+
: undefined) ?? args.keyWords,
|
|
217484
|
+
});
|
|
217485
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(context.server.logger, result);
|
|
217486
|
+
return buildSqlToolResult({
|
|
217487
|
+
success: true,
|
|
217488
|
+
data: {
|
|
217489
|
+
action: "describeInstanceErrorLogs",
|
|
217490
|
+
instanceId: ready.instanceId,
|
|
217491
|
+
totalCount: result.TotalCount ?? 0,
|
|
217492
|
+
errorLogs: result.ErrorLogs ?? [],
|
|
217493
|
+
requestId: result.RequestId,
|
|
217494
|
+
raw: result,
|
|
217495
|
+
},
|
|
217496
|
+
message: (0, index_js_1.t)("databaseSQL.instanceLogs.errorLogsSuccess"),
|
|
217497
|
+
});
|
|
217498
|
+
}
|
|
217116
217499
|
async function handleProvisionMySQL(args, context) {
|
|
217117
217500
|
if (args.confirm !== true) {
|
|
217118
217501
|
return buildSqlToolResult({
|
|
@@ -217483,6 +217866,54 @@ function registerSQLDatabaseTools(server) {
|
|
|
217483
217866
|
})
|
|
217484
217867
|
.optional()
|
|
217485
217868
|
.describe("databaseSQL.schema.query.dbInstance"),
|
|
217869
|
+
startTime: zod_1.z
|
|
217870
|
+
.string()
|
|
217871
|
+
.optional()
|
|
217872
|
+
.describe("databaseSQL.schema.query.startTime"),
|
|
217873
|
+
endTime: zod_1.z
|
|
217874
|
+
.string()
|
|
217875
|
+
.optional()
|
|
217876
|
+
.describe("databaseSQL.schema.query.endTime"),
|
|
217877
|
+
limit: zod_1.z
|
|
217878
|
+
.number()
|
|
217879
|
+
.optional()
|
|
217880
|
+
.describe("databaseSQL.schema.query.limit"),
|
|
217881
|
+
offset: zod_1.z
|
|
217882
|
+
.number()
|
|
217883
|
+
.optional()
|
|
217884
|
+
.describe("databaseSQL.schema.query.offset"),
|
|
217885
|
+
username: zod_1.z
|
|
217886
|
+
.string()
|
|
217887
|
+
.optional()
|
|
217888
|
+
.describe("databaseSQL.schema.query.username"),
|
|
217889
|
+
host: zod_1.z
|
|
217890
|
+
.string()
|
|
217891
|
+
.optional()
|
|
217892
|
+
.describe("databaseSQL.schema.query.host"),
|
|
217893
|
+
database: zod_1.z
|
|
217894
|
+
.string()
|
|
217895
|
+
.optional()
|
|
217896
|
+
.describe("databaseSQL.schema.query.database"),
|
|
217897
|
+
orderBy: zod_1.z
|
|
217898
|
+
.enum([...SLOW_QUERY_ORDER_BY, "Timestamp"])
|
|
217899
|
+
.optional()
|
|
217900
|
+
.describe("databaseSQL.schema.query.orderBy"),
|
|
217901
|
+
orderByType: zod_1.z
|
|
217902
|
+
.enum(ORDER_BY_TYPE)
|
|
217903
|
+
.optional()
|
|
217904
|
+
.describe("databaseSQL.schema.query.orderByType"),
|
|
217905
|
+
sqlText: zod_1.z
|
|
217906
|
+
.string()
|
|
217907
|
+
.optional()
|
|
217908
|
+
.describe("databaseSQL.schema.query.sqlText"),
|
|
217909
|
+
logLevels: zod_1.z
|
|
217910
|
+
.array(zod_1.z.enum(ERROR_LOG_LEVELS))
|
|
217911
|
+
.optional()
|
|
217912
|
+
.describe("databaseSQL.schema.query.logLevels"),
|
|
217913
|
+
keyWords: zod_1.z
|
|
217914
|
+
.array(zod_1.z.string())
|
|
217915
|
+
.optional()
|
|
217916
|
+
.describe("databaseSQL.schema.query.keyWords"),
|
|
217486
217917
|
},
|
|
217487
217918
|
annotations: {
|
|
217488
217919
|
readOnlyHint: true,
|
|
@@ -217506,6 +217937,10 @@ function registerSQLDatabaseTools(server) {
|
|
|
217506
217937
|
return handleGetInstanceInfo(context);
|
|
217507
217938
|
case "getConnectionInfo":
|
|
217508
217939
|
return handleGetConnectionInfo(context);
|
|
217940
|
+
case "describeInstanceSlowQueries":
|
|
217941
|
+
return handleDescribeInstanceSlowQueries(args, context);
|
|
217942
|
+
case "describeInstanceErrorLogs":
|
|
217943
|
+
return handleDescribeInstanceErrorLogs(args, context);
|
|
217509
217944
|
default:
|
|
217510
217945
|
throw new Error((0, index_js_1.t)("databaseSQL.unsupportedQueryAction", { action: args.action }));
|
|
217511
217946
|
}
|
|
@@ -217603,6 +218038,7 @@ const zod_1 = __webpack_require__(21504);
|
|
|
217603
218038
|
const cloudbase_manager_js_1 = __webpack_require__(33109);
|
|
217604
218039
|
const index_js_1 = __webpack_require__(24908);
|
|
217605
218040
|
const json_content_js_1 = __webpack_require__(18027);
|
|
218041
|
+
const project_config_js_1 = __webpack_require__(39175);
|
|
217606
218042
|
const sql_risk_js_1 = __webpack_require__(29885);
|
|
217607
218043
|
const hosting_build_utils_js_1 = __webpack_require__(27572);
|
|
217608
218044
|
// 声明式部署可编排的资源类型,与 DeployOrchestrator 的部署顺序一致:
|
|
@@ -217867,7 +218303,7 @@ function registerDeployTools(server) {
|
|
|
217867
218303
|
},
|
|
217868
218304
|
}, async ({ cwd, mode }) => {
|
|
217869
218305
|
try {
|
|
217870
|
-
const projectRoot =
|
|
218306
|
+
const projectRoot = (0, project_config_js_1.requireProjectRoot)(cwd);
|
|
217871
218307
|
const config = await resolveDeployConfig({ cwd: projectRoot, mode });
|
|
217872
218308
|
assertConfigValid(config);
|
|
217873
218309
|
const hostingItems = Array.isArray(config.hosting)
|
|
@@ -217939,7 +218375,7 @@ function registerDeployTools(server) {
|
|
|
217939
218375
|
},
|
|
217940
218376
|
}, async ({ cwd, mode, envId: envIdInput, only, skip, yes, }) => {
|
|
217941
218377
|
try {
|
|
217942
|
-
const projectRoot =
|
|
218378
|
+
const projectRoot = (0, project_config_js_1.requireProjectRoot)(cwd);
|
|
217943
218379
|
const config = await resolveDeployConfig({ cwd: projectRoot, mode });
|
|
217944
218380
|
assertConfigValid(config);
|
|
217945
218381
|
const envId = await resolveDeployEnvId({
|
|
@@ -218023,7 +218459,7 @@ function registerDeployTools(server) {
|
|
|
218023
218459
|
if (confirm !== true) {
|
|
218024
218460
|
throw new DeployError(exports.DEPLOY_ERROR_CODES.CONFIRM_REQUIRED, (0, index_js_1.t)("deploy.confirmRequired"));
|
|
218025
218461
|
}
|
|
218026
|
-
const projectRoot =
|
|
218462
|
+
const projectRoot = (0, project_config_js_1.requireProjectRoot)(cwd);
|
|
218027
218463
|
const config = await resolveDeployConfig({ cwd: projectRoot, mode });
|
|
218028
218464
|
assertConfigValid(config);
|
|
218029
218465
|
const envId = await resolveDeployEnvId({
|
|
@@ -221001,6 +221437,7 @@ function registerEnvTools(server) {
|
|
|
221001
221437
|
typeof cloudBaseOptions?.envId === "string" &&
|
|
221002
221438
|
cloudBaseOptions.envId.length > 0;
|
|
221003
221439
|
const envIdFromEnv = !cloudBaseOptions?.requestFn &&
|
|
221440
|
+
!process.env.CLOUDBASE_LOCAL_ENDPOINT &&
|
|
221004
221441
|
(process.env.CLOUDBASE_ENV_ID ||
|
|
221005
221442
|
(isEnvScopedCredential ? cloudBaseOptions.envId : undefined));
|
|
221006
221443
|
const shouldPinToEnvVar = Boolean(envIdFromEnv &&
|
|
@@ -221960,6 +222397,512 @@ function registerEnvTools(server) {
|
|
|
221960
222397
|
}
|
|
221961
222398
|
|
|
221962
222399
|
|
|
222400
|
+
/***/ },
|
|
222401
|
+
|
|
222402
|
+
/***/ 6332
|
|
222403
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
222404
|
+
|
|
222405
|
+
"use strict";
|
|
222406
|
+
|
|
222407
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
222408
|
+
exports.FEEDBACK_PREFILL_URL_LIMIT = exports.FEEDBACK_ISSUE_NEW_URL = exports.FEEDBACK_TOOL_NAME = void 0;
|
|
222409
|
+
exports.resolveMcpVersion = resolveMcpVersion;
|
|
222410
|
+
exports.buildFeedbackIssueUrl = buildFeedbackIssueUrl;
|
|
222411
|
+
exports.buildFeedbackIssueLink = buildFeedbackIssueLink;
|
|
222412
|
+
exports.buildFeedbackPayload = buildFeedbackPayload;
|
|
222413
|
+
exports.registerFeedbackTools = registerFeedbackTools;
|
|
222414
|
+
const zod_1 = __webpack_require__(21504);
|
|
222415
|
+
const feedback_session_js_1 = __webpack_require__(23379);
|
|
222416
|
+
const json_content_js_1 = __webpack_require__(18027);
|
|
222417
|
+
const site_map_js_1 = __webpack_require__(34533);
|
|
222418
|
+
/**
|
|
222419
|
+
* Not a CloudBase resource, so this does not use the query* / manage* pair.
|
|
222420
|
+
* The feedback plugin is in the default set and always registers this tool.
|
|
222421
|
+
*/
|
|
222422
|
+
exports.FEEDBACK_TOOL_NAME = "prepareFeedback";
|
|
222423
|
+
const CASE_TEMPLATE_FILE = "1-case-showcase.yml";
|
|
222424
|
+
const RETROSPECTIVE_TEMPLATE_FILE = "2-dev-retrospective.yml";
|
|
222425
|
+
/** Fixed new-issue pages. Intl uses GitHub. Domestic uses the CNB CloudBase-AI-ToolKit repo. */
|
|
222426
|
+
exports.FEEDBACK_ISSUE_NEW_URL = {
|
|
222427
|
+
intl: "https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/issues/new",
|
|
222428
|
+
domestic: "https://cnb.cool/tencent/cloud/cloudbase/CloudBase-AI-ToolKit/-/issues/new",
|
|
222429
|
+
};
|
|
222430
|
+
const RESOURCE_BY_TOOL = {
|
|
222431
|
+
queryHosting: { zh: "静态托管", en: "Static hosting" },
|
|
222432
|
+
manageHosting: { zh: "静态托管", en: "Static hosting" },
|
|
222433
|
+
readNoSqlDatabaseStructure: { zh: "云数据库(文档型)", en: "Document database" },
|
|
222434
|
+
writeNoSqlDatabaseStructure: { zh: "云数据库(文档型)", en: "Document database" },
|
|
222435
|
+
readNoSqlDatabaseContent: { zh: "云数据库(文档型)", en: "Document database" },
|
|
222436
|
+
writeNoSqlDatabaseContent: { zh: "云数据库(文档型)", en: "Document database" },
|
|
222437
|
+
queryMysqlDatabase: { zh: "云数据库(MySQL)", en: "MySQL" },
|
|
222438
|
+
manageMysqlDatabase: { zh: "云数据库(MySQL)", en: "MySQL" },
|
|
222439
|
+
queryPgDatabase: { zh: "云数据库(PostgreSQL)", en: "PostgreSQL" },
|
|
222440
|
+
managePgDatabase: { zh: "云数据库(PostgreSQL)", en: "PostgreSQL" },
|
|
222441
|
+
queryFunctions: { zh: "云函数", en: "Cloud functions" },
|
|
222442
|
+
manageFunctions: { zh: "云函数", en: "Cloud functions" },
|
|
222443
|
+
queryStorage: { zh: "云存储", en: "Cloud storage" },
|
|
222444
|
+
manageStorage: { zh: "云存储", en: "Cloud storage" },
|
|
222445
|
+
queryPgStorage: { zh: "云存储", en: "Cloud storage" },
|
|
222446
|
+
queryAppAuth: { zh: "身份认证", en: "Auth" },
|
|
222447
|
+
manageAppAuth: { zh: "身份认证", en: "Auth" },
|
|
222448
|
+
queryCloudRun: { zh: "CloudRun", en: "CloudRun" },
|
|
222449
|
+
manageCloudRun: { zh: "CloudRun", en: "CloudRun" },
|
|
222450
|
+
};
|
|
222451
|
+
/** Stay under common browser and proxy URL limits. Longer drafts are pasted by the user. */
|
|
222452
|
+
exports.FEEDBACK_PREFILL_URL_LIMIT = 6000;
|
|
222453
|
+
function resolveMcpVersion(declared, packageVersion) {
|
|
222454
|
+
const fromBuild = typeof declared === "string" ? declared.trim() : "";
|
|
222455
|
+
if (fromBuild) {
|
|
222456
|
+
return fromBuild;
|
|
222457
|
+
}
|
|
222458
|
+
const fromPackage = typeof packageVersion === "string" ? packageVersion.trim() : "";
|
|
222459
|
+
return fromPackage;
|
|
222460
|
+
}
|
|
222461
|
+
function readDeclaredMcpVersion() {
|
|
222462
|
+
return true ? "2.34.8" : 0;
|
|
222463
|
+
}
|
|
222464
|
+
function blank(value, lang) {
|
|
222465
|
+
return value.trim().length > 0 ? value.trim() : (lang === "en" ? "blank" : "留空");
|
|
222466
|
+
}
|
|
222467
|
+
function feedbackSite(server) {
|
|
222468
|
+
return (0, site_map_js_1.resolveSiteAndRegion)({
|
|
222469
|
+
site: server.cloudBaseOptions?.site,
|
|
222470
|
+
region: server.cloudBaseOptions?.region,
|
|
222471
|
+
}).site;
|
|
222472
|
+
}
|
|
222473
|
+
function feedbackLang(site) {
|
|
222474
|
+
return site === "intl" ? "en" : "zh";
|
|
222475
|
+
}
|
|
222476
|
+
function uniqueJoin(parts) {
|
|
222477
|
+
const seen = new Set();
|
|
222478
|
+
const ordered = [];
|
|
222479
|
+
for (const part of parts) {
|
|
222480
|
+
const trimmed = part.trim();
|
|
222481
|
+
if (!trimmed || seen.has(trimmed)) {
|
|
222482
|
+
continue;
|
|
222483
|
+
}
|
|
222484
|
+
seen.add(trimmed);
|
|
222485
|
+
ordered.push(trimmed);
|
|
222486
|
+
}
|
|
222487
|
+
return ordered.join(" / ");
|
|
222488
|
+
}
|
|
222489
|
+
function readAgentLabel(server) {
|
|
222490
|
+
const ide = server.ide || process.env.INTEGRATION_IDE || "";
|
|
222491
|
+
const client = server.client || process.env.CLOUDBASE_MCP_CLIENT || "";
|
|
222492
|
+
return uniqueJoin([ide, client]);
|
|
222493
|
+
}
|
|
222494
|
+
function toLocalIso(iso) {
|
|
222495
|
+
const date = new Date(iso);
|
|
222496
|
+
if (Number.isNaN(date.getTime())) {
|
|
222497
|
+
return "";
|
|
222498
|
+
}
|
|
222499
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
222500
|
+
const offsetMinutes = -date.getTimezoneOffset();
|
|
222501
|
+
const sign = offsetMinutes >= 0 ? "+" : "-";
|
|
222502
|
+
const absolute = Math.abs(offsetMinutes);
|
|
222503
|
+
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}` +
|
|
222504
|
+
`T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}` +
|
|
222505
|
+
`${sign}${pad(Math.floor(absolute / 60))}:${pad(absolute % 60)}`);
|
|
222506
|
+
}
|
|
222507
|
+
function resourceTypesFrom(outcomes, lang) {
|
|
222508
|
+
const seen = new Set();
|
|
222509
|
+
const types = [];
|
|
222510
|
+
for (const outcome of outcomes) {
|
|
222511
|
+
if (outcome.failed) {
|
|
222512
|
+
continue;
|
|
222513
|
+
}
|
|
222514
|
+
const resourceType = RESOURCE_BY_TOOL[outcome.toolName]?.[lang];
|
|
222515
|
+
if (!resourceType || seen.has(resourceType)) {
|
|
222516
|
+
continue;
|
|
222517
|
+
}
|
|
222518
|
+
seen.add(resourceType);
|
|
222519
|
+
types.push(resourceType);
|
|
222520
|
+
}
|
|
222521
|
+
return types;
|
|
222522
|
+
}
|
|
222523
|
+
function formatDeployDuration(outcomes, lang) {
|
|
222524
|
+
const build = outcomes.filter((item) => !item.failed && item.toolName === "deployBuild");
|
|
222525
|
+
const apply = outcomes.filter((item) => !item.failed && item.toolName === "deployApply");
|
|
222526
|
+
if (build.length === 0 && apply.length === 0) {
|
|
222527
|
+
return "";
|
|
222528
|
+
}
|
|
222529
|
+
const sum = (items) => items.reduce((total, item) => total + item.durationMs, 0);
|
|
222530
|
+
const parts = [];
|
|
222531
|
+
if (build.length > 0) {
|
|
222532
|
+
parts.push(`deployBuild ${sum(build)}ms`);
|
|
222533
|
+
}
|
|
222534
|
+
if (apply.length > 0) {
|
|
222535
|
+
parts.push(`deployApply ${sum(apply)}ms`);
|
|
222536
|
+
}
|
|
222537
|
+
const joined = parts.join(lang === "en" ? "; " : ";");
|
|
222538
|
+
return lang === "en"
|
|
222539
|
+
? `${joined}. Cloud build time and end-to-end time cannot be separated from these tool names.`
|
|
222540
|
+
: `${joined}。无法区分云端构建与端到端,只记录上述工具耗时,未补另一项`;
|
|
222541
|
+
}
|
|
222542
|
+
function latestDeployTime(outcomes) {
|
|
222543
|
+
const deployOutcomes = outcomes.filter((item) => !item.failed && (item.toolName === "deployBuild" || item.toolName === "deployApply"));
|
|
222544
|
+
if (deployOutcomes.length === 0) {
|
|
222545
|
+
return "";
|
|
222546
|
+
}
|
|
222547
|
+
const latest = deployOutcomes.reduce((current, item) => (item.at > current.at ? item : current));
|
|
222548
|
+
return toLocalIso(latest.at);
|
|
222549
|
+
}
|
|
222550
|
+
function failureLines(server, outcomes, lang) {
|
|
222551
|
+
const counts = new Map();
|
|
222552
|
+
for (const outcome of outcomes) {
|
|
222553
|
+
if (!outcome.failed) {
|
|
222554
|
+
continue;
|
|
222555
|
+
}
|
|
222556
|
+
counts.set(outcome.toolName, (counts.get(outcome.toolName) ?? 0) + 1);
|
|
222557
|
+
}
|
|
222558
|
+
const lines = [];
|
|
222559
|
+
for (const [toolName, count] of counts) {
|
|
222560
|
+
lines.push(lang === "en"
|
|
222561
|
+
? `- Verified: tool call failed ${toolName} ×${count}`
|
|
222562
|
+
: `- 可验证事实:工具调用失败 ${toolName} ×${count}`);
|
|
222563
|
+
}
|
|
222564
|
+
const repeatPeak = (0, feedback_session_js_1.readRepeatPeak)(server);
|
|
222565
|
+
if (repeatPeak > 0) {
|
|
222566
|
+
lines.push(lang === "en"
|
|
222567
|
+
? `- Verified: peak consecutive identical structured errors ${repeatPeak}`
|
|
222568
|
+
: `- 可验证事实:连续相同结构化错误峰值 ${repeatPeak}`);
|
|
222569
|
+
}
|
|
222570
|
+
return lines;
|
|
222571
|
+
}
|
|
222572
|
+
function collectSecretValues(server) {
|
|
222573
|
+
const options = server.cloudBaseOptions;
|
|
222574
|
+
return [options?.envId, options?.secretId, options?.secretKey, options?.token].filter((value) => typeof value === "string" && value.trim().length >= 6);
|
|
222575
|
+
}
|
|
222576
|
+
function redact(text, secrets) {
|
|
222577
|
+
let redacted = text;
|
|
222578
|
+
for (const secret of secrets) {
|
|
222579
|
+
redacted = redacted.split(secret).join("");
|
|
222580
|
+
}
|
|
222581
|
+
return redacted;
|
|
222582
|
+
}
|
|
222583
|
+
function buildCaseDraft(server, outcomes, lang) {
|
|
222584
|
+
const resources = resourceTypesFrom(outcomes, lang);
|
|
222585
|
+
const empty = blank("", lang);
|
|
222586
|
+
const resourceText = resources.length > 0 ? resources.join(lang === "en" ? ", " : "、") : empty;
|
|
222587
|
+
const version = blank(resolveMcpVersion(readDeclaredMcpVersion(), process.env.npm_package_version), lang);
|
|
222588
|
+
if (lang === "en") {
|
|
222589
|
+
return [
|
|
222590
|
+
"This issue will be public. Do not add an environment ID, secrets, or user data.",
|
|
222591
|
+
`Work name: ${empty}`,
|
|
222592
|
+
`One-line summary: ${empty}`,
|
|
222593
|
+
`Public URL: ${empty}`,
|
|
222594
|
+
`Cover / screenshot: ${empty}`,
|
|
222595
|
+
`Agent / CLI: ${blank(readAgentLabel(server), lang)}`,
|
|
222596
|
+
`Model: ${empty}`,
|
|
222597
|
+
`MCP version: ${version}`,
|
|
222598
|
+
`Deploy duration: ${blank(formatDeployDuration(outcomes, lang), lang)}`,
|
|
222599
|
+
`Cloud resources: ${resourceText}`,
|
|
222600
|
+
`Deploy time: ${blank(latestDeployTime(outcomes), lang)}`,
|
|
222601
|
+
`Author: ${empty}`,
|
|
222602
|
+
`Pitfalls: ${empty}`,
|
|
222603
|
+
`Other notes: ${empty}`,
|
|
222604
|
+
].join("\n");
|
|
222605
|
+
}
|
|
222606
|
+
return [
|
|
222607
|
+
"这条 Issue 会公开。不要补充环境 ID、密钥或用户数据。",
|
|
222608
|
+
`作品名称:${empty}`,
|
|
222609
|
+
`一句话简介:${empty}`,
|
|
222610
|
+
`公网访问地址:${empty}`,
|
|
222611
|
+
`封面 / 截图地址:${empty}`,
|
|
222612
|
+
`Agent / CLI:${blank(readAgentLabel(server), lang)}`,
|
|
222613
|
+
`所用模型:${empty}`,
|
|
222614
|
+
`MCP 版本:${version}`,
|
|
222615
|
+
`部署耗时:${blank(formatDeployDuration(outcomes, lang), lang)}`,
|
|
222616
|
+
`用到的云资源:${resourceText}`,
|
|
222617
|
+
`部署时间:${blank(latestDeployTime(outcomes), lang)}`,
|
|
222618
|
+
`作者署名 / 主页:${empty}`,
|
|
222619
|
+
`开发过程中踩到的坑:${empty}`,
|
|
222620
|
+
`其他补充:${empty}`,
|
|
222621
|
+
].join("\n");
|
|
222622
|
+
}
|
|
222623
|
+
function buildRetrospectiveDraft(server, outcomes, lang) {
|
|
222624
|
+
const resources = resourceTypesFrom(outcomes, lang);
|
|
222625
|
+
const failures = failureLines(server, outcomes, lang);
|
|
222626
|
+
const empty = blank("", lang);
|
|
222627
|
+
if (lang === "en") {
|
|
222628
|
+
const failureBlock = failures.length > 0
|
|
222629
|
+
? failures.join("\n")
|
|
222630
|
+
: "No tool failures recorded in this session.";
|
|
222631
|
+
const resourceBlock = resources.length > 0
|
|
222632
|
+
? resources.join(", ")
|
|
222633
|
+
: empty;
|
|
222634
|
+
return [
|
|
222635
|
+
"This issue will be public. Do not add an environment ID, secrets, collection names, or function names.",
|
|
222636
|
+
"Conversation turns are not collected. Do not invent a turn count.",
|
|
222637
|
+
"",
|
|
222638
|
+
"Tool failures:",
|
|
222639
|
+
failureBlock,
|
|
222640
|
+
"",
|
|
222641
|
+
"Cloud resources:",
|
|
222642
|
+
resourceBlock,
|
|
222643
|
+
].join("\n");
|
|
222644
|
+
}
|
|
222645
|
+
const failureBlock = failures.length > 0
|
|
222646
|
+
? failures.join("\n")
|
|
222647
|
+
: "本次会话没有记录到工具失败。";
|
|
222648
|
+
const resourceBlock = resources.length > 0
|
|
222649
|
+
? resources.join("、")
|
|
222650
|
+
: empty;
|
|
222651
|
+
return [
|
|
222652
|
+
"这条 Issue 会公开。不要补充环境 ID、密钥、集合名或函数名。",
|
|
222653
|
+
"不采集对话轮次。不要把失败次数写成轮次,也不要补一个数字。",
|
|
222654
|
+
"",
|
|
222655
|
+
"工具失败:",
|
|
222656
|
+
failureBlock,
|
|
222657
|
+
"",
|
|
222658
|
+
"云资源:",
|
|
222659
|
+
resourceBlock,
|
|
222660
|
+
].join("\n");
|
|
222661
|
+
}
|
|
222662
|
+
function buildFeedbackIssueUrl(site, channel, draft) {
|
|
222663
|
+
return buildFeedbackIssueLink(site, channel, draft).url;
|
|
222664
|
+
}
|
|
222665
|
+
function buildFeedbackIssueLink(site, channel, draft) {
|
|
222666
|
+
const title = site === "intl"
|
|
222667
|
+
? (channel === "case" ? "[case] " : "[retrospective] ")
|
|
222668
|
+
: (channel === "case" ? "[案例] " : "[复盘] ");
|
|
222669
|
+
const base = exports.FEEDBACK_ISSUE_NEW_URL[site];
|
|
222670
|
+
const draftQuery = site === "intl"
|
|
222671
|
+
? `body=${encodeURIComponent(draft)}`
|
|
222672
|
+
: `session=${encodeURIComponent(draft)}`;
|
|
222673
|
+
const head = site === "intl"
|
|
222674
|
+
? `${base}?title=${encodeURIComponent(title)}`
|
|
222675
|
+
: `${base}?template=${encodeURIComponent(channel === "case" ? CASE_TEMPLATE_FILE : RETROSPECTIVE_TEMPLATE_FILE)}&title=${encodeURIComponent(title)}`;
|
|
222676
|
+
const prefilled = `${head}&${draftQuery}`;
|
|
222677
|
+
if (prefilled.length <= exports.FEEDBACK_PREFILL_URL_LIMIT) {
|
|
222678
|
+
return { url: prefilled, prefilled: true };
|
|
222679
|
+
}
|
|
222680
|
+
return { url: head, prefilled: false };
|
|
222681
|
+
}
|
|
222682
|
+
function buildFeedbackPayload(input) {
|
|
222683
|
+
const site = feedbackSite(input.server);
|
|
222684
|
+
const lang = feedbackLang(site);
|
|
222685
|
+
const outcomes = (0, feedback_session_js_1.readToolOutcomes)(input.server);
|
|
222686
|
+
const secrets = collectSecretValues(input.server);
|
|
222687
|
+
const draft = redact(input.channel === "case"
|
|
222688
|
+
? buildCaseDraft(input.server, outcomes, lang)
|
|
222689
|
+
: buildRetrospectiveDraft(input.server, outcomes, lang), secrets);
|
|
222690
|
+
if (!input.confirmed) {
|
|
222691
|
+
return {
|
|
222692
|
+
success: true,
|
|
222693
|
+
channel: input.channel,
|
|
222694
|
+
confirmed: false,
|
|
222695
|
+
submittable: false,
|
|
222696
|
+
draft,
|
|
222697
|
+
nextStep: lang === "en"
|
|
222698
|
+
? "Show this draft to the user unchanged. Do not give a submission link before they explicitly confirm. Do not rewrite it into a different write-up."
|
|
222699
|
+
: "把这份 draft 原样给用户看。用户明确确认之前,不要给出提交链接,也不要改写成另一份说明。",
|
|
222700
|
+
};
|
|
222701
|
+
}
|
|
222702
|
+
const link = buildFeedbackIssueLink(site, input.channel, draft);
|
|
222703
|
+
const pasteHint = link.prefilled
|
|
222704
|
+
? ""
|
|
222705
|
+
: (lang === "en"
|
|
222706
|
+
? " The link does not include the draft because the URL would be too long. Paste the draft into the session field."
|
|
222707
|
+
: " 链接没有带上正文,因为地址过长。请把 draft 粘贴到「本次会话记录」。");
|
|
222708
|
+
return {
|
|
222709
|
+
success: true,
|
|
222710
|
+
channel: input.channel,
|
|
222711
|
+
confirmed: true,
|
|
222712
|
+
submittable: true,
|
|
222713
|
+
draft,
|
|
222714
|
+
url: link.url,
|
|
222715
|
+
nextStep: (lang === "en"
|
|
222716
|
+
? "The user confirmed. The link body is this draft. Do not submit a rewritten version, and do not submit it for them."
|
|
222717
|
+
: "用户已确认。链接里的正文就是这份 draft。不要另写一版再提交,也不要代为提交。") + pasteHint,
|
|
222718
|
+
};
|
|
222719
|
+
}
|
|
222720
|
+
function registerFeedbackTools(server) {
|
|
222721
|
+
server.registerTool(exports.FEEDBACK_TOOL_NAME, {
|
|
222722
|
+
title: "feedback.title",
|
|
222723
|
+
description: "feedback.description",
|
|
222724
|
+
inputSchema: {
|
|
222725
|
+
channel: zod_1.z
|
|
222726
|
+
.enum(["case", "retrospective"])
|
|
222727
|
+
.describe("feedback.schema.channel"),
|
|
222728
|
+
confirmed: zod_1.z
|
|
222729
|
+
.boolean()
|
|
222730
|
+
.optional()
|
|
222731
|
+
.describe("feedback.schema.confirmed"),
|
|
222732
|
+
},
|
|
222733
|
+
annotations: {
|
|
222734
|
+
readOnlyHint: true,
|
|
222735
|
+
destructiveHint: false,
|
|
222736
|
+
openWorldHint: false,
|
|
222737
|
+
category: "feedback",
|
|
222738
|
+
},
|
|
222739
|
+
}, async ({ channel, confirmed }) => {
|
|
222740
|
+
return (0, json_content_js_1.jsonContent)(buildFeedbackPayload({
|
|
222741
|
+
server,
|
|
222742
|
+
channel,
|
|
222743
|
+
confirmed: confirmed === true,
|
|
222744
|
+
}));
|
|
222745
|
+
});
|
|
222746
|
+
}
|
|
222747
|
+
|
|
222748
|
+
|
|
222749
|
+
/***/ },
|
|
222750
|
+
|
|
222751
|
+
/***/ 65735
|
|
222752
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
222753
|
+
|
|
222754
|
+
"use strict";
|
|
222755
|
+
|
|
222756
|
+
/**
|
|
222757
|
+
* 云函数 ZIP 两段式部署·阶段 A:生成 COS 预签名上传地址。
|
|
222758
|
+
*
|
|
222759
|
+
* 通道来源(R1 探针实测裁决,见 output/2026-09-23-functions-zip-two-phase-design.md §4):
|
|
222760
|
+
* - DescribeBuildServiceCosInfo / build-service 上传 / GetTempCosInfo 三条通道全部判死
|
|
222761
|
+
* (CosTimestamp 稳定 InternalError;SCF 拉代码强制给桶名拼 -appid 后缀,共享 build 桶
|
|
222762
|
+
* 永远拉不到;tempcos 桶全 region 404)。
|
|
222763
|
+
* - 活通道:用环境自有存储桶(DescribeEnvs → Storages[0].Bucket/Region)+ 用户凭据
|
|
222764
|
+
* 本地铸 COS q-sign 预签名 PUT URL。CloudBase 临时凭据可直接用于 COS(manager-node
|
|
222765
|
+
* storage 同款 SecretId+SecretKey+token 范式),但必须把 x-cos-security-token 纳入
|
|
222766
|
+
* 签名 Headers 且请求时携带同名头。
|
|
222767
|
+
*
|
|
222768
|
+
* 设计约束:
|
|
222769
|
+
* - 纯函数、零第三方依赖(node:crypto 即可):签名算法从 cos-nodejs-sdk-v5 getAuth
|
|
222770
|
+
* 逐行复刻,测试里与 SDK 真实现做黄金值对照,防止复刻漂移。
|
|
222771
|
+
* - 预签名是本地 HMAC 计算:CAM 零新增权限、不暴露 appId(URL 用全桶名,阶段 B 回传
|
|
222772
|
+
* TCB 的 CosBucketName 用短名)、国际站天然可用。
|
|
222773
|
+
*/
|
|
222774
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
222775
|
+
exports.stripAppIdSuffix = stripAppIdSuffix;
|
|
222776
|
+
exports.camSafeUrlEncode = camSafeUrlEncode;
|
|
222777
|
+
exports.buildCosPutAuthorization = buildCosPutAuthorization;
|
|
222778
|
+
exports.buildFunctionZipUpload = buildFunctionZipUpload;
|
|
222779
|
+
const crypto_1 = __webpack_require__(55511);
|
|
222780
|
+
/** 环境存储桶全名形如 `mybucket-1258016615`;TCB CosBucketName 只收短名(不带 -appid 后缀)。 */
|
|
222781
|
+
function stripAppIdSuffix(bucket) {
|
|
222782
|
+
return bucket.replace(/-\d+$/, "");
|
|
222783
|
+
}
|
|
222784
|
+
/** 复刻 cos-nodejs-sdk-v5 util.camSafeUrlEncode:encodeURIComponent 强制编码 !'()* 五个字符。 */
|
|
222785
|
+
function camSafeUrlEncode(str) {
|
|
222786
|
+
return encodeURIComponent(str)
|
|
222787
|
+
.replace(/!/g, "%21")
|
|
222788
|
+
.replace(/'/g, "%27")
|
|
222789
|
+
.replace(/\(/g, "%28")
|
|
222790
|
+
.replace(/\)/g, "%29")
|
|
222791
|
+
.replace(/\*/g, "%2A");
|
|
222792
|
+
}
|
|
222793
|
+
/** 复刻 SDK getObjectKeys:原始 key 按小写比较排序(排序在编码之前)。 */
|
|
222794
|
+
function sortedKeys(obj) {
|
|
222795
|
+
return Object.keys(obj).sort((a, b) => {
|
|
222796
|
+
a = a.toLowerCase();
|
|
222797
|
+
b = b.toLowerCase();
|
|
222798
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
222799
|
+
});
|
|
222800
|
+
}
|
|
222801
|
+
/** 复刻 SDK obj2str(obj, true):key 编码后小写、value 编码,按 key 升序以 & 连接。 */
|
|
222802
|
+
function encodeKv(obj) {
|
|
222803
|
+
return sortedKeys(obj)
|
|
222804
|
+
.map((key) => {
|
|
222805
|
+
const k = camSafeUrlEncode(key).toLowerCase();
|
|
222806
|
+
const v = camSafeUrlEncode(obj[key] ?? "");
|
|
222807
|
+
return `${k}=${v}`;
|
|
222808
|
+
})
|
|
222809
|
+
.join("&");
|
|
222810
|
+
}
|
|
222811
|
+
/**
|
|
222812
|
+
* 生成 COS q-sign 预签名授权串(PUT 方法)。
|
|
222813
|
+
* 算法逐行复刻 cos-nodejs-sdk-v5 getAuth:
|
|
222814
|
+
* signKey = HMAC-SHA1(SecretKey, KeyTime)
|
|
222815
|
+
* formatString = method \n pathname \n query-str \n header-str \n
|
|
222816
|
+
* stringToSign = sha1 \n KeyTime \n sha1(formatString) \n
|
|
222817
|
+
* signature = HMAC-SHA1(signKey, stringToSign)
|
|
222818
|
+
* Host 头始终签入(对齐 SDK ForceSignHost 默认 true),query 为空故 q-url-param-list 为空。
|
|
222819
|
+
*/
|
|
222820
|
+
function buildCosPutAuthorization(options) {
|
|
222821
|
+
const { secretId, secretKey, bucket, region, objectKey, securityToken, expiresInSeconds = 300, } = options;
|
|
222822
|
+
if (!secretId)
|
|
222823
|
+
throw new Error("missing param SecretId");
|
|
222824
|
+
if (!secretKey)
|
|
222825
|
+
throw new Error("missing param SecretKey");
|
|
222826
|
+
if (!bucket)
|
|
222827
|
+
throw new Error("missing param Bucket");
|
|
222828
|
+
if (!region)
|
|
222829
|
+
throw new Error("missing param Region");
|
|
222830
|
+
if (!objectKey)
|
|
222831
|
+
throw new Error("missing param objectKey");
|
|
222832
|
+
const headers = {
|
|
222833
|
+
host: `${bucket}.cos.${region}.myqcloud.com`,
|
|
222834
|
+
};
|
|
222835
|
+
if (securityToken) {
|
|
222836
|
+
headers["x-cos-security-token"] = securityToken;
|
|
222837
|
+
}
|
|
222838
|
+
const keyTime = options.keyTime ??
|
|
222839
|
+
(() => {
|
|
222840
|
+
const now = options.now ?? Math.floor(Date.now() / 1000);
|
|
222841
|
+
return `${now - 1};${now + expiresInSeconds}`;
|
|
222842
|
+
})();
|
|
222843
|
+
// 与请求 URL 一致的编码路径(对象 key 仅允许安全字符时与原始 key 相同)。
|
|
222844
|
+
const pathname = `/${objectKey.split("/").map(encodeURIComponent).join("/")}`;
|
|
222845
|
+
const signKey = (0, crypto_1.createHmac)("sha1", secretKey).update(keyTime).digest("hex");
|
|
222846
|
+
const formatString = ["put", pathname, "", encodeKv(headers), ""].join("\n");
|
|
222847
|
+
const stringToSign = [
|
|
222848
|
+
"sha1",
|
|
222849
|
+
keyTime,
|
|
222850
|
+
(0, crypto_1.createHash)("sha1").update(Buffer.from(formatString, "utf8")).digest("hex"),
|
|
222851
|
+
"",
|
|
222852
|
+
].join("\n");
|
|
222853
|
+
const signature = (0, crypto_1.createHmac)("sha1", signKey).update(stringToSign).digest("hex");
|
|
222854
|
+
const headerList = sortedKeys(headers)
|
|
222855
|
+
.map((key) => camSafeUrlEncode(key).toLowerCase())
|
|
222856
|
+
.join(";");
|
|
222857
|
+
return [
|
|
222858
|
+
"q-sign-algorithm=sha1",
|
|
222859
|
+
`q-ak=${secretId}`,
|
|
222860
|
+
`q-sign-time=${keyTime}`,
|
|
222861
|
+
`q-key-time=${keyTime}`,
|
|
222862
|
+
`q-header-list=${headerList}`,
|
|
222863
|
+
"q-url-param-list=",
|
|
222864
|
+
`q-signature=${signature}`,
|
|
222865
|
+
].join("&");
|
|
222866
|
+
}
|
|
222867
|
+
/**
|
|
222868
|
+
* 生成两段式部署阶段 A 的完整返回体:预签名 PUT URL + 阶段 B 所需的 COS 三元组。
|
|
222869
|
+
* 对象 key 形如 `fnzip-upload/{ts}-{rand}/{functionName|code}.zip`。functionName 会被
|
|
222870
|
+
* 收窄到 COS 签名安全字符(字母数字与 -_),保证签名 pathname 与请求 URL 一致。
|
|
222871
|
+
*/
|
|
222872
|
+
function buildFunctionZipUpload(params) {
|
|
222873
|
+
const { storage, credential, functionName } = params;
|
|
222874
|
+
const expiresIn = params.expiresIn ?? 300;
|
|
222875
|
+
const ts = params.now ?? Math.floor(Date.now() / 1000);
|
|
222876
|
+
const rand = params.randomSuffix ?? (0, crypto_1.randomBytes)(8).toString("hex");
|
|
222877
|
+
// functionName 只用于让对象 key 可读,必须收窄:否则 "../" 之类能把对象写到
|
|
222878
|
+
// fnzip-upload/ 前缀之外
|
|
222879
|
+
const safeFunctionName = functionName && /^[A-Za-z0-9_-]{1,64}$/.test(functionName)
|
|
222880
|
+
? functionName
|
|
222881
|
+
: "code";
|
|
222882
|
+
const objectKey = `fnzip-upload/${ts}-${rand}/${safeFunctionName}.zip`;
|
|
222883
|
+
const keyTime = params.keyTime ?? `${ts - 1};${ts + expiresIn}`;
|
|
222884
|
+
const authorization = buildCosPutAuthorization({
|
|
222885
|
+
secretId: credential.secretId,
|
|
222886
|
+
secretKey: credential.secretKey,
|
|
222887
|
+
bucket: storage.bucket,
|
|
222888
|
+
region: storage.region,
|
|
222889
|
+
objectKey,
|
|
222890
|
+
securityToken: credential.token || undefined,
|
|
222891
|
+
keyTime,
|
|
222892
|
+
});
|
|
222893
|
+
return {
|
|
222894
|
+
uploadUrl: `https://${storage.bucket}.cos.${storage.region}.myqcloud.com/${objectKey}?${authorization}`,
|
|
222895
|
+
uploadHeaders: credential.token
|
|
222896
|
+
? [{ Key: "x-cos-security-token", Value: credential.token }]
|
|
222897
|
+
: [],
|
|
222898
|
+
cosBucketName: stripAppIdSuffix(storage.bucket),
|
|
222899
|
+
cosBucketRegion: storage.region,
|
|
222900
|
+
cosObjectName: objectKey,
|
|
222901
|
+
expiresInSeconds: expiresIn,
|
|
222902
|
+
};
|
|
222903
|
+
}
|
|
222904
|
+
|
|
222905
|
+
|
|
221963
222906
|
/***/ },
|
|
221964
222907
|
|
|
221965
222908
|
/***/ 84931
|
|
@@ -223319,6 +224262,127 @@ async function waitUntilFunctionActive(getStatus, options = {}) {
|
|
|
223319
224262
|
}
|
|
223320
224263
|
|
|
223321
224264
|
|
|
224265
|
+
/***/ },
|
|
224266
|
+
|
|
224267
|
+
/***/ 77499
|
|
224268
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
224269
|
+
|
|
224270
|
+
"use strict";
|
|
224271
|
+
|
|
224272
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
224273
|
+
exports.FUNCTION_UPLOAD_TARGET_NOT_FOUND_ERROR_CODE = exports.FUNCTION_UPLOAD_TARGET_LIMITS = void 0;
|
|
224274
|
+
exports.registerFunctionUploadTarget = registerFunctionUploadTarget;
|
|
224275
|
+
exports.findFunctionUploadTarget = findFunctionUploadTarget;
|
|
224276
|
+
exports.getFunctionUploadTargetCount = getFunctionUploadTargetCount;
|
|
224277
|
+
exports.resetFunctionUploadTargets = resetFunctionUploadTargets;
|
|
224278
|
+
const function_cos_upload_js_1 = __webpack_require__(65735);
|
|
224279
|
+
/**
|
|
224280
|
+
* 云函数 ZIP 两段式部署的「上传目标」进程内登记。
|
|
224281
|
+
*
|
|
224282
|
+
* 阶段 A(queryFunctions action=getFunctionUploadUrl)铸造预签名上传地址时,
|
|
224283
|
+
* 在本进程登记这次铸造出来的 (envId, bucket, region, objectKey);阶段 B
|
|
224284
|
+
* (manageFunctions createFunction / updateFunctionCode 带 code 三元组)只接受
|
|
224285
|
+
* 登记过的组合。
|
|
224286
|
+
*
|
|
224287
|
+
* 为什么需要它:code.cosObjectName 是模型可以自由填写的字符串,如果不校验,
|
|
224288
|
+
* 它可以指向环境桶里的任意对象,也可以指向另一个桶(包括调用方自己的桶)——
|
|
224289
|
+
* SCF 会用环境角色去拉取那个对象。登记把可用面收窄成「本进程刚为当前环境铸造
|
|
224290
|
+
* 出来的那个 key」。
|
|
224291
|
+
*
|
|
224292
|
+
* 取舍(刻意不做的事):
|
|
224293
|
+
* - 不做「用一次即作废」:同一个 key 在保留期内可以重复提交。上传失败重试、
|
|
224294
|
+
* updateFunctionCode 撞上 ResourceInUse 后的重试、以及同一份代码包重复部署
|
|
224295
|
+
* 都要能重放,收窄的只是「谁能成为目标」,不是「能用几次」。
|
|
224296
|
+
* - 不区分「没登记」与「登记在别的环境」:登记按 envId 隔离,跨环境查询直接
|
|
224297
|
+
* 未命中,调用方只需要知道「这个目标不在登记里,请重新取地址」。
|
|
224298
|
+
*
|
|
224299
|
+
* 登记只保存在当前 MCP 进程内存中,MCP Server 重启即丢失 —— 此时重新调用
|
|
224300
|
+
* getFunctionUploadUrl 取地址、重新上传即可。这与 function-deploy-task-store
|
|
224301
|
+
* 的语义一致(异步部署任务同样只活在进程内)。
|
|
224302
|
+
*/
|
|
224303
|
+
exports.FUNCTION_UPLOAD_TARGET_LIMITS = {
|
|
224304
|
+
/**
|
|
224305
|
+
* 登记的保留时间。远长于上传地址本身的有效期(默认 300 秒):地址过期只影响
|
|
224306
|
+
* 「还能不能 PUT」,而登记要覆盖「取地址 → 上传 → 提交部署」整条链在客户端
|
|
224307
|
+
* 可能的等待(大包上传、人工确认、agent 多轮编排)。
|
|
224308
|
+
*/
|
|
224309
|
+
ttlMs: 60 * 60 * 1000,
|
|
224310
|
+
/** 最大登记数,超出时淘汰最旧的 */
|
|
224311
|
+
maxTargets: 500,
|
|
224312
|
+
};
|
|
224313
|
+
exports.FUNCTION_UPLOAD_TARGET_NOT_FOUND_ERROR_CODE = "FUNCTION_UPLOAD_TARGET_NOT_FOUND";
|
|
224314
|
+
const uploadTargets = new Map();
|
|
224315
|
+
/**
|
|
224316
|
+
* envId 与 objectKey 都不可能含 NUL,用它拼主键不会产生歧义;
|
|
224317
|
+
* 反过来,跨环境的查询无法构造出同一主键(前缀 envId 由服务端解析,调用方改不了)。
|
|
224318
|
+
*/
|
|
224319
|
+
function targetKey(envId, objectKey) {
|
|
224320
|
+
return `${envId}\u0000${objectKey}`;
|
|
224321
|
+
}
|
|
224322
|
+
function cleanupUploadTargets(now) {
|
|
224323
|
+
for (const [key, target] of uploadTargets) {
|
|
224324
|
+
if (now - target.createdAtMs > exports.FUNCTION_UPLOAD_TARGET_LIMITS.ttlMs) {
|
|
224325
|
+
uploadTargets.delete(key);
|
|
224326
|
+
}
|
|
224327
|
+
}
|
|
224328
|
+
}
|
|
224329
|
+
/**
|
|
224330
|
+
* 达到上限时淘汰最旧的登记。
|
|
224331
|
+
*
|
|
224332
|
+
* 与部署任务表不同,这里每一条登记都可以淘汰 —— 淘汰最坏的结果是调用方重新
|
|
224333
|
+
* 取一次上传地址,不会影响任何正在进行中的云端操作,因此不需要 warn。
|
|
224334
|
+
*/
|
|
224335
|
+
function enforceMaxTargets() {
|
|
224336
|
+
const { maxTargets } = exports.FUNCTION_UPLOAD_TARGET_LIMITS;
|
|
224337
|
+
if (uploadTargets.size < maxTargets) {
|
|
224338
|
+
return;
|
|
224339
|
+
}
|
|
224340
|
+
const oldestFirst = [...uploadTargets.entries()].sort((left, right) => left[1].createdAtMs - right[1].createdAtMs);
|
|
224341
|
+
for (const [key] of oldestFirst) {
|
|
224342
|
+
if (uploadTargets.size < maxTargets) {
|
|
224343
|
+
return;
|
|
224344
|
+
}
|
|
224345
|
+
uploadTargets.delete(key);
|
|
224346
|
+
}
|
|
224347
|
+
}
|
|
224348
|
+
/** 阶段 A 登记本次铸造的上传目标。 */
|
|
224349
|
+
function registerFunctionUploadTarget(input) {
|
|
224350
|
+
const now = input.now ?? Date.now();
|
|
224351
|
+
cleanupUploadTargets(now);
|
|
224352
|
+
enforceMaxTargets();
|
|
224353
|
+
uploadTargets.set(targetKey(input.envId, input.objectKey), {
|
|
224354
|
+
envId: input.envId,
|
|
224355
|
+
bucket: input.bucket,
|
|
224356
|
+
region: input.region,
|
|
224357
|
+
objectKey: input.objectKey,
|
|
224358
|
+
createdAtMs: now,
|
|
224359
|
+
});
|
|
224360
|
+
}
|
|
224361
|
+
/**
|
|
224362
|
+
* 阶段 B 校验:命中登记且桶、地域都对得上才返回目标,否则返回 undefined。
|
|
224363
|
+
*
|
|
224364
|
+
* 地域与桶都要比对 —— 只比对象 key 的话,仍然可以把同一个 key 指到别的桶或
|
|
224365
|
+
* 别的地域(例如把代码指到调用方自己的桶)上。
|
|
224366
|
+
*/
|
|
224367
|
+
function findFunctionUploadTarget(input) {
|
|
224368
|
+
const now = input.now ?? Date.now();
|
|
224369
|
+
cleanupUploadTargets(now);
|
|
224370
|
+
const target = uploadTargets.get(targetKey(input.envId, input.objectKey));
|
|
224371
|
+
if (!target) {
|
|
224372
|
+
return undefined;
|
|
224373
|
+
}
|
|
224374
|
+
const bucketMatches = (0, function_cos_upload_js_1.stripAppIdSuffix)(input.bucketName) === (0, function_cos_upload_js_1.stripAppIdSuffix)(target.bucket);
|
|
224375
|
+
return bucketMatches && input.region === target.region ? target : undefined;
|
|
224376
|
+
}
|
|
224377
|
+
function getFunctionUploadTargetCount() {
|
|
224378
|
+
return uploadTargets.size;
|
|
224379
|
+
}
|
|
224380
|
+
/** 测试用:清空登记表 */
|
|
224381
|
+
function resetFunctionUploadTargets() {
|
|
224382
|
+
uploadTargets.clear();
|
|
224383
|
+
}
|
|
224384
|
+
|
|
224385
|
+
|
|
223322
224386
|
/***/ },
|
|
223323
224387
|
|
|
223324
224388
|
/***/ 51546
|
|
@@ -223350,10 +224414,36 @@ const logger_js_1 = __webpack_require__(40781);
|
|
|
223350
224414
|
const tool_result_js_1 = __webpack_require__(69645);
|
|
223351
224415
|
const function_deploy_js_1 = __webpack_require__(39151);
|
|
223352
224416
|
const function_deploy_schema_js_1 = __webpack_require__(76427);
|
|
224417
|
+
const function_cos_upload_js_1 = __webpack_require__(65735);
|
|
224418
|
+
const function_upload_target_store_js_1 = __webpack_require__(77499);
|
|
223353
224419
|
const function_updating_js_1 = __webpack_require__(70326);
|
|
223354
224420
|
const index_js_1 = __webpack_require__(24908);
|
|
223355
224421
|
const fs_1 = __webpack_require__(29021);
|
|
223356
224422
|
const path_1 = __importDefault(__webpack_require__(33873));
|
|
224423
|
+
/**
|
|
224424
|
+
* 阶段 B 校验:code 三元组必须是本进程阶段 A 登记过的上传目标。
|
|
224425
|
+
*
|
|
224426
|
+
* 未命中时统一按「目标不在登记里」返回,不区分「没登记」与「登记在别的环境」——
|
|
224427
|
+
* 与部署任务表同款取舍,调用方只需要知道下一步该重新取上传地址。
|
|
224428
|
+
*/
|
|
224429
|
+
function assertFunctionUploadTarget(input) {
|
|
224430
|
+
if ((0, function_upload_target_store_js_1.findFunctionUploadTarget)(input)) {
|
|
224431
|
+
return;
|
|
224432
|
+
}
|
|
224433
|
+
(0, tool_result_js_1.throwToolPayloadError)({
|
|
224434
|
+
success: false,
|
|
224435
|
+
errorCode: function_upload_target_store_js_1.FUNCTION_UPLOAD_TARGET_NOT_FOUND_ERROR_CODE,
|
|
224436
|
+
data: {
|
|
224437
|
+
action: input.action,
|
|
224438
|
+
cosBucketName: input.bucketName,
|
|
224439
|
+
cosBucketRegion: input.region,
|
|
224440
|
+
cosObjectName: input.objectKey,
|
|
224441
|
+
},
|
|
224442
|
+
message: (0, index_js_1.t)("functions.uploadTargetNotFound", {
|
|
224443
|
+
objectName: input.objectKey,
|
|
224444
|
+
}),
|
|
224445
|
+
});
|
|
224446
|
+
}
|
|
223357
224447
|
exports.SUPPORTED_RUNTIMES = {
|
|
223358
224448
|
nodejs: [
|
|
223359
224449
|
"Nodejs20.19",
|
|
@@ -223431,6 +224521,7 @@ exports.QUERY_FUNCTION_ACTIONS = [
|
|
|
223431
224521
|
"getFunctionDeployStatus",
|
|
223432
224522
|
"listVersionByFunction",
|
|
223433
224523
|
"getFunctionAlias",
|
|
224524
|
+
"getFunctionUploadUrl",
|
|
223434
224525
|
];
|
|
223435
224526
|
exports.MANAGE_FUNCTION_ACTIONS = [
|
|
223436
224527
|
"createFunction",
|
|
@@ -223610,6 +224701,25 @@ const MANAGE_LAYER_SCHEMA = zod_1.z.object({
|
|
|
223610
224701
|
layerName: zod_1.z.string().describe("functions.schema.manageLayer.name"),
|
|
223611
224702
|
layerVersion: zod_1.z.number().describe("functions.schema.manageLayer.version"),
|
|
223612
224703
|
});
|
|
224704
|
+
/**
|
|
224705
|
+
* ZIP 两段式部署阶段 B 的 code 入参(camelCase,映射为 SDK 的 PascalCase code 三元组)。
|
|
224706
|
+
* 三件套均来自 queryFunctions getFunctionUploadUrl 的返回体,原样透传即可。
|
|
224707
|
+
* strict:拼错字段名直接报错,而不是被静默丢弃后按本地目录语义执行。
|
|
224708
|
+
*/
|
|
224709
|
+
const FUNCTION_CODE_SCHEMA = zod_1.z
|
|
224710
|
+
.object({
|
|
224711
|
+
cosBucketName: zod_1.z
|
|
224712
|
+
.string()
|
|
224713
|
+
.describe("functions.schema.code.cosBucketName"),
|
|
224714
|
+
cosObjectName: zod_1.z
|
|
224715
|
+
.string()
|
|
224716
|
+
.describe("functions.schema.code.cosObjectName"),
|
|
224717
|
+
cosBucketRegion: zod_1.z
|
|
224718
|
+
.string()
|
|
224719
|
+
.optional()
|
|
224720
|
+
.describe("functions.schema.code.cosBucketRegion"),
|
|
224721
|
+
})
|
|
224722
|
+
.strict();
|
|
223613
224723
|
const FUNCTION_VERSION_WEIGHT_SCHEMA = zod_1.z.object({
|
|
223614
224724
|
Version: zod_1.z.string().describe("functions.schema.routing.version"),
|
|
223615
224725
|
Weight: zod_1.z.number().describe("functions.schema.routing.weight"),
|
|
@@ -223809,6 +224919,49 @@ function registerFunctionTools(server) {
|
|
|
223809
224919
|
throw new Error((0, index_js_1.t)("functions.confirmRequired", { action }));
|
|
223810
224920
|
}
|
|
223811
224921
|
};
|
|
224922
|
+
/**
|
|
224923
|
+
* 解析当前环境的自有存储桶(DescribeEnvs → Storages[0])。
|
|
224924
|
+
* 两段式部署的上传桶必须用环境自己的桶:共享 build 桶会被 SCF 拉
|
|
224925
|
+
* 代码时的 -appid 拼接判死(R1 探针实测)。无存储的环境直接报错引导。
|
|
224926
|
+
*
|
|
224927
|
+
* DescribeEnvs 是账号级动作,环境级凭据(如 API Key 换取的 STS,
|
|
224928
|
+
* remote MCP 临时 API Key 即此类)调用会被网关拒绝(invalid token),
|
|
224929
|
+
* 此时回退到环境级的 DescribeEnvInfo —— 其 EnvBaseInfo.Storages 与
|
|
224930
|
+
* DescribeEnvs 的 Storages 同构(实测两者均含 Bucket/Region/Status)。
|
|
224931
|
+
*/
|
|
224932
|
+
const resolveEnvFunctionCosStorage = async () => {
|
|
224933
|
+
const cloudbase = await getManager();
|
|
224934
|
+
const envId = cloudBaseOptions?.envId ?? (await (0, cloudbase_manager_js_1.getEnvId)(cloudBaseOptions));
|
|
224935
|
+
const tcbService = cloudbase.commonService("tcb", "2018-06-08");
|
|
224936
|
+
const fetchStorages = async () => {
|
|
224937
|
+
try {
|
|
224938
|
+
const envsResult = (await tcbService.call({
|
|
224939
|
+
Action: "DescribeEnvs",
|
|
224940
|
+
Param: { EnvId: envId },
|
|
224941
|
+
}));
|
|
224942
|
+
const storages = envsResult?.EnvList?.[0]?.Storages ?? envsResult?.EnvInfo?.Storages ?? [];
|
|
224943
|
+
if (storages.length > 0) {
|
|
224944
|
+
return storages;
|
|
224945
|
+
}
|
|
224946
|
+
}
|
|
224947
|
+
catch (e) {
|
|
224948
|
+
(0, logger_js_1.debug)("resolveEnvFunctionCosStorage: DescribeEnvs failed, falling back to DescribeEnvInfo", { envId, error: e instanceof Error ? e.message : String(e) });
|
|
224949
|
+
}
|
|
224950
|
+
const infoResult = (await tcbService.call({
|
|
224951
|
+
Action: "DescribeEnvInfo",
|
|
224952
|
+
Param: { EnvId: envId },
|
|
224953
|
+
}));
|
|
224954
|
+
return infoResult?.EnvInfo?.EnvBaseInfo?.Storages ?? [];
|
|
224955
|
+
};
|
|
224956
|
+
const storages = await fetchStorages();
|
|
224957
|
+
const bucket = storages[0]?.Bucket ?? "";
|
|
224958
|
+
const region = storages[0]?.Region ?? "";
|
|
224959
|
+
if (!bucket || !region) {
|
|
224960
|
+
throw new Error((0, index_js_1.t)("functions.storageMissing"));
|
|
224961
|
+
}
|
|
224962
|
+
// envId 一并返回:阶段 A 的上传目标登记与阶段 B 的校验都按环境隔离
|
|
224963
|
+
return { bucket, region, envId };
|
|
224964
|
+
};
|
|
223812
224965
|
const ensureActionAllowedInCloudMode = (input) => {
|
|
223813
224966
|
if (!(0, cloud_mode_js_1.isCloudMode)()) {
|
|
223814
224967
|
return;
|
|
@@ -223823,6 +224976,11 @@ function registerFunctionTools(server) {
|
|
|
223823
224976
|
if (hasImageDeploy) {
|
|
223824
224977
|
return;
|
|
223825
224978
|
}
|
|
224979
|
+
// 两段式部署阶段 B:代码包已上传到环境 COS 桶,全程不依赖本地目录,
|
|
224980
|
+
// 与镜像部署同属可在 cloud mode 下真实执行的路径。
|
|
224981
|
+
if (Boolean(input.code)) {
|
|
224982
|
+
return;
|
|
224983
|
+
}
|
|
223826
224984
|
throw new Error((0, index_js_1.t)("functions.cloudMode.localOnly", { action: input.action }));
|
|
223827
224985
|
}
|
|
223828
224986
|
if (input.action === "createLayerVersion" && input.contentPath) {
|
|
@@ -224041,7 +225199,13 @@ function registerFunctionTools(server) {
|
|
|
224041
225199
|
}
|
|
224042
225200
|
const cloudbase = await getManager();
|
|
224043
225201
|
const result = await cloudbase.functions.getFunctionDetail(input.functionName, input.codeSecret);
|
|
224044
|
-
|
|
225202
|
+
// 与 getFunctionDetail / listFunctionTriggers 一致:本 action 只想取 Layers,
|
|
225203
|
+
// 但 getFunctionDetail 的返回里带着环境变量明文,日志与 raw 都必须脱敏 ——
|
|
225204
|
+
// 否则一个只读的「看层」动作会把明文环境变量带进模型上下文与持久化日志。
|
|
225205
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, maskFunctionDetailEnvValues(result));
|
|
225206
|
+
const detail = input.revealEnvValues === true
|
|
225207
|
+
? result
|
|
225208
|
+
: maskFunctionDetailEnvValues(result);
|
|
224045
225209
|
const layers = normalizeFunctionLayers(result.Layers);
|
|
224046
225210
|
return buildEnvelope({
|
|
224047
225211
|
action: input.action,
|
|
@@ -224049,7 +225213,7 @@ function registerFunctionTools(server) {
|
|
|
224049
225213
|
layers,
|
|
224050
225214
|
count: layers.length,
|
|
224051
225215
|
requestId: result.RequestId,
|
|
224052
|
-
raw:
|
|
225216
|
+
raw: detail,
|
|
224053
225217
|
}, (0, index_js_1.t)("functions.gotFunctionLayers", { fnName: input.functionName }), [
|
|
224054
225218
|
{
|
|
224055
225219
|
tool: "manageFunctions",
|
|
@@ -224187,7 +225351,9 @@ function registerFunctionTools(server) {
|
|
|
224187
225351
|
}
|
|
224188
225352
|
const cloudbase = await getManager();
|
|
224189
225353
|
const result = await cloudbase.functions.getFunctionDownloadUrl(input.functionName, input.codeSecret);
|
|
224190
|
-
|
|
225354
|
+
// downloadUrl 是带凭据签名的临时链接:与 apps getUploadUrl 同款处理,只落 RequestId,
|
|
225355
|
+
// 避免整条 URL 随宿主日志持久化
|
|
225356
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, { RequestId: result.RequestId });
|
|
224191
225357
|
return buildEnvelope({
|
|
224192
225358
|
action: input.action,
|
|
224193
225359
|
functionName: input.functionName,
|
|
@@ -224269,6 +225435,52 @@ function registerFunctionTools(server) {
|
|
|
224269
225435
|
},
|
|
224270
225436
|
]);
|
|
224271
225437
|
}
|
|
225438
|
+
case "getFunctionUploadUrl": {
|
|
225439
|
+
// ZIP 两段式部署阶段 A:环境自有存储桶 + 用户凭据本地铸 COS 预签名 PUT URL。
|
|
225440
|
+
// functionName 可选,仅用于生成可读的对象 key。
|
|
225441
|
+
const cloudbase = await getManager();
|
|
225442
|
+
const authConfig = cloudbase.currentEnvironment().getAuthConfig();
|
|
225443
|
+
if (!authConfig?.secretId || !authConfig?.secretKey) {
|
|
225444
|
+
throw new Error((0, index_js_1.t)("functions.credentialMissing"));
|
|
225445
|
+
}
|
|
225446
|
+
const storage = await resolveEnvFunctionCosStorage();
|
|
225447
|
+
const upload = (0, function_cos_upload_js_1.buildFunctionZipUpload)({
|
|
225448
|
+
storage,
|
|
225449
|
+
credential: {
|
|
225450
|
+
secretId: authConfig.secretId,
|
|
225451
|
+
secretKey: authConfig.secretKey,
|
|
225452
|
+
// 永久密钥时 token 为空串,转 undefined 才不签入 token 头
|
|
225453
|
+
token: authConfig.token || undefined,
|
|
225454
|
+
},
|
|
225455
|
+
functionName: input.functionName,
|
|
225456
|
+
});
|
|
225457
|
+
// 阶段 A 在进程内登记本次铸造的上传目标:阶段 B 只接受登记过的
|
|
225458
|
+
// (envId, bucket, region, objectKey),cosObjectName 因此不再是任意字符串。
|
|
225459
|
+
(0, function_upload_target_store_js_1.registerFunctionUploadTarget)({
|
|
225460
|
+
envId: storage.envId,
|
|
225461
|
+
bucket: storage.bucket,
|
|
225462
|
+
region: storage.region,
|
|
225463
|
+
objectKey: upload.cosObjectName,
|
|
225464
|
+
});
|
|
225465
|
+
// uploadUrl 内含凭据绑定的签名(临时凭据还绑定 token),禁止落日志
|
|
225466
|
+
(0, logger_js_1.debug)(`[getFunctionUploadUrl] envId=${authConfig.envId ?? "n/a"}, cosObjectName=${upload.cosObjectName}, expiresIn=${upload.expiresInSeconds}s`);
|
|
225467
|
+
return buildEnvelope({
|
|
225468
|
+
action: input.action,
|
|
225469
|
+
...(input.functionName ? { functionName: input.functionName } : {}),
|
|
225470
|
+
uploadUrl: upload.uploadUrl,
|
|
225471
|
+
uploadHeaders: upload.uploadHeaders,
|
|
225472
|
+
cosBucketName: upload.cosBucketName,
|
|
225473
|
+
cosBucketRegion: upload.cosBucketRegion,
|
|
225474
|
+
cosObjectName: upload.cosObjectName,
|
|
225475
|
+
expiresInSeconds: upload.expiresInSeconds,
|
|
225476
|
+
}, (0, index_js_1.t)("functions.gotUploadUrl", { seconds: upload.expiresInSeconds }), [
|
|
225477
|
+
{
|
|
225478
|
+
tool: "manageFunctions",
|
|
225479
|
+
action: "createFunction",
|
|
225480
|
+
reason: (0, index_js_1.t)("functions.reason.cosCreate"),
|
|
225481
|
+
},
|
|
225482
|
+
]);
|
|
225483
|
+
}
|
|
224272
225484
|
default:
|
|
224273
225485
|
throw new Error((0, index_js_1.t)("functions.unsupportedAction", { action: input.action }));
|
|
224274
225486
|
}
|
|
@@ -224525,6 +225737,70 @@ function registerFunctionTools(server) {
|
|
|
224525
225737
|
},
|
|
224526
225738
|
]);
|
|
224527
225739
|
}
|
|
225740
|
+
// code 入参(ZIP 两段式部署阶段 B):代码包已由 getFunctionUploadUrl 上传到
|
|
225741
|
+
// 环境 COS 桶,直接 deployMode=cos 提交,跳过本地目录 / 依赖安装逻辑。
|
|
225742
|
+
if (input.code) {
|
|
225743
|
+
const storage = await resolveEnvFunctionCosStorage();
|
|
225744
|
+
const cosBucketName = (0, function_cos_upload_js_1.stripAppIdSuffix)(input.code.cosBucketName || storage.bucket);
|
|
225745
|
+
const cosBucketRegion = input.code.cosBucketRegion ?? storage.region;
|
|
225746
|
+
assertFunctionUploadTarget({
|
|
225747
|
+
envId: storage.envId,
|
|
225748
|
+
bucketName: input.code.cosBucketName || storage.bucket,
|
|
225749
|
+
region: cosBucketRegion,
|
|
225750
|
+
objectKey: input.code.cosObjectName,
|
|
225751
|
+
action: input.action,
|
|
225752
|
+
});
|
|
225753
|
+
const codeFunc = { ...func };
|
|
225754
|
+
// 用户 zip 自带依赖语义(装没装由上传方决定),默认不触发云端依赖安装
|
|
225755
|
+
delete codeFunc.installDependency;
|
|
225756
|
+
if (input.func?.installDependency !== undefined) {
|
|
225757
|
+
codeFunc.installDependency = input.func.installDependency;
|
|
225758
|
+
}
|
|
225759
|
+
if (codeFunc.type !== "HTTP") {
|
|
225760
|
+
codeFunc.runtime = resolveEventFunctionRuntime(codeFunc.runtime);
|
|
225761
|
+
}
|
|
225762
|
+
let cosCreateResult;
|
|
225763
|
+
try {
|
|
225764
|
+
cosCreateResult = await cloudbase.functions.createFunction({
|
|
225765
|
+
func: codeFunc,
|
|
225766
|
+
code: {
|
|
225767
|
+
CosBucketName: cosBucketName,
|
|
225768
|
+
CosBucketRegion: cosBucketRegion,
|
|
225769
|
+
CosObjectName: input.code.cosObjectName,
|
|
225770
|
+
},
|
|
225771
|
+
deployMode: "cos",
|
|
225772
|
+
force: Boolean(input.force),
|
|
225773
|
+
});
|
|
225774
|
+
}
|
|
225775
|
+
catch (error) {
|
|
225776
|
+
throw wrapFunctionOperationError("createFunction", functionName, undefined, error);
|
|
225777
|
+
}
|
|
225778
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, cosCreateResult);
|
|
225779
|
+
return buildEnvelope({
|
|
225780
|
+
action: input.action,
|
|
225781
|
+
functionName,
|
|
225782
|
+
deployMode: "cos",
|
|
225783
|
+
cosBucketName,
|
|
225784
|
+
cosBucketRegion,
|
|
225785
|
+
cosObjectName: input.code.cosObjectName,
|
|
225786
|
+
raw: cosCreateResult,
|
|
225787
|
+
}, (0, index_js_1.t)("functions.cosCreatedMessage", { fnName: functionName }), [
|
|
225788
|
+
{
|
|
225789
|
+
tool: "queryFunctions",
|
|
225790
|
+
action: "getFunctionDetail",
|
|
225791
|
+
reason: (0, index_js_1.t)("functions.reason.confirmConfig"),
|
|
225792
|
+
},
|
|
225793
|
+
...(codeFunc.type === "HTTP"
|
|
225794
|
+
? [
|
|
225795
|
+
{
|
|
225796
|
+
tool: "manageGateway",
|
|
225797
|
+
action: "createRoute",
|
|
225798
|
+
reason: (0, index_js_1.t)("functions.reason.gatewayRouteForHttp"),
|
|
225799
|
+
},
|
|
225800
|
+
]
|
|
225801
|
+
: []),
|
|
225802
|
+
]);
|
|
225803
|
+
}
|
|
224528
225804
|
if (func.type !== "HTTP") {
|
|
224529
225805
|
const originalRuntime = typeof func.runtime === "string" ? func.runtime : undefined;
|
|
224530
225806
|
func.runtime = resolveEventFunctionRuntime(func.runtime);
|
|
@@ -224733,6 +226009,65 @@ function registerFunctionTools(server) {
|
|
|
224733
226009
|
},
|
|
224734
226010
|
]);
|
|
224735
226011
|
}
|
|
226012
|
+
// code 入参(ZIP 两段式部署阶段 B):zip 已在环境 COS 桶,直接 deployMode=cos
|
|
226013
|
+
// 更新代码包,跳过 functionRootPath / zipFile 本地语义。
|
|
226014
|
+
if (input.code) {
|
|
226015
|
+
const storage = await resolveEnvFunctionCosStorage();
|
|
226016
|
+
const cosBucketName = (0, function_cos_upload_js_1.stripAppIdSuffix)(input.code.cosBucketName || storage.bucket);
|
|
226017
|
+
const cosBucketRegion = input.code.cosBucketRegion ?? storage.region;
|
|
226018
|
+
assertFunctionUploadTarget({
|
|
226019
|
+
envId: storage.envId,
|
|
226020
|
+
bucketName: input.code.cosBucketName || storage.bucket,
|
|
226021
|
+
region: cosBucketRegion,
|
|
226022
|
+
objectKey: input.code.cosObjectName,
|
|
226023
|
+
action: input.action,
|
|
226024
|
+
});
|
|
226025
|
+
let cosUpdateResult;
|
|
226026
|
+
try {
|
|
226027
|
+
cosUpdateResult = await cloudbase.functions.updateFunctionCode({
|
|
226028
|
+
func: {
|
|
226029
|
+
name: input.functionName,
|
|
226030
|
+
// 与 create 的 code 分支一致:默认不触发云端依赖安装,显式传参才覆盖
|
|
226031
|
+
...(input.func?.installDependency !== undefined
|
|
226032
|
+
? { installDependency: input.func.installDependency }
|
|
226033
|
+
: {}),
|
|
226034
|
+
...(input.handler ? { handler: input.handler } : {}),
|
|
226035
|
+
},
|
|
226036
|
+
code: {
|
|
226037
|
+
CosBucketName: cosBucketName,
|
|
226038
|
+
CosBucketRegion: cosBucketRegion,
|
|
226039
|
+
CosObjectName: input.code.cosObjectName,
|
|
226040
|
+
},
|
|
226041
|
+
deployMode: "cos",
|
|
226042
|
+
});
|
|
226043
|
+
}
|
|
226044
|
+
catch (error) {
|
|
226045
|
+
if ((0, function_updating_js_1.isFunctionUpdatingError)(error)) {
|
|
226046
|
+
return (0, function_updating_js_1.buildFunctionUpdatingPayload)({
|
|
226047
|
+
action: "updateFunctionCode",
|
|
226048
|
+
functionName: input.functionName,
|
|
226049
|
+
rawMessage: (0, function_updating_js_1.getErrorMessage)(error),
|
|
226050
|
+
});
|
|
226051
|
+
}
|
|
226052
|
+
throw wrapFunctionOperationError("updateFunctionCode", input.functionName, undefined, error);
|
|
226053
|
+
}
|
|
226054
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, cosUpdateResult);
|
|
226055
|
+
return buildEnvelope({
|
|
226056
|
+
action: input.action,
|
|
226057
|
+
functionName: input.functionName,
|
|
226058
|
+
deployMode: "cos",
|
|
226059
|
+
cosBucketName,
|
|
226060
|
+
cosBucketRegion,
|
|
226061
|
+
cosObjectName: input.code.cosObjectName,
|
|
226062
|
+
raw: cosUpdateResult,
|
|
226063
|
+
}, (0, index_js_1.t)("functions.cosUpdatedMessage", { fnName: input.functionName }), [
|
|
226064
|
+
{
|
|
226065
|
+
tool: "queryFunctions",
|
|
226066
|
+
action: "getFunctionDetail",
|
|
226067
|
+
reason: (0, index_js_1.t)("functions.reason.confirmConfig"),
|
|
226068
|
+
},
|
|
226069
|
+
]);
|
|
226070
|
+
}
|
|
224736
226071
|
const processedRootPath = processFunctionRootPath(input.functionRootPath, input.functionName);
|
|
224737
226072
|
const updateParams = {
|
|
224738
226073
|
func: {
|
|
@@ -225283,6 +226618,7 @@ function registerFunctionTools(server) {
|
|
|
225283
226618
|
.optional()
|
|
225284
226619
|
.describe("functions.schema.manage.functionName"),
|
|
225285
226620
|
zipFile: zod_1.z.string().optional().describe("functions.schema.manage.zipFile"),
|
|
226621
|
+
code: FUNCTION_CODE_SCHEMA.optional().describe("functions.schema.manage.code"),
|
|
225286
226622
|
handler: zod_1.z.string().optional().describe("functions.schema.manage.handler"),
|
|
225287
226623
|
timeout: zod_1.z.number().optional().describe("functions.schema.manage.timeout"),
|
|
225288
226624
|
envVariables: zod_1.z
|
|
@@ -227920,18 +229256,23 @@ const cloudbase_manager_js_1 = __webpack_require__(33109);
|
|
|
227920
229256
|
const json_content_js_1 = __webpack_require__(18027);
|
|
227921
229257
|
const index_js_1 = __webpack_require__(24908);
|
|
227922
229258
|
const QUERY_LOG_ACTIONS = ["checkLogService", "searchLogs"];
|
|
227923
|
-
|
|
229259
|
+
const MANAGE_LOG_ACTIONS = ["createLogService"];
|
|
229260
|
+
function buildEnvelope(data, message, extras) {
|
|
227924
229261
|
return {
|
|
227925
229262
|
success: true,
|
|
227926
229263
|
data,
|
|
227927
229264
|
message,
|
|
229265
|
+
...extras,
|
|
227928
229266
|
};
|
|
227929
229267
|
}
|
|
227930
|
-
function buildErrorEnvelope(error) {
|
|
229268
|
+
function buildErrorEnvelope(error, extras) {
|
|
227931
229269
|
return {
|
|
227932
229270
|
success: false,
|
|
227933
|
-
data: {},
|
|
227934
|
-
message:
|
|
229271
|
+
data: extras?.data ?? {},
|
|
229272
|
+
message: extras?.message ??
|
|
229273
|
+
(error instanceof Error ? error.message : String(error)),
|
|
229274
|
+
errorCode: extras?.errorCode,
|
|
229275
|
+
nextActions: extras?.nextActions,
|
|
227935
229276
|
};
|
|
227936
229277
|
}
|
|
227937
229278
|
function registerLogTools(server) {
|
|
@@ -228004,6 +229345,89 @@ function registerLogTools(server) {
|
|
|
228004
229345
|
return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(error));
|
|
228005
229346
|
}
|
|
228006
229347
|
});
|
|
229348
|
+
server.registerTool?.("manageLogs", {
|
|
229349
|
+
title: "logs.manage.title",
|
|
229350
|
+
description: "logs.manage.description",
|
|
229351
|
+
inputSchema: {
|
|
229352
|
+
action: zod_1.z
|
|
229353
|
+
.enum(MANAGE_LOG_ACTIONS)
|
|
229354
|
+
.describe("logs.manage.schema.action"),
|
|
229355
|
+
confirm: zod_1.z
|
|
229356
|
+
.boolean()
|
|
229357
|
+
.optional()
|
|
229358
|
+
.describe("logs.manage.schema.confirm"),
|
|
229359
|
+
},
|
|
229360
|
+
annotations: {
|
|
229361
|
+
readOnlyHint: false,
|
|
229362
|
+
destructiveHint: false,
|
|
229363
|
+
idempotentHint: false,
|
|
229364
|
+
openWorldHint: false,
|
|
229365
|
+
category: "logs",
|
|
229366
|
+
},
|
|
229367
|
+
}, async ({ action, confirm, }) => {
|
|
229368
|
+
try {
|
|
229369
|
+
if (action !== "createLogService") {
|
|
229370
|
+
return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(new Error((0, index_js_1.t)("logs.manage.unsupportedAction", { action })), {
|
|
229371
|
+
errorCode: "UNSUPPORTED_ACTION",
|
|
229372
|
+
}));
|
|
229373
|
+
}
|
|
229374
|
+
if (confirm !== true) {
|
|
229375
|
+
return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(null, {
|
|
229376
|
+
errorCode: "CONFIRM_REQUIRED",
|
|
229377
|
+
message: (0, index_js_1.t)("logs.manage.create.confirmRequired"),
|
|
229378
|
+
data: { action },
|
|
229379
|
+
nextActions: [
|
|
229380
|
+
{
|
|
229381
|
+
tool: "manageLogs",
|
|
229382
|
+
action: "createLogService",
|
|
229383
|
+
suggested_args: { action: "createLogService", confirm: true },
|
|
229384
|
+
reason: (0, index_js_1.t)("logs.manage.create.needsConfirmation"),
|
|
229385
|
+
},
|
|
229386
|
+
],
|
|
229387
|
+
}));
|
|
229388
|
+
}
|
|
229389
|
+
const cloudbase = await getManager();
|
|
229390
|
+
const enabled = await cloudbase.log.checkLogServiceEnabled();
|
|
229391
|
+
if (enabled) {
|
|
229392
|
+
return (0, json_content_js_1.jsonContent)(buildEnvelope({
|
|
229393
|
+
action,
|
|
229394
|
+
enabled: true,
|
|
229395
|
+
alreadyEnabled: true,
|
|
229396
|
+
}, (0, index_js_1.t)("logs.manage.create.alreadyEnabled"), {
|
|
229397
|
+
nextActions: [
|
|
229398
|
+
{
|
|
229399
|
+
tool: "queryLogs",
|
|
229400
|
+
action: "searchLogs",
|
|
229401
|
+
suggested_args: {
|
|
229402
|
+
action: "searchLogs",
|
|
229403
|
+
queryString: 'log:"ERROR"',
|
|
229404
|
+
},
|
|
229405
|
+
reason: (0, index_js_1.t)("logs.manage.create.nextSearch"),
|
|
229406
|
+
},
|
|
229407
|
+
],
|
|
229408
|
+
}));
|
|
229409
|
+
}
|
|
229410
|
+
const result = await cloudbase.log.createLogService();
|
|
229411
|
+
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
|
|
229412
|
+
return (0, json_content_js_1.jsonContent)(buildEnvelope({
|
|
229413
|
+
action,
|
|
229414
|
+
requestId: result.RequestId ?? null,
|
|
229415
|
+
raw: result,
|
|
229416
|
+
}, (0, index_js_1.t)("logs.manage.create.submitted"), {
|
|
229417
|
+
nextActions: [
|
|
229418
|
+
{
|
|
229419
|
+
tool: "queryLogs",
|
|
229420
|
+
action: "checkLogService",
|
|
229421
|
+
suggested_args: { action: "checkLogService" },
|
|
229422
|
+
reason: (0, index_js_1.t)("logs.manage.create.nextCheck"),
|
|
229423
|
+
},
|
|
229424
|
+
],
|
|
229425
|
+
}));
|
|
229426
|
+
}
|
|
229427
|
+
catch (error) {
|
|
229428
|
+
return (0, json_content_js_1.jsonContent)(buildErrorEnvelope(error));
|
|
229429
|
+
}
|
|
229430
|
+
});
|
|
228007
229431
|
}
|
|
228008
229432
|
|
|
228009
229433
|
|
|
@@ -229350,7 +230774,7 @@ function extractRiskyDocFieldOperations(securityRule) {
|
|
|
229350
230774
|
continue;
|
|
229351
230775
|
}
|
|
229352
230776
|
const referencesNonIdDocField = /doc\.(?!_id\b)[A-Za-z_][A-Za-z0-9_]*/.test(expression);
|
|
229353
|
-
const usesGetByDocId = /get\('database\.[^']+'\s*\+\s*doc\._id\)/.test(expression);
|
|
230777
|
+
const usesGetByDocId = /get\(('database\.[^']+'\s*\+\s*doc\._id|`database\.[^`]*\$\{\s*doc\._id\s*\})\)/.test(expression);
|
|
229354
230778
|
if (referencesNonIdDocField && !usesGetByDocId) {
|
|
229355
230779
|
operations.push(operation);
|
|
229356
230780
|
}
|
|
@@ -229360,8 +230784,8 @@ function extractRiskyDocFieldOperations(securityRule) {
|
|
|
229360
230784
|
function buildRecommendedOwnerWriteRule(resourceId) {
|
|
229361
230785
|
return JSON.stringify({
|
|
229362
230786
|
create: "auth.uid != null",
|
|
229363
|
-
update: "auth.uid != null && (get(
|
|
229364
|
-
delete: "auth.uid != null && (get(
|
|
230787
|
+
update: "auth.uid != null && (get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid)",
|
|
230788
|
+
delete: "auth.uid != null && (get(`database.user_roles.${auth.uid}`).role == 'admin' || doc.authorId == auth.uid)",
|
|
229365
230789
|
});
|
|
229366
230790
|
}
|
|
229367
230791
|
function buildRoleLookupNote() {
|
|
@@ -229423,7 +230847,9 @@ function buildInvalidGetPathHint(securityRule, resourceId) {
|
|
|
229423
230847
|
if (!securityRule) {
|
|
229424
230848
|
return undefined;
|
|
229425
230849
|
}
|
|
229426
|
-
|
|
230850
|
+
// get() 的 path 里嵌了字段名:拼接形态,或反引号模板里在 ${} 之后又接字段
|
|
230851
|
+
const hasFieldEmbeddedInsideGetPath = /get\('database\.[^']+'\s*\+\s*[^)]*\+\s*'\.[A-Za-z_][A-Za-z0-9_]*'\)/.test(securityRule) ||
|
|
230852
|
+
/get\(`database\.[^`]*\.\$\{[^}]+\}\.[A-Za-z_][A-Za-z0-9_]*`\)/.test(securityRule);
|
|
229427
230853
|
if (!hasFieldEmbeddedInsideGetPath) {
|
|
229428
230854
|
return undefined;
|
|
229429
230855
|
}
|
|
@@ -229443,7 +230869,9 @@ function buildTemplateLiteralRuleHint(securityRule, resourceId) {
|
|
|
229443
230869
|
if (!securityRule) {
|
|
229444
230870
|
return undefined;
|
|
229445
230871
|
}
|
|
229446
|
-
|
|
230872
|
+
// 反引号模板字符串是官方形态,必须先剥掉再判——否则会把正确的写法误报成错误
|
|
230873
|
+
const withoutTemplateLiterals = securityRule.replace(/`[^`]*`/g, '');
|
|
230874
|
+
const usesTemplateLiteralPlaceholderInRule = /['"][^'"]*\$\{(?:auth\.uid|doc\._id|doc\.[A-Za-z_][A-Za-z0-9_]*)\}/.test(withoutTemplateLiterals);
|
|
229447
230875
|
if (!usesTemplateLiteralPlaceholderInRule) {
|
|
229448
230876
|
return undefined;
|
|
229449
230877
|
}
|
|
@@ -230979,6 +232407,7 @@ const url_1 = __webpack_require__(79551);
|
|
|
230979
232407
|
const zod_1 = __webpack_require__(21504);
|
|
230980
232408
|
const index_js_1 = __webpack_require__(24908);
|
|
230981
232409
|
const remote_url_safety_js_1 = __webpack_require__(23694);
|
|
232410
|
+
const project_config_js_1 = __webpack_require__(39175);
|
|
230982
232411
|
// CloudBase 模板配置
|
|
230983
232412
|
const TEMPLATES = {
|
|
230984
232413
|
react: {
|
|
@@ -231464,6 +232893,23 @@ function registerSetupTools(server) {
|
|
|
231464
232893
|
};
|
|
231465
232894
|
}
|
|
231466
232895
|
const resolvedIDE = ideResolution.resolvedIDE;
|
|
232896
|
+
let workspaceFolder;
|
|
232897
|
+
try {
|
|
232898
|
+
workspaceFolder = (0, project_config_js_1.resolveProjectRoot)();
|
|
232899
|
+
}
|
|
232900
|
+
catch (error) {
|
|
232901
|
+
if (error instanceof project_config_js_1.ProjectRootError) {
|
|
232902
|
+
return {
|
|
232903
|
+
content: [
|
|
232904
|
+
{
|
|
232905
|
+
type: "text",
|
|
232906
|
+
text: (0, index_js_1.t)("setup.projectRoot.hostConfigDir", { dir: error.dir }),
|
|
232907
|
+
},
|
|
232908
|
+
],
|
|
232909
|
+
};
|
|
232910
|
+
}
|
|
232911
|
+
throw error;
|
|
232912
|
+
}
|
|
231467
232913
|
// 验证IDE类型
|
|
231468
232914
|
const ideValidation = validateIDE(resolvedIDE);
|
|
231469
232915
|
if (!ideValidation.valid) {
|
|
@@ -231501,7 +232947,6 @@ function registerSetupTools(server) {
|
|
|
231501
232947
|
// 创建过滤后的目录结构(当选择特定IDE时)
|
|
231502
232948
|
const workingDir = await createFilteredDirectory(extractDir, filteredFiles, resolvedIDE);
|
|
231503
232949
|
// 检查是否需要复制到项目目录
|
|
231504
|
-
const workspaceFolder = process.env.WORKSPACE_FOLDER_PATHS || process.cwd();
|
|
231505
232950
|
let finalFiles = [];
|
|
231506
232951
|
let createdCount = 0;
|
|
231507
232952
|
let overwrittenCount = 0;
|
|
@@ -232706,6 +234151,143 @@ function resolveRequestId(error) {
|
|
|
232706
234151
|
}
|
|
232707
234152
|
|
|
232708
234153
|
|
|
234154
|
+
/***/ },
|
|
234155
|
+
|
|
234156
|
+
/***/ 23379
|
|
234157
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
234158
|
+
|
|
234159
|
+
"use strict";
|
|
234160
|
+
|
|
234161
|
+
/**
|
|
234162
|
+
* In-process log of tool outcomes for an explicitly requested feedback draft.
|
|
234163
|
+
*
|
|
234164
|
+
* Hosted gateways may construct a new server object per request. The log is
|
|
234165
|
+
* therefore keyed by a hash of the credential when one is present, and only
|
|
234166
|
+
* falls back to the server object when no credential is available. The cache
|
|
234167
|
+
* is bounded. Arguments are never stored, and the raw credential is not stored.
|
|
234168
|
+
*/
|
|
234169
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
234170
|
+
exports.FEEDBACK_CREDENTIAL_LIMIT = exports.FEEDBACK_SESSION_LIMIT = void 0;
|
|
234171
|
+
exports.recordToolOutcome = recordToolOutcome;
|
|
234172
|
+
exports.readToolOutcomes = readToolOutcomes;
|
|
234173
|
+
exports.noteRepeatCount = noteRepeatCount;
|
|
234174
|
+
exports.readRepeatPeak = readRepeatPeak;
|
|
234175
|
+
exports.clearToolOutcomes = clearToolOutcomes;
|
|
234176
|
+
exports.__resetFeedbackSessionsForTests = __resetFeedbackSessionsForTests;
|
|
234177
|
+
const node_crypto_1 = __webpack_require__(75305);
|
|
234178
|
+
const MAX_OUTCOMES = 200;
|
|
234179
|
+
const MAX_CREDENTIALS = 64;
|
|
234180
|
+
const MAX_TOOL_NAME_LENGTH = 80;
|
|
234181
|
+
const byCredential = new Map();
|
|
234182
|
+
const byServer = new WeakMap();
|
|
234183
|
+
function credentialKey(server) {
|
|
234184
|
+
const options = server.cloudBaseOptions;
|
|
234185
|
+
const secretId = typeof options?.secretId === "string" ? options.secretId.trim() : "";
|
|
234186
|
+
if (!secretId) {
|
|
234187
|
+
return undefined;
|
|
234188
|
+
}
|
|
234189
|
+
const token = typeof options?.token === "string" ? options.token.trim() : "";
|
|
234190
|
+
const site = typeof options?.site === "string" ? options.site.trim() : "";
|
|
234191
|
+
return (0, node_crypto_1.createHash)("sha256").update(`${site}\n${secretId}\n${token}`).digest("hex");
|
|
234192
|
+
}
|
|
234193
|
+
function emptyBucket() {
|
|
234194
|
+
return { outcomes: [], repeatPeak: 0, touchedAt: Date.now() };
|
|
234195
|
+
}
|
|
234196
|
+
function evictOldestCredential() {
|
|
234197
|
+
let oldestKey;
|
|
234198
|
+
let oldestTouched = Number.POSITIVE_INFINITY;
|
|
234199
|
+
for (const [key, bucket] of byCredential) {
|
|
234200
|
+
if (bucket.touchedAt < oldestTouched) {
|
|
234201
|
+
oldestTouched = bucket.touchedAt;
|
|
234202
|
+
oldestKey = key;
|
|
234203
|
+
}
|
|
234204
|
+
}
|
|
234205
|
+
if (oldestKey) {
|
|
234206
|
+
byCredential.delete(oldestKey);
|
|
234207
|
+
}
|
|
234208
|
+
}
|
|
234209
|
+
function bucketFor(server) {
|
|
234210
|
+
if (!server || typeof server !== "object") {
|
|
234211
|
+
return undefined;
|
|
234212
|
+
}
|
|
234213
|
+
const key = credentialKey(server);
|
|
234214
|
+
if (key) {
|
|
234215
|
+
let bucket = byCredential.get(key);
|
|
234216
|
+
if (!bucket) {
|
|
234217
|
+
if (byCredential.size >= MAX_CREDENTIALS) {
|
|
234218
|
+
evictOldestCredential();
|
|
234219
|
+
}
|
|
234220
|
+
bucket = emptyBucket();
|
|
234221
|
+
byCredential.set(key, bucket);
|
|
234222
|
+
}
|
|
234223
|
+
bucket.touchedAt = Date.now();
|
|
234224
|
+
return bucket;
|
|
234225
|
+
}
|
|
234226
|
+
let bucket = byServer.get(server);
|
|
234227
|
+
if (!bucket) {
|
|
234228
|
+
bucket = emptyBucket();
|
|
234229
|
+
byServer.set(server, bucket);
|
|
234230
|
+
}
|
|
234231
|
+
return bucket;
|
|
234232
|
+
}
|
|
234233
|
+
function recordToolOutcome(server, input) {
|
|
234234
|
+
const bucket = bucketFor(server);
|
|
234235
|
+
if (!bucket) {
|
|
234236
|
+
return;
|
|
234237
|
+
}
|
|
234238
|
+
const toolName = typeof input.toolName === "string" ? input.toolName.trim() : "";
|
|
234239
|
+
if (!toolName) {
|
|
234240
|
+
return;
|
|
234241
|
+
}
|
|
234242
|
+
const durationMs = Number.isFinite(input.durationMs) && input.durationMs >= 0
|
|
234243
|
+
? Math.round(input.durationMs)
|
|
234244
|
+
: 0;
|
|
234245
|
+
const at = typeof input.at === "string" && input.at.length > 0
|
|
234246
|
+
? input.at
|
|
234247
|
+
: new Date().toISOString();
|
|
234248
|
+
bucket.outcomes.push({
|
|
234249
|
+
toolName: toolName.slice(0, MAX_TOOL_NAME_LENGTH),
|
|
234250
|
+
durationMs,
|
|
234251
|
+
failed: input.failed === true,
|
|
234252
|
+
at,
|
|
234253
|
+
});
|
|
234254
|
+
if (bucket.outcomes.length > MAX_OUTCOMES) {
|
|
234255
|
+
bucket.outcomes.splice(0, bucket.outcomes.length - MAX_OUTCOMES);
|
|
234256
|
+
}
|
|
234257
|
+
}
|
|
234258
|
+
function readToolOutcomes(server) {
|
|
234259
|
+
return bucketFor(server)?.outcomes ?? [];
|
|
234260
|
+
}
|
|
234261
|
+
function noteRepeatCount(server, count) {
|
|
234262
|
+
const bucket = bucketFor(server);
|
|
234263
|
+
if (!bucket || !Number.isFinite(count) || count <= 0) {
|
|
234264
|
+
return;
|
|
234265
|
+
}
|
|
234266
|
+
const rounded = Math.round(count);
|
|
234267
|
+
if (rounded > bucket.repeatPeak) {
|
|
234268
|
+
bucket.repeatPeak = rounded;
|
|
234269
|
+
}
|
|
234270
|
+
}
|
|
234271
|
+
function readRepeatPeak(server) {
|
|
234272
|
+
return bucketFor(server)?.repeatPeak ?? 0;
|
|
234273
|
+
}
|
|
234274
|
+
function clearToolOutcomes(server) {
|
|
234275
|
+
const key = server && typeof server === "object" ? credentialKey(server) : undefined;
|
|
234276
|
+
if (key) {
|
|
234277
|
+
byCredential.delete(key);
|
|
234278
|
+
return;
|
|
234279
|
+
}
|
|
234280
|
+
if (server && typeof server === "object") {
|
|
234281
|
+
byServer.delete(server);
|
|
234282
|
+
}
|
|
234283
|
+
}
|
|
234284
|
+
function __resetFeedbackSessionsForTests() {
|
|
234285
|
+
byCredential.clear();
|
|
234286
|
+
}
|
|
234287
|
+
exports.FEEDBACK_SESSION_LIMIT = MAX_OUTCOMES;
|
|
234288
|
+
exports.FEEDBACK_CREDENTIAL_LIMIT = MAX_CREDENTIALS;
|
|
234289
|
+
|
|
234290
|
+
|
|
232709
234291
|
/***/ },
|
|
232710
234292
|
|
|
232711
234293
|
/***/ 84173
|
|
@@ -233171,14 +234753,101 @@ async function sendDeployNotification(server, notificationData) {
|
|
|
233171
234753
|
"use strict";
|
|
233172
234754
|
|
|
233173
234755
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
234756
|
+
exports.ProjectRootError = void 0;
|
|
234757
|
+
exports.resolveProjectRoot = resolveProjectRoot;
|
|
234758
|
+
exports.requireProjectRoot = requireProjectRoot;
|
|
233174
234759
|
exports.readCloudbaseRcBinding = readCloudbaseRcBinding;
|
|
233175
234760
|
exports.readProjectConfig = readProjectConfig;
|
|
233176
234761
|
exports.readProjectEnvId = readProjectEnvId;
|
|
233177
234762
|
exports.writeProjectConfig = writeProjectConfig;
|
|
233178
234763
|
const node_fs_1 = __webpack_require__(89971);
|
|
234764
|
+
const node_os_1 = __webpack_require__(81258);
|
|
233179
234765
|
const node_path_1 = __webpack_require__(26743);
|
|
233180
234766
|
const toolbox_1 = __webpack_require__(23233);
|
|
234767
|
+
const index_js_1 = __webpack_require__(24908);
|
|
233181
234768
|
const CLOUDBASE_RC_FILENAME = "cloudbaserc.json";
|
|
234769
|
+
const PROJECT_ROOT_ENV_KEYS = [
|
|
234770
|
+
"WORKSPACE_FOLDER_PATHS",
|
|
234771
|
+
"PROJECT_ROOT",
|
|
234772
|
+
"GITHUB_WORKSPACE",
|
|
234773
|
+
"CI_PROJECT_DIR",
|
|
234774
|
+
"BUILD_SOURCESDIRECTORY",
|
|
234775
|
+
];
|
|
234776
|
+
/** Thrown when the resolved directory is a host config root, not a project. */
|
|
234777
|
+
class ProjectRootError extends Error {
|
|
234778
|
+
dir;
|
|
234779
|
+
constructor(dir) {
|
|
234780
|
+
super("setup.projectRoot.hostConfigDir");
|
|
234781
|
+
this.name = "ProjectRootError";
|
|
234782
|
+
this.dir = dir;
|
|
234783
|
+
}
|
|
234784
|
+
}
|
|
234785
|
+
exports.ProjectRootError = ProjectRootError;
|
|
234786
|
+
function firstPathSegment(value) {
|
|
234787
|
+
return value
|
|
234788
|
+
.split(node_path_1.delimiter)
|
|
234789
|
+
.map((segment) => segment.trim())
|
|
234790
|
+
.find((segment) => segment.length > 0);
|
|
234791
|
+
}
|
|
234792
|
+
function isUnderHostConfig(candidate) {
|
|
234793
|
+
const hostRoot = (0, node_path_1.resolve)((0, node_os_1.homedir)(), ".dsh");
|
|
234794
|
+
const resolved = (0, node_path_1.resolve)(candidate);
|
|
234795
|
+
const rel = (0, node_path_1.relative)(hostRoot, resolved);
|
|
234796
|
+
return rel === "" || (!rel.startsWith("..") && !(0, node_path_1.isAbsolute)(rel));
|
|
234797
|
+
}
|
|
234798
|
+
/**
|
|
234799
|
+
* Project directory for reads and writes.
|
|
234800
|
+
*
|
|
234801
|
+
* Explicit path, then host-injected workspace env vars, then process.cwd().
|
|
234802
|
+
* A result under ~/.dsh is refused so tools do not treat the host profile as a project.
|
|
234803
|
+
*/
|
|
234804
|
+
function resolveProjectRoot(explicit) {
|
|
234805
|
+
const trimmed = explicit?.trim();
|
|
234806
|
+
let chosen;
|
|
234807
|
+
if (trimmed) {
|
|
234808
|
+
chosen = (0, node_path_1.resolve)(trimmed);
|
|
234809
|
+
}
|
|
234810
|
+
else {
|
|
234811
|
+
let fromEnv;
|
|
234812
|
+
for (const key of PROJECT_ROOT_ENV_KEYS) {
|
|
234813
|
+
const raw = process.env[key];
|
|
234814
|
+
if (!raw?.trim())
|
|
234815
|
+
continue;
|
|
234816
|
+
const first = firstPathSegment(raw);
|
|
234817
|
+
if (first) {
|
|
234818
|
+
fromEnv = (0, node_path_1.resolve)(first);
|
|
234819
|
+
break;
|
|
234820
|
+
}
|
|
234821
|
+
}
|
|
234822
|
+
chosen = fromEnv ?? (0, node_path_1.resolve)(process.cwd());
|
|
234823
|
+
}
|
|
234824
|
+
if (isUnderHostConfig(chosen)) {
|
|
234825
|
+
throw new ProjectRootError(chosen);
|
|
234826
|
+
}
|
|
234827
|
+
return chosen;
|
|
234828
|
+
}
|
|
234829
|
+
/** Same as resolveProjectRoot, with the refusal already translated for tool output. */
|
|
234830
|
+
function requireProjectRoot(explicit) {
|
|
234831
|
+
try {
|
|
234832
|
+
return resolveProjectRoot(explicit);
|
|
234833
|
+
}
|
|
234834
|
+
catch (error) {
|
|
234835
|
+
if (error instanceof ProjectRootError) {
|
|
234836
|
+
throw new Error((0, index_js_1.t)("setup.projectRoot.hostConfigDir", { dir: error.dir }));
|
|
234837
|
+
}
|
|
234838
|
+
throw error;
|
|
234839
|
+
}
|
|
234840
|
+
}
|
|
234841
|
+
function projectRootForConfig(cwd) {
|
|
234842
|
+
try {
|
|
234843
|
+
return resolveProjectRoot(cwd);
|
|
234844
|
+
}
|
|
234845
|
+
catch (error) {
|
|
234846
|
+
if (error instanceof ProjectRootError)
|
|
234847
|
+
return undefined;
|
|
234848
|
+
throw error;
|
|
234849
|
+
}
|
|
234850
|
+
}
|
|
233182
234851
|
/**
|
|
233183
234852
|
* 解析 cloudbaserc.json 字段值用于绑定(fail-safe:解析不出一律返回 undefined 回落下一级):
|
|
233184
234853
|
* - 字面量 → trim 后直接返回
|
|
@@ -233236,7 +234905,9 @@ function resolveBindingValue(raw, projectRoot) {
|
|
|
233236
234905
|
*/
|
|
233237
234906
|
function readCloudbaseRcBinding(cwd) {
|
|
233238
234907
|
try {
|
|
233239
|
-
const projectRoot = cwd
|
|
234908
|
+
const projectRoot = projectRootForConfig(cwd);
|
|
234909
|
+
if (!projectRoot)
|
|
234910
|
+
return undefined;
|
|
233240
234911
|
const configPath = (0, node_path_1.join)(projectRoot, CLOUDBASE_RC_FILENAME);
|
|
233241
234912
|
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
233242
234913
|
return undefined;
|
|
@@ -233270,7 +234941,9 @@ function readCloudbaseRcBinding(cwd) {
|
|
|
233270
234941
|
*/
|
|
233271
234942
|
function readProjectConfig(cwd) {
|
|
233272
234943
|
try {
|
|
233273
|
-
const projectRoot = cwd
|
|
234944
|
+
const projectRoot = projectRootForConfig(cwd);
|
|
234945
|
+
if (!projectRoot)
|
|
234946
|
+
return undefined;
|
|
233274
234947
|
const configPath = (0, node_path_1.join)(projectRoot, ".cloudbase", "project.json");
|
|
233275
234948
|
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
233276
234949
|
return undefined;
|
|
@@ -233318,7 +234991,9 @@ function readProjectEnvId(cwd) {
|
|
|
233318
234991
|
*/
|
|
233319
234992
|
function writeProjectConfig(patch, cwd) {
|
|
233320
234993
|
try {
|
|
233321
|
-
const projectRoot = cwd
|
|
234994
|
+
const projectRoot = projectRootForConfig(cwd);
|
|
234995
|
+
if (!projectRoot)
|
|
234996
|
+
return false;
|
|
233322
234997
|
const configPath = (0, node_path_1.join)(projectRoot, ".cloudbase", "project.json");
|
|
233323
234998
|
let existing = {};
|
|
233324
234999
|
if ((0, node_fs_1.existsSync)(configPath)) {
|
|
@@ -233544,6 +235219,7 @@ function getRemoteUrlSafetyErrorMessage() {
|
|
|
233544
235219
|
|
|
233545
235220
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
233546
235221
|
exports.REPEAT_GUARD_THRESHOLD = void 0;
|
|
235222
|
+
exports.getRepeatGuardSnapshot = getRepeatGuardSnapshot;
|
|
233547
235223
|
exports.applyRepeatGuardToPayload = applyRepeatGuardToPayload;
|
|
233548
235224
|
exports.resetRepeatGuard = resetRepeatGuard;
|
|
233549
235225
|
exports.__resetRepeatGuardForTests = __resetRepeatGuardForTests;
|
|
@@ -233562,6 +235238,13 @@ exports.REPEAT_GUARD_THRESHOLD = 3;
|
|
|
233562
235238
|
const REPEAT_GUARD_KEY_MAX_LENGTH = 200;
|
|
233563
235239
|
let lastKey = null;
|
|
233564
235240
|
let consecutiveCount = 0;
|
|
235241
|
+
/**
|
|
235242
|
+
* Live streak only. Does not expose the dedup key: that key contains the raw
|
|
235243
|
+
* error message, which may include secrets or identifiers.
|
|
235244
|
+
*/
|
|
235245
|
+
function getRepeatGuardSnapshot() {
|
|
235246
|
+
return { consecutiveCount };
|
|
235247
|
+
}
|
|
233565
235248
|
function buildRepeatGuardKey(payload) {
|
|
233566
235249
|
const code = typeof payload.code === "string" ? payload.code : "";
|
|
233567
235250
|
const message = typeof payload.message === "string" ? payload.message : "";
|
|
@@ -234034,7 +235717,7 @@ class TelemetryReporter {
|
|
|
234034
235717
|
const arch = os_1.default.arch(); // 系统架构
|
|
234035
235718
|
// Build-time injected version; guard for vitest / non-webpack runtimes.
|
|
234036
235719
|
const mcpVersion = process.env.npm_package_version ||
|
|
234037
|
-
( true ? "2.34.
|
|
235720
|
+
( true ? "2.34.8" : 0);
|
|
234038
235721
|
return {
|
|
234039
235722
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
234040
235723
|
deviceId: this.deviceId,
|
|
@@ -234682,6 +236365,7 @@ const logger_js_1 = __webpack_require__(40781);
|
|
|
234682
236365
|
const telemetry_js_1 = __webpack_require__(5198);
|
|
234683
236366
|
const tool_result_js_1 = __webpack_require__(69645);
|
|
234684
236367
|
const repeat_error_guard_js_1 = __webpack_require__(13);
|
|
236368
|
+
const feedback_session_js_1 = __webpack_require__(23379);
|
|
234685
236369
|
const error_guidance_js_1 = __webpack_require__(81194);
|
|
234686
236370
|
/**
|
|
234687
236371
|
* Mirror annotations.category into _meta.category.
|
|
@@ -234757,7 +236441,7 @@ ${envIdSection}
|
|
|
234757
236441
|
## 环境信息
|
|
234758
236442
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
234759
236443
|
- Node.js版本: ${process.version}
|
|
234760
|
-
- MCP 版本:${( true ? "2.34.
|
|
236444
|
+
- MCP 版本:${( true ? "2.34.8" : 0) || 0 || 0}
|
|
234761
236445
|
- 系统架构: ${os_1.default.arch()}
|
|
234762
236446
|
- 时间: ${new Date().toISOString()}
|
|
234763
236447
|
- 请求ID: ${requestId}
|
|
@@ -234791,6 +236475,8 @@ function createWrappedHandler(name, handler, server) {
|
|
|
234791
236475
|
return async (args) => {
|
|
234792
236476
|
const startTime = Date.now();
|
|
234793
236477
|
let success = false;
|
|
236478
|
+
let businessFailed = false;
|
|
236479
|
+
let repeatCountSeen = 0;
|
|
234794
236480
|
let errorMessage;
|
|
234795
236481
|
let requestId;
|
|
234796
236482
|
try {
|
|
@@ -234802,7 +236488,11 @@ function createWrappedHandler(name, handler, server) {
|
|
|
234802
236488
|
}
|
|
234803
236489
|
// 执行原始处理函数
|
|
234804
236490
|
const result = await handler(args);
|
|
236491
|
+
// Returned { success: false } is a business failure for the local
|
|
236492
|
+
// session log. The telemetry flag below stays on the existing path.
|
|
236493
|
+
businessFailed = (0, tool_result_js_1.isBusinessFailureToolResult)(result);
|
|
234805
236494
|
success = true;
|
|
236495
|
+
repeatCountSeen = (0, repeat_error_guard_js_1.getRepeatGuardSnapshot)().consecutiveCount;
|
|
234806
236496
|
// 任一工具成功说明重复错误循环已被打破,清零连续错误计数
|
|
234807
236497
|
(0, repeat_error_guard_js_1.resetRepeatGuard)();
|
|
234808
236498
|
requestId = extractRequestIdFromToolResult(result);
|
|
@@ -234835,8 +236525,11 @@ function createWrappedHandler(name, handler, server) {
|
|
|
234835
236525
|
if ((0, tool_result_js_1.isToolPayloadError)(error)) {
|
|
234836
236526
|
// 连续相同结构化错误达到阈值时注入 repeat_guard 升级提示,
|
|
234837
236527
|
// 打断无头客户端的原样重试循环(不改写 message,保持遥测聚合稳定)
|
|
234838
|
-
|
|
236528
|
+
const payload = (0, repeat_error_guard_js_1.applyRepeatGuardToPayload)(error.payload);
|
|
236529
|
+
repeatCountSeen = (0, repeat_error_guard_js_1.getRepeatGuardSnapshot)().consecutiveCount;
|
|
236530
|
+
throw new tool_result_js_1.ToolPayloadError(payload);
|
|
234839
236531
|
}
|
|
236532
|
+
repeatCountSeen = (0, repeat_error_guard_js_1.getRepeatGuardSnapshot)().consecutiveCount;
|
|
234840
236533
|
// In tests, avoid any extra work that may block (envId lookup, issue link generation, etc.)
|
|
234841
236534
|
if (isTestEnvironment) {
|
|
234842
236535
|
throw error instanceof Error ? error : new Error(String(error));
|
|
@@ -234846,7 +236539,7 @@ function createWrappedHandler(name, handler, server) {
|
|
|
234846
236539
|
requestId,
|
|
234847
236540
|
ide: server.ide || process.env.INTEGRATION_IDE || ''
|
|
234848
236541
|
});
|
|
234849
|
-
const mcpVersion = true ? "2.34.
|
|
236542
|
+
const mcpVersion = true ? "2.34.8" : 0;
|
|
234850
236543
|
const requestIdSuffix = requestId ? `\n🆔 RequestId: ${requestId}` : '';
|
|
234851
236544
|
const enhancedErrorMessage = `${errorMessage}${requestIdSuffix}\n\n📦 CloudBase MCP v${mcpVersion}\n🔗 遇到问题?请复制以下链接到浏览器打开\n即可自动携带错误详情快速创建 GitHub Issue:\n${issueLink}`;
|
|
234852
236545
|
// 创建新的错误对象,保持原有的错误类型但更新消息
|
|
@@ -234862,6 +236555,20 @@ function createWrappedHandler(name, handler, server) {
|
|
|
234862
236555
|
throw enhancedError;
|
|
234863
236556
|
}
|
|
234864
236557
|
finally {
|
|
236558
|
+
try {
|
|
236559
|
+
(0, feedback_session_js_1.noteRepeatCount)(server, repeatCountSeen);
|
|
236560
|
+
(0, feedback_session_js_1.recordToolOutcome)(server, {
|
|
236561
|
+
toolName: name,
|
|
236562
|
+
durationMs: Date.now() - startTime,
|
|
236563
|
+
failed: Boolean(errorMessage) || businessFailed,
|
|
236564
|
+
});
|
|
236565
|
+
}
|
|
236566
|
+
catch (recordError) {
|
|
236567
|
+
(0, logger_js_1.debug)("feedback session record failed", {
|
|
236568
|
+
toolName: name,
|
|
236569
|
+
error: recordError instanceof Error ? recordError.message : String(recordError),
|
|
236570
|
+
});
|
|
236571
|
+
}
|
|
234865
236572
|
// 上报工具调用数据(测试环境中跳过,避免阻塞)
|
|
234866
236573
|
const isTestEnvironment = false || process.env.VITEST === "true";
|
|
234867
236574
|
if (!isTestEnvironment) {
|