mindgraph 0.1.7 → 0.1.9
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/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +45 -16
- package/dist/index.mjs +45 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -318,6 +318,16 @@ interface IngestDocumentRequest {
|
|
|
318
318
|
chunk_overlap?: number;
|
|
319
319
|
layers?: string[];
|
|
320
320
|
agent_id?: string;
|
|
321
|
+
/** Paper metadata */
|
|
322
|
+
authors?: string[];
|
|
323
|
+
abstract_text?: string;
|
|
324
|
+
doi?: string;
|
|
325
|
+
publication_date?: string;
|
|
326
|
+
journal?: string;
|
|
327
|
+
keywords?: string[];
|
|
328
|
+
citation_count?: number;
|
|
329
|
+
arxiv_id?: string;
|
|
330
|
+
language?: string;
|
|
321
331
|
}
|
|
322
332
|
interface IngestDocumentResponse {
|
|
323
333
|
job_id: string;
|
|
@@ -403,6 +413,10 @@ interface MindGraphConfig {
|
|
|
403
413
|
baseUrl: string;
|
|
404
414
|
apiKey?: string;
|
|
405
415
|
jwt?: string;
|
|
416
|
+
/** Max retries for 503 (server warming up) responses. Default: 3. Set to 0 to disable. */
|
|
417
|
+
maxRetries?: number;
|
|
418
|
+
/** Initial backoff in ms before first retry. Doubles each attempt. Default: 1000. */
|
|
419
|
+
retryBackoffMs?: number;
|
|
406
420
|
}
|
|
407
421
|
|
|
408
422
|
declare class MindGraphError extends Error {
|
|
@@ -413,6 +427,8 @@ declare class MindGraphError extends Error {
|
|
|
413
427
|
declare class MindGraph {
|
|
414
428
|
private baseUrl;
|
|
415
429
|
private headers;
|
|
430
|
+
private maxRetries;
|
|
431
|
+
private retryBackoffMs;
|
|
416
432
|
constructor(config: MindGraphConfig);
|
|
417
433
|
private request;
|
|
418
434
|
private get;
|
|
@@ -577,6 +593,10 @@ declare class MindGraph {
|
|
|
577
593
|
}): Promise<unknown>;
|
|
578
594
|
getAgentNodes(agentId: string): Promise<GraphNode[]>;
|
|
579
595
|
batch(req: BatchRequest): Promise<unknown>;
|
|
596
|
+
/** Fetch multiple nodes by UID in a single request. */
|
|
597
|
+
getNodesBatch(uids: string[]): Promise<GraphNode[]>;
|
|
598
|
+
/** Fetch all edges between a set of node UIDs. */
|
|
599
|
+
getEdgesBatch(uids: string[]): Promise<GraphEdge[]>;
|
|
580
600
|
configureEmbeddings(body: {
|
|
581
601
|
model: string;
|
|
582
602
|
dimensions: number;
|
|
@@ -639,6 +659,17 @@ declare class MindGraph {
|
|
|
639
659
|
listJobs(): Promise<Job[]>;
|
|
640
660
|
getJob(id: string): Promise<Job>;
|
|
641
661
|
cancelJob(id: string): Promise<unknown>;
|
|
662
|
+
/** Resume ingestion of a document that has failed chunks. */
|
|
663
|
+
resumeDocument(docUid: string, opts?: {
|
|
664
|
+
layers?: string[];
|
|
665
|
+
agent_id?: string;
|
|
666
|
+
}): Promise<{
|
|
667
|
+
job_id: string;
|
|
668
|
+
document_uid: string;
|
|
669
|
+
chunks_to_resume: number;
|
|
670
|
+
}>;
|
|
671
|
+
/** Delete a document and all its chunks and extracted nodes. */
|
|
672
|
+
deleteDocument(uid: string): Promise<unknown>;
|
|
642
673
|
cleanupOrphans(): Promise<unknown>;
|
|
643
674
|
embedAll(): Promise<unknown>;
|
|
644
675
|
clearGraph(): Promise<ClearResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -318,6 +318,16 @@ interface IngestDocumentRequest {
|
|
|
318
318
|
chunk_overlap?: number;
|
|
319
319
|
layers?: string[];
|
|
320
320
|
agent_id?: string;
|
|
321
|
+
/** Paper metadata */
|
|
322
|
+
authors?: string[];
|
|
323
|
+
abstract_text?: string;
|
|
324
|
+
doi?: string;
|
|
325
|
+
publication_date?: string;
|
|
326
|
+
journal?: string;
|
|
327
|
+
keywords?: string[];
|
|
328
|
+
citation_count?: number;
|
|
329
|
+
arxiv_id?: string;
|
|
330
|
+
language?: string;
|
|
321
331
|
}
|
|
322
332
|
interface IngestDocumentResponse {
|
|
323
333
|
job_id: string;
|
|
@@ -403,6 +413,10 @@ interface MindGraphConfig {
|
|
|
403
413
|
baseUrl: string;
|
|
404
414
|
apiKey?: string;
|
|
405
415
|
jwt?: string;
|
|
416
|
+
/** Max retries for 503 (server warming up) responses. Default: 3. Set to 0 to disable. */
|
|
417
|
+
maxRetries?: number;
|
|
418
|
+
/** Initial backoff in ms before first retry. Doubles each attempt. Default: 1000. */
|
|
419
|
+
retryBackoffMs?: number;
|
|
406
420
|
}
|
|
407
421
|
|
|
408
422
|
declare class MindGraphError extends Error {
|
|
@@ -413,6 +427,8 @@ declare class MindGraphError extends Error {
|
|
|
413
427
|
declare class MindGraph {
|
|
414
428
|
private baseUrl;
|
|
415
429
|
private headers;
|
|
430
|
+
private maxRetries;
|
|
431
|
+
private retryBackoffMs;
|
|
416
432
|
constructor(config: MindGraphConfig);
|
|
417
433
|
private request;
|
|
418
434
|
private get;
|
|
@@ -577,6 +593,10 @@ declare class MindGraph {
|
|
|
577
593
|
}): Promise<unknown>;
|
|
578
594
|
getAgentNodes(agentId: string): Promise<GraphNode[]>;
|
|
579
595
|
batch(req: BatchRequest): Promise<unknown>;
|
|
596
|
+
/** Fetch multiple nodes by UID in a single request. */
|
|
597
|
+
getNodesBatch(uids: string[]): Promise<GraphNode[]>;
|
|
598
|
+
/** Fetch all edges between a set of node UIDs. */
|
|
599
|
+
getEdgesBatch(uids: string[]): Promise<GraphEdge[]>;
|
|
580
600
|
configureEmbeddings(body: {
|
|
581
601
|
model: string;
|
|
582
602
|
dimensions: number;
|
|
@@ -639,6 +659,17 @@ declare class MindGraph {
|
|
|
639
659
|
listJobs(): Promise<Job[]>;
|
|
640
660
|
getJob(id: string): Promise<Job>;
|
|
641
661
|
cancelJob(id: string): Promise<unknown>;
|
|
662
|
+
/** Resume ingestion of a document that has failed chunks. */
|
|
663
|
+
resumeDocument(docUid: string, opts?: {
|
|
664
|
+
layers?: string[];
|
|
665
|
+
agent_id?: string;
|
|
666
|
+
}): Promise<{
|
|
667
|
+
job_id: string;
|
|
668
|
+
document_uid: string;
|
|
669
|
+
chunks_to_resume: number;
|
|
670
|
+
}>;
|
|
671
|
+
/** Delete a document and all its chunks and extracted nodes. */
|
|
672
|
+
deleteDocument(uid: string): Promise<unknown>;
|
|
642
673
|
cleanupOrphans(): Promise<unknown>;
|
|
643
674
|
embedAll(): Promise<unknown>;
|
|
644
675
|
clearGraph(): Promise<ClearResponse>;
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,8 @@ var MindGraph = class {
|
|
|
43
43
|
} else if (config.jwt) {
|
|
44
44
|
this.headers["Authorization"] = `Bearer ${config.jwt}`;
|
|
45
45
|
}
|
|
46
|
+
this.maxRetries = config.maxRetries ?? 3;
|
|
47
|
+
this.retryBackoffMs = config.retryBackoffMs ?? 1e3;
|
|
46
48
|
}
|
|
47
49
|
// ---- HTTP helpers ----
|
|
48
50
|
async request(method, path, body) {
|
|
@@ -54,24 +56,35 @@ var MindGraph = class {
|
|
|
54
56
|
if (body !== void 0) {
|
|
55
57
|
init.body = JSON.stringify(body);
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
parsed
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
let lastError;
|
|
60
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
61
|
+
const res = await fetch(url, init);
|
|
62
|
+
if (!res.ok) {
|
|
63
|
+
const text2 = await res.text().catch(() => "");
|
|
64
|
+
let parsed;
|
|
65
|
+
try {
|
|
66
|
+
parsed = JSON.parse(text2);
|
|
67
|
+
} catch {
|
|
68
|
+
parsed = text2;
|
|
69
|
+
}
|
|
70
|
+
const err = new MindGraphError(
|
|
71
|
+
`${method} ${path} failed: ${res.status}`,
|
|
72
|
+
res.status,
|
|
73
|
+
parsed
|
|
74
|
+
);
|
|
75
|
+
if (res.status === 503 && attempt < this.maxRetries) {
|
|
76
|
+
lastError = err;
|
|
77
|
+
const delay = this.retryBackoffMs * 2 ** attempt;
|
|
78
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
throw err;
|
|
65
82
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
parsed
|
|
70
|
-
);
|
|
83
|
+
const text = await res.text();
|
|
84
|
+
if (!text) return void 0;
|
|
85
|
+
return JSON.parse(text);
|
|
71
86
|
}
|
|
72
|
-
|
|
73
|
-
if (!text) return void 0;
|
|
74
|
-
return JSON.parse(text);
|
|
87
|
+
throw lastError;
|
|
75
88
|
}
|
|
76
89
|
get(path) {
|
|
77
90
|
return this.request("GET", path);
|
|
@@ -329,6 +342,14 @@ var MindGraph = class {
|
|
|
329
342
|
async batch(req) {
|
|
330
343
|
return this.post("/batch", req);
|
|
331
344
|
}
|
|
345
|
+
/** Fetch multiple nodes by UID in a single request. */
|
|
346
|
+
async getNodesBatch(uids) {
|
|
347
|
+
return this.post("/nodes/batch", { uids });
|
|
348
|
+
}
|
|
349
|
+
/** Fetch all edges between a set of node UIDs. */
|
|
350
|
+
async getEdgesBatch(uids) {
|
|
351
|
+
return this.post("/edges/batch", { uids });
|
|
352
|
+
}
|
|
332
353
|
// ---- Embeddings ----
|
|
333
354
|
async configureEmbeddings(body) {
|
|
334
355
|
return this.post("/embeddings/configure", body);
|
|
@@ -452,6 +473,14 @@ var MindGraph = class {
|
|
|
452
473
|
async cancelJob(id) {
|
|
453
474
|
return this.post(`/jobs/${id}/cancel`, {});
|
|
454
475
|
}
|
|
476
|
+
/** Resume ingestion of a document that has failed chunks. */
|
|
477
|
+
async resumeDocument(docUid, opts) {
|
|
478
|
+
return this.post(`/ingest/resume/${docUid}`, opts ?? {});
|
|
479
|
+
}
|
|
480
|
+
/** Delete a document and all its chunks and extracted nodes. */
|
|
481
|
+
async deleteDocument(uid) {
|
|
482
|
+
return this.del(`/ingest/document/${uid}`);
|
|
483
|
+
}
|
|
455
484
|
async cleanupOrphans() {
|
|
456
485
|
return this.post("/ingest/cleanup", {});
|
|
457
486
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -16,6 +16,8 @@ var MindGraph = class {
|
|
|
16
16
|
} else if (config.jwt) {
|
|
17
17
|
this.headers["Authorization"] = `Bearer ${config.jwt}`;
|
|
18
18
|
}
|
|
19
|
+
this.maxRetries = config.maxRetries ?? 3;
|
|
20
|
+
this.retryBackoffMs = config.retryBackoffMs ?? 1e3;
|
|
19
21
|
}
|
|
20
22
|
// ---- HTTP helpers ----
|
|
21
23
|
async request(method, path, body) {
|
|
@@ -27,24 +29,35 @@ var MindGraph = class {
|
|
|
27
29
|
if (body !== void 0) {
|
|
28
30
|
init.body = JSON.stringify(body);
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
parsed
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
let lastError;
|
|
33
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
34
|
+
const res = await fetch(url, init);
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
const text2 = await res.text().catch(() => "");
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(text2);
|
|
40
|
+
} catch {
|
|
41
|
+
parsed = text2;
|
|
42
|
+
}
|
|
43
|
+
const err = new MindGraphError(
|
|
44
|
+
`${method} ${path} failed: ${res.status}`,
|
|
45
|
+
res.status,
|
|
46
|
+
parsed
|
|
47
|
+
);
|
|
48
|
+
if (res.status === 503 && attempt < this.maxRetries) {
|
|
49
|
+
lastError = err;
|
|
50
|
+
const delay = this.retryBackoffMs * 2 ** attempt;
|
|
51
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
throw err;
|
|
38
55
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
parsed
|
|
43
|
-
);
|
|
56
|
+
const text = await res.text();
|
|
57
|
+
if (!text) return void 0;
|
|
58
|
+
return JSON.parse(text);
|
|
44
59
|
}
|
|
45
|
-
|
|
46
|
-
if (!text) return void 0;
|
|
47
|
-
return JSON.parse(text);
|
|
60
|
+
throw lastError;
|
|
48
61
|
}
|
|
49
62
|
get(path) {
|
|
50
63
|
return this.request("GET", path);
|
|
@@ -302,6 +315,14 @@ var MindGraph = class {
|
|
|
302
315
|
async batch(req) {
|
|
303
316
|
return this.post("/batch", req);
|
|
304
317
|
}
|
|
318
|
+
/** Fetch multiple nodes by UID in a single request. */
|
|
319
|
+
async getNodesBatch(uids) {
|
|
320
|
+
return this.post("/nodes/batch", { uids });
|
|
321
|
+
}
|
|
322
|
+
/** Fetch all edges between a set of node UIDs. */
|
|
323
|
+
async getEdgesBatch(uids) {
|
|
324
|
+
return this.post("/edges/batch", { uids });
|
|
325
|
+
}
|
|
305
326
|
// ---- Embeddings ----
|
|
306
327
|
async configureEmbeddings(body) {
|
|
307
328
|
return this.post("/embeddings/configure", body);
|
|
@@ -425,6 +446,14 @@ var MindGraph = class {
|
|
|
425
446
|
async cancelJob(id) {
|
|
426
447
|
return this.post(`/jobs/${id}/cancel`, {});
|
|
427
448
|
}
|
|
449
|
+
/** Resume ingestion of a document that has failed chunks. */
|
|
450
|
+
async resumeDocument(docUid, opts) {
|
|
451
|
+
return this.post(`/ingest/resume/${docUid}`, opts ?? {});
|
|
452
|
+
}
|
|
453
|
+
/** Delete a document and all its chunks and extracted nodes. */
|
|
454
|
+
async deleteDocument(uid) {
|
|
455
|
+
return this.del(`/ingest/document/${uid}`);
|
|
456
|
+
}
|
|
428
457
|
async cleanupOrphans() {
|
|
429
458
|
return this.post("/ingest/cleanup", {});
|
|
430
459
|
}
|