@cloudbase/cli 2.10.0 → 2.11.0-beta.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.
Files changed (205) hide show
  1. package/lib/auth/login.js +51 -65
  2. package/lib/auth/logout.js +3 -14
  3. package/lib/commands/account/login.js +136 -149
  4. package/lib/commands/account/logout.js +3 -14
  5. package/lib/commands/ag/base.js +203 -0
  6. package/lib/commands/ag/create.js +301 -0
  7. package/lib/commands/ag/debug/index.html +699 -0
  8. package/lib/commands/ag/delete.js +200 -0
  9. package/lib/commands/ag/deploy.js +185 -0
  10. package/lib/commands/ag/detail.js +113 -0
  11. package/lib/commands/ag/index.js +22 -0
  12. package/lib/commands/ag/list.js +155 -0
  13. package/lib/commands/ag/run.js +644 -0
  14. package/lib/commands/ai/index.js +76 -95
  15. package/lib/commands/cloudfunction/base.js +182 -203
  16. package/lib/commands/cloudrun/base.js +578 -603
  17. package/lib/commands/common.js +48 -63
  18. package/lib/commands/config/delete.js +16 -27
  19. package/lib/commands/config/get.js +13 -24
  20. package/lib/commands/config/list.js +16 -27
  21. package/lib/commands/config/set.js +33 -44
  22. package/lib/commands/db/base.js +221 -240
  23. package/lib/commands/env/base.js +36 -49
  24. package/lib/commands/env/domain.js +79 -94
  25. package/lib/commands/env/login.js +120 -135
  26. package/lib/commands/framework/index.js +32 -49
  27. package/lib/commands/fun/base.js +223 -244
  28. package/lib/commands/functions/alias/getRoute.js +33 -44
  29. package/lib/commands/functions/alias/setRoute.js +36 -47
  30. package/lib/commands/functions/code-download.js +43 -54
  31. package/lib/commands/functions/code-update.js +23 -34
  32. package/lib/commands/functions/concurrency/delete.js +11 -22
  33. package/lib/commands/functions/concurrency/list.js +20 -31
  34. package/lib/commands/functions/concurrency/set.js +13 -24
  35. package/lib/commands/functions/config-update.js +30 -41
  36. package/lib/commands/functions/copy.js +12 -23
  37. package/lib/commands/functions/delete.js +30 -41
  38. package/lib/commands/functions/deploy.js +184 -202
  39. package/lib/commands/functions/detail.js +23 -34
  40. package/lib/commands/functions/invoke.js +69 -75
  41. package/lib/commands/functions/layer/bind.js +102 -105
  42. package/lib/commands/functions/layer/create.js +29 -35
  43. package/lib/commands/functions/layer/delete.js +42 -48
  44. package/lib/commands/functions/layer/download.js +52 -58
  45. package/lib/commands/functions/layer/list.js +44 -50
  46. package/lib/commands/functions/layer/sort.js +39 -45
  47. package/lib/commands/functions/list.js +25 -36
  48. package/lib/commands/functions/log.js +65 -73
  49. package/lib/commands/functions/run.js +118 -116
  50. package/lib/commands/functions/trigger-create.js +32 -43
  51. package/lib/commands/functions/trigger-delete.js +50 -61
  52. package/lib/commands/functions/version/list.js +29 -40
  53. package/lib/commands/functions/version/publish.js +11 -22
  54. package/lib/commands/gateway/create.js +50 -61
  55. package/lib/commands/gateway/delete.js +38 -49
  56. package/lib/commands/gateway/domain.js +65 -80
  57. package/lib/commands/gateway/list.js +31 -42
  58. package/lib/commands/gateway/switch.js +48 -61
  59. package/lib/commands/helpers/init.js +226 -249
  60. package/lib/commands/helpers/new.js +35 -46
  61. package/lib/commands/helpers/open.js +22 -33
  62. package/lib/commands/hosting/hosting.js +157 -178
  63. package/lib/commands/index.js +1 -0
  64. package/lib/commands/lowcode/app.js +114 -144
  65. package/lib/commands/lowcode/comps.js +136 -127
  66. package/lib/commands/lowcode/utils.js +11 -22
  67. package/lib/commands/pull/pull.js +33 -46
  68. package/lib/commands/run/delete.js +35 -46
  69. package/lib/commands/run/image/delete.js +32 -39
  70. package/lib/commands/run/image/download.js +26 -33
  71. package/lib/commands/run/image/list.js +41 -48
  72. package/lib/commands/run/image/upload.js +26 -33
  73. package/lib/commands/run/list.js +32 -43
  74. package/lib/commands/run/service/config.js +17 -28
  75. package/lib/commands/run/service/deploy.js +15 -26
  76. package/lib/commands/run/service/list.js +48 -59
  77. package/lib/commands/run/service/update.js +7 -18
  78. package/lib/commands/run/standalonegateway/create.js +35 -42
  79. package/lib/commands/run/standalonegateway/destroy.js +23 -30
  80. package/lib/commands/run/standalonegateway/list.js +19 -26
  81. package/lib/commands/run/standalonegateway/package.js +31 -38
  82. package/lib/commands/run/standalonegateway/turn.js +27 -34
  83. package/lib/commands/run/version/create.js +198 -205
  84. package/lib/commands/run/version/delete.js +31 -38
  85. package/lib/commands/run/version/list.js +42 -49
  86. package/lib/commands/run/version/modify.js +27 -34
  87. package/lib/commands/run/version/update.js +201 -208
  88. package/lib/commands/runf/base.js +216 -237
  89. package/lib/commands/self-update.js +59 -72
  90. package/lib/commands/smart.js +66 -79
  91. package/lib/commands/storage/storage.js +192 -219
  92. package/lib/commands/third/thirdAttach.js +16 -27
  93. package/lib/commands/utils.js +119 -149
  94. package/lib/db/index.js +48 -67
  95. package/lib/decorators/captureError.js +10 -21
  96. package/lib/decorators/guard.js +11 -22
  97. package/lib/decorators/injectParams.js +29 -40
  98. package/lib/decorators/params/common.js +5 -2
  99. package/lib/decorators/params/index.js +3 -12
  100. package/lib/env/domain.js +13 -28
  101. package/lib/env/index.js +25 -44
  102. package/lib/env/login.js +30 -45
  103. package/lib/function/alias.js +31 -44
  104. package/lib/function/base.js +187 -215
  105. package/lib/function/code.js +8 -19
  106. package/lib/function/concurrency.js +43 -58
  107. package/lib/function/create.js +43 -53
  108. package/lib/function/delete.js +22 -35
  109. package/lib/function/layer/attach.js +33 -46
  110. package/lib/function/layer/create.js +34 -45
  111. package/lib/function/layer/delete.js +5 -16
  112. package/lib/function/layer/download.js +11 -22
  113. package/lib/function/layer/list.js +12 -25
  114. package/lib/function/layer/sort.js +6 -17
  115. package/lib/function/trigger.js +65 -82
  116. package/lib/function/update.js +24 -32
  117. package/lib/function/version.js +29 -42
  118. package/lib/function/vpc.js +12 -25
  119. package/lib/gateway/index.js +77 -104
  120. package/lib/hosting.js +157 -188
  121. package/lib/run/delete.js +3 -12
  122. package/lib/run/image/build.js +6 -15
  123. package/lib/run/image/delete.js +3 -12
  124. package/lib/run/image/info.js +3 -12
  125. package/lib/run/image/list.js +6 -15
  126. package/lib/run/list.js +19 -30
  127. package/lib/run/repo.js +6 -15
  128. package/lib/run/service/common.js +160 -173
  129. package/lib/run/service/config.js +44 -57
  130. package/lib/run/service/deployPackage.js +33 -44
  131. package/lib/run/service/list.js +8 -14
  132. package/lib/run/service/showLogs.js +69 -90
  133. package/lib/run/service/update.js +50 -63
  134. package/lib/run/standalonegateway/create.js +3 -12
  135. package/lib/run/standalonegateway/destroy.js +3 -12
  136. package/lib/run/standalonegateway/list.js +3 -12
  137. package/lib/run/standalonegateway/package/list.js +3 -12
  138. package/lib/run/standalonegateway/turn/off.js +3 -12
  139. package/lib/run/standalonegateway/turn/on.js +3 -12
  140. package/lib/run/version/create.js +41 -31
  141. package/lib/run/version/delete.js +3 -12
  142. package/lib/run/version/list.js +3 -12
  143. package/lib/run/version/modify.js +3 -12
  144. package/lib/run/version/repo.js +6 -15
  145. package/lib/run/version/update.js +37 -26
  146. package/lib/storage.js +62 -93
  147. package/lib/third/index.js +6 -17
  148. package/lib/utils/ai/banner.js +49 -60
  149. package/lib/utils/ai/claudeWindows.js +2 -2
  150. package/lib/utils/ai/config.js +169 -206
  151. package/lib/utils/ai/ensureFiles.js +6 -17
  152. package/lib/utils/ai/env.js +16 -27
  153. package/lib/utils/ai/envLocalManager.js +35 -52
  154. package/lib/utils/ai/router.js +927 -1005
  155. package/lib/utils/ai/setup.js +527 -563
  156. package/lib/utils/auth.js +3 -14
  157. package/lib/utils/checkTcbrEnv.js +20 -31
  158. package/lib/utils/cli-table.js +6 -1
  159. package/lib/utils/config.js +4 -13
  160. package/lib/utils/dts.js +98 -113
  161. package/lib/utils/env.js +154 -175
  162. package/lib/utils/function-packer.js +29 -42
  163. package/lib/utils/log.js +10 -21
  164. package/lib/utils/mcp-config-modifier.js +105 -120
  165. package/lib/utils/net/cloud-api-request.js +15 -23
  166. package/lib/utils/net/credential.js +26 -39
  167. package/lib/utils/net/http-request.js +63 -80
  168. package/lib/utils/net/manager-service.js +22 -35
  169. package/lib/utils/notice.js +16 -27
  170. package/lib/utils/output/loading.js +3 -12
  171. package/lib/utils/parallel.js +32 -43
  172. package/lib/utils/platform/mac.js +4 -15
  173. package/lib/utils/platform/port.js +4 -15
  174. package/lib/utils/prompt/select.js +6 -15
  175. package/lib/utils/report.js +28 -33
  176. package/lib/utils/reporter/agree.js +11 -22
  177. package/lib/utils/reporter/download.js +17 -28
  178. package/lib/utils/reporter/usage.js +12 -23
  179. package/lib/utils/store/auth.js +17 -30
  180. package/lib/utils/store/config.js +11 -25
  181. package/lib/utils/store/db.js +17 -36
  182. package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
  183. package/lib/utils/template-manager.js +215 -242
  184. package/lib/utils/template.js +81 -96
  185. package/lib/utils/tools/common.js +45 -56
  186. package/lib/utils/tools/time.js +5 -16
  187. package/lib/utils/url.js +10 -4
  188. package/package.json +2 -2
  189. package/specs/ag-command/design.md +421 -0
  190. package/specs/ag-command/doc.md +204 -0
  191. package/specs/ag-command/requirements.md +173 -0
  192. package/specs/ag-command/summary.md +174 -0
  193. package/specs/ag-command/tasks.md +197 -0
  194. package/specs/ag-command/usage-guide.md +420 -0
  195. package/tsconfig.json +1 -1
  196. package/types/commands/ag/base.d.ts +44 -0
  197. package/types/commands/ag/create.d.ts +25 -0
  198. package/types/commands/ag/delete.d.ts +32 -0
  199. package/types/commands/ag/deploy.d.ts +31 -0
  200. package/types/commands/ag/detail.d.ts +28 -0
  201. package/types/commands/ag/index.d.ts +6 -0
  202. package/types/commands/ag/list.d.ts +35 -0
  203. package/types/commands/ag/run.d.ts +52 -0
  204. package/types/commands/cloudrun/base.d.ts +10 -0
  205. package/types/commands/index.d.ts +1 -0
