@vectorx/cloud-toolkit 1.0.0 → 2.0.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 (37) hide show
  1. package/lib/agent.kit.js +202 -13
  2. package/lib/cloud-dev.kit.js +36 -0
  3. package/lib/config/api.config.js +0 -1
  4. package/lib/container/container.js +6 -0
  5. package/lib/container/identifiers.js +3 -0
  6. package/lib/container/index.js +9 -0
  7. package/lib/database.kit.js +56 -0
  8. package/lib/index.js +2 -0
  9. package/lib/services/agent-service.js +132 -0
  10. package/lib/services/cloud-dev-service.js +97 -0
  11. package/lib/services/database-service.js +142 -0
  12. package/lib/services/fun-service.js +2 -2
  13. package/lib/services/index.js +3 -0
  14. package/lib/utils/cos-uploader.js +3 -1
  15. package/lib/utils/open-browser.js +7 -1
  16. package/lib/utils/openChrome.applescript +2 -2
  17. package/lib/utils/project-validator.js +3 -1
  18. package/lib/utils/request.js +2 -1
  19. package/lib/utils/tracker/ai-apm.js +62 -0
  20. package/lib/utils/tracker/apm.js +3 -1
  21. package/lib/utils/tracker/cli-apm.js +7 -2
  22. package/lib/utils/tracker/device.js +3 -1
  23. package/lib/utils/tracker/index.js +1 -0
  24. package/package.json +6 -6
  25. package/types/agent.kit.d.ts +25 -1
  26. package/types/cloud-dev.kit.d.ts +18 -0
  27. package/types/container/identifiers.d.ts +4 -1
  28. package/types/container/index.d.ts +4 -1
  29. package/types/container/types.d.ts +88 -0
  30. package/types/database.kit.d.ts +54 -0
  31. package/types/index.d.ts +2 -0
  32. package/types/services/agent-service.d.ts +11 -0
  33. package/types/services/cloud-dev-service.d.ts +23 -0
  34. package/types/services/database-service.d.ts +33 -0
  35. package/types/services/index.d.ts +3 -0
  36. package/types/utils/tracker/ai-apm.d.ts +54 -0
  37. package/types/utils/tracker/index.d.ts +1 -0
