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/dist/index.d.ts
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 };
|
package/dist/index.js
CHANGED
|
@@ -93,8 +93,8 @@ var MindGraph = class {
|
|
|
93
93
|
return this.get("/stats");
|
|
94
94
|
}
|
|
95
95
|
// ---- Reality Layer ----
|
|
96
|
-
async
|
|
97
|
-
return this.post("/reality/
|
|
96
|
+
async capture(req) {
|
|
97
|
+
return this.post("/reality/capture", req);
|
|
98
98
|
}
|
|
99
99
|
async entity(req) {
|
|
100
100
|
return this.post("/reality/entity", req);
|
|
@@ -108,6 +108,29 @@ var MindGraph = class {
|
|
|
108
108
|
agent_id: agentId
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolve text to an existing entity via alias matching.
|
|
113
|
+
* Returns `{ uid: string | null }`.
|
|
114
|
+
*/
|
|
115
|
+
async resolveEntity(text, agentId) {
|
|
116
|
+
return this.post("/reality/entity", {
|
|
117
|
+
action: "resolve",
|
|
118
|
+
text,
|
|
119
|
+
agent_id: agentId
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Fuzzy-match text against existing entities.
|
|
124
|
+
* Returns `{ matches: [{ uid, label, score }] }`.
|
|
125
|
+
*/
|
|
126
|
+
async fuzzyResolveEntity(text, limit = 5, agentId) {
|
|
127
|
+
return this.post("/reality/entity", {
|
|
128
|
+
action: "fuzzy_resolve",
|
|
129
|
+
text,
|
|
130
|
+
limit,
|
|
131
|
+
agent_id: agentId
|
|
132
|
+
});
|
|
133
|
+
}
|
|
111
134
|
// ---- Epistemic Layer ----
|
|
112
135
|
async argue(req) {
|
|
113
136
|
return this.post("/epistemic/argument", req);
|
|
@@ -125,6 +148,35 @@ var MindGraph = class {
|
|
|
125
148
|
async deliberate(req) {
|
|
126
149
|
return this.post("/intent/deliberation", req);
|
|
127
150
|
}
|
|
151
|
+
/** Open a new decision for deliberation. Returns the Decision node. */
|
|
152
|
+
async openDecision(label, opts) {
|
|
153
|
+
return this.post("/intent/deliberation", {
|
|
154
|
+
action: "open_decision",
|
|
155
|
+
label,
|
|
156
|
+
...opts
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** Add an option to an open decision. Returns the Option node. */
|
|
160
|
+
async addOption(decisionUid, label, opts) {
|
|
161
|
+
return this.post("/intent/deliberation", {
|
|
162
|
+
action: "add_option",
|
|
163
|
+
decision_uid: decisionUid,
|
|
164
|
+
label,
|
|
165
|
+
...opts
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Resolve a decision by choosing an option.
|
|
170
|
+
* `chosenOptionUid` must be the uid of an option added via `addOption()`.
|
|
171
|
+
*/
|
|
172
|
+
async resolveDecision(decisionUid, chosenOptionUid, opts) {
|
|
173
|
+
return this.post("/intent/deliberation", {
|
|
174
|
+
action: "resolve",
|
|
175
|
+
decision_uid: decisionUid,
|
|
176
|
+
chosen_option_uid: chosenOptionUid,
|
|
177
|
+
...opts
|
|
178
|
+
});
|
|
179
|
+
}
|
|
128
180
|
// ---- Action Layer ----
|
|
129
181
|
async procedure(req) {
|
|
130
182
|
return this.post("/action/procedure", req);
|
|
@@ -161,6 +213,7 @@ var MindGraph = class {
|
|
|
161
213
|
return this.post("/agent/execution", req);
|
|
162
214
|
}
|
|
163
215
|
// ---- Cross-cutting ----
|
|
216
|
+
/** Returns an array of results. Shape varies by action. */
|
|
164
217
|
async retrieve(req) {
|
|
165
218
|
return this.post("/retrieve", req);
|
|
166
219
|
}
|
|
@@ -174,8 +227,19 @@ var MindGraph = class {
|
|
|
174
227
|
async getNode(uid) {
|
|
175
228
|
return this.get(`/node/${uid}`);
|
|
176
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Create a node via the low-level CRUD endpoint.
|
|
232
|
+
*
|
|
233
|
+
* The server requires `props._type` to determine the node variant.
|
|
234
|
+
* If `node_type` is provided and `_type` is not already in `props`,
|
|
235
|
+
* it is injected automatically.
|
|
236
|
+
*/
|
|
177
237
|
async addNode(body) {
|
|
178
|
-
|
|
238
|
+
const props = { ...body.props };
|
|
239
|
+
if (body.node_type && !("_type" in props)) {
|
|
240
|
+
props._type = body.node_type;
|
|
241
|
+
}
|
|
242
|
+
return this.post("/node", { ...body, props });
|
|
179
243
|
}
|
|
180
244
|
async updateNode(uid, body) {
|
|
181
245
|
return this.patch(`/node/${uid}`, body);
|
|
@@ -183,16 +247,60 @@ var MindGraph = class {
|
|
|
183
247
|
async deleteNode(uid) {
|
|
184
248
|
await this.del(`/node/${uid}`);
|
|
185
249
|
}
|
|
250
|
+
async getNodeHistory(uid) {
|
|
251
|
+
return this.get(`/node/${uid}/history`);
|
|
252
|
+
}
|
|
253
|
+
async getNodeAtVersion(uid, version) {
|
|
254
|
+
return this.get(`/node/${uid}/history/${version}`);
|
|
255
|
+
}
|
|
186
256
|
// ---- Edge CRUD ----
|
|
187
257
|
async addLink(body) {
|
|
188
258
|
return this.post("/link", body);
|
|
189
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Create an edge via the low-level CRUD endpoint.
|
|
262
|
+
*
|
|
263
|
+
* The server requires `props._type` to determine the edge variant.
|
|
264
|
+
* If `edge_type` is provided and `_type` is not already in `props`,
|
|
265
|
+
* it is injected automatically.
|
|
266
|
+
*/
|
|
267
|
+
async addEdge(body) {
|
|
268
|
+
const props = { ...body.props };
|
|
269
|
+
if (body.edge_type && !("_type" in props)) {
|
|
270
|
+
props._type = body.edge_type;
|
|
271
|
+
}
|
|
272
|
+
return this.post("/edge", { ...body, props });
|
|
273
|
+
}
|
|
274
|
+
async updateEdge(uid, body) {
|
|
275
|
+
return this.patch(`/edge/${uid}`, body);
|
|
276
|
+
}
|
|
277
|
+
async deleteEdge(uid) {
|
|
278
|
+
await this.del(`/edge/${uid}`);
|
|
279
|
+
}
|
|
280
|
+
async getEdgeHistory(uid) {
|
|
281
|
+
return this.get(`/edge/${uid}/history`);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* List edges filtered by source and/or target node.
|
|
285
|
+
* At least one of `from_uid` or `to_uid` is **required** —
|
|
286
|
+
* the server returns 400 if neither is provided.
|
|
287
|
+
*/
|
|
190
288
|
async getEdges(params) {
|
|
289
|
+
if (!params.from_uid && !params.to_uid) {
|
|
290
|
+
throw new Error("at least one of from_uid or to_uid is required");
|
|
291
|
+
}
|
|
191
292
|
const qs = new URLSearchParams();
|
|
192
293
|
if (params.from_uid) qs.set("from_uid", params.from_uid);
|
|
193
294
|
if (params.to_uid) qs.set("to_uid", params.to_uid);
|
|
194
295
|
return this.get(`/edges?${qs}`);
|
|
195
296
|
}
|
|
297
|
+
async getEdgeBetween(params) {
|
|
298
|
+
const qs = new URLSearchParams();
|
|
299
|
+
qs.set("from_uid", params.from_uid);
|
|
300
|
+
qs.set("to_uid", params.to_uid);
|
|
301
|
+
if (params.edge_type) qs.set("edge_type", params.edge_type);
|
|
302
|
+
return this.get(`/edge/between?${qs}`);
|
|
303
|
+
}
|
|
196
304
|
// ---- Search ----
|
|
197
305
|
async search(query, opts) {
|
|
198
306
|
return this.post("/search", { query, ...opts });
|
|
@@ -205,20 +313,87 @@ var MindGraph = class {
|
|
|
205
313
|
...opts
|
|
206
314
|
});
|
|
207
315
|
}
|
|
316
|
+
// ---- Nodes listing ----
|
|
317
|
+
async getNodes(params) {
|
|
318
|
+
const qs = new URLSearchParams();
|
|
319
|
+
if (params?.node_type) qs.set("node_type", params.node_type);
|
|
320
|
+
if (params?.layer) qs.set("layer", params.layer);
|
|
321
|
+
if (params?.limit != null) qs.set("limit", String(params.limit));
|
|
322
|
+
if (params?.offset != null) qs.set("offset", String(params.offset));
|
|
323
|
+
return this.get(`/nodes?${qs}`);
|
|
324
|
+
}
|
|
325
|
+
async getAgentNodes(agentId) {
|
|
326
|
+
return this.get(`/agent/${agentId}/nodes`);
|
|
327
|
+
}
|
|
328
|
+
// ---- Batch ----
|
|
329
|
+
async batch(req) {
|
|
330
|
+
return this.post("/batch", req);
|
|
331
|
+
}
|
|
332
|
+
// ---- Embeddings ----
|
|
333
|
+
async configureEmbeddings(body) {
|
|
334
|
+
return this.post("/embeddings/configure", body);
|
|
335
|
+
}
|
|
336
|
+
async embeddingSearch(body) {
|
|
337
|
+
return this.post("/embeddings/search", body);
|
|
338
|
+
}
|
|
339
|
+
async embeddingSearchText(body) {
|
|
340
|
+
return this.post("/embeddings/search-text", body);
|
|
341
|
+
}
|
|
342
|
+
async getEmbedding(uid) {
|
|
343
|
+
return this.get(`/node/${uid}/embedding`);
|
|
344
|
+
}
|
|
345
|
+
async setEmbedding(uid, vector) {
|
|
346
|
+
await this.request("PUT", `/node/${uid}/embedding`, { vector });
|
|
347
|
+
}
|
|
348
|
+
async deleteEmbedding(uid) {
|
|
349
|
+
await this.del(`/node/${uid}/embedding`);
|
|
350
|
+
}
|
|
351
|
+
// ---- Entity resolution ----
|
|
352
|
+
async mergeEntities(body) {
|
|
353
|
+
return this.post("/entities/merge", body);
|
|
354
|
+
}
|
|
355
|
+
async addAlias(body) {
|
|
356
|
+
return this.post("/alias", body);
|
|
357
|
+
}
|
|
358
|
+
async getAliases(uid) {
|
|
359
|
+
return this.get(`/aliases/${uid}`);
|
|
360
|
+
}
|
|
361
|
+
async resolveAlias(text) {
|
|
362
|
+
return this.get(`/resolve?text=${encodeURIComponent(text)}`);
|
|
363
|
+
}
|
|
364
|
+
// ---- Export / Import ----
|
|
365
|
+
async exportGraph() {
|
|
366
|
+
return this.get("/export");
|
|
367
|
+
}
|
|
368
|
+
async importGraph(data) {
|
|
369
|
+
return this.post("/import", data);
|
|
370
|
+
}
|
|
371
|
+
// ---- Lifecycle ----
|
|
372
|
+
async decay(req) {
|
|
373
|
+
return this.post("/decay", req);
|
|
374
|
+
}
|
|
375
|
+
async purge(req) {
|
|
376
|
+
return this.post("/purge", req ?? {});
|
|
377
|
+
}
|
|
208
378
|
// ---- Traversal shortcuts ----
|
|
209
379
|
async reasoningChain(uid, maxDepth = 5) {
|
|
210
|
-
|
|
380
|
+
const r = await this.post("/traverse", {
|
|
211
381
|
action: "chain",
|
|
212
382
|
start_uid: uid,
|
|
213
383
|
max_depth: maxDepth
|
|
214
384
|
});
|
|
385
|
+
return r?.steps ?? r;
|
|
215
386
|
}
|
|
216
387
|
async neighborhood(uid, maxDepth = 1) {
|
|
217
|
-
|
|
388
|
+
const r = await this.post("/traverse", {
|
|
218
389
|
action: "neighborhood",
|
|
219
390
|
start_uid: uid,
|
|
220
391
|
max_depth: maxDepth
|
|
221
392
|
});
|
|
393
|
+
return r?.steps ?? r;
|
|
394
|
+
}
|
|
395
|
+
async subgraph(uid, opts) {
|
|
396
|
+
return this.post("/subgraph", { start_uids: [uid], ...opts });
|
|
222
397
|
}
|
|
223
398
|
// ---- Lifecycle shortcuts ----
|
|
224
399
|
async tombstone(uid, reason, agentId) {
|
|
@@ -236,24 +411,55 @@ var MindGraph = class {
|
|
|
236
411
|
agent_id: agentId
|
|
237
412
|
});
|
|
238
413
|
}
|
|
239
|
-
// ----
|
|
240
|
-
async
|
|
241
|
-
return this.
|
|
414
|
+
// ---- Epistemic queries ----
|
|
415
|
+
async getGoals() {
|
|
416
|
+
return this.get("/goals");
|
|
417
|
+
}
|
|
418
|
+
async getOpenDecisions() {
|
|
419
|
+
return this.get("/decisions");
|
|
420
|
+
}
|
|
421
|
+
async getOpenQuestions() {
|
|
422
|
+
return this.get("/questions");
|
|
423
|
+
}
|
|
424
|
+
async getWeakClaims() {
|
|
425
|
+
return this.get("/claims/weak");
|
|
426
|
+
}
|
|
427
|
+
async getContradictions() {
|
|
428
|
+
return this.get("/contradictions");
|
|
429
|
+
}
|
|
430
|
+
async getPendingApprovals() {
|
|
431
|
+
return this.get("/approvals/pending");
|
|
432
|
+
}
|
|
433
|
+
// ---- Ingestion & Retrieval ----
|
|
434
|
+
async ingestChunk(req) {
|
|
435
|
+
return this.post("/ingest/chunk", req);
|
|
436
|
+
}
|
|
437
|
+
async ingestDocument(req) {
|
|
438
|
+
return this.post("/ingest/document", req);
|
|
439
|
+
}
|
|
440
|
+
async ingestSession(req) {
|
|
441
|
+
return this.post("/ingest/session", req);
|
|
442
|
+
}
|
|
443
|
+
async retrieveContext(req) {
|
|
444
|
+
return this.post("/retrieve/context", req);
|
|
445
|
+
}
|
|
446
|
+
async listJobs() {
|
|
447
|
+
return this.get("/jobs");
|
|
242
448
|
}
|
|
243
|
-
async
|
|
244
|
-
return this.
|
|
449
|
+
async getJob(id) {
|
|
450
|
+
return this.get(`/jobs/${id}`);
|
|
245
451
|
}
|
|
246
|
-
async
|
|
247
|
-
return this.post(
|
|
452
|
+
async cancelJob(id) {
|
|
453
|
+
return this.post(`/jobs/${id}/cancel`, {});
|
|
248
454
|
}
|
|
249
|
-
async
|
|
250
|
-
return this.
|
|
455
|
+
async cleanupOrphans() {
|
|
456
|
+
return this.post("/ingest/cleanup", {});
|
|
251
457
|
}
|
|
252
|
-
async
|
|
253
|
-
|
|
458
|
+
async embedAll() {
|
|
459
|
+
return this.post("/ingest/embed-all", {});
|
|
254
460
|
}
|
|
255
|
-
async
|
|
256
|
-
return this.
|
|
461
|
+
async clearGraph() {
|
|
462
|
+
return this.post("/clear", {});
|
|
257
463
|
}
|
|
258
464
|
};
|
|
259
465
|
// Annotate the CommonJS export names for ESM import in node:
|