@kortexya/reasoninglayer 2.1.0 → 2.1.2
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 +73 -73
- package/dist/index.cjs +1590 -460
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1590 -460
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,12 +28,7 @@ yarn add @kortexya/reasoninglayer
|
|
|
28
28
|
## Quick Start
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import {
|
|
32
|
-
ReasoningLayerClient,
|
|
33
|
-
Value,
|
|
34
|
-
Constraint,
|
|
35
|
-
psi,
|
|
36
|
-
} from '@kortexya/reasoninglayer';
|
|
31
|
+
import { ReasoningLayerClient, Value, Constraint, psi } from '@kortexya/reasoninglayer';
|
|
37
32
|
|
|
38
33
|
const client = new ReasoningLayerClient({
|
|
39
34
|
baseUrl: 'https://platform.ovh.reasoninglayer.ai',
|
|
@@ -73,10 +68,7 @@ await client.sorts.createSort({
|
|
|
73
68
|
});
|
|
74
69
|
await client.inference.addRule({
|
|
75
70
|
term: psi('well_paid', { name: '?X' }),
|
|
76
|
-
antecedents: [
|
|
77
|
-
psi('employee', { name: '?X', salary: '?S' }),
|
|
78
|
-
Constraint.where('?S', '>', 80000),
|
|
79
|
-
],
|
|
71
|
+
antecedents: [psi('employee', { name: '?X', salary: '?S' }), Constraint.where('?S', '>', 80000)],
|
|
80
72
|
});
|
|
81
73
|
|
|
82
74
|
// Prove it, and walk every employee without writing the offset arithmetic.
|
|
@@ -93,58 +85,57 @@ await client.inference.forwardChain({ maxIterations: 100 }, { timeoutMs: 600_000
|
|
|
93
85
|
|
|
94
86
|
## Resource Clients
|
|
95
87
|
|
|
96
|
-
| Client
|
|
97
|
-
|
|
98
|
-
| `sorts`
|
|
99
|
-
| `terms`
|
|
100
|
-
| `inference`
|
|
101
|
-
| `query`
|
|
102
|
-
| `cognitive`
|
|
103
|
-
| `fuzzy`
|
|
104
|
-
| `constraints`
|
|
105
|
-
| `namespaces`
|
|
106
|
-
| `collections`
|
|
107
|
-
| `execution`
|
|
108
|
-
| `causal`
|
|
109
|
-
| `ingestion`
|
|
110
|
-
| `reviews`
|
|
111
|
-
| `visualization` | Visualization
|
|
112
|
-
| `ilp`
|
|
113
|
-
| `reasoning`
|
|
114
|
-
| `statistical`
|
|
115
|
-
| `control`
|
|
116
|
-
| `spaces`
|
|
117
|
-
| `row`
|
|
118
|
-
| `sources`
|
|
119
|
-
| `communities`
|
|
120
|
-
| `utilities`
|
|
121
|
-
| `scenarios`
|
|
122
|
-
| `actionReviews` | Action reviews
|
|
123
|
-
| `discovery`
|
|
124
|
-
| `extract`
|
|
125
|
-
| `optimize`
|
|
126
|
-
| `snapshots`
|
|
127
|
-
| `audit`
|
|
128
|
-
| `analysis`
|
|
129
|
-
| `compliance`
|
|
88
|
+
| Client | Domain | Key Operations |
|
|
89
|
+
| --------------- | ------------------------ | ------------------------------------------------------------------ |
|
|
90
|
+
| `sorts` | Sort hierarchy | create, GLB/LUB, compare, similarity |
|
|
91
|
+
| `terms` | Psi-terms | CRUD, bulk create, validation |
|
|
92
|
+
| `inference` | Inference engine | rules, facts, backward/forward chaining, fuzzy, Bayesian, NAF |
|
|
93
|
+
| `query` | Query | unifiable, by-sort, structured search, NL query |
|
|
94
|
+
| `cognitive` | Cognitive agents | BDI cycle, beliefs, goals, messaging, WebSocket events |
|
|
95
|
+
| `fuzzy` | Fuzzy logic | unify, merge, subsumption, top-K search |
|
|
96
|
+
| `constraints` | Constraints | arithmetic solving, graph visualization |
|
|
97
|
+
| `namespaces` | Namespaces | hierarchy, imports, metadata |
|
|
98
|
+
| `collections` | Collections | CRUD, tagging |
|
|
99
|
+
| `execution` | Execution | sessions, backtracking, goal stack |
|
|
100
|
+
| `causal` | Causal reasoning | Pearl's hierarchy, interventions, counterfactuals |
|
|
101
|
+
| `ingestion` | Data ingestion | documents, markdown, RDF, sessions |
|
|
102
|
+
| `reviews` | Reviews | approve, reject, merge, re-extract |
|
|
103
|
+
| `visualization` | Visualization | lattice, hypergraph, residuation state |
|
|
104
|
+
| `ilp` | ILP | pattern learning, GFlowNet, synthesis |
|
|
105
|
+
| `reasoning` | Reasoning | entailment, residuation, resource coordination |
|
|
106
|
+
| `statistical` | Statistics | correlation, independence, causal discovery |
|
|
107
|
+
| `control` | Proof control | cut, findall, forall, NAF, conditionals |
|
|
108
|
+
| `spaces` | Spaces | computation spaces, clone, commit, search |
|
|
109
|
+
| `row` | Row polymorphism | schema-flexible search, unification |
|
|
110
|
+
| `sources` | Data sources | register, schema discovery, ingest |
|
|
111
|
+
| `communities` | Communities | detection, memberships, search |
|
|
112
|
+
| `utilities` | Utilities | strings, arithmetic, term copy |
|
|
113
|
+
| `scenarios` | Scenarios | CRUD, verification |
|
|
114
|
+
| `actionReviews` | Action reviews | approve, reject, modify autonomous actions |
|
|
115
|
+
| `discovery` | Discovery | causal effect discovery, prediction |
|
|
116
|
+
| `extract` | Extraction | entity extraction from text |
|
|
117
|
+
| `optimize` | Optimization | LP solve, KB-driven optimization |
|
|
118
|
+
| `snapshots` | Tenant snapshots | capture, export, import, restore |
|
|
119
|
+
| `audit` | Conversation audit chain | append, list, count, verify integrity |
|
|
120
|
+
| `analysis` | Analysis | FCA sort discovery, attribute exploration, rule-base certification |
|
|
121
|
+
| `compliance` | Compliance | audit receipts, EU AI Act conformity |
|
|
130
122
|
|
|
131
123
|
A row per area, not per client — the SDK ships 100 resource clients in all.
|
|
132
124
|
|
|
133
|
-
|
|
134
125
|
## Configuration
|
|
135
126
|
|
|
136
127
|
```typescript
|
|
137
128
|
const client = new ReasoningLayerClient({
|
|
138
129
|
baseUrl: 'https://platform.ovh.reasoninglayer.ai', // Required
|
|
139
|
-
tenantId: 'your-tenant-uuid',
|
|
140
|
-
auth: { mode: 'bearer', token: 'eyJ…' },
|
|
141
|
-
userId: 'user-uuid',
|
|
142
|
-
namespaceId: 'ns-uuid',
|
|
143
|
-
maxRetries: 3,
|
|
144
|
-
timeoutMs: 30000,
|
|
145
|
-
retryOn503: true,
|
|
146
|
-
fetch: customFetch,
|
|
147
|
-
interceptors: [loggingMiddleware],
|
|
130
|
+
tenantId: 'your-tenant-uuid', // Required, sent as X-Tenant-Id
|
|
131
|
+
auth: { mode: 'bearer', token: 'eyJ…' }, // Required — see Authentication below
|
|
132
|
+
userId: 'user-uuid', // Optional, sent as X-User-Id
|
|
133
|
+
namespaceId: 'ns-uuid', // Optional, sent as X-Namespace-Id
|
|
134
|
+
maxRetries: 3, // Default: 3
|
|
135
|
+
timeoutMs: 30000, // Default: 30000ms
|
|
136
|
+
retryOn503: true, // Default: false
|
|
137
|
+
fetch: customFetch, // Optional: custom fetch implementation
|
|
138
|
+
interceptors: [loggingMiddleware], // Optional: request/response middleware
|
|
148
139
|
});
|
|
149
140
|
```
|
|
150
141
|
|
|
@@ -198,7 +189,7 @@ const client = new ReasoningLayerClient({
|
|
|
198
189
|
interceptors: [
|
|
199
190
|
async (request, next) => {
|
|
200
191
|
const response = await next(request);
|
|
201
|
-
console.log(response.status);
|
|
192
|
+
console.log(response.status); // 201
|
|
202
193
|
console.log(response.headers.get('x-ratelimit-remaining')); // '99'
|
|
203
194
|
return response;
|
|
204
195
|
},
|
|
@@ -242,40 +233,49 @@ try {
|
|
|
242
233
|
The SDK provides builder functions for constructing API request values with full type safety:
|
|
243
234
|
|
|
244
235
|
```typescript
|
|
245
|
-
import {
|
|
236
|
+
import {
|
|
237
|
+
Value,
|
|
238
|
+
FuzzyShape,
|
|
239
|
+
guard,
|
|
240
|
+
constrained,
|
|
241
|
+
allen,
|
|
242
|
+
SortBuilder,
|
|
243
|
+
psi,
|
|
244
|
+
LP,
|
|
245
|
+
} from '@kortexya/reasoninglayer';
|
|
246
246
|
|
|
247
247
|
// Tagged values (term CRUD). A plain scalar needs no builder — the resource
|
|
248
248
|
// methods tag it for you. `Value.*` is for the shapes a scalar cannot express.
|
|
249
|
-
const features = { name: 'hello', age: 42 };
|
|
250
|
-
Value.reference('550e8400-e29b-41d4-a716-446655440000')
|
|
251
|
-
|
|
252
|
-
Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24))
|
|
253
|
-
|
|
249
|
+
const features = { name: 'hello', age: 42 }; // tagged on the way to the wire
|
|
250
|
+
Value.reference('550e8400-e29b-41d4-a716-446655440000');
|
|
251
|
+
// { type: 'Reference', value: '550e8400-…' }
|
|
252
|
+
Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24));
|
|
253
|
+
// { type: 'FuzzyNumber', value: { kind: 'Triangular', … } }
|
|
254
254
|
|
|
255
255
|
// Untagged values (inference). `psi()` writes them: a scalar stays a scalar,
|
|
256
256
|
// and a '?Name' string becomes a logic variable.
|
|
257
|
-
psi('employee', { name: '?Name', department: 'Engineering' })
|
|
258
|
-
|
|
257
|
+
psi('employee', { name: '?Name', department: 'Engineering' });
|
|
258
|
+
// { sortName: 'employee', features: { name: { name: '?Name' }, … } }
|
|
259
259
|
|
|
260
260
|
// Guard constraints — a guard is itself a Ψ-term
|
|
261
|
-
guard('gt', 100)
|
|
262
|
-
constrained('?Salary', guard('gt', 80000))
|
|
261
|
+
guard('gt', 100); // { sortName: 'guard_constraint', features: { op: 'gt', right: 100 } }
|
|
262
|
+
constrained('?Salary', guard('gt', 80000));
|
|
263
263
|
|
|
264
264
|
// Allen temporal relations
|
|
265
|
-
allen('before', '?Employment', intervalTermId)
|
|
266
|
-
|
|
265
|
+
allen('before', '?Employment', intervalTermId);
|
|
266
|
+
// { type: 'Allen', intervalA: '?Employment', … }
|
|
267
267
|
|
|
268
268
|
// LP optimization
|
|
269
|
-
LP.maximize({ x: 3, y: 5 })
|
|
270
|
-
LP.constraint({ x: 1, y: 3 }, '<=', 12)
|
|
271
|
-
LP.nonNegative('x', 'y')
|
|
269
|
+
LP.maximize({ x: 3, y: 5 }); // objective function
|
|
270
|
+
LP.constraint({ x: 1, y: 3 }, '<=', 12); // linear constraint
|
|
271
|
+
LP.nonNegative('x', 'y'); // variable bounds
|
|
272
272
|
|
|
273
273
|
// Fluent sort builder
|
|
274
274
|
new SortBuilder('employee')
|
|
275
275
|
.parents(['person'])
|
|
276
276
|
.feature('salary', 'Real')
|
|
277
277
|
.boundConstraint('salary', 'gt', 50000)
|
|
278
|
-
.build()
|
|
278
|
+
.build();
|
|
279
279
|
```
|
|
280
280
|
|
|
281
281
|
## Development
|
|
@@ -299,8 +299,8 @@ pnpm run docs:build # Build documentation site
|
|
|
299
299
|
## Compatibility
|
|
300
300
|
|
|
301
301
|
| SDK Version | Min Backend Version | Node | Browser |
|
|
302
|
-
|
|
303
|
-
| 1.4.0 | Latest
|
|
302
|
+
| ----------- | ------------------- | ---- | ------- |
|
|
303
|
+
| 1.4.0 | Latest | 18+ | ES2022+ |
|
|
304
304
|
|
|
305
305
|
## License
|
|
306
306
|
|