@vectorx/cloud-toolkit 1.0.1 → 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.
- package/lib/agent.kit.js +202 -13
- package/lib/cloud-dev.kit.js +36 -0
- package/lib/container/container.js +6 -0
- package/lib/container/identifiers.js +3 -0
- package/lib/container/index.js +9 -0
- package/lib/database.kit.js +56 -0
- package/lib/index.js +2 -0
- package/lib/services/agent-service.js +132 -0
- package/lib/services/cloud-dev-service.js +97 -0
- package/lib/services/database-service.js +142 -0
- package/lib/services/fun-service.js +2 -2
- package/lib/services/index.js +3 -0
- package/lib/utils/cos-uploader.js +3 -1
- package/lib/utils/open-browser.js +7 -1
- package/lib/utils/openChrome.applescript +2 -2
- package/lib/utils/project-validator.js +3 -1
- package/lib/utils/request.js +2 -1
- package/lib/utils/tracker/ai-apm.js +62 -0
- package/lib/utils/tracker/apm.js +3 -1
- package/lib/utils/tracker/cli-apm.js +7 -2
- package/lib/utils/tracker/device.js +3 -1
- package/lib/utils/tracker/index.js +1 -0
- package/package.json +6 -6
- package/types/agent.kit.d.ts +25 -1
- package/types/cloud-dev.kit.d.ts +18 -0
- package/types/container/identifiers.d.ts +4 -1
- package/types/container/index.d.ts +4 -1
- package/types/container/types.d.ts +88 -0
- package/types/database.kit.d.ts +54 -0
- package/types/index.d.ts +2 -0
- package/types/services/agent-service.d.ts +11 -0
- package/types/services/cloud-dev-service.d.ts +23 -0
- package/types/services/database-service.d.ts +33 -0
- package/types/services/index.d.ts +3 -0
- package/types/utils/tracker/ai-apm.d.ts +54 -0
- package/types/utils/tracker/index.d.ts +1 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DatabaseClient } from "@vectorx/cloud-database-client";
|
|
2
|
+
import type { DatabaseRequestContext, DbColumn, DbPreviewOptions, DbTable, DbTablePreview, SqlQuery } from "../database.kit";
|
|
1
3
|
import type { CloudEnvironment, CloudEnvironmentCreateRequest, CloudEnvironmentUpdateRequest } from "../env.kit";
|
|
2
4
|
import type { FunDeployOptions, FunDeployResult, FunDevOptions, FunDevRuntime } from "../fun.kit";
|
|
3
5
|
import type { CheckStatusRequest, CheckStatusResponse } from "../services/auth-service";
|
|
@@ -38,6 +40,91 @@ export interface IFunService {
|
|
|
38
40
|
total: number;
|
|
39
41
|
}>;
|
|
40
42
|
}
|
|
43
|
+
export interface IDatabaseService {
|
|
44
|
+
getOrCreateClient(ctx: DatabaseRequestContext): Promise<DatabaseClient>;
|
|
45
|
+
listTables(ctx: DatabaseRequestContext, params?: {
|
|
46
|
+
schema?: string;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
tables: DbTable[];
|
|
49
|
+
}>;
|
|
50
|
+
getTableColumns(ctx: DatabaseRequestContext, params: {
|
|
51
|
+
schema?: string;
|
|
52
|
+
table: string;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
columns: DbColumn[];
|
|
55
|
+
}>;
|
|
56
|
+
previewTable(ctx: DatabaseRequestContext, params: {
|
|
57
|
+
schema?: string;
|
|
58
|
+
table: string;
|
|
59
|
+
options?: DbPreviewOptions;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
preview: DbTablePreview;
|
|
62
|
+
}>;
|
|
63
|
+
executeSql(ctx: DatabaseRequestContext, q: SqlQuery): Promise<{
|
|
64
|
+
rows: any[];
|
|
65
|
+
rowCount?: number;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
export interface ICloudDevService {
|
|
69
|
+
getLangfuseConfig(params?: {
|
|
70
|
+
secret_id?: string;
|
|
71
|
+
cli_token?: string;
|
|
72
|
+
}): Promise<LangfuseConfigResult>;
|
|
73
|
+
getCloudDevLLMBaseURL(params?: {
|
|
74
|
+
secret_id?: string;
|
|
75
|
+
cli_token?: string;
|
|
76
|
+
}): string;
|
|
77
|
+
getCloudDevAnthropicLLMBaseURL(params?: {
|
|
78
|
+
secret_id?: string;
|
|
79
|
+
cli_token?: string;
|
|
80
|
+
}): string;
|
|
81
|
+
getUserInfo(params?: {
|
|
82
|
+
secret_id?: string;
|
|
83
|
+
cli_token?: string;
|
|
84
|
+
}): Promise<CloudDevUserInfo>;
|
|
85
|
+
}
|
|
86
|
+
export interface LangfuseConfigResult {
|
|
87
|
+
secretKey: string;
|
|
88
|
+
publicKey: string;
|
|
89
|
+
baseUrl?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface CloudDevUserInfo {
|
|
92
|
+
nick?: string;
|
|
93
|
+
nickname?: string;
|
|
94
|
+
user_id?: string;
|
|
95
|
+
avatar?: string;
|
|
96
|
+
desc?: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
export interface AgentListItem {
|
|
100
|
+
agentId: string;
|
|
101
|
+
agentName: string;
|
|
102
|
+
agentType?: string;
|
|
103
|
+
status?: string;
|
|
104
|
+
createTime?: string;
|
|
105
|
+
updateTime?: string;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
export interface AgentDetail {
|
|
109
|
+
agentId: string;
|
|
110
|
+
agentName: string;
|
|
111
|
+
agentAvatar?: string;
|
|
112
|
+
agentType?: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
status?: string;
|
|
115
|
+
config?: Record<string, unknown>;
|
|
116
|
+
createTime?: string;
|
|
117
|
+
updateTime?: string;
|
|
118
|
+
creator?: string;
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}
|
|
121
|
+
export interface IAgentService {
|
|
122
|
+
getAgentList(params?: {
|
|
123
|
+
pageNo?: number;
|
|
124
|
+
pageSize?: number;
|
|
125
|
+
}): Promise<AgentListItem[]>;
|
|
126
|
+
getAgentInfoById(agentId: string): Promise<AgentDetail | null>;
|
|
127
|
+
}
|
|
41
128
|
export interface CloudEnvInfo {
|
|
42
129
|
cloud_env_name: string;
|
|
43
130
|
status: number;
|
|
@@ -52,4 +139,5 @@ export interface LoginInfo {
|
|
|
52
139
|
create_at: number;
|
|
53
140
|
expire_in_sec: number;
|
|
54
141
|
cloudEnvInfo?: CloudEnvInfo | null;
|
|
142
|
+
userInfo?: CloudDevUserInfo | null;
|
|
55
143
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DatabaseClient } from "@vectorx/cloud-database-client";
|
|
2
|
+
export type DbTable = {
|
|
3
|
+
schema?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export type DbColumn = {
|
|
7
|
+
name: string;
|
|
8
|
+
dataType?: string;
|
|
9
|
+
udtName?: string;
|
|
10
|
+
nullable?: boolean;
|
|
11
|
+
ordinalPosition?: number;
|
|
12
|
+
defaultValue?: string | null;
|
|
13
|
+
};
|
|
14
|
+
export type DbTablePreview = {
|
|
15
|
+
rows: Array<Record<string, any>>;
|
|
16
|
+
rowCount?: number;
|
|
17
|
+
};
|
|
18
|
+
export type DbPreviewOptions = {
|
|
19
|
+
limit?: number;
|
|
20
|
+
offset?: number;
|
|
21
|
+
orderBy?: string;
|
|
22
|
+
orderDirection?: "asc" | "desc";
|
|
23
|
+
};
|
|
24
|
+
export type SqlQuery = {
|
|
25
|
+
sql: string;
|
|
26
|
+
values?: any[];
|
|
27
|
+
readonly?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export interface DatabaseRequestContext {
|
|
30
|
+
envId?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function getDatabaseClient(ctx?: DatabaseRequestContext): Promise<DatabaseClient>;
|
|
33
|
+
export declare function listDatabaseTables(ctx?: DatabaseRequestContext, params?: {
|
|
34
|
+
schema?: string;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
tables: DbTable[];
|
|
37
|
+
}>;
|
|
38
|
+
export declare function getDatabaseTableColumns(ctx?: DatabaseRequestContext, params?: {
|
|
39
|
+
schema?: string;
|
|
40
|
+
table: string;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
columns: DbColumn[];
|
|
43
|
+
}>;
|
|
44
|
+
export declare function previewDatabaseTable(ctx?: DatabaseRequestContext, params?: {
|
|
45
|
+
schema?: string;
|
|
46
|
+
table: string;
|
|
47
|
+
options?: DbPreviewOptions;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
preview: DbTablePreview;
|
|
50
|
+
}>;
|
|
51
|
+
export declare function executeDatabaseSql(ctx?: DatabaseRequestContext, q?: SqlQuery): Promise<{
|
|
52
|
+
rows: any[];
|
|
53
|
+
rowCount?: number;
|
|
54
|
+
}>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./agent.kit";
|
|
2
2
|
export * from "./fun.kit";
|
|
3
3
|
export * from "./env.kit";
|
|
4
|
+
export * from "./database.kit";
|
|
5
|
+
export * from "./cloud-dev.kit";
|
|
4
6
|
export { Uploader } from "./utils/cos-uploader";
|
|
5
7
|
export * from "./container";
|
|
6
8
|
export * from "./services";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentDetail, AgentListItem, IAgentService } from "../container/types";
|
|
2
|
+
export declare class AgentService implements IAgentService {
|
|
3
|
+
private readonly authService;
|
|
4
|
+
constructor();
|
|
5
|
+
private resolveAuthQuery;
|
|
6
|
+
getAgentList(params?: {
|
|
7
|
+
pageNo?: number;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
}): Promise<AgentListItem[]>;
|
|
10
|
+
getAgentInfoById(agentId: string): Promise<AgentDetail | null>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CloudDevUserInfo, ICloudDevService, LangfuseConfigResult } from "../container";
|
|
2
|
+
export declare class CloudDevService implements ICloudDevService {
|
|
3
|
+
private readonly authService;
|
|
4
|
+
constructor();
|
|
5
|
+
private resolveAuthQuery;
|
|
6
|
+
private getCloudDevBaseUrl;
|
|
7
|
+
getLangfuseConfig(params?: {
|
|
8
|
+
secret_id?: string;
|
|
9
|
+
cli_token?: string;
|
|
10
|
+
}): Promise<LangfuseConfigResult>;
|
|
11
|
+
getCloudDevLLMBaseURL(params?: {
|
|
12
|
+
secret_id?: string;
|
|
13
|
+
cli_token?: string;
|
|
14
|
+
}): string;
|
|
15
|
+
getCloudDevAnthropicLLMBaseURL(params?: {
|
|
16
|
+
secret_id?: string;
|
|
17
|
+
cli_token?: string;
|
|
18
|
+
}): string;
|
|
19
|
+
getUserInfo(params?: {
|
|
20
|
+
secret_id?: string;
|
|
21
|
+
cli_token?: string;
|
|
22
|
+
}): Promise<CloudDevUserInfo>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type DatabaseClient } from "@vectorx/cloud-database-client";
|
|
2
|
+
import type { IDatabaseService } from "../container/types";
|
|
3
|
+
import type { DatabaseRequestContext, DbColumn, DbPreviewOptions, DbTable, DbTablePreview, SqlQuery } from "../database.kit";
|
|
4
|
+
export declare class DatabaseService implements IDatabaseService {
|
|
5
|
+
private readonly authService;
|
|
6
|
+
private readonly clientCache;
|
|
7
|
+
private readonly mockRdsEndpointInfo;
|
|
8
|
+
constructor();
|
|
9
|
+
private pickDbEndpoint;
|
|
10
|
+
getOrCreateClient(ctx: DatabaseRequestContext): Promise<DatabaseClient>;
|
|
11
|
+
listTables(ctx: DatabaseRequestContext, params?: {
|
|
12
|
+
schema?: string;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
tables: DbTable[];
|
|
15
|
+
}>;
|
|
16
|
+
getTableColumns(ctx: DatabaseRequestContext, params: {
|
|
17
|
+
schema?: string;
|
|
18
|
+
table: string;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
columns: DbColumn[];
|
|
21
|
+
}>;
|
|
22
|
+
previewTable(ctx: DatabaseRequestContext, params: {
|
|
23
|
+
schema?: string;
|
|
24
|
+
table: string;
|
|
25
|
+
options?: DbPreviewOptions;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
preview: DbTablePreview;
|
|
28
|
+
}>;
|
|
29
|
+
executeSql(ctx: DatabaseRequestContext, q: SqlQuery): Promise<{
|
|
30
|
+
rows: any[];
|
|
31
|
+
rowCount?: number;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const AI_MEASUREMENT_NAME = "vectorx_ai_chat_service_usage";
|
|
2
|
+
export type AiSessionStatus = "success" | "fail" | "aborted";
|
|
3
|
+
export interface InitAiApmOptions {
|
|
4
|
+
userId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function initAiApm(options?: InitAiApmOptions): void;
|
|
7
|
+
export interface AiSessionRunMeta {
|
|
8
|
+
session_id: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
dev_mode?: string;
|
|
11
|
+
is_new_session?: 0 | 1;
|
|
12
|
+
message_length?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function reportAiSessionRun(meta: AiSessionRunMeta): void;
|
|
15
|
+
export interface AiTurnCodeGeneratedMeta {
|
|
16
|
+
session_id?: string;
|
|
17
|
+
model?: string;
|
|
18
|
+
dev_mode?: string;
|
|
19
|
+
files_changed?: number;
|
|
20
|
+
lines_added?: number;
|
|
21
|
+
lines_removed?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function reportAiTurnCodeGenerated(meta: AiTurnCodeGeneratedMeta): void;
|
|
24
|
+
export interface AiSessionCompleteMeta {
|
|
25
|
+
session_id: string;
|
|
26
|
+
model?: string;
|
|
27
|
+
dev_mode?: string;
|
|
28
|
+
duration_ms: number;
|
|
29
|
+
status: AiSessionStatus;
|
|
30
|
+
total_files_changed?: number;
|
|
31
|
+
total_lines_added?: number;
|
|
32
|
+
total_lines_removed?: number;
|
|
33
|
+
error_type?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function reportAiSessionComplete(meta: AiSessionCompleteMeta): void;
|
|
36
|
+
export interface AiCodeChangeMeta {
|
|
37
|
+
session_id?: string;
|
|
38
|
+
tool_name?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare function reportAiCodeChangeApplied(meta: AiCodeChangeMeta): void;
|
|
41
|
+
export declare function reportAiCodeChangeRejected(meta: AiCodeChangeMeta): void;
|
|
42
|
+
export interface AiBulkResolveMeta {
|
|
43
|
+
session_id?: string;
|
|
44
|
+
action: "accept" | "reject";
|
|
45
|
+
files_count?: number;
|
|
46
|
+
}
|
|
47
|
+
export declare function reportAiBulkResolve(meta: AiBulkResolveMeta): void;
|
|
48
|
+
export interface AiMessageSentMeta {
|
|
49
|
+
session_id?: string;
|
|
50
|
+
mode?: string;
|
|
51
|
+
model?: string;
|
|
52
|
+
message_length?: number;
|
|
53
|
+
}
|
|
54
|
+
export declare function reportAiMessageSent(meta: AiMessageSentMeta): void;
|