@kortexya/reasoninglayer 4.0.0 → 4.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/README.md +1 -1
- package/dist/index.cjs +47 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -41
- package/dist/index.d.ts +117 -41
- package/dist/index.js +47 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -231,7 +231,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
|
|
|
231
231
|
* This is the single source of truth for the version constant.
|
|
232
232
|
* The `scripts/release.sh` script updates this value alongside `package.json`.
|
|
233
233
|
*/
|
|
234
|
-
declare const SDK_VERSION = "4.
|
|
234
|
+
declare const SDK_VERSION = "4.1.0";
|
|
235
235
|
/**
|
|
236
236
|
* Authentication mode for the SDK.
|
|
237
237
|
*
|
|
@@ -22103,16 +22103,24 @@ interface MaterializeScenarioRequest$1 {
|
|
|
22103
22103
|
* refused with 409 (#470).
|
|
22104
22104
|
*/
|
|
22105
22105
|
prefixes?: Partial<Record<string, string>>;
|
|
22106
|
-
/** A GeneratedScenario: the `scenario` payload of POST /api/v1/ontology/generate, or a schema-only scenario built from an imported vocabulary.
|
|
22106
|
+
/** A GeneratedScenario: the `scenario` payload of POST /api/v1/ontology/generate, or a schema-only scenario built from an imported vocabulary. No key is required: every collection defaults to empty, so a vocabulary import sends `sorts` alone. `goal` is optional: a scenario without one materializes no agent_goal term. Keys not listed here are ignored. */
|
|
22107
22107
|
scenario: {
|
|
22108
|
-
/**
|
|
22109
|
-
|
|
22108
|
+
/** OWL 2 class axioms, each `{kind, classes?, class?, property?, n?, filler?}`: `disjoint_classes`, `min_cardinality`, `max_cardinality`, `exact_cardinality` or `all_values_from`. Written as the disjointness rule, feature bound or typed feature the engine enforces; an unknown kind is skipped with a warning. Defaults to empty. */
|
|
22109
|
+
axioms?: object[];
|
|
22110
|
+
/** Belief instances (typed facts) to assert. Defaults to empty. */
|
|
22111
|
+
beliefs?: object[];
|
|
22112
|
+
/** Competency questions, each `{question, use_case?, osfql?, sorts?}`, recorded as `proposed` competency questions. Defaults to empty. */
|
|
22113
|
+
competency_questions?: object[];
|
|
22114
|
+
/** Computed features, each `{sort, feature, function, arguments?, depends_on?, description?}`, declared as feature equations. Defaults to empty. */
|
|
22115
|
+
computed_features?: object[];
|
|
22110
22116
|
/** Generic constraints, each `{sort, features}`. Defaults to empty. A feature reads the rule feature encoding: a bare "?X" is a variable, as are {"name": "?X"} and {"_var": "?X"}, and one name is one variable across all of `guardConstraints` and `constraints`; a literal that starts with `?` is {"type": "String", "value": "?x"}. A constraint whose feature does not decode is not written and is named in `warnings`. */
|
|
22111
22117
|
constraints?: object[];
|
|
22112
22118
|
/** Curriculum stages. Defaults to empty. */
|
|
22113
22119
|
curriculum_stages?: object[];
|
|
22114
22120
|
/** Tool registrations. Defaults to empty. */
|
|
22115
22121
|
discovered_tools?: object[];
|
|
22122
|
+
/** Fluents, each `{name, of_sort, value_values?, event_sort, proposed?, provenance?}`: a fluent sort and its event sort, recorded as append-only state terms. Defaults to empty. */
|
|
22123
|
+
fluents?: object[];
|
|
22116
22124
|
/** The agent's goal: `{sort, features?, priority?}`. Optional; omit it for a scenario with no agent. `features` reads the rule feature encoding: a bare "?X" is a variable; a literal that starts with `?` is {"type": "String", "value": "?x"}. A feature that does not decode refuses the scenario. */
|
|
22117
22125
|
goal?: object;
|
|
22118
22126
|
/** Concept groundings. Defaults to empty. */
|
|
@@ -22121,8 +22129,8 @@ interface MaterializeScenarioRequest$1 {
|
|
|
22121
22129
|
guardConstraints?: object[];
|
|
22122
22130
|
/** Engine pipeline stages. Defaults to empty. */
|
|
22123
22131
|
pipelineStages?: object[];
|
|
22124
|
-
/** Inference rules. Each rule is `{head: {sort, features}, antecedents: [{sort, features, negated?, binding?}], certainty?}`, authored through the rule door of POST /api/v1/inference/rules with its feature encoding and its checks. A bare string that starts with `?` ("?X") is a variable shared across the rule, as are {"name": "?X"} and {"_var": "?X"}; a literal that starts with `?` is written {"type": "String", "value": "?x"}. `negated: true` on an antecedent is negation as failure. A rule the door refuses is not written and is named in `warnings`: a conclusion variable that no antecedent binds, no antecedent, a new cycle through negation, or a feature value the door cannot read. A sort a rule names that `sorts` does not declare is created under `thing` before the rules are authored, so an unknown sort is not refused here (only PATCH /api/v1/scenarios/{id} `add_rules`, which is not normalized, refuses one). */
|
|
22125
|
-
rules
|
|
22132
|
+
/** Inference rules. Defaults to empty. Each rule is `{head: {sort, features}, antecedents: [{sort, features, negated?, binding?}], certainty?}`, authored through the rule door of POST /api/v1/inference/rules with its feature encoding and its checks. A bare string that starts with `?` ("?X") is a variable shared across the rule, as are {"name": "?X"} and {"_var": "?X"}; a literal that starts with `?` is written {"type": "String", "value": "?x"}. `negated: true` on an antecedent is negation as failure. A rule the door refuses is not written and is named in `warnings`: a conclusion variable that no antecedent binds, no antecedent, a new cycle through negation, or a feature value the door cannot read. A sort a rule names that `sorts` does not declare is created under `thing` before the rules are authored, so an unknown sort is not refused here (only PATCH /api/v1/scenarios/{id} `add_rules`, which is not normalized, refuses one). */
|
|
22133
|
+
rules?: {
|
|
22126
22134
|
/** The conditions. Defaults to empty. */
|
|
22127
22135
|
antecedents?: {
|
|
22128
22136
|
/** The antecedent's own identity, named ("?P", with or without the `?`) — OSFQL's `?P: pizza(...)`. On a positive antecedent every "?P" elsewhere in the rule references the term it matches; on a negated one it names the term the negation is about, which a positive antecedent must bind. Meaningless on a head. */
|
|
@@ -22148,12 +22156,16 @@ interface MaterializeScenarioRequest$1 {
|
|
|
22148
22156
|
sort: string;
|
|
22149
22157
|
};
|
|
22150
22158
|
}[];
|
|
22159
|
+
/** The ontology's scope. Accepted and not written by this route: PUT /api/v1/ontology/scope stores a scope. */
|
|
22160
|
+
scope?: object;
|
|
22151
22161
|
/** LLM sensor points. Defaults to empty. */
|
|
22152
22162
|
sensorPoints?: object[];
|
|
22153
|
-
/** Sorts to create or reuse. A sort may carry `provenance`, recorded as its origin: `{"kind": "model", "model"?: …}` (a model proposal, `LlmExtracted`) or `{"kind": "imported", "ontology": …, "original_id": …}` (`Imported`). Without it the sort is `Manual`, credited to the caller; `System` cannot be claimed. */
|
|
22154
|
-
sorts
|
|
22163
|
+
/** Sorts to create or reuse. A sort may carry `provenance`, recorded as its origin: `{"kind": "model", "model"?: …}` (a model proposal, `LlmExtracted`) or `{"kind": "imported", "ontology": …, "original_id": …}` (`Imported`). Without it the sort is `Manual`, credited to the caller; `System` cannot be claimed. Defaults to empty. */
|
|
22164
|
+
sorts?: object[];
|
|
22155
22165
|
/** Allen temporal constraints. Defaults to empty. */
|
|
22156
22166
|
temporalConstraints?: object[];
|
|
22167
|
+
/** Use cases, each `{id, title?, description?}`, recorded as `proposed` competency questions of kind `use_case`. Defaults to empty. */
|
|
22168
|
+
use_cases?: object[];
|
|
22157
22169
|
/** Webhook actions. Defaults to empty. */
|
|
22158
22170
|
webhookActions?: object[];
|
|
22159
22171
|
};
|
|
@@ -30369,6 +30381,20 @@ interface RuleEntryDto$1 {
|
|
|
30369
30381
|
* @format double
|
|
30370
30382
|
*/
|
|
30371
30383
|
certainty?: number | null;
|
|
30384
|
+
/**
|
|
30385
|
+
* The rule's content tag (`sha256-<hex>`): send it as `If-Match` on
|
|
30386
|
+
* `DELETE`/`PUT /api/v1/inference/rules/{id}` (#473).
|
|
30387
|
+
*
|
|
30388
|
+
* The same tag those routes judge the precondition against, read from
|
|
30389
|
+
* the same store. `GET /api/v1/terms/{id}` does not serve it, because a
|
|
30390
|
+
* rule's conclusion is the rule's own term and not a fact (#456), so this
|
|
30391
|
+
* listing is the read that publishes it.
|
|
30392
|
+
*
|
|
30393
|
+
* Present on every [`Self::withdrawable`] rule whose conclusion the
|
|
30394
|
+
* tenant's term service holds; absent on a rule no route withdraws,
|
|
30395
|
+
* which has no mutation to precondition.
|
|
30396
|
+
*/
|
|
30397
|
+
etag?: string | null;
|
|
30372
30398
|
/** The head (consequent) of the rule. */
|
|
30373
30399
|
head: PsiTermDto$1;
|
|
30374
30400
|
/**
|
|
@@ -41803,10 +41829,10 @@ interface TermResponse {
|
|
|
41803
41829
|
* - a term answered straight from durable storage because the live store
|
|
41804
41830
|
* did not hold it.
|
|
41805
41831
|
*
|
|
41806
|
-
* A rule's
|
|
41807
|
-
*
|
|
41808
|
-
* {@link
|
|
41809
|
-
*
|
|
41832
|
+
* A rule's tag is not read here: `getTerm(ruleId)` answers 404 for a rule.
|
|
41833
|
+
* The rule routes publish it — {@link AddRuleResponse.etag},
|
|
41834
|
+
* {@link ReplaceRuleResponse.etag} and the listing's
|
|
41835
|
+
* {@link RuleEntryDto.etag}.
|
|
41810
41836
|
*
|
|
41811
41837
|
* Not part of the response body: other routes that answer a `TermResponse`
|
|
41812
41838
|
* never set it.
|
|
@@ -43291,6 +43317,17 @@ interface AddFactResponse {
|
|
|
43291
43317
|
interface AddRuleResponse {
|
|
43292
43318
|
/** The created rule as a PsiTerm. */
|
|
43293
43319
|
term: PsiTermDto;
|
|
43320
|
+
/**
|
|
43321
|
+
* The rule's content tag (`sha256-<hex>`), from the `ETag` response header:
|
|
43322
|
+
* pass it as `ifMatch` to {@link InferenceClient.deleteRule} or
|
|
43323
|
+
* {@link InferenceClient.replaceRule}.
|
|
43324
|
+
*
|
|
43325
|
+
* @remarks
|
|
43326
|
+
* Not part of the response body. Absent when the engine sends no header:
|
|
43327
|
+
* the rule is written, but the read that tags the response failed after the
|
|
43328
|
+
* write committed. Read the tag from {@link RuleEntryDto.etag} then.
|
|
43329
|
+
*/
|
|
43330
|
+
etag?: string;
|
|
43294
43331
|
}
|
|
43295
43332
|
/** One finding of a rule validation. */
|
|
43296
43333
|
interface RuleIssue {
|
|
@@ -43534,6 +43571,17 @@ interface RuleEntryDto {
|
|
|
43534
43571
|
body: PsiTermDto[];
|
|
43535
43572
|
/** Optional certainty/confidence for the rule. */
|
|
43536
43573
|
certainty?: number | null;
|
|
43574
|
+
/**
|
|
43575
|
+
* The rule's content tag (`sha256-<hex>`): pass it as `ifMatch` to
|
|
43576
|
+
* {@link InferenceClient.deleteRule} or {@link InferenceClient.replaceRule}.
|
|
43577
|
+
*
|
|
43578
|
+
* @remarks
|
|
43579
|
+
* The same tag those routes judge the precondition against. Present on a
|
|
43580
|
+
* {@link RuleEntryDto.withdrawable} rule; absent on a rule no route
|
|
43581
|
+
* withdraws, which has no mutation to precondition. `getTerm(ruleId)` does
|
|
43582
|
+
* not serve it: a rule's id answers 404 on the term route.
|
|
43583
|
+
*/
|
|
43584
|
+
etag?: string;
|
|
43537
43585
|
/**
|
|
43538
43586
|
* Where this rule came from, from the reading tenant's point of view.
|
|
43539
43587
|
*
|
|
@@ -43732,6 +43780,17 @@ interface ReplaceRuleResponse {
|
|
|
43732
43780
|
previousRuleId: string;
|
|
43733
43781
|
/** The replacement rule, as created. */
|
|
43734
43782
|
term: PsiTermDto;
|
|
43783
|
+
/**
|
|
43784
|
+
* The REPLACEMENT rule's content tag (`sha256-<hex>`), from the `ETag`
|
|
43785
|
+
* response header: the `ifMatch` for the next edit or withdrawal.
|
|
43786
|
+
*
|
|
43787
|
+
* @remarks
|
|
43788
|
+
* Not part of the response body. Absent when the engine sends no header:
|
|
43789
|
+
* the replacement is written, but the read that tags the response failed
|
|
43790
|
+
* after the write committed. Read the tag from {@link RuleEntryDto.etag}
|
|
43791
|
+
* then.
|
|
43792
|
+
*/
|
|
43793
|
+
etag?: string;
|
|
43735
43794
|
/** What withdrawing the previous rule removed. */
|
|
43736
43795
|
withdrawal: RuleWithdrawalReport;
|
|
43737
43796
|
/** How the edit moved the rule base's guarantees. */
|
|
@@ -48353,10 +48412,11 @@ declare class TermsClient {
|
|
|
48353
48412
|
* `etag` is optional in every case, not only for `asOf`. A historical read
|
|
48354
48413
|
* carries none (a past state is not a representation `If-Match` can guard,
|
|
48355
48414
|
* and a client that could capture one could overwrite the present with the
|
|
48356
|
-
* past), and neither does a
|
|
48357
|
-
*
|
|
48358
|
-
*
|
|
48359
|
-
* {@link
|
|
48415
|
+
* past), and neither does a term answered straight from durable storage.
|
|
48416
|
+
* A rule's id answers 404 here; read the tag
|
|
48417
|
+
* {@link InferenceClient.deleteRule} and {@link InferenceClient.replaceRule}
|
|
48418
|
+
* take as `ifMatch` from the rule routes ({@link AddRuleResponse.etag},
|
|
48419
|
+
* {@link RuleEntryDto.etag}).
|
|
48360
48420
|
*
|
|
48361
48421
|
* @example
|
|
48362
48422
|
* ```typescript
|
|
@@ -48955,7 +49015,7 @@ declare class Inference<SecurityDataType = unknown> {
|
|
|
48955
49015
|
*/
|
|
48956
49016
|
deleteGoal: (goalId: string, params?: RequestParams) => Promise<HttpResponse<DeleteGoalResponse$1, void>>;
|
|
48957
49017
|
/**
|
|
48958
|
-
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag
|
|
49018
|
+
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag — the tag [`rule_content_tag`] publishes on the rule routes (#473) — and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
|
|
48959
49019
|
*
|
|
48960
49020
|
* @tags inference
|
|
48961
49021
|
* @name DeleteRule
|
|
@@ -49146,7 +49206,8 @@ declare class InferenceClient {
|
|
|
49146
49206
|
*
|
|
49147
49207
|
* @param request - Rule definition using TermInputDto. Set `aggregator` to declare an
|
|
49148
49208
|
* engine-side head aggregator (see {@link RuleAggregatorDto}).
|
|
49149
|
-
* @returns The created rule wrapped in an AddRuleResponse
|
|
49209
|
+
* @returns The created rule wrapped in an AddRuleResponse, with its
|
|
49210
|
+
* {@link AddRuleResponse.etag} when the engine sends the `ETag` header.
|
|
49150
49211
|
* @throws {ApiError} If the rule is rejected or the request fails — 422 when
|
|
49151
49212
|
* it is unusable as written: a head or body antecedent naming a sort or
|
|
49152
49213
|
* term that does not exist (the message names it and its position — `the
|
|
@@ -49169,6 +49230,9 @@ declare class InferenceClient {
|
|
|
49169
49230
|
*
|
|
49170
49231
|
* Ask {@link InferenceClient.validateRule} first to learn every reason the
|
|
49171
49232
|
* write would refuse, without writing.
|
|
49233
|
+
* The `ETag` response header is the rule's content tag, folded into
|
|
49234
|
+
* `etag`: the `ifMatch` for {@link InferenceClient.deleteRule} and
|
|
49235
|
+
* {@link InferenceClient.replaceRule}.
|
|
49172
49236
|
* A `{ termId }` reference to a term that is durable but not yet loaded
|
|
49173
49237
|
* into the engine process resolves: the route loads the terms the request
|
|
49174
49238
|
* names before it converts them.
|
|
@@ -49367,8 +49431,8 @@ declare class InferenceClient {
|
|
|
49367
49431
|
* @param ruleId - Term id of the rule (its conclusion), as returned by
|
|
49368
49432
|
* {@link InferenceClient.addRule} or {@link InferenceClient.getRules}.
|
|
49369
49433
|
* @param options - `derivations` decides what happens to the conclusions the
|
|
49370
|
-
* rule derived (defaults to `'refuse'`); `ifMatch` is the
|
|
49371
|
-
*
|
|
49434
|
+
* rule derived (defaults to `'refuse'`); `ifMatch` is the rule's content
|
|
49435
|
+
* tag, sent as the `If-Match` header.
|
|
49372
49436
|
* @param requestOptions - Per-call request options.
|
|
49373
49437
|
* @returns What the withdrawal removed, tier by tier.
|
|
49374
49438
|
* @throws {@link ApiError} 400 if the id names a fact rather than a rule, or
|
|
@@ -49397,14 +49461,16 @@ declare class InferenceClient {
|
|
|
49397
49461
|
* conclusions are resident is refused too; `'retract'` removes them and
|
|
49398
49462
|
* {@link RuleWithdrawalReport.consequencesInvalidated} counts them.
|
|
49399
49463
|
*
|
|
49400
|
-
* **Optimistic concurrency.**
|
|
49401
|
-
*
|
|
49402
|
-
*
|
|
49403
|
-
* edited since answers 412.
|
|
49464
|
+
* **Optimistic concurrency.** Read the rule's tag from
|
|
49465
|
+
* {@link AddRuleResponse.etag}, {@link ReplaceRuleResponse.etag} or the
|
|
49466
|
+
* listing's {@link RuleEntryDto.etag} ({@link InferenceClient.getRules}),
|
|
49467
|
+
* and pass it as `ifMatch`; a rule edited since answers 412. The term route
|
|
49468
|
+
* does not serve it: `client.terms.getTerm(ruleId)` answers 404 for a rule.
|
|
49404
49469
|
*
|
|
49405
49470
|
* @example
|
|
49406
49471
|
* ```typescript
|
|
49407
|
-
* const {
|
|
49472
|
+
* const { rules } = await client.inference.getRules();
|
|
49473
|
+
* const etag = rules.find((rule) => rule.ruleId === ruleId)?.etag;
|
|
49408
49474
|
* const report = await client.inference.deleteRule(ruleId, {
|
|
49409
49475
|
* derivations: 'retract',
|
|
49410
49476
|
* ifMatch: etag,
|
|
@@ -49421,11 +49487,12 @@ declare class InferenceClient {
|
|
|
49421
49487
|
*
|
|
49422
49488
|
* @param ruleId - Term id of the rule (its conclusion) to replace.
|
|
49423
49489
|
* @param request - The replacement rule, in the same shape
|
|
49424
|
-
* {@link InferenceClient.addRule} takes, plus `ifMatch`: the
|
|
49425
|
-
* outgoing rule
|
|
49490
|
+
* {@link InferenceClient.addRule} takes, plus `ifMatch`: the content tag
|
|
49491
|
+
* of the outgoing rule, sent as the `If-Match` header and never in the body.
|
|
49426
49492
|
* @param requestOptions - Per-call request options.
|
|
49427
49493
|
* @returns The replacement, the id it replaced, what the withdrawal removed,
|
|
49428
|
-
* and how the rule base's guarantees moved
|
|
49494
|
+
* and how the rule base's guarantees moved; `etag` is the replacement's
|
|
49495
|
+
* content tag when the engine sends the `ETag` header.
|
|
49429
49496
|
* @throws {@link ApiError} 422 if the replacement is rejected by the
|
|
49430
49497
|
* authoring guards — in which case the original rule is left live. An
|
|
49431
49498
|
* empty `antecedents` list is one such refusal (`rule rejected: a rule
|
|
@@ -49448,16 +49515,23 @@ declare class InferenceClient {
|
|
|
49448
49515
|
* addresses a single clause.
|
|
49449
49516
|
*
|
|
49450
49517
|
* `ifMatch` guards the edit exactly as it guards
|
|
49451
|
-
* {@link InferenceClient.deleteRule}: read the tag
|
|
49452
|
-
*
|
|
49518
|
+
* {@link InferenceClient.deleteRule}: read the tag from
|
|
49519
|
+
* {@link AddRuleResponse.etag}, a previous {@link ReplaceRuleResponse.etag}
|
|
49520
|
+
* or the listing's {@link RuleEntryDto.etag}. The response's own `etag` is
|
|
49521
|
+
* the REPLACEMENT's tag, the `ifMatch` for the next edit.
|
|
49453
49522
|
*
|
|
49454
49523
|
* **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
|
|
49455
49524
|
*
|
|
49456
49525
|
* @example
|
|
49457
49526
|
* ```typescript
|
|
49458
|
-
* const
|
|
49527
|
+
* const created = await client.inference.addRule({
|
|
49528
|
+
* term: psi('senior', { name: Var('N') }),
|
|
49529
|
+
* antecedents: [psi('person', { name: Var('N') })],
|
|
49530
|
+
* });
|
|
49531
|
+
* const result = await client.inference.replaceRule(created.term.termId, {
|
|
49459
49532
|
* term: psi('retiree', { name: Var('N') }),
|
|
49460
49533
|
* antecedents: [psi('person', { name: Var('N') })],
|
|
49534
|
+
* ifMatch: created.etag,
|
|
49461
49535
|
* });
|
|
49462
49536
|
* console.log(result.previousRuleId, '->', result.term.termId);
|
|
49463
49537
|
* if (result.certification.regressed) {
|
|
@@ -71338,19 +71412,21 @@ type ScenarioSortProvenance = {
|
|
|
71338
71412
|
* Sent byte for byte, so every key must be the engine's own spelling — and
|
|
71339
71413
|
* the spellings are mixed:
|
|
71340
71414
|
*
|
|
71341
|
-
* - camelCase: `webhookActions`, `temporalConstraints`,
|
|
71342
|
-
* `pipelineStages`, `sensorPoints
|
|
71343
|
-
* snake_case forms)
|
|
71415
|
+
* - camelCase only: `webhookActions`, `temporalConstraints`,
|
|
71416
|
+
* `guardConstraints`, `pipelineStages`, `sensorPoints`. Since engine #474
|
|
71417
|
+
* their snake_case forms (`webhook_actions`, …) are IGNORED, without an
|
|
71418
|
+
* error;
|
|
71344
71419
|
* - snake_case only: `curriculum_stages`, `discovered_tools`, `use_cases`,
|
|
71345
71420
|
* `competency_questions`, `computed_features`. A camelCase
|
|
71346
71421
|
* `curriculumStages` or `discoveredTools` is IGNORED, without an error;
|
|
71347
71422
|
* - one word: `sorts`, `beliefs`, `rules`, `goal`, `groundings`,
|
|
71348
71423
|
* `constraints`, `fluents`, `axioms`, `scope`.
|
|
71349
71424
|
*
|
|
71350
|
-
*
|
|
71351
|
-
* optional: a scenario without one
|
|
71352
|
-
*
|
|
71353
|
-
*
|
|
71425
|
+
* No key is required: every collection defaults to empty, so a vocabulary
|
|
71426
|
+
* import sends `sorts` alone. `goal` is optional: a scenario without one
|
|
71427
|
+
* materializes no agent goal
|
|
71428
|
+
* ({@link MaterializeScenarioResponse.goalCreated} is `false`). Keys not
|
|
71429
|
+
* listed here are ignored.
|
|
71354
71430
|
*
|
|
71355
71431
|
* The same rule holds inside the collections. A curriculum stage is
|
|
71356
71432
|
* `{stage_number, name, concepts, prerequisites?, mastery_threshold?}`, a
|
|
@@ -71372,9 +71448,9 @@ interface GeneratedScenario {
|
|
|
71372
71448
|
/**
|
|
71373
71449
|
* Sorts to create or reuse. A sort may carry `provenance`
|
|
71374
71450
|
* ({@link ScenarioSortProvenance}); without it the sort is credited to the
|
|
71375
|
-
* caller.
|
|
71451
|
+
* caller. Defaults to empty.
|
|
71376
71452
|
*/
|
|
71377
|
-
sorts
|
|
71453
|
+
sorts?: Record<string, unknown>[];
|
|
71378
71454
|
/**
|
|
71379
71455
|
* Belief instances (typed facts) to assert. Omit it for a schema-only
|
|
71380
71456
|
* scenario: the engine builds sorts alone (a scenario needs at least one
|
|
@@ -71418,7 +71494,7 @@ interface GeneratedScenario {
|
|
|
71418
71494
|
webhookActions?: Record<string, unknown>[];
|
|
71419
71495
|
/** OWL-style axioms over sorts and features (staged builder). */
|
|
71420
71496
|
axioms?: Record<string, unknown>[];
|
|
71421
|
-
/** The model's declared scope
|
|
71497
|
+
/** The model's declared scope. Accepted and not written by materialization: `ontology.putScope` stores a scope. */
|
|
71422
71498
|
scope?: Record<string, unknown>;
|
|
71423
71499
|
/** Use cases the model serves (staged builder). */
|
|
71424
71500
|
use_cases?: Record<string, unknown>[];
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/config.ts
|
|
8
|
-
var SDK_VERSION = "4.
|
|
8
|
+
var SDK_VERSION = "4.1.0";
|
|
9
9
|
function resolveConfig(config) {
|
|
10
10
|
if (!config.baseUrl) {
|
|
11
11
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -2530,7 +2530,7 @@ var Inference = class {
|
|
|
2530
2530
|
...params
|
|
2531
2531
|
});
|
|
2532
2532
|
/**
|
|
2533
|
-
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag
|
|
2533
|
+
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag — the tag [`rule_content_tag`] publishes on the rule routes (#473) — and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
|
|
2534
2534
|
*
|
|
2535
2535
|
* @tags inference
|
|
2536
2536
|
* @name DeleteRule
|
|
@@ -28614,10 +28614,11 @@ var TermsClient = class {
|
|
|
28614
28614
|
* `etag` is optional in every case, not only for `asOf`. A historical read
|
|
28615
28615
|
* carries none (a past state is not a representation `If-Match` can guard,
|
|
28616
28616
|
* and a client that could capture one could overwrite the present with the
|
|
28617
|
-
* past), and neither does a
|
|
28618
|
-
*
|
|
28619
|
-
*
|
|
28620
|
-
* {@link
|
|
28617
|
+
* past), and neither does a term answered straight from durable storage.
|
|
28618
|
+
* A rule's id answers 404 here; read the tag
|
|
28619
|
+
* {@link InferenceClient.deleteRule} and {@link InferenceClient.replaceRule}
|
|
28620
|
+
* take as `ifMatch` from the rule routes ({@link AddRuleResponse.etag},
|
|
28621
|
+
* {@link RuleEntryDto.etag}).
|
|
28621
28622
|
*
|
|
28622
28623
|
* @example
|
|
28623
28624
|
* ```typescript
|
|
@@ -29599,6 +29600,7 @@ function RuleEntryDtoFromApiToFront(dto) {
|
|
|
29599
29600
|
if (dto.aggregator !== void 0 && dto.aggregator !== null) {
|
|
29600
29601
|
entry.aggregator = RuleAggregatorDtoFromApiToFront(dto.aggregator);
|
|
29601
29602
|
}
|
|
29603
|
+
if (dto.etag !== void 0 && dto.etag !== null) entry.etag = dto.etag;
|
|
29602
29604
|
if (dto.osfql !== void 0 && dto.osfql !== null) entry.osfql = dto.osfql;
|
|
29603
29605
|
return entry;
|
|
29604
29606
|
}
|
|
@@ -30050,7 +30052,8 @@ var InferenceClient = class {
|
|
|
30050
30052
|
*
|
|
30051
30053
|
* @param request - Rule definition using TermInputDto. Set `aggregator` to declare an
|
|
30052
30054
|
* engine-side head aggregator (see {@link RuleAggregatorDto}).
|
|
30053
|
-
* @returns The created rule wrapped in an AddRuleResponse
|
|
30055
|
+
* @returns The created rule wrapped in an AddRuleResponse, with its
|
|
30056
|
+
* {@link AddRuleResponse.etag} when the engine sends the `ETag` header.
|
|
30054
30057
|
* @throws {ApiError} If the rule is rejected or the request fails — 422 when
|
|
30055
30058
|
* it is unusable as written: a head or body antecedent naming a sort or
|
|
30056
30059
|
* term that does not exist (the message names it and its position — `the
|
|
@@ -30073,6 +30076,9 @@ var InferenceClient = class {
|
|
|
30073
30076
|
*
|
|
30074
30077
|
* Ask {@link InferenceClient.validateRule} first to learn every reason the
|
|
30075
30078
|
* write would refuse, without writing.
|
|
30079
|
+
* The `ETag` response header is the rule's content tag, folded into
|
|
30080
|
+
* `etag`: the `ifMatch` for {@link InferenceClient.deleteRule} and
|
|
30081
|
+
* {@link InferenceClient.replaceRule}.
|
|
30076
30082
|
* A `{ termId }` reference to a term that is durable but not yet loaded
|
|
30077
30083
|
* into the engine process resolves: the route loads the terms the request
|
|
30078
30084
|
* names before it converts them.
|
|
@@ -30097,7 +30103,7 @@ var InferenceClient = class {
|
|
|
30097
30103
|
AddRuleRequestFromFrontToApi(wireRequest),
|
|
30098
30104
|
toRequestParams(requestOptions)
|
|
30099
30105
|
);
|
|
30100
|
-
return decodeResponse(response, AddRuleResponseFromApiToFront);
|
|
30106
|
+
return withRuleEtag(decodeResponse(response, AddRuleResponseFromApiToFront), response.headers);
|
|
30101
30107
|
}
|
|
30102
30108
|
/**
|
|
30103
30109
|
* Run every check {@link InferenceClient.addRule} runs — without writing.
|
|
@@ -30319,8 +30325,8 @@ var InferenceClient = class {
|
|
|
30319
30325
|
* @param ruleId - Term id of the rule (its conclusion), as returned by
|
|
30320
30326
|
* {@link InferenceClient.addRule} or {@link InferenceClient.getRules}.
|
|
30321
30327
|
* @param options - `derivations` decides what happens to the conclusions the
|
|
30322
|
-
* rule derived (defaults to `'refuse'`); `ifMatch` is the
|
|
30323
|
-
*
|
|
30328
|
+
* rule derived (defaults to `'refuse'`); `ifMatch` is the rule's content
|
|
30329
|
+
* tag, sent as the `If-Match` header.
|
|
30324
30330
|
* @param requestOptions - Per-call request options.
|
|
30325
30331
|
* @returns What the withdrawal removed, tier by tier.
|
|
30326
30332
|
* @throws {@link ApiError} 400 if the id names a fact rather than a rule, or
|
|
@@ -30349,14 +30355,16 @@ var InferenceClient = class {
|
|
|
30349
30355
|
* conclusions are resident is refused too; `'retract'` removes them and
|
|
30350
30356
|
* {@link RuleWithdrawalReport.consequencesInvalidated} counts them.
|
|
30351
30357
|
*
|
|
30352
|
-
* **Optimistic concurrency.**
|
|
30353
|
-
*
|
|
30354
|
-
*
|
|
30355
|
-
* edited since answers 412.
|
|
30358
|
+
* **Optimistic concurrency.** Read the rule's tag from
|
|
30359
|
+
* {@link AddRuleResponse.etag}, {@link ReplaceRuleResponse.etag} or the
|
|
30360
|
+
* listing's {@link RuleEntryDto.etag} ({@link InferenceClient.getRules}),
|
|
30361
|
+
* and pass it as `ifMatch`; a rule edited since answers 412. The term route
|
|
30362
|
+
* does not serve it: `client.terms.getTerm(ruleId)` answers 404 for a rule.
|
|
30356
30363
|
*
|
|
30357
30364
|
* @example
|
|
30358
30365
|
* ```typescript
|
|
30359
|
-
* const {
|
|
30366
|
+
* const { rules } = await client.inference.getRules();
|
|
30367
|
+
* const etag = rules.find((rule) => rule.ruleId === ruleId)?.etag;
|
|
30360
30368
|
* const report = await client.inference.deleteRule(ruleId, {
|
|
30361
30369
|
* derivations: 'retract',
|
|
30362
30370
|
* ifMatch: etag,
|
|
@@ -30377,11 +30385,12 @@ var InferenceClient = class {
|
|
|
30377
30385
|
*
|
|
30378
30386
|
* @param ruleId - Term id of the rule (its conclusion) to replace.
|
|
30379
30387
|
* @param request - The replacement rule, in the same shape
|
|
30380
|
-
* {@link InferenceClient.addRule} takes, plus `ifMatch`: the
|
|
30381
|
-
* outgoing rule
|
|
30388
|
+
* {@link InferenceClient.addRule} takes, plus `ifMatch`: the content tag
|
|
30389
|
+
* of the outgoing rule, sent as the `If-Match` header and never in the body.
|
|
30382
30390
|
* @param requestOptions - Per-call request options.
|
|
30383
30391
|
* @returns The replacement, the id it replaced, what the withdrawal removed,
|
|
30384
|
-
* and how the rule base's guarantees moved
|
|
30392
|
+
* and how the rule base's guarantees moved; `etag` is the replacement's
|
|
30393
|
+
* content tag when the engine sends the `ETag` header.
|
|
30385
30394
|
* @throws {@link ApiError} 422 if the replacement is rejected by the
|
|
30386
30395
|
* authoring guards — in which case the original rule is left live. An
|
|
30387
30396
|
* empty `antecedents` list is one such refusal (`rule rejected: a rule
|
|
@@ -30404,16 +30413,23 @@ var InferenceClient = class {
|
|
|
30404
30413
|
* addresses a single clause.
|
|
30405
30414
|
*
|
|
30406
30415
|
* `ifMatch` guards the edit exactly as it guards
|
|
30407
|
-
* {@link InferenceClient.deleteRule}: read the tag
|
|
30408
|
-
*
|
|
30416
|
+
* {@link InferenceClient.deleteRule}: read the tag from
|
|
30417
|
+
* {@link AddRuleResponse.etag}, a previous {@link ReplaceRuleResponse.etag}
|
|
30418
|
+
* or the listing's {@link RuleEntryDto.etag}. The response's own `etag` is
|
|
30419
|
+
* the REPLACEMENT's tag, the `ifMatch` for the next edit.
|
|
30409
30420
|
*
|
|
30410
30421
|
* **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
|
|
30411
30422
|
*
|
|
30412
30423
|
* @example
|
|
30413
30424
|
* ```typescript
|
|
30414
|
-
* const
|
|
30425
|
+
* const created = await client.inference.addRule({
|
|
30426
|
+
* term: psi('senior', { name: Var('N') }),
|
|
30427
|
+
* antecedents: [psi('person', { name: Var('N') })],
|
|
30428
|
+
* });
|
|
30429
|
+
* const result = await client.inference.replaceRule(created.term.termId, {
|
|
30415
30430
|
* term: psi('retiree', { name: Var('N') }),
|
|
30416
30431
|
* antecedents: [psi('person', { name: Var('N') })],
|
|
30432
|
+
* ifMatch: created.etag,
|
|
30417
30433
|
* });
|
|
30418
30434
|
* console.log(result.previousRuleId, '->', result.term.termId);
|
|
30419
30435
|
* if (result.certification.regressed) {
|
|
@@ -30433,7 +30449,10 @@ var InferenceClient = class {
|
|
|
30433
30449
|
AddRuleRequestFromFrontToApi(wireRequest),
|
|
30434
30450
|
ifMatchParams(request.ifMatch, requestOptions)
|
|
30435
30451
|
);
|
|
30436
|
-
return
|
|
30452
|
+
return withRuleEtag(
|
|
30453
|
+
decodeResponse(response, ReplaceRuleResponseFromApiToFront),
|
|
30454
|
+
response.headers
|
|
30455
|
+
);
|
|
30437
30456
|
}
|
|
30438
30457
|
/**
|
|
30439
30458
|
* Query for matching data by searching rules and facts backwards from a goal pattern.
|
|
@@ -30931,6 +30950,10 @@ var InferenceClient = class {
|
|
|
30931
30950
|
function convertTermArg(input) {
|
|
30932
30951
|
return isPsiTermInput(input) ? toTermInputDto(input) : input;
|
|
30933
30952
|
}
|
|
30953
|
+
function withRuleEtag(body, headers) {
|
|
30954
|
+
const etag = headers.get("etag");
|
|
30955
|
+
return etag === null ? body : { ...body, etag };
|
|
30956
|
+
}
|
|
30934
30957
|
|
|
30935
30958
|
// src/normalizers/query.ts
|
|
30936
30959
|
function TermPatternDtoFromFrontToApi(model) {
|
|
@@ -43046,8 +43069,8 @@ function MaterializeScenarioRequestFromFrontToApi(model) {
|
|
|
43046
43069
|
return {
|
|
43047
43070
|
// The prefix keys are data (`''`, `myOnt`), copied verbatim.
|
|
43048
43071
|
prefixes: model.prefixes === void 0 ? void 0 : { ...model.prefixes },
|
|
43049
|
-
//
|
|
43050
|
-
//
|
|
43072
|
+
// The scenario is user data sent verbatim (RAW_BODY_HEADER, #39): every
|
|
43073
|
+
// key reaches the engine under the spelling the caller wrote.
|
|
43051
43074
|
scenario: model.scenario
|
|
43052
43075
|
};
|
|
43053
43076
|
}
|