mindgraph 0.4.1 → 0.6.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.d.mts +345 -2
- package/dist/index.d.ts +345 -2
- package/dist/index.js +135 -1
- package/dist/index.mjs +135 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -30,6 +30,29 @@ interface SearchResult {
|
|
|
30
30
|
node_type: string;
|
|
31
31
|
score: number;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* One retrieval leg's contribution to a fused hybrid result — the
|
|
35
|
+
* "why retrieved" detail. The fused score reconstructs exactly as
|
|
36
|
+
* `Σ 1/(60 + rank)` over a result's legs.
|
|
37
|
+
*/
|
|
38
|
+
interface LegContribution {
|
|
39
|
+
/** Which leg surfaced the result: `"fts"` (keyword/BM25) or `"vec"` (vector). */
|
|
40
|
+
leg: string;
|
|
41
|
+
/** 1-based within-leg rank the fusion used. */
|
|
42
|
+
rank: number;
|
|
43
|
+
/**
|
|
44
|
+
* The leg's raw score (BM25 relevance for `fts`, cosine similarity for
|
|
45
|
+
* `vec`). Not comparable across legs — RRF fuses by rank, not score.
|
|
46
|
+
*/
|
|
47
|
+
score: number;
|
|
48
|
+
}
|
|
49
|
+
/** A `/retrieve` hybrid result: the full node plus the fused RRF score. */
|
|
50
|
+
interface HybridSearchResult {
|
|
51
|
+
node: GraphNode;
|
|
52
|
+
score: number;
|
|
53
|
+
/** Per-leg contributions; present only when the request set `explain: true`. */
|
|
54
|
+
legs?: LegContribution[];
|
|
55
|
+
}
|
|
33
56
|
interface SearchChunk {
|
|
34
57
|
chunk_uid: string;
|
|
35
58
|
content: string;
|
|
@@ -329,6 +352,12 @@ interface RetrieveRequest {
|
|
|
329
352
|
salience_min?: number;
|
|
330
353
|
limit?: number;
|
|
331
354
|
offset?: number;
|
|
355
|
+
/**
|
|
356
|
+
* Hybrid action only: attach per-leg contributions (`legs`) to each
|
|
357
|
+
* result — the "why retrieved" detail. Requires server ≥ 1.2.0; older
|
|
358
|
+
* servers ignore the field.
|
|
359
|
+
*/
|
|
360
|
+
explain?: boolean;
|
|
332
361
|
}
|
|
333
362
|
interface TraverseRequest {
|
|
334
363
|
action: "chain" | "neighborhood" | "path" | "subgraph";
|
|
@@ -617,6 +646,208 @@ interface MindGraphConfig {
|
|
|
617
646
|
/** Initial backoff in ms before first retry. Doubles each attempt. Default: 1000. */
|
|
618
647
|
retryBackoffMs?: number;
|
|
619
648
|
}
|
|
649
|
+
/** Field schema entry inside `OntologyObjectType.fields_json`. */
|
|
650
|
+
interface FieldDefinition {
|
|
651
|
+
name: string;
|
|
652
|
+
/** One of: string|number|integer|boolean|date|datetime|enum|reference|array|object|json */
|
|
653
|
+
type: string;
|
|
654
|
+
required?: boolean;
|
|
655
|
+
description?: string;
|
|
656
|
+
default?: unknown;
|
|
657
|
+
enum?: string[];
|
|
658
|
+
reference_object_type?: string;
|
|
659
|
+
array_item_type?: string;
|
|
660
|
+
extraction_hint?: string;
|
|
661
|
+
}
|
|
662
|
+
interface OntologySchema {
|
|
663
|
+
id: string;
|
|
664
|
+
org_id: string;
|
|
665
|
+
name: string;
|
|
666
|
+
description?: string;
|
|
667
|
+
status: "draft" | "active" | "deprecated" | "archived";
|
|
668
|
+
version: number;
|
|
669
|
+
propose_status?: "pending" | "running" | "ready" | "failed" | null;
|
|
670
|
+
propose_job_id?: string | null;
|
|
671
|
+
propose_error?: string | null;
|
|
672
|
+
created_by?: string | null;
|
|
673
|
+
updated_by?: string | null;
|
|
674
|
+
created_at: string;
|
|
675
|
+
updated_at: string;
|
|
676
|
+
activated_at?: string | null;
|
|
677
|
+
archived_at?: string | null;
|
|
678
|
+
}
|
|
679
|
+
interface OntologyObjectType {
|
|
680
|
+
id: string;
|
|
681
|
+
schema_id: string;
|
|
682
|
+
org_id: string;
|
|
683
|
+
name: string;
|
|
684
|
+
display_name?: string | null;
|
|
685
|
+
description?: string | null;
|
|
686
|
+
fields_json: FieldDefinition[];
|
|
687
|
+
required_fields: string[];
|
|
688
|
+
identity_fields: string[];
|
|
689
|
+
aliases: string[];
|
|
690
|
+
examples_json: Record<string, unknown>[];
|
|
691
|
+
extraction_hints?: string | null;
|
|
692
|
+
default_confidence: number;
|
|
693
|
+
review_policy: "always" | "low_confidence" | "never";
|
|
694
|
+
status: "active" | "deprecated" | "archived";
|
|
695
|
+
version: number;
|
|
696
|
+
created_at: string;
|
|
697
|
+
updated_at: string;
|
|
698
|
+
}
|
|
699
|
+
interface OntologyRelationType {
|
|
700
|
+
id: string;
|
|
701
|
+
schema_id: string;
|
|
702
|
+
org_id: string;
|
|
703
|
+
name: string;
|
|
704
|
+
display_name?: string | null;
|
|
705
|
+
description?: string | null;
|
|
706
|
+
source_type: string;
|
|
707
|
+
target_type: string;
|
|
708
|
+
cardinality?: "one_to_one" | "one_to_many" | "many_to_many" | null;
|
|
709
|
+
symmetric: boolean;
|
|
710
|
+
transitive: boolean;
|
|
711
|
+
inverse_relation_type?: string | null;
|
|
712
|
+
fields_json: FieldDefinition[];
|
|
713
|
+
extraction_hints?: string | null;
|
|
714
|
+
review_policy: "always" | "low_confidence" | "never";
|
|
715
|
+
status: "active" | "deprecated" | "archived";
|
|
716
|
+
version: number;
|
|
717
|
+
created_at: string;
|
|
718
|
+
updated_at: string;
|
|
719
|
+
}
|
|
720
|
+
interface OntologySchemaDetail extends OntologySchema {
|
|
721
|
+
object_types: OntologyObjectType[];
|
|
722
|
+
relation_types: OntologyRelationType[];
|
|
723
|
+
}
|
|
724
|
+
interface CreateOntologySchemaRequest {
|
|
725
|
+
name: string;
|
|
726
|
+
description?: string;
|
|
727
|
+
}
|
|
728
|
+
interface UpdateOntologySchemaRequest {
|
|
729
|
+
name?: string;
|
|
730
|
+
description?: string;
|
|
731
|
+
}
|
|
732
|
+
interface OntologyObjectTypeInput {
|
|
733
|
+
name: string;
|
|
734
|
+
display_name?: string;
|
|
735
|
+
description?: string;
|
|
736
|
+
fields?: FieldDefinition[];
|
|
737
|
+
required_fields?: string[];
|
|
738
|
+
identity_fields?: string[];
|
|
739
|
+
aliases?: string[];
|
|
740
|
+
examples?: Record<string, unknown>[];
|
|
741
|
+
extraction_hints?: string;
|
|
742
|
+
default_confidence?: number;
|
|
743
|
+
review_policy?: "always" | "low_confidence" | "never";
|
|
744
|
+
}
|
|
745
|
+
interface OntologyRelationTypeInput {
|
|
746
|
+
name: string;
|
|
747
|
+
display_name?: string;
|
|
748
|
+
description?: string;
|
|
749
|
+
source_type: string;
|
|
750
|
+
target_type: string;
|
|
751
|
+
cardinality?: "one_to_one" | "one_to_many" | "many_to_many";
|
|
752
|
+
symmetric?: boolean;
|
|
753
|
+
transitive?: boolean;
|
|
754
|
+
inverse_relation_type?: string;
|
|
755
|
+
fields?: FieldDefinition[];
|
|
756
|
+
extraction_hints?: string;
|
|
757
|
+
review_policy?: "always" | "low_confidence" | "never";
|
|
758
|
+
}
|
|
759
|
+
/** Status: pending | approved | approval_required | rejected | applied | apply_failed. */
|
|
760
|
+
interface OntologyProposal {
|
|
761
|
+
id: string;
|
|
762
|
+
org_id: string;
|
|
763
|
+
schema_id: string;
|
|
764
|
+
proposal_type: string;
|
|
765
|
+
proposed_by_agent_id?: string | null;
|
|
766
|
+
source_uids: string[];
|
|
767
|
+
source_scope_ids: string[];
|
|
768
|
+
changes_json: {
|
|
769
|
+
adds: Array<Record<string, unknown>>;
|
|
770
|
+
updates: Array<Record<string, unknown>>;
|
|
771
|
+
removes: Array<Record<string, unknown>>;
|
|
772
|
+
};
|
|
773
|
+
rationale?: string | null;
|
|
774
|
+
confidence?: number | null;
|
|
775
|
+
risk_level?: string | null;
|
|
776
|
+
review_status: string;
|
|
777
|
+
approval_uid?: string | null;
|
|
778
|
+
proposed_node_uid?: string | null;
|
|
779
|
+
applied_job_id?: string | null;
|
|
780
|
+
applied_error?: string | null;
|
|
781
|
+
apply_attempt_count: number;
|
|
782
|
+
edited_by?: string | null;
|
|
783
|
+
edited_at?: string | null;
|
|
784
|
+
original_snapshot?: Record<string, unknown> | null;
|
|
785
|
+
requires_manual_resolution: boolean;
|
|
786
|
+
created_at: string;
|
|
787
|
+
resolved_at?: string | null;
|
|
788
|
+
resolved_by?: string | null;
|
|
789
|
+
}
|
|
790
|
+
interface ProposalEdits {
|
|
791
|
+
canonical_name?: string;
|
|
792
|
+
fields?: Record<string, unknown>;
|
|
793
|
+
aliases?: string[];
|
|
794
|
+
}
|
|
795
|
+
interface ProposeOntologySchemaRequest {
|
|
796
|
+
description?: string;
|
|
797
|
+
template_hint?: "client_services" | "healthcare" | "supply_chain" | "research_intel" | "custom";
|
|
798
|
+
source_uids?: string[];
|
|
799
|
+
source_documents?: Array<{
|
|
800
|
+
content: string;
|
|
801
|
+
title?: string;
|
|
802
|
+
}>;
|
|
803
|
+
target_use_case?: string;
|
|
804
|
+
example_objects?: string[];
|
|
805
|
+
example_queries?: string[];
|
|
806
|
+
desired_workflows?: string[];
|
|
807
|
+
parent_schema_id?: string;
|
|
808
|
+
}
|
|
809
|
+
interface OntologyQueryRequest {
|
|
810
|
+
query: string;
|
|
811
|
+
schema_id: string;
|
|
812
|
+
object_types?: string[];
|
|
813
|
+
include_cognitive_context?: boolean;
|
|
814
|
+
include_sources?: boolean;
|
|
815
|
+
depth?: number;
|
|
816
|
+
limit?: number;
|
|
817
|
+
}
|
|
818
|
+
interface OntologyQueryResponse {
|
|
819
|
+
objects: GraphNode[];
|
|
820
|
+
relations: GraphEdge[];
|
|
821
|
+
cognitive_context: Record<string, GraphNode[]>;
|
|
822
|
+
external_refs: unknown[];
|
|
823
|
+
graph: {
|
|
824
|
+
nodes: GraphNode[];
|
|
825
|
+
edges: GraphEdge[];
|
|
826
|
+
};
|
|
827
|
+
provenance: Array<{
|
|
828
|
+
node_uid: string;
|
|
829
|
+
source_uid: string;
|
|
830
|
+
text_span: string;
|
|
831
|
+
}>;
|
|
832
|
+
confidence: {
|
|
833
|
+
overall: number;
|
|
834
|
+
};
|
|
835
|
+
truncated?: Record<string, boolean>;
|
|
836
|
+
}
|
|
837
|
+
interface LinkDomainObjectsRequest {
|
|
838
|
+
from_uid: string;
|
|
839
|
+
to_uid: string;
|
|
840
|
+
relation_type: string;
|
|
841
|
+
fields?: Record<string, unknown>;
|
|
842
|
+
confidence?: number;
|
|
843
|
+
agent_id?: string;
|
|
844
|
+
}
|
|
845
|
+
interface ExtractOntologyRequest {
|
|
846
|
+
ontology_schema_id: string;
|
|
847
|
+
source_uids: string[];
|
|
848
|
+
mode?: "propose_only" | "respect_policies" | "force_auto_apply";
|
|
849
|
+
}
|
|
850
|
+
type DomainObject = GraphNode;
|
|
620
851
|
|
|
621
852
|
declare class MindGraphError extends Error {
|
|
622
853
|
status: number;
|
|
@@ -836,12 +1067,17 @@ declare class MindGraph {
|
|
|
836
1067
|
include_edges?: boolean;
|
|
837
1068
|
include_chunks?: boolean;
|
|
838
1069
|
}): Promise<SearchResult[] | EnrichedSearchResponse>;
|
|
839
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* Hybrid BM25 + vector search with reciprocal rank fusion. Pass
|
|
1072
|
+
* `explain: true` to get per-leg contributions (`legs`) on each result —
|
|
1073
|
+
* the "why retrieved" detail (server ≥ 1.2.0; older servers ignore it).
|
|
1074
|
+
*/
|
|
840
1075
|
hybridSearch(query: string, opts?: {
|
|
841
1076
|
k?: number;
|
|
842
1077
|
node_types?: string[];
|
|
843
1078
|
layer?: string;
|
|
844
|
-
|
|
1079
|
+
explain?: boolean;
|
|
1080
|
+
}): Promise<HybridSearchResult[]>;
|
|
845
1081
|
getNodes(params?: {
|
|
846
1082
|
node_type?: string;
|
|
847
1083
|
layer?: string;
|
|
@@ -980,6 +1216,113 @@ declare class MindGraph {
|
|
|
980
1216
|
* Returns a `job_id` immediately; poll `getJob(id)` for progress.
|
|
981
1217
|
*/
|
|
982
1218
|
runSynthesis(projectUid: string): Promise<SynthesisJobResponse>;
|
|
1219
|
+
listOntologySchemas(): Promise<{
|
|
1220
|
+
items: OntologySchema[];
|
|
1221
|
+
}>;
|
|
1222
|
+
getOntologySchema(id: string): Promise<OntologySchemaDetail>;
|
|
1223
|
+
createOntologySchema(req: CreateOntologySchemaRequest): Promise<OntologySchema>;
|
|
1224
|
+
updateOntologySchema(id: string, req: UpdateOntologySchemaRequest): Promise<OntologySchema>;
|
|
1225
|
+
activateOntologySchema(id: string): Promise<OntologySchema>;
|
|
1226
|
+
deprecateOntologySchema(id: string): Promise<OntologySchema>;
|
|
1227
|
+
archiveOntologySchema(id: string): Promise<OntologySchema>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Kick off an LLM-driven schema proposal job.
|
|
1230
|
+
* Returns immediately with `{ schema_id, job_id }`; poll
|
|
1231
|
+
* `getOntologySchema(schema_id)` for streaming progress.
|
|
1232
|
+
*/
|
|
1233
|
+
proposeOntologySchema(req: ProposeOntologySchemaRequest): Promise<{
|
|
1234
|
+
schema_id: string;
|
|
1235
|
+
job_id: string;
|
|
1236
|
+
}>;
|
|
1237
|
+
testOntologySchema(id: string, opts?: {
|
|
1238
|
+
example_queries?: string[];
|
|
1239
|
+
}): Promise<{
|
|
1240
|
+
job_id: string;
|
|
1241
|
+
}>;
|
|
1242
|
+
addOntologyObjectType(schemaId: string, req: OntologyObjectTypeInput): Promise<OntologyObjectType>;
|
|
1243
|
+
updateOntologyObjectType(schemaId: string, typeId: string, req: Partial<OntologyObjectTypeInput>): Promise<OntologyObjectType>;
|
|
1244
|
+
deleteOntologyObjectType(schemaId: string, typeId: string): Promise<OntologyObjectType>;
|
|
1245
|
+
addOntologyRelationType(schemaId: string, req: OntologyRelationTypeInput): Promise<OntologyRelationType>;
|
|
1246
|
+
updateOntologyRelationType(schemaId: string, typeId: string, req: Partial<OntologyRelationTypeInput>): Promise<OntologyRelationType>;
|
|
1247
|
+
deleteOntologyRelationType(schemaId: string, typeId: string): Promise<OntologyRelationType>;
|
|
1248
|
+
listOntologyProposals(opts?: {
|
|
1249
|
+
status?: string;
|
|
1250
|
+
schema_id?: string;
|
|
1251
|
+
object_type?: string;
|
|
1252
|
+
limit?: number;
|
|
1253
|
+
offset?: number;
|
|
1254
|
+
}): Promise<{
|
|
1255
|
+
items: OntologyProposal[];
|
|
1256
|
+
limit: number;
|
|
1257
|
+
offset: number;
|
|
1258
|
+
}>;
|
|
1259
|
+
getOntologyProposal(id: string): Promise<OntologyProposal>;
|
|
1260
|
+
patchOntologyProposal(id: string, req: {
|
|
1261
|
+
edits: ProposalEdits;
|
|
1262
|
+
}): Promise<OntologyProposal>;
|
|
1263
|
+
approveOntologyProposal(id: string, opts?: {
|
|
1264
|
+
feedback?: string;
|
|
1265
|
+
edits?: ProposalEdits;
|
|
1266
|
+
}): Promise<OntologyProposal>;
|
|
1267
|
+
rejectOntologyProposal(id: string, reason?: string): Promise<OntologyProposal>;
|
|
1268
|
+
applyOntologyProposal(id: string): Promise<{
|
|
1269
|
+
id: string;
|
|
1270
|
+
queued: boolean;
|
|
1271
|
+
}>;
|
|
1272
|
+
batchApproveOntologyProposals(ids: string[], feedback?: string): Promise<{
|
|
1273
|
+
processed: string[];
|
|
1274
|
+
skipped: {
|
|
1275
|
+
id: string;
|
|
1276
|
+
reason: string;
|
|
1277
|
+
}[];
|
|
1278
|
+
}>;
|
|
1279
|
+
batchRejectOntologyProposals(ids: string[], reason?: string): Promise<{
|
|
1280
|
+
processed: string[];
|
|
1281
|
+
skipped: {
|
|
1282
|
+
id: string;
|
|
1283
|
+
reason: string;
|
|
1284
|
+
}[];
|
|
1285
|
+
}>;
|
|
1286
|
+
queryOntology(req: OntologyQueryRequest): Promise<OntologyQueryResponse>;
|
|
1287
|
+
getDomainObject(uid: string): Promise<DomainObject>;
|
|
1288
|
+
getDomainObjectContext(uid: string, depth?: number): Promise<OntologyQueryResponse>;
|
|
1289
|
+
getDomainObjectHistory(uid: string): Promise<{
|
|
1290
|
+
versions: Array<{
|
|
1291
|
+
version: number;
|
|
1292
|
+
changed_at: string;
|
|
1293
|
+
changed_by: string;
|
|
1294
|
+
change_reason?: string;
|
|
1295
|
+
snapshot: unknown;
|
|
1296
|
+
}>;
|
|
1297
|
+
}>;
|
|
1298
|
+
listDomainObjects(opts: {
|
|
1299
|
+
schema_id: string;
|
|
1300
|
+
object_type?: string;
|
|
1301
|
+
limit?: number;
|
|
1302
|
+
offset?: number;
|
|
1303
|
+
sort?: string;
|
|
1304
|
+
}): Promise<{
|
|
1305
|
+
items: DomainObject[];
|
|
1306
|
+
limit: number;
|
|
1307
|
+
offset: number;
|
|
1308
|
+
has_more: boolean;
|
|
1309
|
+
}>;
|
|
1310
|
+
searchDomainObjects(query: string, opts?: {
|
|
1311
|
+
schema_id?: string;
|
|
1312
|
+
object_types?: string[];
|
|
1313
|
+
limit?: number;
|
|
1314
|
+
}): Promise<{
|
|
1315
|
+
items: Array<{
|
|
1316
|
+
object: DomainObject;
|
|
1317
|
+
score: number;
|
|
1318
|
+
}>;
|
|
1319
|
+
}>;
|
|
1320
|
+
linkDomainObjects(req: LinkDomainObjectsRequest): Promise<{
|
|
1321
|
+
edge_uid: string;
|
|
1322
|
+
}>;
|
|
1323
|
+
extractOntology(req: ExtractOntologyRequest): Promise<{
|
|
1324
|
+
job_id: string;
|
|
1325
|
+
}>;
|
|
983
1326
|
}
|
|
984
1327
|
|
|
985
1328
|
export { type AnalogyCandidate, type ArgumentRequest, type ArticleResult, type BatchRequest, type CaptureRequest, type ClaimHub, type ClearResponse, type ClusterClaimSample, type ClusteredClaimHub, type CommitmentRequest, type ConceptCluster, type DecayRequest, type DeliberationRequest, type DialecticalPair, type DistillRequest, type DocumentRef, type EnrichedSearchResponse, type EntityBridge, type EntityRequest, type EpistemicCounts, type EventProps, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type ListArticlesResponse, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type NationProps, type OrganizationProps, type PathStep, type PersonProps, type PlaceProps, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RankedClaimHub, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchChunk, type SearchResult, type SessionRequest, type SignalsQuery, type SignalsResponse, type StructureRequest, type SynthesisJobResponse, type TheorySupportGap, type TraverseRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,29 @@ interface SearchResult {
|
|
|
30
30
|
node_type: string;
|
|
31
31
|
score: number;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* One retrieval leg's contribution to a fused hybrid result — the
|
|
35
|
+
* "why retrieved" detail. The fused score reconstructs exactly as
|
|
36
|
+
* `Σ 1/(60 + rank)` over a result's legs.
|
|
37
|
+
*/
|
|
38
|
+
interface LegContribution {
|
|
39
|
+
/** Which leg surfaced the result: `"fts"` (keyword/BM25) or `"vec"` (vector). */
|
|
40
|
+
leg: string;
|
|
41
|
+
/** 1-based within-leg rank the fusion used. */
|
|
42
|
+
rank: number;
|
|
43
|
+
/**
|
|
44
|
+
* The leg's raw score (BM25 relevance for `fts`, cosine similarity for
|
|
45
|
+
* `vec`). Not comparable across legs — RRF fuses by rank, not score.
|
|
46
|
+
*/
|
|
47
|
+
score: number;
|
|
48
|
+
}
|
|
49
|
+
/** A `/retrieve` hybrid result: the full node plus the fused RRF score. */
|
|
50
|
+
interface HybridSearchResult {
|
|
51
|
+
node: GraphNode;
|
|
52
|
+
score: number;
|
|
53
|
+
/** Per-leg contributions; present only when the request set `explain: true`. */
|
|
54
|
+
legs?: LegContribution[];
|
|
55
|
+
}
|
|
33
56
|
interface SearchChunk {
|
|
34
57
|
chunk_uid: string;
|
|
35
58
|
content: string;
|
|
@@ -329,6 +352,12 @@ interface RetrieveRequest {
|
|
|
329
352
|
salience_min?: number;
|
|
330
353
|
limit?: number;
|
|
331
354
|
offset?: number;
|
|
355
|
+
/**
|
|
356
|
+
* Hybrid action only: attach per-leg contributions (`legs`) to each
|
|
357
|
+
* result — the "why retrieved" detail. Requires server ≥ 1.2.0; older
|
|
358
|
+
* servers ignore the field.
|
|
359
|
+
*/
|
|
360
|
+
explain?: boolean;
|
|
332
361
|
}
|
|
333
362
|
interface TraverseRequest {
|
|
334
363
|
action: "chain" | "neighborhood" | "path" | "subgraph";
|
|
@@ -617,6 +646,208 @@ interface MindGraphConfig {
|
|
|
617
646
|
/** Initial backoff in ms before first retry. Doubles each attempt. Default: 1000. */
|
|
618
647
|
retryBackoffMs?: number;
|
|
619
648
|
}
|
|
649
|
+
/** Field schema entry inside `OntologyObjectType.fields_json`. */
|
|
650
|
+
interface FieldDefinition {
|
|
651
|
+
name: string;
|
|
652
|
+
/** One of: string|number|integer|boolean|date|datetime|enum|reference|array|object|json */
|
|
653
|
+
type: string;
|
|
654
|
+
required?: boolean;
|
|
655
|
+
description?: string;
|
|
656
|
+
default?: unknown;
|
|
657
|
+
enum?: string[];
|
|
658
|
+
reference_object_type?: string;
|
|
659
|
+
array_item_type?: string;
|
|
660
|
+
extraction_hint?: string;
|
|
661
|
+
}
|
|
662
|
+
interface OntologySchema {
|
|
663
|
+
id: string;
|
|
664
|
+
org_id: string;
|
|
665
|
+
name: string;
|
|
666
|
+
description?: string;
|
|
667
|
+
status: "draft" | "active" | "deprecated" | "archived";
|
|
668
|
+
version: number;
|
|
669
|
+
propose_status?: "pending" | "running" | "ready" | "failed" | null;
|
|
670
|
+
propose_job_id?: string | null;
|
|
671
|
+
propose_error?: string | null;
|
|
672
|
+
created_by?: string | null;
|
|
673
|
+
updated_by?: string | null;
|
|
674
|
+
created_at: string;
|
|
675
|
+
updated_at: string;
|
|
676
|
+
activated_at?: string | null;
|
|
677
|
+
archived_at?: string | null;
|
|
678
|
+
}
|
|
679
|
+
interface OntologyObjectType {
|
|
680
|
+
id: string;
|
|
681
|
+
schema_id: string;
|
|
682
|
+
org_id: string;
|
|
683
|
+
name: string;
|
|
684
|
+
display_name?: string | null;
|
|
685
|
+
description?: string | null;
|
|
686
|
+
fields_json: FieldDefinition[];
|
|
687
|
+
required_fields: string[];
|
|
688
|
+
identity_fields: string[];
|
|
689
|
+
aliases: string[];
|
|
690
|
+
examples_json: Record<string, unknown>[];
|
|
691
|
+
extraction_hints?: string | null;
|
|
692
|
+
default_confidence: number;
|
|
693
|
+
review_policy: "always" | "low_confidence" | "never";
|
|
694
|
+
status: "active" | "deprecated" | "archived";
|
|
695
|
+
version: number;
|
|
696
|
+
created_at: string;
|
|
697
|
+
updated_at: string;
|
|
698
|
+
}
|
|
699
|
+
interface OntologyRelationType {
|
|
700
|
+
id: string;
|
|
701
|
+
schema_id: string;
|
|
702
|
+
org_id: string;
|
|
703
|
+
name: string;
|
|
704
|
+
display_name?: string | null;
|
|
705
|
+
description?: string | null;
|
|
706
|
+
source_type: string;
|
|
707
|
+
target_type: string;
|
|
708
|
+
cardinality?: "one_to_one" | "one_to_many" | "many_to_many" | null;
|
|
709
|
+
symmetric: boolean;
|
|
710
|
+
transitive: boolean;
|
|
711
|
+
inverse_relation_type?: string | null;
|
|
712
|
+
fields_json: FieldDefinition[];
|
|
713
|
+
extraction_hints?: string | null;
|
|
714
|
+
review_policy: "always" | "low_confidence" | "never";
|
|
715
|
+
status: "active" | "deprecated" | "archived";
|
|
716
|
+
version: number;
|
|
717
|
+
created_at: string;
|
|
718
|
+
updated_at: string;
|
|
719
|
+
}
|
|
720
|
+
interface OntologySchemaDetail extends OntologySchema {
|
|
721
|
+
object_types: OntologyObjectType[];
|
|
722
|
+
relation_types: OntologyRelationType[];
|
|
723
|
+
}
|
|
724
|
+
interface CreateOntologySchemaRequest {
|
|
725
|
+
name: string;
|
|
726
|
+
description?: string;
|
|
727
|
+
}
|
|
728
|
+
interface UpdateOntologySchemaRequest {
|
|
729
|
+
name?: string;
|
|
730
|
+
description?: string;
|
|
731
|
+
}
|
|
732
|
+
interface OntologyObjectTypeInput {
|
|
733
|
+
name: string;
|
|
734
|
+
display_name?: string;
|
|
735
|
+
description?: string;
|
|
736
|
+
fields?: FieldDefinition[];
|
|
737
|
+
required_fields?: string[];
|
|
738
|
+
identity_fields?: string[];
|
|
739
|
+
aliases?: string[];
|
|
740
|
+
examples?: Record<string, unknown>[];
|
|
741
|
+
extraction_hints?: string;
|
|
742
|
+
default_confidence?: number;
|
|
743
|
+
review_policy?: "always" | "low_confidence" | "never";
|
|
744
|
+
}
|
|
745
|
+
interface OntologyRelationTypeInput {
|
|
746
|
+
name: string;
|
|
747
|
+
display_name?: string;
|
|
748
|
+
description?: string;
|
|
749
|
+
source_type: string;
|
|
750
|
+
target_type: string;
|
|
751
|
+
cardinality?: "one_to_one" | "one_to_many" | "many_to_many";
|
|
752
|
+
symmetric?: boolean;
|
|
753
|
+
transitive?: boolean;
|
|
754
|
+
inverse_relation_type?: string;
|
|
755
|
+
fields?: FieldDefinition[];
|
|
756
|
+
extraction_hints?: string;
|
|
757
|
+
review_policy?: "always" | "low_confidence" | "never";
|
|
758
|
+
}
|
|
759
|
+
/** Status: pending | approved | approval_required | rejected | applied | apply_failed. */
|
|
760
|
+
interface OntologyProposal {
|
|
761
|
+
id: string;
|
|
762
|
+
org_id: string;
|
|
763
|
+
schema_id: string;
|
|
764
|
+
proposal_type: string;
|
|
765
|
+
proposed_by_agent_id?: string | null;
|
|
766
|
+
source_uids: string[];
|
|
767
|
+
source_scope_ids: string[];
|
|
768
|
+
changes_json: {
|
|
769
|
+
adds: Array<Record<string, unknown>>;
|
|
770
|
+
updates: Array<Record<string, unknown>>;
|
|
771
|
+
removes: Array<Record<string, unknown>>;
|
|
772
|
+
};
|
|
773
|
+
rationale?: string | null;
|
|
774
|
+
confidence?: number | null;
|
|
775
|
+
risk_level?: string | null;
|
|
776
|
+
review_status: string;
|
|
777
|
+
approval_uid?: string | null;
|
|
778
|
+
proposed_node_uid?: string | null;
|
|
779
|
+
applied_job_id?: string | null;
|
|
780
|
+
applied_error?: string | null;
|
|
781
|
+
apply_attempt_count: number;
|
|
782
|
+
edited_by?: string | null;
|
|
783
|
+
edited_at?: string | null;
|
|
784
|
+
original_snapshot?: Record<string, unknown> | null;
|
|
785
|
+
requires_manual_resolution: boolean;
|
|
786
|
+
created_at: string;
|
|
787
|
+
resolved_at?: string | null;
|
|
788
|
+
resolved_by?: string | null;
|
|
789
|
+
}
|
|
790
|
+
interface ProposalEdits {
|
|
791
|
+
canonical_name?: string;
|
|
792
|
+
fields?: Record<string, unknown>;
|
|
793
|
+
aliases?: string[];
|
|
794
|
+
}
|
|
795
|
+
interface ProposeOntologySchemaRequest {
|
|
796
|
+
description?: string;
|
|
797
|
+
template_hint?: "client_services" | "healthcare" | "supply_chain" | "research_intel" | "custom";
|
|
798
|
+
source_uids?: string[];
|
|
799
|
+
source_documents?: Array<{
|
|
800
|
+
content: string;
|
|
801
|
+
title?: string;
|
|
802
|
+
}>;
|
|
803
|
+
target_use_case?: string;
|
|
804
|
+
example_objects?: string[];
|
|
805
|
+
example_queries?: string[];
|
|
806
|
+
desired_workflows?: string[];
|
|
807
|
+
parent_schema_id?: string;
|
|
808
|
+
}
|
|
809
|
+
interface OntologyQueryRequest {
|
|
810
|
+
query: string;
|
|
811
|
+
schema_id: string;
|
|
812
|
+
object_types?: string[];
|
|
813
|
+
include_cognitive_context?: boolean;
|
|
814
|
+
include_sources?: boolean;
|
|
815
|
+
depth?: number;
|
|
816
|
+
limit?: number;
|
|
817
|
+
}
|
|
818
|
+
interface OntologyQueryResponse {
|
|
819
|
+
objects: GraphNode[];
|
|
820
|
+
relations: GraphEdge[];
|
|
821
|
+
cognitive_context: Record<string, GraphNode[]>;
|
|
822
|
+
external_refs: unknown[];
|
|
823
|
+
graph: {
|
|
824
|
+
nodes: GraphNode[];
|
|
825
|
+
edges: GraphEdge[];
|
|
826
|
+
};
|
|
827
|
+
provenance: Array<{
|
|
828
|
+
node_uid: string;
|
|
829
|
+
source_uid: string;
|
|
830
|
+
text_span: string;
|
|
831
|
+
}>;
|
|
832
|
+
confidence: {
|
|
833
|
+
overall: number;
|
|
834
|
+
};
|
|
835
|
+
truncated?: Record<string, boolean>;
|
|
836
|
+
}
|
|
837
|
+
interface LinkDomainObjectsRequest {
|
|
838
|
+
from_uid: string;
|
|
839
|
+
to_uid: string;
|
|
840
|
+
relation_type: string;
|
|
841
|
+
fields?: Record<string, unknown>;
|
|
842
|
+
confidence?: number;
|
|
843
|
+
agent_id?: string;
|
|
844
|
+
}
|
|
845
|
+
interface ExtractOntologyRequest {
|
|
846
|
+
ontology_schema_id: string;
|
|
847
|
+
source_uids: string[];
|
|
848
|
+
mode?: "propose_only" | "respect_policies" | "force_auto_apply";
|
|
849
|
+
}
|
|
850
|
+
type DomainObject = GraphNode;
|
|
620
851
|
|
|
621
852
|
declare class MindGraphError extends Error {
|
|
622
853
|
status: number;
|
|
@@ -836,12 +1067,17 @@ declare class MindGraph {
|
|
|
836
1067
|
include_edges?: boolean;
|
|
837
1068
|
include_chunks?: boolean;
|
|
838
1069
|
}): Promise<SearchResult[] | EnrichedSearchResponse>;
|
|
839
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* Hybrid BM25 + vector search with reciprocal rank fusion. Pass
|
|
1072
|
+
* `explain: true` to get per-leg contributions (`legs`) on each result —
|
|
1073
|
+
* the "why retrieved" detail (server ≥ 1.2.0; older servers ignore it).
|
|
1074
|
+
*/
|
|
840
1075
|
hybridSearch(query: string, opts?: {
|
|
841
1076
|
k?: number;
|
|
842
1077
|
node_types?: string[];
|
|
843
1078
|
layer?: string;
|
|
844
|
-
|
|
1079
|
+
explain?: boolean;
|
|
1080
|
+
}): Promise<HybridSearchResult[]>;
|
|
845
1081
|
getNodes(params?: {
|
|
846
1082
|
node_type?: string;
|
|
847
1083
|
layer?: string;
|
|
@@ -980,6 +1216,113 @@ declare class MindGraph {
|
|
|
980
1216
|
* Returns a `job_id` immediately; poll `getJob(id)` for progress.
|
|
981
1217
|
*/
|
|
982
1218
|
runSynthesis(projectUid: string): Promise<SynthesisJobResponse>;
|
|
1219
|
+
listOntologySchemas(): Promise<{
|
|
1220
|
+
items: OntologySchema[];
|
|
1221
|
+
}>;
|
|
1222
|
+
getOntologySchema(id: string): Promise<OntologySchemaDetail>;
|
|
1223
|
+
createOntologySchema(req: CreateOntologySchemaRequest): Promise<OntologySchema>;
|
|
1224
|
+
updateOntologySchema(id: string, req: UpdateOntologySchemaRequest): Promise<OntologySchema>;
|
|
1225
|
+
activateOntologySchema(id: string): Promise<OntologySchema>;
|
|
1226
|
+
deprecateOntologySchema(id: string): Promise<OntologySchema>;
|
|
1227
|
+
archiveOntologySchema(id: string): Promise<OntologySchema>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Kick off an LLM-driven schema proposal job.
|
|
1230
|
+
* Returns immediately with `{ schema_id, job_id }`; poll
|
|
1231
|
+
* `getOntologySchema(schema_id)` for streaming progress.
|
|
1232
|
+
*/
|
|
1233
|
+
proposeOntologySchema(req: ProposeOntologySchemaRequest): Promise<{
|
|
1234
|
+
schema_id: string;
|
|
1235
|
+
job_id: string;
|
|
1236
|
+
}>;
|
|
1237
|
+
testOntologySchema(id: string, opts?: {
|
|
1238
|
+
example_queries?: string[];
|
|
1239
|
+
}): Promise<{
|
|
1240
|
+
job_id: string;
|
|
1241
|
+
}>;
|
|
1242
|
+
addOntologyObjectType(schemaId: string, req: OntologyObjectTypeInput): Promise<OntologyObjectType>;
|
|
1243
|
+
updateOntologyObjectType(schemaId: string, typeId: string, req: Partial<OntologyObjectTypeInput>): Promise<OntologyObjectType>;
|
|
1244
|
+
deleteOntologyObjectType(schemaId: string, typeId: string): Promise<OntologyObjectType>;
|
|
1245
|
+
addOntologyRelationType(schemaId: string, req: OntologyRelationTypeInput): Promise<OntologyRelationType>;
|
|
1246
|
+
updateOntologyRelationType(schemaId: string, typeId: string, req: Partial<OntologyRelationTypeInput>): Promise<OntologyRelationType>;
|
|
1247
|
+
deleteOntologyRelationType(schemaId: string, typeId: string): Promise<OntologyRelationType>;
|
|
1248
|
+
listOntologyProposals(opts?: {
|
|
1249
|
+
status?: string;
|
|
1250
|
+
schema_id?: string;
|
|
1251
|
+
object_type?: string;
|
|
1252
|
+
limit?: number;
|
|
1253
|
+
offset?: number;
|
|
1254
|
+
}): Promise<{
|
|
1255
|
+
items: OntologyProposal[];
|
|
1256
|
+
limit: number;
|
|
1257
|
+
offset: number;
|
|
1258
|
+
}>;
|
|
1259
|
+
getOntologyProposal(id: string): Promise<OntologyProposal>;
|
|
1260
|
+
patchOntologyProposal(id: string, req: {
|
|
1261
|
+
edits: ProposalEdits;
|
|
1262
|
+
}): Promise<OntologyProposal>;
|
|
1263
|
+
approveOntologyProposal(id: string, opts?: {
|
|
1264
|
+
feedback?: string;
|
|
1265
|
+
edits?: ProposalEdits;
|
|
1266
|
+
}): Promise<OntologyProposal>;
|
|
1267
|
+
rejectOntologyProposal(id: string, reason?: string): Promise<OntologyProposal>;
|
|
1268
|
+
applyOntologyProposal(id: string): Promise<{
|
|
1269
|
+
id: string;
|
|
1270
|
+
queued: boolean;
|
|
1271
|
+
}>;
|
|
1272
|
+
batchApproveOntologyProposals(ids: string[], feedback?: string): Promise<{
|
|
1273
|
+
processed: string[];
|
|
1274
|
+
skipped: {
|
|
1275
|
+
id: string;
|
|
1276
|
+
reason: string;
|
|
1277
|
+
}[];
|
|
1278
|
+
}>;
|
|
1279
|
+
batchRejectOntologyProposals(ids: string[], reason?: string): Promise<{
|
|
1280
|
+
processed: string[];
|
|
1281
|
+
skipped: {
|
|
1282
|
+
id: string;
|
|
1283
|
+
reason: string;
|
|
1284
|
+
}[];
|
|
1285
|
+
}>;
|
|
1286
|
+
queryOntology(req: OntologyQueryRequest): Promise<OntologyQueryResponse>;
|
|
1287
|
+
getDomainObject(uid: string): Promise<DomainObject>;
|
|
1288
|
+
getDomainObjectContext(uid: string, depth?: number): Promise<OntologyQueryResponse>;
|
|
1289
|
+
getDomainObjectHistory(uid: string): Promise<{
|
|
1290
|
+
versions: Array<{
|
|
1291
|
+
version: number;
|
|
1292
|
+
changed_at: string;
|
|
1293
|
+
changed_by: string;
|
|
1294
|
+
change_reason?: string;
|
|
1295
|
+
snapshot: unknown;
|
|
1296
|
+
}>;
|
|
1297
|
+
}>;
|
|
1298
|
+
listDomainObjects(opts: {
|
|
1299
|
+
schema_id: string;
|
|
1300
|
+
object_type?: string;
|
|
1301
|
+
limit?: number;
|
|
1302
|
+
offset?: number;
|
|
1303
|
+
sort?: string;
|
|
1304
|
+
}): Promise<{
|
|
1305
|
+
items: DomainObject[];
|
|
1306
|
+
limit: number;
|
|
1307
|
+
offset: number;
|
|
1308
|
+
has_more: boolean;
|
|
1309
|
+
}>;
|
|
1310
|
+
searchDomainObjects(query: string, opts?: {
|
|
1311
|
+
schema_id?: string;
|
|
1312
|
+
object_types?: string[];
|
|
1313
|
+
limit?: number;
|
|
1314
|
+
}): Promise<{
|
|
1315
|
+
items: Array<{
|
|
1316
|
+
object: DomainObject;
|
|
1317
|
+
score: number;
|
|
1318
|
+
}>;
|
|
1319
|
+
}>;
|
|
1320
|
+
linkDomainObjects(req: LinkDomainObjectsRequest): Promise<{
|
|
1321
|
+
edge_uid: string;
|
|
1322
|
+
}>;
|
|
1323
|
+
extractOntology(req: ExtractOntologyRequest): Promise<{
|
|
1324
|
+
job_id: string;
|
|
1325
|
+
}>;
|
|
983
1326
|
}
|
|
984
1327
|
|
|
985
1328
|
export { type AnalogyCandidate, type ArgumentRequest, type ArticleResult, type BatchRequest, type CaptureRequest, type ClaimHub, type ClearResponse, type ClusterClaimSample, type ClusteredClaimHub, type CommitmentRequest, type ConceptCluster, type DecayRequest, type DeliberationRequest, type DialecticalPair, type DistillRequest, type DocumentRef, type EnrichedSearchResponse, type EntityBridge, type EntityRequest, type EpistemicCounts, type EventProps, type EvolveRequest, type ExecutionRequest, type GovernanceRequest, type GraphEdge, type GraphNode, type IngestChunkRequest, type IngestChunkResponse, type IngestDocumentRequest, type IngestDocumentResponse, type IngestSessionRequest, type InquiryRequest, type Job, type ListArticlesResponse, type MemoryConfigRequest, MindGraph, type MindGraphConfig, MindGraphError, type NationProps, type OrganizationProps, type PathStep, type PersonProps, type PlaceProps, type PlanRequest, type ProcedureRequest, type PurgeRequest, type RankedClaimHub, type RetrieveContextRequest, type RetrieveContextResponse, type RetrieveRequest, type RiskRequest, type SearchChunk, type SearchResult, type SessionRequest, type SignalsQuery, type SignalsResponse, type StructureRequest, type SynthesisJobResponse, type TheorySupportGap, type TraverseRequest };
|
package/dist/index.js
CHANGED
|
@@ -397,7 +397,11 @@ var MindGraph = class {
|
|
|
397
397
|
async search(query, opts) {
|
|
398
398
|
return this.post("/search", { query, ...opts });
|
|
399
399
|
}
|
|
400
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* Hybrid BM25 + vector search with reciprocal rank fusion. Pass
|
|
402
|
+
* `explain: true` to get per-leg contributions (`legs`) on each result —
|
|
403
|
+
* the "why retrieved" detail (server ≥ 1.2.0; older servers ignore it).
|
|
404
|
+
*/
|
|
401
405
|
async hybridSearch(query, opts) {
|
|
402
406
|
return this.post("/retrieve", {
|
|
403
407
|
action: "hybrid",
|
|
@@ -639,6 +643,136 @@ var MindGraph = class {
|
|
|
639
643
|
async runSynthesis(projectUid) {
|
|
640
644
|
return this.post(`/synthesis/run/${projectUid}`, {});
|
|
641
645
|
}
|
|
646
|
+
// ============================================================================
|
|
647
|
+
// Operational Ontology Layer (Layer 7)
|
|
648
|
+
// ============================================================================
|
|
649
|
+
// ---- Schema management (cloud Postgres) ----
|
|
650
|
+
async listOntologySchemas() {
|
|
651
|
+
return this.get("/v1/ontology/schemas");
|
|
652
|
+
}
|
|
653
|
+
async getOntologySchema(id) {
|
|
654
|
+
return this.get(`/v1/ontology/schemas/${id}`);
|
|
655
|
+
}
|
|
656
|
+
async createOntologySchema(req) {
|
|
657
|
+
return this.post("/v1/ontology/schemas", req);
|
|
658
|
+
}
|
|
659
|
+
async updateOntologySchema(id, req) {
|
|
660
|
+
return this.patch(`/v1/ontology/schemas/${id}`, req);
|
|
661
|
+
}
|
|
662
|
+
async activateOntologySchema(id) {
|
|
663
|
+
return this.post(`/v1/ontology/schemas/${id}/activate`, {});
|
|
664
|
+
}
|
|
665
|
+
async deprecateOntologySchema(id) {
|
|
666
|
+
return this.post(`/v1/ontology/schemas/${id}/deprecate`, {});
|
|
667
|
+
}
|
|
668
|
+
async archiveOntologySchema(id) {
|
|
669
|
+
return this.del(`/v1/ontology/schemas/${id}`);
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Kick off an LLM-driven schema proposal job.
|
|
673
|
+
* Returns immediately with `{ schema_id, job_id }`; poll
|
|
674
|
+
* `getOntologySchema(schema_id)` for streaming progress.
|
|
675
|
+
*/
|
|
676
|
+
async proposeOntologySchema(req) {
|
|
677
|
+
return this.post("/v1/ontology/propose-schema", req);
|
|
678
|
+
}
|
|
679
|
+
async testOntologySchema(id, opts) {
|
|
680
|
+
return this.post(`/v1/ontology/schemas/${id}/test`, opts ?? {});
|
|
681
|
+
}
|
|
682
|
+
// ---- Schema sub-resources ----
|
|
683
|
+
async addOntologyObjectType(schemaId, req) {
|
|
684
|
+
return this.post(`/v1/ontology/schemas/${schemaId}/object-types`, req);
|
|
685
|
+
}
|
|
686
|
+
async updateOntologyObjectType(schemaId, typeId, req) {
|
|
687
|
+
return this.patch(
|
|
688
|
+
`/v1/ontology/schemas/${schemaId}/object-types/${typeId}`,
|
|
689
|
+
req
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
async deleteOntologyObjectType(schemaId, typeId) {
|
|
693
|
+
return this.del(
|
|
694
|
+
`/v1/ontology/schemas/${schemaId}/object-types/${typeId}`
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
async addOntologyRelationType(schemaId, req) {
|
|
698
|
+
return this.post(`/v1/ontology/schemas/${schemaId}/relation-types`, req);
|
|
699
|
+
}
|
|
700
|
+
async updateOntologyRelationType(schemaId, typeId, req) {
|
|
701
|
+
return this.patch(
|
|
702
|
+
`/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`,
|
|
703
|
+
req
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
async deleteOntologyRelationType(schemaId, typeId) {
|
|
707
|
+
return this.del(
|
|
708
|
+
`/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
// ---- Proposals ----
|
|
712
|
+
async listOntologyProposals(opts) {
|
|
713
|
+
const q = new URLSearchParams();
|
|
714
|
+
if (opts?.status) q.set("status", opts.status);
|
|
715
|
+
if (opts?.schema_id) q.set("schema_id", opts.schema_id);
|
|
716
|
+
if (opts?.object_type) q.set("object_type", opts.object_type);
|
|
717
|
+
if (opts?.limit != null) q.set("limit", String(opts.limit));
|
|
718
|
+
if (opts?.offset != null) q.set("offset", String(opts.offset));
|
|
719
|
+
const qs = q.toString();
|
|
720
|
+
return this.get(`/v1/ontology/proposals${qs ? `?${qs}` : ""}`);
|
|
721
|
+
}
|
|
722
|
+
async getOntologyProposal(id) {
|
|
723
|
+
return this.get(`/v1/ontology/proposals/${id}`);
|
|
724
|
+
}
|
|
725
|
+
async patchOntologyProposal(id, req) {
|
|
726
|
+
return this.patch(`/v1/ontology/proposals/${id}`, req);
|
|
727
|
+
}
|
|
728
|
+
async approveOntologyProposal(id, opts) {
|
|
729
|
+
return this.post(`/v1/ontology/proposals/${id}/approve`, opts ?? {});
|
|
730
|
+
}
|
|
731
|
+
async rejectOntologyProposal(id, reason) {
|
|
732
|
+
return this.post(`/v1/ontology/proposals/${id}/reject`, { reason });
|
|
733
|
+
}
|
|
734
|
+
async applyOntologyProposal(id) {
|
|
735
|
+
return this.post(`/v1/ontology/proposals/${id}/apply`, {});
|
|
736
|
+
}
|
|
737
|
+
async batchApproveOntologyProposals(ids, feedback) {
|
|
738
|
+
return this.post("/v1/ontology/proposals/batch-approve", { ids, feedback });
|
|
739
|
+
}
|
|
740
|
+
async batchRejectOntologyProposals(ids, reason) {
|
|
741
|
+
return this.post("/v1/ontology/proposals/batch-reject", { ids, reason });
|
|
742
|
+
}
|
|
743
|
+
// ---- Retrieval (graph server) ----
|
|
744
|
+
async queryOntology(req) {
|
|
745
|
+
return this.post("/ontology/query", req);
|
|
746
|
+
}
|
|
747
|
+
async getDomainObject(uid) {
|
|
748
|
+
return this.get(`/ontology/object/${uid}`);
|
|
749
|
+
}
|
|
750
|
+
async getDomainObjectContext(uid, depth) {
|
|
751
|
+
const qs = depth != null ? `?depth=${depth}` : "";
|
|
752
|
+
return this.get(`/ontology/object/${uid}/context${qs}`);
|
|
753
|
+
}
|
|
754
|
+
async getDomainObjectHistory(uid) {
|
|
755
|
+
return this.get(`/ontology/object/${uid}/history`);
|
|
756
|
+
}
|
|
757
|
+
async listDomainObjects(opts) {
|
|
758
|
+
const q = new URLSearchParams();
|
|
759
|
+
q.set("schema_id", opts.schema_id);
|
|
760
|
+
if (opts.object_type) q.set("object_type", opts.object_type);
|
|
761
|
+
if (opts.limit != null) q.set("limit", String(opts.limit));
|
|
762
|
+
if (opts.offset != null) q.set("offset", String(opts.offset));
|
|
763
|
+
if (opts.sort) q.set("sort", opts.sort);
|
|
764
|
+
return this.get(`/ontology/objects?${q.toString()}`);
|
|
765
|
+
}
|
|
766
|
+
async searchDomainObjects(query, opts) {
|
|
767
|
+
return this.post("/ontology/objects/search", { query, ...opts ?? {} });
|
|
768
|
+
}
|
|
769
|
+
async linkDomainObjects(req) {
|
|
770
|
+
return this.post("/ontology/relation", { action: "create", ...req });
|
|
771
|
+
}
|
|
772
|
+
// ---- Extraction ----
|
|
773
|
+
async extractOntology(req) {
|
|
774
|
+
return this.post("/ontology/extract", req);
|
|
775
|
+
}
|
|
642
776
|
};
|
|
643
777
|
// Annotate the CommonJS export names for ESM import in node:
|
|
644
778
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -370,7 +370,11 @@ var MindGraph = class {
|
|
|
370
370
|
async search(query, opts) {
|
|
371
371
|
return this.post("/search", { query, ...opts });
|
|
372
372
|
}
|
|
373
|
-
/**
|
|
373
|
+
/**
|
|
374
|
+
* Hybrid BM25 + vector search with reciprocal rank fusion. Pass
|
|
375
|
+
* `explain: true` to get per-leg contributions (`legs`) on each result —
|
|
376
|
+
* the "why retrieved" detail (server ≥ 1.2.0; older servers ignore it).
|
|
377
|
+
*/
|
|
374
378
|
async hybridSearch(query, opts) {
|
|
375
379
|
return this.post("/retrieve", {
|
|
376
380
|
action: "hybrid",
|
|
@@ -612,6 +616,136 @@ var MindGraph = class {
|
|
|
612
616
|
async runSynthesis(projectUid) {
|
|
613
617
|
return this.post(`/synthesis/run/${projectUid}`, {});
|
|
614
618
|
}
|
|
619
|
+
// ============================================================================
|
|
620
|
+
// Operational Ontology Layer (Layer 7)
|
|
621
|
+
// ============================================================================
|
|
622
|
+
// ---- Schema management (cloud Postgres) ----
|
|
623
|
+
async listOntologySchemas() {
|
|
624
|
+
return this.get("/v1/ontology/schemas");
|
|
625
|
+
}
|
|
626
|
+
async getOntologySchema(id) {
|
|
627
|
+
return this.get(`/v1/ontology/schemas/${id}`);
|
|
628
|
+
}
|
|
629
|
+
async createOntologySchema(req) {
|
|
630
|
+
return this.post("/v1/ontology/schemas", req);
|
|
631
|
+
}
|
|
632
|
+
async updateOntologySchema(id, req) {
|
|
633
|
+
return this.patch(`/v1/ontology/schemas/${id}`, req);
|
|
634
|
+
}
|
|
635
|
+
async activateOntologySchema(id) {
|
|
636
|
+
return this.post(`/v1/ontology/schemas/${id}/activate`, {});
|
|
637
|
+
}
|
|
638
|
+
async deprecateOntologySchema(id) {
|
|
639
|
+
return this.post(`/v1/ontology/schemas/${id}/deprecate`, {});
|
|
640
|
+
}
|
|
641
|
+
async archiveOntologySchema(id) {
|
|
642
|
+
return this.del(`/v1/ontology/schemas/${id}`);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Kick off an LLM-driven schema proposal job.
|
|
646
|
+
* Returns immediately with `{ schema_id, job_id }`; poll
|
|
647
|
+
* `getOntologySchema(schema_id)` for streaming progress.
|
|
648
|
+
*/
|
|
649
|
+
async proposeOntologySchema(req) {
|
|
650
|
+
return this.post("/v1/ontology/propose-schema", req);
|
|
651
|
+
}
|
|
652
|
+
async testOntologySchema(id, opts) {
|
|
653
|
+
return this.post(`/v1/ontology/schemas/${id}/test`, opts ?? {});
|
|
654
|
+
}
|
|
655
|
+
// ---- Schema sub-resources ----
|
|
656
|
+
async addOntologyObjectType(schemaId, req) {
|
|
657
|
+
return this.post(`/v1/ontology/schemas/${schemaId}/object-types`, req);
|
|
658
|
+
}
|
|
659
|
+
async updateOntologyObjectType(schemaId, typeId, req) {
|
|
660
|
+
return this.patch(
|
|
661
|
+
`/v1/ontology/schemas/${schemaId}/object-types/${typeId}`,
|
|
662
|
+
req
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
async deleteOntologyObjectType(schemaId, typeId) {
|
|
666
|
+
return this.del(
|
|
667
|
+
`/v1/ontology/schemas/${schemaId}/object-types/${typeId}`
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
async addOntologyRelationType(schemaId, req) {
|
|
671
|
+
return this.post(`/v1/ontology/schemas/${schemaId}/relation-types`, req);
|
|
672
|
+
}
|
|
673
|
+
async updateOntologyRelationType(schemaId, typeId, req) {
|
|
674
|
+
return this.patch(
|
|
675
|
+
`/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`,
|
|
676
|
+
req
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
async deleteOntologyRelationType(schemaId, typeId) {
|
|
680
|
+
return this.del(
|
|
681
|
+
`/v1/ontology/schemas/${schemaId}/relation-types/${typeId}`
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
// ---- Proposals ----
|
|
685
|
+
async listOntologyProposals(opts) {
|
|
686
|
+
const q = new URLSearchParams();
|
|
687
|
+
if (opts?.status) q.set("status", opts.status);
|
|
688
|
+
if (opts?.schema_id) q.set("schema_id", opts.schema_id);
|
|
689
|
+
if (opts?.object_type) q.set("object_type", opts.object_type);
|
|
690
|
+
if (opts?.limit != null) q.set("limit", String(opts.limit));
|
|
691
|
+
if (opts?.offset != null) q.set("offset", String(opts.offset));
|
|
692
|
+
const qs = q.toString();
|
|
693
|
+
return this.get(`/v1/ontology/proposals${qs ? `?${qs}` : ""}`);
|
|
694
|
+
}
|
|
695
|
+
async getOntologyProposal(id) {
|
|
696
|
+
return this.get(`/v1/ontology/proposals/${id}`);
|
|
697
|
+
}
|
|
698
|
+
async patchOntologyProposal(id, req) {
|
|
699
|
+
return this.patch(`/v1/ontology/proposals/${id}`, req);
|
|
700
|
+
}
|
|
701
|
+
async approveOntologyProposal(id, opts) {
|
|
702
|
+
return this.post(`/v1/ontology/proposals/${id}/approve`, opts ?? {});
|
|
703
|
+
}
|
|
704
|
+
async rejectOntologyProposal(id, reason) {
|
|
705
|
+
return this.post(`/v1/ontology/proposals/${id}/reject`, { reason });
|
|
706
|
+
}
|
|
707
|
+
async applyOntologyProposal(id) {
|
|
708
|
+
return this.post(`/v1/ontology/proposals/${id}/apply`, {});
|
|
709
|
+
}
|
|
710
|
+
async batchApproveOntologyProposals(ids, feedback) {
|
|
711
|
+
return this.post("/v1/ontology/proposals/batch-approve", { ids, feedback });
|
|
712
|
+
}
|
|
713
|
+
async batchRejectOntologyProposals(ids, reason) {
|
|
714
|
+
return this.post("/v1/ontology/proposals/batch-reject", { ids, reason });
|
|
715
|
+
}
|
|
716
|
+
// ---- Retrieval (graph server) ----
|
|
717
|
+
async queryOntology(req) {
|
|
718
|
+
return this.post("/ontology/query", req);
|
|
719
|
+
}
|
|
720
|
+
async getDomainObject(uid) {
|
|
721
|
+
return this.get(`/ontology/object/${uid}`);
|
|
722
|
+
}
|
|
723
|
+
async getDomainObjectContext(uid, depth) {
|
|
724
|
+
const qs = depth != null ? `?depth=${depth}` : "";
|
|
725
|
+
return this.get(`/ontology/object/${uid}/context${qs}`);
|
|
726
|
+
}
|
|
727
|
+
async getDomainObjectHistory(uid) {
|
|
728
|
+
return this.get(`/ontology/object/${uid}/history`);
|
|
729
|
+
}
|
|
730
|
+
async listDomainObjects(opts) {
|
|
731
|
+
const q = new URLSearchParams();
|
|
732
|
+
q.set("schema_id", opts.schema_id);
|
|
733
|
+
if (opts.object_type) q.set("object_type", opts.object_type);
|
|
734
|
+
if (opts.limit != null) q.set("limit", String(opts.limit));
|
|
735
|
+
if (opts.offset != null) q.set("offset", String(opts.offset));
|
|
736
|
+
if (opts.sort) q.set("sort", opts.sort);
|
|
737
|
+
return this.get(`/ontology/objects?${q.toString()}`);
|
|
738
|
+
}
|
|
739
|
+
async searchDomainObjects(query, opts) {
|
|
740
|
+
return this.post("/ontology/objects/search", { query, ...opts ?? {} });
|
|
741
|
+
}
|
|
742
|
+
async linkDomainObjects(req) {
|
|
743
|
+
return this.post("/ontology/relation", { action: "create", ...req });
|
|
744
|
+
}
|
|
745
|
+
// ---- Extraction ----
|
|
746
|
+
async extractOntology(req) {
|
|
747
|
+
return this.post("/ontology/extract", req);
|
|
748
|
+
}
|
|
615
749
|
};
|
|
616
750
|
export {
|
|
617
751
|
MindGraph,
|