@@ -0,0 +1,97 @@
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
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.CloudDevService = void 0;
22
+ const endpoints_1 = require("@vectorx/endpoints");
23
+ const inversify_1 = require("inversify");
24
+ const container_1 = require("../container");
25
+ const env_helper_1 = require("../utils/env-helper");
26
+ const request_1 = require("../utils/request");
27
+ const CLOUD_DEV_PREFIX = "/octopus-server/cloud-developement";
28
+ let CloudDevService = class CloudDevService {
29
+ constructor() {
30
+ this.authService = container_1.container.get(container_1.SERVICE_IDENTIFIERS.AuthService);
31
+ }
32
+ resolveAuthQuery(params) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ if ((params === null || params === void 0 ? void 0 : params.secret_id) && (params === null || params === void 0 ? void 0 : params.cli_token)) {
35
+ return { secret_id: params.secret_id, cli_token: params.cli_token };
36
+ }
37
+ if (!env_helper_1.isIDE) {
38
+ const loginInfo = yield this.authService.getLoginInfo();
39
+ if (!loginInfo) {
40
+ throw new Error("未登录,请先执行登录命令");
41
+ }
42
+ return { secret_id: loginInfo.secret_id, cli_token: loginInfo.cli_token };
43
+ }
44
+ return {};
45
+ });
46
+ }
47
+ getCloudDevBaseUrl() {
48
+ return `${(0, endpoints_1.getMiniappBetaBaseUrl)()}${CLOUD_DEV_PREFIX}`;
49
+ }
50
+ getLangfuseConfig(params) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const query = yield this.resolveAuthQuery(params);
53
+ const httpResponse = yield request_1.request.fetch({
54
+ method: "GET",
55
+ url: `${this.getCloudDevBaseUrl()}/langfuse/config`,
56
+ data: { query },
57
+ });
58
+ const data = request_1.request.handleCode(request_1.request.handleHttpStatus(httpResponse));
59
+ return {
60
+ secretKey: data.data.secret_key,
61
+ publicKey: data.data.public_key,
62
+ baseUrl: data.data.base_url,
63
+ };
64
+ });
65
+ }
66
+ getCloudDevLLMBaseURL(params) {
67
+ const base = `${this.getCloudDevBaseUrl()}/llm/chat/completions`;
68
+ if ((params === null || params === void 0 ? void 0 : params.secret_id) && (params === null || params === void 0 ? void 0 : params.cli_token)) {
69
+ return `${base}?secret_id=${params.secret_id}&cli_token=${params.cli_token}`;
70
+ }
71
+ return base;
72
+ }
73
+ getCloudDevAnthropicLLMBaseURL(params) {
74
+ const base = `${this.getCloudDevBaseUrl()}/llm/external/chat/completions`;
75
+ if ((params === null || params === void 0 ? void 0 : params.secret_id) && (params === null || params === void 0 ? void 0 : params.cli_token)) {
76
+ return `${base}?secret_id=${params.secret_id}&cli_token=${params.cli_token}`;
77
+ }
78
+ return base;
79
+ }
80
+ getUserInfo(params) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const query = yield this.resolveAuthQuery(params);
83
+ const httpResponse = yield request_1.request.fetch({
84
+ method: "GET",
85
+ url: `${this.getCloudDevBaseUrl()}/user/info`,
86
+ data: { query },
87
+ });
88
+ const data = request_1.request.handleCode(request_1.request.handleHttpStatus(httpResponse));
89
+ return data.data;
90
+ });
91
+ }
92
+ };
93
+ exports.CloudDevService = CloudDevService;
94
+ exports.CloudDevService = CloudDevService = __decorate([
95
+ (0, inversify_1.injectable)(),
96
+ __metadata("design:paramtypes", [])
97
+ ], CloudDevService);
@@ -0,0 +1,142 @@
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
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.DatabaseService = void 0;
22
+ const cloud_database_client_1 = require("@vectorx/cloud-database-client");
23
+ const inversify_1 = require("inversify");
24
+ const container_1 = require("../container");
25
+ const stderrSink = {
26
+ debug: (...args) => process.stderr.write(`[debug] ${args.join(" ")}\n`),
27
+ info: (...args) => process.stderr.write(`[info] ${args.join(" ")}\n`),
28
+ warn: (...args) => process.stderr.write(`[warn] ${args.join(" ")}\n`),
29
+ error: (...args) => process.stderr.write(`[error] ${args.join(" ")}\n`),
30
+ };
31
+ let DatabaseService = class DatabaseService {
32
+ constructor() {
33
+ this.clientCache = new Map();
34
+ this.mockRdsEndpointInfo = {
35
+ InstanceName: "ra-supabase-ne5e81twbues8l",
36
+ RequestId: "D56F483E-3439-5228-B9FB-E56A221937DF",
37
+ DBInstanceEndpoints: [
38
+ {
39
+ IpType: "public",
40
+ Port: "5432",
41
+ ConnectionString: "pgm-uf6ib032536q2cq14o.pg.rds.aliyuncs.com",
42
+ },
43
+ ],
44
+ };
45
+ this.authService = container_1.container.get(container_1.SERVICE_IDENTIFIERS.AuthService);
46
+ }
47
+ pickDbEndpoint() {
48
+ const preferred = process.env.PG_ENDPOINT_IP_TYPE;
49
+ const ipType = preferred === "vpc" ? "vpc" : "public";
50
+ const endpoints = this.mockRdsEndpointInfo.DBInstanceEndpoints;
51
+ const hit = endpoints.find((e) => e.IpType === ipType);
52
+ if (!hit) {
53
+ throw new Error(`DB endpoint 不存在:ipType=${ipType}`);
54
+ }
55
+ const portNum = Number(hit.Port);
56
+ if (!Number.isFinite(portNum) || portNum <= 0) {
57
+ throw new Error(`DB endpoint 端口非法:${String(hit.Port)}`);
58
+ }
59
+ return { host: hit.ConnectionString, port: portNum, ipType };
60
+ }
61
+ getOrCreateClient(ctx) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ var _a;
64
+ const envId = (_a = ctx.envId) !== null && _a !== void 0 ? _a : "default";
65
+ const key = `postgres::${envId}`;
66
+ const cached = this.clientCache.get(key);
67
+ if (cached)
68
+ return cached;
69
+ const endpoint = this.pickDbEndpoint();
70
+ const database = "supabase_db";
71
+ const password = "miniappSupabaseDatabase_0202";
72
+ const user = "supabase_admin";
73
+ const maxRaw = process.env.PG_POOL_MAX;
74
+ const idleRaw = process.env.PG_POOL_IDLE_TIMEOUT_MS;
75
+ const connTimeoutRaw = process.env.PG_POOL_CONNECTION_TIMEOUT_MS;
76
+ const max = typeof maxRaw === "string" && maxRaw.trim() ? Number(maxRaw) : undefined;
77
+ const idleTimeoutMillis = typeof idleRaw === "string" && idleRaw.trim() ? Number(idleRaw) : undefined;
78
+ const connectionTimeoutMillis = typeof connTimeoutRaw === "string" && connTimeoutRaw.trim()
79
+ ? Number(connTimeoutRaw)
80
+ : undefined;
81
+ const provider = new cloud_database_client_1.PostgresProvider({
82
+ config: {
83
+ host: endpoint.host,
84
+ port: endpoint.port,
85
+ user,
86
+ password,
87
+ database,
88
+ max,
89
+ idleTimeoutMillis,
90
+ connectionTimeoutMillis,
91
+ },
92
+ verbose: false,
93
+ logger: new cloud_database_client_1.OrmLikeDbLogger({
94
+ format: "pretty",
95
+ sink: stderrSink,
96
+ }),
97
+ maxValueLength: 200,
98
+ });
99
+ const client = (0, cloud_database_client_1.createDatabaseClient)({ provider });
100
+ this.clientCache.set(key, client);
101
+ stderrSink.info(`[DatabaseService] 创建数据库连接: envId=${envId}, host=${endpoint.host}:${endpoint.port}`);
102
+ return client;
103
+ });
104
+ }
105
+ listTables(ctx, params) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const client = yield this.getOrCreateClient(ctx);
108
+ const tables = yield client.listTables({
109
+ schema: params === null || params === void 0 ? void 0 : params.schema,
110
+ });
111
+ return { tables };
112
+ });
113
+ }
114
+ getTableColumns(ctx, params) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const client = yield this.getOrCreateClient(ctx);
117
+ const columns = yield client.getTableColumns({
118
+ schema: params.schema,
119
+ table: params.table,
120
+ });
121
+ return { columns };
122
+ });
123
+ }
124
+ previewTable(ctx, params) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const client = yield this.getOrCreateClient(ctx);
127
+ const preview = yield client.previewTable({ schema: params.schema, table: params.table }, params.options);
128
+ return { preview };
129
+ });
130
+ }
131
+ executeSql(ctx, q) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const client = yield this.getOrCreateClient(ctx);
134
+ return yield client.executeSql(q);
135
+ });
136
+ }
137
+ };
138
+ exports.DatabaseService = DatabaseService;
139
+ exports.DatabaseService = DatabaseService = __decorate([
140
+ (0, inversify_1.injectable)(),
141
+ __metadata("design:paramtypes", [])
142
+ ], DatabaseService);
@@ -133,7 +133,7 @@ let FunService = class FunService {
133
133
  deploy(options) {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
135
  var _a, _b;
136
- const { envId, workDir = process.cwd(), includeNodeModules = true, desc, logCollector } = options;
136
+ const { envId, workDir = process.cwd(), includeNodeModules = true, desc, logCollector, } = options;
137
137
  const log = (message_1, ...args_1) => __awaiter(this, [message_1, ...args_1], void 0, function* (message, type = "info", loading = false) {
138
138
  if (logCollector) {
139
139
  yield logCollector.addLog(message, type, loading);
@@ -225,7 +225,7 @@ let FunService = class FunService {
225
225
  }));
226
226
  archive.pipe(output);
227
227
  archive.directory(absWorkDir, false, (data) => {
228
- const excludePatterns = [/^\.git/, /^dist/, /\.zip$/, /\.DS_Store$/];
228
+ const excludePatterns = [/^\.git/, /^\.agentConfig/, /^dist/, /\.zip$/, /\.DS_Store$/];
229
229
  if (!includeNodeModules) {
230
230
  excludePatterns.push(/^node_modules/);
231
231
  }
@@ -16,5 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./auth-service"), exports);
18
18
  __exportStar(require("./upload-service"), exports);
19
+ __exportStar(require("./cloud-dev-service"), exports);
19
20
  __exportStar(require("./cloud-env-service"), exports);
21
+ __exportStar(require("./database-service"), exports);
20
22
  __exportStar(require("./fun-service"), exports);
23
+ __exportStar(require("./agent-service"), exports);
@@ -31,7 +31,9 @@ class Uploader {
31
31
  if (uploadLimitPolicy) {
32
32
  const { fileTypes, maxSize } = uploadLimitPolicy;
33
33
  if ((fileTypes === null || fileTypes === void 0 ? void 0 : fileTypes.length) &&
34
- !fileTypes.reduce((a, c) => [...a, ...c.split("/")], []).some((f) => fileType.endsWith(f))) {
34
+ !fileTypes
35
+ .reduce((a, c) => [...a, ...c.split("/")], [])
36
+ .some((f) => fileType.endsWith(f))) {
35
37
  throw new Error(`文件类型 ${fileType} 不在可上传的文件类型 ${fileTypes.join(", ")} 中。`);
36
38
  }
37
39
  if (maxSize !== undefined && fileSize > maxSize) {
@@ -17,7 +17,13 @@ const openBrowser = (host, port) => {
17
17
  catch (error) {
18
18
  console.log("error", error);
19
19
  (0, open_1.default)(url, {
20
- app: ["google chrome", "--new-window", "--app", "--disable-extensions", "--disable-popup-blocking"],
20
+ app: [
21
+ "google chrome",
22
+ "--new-window",
23
+ "--app",
24
+ "--disable-extensions",
25
+ "--disable-popup-blocking",
26
+ ],
21
27
  });
22
28
  }
23
29
  };
@@ -6,7 +6,7 @@ on run argv
6
6
  set theURL to item 1 of argv
7
7
 
8
8
  with timeout of 2 seconds
9
- tell application "Chrome"
9
+ tell application "Google Chrome"
10
10
 
11
11
  if (count every window) = 0 then
12
12
  make new window
@@ -51,7 +51,7 @@ end run
51
51
  -- if found, store tab, index, and window in properties
52
52
  -- (properties were declared on top of file)
53
53
  on lookupTabWithUrl(lookupUrl)
54
- tell application "Chrome"
54
+ tell application "Google Chrome"
55
55
  -- Find a tab with the given url
56
56
  set found to false
57
57
  set theTabIndex to -1
@@ -88,7 +88,9 @@ class ProjectValidator {
88
88
  return { valid: false, errors };
89
89
  }
90
90
  try {
91
- const version = env_helper_1.isIDE ? ((_a = this.uploadInfo) === null || _a === void 0 ? void 0 : _a.version) || projectConfig.version : projectConfig.version;
91
+ const version = env_helper_1.isIDE
92
+ ? ((_a = this.uploadInfo) === null || _a === void 0 ? void 0 : _a.version) || projectConfig.version
93
+ : projectConfig.version;
92
94
  const desc = env_helper_1.isIDE ? ((_b = this.uploadInfo) === null || _b === void 0 ? void 0 : _b.desc) || projectConfig.desc : projectConfig.desc;
93
95
  const uploadService = container_1.container.get(container_1.SERVICE_IDENTIFIERS.UploadService);
94
96
  const buildPreCheckResult = yield uploadService.buildPreCheck({
@@ -59,7 +59,8 @@ class Request {
59
59
  url: requestUrl,
60
60
  status_code: response.status,
61
61
  }, {
62
- message: (responseData && (responseData.msg || responseData.message)) || `HTTP ${response.status}`,
62
+ message: (responseData && (responseData.msg || responseData.message)) ||
63
+ `HTTP ${response.status}`,
63
64
  status: response.status,
64
65
  });
65
66
  }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AI_MEASUREMENT_NAME = void 0;
4
+ exports.initAiApm = initAiApm;
5
+ exports.reportAiSessionRun = reportAiSessionRun;
6
+ exports.reportAiTurnCodeGenerated = reportAiTurnCodeGenerated;
7
+ exports.reportAiSessionComplete = reportAiSessionComplete;
8
+ exports.reportAiCodeChangeApplied = reportAiCodeChangeApplied;
9
+ exports.reportAiCodeChangeRejected = reportAiCodeChangeRejected;
10
+ exports.reportAiBulkResolve = reportAiBulkResolve;
11
+ exports.reportAiMessageSent = reportAiMessageSent;
12
+ const apm_1 = require("./apm");
13
+ exports.AI_MEASUREMENT_NAME = "vectorx_ai_chat_service_usage";
14
+ let _apm = null;
15
+ function initAiApm(options = {}) {
16
+ if (!_apm)
17
+ _apm = new apm_1.APM();
18
+ _apm.setContext(options.userId || "", {});
19
+ }
20
+ function reportAiSessionRun(meta) {
21
+ if (!_apm)
22
+ return;
23
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign(Object.assign(Object.assign({ event: "session_run", session_id: meta.session_id }, (meta.model ? { model: meta.model } : {})), (meta.dev_mode ? { dev_mode: meta.dev_mode } : {})), (typeof meta.is_new_session === "number" ? { is_new_session: meta.is_new_session } : {})), (typeof meta.message_length === "number" ? { message_length: meta.message_length } : {})));
24
+ }
25
+ function reportAiTurnCodeGenerated(meta) {
26
+ if (!_apm)
27
+ return;
28
+ if (!meta.files_changed && !meta.lines_added && !meta.lines_removed)
29
+ return;
30
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ event: "turn_code_generated" }, (meta.session_id ? { session_id: meta.session_id } : {})), (meta.model ? { model: meta.model } : {})), (meta.dev_mode ? { dev_mode: meta.dev_mode } : {})), (typeof meta.files_changed === "number" ? { files_changed: meta.files_changed } : {})), (typeof meta.lines_added === "number" ? { lines_added: meta.lines_added } : {})), (typeof meta.lines_removed === "number" ? { lines_removed: meta.lines_removed } : {})));
31
+ }
32
+ function reportAiSessionComplete(meta) {
33
+ if (!_apm)
34
+ return;
35
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ event: "session_complete", session_id: meta.session_id }, (meta.model ? { model: meta.model } : {})), (meta.dev_mode ? { dev_mode: meta.dev_mode } : {})), { duration_ms: meta.duration_ms, status: meta.status }), (typeof meta.total_files_changed === "number"
36
+ ? { total_files_changed: meta.total_files_changed }
37
+ : {})), (typeof meta.total_lines_added === "number"
38
+ ? { total_lines_added: meta.total_lines_added }
39
+ : {})), (typeof meta.total_lines_removed === "number"
40
+ ? { total_lines_removed: meta.total_lines_removed }
41
+ : {})), (meta.error_type ? { error_type: meta.error_type } : {})));
42
+ }
43
+ function reportAiCodeChangeApplied(meta) {
44
+ if (!_apm)
45
+ return;
46
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign({ event: "code_change_applied" }, (meta.session_id ? { session_id: meta.session_id } : {})), (meta.tool_name ? { tool_name: meta.tool_name } : {})));
47
+ }
48
+ function reportAiCodeChangeRejected(meta) {
49
+ if (!_apm)
50
+ return;
51
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign({ event: "code_change_rejected" }, (meta.session_id ? { session_id: meta.session_id } : {})), (meta.tool_name ? { tool_name: meta.tool_name } : {})));
52
+ }
53
+ function reportAiBulkResolve(meta) {
54
+ if (!_apm)
55
+ return;
56
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign({ event: "bulk_resolve", action: meta.action }, (meta.session_id ? { session_id: meta.session_id } : {})), (typeof meta.files_count === "number" ? { files_count: meta.files_count } : {})));
57
+ }
58
+ function reportAiMessageSent(meta) {
59
+ if (!_apm)
60
+ return;
61
+ _apm.report(exports.AI_MEASUREMENT_NAME, Object.assign(Object.assign(Object.assign(Object.assign({ event: "message_sent" }, (meta.session_id ? { session_id: meta.session_id } : {})), (meta.mode ? { mode: meta.mode } : {})), (meta.model ? { model: meta.model } : {})), (typeof meta.message_length === "number" ? { message_length: meta.message_length } : {})));
62
+ }
@@ -12,7 +12,9 @@ const device_1 = require("./device");
12
12
  const deviceInfo = (0, device_1.getDeviceInfo)();
