mindgraph 0.1.2 → 0.1.7
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 +35 -1
- package/dist/index.d.mts +260 -27
- package/dist/index.d.ts +260 -27
- package/dist/index.js +224 -18
- package/dist/index.mjs +224 -18
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ new MindGraph({ baseUrl: string, apiKey?: string, jwt?: string })
|
|
|
50
50
|
|
|
51
51
|
| Method | Description |
|
|
52
52
|
|--------|-------------|
|
|
53
|
-
| `
|
|
53
|
+
| `capture(req)` | Capture a source, snippet, or observation |
|
|
54
54
|
| `entity(req)` | Create, alias, resolve, or merge entities |
|
|
55
55
|
| `findOrCreateEntity(label, entityType?, agentId?)` | Convenience: create or find an entity by label |
|
|
56
56
|
|
|
@@ -81,6 +81,7 @@ new MindGraph({ baseUrl: string, apiKey?: string, jwt?: string })
|
|
|
81
81
|
| Method | Description |
|
|
82
82
|
|--------|-------------|
|
|
83
83
|
| `session(req)` | Open a session, record traces, or close a session |
|
|
84
|
+
| `journal(label, props, options?)` | Record a journal entry linked to an optional session |
|
|
84
85
|
| `distill(req)` | Create a summary that distills multiple source nodes |
|
|
85
86
|
| `memoryConfig(req)` | Set/get preferences and memory policies |
|
|
86
87
|
|
|
@@ -117,6 +118,24 @@ new MindGraph({ baseUrl: string, apiKey?: string, jwt?: string })
|
|
|
117
118
|
| `reasoningChain(uid, maxDepth?)` | Follow epistemic edges from a node |
|
|
118
119
|
| `neighborhood(uid, maxDepth?)` | Get all nodes within N hops |
|
|
119
120
|
|
|
121
|
+
### Ingestion & Retrieval
|
|
122
|
+
|
|
123
|
+
| Method | Description |
|
|
124
|
+
|--------|-------------|
|
|
125
|
+
| `ingestChunk(req)` | Ingest a single text chunk (sync): stores, embeds, and runs LLM extraction |
|
|
126
|
+
| `ingestDocument(req)` | Ingest a full document (async): chunks text, returns job ID |
|
|
127
|
+
| `ingestSession(req)` | Ingest a session transcript (async): links to session, returns job ID |
|
|
128
|
+
| `retrieveContext(req)` | Retrieve semantically matched chunks + connected graph nodes/edges |
|
|
129
|
+
| `getJob(id)` | Get async job status and progress |
|
|
130
|
+
| `clearGraph()` | Clear all graph data |
|
|
131
|
+
|
|
132
|
+
### Lifecycle Shortcuts
|
|
133
|
+
|
|
134
|
+
| Method | Description |
|
|
135
|
+
|--------|-------------|
|
|
136
|
+
| `tombstone(uid, reason?, agentId?)` | Soft-delete a node |
|
|
137
|
+
| `restore(uid, agentId?)` | Restore a tombstoned node |
|
|
138
|
+
|
|
120
139
|
### Cross-cutting
|
|
121
140
|
|
|
122
141
|
| Method | Description |
|
|
@@ -132,6 +151,21 @@ new MindGraph({ baseUrl: string, apiKey?: string, jwt?: string })
|
|
|
132
151
|
| `health()` | Health check |
|
|
133
152
|
| `stats()` | Graph-wide statistics |
|
|
134
153
|
|
|
154
|
+
### Management (Cloud only)
|
|
155
|
+
|
|
156
|
+
| Method | Description |
|
|
157
|
+
|--------|-------------|
|
|
158
|
+
| `signup(email, password)` | Create a new account |
|
|
159
|
+
| `login(email, password)` | Login and receive JWT |
|
|
160
|
+
| `createApiKey(name?)` | Create an API key |
|
|
161
|
+
| `listApiKeys()` | List all API keys |
|
|
162
|
+
| `revokeApiKey(id)` | Revoke an API key |
|
|
163
|
+
| `getUsage()` | Get usage statistics |
|
|
164
|
+
|
|
165
|
+
## Examples
|
|
166
|
+
|
|
167
|
+
See [`examples/`](examples/) for runnable demos, including a [research continuity](examples/research-continuity.ts) scenario showing cross-session memory retrieval.
|
|
168
|
+
|
|
135
169
|
## Error Handling
|
|
136
170
|
|
|
137
171
|
All methods throw `MindGraphError` on HTTP errors:
|
package/dist/index.d.mts
CHANGED
|
@@ -38,7 +38,7 @@ interface PathStep {
|
|
|
38
38
|
depth: number;
|
|
39
39
|
parent_uid: string | null;
|
|
40
40
|
}
|
|
41
|
-
interface
|
|
41
|
+
interface CaptureRequest {
|
|
42
42
|
action: "source" | "snippet" | "observation";
|
|
43
43
|
label: string;
|
|
44
44
|
summary?: string;
|
|
@@ -250,6 +250,10 @@ interface ExecutionRequest {
|
|
|
250
250
|
agent_id?: string;
|
|
251
251
|
}
|
|
252
252
|
interface RetrieveRequest {
|
|
253
|
+
/**
|
|
254
|
+
* Retrieval action. Note: `"semantic"` requires a configured embedding
|
|
255
|
+
* provider on the server; for semantic search use `retrieveContext()` instead.
|
|
256
|
+
*/
|
|
253
257
|
action: "text" | "semantic" | "hybrid" | "active_goals" | "open_questions" | "weak_claims" | "pending_approvals" | "unresolved_contradictions" | "layer" | "recent";
|
|
254
258
|
query?: string;
|
|
255
259
|
k?: number;
|
|
@@ -286,26 +290,114 @@ interface EvolveRequest {
|
|
|
286
290
|
version?: number;
|
|
287
291
|
agent_id?: string;
|
|
288
292
|
}
|
|
289
|
-
interface
|
|
290
|
-
|
|
291
|
-
|
|
293
|
+
interface IngestChunkRequest {
|
|
294
|
+
content: string;
|
|
295
|
+
chunk_type?: string;
|
|
296
|
+
document_uid?: string;
|
|
297
|
+
chunk_index?: number;
|
|
298
|
+
label?: string;
|
|
299
|
+
layers?: string[];
|
|
300
|
+
agent_id?: string;
|
|
301
|
+
}
|
|
302
|
+
interface IngestChunkResponse {
|
|
303
|
+
chunk_uid: string;
|
|
304
|
+
nodes_created: number;
|
|
305
|
+
nodes_deduplicated: number;
|
|
306
|
+
edges_created: number;
|
|
307
|
+
extracted_node_uids: string[];
|
|
308
|
+
errors: string[];
|
|
309
|
+
}
|
|
310
|
+
interface IngestDocumentRequest {
|
|
311
|
+
content: string;
|
|
312
|
+
title?: string;
|
|
313
|
+
document_type?: string;
|
|
314
|
+
/** Semantic content type: "article" (default), "meeting_notes", "journal". Drives default extraction layers. */
|
|
315
|
+
content_type?: string;
|
|
316
|
+
source_uri?: string;
|
|
317
|
+
chunk_size?: number;
|
|
318
|
+
chunk_overlap?: number;
|
|
319
|
+
layers?: string[];
|
|
320
|
+
agent_id?: string;
|
|
292
321
|
}
|
|
293
|
-
interface
|
|
294
|
-
|
|
295
|
-
|
|
322
|
+
interface IngestDocumentResponse {
|
|
323
|
+
job_id: string;
|
|
324
|
+
document_uid: string;
|
|
296
325
|
}
|
|
297
|
-
interface
|
|
298
|
-
|
|
299
|
-
|
|
326
|
+
interface IngestSessionRequest {
|
|
327
|
+
content: string;
|
|
328
|
+
title?: string;
|
|
329
|
+
session_uid?: string;
|
|
330
|
+
chunk_size?: number;
|
|
331
|
+
chunk_overlap?: number;
|
|
332
|
+
layers?: string[];
|
|
333
|
+
agent_id?: string;
|
|
334
|
+
}
|
|
335
|
+
interface RetrieveContextRequest {
|
|
336
|
+
query: string;
|
|
337
|
+
k?: number;
|
|
338
|
+
depth?: number;
|
|
339
|
+
node_types?: string[];
|
|
340
|
+
layer?: string;
|
|
341
|
+
include_chunks?: boolean;
|
|
342
|
+
include_graph?: boolean;
|
|
343
|
+
min_similarity?: number;
|
|
300
344
|
}
|
|
301
|
-
interface
|
|
302
|
-
|
|
345
|
+
interface RetrieveContextResponse {
|
|
346
|
+
chunks: {
|
|
347
|
+
chunk_uid: string;
|
|
348
|
+
content: string;
|
|
349
|
+
score: number;
|
|
350
|
+
document_uid: string | null;
|
|
351
|
+
chunk_index: number | null;
|
|
352
|
+
}[];
|
|
353
|
+
graph: {
|
|
354
|
+
nodes: Record<string, unknown>[];
|
|
355
|
+
edges: Record<string, unknown>[];
|
|
356
|
+
};
|
|
303
357
|
}
|
|
304
|
-
interface
|
|
358
|
+
interface Job {
|
|
305
359
|
id: string;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
360
|
+
title: string;
|
|
361
|
+
status: "pending" | "processing" | "completed" | "failed" | "cancelled";
|
|
362
|
+
progress: {
|
|
363
|
+
total_chunks: number;
|
|
364
|
+
processed_chunks: number;
|
|
365
|
+
nodes_created: number;
|
|
366
|
+
edges_created: number;
|
|
367
|
+
};
|
|
368
|
+
result: Record<string, unknown> | null;
|
|
369
|
+
error: string | null;
|
|
370
|
+
created_at: number;
|
|
371
|
+
queue_position?: number;
|
|
372
|
+
}
|
|
373
|
+
interface ClearResponse {
|
|
374
|
+
cleared: boolean;
|
|
375
|
+
nodes_removed: number;
|
|
376
|
+
edges_removed: number;
|
|
377
|
+
versions_removed: number;
|
|
378
|
+
aliases_removed: number;
|
|
379
|
+
embeddings_removed: number;
|
|
380
|
+
}
|
|
381
|
+
interface BatchRequest {
|
|
382
|
+
nodes?: {
|
|
383
|
+
label: string;
|
|
384
|
+
node_type?: string;
|
|
385
|
+
props?: Record<string, unknown>;
|
|
386
|
+
}[];
|
|
387
|
+
edges?: {
|
|
388
|
+
from_uid: string;
|
|
389
|
+
to_uid: string;
|
|
390
|
+
edge_type: string;
|
|
391
|
+
}[];
|
|
392
|
+
agent_id?: string;
|
|
393
|
+
}
|
|
394
|
+
interface DecayRequest {
|
|
395
|
+
half_life_secs: number;
|
|
396
|
+
min_salience?: number;
|
|
397
|
+
min_age_secs?: number;
|
|
398
|
+
}
|
|
399
|
+
interface PurgeRequest {
|
|
400
|
+
before?: number;
|
|
309
401
|
}
|
|
310
402
|
interface MindGraphConfig {
|
|
311
403
|
baseUrl: string;
|
|
@@ -331,17 +423,55 @@ declare class MindGraph {
|
|
|
331
423
|
status: string;
|
|
332
424
|
}>;
|
|
333
425
|
stats(): Promise<Record<string, unknown>>;
|
|
334
|
-
|
|
426
|
+
capture(req: CaptureRequest): Promise<unknown>;
|
|
335
427
|
entity(req: EntityRequest): Promise<unknown>;
|
|
336
428
|
/** Convenience: create or find an entity by label. */
|
|
337
429
|
findOrCreateEntity(label: string, props?: Record<string, unknown>, agentId?: string): Promise<GraphNode & {
|
|
338
430
|
created: boolean;
|
|
339
431
|
}>;
|
|
432
|
+
/**
|
|
433
|
+
* Resolve text to an existing entity via alias matching.
|
|
434
|
+
* Returns `{ uid: string | null }`.
|
|
435
|
+
*/
|
|
436
|
+
resolveEntity(text: string, agentId?: string): Promise<{
|
|
437
|
+
uid: string | null;
|
|
438
|
+
}>;
|
|
439
|
+
/**
|
|
440
|
+
* Fuzzy-match text against existing entities.
|
|
441
|
+
* Returns `{ matches: [{ uid, label, score }] }`.
|
|
442
|
+
*/
|
|
443
|
+
fuzzyResolveEntity(text: string, limit?: number, agentId?: string): Promise<{
|
|
444
|
+
matches: {
|
|
445
|
+
uid: string;
|
|
446
|
+
label: string;
|
|
447
|
+
score: number;
|
|
448
|
+
}[];
|
|
449
|
+
}>;
|
|
340
450
|
argue(req: ArgumentRequest): Promise<unknown>;
|
|
341
451
|
inquire(req: InquiryRequest): Promise<unknown>;
|
|
342
452
|
structure(req: StructureRequest): Promise<unknown>;
|
|
343
453
|
commit(req: CommitmentRequest): Promise<unknown>;
|
|
344
454
|
deliberate(req: DeliberationRequest): Promise<unknown>;
|
|
455
|
+
/** Open a new decision for deliberation. Returns the Decision node. */
|
|
456
|
+
openDecision(label: string, opts?: {
|
|
457
|
+
summary?: string;
|
|
458
|
+
props?: Record<string, unknown>;
|
|
459
|
+
agent_id?: string;
|
|
460
|
+
}): Promise<unknown>;
|
|
461
|
+
/** Add an option to an open decision. Returns the Option node. */
|
|
462
|
+
addOption(decisionUid: string, label: string, opts?: {
|
|
463
|
+
summary?: string;
|
|
464
|
+
props?: Record<string, unknown>;
|
|
465
|
+
agent_id?: string;
|
|
466
|
+
}): Promise<unknown>;
|
|
467
|
+
/**
|
|
468
|
+
* Resolve a decision by choosing an option.
|
|
469
|
+
* `chosenOptionUid` must be the uid of an option added via `addOption()`.
|
|
470
|
+
*/
|
|
471
|
+
resolveDecision(decisionUid: string, chosenOptionUid: string, opts?: {
|
|
472
|
+
summary?: string;
|
|
473
|
+
agent_id?: string;
|
|
474
|
+
}): Promise<unknown>;
|
|
345
475
|
procedure(req: ProcedureRequest): Promise<unknown>;
|
|
346
476
|
risk(req: RiskRequest): Promise<unknown>;
|
|
347
477
|
session(req: SessionRequest): Promise<unknown>;
|
|
@@ -358,10 +488,18 @@ declare class MindGraph {
|
|
|
358
488
|
plan(req: PlanRequest): Promise<unknown>;
|
|
359
489
|
governance(req: GovernanceRequest): Promise<unknown>;
|
|
360
490
|
execution(req: ExecutionRequest): Promise<unknown>;
|
|
361
|
-
|
|
491
|
+
/** Returns an array of results. Shape varies by action. */
|
|
492
|
+
retrieve(req: RetrieveRequest): Promise<unknown[]>;
|
|
362
493
|
traverse(req: TraverseRequest): Promise<unknown>;
|
|
363
494
|
evolve(req: EvolveRequest): Promise<unknown>;
|
|
364
495
|
getNode(uid: string): Promise<GraphNode>;
|
|
496
|
+
/**
|
|
497
|
+
* Create a node via the low-level CRUD endpoint.
|
|
498
|
+
*
|
|
499
|
+
* The server requires `props._type` to determine the node variant.
|
|
500
|
+
* If `node_type` is provided and `_type` is not already in `props`,
|
|
501
|
+
* it is injected automatically.
|
|
502
|
+
*/
|
|
365
503
|
addNode(body: {
|
|
366
504
|
label: string;
|
|
367
505
|
node_type?: string;
|
|
@@ -376,16 +514,50 @@ declare class MindGraph {
|
|
|
376
514
|
agent_id?: string;
|
|
377
515
|
}): Promise<GraphNode>;
|
|
378
516
|
deleteNode(uid: string): Promise<void>;
|
|
517
|
+
getNodeHistory(uid: string): Promise<unknown[]>;
|
|
518
|
+
getNodeAtVersion(uid: string, version: number): Promise<GraphNode>;
|
|
379
519
|
addLink(body: {
|
|
380
520
|
from_uid: string;
|
|
381
521
|
to_uid: string;
|
|
382
522
|
edge_type: string;
|
|
383
523
|
agent_id?: string;
|
|
384
524
|
}): Promise<unknown>;
|
|
525
|
+
/**
|
|
526
|
+
* Create an edge via the low-level CRUD endpoint.
|
|
527
|
+
*
|
|
528
|
+
* The server requires `props._type` to determine the edge variant.
|
|
529
|
+
* If `edge_type` is provided and `_type` is not already in `props`,
|
|
530
|
+
* it is injected automatically.
|
|
531
|
+
*/
|
|
532
|
+
addEdge(body: {
|
|
533
|
+
from_uid: string;
|
|
534
|
+
to_uid: string;
|
|
535
|
+
edge_type: string;
|
|
536
|
+
weight?: number;
|
|
537
|
+
props?: Record<string, unknown>;
|
|
538
|
+
agent_id?: string;
|
|
539
|
+
}): Promise<unknown>;
|
|
540
|
+
updateEdge(uid: string, body: {
|
|
541
|
+
weight?: number;
|
|
542
|
+
props?: Record<string, unknown>;
|
|
543
|
+
agent_id?: string;
|
|
544
|
+
}): Promise<unknown>;
|
|
545
|
+
deleteEdge(uid: string): Promise<void>;
|
|
546
|
+
getEdgeHistory(uid: string): Promise<unknown[]>;
|
|
547
|
+
/**
|
|
548
|
+
* List edges filtered by source and/or target node.
|
|
549
|
+
* At least one of `from_uid` or `to_uid` is **required** —
|
|
550
|
+
* the server returns 400 if neither is provided.
|
|
551
|
+
*/
|
|
385
552
|
getEdges(params: {
|
|
386
553
|
from_uid?: string;
|
|
387
554
|
to_uid?: string;
|
|
388
555
|
}): Promise<GraphEdge[]>;
|
|
556
|
+
getEdgeBetween(params: {
|
|
557
|
+
from_uid: string;
|
|
558
|
+
to_uid: string;
|
|
559
|
+
edge_type?: string;
|
|
560
|
+
}): Promise<GraphEdge[]>;
|
|
389
561
|
search(query: string, opts?: {
|
|
390
562
|
node_type?: string;
|
|
391
563
|
layer?: string;
|
|
@@ -397,18 +569,79 @@ declare class MindGraph {
|
|
|
397
569
|
node_types?: string[];
|
|
398
570
|
layer?: string;
|
|
399
571
|
}): Promise<SearchResult[]>;
|
|
572
|
+
getNodes(params?: {
|
|
573
|
+
node_type?: string;
|
|
574
|
+
layer?: string;
|
|
575
|
+
limit?: number;
|
|
576
|
+
offset?: number;
|
|
577
|
+
}): Promise<unknown>;
|
|
578
|
+
getAgentNodes(agentId: string): Promise<GraphNode[]>;
|
|
579
|
+
batch(req: BatchRequest): Promise<unknown>;
|
|
580
|
+
configureEmbeddings(body: {
|
|
581
|
+
model: string;
|
|
582
|
+
dimensions: number;
|
|
583
|
+
distance_metric?: string;
|
|
584
|
+
}): Promise<unknown>;
|
|
585
|
+
embeddingSearch(body: {
|
|
586
|
+
vector: number[];
|
|
587
|
+
k?: number;
|
|
588
|
+
node_types?: string[];
|
|
589
|
+
threshold?: number;
|
|
590
|
+
}): Promise<unknown>;
|
|
591
|
+
embeddingSearchText(body: {
|
|
592
|
+
text: string;
|
|
593
|
+
k?: number;
|
|
594
|
+
node_types?: string[];
|
|
595
|
+
threshold?: number;
|
|
596
|
+
}): Promise<unknown>;
|
|
597
|
+
getEmbedding(uid: string): Promise<unknown>;
|
|
598
|
+
setEmbedding(uid: string, vector: number[]): Promise<void>;
|
|
599
|
+
deleteEmbedding(uid: string): Promise<void>;
|
|
600
|
+
mergeEntities(body: {
|
|
601
|
+
keep_uid: string;
|
|
602
|
+
merge_uid: string;
|
|
603
|
+
agent_id?: string;
|
|
604
|
+
}): Promise<unknown>;
|
|
605
|
+
addAlias(body: {
|
|
606
|
+
text: string;
|
|
607
|
+
canonical_uid: string;
|
|
608
|
+
score?: number;
|
|
609
|
+
}): Promise<unknown>;
|
|
610
|
+
getAliases(uid: string): Promise<unknown>;
|
|
611
|
+
resolveAlias(text: string): Promise<unknown>;
|
|
612
|
+
exportGraph(): Promise<unknown>;
|
|
613
|
+
importGraph(data: unknown): Promise<unknown>;
|
|
614
|
+
decay(req: DecayRequest): Promise<unknown>;
|
|
615
|
+
purge(req?: PurgeRequest): Promise<unknown>;
|
|
400
616
|
reasoningChain(uid: string, maxDepth?: number): Promise<PathStep[]>;
|
|
401
617
|
neighborhood(uid: string, maxDepth?: number): Promise<PathStep[]>;
|
|
618
|
+
subgraph(uid: string, opts?: {
|
|
619
|
+
max_depth?: number;
|
|
620
|
+
direction?: "outgoing" | "incoming" | "both";
|
|
621
|
+
edge_types?: string[];
|
|
622
|
+
weight_threshold?: number;
|
|
623
|
+
}): Promise<{
|
|
624
|
+
nodes: GraphNode[];
|
|
625
|
+
edges: GraphEdge[];
|
|
626
|
+
}>;
|
|
402
627
|
tombstone(uid: string, reason?: string, agentId?: string): Promise<unknown>;
|
|
403
628
|
restore(uid: string, agentId?: string): Promise<unknown>;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
629
|
+
getGoals(): Promise<GraphNode[]>;
|
|
630
|
+
getOpenDecisions(): Promise<GraphNode[]>;
|
|
631
|
+
getOpenQuestions(): Promise<GraphNode[]>;
|
|
632
|
+
getWeakClaims(): Promise<GraphNode[]>;
|
|
633
|
+
getContradictions(): Promise<unknown[]>;
|
|
634
|
+
getPendingApprovals(): Promise<GraphNode[]>;
|
|
635
|
+
ingestChunk(req: IngestChunkRequest): Promise<IngestChunkResponse>;
|
|
636
|
+
ingestDocument(req: IngestDocumentRequest): Promise<IngestDocumentResponse>;
|
|
637
|
+
ingestSession(req: IngestSessionRequest): Promise<IngestDocumentResponse>;
|
|
638
|
+
retrieveContext(req: RetrieveContextRequest): Promise<RetrieveContextResponse>;
|
|
639
|
+
listJobs(): Promise<Job[]>;
|
|
640
|
+
getJob(id: string): Promise<Job>;
|
|
641
|
+
cancelJob(id: string): Promise<unknown>;
|
|
642
|
+
cleanupOrphans(): Promise<unknown>;
|
|
643
|
+
embedAll(): Promise<unknown>;
|
|
644
|
+
clearGraph(): Promise<ClearResponse>;
|
|
412
645
|
}
|
|
413
646
|
|
|
414
|
-
export { type
|
|
647
|
+
export { type ArgumentRequest, type BatchRequest, type CaptureRequest, type ClearResponse, type CommitmentRequest, type DecayRequest, type DeliberationRequest, type DistillRequest, type EntityRequest, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type PathStep, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchResult, type SessionRequest, type StructureRequest, type TraverseRequest };
|