mstool-shared 1.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/package.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "mstool-shared",
3
+ "version": "1.0.0",
4
+ "description": "MSTool shared types and protocols",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.ts",
7
+ "keywords": ["mstool", "agent", "ops"],
8
+ "license": "MIT",
9
+ "repository": { "type": "git", "url": "https://github.com/scaleflower/mstools" }
10
+ }
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ export * from './types/user';
2
+ export * from './types/project';
3
+ export * from './types/agent-node';
4
+ export * from './types/target-host';
5
+ export * from './types/database';
6
+ export * from './types/session';
7
+ export * from './types/skill';
8
+ export * from './types/memory';
9
+ export * from './types/model-provider';
10
+ export * from './types/alert';
11
+ export * from './types/ws-protocol';
12
+ export * from './types/collection';
13
+ export * from './types/awr';
@@ -0,0 +1,25 @@
1
+ export enum AgentNodeStatus {
2
+ ONLINE = 'online',
3
+ OFFLINE = 'offline',
4
+ REGISTERING = 'registering',
5
+ }
6
+
7
+ export interface AgentNode {
8
+ id: string;
9
+ name: string;
10
+ projectId: string;
11
+ status: AgentNodeStatus;
12
+ version?: string;
13
+ lastSeenAt?: Date;
14
+ registeredAt: Date;
15
+ }
16
+
17
+ export interface NodeRegistrationToken {
18
+ id: string;
19
+ token: string;
20
+ projectId: string;
21
+ createdById: string;
22
+ usedAt?: Date;
23
+ expiresAt: Date;
24
+ createdAt: Date;
25
+ }
@@ -0,0 +1,53 @@
1
+ export enum AlertTriggerType {
2
+ THRESHOLD = 'threshold',
3
+ AI_ANALYSIS = 'ai_analysis',
4
+ }
5
+
6
+ export enum AlertChannel {
7
+ DINGTALK = 'dingtalk',
8
+ EMAIL = 'email',
9
+ IN_PLATFORM = 'in_platform',
10
+ }
11
+
12
+ export enum AlertSeverity {
13
+ INFO = 'info',
14
+ WARNING = 'warning',
15
+ CRITICAL = 'critical',
16
+ }
17
+
18
+ export enum AlertStatus {
19
+ ACTIVE = 'active',
20
+ RESOLVED = 'resolved',
21
+ ACKNOWLEDGED = 'acknowledged',
22
+ }
23
+
24
+ export interface AlertRule {
25
+ id: string;
26
+ projectId: string;
27
+ name: string;
28
+ triggerType: AlertTriggerType;
29
+ condition?: AlertThresholdCondition;
30
+ channels: AlertChannel[];
31
+ isEnabled: boolean;
32
+ createdAt: Date;
33
+ updatedAt: Date;
34
+ }
35
+
36
+ export interface AlertThresholdCondition {
37
+ metric: 'cpu' | 'memory' | 'disk';
38
+ operator: '>' | '<' | '>=' | '<=';
39
+ threshold: number;
40
+ durationSeconds: number;
41
+ }
42
+
43
+ export interface Alert {
44
+ id: string;
45
+ ruleId: string;
46
+ projectId: string;
47
+ hostId: string;
48
+ severity: AlertSeverity;
49
+ status: AlertStatus;
50
+ message: string;
51
+ triggeredAt: Date;
52
+ resolvedAt?: Date;
53
+ }
@@ -0,0 +1,34 @@
1
+ export enum AwrReportStatus {
2
+ PENDING = 'pending',
3
+ GENERATING = 'generating',
4
+ COMPLETED = 'completed',
5
+ FAILED = 'failed',
6
+ }
7
+
8
+ export interface AwrReport {
9
+ id: string;
10
+ projectId: string;
11
+ connectionId: string;
12
+ dbId?: string;
13
+ instanceNum?: number;
14
+ beginSnapId: number;
15
+ endSnapId: number;
16
+ status: AwrReportStatus;
17
+ htmlContent?: string;
18
+ aiAnalysis?: string;
19
+ errorMessage?: string;
20
+ triggeredById?: string;
21
+ createdAt: Date;
22
+ completedAt?: Date;
23
+ }
24
+
25
+ export interface AwrSchedule {
26
+ id: string;
27
+ projectId: string;
28
+ connectionId: string;
29
+ cronExpression: string;
30
+ snapIntervalMinutes: number;
31
+ isEnabled: boolean;
32
+ lastRunAt?: Date;
33
+ createdAt: Date;
34
+ }
@@ -0,0 +1,32 @@
1
+ export interface HostMetrics {
2
+ hostId: string;
3
+ collectedAt: Date;
4
+ cpuPercent: number;
5
+ memoryPercent: number;
6
+ memoryUsedBytes: number;
7
+ memoryTotalBytes: number;
8
+ diskUsedBytes: number;
9
+ diskTotalBytes: number;
10
+ networkRxBytesPerSec: number;
11
+ networkTxBytesPerSec: number;
12
+ }
13
+
14
+ export interface ProcessInfo {
15
+ hostId: string;
16
+ collectedAt: Date;
17
+ pid: number;
18
+ name: string;
19
+ cpuPercent: number;
20
+ memoryPercent: number;
21
+ status: string;
22
+ }
23
+
24
+ export interface CollectionSchedule {
25
+ id: string;
26
+ projectId: string;
27
+ hostId?: string;
28
+ intervalSeconds: number;
29
+ isEnabled: boolean;
30
+ lastRunAt?: Date;
31
+ createdAt: Date;
32
+ }
@@ -0,0 +1,27 @@
1
+ export enum DbType {
2
+ ORACLE = 'oracle',
3
+ MYSQL = 'mysql',
4
+ POSTGRESQL = 'postgresql',
5
+ }
6
+
7
+ export interface DbConnection {
8
+ id: string;
9
+ projectId: string;
10
+ name: string;
11
+ dbType: DbType;
12
+ host: string;
13
+ port: number;
14
+ serviceName: string;
15
+ agentNodeId: string;
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ }
19
+
20
+ export interface UserDbCredential {
21
+ id: string;
22
+ userId: string;
23
+ connectionId: string;
24
+ username: string;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ }
@@ -0,0 +1,9 @@
1
+ export interface Memory {
2
+ id: string;
3
+ projectId: string;
4
+ key: string;
5
+ value: string;
6
+ createdById: string;
7
+ createdAt: Date;
8
+ updatedAt: Date;
9
+ }
@@ -0,0 +1,18 @@
1
+ export enum ModelProviderType {
2
+ ANTHROPIC = 'anthropic',
3
+ OPENAI = 'openai',
4
+ ALIYUN = 'aliyun',
5
+ OLLAMA = 'ollama',
6
+ VLLM = 'vllm',
7
+ }
8
+
9
+ export interface ModelProvider {
10
+ id: string;
11
+ name: string;
12
+ type: ModelProviderType;
13
+ baseUrl?: string;
14
+ isEnabled: boolean;
15
+ models: string[];
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ }
@@ -0,0 +1,14 @@
1
+ export interface Project {
2
+ id: string;
3
+ name: string;
4
+ description?: string;
5
+ createdById: string;
6
+ createdAt: Date;
7
+ updatedAt: Date;
8
+ }
9
+
10
+ export interface ProjectMember {
11
+ projectId: string;
12
+ userId: string;
13
+ joinedAt: Date;
14
+ }
@@ -0,0 +1,34 @@
1
+ export interface Session {
2
+ id: string;
3
+ projectId: string;
4
+ userId: string;
5
+ title: string;
6
+ skillId?: string;
7
+ modelProviderId?: string;
8
+ modelId?: string;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ }
12
+
13
+ export enum MessageRole {
14
+ USER = 'user',
15
+ ASSISTANT = 'assistant',
16
+ TOOL = 'tool',
17
+ }
18
+
19
+ export interface Message {
20
+ id: string;
21
+ sessionId: string;
22
+ role: MessageRole;
23
+ content: string | ToolCallContent[];
24
+ createdAt: Date;
25
+ }
26
+
27
+ export interface ToolCallContent {
28
+ type: 'tool_call' | 'tool_result';
29
+ toolCallId: string;
30
+ toolName?: string;
31
+ args?: Record<string, unknown>;
32
+ result?: unknown;
33
+ isError?: boolean;
34
+ }
@@ -0,0 +1,43 @@
1
+ export interface Skill {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ prompt: string;
6
+ parameters: SkillParameter[];
7
+ createdById: string;
8
+ isPublished: boolean;
9
+ downloadCount: number;
10
+ createdAt: Date;
11
+ updatedAt: Date;
12
+ }
13
+
14
+ export interface SkillParameter {
15
+ name: string;
16
+ type: 'string' | 'number' | 'boolean';
17
+ description: string;
18
+ required: boolean;
19
+ defaultValue?: string | number | boolean;
20
+ }
21
+
22
+ export interface SkillAuditLog {
23
+ id: string;
24
+ skillId: string;
25
+ userId: string;
26
+ sessionId: string;
27
+ calledAt: Date;
28
+ }
29
+
30
+ export enum SkillReviewStatus {
31
+ PENDING = 'pending',
32
+ APPROVED = 'approved',
33
+ REJECTED = 'rejected',
34
+ }
35
+
36
+ export interface SkillReview {
37
+ id: string;
38
+ skillId: string;
39
+ reviewerId: string;
40
+ status: SkillReviewStatus;
41
+ comment?: string;
42
+ reviewedAt: Date;
43
+ }
@@ -0,0 +1,34 @@
1
+ export enum AuthType {
2
+ KEY = 'key',
3
+ PASSWORD = 'password',
4
+ }
5
+
6
+ export interface JumpHost {
7
+ host: string;
8
+ port: number;
9
+ username: string;
10
+ authType: AuthType;
11
+ }
12
+
13
+ export interface TargetHost {
14
+ id: string;
15
+ projectId: string;
16
+ name: string;
17
+ host: string;
18
+ port: number;
19
+ username: string;
20
+ authType: AuthType;
21
+ agentNodeId: string;
22
+ jumpHosts: JumpHost[];
23
+ logPaths: LogPath[];
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ }
27
+
28
+ export interface LogPath {
29
+ id: string;
30
+ hostId: string;
31
+ path: string;
32
+ description?: string;
33
+ createdAt: Date;
34
+ }
@@ -0,0 +1,19 @@
1
+ export enum UserRole {
2
+ PLATFORM_ADMIN = 'platform_admin',
3
+ PROJECT_ADMIN = 'project_admin',
4
+ PROJECT_MEMBER = 'project_member',
5
+ }
6
+
7
+ export interface User {
8
+ id: string;
9
+ username: string;
10
+ email: string;
11
+ role: UserRole;
12
+ createdAt: Date;
13
+ updatedAt: Date;
14
+ }
15
+
16
+ export interface UserProfile extends User {
17
+ displayName?: string;
18
+ avatarUrl?: string;
19
+ }
@@ -0,0 +1,46 @@
1
+ export enum WsMessageType {
2
+ REQUEST = 'request',
3
+ RESULT = 'result',
4
+ STREAM_CHUNK = 'stream_chunk',
5
+ STREAM_END = 'stream_end',
6
+ ERROR = 'error',
7
+ PING = 'ping',
8
+ PONG = 'pong',
9
+ REGISTER = 'register',
10
+ REGISTER_ACK = 'register_ack',
11
+ }
12
+
13
+ export interface WsMessage<T = unknown> {
14
+ task_id: string;
15
+ type: WsMessageType;
16
+ payload: T;
17
+ }
18
+
19
+ export interface WsToolRequest {
20
+ tool: string;
21
+ args: Record<string, unknown>;
22
+ }
23
+
24
+ export interface WsToolResult {
25
+ output: unknown;
26
+ }
27
+
28
+ export interface WsStreamChunk {
29
+ chunk: string;
30
+ }
31
+
32
+ export interface WsError {
33
+ code: string;
34
+ message: string;
35
+ }
36
+
37
+ export interface WsRegisterPayload {
38
+ token: string;
39
+ version: string;
40
+ hostname: string;
41
+ }
42
+
43
+ export interface WsRegisterAckPayload {
44
+ nodeId: string;
45
+ nodeSecret: string;
46
+ }