13
13
  const getUserAgent = () => {
14
14
  var _a, _b;
15
- const electronStr = typeof ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.electron) !== "undefined" ? `Electron/${(_b = process === null || process === void 0 ? void 0 : process.versions) === null || _b === void 0 ? void 0 : _b.electron}` : "";
15
+ const electronStr = typeof ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.electron) !== "undefined"
16
+ ? `Electron/${(_b = process === null || process === void 0 ? void 0 : process.versions) === null || _b === void 0 ? void 0 : _b.electron}`
17
+ : "";
16
18
  const nodeStr = `Node/${process.version}`;
17
19
  const osVersion = `${deviceInfo.os_platform}/${deviceInfo.os_version}`;
18
20
  const cpu = `CPU/${deviceInfo.cpu_speed}mhz (${deviceInfo.cpu_model}; ${deviceInfo.os_arch})`;
@@ -29,7 +29,10 @@ function hashError(input) {
29
29
  }
30
30
  function normalizeError(err) {
31
31
  var _a, _b, _c, _d;
32
- const msg = safeTruncate((err === null || err === void 0 ? void 0 : err.errMsg) || (err === null || err === void 0 ? void 0 : err.message) || (typeof (err === null || err === void 0 ? void 0 : err.toString) === "function" ? err.toString() : "") || "Unknown error");
32
+ const msg = safeTruncate((err === null || err === void 0 ? void 0 : err.errMsg) ||
33
+ (err === null || err === void 0 ? void 0 : err.message) ||
34
+ (typeof (err === null || err === void 0 ? void 0 : err.toString) === "function" ? err.toString() : "") ||
35
+ "Unknown error");
33
36
  const code = (_c = (_b = (_a = err === null || err === void 0 ? void 0 : err.code) !== null && _a !== void 0 ? _a : err === null || err === void 0 ? void 0 : err.statusCode) !== null && _b !== void 0 ? _b : err === null || err === void 0 ? void 0 : err.status) !== null && _c !== void 0 ? _c : (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.status;
34
37
  const stack = (err === null || err === void 0 ? void 0 : err.stack) ? String(err.stack) : "";
35
38
  const h = hashError(stack || msg);
@@ -59,7 +62,9 @@ function setCliApmCurrentCommand(cmdPath) {
59
62
  function createCliCommandTracker(meta) {
60
63
  var _a, _b, _c;
61
64
  setCliApmCurrentCommand(meta.cmd_path);
62
- const base = Object.assign(Object.assign(Object.assign(Object.assign({ event: "command", cmd_path: meta.cmd_path }, (meta.cmd_root ? { cmd_root: meta.cmd_root } : {})), (typeof meta.params_count === "number" ? { params_count: meta.params_count } : {})), (Array.isArray(meta.options_keys) ? { options_keys: JSON.stringify(meta.options_keys) } : {})), { cli_version: (process === null || process === void 0 ? void 0 : process.CLI_VERSION) || "unknown", node_major: Number((_c = (_b = (_a = process.versions) === null || _a === void 0 ? void 0 : _a.node) === null || _b === void 0 ? void 0 : _b.split(".")) === null || _c === void 0 ? void 0 : _c[0]) || undefined, is_ci: process.env.CI ? 1 : 0 });
65
+ const base = Object.assign(Object.assign(Object.assign(Object.assign({ event: "command", cmd_path: meta.cmd_path }, (meta.cmd_root ? { cmd_root: meta.cmd_root } : {})), (typeof meta.params_count === "number" ? { params_count: meta.params_count } : {})), (Array.isArray(meta.options_keys)
66
+ ? { options_keys: JSON.stringify(meta.options_keys) }
67
+ : {})), { cli_version: (process === null || process === void 0 ? void 0 : process.CLI_VERSION) || "unknown", node_major: Number((_c = (_b = (_a = process.versions) === null || _a === void 0 ? void 0 : _a.node) === null || _b === void 0 ? void 0 : _b.split(".")) === null || _c === void 0 ? void 0 : _c[0]) || undefined, is_ci: process.env.CI ? 1 : 0 });
63
68
  return {
64
69
  reportSuccess(durationMs) {
65
70
  if (!apm)
@@ -44,7 +44,9 @@ function getOsVersion() {
44
44
  var _a, _b;
45
45
  try {
46
46
  if (process.platform === "darwin") {
47
- return (_a = (0, child_process_1.execSync)("sw_vers -productVersion", { encoding: "utf-8" })) === null || _a === void 0 ? void 0 : _a.trim();
47
+ return (_a = (0, child_process_1.execSync)("sw_vers -productVersion", {
48
+ encoding: "utf-8",
49
+ })) === null || _a === void 0 ? void 0 : _a.trim();
48
50
  }
49
51
  return (_b = os_1.default.release()) === null || _b === void 0 ? void 0 : _b.trim();
50
52
  }
@@ -18,3 +18,4 @@ __exportStar(require("./tracker"), exports);
18
18
  __exportStar(require("./device"), exports);
19
19
  __exportStar(require("./apm"), exports);
20
20
  __exportStar(require("./cli-apm"), exports);
21
+ __exportStar(require("./ai-apm"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorx/cloud-toolkit",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "VectorX Cloud Toolkit",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",
@@ -18,10 +18,9 @@
18
18
  "author": "",
19
19
  "license": "ISC",
20
20
  "engines": {
21
- "node": ">=18.0.0"
21
+ "node": ">=20.0.0"
22
22
  },
23
23
  "dependencies": {
24
- "@vectorx/endpoints": "1.0.0",
25
24
  "archiver": "^5.3.1",
26
25
  "cli-table3": "^0.5.1",
27
26
  "cos-nodejs-sdk-v5": "2.x",
@@ -38,7 +37,9 @@
38
37
  "ora": "^4.0.2",
39
38
  "semver": "^7.5.4",
40
39
  "terminal-link": "^2.1.1",
41
- "uuid": "^11.1.0"
40
+ "uuid": "^11.1.0",
41
+ "@vectorx/cloud-database-client": "1.1.0",
42
+ "@vectorx/endpoints": "1.1.0"
42
43
  },
43
44
  "peerDependencies": {
44
45
  "@vectorx/functions-framework": "*"
@@ -58,6 +59,5 @@
58
59
  "dev": "rimraf lib types && tsc -w && cp -r src/utils/*.applescript lib/utils/",
59
60
  "build": "rimraf lib types && tsc --resolveJsonModule && cp -r src/utils/*.applescript lib/utils/",
60
61
  "test": "echo \"Error: no test specified\" && exit 1"
61
- },
62
- "readme": "### 云开发工具集合"
62
+ }
63
63
  }
@@ -1,7 +1,10 @@
1
+ import type { LogCollector } from "./fun.kit";
1
2
  type AgentSimulatorCtor = new (opts: {
2
3
  port: number;
3
4
  agentServerUrl: string;
4
5
  open: boolean;
6
+ quiet?: boolean;
7
+ agentId?: string;
5
8
  }) => {
6
9
  start(): Promise<void>;
7
10
  };
@@ -9,13 +12,21 @@ export interface AgentDevOptions {
9
12
  workDir?: string;
10
13
  port?: number;
11
14
  simulatorPort?: number;
15
+ idePort?: number;
12
16
  watch?: boolean;
13
17
  open?: boolean;
14
18
  nodePath?: string;
15
19
  enableRedLangfuse?: boolean;
16
20
  mode?: "agent" | "fun";
21
+ useIde?: boolean;
17
22
  deps?: {
18
23
  AgentSimulator?: AgentSimulatorCtor;
24
+ startFunctionDebugger?: (opts: any) => Promise<{
25
+ uiUrl: string;
26
+ apiUrl: string;
27
+ wsUrl: string;
28
+ close: () => Promise<void>;
29
+ }>;
19
30
  };
20
31
  }
21
32
  export interface IUploadOptions {
@@ -29,6 +40,7 @@ export interface AgentBuildOptions {
29
40
  upload?: boolean;
30
41
  validator?: IProjectValidator;
31
42
  uploadInfo?: IUploadOptions;
43
+ logCollector?: LogCollector;
32
44
  }
33
45
  export interface AgentNewOptions {
34
46
  projectName: string;
@@ -79,6 +91,7 @@ export declare function startDev(options: AgentDevOptions): Promise<{
79
91
  simulator: {
80
92
  start(): Promise<void>;
81
93
  };
94
+ ideUrl: string;
82
95
  rcbProcess: any;
83
96
  }>;
84
97
  export declare function build(options: AgentBuildOptions): Promise<BuildResult>;
@@ -86,4 +99,15 @@ export declare function createNew(options: AgentNewOptions): Promise<{
86
99
  projectDir: string;
87
100
  }>;
88
101
  export declare function cleanup(): void;
89
- export {};
102
+ export interface AgentInfoResult {
103
+ agentId: string;
104
+ agentName: string;
105
+ agentIcon: string;
106
+ }
107
+ export declare function getAgentInfo(workDir?: string): Promise<AgentInfoResult>;
108
+ export type { AgentListItem, AgentDetail } from "./container/types";
109
+ export declare function getAgentList(params?: {
110
+ pageNo?: number;
111
+ pageSize?: number;
112
+ }): Promise<import("./container/types").AgentListItem[]>;
113
+ export declare function getAgentInfoById(agentId: string): Promise<import("./container/types").AgentDetail | null>;
@@ -0,0 +1,18 @@
1
+ import type { CloudDevUserInfo, LangfuseConfigResult } from "./container";
2
+ export type { LangfuseConfigResult, CloudDevUserInfo };
3
+ export declare function getLangfuseConfig(params?: {
4
+ secret_id?: string;
5
+ cli_token?: string;
6
+ }): Promise<LangfuseConfigResult>;
7
+ export declare function getCloudDevLLMBaseURL(params?: {
8
+ secret_id?: string;
9
+ cli_token?: string;
10
+ }): string;
11
+ export declare function getCloudDevAnthropicLLMBaseURL(params?: {
12
+ secret_id?: string;
13
+ cli_token?: string;
14
+ }): string;
15
+ export declare function getUserInfo(params?: {
16
+ secret_id?: string;
17
+ cli_token?: string;
18
+ }): Promise<CloudDevUserInfo>;
@@ -1,8 +1,11 @@
1
1
  import type { ServiceIdentifier } from "inversify";
2
- import type { IAuthService, ICloudEnvService, IFunService, IUploadService } from "./types";
2
+ import type { IAgentService, IAuthService, ICloudDevService, ICloudEnvService, IDatabaseService, IFunService, IUploadService } from "./types";
3
3
  export declare const SERVICE_IDENTIFIERS: {
4
4
  AuthService: ServiceIdentifier<IAuthService>;
5
5
  UploadService: ServiceIdentifier<IUploadService>;
6
6
  CloudEnvService: ServiceIdentifier<ICloudEnvService>;
7
+ CloudDevService: ServiceIdentifier<ICloudDevService>;
7
8
  FunService: ServiceIdentifier<IFunService>;
9
+ DatabaseService: ServiceIdentifier<IDatabaseService>;
10
+ AgentService: ServiceIdentifier<IAgentService>;
8
11
  };
@@ -1,11 +1,14 @@
1
1
  import { container } from "./container";
2
2
  import { SERVICE_IDENTIFIERS } from "./identifiers";
3
- import type { IAuthService, ICloudEnvService, IFunService, IUploadService } from "./types";
3
+ import type { IAgentService, IAuthService, ICloudDevService, ICloudEnvService, IDatabaseService, IFunService, IUploadService } from "./types";
4
4
  export declare class ServiceProvider {
5
5
  static getAuthService(): IAuthService;
6
6
  static getUploadService(): IUploadService;
7
7
  static getCloudEnvService(): ICloudEnvService;
8
+ static getCloudDevService(): ICloudDevService;
8
9
  static getFunService(): IFunService;
10
+ static getDatabaseService(): IDatabaseService;
11
+ static getAgentService(): IAgentService;
9
12
  }
10
13
  export { container, SERVICE_IDENTIFIERS };
11
14
  export * from "./types";