@cortexa/core 0.7.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/LICENSE +191 -0
- package/README.md +423 -0
- package/dist/chunk-6VDDIS65.js +21 -0
- package/dist/chunk-6VDDIS65.js.map +1 -0
- package/dist/chunk-T4NUBJ7T.js +13 -0
- package/dist/chunk-T4NUBJ7T.js.map +1 -0
- package/dist/cli/chunk-7HYSAZX4.js +15 -0
- package/dist/cli/chunk-7HYSAZX4.js.map +1 -0
- package/dist/cli/chunk-HVMZ6P54.js +23 -0
- package/dist/cli/chunk-HVMZ6P54.js.map +1 -0
- package/dist/cli/index.js +5921 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mongodb-WTT5HVQH.js +145 -0
- package/dist/cli/mongodb-WTT5HVQH.js.map +1 -0
- package/dist/cli/mongodb-stream-Q5OBFWZP.js +93 -0
- package/dist/cli/mongodb-stream-Q5OBFWZP.js.map +1 -0
- package/dist/cli/mssql-KG7P3R2I.js +79 -0
- package/dist/cli/mssql-KG7P3R2I.js.map +1 -0
- package/dist/cli/mysql-stream-Z2MZS2KF.js +195 -0
- package/dist/cli/mysql-stream-Z2MZS2KF.js.map +1 -0
- package/dist/cli/postgres-stream-S4CRICEA.js +237 -0
- package/dist/cli/postgres-stream-S4CRICEA.js.map +1 -0
- package/dist/index.cjs +5733 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +670 -0
- package/dist/index.d.ts +670 -0
- package/dist/index.js +4805 -0
- package/dist/index.js.map +1 -0
- package/dist/mongodb-M5UGJZTC.js +143 -0
- package/dist/mongodb-M5UGJZTC.js.map +1 -0
- package/dist/mongodb-stream-Q23UHLTM.js +92 -0
- package/dist/mongodb-stream-Q23UHLTM.js.map +1 -0
- package/dist/mssql-I27XEHQ2.js +77 -0
- package/dist/mssql-I27XEHQ2.js.map +1 -0
- package/dist/mysql-stream-YCNLPPPG.js +194 -0
- package/dist/mysql-stream-YCNLPPPG.js.map +1 -0
- package/dist/postgres-stream-A7EVYUX2.js +236 -0
- package/dist/postgres-stream-A7EVYUX2.js.map +1 -0
- package/package.json +105 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
|
|
3
|
+
interface RetryConfig {
|
|
4
|
+
maxRetries?: number;
|
|
5
|
+
initialDelayMs?: number;
|
|
6
|
+
maxDelayMs?: number;
|
|
7
|
+
backoffMultiplier?: number;
|
|
8
|
+
retryableStatusCodes?: number[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface LLMResponse {
|
|
12
|
+
content: string;
|
|
13
|
+
tokensUsed: {
|
|
14
|
+
prompt: number;
|
|
15
|
+
completion: number;
|
|
16
|
+
};
|
|
17
|
+
model: string;
|
|
18
|
+
}
|
|
19
|
+
interface LLMChatOptions {
|
|
20
|
+
jsonMode?: boolean;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
}
|
|
23
|
+
interface LLMProvider {
|
|
24
|
+
chat(prompt: string, options?: LLMChatOptions): Promise<LLMResponse>;
|
|
25
|
+
}
|
|
26
|
+
interface LLMConfig {
|
|
27
|
+
provider: string;
|
|
28
|
+
apiKey?: string;
|
|
29
|
+
model?: string;
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
retry?: RetryConfig;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface WorkflowConfig {
|
|
36
|
+
stateColumn: string;
|
|
37
|
+
expectedTransitions: string[];
|
|
38
|
+
stuckThreshold?: string;
|
|
39
|
+
}
|
|
40
|
+
type InsightType = 'transition_skip' | 'transition_unexpected' | 'transition_stuck' | 'correlation_divergence' | 'correlation_timing' | 'distribution_shift' | 'temporal_shift';
|
|
41
|
+
type Severity = 'low' | 'medium' | 'high' | 'critical';
|
|
42
|
+
interface StateTransition {
|
|
43
|
+
entity: string;
|
|
44
|
+
tableName: string;
|
|
45
|
+
primaryKey: string | number;
|
|
46
|
+
fromState: string;
|
|
47
|
+
toState: string;
|
|
48
|
+
durationMs: number;
|
|
49
|
+
timestamp: Date;
|
|
50
|
+
expected: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface TransitionStats {
|
|
53
|
+
entity: string;
|
|
54
|
+
fromState: string;
|
|
55
|
+
toState: string;
|
|
56
|
+
count: number;
|
|
57
|
+
avgDurationMs: number;
|
|
58
|
+
minDurationMs: number;
|
|
59
|
+
maxDurationMs: number;
|
|
60
|
+
}
|
|
61
|
+
interface Insight {
|
|
62
|
+
entity: string;
|
|
63
|
+
insightType: InsightType;
|
|
64
|
+
severity: Severity;
|
|
65
|
+
message: string;
|
|
66
|
+
context: Record<string, unknown>;
|
|
67
|
+
timestamp: Date;
|
|
68
|
+
}
|
|
69
|
+
interface ReasoningConfig {
|
|
70
|
+
workflows: Record<string, WorkflowConfig>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface CorrelationConfig {
|
|
74
|
+
entities: [string, string];
|
|
75
|
+
timeWindow: string;
|
|
76
|
+
}
|
|
77
|
+
interface DistributionConfig {
|
|
78
|
+
columns: string[];
|
|
79
|
+
temporalBuckets: 'hourly' | 'daily';
|
|
80
|
+
}
|
|
81
|
+
interface AnalyticsConfig {
|
|
82
|
+
correlations?: Record<string, CorrelationConfig>;
|
|
83
|
+
distributions?: Record<string, DistributionConfig>;
|
|
84
|
+
}
|
|
85
|
+
interface CorrelationStatus {
|
|
86
|
+
name: string;
|
|
87
|
+
entities: [string, string];
|
|
88
|
+
rateRatio: number;
|
|
89
|
+
baselineRatio: number;
|
|
90
|
+
coOccurrenceRate: number;
|
|
91
|
+
baselineCoOccurrence: number;
|
|
92
|
+
healthy: boolean;
|
|
93
|
+
}
|
|
94
|
+
interface DistributionSummary {
|
|
95
|
+
entity: string;
|
|
96
|
+
columnName: string;
|
|
97
|
+
bucketCount: number;
|
|
98
|
+
baselineSamples: number;
|
|
99
|
+
currentShift: number | null;
|
|
100
|
+
shifted: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type NodeType = 'entity' | 'event' | 'anomaly' | 'insight';
|
|
104
|
+
type EdgeType = 'contains' | 'causes' | 'correlates' | 'transitions_to' | 'detected_on';
|
|
105
|
+
interface KnowledgeNode {
|
|
106
|
+
id: number;
|
|
107
|
+
nodeType: NodeType;
|
|
108
|
+
refId: string;
|
|
109
|
+
label: string;
|
|
110
|
+
metadata: Record<string, unknown>;
|
|
111
|
+
timestamp: string;
|
|
112
|
+
}
|
|
113
|
+
interface KnowledgeEdge {
|
|
114
|
+
id: number;
|
|
115
|
+
sourceId: number;
|
|
116
|
+
targetId: number;
|
|
117
|
+
edgeType: EdgeType;
|
|
118
|
+
weight: number;
|
|
119
|
+
metadata: Record<string, unknown>;
|
|
120
|
+
timestamp: string;
|
|
121
|
+
}
|
|
122
|
+
interface EntityIntelligenceResult {
|
|
123
|
+
entityName: string;
|
|
124
|
+
tableCount: number;
|
|
125
|
+
totalEvents: number;
|
|
126
|
+
anomalyCount: number;
|
|
127
|
+
topCorrelations: Array<{
|
|
128
|
+
entity: string;
|
|
129
|
+
weight: number;
|
|
130
|
+
}>;
|
|
131
|
+
recentInsights: KnowledgeNode[];
|
|
132
|
+
riskScore: number;
|
|
133
|
+
}
|
|
134
|
+
interface KnowledgeConfig {
|
|
135
|
+
enabled: boolean;
|
|
136
|
+
}
|
|
137
|
+
interface GraphSummary {
|
|
138
|
+
totalNodes: number;
|
|
139
|
+
totalEdges: number;
|
|
140
|
+
entities: number;
|
|
141
|
+
events: number;
|
|
142
|
+
anomalies: number;
|
|
143
|
+
insights: number;
|
|
144
|
+
}
|
|
145
|
+
interface GraphExport {
|
|
146
|
+
nodes: KnowledgeNode[];
|
|
147
|
+
edges: KnowledgeEdge[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
type GovernanceLevel = 'auto_approve' | 'require_approval' | 'never_automate';
|
|
151
|
+
type RecommendationStatus = 'pending' | 'approved' | 'rejected' | 'executed' | 'failed' | 'blocked';
|
|
152
|
+
interface ActionContext {
|
|
153
|
+
insight: Insight;
|
|
154
|
+
entity: string;
|
|
155
|
+
recommendation: Recommendation;
|
|
156
|
+
}
|
|
157
|
+
interface ActionHandler {
|
|
158
|
+
name: string;
|
|
159
|
+
handler: (context: ActionContext) => Promise<void>;
|
|
160
|
+
description?: string;
|
|
161
|
+
}
|
|
162
|
+
interface ActionRule {
|
|
163
|
+
action: string;
|
|
164
|
+
when: {
|
|
165
|
+
insightType?: string[];
|
|
166
|
+
severity?: string[];
|
|
167
|
+
entity?: string[];
|
|
168
|
+
};
|
|
169
|
+
confidence?: number;
|
|
170
|
+
}
|
|
171
|
+
interface Recommendation {
|
|
172
|
+
id: number;
|
|
173
|
+
action: string;
|
|
174
|
+
reason: string;
|
|
175
|
+
confidence: number;
|
|
176
|
+
status: RecommendationStatus;
|
|
177
|
+
governance: GovernanceLevel;
|
|
178
|
+
insightId: string | null;
|
|
179
|
+
entity: string;
|
|
180
|
+
context: Record<string, unknown>;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
resolvedAt: string | null;
|
|
183
|
+
resolvedBy: string | null;
|
|
184
|
+
}
|
|
185
|
+
interface RecommendationSummary {
|
|
186
|
+
total: number;
|
|
187
|
+
executed: number;
|
|
188
|
+
pending: number;
|
|
189
|
+
approved: number;
|
|
190
|
+
rejected: number;
|
|
191
|
+
blocked: number;
|
|
192
|
+
failed: number;
|
|
193
|
+
}
|
|
194
|
+
interface ActionsConfig {
|
|
195
|
+
enabled: boolean;
|
|
196
|
+
rules?: ActionRule[];
|
|
197
|
+
governance?: Record<string, GovernanceLevel>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
type NotificationTrigger = 'anomaly' | 'insight' | 'recommendation' | 'action:executed' | 'action:failed';
|
|
201
|
+
interface WebhookTarget {
|
|
202
|
+
url: string;
|
|
203
|
+
headers?: Record<string, string>;
|
|
204
|
+
type?: 'generic' | 'slack';
|
|
205
|
+
}
|
|
206
|
+
interface NotificationFilter {
|
|
207
|
+
severity?: Array<'low' | 'medium' | 'high' | 'critical'>;
|
|
208
|
+
entity?: string[];
|
|
209
|
+
}
|
|
210
|
+
interface NotificationRule {
|
|
211
|
+
triggers: NotificationTrigger[];
|
|
212
|
+
targets: WebhookTarget[];
|
|
213
|
+
filter?: NotificationFilter;
|
|
214
|
+
}
|
|
215
|
+
interface NotificationsConfig {
|
|
216
|
+
enabled: boolean;
|
|
217
|
+
rules: NotificationRule[];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
type LlmConfig = LLMConfig;
|
|
221
|
+
interface ConnectionConfig {
|
|
222
|
+
type: 'postgres' | 'mysql' | 'mariadb' | 'cockroachdb' | 'sqlite' | 'mongodb' | 'mssql';
|
|
223
|
+
url?: string;
|
|
224
|
+
host?: string;
|
|
225
|
+
port?: number;
|
|
226
|
+
database?: string;
|
|
227
|
+
user?: string;
|
|
228
|
+
password?: string;
|
|
229
|
+
path?: string;
|
|
230
|
+
}
|
|
231
|
+
interface CortexaConfig {
|
|
232
|
+
connection: ConnectionConfig;
|
|
233
|
+
llm?: LLMConfig;
|
|
234
|
+
reasoning?: ReasoningConfig;
|
|
235
|
+
analytics?: AnalyticsConfig;
|
|
236
|
+
knowledge?: KnowledgeConfig;
|
|
237
|
+
actions?: ActionsConfig;
|
|
238
|
+
notifications?: NotificationsConfig;
|
|
239
|
+
batchSize?: number;
|
|
240
|
+
}
|
|
241
|
+
declare function defineConfig(config: CortexaConfig): CortexaConfig;
|
|
242
|
+
|
|
243
|
+
interface RawColumn {
|
|
244
|
+
columnName: string;
|
|
245
|
+
dataType: string;
|
|
246
|
+
isNullable: boolean;
|
|
247
|
+
columnDefault: string | null;
|
|
248
|
+
}
|
|
249
|
+
interface RawForeignKey {
|
|
250
|
+
columnName: string;
|
|
251
|
+
referencedTable: string;
|
|
252
|
+
referencedColumn: string;
|
|
253
|
+
}
|
|
254
|
+
interface RawIndex {
|
|
255
|
+
indexName: string;
|
|
256
|
+
columns: string[];
|
|
257
|
+
isUnique: boolean;
|
|
258
|
+
}
|
|
259
|
+
interface RawTable {
|
|
260
|
+
tableName: string;
|
|
261
|
+
tableSchema: string;
|
|
262
|
+
columns: RawColumn[];
|
|
263
|
+
foreignKeys: RawForeignKey[];
|
|
264
|
+
indexes: RawIndex[];
|
|
265
|
+
sampleRows: Record<string, unknown>[];
|
|
266
|
+
rowCount: number;
|
|
267
|
+
}
|
|
268
|
+
interface RawSchema {
|
|
269
|
+
tables: RawTable[];
|
|
270
|
+
discoveredAt: string;
|
|
271
|
+
}
|
|
272
|
+
interface ClassifiedColumn {
|
|
273
|
+
columnName: string;
|
|
274
|
+
label: string;
|
|
275
|
+
meaning: string;
|
|
276
|
+
}
|
|
277
|
+
type EntityType = 'master' | 'transaction' | 'reference' | 'junction';
|
|
278
|
+
interface ClassifiedEntity {
|
|
279
|
+
tableName: string;
|
|
280
|
+
entityLabel: string;
|
|
281
|
+
entityType: EntityType;
|
|
282
|
+
description: string;
|
|
283
|
+
confidence: number;
|
|
284
|
+
columns: ClassifiedColumn[];
|
|
285
|
+
}
|
|
286
|
+
interface Relationship {
|
|
287
|
+
sourceEntity: string;
|
|
288
|
+
targetEntity: string;
|
|
289
|
+
relationship: string;
|
|
290
|
+
sourceColumn: string;
|
|
291
|
+
targetColumn: string;
|
|
292
|
+
inferred: boolean;
|
|
293
|
+
confidence: number;
|
|
294
|
+
}
|
|
295
|
+
interface EntityGraph {
|
|
296
|
+
entities: ClassifiedEntity[];
|
|
297
|
+
relationships: Relationship[];
|
|
298
|
+
}
|
|
299
|
+
interface DiscoveryOptions {
|
|
300
|
+
/** Tables to exclude from discovery (e.g., ['passwords', 'api_keys', 'sessions']) */
|
|
301
|
+
excludeTables?: string[];
|
|
302
|
+
/** Columns to exclude from LLM prompt across all tables (e.g., ['ssn', 'credit_card', 'password_hash']) */
|
|
303
|
+
excludeColumns?: string[];
|
|
304
|
+
/** Whether to include sample rows from actual data. Default: true. Set to false to send only metadata to LLM. */
|
|
305
|
+
includeSampleData?: boolean;
|
|
306
|
+
/** Max number of sample rows per table. Default: 5. */
|
|
307
|
+
sampleRowLimit?: number;
|
|
308
|
+
}
|
|
309
|
+
interface DiscoveryResult {
|
|
310
|
+
entities: ClassifiedEntity[];
|
|
311
|
+
relationships: Relationship[];
|
|
312
|
+
raw: RawSchema;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
interface RawChange {
|
|
316
|
+
tableName: string;
|
|
317
|
+
tableSchema: string;
|
|
318
|
+
operation: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
319
|
+
primaryKey: string | number;
|
|
320
|
+
newData?: Record<string, unknown>;
|
|
321
|
+
oldData?: Record<string, unknown>;
|
|
322
|
+
changedColumns?: string[];
|
|
323
|
+
detectedAt: Date;
|
|
324
|
+
}
|
|
325
|
+
interface BusinessEvent {
|
|
326
|
+
entity: string;
|
|
327
|
+
entityType: EntityType;
|
|
328
|
+
type: 'created' | 'updated' | 'deleted';
|
|
329
|
+
table: string;
|
|
330
|
+
primaryKey: string | number;
|
|
331
|
+
timestamp: Date;
|
|
332
|
+
changedColumns?: string[];
|
|
333
|
+
metadata: Record<string, unknown>;
|
|
334
|
+
}
|
|
335
|
+
type AnomalyType = 'rate_spike' | 'rate_drop' | 'stuck_record';
|
|
336
|
+
interface Anomaly {
|
|
337
|
+
entity: string;
|
|
338
|
+
anomalyType: AnomalyType;
|
|
339
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
340
|
+
expected: number;
|
|
341
|
+
actual: number;
|
|
342
|
+
message: string;
|
|
343
|
+
timestamp: Date;
|
|
344
|
+
}
|
|
345
|
+
interface Baseline {
|
|
346
|
+
entity: string;
|
|
347
|
+
metric: string;
|
|
348
|
+
mean: number;
|
|
349
|
+
stddev: number;
|
|
350
|
+
sampleSize: number;
|
|
351
|
+
}
|
|
352
|
+
interface StreamCapability {
|
|
353
|
+
canStream: boolean;
|
|
354
|
+
reason: string;
|
|
355
|
+
}
|
|
356
|
+
interface WatchOptions {
|
|
357
|
+
interval?: number;
|
|
358
|
+
excludeTables?: string[];
|
|
359
|
+
excludeColumns?: string[];
|
|
360
|
+
stuckThreshold?: number;
|
|
361
|
+
anomalyThreshold?: number;
|
|
362
|
+
preferPolling?: boolean;
|
|
363
|
+
stuckCheckInterval?: number;
|
|
364
|
+
once?: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
interface GraphStoreStorage {
|
|
368
|
+
saveKgNode(node: {
|
|
369
|
+
nodeType: string;
|
|
370
|
+
refId: string;
|
|
371
|
+
label: string;
|
|
372
|
+
metadata: string;
|
|
373
|
+
}): number;
|
|
374
|
+
getKgNode(id: number): {
|
|
375
|
+
id: number;
|
|
376
|
+
nodeType: string;
|
|
377
|
+
refId: string;
|
|
378
|
+
label: string;
|
|
379
|
+
metadata: string;
|
|
380
|
+
timestamp: string;
|
|
381
|
+
} | undefined;
|
|
382
|
+
getKgNodeByRef(nodeType: string, refId: string): {
|
|
383
|
+
id: number;
|
|
384
|
+
nodeType: string;
|
|
385
|
+
refId: string;
|
|
386
|
+
label: string;
|
|
387
|
+
metadata: string;
|
|
388
|
+
timestamp: string;
|
|
389
|
+
} | undefined;
|
|
390
|
+
getKgNodesByType(nodeType: string): Array<{
|
|
391
|
+
id: number;
|
|
392
|
+
nodeType: string;
|
|
393
|
+
refId: string;
|
|
394
|
+
label: string;
|
|
395
|
+
metadata: string;
|
|
396
|
+
timestamp: string;
|
|
397
|
+
}>;
|
|
398
|
+
getAllKgNodes(): Array<{
|
|
399
|
+
id: number;
|
|
400
|
+
nodeType: string;
|
|
401
|
+
refId: string;
|
|
402
|
+
label: string;
|
|
403
|
+
metadata: string;
|
|
404
|
+
timestamp: string;
|
|
405
|
+
}>;
|
|
406
|
+
deleteKgNode(id: number): void;
|
|
407
|
+
saveKgEdge(edge: {
|
|
408
|
+
sourceId: number;
|
|
409
|
+
targetId: number;
|
|
410
|
+
edgeType: string;
|
|
411
|
+
weight: number;
|
|
412
|
+
metadata: string;
|
|
413
|
+
}): number;
|
|
414
|
+
getKgEdgesFrom(nodeId: number, edgeType?: string): Array<{
|
|
415
|
+
id: number;
|
|
416
|
+
sourceId: number;
|
|
417
|
+
targetId: number;
|
|
418
|
+
edgeType: string;
|
|
419
|
+
weight: number;
|
|
420
|
+
metadata: string;
|
|
421
|
+
timestamp: string;
|
|
422
|
+
}>;
|
|
423
|
+
getKgEdgesTo(nodeId: number, edgeType?: string): Array<{
|
|
424
|
+
id: number;
|
|
425
|
+
sourceId: number;
|
|
426
|
+
targetId: number;
|
|
427
|
+
edgeType: string;
|
|
428
|
+
weight: number;
|
|
429
|
+
metadata: string;
|
|
430
|
+
timestamp: string;
|
|
431
|
+
}>;
|
|
432
|
+
getAllKgEdges(): Array<{
|
|
433
|
+
id: number;
|
|
434
|
+
sourceId: number;
|
|
435
|
+
targetId: number;
|
|
436
|
+
edgeType: string;
|
|
437
|
+
weight: number;
|
|
438
|
+
metadata: string;
|
|
439
|
+
timestamp: string;
|
|
440
|
+
}>;
|
|
441
|
+
getKgSummary(): {
|
|
442
|
+
totalNodes: number;
|
|
443
|
+
totalEdges: number;
|
|
444
|
+
entities: number;
|
|
445
|
+
events: number;
|
|
446
|
+
anomalies: number;
|
|
447
|
+
insights: number;
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
declare class GraphStore {
|
|
451
|
+
private readonly storage;
|
|
452
|
+
constructor(storage: GraphStoreStorage);
|
|
453
|
+
upsertNode(nodeType: NodeType, refId: string, label: string, metadata?: Record<string, unknown>): number;
|
|
454
|
+
getNode(id: number): KnowledgeNode | undefined;
|
|
455
|
+
getNodeByRef(nodeType: NodeType, refId: string): KnowledgeNode | undefined;
|
|
456
|
+
getNodesByType(nodeType: NodeType): KnowledgeNode[];
|
|
457
|
+
getAllNodes(): KnowledgeNode[];
|
|
458
|
+
deleteNode(id: number): void;
|
|
459
|
+
addEdge(sourceId: number, targetId: number, edgeType: EdgeType, weight?: number, metadata?: Record<string, unknown>): number;
|
|
460
|
+
getEdgesFrom(nodeId: number, edgeType?: EdgeType): KnowledgeEdge[];
|
|
461
|
+
getEdgesTo(nodeId: number, edgeType?: EdgeType): KnowledgeEdge[];
|
|
462
|
+
getAllEdges(): KnowledgeEdge[];
|
|
463
|
+
neighbors(nodeId: number): KnowledgeNode[];
|
|
464
|
+
getSummary(): GraphSummary;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
interface ExplainTarget {
|
|
468
|
+
type: 'anomaly' | 'insight' | 'event' | 'entity';
|
|
469
|
+
id: number;
|
|
470
|
+
}
|
|
471
|
+
interface ExplainOptions {
|
|
472
|
+
maxContextEvents?: number;
|
|
473
|
+
maxGraphDepth?: number;
|
|
474
|
+
includeRecommendations?: boolean;
|
|
475
|
+
}
|
|
476
|
+
interface Evidence {
|
|
477
|
+
type: 'event' | 'baseline' | 'transition' | 'correlation' | 'graph_node';
|
|
478
|
+
description: string;
|
|
479
|
+
data: Record<string, unknown>;
|
|
480
|
+
relevance: number;
|
|
481
|
+
}
|
|
482
|
+
interface CausalStep {
|
|
483
|
+
order: number;
|
|
484
|
+
description: string;
|
|
485
|
+
confidence: number;
|
|
486
|
+
}
|
|
487
|
+
interface RecommendedAction {
|
|
488
|
+
action: string;
|
|
489
|
+
reason: string;
|
|
490
|
+
priority: 'low' | 'medium' | 'high';
|
|
491
|
+
}
|
|
492
|
+
interface ExplainResult {
|
|
493
|
+
explanationId: string;
|
|
494
|
+
target: ExplainTarget;
|
|
495
|
+
summary: string;
|
|
496
|
+
confidence: number;
|
|
497
|
+
evidence: Evidence[];
|
|
498
|
+
causalChain: CausalStep[];
|
|
499
|
+
recommendedActions: RecommendedAction[];
|
|
500
|
+
generatedAt: string;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
interface AskOptions {
|
|
504
|
+
maxContextEvents?: number;
|
|
505
|
+
maxGraphDepth?: number;
|
|
506
|
+
entityHint?: string;
|
|
507
|
+
}
|
|
508
|
+
type SignalType = 'baselineDeviation' | 'anomaly' | 'insight' | 'eventCluster' | 'transition' | 'correlation' | 'graphRelation';
|
|
509
|
+
interface SupportingSignal {
|
|
510
|
+
type: SignalType;
|
|
511
|
+
entity: string;
|
|
512
|
+
description: string;
|
|
513
|
+
data: Record<string, unknown>;
|
|
514
|
+
}
|
|
515
|
+
interface AskResult {
|
|
516
|
+
askId: string;
|
|
517
|
+
question: string;
|
|
518
|
+
answer: string;
|
|
519
|
+
confidence: number;
|
|
520
|
+
supportingSignals: SupportingSignal[];
|
|
521
|
+
relatedEntities: string[];
|
|
522
|
+
recommendedActions: string[];
|
|
523
|
+
generatedAt: string;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
interface ChangeStream {
|
|
527
|
+
start(onChange: (change: RawChange) => void): Promise<void>;
|
|
528
|
+
stop(): Promise<void>;
|
|
529
|
+
isRunning(): boolean;
|
|
530
|
+
cleanup(): Promise<void>;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
declare class KnowledgeGraph {
|
|
534
|
+
private readonly store;
|
|
535
|
+
private readonly traversal;
|
|
536
|
+
private readonly entityIntelligence;
|
|
537
|
+
constructor(store: GraphStore);
|
|
538
|
+
causesOf(nodeId: number, maxDepth?: number): KnowledgeNode[];
|
|
539
|
+
impactOf(nodeId: number, maxDepth?: number): KnowledgeNode[];
|
|
540
|
+
timeline(nodeId: number): KnowledgeNode[];
|
|
541
|
+
entity(refId: string): {
|
|
542
|
+
intelligence: () => EntityIntelligenceResult | undefined;
|
|
543
|
+
};
|
|
544
|
+
getNode(id: number): KnowledgeNode | undefined;
|
|
545
|
+
getNodeByRef(nodeType: NodeType, refId: string): KnowledgeNode | undefined;
|
|
546
|
+
getEdges(nodeId: number, edgeType?: EdgeType): KnowledgeEdge[];
|
|
547
|
+
neighbors(nodeId: number): KnowledgeNode[];
|
|
548
|
+
getSummary(): GraphSummary;
|
|
549
|
+
export(rootNodeId?: number): GraphExport;
|
|
550
|
+
}
|
|
551
|
+
interface CortexaOptions extends CortexaConfig {
|
|
552
|
+
projectRoot?: string;
|
|
553
|
+
llmProvider?: LLMProvider;
|
|
554
|
+
}
|
|
555
|
+
interface CortexaStatus {
|
|
556
|
+
connected: boolean;
|
|
557
|
+
tables: number;
|
|
558
|
+
db: string;
|
|
559
|
+
watching: boolean;
|
|
560
|
+
}
|
|
561
|
+
declare class Cortexa extends EventEmitter {
|
|
562
|
+
private readonly config;
|
|
563
|
+
private connector;
|
|
564
|
+
private storage;
|
|
565
|
+
private readonly logger;
|
|
566
|
+
private llmProvider;
|
|
567
|
+
private watcher;
|
|
568
|
+
private knowledgeGraph;
|
|
569
|
+
private actionRegistry;
|
|
570
|
+
private discoveredTables;
|
|
571
|
+
private _status;
|
|
572
|
+
constructor(config: CortexaOptions);
|
|
573
|
+
connect(): Promise<void>;
|
|
574
|
+
disconnect(): Promise<void>;
|
|
575
|
+
discover(options?: DiscoveryOptions): Promise<DiscoveryResult>;
|
|
576
|
+
entity(tableName: string): ClassifiedEntity | undefined;
|
|
577
|
+
exportGraph(): EntityGraph;
|
|
578
|
+
watch(options?: WatchOptions): Promise<void>;
|
|
579
|
+
unwatch(): void;
|
|
580
|
+
cleanupStream(): Promise<void>;
|
|
581
|
+
getEvents(filter?: {
|
|
582
|
+
entity?: string;
|
|
583
|
+
last?: number;
|
|
584
|
+
operation?: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
585
|
+
eventType?: string;
|
|
586
|
+
}): Array<{
|
|
587
|
+
id: number;
|
|
588
|
+
eventType: string;
|
|
589
|
+
entity: string;
|
|
590
|
+
tableName: string;
|
|
591
|
+
operation: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
592
|
+
rowId: string | null;
|
|
593
|
+
rowData: string | null;
|
|
594
|
+
timestamp: string;
|
|
595
|
+
}>;
|
|
596
|
+
getBaselines(): Array<{
|
|
597
|
+
entity: string;
|
|
598
|
+
metric: string;
|
|
599
|
+
mean: number;
|
|
600
|
+
stddev: number;
|
|
601
|
+
sampleSize: number;
|
|
602
|
+
}>;
|
|
603
|
+
getAnomalies(filter?: {
|
|
604
|
+
last?: number;
|
|
605
|
+
entity?: string;
|
|
606
|
+
severity?: Severity;
|
|
607
|
+
anomalyType?: AnomalyType;
|
|
608
|
+
}): Array<{
|
|
609
|
+
id: number;
|
|
610
|
+
entity: string;
|
|
611
|
+
anomalyType: AnomalyType;
|
|
612
|
+
severity: Severity;
|
|
613
|
+
expected: number;
|
|
614
|
+
actual: number;
|
|
615
|
+
message: string;
|
|
616
|
+
timestamp: string;
|
|
617
|
+
}>;
|
|
618
|
+
getInsights(filter?: {
|
|
619
|
+
entity?: string;
|
|
620
|
+
last?: number;
|
|
621
|
+
insightType?: InsightType;
|
|
622
|
+
severity?: Severity;
|
|
623
|
+
}): Array<{
|
|
624
|
+
id: number;
|
|
625
|
+
entity: string;
|
|
626
|
+
insightType: InsightType;
|
|
627
|
+
severity: Severity;
|
|
628
|
+
message: string;
|
|
629
|
+
context: Record<string, unknown>;
|
|
630
|
+
timestamp: string;
|
|
631
|
+
}>;
|
|
632
|
+
getTransitions(entity?: string): Array<{
|
|
633
|
+
entity: string;
|
|
634
|
+
fromState: string;
|
|
635
|
+
toState: string;
|
|
636
|
+
count: number;
|
|
637
|
+
avgDurationMs: number;
|
|
638
|
+
minDurationMs: number;
|
|
639
|
+
maxDurationMs: number;
|
|
640
|
+
}>;
|
|
641
|
+
getCorrelations(): CorrelationStatus[];
|
|
642
|
+
getDistributions(entity?: string): DistributionSummary[];
|
|
643
|
+
graph(): KnowledgeGraph;
|
|
644
|
+
explain(target: ExplainTarget, options?: ExplainOptions): Promise<ExplainResult>;
|
|
645
|
+
ask(question: string, options?: AskOptions): Promise<AskResult>;
|
|
646
|
+
registerAction(name: string, handler: (context: ActionContext) => Promise<void>, description?: string): void;
|
|
647
|
+
approveRecommendation(id: number): void;
|
|
648
|
+
rejectRecommendation(id: number): void;
|
|
649
|
+
getRecommendations(filter?: {
|
|
650
|
+
status?: string;
|
|
651
|
+
action?: string;
|
|
652
|
+
last?: number;
|
|
653
|
+
}): Array<{
|
|
654
|
+
id: number;
|
|
655
|
+
action: string;
|
|
656
|
+
reason: string;
|
|
657
|
+
confidence: number;
|
|
658
|
+
status: string;
|
|
659
|
+
governance: string;
|
|
660
|
+
insightId: string | null;
|
|
661
|
+
entity: string;
|
|
662
|
+
context: string;
|
|
663
|
+
createdAt: string;
|
|
664
|
+
resolvedAt: string | null;
|
|
665
|
+
resolvedBy: string | null;
|
|
666
|
+
}>;
|
|
667
|
+
get status(): CortexaStatus;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
export { type ActionContext, type ActionHandler, type ActionRule, type ActionsConfig, type AnalyticsConfig, type Anomaly, type AnomalyType, type AskOptions, type AskResult, type Baseline, type BusinessEvent, type CausalStep, type ChangeStream, type ClassifiedEntity, type ConnectionConfig, type CorrelationConfig, type CorrelationStatus, Cortexa, type CortexaConfig, type CortexaOptions, type CortexaStatus, type DiscoveryOptions, type DiscoveryResult, type DistributionConfig, type DistributionSummary, type EdgeType, type EntityGraph, type EntityIntelligenceResult, type Evidence, type ExplainOptions, type ExplainResult, type ExplainTarget, type GovernanceLevel, type GraphExport, type GraphSummary, type Insight, type InsightType, type KnowledgeConfig, type KnowledgeEdge, KnowledgeGraph, type KnowledgeNode, type LLMProvider, type LlmConfig, type NodeType, type NotificationFilter, type NotificationRule, type NotificationTrigger, type NotificationsConfig, type RawSchema, type ReasoningConfig, type Recommendation, type RecommendationStatus, type RecommendationSummary, type RecommendedAction, type Relationship, type Severity, type SignalType, type StateTransition, type StreamCapability, type SupportingSignal, type TransitionStats, type WatchOptions, type WebhookTarget, type WorkflowConfig, defineConfig };
|