@kortexya/reasoninglayer 1.26.0 → 1.28.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 +51 -30
- package/dist/index.cjs +5271 -1375
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11844 -5090
- package/dist/index.d.ts +11844 -5090
- package/dist/index.js +5259 -1376
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -7,8 +7,10 @@ TypeScript SDK for the [Reasoning Layer](https://kortexya.com) API — a knowled
|
|
|
7
7
|
- **Zero runtime dependencies** — only `fetch` and `AbortController` (ES2022)
|
|
8
8
|
- **Dual ESM/CJS** — works in Node 18+, modern browsers, Deno, and Bun
|
|
9
9
|
- **Full type safety** — strict TypeScript with discriminated unions, no `any` types
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
10
|
+
- **100 resource clients** covering sorts, terms, inference, query, fuzzy logic, cognitive agents, causal reasoning, optimization, snapshots, the audit chain, and more
|
|
11
|
+
- **Builder namespaces** — `Value`, `FuzzyShape`, `Geometry`, `Constraint`, `psi`, `guard`, `constrained`, `SortBuilder`, `allen`, `LP`, `flow`
|
|
12
|
+
- **Per-call request options** — a timeout, retry budget, abort signal or header override on any method, without a second client
|
|
13
|
+
- **Async pagination** — `for await` over the paged endpoints, both dialects
|
|
12
14
|
- **Automatic retry** — exponential backoff with jitter on 429 and 503 responses
|
|
13
15
|
- **WebSocket** — real-time cognitive agent event subscriptions with auto-reconnect
|
|
14
16
|
- **Error hierarchy** — typed errors for constraint violations, rate limits, timeouts, and network failures
|
|
@@ -26,7 +28,12 @@ yarn add @kortexya/reasoninglayer
|
|
|
26
28
|
## Quick Start
|
|
27
29
|
|
|
28
30
|
```typescript
|
|
29
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
ReasoningLayerClient,
|
|
33
|
+
Value,
|
|
34
|
+
Constraint,
|
|
35
|
+
psi,
|
|
36
|
+
} from '@kortexya/reasoninglayer';
|
|
30
37
|
|
|
31
38
|
const client = new ReasoningLayerClient({
|
|
32
39
|
baseUrl: 'https://platform.ovh.reasoninglayer.ai',
|
|
@@ -34,47 +41,54 @@ const client = new ReasoningLayerClient({
|
|
|
34
41
|
auth: { mode: 'bearer', token: process.env.RL_API_TOKEN! },
|
|
35
42
|
});
|
|
36
43
|
|
|
37
|
-
//
|
|
38
|
-
const
|
|
39
|
-
|
|
44
|
+
// A sort hierarchy. Features are declared, not inferred.
|
|
45
|
+
const person = await client.sorts.createSort({
|
|
46
|
+
name: 'person',
|
|
47
|
+
features: [{ name: 'name', required: true, expectedTypeHint: 'String' }],
|
|
48
|
+
});
|
|
49
|
+
const employee = await client.sorts.createSort({
|
|
40
50
|
name: 'employee',
|
|
41
|
-
parents: [
|
|
42
|
-
features:
|
|
51
|
+
parents: [person.id],
|
|
52
|
+
features: [
|
|
53
|
+
{ name: 'salary', required: false, expectedTypeHint: 'Real' },
|
|
54
|
+
{ name: 'hired_at', required: false, expectedTypeHint: 'DateTime' },
|
|
55
|
+
],
|
|
43
56
|
});
|
|
44
57
|
|
|
45
|
-
//
|
|
58
|
+
// A Ψ-term. Plain JS values convert themselves; `Value.*` is for the rest.
|
|
46
59
|
const term = await client.terms.createTerm({
|
|
47
|
-
|
|
60
|
+
sortId: employee.id,
|
|
61
|
+
ownerId: 'your-tenant-uuid',
|
|
48
62
|
features: {
|
|
49
|
-
name:
|
|
50
|
-
salary:
|
|
63
|
+
name: 'Alice',
|
|
64
|
+
salary: 95000,
|
|
65
|
+
hired_at: Value.dateTime('2024-03-01T00:00:00Z'),
|
|
51
66
|
},
|
|
52
67
|
});
|
|
53
68
|
|
|
54
|
-
//
|
|
69
|
+
// A rule. `?X` is a logic variable; repeating it is what makes a join.
|
|
70
|
+
await client.sorts.createSort({
|
|
71
|
+
name: 'well_paid',
|
|
72
|
+
features: [{ name: 'name', required: false }],
|
|
73
|
+
});
|
|
55
74
|
await client.inference.addRule({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
term: TermInput.byName('employee', {
|
|
62
|
-
name: FeatureInput.variable('X'),
|
|
63
|
-
salary: FeatureInput.constrainedVar('S', { op: 'gt', value: 80000 }),
|
|
64
|
-
}),
|
|
65
|
-
},
|
|
75
|
+
term: psi('well_paid', { name: '?X' }),
|
|
76
|
+
antecedents: [
|
|
77
|
+
psi('employee', { name: '?X', salary: '?S' }),
|
|
78
|
+
Constraint.where('?S', '>', 80000),
|
|
66
79
|
],
|
|
67
80
|
});
|
|
68
81
|
|
|
69
|
-
//
|
|
70
|
-
const
|
|
71
|
-
goal:
|
|
72
|
-
person: FeatureInput.variable('Who'),
|
|
73
|
-
}),
|
|
74
|
-
max_solutions: 10,
|
|
82
|
+
// Prove it, and walk every employee without writing the offset arithmetic.
|
|
83
|
+
const proved = await client.inference.backwardChain({
|
|
84
|
+
goal: psi('well_paid', { name: '?X' }),
|
|
75
85
|
});
|
|
86
|
+
for await (const employee of client.terms.iterateTerms({ sortName: 'employee' })) {
|
|
87
|
+
console.log(employee.id);
|
|
88
|
+
}
|
|
76
89
|
|
|
77
|
-
|
|
90
|
+
// One slow call gets a budget of its own; the client keeps its default.
|
|
91
|
+
await client.inference.forwardChain({ maxIterations: 100 }, { timeoutMs: 600_000 });
|
|
78
92
|
```
|
|
79
93
|
|
|
80
94
|
## Resource Clients
|
|
@@ -109,6 +123,13 @@ console.log(result.solutions); // Solutions with bindings
|
|
|
109
123
|
| `discovery` | Discovery | causal effect discovery, prediction |
|
|
110
124
|
| `extract` | Extraction | entity extraction from text |
|
|
111
125
|
| `optimize` | Optimization | LP solve, KB-driven optimization |
|
|
126
|
+
| `snapshots` | Tenant snapshots | capture, export, import, restore |
|
|
127
|
+
| `audit` | Conversation audit chain | append, list, count, verify integrity |
|
|
128
|
+
| `analysis` | Analysis | FCA sort discovery, attribute exploration, rule-base certification |
|
|
129
|
+
| `compliance` | Compliance | audit receipts, EU AI Act conformity |
|
|
130
|
+
|
|
131
|
+
A row per area, not per client — the SDK ships 100 resource clients in all.
|
|
132
|
+
|
|
112
133
|
|
|
113
134
|
## Configuration
|
|
114
135
|
|