@axiom-lattice/protocols 2.1.14 → 2.1.15

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.
@@ -0,0 +1,367 @@
1
+ /**
2
+ * MetricsServerConfigStoreProtocol
3
+ *
4
+ * Metrics Server configuration store protocol for the Axiom Lattice framework
5
+ * Provides standardized interfaces for metrics server connection config management
6
+ */
7
+
8
+ /**
9
+ * Supported metrics server types
10
+ */
11
+ export type MetricsServerType = 'prometheus' | 'grafana' | 'custom' | 'semantic';
12
+
13
+ /**
14
+ * Metrics server connection configuration
15
+ */
16
+ export interface MetricsServerConfig {
17
+ /** Server type */
18
+ type: MetricsServerType;
19
+ /** Server base URL (e.g., http://localhost:9090) */
20
+ serverUrl: string;
21
+ /** Optional API key for authentication */
22
+ apiKey?: string;
23
+ /** Optional username for basic auth */
24
+ username?: string;
25
+ /** Optional password for basic auth */
26
+ password?: string;
27
+ /** Optional additional headers */
28
+ headers?: Record<string, string>;
29
+ /** Optional timeout in milliseconds (default: 30000) */
30
+ timeout?: number;
31
+ }
32
+
33
+ /**
34
+ * Metrics server configuration entry stored in the store
35
+ */
36
+ export interface MetricsServerConfigEntry {
37
+ /**
38
+ * Unique identifier for the configuration
39
+ */
40
+ id: string;
41
+
42
+ /**
43
+ * Tenant identifier for multi-tenant isolation
44
+ */
45
+ tenantId: string;
46
+
47
+ /**
48
+ * Business key for the configuration (unique within tenant)
49
+ */
50
+ key: string;
51
+
52
+ /**
53
+ * Metrics server connection configuration
54
+ */
55
+ config: MetricsServerConfig;
56
+
57
+ /**
58
+ * Optional friendly name
59
+ */
60
+ name?: string;
61
+
62
+ /**
63
+ * Optional description
64
+ */
65
+ description?: string;
66
+
67
+ /**
68
+ * Creation timestamp
69
+ */
70
+ createdAt: Date;
71
+
72
+ /**
73
+ * Last update timestamp
74
+ */
75
+ updatedAt: Date;
76
+ }
77
+
78
+ /**
79
+ * Request to create a new metrics server configuration
80
+ */
81
+ export interface CreateMetricsServerConfigRequest {
82
+ /**
83
+ * Business key for the configuration (unique within tenant)
84
+ */
85
+ key: string;
86
+
87
+ /**
88
+ * Metrics server connection configuration
89
+ */
90
+ config: MetricsServerConfig;
91
+
92
+ /**
93
+ * Optional friendly name
94
+ */
95
+ name?: string;
96
+
97
+ /**
98
+ * Optional description
99
+ */
100
+ description?: string;
101
+ }
102
+
103
+ /**
104
+ * Request to update an existing metrics server configuration
105
+ */
106
+ export interface UpdateMetricsServerConfigRequest {
107
+ /**
108
+ * Business key for the configuration
109
+ */
110
+ key?: string;
111
+
112
+ /**
113
+ * Metrics server connection configuration
114
+ */
115
+ config?: MetricsServerConfig;
116
+
117
+ /**
118
+ * Optional friendly name
119
+ */
120
+ name?: string;
121
+
122
+ /**
123
+ * Optional description
124
+ */
125
+ description?: string;
126
+ }
127
+
128
+ /**
129
+ * Metric metadata information
130
+ */
131
+ export interface MetricMeta {
132
+ /** Metric name */
133
+ name: string;
134
+ /** Metric type (gauge, counter, histogram, summary) */
135
+ type?: string;
136
+ /** Metric description/help text */
137
+ description?: string;
138
+ /** Available label names */
139
+ labels?: string[];
140
+ /** Unit of measurement */
141
+ unit?: string;
142
+ }
143
+
144
+ /**
145
+ * Metric data point
146
+ */
147
+ export interface MetricDataPoint {
148
+ /** Timestamp */
149
+ timestamp: number;
150
+ /** Metric value */
151
+ value: number;
152
+ /** Label values */
153
+ labels?: Record<string, string>;
154
+ }
155
+
156
+ /**
157
+ * Metric query result
158
+ */
159
+ export interface MetricQueryResult {
160
+ /** Metric name */
161
+ metricName: string;
162
+ /** Data points */
163
+ dataPoints: MetricDataPoint[];
164
+ /** Query metadata */
165
+ metadata?: {
166
+ startTime?: number;
167
+ endTime?: number;
168
+ step?: number;
169
+ };
170
+ }
171
+
172
+ /**
173
+ * Data source information for semantic metrics server
174
+ */
175
+ export interface DataSource {
176
+ /** Unique identifier for the data source */
177
+ id: string | number;
178
+ /** Display name of the data source */
179
+ name: string;
180
+ /** JDBC connection URL or similar */
181
+ url: string;
182
+ /** Username for connection */
183
+ username?: string;
184
+ /** Schema name in the database */
185
+ schemaName?: string;
186
+ /** Description of the data source */
187
+ description?: string;
188
+ /** Status code */
189
+ status: number;
190
+ /** Status label (e.g., "active", "inactive") */
191
+ statusLabel?: string;
192
+ /** Whether the data source is currently connected */
193
+ connected: boolean;
194
+ /** Creation timestamp */
195
+ createdAt?: string;
196
+ /** Last update timestamp */
197
+ updatedAt?: string;
198
+ }
199
+
200
+ /**
201
+ * Semantic metrics server configuration
202
+ * Extends base config with semantic-specific properties
203
+ */
204
+ export interface SemanticMetricsServerConfig extends MetricsServerConfig {
205
+ /** Must be 'semantic' */
206
+ type: 'semantic';
207
+ /** IDs of selected data sources */
208
+ selectedDataSources?: string[];
209
+ }
210
+
211
+ /**
212
+ * Filter definition for semantic metrics query
213
+ */
214
+ export interface SemanticMetricsFilter {
215
+ /** Dimension/column name to filter on */
216
+ dimension: string;
217
+ /** Operator (e.g., "BETWEEN", "=", ">", "<") */
218
+ operator: string;
219
+ /** Values for the filter */
220
+ values: (string | number | boolean)[];
221
+ }
222
+
223
+ /**
224
+ * Request body for semantic metrics query
225
+ */
226
+ export interface SemanticMetricsQueryRequest {
227
+ /** Data source ID to query */
228
+ datasourceId: string | number;
229
+ /** Array of metric names to query */
230
+ metrics: string[];
231
+ /** Optional group by dimensions */
232
+ groupBy?: string[];
233
+ /** Optional filters */
234
+ filters?: SemanticMetricsFilter[];
235
+ /** Optional result limit */
236
+ limit?: number;
237
+ }
238
+
239
+ /**
240
+ * Single data point in semantic metrics query response
241
+ */
242
+ export interface SemanticMetricDataPoint {
243
+ /** Timestamp in milliseconds */
244
+ timestamp?: number;
245
+ /** Metric value */
246
+ value: number;
247
+ /** Metric name */
248
+ metricName?: string;
249
+ /** Additional dimension values */
250
+ labels?: Record<string, string>;
251
+ /** Group by dimension values */
252
+ groupByValues?: Record<string, string>;
253
+ }
254
+
255
+ /**
256
+ * AI Hints for a single metric result
257
+ */
258
+ export interface SemanticMetricAiHints {
259
+ polarity: string;
260
+ valueInterpretation: string;
261
+ thresholds?: Array<{
262
+ metric: string;
263
+ operator: string;
264
+ value: number;
265
+ level: string;
266
+ }>;
267
+ suggestedFollowup?: string[];
268
+ }
269
+
270
+ /**
271
+ * Single metric result from semantic metrics query
272
+ */
273
+ export interface SemanticMetricResult {
274
+ metricName: string;
275
+ displayName: string;
276
+ dataType: string;
277
+ format: string;
278
+ polarity: string;
279
+ columns: string[];
280
+ rows: Array<Record<string, unknown>>;
281
+ rowCount: number;
282
+ executionTimeMs: number;
283
+ aiHints: SemanticMetricAiHints;
284
+ }
285
+
286
+ /**
287
+ * Response from semantic metrics query
288
+ */
289
+ export interface SemanticMetricsQueryResponse {
290
+ /** Data source ID that was queried */
291
+ datasourceId: string | number;
292
+ /** Data source name */
293
+ datasourceName?: string;
294
+ /** Query results for each metric */
295
+ results: SemanticMetricResult[];
296
+ /** Total execution time in ms */
297
+ totalExecutionTimeMs?: number;
298
+ }
299
+
300
+ /**
301
+ * MetricsServerConfigStore interface
302
+ * Provides CRUD operations for metrics server configuration data
303
+ */
304
+ export interface MetricsServerConfigStore {
305
+ /**
306
+ * Get all metrics server configurations for a tenant
307
+ * @param tenantId - Tenant identifier
308
+ * @returns Array of all metrics server configurations
309
+ */
310
+ getAllConfigs(tenantId: string): Promise<MetricsServerConfigEntry[]>;
311
+
312
+ /**
313
+ * Get all metrics server configurations across all tenants
314
+ * @returns Array of all metrics server configurations
315
+ */
316
+ getAllConfigsWithoutTenant(): Promise<MetricsServerConfigEntry[]>;
317
+
318
+ /**
319
+ * Get metrics server configuration by ID
320
+ * @param tenantId - Tenant identifier
321
+ * @param id - Configuration identifier
322
+ * @returns Configuration if found, null otherwise
323
+ */
324
+ getConfigById(tenantId: string, id: string): Promise<MetricsServerConfigEntry | null>;
325
+
326
+ /**
327
+ * Get metrics server configuration by business key
328
+ * @param tenantId - Tenant identifier
329
+ * @param key - Business key
330
+ * @returns Configuration if found, null otherwise
331
+ */
332
+ getConfigByKey(tenantId: string, key: string): Promise<MetricsServerConfigEntry | null>;
333
+
334
+ /**
335
+ * Create a new metrics server configuration
336
+ * @param tenantId - Tenant identifier
337
+ * @param id - Configuration identifier
338
+ * @param data - Configuration creation data
339
+ * @returns Created configuration
340
+ */
341
+ createConfig(tenantId: string, id: string, data: CreateMetricsServerConfigRequest): Promise<MetricsServerConfigEntry>;
342
+
343
+ /**
344
+ * Update an existing metrics server configuration
345
+ * @param tenantId - Tenant identifier
346
+ * @param id - Configuration identifier
347
+ * @param updates - Partial configuration data to update
348
+ * @returns Updated configuration if found, null otherwise
349
+ */
350
+ updateConfig(tenantId: string, id: string, updates: Partial<UpdateMetricsServerConfigRequest>): Promise<MetricsServerConfigEntry | null>;
351
+
352
+ /**
353
+ * Delete a metrics server configuration by ID
354
+ * @param tenantId - Tenant identifier
355
+ * @param id - Configuration identifier
356
+ * @returns true if deleted, false otherwise
357
+ */
358
+ deleteConfig(tenantId: string, id: string): Promise<boolean>;
359
+
360
+ /**
361
+ * Check if configuration exists
362
+ * @param tenantId - Tenant identifier
363
+ * @param id - Configuration identifier
364
+ * @returns true if configuration exists, false otherwise
365
+ */
366
+ hasConfig(tenantId: string, id: string): Promise<boolean>;
367
+ }
@@ -190,4 +190,19 @@ export interface SkillStore {
190
190
  * @returns Array of sub-skills if found, empty array otherwise
191
191
  */
192
192
  getSubSkills(parentSkillName: string): Promise<Skill[]>;
193
+
194
+ /**
195
+ * List all resources in a skill's resources directory
196
+ * @param id Skill identifier
197
+ * @returns Array of resource paths relative to resources/ directory
198
+ */
199
+ listSkillResources?(id: string): Promise<string[]>;
200
+
201
+ /**
202
+ * Load a specific resource from a skill's resources directory
203
+ * @param id Skill identifier
204
+ * @param resourcePath Path to the resource relative to resources/ directory
205
+ * @returns The resource content as string, or null if not found
206
+ */
207
+ loadSkillResource?(id: string, resourcePath: string): Promise<string | null>;
193
208
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * TenantStoreProtocol
3
+ *
4
+ * Tenant store protocol definitions
5
+ * for the Axiom Lattice framework
6
+ */
7
+
8
+ export type TenantStatus = 'active' | 'inactive' | 'suspended';
9
+
10
+ /**
11
+ * Tenant type definition
12
+ */
13
+ export interface Tenant {
14
+ id: string;
15
+ name: string;
16
+ description?: string;
17
+ status: TenantStatus;
18
+ metadata?: Record<string, any>;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ }
22
+
23
+ /**
24
+ * Create tenant request type
25
+ */
26
+ export interface CreateTenantRequest {
27
+ name: string;
28
+ description?: string;
29
+ status?: TenantStatus;
30
+ metadata?: Record<string, any>;
31
+ }
32
+
33
+ /**
34
+ * Update tenant request type
35
+ */
36
+ export interface UpdateTenantRequest {
37
+ name?: string;
38
+ description?: string;
39
+ status?: TenantStatus;
40
+ metadata?: Record<string, any>;
41
+ }
42
+
43
+ /**
44
+ * TenantStore interface
45
+ * Provides CRUD operations for tenant data
46
+ * Note: Tenant is a top-level entity, so no tenantId parameter is needed
47
+ */
48
+ export interface TenantStore {
49
+ getAllTenants(): Promise<Tenant[]>;
50
+ getTenantById(id: string): Promise<Tenant | null>;
51
+ createTenant(id: string, data: CreateTenantRequest): Promise<Tenant>;
52
+ updateTenant(id: string, updates: UpdateTenantRequest): Promise<Tenant | null>;
53
+ deleteTenant(id: string): Promise<boolean>;
54
+ }
@@ -0,0 +1,34 @@
1
+ export type UserStatus = 'active' | 'pending' | 'suspended';
2
+
3
+ export interface User {
4
+ id: string;
5
+ email: string;
6
+ name: string;
7
+ status: UserStatus;
8
+ metadata?: Record<string, any>;
9
+ createdAt: Date;
10
+ updatedAt: Date;
11
+ }
12
+
13
+ export interface CreateUserRequest {
14
+ email: string;
15
+ name: string;
16
+ status?: UserStatus;
17
+ metadata?: Record<string, any>;
18
+ }
19
+
20
+ export interface UpdateUserRequest {
21
+ email?: string;
22
+ name?: string;
23
+ status?: UserStatus;
24
+ metadata?: Record<string, any>;
25
+ }
26
+
27
+ export interface UserStore {
28
+ getAllUsers(): Promise<User[]>;
29
+ getUserById(id: string): Promise<User | null>;
30
+ getUserByEmail(email: string): Promise<User | null>;
31
+ createUser(id: string, data: CreateUserRequest): Promise<User>;
32
+ updateUser(id: string, updates: UpdateUserRequest): Promise<User | null>;
33
+ deleteUser(id: string): Promise<boolean>;
34
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * UserTenantLinkProtocol
3
+ *
4
+ * User-Tenant relationship store protocol
5
+ * Supports many-to-many relationship between users and tenants
6
+ */
7
+
8
+ /**
9
+ * User role in tenant
10
+ */
11
+ export type UserTenantRole = 'owner' | 'admin' | 'member';
12
+
13
+ /**
14
+ * User-Tenant link type definition
15
+ */
16
+ export interface UserTenantLink {
17
+ userId: string;
18
+ tenantId: string;
19
+ role: UserTenantRole;
20
+ joinedAt: Date;
21
+ metadata?: Record<string, any>;
22
+ }
23
+
24
+ /**
25
+ * Create user-tenant link request
26
+ */
27
+ export interface CreateUserTenantLinkRequest {
28
+ userId: string;
29
+ tenantId: string;
30
+ role?: UserTenantRole;
31
+ metadata?: Record<string, any>;
32
+ }
33
+
34
+ /**
35
+ * Update user-tenant link request
36
+ */
37
+ export interface UpdateUserTenantLinkRequest {
38
+ role?: UserTenantRole;
39
+ metadata?: Record<string, any>;
40
+ }
41
+
42
+ /**
43
+ * UserTenantLinkStore interface
44
+ * Manages many-to-many relationship between users and tenants
45
+ */
46
+ export interface UserTenantLinkStore {
47
+ /**
48
+ * Get all tenants for a user
49
+ */
50
+ getTenantsByUser(userId: string): Promise<UserTenantLink[]>;
51
+
52
+ /**
53
+ * Get all users for a tenant
54
+ */
55
+ getUsersByTenant(tenantId: string): Promise<UserTenantLink[]>;
56
+
57
+ /**
58
+ * Get specific link
59
+ */
60
+ getLink(userId: string, tenantId: string): Promise<UserTenantLink | null>;
61
+
62
+ /**
63
+ * Create link between user and tenant
64
+ */
65
+ createLink(data: CreateUserTenantLinkRequest): Promise<UserTenantLink>;
66
+
67
+ /**
68
+ * Update link
69
+ */
70
+ updateLink(userId: string, tenantId: string, updates: UpdateUserTenantLinkRequest): Promise<UserTenantLink | null>;
71
+
72
+ /**
73
+ * Delete link
74
+ */
75
+ deleteLink(userId: string, tenantId: string): Promise<boolean>;
76
+
77
+ /**
78
+ * Check if user belongs to tenant
79
+ */
80
+ hasLink(userId: string, tenantId: string): Promise<boolean>;
81
+ }
package/src/index.ts CHANGED
@@ -22,7 +22,11 @@ export * from "./SkillLatticeProtocol";
22
22
  export * from "./SkillStoreProtocol";
23
23
  export * from "./McpLatticeProtocol";
24
24
  export * from "./WorkspaceStoreProtocol";
25
+ export * from "./TenantStoreProtocol";
25
26
  export * from "./DatabaseConfigStoreProtocol";
27
+ export * from "./MetricsServerConfigStoreProtocol";
28
+ export * from "./UserStoreProtocol";
29
+ export * from "./UserTenantLinkProtocol";
26
30
 
27
31
  // 导出通用类型
28
32
  export * from "./types";