@@ -0,0 +1,420 @@
1
+ # AG 命令使用指南
2
+
3
+ ## 概述
4
+
5
+ `tcb ag` 命令用于管理基于 Web 云函数的 Serverless 服务类型 Agent。本指南将详细介绍如何使用各个子命令。
6
+
7
+ ## 快速开始
8
+
9
+ ### 1. 假设当前工作空间目录为 workspace,此处创建新的 Agent 项目
10
+
11
+ ```bash
12
+ # 交互式创建 Agent 项目(推荐)
13
+ tcb ag create my-agent
14
+
15
+ # 指定参数创建
16
+ tcb ag create my-agent --lang node --framework default --template react
17
+ ```
18
+
19
+ ### 2. 本地开发和调试
20
+
21
+ ```bash
22
+ # 进入工作空间目录
23
+ cd workspace
24
+
25
+ # 本地运行 Agent 服务
26
+ tcb ag run my-agent
27
+
28
+ # 同时启动 Agent 服务和前端项目
29
+ tcb ag run my-agent --web
30
+
31
+ # 启动调试面板
32
+ tcb ag run my-agent --open-debug-panel
33
+ ```
34
+
35
+ ### 3. 部署到云端
36
+
37
+ ```bash
38
+ # 部署到 Web 函数(默认)
39
+ tcb ag deploy my-agent
40
+
41
+ # 部署到云托管
42
+ tcb ag deploy my-agent --deployMode cloudrun
43
+ ```
44
+
45
+ ## 命令详解
46
+
47
+ ### ag create - 初始化 Agent 项目
48
+
49
+ 创建新的 Agent 项目结构,支持交互式选择和命令行参数。
50
+
51
+ **语法:**
52
+ ```bash
53
+ tcb ag create <agentName> [options]
54
+ ```
55
+
56
+ **参数:**
57
+ - `agentName`: Agent 名称,用作项目目录名
58
+
59
+ **选项:**
60
+ - `-e, --envId <envId>`: 环境 ID
61
+ - `--template <template>`: 前端模板 (react)
62
+ - `--framework <framework>`: 后端 Agent 框架 (default)
63
+ - `--lang <lang>`: 后端开发语言 (node, python)
64
+ - `--name <name>`: Agent 显示名称
65
+
66
+ **交互式创建(推荐):**
67
+ ```bash
68
+ # 启动交互式向导,逐步选择配置
69
+ tcb ag create my-agent
70
+ ```
71
+
72
+ **命令行参数创建:**
73
+ ```bash
74
+ # Node.js + 默认框架
75
+ tcb ag create my-agent --lang node --framework default
76
+
77
+ # Python + 默认框架 + React 前端
78
+ tcb ag create my-agent --lang python --framework default --template react
79
+
80
+ # 指定环境和名称
81
+ tcb ag create my-agent -e dev-xxxx --name "智能聊天机器人"
82
+ ```
83
+
84
+ **支持的技术栈:**
85
+
86
+ **后端语言:**
87
+ - `node`: JavaScript/TypeScript
88
+ - `python`: Python
89
+
90
+ **后端框架:**
91
+ - `default`: 多框架集合模板
92
+
93
+ **前端模板:**
94
+ - `react`: React 现代化前端框架
95
+
96
+ ### ag deploy - 部署 Agent
97
+
98
+ 将 Agent 部署到云端。
99
+
100
+ **语法:**
101
+ ```bash
102
+ tcb ag deploy [agentName] [options]
103
+ ```
104
+
105
+ **参数:**
106
+ - `agentName`: Agent 名称(可选,如果不指定会提示选择)
107
+
108
+ **选项:**
109
+ - `-e, --envId <envId>`: 环境 ID
110
+ - `--deployMode <deployMode>`: 部署模式(webFn: Web 函数,cloudrun: 云托管,默认: webFn)
111
+ - `--force`: 强制部署,跳过确认提示
112
+ - `--source <source>`: 指定要部署的代码目录路径
113
+
114
+ **示例:**
115
+ ```bash
116
+ # 基本部署
117
+ tcb ag deploy my-agent
118
+
119
+ # 部署到云托管
120
+ tcb ag deploy my-agent --deployMode cloudrun
121
+
122
+ # 强制部署
123
+ tcb ag deploy my-agent --force
124
+
125
+ # 指定源代码目录
126
+ tcb ag deploy my-agent --source ./my-agent-code
127
+
128
+ # 不指定 Agent 名称,交互式选择
129
+ tcb ag deploy
130
+ ```
131
+
132
+ ### ag run - 本地运行 Agent
133
+
134
+ 在本地启动 Agent 调试服务,支持 Node.js 和 Python 项目。
135
+
136
+ **语法:**
137
+ ```bash
138
+ tcb ag run <agentName> [options]
139
+ ```
140
+
141
+ **参数:**
142
+ - `agentName`: Agent 名称
143
+
144
+ **选项:**
145
+ - `-e, --envId <envId>`: 环境 ID
146
+ - `--extendedContext <extendedContext>`: 扩展上下文 JSON 字符串
147
+ - `--port <port>`: 监听端口(默认: 3000)
148
+ - `--dry-run`: 只验证代码,不启动服务
149
+ - `--open-debug-panel`: 是否打开调试面板(默认: false)
150
+ - `--entryPath <entryPath>`: 指定 Agent 服务启动的入口文件路径
151
+ - `--web`: 同时启动前端项目(如果存在 client 目录)
152
+
153
+ **基本使用:**
154
+ ```bash
155
+ # 基本运行
156
+ tcb ag run my-agent
157
+
158
+ # 指定端口和环境
159
+ tcb ag run my-agent -e dev-xxxx --port 9000
160
+
161
+ # 指定入口文件
162
+ tcb ag run my-agent --entryPath ./custom-server.js
163
+ ```
164
+
165
+ **调试功能:**
166
+ ```bash
167
+ # 启动调试面板
168
+ tcb ag run my-agent --open-debug-panel
169
+
170
+ # 同时启动前端项目
171
+ tcb ag run my-agent --web
172
+
173
+ # 组合使用:Agent + 前端 + 调试面板
174
+ tcb ag run my-agent --web --open-debug-panel
175
+ ```
176
+
177
+ **高级功能:**
178
+ ```bash
179
+ # 传递扩展上下文
180
+ tcb ag run my-agent --extendedContext '{"userId": "123", "debug": true}'
181
+
182
+ # 代码验证模式(不启动服务)
183
+ tcb ag run my-agent --dry-run
184
+ ```
185
+
186
+ **支持的项目类型:**
187
+ - **Node.js 项目**: 自动检测 package.json 和入口文件
188
+ - **Python 项目**: 自动检测 requirements.txt 和 Python 入口文件
189
+ - **前端项目**: 检测 client 目录下的前端项目(React、Vue 等)
190
+
191
+
192
+ ### ag list - 查看 Agent 列表
193
+
194
+ 列出环境中的所有 Agent。
195
+
196
+ **语法:**
197
+ ```bash
198
+ tcb ag list [options]
199
+ ```
200
+
201
+ **选项:**
202
+ - `-e, --envId <envId>`: 环境 ID
203
+ - `-l, --limit <limit>`: 数据长度(默认: 20)
204
+ - `-o, --offset <offset>`: 偏移量(默认: 0)
205
+ - `--format <format>`: 输出格式(table | json,默认: table)
206
+
207
+ **示例:**
208
+ ```bash
209
+ # 基本列表
210
+ tcb ag list
211
+
212
+ # 分页查询
213
+ tcb ag list -l 10 -o 20
214
+
215
+ # JSON 格式输出
216
+ tcb ag list --format json
217
+ ```
218
+
219
+ ### ag detail - 查看 Agent 详情
220
+
221
+ 查看指定 Agent 的详细信息。
222
+
223
+ **语法:**
224
+ ```bash
225
+ tcb ag detail <agentName> [options]
226
+ ```
227
+
228
+ **参数:**
229
+ - `agentName`: Agent 名称
230
+
231
+ **选项:**
232
+ - `-e, --envId <envId>`: 环境 ID
233
+ - `--format <format>`: 输出格式(table | json,默认: table)
234
+
235
+ **示例:**
236
+ ```bash
237
+ # 查看详情
238
+ tcb ag detail my-agent
239
+
240
+ # JSON 格式输出
241
+ tcb ag detail my-agent --format json
242
+ ```
243
+
244
+ ### ag delete - 删除 Agent
245
+
246
+ 删除指定的 Agent 或所有 Agent。
247
+
248
+ **语法:**
249
+ ```bash
250
+ tcb ag delete [agentName] [options]
251
+ ```
252
+
253
+ **参数:**
254
+ - `agentName`: Agent 名称(可选)
255
+
256
+ **选项:**
257
+ - `-e, --envId <envId>`: 环境 ID
258
+ - `--agentId <agentId>`: Agent ID(用于指定特定的 Agent ID)
259
+ - `--force`: 强制删除,不提示确认
260
+ - `--all`: 删除配置文件中的所有 Agent
261
+
262
+ **示例:**
263
+ ```bash
264
+ # 删除指定 Agent
265
+ tcb ag delete my-agent
266
+
267
+ # 强制删除
268
+ tcb ag delete my-agent --force
269
+
270
+ # 删除所有 Agent
271
+ tcb ag delete --all
272
+
273
+ # 通过 Agent ID 删除
274
+ tcb ag delete --agentId specific-agent-id
275
+ ```
276
+
277
+ ## 配置文件
278
+
279
+ ### cloudbaserc.json
280
+
281
+ Agent 配置存储在项目根目录的 `cloudbaserc.json` 文件中。使用 `tcb ag create` 命令会自动创建或更新此配置文件。
282
+
283
+ **配置文件结构:**
284
+ ```json
285
+ {
286
+ "envId": "test-tooltip-7g3fqqhv48eec964",
287
+ "agentRoot": "./",
288
+ "agents": [
289
+ {
290
+ "id": "my-agent",
291
+ "name": "智能聊天机器人",
292
+ "timeout": 300,
293
+ "environment": {
294
+ "key": "value"
295
+ },
296
+ "runtime": "Nodejs20.19",
297
+ "memorySize": 2048,
298
+ "description": "",
299
+ "sessionConfig": {
300
+ "enable": true
301
+ },
302
+ "ignore": ["client/**", "client/node_modules/**"],
303
+ "resources": [],
304
+ "installDependency": true
305
+ }
306
+ ]
307
+ }
308
+ ```
309
+
310
+ **配置字段说明:**
311
+ - `envId`: CloudBase 环境 ID
312
+ - `agentRoot`: Agent 项目根目录
313
+ - `agents`: Agent 配置数组
314
+ - `id`: Agent 唯一标识符
315
+ - `name`: Agent 显示名称
316
+ - `timeout`: 超时时间(秒)
317
+ - `environment`: 环境变量配置
318
+ - `runtime`: 运行时版本(Nodejs20.19 或 Python3.10)
319
+ - `memorySize`: 内存大小(MB)
320
+ - `sessionConfig`: 会话配置
321
+ - `ignore`: 部署时忽略的文件/目录
322
+ - `resources`: 绑定的资源列表
323
+ - `installDependency`: 是否自动安装依赖
324
+
325
+ ## 最佳实践
326
+
327
+ ### 1. 开发流程
328
+
329
+ 1. **创建项目**:使用 `tcb ag create` 初始化项目
330
+ 2. **本地开发**:使用 `tcb ag run` 进行本地调试
331
+ 3. **全栈开发**:使用 `tcb ag run --web` 同时启动前后端
332
+ 4. **调试测试**:使用 `tcb ag run --open-debug-panel` 打开调试面板
333
+ 5. **部署上线**:使用 `tcb ag deploy` 部署到云端
334
+
335
+ ### 2. 调试和开发技巧
336
+
337
+ **使用调试面板:**
338
+ - 启动调试面板:`tcb ag run my-agent --open-debug-panel`
339
+ - 调试面板提供 HTTP 和 SSE 请求测试功能
340
+ - 支持自定义请求头和请求体
341
+
342
+ **前端开发:**
343
+ - 使用 `--web` 参数同时启动前后端
344
+ - 前端项目会自动配置 API 地址指向 Agent 服务
345
+ - 支持 React、Vue 等主流前端框架
346
+
347
+ **多语言支持:**
348
+ - Node.js 项目:自动检测 package.json 和入口文件
349
+ - Python 项目:自动检测 requirements.txt 和 Python 入口文件
350
+ - 支持自定义入口文件:`--entryPath`
351
+
352
+ ## 故障排除
353
+
354
+ ### 常见问题
355
+
356
+ 1. **Agent 名称规范**
357
+ - Agent 名称用作项目目录名,建议使用小写字母和连字符
358
+ - 避免使用特殊字符和空格
359
+
360
+ 2. **环境 ID 不存在**
361
+ - 检查环境 ID 是否正确
362
+ - 确保有访问该环境的权限
363
+
364
+ 3. **部署失败**
365
+ - 检查代码结构是否完整
366
+ - 确保 package.json 或 requirements.txt 存在
367
+ - 检查入口文件是否正确
368
+
369
+ 4. **本地调试无法启动**
370
+ - 检查端口是否被占用
371
+ - 确保项目依赖已安装
372
+ - 检查 Python 环境(Python 项目)
373
+
374
+ 5. **前端项目无法启动**
375
+ - 确保 client 目录存在
376
+ - 检查前端项目的 package.json 和启动脚本
377
+ - 确保前端依赖已安装
378
+
379
+ ### 获取帮助
380
+
381
+ ```bash
382
+ # 查看命令帮助
383
+ tcb ag --help
384
+ tcb ag create --help
385
+ tcb ag run --help
386
+ tcb ag deploy --help
387
+
388
+ # 查看版本信息
389
+ tcb --version
390
+ ```
391
+
392
+ ## 新功能亮点
393
+
394
+ ### 🚀 交互式项目创建
395
+ - 支持交互式向导,逐步选择后端语言、框架和前端模板
396
+ - 自动更新 `cloudbaserc.json` 配置文件
397
+ - 支持 Node.js 和 Python 两种后端语言
398
+
399
+ ### 🔧 强大的本地调试
400
+ - 内置调试面板,支持 HTTP 和 SSE 请求测试
401
+ - 支持同时启动前后端项目(`--web` 参数)
402
+ - 自动检测项目类型和入口文件
403
+ - 支持自定义入口文件路径
404
+
405
+ ### 🌐 全栈开发支持
406
+ - 前端项目自动配置 API 地址
407
+ - 支持多种前端框架(React、Vue 等)
408
+ - 自动安装前端依赖
409
+ - 智能环境变量配置
410
+
411
+ ### 🐍 Python 项目支持
412
+ - 完整的 Python 项目支持
413
+ - 自动检测 Python 解释器和依赖
414
+ - 支持 requirements.txt 自动安装
415
+
416
+ ## 更多资源
417
+
418
+ - [CloudBase 官方文档](https://docs.cloudbase.net/)
419
+ - [Agent 开发指南](https://docs.cloudbase.net/agent/)
420
+ - [问题反馈](https://github.com/TencentCloudBase/cloudbase-cli/issues)
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "module": "commonjs",
4
- "target": "es2015",
4
+ "target": "es2019",
5
5
  "moduleResolution": "node",
6
6
  "outDir": "lib",
7
7
  "removeComments": true,
@@ -0,0 +1,44 @@
1
+ import { IAgentResource } from '@cloudbase/manager-node/types/agent/type';
2
+ import { CloudBaseError } from '../../error';
3
+ export interface CloudbaseConfig {
4
+ envId: string;
5
+ agentRoot: string;
6
+ agents?: IAgentConfig[];
7
+ [key: string]: any;
8
+ }
9
+ export interface IAgentConfig {
10
+ id?: string;
11
+ name: string;
12
+ timeout: number;
13
+ environment: {
14
+ [key: string]: string;
15
+ };
16
+ runtime: string;
17
+ memorySize: number;
18
+ description: string;
19
+ sessionConfig: {
20
+ enable: boolean;
21
+ };
22
+ ignore: string[];
23
+ resources: IAgentResource[];
24
+ installDependency: boolean;
25
+ }
26
+ export declare class AgentError extends CloudBaseError {
27
+ constructor(message: string, code?: string);
28
+ }
29
+ export declare function getAgentService(envId: string): Promise<import("@cloudbase/manager-node/types/agent").AgentService>;
30
+ export declare function getCloudbaseConfig(cwd?: string): Promise<CloudbaseConfig>;
31
+ export declare function updateCloudbaseConfig(config: Partial<CloudbaseConfig>, cwd?: string): Promise<void>;
32
+ export declare function getAgentConfig(agentName: string, cwd?: string): Promise<IAgentConfig>;
33
+ export declare function updateAgentConfig(agentName: string, agentConfig: Partial<IAgentConfig>, cwd?: string): Promise<void>;
34
+ export declare function removeAgentConfig(agentName: string, cwd?: string): Promise<void>;
35
+ export declare function validateAgentId(agentId: string): boolean;
36
+ export declare function selectAgent(agents: IAgentConfig[]): Promise<string>;
37
+ export declare function inputAgentName(defaultName?: string): Promise<string>;
38
+ export declare function confirmOperation(message: string, defaultValue?: boolean): Promise<boolean>;
39
+ export declare function selectEnvironment(): Promise<string>;
40
+ export declare function formatAgentStatus(status: string): string;
41
+ export declare function formatFileSize(bytes: number): string;
42
+ export declare function formatTime(timestamp: string | number): string;
43
+ export declare function getAgentIdFromConfig(agentName: string, cwd?: string): Promise<string>;
44
+ export declare function updateAgentIdInConfig(agentName: string, agentId: string, cwd?: string): Promise<void>;
@@ -0,0 +1,25 @@
1
+ import { Command } from '../common';
2
+ import { Logger } from '../../decorators';
3
+ export declare class AgentCreateCommand extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ options: {
8
+ flags: string;
9
+ desc: string;
10
+ }[];
11
+ requiredEnvId: boolean;
12
+ autoRunLogin: boolean;
13
+ desc: string;
14
+ };
15
+ execute(ctx: any, envId: string, log: Logger, params: string[], options: {
16
+ template?: string;
17
+ framework?: string;
18
+ lang?: string;
19
+ }): Promise<void>;
20
+ private addAgentToConfig;
21
+ private interactiveSelection;
22
+ private validateSelections;
23
+ private downloadBackendTemplate;
24
+ private downloadFrontendTemplate;
25
+ }
@@ -0,0 +1,32 @@
1
+ import { Command } from '../common';
2
+ import { Logger } from '../../decorators';
3
+ export declare class AgentDeleteCommand extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ options: ({
8
+ flags: string;
9
+ desc: string;
10
+ defaultValue?: undefined;
11
+ } | {
12
+ flags: string;
13
+ desc: string;
14
+ defaultValue: string;
15
+ } | {
16
+ flags: string;
17
+ desc: string;
18
+ defaultValue: boolean;
19
+ })[];
20
+ requiredEnvId: boolean;
21
+ autoRunLogin: boolean;
22
+ desc: string;
23
+ };
24
+ execute(ctx: any, envId: string, log: Logger, params: string[], options: {
25
+ force: boolean;
26
+ all: boolean;
27
+ agentId: string;
28
+ }): Promise<void>;
29
+ private selectEnv;
30
+ private deleteAgent;
31
+ private deleteAllAgents;
32
+ }
@@ -0,0 +1,31 @@
1
+ import { Command } from '../common';
2
+ import { Logger } from '../../decorators';
3
+ type DeployMode = 'webFn' | 'cloudrun';
4
+ export declare class AgentDeployCommand extends Command {
5
+ get options(): {
6
+ cmd: string;
7
+ childCmd: string;
8
+ options: ({
9
+ flags: string;
10
+ desc: string;
11
+ defaultValue?: undefined;
12
+ } | {
13
+ flags: string;
14
+ desc: string;
15
+ defaultValue: boolean;
16
+ })[];
17
+ requiredEnvId: boolean;
18
+ autoRunLogin: boolean;
19
+ desc: string;
20
+ };
21
+ execute(ctx: any, envId: string, log: Logger, params: string[], options: {
22
+ deployMode?: DeployMode;
23
+ port?: number;
24
+ force: boolean;
25
+ source?: string;
26
+ }): Promise<void>;
27
+ private deployAgentInCloudrun;
28
+ private selectEnv;
29
+ private checkIfFirstDeploy;
30
+ }
31
+ export {};
@@ -0,0 +1,28 @@
1
+ import { Command } from '../common';
2
+ import { Logger } from '../../decorators';
3
+ export declare class AgentDetailCommand extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ options: ({
8
+ flags: string;
9
+ desc: string;
10
+ choices?: undefined;
11
+ defaultValue?: undefined;
12
+ } | {
13
+ flags: string;
14
+ desc: string;
15
+ choices: string[];
16
+ defaultValue: string;
17
+ })[];
18
+ requiredEnvId: boolean;
19
+ autoRunLogin: boolean;
20
+ desc: string;
21
+ };
22
+ execute(ctx: any, envId: string, log: Logger, params: string[], options: {
23
+ format: 'table' | 'json';
24
+ }): Promise<void>;
25
+ private selectEnv;
26
+ private outputTable;
27
+ private outputJson;
28
+ }
@@ -0,0 +1,6 @@
1
+ export * from './create';
2
+ export * from './deploy';
3
+ export * from './run';
4
+ export * from './list';
5
+ export * from './detail';
6
+ export * from './delete';
@@ -0,0 +1,35 @@
1
+ import { Command } from '../common';
2
+ import { Logger } from '../../decorators';
3
+ export declare class AgentListCommand extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ options: ({
8
+ flags: string;
9
+ desc: string;
10
+ defaultValue?: undefined;
11
+ choices?: undefined;
12
+ } | {
13
+ flags: string;
14
+ desc: string;
15
+ defaultValue: number;
16
+ choices?: undefined;
17
+ } | {
18
+ flags: string;
19
+ desc: string;
20
+ choices: string[];
21
+ defaultValue: string;
22
+ })[];
23
+ requiredEnvId: boolean;
24
+ autoRunLogin: boolean;
25
+ desc: string;
26
+ };
27
+ execute(ctx: any, envId: string, log: Logger, options: {
28
+ limit: number;
29
+ offset: number;
30
+ format: 'table' | 'json';
31
+ }): Promise<void>;
32
+ private selectEnv;
33
+ private outputTable;
34
+ private outputJson;
35
+ }
@@ -0,0 +1,52 @@
1
+ import { Command } from '../common';
2
+ import { Logger } from '../../decorators';
3
+ export declare class AgentRunCommand extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ allowUnknownOption: boolean;
8
+ options: ({
9
+ flags: string;
10
+ desc: string;
11
+ defaultValue?: undefined;
12
+ } | {
13
+ flags: string;
14
+ desc: string;
15
+ defaultValue: number;
16
+ } | {
17
+ flags: string;
18
+ desc: string;
19
+ defaultValue: string;
20
+ })[];
21
+ requiredEnvId: boolean;
22
+ autoRunLogin: boolean;
23
+ desc: string;
24
+ };
25
+ execute(ctx: any, envId: string, log: Logger, params: string[], options: {
26
+ extendedContext?: string;
27
+ port: number;
28
+ dryRun: boolean;
29
+ openDebugPanel: string;
30
+ entryPath?: string;
31
+ web?: boolean;
32
+ }): Promise<void>;
33
+ private selectEnv;
34
+ private setupEnvironment;
35
+ private startNormal;
36
+ private startDebugPanelAfterAgentReady;
37
+ private startWebProjectAfterAgentReady;
38
+ private startWebProject;
39
+ private startDebugPanelServer;
40
+ private findAvailablePort;
41
+ private openDebugPanel;
42
+ private waitForService;
43
+ private startAgentService;
44
+ private detectLanguage;
45
+ private validateCustomEntryPath;
46
+ private getPythonEntryPath;
47
+ private getEntryPath;
48
+ private startWithPython;
49
+ private checkPythonAvailable;
50
+ private startWithNode;
51
+ private loadEnvFile;
52
+ }
@@ -1,7 +1,17 @@
1
+ import { CloudrunServerType } from '@cloudbase/manager-node/types/cloudrun/type';
1
2
  import { Logger } from '../../decorators';
2
3
  import { Command } from '../common';
3
4
  export declare function getCloudrunService(envId: string): Promise<import("@cloudbase/manager-node/types/cloudrun").CloudRunService>;
4
5
  export declare function getAgentService(envId: string): Promise<import("@cloudbase/manager-node/types/agent").AgentService>;
6
+ export declare function cloudRunDeploy(deployOptions: {
7
+ envId: string;
8
+ serviceName: string;
9
+ targetDir: string;
10
+ serverType: CloudrunServerType;
11
+ port?: number;
12
+ installDependency?: string;
13
+ log: Logger;
14
+ }): Promise<void>;
5
15
  export declare class CloudRunInitCommand extends Command {
6
16
  get options(): {
7
17
  cmd: string;