@kortexya/reasoninglayer 3.0.1 → 3.1.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.cjs CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/config.ts
10
- var SDK_VERSION = "3.0.1";
10
+ var SDK_VERSION = "3.1.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -167,6 +167,21 @@ var OsfqlError = class extends ApiError {
167
167
  this.sortDeleteRefusal = failure.sortDeleteRefusal;
168
168
  }
169
169
  };
170
+ var NamedConstraintViolationError = class extends ApiError {
171
+ name = "NamedConstraintViolationError";
172
+ /** The feature whose constraint refused the write, when the engine names it. */
173
+ feature;
174
+ /** The constraint's name, when its author gave one. */
175
+ constraintName;
176
+ /** The constraint's message, when its author gave one. */
177
+ constraintMessage;
178
+ constructor(message, body, headers, refusal, errorCode) {
179
+ super(message, 422, body, headers, errorCode);
180
+ this.feature = refusal.feature;
181
+ this.constraintName = refusal.constraintName;
182
+ this.constraintMessage = refusal.constraintMessage;
183
+ }
184
+ };
170
185
  var RateLimitError = class extends ApiError {
171
186
  name = "RateLimitError";
172
187
  /** Seconds to wait before retrying, or null if not specified. */
@@ -290,6 +305,10 @@ function createApiError(status, body, headers) {
290
305
  if (rows !== null) {
291
306
  return new BulkRefusedError(message, body, headers, rows, errorCode);
292
307
  }
308
+ const named = namedConstraintRefusal(body);
309
+ if (named !== null) {
310
+ return new NamedConstraintViolationError(message, body, headers, named, errorCode);
311
+ }
293
312
  return new ApiError(message, status, body, headers, errorCode);
294
313
  }
295
314
  case 429: {
@@ -341,7 +360,9 @@ function bulkRefusalRows(body) {
341
360
  rows.push({
342
361
  index: row.index,
343
362
  message: row.message,
344
- ...typeof row.feature === "string" ? { feature: row.feature } : {}
363
+ ...typeof row.feature === "string" ? { feature: row.feature } : {},
364
+ ...typeof row.constraint_name === "string" ? { constraintName: row.constraint_name } : {},
365
+ ...typeof row.constraint_message === "string" ? { constraintMessage: row.constraint_message } : {}
345
366
  });
346
367
  }
347
368
  return rows.length > 0 ? rows : null;
@@ -369,6 +390,18 @@ function derivedFactRefusal(body) {
369
390
  repairs
370
391
  };
371
392
  }
393
+ function namedConstraintRefusal(body) {
394
+ if (typeof body !== "object" || body === null) return null;
395
+ const obj = body;
396
+ const constraintName = typeof obj.constraint_name === "string" ? obj.constraint_name : void 0;
397
+ const constraintMessage = typeof obj.constraint_message === "string" ? obj.constraint_message : void 0;
398
+ if (constraintName === void 0 && constraintMessage === void 0) return null;
399
+ return {
400
+ ...typeof obj.feature === "string" ? { feature: obj.feature } : {},
401
+ ...constraintName !== void 0 ? { constraintName } : {},
402
+ ...constraintMessage !== void 0 ? { constraintMessage } : {}
403
+ };
404
+ }
372
405
  function isConstraintViolationBody(body) {
373
406
  if (!isErrorBody(body)) return false;
374
407
  if (!("details" in body)) return false;
@@ -1276,6 +1309,24 @@ var Sorts = class {
1276
1309
  format: "json",
1277
1310
  ...params
1278
1311
  });
1312
+ /**
1313
+ * @description A `Proposed` sort becomes `Active`; a sort only flagged `needs_review` has the flag cleared. Anything else is not awaiting approval (409). Requires `Manage` on the sort under a gateway policy; the gateway's `approve_sort` rule additionally refuses the sort's own proposer.
1314
+ *
1315
+ * @tags sorts
1316
+ * @name ApproveSort
1317
+ * @summary Approve a candidate sort
1318
+ * @request POST:/api/v1/sorts/{id}/approve
1319
+ * @secure
1320
+ */
1321
+ approveSort = (id, data, params = {}) => this.http.request({
1322
+ path: `/api/v1/sorts/${id}/approve`,
1323
+ method: "POST",
1324
+ body: data,
1325
+ secure: true,
1326
+ type: "application/json",
1327
+ format: "json",
1328
+ ...params
1329
+ });
1279
1330
  /**
1280
1331
  * @description POST /api/v1/sorts/bulk Creates multiple sorts in a single request, automatically resolving parent references by name. Sorts are topologically sorted to ensure parents are created before children. This is much faster than individual requests for large hierarchies. # Authorization Requires X-Tenant-Id header. The tenant_id field in the request body is ignored.
1281
1332
  *
@@ -1375,6 +1426,60 @@ var Sorts = class {
1375
1426
  format: "json",
1376
1427
  ...params
1377
1428
  });
1429
+ /**
1430
+ * @description Retires the sort, optionally in favour of a replacement (whose id or name is given), with a mandatory reason. Used both to reject a candidate after materialize and to retire an established concept.
1431
+ *
1432
+ * @tags sorts
1433
+ * @name DeprecateSort
1434
+ * @summary Deprecate (reject) a sort
1435
+ * @request POST:/api/v1/sorts/{id}/deprecate
1436
+ * @secure
1437
+ */
1438
+ deprecateSort = (id, data, params = {}) => this.http.request({
1439
+ path: `/api/v1/sorts/${id}/deprecate`,
1440
+ method: "POST",
1441
+ body: data,
1442
+ secure: true,
1443
+ type: "application/json",
1444
+ format: "json",
1445
+ ...params
1446
+ });
1447
+ /**
1448
+ * @description The steward's edit of where a concept sits: `add` and `remove` name parents by id or by name, and the sort keeps every other parent in its current order (added ones go last). The move itself is the one `PUT /api/v1/sorts/{id}/parents` runs (#292): the sort keeps its id and record, its subtree moves with it, the inherited declarations and the subsumption caches (GLB/LUB included) are repaired, and a refused move changes nothing. Requires `Manage` on the sort and on every parent added or removed under a gateway policy: a move changes who inherits access to the sort through a descendant grant. A change appends an `OversightDecision{modified}` to the audit ledger naming the reviewer. # Refused (422), with nothing changed An unknown parent, a parent to remove that is not one, an empty edit, the sort itself, a parent below the sort (a cycle), and every state the move would make contradictory (⊥): two cells of one disjoint facet, an inherited declaration no value satisfies, an own declaration weaker than a new ancestor's, a bound constraint left without its feature.
1449
+ *
1450
+ * @tags sorts
1451
+ * @name EditSortParents
1452
+ * @summary Add and remove parents of a sort
1453
+ * @request POST:/api/v1/sorts/{id}/parents
1454
+ * @secure
1455
+ */
1456
+ editSortParents = (id, data, params = {}) => this.http.request({
1457
+ path: `/api/v1/sorts/${id}/parents`,
1458
+ method: "POST",
1459
+ body: data,
1460
+ secure: true,
1461
+ type: "application/json",
1462
+ format: "json",
1463
+ ...params
1464
+ });
1465
+ /**
1466
+ * @description Formal Concept Analysis over sort × feature declaration, each declaration taken whole (name, range or type, constraint, requiredness, bound): every set of at least `min_sorts` sorts sharing at least two identical declarations is a candidate mixin. Deterministic; never writes. Accepting a proposal is creating the mixin (as a `proposed` sort) and re-parenting the members — the caller's decision.
1467
+ *
1468
+ * @tags sorts
1469
+ * @name FactorSortShapes
1470
+ * @summary Propose mixin parents for shapes several sorts repeat unchanged
1471
+ * @request POST:/api/v1/sorts/discovery/factor
1472
+ * @secure
1473
+ */
1474
+ factorSortShapes = (data, params = {}) => this.http.request({
1475
+ path: `/api/v1/sorts/discovery/factor`,
1476
+ method: "POST",
1477
+ body: data,
1478
+ secure: true,
1479
+ type: "application/json",
1480
+ format: "json",
1481
+ ...params
1482
+ });
1378
1483
  /**
1379
1484
  * No description
1380
1485
  *
@@ -1723,7 +1828,7 @@ var Sorts = class {
1723
1828
  ...params
1724
1829
  });
1725
1830
  /**
1726
- * @description The body's `parents` REPLACES the sort's parent set; an empty list makes it a root. The sort keeps its id and its whole record — features, bounds, SKOS fields, annotations, status, provenance — and its subtree moves with it. Nothing is deleted and nothing is re-created. What depends on the ancestors is repaired for the sort and every subsort: the subsumption encoding, and the INHERITED feature declarations (a feature inherited from an old ancestor goes, one from a new ancestor comes; a declaration the sort makes itself is never touched). The response reports those changes, the terms whose sort now has different ancestors, and the rules naming a moved sort. The OSFQL spelling is `ALTER SORT <name> PARENTS (<parent>, …);` — the same move. # Refused, with nothing changed An unknown parent (or another tenant's), the sort itself, a parent below the sort (a cycle), a move past the depth cap, a facet violation, an own declaration weaker than a new ancestor's, a bound constraint left naming a feature a sort would stop inheriting, a declaration contradiction inherited from two new ancestors, a shared or authorization-schema sort, and a sort with more than 512 persisted subsorts. # Errors - 400 Bad Request: the move was refused; the message names the cause - 404 Not Found: no such sort for this tenant
1831
+ * @description The body's `parents` REPLACES the sort's parent set; an empty list makes it a root. The sort keeps its id and its whole record — features, bounds, SKOS fields, annotations, status, provenance — and its subtree moves with it. Nothing is deleted and nothing is re-created. What depends on the ancestors is repaired for the sort and every subsort: the subsumption encoding, and the INHERITED feature declarations (a feature inherited from an old ancestor goes, one from a new ancestor comes; a declaration the sort makes itself is never touched). The response reports those changes, the terms whose sort now has different ancestors, and the rules naming a moved sort. The OSFQL spelling is `ALTER SORT <name> PARENTS (<parent>, …);` — the same move. # Governed Requires `Manage` on the sort and on every parent the move adds or removes, and a move that changes anything appends an `OversightDecision{modified}` naming the reviewer — the same door `POST /sorts/{id}/parents` and OSFQL go through. # Refused, with nothing changed An unknown parent (or another tenant's), the sort itself, a parent below the sort (a cycle), a move past the depth cap, a facet violation, an own declaration weaker than a new ancestor's, a bound constraint left naming a feature a sort would stop inheriting, a declaration contradiction inherited from two new ancestors, a shared or authorization-schema sort, and a sort with more than 512 persisted subsorts. # Errors - 400 Bad Request: the move was refused; the message names the cause - 404 Not Found: no such sort for this tenant
1727
1832
  *
1728
1833
  * @tags sorts
1729
1834
  * @name ReparentSort
@@ -2593,6 +2698,24 @@ var Inference = class {
2593
2698
  format: "json",
2594
2699
  ...params
2595
2700
  });
2701
+ /**
2702
+ * @description Takes the body `POST /api/v1/inference/rules` takes and runs every check that write runs — sorts and referenced terms resolve, guard bounds compare with their declared types, nested negation, binders, range restriction (every conclusion variable bound by a POSITIVE antecedent), aggregator, and the homoiconic encoding itself — by building the rule into a scratch copy of the tenant's store. Nothing is written, persisted, or propagated. Stratification included: a rule that closes a NEW cycle through negation against the existing program is refused by both (a cycle the program already had is not blamed on it). `ok` is exactly whether the write would accept the rule; `refusals` names why not, with the status the write would answer. `warnings` adds what the write accepts but the program may not mean: variables only a `NOT` mentions (NAF safety).
2703
+ *
2704
+ * @tags inference
2705
+ * @name ValidateRule
2706
+ * @summary Validate a rule without writing it
2707
+ * @request POST:/api/v1/inference/rules/validate
2708
+ * @secure
2709
+ */
2710
+ validateRule = (data, params = {}) => this.http.request({
2711
+ path: `/api/v1/inference/rules/validate`,
2712
+ method: "POST",
2713
+ body: data,
2714
+ secure: true,
2715
+ type: "application/json",
2716
+ format: "json",
2717
+ ...params
2718
+ });
2596
2719
  };
