mindgraph 0.1.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 +153 -0
- package/dist/index.d.mts +393 -0
- package/dist/index.d.ts +393 -0
- package/dist/index.js +255 -0
- package/dist/index.mjs +227 -0
- package/package.json +21 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
interface GraphNode {
|
|
2
|
+
uid: string;
|
|
3
|
+
label: string;
|
|
4
|
+
summary: string;
|
|
5
|
+
node_type: string;
|
|
6
|
+
layer: string;
|
|
7
|
+
confidence: number;
|
|
8
|
+
salience: number;
|
|
9
|
+
props: Record<string, unknown>;
|
|
10
|
+
created_at: number;
|
|
11
|
+
updated_at: number;
|
|
12
|
+
tombstone_at: number | null;
|
|
13
|
+
}
|
|
14
|
+
interface GraphEdge {
|
|
15
|
+
uid: string;
|
|
16
|
+
from_uid: string;
|
|
17
|
+
to_uid: string;
|
|
18
|
+
edge_type: string;
|
|
19
|
+
layer: string;
|
|
20
|
+
weight: number;
|
|
21
|
+
props: Record<string, unknown>;
|
|
22
|
+
created_at: number;
|
|
23
|
+
updated_at: number;
|
|
24
|
+
tombstone_at: number | null;
|
|
25
|
+
}
|
|
26
|
+
interface SearchResult {
|
|
27
|
+
uid: string;
|
|
28
|
+
label: string;
|
|
29
|
+
summary: string;
|
|
30
|
+
node_type: string;
|
|
31
|
+
score: number;
|
|
32
|
+
}
|
|
33
|
+
interface PathStep {
|
|
34
|
+
uid: string;
|
|
35
|
+
label: string;
|
|
36
|
+
node_type: string;
|
|
37
|
+
edge_type: string | null;
|
|
38
|
+
depth: number;
|
|
39
|
+
parent_uid: string | null;
|
|
40
|
+
}
|
|
41
|
+
interface IngestRequest {
|
|
42
|
+
action: "source" | "snippet" | "observation";
|
|
43
|
+
label: string;
|
|
44
|
+
content: string;
|
|
45
|
+
source_uid?: string;
|
|
46
|
+
medium?: string;
|
|
47
|
+
url?: string;
|
|
48
|
+
timestamp?: number;
|
|
49
|
+
confidence?: number;
|
|
50
|
+
salience?: number;
|
|
51
|
+
agent_id?: string;
|
|
52
|
+
}
|
|
53
|
+
interface EntityRequest {
|
|
54
|
+
action: "create" | "alias" | "resolve" | "fuzzy_resolve" | "merge" | "relate";
|
|
55
|
+
label?: string;
|
|
56
|
+
entity_type?: string;
|
|
57
|
+
text?: string;
|
|
58
|
+
canonical_uid?: string;
|
|
59
|
+
alias_score?: number;
|
|
60
|
+
keep_uid?: string;
|
|
61
|
+
merge_uid?: string;
|
|
62
|
+
limit?: number;
|
|
63
|
+
source_uid?: string;
|
|
64
|
+
target_uid?: string;
|
|
65
|
+
edge_type?: string;
|
|
66
|
+
agent_id?: string;
|
|
67
|
+
}
|
|
68
|
+
interface ArgumentRequest {
|
|
69
|
+
claim: {
|
|
70
|
+
label: string;
|
|
71
|
+
content: string;
|
|
72
|
+
confidence?: number;
|
|
73
|
+
};
|
|
74
|
+
evidence?: {
|
|
75
|
+
label: string;
|
|
76
|
+
description: string;
|
|
77
|
+
evidence_type?: string;
|
|
78
|
+
}[];
|
|
79
|
+
warrant?: {
|
|
80
|
+
label: string;
|
|
81
|
+
principle: string;
|
|
82
|
+
};
|
|
83
|
+
argument?: {
|
|
84
|
+
label: string;
|
|
85
|
+
summary: string;
|
|
86
|
+
};
|
|
87
|
+
refutes_uid?: string;
|
|
88
|
+
extends_uid?: string;
|
|
89
|
+
source_uids?: string[];
|
|
90
|
+
agent_id?: string;
|
|
91
|
+
}
|
|
92
|
+
interface InquiryRequest {
|
|
93
|
+
action: "hypothesis" | "theory" | "paradigm" | "anomaly" | "assumption" | "question" | "open_question";
|
|
94
|
+
label: string;
|
|
95
|
+
content: string;
|
|
96
|
+
status?: string;
|
|
97
|
+
anomalous_to_uid?: string;
|
|
98
|
+
assumes_uid?: string[];
|
|
99
|
+
tests_uid?: string;
|
|
100
|
+
addresses_uid?: string;
|
|
101
|
+
confidence?: number;
|
|
102
|
+
salience?: number;
|
|
103
|
+
related_uids?: string[];
|
|
104
|
+
agent_id?: string;
|
|
105
|
+
}
|
|
106
|
+
interface StructureRequest {
|
|
107
|
+
action: "concept" | "pattern" | "mechanism" | "model" | "model_evaluation" | "analogy" | "inference_chain" | "reasoning_strategy" | "sensitivity_analysis" | "theorem" | "equation";
|
|
108
|
+
label: string;
|
|
109
|
+
content: string;
|
|
110
|
+
summary?: string;
|
|
111
|
+
analogous_to_uid?: string;
|
|
112
|
+
transfers_to_uid?: string[];
|
|
113
|
+
evaluates_uid?: string;
|
|
114
|
+
outperforms_uid?: string;
|
|
115
|
+
chain_steps?: string[];
|
|
116
|
+
derived_from_uid?: string[];
|
|
117
|
+
proven_by_uid?: string;
|
|
118
|
+
related_uids?: string[];
|
|
119
|
+
confidence?: number;
|
|
120
|
+
agent_id?: string;
|
|
121
|
+
}
|
|
122
|
+
interface CommitmentRequest {
|
|
123
|
+
action: "goal" | "project" | "milestone";
|
|
124
|
+
label: string;
|
|
125
|
+
description: string;
|
|
126
|
+
priority?: string;
|
|
127
|
+
status?: string;
|
|
128
|
+
parent_uid?: string;
|
|
129
|
+
due_date?: number;
|
|
130
|
+
motivated_by_uid?: string[];
|
|
131
|
+
agent_id?: string;
|
|
132
|
+
}
|
|
133
|
+
interface DeliberationRequest {
|
|
134
|
+
action: "open_decision" | "add_option" | "add_constraint" | "resolve" | "get_open";
|
|
135
|
+
label?: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
decision_uid?: string;
|
|
138
|
+
chosen_option_uid?: string;
|
|
139
|
+
resolution_rationale?: string;
|
|
140
|
+
constraint_type?: string;
|
|
141
|
+
blocks_uid?: string;
|
|
142
|
+
informs_uid?: string[];
|
|
143
|
+
agent_id?: string;
|
|
144
|
+
}
|
|
145
|
+
interface ProcedureRequest {
|
|
146
|
+
action: "create_flow" | "add_step" | "add_affordance" | "add_control";
|
|
147
|
+
label: string;
|
|
148
|
+
description?: string;
|
|
149
|
+
flow_uid?: string;
|
|
150
|
+
step_order?: number;
|
|
151
|
+
previous_step_uid?: string;
|
|
152
|
+
affordance_type?: string;
|
|
153
|
+
control_type?: string;
|
|
154
|
+
uses_affordance_uids?: string[];
|
|
155
|
+
goal_uid?: string;
|
|
156
|
+
agent_id?: string;
|
|
157
|
+
}
|
|
158
|
+
interface RiskRequest {
|
|
159
|
+
action: "assess" | "get_assessments";
|
|
160
|
+
label?: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
assessed_uid?: string;
|
|
163
|
+
severity?: string;
|
|
164
|
+
likelihood?: number;
|
|
165
|
+
mitigations?: string[];
|
|
166
|
+
residual_risk?: number;
|
|
167
|
+
filter_uid?: string;
|
|
168
|
+
agent_id?: string;
|
|
169
|
+
}
|
|
170
|
+
interface SessionRequest {
|
|
171
|
+
action: "open" | "trace" | "close";
|
|
172
|
+
label?: string;
|
|
173
|
+
focus?: string;
|
|
174
|
+
session_uid?: string;
|
|
175
|
+
trace_content?: string;
|
|
176
|
+
trace_type?: string;
|
|
177
|
+
relevant_node_uids?: string[];
|
|
178
|
+
agent_id?: string;
|
|
179
|
+
}
|
|
180
|
+
interface DistillRequest {
|
|
181
|
+
label: string;
|
|
182
|
+
content: string;
|
|
183
|
+
summarizes_uids?: string[];
|
|
184
|
+
session_uid?: string;
|
|
185
|
+
importance?: number;
|
|
186
|
+
agent_id?: string;
|
|
187
|
+
}
|
|
188
|
+
interface MemoryConfigRequest {
|
|
189
|
+
action: "set_preference" | "get_preferences" | "set_policy" | "get_policies";
|
|
190
|
+
label?: string;
|
|
191
|
+
key?: string;
|
|
192
|
+
value?: string;
|
|
193
|
+
policy_content?: string;
|
|
194
|
+
agent_id?: string;
|
|
195
|
+
}
|
|
196
|
+
interface PlanRequest {
|
|
197
|
+
action: "create_task" | "create_plan" | "add_step" | "update_status" | "get_plan";
|
|
198
|
+
label?: string;
|
|
199
|
+
description?: string;
|
|
200
|
+
goal_uid?: string;
|
|
201
|
+
task_uid?: string;
|
|
202
|
+
plan_uid?: string;
|
|
203
|
+
step_order?: number;
|
|
204
|
+
depends_on_uids?: string[];
|
|
205
|
+
target_uid?: string;
|
|
206
|
+
status?: string;
|
|
207
|
+
related_uids?: string[];
|
|
208
|
+
agent_id?: string;
|
|
209
|
+
}
|
|
210
|
+
interface GovernanceRequest {
|
|
211
|
+
action: "create_policy" | "set_budget" | "request_approval" | "resolve_approval" | "get_pending";
|
|
212
|
+
label?: string;
|
|
213
|
+
policy_content?: string;
|
|
214
|
+
budget_type?: string;
|
|
215
|
+
budget_limit?: number;
|
|
216
|
+
governed_uid?: string;
|
|
217
|
+
approval_uid?: string;
|
|
218
|
+
approved?: boolean;
|
|
219
|
+
resolution_note?: string;
|
|
220
|
+
requires_plan_uid?: string;
|
|
221
|
+
approval_request?: string;
|
|
222
|
+
agent_id?: string;
|
|
223
|
+
}
|
|
224
|
+
interface ExecutionRequest {
|
|
225
|
+
action: "start" | "complete" | "fail" | "register_agent" | "get_executions";
|
|
226
|
+
label?: string;
|
|
227
|
+
plan_uid?: string;
|
|
228
|
+
executor_uid?: string;
|
|
229
|
+
execution_uid?: string;
|
|
230
|
+
outcome?: string;
|
|
231
|
+
produces_node_uid?: string;
|
|
232
|
+
error_description?: string;
|
|
233
|
+
agent_name?: string;
|
|
234
|
+
agent_role?: string;
|
|
235
|
+
filter_plan_uid?: string;
|
|
236
|
+
related_uids?: string[];
|
|
237
|
+
agent_id?: string;
|
|
238
|
+
}
|
|
239
|
+
interface RetrieveRequest {
|
|
240
|
+
action: "text" | "semantic" | "hybrid" | "active_goals" | "open_questions" | "weak_claims" | "pending_approvals" | "unresolved_contradictions" | "layer" | "recent";
|
|
241
|
+
query?: string;
|
|
242
|
+
k?: number;
|
|
243
|
+
threshold?: number;
|
|
244
|
+
layer?: string;
|
|
245
|
+
node_types?: string[];
|
|
246
|
+
confidence_min?: number;
|
|
247
|
+
salience_min?: number;
|
|
248
|
+
limit?: number;
|
|
249
|
+
offset?: number;
|
|
250
|
+
}
|
|
251
|
+
interface TraverseRequest {
|
|
252
|
+
action: "chain" | "neighborhood" | "path" | "subgraph";
|
|
253
|
+
start_uid: string;
|
|
254
|
+
end_uid?: string;
|
|
255
|
+
max_depth?: number;
|
|
256
|
+
direction?: "outgoing" | "incoming" | "both";
|
|
257
|
+
edge_types?: string[];
|
|
258
|
+
weight_threshold?: number;
|
|
259
|
+
}
|
|
260
|
+
interface EvolveRequest {
|
|
261
|
+
action: "update" | "tombstone" | "restore" | "decay" | "history" | "snapshot" | "tombstone_edge" | "restore_edge" | "tombstone_cascade";
|
|
262
|
+
uid: string;
|
|
263
|
+
label?: string;
|
|
264
|
+
summary?: string;
|
|
265
|
+
confidence?: number;
|
|
266
|
+
salience?: number;
|
|
267
|
+
props_patch?: Record<string, unknown>;
|
|
268
|
+
reason?: string;
|
|
269
|
+
cascade?: boolean;
|
|
270
|
+
half_life_secs?: number;
|
|
271
|
+
min_salience?: number;
|
|
272
|
+
min_age_secs?: number;
|
|
273
|
+
version?: number;
|
|
274
|
+
agent_id?: string;
|
|
275
|
+
}
|
|
276
|
+
interface SignupRequest {
|
|
277
|
+
email: string;
|
|
278
|
+
password: string;
|
|
279
|
+
}
|
|
280
|
+
interface LoginRequest {
|
|
281
|
+
email: string;
|
|
282
|
+
password: string;
|
|
283
|
+
}
|
|
284
|
+
interface CreateOrgRequest {
|
|
285
|
+
name: string;
|
|
286
|
+
slug?: string;
|
|
287
|
+
}
|
|
288
|
+
interface CreateApiKeyRequest {
|
|
289
|
+
name?: string;
|
|
290
|
+
}
|
|
291
|
+
interface ApiKeyResponse {
|
|
292
|
+
id: string;
|
|
293
|
+
key: string;
|
|
294
|
+
name: string;
|
|
295
|
+
prefix: string;
|
|
296
|
+
}
|
|
297
|
+
interface MindGraphConfig {
|
|
298
|
+
baseUrl: string;
|
|
299
|
+
apiKey?: string;
|
|
300
|
+
jwt?: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
declare class MindGraphError extends Error {
|
|
304
|
+
status: number;
|
|
305
|
+
body?: unknown | undefined;
|
|
306
|
+
constructor(message: string, status: number, body?: unknown | undefined);
|
|
307
|
+
}
|
|
308
|
+
declare class MindGraph {
|
|
309
|
+
private baseUrl;
|
|
310
|
+
private headers;
|
|
311
|
+
constructor(config: MindGraphConfig);
|
|
312
|
+
private request;
|
|
313
|
+
private get;
|
|
314
|
+
private post;
|
|
315
|
+
private patch;
|
|
316
|
+
private del;
|
|
317
|
+
health(): Promise<{
|
|
318
|
+
status: string;
|
|
319
|
+
}>;
|
|
320
|
+
stats(): Promise<Record<string, unknown>>;
|
|
321
|
+
ingest(req: IngestRequest): Promise<unknown>;
|
|
322
|
+
entity(req: EntityRequest): Promise<unknown>;
|
|
323
|
+
/** Convenience: create or find an entity by label. */
|
|
324
|
+
findOrCreateEntity(label: string, entityType?: string, agentId?: string): Promise<GraphNode & {
|
|
325
|
+
created: boolean;
|
|
326
|
+
}>;
|
|
327
|
+
argue(req: ArgumentRequest): Promise<unknown>;
|
|
328
|
+
inquire(req: InquiryRequest): Promise<unknown>;
|
|
329
|
+
structure(req: StructureRequest): Promise<unknown>;
|
|
330
|
+
commit(req: CommitmentRequest): Promise<unknown>;
|
|
331
|
+
deliberate(req: DeliberationRequest): Promise<unknown>;
|
|
332
|
+
procedure(req: ProcedureRequest): Promise<unknown>;
|
|
333
|
+
risk(req: RiskRequest): Promise<unknown>;
|
|
334
|
+
session(req: SessionRequest): Promise<unknown>;
|
|
335
|
+
distill(req: DistillRequest): Promise<unknown>;
|
|
336
|
+
memoryConfig(req: MemoryConfigRequest): Promise<unknown>;
|
|
337
|
+
plan(req: PlanRequest): Promise<unknown>;
|
|
338
|
+
governance(req: GovernanceRequest): Promise<unknown>;
|
|
339
|
+
execution(req: ExecutionRequest): Promise<unknown>;
|
|
340
|
+
retrieve(req: RetrieveRequest): Promise<unknown>;
|
|
341
|
+
traverse(req: TraverseRequest): Promise<unknown>;
|
|
342
|
+
evolve(req: EvolveRequest): Promise<unknown>;
|
|
343
|
+
getNode(uid: string): Promise<GraphNode>;
|
|
344
|
+
addNode(body: {
|
|
345
|
+
label: string;
|
|
346
|
+
node_type?: string;
|
|
347
|
+
props?: Record<string, unknown>;
|
|
348
|
+
agent_id?: string;
|
|
349
|
+
}): Promise<GraphNode>;
|
|
350
|
+
updateNode(uid: string, body: {
|
|
351
|
+
label?: string;
|
|
352
|
+
summary?: string;
|
|
353
|
+
confidence?: number;
|
|
354
|
+
salience?: number;
|
|
355
|
+
agent_id?: string;
|
|
356
|
+
}): Promise<GraphNode>;
|
|
357
|
+
deleteNode(uid: string): Promise<void>;
|
|
358
|
+
addLink(body: {
|
|
359
|
+
from_uid: string;
|
|
360
|
+
to_uid: string;
|
|
361
|
+
edge_type: string;
|
|
362
|
+
agent_id?: string;
|
|
363
|
+
}): Promise<unknown>;
|
|
364
|
+
getEdges(params: {
|
|
365
|
+
from_uid?: string;
|
|
366
|
+
to_uid?: string;
|
|
367
|
+
}): Promise<GraphEdge[]>;
|
|
368
|
+
search(query: string, opts?: {
|
|
369
|
+
node_type?: string;
|
|
370
|
+
layer?: string;
|
|
371
|
+
limit?: number;
|
|
372
|
+
}): Promise<SearchResult[]>;
|
|
373
|
+
/** Hybrid BM25 + vector search with reciprocal rank fusion. */
|
|
374
|
+
hybridSearch(query: string, opts?: {
|
|
375
|
+
k?: number;
|
|
376
|
+
node_types?: string[];
|
|
377
|
+
layer?: string;
|
|
378
|
+
}): Promise<SearchResult[]>;
|
|
379
|
+
reasoningChain(uid: string, maxDepth?: number): Promise<PathStep[]>;
|
|
380
|
+
neighborhood(uid: string, maxDepth?: number): Promise<PathStep[]>;
|
|
381
|
+
tombstone(uid: string, reason?: string, agentId?: string): Promise<unknown>;
|
|
382
|
+
restore(uid: string, agentId?: string): Promise<unknown>;
|
|
383
|
+
signup(email: string, password: string): Promise<unknown>;
|
|
384
|
+
login(email: string, password: string): Promise<unknown>;
|
|
385
|
+
createApiKey(name?: string): Promise<ApiKeyResponse>;
|
|
386
|
+
listApiKeys(): Promise<{
|
|
387
|
+
api_keys: unknown[];
|
|
388
|
+
}>;
|
|
389
|
+
revokeApiKey(id: string): Promise<void>;
|
|
390
|
+
getUsage(): Promise<unknown>;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export { type ApiKeyResponse, type ArgumentRequest, type CommitmentRequest, type CreateApiKeyRequest, type CreateOrgRequest, type DeliberationRequest, type DistillRequest, type EntityRequest, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestRequest, type InquiryRequest, type LoginRequest, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type PathStep, type PlanRequest, type ProcedureRequest, type RetrieveRequest, type RiskRequest, type SearchResult, type SessionRequest, type SignupRequest, type StructureRequest, type TraverseRequest };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MindGraph: () => MindGraph,
|
|
24
|
+
MindGraphError: () => MindGraphError
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/client.ts
|
|
29
|
+
var MindGraphError = class extends Error {
|
|
30
|
+
constructor(message, status, body) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.status = status;
|
|
33
|
+
this.body = body;
|
|
34
|
+
this.name = "MindGraphError";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var MindGraph = class {
|
|
38
|
+
constructor(config) {
|
|
39
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
40
|
+
this.headers = { "Content-Type": "application/json" };
|
|
41
|
+
if (config.apiKey) {
|
|
42
|
+
this.headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
43
|
+
} else if (config.jwt) {
|
|
44
|
+
this.headers["Authorization"] = `Bearer ${config.jwt}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// ---- HTTP helpers ----
|
|
48
|
+
async request(method, path, body) {
|
|
49
|
+
const url = `${this.baseUrl}${path}`;
|
|
50
|
+
const init = {
|
|
51
|
+
method,
|
|
52
|
+
headers: this.headers
|
|
53
|
+
};
|
|
54
|
+
if (body !== void 0) {
|
|
55
|
+
init.body = JSON.stringify(body);
|
|
56
|
+
}
|
|
57
|
+
const res = await fetch(url, init);
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
const text2 = await res.text().catch(() => "");
|
|
60
|
+
let parsed;
|
|
61
|
+
try {
|
|
62
|
+
parsed = JSON.parse(text2);
|
|
63
|
+
} catch {
|
|
64
|
+
parsed = text2;
|
|
65
|
+
}
|
|
66
|
+
throw new MindGraphError(
|
|
67
|
+
`${method} ${path} failed: ${res.status}`,
|
|
68
|
+
res.status,
|
|
69
|
+
parsed
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const text = await res.text();
|
|
73
|
+
if (!text) return void 0;
|
|
74
|
+
return JSON.parse(text);
|
|
75
|
+
}
|
|
76
|
+
get(path) {
|
|
77
|
+
return this.request("GET", path);
|
|
78
|
+
}
|
|
79
|
+
post(path, body) {
|
|
80
|
+
return this.request("POST", path, body);
|
|
81
|
+
}
|
|
82
|
+
patch(path, body) {
|
|
83
|
+
return this.request("PATCH", path, body);
|
|
84
|
+
}
|
|
85
|
+
del(path) {
|
|
86
|
+
return this.request("DELETE", path);
|
|
87
|
+
}
|
|
88
|
+
// ---- Health ----
|
|
89
|
+
async health() {
|
|
90
|
+
return this.get("/health");
|
|
91
|
+
}
|
|
92
|
+
async stats() {
|
|
93
|
+
return this.get("/stats");
|
|
94
|
+
}
|
|
95
|
+
// ---- Reality Layer ----
|
|
96
|
+
async ingest(req) {
|
|
97
|
+
return this.post("/reality/ingest", req);
|
|
98
|
+
}
|
|
99
|
+
async entity(req) {
|
|
100
|
+
return this.post("/reality/entity", req);
|
|
101
|
+
}
|
|
102
|
+
/** Convenience: create or find an entity by label. */
|
|
103
|
+
async findOrCreateEntity(label, entityType = "other", agentId) {
|
|
104
|
+
return this.post("/reality/entity", {
|
|
105
|
+
action: "create",
|
|
106
|
+
label,
|
|
107
|
+
entity_type: entityType,
|
|
108
|
+
agent_id: agentId
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// ---- Epistemic Layer ----
|
|
112
|
+
async argue(req) {
|
|
113
|
+
return this.post("/epistemic/argument", req);
|
|
114
|
+
}
|
|
115
|
+
async inquire(req) {
|
|
116
|
+
return this.post("/epistemic/inquiry", req);
|
|
117
|
+
}
|
|
118
|
+
async structure(req) {
|
|
119
|
+
return this.post("/epistemic/structure", req);
|
|
120
|
+
}
|
|
121
|
+
// ---- Intent Layer ----
|
|
122
|
+
async commit(req) {
|
|
123
|
+
return this.post("/intent/commitment", req);
|
|
124
|
+
}
|
|
125
|
+
async deliberate(req) {
|
|
126
|
+
return this.post("/intent/deliberation", req);
|
|
127
|
+
}
|
|
128
|
+
// ---- Action Layer ----
|
|
129
|
+
async procedure(req) {
|
|
130
|
+
return this.post("/action/procedure", req);
|
|
131
|
+
}
|
|
132
|
+
async risk(req) {
|
|
133
|
+
return this.post("/action/risk", req);
|
|
134
|
+
}
|
|
135
|
+
// ---- Memory Layer ----
|
|
136
|
+
async session(req) {
|
|
137
|
+
return this.post("/memory/session", req);
|
|
138
|
+
}
|
|
139
|
+
async distill(req) {
|
|
140
|
+
return this.post("/memory/distill", req);
|
|
141
|
+
}
|
|
142
|
+
async memoryConfig(req) {
|
|
143
|
+
return this.post("/memory/config", req);
|
|
144
|
+
}
|
|
145
|
+
// ---- Agent Layer ----
|
|
146
|
+
async plan(req) {
|
|
147
|
+
return this.post("/agent/plan", req);
|
|
148
|
+
}
|
|
149
|
+
async governance(req) {
|
|
150
|
+
return this.post("/agent/governance", req);
|
|
151
|
+
}
|
|
152
|
+
async execution(req) {
|
|
153
|
+
return this.post("/agent/execution", req);
|
|
154
|
+
}
|
|
155
|
+
// ---- Cross-cutting ----
|
|
156
|
+
async retrieve(req) {
|
|
157
|
+
return this.post("/retrieve", req);
|
|
158
|
+
}
|
|
159
|
+
async traverse(req) {
|
|
160
|
+
return this.post("/traverse", req);
|
|
161
|
+
}
|
|
162
|
+
async evolve(req) {
|
|
163
|
+
return this.post("/evolve", req);
|
|
164
|
+
}
|
|
165
|
+
// ---- Node CRUD ----
|
|
166
|
+
async getNode(uid) {
|
|
167
|
+
return this.get(`/node/${uid}`);
|
|
168
|
+
}
|
|
169
|
+
async addNode(body) {
|
|
170
|
+
return this.post("/node", body);
|
|
171
|
+
}
|
|
172
|
+
async updateNode(uid, body) {
|
|
173
|
+
return this.patch(`/node/${uid}`, body);
|
|
174
|
+
}
|
|
175
|
+
async deleteNode(uid) {
|
|
176
|
+
await this.del(`/node/${uid}`);
|
|
177
|
+
}
|
|
178
|
+
// ---- Edge CRUD ----
|
|
179
|
+
async addLink(body) {
|
|
180
|
+
return this.post("/link", body);
|
|
181
|
+
}
|
|
182
|
+
async getEdges(params) {
|
|
183
|
+
const qs = new URLSearchParams();
|
|
184
|
+
if (params.from_uid) qs.set("from_uid", params.from_uid);
|
|
185
|
+
if (params.to_uid) qs.set("to_uid", params.to_uid);
|
|
186
|
+
return this.get(`/edges?${qs}`);
|
|
187
|
+
}
|
|
188
|
+
// ---- Search ----
|
|
189
|
+
async search(query, opts) {
|
|
190
|
+
return this.post("/search", { query, ...opts });
|
|
191
|
+
}
|
|
192
|
+
/** Hybrid BM25 + vector search with reciprocal rank fusion. */
|
|
193
|
+
async hybridSearch(query, opts) {
|
|
194
|
+
return this.post("/retrieve", {
|
|
195
|
+
action: "hybrid",
|
|
196
|
+
query,
|
|
197
|
+
...opts
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
// ---- Traversal shortcuts ----
|
|
201
|
+
async reasoningChain(uid, maxDepth = 5) {
|
|
202
|
+
return this.post("/traverse", {
|
|
203
|
+
action: "chain",
|
|
204
|
+
start_uid: uid,
|
|
205
|
+
max_depth: maxDepth
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async neighborhood(uid, maxDepth = 1) {
|
|
209
|
+
return this.post("/traverse", {
|
|
210
|
+
action: "neighborhood",
|
|
211
|
+
start_uid: uid,
|
|
212
|
+
max_depth: maxDepth
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// ---- Lifecycle shortcuts ----
|
|
216
|
+
async tombstone(uid, reason, agentId) {
|
|
217
|
+
return this.post("/evolve", {
|
|
218
|
+
action: "tombstone",
|
|
219
|
+
uid,
|
|
220
|
+
reason,
|
|
221
|
+
agent_id: agentId
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async restore(uid, agentId) {
|
|
225
|
+
return this.post("/evolve", {
|
|
226
|
+
action: "restore",
|
|
227
|
+
uid,
|
|
228
|
+
agent_id: agentId
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
// ---- Management (Cloud only) ----
|
|
232
|
+
async signup(email, password) {
|
|
233
|
+
return this.post("/v1/auth/signup", { email, password });
|
|
234
|
+
}
|
|
235
|
+
async login(email, password) {
|
|
236
|
+
return this.post("/v1/auth/login", { email, password });
|
|
237
|
+
}
|
|
238
|
+
async createApiKey(name = "default") {
|
|
239
|
+
return this.post("/v1/api-keys", { name });
|
|
240
|
+
}
|
|
241
|
+
async listApiKeys() {
|
|
242
|
+
return this.get("/v1/api-keys");
|
|
243
|
+
}
|
|
244
|
+
async revokeApiKey(id) {
|
|
245
|
+
await this.del(`/v1/api-keys/${id}`);
|
|
246
|
+
}
|
|
247
|
+
async getUsage() {
|
|
248
|
+
return this.get("/v1/usage");
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
252
|
+
0 && (module.exports = {
|
|
253
|
+
MindGraph,
|
|
254
|
+
MindGraphError
|
|
255
|
+
});
|