@kortexya/reasoninglayer 1.27.0 → 2.0.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 CHANGED
@@ -186,16 +186,31 @@ browser code that has already gone through the platform's login flow.
186
186
 
187
187
  ## Response Metadata
188
188
 
189
+ A resource method resolves to the parsed body alone. To see a **successful**
190
+ response's status, headers or rate-limit budget, register an interceptor — it
191
+ wraps every request the client makes.
192
+
189
193
  ```typescript
190
- // Default: returns data directly
191
- const sort = await client.sorts.createSort({ name: 'person' });
194
+ const client = new ReasoningLayerClient({
195
+ baseUrl: 'https://platform.ovh.reasoninglayer.ai',
196
+ tenantId: 'your-tenant-uuid',
197
+ auth: { mode: 'cookie' },
198
+ interceptors: [
199
+ async (request, next) => {
200
+ const response = await next(request);
201
+ console.log(response.status); // 201
202
+ console.log(response.headers.get('x-ratelimit-remaining')); // '99'
203
+ return response;
204
+ },
205
+ ],
206
+ });
192
207
 
193
- // With metadata: returns { data, status, headers, rateLimit }
194
- const result = await client.sorts.withMetadata().createSort({ name: 'person' });
195
- console.log(result.status); // 201
196
- console.log(result.rateLimit); // { limit, remaining, retryAfter }
208
+ const sort = await client.sorts.createSort({ name: 'person' });
197
209
  ```
198
210
 
211
+ On a **failure**, the thrown `ApiError` carries `status` and `headers`
212
+ directly — see Error Handling below.
213
+
199
214
  ## Error Handling
200
215
 
201
216
  ```typescript
@@ -227,23 +242,28 @@ try {
227
242
  The SDK provides builder functions for constructing API request values with full type safety:
228
243
 
229
244
  ```typescript
230
- import { Value, FeatureInput, TermInput, guard, allen, SortBuilder, psi, LP } from '@kortexya/reasoninglayer';
245
+ import { Value, FuzzyShape, guard, constrained, allen, SortBuilder, psi, LP } from '@kortexya/reasoninglayer';
231
246
 
232
- // Tagged values (term CRUD)
233
- Value.string('hello') // { type: 'String', value: 'hello' }
234
- Value.integer(42) // { type: 'Integer', value: 42 }
235
- Value.fuzzyNumber('triangular', { a: 20, b: 22, c: 24 })
247
+ // Tagged values (term CRUD). A plain scalar needs no builder — the resource
248
+ // methods tag it for you. `Value.*` is for the shapes a scalar cannot express.
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', … } }
236
254
 
237
- // Untagged values (inference)
238
- FeatureInput.string('hello') // 'hello'
239
- FeatureInput.variable('X') // { name: 'X' }
240
- FeatureInput.constrainedVar('S', { op: 'gt', value: 80000 })
255
+ // Untagged values (inference). `psi()` writes them: a scalar stays a scalar,
256
+ // and a '?Name' string becomes a logic variable.
257
+ psi('employee', { name: '?Name', department: 'Engineering' })
258
+ // { sortName: 'employee', features: { name: { name: '?Name' }, } }
241
259
 
242
- // Guard constraints
243
- guard('gt', 100) // { guard: { op: 'gt', value: 100 } }
260
+ // Guard constraints — a guard is itself a Ψ-term
261
+ guard('gt', 100) // { sortName: 'guard_constraint', features: { op: 'gt', right: 100 } }
262
+ constrained('?Salary', guard('gt', 80000))
244
263
 
245
264
  // Allen temporal relations
246
- allen('before') // { allen: 'before' }
265
+ allen('before', '?Employment', intervalTermId)
266
+ // { type: 'Allen', intervalA: '?Employment', … }
247
267
 
248
268
  // LP optimization
249
269
  LP.maximize({ x: 3, y: 5 }) // objective function