mindgraph 0.1.1 → 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 +312 -82
- package/dist/index.d.ts +312 -82
- package/dist/index.js +228 -22
- package/dist/index.mjs +228 -22
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -93,18 +93,41 @@ 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);
|
|
101
101
|
}
|
|
102
102
|
/** Convenience: create or find an entity by label. */
|
|
103
|
-
async findOrCreateEntity(label,
|
|
103
|
+
async findOrCreateEntity(label, props, agentId) {
|
|
104
104
|
return this.post("/reality/entity", {
|
|
105
105
|
action: "create",
|
|
106
106
|
label,
|
|
107
|
-
entity_type:
|
|
107
|
+
props: { entity_type: "other", ...props },
|
|
108
|
+
agent_id: agentId
|
|
109
|
+
});
|
|
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,
|
|
108
131
|
agent_id: agentId
|
|
109
132
|
});
|
|
110
133
|
}
|
|
@@ -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);
|
|
@@ -136,11 +188,11 @@ var MindGraph = class {
|
|
|
136
188
|
async session(req) {
|
|
137
189
|
return this.post("/memory/session", req);
|
|
138
190
|
}
|
|
139
|
-
async journal(label,
|
|
191
|
+
async journal(label, props, options) {
|
|
140
192
|
return this.post("/memory/session", {
|
|
141
193
|
action: "journal",
|
|
142
194
|
label,
|
|
143
|
-
|
|
195
|
+
props,
|
|
144
196
|
...options
|
|
145
197
|
});
|
|
146
198
|
}
|
|
@@ -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:
|
package/dist/index.mjs
CHANGED
|
@@ -66,18 +66,41 @@ 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);
|
|
74
74
|
}
|
|
75
75
|
/** Convenience: create or find an entity by label. */
|
|
76
|
-
async findOrCreateEntity(label,
|
|
76
|
+
async findOrCreateEntity(label, props, agentId) {
|
|
77
77
|
return this.post("/reality/entity", {
|
|
78
78
|
action: "create",
|
|
79
79
|
label,
|
|
80
|
-
entity_type:
|
|
80
|
+
props: { entity_type: "other", ...props },
|
|
81
|
+
agent_id: agentId
|
|
82
|
+
});
|
|
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,
|
|
81
104
|
agent_id: agentId
|
|
82
105
|
});
|
|
83
106
|
}
|
|
@@ -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);
|
|
@@ -109,11 +161,11 @@ var MindGraph = class {
|
|
|
109
161
|
async session(req) {
|
|
110
162
|
return this.post("/memory/session", req);
|
|
111
163
|
}
|
|
112
|
-
async journal(label,
|
|
164
|
+
async journal(label, props, options) {
|
|
113
165
|
return this.post("/memory/session", {
|
|
114
166
|
action: "journal",
|
|
115
167
|
label,
|
|
116
|
-
|
|
168
|
+
props,
|
|
117
169
|
...options
|
|
118
170
|
});
|
|
119
171
|
}
|
|
@@ -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"
|