@cloudbase/manager-node 5.2.0 → 5.3.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AiModelService = void 0;
10
+ const utils_1 = require("../utils");
11
+ class AiModelService {
12
+ constructor(environment) {
13
+ this.environment = environment;
14
+ this.tcbService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
15
+ }
16
+ /**
17
+ * 创建 AI 模型配置分组
18
+ */
19
+ async createAIModel(options) {
20
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
21
+ const { envId, groupName, baseUrl, models, remark, status, secret } = options;
22
+ if (!groupName || groupName.trim().length === 0) {
23
+ throw new Error('groupName is required');
24
+ }
25
+ if (groupName.toLowerCase().startsWith('cloudbase')) {
26
+ throw new Error('groupName cannot start with cloudbase');
27
+ }
28
+ if (status !== undefined && status !== 1 && status !== 2) {
29
+ throw new Error('status must be 1 or 2');
30
+ }
31
+ return this.tcbService.request('CreateAIModel', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ EnvId: envId || EnvId, GroupName: groupName }, (baseUrl !== undefined ? { BaseUrl: baseUrl } : {})), (models !== undefined ? { Models: models } : {})), (remark !== undefined ? { Remark: remark } : {})), (status !== undefined ? { Status: status } : {})), (secret !== undefined ? { Secret: secret } : {})));
32
+ }
33
+ /**
34
+ * 更新 AI 模型配置分组
35
+ */
36
+ async updateAIModel(options) {
37
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
38
+ const { envId, groupName, baseUrl, models, remark, status, secret } = options;
39
+ if (!groupName || groupName.trim().length === 0) {
40
+ throw new Error('groupName is required');
41
+ }
42
+ if (status !== undefined && status !== 1 && status !== 2) {
43
+ throw new Error('status must be 1 or 2');
44
+ }
45
+ return this.tcbService.request('UpdateAIModel', Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ EnvId: envId || EnvId, GroupName: groupName }, (baseUrl !== undefined ? { BaseUrl: baseUrl } : {})), (models !== undefined ? { Models: models } : {})), (remark !== undefined ? { Remark: remark } : {})), (status !== undefined ? { Status: status } : {})), (secret !== undefined ? { Secret: secret } : {})));
46
+ }
47
+ /**
48
+ * 删除 AI 模型配置分组,支持批量删除
49
+ */
50
+ async deleteAIModel(options) {
51
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
52
+ const { envId, groupNames } = options;
53
+ if (!Array.isArray(groupNames) || groupNames.length === 0) {
54
+ throw new Error('groupNames is required');
55
+ }
56
+ const invalidGroupName = groupNames.find(item => typeof item !== 'string' || item.trim().length === 0);
57
+ if (invalidGroupName !== undefined) {
58
+ throw new Error('groupNames contains invalid item');
59
+ }
60
+ return this.tcbService.request('DeleteAIModel', {
61
+ EnvId: envId || EnvId,
62
+ GroupNames: groupNames
63
+ });
64
+ }
65
+ /**
66
+ * 查询指定云开发环境下已配置的 AI 模型分组列表
67
+ */
68
+ async describeAIModels(options = {}) {
69
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
70
+ const { envId } = options;
71
+ return this.tcbService.request('DescribeAIModels', {
72
+ EnvId: envId || EnvId
73
+ });
74
+ }
75
+ /**
76
+ * 查询云开发平台支持的托管类型 AI 模型列表
77
+ */
78
+ async describeManagedAIModelList(options = {}) {
79
+ const { EnvId } = this.environment.lazyEnvironmentConfig;
80
+ const { envId } = options;
81
+ return this.tcbService.request('DescribeManagedAIModelList', {
82
+ EnvId: envId || EnvId
83
+ });
84
+ }
85
+ }
86
+ exports.AiModelService = AiModelService;
87
+ __decorate([
88
+ (0, utils_1.preLazy)()
89
+ ], AiModelService.prototype, "createAIModel", null);
90
+ __decorate([
91
+ (0, utils_1.preLazy)()
92
+ ], AiModelService.prototype, "updateAIModel", null);
93
+ __decorate([
94
+ (0, utils_1.preLazy)()
95
+ ], AiModelService.prototype, "deleteAIModel", null);
96
+ __decorate([
97
+ (0, utils_1.preLazy)()
98
+ ], AiModelService.prototype, "describeAIModels", null);
99
+ __decorate([
100
+ (0, utils_1.preLazy)()
101
+ ], AiModelService.prototype, "describeManagedAIModelList", null);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -21,6 +21,7 @@ const mysql_1 = require("./mysql");
21
21
  const cloudApp_1 = require("./cloudApp");
