@cloudbase/manager-node 4.11.0-alpha.6 → 4.11.0-alpha.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/lib/agent/index.js +607 -16
- package/lib/agent/type.js +1 -0
- package/lib/environment.js +10 -0
- package/lib/function/index.js +84 -25
- package/lib/index.js +6 -0
- package/lib/log/index.js +105 -0
- package/lib/log/types.js +24 -0
- package/lib/permission/index.js +313 -0
- package/lib/permission/types.js +2 -0
- package/package.json +1 -1
- package/types/agent/index.d.ts +115 -5
- package/types/agent/type.d.ts +389 -0
- package/types/environment.d.ts +6 -0
- package/types/function/index.d.ts +30 -1
- package/types/index.d.ts +4 -0
- package/types/log/index.d.ts +53 -0
- package/types/log/types.d.ts +177 -0
- package/types/permission/index.d.ts +31 -0
- package/types/permission/types.d.ts +127 -0
package/types/agent/index.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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;
|
package/types/agent/type.d.ts
CHANGED
|
@@ -1,3 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent 类型
|
|
3
|
+
*/
|
|
4
|
+
export type AgentType = 'scf' | 'tcbr';
|
|
5
|
+
/**
|
|
6
|
+
* 运行时版本
|
|
7
|
+
*/
|
|
8
|
+
export type RuntimeVersion = 'Nodejs20.19' | 'Nodejs18.15' | 'Nodejs16.13' | 'Nodejs14.18' | 'Python3.10' | 'Python3.9' | 'Python3.7' | 'Php8.0' | 'Php7.4' | 'Go1' | 'Java11' | 'Java8';
|
|
9
|
+
/**
|
|
10
|
+
* 会话来源
|
|
11
|
+
*/
|
|
12
|
+
export type SessionSource = 'HEADER' | 'COOKIE' | 'QUERY_STRING';
|
|
13
|
+
/**
|
|
14
|
+
* 会话配置
|
|
15
|
+
*/
|
|
16
|
+
export interface ISessionConfig {
|
|
17
|
+
/** 会话来源,默认 'HEADER' */
|
|
18
|
+
SessionSource?: SessionSource;
|
|
19
|
+
/** 会话名称,5-40字符,字母开头 */
|
|
20
|
+
SessionName?: string;
|
|
21
|
+
/** 单实例并发会话数,1-100,默认 1 */
|
|
22
|
+
MaximumConcurrencySessionPerInstance?: number;
|
|
23
|
+
/** 会话最长生命周期(秒),1-604800,默认 21600 */
|
|
24
|
+
MaximumTTLInSeconds?: number;
|
|
25
|
+
/** 会话最长空闲时间(秒),不超过 TTL,默认 1800 */
|
|
26
|
+
MaximumIdleTimeInSeconds?: number;
|
|
27
|
+
/** 单实例最大并发数,1-100,默认 50 */
|
|
28
|
+
MaxConcurrency?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 创建 SCF Agent 的参数
|
|
32
|
+
* 支持两种方式:
|
|
33
|
+
* 1. 传入 cwd 代码目录,自动打包上传
|
|
34
|
+
* 2. 传入 ZipFile / CosBucketRegion + TempCosObjectName,直接上传
|
|
35
|
+
*/
|
|
36
|
+
export interface ICreateScfAgentParams {
|
|
37
|
+
/** Agent 名称 */
|
|
38
|
+
Name: string;
|
|
39
|
+
/** Agent ID,不传则自动生成 */
|
|
40
|
+
AgentId?: string;
|
|
41
|
+
/** 环境变量 */
|
|
42
|
+
envVariables?: Record<string, string>;
|
|
43
|
+
/** 运行时版本 */
|
|
44
|
+
Runtime: RuntimeVersion;
|
|
45
|
+
/** 超时时间(秒),1-900,默认 3 */
|
|
46
|
+
Timeout?: number;
|
|
47
|
+
/** 函数运行时内存大小(MB),可选 64、128-3072(128为阶梯),默认 128 */
|
|
48
|
+
MemorySize?: number;
|
|
49
|
+
/** 是否自动安装依赖,默认 false */
|
|
50
|
+
InstallDependency?: boolean;
|
|
51
|
+
/** 会话配置 */
|
|
52
|
+
SessionConfig?: ISessionConfig;
|
|
53
|
+
/** 代码目录路径 */
|
|
54
|
+
cwd?: string;
|
|
55
|
+
/** 忽略的文件模式 */
|
|
56
|
+
ignore?: string | string[];
|
|
57
|
+
/** 部署方式:zip(直接上传)或 cos(COS 上传,大文件推荐) */
|
|
58
|
+
deployMode?: 'zip' | 'cos';
|
|
59
|
+
/** Base64 编码的 ZIP 文件内容 */
|
|
60
|
+
ZipFile?: string;
|
|
61
|
+
/** COS Bucket 区域 */
|
|
62
|
+
CosBucketRegion?: string;
|
|
63
|
+
/** COS 临时对象名称 */
|
|
64
|
+
TempCosObjectName?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 仓库信息
|
|
68
|
+
*/
|
|
69
|
+
export interface IRepoInfo {
|
|
70
|
+
/** Git 仓库地址或模板下载地址 */
|
|
71
|
+
Repo: string;
|
|
72
|
+
/** 来源标识,如 'template' */
|
|
73
|
+
Source: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 通过镜像创建 TCBR Agent 的参数
|
|
77
|
+
*/
|
|
78
|
+
export interface ICreateTcbrAgentByImageParams {
|
|
79
|
+
/** Agent 名称 */
|
|
80
|
+
Name: string;
|
|
81
|
+
/** Agent ID */
|
|
82
|
+
AgentId: string;
|
|
83
|
+
/** 模板标识符 */
|
|
84
|
+
Template: string;
|
|
85
|
+
/** 环境变量 */
|
|
86
|
+
envVariables?: Record<string, string>;
|
|
87
|
+
/** Docker 镜像 URL */
|
|
88
|
+
ImageUrl: string;
|
|
89
|
+
/** 仓库信息 */
|
|
90
|
+
RepoInfo: IRepoInfo;
|
|
91
|
+
/** 头像 URL */
|
|
92
|
+
Avatar?: string;
|
|
93
|
+
/** 简介 */
|
|
94
|
+
Introduction?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 通过代码包创建 TCBR Agent 的参数
|
|
98
|
+
*/
|
|
99
|
+
export interface ICreateTcbrAgentByPackageParams {
|
|
100
|
+
/** Agent 名称 */
|
|
101
|
+
Name: string;
|
|
102
|
+
/** Agent ID */
|
|
103
|
+
AgentId: string;
|
|
104
|
+
/** 模板标识符 */
|
|
105
|
+
Template: string;
|
|
106
|
+
/** 环境变量 */
|
|
107
|
+
envVariables?: Record<string, string>;
|
|
108
|
+
/** 代码包名称(上传后获取) */
|
|
109
|
+
PackageName: string;
|
|
110
|
+
/** 代码包版本(上传后获取) */
|
|
111
|
+
PackageVersion: string;
|
|
112
|
+
/** 来源标识,如 'aiAgentWithConfigYaml' */
|
|
113
|
+
Source?: string;
|
|
114
|
+
/** 头像 URL */
|
|
115
|
+
Avatar?: string;
|
|
116
|
+
/** 简介 */
|
|
117
|
+
Introduction?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 通过本地代码创建 TCBR Agent 的参数(自动上传)
|
|
121
|
+
*/
|
|
122
|
+
export interface ICreateTcbrAgentByCodeParams {
|
|
123
|
+
/** Agent 名称 */
|
|
124
|
+
Name: string;
|
|
125
|
+
/** Agent ID */
|
|
126
|
+
AgentId: string;
|
|
127
|
+
/** 模板标识符 */
|
|
128
|
+
Template: string;
|
|
129
|
+
/** 环境变量 */
|
|
130
|
+
envVariables?: Record<string, string>;
|
|
131
|
+
/** 来源标识 */
|
|
132
|
+
Source?: string;
|
|
133
|
+
/** 头像 URL */
|
|
134
|
+
Avatar?: string;
|
|
135
|
+
/** 简介 */
|
|
136
|
+
Introduction?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 查询 Agent 列表的参数
|
|
140
|
+
*/
|
|
141
|
+
export interface IDescribeAgentListParams {
|
|
142
|
+
/** 每页数量,默认 20 */
|
|
143
|
+
PageSize?: number;
|
|
144
|
+
/** 页码,默认 1 */
|
|
145
|
+
PageNumber?: number;
|
|
146
|
+
/** 指定 Agent ID(查询单个) */
|
|
147
|
+
AgentId?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Agent 信息
|
|
151
|
+
*/
|
|
152
|
+
export interface IAgentInfo {
|
|
153
|
+
/** Agent ID */
|
|
154
|
+
AgentId: string;
|
|
155
|
+
/** Agent 名称 */
|
|
156
|
+
Name: string;
|
|
157
|
+
/** Agent 类型 */
|
|
158
|
+
AgentType: AgentType;
|
|
159
|
+
/** 简介 */
|
|
160
|
+
Introduction?: string;
|
|
161
|
+
/** 头像 */
|
|
162
|
+
Avatar?: string;
|
|
163
|
+
/** 背景图 */
|
|
164
|
+
Background?: string;
|
|
165
|
+
/** 标签 */
|
|
166
|
+
Tags?: string[];
|
|
167
|
+
/** 创建时间 */
|
|
168
|
+
CreateTime?: string;
|
|
169
|
+
/** 更新时间 */
|
|
170
|
+
UpdateTime?: string;
|
|
171
|
+
/** 状态 */
|
|
172
|
+
Status?: string;
|
|
173
|
+
/** 服务 ID */
|
|
174
|
+
ServiceId?: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Agent 列表响应
|
|
178
|
+
*/
|
|
179
|
+
export interface IDescribeAgentListResponse {
|
|
180
|
+
/** Agent 列表 */
|
|
181
|
+
AgentList: IAgentInfo[];
|
|
182
|
+
/** 总数 */
|
|
183
|
+
Total: number;
|
|
184
|
+
/** 请求 ID */
|
|
185
|
+
RequestId: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Agent 详情响应(包含底层资源状态)
|
|
189
|
+
*/
|
|
190
|
+
export interface IDescribeAgentResponse {
|
|
191
|
+
/** Agent 基本信息 */
|
|
192
|
+
AgentInfo: IAgentInfo | null;
|
|
193
|
+
/** Agent 是否已部署完成且可用 */
|
|
194
|
+
IsReady: boolean;
|
|
195
|
+
/** 不可用时的原因说明 */
|
|
196
|
+
NotReadyReason?: string;
|
|
197
|
+
/** 请求 ID */
|
|
198
|
+
RequestId: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 删除 Agent 的参数
|
|
202
|
+
*/
|
|
203
|
+
export interface IDeleteAgentParams {
|
|
204
|
+
/** Agent ID */
|
|
205
|
+
AgentId: string;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 更新 Agent 的参数(通用)
|
|
209
|
+
* 会自动判断 Agent 类型并调用对应的更新方法
|
|
210
|
+
*/
|
|
211
|
+
export interface IUpdateAgentParams {
|
|
212
|
+
/** Agent ID(必填) */
|
|
213
|
+
AgentId: string;
|
|
214
|
+
/** 代码目录路径(可选,不传则不更新代码) */
|
|
215
|
+
cwd?: string;
|
|
216
|
+
/** Base64 编码的 ZIP 文件内容(与 cwd 二选一,仅 SCF 类型) */
|
|
217
|
+
ZipFile?: string;
|
|
218
|
+
/** 环境变量 */
|
|
219
|
+
envVariables?: Record<string, string>;
|
|
220
|
+
/** 运行时版本 */
|
|
221
|
+
Runtime?: RuntimeVersion;
|
|
222
|
+
/** 超时时间(秒),1-900 */
|
|
223
|
+
Timeout?: number;
|
|
224
|
+
/** 函数运行时内存大小(MB),可选 64、128-3072(128为阶梯) */
|
|
225
|
+
MemorySize?: number;
|
|
226
|
+
/** 是否自动安装依赖 */
|
|
227
|
+
InstallDependency?: boolean;
|
|
228
|
+
/** 忽略的文件模式(仅 cwd 方式有效,SCF 类型) */
|
|
229
|
+
Ignore?: string | string[];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 更新 SCF Agent 的参数
|
|
233
|
+
*/
|
|
234
|
+
export interface IUpdateScfAgentParams {
|
|
235
|
+
/** Agent ID */
|
|
236
|
+
AgentId: string;
|
|
237
|
+
/** 代码目录路径(与 ZipFile 二选一) */
|
|
238
|
+
cwd?: string;
|
|
239
|
+
/** Base64 编码的 ZIP 文件内容(与 cwd 二选一) */
|
|
240
|
+
ZipFile?: string;
|
|
241
|
+
/** 环境变量 */
|
|
242
|
+
envVariables?: Record<string, string>;
|
|
243
|
+
/** 运行时版本 */
|
|
244
|
+
Runtime?: RuntimeVersion;
|
|
245
|
+
/** 函数超时时间(秒),1-900 */
|
|
246
|
+
Timeout?: number;
|
|
247
|
+
/** 函数运行时内存大小(MB),可选 64、128-3072(128为阶梯) */
|
|
248
|
+
MemorySize?: number;
|
|
249
|
+
/** 是否自动安装依赖 */
|
|
250
|
+
InstallDependency?: boolean;
|
|
251
|
+
/** 忽略的文件模式(仅 cwd 方式有效) */
|
|
252
|
+
Ignore?: string | string[];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 更新 SCF Agent 的返回结果
|
|
256
|
+
*/
|
|
257
|
+
export interface IUpdateScfAgentResponse {
|
|
258
|
+
/** 请求 ID */
|
|
259
|
+
RequestId: string;
|
|
260
|
+
/** 总耗时(毫秒) */
|
|
261
|
+
elapsedTime: number;
|
|
262
|
+
/** 结果消息 */
|
|
263
|
+
message: string;
|
|
264
|
+
/** 详细步骤信息 */
|
|
265
|
+
details: string[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 更新 TCBR Agent 的参数
|
|
269
|
+
*/
|
|
270
|
+
export interface IUpdateTcbrAgentParams {
|
|
271
|
+
/** Agent ID */
|
|
272
|
+
AgentId: string;
|
|
273
|
+
/** 代码目录路径(与 ImageUrl 二选一) */
|
|
274
|
+
cwd?: string;
|
|
275
|
+
/** Docker 镜像 URL */
|
|
276
|
+
ImageUrl?: string;
|
|
277
|
+
/** 环境变量 */
|
|
278
|
+
envVariables?: Record<string, string>;
|
|
279
|
+
/** 是否安装依赖,默认 true(仅代码包部署时有效) */
|
|
280
|
+
InstallDependency?: boolean;
|
|
281
|
+
/** CPU 规格(核),如 0.25、0.5、1、2 */
|
|
282
|
+
Cpu?: number;
|
|
283
|
+
/** 内存规格(GB),如 0.5、1、2、4 */
|
|
284
|
+
Mem?: number;
|
|
285
|
+
/** 最小副本数 */
|
|
286
|
+
MinNum?: number;
|
|
287
|
+
/** 最大副本数 */
|
|
288
|
+
MaxNum?: number;
|
|
289
|
+
/** 服务端口 */
|
|
290
|
+
Port?: number;
|
|
291
|
+
/** 延迟检测时间(秒) */
|
|
292
|
+
InitialDelaySeconds?: number;
|
|
293
|
+
/** 日志采集路径,如 "stdout" */
|
|
294
|
+
CustomLogs?: string;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* 获取上传信息的参数
|
|
298
|
+
*/
|
|
299
|
+
export interface IDescribeCloudBaseBuildServiceParams {
|
|
300
|
+
/** 服务名(即 AgentId) */
|
|
301
|
+
ServiceName: string;
|
|
302
|
+
/** build 类型 */
|
|
303
|
+
CIBusiness?: 'cloudbaserun' | 'framework-ci';
|
|
304
|
+
/** 服务版本 */
|
|
305
|
+
ServiceVersion?: string;
|
|
306
|
+
/** 文件后缀 */
|
|
307
|
+
Suffix?: string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 上传信息响应
|
|
311
|
+
*/
|
|
312
|
+
export interface IDescribeCloudBaseBuildServiceResponse {
|
|
313
|
+
/** 上传 URL */
|
|
314
|
+
UploadUrl: string;
|
|
315
|
+
/** 上传请求头 */
|
|
316
|
+
UploadHeaders: Array<{
|
|
317
|
+
Key: string;
|
|
318
|
+
Value: string;
|
|
319
|
+
}>;
|
|
320
|
+
/** 包名 */
|
|
321
|
+
PackageName: string;
|
|
322
|
+
/** 包版本 */
|
|
323
|
+
PackageVersion: string;
|
|
324
|
+
/** 下载链接 */
|
|
325
|
+
DownloadUrl?: string;
|
|
326
|
+
/** 下载链接是否过期 */
|
|
327
|
+
OutDate?: boolean;
|
|
328
|
+
/** 请求 ID */
|
|
329
|
+
RequestId: string;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* 创建 Agent 响应
|
|
333
|
+
*/
|
|
334
|
+
export interface ICreateAgentResponse {
|
|
335
|
+
/** Agent ID */
|
|
336
|
+
AgentId: string;
|
|
337
|
+
/** 请求 ID */
|
|
338
|
+
RequestId: string;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* 通用操作响应
|
|
342
|
+
*/
|
|
343
|
+
export interface ICommonResponse {
|
|
344
|
+
/** 请求 ID */
|
|
345
|
+
RequestId: string;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 删除 Agent 响应
|
|
349
|
+
*/
|
|
350
|
+
export interface IDeleteAgentResponse {
|
|
351
|
+
/** 请求 ID */
|
|
352
|
+
RequestId: string;
|
|
353
|
+
/** Agent 记录是否删除成功 */
|
|
354
|
+
AgentDeleted: boolean;
|
|
355
|
+
/** 底层资源删除结果,无底层资源时为 undefined */
|
|
356
|
+
ResourceResult?: {
|
|
357
|
+
/** 资源类型 */
|
|
358
|
+
Type: 'scf' | 'tcbr';
|
|
359
|
+
/** 资源名称 */
|
|
360
|
+
Name: string;
|
|
361
|
+
/** 是否删除成功 */
|
|
362
|
+
Deleted: boolean;
|
|
363
|
+
/** 删除失败时的错误信息 */
|
|
364
|
+
Error?: string;
|
|
365
|
+
/** 删除失败时的清理提示 */
|
|
366
|
+
CleanupHint?: string;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* 获取 Agent 日志的参数
|
|
371
|
+
*/
|
|
372
|
+
export interface IGetAgentLogsParams {
|
|
373
|
+
/** Agent ID */
|
|
374
|
+
AgentId: string;
|
|
375
|
+
/** 偏移量,默认 0 */
|
|
376
|
+
offset?: number;
|
|
377
|
+
/** 返回数量,默认 10 */
|
|
378
|
+
limit?: number;
|
|
379
|
+
/** 开始时间,如 "2024-01-01 00:00:00" */
|
|
380
|
+
startTime?: string;
|
|
381
|
+
/** 结束时间,如 "2024-01-01 23:59:59" */
|
|
382
|
+
endTime?: string;
|
|
383
|
+
/** 按 RequestId 筛选(仅 SCF Agent) */
|
|
384
|
+
requestId?: string;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* @deprecated 请使用 ICreateTcbrAgentByCodeParams
|
|
388
|
+
* 创建函数型 Agent 的参数(旧版)
|
|
389
|
+
*/
|
|
1
390
|
export interface ICreateFunctionAgentParams {
|
|
2
391
|
/**
|
|
3
392
|
* 智能体名称
|
package/types/environment.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { AgentService } from './agent';
|
|
|
5
5
|
import { StorageService } from './storage';
|
|
6
6
|
import { EnvService } from './env';
|
|
7
7
|
import { CommonService } from './common';
|
|
8
|
+
import { LogService } from './log';
|
|
8
9
|
import { CloudBaseContext } from './context';
|
|
9
10
|
import { HostingService } from './hosting';
|
|
10
11
|
import { ThirdService } from './third';
|
|
@@ -13,6 +14,7 @@ import { UserService } from './user';
|
|
|
13
14
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
14
15
|
import { MysqlService } from './mysql';
|
|
15
16
|
import { EnvInfo } from './interfaces';
|
|
17
|
+
import { PermissionService } from './permission';
|
|
16
18
|
export declare class Environment {
|
|
17
19
|
inited: boolean;
|
|
18
20
|
cloudBaseContext: CloudBaseContext;
|
|
@@ -25,12 +27,14 @@ export declare class Environment {
|
|
|
25
27
|
private databaseService;
|
|
26
28
|
private storageService;
|
|
27
29
|
private envService;
|
|
30
|
+
private logService;
|
|
28
31
|
private hostingService;
|
|
29
32
|
private thirdService;
|
|
30
33
|
private accessService;
|
|
31
34
|
private userService;
|
|
32
35
|
private cloudBaseRunService;
|
|
33
36
|
private mysqlService;
|
|
37
|
+
private permissionService;
|
|
34
38
|
constructor(context: CloudBaseContext, envId: string);
|
|
35
39
|
lazyInit(): Promise<any>;
|
|
36
40
|
getEnvId(): string;
|
|
@@ -41,12 +45,14 @@ export declare class Environment {
|
|
|
41
45
|
getCloudRunService(): CloudRunService;
|
|
42
46
|
getAgentService(): AgentService;
|
|
43
47
|
getEnvService(): EnvService;
|
|
48
|
+
getLogService(): LogService;
|
|
44
49
|
getHostingService(): HostingService;
|
|
45
50
|
getThirdService(): ThirdService;
|
|
46
51
|
getAccessService(): AccessService;
|
|
47
52
|
getUserService(): UserService;
|
|
48
53
|
getCloudBaseRunService(): CloudBaseRunService;
|
|
49
54
|
getMysqlService(): MysqlService;
|
|
55
|
+
getPermissionService(): PermissionService;
|
|
50
56
|
getCommonService(serviceType: string, serviceVersion: any): CommonService;
|
|
51
57
|
getServicesEnvInfo(): Promise<any>;
|
|
52
58
|
getAuthConfig(): {
|
|
@@ -368,6 +368,27 @@ export declare class FunctionService {
|
|
|
368
368
|
* @memberof FunctionService
|
|
369
369
|
*/
|
|
370
370
|
updateFunctionCode(funcParam: IUpdateFunctionCodeParam): Promise<IResponseInfo>;
|
|
371
|
+
/**
|
|
372
|
+
* 更新函数代码和配置(带进度信息)
|
|
373
|
+
* 支持同时更新代码和配置,按顺序执行:等待就绪 → 更新代码 → 等待就绪 → 更新配置 → 等待就绪
|
|
374
|
+
* @param options 更新选项
|
|
375
|
+
* @returns 更新结果,包含耗时信息
|
|
376
|
+
*/
|
|
377
|
+
updateFunctionWithProgress(options: {
|
|
378
|
+
/** 函数名称 */
|
|
379
|
+
name: string;
|
|
380
|
+
/** 代码相关参数(可选),复用 IUpdateFunctionCodeParam(排除 func,由 name 替代) */
|
|
381
|
+
code?: Omit<IUpdateFunctionCodeParam, 'func'>;
|
|
382
|
+
/** 配置相关参数(可选),复用 ICloudFunction(排除 name,由外层 name 替代) */
|
|
383
|
+
config?: Omit<ICloudFunction, 'name'>;
|
|
384
|
+
}): Promise<{
|
|
385
|
+
/** 总耗时(毫秒) */
|
|
386
|
+
elapsedTime: number;
|
|
387
|
+
/** 结果消息 */
|
|
388
|
+
message: string;
|
|
389
|
+
/** 详细步骤信息 */
|
|
390
|
+
details: string[];
|
|
391
|
+
}>;
|
|
371
392
|
/**
|
|
372
393
|
* 调用云函数
|
|
373
394
|
* @param {string} name 云函数名称
|
|
@@ -496,8 +517,16 @@ export declare class FunctionService {
|
|
|
496
517
|
uploadFunctionZipToCos(options: IFunctionCode, installDependency: 'TRUE' | 'FALSE'): Promise<{
|
|
497
518
|
UnixTimestamp: string;
|
|
498
519
|
}>;
|
|
520
|
+
getCodeParams(options: IFunctionCode, installDependency: 'TRUE' | 'FALSE'): Promise<{
|
|
521
|
+
ZipFile: string;
|
|
522
|
+
CosBucketRegion?: undefined;
|
|
523
|
+
TempCosObjectName?: undefined;
|
|
524
|
+
} | {
|
|
525
|
+
CosBucketRegion: string;
|
|
526
|
+
TempCosObjectName: string;
|
|
527
|
+
ZipFile?: undefined;
|
|
528
|
+
}>;
|
|
499
529
|
private createAccessPath;
|
|
500
|
-
private getCodeParams;
|
|
501
530
|
private getTempCosInfo;
|
|
502
531
|
private retryCreateTrigger;
|
|
503
532
|
/**
|
package/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { CloudRunService } from './cloudrun';
|
|
|
4
4
|
import { AgentService } from './agent';
|
|
5
5
|
import { StorageService } from './storage';
|
|
6
6
|
import { DatabaseService } from './database';
|
|
7
|
+
import { LogService } from './log';
|
|
7
8
|
import { CommonService } from './common';
|
|
8
9
|
import { HostingService } from './hosting';
|
|
9
10
|
import { Environment } from './environment';
|
|
@@ -14,6 +15,7 @@ import { UserService } from './user';
|
|
|
14
15
|
import { CloudBaseRunService } from './cloudBaseRun';
|
|
15
16
|
import { MysqlService } from './mysql';
|
|
16
17
|
import { DocsService } from './docs';
|
|
18
|
+
import { PermissionService } from './permission';
|
|
17
19
|
interface CloudBaseConfig {
|
|
18
20
|
secretId?: string;
|
|
19
21
|
secretKey?: string;
|
|
@@ -54,8 +56,10 @@ declare class CloudBase {
|
|
|
54
56
|
get cloudApp(): CloudBaseRunService;
|
|
55
57
|
commonService(service?: string, version?: string): CommonService;
|
|
56
58
|
get env(): EnvService;
|
|
59
|
+
get log(): LogService;
|
|
57
60
|
get third(): ThirdService;
|
|
58
61
|
get user(): UserService;
|
|
62
|
+
get permission(): PermissionService;
|
|
59
63
|
get docs(): DocsService;
|
|
60
64
|
getEnvironmentManager(): EnvironmentManager;
|
|
61
65
|
getManagerConfig(): CloudBaseConfig;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Environment } from '../environment';
|
|
2
|
+
import { ISearchClsLogParams, ISearchClsLogResponse } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export interface ICreateEnvResourceResponse {
|
|
5
|
+
RequestId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ILogServiceEntry {
|
|
8
|
+
LogsetId?: string;
|
|
9
|
+
TopicId?: string;
|
|
10
|
+
TopicName?: string;
|
|
11
|
+
Region?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 纯函数:根据 DescribeEnvs 返回的 LogServices 列表判断日志服务是否已开通。
|
|
15
|
+
* 已开通条件:至少一个条目有有效的 TopicId。
|
|
16
|
+
*/
|
|
17
|
+
export declare function isLogServiceEnabled(logServices?: ILogServiceEntry[]): boolean;
|
|
18
|
+
export declare class LogService {
|
|
19
|
+
private envId;
|
|
20
|
+
private cloudService;
|
|
21
|
+
private tcbrService;
|
|
22
|
+
constructor(environment: Environment);
|
|
23
|
+
/**
|
|
24
|
+
* 检查当前环境的日志服务是否已开通
|
|
25
|
+
*
|
|
26
|
+
* 通过 DescribeEnvs 接口获取环境信息,判断 LogServices 字段中是否包含有效的
|
|
27
|
+
* 日志主题(TopicId 不为空)。
|
|
28
|
+
*
|
|
29
|
+
* @returns true 表示已开通,false 表示未开通或开通中
|
|
30
|
+
*/
|
|
31
|
+
checkLogServiceEnabled(): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* 开通环境日志服务(异步操作)
|
|
34
|
+
*
|
|
35
|
+
* 调用 CreateEnvResource 接口开通日志资源。
|
|
36
|
+
* 注意:接口调用成功不代表日志资源立即可用,需通过 checkLogServiceEnabled() 轮询确认。
|
|
37
|
+
*
|
|
38
|
+
* @returns 请求 ID
|
|
39
|
+
*/
|
|
40
|
+
createLogService(): Promise<ICreateEnvResourceResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* 搜索 CLS 日志
|
|
43
|
+
*
|
|
44
|
+
* @param params 查询参数,通过 queryString 使用 CLS 原生检索分析语法
|
|
45
|
+
* @returns 日志搜索结果
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* - 纯检索结果在 `LogResults.Results` 中
|
|
49
|
+
* - SQL 分析结果(queryString 含 `| select ...`)在 `LogResults.AnalysisRecords` 中
|
|
50
|
+
* - 详细的 QueryString 语法参考见 README.md
|
|
51
|
+
*/
|
|
52
|
+
searchClsLog(params: ISearchClsLogParams): Promise<ISearchClsLogResponse>;
|
|
53
|
+
}
|