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.js CHANGED
@@ -26,6 +26,9 @@ __export(index_exports, {
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/client.ts
29
+ function seg(value) {
30
+ return encodeURIComponent(String(value));
31
+ }
29
32
  var MindGraphError = class extends Error {
30
33
  constructor(message, status, body) {
31
34
  super(message);
@@ -83,7 +86,8 @@ var MindGraph = class {
83
86
  );
84
87
  if (res.status === 503 && attempt < this.maxRetries) {
85
88
  lastError = err;
86
- const delay = this.retryBackoffMs * 2 ** attempt;
89
+ const retryAfterSecs = Number(res.headers.get("retry-after"));
90
+ const delay = Number.isFinite(retryAfterSecs) && retryAfterSecs > 0 ? Math.min(retryAfterSecs * 1e3, 1e4) : this.retryBackoffMs * 2 ** attempt;
87
91
  await new Promise((r) => setTimeout(r, delay));
88
92
  continue;
89
93
  }
@@ -134,6 +138,52 @@ var MindGraph = class {
134
138
  async entity(req) {
135
139
  return this.post("/reality/entity", req);
136
140
  }
141
+ async series(req) {
142
+ return this.post("/reality/series", req);
143
+ }
144
+ async createSeries(req) {
145
+ return this.post("/reality/series", { action: "create", ...req });
146
+ }
147
+ async appendSeries(req) {
148
+ return this.post("/reality/series", { action: "append", ...req });
149
+ }
150
+ async seriesWindow(req) {
151
+ return this.post("/reality/series", { action: "window", ...req });
152
+ }
153
+ async aggregateSeries(req) {
154
+ return this.post("/reality/series", { action: "aggregate", ...req });
155
+ }
156
+ async latestSeries(seriesUid, options) {
157
+ return this.post("/reality/series", {
158
+ action: "latest",
159
+ series_uid: seriesUid,
160
+ ...options
161
+ });
162
+ }
163
+ async listSeriesForEntity(entityUid, options) {
164
+ return this.post("/reality/series", {
165
+ action: "list_for_entity",
166
+ entity_uid: entityUid,
167
+ ...options
168
+ });
169
+ }
170
+ async batchLatestSeries(entityUids, options) {
171
+ return this.post("/reality/series", {
172
+ action: "batch_latest",
173
+ entity_uids: entityUids,
174
+ ...options
175
+ });
176
+ }
177
+ async batchAggregateSeries(req) {
178
+ return this.post("/reality/series", { action: "batch_aggregate", ...req });
179
+ }
180
+ async deleteSeries(seriesUid, options) {
181
+ return this.post("/reality/series", {
182
+ action: "delete_series",
183
+ series_uid: seriesUid,
184
+ ...options
185
+ });
186
+ }
137
187
  /** Convenience: create or find an entity by label. */
138
188
  async findOrCreateEntity(label, props, agentId) {
139
189
  return this.post("/reality/entity", {
@@ -295,6 +345,9 @@ var MindGraph = class {
295
345
  async memoryConfig(req) {
296
346
  return this.post("/memory/config", req);
297
347
  }
348
+ async memorySync(req) {
349
+ return this.post("/memory/sync", req);
350
+ }
298
351
  // ---- Agent Layer ----
299
352
  async plan(req) {
300
353
  return this.post("/agent/plan", req);
@@ -318,7 +371,7 @@ var MindGraph = class {
318
371
  }
319
372
  // ---- Node CRUD ----
320
373
  async getNode(uid) {
321
- return this.get(`/node/${uid}`);
374
+ return this.get(`/node/${seg(uid)}`);
322
375
  }
323
376
  /**
324
377
  * Create a node via the low-level CRUD endpoint.
@@ -335,10 +388,10 @@ var MindGraph = class {
335
388
  return this.post("/node", { ...body, props });
336
389
  }
337
390
  async updateNode(uid, body) {
338
- return this.patch(`/node/${uid}`, body);
391
+ return this.patch(`/node/${seg(uid)}`, body);
339
392
  }
340
393
  async deleteNode(uid) {
341
- await this.del(`/node/${uid}`);
394
+ await this.del(`/node/${seg(uid)}`);
342
395
  }
343
396
  async batchDeleteNodes(params) {
344
397
  const body = {};
@@ -359,10 +412,10 @@ var MindGraph = class {
359
412
  return this.post("/nodes/delete", body);
360
413
  }
361
414
  async getNodeHistory(uid) {
362
- return this.get(`/node/${uid}/history`);
415
+ return this.get(`/node/${seg(uid)}/history`);
363
416
  }
364
417
  async getNodeAtVersion(uid, version) {
365
- return this.get(`/node/${uid}/history/${version}`);
418
+ return this.get(`/node/${seg(uid)}/history/${seg(version)}`);
366
419
  }
367
420
  // ---- Edge CRUD ----
368
421
  async addLink(body) {
@@ -383,13 +436,13 @@ var MindGraph = class {
383
436
  return this.post("/edge", { ...body, props });
384
437
  }
385
438
  async updateEdge(uid, body) {
386
- return this.patch(`/edge/${uid}`, body);
439
+ return this.patch(`/edge/${seg(uid)}`, body);
387
440
  }
388
441
  async deleteEdge(uid) {
389
- await this.del(`/edge/${uid}`);
442
+ await this.del(`/edge/${seg(uid)}`);
390
443
  }
391
444
  async getEdgeHistory(uid) {
392
- return this.get(`/edge/${uid}/history`);
445
+ return this.get(`/edge/${seg(uid)}/history`);
393
446
  }
394
447
  /**
395
448
  * List edges filtered by source and/or target node.
@@ -438,7 +491,7 @@ var MindGraph = class {
438
491
  return this.get(`/nodes?${qs}`);
439
492
  }
440
493
  async getAgentNodes(agentId) {
441
- return this.get(`/agent/${agentId}/nodes`);
494
+ return this.get(`/agent/${seg(agentId)}/nodes`);
442
495
  }
443
496
  // ---- Batch ----
444
497
  async batch(req) {
@@ -463,13 +516,13 @@ var MindGraph = class {
463
516
  return this.post("/embeddings/search-text", body);
464
517
  }
465
518
  async getEmbedding(uid) {
466
- return this.get(`/node/${uid}/embedding`);
519
+ return this.get(`/node/${seg(uid)}/embedding`);
467
520
  }
468
521
  async setEmbedding(uid, vector) {
469
- await this.request("PUT", `/node/${uid}/embedding`, { vector });
522
+ await this.request("PUT", `/node/${seg(uid)}/embedding`, { vector });
470
523
  }
471
524
  async deleteEmbedding(uid) {
472
- await this.del(`/node/${uid}/embedding`);
525
+ await this.del(`/node/${seg(uid)}/embedding`);
473
526
  }
474
527
  // ---- Entity resolution ----
475
528
  async mergeEntities(body) {
@@ -479,7 +532,7 @@ var MindGraph = class {
479
532
  return this.post("/alias", body);
480
533
  }
481
534
  async getAliases(uid) {
482
- return this.get(`/aliases/${uid}`);
535
+ return this.get(`/aliases/${seg(uid)}`);
483
536
  }
484
537
  async resolveAlias(text) {
485
538
  return this.get(`/resolve?text=${encodeURIComponent(text)}`);
@@ -602,18 +655,18 @@ var MindGraph = class {
602
655
  return this.get("/jobs");
603
656
  }
604
657
  async getJob(id) {
605
- return this.get(`/jobs/${id}`);
658
+ return this.get(`/jobs/${seg(id)}`);
606
659
  }
607
660
  async cancelJob(id) {
608
- return this.post(`/jobs/${id}/cancel`, {});
661
+ return this.post(`/jobs/${seg(id)}/cancel`, {});
609
662
  }
610
663
  /** Resume ingestion of a document that has failed chunks. */
611
664
  async resumeDocument(docUid, opts) {
612
- return this.post(`/ingest/resume/${docUid}`, opts ?? {});
665
+ return this.post(`/ingest/resume/${seg(docUid)}`, opts ?? {});
613
666
  }
614
667
  /** Delete a document and all its chunks and extracted nodes. */
615
668
  async deleteDocument(uid) {
616
- return this.del(`/ingest/document/${uid}`);
669
+ return this.del(`/ingest/document/${seg(uid)}`);
617
670
  }
618
671
  async cleanupOrphans() {
619
672
  return this.post("/ingest/cleanup", {});
@@ -637,27 +690,27 @@ var MindGraph = class {
637
690
  }
638
691
  /** Get a single wiki article by UID. */
639
692
  async getArticle(uid) {
640
- return this.get(`/wiki/article/${uid}`);
693
+ return this.get(`/wiki/article/${seg(uid)}`);
641
694
  }
642
695
  /** Find the article that covers or summarizes a given entity/document UID. */
643
696
  async getArticleBySubject(subjectUid) {
644
697
  try {
645
- return await this.get(`/wiki/article/by-subject/${subjectUid}`);
698
+ return await this.get(`/wiki/article/by-subject/${seg(subjectUid)}`);
646
699
  } catch {
647
700
  return null;
648
701
  }
649
702
  }
650
703
  /** Update an article's markdown content (user editing). */
651
704
  async updateArticle(uid, content) {
652
- return this.patch(`/wiki/article/${uid}`, { content });
705
+ return this.patch(`/wiki/article/${seg(uid)}`, { content });
653
706
  }
654
707
  /** Trigger wiki compilation for a specific document. */
655
708
  async compileDocument(docUid) {
656
- return this.post(`/wiki/compile/${docUid}`, {});
709
+ return this.post(`/wiki/compile/${seg(docUid)}`, {});
657
710
  }
658
711
  /** Trigger wiki compilation for a specific entity. */
659
712
  async compileEntity(entityUid) {
660
- return this.post(`/wiki/compile/entity/${entityUid}`, {});
713
+ return this.post(`/wiki/compile/entity/${seg(entityUid)}`, {});
661
714
  }
662
715
  /** Backfill: compile articles for all documents and eligible entities. */
663
716
  async compileAll() {
@@ -678,7 +731,7 @@ var MindGraph = class {
678
731
  if (opts?.signals) q.set("signals", opts.signals);
679
732
  if (opts?.target_types) q.set("target_types", opts.target_types);
680
733
  const qs = q.toString();
681
- return this.get(`/synthesis/signals/${projectUid}${qs ? `?${qs}` : ""}`);
734
+ return this.get(`/synthesis/signals/${seg(projectUid)}${qs ? `?${qs}` : ""}`);
682
735
  }
683
736
  /**
684
737
  * Spawn a background synthesis job for a project: mines signals,
@@ -688,7 +741,7 @@ var MindGraph = class {
688
741
  * Returns a `job_id` immediately; poll `getJob(id)` for progress.
689
742
  */
690
743
  async runSynthesis(projectUid) {
691
- return this.post(`/synthesis/run/${projectUid}`, {});
744
+ return this.post(`/synthesis/run/${seg(projectUid)}`, {});
692
745
  }
693
746
  // ============================================================================
694
747
  // Operational Ontology Layer (Layer 7)
@@ -698,22 +751,36 @@ var MindGraph = class {
698
751
  return this.get("/v1/ontology/schemas");
699
752
  }
700
753
  async getOntologySchema(id) {
701
- return this.get(`/v1/ontology/schemas/${id}`);
754
+ return this.get(`/v1/ontology/schemas/${seg(id)}`);
755
+ }
756
+ async createOntologySeriesBinding(schemaId, request) {
757
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/series-bindings`, request);
758
+ }
759
+ async syncOntologySeriesBinding(bindingId, mode) {
760
+ return this.post(
761
+ `/v1/ontology/series-bindings/${seg(bindingId)}/sync`,
762
+ mode ? { mode } : {}
763
+ );
764
+ }
765
+ async archiveOntologySeriesBinding(schemaId, bindingId) {
766
+ return this.del(
767
+ `/v1/ontology/schemas/${seg(schemaId)}/series-bindings/${seg(bindingId)}`
768
+ );
702
769
  }
703
770
  async createOntologySchema(req) {
704
771
  return this.post("/v1/ontology/schemas", req);
705
772
  }
706
773
  async updateOntologySchema(id, req) {
707
- return this.patch(`/v1/ontology/schemas/${id}`, req);
774
+ return this.patch(`/v1/ontology/schemas/${seg(id)}`, req);
708
775
  }
709
776
  async activateOntologySchema(id) {
710
- return this.post(`/v1/ontology/schemas/${id}/activate`, {});
777
+ return this.post(`/v1/ontology/schemas/${seg(id)}/activate`, {});
711
778
  }
712
779
  async deprecateOntologySchema(id) {
713
- return this.post(`/v1/ontology/schemas/${id}/deprecate`, {});
780
+ return this.post(`/v1/ontology/schemas/${seg(id)}/deprecate`, {});
714
781
  }
715
782
  async archiveOntologySchema(id) {
716
- return this.del(`/v1/ontology/schemas/${id}`);
783
+ return this.del(`/v1/ontology/schemas/${seg(id)}`);
717
784
  }
718
785
  /**
719
786
  * Kick off an LLM-driven schema proposal job.
@@ -724,47 +791,47 @@ var MindGraph = class {
724
791
  return this.post("/v1/ontology/propose-schema", req);
725
792
  }
726
793
  async testOntologySchema(id, opts) {
727
- return this.post(`/v1/ontology/schemas/${id}/test`, opts ?? {});
794
+ return this.post(`/v1/ontology/schemas/${seg(id)}/test`, opts ?? {});
728
795
  }
729
796
  // ---- Schema sub-resources ----
730
797
  async addOntologyObjectType(schemaId, req) {
731
- return this.post(`/v1/ontology/schemas/${schemaId}/object-types`, req);
798
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/object-types`, req);
732
799
  }
733
800
  async updateOntologyObjectType(schemaId, typeId, req) {
734
801
  return this.patch(
735
- `/v1/ontology/schemas/${schemaId}/object-types/${typeId}`,
802
+ `/v1/ontology/schemas/${seg(schemaId)}/object-types/${seg(typeId)}`,
736
803
  req
737
804
  );
738
805
  }
739
806
  async deleteOntologyObjectType(schemaId, typeId) {
740
807
  return this.del(
741
- `/v1/ontology/schemas/${schemaId}/object-types/${typeId}`
808
+ `/v1/ontology/schemas/${seg(schemaId)}/object-types/${seg(typeId)}`
742
809
  );
743
810
  }
744
811
  async addOntologyRelationType(schemaId, req) {
745
- return this.post(`/v1/ontology/schemas/${schemaId}/relation-types`, req);
812
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/relation-types`, req);
746
813
  }
747
814
  async updateOntologyRelationType(schemaId, typeId, req) {
748
815
  return this.patch(
749
- `/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`,
816
+ `/v1/ontology/schemas/${seg(schemaId)}/relation-types/${seg(typeId)}`,
750
817
  req
751
818
  );
752
819
  }
753
820
  async deleteOntologyRelationType(schemaId, typeId) {
754
821
  return this.del(
755
- `/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`
822
+ `/v1/ontology/schemas/${seg(schemaId)}/relation-types/${seg(typeId)}`
756
823
  );
757
824
  }
758
825
  /** Generate inert semantic classifications for individual human review. */
759
826
  async analyzeOntologySemanticGuidance(schemaId) {
760
827
  return this.post(
761
- `/v1/ontology/schemas/${schemaId}/semantic-guidance/analyze`,
828
+ `/v1/ontology/schemas/${seg(schemaId)}/semantic-guidance/analyze`,
762
829
  {}
763
830
  );
764
831
  }
765
832
  /** Read-only exact-identity collision audit; never merges graph data. */
766
833
  async auditOntologyDuplicates(schemaId) {
767
- return this.post(`/v1/ontology/schemas/${schemaId}/duplicates/audit`, {});
834
+ return this.post(`/v1/ontology/schemas/${seg(schemaId)}/duplicates/audit`, {});
768
835
  }
769
836
  // ---- Proposals ----
770
837
  async listOntologyProposals(opts) {
@@ -780,19 +847,19 @@ var MindGraph = class {
780
847
  return this.get(`/v1/ontology/proposals${qs ? `?${qs}` : ""}`);
781
848
  }
782
849
  async getOntologyProposal(id) {
783
- return this.get(`/v1/ontology/proposals/${id}`);
850
+ return this.get(`/v1/ontology/proposals/${seg(id)}`);
784
851
  }
785
852
  async patchOntologyProposal(id, req) {
786
- return this.patch(`/v1/ontology/proposals/${id}`, req);
853
+ return this.patch(`/v1/ontology/proposals/${seg(id)}`, req);
787
854
  }
788
855
  async approveOntologyProposal(id, opts) {
789
- return this.post(`/v1/ontology/proposals/${id}/approve`, opts ?? {});
856
+ return this.post(`/v1/ontology/proposals/${seg(id)}/approve`, opts ?? {});
790
857
  }
791
858
  async rejectOntologyProposal(id, reason) {
792
- return this.post(`/v1/ontology/proposals/${id}/reject`, { reason });
859
+ return this.post(`/v1/ontology/proposals/${seg(id)}/reject`, { reason });
793
860
  }
794
861
  async applyOntologyProposal(id) {
795
- return this.post(`/v1/ontology/proposals/${id}/apply`, {});
862
+ return this.post(`/v1/ontology/proposals/${seg(id)}/apply`, {});
796
863
  }
797
864
  async batchApproveOntologyProposals(ids, feedback) {
798
865
  return this.post("/v1/ontology/proposals/batch-approve", { ids, feedback });
@@ -841,7 +908,7 @@ var MindGraph = class {
841
908
  if (binding.project_uid) query.set("project_uid", binding.project_uid);
842
909
  }
843
910
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
844
- return this.get(`/ontology/object/${uid}${suffix}`);
911
+ return this.get(`/ontology/object/${seg(uid)}${suffix}`);
845
912
  }
846
913
  async getDomainObjectContext(uid, depth, binding) {
847
914
  const query = new URLSearchParams();
@@ -852,10 +919,10 @@ var MindGraph = class {
852
919
  if (binding.project_uid) query.set("project_uid", binding.project_uid);
853
920
  }
854
921
  const suffix = query.size > 0 ? `?${query.toString()}` : "";
855
- return this.get(`/ontology/object/${uid}/context${suffix}`);
922
+ return this.get(`/ontology/object/${seg(uid)}/context${suffix}`);
856
923
  }
857
924
  async getDomainObjectHistory(uid) {
858
- return this.get(`/ontology/object/${uid}/history`);
925
+ return this.get(`/ontology/object/${seg(uid)}/history`);
859
926
  }
860
927
  async listDomainObjects(opts) {
861
928
  const q = new URLSearchParams();