@kortexya/reasoninglayer 1.16.0 → 1.18.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.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/config.ts
8
- var SDK_VERSION = "1.16.0";
8
+ var SDK_VERSION = "1.18.0";
9
9
  function resolveConfig(config) {
10
10
  if (!config.baseUrl) {
11
11
  throw new Error("ClientConfig.baseUrl is required");
@@ -585,6 +585,8 @@ var USER_DATA_FIELDS = /* @__PURE__ */ new Set([
585
585
  "per_strategy_taxonomies",
586
586
  "propsOverride",
587
587
  "props_override",
588
+ "referencedTerms",
589
+ "referenced_terms",
588
590
  "roleMinimums",
589
591
  "role_minimums",
590
592
  "scope",
@@ -592,6 +594,8 @@ var USER_DATA_FIELDS = /* @__PURE__ */ new Set([
592
594
  "scores_by_name",
593
595
  "sortNames",
594
596
  "sort_names",
597
+ "toolResults",
598
+ "tool_results",
595
599
  "topK",
596
600
  "top_k",
597
601
  "values"
@@ -994,6 +998,22 @@ var Sorts = class {
994
998
  format: "json",
995
999
  ...params
996
1000
  });
1001
+ /**
1002
+ * No description
1003
+ *
1004
+ * @tags sorts
1005
+ * @name GetFuzzySubsumption
1006
+ * @summary Get the fuzzy subsumption degree `sub ⊑· sup` between two sorts
1007
+ * @request POST:/api/v1/sorts/subsumption/get
1008
+ */
1009
+ getFuzzySubsumption = (data, params = {}) => this.http.request({
1010
+ path: `/api/v1/sorts/subsumption/get`,
1011
+ method: "POST",
1012
+ body: data,
1013
+ type: "application/json" /* Json */,
1014
+ format: "json",
1015
+ ...params
1016
+ });
997
1017
  /**
998
1018
  * @description Per Definition IV.5 (Milanese & Pasi 2024): ≾̇ = ((≾̃ .− ∼) ⊍ ≤)⁺
999
1019
  *
@@ -1011,16 +1031,17 @@ var Sorts = class {
1011
1031
  ...params
1012
1032
  });
1013
1033
  /**
1014
- * No description
1034
+ * @description With `?format=osfql` the sort is returned as its commented OSFQL `DEFINE` block (`text/plain`, `ETag` = SHA-256 of the body) instead of the JSON DTO — the single-sort companion of `GET /api/v1/sorts/schema`.
1015
1035
  *
1016
1036
  * @tags sorts
1017
1037
  * @name GetSort
1018
1038
  * @summary Get a sort by ID
1019
1039
  * @request GET:/api/v1/sorts/{id}
1020
1040
  */
1021
- getSort = (id, params = {}) => this.http.request({
1041
+ getSort = (id, query, params = {}) => this.http.request({
1022
1042
  path: `/api/v1/sorts/${id}`,
1023
1043
  method: "GET",
1044
+ query,
1024
1045
  format: "json",
1025
1046
  ...params
1026
1047
  });
@@ -1040,6 +1061,22 @@ var Sorts = class {
1040
1061
  format: "json",
1041
1062
  ...params
1042
1063
  });
1064
+ /**
1065
+ * @description The bulk companion of `?format=osfql` on the by-id route: a single deterministic, re-parseable `text/plain` block of commented `DEFINE` statements (one per sort, ordered by name) for LLM prompt conditioning and replayable export. Supports the tenant listing's filters (`name_prefix`, `include_system`, `needs_review`, `llm_extracted`, and `offset`/`limit`, applied after the deterministic ordering so pages are stable). The `ETag` is the SHA-256 of the body, so prompt-conditioning consumers get a stable cache key for "schema unchanged".
1066
+ *
1067
+ * @tags sorts
1068
+ * @name GetSortsSchema
1069
+ * @summary Export the authenticated tenant's schema as one OSFQL DDL block
1070
+ * @request GET:/api/v1/sorts/schema
1071
+ * @secure
1072
+ */
1073
+ getSortsSchema = (query, params = {}) => this.http.request({
1074
+ path: `/api/v1/sorts/schema`,
1075
+ method: "GET",
1076
+ query,
1077
+ secure: true,
1078
+ ...params
1079
+ });
1043
1080
  /**
1044
1081
  * No description
1045
1082
  *
@@ -1146,6 +1183,22 @@ var Sorts = class {
1146
1183
  format: "json",
1147
1184
  ...params
1148
1185
  });
1186
+ /**
1187
+ * @description Subsumption is **directional**: ⊑·(s₁, s₂) and ⊑·(s₂, s₁) are different assertions. For the symmetric relation use `/api/v1/sorts/similarity`. The degree must be in [0, 1] and the assignment must keep the relation a fuzzy partial order (max–min transitivity, antisymmetry); one that does not is rejected rather than stored.
1188
+ *
1189
+ * @tags sorts
1190
+ * @name SetFuzzySubsumption
1191
+ * @summary Set the fuzzy subsumption degree `sub ⊑· sup` between two sorts
1192
+ * @request POST:/api/v1/sorts/subsumption
1193
+ */
1194
+ setFuzzySubsumption = (data, params = {}) => this.http.request({
1195
+ path: `/api/v1/sorts/subsumption`,
1196
+ method: "POST",
1197
+ body: data,
1198
+ type: "application/json" /* Json */,
1199
+ format: "json",
1200
+ ...params
1201
+ });
1149
1202
  /**
1150
1203
  * @description Similarity is symmetric: ∼(s₁, s₂) = ∼(s₂, s₁) Degree must be in [0, 1] range.
1151
1204
  *
@@ -1621,11 +1674,11 @@ var Inference = class {
1621
1674
  ...params
1622
1675
  });
1623
1676
  /**
1624
- * @description # DEPRECATED This endpoint is deprecated. Use `DELETE /api/v1/terms/{term_id}` for individual terms. # TRUE HOMOICONIC API # Authorization Requires X-Tenant-Id header.
1677
+ * @description This drops the hydrated base facts, the forward-chain `persist_derived` facts and the residuation store, then forgets the hydration flag so the next request reloads the base facts from PostgreSQL. **It does not delete durable data.** The terms are the authority; this is their cache. That makes it the retraction primitive forward chaining otherwise lacks. Chaining is monotonic — delete a `blocks` edge and the derived "A blocks B" survives every later pass, so the KB keeps asserting a relationship the user removed. Clearing and re-chaining rebuilds the closure from the terms that actually exist. # History Until 2026-07-28 this handler enumerated every term in the tenant and deleted it from PostgreSQL, while calling itself "clear facts" and reporting `"Cleared N facts/rules"`. It is reachable with an ordinary tenant credential — unlike `/api/v1/admin/clear-tenant/{tenant_id}`, which gateways block — so a caller reading the name, the path or the response body had no way to know it was a tenant wipe. It destroyed a live tenant that way. Use `DELETE /api/v1/terms/{term_id}` to delete a term, and the admin route to wipe a tenant; deleting durable data must not be something an endpoint does as a side effect of its name. # Authorization Requires X-Tenant-Id header, and the path tenant must match it.
1625
1678
  *
1626
1679
  * @tags inference
1627
1680
  * @name ClearFacts
1628
- * @summary Clear all facts and rules for a tenant
1681
+ * @summary Clear a tenant's in-memory inference working set.
1629
1682
  * @request DELETE:/api/v1/inference/facts/{tenant_id}
1630
1683
  * @secure
1631
1684
  */
@@ -3041,6 +3094,21 @@ var StructuredIngestion = class {
3041
3094
  secure: true,
3042
3095
  ...params
3043
3096
  });
3097
+ /**
3098
+ * @description Refused with 409 while a registered source still references the file's path (the source's adapter would otherwise hold a dangling `file_path`). After that source is unregistered, the delete succeeds (204). A missing sidecar (no such upload id) is 404.
3099
+ *
3100
+ * @tags structured_ingestion
3101
+ * @name DeleteSourceFile
3102
+ * @summary Delete a tenant-uploaded source file (#107).
3103
+ * @request DELETE:/api/v1/sources/files/{id}
3104
+ * @secure
3105
+ */
3106
+ deleteSourceFile = (id, params = {}) => this.http.request({
3107
+ path: `/api/v1/sources/files/${id}`,
3108
+ method: "DELETE",
3109
+ secure: true,
3110
+ ...params
3111
+ });
3044
3112
  /**
3045
3113
  * @description Performs schema introspection on the source to discover types (sorts), features (fields), and relations. This is a preview operation - no data is ingested. `type_filter` narrows the discovery to a named subset **without re-registering the source** — the escape hatch a client uses after `/tables` when the source is over the discovery cap (#66, Gap 2). It conjoins with the source config's own `include_tables`: a request narrows *within* the registration, it cannot widen past it.
3046
3114
  *
@@ -3093,6 +3161,22 @@ var StructuredIngestion = class {
3093
3161
  format: "json",
3094
3162
  ...params
3095
3163
  });
3164
+ /**
3165
+ * @description Walks `{base}/{tenant_id}/*\/​.meta.json`. A missing tenant dir yields an empty list (200), not 404 — a tenant that never uploaded is not an error.
3166
+ *
3167
+ * @tags structured_ingestion
3168
+ * @name ListSourceFiles
3169
+ * @summary List the calling tenant's uploaded source files (#107).
3170
+ * @request GET:/api/v1/sources/files
3171
+ * @secure
3172
+ */
3173
+ listSourceFiles = (params = {}) => this.http.request({
3174
+ path: `/api/v1/sources/files`,
3175
+ method: "GET",
3176
+ secure: true,
3177
+ format: "json",
3178
+ ...params
3179
+ });
3096
3180
  /**
3097
3181
  * No description
3098
3182
  *
@@ -3159,6 +3243,24 @@ var StructuredIngestion = class {
3159
3243
  format: "json",
3160
3244
  ...params
3161
3245
  });
3246
+ /**
3247
+ * @description Multipart, one field named `file`. Streamed to disk under `{base}/{tenant_id}/{id}/{safe_name}` with a `.meta.json` sidecar. The response `path` is the engine-internal location handed to `POST /api/v1/sources` as `config.file_path` (csv/parquet) or `config.database_path` (sqlite).
3248
+ *
3249
+ * @tags structured_ingestion
3250
+ * @name UploadSourceFile
3251
+ * @summary Upload a file-based source artifact for the calling tenant (#107).
3252
+ * @request POST:/api/v1/sources/files
3253
+ * @secure
3254
+ */
3255
+ uploadSourceFile = (data, params = {}) => this.http.request({
3256
+ path: `/api/v1/sources/files`,
3257
+ method: "POST",
3258
+ body: data,
3259
+ secure: true,
3260
+ type: "multipart/form-data" /* FormData */,
3261
+ format: "json",
3262
+ ...params
3263
+ });
3162
3264
  };
3163
3265
 
3164
3266
  // src/api-spec/generated/NeuroSymbolic.ts
@@ -5862,6 +5964,22 @@ var Extraction = class {
5862
5964
  constructor(http) {
5863
5965
  this.http = http;
5864
5966
  }
5967
+ /**
5968
+ * @description Read-only with respect to the knowledge base: certification inspects the tenant's sort lattice and never writes a term. Certificates *are* written to the verification certificate store, so the batch is auditable afterwards.
5969
+ *
5970
+ * @tags extraction
5971
+ * @name CertifyExtraction
5972
+ * @summary `POST /api/v1/extraction/certify` — gate a batch of extraction candidates through the OSF well-sortedness certifier before they may become durable KB content.
5973
+ * @request POST:/api/v1/extraction/certify
5974
+ */
5975
+ certifyExtraction = (data, params = {}) => this.http.request({
5976
+ path: `/api/v1/extraction/certify`,
5977
+ method: "POST",
5978
+ body: data,
5979
+ type: "application/json" /* Json */,
5980
+ format: "json",
5981
+ ...params
5982
+ });
5865
5983
  /**
5866
5984
  * @description Uses GLiNER2 (zero-shot NER) with sort names from the tenant's knowledge base, guaranteeing that all returned entity labels are valid sort names. Label selection (when no explicit labels provided): Embed the input text and ANN-search the pre-computed sort embedding index (Qdrant) for the most semantically similar HPO sorts. This is O(log n) and typically returns 20-100 highly relevant labels from 19K+ HPO sorts. Requires: - GLiNER2 NER service (`GLINER_NER_URL`) - Qdrant vector store for semantic label selection If either is not configured, returns a 500 error.
5867
5985
  *
@@ -6259,7 +6377,7 @@ var Query = class {
6259
6377
  this.http = http;
6260
6378
  }
6261
6379
  /**
6262
- * @description Returns all terms with the specified sort OR any of its subtypes. This implements proper OSF polymorphic query semantics where querying a parent sort returns all instances of that sort and its descendants.
6380
+ * @description Returns all terms with the specified sort OR any of its subtypes. This implements proper OSF polymorphic query semantics where querying a parent sort returns all instances of that sort and its descendants. ## Resolving `sort_name` A name can denote more than one id (see `sort_name_candidates`), and no cheap probe tells which of them the query can actually answer from: on the production adapter `get_sort` and `get_sort_ids_by_names` are bare reads of an in-memory cache with no persistence fallback, while the query's own `get_compatible_sorts` does fall back to Postgres. Confirming a candidate with `get_sort` would therefore 404 every tenant sort created before the last restart — a guard strictly stricter than the thing it guards. So the candidates are **tried** against the real query, in order, and the first that answers wins; only `SortNotFound` moves on to the next, every other failure is returned as-is. When the first candidate answers — the common case — the route runs exactly one term query, as it always did. A phantom id (minted into the tenant lattice by ingestion and never persisted, #138) cannot be returned: the query authority refuses it and the loop skips past it. When no candidate answers, the sort is not queryable and the honest reply is 404 naming the sort the CALLER asked for — never a 400 leaking an internal `SortId` the caller never supplied.
6263
6381
  *
6264
6382
  * @tags query
6265
6383
  * @name FindBySort
@@ -6653,7 +6771,7 @@ var Reasoning = class {
6653
6771
  this.http = http;
6654
6772
  }
6655
6773
  /**
6656
- * @description POST /api/v1/reasoning/disentailment Disentailment A =/=> B means: "if A holds, then B must NOT hold" Returns whether the disentailment is violated (conflict: both A and B hold)
6774
+ * @description POST /api/v1/reasoning/disentailment Disentailment A =/=> B means: "if A holds, then B must NOT hold". Returns whether the disentailment is violated — the conflict where the facts establish A and B follows anyway. This is hierarchy-aware and graded on the same footing as the entailment route, so a conflict reachable only through the sort lattice (a `contaminated` clause held by a `lead_paint` fact that subsumes it) is detected without that clause being supplied as a fact. `A ⇏ B` is violated exactly to the degree `A ⇒ B` is established, so `degree` here reports the complement: how strongly the disentailment still holds.
6657
6775
  *
6658
6776
  * @tags reasoning
6659
6777
  * @name Disentailment
@@ -6669,7 +6787,7 @@ var Reasoning = class {
6669
6787
  ...params
6670
6788
  });
6671
6789
  /**
6672
- * @description POST /api/v1/reasoning/entailment Returns whether antecedent entails consequent
6790
+ * @description POST /api/v1/reasoning/entailment Answers `facts antecedent ⇒ consequent`, hierarchy-aware and graded. A clause holds in the fact base to the degree that some fact *witnesses* it — that is, to the degree the clause subsumes a fact — so a `sparrow` fact establishes the clause `animal` without an `animal` fact being supplied. The consequent is additionally established when it subsumes the antecedent it would follow from. See [`osfkb_domain::operations::homoiconic_entailment`] for the full semantics. `entails` is the crisp reading of `degree`; `degree`, `antecedent_degree` and `consequent_degree` are computed from the sort lattice (crisply, and through explicit fuzzy `⊑·` relations and approved sort similarity), never cast from the boolean.
6673
6791
  *
6674
6792
  * @tags reasoning
6675
6793
  * @name Entailment
@@ -8698,6 +8816,20 @@ var Health = class {
8698
8816
  format: "json",
8699
8817
  ...params
8700
8818
  });
8819
+ /**
8820
+ * No description
8821
+ *
8822
+ * @tags health
8823
+ * @name HealthCheckApi
8824
+ * @summary `GET /api/v1/health` — the same enriched health check under the `/api/v1` prefix. The playground front proxy forwards only `/api/*` to the engine (and answers the bare `/health` itself with a static OK), so THIS is the path that makes the deployed `build_info.version` publicly readable — a stale rollout must never be indistinguishable from a fresh one.
8825
+ * @request GET:/api/v1/health
8826
+ */
8827
+ healthCheckApi = (params = {}) => this.http.request({
8828
+ path: `/api/v1/health`,
8829
+ method: "GET",
8830
+ format: "json",
8831
+ ...params
8832
+ });
8701
8833
  };
8702
8834
 
8703
8835
  // src/api-spec/generated/Scheduling.ts
@@ -9038,6 +9170,24 @@ var Generation = class {
9038
9170
  format: "json",
9039
9171
  ...params
9040
9172
  });
9173
+ /**
9174
+ * @description POST /api/v1/text/generate
9175
+ *
9176
+ * @tags generation
9177
+ * @name GenerateText
9178
+ * @summary Run the caller's system prompt over their text.
9179
+ * @request POST:/api/v1/text/generate
9180
+ * @secure
9181
+ */
9182
+ generateText = (data, params = {}) => this.http.request({
9183
+ path: `/api/v1/text/generate`,
9184
+ method: "POST",
9185
+ body: data,
9186
+ secure: true,
9187
+ type: "application/json" /* Json */,
9188
+ format: "json",
9189
+ ...params
9190
+ });
9041
9191
  /**
9042
9192
  * @description Returns `503` when no in-process Gemma is loaded (server started without `OSFKB_OSFQL_GEMMA_DIR`), `400` on an empty prompt, and `422` when the tenant has no persisted lattice to constrain to (ingest a theory with `persist:true` first).
9043
9193
  *
@@ -9374,6 +9524,58 @@ var Compliance = class {
9374
9524
  format: "json",
9375
9525
  ...params
9376
9526
  });
9527
+ /**
9528
+ * No description
9529
+ *
9530
+ * @tags compliance
9531
+ * @name CreateDsr
9532
+ * @summary File a GDPR data subject request
9533
+ * @request POST:/api/v1/dsr
9534
+ * @secure
9535
+ */
9536
+ createDsr = (data, params = {}) => this.http.request({
9537
+ path: `/api/v1/dsr`,
9538
+ method: "POST",
9539
+ body: data,
9540
+ secure: true,
9541
+ type: "application/json" /* Json */,
9542
+ format: "json",
9543
+ ...params
9544
+ });
9545
+ /**
9546
+ * @description **Dry run by default.** An exact match on an identifying feature is the only deterministic way to resolve a person to terms, but exactness is not uniqueness — two people share a name. Erasing on a bare match would silently destroy a homonym's data, and erasure is irreversible, so the plan has to be inspectable before it runs. Pass `confirm: true` once the match has been reviewed.
9547
+ *
9548
+ * @tags compliance
9549
+ * @name EraseSubject
9550
+ * @summary Plan or execute erasure of a data subject's terms
9551
+ * @request POST:/api/v1/dsr/{id}/erase
9552
+ * @secure
9553
+ */
9554
+ eraseSubject = (id, data, params = {}) => this.http.request({
9555
+ path: `/api/v1/dsr/${id}/erase`,
9556
+ method: "POST",
9557
+ body: data,
9558
+ secure: true,
9559
+ type: "application/json" /* Json */,
9560
+ format: "json",
9561
+ ...params
9562
+ });
9563
+ /**
9564
+ * No description
9565
+ *
9566
+ * @tags compliance
9567
+ * @name GetDsr
9568
+ * @summary Read a data subject request
9569
+ * @request GET:/api/v1/dsr/{id}
9570
+ * @secure
9571
+ */
9572
+ getDsr = (id, params = {}) => this.http.request({
9573
+ path: `/api/v1/dsr/${id}`,
9574
+ method: "GET",
9575
+ secure: true,
9576
+ format: "json",
9577
+ ...params
9578
+ });
9377
9579
  /**
9378
9580
  * No description
9379
9581
  *
@@ -9407,6 +9609,22 @@ var Compliance = class {
9407
9609
  format: "json",
9408
9610
  ...params
9409
9611
  });
9612
+ /**
9613
+ * No description
9614
+ *
9615
+ * @tags compliance
9616
+ * @name ListDsr
9617
+ * @summary List a data subject's requests
9618
+ * @request GET:/api/v1/dsr
9619
+ * @secure
9620
+ */
9621
+ listDsr = (params = {}) => this.http.request({
9622
+ path: `/api/v1/dsr`,
9623
+ method: "GET",
9624
+ secure: true,
9625
+ format: "json",
9626
+ ...params
9627
+ });
9410
9628
  /**
9411
9629
  * No description
9412
9630
  *
@@ -9888,6 +10106,24 @@ var OntologyBridge = class {
9888
10106
  format: "json",
9889
10107
  ...params
9890
10108
  });
10109
+ /**
10110
+ * @description The gap this closes (#133): the engine could lower OSFQL to a source's native language and could execute native queries, and the two were never reachable together over HTTP. `POST /api/v1/osfql` runs against the knowledge base and never consults a binding; `POST /api/v1/ontology/transpile` emits the query text and stops. A `transpile`-mode source — which deliberately ingests nothing — therefore had no way to be queried at all, and asking about its data returned an empty result indistinguishable from a broken connector. The dialect is derived from the source's type, never taken from the caller: the binding says which source answers for the sort, and that source's type is the only dialect that could run. Letting a caller name one would let them ask for Cypher against Postgres. The emitted query is returned with the rows. Transpile mode's claim is that OSFQL becomes a native query against the operator's own database; returning only rows leaves that unverifiable.
10111
+ *
10112
+ * @tags ontology_bridge
10113
+ * @name ExecuteTranspiled
10114
+ * @summary Transpile an OSFQL MATCH and execute it on the source it is bound to.
10115
+ * @request POST:/api/v1/ontology/query
10116
+ * @secure
10117
+ */
10118
+ executeTranspiled = (data, params = {}) => this.http.request({
10119
+ path: `/api/v1/ontology/query`,
10120
+ method: "POST",
10121
+ body: data,
10122
+ secure: true,
10123
+ type: "application/json" /* Json */,
10124
+ format: "json",
10125
+ ...params
10126
+ });
9891
10127
  /**
9892
10128
  * @description Produces query tools, write tools, and inference tools from the current sort hierarchy and SQL bindings, along with a system prompt suitable for grounding an LLM.
9893
10129
  *
@@ -9957,7 +10193,7 @@ var OntologyBridge = class {
9957
10193
  ...params
9958
10194
  });
9959
10195
  /**
9960
- * @description Parses the OSFQL query, compiles it, and transpiles the first `ScanBySort` operation to SQL using the current sort-table bindings.
10196
+ * @description Parses the OSFQL query, compiles it, and transpiles EVERY `ScanBySort` operation into one statement using the current sort-table bindings — a JOIN for the SQL dialects, a multi-pattern MATCH for Cypher. A plan operation that is not a scan is refused by name rather than dropped: `fully_transpilable` is what a caller checks to decide whether the emitted text is the whole question, and it reported `true` for a query half of which was never emitted (#134).
9961
10197
  *
9962
10198
  * @tags ontology_bridge
9963
10199
  * @name Transpile
@@ -10256,6 +10492,24 @@ var Speakers = class {
10256
10492
  format: "json",
10257
10493
  ...params
10258
10494
  });
10495
+ /**
10496
+ * @description POST /api/v1/speakers/identify
10497
+ *
10498
+ * @tags speakers
10499
+ * @name IdentifySpeakers
10500
+ * @summary Identify which enrolled voices speak in a piece of audio — no transcript.
10501
+ * @request POST:/api/v1/speakers/identify
10502
+ * @secure
10503
+ */
10504
+ identifySpeakers = (data, params = {}) => this.http.request({
10505
+ path: `/api/v1/speakers/identify`,
10506
+ method: "POST",
10507
+ body: data,
10508
+ secure: true,
10509
+ type: "application/json" /* Json */,
10510
+ format: "json",
10511
+ ...params
10512
+ });
10259
10513
  /**
10260
10514
  * @description GET /api/v1/speakers
10261
10515
  *
@@ -10522,6 +10776,22 @@ var Documents = class {
10522
10776
  constructor(http) {
10523
10777
  this.http = http;
10524
10778
  }
10779
+ /**
10780
+ * No description
10781
+ *
10782
+ * @tags documents
10783
+ * @name EraseDocument
10784
+ * @summary Erase a document and everything extracted from it
10785
+ * @request DELETE:/api/v1/documents/{id}
10786
+ * @secure
10787
+ */
10788
+ eraseDocument = (id, params = {}) => this.http.request({
10789
+ path: `/api/v1/documents/${id}`,
10790
+ method: "DELETE",
10791
+ secure: true,
10792
+ format: "json",
10793
+ ...params
10794
+ });
10525
10795
  /**
10526
10796
  * No description
10527
10797
  *
@@ -11592,6 +11862,32 @@ var OntologyExport = class {
11592
11862
  });
11593
11863
  };
11594
11864
 
11865
+ // src/api-spec/generated/Embeddings.ts
11866
+ var Embeddings = class {
11867
+ http;
11868
+ constructor(http) {
11869
+ this.http = http;
11870
+ }
11871
+ /**
11872
+ * @description POST /api/v1/embeddings/rank
11873
+ *
11874
+ * @tags embeddings
11875
+ * @name RankEmbeddings
11876
+ * @summary Score every candidate against the query by embedding cosine similarity.
11877
+ * @request POST:/api/v1/embeddings/rank
11878
+ * @secure
11879
+ */
11880
+ rankEmbeddings = (data, params = {}) => this.http.request({
11881
+ path: `/api/v1/embeddings/rank`,
11882
+ method: "POST",
11883
+ body: data,
11884
+ secure: true,
11885
+ type: "application/json" /* Json */,
11886
+ format: "json",
11887
+ ...params
11888
+ });
11889
+ };
11890
+
11595
11891
  // src/normalizers/sorts.ts
11596
11892
  function ConstraintDtoFromApiToFront(dto) {
11597
11893
  if (dto.type === "FuzzyPathSimilarity") {
@@ -19740,20 +20036,21 @@ var IngestionSession = class {
19740
20036
  }));
19741
20037
  return;
19742
20038
  }
19743
- const timer = setTimeout(resolve, ms);
20039
+ let onAbort;
20040
+ const timer = setTimeout(() => {
20041
+ if (signal && onAbort) {
20042
+ signal.removeEventListener("abort", onAbort);
20043
+ }
20044
+ resolve();
20045
+ }, ms);
19744
20046
  if (signal) {
19745
- const onAbort = () => {
20047
+ onAbort = () => {
19746
20048
  clearTimeout(timer);
19747
20049
  reject(new ReasoningLayerError("Ingestion polling was aborted", {
19748
20050
  cause: signal.reason
19749
20051
  }));
19750
20052
  };
19751
20053
  signal.addEventListener("abort", onAbort, { once: true });
19752
- const originalResolve = resolve;
19753
- resolve = () => {
19754
- signal.removeEventListener("abort", onAbort);
19755
- originalResolve();
19756
- };
19757
20054
  }
19758
20055
  });
