@axiom-lattice/protocols 2.1.14 → 2.1.16

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,401 @@
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
+ * Request body for executing custom SQL query
302
+ */
303
+ export interface ExecuteSqlQueryRequest {
304
+ /** Data source ID to query */
305
+ datasourceId: string | number;
306
+ /** Custom SQL query string with named parameters (e.g., :year, :category) */
307
+ customSql: string;
308
+ /** Optional parameters for the SQL query */
309
+ params?: Record<string, string | number | boolean>;
310
+ /** Optional result limit */
311
+ limit?: number;
312
+ }
313
+
314
+ /**
315
+ * Response from custom SQL query execution
316
+ */
317
+ export interface ExecuteSqlQueryResponse {
318
+ /** Data source ID that was queried */
319
+ datasourceId: string | number;
320
+ /** Data source name */
321
+ datasourceName?: string;
322
+ /** Column names */
323
+ columns: string[];
324
+ /** Query result rows */
325
+ rows: Array<Record<string, unknown>>;
326
+ /** Total row count */
327
+ rowCount: number;
328
+ /** Execution time in milliseconds */
329
+ executionTimeMs: number;
330
+ /** The actual executed SQL (for debugging) */
331
+ executedSql?: string;
332
+ }
333
+
334
+ /**
335
+ * MetricsServerConfigStore interface
336
+ * Provides CRUD operations for metrics server configuration data
337
+ */
338
+ export interface MetricsServerConfigStore {
339
+ /**
340
+ * Get all metrics server configurations for a tenant
341
+ * @param tenantId - Tenant identifier
342
+ * @returns Array of all metrics server configurations
343
+ */
344
+ getAllConfigs(tenantId: string): Promise<MetricsServerConfigEntry[]>;
345
+
346
+ /**
347
+ * Get all metrics server configurations across all tenants
348
+ * @returns Array of all metrics server configurations
349
+ */
350
+ getAllConfigsWithoutTenant(): Promise<MetricsServerConfigEntry[]>;
351
+
352
+ /**
353
+ * Get metrics server configuration by ID
354
+ * @param tenantId - Tenant identifier
355
+ * @param id - Configuration identifier
356
+ * @returns Configuration if found, null otherwise
357
+ */
358
+ getConfigById(tenantId: string, id: string): Promise<MetricsServerConfigEntry | null>;
359
+
360
+ /**
361
+ * Get metrics server configuration by business key
362
+ * @param tenantId - Tenant identifier
363
+ * @param key - Business key
364
+ * @returns Configuration if found, null otherwise
365
+ */
366
+ getConfigByKey(tenantId: string, key: string): Promise<MetricsServerConfigEntry | null>;
367
+
368
+ /**
369
+ * Create a new metrics server configuration
370
+ * @param tenantId - Tenant identifier
371
+ * @param id - Configuration identifier
372
+ * @param data - Configuration creation data
373
+ * @returns Created configuration
374
+ */
375
+ createConfig(tenantId: string, id: string, data: CreateMetricsServerConfigRequest): Promise<MetricsServerConfigEntry>;
376
+
377
+ /**
378
+ * Update an existing metrics server configuration
379
+ * @param tenantId - Tenant identifier
380
+ * @param id - Configuration identifier
381
+ * @param updates - Partial configuration data to update
382
+ * @returns Updated configuration if found, null otherwise
383
+ */
384
+ updateConfig(tenantId: string, id: string, updates: Partial<UpdateMetricsServerConfigRequest>): Promise<MetricsServerConfigEntry | null>;
385
+
386
+ /**
387
+ * Delete a metrics server configuration by ID
388
+ * @param tenantId - Tenant identifier
389
+ * @param id - Configuration identifier
390
+ * @returns true if deleted, false otherwise
391
+ */
392
+ deleteConfig(tenantId: string, id: string): Promise<boolean>;
393
+
394
+ /**
395
+ * Check if configuration exists
396
+ * @param tenantId - Tenant identifier
397
+ * @param id - Configuration identifier
398
+ * @returns true if configuration exists, false otherwise
399
+ */
400
+ hasConfig(tenantId: string, id: string): Promise<boolean>;
401
+ }
@@ -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";