mindgraph 0.13.0 → 0.15.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/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
1
  // src/client.ts
2
+ function seg(value) {
3
+ return encodeURIComponent(String(value));
4
+ }
2
5
  var MindGraphError = class extends Error {
3
6
  constructor(message, status, body) {
4
7
  super(message);
@@ -56,7 +59,8 @@ var MindGraph = class {
56
59
  );
57
60
  if (res.status === 503 && attempt < this.maxRetries) {
58
61
  lastError = err;
59
- const delay = this.retryBackoffMs * 2 ** attempt;
62
+ const retryAfterSecs = Number(res.headers.get("retry-after"));
63
+ const delay = Number.isFinite(retryAfterSecs) && retryAfterSecs > 0 ? Math.min(retryAfterSecs * 1e3, 1e4) : this.retryBackoffMs * 2 ** attempt;
60
64
  await new Promise((r) => setTimeout(r, delay));
61
65
  continue;
62
66
  }
@@ -107,6 +111,52 @@ var MindGraph = class {
107
111
  async entity(req) {
108
112
  return this.post("/reality/entity", req);
109
113
  }
114
+ async series(req) {
115
+ return this.post("/reality/series", req);
116
+ }
117
+ async createSeries(req) {
118
+ return this.post("/reality/series", { action: "create", ...req });
119
+ }
120
+ async appendSeries(req) {
121
+ return this.post("/reality/series", { action: "append", ...req });
122
+ }
123
+ async seriesWindow(req) {
124
+ return this.post("/reality/series", { action: "window", ...req });
125
+ }
126
+ async aggregateSeries(req) {
127
+ return this.post("/reality/series", { action: "aggregate", ...req });
128
+ }
129
+ async latestSeries(seriesUid, options) {
130
+ return this.post("/reality/series", {
131
+ action: "latest",
132
+ series_uid: seriesUid,
133
+ ...options
134
+ });
135
+ }
136
+ async listSeriesForEntity(entityUid, options) {
137
+ return this.post("/reality/series", {
138
+ action: "list_for_entity",
139
+ entity_uid: entityUid,
140
+ ...options
141
+ });
142
+ }
143
+ async batchLatestSeries(entityUids, options) {
144
+ return this.post("/reality/series", {
145
+ action: "batch_latest",
146
+ entity_uids: entityUids,
147
+ ...options
148
+ });
149
+ }
150
+ async batchAggregateSeries(req) {
151
+ return this.post("/reality/series", { action: "batch_aggregate", ...req });
152
+ }
153
+ async deleteSeries(seriesUid, options) {
154
+ return this.post("/reality/series", {
155
+ action: "delete_series",
156
+ series_uid: seriesUid,
157
+ ...options
158
+ });
159
+ }
110
160
  /** Convenience: create or find an entity by label. */
111
161
  async findOrCreateEntity(label, props, agentId) {
112
162
  return this.post("/reality/entity", {
@@ -268,6 +318,9 @@ var MindGraph = class {
268
318
  async memoryConfig(req) {
269
319
  return this.post("/memory/config", req);
270
320
  }
321
+ async memorySync(req) {
322
+ return this.post("/memory/sync", req);
323
+ }
271
324
  // ---- Agent Layer ----
272
325
  async plan(req) {
273
326
  return this.post("/agent/plan", req);
@@ -291,7 +344,7 @@ var MindGraph = class {
291
344
  }
292
345
  // ---- Node CRUD ----
293
346
  async getNode(uid) {
294
- return this.get(`/node/${uid}`);
347
+ return this.get(`/node/${seg(uid)}`);
295
348
  }
296
349
  /**
297
350
  * Create a node via the low-level CRUD endpoint.
@@ -308,10 +361,10 @@ var MindGraph = class {
308
361
  return this.post("/node", { ...body, props });
309
362
  }
310
363
  async updateNode(uid, body) {
311
- return this.patch(`/node/${uid}`, body);
364
+ return this.patch(`/node/${seg(uid)}`, body);
312
365
  }
313
366
  async deleteNode(uid) {
314
- await this.del(`/node/${uid}`);
367
+ await this.del(`/node/${seg(uid)}`);
315
368
  }
316
369
  async batchDeleteNodes(params) {
317
370
  const body = {};
@@ -332,10 +385,10 @@ var MindGraph = class {
332
385
  return this.post("/nodes/delete", body);
333
386
  }
334
387
  async getNodeHistory(uid) {
335
- return this.get(`/node/${uid}/history`);
388
+ return this.get(`/node/${seg(uid)}/history`);
336
389
  }
337
390
  async getNodeAtVersion(uid, version) {
338
- return this.get(`/node/${uid}/history/${version}`);
391
+ return this.get(`/node/${seg(uid)}/history/${seg(version)}`);
339
392
  }
340
393
  // ---- Edge CRUD ----
341
394
  async addLink(body) {
@@ -356,13 +409,13 @@ var MindGraph = class {
356
409
  return this.post("/edge", { ...body, props });
357
410
  }
358
411
  async updateEdge(uid, body) {
359
- return this.patch(`/edge/${uid}`, body);
412
+ return this.patch(`/edge/${seg(uid)}`, body);
360
413
  }
361
414
  async deleteEdge(uid) {
362
- await this.del(`/edge/${uid}`);
415
+ await this.del(`/edge/${seg(uid)}`);
363
416
  }
364
417
  async getEdgeHistory(uid) {
365
- return this.get(`/edge/${uid}/history`);
418
+ return this.get(`/edge/${seg(uid)}/history`);
366
419
  }
367
420
  /**
368
421
  * List edges filtered by source and/or target node.
@@ -411,7 +464,7 @@ var MindGraph = class {
411
464
  return this.get(`/nodes?${qs}`);
412
465
  }
413
466
  async getAgentNodes(agentId) {
414
- return this.get(`/agent/${agentId}/nodes`);
467
+ return this.get(`/agent/${seg(agentId)}/nodes`);
415
468
  }
416
469
  // ---- Batch ----
417
470
  async batch(req) {
@@ -436,13 +489,13 @@ var MindGraph = class {
436
489
  return this.post("/embeddings/search-text", body);
437
490
  }
438
491
  async getEmbedding(uid) {
439
- return this.get(`/node/${uid}/embedding`);
492
+ return this.get(`/node/${seg(uid)}/embedding`);
440
493
  }
441
494
  async setEmbedding(uid, vector) {
442
- await this.request("PUT", `/node/${uid}/embedding`, { vector });
495
+ await this.request("PUT", `/node/${seg(uid)}/embedding`, { vector });
443
496
  }
444
497
  async deleteEmbedding(uid) {
445
- await this.del(`/node/${uid}/embedding`);
498
+ await this.del(`/node/${seg(uid)}/embedding`);
446
499
  }
447
500
  // ---- Entity resolution ----
448
501
  async mergeEntities(body) {
@@ -452,7 +505,7 @@ var MindGraph = class {
452
505
  return this.post("/alias", body);
453
506
  }
454
507
  async getAliases(uid) {
455
- return this.get(`/aliases/${uid}`);
508
+ return this.get(`/aliases/${seg(uid)}`);
456
509
  }
457
510
  async resolveAlias(text) {
458
511
  return this.get(`/resolve?text=${encodeURIComponent(text)}`);
@@ -575,18 +628,18 @@ var MindGraph = class {
575
628
  return this.get("/jobs");
576
629
  }
577
630
  async getJob(id) {
578
- return this.get(`/jobs/${id}`);
631
+ return this.get(`/jobs/${seg(id)}`);
579
632
  }
580
633
  async cancelJob(id) {
581
- return this.post(`/jobs/${id}/cancel`, {});
634
+ return this.post(`/jobs/${seg(id)}/cancel`, {});
582
635
  }
583
636
  /** Resume ingestion of a document that has failed chunks. */
584
637
  async resumeDocument(docUid, opts) {
585
- return this.post(`/ingest/resume/${docUid}`, opts ?? {});
638
+ return this.post(`/ingest/resume/${seg(docUid)}`, opts ?? {});
586
639
  }
587
640
  /** Delete a document and all its chunks and extracted nodes. */
588
641
  async deleteDocument(uid) {
589
- return this.del(`/ingest/document/${uid}`);
642
+ return this.del(`/ingest/document/${seg(uid)}`);
590
643
  }
591
644
  async cleanupOrphans() {
592
645
  return this.post("/ingest/cleanup", {});
@@ -610,27 +663,27 @@ var MindGraph = class {
610
663
  }
611
664
  /** Get a single wiki article by UID. */
612
665
  async getArticle(uid) {
613
- return this.get(`/wiki/article/${uid}`);
666
+ return this.get(`/wiki/article/${seg(uid)}`);
614
667
  }
615
668
  /** Find the article that covers or summarizes a given entity/document UID. */
616
669
  async getArticleBySubject(subjectUid) {
617
670
  try {
618
- return await this.get(`/wiki/article/by-subject/${subjectUid}`);
671
+ return await this.get(`/wiki/article/by-subject/${seg(subjectUid)}`);
619
672
  } catch {
620
673
  return null;
621
674
  }
622
675
  }
623
676
  /** Update an article's markdown content (user editing). */
624
677
  async updateArticle(uid, content) {
625
- return this.patch(`/wiki/article/${uid}`, { content });
678
+ return this.patch(`/wiki/article/${seg(uid)}`, { content });
626
679
  }
627
680
  /** Trigger wiki compilation for a specific document. */
628
681
  async compileDocument(docUid) {
629
- return this.post(`/wiki/compile/${docUid}`, {});
682
+ return this.post(`/wiki/compile/${seg(docUid)}`, {});
630
683
  }
631
684
  /** Trigger wiki compilation for a specific entity. */
632
685
  async compileEntity(entityUid) {
633
- return this.post(`/wiki/compile/entity/${entityUid}`, {});
686
+ return this.post(`/wiki/compile/entity/${seg(entityUid)}`, {});
634
687
  }
635
688
  /** Backfill: compile articles for all documents and eligible entities. */
636
689
  async compileAll() {
@@ -651,7 +704,7 @@ var MindGraph = class {
651
704
  if (opts?.signals) q.set("signals", opts.signals);
652
705
  if (opts?.target_types) q.set("target_types", opts.target_types);
653
706
  const qs = q.toString();
654
- return this.get(`/synthesis/signals/${projectUid}${qs ? `?${qs}` : ""}`);
707
+ return this.get(`/synthesis/signals/${seg(projectUid)}${qs ? `?${qs}` : ""}`);
655
708
  }
656
709
  /**
657
710
  * Spawn a background synthesis job for a project: mines signals,
@@ -661,7 +714,7 @@ var MindGraph = class {
661
714
  * Returns a `job_id` immediately; poll `getJob(id)` for progress.
662
715
  */
663
716
  async runSynthesis(projectUid) {
664
- return this.post(`/synthesis/run/${projectUid}`, {});
717
+ return this.post(`/synthesis/run/${seg(projectUid)}`, {});
665
718
  }
666
719
  // ============================================================================
667
720
  // Operational Ontology Layer (Layer 7)
@@ -671,22 +724,36 @@ var MindGraph = class {
671
724
  return this.get("/v1/ontology/schemas");
672
725
  }
673
726
  async getOntologySchema(id) {
674
- return this.get(`/v1/ontology/schemas/${id}`);
727
+ return this.get(`/v1/ontology/schemas/${seg(id)}`);
728
+ }
729
+ async createOntologySeriesBinding(schemaId, request) {
730
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/series-bindings`, request);
731
+ }
732
+ async syncOntologySeriesBinding(bindingId, mode) {
733
+ return this.post(
734
+ `/v1/ontology/series-bindings/${seg(bindingId)}/sync`,
735
+ mode ? { mode } : {}
736
+ );
737
+ }
738
+ async archiveOntologySeriesBinding(schemaId, bindingId) {
739
+ return this.del(
740
+ `/v1/ontology/schemas/${seg(schemaId)}/series-bindings/${seg(bindingId)}`
741
+ );
675
742
  }
676
743
  async createOntologySchema(req) {
677
744
  return this.post("/v1/ontology/schemas", req);
678
745
  }
679
746
  async updateOntologySchema(id, req) {
680
- return this.patch(`/v1/ontology/schemas/${id}`, req);
747
+ return this.patch(`/v1/ontology/schemas/${seg(id)}`, req);
681
748
  }
682
749
  async activateOntologySchema(id) {
683
- return this.post(`/v1/ontology/schemas/${id}/activate`, {});
750
+ return this.post(`/v1/ontology/schemas/${seg(id)}/activate`, {});
684
751
  }
685
752
  async deprecateOntologySchema(id) {
686
- return this.post(`/v1/ontology/schemas/${id}/deprecate`, {});
753
+ return this.post(`/v1/ontology/schemas/${seg(id)}/deprecate`, {});
687
754
  }
688
755
  async archiveOntologySchema(id) {
689
- return this.del(`/v1/ontology/schemas/${id}`);
756
+ return this.del(`/v1/ontology/schemas/${seg(id)}`);
690
757
  }
691
758
  /**
692
759
  * Kick off an LLM-driven schema proposal job.
@@ -697,47 +764,47 @@ var MindGraph = class {
697
764
  return this.post("/v1/ontology/propose-schema", req);
698
765
  }
699
766
  async testOntologySchema(id, opts) {
700
- return this.post(`/v1/ontology/schemas/${id}/test`, opts ?? {});
767
+ return this.post(`/v1/ontology/schemas/${seg(id)}/test`, opts ?? {});
701
768
  }
702
769
  // ---- Schema sub-resources ----
703
770
  async addOntologyObjectType(schemaId, req) {
704
- return this.post(`/v1/ontology/schemas/${schemaId}/object-types`, req);
771
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/object-types`, req);
705
772
  }
706
773
  async updateOntologyObjectType(schemaId, typeId, req) {
707
774
  return this.patch(
708
- `/v1/ontology/schemas/${schemaId}/object-types/${typeId}`,
775
+ `/v1/ontology/schemas/${seg(schemaId)}/object-types/${seg(typeId)}`,
709
776
  req
710
777
  );
711
778
  }
712
779
  async deleteOntologyObjectType(schemaId, typeId) {
713
780
  return this.del(
714
- `/v1/ontology/schemas/${schemaId}/object-types/${typeId}`
781
+ `/v1/ontology/schemas/${seg(schemaId)}/object-types/${seg(typeId)}`
715
782
  );
716
783
  }
717
784
  async addOntologyRelationType(schemaId, req) {
718
- return this.post(`/v1/ontology/schemas/${schemaId}/relation-types`, req);
785
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/relation-types`, req);
719
786
  }
720
787
  async updateOntologyRelationType(schemaId, typeId, req) {
721
788
  return this.patch(
722
- `/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`,
789
+ `/v1/ontology/schemas/${seg(schemaId)}/relation-types/${seg(typeId)}`,
723
790
  req
724
791
  );
725
792
  }
726
793
  async deleteOntologyRelationType(schemaId, typeId) {
727
794
  return this.del(
728
- `/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`
795
+ `/v1/ontology/schemas/${seg(schemaId)}/relation-types/${seg(typeId)}`
729
796
  );
730
797
  }
731
798
  /** Generate inert semantic classifications for individual human review. */
732
799
  async analyzeOntologySemanticGuidance(schemaId) {
733
800
  return this.post(
734
- `/v1/ontology/schemas/${schemaId}/semantic-guidance/analyze`,
801
+ `/v1/ontology/schemas/${seg(schemaId)}/semantic-guidance/analyze`,
735
802
  {}
736
803
  );
737
804
  }
738
805
  /** Read-only exact-identity collision audit; never merges graph data. */
739
806
  async auditOntologyDuplicates(schemaId) {
740
- return this.post(`/v1/ontology/schemas/${schemaId}/duplicates/audit`, {});
807
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/duplicates/audit`, {});
741
808
  }
742
809
  // ---- Proposals ----
743
810
  async listOntologyProposals(opts) {
@@ -753,19 +820,19 @@ var MindGraph = class {
753
820
  return this.get(`/v1/ontology/proposals${qs ? `?${qs}` : ""}`);
754
821
  }
755
822
  async getOntologyProposal(id) {
756
- return this.get(`/v1/ontology/proposals/${id}`);
823
+ return this.get(`/v1/ontology/proposals/${seg(id)}`);
757
824
  }
758
825
  async patchOntologyProposal(id, req) {
759
- return this.patch(`/v1/ontology/proposals/${id}`, req);
826
+ return this.patch(`/v1/ontology/proposals/${seg(id)}`, req);
760
827
  }
761
828
  async approveOntologyProposal(id, opts) {
762
- return this.post(`/v1/ontology/proposals/${id}/approve`, opts ?? {});
829
+ return this.post(`/v1/ontology/proposals/${seg(id)}/approve`, opts ?? {});
763
830
  }
764
831
  async rejectOntologyProposal(id, reason) {
765
- return this.post(`/v1/ontology/proposals/${id}/reject`, { reason });
832
+ return this.post(`/v1/ontology/proposals/${seg(id)}/reject`, { reason });
766
833
  }
767
834
  async applyOntologyProposal(id) {
768
- return this.post(`/v1/ontology/proposals/${id}/apply`, {});
835
+ return this.post(`/v1/ontology/proposals/${seg(id)}/apply`, {});
769
836
  }
770
837
  async batchApproveOntologyProposals(ids, feedback) {
771
838
  return this.post("/v1/ontology/proposals/batch-approve", { ids, feedback });
@@ -814,7 +881,7 @@ var MindGraph = class {
814
881
  if (binding.project_uid) query.set("project_uid", binding.project_uid);
815
882
  }
816
883
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
817
- return this.get(`/ontology/object/${uid}${suffix}`);
884
+ return this.get(`/ontology/object/${seg(uid)}${suffix}`);
818
885
  }
819
886
  async getDomainObjectContext(uid, depth, binding) {
820
887
  const query = new URLSearchParams();
@@ -825,10 +892,10 @@ var MindGraph = class {
825
892
  if (binding.project_uid) query.set("project_uid", binding.project_uid);
826
893
  }
827
894
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
828
- return this.get(`/ontology/object/${uid}/context${suffix}`);
895
+ return this.get(`/ontology/object/${seg(uid)}/context${suffix}`);
829
896
  }
830
897
  async getDomainObjectHistory(uid) {
831
- return this.get(`/ontology/object/${uid}/history`);
898
+ return this.get(`/ontology/object/${seg(uid)}/history`);
832
899
  }
833
900
  async listDomainObjects(opts) {
834
901
  const q = new URLSearchParams();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindgraph",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "TypeScript client for the MindGraph Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",