@kortexya/reasoninglayer 3.1.0 → 3.2.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 +86 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +285 -27
- package/dist/index.d.ts +285 -27
- package/dist/index.js +86 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
10
|
+
var SDK_VERSION = "3.2.0";
|
|
11
11
|
function resolveConfig(config) {
|
|
12
12
|
if (!config.baseUrl) {
|
|
13
13
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -1310,7 +1310,7 @@ var Sorts = class {
|
|
|
1310
1310
|
...params
|
|
1311
1311
|
});
|
|
1312
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
|
|
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. Separation of duties is enforced here, by the engine that holds the proposal record: the acting user (`X-Authenticated-User`) who is the sort's recorded proposer (`SortStatus::Proposed { submitted_by }`) is refused with a coded 403 (`code: "separation_of_duties"`) naming the sort, and the refusal is recorded in the oversight ledger as a `rejected` decision on the action `sort.approve.refused` (#398). The gateway checks the steward permission at the project, where the roles live.
|
|
1314
1314
|
*
|
|
1315
1315
|
* @tags sorts
|
|
1316
1316
|
* @name ApproveSort
|
|
@@ -1463,7 +1463,7 @@ var Sorts = class {
|
|
|
1463
1463
|
...params
|
|
1464
1464
|
});
|
|
1465
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.
|
|
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: `POST /api/v1/scenarios/materialize` with the mixin and each member naming it as a parent does both, the moves going through the governed door of `POST /api/v1/sorts/{id}/parents`. A declaration a sort restates identically to an ancestor's is factored already and is never proposed again.
|
|
1467
1467
|
*
|
|
1468
1468
|
* @tags sorts
|
|
1469
1469
|
* @name FactorSortShapes
|
|
@@ -8844,7 +8844,7 @@ var Scenarios = class {
|
|
|
8844
8844
|
...params
|
|
8845
8845
|
});
|
|
8846
8846
|
/**
|
|
8847
|
-
* @description Materializes an already-generated GeneratedScenario verbatim (no LLM call): sorts, belief instances, rules, goal, and the ontology-declared engine pipeline. Used by the studio's build wizard to persist exactly what was reviewed so it is immediately queryable in chat.
|
|
8847
|
+
* @description Materializes an already-generated GeneratedScenario verbatim (no LLM call): sorts, belief instances, rules, goal, and the ontology-declared engine pipeline. Used by the studio's build wizard to persist exactly what was reviewed so it is immediately queryable in chat. An existing sort is reused and moved under any parent the scenario newly names for it, through the governed move of POST /sorts/{id}/parents; a refused move is reported in `warnings` and leaves the sort where it was.
|
|
8848
8848
|
*
|
|
8849
8849
|
* @tags scenarios
|
|
8850
8850
|
* @name MaterializeScenario
|
|
@@ -9449,7 +9449,7 @@ var Synthetic = class {
|
|
|
9449
9449
|
...params
|
|
9450
9450
|
});
|
|
9451
9451
|
/**
|
|
9452
|
-
* @description Uses principled strategies to create training examples that are negative (invalid) for specific, documented reasons: sort incompatibility, feature perturbation, cross-sort confusion, missing required features, and feature type mismatch. # Authorization Requires X-Tenant-Id header for tenant-scoped operations.
|
|
9452
|
+
* @description Uses principled strategies to create training examples that are negative (invalid) for specific, documented reasons: a violation of each declared feature constraint (named in `violated_constraint`), sort incompatibility, feature perturbation, cross-sort confusion, missing required features, and feature type mismatch. Proposed sorts are included — negatives exist to test a model before it is approved; deprecated sorts are not. # Authorization Requires X-Tenant-Id header for tenant-scoped operations.
|
|
9453
9453
|
*
|
|
9454
9454
|
* @tags synthetic
|
|
9455
9455
|
* @name GenerateNegatives
|
|
@@ -16234,8 +16234,10 @@ var SortsClient = class {
|
|
|
16234
16234
|
* @returns The approved sort, and how much suspended work its declaration
|
|
16235
16235
|
* released (`wokenResiduations`).
|
|
16236
16236
|
* @throws {ForbiddenError} 403 when the caller holds no Manage grant on the
|
|
16237
|
-
* sort —
|
|
16238
|
-
*
|
|
16237
|
+
* sort, or — with `code: "separation_of_duties"` in the body (see
|
|
16238
|
+
* `SortApprovalErrorCode`; read it with `errorBodyCode`) — when the
|
|
16239
|
+
* acting user (`authenticatedUser`) is the sort's recorded proposer.
|
|
16240
|
+
* Another steward can approve it.
|
|
16239
16241
|
* @throws {NotFoundError} 404 when the sort does not exist.
|
|
16240
16242
|
* @throws {ApiError} 409 when the sort is not awaiting approval.
|
|
16241
16243
|
*
|
|
@@ -16244,11 +16246,21 @@ var SortsClient = class {
|
|
|
16244
16246
|
* authenticated user as reviewer. This replaced `approveProposed` on
|
|
16245
16247
|
* {@link SortsClient.patchSort}, which the engine now refuses.
|
|
16246
16248
|
*
|
|
16249
|
+
* Separation of duties is enforced by the engine: the proposer's own
|
|
16250
|
+
* approval is refused with the coded 403 and recorded in the oversight
|
|
16251
|
+
* ledger as a `rejected` decision on `sort.approve.refused`.
|
|
16252
|
+
*
|
|
16247
16253
|
* @example
|
|
16248
16254
|
* ```typescript
|
|
16249
|
-
*
|
|
16250
|
-
*
|
|
16251
|
-
*
|
|
16255
|
+
* try {
|
|
16256
|
+
* const { sort, wokenResiduations } = await client.sorts.approveSort(sortId, {
|
|
16257
|
+
* reason: 'Matches the order lifecycle use case',
|
|
16258
|
+
* });
|
|
16259
|
+
* } catch (error) {
|
|
16260
|
+
* if (errorBodyCode(error) === 'separation_of_duties') {
|
|
16261
|
+
* // The acting user proposed this sort: ask another steward to approve it.
|
|
16262
|
+
* }
|
|
16263
|
+
* }
|
|
16252
16264
|
* ```
|
|
16253
16265
|
*/
|
|
16254
16266
|
async approveSort(sortId, request = {}, requestOptions) {
|
|
@@ -18886,7 +18898,8 @@ function RuleTermDraftDtoFromApiToFront(dto) {
|
|
|
18886
18898
|
// The engine types each value as a scalar (`RuleDraftFeatureValueDto`) and
|
|
18887
18899
|
// refuses a draft carrying anything else, so the map passes through; only
|
|
18888
18900
|
// the generated `Partial` is narrowed to a total record.
|
|
18889
|
-
features: definedRecordOrNullish(dto.features)
|
|
18901
|
+
features: definedRecordOrNullish(dto.features),
|
|
18902
|
+
...dto.negated === true ? { negated: true } : {}
|
|
18890
18903
|
};
|
|
18891
18904
|
}
|
|
18892
18905
|
function RuleDraftDtoFromApiToFront(dto) {
|
|
@@ -18961,9 +18974,16 @@ var InferenceClient = class {
|
|
|
18961
18974
|
* engine-side head aggregator (see {@link RuleAggregatorDto}).
|
|
18962
18975
|
* @returns The created rule wrapped in an AddRuleResponse.
|
|
18963
18976
|
* @throws {ApiError} If the rule is rejected or the request fails — 422 when
|
|
18964
|
-
* it is unusable as written
|
|
18965
|
-
*
|
|
18966
|
-
*
|
|
18977
|
+
* it is unusable as written: a head or body antecedent naming a sort or
|
|
18978
|
+
* term that does not exist (the message names it and its position — `the
|
|
18979
|
+
* head (conclusion)` or `body antecedent N`), a guard bound the declared
|
|
18980
|
+
* type cannot compare, a binder on the conclusion, or a rule that closes a
|
|
18981
|
+
* NEW cycle through negation (no stratification would order the program; a
|
|
18982
|
+
* cycle the program already had is not blamed on it). The refusal is a
|
|
18983
|
+
* plain {@link ApiError} with `status` 422 — not a `BadRequestError`
|
|
18984
|
+
* (earlier engines answered an unknown head sort with 400), and not a
|
|
18985
|
+
* `NamedConstraintViolationError`, which is reserved for a feature
|
|
18986
|
+
* constraint's refusal.
|
|
18967
18987
|
*
|
|
18968
18988
|
* @remarks
|
|
18969
18989
|
* **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
|
|
@@ -19613,7 +19633,10 @@ var InferenceClient = class {
|
|
|
19613
19633
|
* `{"type": "String", "value": "..."}` envelope. The engine refuses a model answer that
|
|
19614
19634
|
* carries one, re-prompts, and answers 422 when the model keeps producing it. Each
|
|
19615
19635
|
* {@link RuleTermDraftDto} maps directly onto a `TermInputDto` inline-by-sort-name
|
|
19616
|
-
* term, so an approved draft can be handed straight to {@link addRule}
|
|
19636
|
+
* term, so an approved draft can be handed straight to {@link addRule} — except an
|
|
19637
|
+
* antecedent with `negated: true`, which must be wrapped in the `negation` carrier
|
|
19638
|
+
* (`not(psi(sortName, features))`); sent bare, it would assert the positive
|
|
19639
|
+
* condition.
|
|
19617
19640
|
*
|
|
19618
19641
|
* Drafting is multi-turn: if `status` is `'needs_clarification'`, answer each question
|
|
19619
19642
|
* and call again with the echoed `sessionId` and an `answers` map keyed by the question's
|
|
@@ -19856,6 +19879,7 @@ function NlQueryRequestFromFrontToApi(model) {
|
|
|
19856
19879
|
mode: model.mode,
|
|
19857
19880
|
tenant_id: model.tenantId,
|
|
19858
19881
|
conversation_history: model.conversationHistory ?? void 0,
|
|
19882
|
+
focus_sorts: model.focusSorts ?? void 0,
|
|
19859
19883
|
session_id: model.sessionId ?? void 0,
|
|
19860
19884
|
exclude_domains: model.excludeDomains ?? void 0,
|
|
19861
19885
|
focus_proposal: model.focusProposal ?? void 0,
|
|
@@ -20161,6 +20185,10 @@ var QueryClient = class {
|
|
|
20161
20185
|
* @remarks
|
|
20162
20186
|
* Plain JSON, no tagged/untagged value serialization.
|
|
20163
20187
|
*
|
|
20188
|
+
* In llm mode, `focusSorts` names the sorts the question is about: each is
|
|
20189
|
+
* always in the schema the translator sees, even a sort built a moment ago
|
|
20190
|
+
* with no records, which the record-count ranking would otherwise cut.
|
|
20191
|
+
*
|
|
20164
20192
|
* TRIZ mode (`mode: "triz"`) is multi-turn:
|
|
20165
20193
|
* 1. A request with no `sessionId` opens a session, structures the problem
|
|
20166
20194
|
* (reading any `images` first) and solves it. The response names the
|
|
@@ -31378,6 +31406,14 @@ var ScenariosClient = class {
|
|
|
31378
31406
|
* scenario's use cases and competency questions are recorded as `proposed`
|
|
31379
31407
|
* competency questions.
|
|
31380
31408
|
*
|
|
31409
|
+
* A sort (or fluent) may carry `provenance` — see {@link ScenarioSortProvenance} —
|
|
31410
|
+
* recorded as its origin; without it the sort is credited to the caller.
|
|
31411
|
+
*
|
|
31412
|
+
* An existing sort is reused, and moved under any parent the scenario newly names
|
|
31413
|
+
* for it through the same governed move as `SortsClient.editSortParents`. A move the
|
|
31414
|
+
* engine refuses leaves the sort where it was and is reported in `warnings`, not
|
|
31415
|
+
* as an error — read `warnings` after every call.
|
|
31416
|
+
*
|
|
31381
31417
|
* @example
|
|
31382
31418
|
* ```typescript
|
|
31383
31419
|
* const result = await client.scenarios.materializeScenario({ scenario: generated });
|
|
@@ -34386,6 +34422,14 @@ function CheckDiversityResponseFromApiToFront(dto) {
|
|
|
34386
34422
|
termsCompared: dto.terms_compared
|
|
34387
34423
|
};
|
|
34388
34424
|
}
|
|
34425
|
+
function ViolatedConstraintDtoFromApiToFront(dto) {
|
|
34426
|
+
return {
|
|
34427
|
+
feature: dto.feature,
|
|
34428
|
+
kind: dto.kind,
|
|
34429
|
+
...dto.constraint_name != null ? { constraintName: dto.constraint_name } : {},
|
|
34430
|
+
...dto.constraint_message != null ? { constraintMessage: dto.constraint_message } : {}
|
|
34431
|
+
};
|
|
34432
|
+
}
|
|
34389
34433
|
function NegativeExampleDtoFromApiToFront(dto) {
|
|
34390
34434
|
return {
|
|
34391
34435
|
explanation: dto.explanation,
|
|
@@ -34395,11 +34439,13 @@ function NegativeExampleDtoFromApiToFront(dto) {
|
|
|
34395
34439
|
termId: dto.term_id,
|
|
34396
34440
|
...dto.sort != null ? { sort: dto.sort } : {},
|
|
34397
34441
|
...dto.features != null ? { features: Object.fromEntries(Object.entries(dto.features)) } : {},
|
|
34398
|
-
...dto.world_mode != null ? { worldMode: dto.world_mode } : {}
|
|
34442
|
+
...dto.world_mode != null ? { worldMode: dto.world_mode } : {},
|
|
34443
|
+
...dto.violated_constraint != null ? { violatedConstraint: ViolatedConstraintDtoFromApiToFront(dto.violated_constraint) } : {}
|
|
34399
34444
|
};
|
|
34400
34445
|
}
|
|
34401
34446
|
function GenerateNegativesRequestFromFrontToApi(model) {
|
|
34402
34447
|
return {
|
|
34448
|
+
enable_constraint_violation: model.enableConstraintViolation,
|
|
34403
34449
|
enable_cross_sort_confusion: model.enableCrossSortConfusion,
|
|
34404
34450
|
enable_feature_perturbation: model.enableFeaturePerturbation,
|
|
34405
34451
|
enable_sort_incompatibility: model.enableSortIncompatibility,
|
|
@@ -34676,6 +34722,30 @@ var SyntheticClient = class {
|
|
|
34676
34722
|
* @param request - Negative generation parameters including target sorts and strategy flags.
|
|
34677
34723
|
* @returns Generated negative examples with provenance.
|
|
34678
34724
|
* @throws {ApiError} If the request fails.
|
|
34725
|
+
*
|
|
34726
|
+
* @remarks
|
|
34727
|
+
* Each negative is invalid for a documented reason, named by its
|
|
34728
|
+
* `strategy`: a violation of each declared feature constraint
|
|
34729
|
+
* (`ConstraintViolation`, one negative per enum / range / pattern /
|
|
34730
|
+
* maximum-cardinality constraint, with the constraint in
|
|
34731
|
+
* `violatedConstraint`), sort incompatibility, feature perturbation,
|
|
34732
|
+
* cross-sort confusion, a missing required feature, or a feature type
|
|
34733
|
+
* mismatch. Set `enableConstraintViolation: false` to skip the first.
|
|
34734
|
+
*
|
|
34735
|
+
* Proposed sorts are included — negatives exist to test a model before it
|
|
34736
|
+
* is approved; deprecated sorts are not.
|
|
34737
|
+
*
|
|
34738
|
+
* @example
|
|
34739
|
+
* ```typescript
|
|
34740
|
+
* const { negatives } = await client.synthetic.generateNegatives({
|
|
34741
|
+
* targetSorts: [pizzaSortId],
|
|
34742
|
+
* });
|
|
34743
|
+
* for (const n of negatives) {
|
|
34744
|
+
* if (n.violatedConstraint) {
|
|
34745
|
+
* console.log(n.violatedConstraint.feature, n.violatedConstraint.constraintMessage);
|
|
34746
|
+
* }
|
|
34747
|
+
* }
|
|
34748
|
+
* ```
|
|
34679
34749
|
*/
|
|
34680
34750
|
async generateNegatives(request, requestOptions) {
|
|
34681
34751
|
const response = await this.api.generateNegatives(
|