@datasynx/agentic-ai-cartography 1.1.1 → 2.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/README.md +197 -33
- package/dist/bookmarks-VS56KVCO.js +25 -0
- package/dist/chunk-CJ2PITFA.js +785 -0
- package/dist/chunk-CJ2PITFA.js.map +1 -0
- package/dist/chunk-D6SRSLBF.js +48 -0
- package/dist/{chunk-WJR63RWY.js → chunk-J6FDZ6HZ.js} +11 -2
- package/dist/chunk-J6FDZ6HZ.js.map +1 -0
- package/dist/chunk-UGSNG3QJ.js +49 -0
- package/dist/chunk-UGSNG3QJ.js.map +1 -0
- package/dist/chunk-W7YE6AAH.js +1516 -0
- package/dist/chunk-W7YE6AAH.js.map +1 -0
- package/dist/cli.js +133 -664
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +60115 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +734 -0
- package/dist/index.d.ts +363 -7
- package/dist/index.js +1462 -161
- package/dist/index.js.map +1 -1
- package/dist/mcp-bin.js +33 -0
- package/dist/mcp-bin.js.map +1 -0
- package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
- package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
- package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
- package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
- package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
- package/dist/sdk-A6NLO3DJ.js +12294 -0
- package/dist/sdk-A6NLO3DJ.js.map +1 -0
- package/dist/sdk-G5D4WQZ4.js +12293 -0
- package/dist/sdk-G5D4WQZ4.js.map +1 -0
- package/dist/sdk-QSTAREST.js +4869 -0
- package/dist/sdk-QSTAREST.js.map +1 -0
- package/dist/sqlite-vec-EZN67B2V.js +40 -0
- package/dist/sqlite-vec-EZN67B2V.js.map +1 -0
- package/dist/sqlite-vec-UK5YYE5T.js +39 -0
- package/dist/sqlite-vec-UK5YYE5T.js.map +1 -0
- package/dist/transformers.node-BTYUTJK5.js +42884 -0
- package/dist/transformers.node-BTYUTJK5.js.map +1 -0
- package/dist/transformers.node-J6PRTTOX.js +42883 -0
- package/dist/transformers.node-J6PRTTOX.js.map +1 -0
- package/dist/{types-54623ALF.js → types-JG27FR3E.js} +5 -2
- package/dist/types-JG27FR3E.js.map +1 -0
- package/package.json +51 -16
- package/server.json +28 -0
- package/dist/bookmarks-BWNVQGPG.js +0 -14
- package/dist/chunk-QKNYI3SU.js +0 -459
- package/dist/chunk-QKNYI3SU.js.map +0 -1
- package/dist/chunk-WJR63RWY.js.map +0 -1
- /package/dist/{bookmarks-BWNVQGPG.js.map → bookmarks-VS56KVCO.js.map} +0 -0
- /package/dist/{types-54623ALF.js.map → chunk-D6SRSLBF.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import { McpServerConfig, HookCallback } from '@anthropic-ai/claude-agent-sdk';
|
|
3
6
|
|
|
4
7
|
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", "saas_tool", "unknown"];
|
|
5
8
|
type NodeType = typeof NODE_TYPES[number];
|
|
9
|
+
/**
|
|
10
|
+
* Semantic groupings of node types — the single source of truth shared by the MCP
|
|
11
|
+
* resource layer (services/databases) and the exporters (layer assignment). Each
|
|
12
|
+
* node type belongs to at most one group; anything ungrouped is treated as "other".
|
|
13
|
+
*/
|
|
14
|
+
declare const NODE_TYPE_GROUPS: {
|
|
15
|
+
readonly saas: readonly ["saas_tool"];
|
|
16
|
+
readonly web: readonly ["web_service", "api_endpoint"];
|
|
17
|
+
readonly data: readonly ["database_server", "database", "table", "cache_server"];
|
|
18
|
+
readonly messaging: readonly ["message_broker", "queue", "topic"];
|
|
19
|
+
readonly infra: readonly ["host", "container", "pod", "k8s_cluster"];
|
|
20
|
+
readonly config: readonly ["config_file"];
|
|
21
|
+
};
|
|
6
22
|
declare const EDGE_RELATIONSHIPS: readonly ["connects_to", "reads_from", "writes_to", "calls", "contains", "depends_on"];
|
|
7
23
|
type EdgeRelationship = typeof EDGE_RELATIONSHIPS[number];
|
|
8
24
|
declare const NodeSchema: z.ZodObject<{
|
|
@@ -130,6 +146,33 @@ interface ConnectionRow extends Connection {
|
|
|
130
146
|
sessionId: string;
|
|
131
147
|
createdAt: string;
|
|
132
148
|
}
|
|
149
|
+
/** Aggregate, low-token index of a topology — used for progressive disclosure. */
|
|
150
|
+
interface GraphSummary {
|
|
151
|
+
sessionId: string;
|
|
152
|
+
totals: {
|
|
153
|
+
nodes: number;
|
|
154
|
+
edges: number;
|
|
155
|
+
};
|
|
156
|
+
nodesByType: Record<string, number>;
|
|
157
|
+
nodesByDomain: Record<string, number>;
|
|
158
|
+
edgesByRelationship: Record<string, number>;
|
|
159
|
+
topConnected: Array<{
|
|
160
|
+
id: string;
|
|
161
|
+
name: string;
|
|
162
|
+
type: string;
|
|
163
|
+
degree: number;
|
|
164
|
+
}>;
|
|
165
|
+
}
|
|
166
|
+
/** Result of a recursive dependency traversal. */
|
|
167
|
+
interface TraversalResult {
|
|
168
|
+
root?: NodeRow;
|
|
169
|
+
direction: 'downstream' | 'upstream' | 'both';
|
|
170
|
+
maxDepth: number;
|
|
171
|
+
nodes: Array<NodeRow & {
|
|
172
|
+
depth: number;
|
|
173
|
+
}>;
|
|
174
|
+
edges: EdgeRow[];
|
|
175
|
+
}
|
|
133
176
|
interface EventRow {
|
|
134
177
|
id: string;
|
|
135
178
|
sessionId: string;
|
|
@@ -170,6 +213,12 @@ declare class CartographyDB {
|
|
|
170
213
|
constructor(dbPath: string);
|
|
171
214
|
private migrate;
|
|
172
215
|
close(): void;
|
|
216
|
+
/**
|
|
217
|
+
* Advanced: the underlying better-sqlite3 connection. Used by the optional
|
|
218
|
+
* semantic-search layer to load the `sqlite-vec` extension and manage its
|
|
219
|
+
* virtual table. Prefer the typed methods above for everything else.
|
|
220
|
+
*/
|
|
221
|
+
rawConnection(): Database.Database;
|
|
173
222
|
createSession(mode: 'discover', config: CartographyConfig): string;
|
|
174
223
|
endSession(id: string): void;
|
|
175
224
|
getSession(id: string): SessionRow | undefined;
|
|
@@ -177,11 +226,18 @@ declare class CartographyDB {
|
|
|
177
226
|
getSessions(): SessionRow[];
|
|
178
227
|
private mapSession;
|
|
179
228
|
upsertNode(sessionId: string, node: DiscoveryNode, depth?: number): void;
|
|
180
|
-
getNodes(sessionId: string
|
|
229
|
+
getNodes(sessionId: string, opts?: {
|
|
230
|
+
limit?: number;
|
|
231
|
+
offset?: number;
|
|
232
|
+
}): NodeRow[];
|
|
233
|
+
getNodeCount(sessionId: string): number;
|
|
181
234
|
private mapNode;
|
|
182
235
|
deleteNode(sessionId: string, nodeId: string): void;
|
|
183
236
|
insertEdge(sessionId: string, edge: DiscoveryEdge): void;
|
|
184
|
-
getEdges(sessionId: string
|
|
237
|
+
getEdges(sessionId: string, opts?: {
|
|
238
|
+
limit?: number;
|
|
239
|
+
offset?: number;
|
|
240
|
+
}): EdgeRow[];
|
|
185
241
|
insertEvent(sessionId: string, event: Pick<EventRow, 'eventType' | 'process' | 'pid' | 'target' | 'targetType' | 'port'>, taskId?: string): void;
|
|
186
242
|
getEvents(sessionId: string, since?: string): EventRow[];
|
|
187
243
|
startTask(sessionId: string, description?: string): string;
|
|
@@ -205,6 +261,31 @@ declare class CartographyDB {
|
|
|
205
261
|
* Prune sessions older than the given ISO date string. Returns count of deleted sessions.
|
|
206
262
|
*/
|
|
207
263
|
pruneSessions(olderThan: string): number;
|
|
264
|
+
/** Fetch a single node by id within a session. */
|
|
265
|
+
getNode(sessionId: string, nodeId: string): NodeRow | undefined;
|
|
266
|
+
/** Batch-fetch nodes by id, keyed for O(1) lookup. Chunked to stay under SQLite's bind-variable limit. */
|
|
267
|
+
getNodesByIds(sessionId: string, ids: readonly string[]): Map<string, NodeRow>;
|
|
268
|
+
/** Fetch all nodes of one or more types. */
|
|
269
|
+
getNodesByType(sessionId: string, types: readonly string[]): NodeRow[];
|
|
270
|
+
/**
|
|
271
|
+
* Lexical search over node id, name, domain, sub-domain and tags.
|
|
272
|
+
* Case-insensitive substring match — the deterministic fallback for semantic search.
|
|
273
|
+
*/
|
|
274
|
+
searchNodes(sessionId: string, query: string, opts?: {
|
|
275
|
+
types?: readonly string[];
|
|
276
|
+
limit?: number;
|
|
277
|
+
}): NodeRow[];
|
|
278
|
+
/**
|
|
279
|
+
* Traverse the dependency graph from a node using a recursive CTE with a
|
|
280
|
+
* path-based cycle guard. `downstream` follows source→target (what the node
|
|
281
|
+
* depends on / points to); `upstream` follows target→source (what depends on it).
|
|
282
|
+
*/
|
|
283
|
+
getDependencies(sessionId: string, nodeId: string, opts?: {
|
|
284
|
+
direction?: 'downstream' | 'upstream' | 'both';
|
|
285
|
+
maxDepth?: number;
|
|
286
|
+
}): TraversalResult;
|
|
287
|
+
/** Lightweight aggregate index of the whole topology — the progressive-disclosure summary. */
|
|
288
|
+
getGraphSummary(sessionId: string): GraphSummary;
|
|
208
289
|
getStats(sessionId: string): {
|
|
209
290
|
nodes: number;
|
|
210
291
|
edges: number;
|
|
@@ -213,16 +294,291 @@ declare class CartographyDB {
|
|
|
213
294
|
};
|
|
214
295
|
}
|
|
215
296
|
|
|
216
|
-
|
|
297
|
+
/**
|
|
298
|
+
* The Cartography MCP server — the package's primary, LLM-agnostic interface.
|
|
299
|
+
*
|
|
300
|
+
* It exposes the discovered infrastructure topology as Model Context Protocol
|
|
301
|
+
* **Resources** (read-only context, progressive disclosure), a small set of query
|
|
302
|
+
* **Tools** (parameterized lookups), and reusable **Prompts**. Any MCP host —
|
|
303
|
+
* Claude Code, Cursor, Cline, Windsurf, the Vercel AI SDK, LangGraph — can drive
|
|
304
|
+
* it; the package never needs to know which model is in use.
|
|
305
|
+
*/
|
|
306
|
+
|
|
307
|
+
/** A pluggable search backend; defaults to lexical search, can be upgraded to semantic. */
|
|
308
|
+
type SearchFn = (db: CartographyDB, sessionId: string, query: string, opts: {
|
|
309
|
+
types?: readonly string[];
|
|
310
|
+
limit: number;
|
|
311
|
+
}) => Promise<Array<{
|
|
312
|
+
node: NodeRow;
|
|
313
|
+
score?: number;
|
|
314
|
+
}>>;
|
|
315
|
+
/** A pluggable discovery backend invoked by the `run_discovery` tool. */
|
|
316
|
+
type DiscoveryFn = (db: CartographyDB, sessionId: string, opts: {
|
|
317
|
+
hint?: string;
|
|
318
|
+
}) => Promise<{
|
|
319
|
+
nodes: number;
|
|
320
|
+
edges: number;
|
|
321
|
+
}>;
|
|
322
|
+
interface CreateMcpServerOptions {
|
|
323
|
+
/** Database instance. If omitted, one is opened at `config.dbPath`. */
|
|
324
|
+
db?: CartographyDB;
|
|
325
|
+
/** Path to the SQLite catalog (used when `db` is not provided). */
|
|
326
|
+
dbPath?: string;
|
|
327
|
+
/** Session to serve: a session id, or `'latest'` (default) for the newest discovery. */
|
|
328
|
+
session?: string | 'latest';
|
|
329
|
+
/** Semantic/lexical search backend. Defaults to lexical `searchNodes`. */
|
|
330
|
+
search?: SearchFn;
|
|
331
|
+
/** Discovery backend for `run_discovery`/`refresh`. Optional. */
|
|
332
|
+
discovery?: DiscoveryFn;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Build a fully-configured Cartography MCP server. Call `.connect(transport)` to run it.
|
|
336
|
+
*/
|
|
337
|
+
declare function createMcpServer(opts?: CreateMcpServerOptions): McpServer;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Transport bindings for the Cartography MCP server.
|
|
341
|
+
*
|
|
342
|
+
* - **stdio**: the local-first default — zero network, every client supports it.
|
|
343
|
+
* - **Streamable HTTP**: a single `/mcp` endpoint for team/remote use, bound to
|
|
344
|
+
* localhost with DNS-rebinding protection. The deprecated SSE transport is not used.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
/** Connect a server over stdio (resolves when the transport closes). */
|
|
348
|
+
declare function runStdio(server: McpServer): Promise<void>;
|
|
349
|
+
interface HttpOptions {
|
|
350
|
+
port?: number;
|
|
351
|
+
host?: string;
|
|
352
|
+
/** Extra allowed Host headers (defaults to localhost:port variants). */
|
|
353
|
+
allowedHosts?: string[];
|
|
354
|
+
/** Allowed Origin headers (defaults to none → same-origin only). */
|
|
355
|
+
allowedOrigins?: string[];
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Start a Streamable HTTP server. A fresh MCP server instance is created per
|
|
359
|
+
* session via `factory`, so multiple clients can connect concurrently.
|
|
360
|
+
*/
|
|
361
|
+
declare function runHttp(factory: () => McpServer, opts?: HttpOptions): Promise<http.Server>;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Cross-platform utilities for Linux, macOS, and Windows.
|
|
365
|
+
* Centralizes all OS-specific logic so scanning tools work everywhere.
|
|
366
|
+
*/
|
|
367
|
+
type Platform = 'linux' | 'darwin' | 'win32';
|
|
368
|
+
declare function safeEnv(): NodeJS.ProcessEnv;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Scanner plugin contract.
|
|
372
|
+
*
|
|
373
|
+
* A scanner detects whether it applies to the current machine, then produces a
|
|
374
|
+
* read-only {@link ScanResult}: deterministic nodes/edges where the data is
|
|
375
|
+
* structured enough, plus an optional raw report for an LLM to classify further.
|
|
376
|
+
*
|
|
377
|
+
* Modeled on Steampipe plugins / Backstage processors: new sources can be added
|
|
378
|
+
* (in-tree or via `@datasynx/scanner-*` packages) and registered without forking
|
|
379
|
+
* the core. Each scanner declares the commands it needs, feeding the safety layer.
|
|
380
|
+
*/
|
|
381
|
+
|
|
382
|
+
interface ScanContext {
|
|
383
|
+
/** Optional focus hint from the caller (e.g. tool names to look for). */
|
|
384
|
+
hint?: string;
|
|
385
|
+
/** The current platform. */
|
|
386
|
+
platform: Platform;
|
|
387
|
+
/** Allowlist-gated command runner (returns '' on error/blocked). */
|
|
388
|
+
run: (cmd: string, opts?: {
|
|
389
|
+
timeout?: number;
|
|
390
|
+
env?: NodeJS.ProcessEnv;
|
|
391
|
+
}) => string;
|
|
392
|
+
}
|
|
393
|
+
interface ScanResult {
|
|
394
|
+
/** Deterministically classified nodes. */
|
|
395
|
+
nodes: DiscoveryNode[];
|
|
396
|
+
/** Deterministically classified edges. */
|
|
397
|
+
edges: DiscoveryEdge[];
|
|
398
|
+
/** Optional raw text report for LLM-driven classification. */
|
|
399
|
+
report?: string;
|
|
400
|
+
}
|
|
401
|
+
interface Scanner {
|
|
402
|
+
/** Stable id, e.g. "bookmarks", "installed-apps", "cloud-aws". */
|
|
403
|
+
id: string;
|
|
404
|
+
/** Human-readable title. */
|
|
405
|
+
title: string;
|
|
406
|
+
/** Platforms this scanner supports, or 'all'. */
|
|
407
|
+
platforms: Platform[] | 'all';
|
|
408
|
+
/** Read-only commands this scanner may run (declared for the safety layer/docs). */
|
|
409
|
+
allowedCommands?: string[];
|
|
410
|
+
/** Cheap check whether the scanner applies here (e.g. a CLI is installed). */
|
|
411
|
+
detect(ctx: ScanContext): boolean | Promise<boolean>;
|
|
412
|
+
/** Perform the read-only scan. */
|
|
413
|
+
scan(ctx: ScanContext): Promise<ScanResult>;
|
|
414
|
+
}
|
|
415
|
+
/** A typed registry of scanners with lazy, platform-aware selection. */
|
|
416
|
+
declare class ScannerRegistry {
|
|
417
|
+
private scanners;
|
|
418
|
+
register(scanner: Scanner): this;
|
|
419
|
+
get(id: string): Scanner | undefined;
|
|
420
|
+
list(): Scanner[];
|
|
421
|
+
/** Scanners whose `platforms` include the given platform. */
|
|
422
|
+
forPlatform(platform: Platform): Scanner[];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
declare const bookmarksScanner: Scanner;
|
|
426
|
+
|
|
427
|
+
declare const installedAppsScanner: Scanner;
|
|
428
|
+
|
|
429
|
+
/** Extract distinct listening port numbers from ss/lsof/PowerShell output. */
|
|
430
|
+
declare function extractListeningPorts(raw: string): number[];
|
|
431
|
+
declare const portsScanner: Scanner;
|
|
432
|
+
|
|
433
|
+
/** A registry pre-loaded with the built-in deterministic scanners. */
|
|
434
|
+
declare function defaultRegistry(): ScannerRegistry;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Deterministic, LLM-free local discovery.
|
|
438
|
+
*
|
|
439
|
+
* Runs every applicable scanner from a {@link ScannerRegistry}, deduplicates and
|
|
440
|
+
* persists the resulting nodes/edges, and returns counts. This is what powers the
|
|
441
|
+
* MCP `run_discovery` tool without requiring any model — the host LLM can then
|
|
442
|
+
* enrich the catalog via the read tools. (The Claude-driven loop in agent.ts
|
|
443
|
+
* remains available as the optional, richer turnkey path.)
|
|
444
|
+
*/
|
|
445
|
+
|
|
446
|
+
interface LocalDiscoveryOptions {
|
|
447
|
+
hint?: string;
|
|
448
|
+
registry?: ScannerRegistry;
|
|
449
|
+
/** Called after each scanner with a short progress line. */
|
|
450
|
+
onProgress?: (line: string) => void;
|
|
451
|
+
}
|
|
452
|
+
declare function runLocalDiscovery(db: CartographyDB, sessionId: string, opts?: LocalDiscoveryOptions): Promise<{
|
|
453
|
+
nodes: number;
|
|
454
|
+
edges: number;
|
|
455
|
+
scanners: string[];
|
|
456
|
+
}>;
|
|
457
|
+
/** Adapter matching the MCP `DiscoveryFn` signature. */
|
|
458
|
+
declare function localDiscoveryFn(registry?: ScannerRegistry): (db: CartographyDB, sessionId: string, opts: {
|
|
459
|
+
hint?: string;
|
|
460
|
+
}) => Promise<{
|
|
461
|
+
nodes: number;
|
|
462
|
+
edges: number;
|
|
463
|
+
}>;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Embedding providers for semantic search.
|
|
467
|
+
*
|
|
468
|
+
* The default provider runs a small sentence-transformer locally via
|
|
469
|
+
* `@huggingface/transformers` (no API key, offline after first download), keeping
|
|
470
|
+
* the package LLM-agnostic. Everything is a lazy import so installs that never use
|
|
471
|
+
* semantic search pay no cost and need no native model.
|
|
472
|
+
*/
|
|
473
|
+
/** Produces fixed-dimension embeddings for a batch of texts. */
|
|
474
|
+
interface EmbeddingProvider {
|
|
475
|
+
readonly id: string;
|
|
476
|
+
readonly dimensions: number;
|
|
477
|
+
embed(texts: string[]): Promise<Float32Array[]>;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Local sentence-transformer embedder (Xenova/all-MiniLM-L6-v2, 384 dims).
|
|
481
|
+
* Returns `undefined` if `@huggingface/transformers` is not installed or the
|
|
482
|
+
* model cannot be loaded, so callers can fall back to lexical search.
|
|
483
|
+
*/
|
|
484
|
+
declare function createLocalEmbedder(model?: string): Promise<EmbeddingProvider | undefined>;
|
|
485
|
+
/**
|
|
486
|
+
* A deterministic, dependency-free hashing embedder (bag-of-character-ngrams).
|
|
487
|
+
* Not as good as a transformer, but offline, instant, and useful as a fallback
|
|
488
|
+
* and for tests. Produces L2-normalized vectors.
|
|
489
|
+
*/
|
|
490
|
+
declare function createHashEmbedder(dimensions?: number): EmbeddingProvider;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Vector store backed by `sqlite-vec`. Stores one embedding per node in a `vec0`
|
|
494
|
+
* virtual table living inside the same SQLite catalog, with incremental indexing
|
|
495
|
+
* (content-hashed) so re-runs only embed what changed.
|
|
496
|
+
*/
|
|
497
|
+
|
|
498
|
+
declare class VectorStore {
|
|
499
|
+
private db;
|
|
500
|
+
private embedder;
|
|
501
|
+
private loaded;
|
|
502
|
+
constructor(db: CartographyDB, embedder: EmbeddingProvider);
|
|
503
|
+
/** Load sqlite-vec and ensure the schema exists. Returns false if unavailable. */
|
|
504
|
+
init(): Promise<boolean>;
|
|
505
|
+
/** Incrementally embed and index any new/changed nodes for a session. */
|
|
506
|
+
index(sessionId: string): Promise<{
|
|
507
|
+
embedded: number;
|
|
508
|
+
total: number;
|
|
509
|
+
}>;
|
|
510
|
+
/** k-nearest-neighbour search within a session. Returns node ids + distances. */
|
|
511
|
+
search(sessionId: string, query: string, k: number): Promise<Array<{
|
|
512
|
+
nodeId: string;
|
|
513
|
+
distance: number;
|
|
514
|
+
}>>;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Semantic search backend for the MCP server. Wraps a {@link VectorStore} and
|
|
519
|
+
* degrades gracefully to lexical search when embeddings/sqlite-vec are unavailable
|
|
520
|
+
* or return nothing.
|
|
521
|
+
*/
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Build a {@link SearchFn} that prefers semantic (vector) search and falls back to
|
|
525
|
+
* lexical. Pass an explicit embedder, or let it lazily load the local transformer
|
|
526
|
+
* (returns a lexical-only function if none is available).
|
|
527
|
+
*/
|
|
528
|
+
declare function createSemanticSearch(db: CartographyDB, embedder?: EmbeddingProvider): Promise<SearchFn>;
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Circuit breaker for sequential CLI scans.
|
|
532
|
+
* After `threshold` consecutive failures, remaining commands are skipped.
|
|
533
|
+
*/
|
|
534
|
+
declare function createScanRunner(runFn: (cmd: string, opts?: {
|
|
535
|
+
timeout?: number;
|
|
536
|
+
env?: NodeJS.ProcessEnv;
|
|
537
|
+
}) => string, opts?: {
|
|
538
|
+
timeout?: number;
|
|
539
|
+
env?: NodeJS.ProcessEnv;
|
|
540
|
+
threshold?: number;
|
|
541
|
+
}): (cmd: string) => string;
|
|
217
542
|
interface CartographyToolsOptions {
|
|
218
543
|
/** Called when the agent needs a human answer. Return the user's response. */
|
|
219
544
|
onAskUser?: (question: string, context?: string) => Promise<string>;
|
|
220
545
|
}
|
|
221
546
|
declare function stripSensitive(target: string): string;
|
|
222
|
-
declare function createCartographyTools(db: CartographyDB, sessionId: string, opts?: CartographyToolsOptions): Promise<
|
|
547
|
+
declare function createCartographyTools(db: CartographyDB, sessionId: string, opts?: CartographyToolsOptions): Promise<McpServerConfig>;
|
|
223
548
|
|
|
224
549
|
declare const safetyHook: HookCallback;
|
|
225
550
|
|
|
551
|
+
/**
|
|
552
|
+
* Read-only command policy — a strict allowlist.
|
|
553
|
+
*
|
|
554
|
+
* Unlike a denylist (which is inherently leaky — novel destructive commands slip
|
|
555
|
+
* through), this module permits only commands that are known to be read-only and
|
|
556
|
+
* rejects everything else. It is the authoritative safety boundary for every
|
|
557
|
+
* command the package spawns, independent of which agent or LLM is driving.
|
|
558
|
+
*
|
|
559
|
+
* The check is shell-aware: it splits a command line into segments on the control
|
|
560
|
+
* operators `|`, `&&`, `||`, `;` (respecting single/double quotes), then validates
|
|
561
|
+
* the leading executable of each segment plus its sub-command/arguments.
|
|
562
|
+
*/
|
|
563
|
+
interface PolicyResult {
|
|
564
|
+
allowed: boolean;
|
|
565
|
+
reason?: string;
|
|
566
|
+
}
|
|
567
|
+
type ShellKind = 'posix' | 'powershell';
|
|
568
|
+
/** Split a command line on shell control operators, honoring single/double quotes. */
|
|
569
|
+
declare function splitSegments(cmd: string): string[];
|
|
570
|
+
/**
|
|
571
|
+
* Decide whether a command line is read-only and therefore safe to execute.
|
|
572
|
+
* Returns `{ allowed: false, reason }` for anything not explicitly permitted.
|
|
573
|
+
*/
|
|
574
|
+
declare function checkReadOnly(command: string, opts?: {
|
|
575
|
+
shell?: ShellKind;
|
|
576
|
+
}): PolicyResult;
|
|
577
|
+
/** Convenience boolean form. */
|
|
578
|
+
declare function isReadOnlyCommand(command: string): boolean;
|
|
579
|
+
/** Throwing form for guard sites that prefer exceptions. */
|
|
580
|
+
declare function assertReadOnly(command: string): void;
|
|
581
|
+
|
|
226
582
|
type DiscoveryEvent = {
|
|
227
583
|
kind: 'thinking';
|
|
228
584
|
text: string;
|
|
@@ -330,7 +686,7 @@ declare function computeClusterBounds(assets: DataAsset[], hexSize: number): {
|
|
|
330
686
|
};
|
|
331
687
|
|
|
332
688
|
/**
|
|
333
|
-
* Node-
|
|
689
|
+
* Node-to-Asset Mapping.
|
|
334
690
|
* Converts existing DiscoveryNode/Edge data into the CartographyMap data model.
|
|
335
691
|
*/
|
|
336
692
|
|
|
@@ -375,4 +731,4 @@ declare function logInfo(message: string, context?: Record<string, unknown>): vo
|
|
|
375
731
|
declare function logWarn(message: string, context?: Record<string, unknown>): void;
|
|
376
732
|
declare function logError(message: string, context?: Record<string, unknown>): void;
|
|
377
733
|
|
|
378
|
-
export { type CartographyConfig, CartographyDB, type CartographyMapData, type Cluster, ClusterSchema, type Connection, ConnectionSchema, DOMAIN_COLORS, DOMAIN_PALETTE, type DataAsset, DataAssetSchema, type DiscoveryEdge, type DiscoveryEvent, type DiscoveryNode, EDGE_RELATIONSHIPS, type EdgeRelationship, type EdgeRow, EdgeSchema, type LogEntry, type LogLevel, NODE_TYPES, type NodeRow, NodeSchema, type NodeType, type SessionRow, assignColors, buildMapData, checkPrerequisites, cleanupTempFiles, computeCentroid, computeClusterBounds, createCartographyTools,
|
|
734
|
+
export { type CartographyConfig, CartographyDB, type CartographyMapData, type Cluster, ClusterSchema, type Connection, ConnectionSchema, type CreateMcpServerOptions, DOMAIN_COLORS, DOMAIN_PALETTE, type DataAsset, DataAssetSchema, type DiscoveryEdge, type DiscoveryEvent, type DiscoveryFn, type DiscoveryNode, EDGE_RELATIONSHIPS, type EdgeRelationship, type EdgeRow, EdgeSchema, type EmbeddingProvider, type GraphSummary, type HttpOptions, type LocalDiscoveryOptions, type LogEntry, type LogLevel, NODE_TYPES, NODE_TYPE_GROUPS, type NodeRow, NodeSchema, type NodeType, type PolicyResult, type ScanContext, type ScanResult, type Scanner, ScannerRegistry, type SearchFn, type SessionRow, type ShellKind, type TraversalResult, VectorStore, assertReadOnly, assignColors, bookmarksScanner, buildMapData, checkPrerequisites, checkReadOnly, cleanupTempFiles, computeCentroid, computeClusterBounds, createCartographyTools, createHashEmbedder, createLocalEmbedder, createMcpServer, createScanRunner, createSemanticSearch, defaultConfig, defaultRegistry, edgesToConnections, exportAll, exportBackstageYAML, exportDiscoveryApp, exportJGF, exportJSON, extractListeningPorts, generateDependencyMermaid, generateTopologyMermaid, groupByDomain, hexCorners, hexDistance, hexNeighbors, hexRing, hexSpiral, hexToPixel, installedAppsScanner, isReadOnlyCommand, layoutClusters, localDiscoveryFn, log, logDebug, logError, logInfo, logWarn, nodesToAssets, pixelToHex, portsScanner, runDiscovery, runHttp, runLocalDiscovery, runStdio, safeEnv, safetyHook, setVerbose, shadeVariant, splitSegments, stripSensitive };
|