2597
2720
 
2598
2721
  // src/api-spec/generated/Cognitive.ts
@@ -3202,11 +3325,11 @@ var CognitiveAgentsMessaging = class {
3202
3325
  * No description
3203
3326
  *
3204
3327
  * @tags Cognitive Agents - Messaging
3205
- * @name GetInbox
3328
+ * @name GetAgentInbox
3206
3329
  * @summary Get an agent's inbox.
3207
3330
  * @request POST:/api/v1/cognitive/agents/messages/inbox
3208
3331
  */
3209
- getInbox = (data, params = {}) => this.http.request({
3332
+ getAgentInbox = (data, params = {}) => this.http.request({
3210
3333
  path: `/api/v1/cognitive/agents/messages/inbox`,
3211
3334
  method: "POST",
3212
3335
  body: data,
@@ -10225,6 +10348,23 @@ var Ontology = class {
10225
10348
  format: "json",
10226
10349
  ...params
10227
10350
  });
10351
+ /**
10352
+ * @description The fluent term about `of` with the latest `valid_from` not after `at` (default: now). 404 when the sort is unknown or no state is recorded by then.
10353
+ *
10354
+ * @tags ontology
10355
+ * @name CurrentFluentValue
10356
+ * @summary Current value of a fluent
10357
+ * @request GET:/api/v1/fluents/current
10358
+ * @secure
10359
+ */
10360
+ currentFluentValue = (query, params = {}) => this.http.request({
10361
+ path: `/api/v1/fluents/current`,
10362
+ method: "GET",
10363
+ query,
10364
+ secure: true,
10365
+ format: "json",
10366
+ ...params
10367
+ });
10228
10368
  /**
10229
10369
  * No description
10230
10370
  *
@@ -10277,6 +10417,22 @@ var Ontology = class {
10277
10417
  format: "json",
10278
10418
  ...params
10279
10419
  });
10420
+ /**
10421
+ * No description
10422
+ *
10423
+ * @tags ontology
10424
+ * @name GetOntologyScope
10425
+ * @summary Read the ontology's scope.
10426
+ * @request GET:/api/v1/ontology/scope
10427
+ * @secure
10428
+ */
10429
+ getOntologyScope = (params = {}) => this.http.request({
10430
+ path: `/api/v1/ontology/scope`,
10431
+ method: "GET",
10432
+ secure: true,
10433
+ format: "json",
10434
+ ...params
10435
+ });
10280
10436
  /**
10281
10437
  * No description
10282
10438
  *
@@ -10325,6 +10481,24 @@ var Ontology = class {
10325
10481
  format: "json",
10326
10482
  ...params
10327
10483
  });
10484
+ /**
10485
+ * No description
10486
+ *
10487
+ * @tags ontology
10488
+ * @name PutOntologyScope
10489
+ * @summary Set the ontology's scope (replaces it).
10490
+ * @request PUT:/api/v1/ontology/scope
10491
+ * @secure
10492
+ */
10493
+ putOntologyScope = (data, params = {}) => this.http.request({
10494
+ path: `/api/v1/ontology/scope`,
10495
+ method: "PUT",
10496
+ body: data,
10497
+ secure: true,
10498
+ type: "application/json",
10499
+ format: "json",
10500
+ ...params
10501
+ });
10328
10502
  /**
10329
10503
  * No description
10330
10504
  *
@@ -10343,6 +10517,19 @@ var Ontology = class {
10343
10517
  format: "json",
10344
10518
  ...params
10345
10519
  });
10520
+ /**
10521
+ * No description
10522
+ *
10523
+ * @tags ontology
10524
+ * @name UpperOntology
10525
+ * @summary Serve an embedded upper-ontology seed (`bfo-2020` or `cco-facility`) — the same OWL the lattice-grounding aligner uses, offered to the guided builder's vocabulary stage as an anchor to reuse rather than reinvent.
10526
+ * @request GET:/api/v1/ontology/upper/{name}
10527
+ */
10528
+ upperOntology = (name, params = {}) => this.http.request({
10529
+ path: `/api/v1/ontology/upper/${name}`,
10530
+ method: "GET",
10531
+ ...params
10532
+ });
10346
10533
  };
10347
10534
 
10348
10535
  // src/api-spec/generated/Generation.ts
@@ -13632,6 +13819,31 @@ var OntologyExport = class {
13632
13819
  });
13633
13820
  };
13634
13821
 
13822
+ // src/api-spec/generated/Argumentation.ts
13823
+ var Argumentation = class {
13824
+ http;
13825
+ constructor(http) {
13826
+ this.http = http;
13827
+ }
13828
+ /**
13829
+ * No description
13830
+ *
13831
+ * @tags argumentation
13832
+ * @name EvaluateArgumentation
13833
+ * @request POST:/api/v1/argumentation/evaluate
13834
+ * @secure
13835
+ */
13836
+ evaluateArgumentation = (data, params = {}) => this.http.request({
13837
+ path: `/api/v1/argumentation/evaluate`,
13838
+ method: "POST",
13839
+ body: data,
13840
+ secure: true,
13841
+ type: "application/json",
13842
+ format: "json",
13843
+ ...params
13844
+ });
13845
+ };
13846
+
13635
13847
  // src/api-spec/generated/Embeddings.ts
13636
13848
  var Embeddings = class {
13637
13849
  http;
@@ -15088,7 +15300,9 @@ function BulkRowRefusalFromApiToFront(dto) {
15088
15300
  return {
15089
15301
  index: dto.index,
15090
15302
  message: dto.message,
15091
- ...dto.feature ? { feature: dto.feature } : {}
15303
+ ...dto.feature ? { feature: dto.feature } : {},
15304
+ ...dto.constraint_name != null ? { constraintName: dto.constraint_name } : {},
15305
+ ...dto.constraint_message != null ? { constraintMessage: dto.constraint_message } : {}
15092
15306
  };
15093
15307
  }
15094
15308
  function ClearTermsResponseFromApiToFront(dto) {
@@ -15204,6 +15418,7 @@ function TermVersionDtoFromApiToFront(dto) {
15204
15418
  if (dto.diff != null) out.diff = VersionDiffDtoFromApiToFront(dto.diff);
15205
15419
  if (dto.follows_a_gap !== void 0) out.followsAGap = dto.follows_a_gap;
15206
15420
  if (dto.forked_to != null) out.forkedTo = dto.forked_to;
15421
+ if (dto.seeded !== void 0) out.seeded = dto.seeded;
15207
15422
  return out;
15208
15423
  }
15209
15424
  function TermVersionsResponseFromApiToFront(dto) {
@@ -15244,6 +15459,8 @@ function ConstraintDtoFromFrontToApi(model) {
15244
15459
  function FeatureDescriptorDtoFromApiToFront(dto) {
15245
15460
  return {
15246
15461
  name: dto.name,
15462
+ description: dto.description ?? void 0,
15463
+ index: dto.index ?? void 0,
15247
15464
  expectedSort: dto.expected_sort ?? void 0,
15248
15465
  expectedTypeHint: dto.expected_type_hint ?? void 0,
15249
15466
  // The spec made this optional and documents the default explicitly:
@@ -15254,31 +15471,33 @@ function FeatureDescriptorDtoFromApiToFront(dto) {
15254
15471
  // `undefined` for a question the wire already answers.
15255
15472
  required: dto.required ?? false,
15256
15473
  constraint: dto.constraint ? ConstraintDtoFromApiToFront(dto.constraint) : void 0,
15474
+ constraintName: dto.constraint_name ?? void 0,
15475
+ constraintMessage: dto.constraint_message ?? void 0,
15257
15476
  key: dto.key,
15258
15477
  expectedSortName: dto.expected_sort_name ?? void 0,
15259
15478
  minCount: dto.min_count ?? void 0,
15260
15479
  maxCount: dto.max_count ?? void 0,
15261
15480
  cardinalityOrigin: dto.cardinality_origin ?? void 0,
15262
- annotations: definedRecord2(dto.annotations),
15263
- description: dto.description ?? void 0,
15264
- index: dto.index ?? void 0
15481
+ annotations: definedRecord2(dto.annotations)
15265
15482
  };
15266
15483
  }
15267
15484
  function FeatureDescriptorDtoFromFrontToApi(model) {
15268
15485
  return {
15269
15486
  name: model.name,
15487
+ description: model.description ?? void 0,
15488
+ index: model.index ?? void 0,
15270
15489
  expected_sort: model.expectedSort ?? void 0,
15271
15490
  expected_type_hint: model.expectedTypeHint ?? void 0,
15272
15491
  required: model.required,
15273
15492
  constraint: model.constraint ? ConstraintDtoFromFrontToApi(model.constraint) : void 0,
15493
+ constraint_name: model.constraintName ?? void 0,
15494
+ constraint_message: model.constraintMessage ?? void 0,
15274
15495
  key: model.key,
15275
15496
  expected_sort_name: model.expectedSortName ?? void 0,
15276
15497
  min_count: model.minCount ?? void 0,
15277
15498
  max_count: model.maxCount ?? void 0,
15278
15499
  cardinality_origin: model.cardinalityOrigin ?? void 0,
15279
- annotations: model.annotations,
15280
- description: model.description ?? void 0,
15281
- index: model.index ?? void 0
15500
+ annotations: model.annotations
15282
15501
  };
15283
15502
  }
15284
15503
  function CoextensiveDefinitionDtoFromApiToFront(dto) {
@@ -15385,6 +15604,12 @@ function SortInfoDtoFromApiToFront(dto) {
15385
15604
  name: dto.name ?? void 0
15386
15605
  };
15387
15606
  }
15607
+ function SortResponseFromApiToFront(dto) {
15608
+ return {
15609
+ sort: SortDtoFromApiToFront(dto.sort),
15610
+ wokenResiduations: dto.woken_residuations ?? void 0
15611
+ };
15612
+ }
15388
15613
  function SortListResponseFromApiToFront(dto) {
15389
15614
  return {
15390
15615
  sorts: dto.sorts.map(SortDtoFromApiToFront),
@@ -15723,11 +15948,38 @@ function SortIndexStatusResponseFromApiToFront(dto) {
15723
15948
  if (dto.last_indexed_count != null) out.lastIndexedCount = dto.last_indexed_count;
15724
15949
  return out;
15725
15950
  }
15726
- function DeprecateSortRequestFromFrontToApi(model) {
15727
- const out = { replacement: model.replacement };
15951
+ function ApproveSortRequestFromFrontToApi(model) {
15952
+ const out = {};
15728
15953
  if (model.reason !== void 0) out.reason = model.reason;
15729
15954
  return out;
15730
15955
  }
15956
+ function DeprecateSortRequestFromFrontToApi(model) {
15957
+ const out = { reason: model.reason };
15958
+ if (model.replacement !== void 0) out.replacement = model.replacement;
15959
+ return out;
15960
+ }
15961
+ function FactorSortsRequestFromFrontToApi(model) {
15962
+ const out = {};
15963
+ if (model.sortIds !== void 0) out.sort_ids = model.sortIds;
15964
+ if (model.minSorts !== void 0) out.min_sorts = model.minSorts;
15965
+ return out;
15966
+ }
15967
+ function FactorSharedFeatureFromApiToFront(dto) {
15968
+ const out = { name: dto.name, required: dto.required };
15969
+ if (dto.expected_sort != null) out.expectedSort = dto.expected_sort;
15970
+ if (dto.expected_type_hint != null) out.expectedTypeHint = dto.expected_type_hint;
15971
+ if (dto.constraint != null) out.constraint = ConstraintDtoFromApiToFront(dto.constraint);
15972
+ return out;
15973
+ }
15974
+ function FactorSortsResponseFromApiToFront(dto) {
15975
+ return {
15976
+ proposals: dto.proposals.map((p) => ({
15977
+ memberSorts: p.member_sorts.map((m) => ({ id: m.id, name: m.name })),
15978
+ sharedFeatures: p.shared_features.map(FactorSharedFeatureFromApiToFront),
15979
+ suggestedName: p.suggested_name
15980
+ }))
15981
+ };
15982
+ }
15731
15983
  function PatchSortRequestFromFrontToApi(model) {
15732
15984
  const out = {};
15733
15985
  if (model.name !== void 0) out.name = model.name;
@@ -15739,10 +15991,6 @@ function PatchSortRequestFromFrontToApi(model) {
15739
15991
  if (model.scopeNote !== void 0) out.scope_note = model.scopeNote;
15740
15992
  if (model.annotations !== void 0) out.annotations = model.annotations;
15741
15993
  if (model.worldMode !== void 0) out.world_mode = model.worldMode;
15742
- if (model.approveProposed !== void 0) out.approve_proposed = model.approveProposed;
15743
- if (model.deprecate !== void 0) {
15744
- out.deprecate = model.deprecate === null ? null : DeprecateSortRequestFromFrontToApi(model.deprecate);
15745
- }
15746
15994
  return out;
15747
15995
  }
15748
15996
  function DeleteSortOptionsFromFrontToApi(options) {
@@ -15765,6 +16013,14 @@ function DeleteSortResponseFromApiToFront(dto) {
15765
16013
  if (dto.rules_orphaned !== void 0) {
15766
16014
  out.rulesOrphaned = dto.rules_orphaned.map(SortReferencingRuleDtoFromApiToFront);
15767
16015
  }
16016
+ if (dto.sorts_deleted !== void 0) out.sortsDeleted = dto.sorts_deleted;
16017
+ return out;
16018
+ }
16019
+ function EditSortParentsRequestFromFrontToApi(model) {
16020
+ const out = {};
16021
+ if (model.add !== void 0) out.add = model.add;
16022
+ if (model.remove !== void 0) out.remove = model.remove;
16023
+ if (model.reason !== void 0) out.reason = model.reason;
15768
16024
  return out;
15769
16025
  }
15770
16026
  function SortReferencingRuleDtoFromApiToFront(dto) {
@@ -15932,8 +16188,8 @@ var SortsClient = class {
15932
16188
  return SortDtoFromApiToFront(response.data.sort);
15933
16189
  }
15934
16190
  /**
15935
- * Curate a sort's vocabulary and lifecycle: rename, describe, label,
15936
- * relate, annotate, approve or deprecate it.
16191
+ * Curate a sort's vocabulary: rename, describe, label, relate, annotate it,
16192
+ * or change its world mode.
15937
16193
  *
15938
16194
  * @param sortId - Sort UUID.
15939
16195
  * @param request - The fields to change. Only present fields mutate.
@@ -15970,6 +16226,97 @@ var SortsClient = class {
15970
16226
  );
15971
16227
  return SortDtoFromApiToFront(response.data.sort);
15972
16228
  }
16229
+ /**
16230
+ * Approve a candidate sort: promote it from `Proposed` to `Active`.
16231
+ *
16232
+ * @param sortId - Sort UUID.
16233
+ * @param request - Optionally, why the steward accepted it.
16234
+ * @returns The approved sort, and how much suspended work its declaration
16235
+ * released (`wokenResiduations`).
16236
+ * @throws {ForbiddenError} 403 when the caller holds no Manage grant on the
16237
+ * sort — including the proposer approving their own candidate, which the
16238
+ * gateway denies.
16239
+ * @throws {NotFoundError} 404 when the sort does not exist.
16240
+ * @throws {ApiError} 409 when the sort is not awaiting approval.
16241
+ *
16242
+ * @remarks
16243
+ * Appends an approval decision to the compliance ledger, with the
16244
+ * authenticated user as reviewer. This replaced `approveProposed` on
16245
+ * {@link SortsClient.patchSort}, which the engine now refuses.
16246
+ *
16247
+ * @example
16248
+ * ```typescript
16249
+ * const { sort, wokenResiduations } = await client.sorts.approveSort(sortId, {
16250
+ * reason: 'Matches the order lifecycle use case',
16251
+ * });
16252
+ * ```
16253
+ */
16254
+ async approveSort(sortId, request = {}, requestOptions) {
16255
+ const response = await this.sorts.approveSort(
16256
+ sortId,
16257
+ ApproveSortRequestFromFrontToApi(request),
16258
+ toRequestParams(requestOptions)
16259
+ );
16260
+ return SortResponseFromApiToFront(response.data);
16261
+ }
16262
+ /**
16263
+ * Deprecate a sort: reject a candidate, or retire an active concept,
16264
+ * optionally in favour of a replacement.
16265
+ *
16266
+ * @param sortId - Sort UUID.
16267
+ * @param request - Why (required), and the replacement's id or name.
16268
+ * @returns The deprecated sort.
16269
+ * @throws {BadRequestError} 400 when `reason` is empty or the replacement does not exist.
16270
+ * @throws {ForbiddenError} 403 when the caller holds no Manage grant on the sort.
16271
+ * @throws {NotFoundError} 404 when the sort does not exist.
16272
+ *
16273
+ * @remarks
16274
+ * Appends a rejection decision to the compliance ledger. `replacement`
16275
+ * accepts a sort id or a sort name in this tenant. This replaced the
16276
+ * `deprecate` arm of {@link SortsClient.patchSort}, which the engine now
16277
+ * refuses.
16278
+ *
16279
+ * @example
16280
+ * ```typescript
16281
+ * await client.sorts.deprecateSort(sortId, {
16282
+ * reason: 'Duplicate of customer',
16283
+ * replacement: 'customer',
16284
+ * });
16285
+ * ```
16286
+ */
16287
+ async deprecateSort(sortId, request, requestOptions) {
16288
+ const response = await this.sorts.deprecateSort(
16289
+ sortId,
16290
+ DeprecateSortRequestFromFrontToApi(request),
16291
+ toRequestParams(requestOptions)
16292
+ );
16293
+ return SortResponseFromApiToFront(response.data);
16294
+ }
16295
+ /**
16296
+ * Propose mixin parents for feature shapes several sorts repeat unchanged.
16297
+ *
16298
+ * @param request - Which sorts to analyse (default: all), and the least
16299
+ * number of sorts a proposal must cover (default and floor: 2).
16300
+ * @returns Candidate parents, most shared declarations first.
16301
+ * @throws {ApiError} If the request fails.
16302
+ *
16303
+ * @remarks
16304
+ * Deterministic and read-only: it groups sorts over identical feature +
16305
+ * constraint declarations. `suggestedName` is a placeholder to rename
16306
+ * before creating the parent.
16307
+ *
16308
+ * @example
16309
+ * ```typescript
16310
+ * const { proposals } = await client.sorts.factorSorts({ minSorts: 3 });
16311
+ * ```
16312
+ */
16313
+ async factorSorts(request = {}, requestOptions) {
16314
+ const response = await this.sorts.factorSortShapes(
16315
+ FactorSortsRequestFromFrontToApi(request),
16316
+ toRequestParams(requestOptions)
16317
+ );
16318
+ return FactorSortsResponseFromApiToFront(response.data);
16319
+ }
15973
16320
  /**
15974
16321
  * Delete a sort by ID.
15975
16322
  *
@@ -16081,6 +16428,47 @@ var SortsClient = class {
16081
16428
  );
16082
16429
  return SortDeletePreviewResponseFromApiToFront(response.data);
16083
16430
  }
16431
+ /**
16432
+ * Add and remove parents of a sort — a steward's governed move in the lattice.
16433
+ *
16434
+ * @param sortId - Sort UUID.
16435
+ * @param request - Parents to add and to remove (by id or by name), and why.
16436
+ * @returns The move's report — what moved, what each sort's inheritance
16437
+ * gained and lost, the terms and rules concerned — with the sort as it now
16438
+ * stands.
16439
+ * @throws {ForbiddenError} 403 without `Manage` on the sort and on every
16440
+ * parent added or removed.
16441
+ * @throws {NotFoundError} 404 when the sort does not exist.
16442
+ * @throws {ApiError} 422, with nothing changed, for an unknown parent, a
16443
+ * parent to remove that is not one, an empty edit, the sort itself, a
16444
+ * parent below the sort (a cycle), or any state the move would make
16445
+ * contradictory (⊥).
16446
+ *
16447
+ * @remarks
16448
+ * The sort keeps every other parent in its current order; added ones go last.
16449
+ * The move is the one {@link SortsClient.reparentSort} runs: the sort keeps
16450
+ * its id and record, its subtree moves with it, inherited declarations and
16451
+ * the subsumption caches are repaired. A change appends an oversight
16452
+ * decision to the audit ledger naming the reviewer.
16453
+ *
16454
+ * @example
16455
+ * ```typescript
16456
+ * const moved = await client.sorts.editSortParents(sortId, {
16457
+ * add: ['vehicle'],
16458
+ * remove: ['thing'],
16459
+ * reason: 'A truck is a vehicle',
16460
+ * });
16461
+ * console.log(moved.inheritanceChanges);
16462
+ * ```
16463
+ */
16464
+ async editSortParents(sortId, request, requestOptions) {
16465
+ const response = await this.sorts.editSortParents(
16466
+ sortId,
16467
+ EditSortParentsRequestFromFrontToApi(request),
16468
+ toRequestParams(requestOptions)
16469
+ );
16470
+ return SortReparentResponseFromApiToFront(response.data);
16471
+ }
16084
16472
  /**
16085
16473
  * Move a sort in the lattice: replace its parent set.
16086
16474
  *
@@ -17938,6 +18326,21 @@ function ResidualDerivationDtoFromApiToFront(dto) {
17938
18326
  function AddRuleResponseFromApiToFront(dto) {
17939
18327
  return { term: PsiTermDtoFromApiToFront(dto.term) };
17940
18328
  }
18329
+ function RuleValidationResponseFromApiToFront(dto) {
18330
+ const issue = (i) => ({
18331
+ kind: i.kind,
18332
+ message: i.message,
18333
+ ...i.status != null ? { status: i.status } : {}
18334
+ });
18335
+ const out = {
18336
+ ok: dto.ok,
18337
+ refusals: dto.refusals.map(issue),
18338
+ warnings: dto.warnings.map(issue)
18339
+ };
18340
+ if (dto.rule !== void 0)
18341
+ out.rule = dto.rule === null ? null : PsiTermDtoFromApiToFront(dto.rule);
18342
+ return out;
18343
+ }
17941
18344
  function AddFactResponseFromApiToFront(dto) {
17942
18345
  return { term: PsiTermDtoFromApiToFront(dto.term) };
17943
18346
  }
@@ -18557,11 +18960,16 @@ var InferenceClient = class {
18557
18960
  * @param request - Rule definition using TermInputDto. Set `aggregator` to declare an
18558
18961
  * engine-side head aggregator (see {@link RuleAggregatorDto}).
18559
18962
  * @returns The created rule wrapped in an AddRuleResponse.
18560
- * @throws {ApiError} If the rule is rejected or the request fails.
18963
+ * @throws {ApiError} If the rule is rejected or the request fails — 422 when
18964
+ * it is unusable as written, including a rule that closes a NEW cycle
18965
+ * through negation (no stratification would order the program; a cycle
18966
+ * the program already had is not blamed on it).
18561
18967
  *
18562
18968
  * @remarks
18563
18969
  * **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
18564
18970
  *
18971
+ * Ask {@link InferenceClient.validateRule} first to learn every reason the
18972
+ * write would refuse, without writing.
18565
18973
  * A `{ termId }` reference to a term that is durable but not yet loaded
18566
18974
  * into the engine process resolves: the route loads the terms the request
18567
18975
  * names before it converts them.
@@ -18588,6 +18996,45 @@ var InferenceClient = class {
18588
18996
  );
18589
18997
  return AddRuleResponseFromApiToFront(response.data);
18590
18998
  }
18999
+ /**
19000
+ * Run every check {@link InferenceClient.addRule} runs — without writing.
19001
+ *
19002
+ * @param request - The same rule `addRule` takes.
19003
+ * @returns Whether the write would accept it (`ok`), every refusal with the
19004
+ * status the write would answer, the NAF-safety warnings, and the rule as
19005
+ * the write would build it.
19006
+ * @throws {ApiError} If the request itself fails.
19007
+ *
19008
+ * @remarks
19009
+ * The rule is built into a scratch copy of the tenant's store: sorts and
19010
+ * referenced terms resolve, guard bounds compare with their declared types,
19011
+ * nested negation, binders, range restriction, the aggregator, the
19012
+ * homoiconic encoding, and stratification (a NEW cycle through negation is
19013
+ * an `unstratifiable` refusal). Nothing is written, persisted or propagated.
19014
+ * **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
19015
+ *
19016
+ * @example
19017
+ * ```typescript
19018
+ * const check = await client.inference.validateRule({
19019
+ * term: psi('adult', { name: Var('N') }),
19020
+ * antecedents: [psi('person', { name: Var('N') })],
19021
+ * });
19022
+ * if (!check.ok) for (const r of check.refusals) console.warn(r.kind, r.message);
19023
+ * ```
19024
+ */
19025
+ async validateRule(request, requestOptions) {
19026
+ const wireRequest = {
19027
+ term: convertTermArg(request.term),
19028
+ antecedents: request.antecedents?.map(convertTermArg),
19029
+ certainty: request.certainty,
19030
+ aggregator: request.aggregator
19031
+ };
19032
+ const response = await this.api.validateRule(
19033
+ AddRuleRequestFromFrontToApi(wireRequest),
19034
+ toRequestParams(requestOptions)
19035
+ );
19036
+ return RuleValidationResponseFromApiToFront(response.data);
19037
+ }
18591
19038
  /**
18592
19039
  * Add a fact.
18593
19040
  *
@@ -18624,7 +19071,9 @@ var InferenceClient = class {
18624
19071
  * its index in `request.rules`, with the engine's reason (for example
18625
19072
  * `rule head term did not resolve: it names sort \`x\`, which this
18626
19073
  * tenant's sort hierarchy does not define`). `rulesAdded` plus
18627
- * `rejected.length` equals the number submitted.
19074
+ * `rejected.length` equals the number submitted. A rule that closes a NEW
19075
+ * cycle through negation is refused the same way (the reason names the
19076
+ * cycle's sorts), decided for every row before any row is written.
18628
19077
  *
18629
19078
  * @example
18630
19079
  * ```typescript
@@ -21113,13 +21562,23 @@ var CognitiveClient = class {
21113
21562
  * Uses POST `/api/v1/cognitive/agents/messages/inbox`. The inbox is per-agent;
21114
21563
  * aggregate across a roster by calling this for each agent.
21115
21564
  */
21116
- async getInbox(request, requestOptions) {
21117
- const response = await this.messaging.getInbox(
21565
+ async getAgentInbox(request, requestOptions) {
21566
+ const response = await this.messaging.getAgentInbox(
21118
21567
  GetInboxRequestFromFrontToApi({ ...request, tenantId: this.tenantId }),
21119
21568
  toRequestParams(requestOptions)
21120
21569
  );
21121
21570
  return GetInboxResponseFromApiToFront(response.data);
21122
21571
  }
21572
+ /**
21573
+ * Get an agent's inbox.
21574
+ *
21575
+ * @deprecated Renamed to {@link CognitiveClient.getAgentInbox} when the engine
21576
+ * renamed the operation (`get_inbox` → `get_agent_inbox`); kept so existing
21577
+ * callers keep compiling. Same request, same response.
21578
+ */
21579
+ async getInbox(request, requestOptions) {
21580
+ return this.getAgentInbox(request, requestOptions);
21581
+ }
21123
21582
  // --- Feedback ---
21124
21583
  /**
21125
21584
  * Provide feedback on an agent result.
@@ -30775,6 +31234,8 @@ function GetScenarioResponseFromApiToFront(dto) {
30775
31234
  }
30776
31235
  function MaterializeScenarioRequestFromFrontToApi(model) {
30777
31236
  return {
31237
+ // Accepted: the scenario is opaque user data sent verbatim (RAW_BODY_HEADER,
31238
+ // #39); the engine validates its shape, so the SDK does not re-type it.
30778
31239
  scenario: model.scenario
30779
31240
  };
30780
31241
  }
@@ -30788,7 +31249,11 @@ function MaterializeScenarioResponseFromApiToFront(dto) {
30788
31249
  rulesCreated: dto.rules_created,
30789
31250
  sensorPointsCreated: dto.sensor_points_created,
30790
31251
  sortsCreated: dto.sorts_created,
30791
- warnings: dto.warnings
31252
+ warnings: dto.warnings,
31253
+ ...dto.competency_questions_created !== void 0 ? { competencyQuestionsCreated: dto.competency_questions_created } : {},
31254
+ ...dto.computed_features_created !== void 0 ? { computedFeaturesCreated: dto.computed_features_created } : {},
31255
+ ...dto.fluents_created !== void 0 ? { fluentsCreated: dto.fluents_created } : {},
31256
+ ...dto.proposed_sort_ids !== void 0 ? { proposedSortIds: dto.proposed_sort_ids } : {}
30792
31257
  };
30793
31258
  }
30794
31259
  function UpdateScenarioRequestFromFrontToApi(model) {
@@ -30908,6 +31373,11 @@ var ScenariosClient = class {
30908
31373
  * written. No value-level serialization split applies. Response fields are
30909
31374
  * normalized from snake_case to camelCase.
30910
31375
  *
31376
+ * Staged builder: sorts marked `proposed: true` land as `Proposed` candidates
31377
+ * (their ids in `proposedSortIds`, awaiting a steward's approval), and the
31378
+ * scenario's use cases and competency questions are recorded as `proposed`
31379
+ * competency questions.
31380
+ *
30911
31381
  * @example
30912
31382
  * ```typescript
30913
31383
  * const result = await client.scenarios.materializeScenario({ scenario: generated });
@@ -32633,7 +33103,8 @@ function StartExplorationRequestFromFrontToApi(model) {
32633
33103
  max_concepts: model.maxConcepts,
32634
33104
  min_extent_size: model.minExtentSize,
32635
33105
  min_intent_size: model.minIntentSize,
32636
- max_terms: model.maxTerms
33106
+ max_terms: model.maxTerms,
33107
+ ...model.sortNames !== void 0 ? { sort_names: model.sortNames } : {}
32637
33108
  };
32638
33109
  }
32639
33110
  function StartExplorationResponseFromApiToFront(dto) {
@@ -33921,7 +34392,10 @@ function NegativeExampleDtoFromApiToFront(dto) {
33921
34392
  rejectionReason: dto.rejection_reason,
33922
34393
  sortId: dto.sort_id,
33923
34394
  strategy: dto.strategy,
33924
- termId: dto.term_id
34395
+ termId: dto.term_id,
34396
+ ...dto.sort != null ? { sort: dto.sort } : {},
34397
+ ...dto.features != null ? { features: Object.fromEntries(Object.entries(dto.features)) } : {},
34398
+ ...dto.world_mode != null ? { worldMode: dto.world_mode } : {}
33925
34399
  };
33926
34400
  }
33927
34401
  function GenerateNegativesRequestFromFrontToApi(model) {
@@ -35442,12 +35916,15 @@ var ImageExtractionClient = class {
35442
35916
 
35443
35917
  // src/normalizers/ontology.ts
35444
35918
  function GenerateOntologyRequestFromFrontToApi(model) {
35445
- return {
35919
+ const out = {
35446
35920
  answers: model.answers,
35447
35921
  prompt: model.prompt,
35448
35922
  session_id: model.sessionId,
35449
35923
  tenant_id: model.tenantId
35450
35924
  };
35925
+ if (model.stage !== void 0) out.stage = model.stage;
35926
+ if (model.draft !== void 0) out.draft = model.draft;
35927
+ return out;
35451
35928
  }
35452
35929
  function GenerateOntologyResponseFromApiToFront(dto) {
35453
35930
  if (dto.status === "needs_clarification") {
@@ -35458,6 +35935,15 @@ function GenerateOntologyResponseFromApiToFront(dto) {
35458
35935
  understood: dto.understood
35459
35936
  };
35460
35937
  }
35938
+ if (dto.status === "patch") {
35939
+ const out = {
35940
+ stage: dto.stage,
35941
+ patch: dto.patch,
35942
+ status: dto.status
35943
+ };
35944
+ if (dto.notes != null) out.notes = dto.notes;
35945
+ return out;
35946
+ }
35461
35947
  return {
35462
35948
  existingSortsCount: dto.existing_sorts_count,
35463
35949
  generationTimeMs: dto.generation_time_ms,
@@ -35519,18 +36005,28 @@ function PipelineStatusResponseFromApiToFront(dto) {
35519
36005
  };
35520
36006
  }
35521
36007
  function CompetencyQuestionFromApiToFront(dto) {
35522
- return {
36008
+ const out = {
35523
36009
  key: dto.key,
35524
36010
  question: dto.question,
35525
- osfql: dto.osfql,
35526
36011
  kind: dto.kind,
35527
36012
  origin: dto.origin,
35528
- status: dto.status,
35529
- expected: dto.expected
36013
+ osfql: dto.osfql,
36014
+ expected: dto.expected,
36015
+ status: dto.status
35530
36016
  };
36017
+ if (dto.description != null) out.description = dto.description;
36018
+ if (dto.use_case != null) out.useCase = dto.use_case;
36019
+ if (dto.sorts !== void 0) out.sorts = dto.sorts;
36020
+ return out;
35531
36021
  }
35532
36022
  function CreateCompetencyQuestionRequestFromFrontToApi(model) {
35533
- return { question: model.question, osfql: model.osfql, kind: model.kind };
36023
+ const out = { question: model.question };
36024
+ if (model.kind !== void 0) out.kind = model.kind;
36025
+ if (model.osfql !== void 0) out.osfql = model.osfql;
36026
+ if (model.description !== void 0) out.description = model.description;
36027
+ if (model.useCase !== void 0) out.use_case = model.useCase;
36028
+ if (model.sorts !== void 0) out.sorts = model.sorts;
36029
+ return out;
35534
36030
  }
35535
36031
  function ListCompetencyQuestionsResponseFromApiToFront(dto) {
35536
36032
  return {
@@ -35644,6 +36140,44 @@ function EnrichOntologyResponseFromApiToFront(dto) {
35644
36140
  applied: dto.applied
35645
36141
  };
35646
36142
  }
36143
+ function OntologyScopeFromFrontToApi(model) {
36144
+ const out = {
36145
+ purpose: model.purpose,
36146
+ dynamics: model.dynamics,
36147
+ write_mode: model.writeMode
36148
+ };
36149
+ if (model.inScope !== void 0) out.in_scope = model.inScope;
36150
+ if (model.outOfScope !== void 0) out.out_of_scope = model.outOfScope;
36151
+ if (model.deferred !== void 0) out.deferred = model.deferred;
36152
+ if (model.notes !== void 0) out.notes = model.notes;
36153
+ return out;
36154
+ }
36155
+ function OntologyScopeResponseFromApiToFront(dto) {
36156
+ const out = {
36157
+ purpose: dto.purpose,
36158
+ inScope: dto.in_scope ?? [],
36159
+ outOfScope: dto.out_of_scope ?? [],
36160
+ deferred: dto.deferred ?? [],
36161
+ dynamics: dto.dynamics,
36162
+ writeMode: dto.write_mode,
36163
+ updatedAt: dto.updated_at
36164
+ };
36165
+ if (dto.notes != null) out.notes = dto.notes;
36166
+ if (dto.updated_by != null) out.updatedBy = dto.updated_by;
36167
+ return out;
36168
+ }
36169
+ function CurrentFluentResponseFromApiToFront(dto) {
36170
+ const out = {
36171
+ sort: dto.sort,
36172
+ of: dto.of,
36173
+ at: dto.at,
36174
+ termId: dto.term_id,
36175
+ value: dto.value,
36176
+ validFrom: dto.valid_from
36177
+ };
36178
+ if (dto.generated_by != null) out.generatedBy = dto.generated_by;
36179
+ return out;
36180
+ }
35647
36181
 
35648
36182
  // src/resources/ontology.ts
35649
36183
  var OntologyClient = class {
@@ -35665,6 +36199,13 @@ var OntologyClient = class {
35665
36199
  * If the response status is `"needs_clarification"`, supply `sessionId`
35666
36200
  * and `answers` on the next call to complete the generation.
35667
36201
  *
36202
+ * Staged builder: with `stage` (and the current `draft`), the response is
36203
+ * `{ status: 'patch', stage, patch, notes? }` — that stage's scenario keys
36204
+ * alone, to merge into the draft.
36205
+ *
36206
+ * The body is sent verbatim (no key re-casing): `draft` is scenario JSON
36207
+ * whose nested keys include the user's own feature names.
36208
+ *
35668
36209
  * @example
35669
36210
  * ```typescript
35670
36211
  * // First call -- may need clarification
@@ -35680,12 +36221,20 @@ var OntologyClient = class {
35680
36221
  * answers: { priority_levels: '3' },
35681
36222
  * });
35682
36223
  * }
36224
+ *
36225
+ * // Staged: one stage's patch over the current draft
36226
+ * const step = await client.ontology.generate({
36227
+ * prompt: 'Build a customer support ticket system',
36228
+ * stage: 'sorts',
36229
+ * draft,
36230
+ * });
36231
+ * if (step.status === 'patch') Object.assign(draft, step.patch);
35683
36232
  * ```
35684
36233
  */
35685
36234
  async generate(request, requestOptions) {
35686
36235
  const response = await this.api.generate(
35687
36236
  GenerateOntologyRequestFromFrontToApi(request),
35688
- toRequestParams(requestOptions)
36237
+ mergeRequestParams({ headers: { [RAW_BODY_HEADER]: "1" } }, requestOptions)
35689
36238
  );
35690
36239
  return GenerateOntologyResponseFromApiToFront(response.data);
35691
36240
  }
@@ -35885,6 +36434,118 @@ var OntologyClient = class {
35885
36434
  );
35886
36435
  return EnrichOntologyResponseFromApiToFront(response.data);
35887
36436
  }
36437
+ /**
36438
+ * Read the ontology's scope.
36439
+ *
36440
+ * @returns The stored scope, or `null` when none has been set.
36441
+ * @throws {ApiError} If the request fails for a reason other than "no scope".
36442
+ *
36443
+ * @remarks
36444
+ * One scope per tenant, or per namespace when `X-Namespace-Id` is sent. The
36445
+ * engine answers 404 when none was set; that is an expected state for a new
36446
+ * ontology, so it reads as `null` rather than an error.
36447
+ *
36448
+ * @example
36449
+ * ```typescript
36450
+ * const scope = await client.ontology.getScope();
36451
+ * if (scope === null) {
36452
+ * // first visit: ask the user what the ontology is for
36453
+ * }
36454
+ * ```
36455
+ */
36456
+ async getScope(requestOptions) {
36457
+ try {
36458
+ const response = await this.api.getOntologyScope(toRequestParams(requestOptions));
36459
+ return OntologyScopeResponseFromApiToFront(response.data);
36460
+ } catch (error) {
36461
+ if (error instanceof ApiError && error.status === 404) {
36462
+ return null;
36463
+ }
36464
+ throw error;
36465
+ }
36466
+ }
36467
+ /**
36468
+ * Set the ontology's scope, replacing the stored one.
36469
+ *
36470
+ * @param scope - Purpose, coverage, dynamics and write mode.
36471
+ * @returns The stored scope with its provenance.
36472
+ * @throws {BadRequestError} If `purpose` is empty.
36473
+ *
36474
+ * @example
36475
+ * ```typescript
36476
+ * await client.ontology.putScope({
36477
+ * purpose: 'Answer questions about late deliveries',
36478
+ * inScope: ['orders', 'shipments'],
36479
+ * dynamics: 'dynamic',
36480
+ * writeMode: 'append',
36481
+ * });
36482
+ * ```
36483
+ */
36484
+ async putScope(scope, requestOptions) {
36485
+ const response = await this.api.putOntologyScope(
36486
+ OntologyScopeFromFrontToApi(scope),
36487
+ toRequestParams(requestOptions)
36488
+ );
36489
+ return OntologyScopeResponseFromApiToFront(response.data);
36490
+ }
36491
+ /**
36492
+ * Fetch an embedded upper-ontology seed as OWL RDF/XML.
36493
+ *
36494
+ * @param name - `bfo-2020` or `cco-facility`.
36495
+ * @returns The OWL document, as text.
36496
+ * @throws {NotFoundError} If the name is not an embedded upper ontology.
36497
+ *
36498
+ * @remarks
36499
+ * The same OWL the lattice-grounding aligner uses, offered as an anchor to
36500
+ * reuse rather than reinvent. The response is `application/rdf+xml`, not JSON.
36501
+ *
36502
+ * @example
36503
+ * ```typescript
36504
+ * const owl = await client.ontology.getUpperOntology('bfo-2020');
36505
+ * ```
36506
+ */
36507
+ async getUpperOntology(name, requestOptions) {
36508
+ const response = await this.api.http.request({
36509
+ ...toRequestParams(requestOptions),
36510
+ path: `/api/v1/ontology/upper/${encodeURIComponent(name)}`,
36511
+ method: "GET",
36512
+ format: "text"
36513
+ });
36514
+ return response.data;
36515
+ }
36516
+ /**
36517
+ * Read the state a fluent holds for an entity at an instant.
36518
+ *
36519
+ * @param query - The fluent sort, the entity's term id, and the instant (default now).
36520
+ * @returns The latest fluent term with `validFrom <= at`.
36521
+ * @throws {NotFoundError} If the fluent sort is unknown, or no state was recorded by `at`.
36522
+ * @throws {BadRequestError} If `at` is not RFC 3339.
36523
+ *
36524
+ * @remarks
36525
+ * The engine answers the same 404 for an unknown fluent sort and for an
36526
+ * entity with no state yet, so this throws rather than returning `null`:
36527
+ * the two cannot be told apart.
36528
+ *
36529
+ * @example
36530
+ * ```typescript
36531
+ * const status = await client.ontology.getCurrentFluent({
36532
+ * sort: 'order_status',
36533
+ * of: orderId,
36534
+ * });
36535
+ * console.log(status.value, status.validFrom);
36536
+ * ```
36537
+ */
36538
+ async getCurrentFluent(query, requestOptions) {
36539
+ const response = await this.api.currentFluentValue(
36540
+ {
36541
+ sort: query.sort,
36542
+ of: query.of,
36543
+ ...query.at !== void 0 ? { at: query.at } : {}
36544
+ },
36545
+ toRequestParams(requestOptions)
36546
+ );
36547
+ return CurrentFluentResponseFromApiToFront(response.data);
36548
+ }
35888
36549
  };
35889
36550
 
35890
36551
  // src/normalizers/generation.ts
@@ -38104,6 +38765,7 @@ function UIActionResponseFromApiToFront(dto) {
38104
38765
  error: dto.error ?? void 0,
38105
38766
  pendingReviewId: dto.pending_review_id ?? void 0,
38106
38767
  producedTermIds: dto.produced_term_ids,
38768
+ ...dto.retracted_term_ids !== void 0 ? { retractedTermIds: dto.retracted_term_ids } : {},
38107
38769
  requiresApproval: dto.requires_approval,
38108
38770
  requiresConfirmation: dto.requires_confirmation,
38109
38771
  retractedTermIds: dto.retracted_term_ids,
@@ -38481,15 +39143,20 @@ function TurnDtoFromApiToFront(dto) {
38481
39143
  claimAnnotations: dto.claim_annotations?.map(ClaimAnnotationDtoFromApiToFront),
38482
39144
  // Rows go through the same narrowing as the message response, so a reloaded
38483
39145
  // turn keeps its table with the same value types a live turn has.
38484
- queryResults: dto.query_results?.map(osfqlRowFromApiToFront) ?? void 0
39146
+ queryResults: dto.query_results?.map(osfqlRowFromApiToFront) ?? void 0,
39147
+ ...dto.payload !== void 0 && dto.payload !== null ? { payload: dto.payload } : {}
38485
39148
  };
38486
39149
  }
38487
39150
  function RecordTurnRequestFromFrontToApi(model) {
38488
- return {
39151
+ const out = {
38489
39152
  role: model.role,
38490
39153
  content: model.content,
38491
39154
  osfql: model.osfql
38492
39155
  };
39156
+ if (model.payload !== void 0) out.payload = model.payload;
39157
+ if (model.conversationKind !== void 0) out.conversation_kind = model.conversationKind;
39158
+ if (model.title !== void 0) out.title = model.title;
39159
+ return out;
38493
39160
  }
38494
39161
  function RecordTurnResponseFromApiToFront(dto) {
38495
39162
  return {
@@ -38502,7 +39169,9 @@ function ConversationSummaryDtoFromApiToFront(dto) {
38502
39169
  id: dto.id,
38503
39170
  sessionId: dto.session_id ?? void 0,
38504
39171
  createdAt: dto.created_at,
38505
- turnCount: dto.turn_count
39172
+ turnCount: dto.turn_count,
39173
+ ...dto.kind != null ? { kind: dto.kind } : {},
39174
+ ...dto.title != null ? { title: dto.title } : {}
38506
39175
  };
38507
39176
  }
38508
39177
  function ListConversationsResponseFromApiToFront(dto) {
@@ -38788,6 +39457,11 @@ var ConversationClient = class {
38788
39457
  * Request and response bodies use plain JSON scalars; no tagged/untagged value
38789
39458
  * serialization is involved. Turns recorded here are returned by {@link getTurns}.
38790
39459
  *
39460
+ * `payload` is opaque structured card state (drafts, questions, findings…),
39461
+ * stored verbatim and returned on the turn — so the body is sent without key
39462
+ * re-casing. `conversationKind` and `title` apply when the conversation is
39463
+ * created (`title` also later, while it has none); a surface uses
39464
+ * `conversationKind` to partition the shared history list.
38791
39465
  * The engine also offers each turn to the tenant's long-term memory. A turn the
38792
39466
  * memory policy refuses (for example text over 500 characters) is still
38793
39467
  * recorded and still answers `200`; it only does not enter memory.
@@ -38806,11 +39480,21 @@ var ConversationClient = class {
38806
39480
  * content: 'Done — split it into `auth/session.rs` and `auth/token.rs`.',
38807
39481
  * osfql: 'MATCH module(name: ?N);',
38808
39482
  * });
39483
+ *
39484
+ * // A surface with richer turns: its own history partition and card state.
39485
+ * await client.conversation.recordTurn('new', {
39486
+ * role: 'assistant',
39487
+ * content: 'Here is a draft scope.',
39488
+ * conversationKind: 'guided_ontology',
39489
+ * title: 'Pizza ontology',
39490
+ * payload: { card: 'scope_draft', draft: { purpose: 'Take pizza orders' } },
39491
+ * });
38809
39492
  * ```
38810
39493
  */
38811
39494
  async recordTurn(conversationId, request, requestOptions) {
38812
39495
  const response = await this.http.request({
38813
39496
  ...toRequestParams(requestOptions),
39497
+ headers: mergeRequestHeaders({ [RAW_BODY_HEADER]: "1" }, requestOptions),
38814
39498
  path: `/api/v1/conversation/${encodeURIComponent(conversationId)}/turns`,
38815
39499
  method: "POST",
38816
39500
  body: RecordTurnRequestFromFrontToApi(request),
@@ -47366,6 +48050,96 @@ var OntologyExportClient = class {
47366
48050
  }
47367
48051
  };
47368
48052
 
48053
+ // src/normalizers/argumentation.ts
48054
+ function ArgumentationEvaluateRequestFromFrontToApi(model) {
48055
+ const out = {
48056
+ claims: model.claims.map((c) => ({
48057
+ term_id: c.termId,
48058
+ ...c.id !== void 0 ? { id: c.id } : {}
48059
+ }))
48060
+ };
48061
+ if (model.preferences !== void 0) {
48062
+ out.preferences = model.preferences.map((p) => ({ preferred: p.preferred, over: p.over }));
48063
+ }
48064
+ if (model.retracted !== void 0) out.retracted = model.retracted;
48065
+ if (model.enableDerivation !== void 0) out.enable_derivation = model.enableDerivation;
48066
+ if (model.useTenantRules !== void 0) out.use_tenant_rules = model.useTenantRules;
48067
+ if (model.rulesOsfql !== void 0) out.rules_osfql = model.rulesOsfql;
48068
+ if (model.matchThreshold !== void 0) out.match_threshold = model.matchThreshold;
48069
+ return out;
48070
+ }
48071
+ function ArgumentationEvaluateResponseFromApiToFront(dto) {
48072
+ return {
48073
+ arguments: dto.arguments.map((a) => ({
48074
+ id: a.id,
48075
+ index: a.index,
48076
+ termId: a.term_id,
48077
+ text: a.text,
48078
+ label: a.label
48079
+ })),
48080
+ attacks: dto.attacks.map((a) => ({
48081
+ from: a.from,
48082
+ to: a.to,
48083
+ kind: a.kind,
48084
+ reason: a.reason,
48085
+ proved: a.proved
48086
+ })),
48087
+ grounded: {
48088
+ accepted: dto.grounded.accepted,
48089
+ rejected: dto.grounded.rejected,
48090
+ undecided: dto.grounded.undecided
48091
+ },
48092
+ questions: dto.questions.map((q) => ({ a: q.a, b: q.b, prompt: q.prompt })),
48093
+ warnings: dto.warnings ?? []
48094
+ };
48095
+ }
48096
+
48097
+ // src/resources/argumentation.ts
48098
+ var ArgumentationClient = class {
48099
+ /** @internal */
48100
+ api;
48101
+ /** @internal */
48102
+ constructor(api) {
48103
+ this.api = api;
48104
+ }
48105
+ /**
48106
+ * Evaluate a set of claims: label each argument and surface the conflicts
48107
+ * only the user can resolve.
48108
+ *
48109
+ * @param request - The claims, and the resolutions and retractions so far.
48110
+ * @returns Labelled arguments, evidence-carrying attacks, the grounded
48111
+ * extension, and one question per unresolved conflict.
48112
+ * @throws {BadRequestError} 400 when there are no claims, or a term or
48113
+ * preference id is unknown.
48114
+ * @throws {ApiError} 422 when `rulesOsfql` fails to parse, compile, or execute.
48115
+ *
48116
+ * @remarks
48117
+ * Multi-turn: answer a question by adding a {@link ArgumentPreference} and
48118
+ * evaluate again with the same argument ids; each preference deletes one
48119
+ * attack. Plain JSON on the wire — no tagged/untagged value split applies.
48120
+ *
48121
+ * @example
48122
+ * ```typescript
48123
+ * const turn = await client.argumentation.evaluate({
48124
+ * claims: [{ termId: a, id: 'a' }, { termId: b, id: 'b' }],
48125
+ * });
48126
+ * for (const q of turn.questions) console.log(q.prompt);
48127
+ *
48128
+ * const settled = await client.argumentation.evaluate({
48129
+ * claims: [{ termId: a, id: 'a' }, { termId: b, id: 'b' }],
48130
+ * preferences: [{ preferred: 'a', over: 'b' }],
48131
+ * });
48132
+ * ```
48133
+ */
48134
+ async evaluate(request, requestOptions) {
48135
+ const response = await this.api.evaluateArgumentation(
48136
+ ArgumentationEvaluateRequestFromFrontToApi(request),
48137
+ toRequestParams(requestOptions)
48138
+ );
48139
+ return ArgumentationEvaluateResponseFromApiToFront(response.data);
48140
+ }
48141
+ };
48142
+
47369
48143
  // src/normalizers/demo.ts
47370
48144
  function DemoSeedRequestFromFrontToApi(model) {
47371
48145
  const dto = {};
@@ -50397,6 +51171,8 @@ var ReasoningLayerClient = class {
50397
51171
  agui;
50398
51172
  /** Ontology export — OWL ontology and SHACL shapes projected from the sort lattice. */
50399
51173
  ontologyExport;
51174
+ /** Grounded argumentation — label conflicting claims and surface the questions only the user can settle. */
51175
+ argumentation;
50400
51176
  /** Demo substrate seeding — full SUMO + demo scenarios into the tenant substrate. */
50401
51177
  demo;
50402
51178
  /** Execution-free reward scoring for candidate queries (recall / precision). */
@@ -50538,7 +51314,8 @@ var ReasoningLayerClient = class {
50538
51314
  forecast: this.forecast,
50539
51315
  corpus: this.corpus,
50540
51316
  osfDiff: this.osfDiff,
50541
- conformance: this.conformance
51317
+ conformance: this.conformance,
51318
+ argumentation: this.argumentation
50542
51319
  };
50543
51320
  }
50544
51321
  /** Data ingestion and extraction operations — documents, sources, collections, images. */
@@ -50671,6 +51448,7 @@ var ReasoningLayerClient = class {
50671
51448
  const generatedGuardrail = encodePathParams(new Guardrail(generatedHttp));
50672
51449
  const generatedAgui = encodePathParams(new Agui(generatedHttp));
50673
51450
  const generatedOntologyExport = encodePathParams(new OntologyExport(generatedHttp));
51451
+ const generatedArgumentation = encodePathParams(new Argumentation(generatedHttp));
50674
51452
  this.sorts = new SortsClient(generatedSorts, generatedTypes, resolved.tenantId);
50675
51453
  this.terms = new TermsClient(generatedTerms);
50676
51454
  this.inference = new InferenceClient(generatedInference, resolved.tenantId);
@@ -50802,6 +51580,7 @@ var ReasoningLayerClient = class {
50802
51580
  this.guardrail = new GuardrailClient(generatedGuardrail);
50803
51581
  this.agui = new AguiClient(generatedAgui);
50804
51582
  this.ontologyExport = new OntologyExportClient(generatedOntologyExport);
51583
+ this.argumentation = new ArgumentationClient(generatedArgumentation);
50805
51584
  this.demo = new DemoClient(encodePathParams(new Demo(generatedHttp)));
50806
51585
  this.reward = new RewardClient(encodePathParams(new Reward(generatedHttp)));
50807
51586
  this.translation = new TranslationClient(
@@ -51133,6 +51912,9 @@ var speech_exports = {};
51133
51912
  // src/types/connectors.ts
51134
51913
  var connectors_exports = {};
51135
51914
 
51915
+ // src/types/argumentation.ts
51916
+ var argumentation_exports = {};
51917
+
51136
51918
  // src/types/cron.ts
51137
51919
  var cron_exports = {};
51138
51920
 
@@ -52743,6 +53525,7 @@ exports.Agui = agui_exports;
52743
53525
  exports.Analysis = analysis_exports;
52744
53526
  exports.Anonymization = anonymization_exports;
52745
53527
  exports.ApiError = ApiError;
53528
+ exports.Argumentation = argumentation_exports;
52746
53529
  exports.Audit = audit_exports;
52747
53530
  exports.AuthenticationError = AuthenticationError;
52748
53531
  exports.Authz = authz_exports;
@@ -52808,6 +53591,7 @@ exports.LTN = ltn_exports;
52808
53591
  exports.Marketplace = marketplace_exports;
52809
53592
  exports.Memory = memory_exports;
52810
53593
  exports.Metrics = metrics_exports;
53594
+ exports.NamedConstraintViolationError = NamedConstraintViolationError;
52811
53595
  exports.Namespaces = namespaces_exports;
52812
53596
  exports.NetworkError = NetworkError;
52813
53597
  exports.NeuroSymbolic = neuro_symbolic_exports;