mindgraph 0.11.0 → 0.13.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 +4 -3
- package/dist/index.d.mts +381 -18
- package/dist/index.d.ts +381 -18
- package/dist/index.js +74 -11
- package/dist/index.mjs +74 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -46,15 +46,21 @@ var MindGraph = class {
|
|
|
46
46
|
if (config.orgId) {
|
|
47
47
|
this.headers["X-MindGraph-Org"] = config.orgId;
|
|
48
48
|
}
|
|
49
|
+
this.telemetrySurface = config.telemetrySurface;
|
|
49
50
|
this.maxRetries = config.maxRetries ?? 3;
|
|
50
51
|
this.retryBackoffMs = config.retryBackoffMs ?? 1e3;
|
|
51
52
|
}
|
|
52
53
|
// ---- HTTP helpers ----
|
|
53
54
|
async request(method, path, body) {
|
|
54
55
|
const url = `${this.baseUrl}${path}`;
|
|
56
|
+
const requestId = createRequestId();
|
|
55
57
|
const init = {
|
|
56
58
|
method,
|
|
57
|
-
headers:
|
|
59
|
+
headers: {
|
|
60
|
+
...this.headers,
|
|
61
|
+
"X-MindGraph-Request-ID": requestId,
|
|
62
|
+
...this.telemetrySurface ? { "X-MindGraph-Surface": this.telemetrySurface } : {}
|
|
63
|
+
}
|
|
58
64
|
};
|
|
59
65
|
if (body !== void 0) {
|
|
60
66
|
init.body = JSON.stringify(body);
|
|
@@ -564,6 +570,10 @@ var MindGraph = class {
|
|
|
564
570
|
async getMergeCandidates() {
|
|
565
571
|
return this.post("/retrieve", { action: "merge_candidates" });
|
|
566
572
|
}
|
|
573
|
+
/** Load-bearing conclusions awaiting repair after a premise changed. */
|
|
574
|
+
async getStaleDerivations(limit = 50, offset = 0) {
|
|
575
|
+
return this.post("/retrieve", { action: "stale_derivations", limit, offset });
|
|
576
|
+
}
|
|
567
577
|
async getPendingApprovals() {
|
|
568
578
|
return this.get("/approvals/pending");
|
|
569
579
|
}
|
|
@@ -745,12 +755,25 @@ var MindGraph = class {
|
|
|
745
755
|
`/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`
|
|
746
756
|
);
|
|
747
757
|
}
|
|
758
|
+
/** Generate inert semantic classifications for individual human review. */
|
|
759
|
+
async analyzeOntologySemanticGuidance(schemaId) {
|
|
760
|
+
return this.post(
|
|
761
|
+
`/v1/ontology/schemas/${schemaId}/semantic-guidance/analyze`,
|
|
762
|
+
{}
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
/** Read-only exact-identity collision audit; never merges graph data. */
|
|
766
|
+
async auditOntologyDuplicates(schemaId) {
|
|
767
|
+
return this.post(`/v1/ontology/schemas/${schemaId}/duplicates/audit`, {});
|
|
768
|
+
}
|
|
748
769
|
// ---- Proposals ----
|
|
749
770
|
async listOntologyProposals(opts) {
|
|
750
771
|
const q = new URLSearchParams();
|
|
751
772
|
if (opts?.status) q.set("status", opts.status);
|
|
752
773
|
if (opts?.schema_id) q.set("schema_id", opts.schema_id);
|
|
753
774
|
if (opts?.object_type) q.set("object_type", opts.object_type);
|
|
775
|
+
if (opts?.proposal_type) q.set("proposal_type", opts.proposal_type);
|
|
776
|
+
if (opts?.extract_job_id) q.set("extract_job_id", opts.extract_job_id);
|
|
754
777
|
if (opts?.limit != null) q.set("limit", String(opts.limit));
|
|
755
778
|
if (opts?.offset != null) q.set("offset", String(opts.offset));
|
|
756
779
|
const qs = q.toString();
|
|
@@ -781,21 +804,55 @@ var MindGraph = class {
|
|
|
781
804
|
async queryOntology(req) {
|
|
782
805
|
return this.post("/ontology/query", req);
|
|
783
806
|
}
|
|
807
|
+
async queryDomainStructured(req) {
|
|
808
|
+
return this.post("/ontology/query/structured", req);
|
|
809
|
+
}
|
|
810
|
+
async queryRelatedDomainObjects(req) {
|
|
811
|
+
return this.queryDomainStructured({
|
|
812
|
+
schema_id: req.schema_id,
|
|
813
|
+
select: req.far_type,
|
|
814
|
+
...req.project_uid ? { project_uid: req.project_uid } : {},
|
|
815
|
+
anchor: { type: req.entry_type, uid: req.uid },
|
|
816
|
+
path: [{
|
|
817
|
+
relation: req.relation,
|
|
818
|
+
entry_role: req.entry_role
|
|
819
|
+
}],
|
|
820
|
+
...req.where ? { where: req.where } : {},
|
|
821
|
+
...req.include_provenance ? { include: { provenance: true } } : {},
|
|
822
|
+
page: {
|
|
823
|
+
...req.limit != null ? { limit: req.limit } : {},
|
|
824
|
+
...req.offset != null ? { offset: req.offset } : {}
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
}
|
|
784
828
|
/**
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
*
|
|
788
|
-
* tools (`search_customers`, `summarize_customer`, …).
|
|
829
|
+
* Schema-qualified read-tool descriptors generated from every active
|
|
830
|
+
* ontology. Includes per-object discovery/point/context tools,
|
|
831
|
+
* relation-and-role-specific related tools, and one structured composite.
|
|
789
832
|
*/
|
|
790
833
|
async listOntologyTools() {
|
|
791
834
|
return this.get("/v1/ontology/tools");
|
|
792
835
|
}
|
|
793
|
-
async getDomainObject(uid) {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
836
|
+
async getDomainObject(uid, binding) {
|
|
837
|
+
const query = new URLSearchParams();
|
|
838
|
+
if (binding) {
|
|
839
|
+
query.set("schema_id", binding.schema_id);
|
|
840
|
+
query.set("object_type", binding.object_type);
|
|
841
|
+
if (binding.project_uid) query.set("project_uid", binding.project_uid);
|
|
842
|
+
}
|
|
843
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
844
|
+
return this.get(`/ontology/object/${uid}${suffix}`);
|
|
845
|
+
}
|
|
846
|
+
async getDomainObjectContext(uid, depth, binding) {
|
|
847
|
+
const query = new URLSearchParams();
|
|
848
|
+
if (depth != null) query.set("depth", String(depth));
|
|
849
|
+
if (binding) {
|
|
850
|
+
query.set("schema_id", binding.schema_id);
|
|
851
|
+
query.set("object_type", binding.object_type);
|
|
852
|
+
if (binding.project_uid) query.set("project_uid", binding.project_uid);
|
|
853
|
+
}
|
|
854
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
855
|
+
return this.get(`/ontology/object/${uid}/context${suffix}`);
|
|
799
856
|
}
|
|
800
857
|
async getDomainObjectHistory(uid) {
|
|
801
858
|
return this.get(`/ontology/object/${uid}/history`);
|
|
@@ -838,6 +895,12 @@ var MindGraph = class {
|
|
|
838
895
|
return this.post("/ontology/extract", req);
|
|
839
896
|
}
|
|
840
897
|
};
|
|
898
|
+
function createRequestId() {
|
|
899
|
+
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
900
|
+
return globalThis.crypto.randomUUID();
|
|
901
|
+
}
|
|
902
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
903
|
+
}
|
|
841
904
|
// Annotate the CommonJS export names for ESM import in node:
|
|
842
905
|
0 && (module.exports = {
|
|
843
906
|
MindGraph,
|
package/dist/index.mjs
CHANGED
|
@@ -19,15 +19,21 @@ var MindGraph = class {
|
|
|
19
19
|
if (config.orgId) {
|
|
20
20
|
this.headers["X-MindGraph-Org"] = config.orgId;
|
|
21
21
|
}
|
|
22
|
+
this.telemetrySurface = config.telemetrySurface;
|
|
22
23
|
this.maxRetries = config.maxRetries ?? 3;
|
|
23
24
|
this.retryBackoffMs = config.retryBackoffMs ?? 1e3;
|
|
24
25
|
}
|
|
25
26
|
// ---- HTTP helpers ----
|
|
26
27
|
async request(method, path, body) {
|
|
27
28
|
const url = `${this.baseUrl}${path}`;
|
|
29
|
+
const requestId = createRequestId();
|
|
28
30
|
const init = {
|
|
29
31
|
method,
|
|
30
|
-
headers:
|
|
32
|
+
headers: {
|
|
33
|
+
...this.headers,
|
|
34
|
+
"X-MindGraph-Request-ID": requestId,
|
|
35
|
+
...this.telemetrySurface ? { "X-MindGraph-Surface": this.telemetrySurface } : {}
|
|
36
|
+
}
|
|
31
37
|
};
|
|
32
38
|
if (body !== void 0) {
|
|
33
39
|
init.body = JSON.stringify(body);
|
|
@@ -537,6 +543,10 @@ var MindGraph = class {
|
|
|
537
543
|
async getMergeCandidates() {
|
|
538
544
|
return this.post("/retrieve", { action: "merge_candidates" });
|
|
539
545
|
}
|
|
546
|
+
/** Load-bearing conclusions awaiting repair after a premise changed. */
|
|
547
|
+
async getStaleDerivations(limit = 50, offset = 0) {
|
|
548
|
+
return this.post("/retrieve", { action: "stale_derivations", limit, offset });
|
|
549
|
+
}
|
|
540
550
|
async getPendingApprovals() {
|
|
541
551
|
return this.get("/approvals/pending");
|
|
542
552
|
}
|
|
@@ -718,12 +728,25 @@ var MindGraph = class {
|
|
|
718
728
|
`/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`
|
|
719
729
|
);
|
|
720
730
|
}
|
|
731
|
+
/** Generate inert semantic classifications for individual human review. */
|
|
732
|
+
async analyzeOntologySemanticGuidance(schemaId) {
|
|
733
|
+
return this.post(
|
|
734
|
+
`/v1/ontology/schemas/${schemaId}/semantic-guidance/analyze`,
|
|
735
|
+
{}
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
/** Read-only exact-identity collision audit; never merges graph data. */
|
|
739
|
+
async auditOntologyDuplicates(schemaId) {
|
|
740
|
+
return this.post(`/v1/ontology/schemas/${schemaId}/duplicates/audit`, {});
|
|
741
|
+
}
|
|
721
742
|
// ---- Proposals ----
|
|
722
743
|
async listOntologyProposals(opts) {
|
|
723
744
|
const q = new URLSearchParams();
|
|
724
745
|
if (opts?.status) q.set("status", opts.status);
|
|
725
746
|
if (opts?.schema_id) q.set("schema_id", opts.schema_id);
|
|
726
747
|
if (opts?.object_type) q.set("object_type", opts.object_type);
|
|
748
|
+
if (opts?.proposal_type) q.set("proposal_type", opts.proposal_type);
|
|
749
|
+
if (opts?.extract_job_id) q.set("extract_job_id", opts.extract_job_id);
|
|
727
750
|
if (opts?.limit != null) q.set("limit", String(opts.limit));
|
|
728
751
|
if (opts?.offset != null) q.set("offset", String(opts.offset));
|
|
729
752
|
const qs = q.toString();
|
|
@@ -754,21 +777,55 @@ var MindGraph = class {
|
|
|
754
777
|
async queryOntology(req) {
|
|
755
778
|
return this.post("/ontology/query", req);
|
|
756
779
|
}
|
|
780
|
+
async queryDomainStructured(req) {
|
|
781
|
+
return this.post("/ontology/query/structured", req);
|
|
782
|
+
}
|
|
783
|
+
async queryRelatedDomainObjects(req) {
|
|
784
|
+
return this.queryDomainStructured({
|
|
785
|
+
schema_id: req.schema_id,
|
|
786
|
+
select: req.far_type,
|
|
787
|
+
...req.project_uid ? { project_uid: req.project_uid } : {},
|
|
788
|
+
anchor: { type: req.entry_type, uid: req.uid },
|
|
789
|
+
path: [{
|
|
790
|
+
relation: req.relation,
|
|
791
|
+
entry_role: req.entry_role
|
|
792
|
+
}],
|
|
793
|
+
...req.where ? { where: req.where } : {},
|
|
794
|
+
...req.include_provenance ? { include: { provenance: true } } : {},
|
|
795
|
+
page: {
|
|
796
|
+
...req.limit != null ? { limit: req.limit } : {},
|
|
797
|
+
...req.offset != null ? { offset: req.offset } : {}
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}
|
|
757
801
|
/**
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
* tools (`search_customers`, `summarize_customer`, …).
|
|
802
|
+
* Schema-qualified read-tool descriptors generated from every active
|
|
803
|
+
* ontology. Includes per-object discovery/point/context tools,
|
|
804
|
+
* relation-and-role-specific related tools, and one structured composite.
|
|
762
805
|
*/
|
|
763
806
|
async listOntologyTools() {
|
|
764
807
|
return this.get("/v1/ontology/tools");
|
|
765
808
|
}
|
|
766
|
-
async getDomainObject(uid) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
809
|
+
async getDomainObject(uid, binding) {
|
|
810
|
+
const query = new URLSearchParams();
|
|
811
|
+
if (binding) {
|
|
812
|
+
query.set("schema_id", binding.schema_id);
|
|
813
|
+
query.set("object_type", binding.object_type);
|
|
814
|
+
if (binding.project_uid) query.set("project_uid", binding.project_uid);
|
|
815
|
+
}
|
|
816
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
817
|
+
return this.get(`/ontology/object/${uid}${suffix}`);
|
|
818
|
+
}
|
|
819
|
+
async getDomainObjectContext(uid, depth, binding) {
|
|
820
|
+
const query = new URLSearchParams();
|
|
821
|
+
if (depth != null) query.set("depth", String(depth));
|
|
822
|
+
if (binding) {
|
|
823
|
+
query.set("schema_id", binding.schema_id);
|
|
824
|
+
query.set("object_type", binding.object_type);
|
|
825
|
+
if (binding.project_uid) query.set("project_uid", binding.project_uid);
|
|
826
|
+
}
|
|
827
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
828
|
+
return this.get(`/ontology/object/${uid}/context${suffix}`);
|
|
772
829
|
}
|
|
773
830
|
async getDomainObjectHistory(uid) {
|
|
774
831
|
return this.get(`/ontology/object/${uid}/history`);
|
|
@@ -811,6 +868,12 @@ var MindGraph = class {
|
|
|
811
868
|
return this.post("/ontology/extract", req);
|
|
812
869
|
}
|
|
813
870
|
};
|
|
871
|
+
function createRequestId() {
|
|
872
|
+
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
873
|
+
return globalThis.crypto.randomUUID();
|
|
874
|
+
}
|
|
875
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
876
|
+
}
|
|
814
877
|
export {
|
|
815
878
|
MindGraph,
|
|
816
879
|
MindGraphError
|