19759
20056
  }
@@ -20538,8 +20835,10 @@ function EvidenceAssessmentRequestFromFrontToApi(model) {
20538
20835
  };
20539
20836
  }
20540
20837
  function EvidenceItemDtoFromApiToFront(dto) {
20838
+ const wireDescription = dto.description;
20541
20839
  return {
20542
20840
  contribution: dto.contribution,
20841
+ description: wireDescription ?? null,
20543
20842
  qualityWeight: dto.quality_weight,
20544
20843
  supports: dto.supports,
20545
20844
  termId: dto.term_id
@@ -20694,6 +20993,13 @@ var ReasoningClient = class {
20694
20993
  /**
20695
20994
  * Assess the truthfulness/validity of a subject based on related evidence.
20696
20995
  *
20996
+ * @remarks
20997
+ * Each item in the supporting/contradicting breakdown carries a
20998
+ * `description` — the evidence term's own sentence,
20999
+ * e.g. `"Aspirin reduces_risk_of Cancer"` — so evidence can be rendered
21000
+ * without a second lookup by `termId`. It is `null` against a backend that
21001
+ * predates the field.
21002
+ *
20697
21003
  * @param request - Evidence assessment request.
20698
21004
  * @returns Assessment result with truthfulness score, label, and evidence breakdown.
20699
21005
  */
@@ -28748,7 +29054,15 @@ function PaperMetadataFromApiToFront(dto) {
28748
29054
  abstractText: dto.abstract_text ?? null,
28749
29055
  citationCount: dto.citation_count ?? null,
28750
29056
  source: dto.source,
28751
- fullTextUrl: dto.full_text_url ?? null
29057
+ fullTextUrl: dto.full_text_url ?? null,
29058
+ paperKey: dto.paper_key ?? null
29059
+ };
29060
+ }
29061
+ function PaperRefFromApiToFront(dto) {
29062
+ return {
29063
+ paperKey: dto.paper_key,
29064
+ doi: dto.doi ?? null,
29065
+ title: dto.title
28752
29066
  };
28753
29067
  }
28754
29068
  function PaperSearchResultFromApiToFront(dto) {
@@ -28782,6 +29096,8 @@ function ResearchCycleResultFromApiToFront(dto) {
28782
29096
  papersIngested: dto.papers_ingested,
28783
29097
  claimsVerified: dto.claims_verified,
28784
29098
  contradictionsDetected: dto.contradictions_detected,
29099
+ contradictionsResolved: dto.contradictions_resolved ?? 0,
29100
+ claimsMerged: dto.claims_merged ?? 0,
28785
29101
  processingTimeMs: dto.processing_time_ms,
28786
29102
  searchQueries: dto.search_queries ?? []
28787
29103
  };
@@ -28794,6 +29110,7 @@ function ResearchSessionResponseFromApiToFront(raw) {
28794
29110
  status: dto.status,
28795
29111
  error: dto.error ?? null,
28796
29112
  cycles: (dto.cycles ?? []).map(ResearchCycleResultFromApiToFront),
29113
+ papers: (dto.papers ?? []).map(PaperMetadataFromApiToFront),
28797
29114
  totalPapersIngested: dto.total_papers_ingested,
28798
29115
  totalFindings: dto.total_findings,
28799
29116
  totalContradictions: dto.total_contradictions,
@@ -28838,7 +29155,9 @@ function EvidenceItemSummaryFromApiToFront(dto) {
28838
29155
  qualityWeight: dto.quality_weight,
28839
29156
  supports: dto.supports,
28840
29157
  contribution: dto.contribution,
28841
- paperDoi: dto.paper_doi ?? null
29158
+ paperDoi: dto.paper_doi ?? null,
29159
+ paperKey: dto.paper_key ?? null,
29160
+ paperTitle: dto.paper_title ?? null
28842
29161
  };
28843
29162
  }
28844
29163
  function ProvenanceStepFromApiToFront(dto) {
@@ -28849,6 +29168,13 @@ function ProvenanceStepFromApiToFront(dto) {
28849
29168
  timestamp: dto.timestamp ?? null
28850
29169
  };
28851
29170
  }
29171
+ function ResiduatedFeatureFromApiToFront(dto) {
29172
+ return {
29173
+ featureName: dto.feature_name,
29174
+ neededSort: dto.needed_sort ?? null,
29175
+ infoGain: dto.info_gain
29176
+ };
29177
+ }
28852
29178
  function ResearchFindingFromApiToFront(dto) {
28853
29179
  return {
28854
29180
  claimId: dto.claim_id,
@@ -28859,7 +29185,9 @@ function ResearchFindingFromApiToFront(dto) {
28859
29185
  contradictingEvidence: (dto.contradicting_evidence ?? []).map(EvidenceItemSummaryFromApiToFront),
28860
29186
  provenanceChain: (dto.provenance_chain ?? []).map(ProvenanceStepFromApiToFront),
28861
29187
  residuated: dto.residuated,
28862
- residuationReason: dto.residuation_reason ?? null
29188
+ residuationReason: dto.residuation_reason ?? null,
29189
+ residuatedFeatures: (dto.residuated_features ?? []).map(ResiduatedFeatureFromApiToFront),
29190
+ sources: (dto.sources ?? []).map(PaperRefFromApiToFront)
28863
29191
  };
28864
29192
  }
28865
29193
  function ResearchFindingsResponseFromApiToFront(raw) {
@@ -28887,6 +29215,17 @@ function ResearchGapsResponseFromApiToFront(raw) {
28887
29215
  total: dto.total
28888
29216
  };
28889
29217
  }
29218
+ function ContradictionResolutionFromApiToFront(dto) {
29219
+ return {
29220
+ preferredClaimId: dto.preferred_claim_id,
29221
+ dismissedClaimId: dto.dismissed_claim_id,
29222
+ preferredTruthfulness: dto.preferred_truthfulness,
29223
+ dismissedTruthfulness: dto.dismissed_truthfulness,
29224
+ strategy: dto.strategy,
29225
+ confidence: dto.confidence,
29226
+ explanation: dto.explanation
29227
+ };
29228
+ }
28890
29229
  function ContradictionFromApiToFront(dto) {
28891
29230
  return {
28892
29231
  claimAId: dto.claim_a_id,
@@ -28894,7 +29233,10 @@ function ContradictionFromApiToFront(dto) {
28894
29233
  statementA: dto.statement_a,
28895
29234
  statementB: dto.statement_b,
28896
29235
  confidence: dto.confidence,
28897
- explanation: dto.explanation
29236
+ explanation: dto.explanation,
29237
+ resolution: dto.resolution ? ContradictionResolutionFromApiToFront(dto.resolution) : null,
29238
+ claimASources: (dto.claim_a_sources ?? []).map(PaperRefFromApiToFront),
29239
+ claimBSources: (dto.claim_b_sources ?? []).map(PaperRefFromApiToFront)
28898
29240
  };
28899
29241
  }
28900
29242
  function ResearchContradictionsResponseFromApiToFront(raw) {
@@ -28915,7 +29257,9 @@ function ResearchStatisticsFromApiToFront(dto) {
28915
29257
  totalContradictions: dto.total_contradictions,
28916
29258
  totalProcessingTimeMs: dto.total_processing_time_ms,
28917
29259
  gapsResolved: dto.gaps_resolved,
28918
- gapsRemaining: dto.gaps_remaining
29260
+ gapsRemaining: dto.gaps_remaining,
29261
+ claimsMerged: dto.claims_merged ?? 0,
29262
+ contradictionsResolved: dto.contradictions_resolved ?? 0
28919
29263
  };
28920
29264
  }
28921
29265
  function ReportVerificationFromApiToFront(dto) {
@@ -28991,7 +29335,8 @@ function IngestPaperRequestFromFrontToApi(model) {
28991
29335
  function VerifyClaimRequestFromFrontToApi(model) {
28992
29336
  return {
28993
29337
  claim_term_id: model.claimTermId,
28994
- evidence_sort_id: model.evidenceSortId
29338
+ evidence_sort_id: model.evidenceSortId,
29339
+ session_id: model.sessionId
28995
29340
  };
28996
29341
  }
28997
29342
 
@@ -36604,6 +36949,81 @@ var ConnectorsClient = class {
36604
36949
  }
36605
36950
  };
36606
36951
 
36952
+ // src/normalizers/embeddings.ts
36953
+ function EmbeddingRankRequestFromFrontToApi(model) {
36954
+ return {
36955
+ candidates: model.candidates ?? [],
36956
+ query: model.query
36957
+ };
36958
+ }
36959
+ function EmbeddingRankResponseFromApiToFront(dto) {
36960
+ return {
36961
+ scores: dto.scores ?? []
36962
+ };
36963
+ }
36964
+
36965
+ // src/resources/embeddings.ts
36966
+ var EmbeddingsClient = class {
36967
+ /** @internal */
36968
+ api;
36969
+ /** @internal */
36970
+ constructor(api) {
36971
+ this.api = api;
36972
+ }
36973
+ /**
36974
+ * Score every candidate against the query by embedding cosine similarity.
36975
+ *
36976
+ * @param request - The query and the candidate texts to score against it.
36977
+ * @returns `scores` — one cosine similarity in `[-1, 1]` per candidate,
36978
+ * **index-aligned with `request.candidates`** (index `i` scores
36979
+ * `candidates[i]`) and the same length, so the scores can be zipped straight
36980
+ * back onto whatever was retrieved. Higher is more similar; a candidate
36981
+ * whose text is blank scores `0`.
36982
+ * @throws {BadRequestError} `400` — the query is blank, the candidate list is
36983
+ * over the backend's 512-candidate cap, or the query / a candidate is over
36984
+ * 8192 characters.
36985
+ * @throws {ApiError} `503` when the deployment has **no embedding backend
36986
+ * configured** (or its embedder is unreachable / misconfigured). The SDK
36987
+ * surfaces every 5xx as an `InternalServerError`; read its `status` to tell
36988
+ * `503` (no embedder) from `500` (ranking failed).
36989
+ *
36990
+ * @remarks
36991
+ * Distinguish "no embedder" from "no similarity": a deployment without an
36992
+ * embedding backend answers `503` rather than a fabricated score, precisely so
36993
+ * a caller cannot mistake it for "everything scored 0" and silently rank by
36994
+ * noise. The documented fallback on a `503` is to keep the source order.
36995
+ *
36996
+ * An empty `candidates` list is valid, not an error: it answers `200` with an
36997
+ * empty `scores` array, so a caller that retrieved nothing still gets a
36998
+ * well-formed, index-aligned response.
36999
+ *
37000
+ * A `0` score is absence of signal, not evidence of dissimilarity — it is also
37001
+ * what an orthogonal candidate and a blank candidate both receive.
37002
+ *
37003
+ * @example
37004
+ * ```typescript
37005
+ * const retrieved = [
37006
+ * { id: 'doc-1', text: 'Chaperones assist protein folding in the cytosol.' },
37007
+ * { id: 'doc-2', text: 'Quarterly revenue rose 12% year over year.' },
37008
+ * ];
37009
+ *
37010
+ * const { scores } = await client.embeddings.rank({
37011
+ * query: 'how proteins fold',
37012
+ * candidates: retrieved.map((doc) => doc.text),
37013
+ * });
37014
+ *
37015
+ * // Scores are index-aligned — zip them back onto what was retrieved.
37016
+ * const ranked = retrieved
37017
+ * .map((doc, i) => ({ doc, score: scores[i] }))
37018
+ * .sort((a, b) => b.score - a.score);
37019
+ * ```
37020
+ */
37021
+ async rank(request) {
37022
+ const response = await this.api.rankEmbeddings(EmbeddingRankRequestFromFrontToApi(request));
37023
+ return EmbeddingRankResponseFromApiToFront(response.data);
37024
+ }
37025
+ };
37026
+
36607
37027
  // src/client.ts
36608
37028
  var ReasoningLayerClient = class {
36609
37029
  /** Sort (type hierarchy) operations. */
@@ -36790,6 +37210,8 @@ var ReasoningLayerClient = class {
36790
37210
  speech;
36791
37211
  /** External data connectors — register / list / remove / connect / disconnect + OAuth callback. */
36792
37212
  connectors;
37213
+ /** Embedding-space ranking — cosine score per candidate against a query, index-aligned. */
37214
+ embeddings;
36793
37215
  // ─── Group Caches ─────────────────────────────────────────────────
36794
37216
  _core;
36795
37217
  _ai;
@@ -37107,6 +37529,7 @@ var ReasoningLayerClient = class {
37107
37529
  this.speakers = new SpeakersClient(new Speakers(generatedHttp));
37108
37530
  this.speech = new SpeechClient(new Speech(generatedHttp));
37109
37531
  this.connectors = new ConnectorsClient(new Connectors(generatedHttp));
37532
+ this.embeddings = new EmbeddingsClient(new Embeddings(generatedHttp));
37110
37533
  }
37111
37534
  };
37112
37535
 
@@ -37390,6 +37813,9 @@ var speech_exports = {};
37390
37813
  // src/types/connectors.ts
37391
37814
  var connectors_exports = {};
37392
37815
 
37816
+ // src/types/embeddings.ts
37817
+ var embeddings_exports = {};
37818
+
37393
37819
  // src/builders/value.ts
37394
37820
  var Value = {
37395
37821
  /**
@@ -38395,6 +38821,6 @@ var Flow = {
38395
38821
  }
38396
38822
  };
38397
38823
 
38398
- export { ANY_ROLE, action_reviews_exports as ActionReviews, actions_exports as Actions, admin_exports as Admin, agui_exports as Agui, analysis_exports as Analysis, anonymization_exports as Anonymization, ApiError, AuthenticationError, authz_exports as Authz, BadRequestError, cdl_exports as CDL, causal_exports as Causal, chase_exports as Chase, cognitive_exports as Cognitive, coherence_exports as Coherence, collections_exports as Collections, communities_exports as Communities, compliance_exports as Compliance, compliance_markings_exports as ComplianceMarkings, conformal_exports as Conformal, conformance_exports as Conformance, connectors_exports as Connectors, Constraint, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, conversation_exports as Conversation, corpus_exports as Corpus, dl_exports as DL, demo_exports as Demo, discovery_exports as Discovery, document_check_exports as DocumentCheck, documents_exports as Documents, execution_exports as Execution, extract_exports as Extract, feasibility_exports as Feasibility, Flow, flow_networks_exports as FlowNetworks, ForbiddenError, forecast_exports as Forecast, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, guardrail_exports as Guardrail, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, IngestionFailedError, IngestionSession, InternalServerError, LP, ltn_exports as LTN, marketplace_exports as Marketplace, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, ontology_alignment_exports as OntologyAlignment, ontology_bridge_exports as OntologyBridge, ontology_export_exports as OntologyExport, ontology_facade_exports as OntologyFacade, operations_exports as Operations, optimize_exports as Optimize, osf_diff_exports as OsfDiff, osfql_exports as Osfql, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, property_graph_exports as PropertyGraph, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, research_exports as Research, reviews_exports as Reviews, reward_exports as Reward, row_exports as Row, SDK_VERSION, sat_exports as Sat, scenarios_exports as Scenarios, scheduling_exports as Scheduling, smt_exports as Smt, solver_exports as Solver, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, sparql_exports as Sparql, speakers_exports as Speakers, speech_exports as Speech, statistical_exports as Statistical, streaming_exports as Streaming, synthetic_exports as Synthetic, temporal_exports as Temporal, terms_exports as Terms, TimeoutError, translation_exports as Translation, ui_exports as UI, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, verification_exports as Verification, vision_exports as Vision, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
38824
+ export { ANY_ROLE, action_reviews_exports as ActionReviews, actions_exports as Actions, admin_exports as Admin, agui_exports as Agui, analysis_exports as Analysis, anonymization_exports as Anonymization, ApiError, AuthenticationError, authz_exports as Authz, BadRequestError, cdl_exports as CDL, causal_exports as Causal, chase_exports as Chase, cognitive_exports as Cognitive, coherence_exports as Coherence, collections_exports as Collections, communities_exports as Communities, compliance_exports as Compliance, compliance_markings_exports as ComplianceMarkings, conformal_exports as Conformal, conformance_exports as Conformance, connectors_exports as Connectors, Constraint, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, conversation_exports as Conversation, corpus_exports as Corpus, dl_exports as DL, demo_exports as Demo, discovery_exports as Discovery, document_check_exports as DocumentCheck, documents_exports as Documents, embeddings_exports as Embeddings, execution_exports as Execution, extract_exports as Extract, feasibility_exports as Feasibility, Flow, flow_networks_exports as FlowNetworks, ForbiddenError, forecast_exports as Forecast, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, guardrail_exports as Guardrail, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, IngestionFailedError, IngestionSession, InternalServerError, LP, ltn_exports as LTN, marketplace_exports as Marketplace, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, ontology_alignment_exports as OntologyAlignment, ontology_bridge_exports as OntologyBridge, ontology_export_exports as OntologyExport, ontology_facade_exports as OntologyFacade, operations_exports as Operations, optimize_exports as Optimize, osf_diff_exports as OsfDiff, osfql_exports as Osfql, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, property_graph_exports as PropertyGraph, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, research_exports as Research, reviews_exports as Reviews, reward_exports as Reward, row_exports as Row, SDK_VERSION, sat_exports as Sat, scenarios_exports as Scenarios, scheduling_exports as Scheduling, smt_exports as Smt, solver_exports as Solver, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, sparql_exports as Sparql, speakers_exports as Speakers, speech_exports as Speech, statistical_exports as Statistical, streaming_exports as Streaming, synthetic_exports as Synthetic, temporal_exports as Temporal, terms_exports as Terms, TimeoutError, translation_exports as Translation, ui_exports as UI, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, verification_exports as Verification, vision_exports as Vision, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
38399
38825
  //# sourceMappingURL=index.js.map
38400
38826
  //# sourceMappingURL=index.js.map