@kortexya/reasoninglayer 1.17.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.17.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");
@@ -6377,7 +6377,7 @@ var Query = class {
6377
6377
  this.http = http;
6378
6378
  }
6379
6379
  /**
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.
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.
6381
6381
  *
6382
6382
  * @tags query
6383
6383
  * @name FindBySort
@@ -11862,6 +11862,32 @@ var OntologyExport = class {
11862
11862
  });
11863
11863
  };
11864
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
+
11865
11891
  // src/normalizers/sorts.ts
11866
11892
  function ConstraintDtoFromApiToFront(dto) {
11867
11893
  if (dto.type === "FuzzyPathSimilarity") {
@@ -20809,8 +20835,10 @@ function EvidenceAssessmentRequestFromFrontToApi(model) {
20809
20835
  };
20810
20836
  }
20811
20837
  function EvidenceItemDtoFromApiToFront(dto) {
20838
+ const wireDescription = dto.description;
20812
20839
  return {
20813
20840
  contribution: dto.contribution,
20841
+ description: wireDescription ?? null,
20814
20842
  qualityWeight: dto.quality_weight,
20815
20843
  supports: dto.supports,
20816
20844
  termId: dto.term_id
@@ -20965,6 +20993,13 @@ var ReasoningClient = class {
20965
20993
  /**
20966
20994
  * Assess the truthfulness/validity of a subject based on related evidence.
20967
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
+ *
20968
21003
  * @param request - Evidence assessment request.
20969
21004
  * @returns Assessment result with truthfulness score, label, and evidence breakdown.
20970
21005
  */
@@ -29300,7 +29335,8 @@ function IngestPaperRequestFromFrontToApi(model) {
29300
29335
  function VerifyClaimRequestFromFrontToApi(model) {
29301
29336
  return {
29302
29337
  claim_term_id: model.claimTermId,
29303
- evidence_sort_id: model.evidenceSortId
29338
+ evidence_sort_id: model.evidenceSortId,
29339
+ session_id: model.sessionId
29304
29340
  };
29305
29341
  }
29306
29342
 
@@ -36913,6 +36949,81 @@ var ConnectorsClient = class {
36913
36949
  }
36914
36950
  };
36915
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
+
36916
37027
  // src/client.ts
36917
37028
  var ReasoningLayerClient = class {
36918
37029
  /** Sort (type hierarchy) operations. */
@@ -37099,6 +37210,8 @@ var ReasoningLayerClient = class {
37099
37210
  speech;
37100
37211
  /** External data connectors — register / list / remove / connect / disconnect + OAuth callback. */
37101
37212
  connectors;
37213
+ /** Embedding-space ranking — cosine score per candidate against a query, index-aligned. */
37214
+ embeddings;
37102
37215
  // ─── Group Caches ─────────────────────────────────────────────────
37103
37216
  _core;
37104
37217
  _ai;
@@ -37416,6 +37529,7 @@ var ReasoningLayerClient = class {
37416
37529
  this.speakers = new SpeakersClient(new Speakers(generatedHttp));
37417
37530
  this.speech = new SpeechClient(new Speech(generatedHttp));
37418
37531
  this.connectors = new ConnectorsClient(new Connectors(generatedHttp));
37532
+ this.embeddings = new EmbeddingsClient(new Embeddings(generatedHttp));
37419
37533
  }
37420
37534
  };
37421
37535
 
@@ -37699,6 +37813,9 @@ var speech_exports = {};
37699
37813
  // src/types/connectors.ts
37700
37814
  var connectors_exports = {};
37701
37815
 
37816
+ // src/types/embeddings.ts
37817
+ var embeddings_exports = {};
37818
+
37702
37819
  // src/builders/value.ts
37703
37820
  var Value = {
37704
37821
  /**
@@ -38704,6 +38821,6 @@ var Flow = {
38704
38821
  }
38705
38822
  };
38706
38823
 
38707
- 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 };
38708
38825
  //# sourceMappingURL=index.js.map
38709
38826
  //# sourceMappingURL=index.js.map