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.mjs
CHANGED
|
@@ -66,8 +66,8 @@ var MindGraph = class {
|
|
|
66
66
|
return this.get("/stats");
|
|
67
67
|
}
|
|
68
68
|
// ---- Reality Layer ----
|
|
69
|
-
async
|
|
70
|
-
return this.post("/reality/
|
|
69
|
+
async capture(req) {
|
|
70
|
+
return this.post("/reality/capture", req);
|
|
71
71
|
}
|
|
72
72
|
async entity(req) {
|
|
73
73
|
return this.post("/reality/entity", req);
|
|
@@ -81,6 +81,29 @@ var MindGraph = class {
|
|
|
81
81
|
agent_id: agentId
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Resolve text to an existing entity via alias matching.
|
|
86
|
+
* Returns `{ uid: string | null }`.
|
|
87
|
+
*/
|
|
88
|
+
async resolveEntity(text, agentId) {
|
|
89
|
+
return this.post("/reality/entity", {
|
|
90
|
+
action: "resolve",
|
|
91
|
+
text,
|
|
92
|
+
agent_id: agentId
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Fuzzy-match text against existing entities.
|
|
97
|
+
* Returns `{ matches: [{ uid, label, score }] }`.
|
|
98
|
+
*/
|
|
99
|
+
async fuzzyResolveEntity(text, limit = 5, agentId) {
|
|
100
|
+
return this.post("/reality/entity", {
|
|
101
|
+
action: "fuzzy_resolve",
|
|
102
|
+
text,
|
|
103
|
+
limit,
|
|
104
|
+
agent_id: agentId
|
|
105
|
+
});
|
|
106
|
+
}
|
|
84
107
|
// ---- Epistemic Layer ----
|
|
85
108
|
async argue(req) {
|
|
86
109
|
return this.post("/epistemic/argument", req);
|
|
@@ -98,6 +121,35 @@ var MindGraph = class {
|
|
|
98
121
|
async deliberate(req) {
|
|
99
122
|
return this.post("/intent/deliberation", req);
|
|
100
123
|
}
|
|
124
|
+
/** Open a new decision for deliberation. Returns the Decision node. */
|
|
125
|
+
async openDecision(label, opts) {
|
|
126
|
+
return this.post("/intent/deliberation", {
|
|
127
|
+
action: "open_decision",
|
|
128
|
+
label,
|
|
129
|
+
...opts
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** Add an option to an open decision. Returns the Option node. */
|
|
133
|
+
async addOption(decisionUid, label, opts) {
|
|
134
|
+
return this.post("/intent/deliberation", {
|
|
135
|
+
action: "add_option",
|
|
136
|
+
decision_uid: decisionUid,
|
|
137
|
+
label,
|
|
138
|
+
...opts
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Resolve a decision by choosing an option.
|
|
143
|
+
* `chosenOptionUid` must be the uid of an option added via `addOption()`.
|
|
144
|
+
*/
|
|
145
|
+
async resolveDecision(decisionUid, chosenOptionUid, opts) {
|
|
146
|
+
return this.post("/intent/deliberation", {
|
|
147
|
+
action: "resolve",
|
|
148
|
+
decision_uid: decisionUid,
|
|
149
|
+
chosen_option_uid: chosenOptionUid,
|
|
150
|
+
...opts
|
|
151
|
+
});
|
|
152
|
+
}
|
|
101
153
|
// ---- Action Layer ----
|
|
102
154
|
async procedure(req) {
|
|
103
155
|
return this.post("/action/procedure", req);
|
|
@@ -134,6 +186,7 @@ var MindGraph = class {
|
|
|
134
186
|
return this.post("/agent/execution", req);
|
|
135
187
|
}
|
|
136
188
|
// ---- Cross-cutting ----
|
|
189
|
+
/** Returns an array of results. Shape varies by action. */
|
|
137
190
|
async retrieve(req) {
|
|
138
191
|
return this.post("/retrieve", req);
|
|
139
192
|
}
|
|
@@ -147,8 +200,19 @@ var MindGraph = class {
|
|
|
147
200
|
async getNode(uid) {
|
|
148
201
|
return this.get(`/node/${uid}`);
|
|
149
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Create a node via the low-level CRUD endpoint.
|
|
205
|
+
*
|
|
206
|
+
* The server requires `props._type` to determine the node variant.
|
|
207
|
+
* If `node_type` is provided and `_type` is not already in `props`,
|
|
208
|
+
* it is injected automatically.
|
|
209
|
+
*/
|
|
150
210
|
async addNode(body) {
|
|
151
|
-
|
|
211
|
+
const props = { ...body.props };
|
|
212
|
+
if (body.node_type && !("_type" in props)) {
|
|
213
|
+
props._type = body.node_type;
|
|
214
|
+
}
|
|
215
|
+
return this.post("/node", { ...body, props });
|
|
152
216
|
}
|
|
153
217
|
async updateNode(uid, body) {
|
|
154
218
|
return this.patch(`/node/${uid}`, body);
|
|
@@ -156,16 +220,60 @@ var MindGraph = class {
|
|
|
156
220
|
async deleteNode(uid) {
|
|
157
221
|
await this.del(`/node/${uid}`);
|
|
158
222
|
}
|
|
223
|
+
async getNodeHistory(uid) {
|
|
224
|
+
return this.get(`/node/${uid}/history`);
|
|
225
|
+
}
|
|
226
|
+
async getNodeAtVersion(uid, version) {
|
|
227
|
+
return this.get(`/node/${uid}/history/${version}`);
|
|
228
|
+
}
|
|
159
229
|
// ---- Edge CRUD ----
|
|
160
230
|
async addLink(body) {
|
|
161
231
|
return this.post("/link", body);
|
|
162
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Create an edge via the low-level CRUD endpoint.
|
|
235
|
+
*
|
|
236
|
+
* The server requires `props._type` to determine the edge variant.
|
|
237
|
+
* If `edge_type` is provided and `_type` is not already in `props`,
|
|
238
|
+
* it is injected automatically.
|
|
239
|
+
*/
|
|
240
|
+
async addEdge(body) {
|
|
241
|
+
const props = { ...body.props };
|
|
242
|
+
if (body.edge_type && !("_type" in props)) {
|
|
243
|
+
props._type = body.edge_type;
|
|
244
|
+
}
|
|
245
|
+
return this.post("/edge", { ...body, props });
|
|
246
|
+
}
|
|
247
|
+
async updateEdge(uid, body) {
|
|
248
|
+
return this.patch(`/edge/${uid}`, body);
|
|
249
|
+
}
|
|
250
|
+
async deleteEdge(uid) {
|
|
251
|
+
await this.del(`/edge/${uid}`);
|
|
252
|
+
}
|
|
253
|
+
async getEdgeHistory(uid) {
|
|
254
|
+
return this.get(`/edge/${uid}/history`);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* List edges filtered by source and/or target node.
|
|
258
|
+
* At least one of `from_uid` or `to_uid` is **required** —
|
|
259
|
+
* the server returns 400 if neither is provided.
|
|
260
|
+
*/
|
|
163
261
|
async getEdges(params) {
|
|
262
|
+
if (!params.from_uid && !params.to_uid) {
|
|
263
|
+
throw new Error("at least one of from_uid or to_uid is required");
|
|
264
|
+
}
|
|
164
265
|
const qs = new URLSearchParams();
|
|
165
266
|
if (params.from_uid) qs.set("from_uid", params.from_uid);
|
|
166
267
|
if (params.to_uid) qs.set("to_uid", params.to_uid);
|
|
167
268
|
return this.get(`/edges?${qs}`);
|
|
168
269
|
}
|
|
270
|
+
async getEdgeBetween(params) {
|
|
271
|
+
const qs = new URLSearchParams();
|
|
272
|
+
qs.set("from_uid", params.from_uid);
|
|
273
|
+
qs.set("to_uid", params.to_uid);
|
|
274
|
+
if (params.edge_type) qs.set("edge_type", params.edge_type);
|
|
275
|
+
return this.get(`/edge/between?${qs}`);
|
|
276
|
+
}
|
|
169
277
|
// ---- Search ----
|
|
170
278
|
async search(query, opts) {
|
|
171
279
|
return this.post("/search", { query, ...opts });
|
|
@@ -178,20 +286,87 @@ var MindGraph = class {
|
|
|
178
286
|
...opts
|
|
179
287
|
});
|
|
180
288
|
}
|
|
289
|
+
// ---- Nodes listing ----
|
|
290
|
+
async getNodes(params) {
|
|
291
|
+
const qs = new URLSearchParams();
|
|
292
|
+
if (params?.node_type) qs.set("node_type", params.node_type);
|
|
293
|
+
if (params?.layer) qs.set("layer", params.layer);
|
|
294
|
+
if (params?.limit != null) qs.set("limit", String(params.limit));
|
|
295
|
+
if (params?.offset != null) qs.set("offset", String(params.offset));
|
|
296
|
+
return this.get(`/nodes?${qs}`);
|
|
297
|
+
}
|
|
298
|
+
async getAgentNodes(agentId) {
|
|
299
|
+
return this.get(`/agent/${agentId}/nodes`);
|
|
300
|
+
}
|
|
301
|
+
// ---- Batch ----
|
|
302
|
+
async batch(req) {
|
|
303
|
+
return this.post("/batch", req);
|
|
304
|
+
}
|
|
305
|
+
// ---- Embeddings ----
|
|
306
|
+
async configureEmbeddings(body) {
|
|
307
|
+
return this.post("/embeddings/configure", body);
|
|
308
|
+
}
|
|
309
|
+
async embeddingSearch(body) {
|
|
310
|
+
return this.post("/embeddings/search", body);
|
|
311
|
+
}
|
|
312
|
+
async embeddingSearchText(body) {
|
|
313
|
+
return this.post("/embeddings/search-text", body);
|
|
314
|
+
}
|
|
315
|
+
async getEmbedding(uid) {
|
|
316
|
+
return this.get(`/node/${uid}/embedding`);
|
|
317
|
+
}
|
|
318
|
+
async setEmbedding(uid, vector) {
|
|
319
|
+
await this.request("PUT", `/node/${uid}/embedding`, { vector });
|
|
320
|
+
}
|
|
321
|
+
async deleteEmbedding(uid) {
|
|
322
|
+
await this.del(`/node/${uid}/embedding`);
|
|
323
|
+
}
|
|
324
|
+
// ---- Entity resolution ----
|
|
325
|
+
async mergeEntities(body) {
|
|
326
|
+
return this.post("/entities/merge", body);
|
|
327
|
+
}
|
|
328
|
+
async addAlias(body) {
|
|
329
|
+
return this.post("/alias", body);
|
|
330
|
+
}
|
|
331
|
+
async getAliases(uid) {
|
|
332
|
+
return this.get(`/aliases/${uid}`);
|
|
333
|
+
}
|
|
334
|
+
async resolveAlias(text) {
|
|
335
|
+
return this.get(`/resolve?text=${encodeURIComponent(text)}`);
|
|
336
|
+
}
|
|
337
|
+
// ---- Export / Import ----
|
|
338
|
+
async exportGraph() {
|
|
339
|
+
return this.get("/export");
|
|
340
|
+
}
|
|
341
|
+
async importGraph(data) {
|
|
342
|
+
return this.post("/import", data);
|
|
343
|
+
}
|
|
344
|
+
// ---- Lifecycle ----
|
|
345
|
+
async decay(req) {
|
|
346
|
+
return this.post("/decay", req);
|
|
347
|
+
}
|
|
348
|
+
async purge(req) {
|
|
349
|
+
return this.post("/purge", req ?? {});
|
|
350
|
+
}
|
|
181
351
|
// ---- Traversal shortcuts ----
|
|
182
352
|
async reasoningChain(uid, maxDepth = 5) {
|
|
183
|
-
|
|
353
|
+
const r = await this.post("/traverse", {
|
|
184
354
|
action: "chain",
|
|
185
355
|
start_uid: uid,
|
|
186
356
|
max_depth: maxDepth
|
|
187
357
|
});
|
|
358
|
+
return r?.steps ?? r;
|
|
188
359
|
}
|
|
189
360
|
async neighborhood(uid, maxDepth = 1) {
|
|
190
|
-
|
|
361
|
+
const r = await this.post("/traverse", {
|
|
191
362
|
action: "neighborhood",
|
|
192
363
|
start_uid: uid,
|
|
193
364
|
max_depth: maxDepth
|
|
194
365
|
});
|
|
366
|
+
return r?.steps ?? r;
|
|
367
|
+
}
|
|
368
|
+
async subgraph(uid, opts) {
|
|
369
|
+
return this.post("/subgraph", { start_uids: [uid], ...opts });
|
|
195
370
|
}
|
|
196
371
|
// ---- Lifecycle shortcuts ----
|
|
197
372
|
async tombstone(uid, reason, agentId) {
|
|
@@ -209,24 +384,55 @@ var MindGraph = class {
|
|
|
209
384
|
agent_id: agentId
|
|
210
385
|
});
|
|
211
386
|
}
|
|
212
|
-
// ----
|
|
213
|
-
async
|
|
214
|
-
return this.
|
|
387
|
+
// ---- Epistemic queries ----
|
|
388
|
+
async getGoals() {
|
|
389
|
+
return this.get("/goals");
|
|
390
|
+
}
|
|
391
|
+
async getOpenDecisions() {
|
|
392
|
+
return this.get("/decisions");
|
|
393
|
+
}
|
|
394
|
+
async getOpenQuestions() {
|
|
395
|
+
return this.get("/questions");
|
|
396
|
+
}
|
|
397
|
+
async getWeakClaims() {
|
|
398
|
+
return this.get("/claims/weak");
|
|
399
|
+
}
|
|
400
|
+
async getContradictions() {
|
|
401
|
+
return this.get("/contradictions");
|
|
402
|
+
}
|
|
403
|
+
async getPendingApprovals() {
|
|
404
|
+
return this.get("/approvals/pending");
|
|
405
|
+
}
|
|
406
|
+
// ---- Ingestion & Retrieval ----
|
|
407
|
+
async ingestChunk(req) {
|
|
408
|
+
return this.post("/ingest/chunk", req);
|
|
409
|
+
}
|
|
410
|
+
async ingestDocument(req) {
|
|
411
|
+
return this.post("/ingest/document", req);
|
|
412
|
+
}
|
|
413
|
+
async ingestSession(req) {
|
|
414
|
+
return this.post("/ingest/session", req);
|
|
415
|
+
}
|
|
416
|
+
async retrieveContext(req) {
|
|
417
|
+
return this.post("/retrieve/context", req);
|
|
418
|
+
}
|
|
419
|
+
async listJobs() {
|
|
420
|
+
return this.get("/jobs");
|
|
215
421
|
}
|
|
216
|
-
async
|
|
217
|
-
return this.
|
|
422
|
+
async getJob(id) {
|
|
423
|
+
return this.get(`/jobs/${id}`);
|
|
218
424
|
}
|
|
219
|
-
async
|
|
220
|
-
return this.post(
|
|
425
|
+
async cancelJob(id) {
|
|
426
|
+
return this.post(`/jobs/${id}/cancel`, {});
|
|
221
427
|
}
|
|
222
|
-
async
|
|
223
|
-
return this.
|
|
428
|
+
async cleanupOrphans() {
|
|
429
|
+
return this.post("/ingest/cleanup", {});
|
|
224
430
|
}
|
|
225
|
-
async
|
|
226
|
-
|
|
431
|
+
async embedAll() {
|
|
432
|
+
return this.post("/ingest/embed-all", {});
|
|
227
433
|
}
|
|
228
|
-
async
|
|
229
|
-
return this.
|
|
434
|
+
async clearGraph() {
|
|
435
|
+
return this.post("/clear", {});
|
|
230
436
|
}
|
|
231
437
|
};
|
|
232
438
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mindgraph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "TypeScript client for the MindGraph Cloud API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"keywords": ["mindgraph", "knowledge-graph", "cognitive", "ai", "agent"],
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@types/node": "^25.4.0",
|
|
17
18
|
"tsup": "^8.0.0",
|
|
18
19
|
"typescript": "^5.7.0",
|
|
19
20
|
"vitest": "^3.0.0"
|