22
22
  const permission_1 = require("./permission");
23
23
  const sandbox_1 = require("./sandbox");
24
+ const aiModel_1 = require("./aiModel");
24
25
  class Environment {
25
26
  constructor(context, envId) {
26
27
  this.inited = false;
@@ -45,6 +46,7 @@ class Environment {
45
46
  this.permissionService = new permission_1.PermissionService(this);
46
47
  this.cloudAppService = new cloudApp_1.CloudAppService(this);
47
48
  this.sandboxService = new sandbox_1.SandboxService(this);
49
+ this.aiModelService = new aiModel_1.AiModelService(this);
48
50
  }
49
51
  async lazyInit() {
50
52
  if (!this.inited) {
@@ -116,6 +118,9 @@ class Environment {
116
118
  getSandboxService() {
117
119
  return this.sandboxService;
118
120
  }
121
+ getAiModelService() {
122
+ return this.aiModelService;
123
+ }
119
124
  getCommonService(serviceType = 'tcb', serviceVersion) {
120
125
  return new common_1.CommonService(this, serviceType, serviceVersion);
121
126
  }
package/lib/index.js CHANGED
@@ -119,6 +119,9 @@ class CloudBase {
119
119
  get sandbox() {
120
120
  return this.currentEnvironment().getSandboxService();
121
121
  }
122
+ get aiModel() {
123
+ return this.currentEnvironment().getAiModelService();
124
+ }
122
125
  get docs() {
123
126
  if (!this.docsService) {
124
127
  this.docsService = new docs_1.DocsService();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -0,0 +1,27 @@
1
+ import { Environment } from '../environment';
2
+ import { CreateAIModelOptions, CreateAIModelResp, UpdateAIModelOptions, UpdateAIModelResp, DeleteAIModelOptions, DeleteAIModelResp, DescribeAIModelsOptions, DescribeAIModelsResp, DescribeManagedAIModelListOptions, DescribeManagedAIModelListResp } from './type';
3
+ export declare class AiModelService {
4
+ private environment;
5
+ private tcbService;
6
+ constructor(environment: Environment);
7
+ /**
8
+ * 创建 AI 模型配置分组
9
+ */
10
+ createAIModel(options: CreateAIModelOptions): Promise<CreateAIModelResp>;
11
+ /**
12
+ * 更新 AI 模型配置分组
13
+ */
14
+ updateAIModel(options: UpdateAIModelOptions): Promise<UpdateAIModelResp>;
15
+ /**
16
+ * 删除 AI 模型配置分组,支持批量删除
17
+ */
18
+ deleteAIModel(options: DeleteAIModelOptions): Promise<DeleteAIModelResp>;
19
+ /**
20
+ * 查询指定云开发环境下已配置的 AI 模型分组列表
21
+ */
22
+ describeAIModels(options?: DescribeAIModelsOptions): Promise<DescribeAIModelsResp>;
23
+ /**
24
+ * 查询云开发平台支持的托管类型 AI 模型列表
25
+ */
26
+ describeManagedAIModelList(options?: DescribeManagedAIModelListOptions): Promise<DescribeManagedAIModelListResp>;
27
+ }
@@ -0,0 +1,205 @@
1
+ import { IResponseInfo } from '../interfaces';
2
+ /** 模型状态,1:开启,2:关闭 */
3
+ export type AIModelStatus = 1 | 2;
4
+ /** AI 模型信息 */
5
+ export interface AIModel {
6
+ /** 模型名,示例值:huanyuan-v1 */
7
+ Model?: string;
8
+ /** 是否开启 MCP,示例值:false */
9
+ EnableMCP?: boolean;
10
+ /** 标签 */
11
+ Tags?: string[];
12
+ }
13
+ /** AI 模型密钥信息 */
14
+ export interface AIModelSecret {
15
+ /** 密钥来源,示例值:custom */
16
+ SecretSource?: string;
17
+ /** 密钥 ID,和 SecretKey 一一对应 */
18
+ SecretId?: string;
19
+ /** 密钥 Key,和 SecretId 一一对应 */
20
+ SecretKey?: string;
21
+ /** ApiKey,SecretKey 和 ApiKey 二选一 */
22
+ ApiKey?: string;
23
+ }
24
+ /** AI 模型分组类型 */
25
+ export type AIModelGroupType = 'builtin' | 'custom';
26
+ /** AI 模型分组信息 */
27
+ export interface AIModelGroup {
28
+ /**
29
+ * 模型分组
30
+ * 枚举值:
31
+ * - hunyuan-exp
32
+ * - hunyuan-image
33
+ * - deepseek
34
+ * - cloudbase
35
+ * - custom-xxxx
36
+ */
37
+ GroupName?: string;
38
+ /**
39
+ * 模型列表
40
+ * 注意:此字段可能返回 null,表示取不到有效值
41
+ */
42
+ Models?: AIModel[] | null;
43
+ /** 模型类型:builtin 内置模型分组类别,custom 用户自定义模型分组类别 */
44
+ Type?: AIModelGroupType;
45
+ /** 原始模型类型:builtin 内置模型类型,custom 用户自定义模型类型 */
46
+ OriginType?: AIModelGroupType;
47
+ /** 备注 */
48
+ Remark?: string;
49
+ /** 模型地址 */
50
+ BaseUrl?: string;
51
+ /** 模型状态,1:开启,2:关闭 */
52
+ Status?: AIModelStatus;
53
+ /**
54
+ * 模型密钥
55
+ * 注意:此字段可能返回 null,表示取不到有效值
56
+ */
57
+ Secret?: AIModelSecret | null;
58
+ /** 创建时间,ISO8601 格式 */
59
+ CreateTime?: string;
60
+ /** 更新时间,ISO8601 格式 */
61
+ UpdateTime?: string;
62
+ }
63
+ /** 托管 AI 模型计费类型 */
64
+ export type ManagedAIModelChargingType = 'Uniform' | 'Tiered';
65
+ /** 托管 AI 模型参数规格 */
66
+ export interface ManagedAIModelSpec {
67
+ /** 最大输入 Token,示例值:192k */
68
+ MaxInputToken?: string;
69
+ /** 最大输出 Token,示例值:32k */
70
+ MaxOutputToken?: string;
71
+ /** 上下文长度,示例值:128k */
72
+ ContextLength?: string;
73
+ }
74
+ /** 托管 AI 模型计费信息 */
75
+ export interface ManagedAIModelChargingInfo {
76
+ /** 计费类型:Uniform 固定计费,Tiered 分段计费 */
77
+ Type?: ManagedAIModelChargingType;
78
+ /** 分组名称,示例值:0-16k */
79
+ Name?: string;
80
+ /** 输入 Token 价格,示例值:1.2 */
81
+ InputPrice?: string;
82
+ /** 输出 Token 价格,示例值:4 */
83
+ OutputPrice?: string;
84
+ /** 命中缓存价格,示例值:0.4 */
85
+ CachePrice?: string;
86
+ /** 计费单位,示例值:千tokens */
87
+ InputOutputUnit?: string;
88
+ }
89
+ /** 托管型 AI 模型信息 */
90
+ export interface ManagedAIModel {
91
+ /** 模型名,示例值:hy3-preview */
92
+ Model?: string;
93
+ /** 是否开启 MCP,示例值:true */
94
+ EnableMCP?: boolean;
95
+ /** 模型规格 */
96
+ ModelSpec?: ManagedAIModelSpec;
97
+ /** 模型计费信息 */
98
+ ModelChargingInfo?: ManagedAIModelChargingInfo[];
99
+ }
100
+ /** 云开发内置 AI 模型分组信息 */
101
+ export interface ManagedAIModelGroup {
102
+ /** 模型分组,示例值:cloudbase */
103
+ GroupName?: string;
104
+ /**
105
+ * 模型列表
106
+ * 注意:此字段可能返回 null,表示取不到有效值
107
+ */
108
+ Models?: ManagedAIModel[] | null;
109
+ /** 备注,示例值:腾讯云开发 */
110
+ Remark?: string;
111
+ }
112
+ /**
113
+ * CreateAIModel 用户入参
114
+ */
115
+ export interface CreateAIModelOptions {
116
+ /** 环境 ID。不传则使用当前环境 ID */
117
+ envId?: string;
118
+ /**
119
+ * 分组名
120
+ * 入参限制:不允许以 cloudbase 为前缀
121
+ */
122
+ groupName: string;
123
+ /** 模型服务地址,示例值:http://xxx */
124
+ baseUrl?: string;
125
+ /** 模型名列表 */
126
+ models?: AIModel[];
127
+ /** 分组备注 */
128
+ remark?: string;
129
+ /** 模型状态,1:开启,2:关闭 */
130
+ status?: AIModelStatus;
131
+ /** 模型密钥 */
132
+ secret?: AIModelSecret;
133
+ }
134
+ /** CreateAIModel 返回结果 */
135
+ export interface CreateAIModelResp extends IResponseInfo {
136
+ /** 创建数量 */
137
+ Count: number;
138
+ }
139
+ /**
140
+ * UpdateAIModel 用户入参
141
+ */
142
+ export interface UpdateAIModelOptions {
143
+ /** 环境 ID。不传则使用当前环境 ID */
144
+ envId?: string;
145
+ /** 分组名 */
146
+ groupName: string;
147
+ /** 模型地址,示例值:http://xxx */
148
+ baseUrl?: string;
149
+ /**
150
+ * 模型名列表
151
+ * 注意:Models 列表更新采用全量替换
152
+ */
153
+ models?: AIModel[];
154
+ /** 备注 */
155
+ remark?: string;
156
+ /** 模型状态,1:开启,2:关闭 */
157
+ status?: AIModelStatus;
158
+ /** 模型密钥 */
159
+ secret?: AIModelSecret;
160
+ }
161
+ /** UpdateAIModel 返回结果 */
162
+ export interface UpdateAIModelResp extends IResponseInfo {
163
+ /** 更新数量 */
164
+ Count: number;
165
+ }
166
+ /**
167
+ * DeleteAIModel 用户入参
168
+ */
169
+ export interface DeleteAIModelOptions {
170
+ /** 环境 ID。不传则使用当前环境 ID */
171
+ envId?: string;
172
+ /** 分组名列表 */
173
+ groupNames: string[];
174
+ }
175
+ /** DeleteAIModel 返回结果 */
176
+ export interface DeleteAIModelResp extends IResponseInfo {
177
+ /** 成功删除数量 */
178
+ Count: number;
179
+ }
180
+ /** DescribeAIModels 用户入参 */
181
+ export interface DescribeAIModelsOptions {
182
+ /** 环境 ID。不传则使用当前环境 ID */
183
+ envId?: string;
184
+ }
185
+ /** DescribeAIModels 返回结果 */
186
+ export interface DescribeAIModelsResp extends IResponseInfo {
187
+ /**
188
+ * 模型列表
189
+ * 注意:此字段可能返回 null,表示取不到有效值
190
+ */
191
+ AIModels: AIModelGroup[] | null;
192
+ }
193
+ /** DescribeManagedAIModelList 用户入参 */
194
+ export interface DescribeManagedAIModelListOptions {
195
+ /** 环境 ID。不传则使用当前环境 ID */
196
+ envId?: string;
197
+ }
198
+ /** DescribeManagedAIModelList 返回结果 */
199
+ export interface DescribeManagedAIModelListResp extends IResponseInfo {
200
+ /**
201
+ * 托管模型列表
202
+ * 注意:此字段可能返回 null,表示取不到有效值
203
+ */
204
+ ManagedAIModelList: ManagedAIModelGroup[] | null;
205
+ }
@@ -17,6 +17,7 @@ import { CloudAppService } from './cloudApp';
17
17
  import { EnvInfo } from './interfaces';
18
18
  import { PermissionService } from './permission';
19
19
  import { SandboxService } from './sandbox';
20
+ import { AiModelService } from './aiModel';
20
21
  export declare class Environment {
21
22
  inited: boolean;
22
23
  cloudBaseContext: CloudBaseContext;
@@ -39,6 +40,7 @@ export declare class Environment {
39
40
  private permissionService;
40
41
  private cloudAppService;
41
42
  private sandboxService;
43
+ private aiModelService;
42
44
  constructor(context: CloudBaseContext, envId: string);
43
45
  lazyInit(): Promise<any>;
44
46
  getEnvId(): string;
@@ -59,6 +61,7 @@ export declare class Environment {
59
61
  getCloudAppService(): CloudAppService;
60
62
  getPermissionService(): PermissionService;
61
63
  getSandboxService(): SandboxService;
64
+ getAiModelService(): AiModelService;
62
65
  getCommonService(serviceType: string, serviceVersion: any): CommonService;
63
66
  getServicesEnvInfo(): Promise<any>;
64
67
  getAuthConfig(): {
package/types/index.d.ts CHANGED
@@ -18,6 +18,7 @@ import { DocsService } from './docs';
18
18
  import { PermissionService } from './permission';
19
19
  import { SandboxService } from './sandbox';
20
20
  import { CloudAppService } from './cloudApp';
21
+ import { AiModelService } from './aiModel';
21
22
  interface CloudBaseConfig {
22
23
  secretId?: string;
23
24
  secretKey?: string;
@@ -82,6 +83,7 @@ declare class CloudBase {
82
83
  get user(): UserService;
83
84
  get permission(): PermissionService;
84
85
  get sandbox(): SandboxService;
86
+ get aiModel(): AiModelService;
85
87
  get docs(): DocsService;
86
88
  getEnvironmentManager(): EnvironmentManager;
87
89
  getManagerConfig(): CloudBaseConfig;