rust-kgdb 0.6.80 → 0.6.82
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 +282 -1
- package/examples/rpc-catalog-dprod-demo.js +339 -0
- package/examples/rpc-federation-sql-demo.js +273 -0
- package/examples/rpc-virtual-tables-demo.js +268 -0
- package/hypermind-agent.js +626 -0
- package/index.d.ts +304 -0
- package/index.js +9 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -895,6 +895,310 @@ export interface ToolMorphism {
|
|
|
895
895
|
*/
|
|
896
896
|
export const TOOL_REGISTRY: Record<string, ToolMorphism>
|
|
897
897
|
|
|
898
|
+
/**
|
|
899
|
+
* FEDERATION_TOOLS - HyperFederate federation tools as typed morphisms
|
|
900
|
+
*
|
|
901
|
+
* 7 tools for cross-database queries:
|
|
902
|
+
* - federation.sql.query: Execute federated SQL across KGDB + Snowflake + BigQuery
|
|
903
|
+
* - federation.virtual.create: Create session-bound virtual table
|
|
904
|
+
* - federation.virtual.query: Query existing virtual table
|
|
905
|
+
* - federation.catalog.list: List data products in DCAT DPROD catalog
|
|
906
|
+
* - federation.catalog.register: Register data product
|
|
907
|
+
* - federation.udf.call: Call semantic UDF (similar_to, neighbors, etc.)
|
|
908
|
+
* - federation.table_function.call: Call table function (graph_search, pagerank, etc.)
|
|
909
|
+
*/
|
|
910
|
+
export const FEDERATION_TOOLS: Record<string, ToolMorphism>
|
|
911
|
+
|
|
912
|
+
// ============================================================================
|
|
913
|
+
// HyperFederate (v0.7.0+) - Cross-Database Federation
|
|
914
|
+
// ============================================================================
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Federation configuration for RpcFederationProxy
|
|
918
|
+
*/
|
|
919
|
+
export interface FederationConfig {
|
|
920
|
+
/** HyperFederate server endpoint (default: http://localhost:30180) */
|
|
921
|
+
endpoint?: string
|
|
922
|
+
/** Request timeout in ms (default: 30000) */
|
|
923
|
+
timeout?: number
|
|
924
|
+
/** WasmSandbox for capability-based security */
|
|
925
|
+
sandbox?: WasmSandbox
|
|
926
|
+
/** Additional HTTP headers */
|
|
927
|
+
headers?: Record<string, string>
|
|
928
|
+
/** Session ID for virtual table isolation */
|
|
929
|
+
sessionId?: string
|
|
930
|
+
/** Identity ID for access control */
|
|
931
|
+
identityId?: string
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Virtual table specification for createVirtualTable
|
|
936
|
+
*/
|
|
937
|
+
export interface VirtualTableSpec {
|
|
938
|
+
/** Refresh policy: 'on_demand' | 'ttl' | 'on_source_change' */
|
|
939
|
+
refreshPolicy?: 'on_demand' | 'ttl' | 'on_source_change'
|
|
940
|
+
/** TTL in seconds (for 'ttl' policy) */
|
|
941
|
+
ttlSeconds?: number
|
|
942
|
+
/** Identity IDs to share with */
|
|
943
|
+
sharedWith?: string[]
|
|
944
|
+
/** Group IDs to share with */
|
|
945
|
+
sharedWithGroups?: string[]
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Virtual table metadata returned by createVirtualTable
|
|
950
|
+
*/
|
|
951
|
+
export interface VirtualTableMetadata {
|
|
952
|
+
id: string
|
|
953
|
+
name: string
|
|
954
|
+
uri?: string
|
|
955
|
+
columns: string[]
|
|
956
|
+
rowCount?: number
|
|
957
|
+
refreshPolicy: string
|
|
958
|
+
createdAt: string
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Data product specification for registerDataProduct
|
|
963
|
+
*/
|
|
964
|
+
export interface DataProductSpec {
|
|
965
|
+
/** Product name */
|
|
966
|
+
name: string
|
|
967
|
+
/** Product description */
|
|
968
|
+
description: string
|
|
969
|
+
/** Data source identifiers (e.g., ['kgdb', 'snowflake', 'bigquery']) */
|
|
970
|
+
sources: string[]
|
|
971
|
+
/** API endpoint for querying */
|
|
972
|
+
outputPort: string
|
|
973
|
+
/** Column schema definition */
|
|
974
|
+
schema: {
|
|
975
|
+
columns: Array<{ name: string; type: string }>
|
|
976
|
+
}
|
|
977
|
+
/** Quality metrics */
|
|
978
|
+
quality?: {
|
|
979
|
+
completeness?: number
|
|
980
|
+
accuracy?: number
|
|
981
|
+
}
|
|
982
|
+
/** Owner identity */
|
|
983
|
+
owner: string
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* RecordBatch result from federated queries
|
|
988
|
+
*/
|
|
989
|
+
export interface RecordBatch {
|
|
990
|
+
columns: string[]
|
|
991
|
+
rows: Record<string, unknown>[]
|
|
992
|
+
rowCount: number
|
|
993
|
+
duration?: number
|
|
994
|
+
metadata?: {
|
|
995
|
+
sources?: string[]
|
|
996
|
+
planHash?: string
|
|
997
|
+
cached?: boolean
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Audit log entry for provenance tracking
|
|
1003
|
+
*/
|
|
1004
|
+
export interface FederationAuditEntry {
|
|
1005
|
+
action: string
|
|
1006
|
+
sql?: string
|
|
1007
|
+
name?: string
|
|
1008
|
+
duration?: number
|
|
1009
|
+
rows?: number
|
|
1010
|
+
error?: string
|
|
1011
|
+
timestamp: string
|
|
1012
|
+
sessionId: string
|
|
1013
|
+
sources?: string[]
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* RpcFederationProxy - WASM RPC proxy for HyperFederate cross-database federation
|
|
1018
|
+
*
|
|
1019
|
+
* Enables querying across KGDB + Snowflake + BigQuery in single SQL statements.
|
|
1020
|
+
* Uses capability-based security via WasmSandbox with fuel metering.
|
|
1021
|
+
*
|
|
1022
|
+
* Category Theory: Proxy is a natural transformation between local and remote execution
|
|
1023
|
+
* Type Theory: All operations are typed morphisms (Input → Output)
|
|
1024
|
+
* Proof Theory: Full audit log with W3C PROV provenance tracking
|
|
1025
|
+
*
|
|
1026
|
+
* @example
|
|
1027
|
+
* ```typescript
|
|
1028
|
+
* const federation = new RpcFederationProxy({
|
|
1029
|
+
* endpoint: 'http://localhost:30180',
|
|
1030
|
+
* identityId: 'risk-analyst-001'
|
|
1031
|
+
* })
|
|
1032
|
+
*
|
|
1033
|
+
* // Three-way federation query
|
|
1034
|
+
* const result = await federation.query(`
|
|
1035
|
+
* SELECT kg.person, kg.riskScore, sf.C_NAME, bq.total_births
|
|
1036
|
+
* FROM graph_search('PREFIX finance: ... SELECT ?person ?riskScore WHERE {...}') kg
|
|
1037
|
+
* JOIN snowflake_tpch.CUSTOMER sf ON CAST(kg.custKey AS INT) = sf.C_CUSTKEY
|
|
1038
|
+
* LEFT JOIN bigquery_public.usa_names bq ON LOWER(SPLIT(sf.C_NAME, ' ')[0]) = LOWER(bq.name)
|
|
1039
|
+
* LIMIT 10
|
|
1040
|
+
* `)
|
|
1041
|
+
* ```
|
|
1042
|
+
*/
|
|
1043
|
+
export class RpcFederationProxy {
|
|
1044
|
+
/** HyperFederate server endpoint */
|
|
1045
|
+
endpoint: string
|
|
1046
|
+
/** Request timeout in ms */
|
|
1047
|
+
timeout: number
|
|
1048
|
+
/** WasmSandbox for capability-based security */
|
|
1049
|
+
sandbox: WasmSandbox
|
|
1050
|
+
/** Audit log for provenance tracking */
|
|
1051
|
+
auditLog: FederationAuditEntry[]
|
|
1052
|
+
/** Session ID for virtual table isolation */
|
|
1053
|
+
sessionId: string
|
|
1054
|
+
/** Identity ID for access control */
|
|
1055
|
+
identityId: string
|
|
1056
|
+
|
|
1057
|
+
constructor(config?: FederationConfig)
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Execute federated SQL query across multiple data sources
|
|
1061
|
+
*
|
|
1062
|
+
* @param sql - Federated SQL query (supports graph_search, snowflake.*, bigquery.*, etc.)
|
|
1063
|
+
* @param options - Query options (limit, timeout)
|
|
1064
|
+
* @returns RecordBatch result with columns, rows, metadata
|
|
1065
|
+
*
|
|
1066
|
+
* @example
|
|
1067
|
+
* ```typescript
|
|
1068
|
+
* const result = await federation.query(`
|
|
1069
|
+
* SELECT kg.entity, kg.riskScore, sf.C_ACCTBAL
|
|
1070
|
+
* FROM graph_search('...') kg
|
|
1071
|
+
* JOIN snowflake.CUSTOMER sf ON ...
|
|
1072
|
+
* `)
|
|
1073
|
+
* console.log(result.rows)
|
|
1074
|
+
* ```
|
|
1075
|
+
*/
|
|
1076
|
+
query(sql: string, options?: { limit?: number; timeout?: number }): Promise<RecordBatch>
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* Create a virtual table from a federation query result
|
|
1080
|
+
*
|
|
1081
|
+
* Virtual tables are session-bound, stored as RDF triples in KGDB,
|
|
1082
|
+
* and support access control via shared_with and shared_with_groups.
|
|
1083
|
+
*
|
|
1084
|
+
* @param name - Virtual table name
|
|
1085
|
+
* @param sql - SQL query that defines the virtual table
|
|
1086
|
+
* @param options - Virtual table options
|
|
1087
|
+
* @returns Virtual table metadata
|
|
1088
|
+
*
|
|
1089
|
+
* @example
|
|
1090
|
+
* ```typescript
|
|
1091
|
+
* const vt = await federation.createVirtualTable('high_risk_customers', `
|
|
1092
|
+
* SELECT kg.*, sf.C_ACCTBAL
|
|
1093
|
+
* FROM graph_search('...') kg
|
|
1094
|
+
* JOIN snowflake.CUSTOMER sf ON ...
|
|
1095
|
+
* WHERE kg.riskScore > 0.8
|
|
1096
|
+
* `, { refreshPolicy: 'on_demand', ttlSeconds: 3600 })
|
|
1097
|
+
* ```
|
|
1098
|
+
*/
|
|
1099
|
+
createVirtualTable(name: string, sql: string, options?: VirtualTableSpec): Promise<VirtualTableMetadata>
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Query a virtual table
|
|
1103
|
+
*
|
|
1104
|
+
* @param name - Virtual table name
|
|
1105
|
+
* @param whereClauses - Optional WHERE clause conditions
|
|
1106
|
+
* @returns Query result
|
|
1107
|
+
*/
|
|
1108
|
+
queryVirtualTable(name: string, whereClauses?: string): Promise<RecordBatch>
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* List data products in the DCAT DPROD catalog
|
|
1112
|
+
*
|
|
1113
|
+
* @param filter - Filter options (owner, sources, search)
|
|
1114
|
+
* @returns List of data products
|
|
1115
|
+
*/
|
|
1116
|
+
listCatalog(filter?: { owner?: string; sources?: string[]; search?: string }): Promise<DataProductSpec[]>
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Register a data product in the DCAT DPROD catalog
|
|
1120
|
+
*
|
|
1121
|
+
* @param spec - Data product specification
|
|
1122
|
+
* @returns Registered data product with ID
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* ```typescript
|
|
1126
|
+
* const product = await federation.registerDataProduct({
|
|
1127
|
+
* name: 'High Risk Customer Analysis',
|
|
1128
|
+
* description: 'Cross-domain risk scoring',
|
|
1129
|
+
* sources: ['kgdb', 'snowflake', 'bigquery'],
|
|
1130
|
+
* outputPort: '/api/v1/products/high-risk/query',
|
|
1131
|
+
* schema: { columns: [{ name: 'entity', type: 'STRING' }] },
|
|
1132
|
+
* quality: { completeness: 0.98, accuracy: 0.95 },
|
|
1133
|
+
* owner: 'risk-analytics-team'
|
|
1134
|
+
* })
|
|
1135
|
+
* ```
|
|
1136
|
+
*/
|
|
1137
|
+
registerDataProduct(spec: DataProductSpec): Promise<{ id: string; uri?: string; name: string; createdAt: string }>
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Call a semantic UDF (one of 7 AI-powered functions)
|
|
1141
|
+
*
|
|
1142
|
+
* Available UDFs:
|
|
1143
|
+
* - similar_to(entity, threshold) - Find similar entities via RDF2Vec
|
|
1144
|
+
* - text_search(query, limit) - Semantic text search
|
|
1145
|
+
* - neighbors(entity, hops) - N-hop graph traversal
|
|
1146
|
+
* - graph_pattern(s, p, o) - Triple pattern matching
|
|
1147
|
+
* - sparql_query(sparql) - Inline SPARQL execution
|
|
1148
|
+
* - entity_type(entity) - Get RDF types
|
|
1149
|
+
* - entity_properties(entity) - Get all properties
|
|
1150
|
+
*
|
|
1151
|
+
* @param udfName - UDF function name
|
|
1152
|
+
* @param args - UDF arguments
|
|
1153
|
+
* @returns UDF result
|
|
1154
|
+
*/
|
|
1155
|
+
callUdf(udfName: string, ...args: unknown[]): Promise<RecordBatch>
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* Call a table function (one of 9 graph analytics functions)
|
|
1159
|
+
*
|
|
1160
|
+
* Available functions:
|
|
1161
|
+
* - graph_search(sparql) - SPARQL → SQL bridge
|
|
1162
|
+
* - vector_search(text, k, threshold) - Semantic similarity
|
|
1163
|
+
* - pagerank(sparql, damping, iterations) - PageRank centrality
|
|
1164
|
+
* - connected_components(sparql) - Community detection
|
|
1165
|
+
* - shortest_paths(src, dst, max_hops) - Path finding
|
|
1166
|
+
* - triangle_count(sparql) - Graph density
|
|
1167
|
+
* - label_propagation(sparql, iterations) - Community detection
|
|
1168
|
+
* - datalog_reason(rules) - Datalog inference
|
|
1169
|
+
* - motif_search(pattern) - Graph pattern matching
|
|
1170
|
+
*
|
|
1171
|
+
* @param functionName - Table function name
|
|
1172
|
+
* @param args - Function arguments
|
|
1173
|
+
* @returns RecordBatch result
|
|
1174
|
+
*/
|
|
1175
|
+
callTableFunction(functionName: string, ...args: unknown[]): Promise<RecordBatch>
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Get the audit log for provenance tracking
|
|
1179
|
+
* @returns Audit log entries
|
|
1180
|
+
*/
|
|
1181
|
+
getAuditLog(): FederationAuditEntry[]
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Clear the audit log
|
|
1185
|
+
*/
|
|
1186
|
+
clearAuditLog(): void
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Get sandbox fuel remaining
|
|
1190
|
+
* @returns Fuel remaining
|
|
1191
|
+
*/
|
|
1192
|
+
getFuelRemaining(): number
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* Check if a capability is granted
|
|
1196
|
+
* @param capability - Capability name
|
|
1197
|
+
* @returns True if capability is granted
|
|
1198
|
+
*/
|
|
1199
|
+
hasCapability(capability: string): boolean
|
|
1200
|
+
}
|
|
1201
|
+
|
|
898
1202
|
/**
|
|
899
1203
|
* LLMPlanner - Natural language to typed tool pipelines
|
|
900
1204
|
*
|
package/index.js
CHANGED
|
@@ -79,6 +79,10 @@ const {
|
|
|
79
79
|
// LLM Planning (v0.6.7+) - Natural Language to Typed Tools
|
|
80
80
|
LLMPlanner,
|
|
81
81
|
TOOL_REGISTRY,
|
|
82
|
+
// HyperFederate (v0.7.0+) - Cross-Database Federation via WASM RPC
|
|
83
|
+
// Query across KGDB + Snowflake + BigQuery in single SQL
|
|
84
|
+
RpcFederationProxy,
|
|
85
|
+
FEDERATION_TOOLS,
|
|
82
86
|
// Type System (v0.6.7+)
|
|
83
87
|
TypeId,
|
|
84
88
|
// Memory Layer (v0.5.13+) - GraphDB-Powered Agent Memory
|
|
@@ -147,6 +151,11 @@ module.exports = {
|
|
|
147
151
|
// LLM Planning (v0.6.7+) - Natural Language to Typed Tools
|
|
148
152
|
LLMPlanner,
|
|
149
153
|
TOOL_REGISTRY,
|
|
154
|
+
// HyperFederate (v0.7.0+) - Cross-Database Federation
|
|
155
|
+
// Query across KGDB + Snowflake + BigQuery in single SQL statement
|
|
156
|
+
// Supports: 7 Semantic UDFs + 9 Table Functions + Virtual Tables + DCAT Catalog
|
|
157
|
+
RpcFederationProxy, // WASM RPC proxy for federated queries
|
|
158
|
+
FEDERATION_TOOLS, // 7 federation tools as typed morphisms
|
|
150
159
|
// Type System (v0.6.7+)
|
|
151
160
|
TypeId,
|
|
152
161
|
// Memory Layer (v0.5.13+) - GraphDB-Powered Agent Memory
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-kgdb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.82",
|
|
4
4
|
"description": "High-performance RDF/SPARQL database with AI agent framework. GraphDB (449ns lookups, 35x faster than RDFox), GraphFrames analytics (PageRank, motifs), Datalog reasoning, HNSW vector embeddings. HyperMindAgent for schema-aware query generation with audit trails. W3C SPARQL 1.1 compliant. Native performance via Rust + NAPI-RS.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|