@cloudbase/manager-node 4.11.0-alpha.5 → 4.11.0-alpha.7

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.
@@ -924,6 +924,56 @@ class FunctionService {
924
924
  });
925
925
  }
926
926
  }
927
+ /**
928
+ * 更新函数代码和配置(带进度信息)
929
+ * 支持同时更新代码和配置,按顺序执行:等待就绪 → 更新代码 → 等待就绪 → 更新配置 → 等待就绪
930
+ * @param options 更新选项
931
+ * @returns 更新结果,包含耗时信息
932
+ */
933
+ async updateFunctionWithProgress(options) {
934
+ const { name, code, config } = options;
935
+ const startTime = Date.now();
936
+ const details = [];
937
+ // codeSecret 在不同阶段可能不同:
938
+ // - 更新代码前/后:用旧的 codeSecret(函数此时还是旧密钥)
939
+ // - 更新配置后:如果 config 中带了新 codeSecret,函数密钥已变更,需用新值
940
+ const oldCodeSecret = (code === null || code === void 0 ? void 0 : code.codeSecret) || (config === null || config === void 0 ? void 0 : config.codeSecret);
941
+ const newCodeSecret = (config === null || config === void 0 ? void 0 : config.codeSecret) || (code === null || code === void 0 ? void 0 : code.codeSecret);
942
+ // 1. 等待函数状态就绪(此时函数还是旧密钥)
943
+ details.push('等待函数状态就绪...');
944
+ await this.waitFunctionActive(name, oldCodeSecret);
945
+ details.push(`函数状态就绪 (${Math.round((Date.now() - startTime) / 1000)}s)`);
946
+ // 2. 更新代码
947
+ if (code && (code.functionPath || code.base64Code)) {
948
+ details.push('开始更新代码...');
949
+ await this.updateFunctionCode(Object.assign({ func: {
950
+ name,
951
+ // 从 config 取公共字段
952
+ runtime: config === null || config === void 0 ? void 0 : config.runtime,
953
+ installDependency: config === null || config === void 0 ? void 0 : config.installDependency,
954
+ ignore: config === null || config === void 0 ? void 0 : config.ignore,
955
+ codeSecret: oldCodeSecret
956
+ } }, code));
957
+ details.push(`代码更新完成 (${Math.round((Date.now() - startTime) / 1000)}s)`);
958
+ // 等待函数再次就绪(代码更新不改变 codeSecret,仍用旧值)
959
+ await this.waitFunctionActive(name, oldCodeSecret);
960
+ }
961
+ // 3. 更新配置
962
+ if (config) {
963
+ details.push('开始更新配置...');
964
+ await this.updateFunctionConfig(Object.assign({ name }, config));
965
+ details.push(`配置更新完成 (${Math.round((Date.now() - startTime) / 1000)}s)`);
966
+ // 等待函数再次就绪(配置更新后 codeSecret 可能已变更,用新值)
967
+ await this.waitFunctionActive(name, newCodeSecret);
968
+ }
969
+ const elapsedTime = Date.now() - startTime;
970
+ details.push(`全部更新完成 (${Math.round(elapsedTime / 1000)}s)`);
971
+ return {
972
+ elapsedTime,
973
+ message: `更新成功,总耗时 ${Math.round(elapsedTime / 1000)}s`,
974
+ details
975
+ };
976
+ }
927
977
  /**
928
978
  * 调用云函数
929
979
  * @param {string} name 云函数名称
@@ -1471,7 +1521,13 @@ class FunctionService {
1471
1521
  }
1472
1522
  });
1473
1523
  return new Promise((resolve, reject) => {
1524
+ // 添加超时保护
1525
+ const timeout = setTimeout(() => {
1526
+ packer.clean();
1527
+ reject(new error_1.CloudBaseError(`[${func.name}] COS 上传超时(60秒)`));
1528
+ }, 60000);
1474
1529
  cos.sliceUploadFile(uploadParams, async (err, data) => {
1530
+ clearTimeout(timeout);
1475
1531
  // 清理临时文件
1476
1532
  await packer.clean();
1477
1533
  if (err) {
@@ -1550,29 +1606,6 @@ class FunctionService {
1550
1606
  UnixTimestamp
1551
1607
  };
1552
1608
  }
1553
- async createAccessPath(name, path) {
1554
- const access = this.environment.getAccessService();
1555
- try {
1556
- await access.createAccess({
1557
- name,
1558
- path
1559
- });
1560
- }
1561
- catch (e) {
1562
- // 当 Path 存在时,校验 Path 绑定的函数是不是当前函数
1563
- if (e.code === 'InvalidParameter.APICreated') {
1564
- const { APISet } = await access.getAccessList({
1565
- name
1566
- });
1567
- if ((APISet === null || APISet === void 0 ? void 0 : APISet[0].Name) !== name || (APISet === null || APISet === void 0 ? void 0 : APISet[0].Type) !== 1) {
1568
- throw e;
1569
- }
1570
- }
1571
- else {
1572
- throw e;
1573
- }
1574
- }
1575
- }
1576
1609
  async getCodeParams(options, installDependency) {
1577
1610
  const { func, functionPath, functionRootPath, base64Code, deployMode } = options;
1578
1611
  // 直接传入 base64Code 的情况,校验大小
@@ -1625,6 +1658,29 @@ class FunctionService {
1625
1658
  TempCosObjectName: `/${legacyResult.Key}`
1626
1659
  };
1627
1660
  }
1661
+ async createAccessPath(name, path) {
1662
+ const access = this.environment.getAccessService();
1663
+ try {
1664
+ await access.createAccess({
1665
+ name,
1666
+ path
1667
+ });
1668
+ }
1669
+ catch (e) {
1670
+ // 当 Path 存在时,校验 Path 绑定的函数是不是当前函数
1671
+ if (e.code === 'InvalidParameter.APICreated') {
1672
+ const { APISet } = await access.getAccessList({
1673
+ name
1674
+ });
1675
+ if ((APISet === null || APISet === void 0 ? void 0 : APISet[0].Name) !== name || (APISet === null || APISet === void 0 ? void 0 : APISet[0].Type) !== 1) {
1676
+ throw e;
1677
+ }
1678
+ }
1679
+ else {
1680
+ throw e;
1681
+ }
1682
+ }
1683
+ }
1628
1684
  // 获取 COS 临时信息
1629
1685
  async getTempCosInfo(name) {
1630
1686
  const { env, appId } = await this.getFunctionConfig();
@@ -1755,6 +1811,9 @@ __decorate([
1755
1811
  __decorate([
1756
1812
  (0, utils_1.preLazy)()
1757
1813
  ], FunctionService.prototype, "updateFunctionCode", null);
1814
+ __decorate([
1815
+ (0, utils_1.preLazy)()
1816
+ ], FunctionService.prototype, "updateFunctionWithProgress", null);
1758
1817
  __decorate([
1759
1818
  (0, utils_1.preLazy)()
1760
1819
  ], FunctionService.prototype, "invokeFunction", null);
@@ -1829,10 +1888,10 @@ __decorate([
1829
1888
  ], FunctionService.prototype, "uploadFunctionZipToCos", null);
1830
1889
  __decorate([
1831
1890
  (0, utils_1.preLazy)()
1832
- ], FunctionService.prototype, "createAccessPath", null);
1891
+ ], FunctionService.prototype, "getCodeParams", null);
1833
1892
  __decorate([
1834
1893
  (0, utils_1.preLazy)()
1835
- ], FunctionService.prototype, "getCodeParams", null);
1894
+ ], FunctionService.prototype, "createAccessPath", null);
1836
1895
  __decorate([
1837
1896
  (0, utils_1.preLazy)()
1838
1897
  ], FunctionService.prototype, "getTempCosInfo", null);
package/lib/index.js CHANGED
@@ -79,6 +79,9 @@ class CloudBase {
79
79
  get env() {
80
80
  return this.currentEnvironment().getEnvService();
81
81
  }
82
+ get log() {
83
+ return this.currentEnvironment().getLogService();
84
+ }
82
85
  get third() {
83
86
  return this.currentEnvironment().getThirdService();
84
87
  }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.LogService = void 0;
18
+ const utils_1 = require("../utils");
19
+ __exportStar(require("./types"), exports);
20
+ class LogService {
21
+ constructor(environment) {
22
+ this.envId = environment.getEnvId();
23
+ this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
24
+ this.tcbrService = new utils_1.CloudService(environment.cloudBaseContext, 'tcbr', '2022-02-17');
25
+ }
26
+ /**
27
+ * 搜索 CLS 日志
28
+ *
29
+ * @param params 查询参数,通过 queryString 使用 CLS 原生检索分析语法
30
+ * @returns 日志搜索结果
31
+ *
32
+ * @remarks
33
+ * - 纯检索结果在 `LogResults.Results` 中
34
+ * - SQL 分析结果(queryString 含 `| select ...`)在 `LogResults.AnalysisRecords` 中
35
+ * - 详细的 QueryString 语法参考见 README.md
36
+ */
37
+ async searchClsLog(params) {
38
+ const { queryString, StartTime, EndTime, Limit, Context, Sort, UseLucene, service } = params;
39
+ const requestService = service === 'tcbr' ? this.tcbrService : this.cloudService;
40
+ const requestParams = {
41
+ EnvId: this.envId,
42
+ StartTime,
43
+ EndTime,
44
+ QueryString: queryString,
45
+ Limit,
46
+ Context,
47
+ Sort,
48
+ UseLucene
49
+ };
50
+ // TenantModel 仅 tcb 服务需要,tcbr 不支持该参数
51
+ if (service !== 'tcbr') {
52
+ requestParams.TenantModel = 'public';
53
+ }
54
+ return requestService.request('SearchClsLog', requestParams);
55
+ }
56
+ }
57
+ exports.LogService = LogService;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ // =====================================================
3
+ // CLS 日志字段枚举 & Module 查询 Schema
4
+ // =====================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CLS_MODULE_SCHEMA = void 0;
7
+ // =====================================================
8
+ // CLS Module 运行时常量
9
+ // =====================================================
10
+ /**
11
+ * ClsModuleSchema 的运行时版本,用于动态生成查询条件 / MCP tool description
12
+ *
13
+ * - key 与 ClsLogModule 类型保持同步
14
+ * - eventTypes / logTypes 为字符串数组,空数组表示该维度不可过滤
15
+ */
16
+ exports.CLS_MODULE_SCHEMA = {
17
+ database: { label: '云数据库(文档型)', eventTypes: ['MongoSlowQuery'], logTypes: [] },
18
+ rdb: { label: '云数据库(SQL型)', eventTypes: ['MysqlFreeze', 'MysqlRecover', 'MysqlSlowQuery'], logTypes: [] },
19
+ model: { label: '数据模型', eventTypes: [], logTypes: [] },
20
+ workflow: { label: '审批流', eventTypes: [], logTypes: [] },
21
+ auth: { label: '用户权限', eventTypes: [], logTypes: [] },
22
+ llm: { label: '大模型', eventTypes: [], logTypes: ['llm-tracelog'] },
23
+ app: { label: '应用', eventTypes: ['AppProdPub', 'AppProdDel'], logTypes: [] },
24
+ };
package/lib/user/index.js CHANGED
@@ -114,6 +114,194 @@ class UserService {
114
114
  async getTcbAccountInfo() {
115
115
  return this.tcbService.request('DescribeTcbAccountInfo');
116
116
  }
117
+ async createUser(options) {
118
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
119
+ const { name, uid, type, password, userStatus, nickName, phone, email, avatarUrl, description } = options;
120
+ // name 校验:1-64,字母/数字开头,仅字母数字._-
121
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(name)) {
122
+ throw new Error('Invalid name');
123
+ }
124
+ // uid 校验:<=64
125
+ if (uid && uid.length > 64) {
126
+ throw new Error('Invalid uid');
127
+ }
128
+ // type / status 白名单
129
+ if (type && !['internalUser', 'externalUser'].includes(type)) {
130
+ throw new Error('Invalid type');
131
+ }
132
+ if (userStatus && !['ACTIVE', 'BLOCKED'].includes(userStatus)) {
133
+ throw new Error('Invalid userStatus');
134
+ }
135
+ if (password) {
136
+ if (password.length < 8 || password.length > 32) {
137
+ throw new Error('Invalid password length');
138
+ }
139
+ if (!/^[A-Za-z0-9]/.test(password)) {
140
+ throw new Error('Password cannot start with special character');
141
+ }
142
+ const kinds = [
143
+ /[a-z]/.test(password),
144
+ /[A-Z]/.test(password),
145
+ /[0-9]/.test(password),
146
+ /[()!@#$%^&*|?><_-]/.test(password)
147
+ ].filter(Boolean).length;
148
+ if (kinds < 3) {
149
+ throw new Error('Password must include at least 3 character categories');
150
+ }
151
+ }
152
+ // 其他字段校验
153
+ if (nickName && (nickName.length < 2 || nickName.length > 64)) {
154
+ throw new Error('Invalid nickName');
155
+ }
156
+ if (description && description.length > 200) {
157
+ throw new Error('Invalid description');
158
+ }
159
+ if (phone && !/^1\d{10}$/.test(phone)) {
160
+ throw new Error('Invalid phone');
161
+ }
162
+ if (email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
163
+ throw new Error('Invalid email');
164
+ }
165
+ const reqData = {
166
+ EnvId,
167
+ Name: name
168
+ };
169
+ if (uid)
170
+ reqData.Uid = uid;
171
+ if (type)
172
+ reqData.Type = type;
173
+ if (password)
174
+ reqData.Password = password;
175
+ if (userStatus)
176
+ reqData.UserStatus = userStatus;
177
+ if (nickName)
178
+ reqData.NickName = nickName;
179
+ if (phone)
180
+ reqData.Phone = phone;
181
+ if (email)
182
+ reqData.Email = email;
183
+ if (avatarUrl)
184
+ reqData.AvatarUrl = avatarUrl;
185
+ if (description)
186
+ reqData.Description = description;
187
+ return this.tcbService.request('CreateUser', reqData);
188
+ }
189
+ async describeUserList(options = {}) {
190
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
191
+ const { pageNo = 1, pageSize = 20, name, nickName, phone, email } = options;
192
+ if (!Number.isInteger(pageNo) || pageNo < 1) {
193
+ throw new Error('Invalid pageNo');
194
+ }
195
+ if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100) {
196
+ throw new Error('Invalid pageSize');
197
+ }
198
+ const reqData = {
199
+ EnvId,
200
+ PageNo: pageNo,
201
+ PageSize: pageSize
202
+ };
203
+ if (this.isValidStr(name))
204
+ reqData.Name = name;
205
+ if (this.isValidStr(nickName))
206
+ reqData.NickName = nickName;
207
+ if (this.isValidStr(phone))
208
+ reqData.Phone = phone;
209
+ if (this.isValidStr(email))
210
+ reqData.Email = email;
211
+ return this.tcbService.request('DescribeUserList', reqData);
212
+ }
213
+ async modifyUser(options) {
214
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
215
+ const { uid, name, type, password, userStatus, nickName, phone, email, avatarUrl, description } = options;
216
+ if (!this.isValidStr(uid) || uid.length > 64) {
217
+ throw new Error('Invalid uid');
218
+ }
219
+ // Name: 不传或空字符串 => 不修改;传了非空则校验
220
+ if (name !== undefined && name !== '' && !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(name)) {
221
+ throw new Error('Invalid name');
222
+ }
223
+ // Type / UserStatus: 不传或空字符串 => 不修改;非空时白名单校验
224
+ if (type !== undefined && !['internalUser', 'externalUser'].includes(type)) {
225
+ throw new Error('Invalid type');
226
+ }
227
+ if (userStatus !== undefined && !['ACTIVE', 'BLOCKED'].includes(userStatus)) {
228
+ throw new Error('Invalid userStatus');
229
+ }
230
+ // Password: 不传或空字符串 => 不修改;非空时校验复杂度
231
+ if (password !== undefined && password !== '') {
232
+ if (password.length < 8 || password.length > 32) {
233
+ throw new Error('Invalid password length');
234
+ }
235
+ if (!/^[A-Za-z0-9]/.test(password)) {
236
+ throw new Error('Password cannot start with special character');
237
+ }
238
+ const kinds = [
239
+ /[a-z]/.test(password),
240
+ /[A-Z]/.test(password),
241
+ /[0-9]/.test(password),
242
+ /[()!@#$%^&*|?><_-]/.test(password)
243
+ ].filter(Boolean).length;
244
+ if (kinds < 3) {
245
+ throw new Error('Password must include at least 3 character categories');
246
+ }
247
+ }
248
+ // 这些字段:不传 => 不修改;传空字符串 => 清空(允许)
249
+ if (nickName !== undefined && nickName !== '' && (nickName.length < 2 || nickName.length > 64)) {
250
+ throw new Error('Invalid nickName');
251
+ }
252
+ if (phone !== undefined && phone !== '' && !/^1\d{10}$/.test(phone)) {
253
+ throw new Error('Invalid phone');
254
+ }
255
+ if (email !== undefined && email !== '' && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
256
+ throw new Error('Invalid email');
257
+ }
258
+ if (description !== undefined && description !== '' && description.length > 200) {
259
+ throw new Error('Invalid description');
260
+ }
261
+ const reqData = {
262
+ EnvId,
263
+ Uid: uid
264
+ };
265
+ // Name/Type/Password/UserStatus:空字符串视为不修改
266
+ if (name !== undefined && name !== '')
267
+ reqData.Name = name;
268
+ if (type !== undefined)
269
+ reqData.Type = type;
270
+ if (password !== undefined && password !== '')
271
+ reqData.Password = password;
272
+ if (userStatus !== undefined)
273
+ reqData.UserStatus = userStatus;
274
+ // 这些字段支持传空字符串清空:只要“传了”就下发
275
+ if (Object.prototype.hasOwnProperty.call(options, 'nickName'))
276
+ reqData.NickName = nickName;
277
+ if (Object.prototype.hasOwnProperty.call(options, 'phone'))
278
+ reqData.Phone = phone;
279
+ if (Object.prototype.hasOwnProperty.call(options, 'email'))
280
+ reqData.Email = email;
281
+ if (Object.prototype.hasOwnProperty.call(options, 'avatarUrl'))
282
+ reqData.AvatarUrl = avatarUrl;
283
+ if (Object.prototype.hasOwnProperty.call(options, 'description'))
284
+ reqData.Description = description;
285
+ return this.tcbService.request('ModifyUser', reqData);
286
+ }
287
+ async deleteUsers(options) {
288
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
289
+ const { uids } = options;
290
+ if (!Array.isArray(uids) || uids.length === 0) {
291
+ throw new Error('uids is required');
292
+ }
293
+ if (uids.length > 100) {
294
+ throw new Error('uids length must be <= 100');
295
+ }
296
+ const invalidUid = uids.find(uid => !this.isValidStr(uid));
297
+ if (invalidUid) {
298
+ throw new Error('Invalid uid in uids');
299
+ }
300
+ return this.tcbService.request('DeleteUsers', {
301
+ EnvId,
302
+ Uids: uids
303
+ });
304
+ }
117
305
  isValidStr(obj) {
118
306
  return typeof obj === 'string' && obj.trim().length > 0;
119
307
  }
@@ -137,3 +325,15 @@ __decorate([
137
325
  __decorate([
138
326
  (0, utils_1.preLazy)()
139
327
  ], UserService.prototype, "updateEndUser", null);
328
+ __decorate([
329
+ (0, utils_1.preLazy)()
330
+ ], UserService.prototype, "createUser", null);
331
+ __decorate([
332
+ (0, utils_1.preLazy)()
333
+ ], UserService.prototype, "describeUserList", null);
334
+ __decorate([
335
+ (0, utils_1.preLazy)()
336
+ ], UserService.prototype, "modifyUser", null);
337
+ __decorate([
338
+ (0, utils_1.preLazy)()
339
+ ], UserService.prototype, "deleteUsers", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.11.0-alpha.5",
3
+ "version": "4.11.0-alpha.7",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,17 +1,127 @@
1
1
  import { Environment } from '../environment';
2
- import { ICreateFunctionAgentParams } from './type';
2
+ import { ICreateFunctionAgentParams, ICreateScfAgentParams, ICreateTcbrAgentByImageParams, ICreateTcbrAgentByPackageParams, ICreateTcbrAgentByCodeParams, IDescribeAgentListParams, IDescribeAgentListResponse, IDescribeAgentResponse, IDeleteAgentParams, IDescribeCloudBaseBuildServiceParams, IDescribeCloudBaseBuildServiceResponse, ICreateAgentResponse, IDeleteAgentResponse, ICommonResponse, IUpdateAgentParams, IUpdateScfAgentParams, IUpdateScfAgentResponse, IUpdateTcbrAgentParams, IGetAgentLogsParams } from './type';
3
3
  /**
4
4
  * Agent 管理类
5
+ * 支持三种部署方式:
6
+ * - SCF 云函数:轻量级、按需计费
7
+ * - TCBR 云托管-镜像:容器化部署
8
+ * - TCBR 云托管-代码包:源码部署
5
9
  */
6
10
  export declare class AgentService {
7
11
  private environment;
8
12
  private tcbService;
9
13
  constructor(environment: Environment);
10
14
  /**
11
- * 创建函数型 Agent
12
- * @param {string} [cwd=process.cwd()] 工作目录
13
- * @param {ICreateFunctionAgentParams} agentInfo Agent 信息
14
- * @returns {Promise<{ BotId: string; RequestId: string }>} Agent 创建结果
15
+ * 创建 SCF Agent
16
+ * 支持两种方式:
17
+ * 1. 传入 cwd 代码目录,自动打包上传
18
+ * 2. 传入 ZipFile / CosBucketRegion + TempCosObjectName,直接上传
19
+ * @param params 创建参数
20
+ * @returns Agent 创建结果
21
+ */
22
+ createScfAgent(params: ICreateScfAgentParams): Promise<ICreateAgentResponse>;
23
+ /**
24
+ * 查询 Agent 列表
25
+ * @param params 查询参数
26
+ * @returns Agent 列表
27
+ */
28
+ describeAgentList(params?: IDescribeAgentListParams): Promise<IDescribeAgentListResponse>;
29
+ /**
30
+ * 查询单个 Agent 详情(包含可用状态)
31
+ * @param agentId Agent ID
32
+ * @returns Agent 详情,IsReady 表示是否可用
33
+ * @example
34
+ * ```typescript
35
+ * const result = await agentService.describeAgent('agent-xxx')
36
+ * if (result.IsReady) {
37
+ * console.log('Agent 已就绪,可以调用')
38
+ * } else {
39
+ * console.log('Agent 不可用:', result.NotReadyReason)
40
+ * }
41
+ * ```
42
+ */
43
+ describeAgent(agentId: string): Promise<IDescribeAgentResponse>;
44
+ /**
45
+ * 删除 Agent
46
+ * 先删除 Agent 记录,再尝试删除底层的云函数或云托管服务
47
+ * @param params 删除参数
48
+ * @returns 操作结果,包含 Agent 和底层资源的删除状态
49
+ */
50
+ deleteAgent(params: IDeleteAgentParams): Promise<IDeleteAgentResponse>;
51
+ /**
52
+ * 更新 Agent(自动判断类型)
53
+ * 先查询 Agent 类型,然后调用对应的更新方法
54
+ * @param params 更新参数
55
+ * @returns 操作结果
56
+ */
57
+ updateAgent(params: IUpdateAgentParams): Promise<IUpdateScfAgentResponse>;
58
+ /**
59
+ * 更新 SCF Agent(云函数)
60
+ * 支持两种方式:本地代码目录、ZIP 文件
61
+ * @param params 更新参数
62
+ * @returns 更新结果,包含耗时信息
63
+ */
64
+ updateScfAgent(params: IUpdateScfAgentParams): Promise<IUpdateScfAgentResponse>;
65
+ /**
66
+ * 获取 Agent 调用日志(自动判断类型)
67
+ * @param params 查询参数
68
+ * @returns 日志结果,根据 Agent 类型返回不同结构:
69
+ * - SCF: IFunctionLogDetailRes[]
70
+ * - TCBR: ISearchClsLogResponse
71
+ * @example
72
+ * ```typescript
73
+ * const logs = await agentService.getAgentLogs({
74
+ * AgentId: 'agent-xxx',
75
+ * limit: 20,
76
+ * startTime: '2025-01-01 00:00:00',
77
+ * endTime: '2025-01-01 23:59:59'
78
+ * })
79
+ * ```
80
+ */
81
+ getAgentLogs(params: IGetAgentLogsParams): Promise<any>;
82
+ /**
83
+ * 通过镜像创建 TCBR Agent
84
+ * @internal 暂不对外暴露,后续版本开放
85
+ * @param params 创建参数
86
+ * @returns Agent 创建结果
87
+ */
88
+ createTcbrAgentByImage(params: ICreateTcbrAgentByImageParams): Promise<ICreateAgentResponse>;
89
+ /**
90
+ * 获取代码包上传信息
91
+ * @internal 暂不对外暴露,后续版本开放
92
+ * @param params 查询参数
93
+ * @returns 上传信息
94
+ */
95
+ describeCloudBaseBuildService(params: IDescribeCloudBaseBuildServiceParams): Promise<IDescribeCloudBaseBuildServiceResponse>;
96
+ /**
97
+ * 通过代码包信息创建 TCBR Agent(已上传代码包)
98
+ * @internal 暂不对外暴露,后续版本开放
99
+ * @param params 创建参数
100
+ * @returns Agent 创建结果
101
+ */
102
+ createTcbrAgentByPackage(params: ICreateTcbrAgentByPackageParams): Promise<ICreateAgentResponse>;
103
+ /**
104
+ * 通过本地代码创建 TCBR Agent(自动打包上传)
105
+ * @internal 暂不对外暴露,后续版本开放
106
+ * @param cwd 代码目录,默认当前工作目录
107
+ * @param params 创建参数
108
+ * @returns Agent 创建结果
109
+ */
110
+ createTcbrAgentByCode(cwd: string, params: ICreateTcbrAgentByCodeParams): Promise<ICreateAgentResponse>;
111
+ /**
112
+ * 更新 TCBR Agent(云托管)
113
+ * 支持两种方式:本地代码目录、镜像
114
+ * @internal 暂不对外暴露,后续版本开放
115
+ * @param params 更新参数
116
+ * @returns 操作结果
117
+ */
118
+ updateTcbrAgent(params: IUpdateTcbrAgentParams): Promise<ICommonResponse>;
119
+ /**
120
+ * @deprecated 请使用 createTcbrAgentByCode
121
+ * 创建函数型 Agent(旧版)
122
+ * @param cwd 工作目录
123
+ * @param agentInfo Agent 信息
124
+ * @returns Agent 创建结果
15
125
  */
16
126
  createFunctionAgent(cwd: string, agentInfo: ICreateFunctionAgentParams): Promise<{
17
127
  BotId: string;