@datasynx/agentic-ai-cartography 0.1.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 +21 -0
- package/README.md +201 -0
- package/dist/cli.js +1954 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +350 -0
- package/dist/index.js +1161 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HookCallback } from '@anthropic-ai/claude-code';
|
|
3
|
+
|
|
4
|
+
declare const NODE_TYPES: readonly ["host", "database_server", "database", "table", "web_service", "api_endpoint", "cache_server", "message_broker", "queue", "topic", "container", "pod", "k8s_cluster", "config_file", "unknown"];
|
|
5
|
+
type NodeType = typeof NODE_TYPES[number];
|
|
6
|
+
declare const EDGE_RELATIONSHIPS: readonly ["connects_to", "reads_from", "writes_to", "calls", "contains", "depends_on"];
|
|
7
|
+
type EdgeRelationship = typeof EDGE_RELATIONSHIPS[number];
|
|
8
|
+
declare const EVENT_TYPES: readonly ["process_start", "process_end", "connection_open", "connection_close", "window_focus", "tool_switch"];
|
|
9
|
+
type EventType = typeof EVENT_TYPES[number];
|
|
10
|
+
declare const NodeSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
type: z.ZodEnum<["host", "database_server", "database", "table", "web_service", "api_endpoint", "cache_server", "message_broker", "queue", "topic", "container", "pod", "k8s_cluster", "config_file", "unknown"]>;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
discoveredVia: z.ZodString;
|
|
15
|
+
confidence: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
17
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
id: string;
|
|
20
|
+
type: "host" | "database_server" | "database" | "table" | "web_service" | "api_endpoint" | "cache_server" | "message_broker" | "queue" | "topic" | "container" | "pod" | "k8s_cluster" | "config_file" | "unknown";
|
|
21
|
+
name: string;
|
|
22
|
+
discoveredVia: string;
|
|
23
|
+
confidence: number;
|
|
24
|
+
metadata: Record<string, unknown>;
|
|
25
|
+
tags: string[];
|
|
26
|
+
}, {
|
|
27
|
+
id: string;
|
|
28
|
+
type: "host" | "database_server" | "database" | "table" | "web_service" | "api_endpoint" | "cache_server" | "message_broker" | "queue" | "topic" | "container" | "pod" | "k8s_cluster" | "config_file" | "unknown";
|
|
29
|
+
name: string;
|
|
30
|
+
discoveredVia: string;
|
|
31
|
+
confidence?: number | undefined;
|
|
32
|
+
metadata?: Record<string, unknown> | undefined;
|
|
33
|
+
tags?: string[] | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
type DiscoveryNode = z.infer<typeof NodeSchema>;
|
|
36
|
+
declare const EdgeSchema: z.ZodObject<{
|
|
37
|
+
sourceId: z.ZodString;
|
|
38
|
+
targetId: z.ZodString;
|
|
39
|
+
relationship: z.ZodEnum<["connects_to", "reads_from", "writes_to", "calls", "contains", "depends_on"]>;
|
|
40
|
+
evidence: z.ZodString;
|
|
41
|
+
confidence: z.ZodDefault<z.ZodNumber>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
confidence: number;
|
|
44
|
+
sourceId: string;
|
|
45
|
+
targetId: string;
|
|
46
|
+
relationship: "connects_to" | "reads_from" | "writes_to" | "calls" | "contains" | "depends_on";
|
|
47
|
+
evidence: string;
|
|
48
|
+
}, {
|
|
49
|
+
sourceId: string;
|
|
50
|
+
targetId: string;
|
|
51
|
+
relationship: "connects_to" | "reads_from" | "writes_to" | "calls" | "contains" | "depends_on";
|
|
52
|
+
evidence: string;
|
|
53
|
+
confidence?: number | undefined;
|
|
54
|
+
}>;
|
|
55
|
+
type DiscoveryEdge = z.infer<typeof EdgeSchema>;
|
|
56
|
+
declare const EventSchema: z.ZodObject<{
|
|
57
|
+
eventType: z.ZodEnum<["process_start", "process_end", "connection_open", "connection_close", "window_focus", "tool_switch"]>;
|
|
58
|
+
process: z.ZodString;
|
|
59
|
+
pid: z.ZodNumber;
|
|
60
|
+
target: z.ZodOptional<z.ZodString>;
|
|
61
|
+
targetType: z.ZodOptional<z.ZodEnum<["host", "database_server", "database", "table", "web_service", "api_endpoint", "cache_server", "message_broker", "queue", "topic", "container", "pod", "k8s_cluster", "config_file", "unknown"]>>;
|
|
62
|
+
protocol: z.ZodOptional<z.ZodString>;
|
|
63
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
eventType: "process_start" | "process_end" | "connection_open" | "connection_close" | "window_focus" | "tool_switch";
|
|
66
|
+
process: string;
|
|
67
|
+
pid: number;
|
|
68
|
+
target?: string | undefined;
|
|
69
|
+
targetType?: "host" | "database_server" | "database" | "table" | "web_service" | "api_endpoint" | "cache_server" | "message_broker" | "queue" | "topic" | "container" | "pod" | "k8s_cluster" | "config_file" | "unknown" | undefined;
|
|
70
|
+
protocol?: string | undefined;
|
|
71
|
+
port?: number | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
eventType: "process_start" | "process_end" | "connection_open" | "connection_close" | "window_focus" | "tool_switch";
|
|
74
|
+
process: string;
|
|
75
|
+
pid: number;
|
|
76
|
+
target?: string | undefined;
|
|
77
|
+
targetType?: "host" | "database_server" | "database" | "table" | "web_service" | "api_endpoint" | "cache_server" | "message_broker" | "queue" | "topic" | "container" | "pod" | "k8s_cluster" | "config_file" | "unknown" | undefined;
|
|
78
|
+
protocol?: string | undefined;
|
|
79
|
+
port?: number | undefined;
|
|
80
|
+
}>;
|
|
81
|
+
type ActivityEvent = z.infer<typeof EventSchema>;
|
|
82
|
+
declare const SOPStepSchema: z.ZodObject<{
|
|
83
|
+
order: z.ZodNumber;
|
|
84
|
+
instruction: z.ZodString;
|
|
85
|
+
tool: z.ZodString;
|
|
86
|
+
target: z.ZodOptional<z.ZodString>;
|
|
87
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
order: number;
|
|
90
|
+
instruction: string;
|
|
91
|
+
tool: string;
|
|
92
|
+
target?: string | undefined;
|
|
93
|
+
notes?: string | undefined;
|
|
94
|
+
}, {
|
|
95
|
+
order: number;
|
|
96
|
+
instruction: string;
|
|
97
|
+
tool: string;
|
|
98
|
+
target?: string | undefined;
|
|
99
|
+
notes?: string | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
type SOPStep = z.infer<typeof SOPStepSchema>;
|
|
102
|
+
declare const SOPSchema: z.ZodObject<{
|
|
103
|
+
title: z.ZodString;
|
|
104
|
+
description: z.ZodString;
|
|
105
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
106
|
+
order: z.ZodNumber;
|
|
107
|
+
instruction: z.ZodString;
|
|
108
|
+
tool: z.ZodString;
|
|
109
|
+
target: z.ZodOptional<z.ZodString>;
|
|
110
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
order: number;
|
|
113
|
+
instruction: string;
|
|
114
|
+
tool: string;
|
|
115
|
+
target?: string | undefined;
|
|
116
|
+
notes?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
order: number;
|
|
119
|
+
instruction: string;
|
|
120
|
+
tool: string;
|
|
121
|
+
target?: string | undefined;
|
|
122
|
+
notes?: string | undefined;
|
|
123
|
+
}>, "many">;
|
|
124
|
+
involvedSystems: z.ZodArray<z.ZodString, "many">;
|
|
125
|
+
estimatedDuration: z.ZodString;
|
|
126
|
+
frequency: z.ZodString;
|
|
127
|
+
confidence: z.ZodNumber;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
confidence: number;
|
|
130
|
+
title: string;
|
|
131
|
+
description: string;
|
|
132
|
+
steps: {
|
|
133
|
+
order: number;
|
|
134
|
+
instruction: string;
|
|
135
|
+
tool: string;
|
|
136
|
+
target?: string | undefined;
|
|
137
|
+
notes?: string | undefined;
|
|
138
|
+
}[];
|
|
139
|
+
involvedSystems: string[];
|
|
140
|
+
estimatedDuration: string;
|
|
141
|
+
frequency: string;
|
|
142
|
+
}, {
|
|
143
|
+
confidence: number;
|
|
144
|
+
title: string;
|
|
145
|
+
description: string;
|
|
146
|
+
steps: {
|
|
147
|
+
order: number;
|
|
148
|
+
instruction: string;
|
|
149
|
+
tool: string;
|
|
150
|
+
target?: string | undefined;
|
|
151
|
+
notes?: string | undefined;
|
|
152
|
+
}[];
|
|
153
|
+
involvedSystems: string[];
|
|
154
|
+
estimatedDuration: string;
|
|
155
|
+
frequency: string;
|
|
156
|
+
}>;
|
|
157
|
+
type SOP = z.infer<typeof SOPSchema>;
|
|
158
|
+
interface NodeRow extends DiscoveryNode {
|
|
159
|
+
sessionId: string;
|
|
160
|
+
discoveredAt: string;
|
|
161
|
+
depth: number;
|
|
162
|
+
pathId?: string;
|
|
163
|
+
}
|
|
164
|
+
interface EdgeRow extends DiscoveryEdge {
|
|
165
|
+
id: string;
|
|
166
|
+
sessionId: string;
|
|
167
|
+
discoveredAt: string;
|
|
168
|
+
pathId?: string;
|
|
169
|
+
}
|
|
170
|
+
interface EventRow {
|
|
171
|
+
id: string;
|
|
172
|
+
sessionId: string;
|
|
173
|
+
taskId?: string;
|
|
174
|
+
timestamp: string;
|
|
175
|
+
eventType: EventType;
|
|
176
|
+
process: string;
|
|
177
|
+
pid: number;
|
|
178
|
+
target?: string;
|
|
179
|
+
targetType?: NodeType;
|
|
180
|
+
port?: number;
|
|
181
|
+
durationMs?: number;
|
|
182
|
+
}
|
|
183
|
+
interface TaskRow {
|
|
184
|
+
id: string;
|
|
185
|
+
sessionId: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
startedAt: string;
|
|
188
|
+
completedAt?: string;
|
|
189
|
+
steps: string;
|
|
190
|
+
involvedServices: string;
|
|
191
|
+
status: 'active' | 'completed' | 'cancelled';
|
|
192
|
+
isSOPCandidate: boolean;
|
|
193
|
+
}
|
|
194
|
+
interface WorkflowRow {
|
|
195
|
+
id: string;
|
|
196
|
+
sessionId: string;
|
|
197
|
+
name?: string;
|
|
198
|
+
pattern: string;
|
|
199
|
+
taskIds: string;
|
|
200
|
+
occurrences: number;
|
|
201
|
+
firstSeen: string;
|
|
202
|
+
lastSeen: string;
|
|
203
|
+
avgDurationMs: number;
|
|
204
|
+
involvedServices: string;
|
|
205
|
+
}
|
|
206
|
+
interface SessionRow {
|
|
207
|
+
id: string;
|
|
208
|
+
mode: 'discover' | 'shadow';
|
|
209
|
+
startedAt: string;
|
|
210
|
+
completedAt?: string;
|
|
211
|
+
config: string;
|
|
212
|
+
}
|
|
213
|
+
type DaemonMessage = {
|
|
214
|
+
type: 'event';
|
|
215
|
+
data: EventRow;
|
|
216
|
+
} | {
|
|
217
|
+
type: 'prompt';
|
|
218
|
+
id: string;
|
|
219
|
+
prompt: PendingPrompt;
|
|
220
|
+
} | {
|
|
221
|
+
type: 'status';
|
|
222
|
+
data: ShadowStatus;
|
|
223
|
+
} | {
|
|
224
|
+
type: 'agent-output';
|
|
225
|
+
text: string;
|
|
226
|
+
} | {
|
|
227
|
+
type: 'info';
|
|
228
|
+
message: string;
|
|
229
|
+
};
|
|
230
|
+
type ClientMessage = {
|
|
231
|
+
type: 'prompt-response';
|
|
232
|
+
id: string;
|
|
233
|
+
answer: string;
|
|
234
|
+
} | {
|
|
235
|
+
type: 'command';
|
|
236
|
+
command: 'new-task' | 'end-task' | 'status' | 'stop';
|
|
237
|
+
} | {
|
|
238
|
+
type: 'task-description';
|
|
239
|
+
description: string;
|
|
240
|
+
};
|
|
241
|
+
interface PendingPrompt {
|
|
242
|
+
kind: 'node-approval' | 'task-boundary' | 'task-end';
|
|
243
|
+
context: Record<string, unknown>;
|
|
244
|
+
options: string[];
|
|
245
|
+
defaultAnswer: string;
|
|
246
|
+
timeoutMs: number;
|
|
247
|
+
createdAt: string;
|
|
248
|
+
}
|
|
249
|
+
interface ShadowStatus {
|
|
250
|
+
pid: number;
|
|
251
|
+
uptime: number;
|
|
252
|
+
nodeCount: number;
|
|
253
|
+
eventCount: number;
|
|
254
|
+
taskCount: number;
|
|
255
|
+
pendingPrompts: number;
|
|
256
|
+
autoSave: boolean;
|
|
257
|
+
mode: 'foreground' | 'daemon';
|
|
258
|
+
agentActive: boolean;
|
|
259
|
+
cyclesRun: number;
|
|
260
|
+
cyclesSkipped: number;
|
|
261
|
+
}
|
|
262
|
+
declare const MIN_POLL_INTERVAL_MS = 15000;
|
|
263
|
+
interface CartographyConfig {
|
|
264
|
+
mode: 'discover' | 'shadow';
|
|
265
|
+
maxDepth: number;
|
|
266
|
+
maxTurns: number;
|
|
267
|
+
entryPoints: string[];
|
|
268
|
+
agentModel: string;
|
|
269
|
+
shadowMode: 'foreground' | 'daemon';
|
|
270
|
+
pollIntervalMs: number;
|
|
271
|
+
inactivityTimeoutMs: number;
|
|
272
|
+
promptTimeoutMs: number;
|
|
273
|
+
trackWindowFocus: boolean;
|
|
274
|
+
autoSaveNodes: boolean;
|
|
275
|
+
enableNotifications: boolean;
|
|
276
|
+
shadowModel: string;
|
|
277
|
+
organization?: string;
|
|
278
|
+
outputDir: string;
|
|
279
|
+
dbPath: string;
|
|
280
|
+
socketPath: string;
|
|
281
|
+
pidFile: string;
|
|
282
|
+
verbose: boolean;
|
|
283
|
+
}
|
|
284
|
+
declare function defaultConfig(overrides?: Partial<CartographyConfig>): CartographyConfig;
|
|
285
|
+
|
|
286
|
+
declare class CartographyDB {
|
|
287
|
+
private db;
|
|
288
|
+
constructor(dbPath: string);
|
|
289
|
+
private migrate;
|
|
290
|
+
close(): void;
|
|
291
|
+
createSession(mode: 'discover' | 'shadow', config: CartographyConfig): string;
|
|
292
|
+
endSession(id: string): void;
|
|
293
|
+
getSession(id: string): SessionRow | undefined;
|
|
294
|
+
getLatestSession(mode?: string): SessionRow | undefined;
|
|
295
|
+
getSessions(): SessionRow[];
|
|
296
|
+
private mapSession;
|
|
297
|
+
upsertNode(sessionId: string, node: DiscoveryNode, depth?: number): void;
|
|
298
|
+
getNodes(sessionId: string): NodeRow[];
|
|
299
|
+
insertEdge(sessionId: string, edge: DiscoveryEdge): void;
|
|
300
|
+
getEdges(sessionId: string): EdgeRow[];
|
|
301
|
+
insertEvent(sessionId: string, event: ActivityEvent, taskId?: string): void;
|
|
302
|
+
getEvents(sessionId: string, since?: string): EventRow[];
|
|
303
|
+
startTask(sessionId: string, description?: string): string;
|
|
304
|
+
endCurrentTask(sessionId: string): void;
|
|
305
|
+
updateTaskDescription(sessionId: string, description: string): void;
|
|
306
|
+
getActiveTask(sessionId: string): TaskRow | undefined;
|
|
307
|
+
getTasks(sessionId: string): TaskRow[];
|
|
308
|
+
private mapTask;
|
|
309
|
+
insertWorkflow(sessionId: string, data: Omit<WorkflowRow, 'id'>): void;
|
|
310
|
+
getWorkflows(sessionId: string): WorkflowRow[];
|
|
311
|
+
insertSOP(sop: {
|
|
312
|
+
workflowId: string;
|
|
313
|
+
} & SOP): void;
|
|
314
|
+
getSOPs(sessionId: string): Array<SOP & {
|
|
315
|
+
id: string;
|
|
316
|
+
workflowId: string;
|
|
317
|
+
}>;
|
|
318
|
+
setApproval(pattern: string, action: 'save' | 'ignore' | 'auto'): void;
|
|
319
|
+
getApproval(pattern: string): string | undefined;
|
|
320
|
+
getStats(sessionId: string): {
|
|
321
|
+
nodes: number;
|
|
322
|
+
edges: number;
|
|
323
|
+
events: number;
|
|
324
|
+
tasks: number;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
type McpServer = any;
|
|
329
|
+
declare function stripSensitive(target: string): string;
|
|
330
|
+
declare function createCartographyTools(db: CartographyDB, sessionId: string): Promise<McpServer>;
|
|
331
|
+
|
|
332
|
+
declare const safetyHook: HookCallback;
|
|
333
|
+
|
|
334
|
+
declare function runDiscovery(config: CartographyConfig, db: CartographyDB, sessionId: string, onOutput?: (text: string) => void): Promise<void>;
|
|
335
|
+
declare function runShadowCycle(config: CartographyConfig, db: CartographyDB, sessionId: string, prevSnapshot: string, currSnapshot: string, onOutput?: (msg: unknown) => void): Promise<void>;
|
|
336
|
+
declare function generateSOPs(db: CartographyDB, sessionId: string): Promise<number>;
|
|
337
|
+
|
|
338
|
+
declare function generateTopologyMermaid(nodes: NodeRow[], edges: EdgeRow[]): string;
|
|
339
|
+
declare function generateDependencyMermaid(nodes: NodeRow[], edges: EdgeRow[]): string;
|
|
340
|
+
declare function generateWorkflowMermaid(sop: SOP): string;
|
|
341
|
+
declare function exportBackstageYAML(nodes: NodeRow[], edges: EdgeRow[], org?: string): string;
|
|
342
|
+
declare function exportJSON(db: CartographyDB, sessionId: string): string;
|
|
343
|
+
declare function exportHTML(nodes: NodeRow[], edges: EdgeRow[]): string;
|
|
344
|
+
declare function exportSOPMarkdown(sop: SOP): string;
|
|
345
|
+
declare function exportAll(db: CartographyDB, sessionId: string, outputDir: string, formats?: string[]): void;
|
|
346
|
+
|
|
347
|
+
declare function checkPrerequisites(): void;
|
|
348
|
+
declare function checkPollInterval(intervalMs: number): number;
|
|
349
|
+
|
|
350
|
+
export { type ActivityEvent, type CartographyConfig, CartographyDB, type ClientMessage, type DaemonMessage, type DiscoveryEdge, type DiscoveryNode, EDGE_RELATIONSHIPS, EVENT_TYPES, type EdgeRelationship, type EdgeRow, EdgeSchema, type EventRow, EventSchema, type EventType, MIN_POLL_INTERVAL_MS, NODE_TYPES, type NodeRow, NodeSchema, type NodeType, type PendingPrompt, type SOP, SOPSchema, type SOPStep, SOPStepSchema, type SessionRow, type ShadowStatus, type TaskRow, type WorkflowRow, checkPollInterval, checkPrerequisites, createCartographyTools, CartographyDB as default, defaultConfig, exportAll, exportBackstageYAML, exportHTML, exportJSON, exportSOPMarkdown, generateDependencyMermaid, generateSOPs, generateTopologyMermaid, generateWorkflowMermaid, runDiscovery, runShadowCycle, safetyHook, stripSensitive };
|