@kortexya/reasoninglayer 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/config.ts
10
- var SDK_VERSION = "1.9.0";
10
+ var SDK_VERSION = "1.11.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -22875,6 +22875,266 @@ var VerificationClient = class {
22875
22875
  }
22876
22876
  };
22877
22877
 
22878
+ // src/normalizers/research.ts
22879
+ function PaperMetadataFromApiToFront(dto) {
22880
+ return {
22881
+ title: dto.title,
22882
+ authors: dto.authors,
22883
+ doi: dto.doi ?? null,
22884
+ pmid: dto.pmid ?? null,
22885
+ arxivId: dto.arxiv_id ?? null,
22886
+ journal: dto.journal ?? null,
22887
+ year: dto.year ?? null,
22888
+ abstractText: dto.abstract_text ?? null,
22889
+ citationCount: dto.citation_count ?? null,
22890
+ source: dto.source,
22891
+ fullTextUrl: dto.full_text_url ?? null
22892
+ };
22893
+ }
22894
+ function PaperSearchResultFromApiToFront(dto) {
22895
+ return {
22896
+ metadata: PaperMetadataFromApiToFront(dto.metadata),
22897
+ relevanceScore: dto.relevance_score ?? null
22898
+ };
22899
+ }
22900
+ function SearchPapersResponseFromApiToFront(raw) {
22901
+ const dto = raw;
22902
+ return {
22903
+ results: (dto.results ?? []).map(PaperSearchResultFromApiToFront),
22904
+ totalFound: dto.total_found
22905
+ };
22906
+ }
22907
+ function CreateResearchSessionResponseFromApiToFront(raw) {
22908
+ const dto = raw;
22909
+ return {
22910
+ sessionId: dto.session_id,
22911
+ status: dto.status,
22912
+ question: dto.question,
22913
+ createdAt: dto.created_at
22914
+ };
22915
+ }
22916
+ function ResearchCycleResultFromApiToFront(dto) {
22917
+ return {
22918
+ cycleNumber: dto.cycle_number,
22919
+ gapsDetected: dto.gaps_detected,
22920
+ gapsResolved: dto.gaps_resolved,
22921
+ papersRetrieved: dto.papers_retrieved,
22922
+ papersIngested: dto.papers_ingested,
22923
+ claimsVerified: dto.claims_verified,
22924
+ contradictionsDetected: dto.contradictions_detected,
22925
+ processingTimeMs: dto.processing_time_ms,
22926
+ searchQueries: dto.search_queries ?? []
22927
+ };
22928
+ }
22929
+ function ResearchSessionResponseFromApiToFront(raw) {
22930
+ const dto = raw;
22931
+ return {
22932
+ sessionId: dto.session_id,
22933
+ question: dto.question,
22934
+ status: dto.status,
22935
+ error: dto.error ?? null,
22936
+ cycles: (dto.cycles ?? []).map(ResearchCycleResultFromApiToFront),
22937
+ totalPapersIngested: dto.total_papers_ingested,
22938
+ totalFindings: dto.total_findings,
22939
+ totalContradictions: dto.total_contradictions,
22940
+ totalGaps: dto.total_gaps,
22941
+ createdAt: dto.created_at,
22942
+ updatedAt: dto.updated_at
22943
+ };
22944
+ }
22945
+ function ResearchSessionSummaryFromApiToFront(raw) {
22946
+ const dto = raw;
22947
+ return {
22948
+ sessionId: dto.session_id,
22949
+ question: dto.question,
22950
+ status: dto.status,
22951
+ totalPapersIngested: dto.total_papers_ingested,
22952
+ totalFindings: dto.total_findings,
22953
+ totalContradictions: dto.total_contradictions,
22954
+ totalGaps: dto.total_gaps,
22955
+ createdAt: dto.created_at,
22956
+ updatedAt: dto.updated_at
22957
+ };
22958
+ }
22959
+ function ListResearchSessionsResponseFromApiToFront(raw) {
22960
+ const dto = raw;
22961
+ return {
22962
+ sessions: (dto.sessions ?? []).map(ResearchSessionSummaryFromApiToFront)
22963
+ };
22964
+ }
22965
+ function ResearchCycleResponseFromApiToFront(raw) {
22966
+ const dto = raw;
22967
+ return {
22968
+ sessionId: dto.session_id,
22969
+ status: dto.status,
22970
+ cycle: ResearchCycleResultFromApiToFront(dto.cycle),
22971
+ converged: dto.converged
22972
+ };
22973
+ }
22974
+ function EvidenceItemSummaryFromApiToFront(dto) {
22975
+ return {
22976
+ termId: dto.term_id,
22977
+ description: dto.description,
22978
+ qualityWeight: dto.quality_weight,
22979
+ supports: dto.supports,
22980
+ contribution: dto.contribution,
22981
+ paperDoi: dto.paper_doi ?? null
22982
+ };
22983
+ }
22984
+ function ProvenanceStepFromApiToFront(dto) {
22985
+ return {
22986
+ stepType: dto.step_type,
22987
+ description: dto.description,
22988
+ entityId: dto.entity_id ?? null,
22989
+ timestamp: dto.timestamp ?? null
22990
+ };
22991
+ }
22992
+ function ResearchFindingFromApiToFront(dto) {
22993
+ return {
22994
+ claimId: dto.claim_id,
22995
+ statement: dto.statement,
22996
+ truthfulness: dto.truthfulness,
22997
+ label: dto.label,
22998
+ supportingEvidence: (dto.supporting_evidence ?? []).map(EvidenceItemSummaryFromApiToFront),
22999
+ contradictingEvidence: (dto.contradicting_evidence ?? []).map(EvidenceItemSummaryFromApiToFront),
23000
+ provenanceChain: (dto.provenance_chain ?? []).map(ProvenanceStepFromApiToFront),
23001
+ residuated: dto.residuated,
23002
+ residuationReason: dto.residuation_reason ?? null
23003
+ };
23004
+ }
23005
+ function ResearchFindingsResponseFromApiToFront(raw) {
23006
+ const dto = raw;
23007
+ return {
23008
+ sessionId: dto.session_id,
23009
+ findings: (dto.findings ?? []).map(ResearchFindingFromApiToFront),
23010
+ total: dto.total
23011
+ };
23012
+ }
23013
+ function KnowledgeGapFromApiToFront(dto) {
23014
+ return {
23015
+ sortName: dto.sort_name,
23016
+ infoGain: dto.info_gain,
23017
+ neededBy: dto.needed_by ?? [],
23018
+ wakeTrigger: dto.wake_trigger,
23019
+ suggestedSearchQuery: dto.suggested_search_query ?? null
23020
+ };
23021
+ }
23022
+ function ResearchGapsResponseFromApiToFront(raw) {
23023
+ const dto = raw;
23024
+ return {
23025
+ sessionId: dto.session_id,
23026
+ gaps: (dto.gaps ?? []).map(KnowledgeGapFromApiToFront),
23027
+ total: dto.total
23028
+ };
23029
+ }
23030
+ function ContradictionFromApiToFront(dto) {
23031
+ return {
23032
+ claimAId: dto.claim_a_id,
23033
+ claimBId: dto.claim_b_id,
23034
+ statementA: dto.statement_a,
23035
+ statementB: dto.statement_b,
23036
+ confidence: dto.confidence,
23037
+ explanation: dto.explanation
23038
+ };
23039
+ }
23040
+ function ResearchContradictionsResponseFromApiToFront(raw) {
23041
+ const dto = raw;
23042
+ return {
23043
+ sessionId: dto.session_id,
23044
+ contradictions: (dto.contradictions ?? []).map(ContradictionFromApiToFront),
23045
+ total: dto.total
23046
+ };
23047
+ }
23048
+ function ResearchStatisticsFromApiToFront(dto) {
23049
+ return {
23050
+ totalCycles: dto.total_cycles,
23051
+ totalPapersRetrieved: dto.total_papers_retrieved,
23052
+ totalPapersIngested: dto.total_papers_ingested,
23053
+ totalClaimsExtracted: dto.total_claims_extracted,
23054
+ totalClaimsVerified: dto.total_claims_verified,
23055
+ totalContradictions: dto.total_contradictions,
23056
+ totalProcessingTimeMs: dto.total_processing_time_ms,
23057
+ gapsResolved: dto.gaps_resolved,
23058
+ gapsRemaining: dto.gaps_remaining
23059
+ };
23060
+ }
23061
+ function ReportVerificationFromApiToFront(dto) {
23062
+ return {
23063
+ verdict: dto.verdict,
23064
+ score: dto.score,
23065
+ computationTimeMs: dto.computation_time_ms
23066
+ };
23067
+ }
23068
+ function ResearchReportResponseFromApiToFront(raw) {
23069
+ const dto = raw;
23070
+ return {
23071
+ sessionId: dto.session_id,
23072
+ question: dto.question,
23073
+ summary: dto.summary,
23074
+ findings: (dto.findings ?? []).map(ResearchFindingFromApiToFront),
23075
+ knowledgeGaps: (dto.knowledge_gaps ?? []).map(KnowledgeGapFromApiToFront),
23076
+ contradictions: (dto.contradictions ?? []).map(ContradictionFromApiToFront),
23077
+ statistics: ResearchStatisticsFromApiToFront(dto.statistics),
23078
+ generatedContent: dto.generated_content ?? null,
23079
+ verification: dto.verification ? ReportVerificationFromApiToFront(dto.verification) : null
23080
+ };
23081
+ }
23082
+ function IngestPaperResponseFromApiToFront(raw) {
23083
+ const dto = raw;
23084
+ return {
23085
+ success: dto.success,
23086
+ metadata: dto.metadata ? PaperMetadataFromApiToFront(dto.metadata) : null,
23087
+ entitiesExtracted: dto.entities_extracted,
23088
+ claimsExtracted: dto.claims_extracted,
23089
+ error: dto.error ?? null
23090
+ };
23091
+ }
23092
+ function VerifyClaimResponseFromApiToFront(raw) {
23093
+ const dto = raw;
23094
+ return {
23095
+ truthfulness: dto.truthfulness,
23096
+ label: dto.label,
23097
+ supportingCount: dto.supporting_count,
23098
+ contradictingCount: dto.contradicting_count,
23099
+ residuated: dto.residuated,
23100
+ residuationReason: dto.residuation_reason ?? null
23101
+ };
23102
+ }
23103
+ function CreateResearchSessionRequestFromFrontToApi(model) {
23104
+ return {
23105
+ question: model.question,
23106
+ max_cycles: model.maxCycles,
23107
+ max_papers: model.maxPapers,
23108
+ paper_sources: model.paperSources
23109
+ };
23110
+ }
23111
+ function RunResearchCycleRequestFromFrontToApi(model) {
23112
+ return {
23113
+ additional_queries: model.additionalQueries,
23114
+ max_papers_this_cycle: model.maxPapersThisCycle
23115
+ };
23116
+ }
23117
+ function SearchPapersRequestFromFrontToApi(model) {
23118
+ return {
23119
+ query: model.query,
23120
+ max_results: model.maxResults,
23121
+ sources: model.sources
23122
+ };
23123
+ }
23124
+ function IngestPaperRequestFromFrontToApi(model) {
23125
+ return {
23126
+ identifier: model.identifier,
23127
+ identifier_type: model.identifierType,
23128
+ session_id: model.sessionId
23129
+ };
23130
+ }
23131
+ function VerifyClaimRequestFromFrontToApi(model) {
23132
+ return {
23133
+ claim_term_id: model.claimTermId,
23134
+ evidence_sort_id: model.evidenceSortId
23135
+ };
23136
+ }
23137
+
22878
23138
  // src/resources/research.ts
22879
23139
  var ResearchClient = class {
22880
23140
  /** @internal */
@@ -22911,12 +23171,12 @@ var ResearchClient = class {
22911
23171
  const response = await this.http.request({
22912
23172
  path: "/api/v1/research/sessions",
22913
23173
  method: "POST",
22914
- body: request,
23174
+ body: CreateResearchSessionRequestFromFrontToApi(request),
22915
23175
  secure: true,
22916
23176
  type: "application/json" /* Json */,
22917
23177
  format: "json"
22918
23178
  });
22919
- return response.data;
23179
+ return CreateResearchSessionResponseFromApiToFront(response.data);
22920
23180
  }
22921
23181
  /**
22922
23182
  * Get the current state of a research session.
@@ -22946,7 +23206,31 @@ var ResearchClient = class {
22946
23206
  secure: true,
22947
23207
  format: "json"
22948
23208
  });
22949
- return response.data;
23209
+ return ResearchSessionResponseFromApiToFront(response.data);
23210
+ }
23211
+ /**
23212
+ * List the current tenant's research sessions, newest first.
23213
+ *
23214
+ * Tenant-scoped via the `X-Tenant-Id` header (set on the client), mirroring
23215
+ * how conversations are listed. Returns lightweight summaries — use
23216
+ * {@link getSession} / {@link getReport} for a session's full detail.
23217
+ *
23218
+ * @returns The tenant's session summaries.
23219
+ *
23220
+ * @example
23221
+ * ```ts
23222
+ * const { sessions } = await client.research.listSessions();
23223
+ * sessions.forEach((s) => console.log(s.sessionId, s.status, s.question));
23224
+ * ```
23225
+ */
23226
+ async listSessions() {
23227
+ const response = await this.http.request({
23228
+ path: `/api/v1/research/sessions`,
23229
+ method: "GET",
23230
+ secure: true,
23231
+ format: "json"
23232
+ });
23233
+ return ListResearchSessionsResponseFromApiToFront(response.data);
22950
23234
  }
22951
23235
  /**
22952
23236
  * Run a single research cycle within a session.
@@ -22977,12 +23261,12 @@ var ResearchClient = class {
22977
23261
  const response = await this.http.request({
22978
23262
  path: `/api/v1/research/sessions/${encodeURIComponent(sessionId)}/run`,
22979
23263
  method: "POST",
22980
- body: request,
23264
+ body: request ? RunResearchCycleRequestFromFrontToApi(request) : void 0,
22981
23265
  secure: true,
22982
23266
  type: "application/json" /* Json */,
22983
23267
  format: "json"
22984
23268
  });
22985
- return response.data;
23269
+ return ResearchCycleResponseFromApiToFront(response.data);
22986
23270
  }
22987
23271
  /**
22988
23272
  * Run the research session to completion (all remaining cycles).
@@ -23011,7 +23295,7 @@ var ResearchClient = class {
23011
23295
  secure: true,
23012
23296
  format: "json"
23013
23297
  });
23014
- return response.data;
23298
+ return ResearchSessionResponseFromApiToFront(response.data);
23015
23299
  }
23016
23300
  /**
23017
23301
  * Delete a research session and all associated data.
@@ -23064,7 +23348,7 @@ var ResearchClient = class {
23064
23348
  secure: true,
23065
23349
  format: "json"
23066
23350
  });
23067
- return response.data;
23351
+ return ResearchFindingsResponseFromApiToFront(response.data);
23068
23352
  }
23069
23353
  /**
23070
23354
  * Get knowledge gaps for a research session.
@@ -23097,7 +23381,7 @@ var ResearchClient = class {
23097
23381
  secure: true,
23098
23382
  format: "json"
23099
23383
  });
23100
- return response.data;
23384
+ return ResearchGapsResponseFromApiToFront(response.data);
23101
23385
  }
23102
23386
  /**
23103
23387
  * Get detected contradictions for a research session.
@@ -23129,7 +23413,7 @@ var ResearchClient = class {
23129
23413
  secure: true,
23130
23414
  format: "json"
23131
23415
  });
23132
- return response.data;
23416
+ return ResearchContradictionsResponseFromApiToFront(response.data);
23133
23417
  }
23134
23418
  /**
23135
23419
  * Get the full research report for a session.
@@ -23163,7 +23447,7 @@ var ResearchClient = class {
23163
23447
  secure: true,
23164
23448
  format: "json"
23165
23449
  });
23166
- return response.data;
23450
+ return ResearchReportResponseFromApiToFront(response.data);
23167
23451
  }
23168
23452
  /**
23169
23453
  * Search for papers across external scientific databases.
@@ -23195,12 +23479,12 @@ var ResearchClient = class {
23195
23479
  const response = await this.http.request({
23196
23480
  path: "/api/v1/research/papers/search",
23197
23481
  method: "POST",
23198
- body: request,
23482
+ body: SearchPapersRequestFromFrontToApi(request),
23199
23483
  secure: true,
23200
23484
  type: "application/json" /* Json */,
23201
23485
  format: "json"
23202
23486
  });
23203
- return response.data;
23487
+ return SearchPapersResponseFromApiToFront(response.data);
23204
23488
  }
23205
23489
  /**
23206
23490
  * Ingest a specific paper into the knowledge base.
@@ -23232,12 +23516,12 @@ var ResearchClient = class {
23232
23516
  const response = await this.http.request({
23233
23517
  path: "/api/v1/research/papers/ingest",
23234
23518
  method: "POST",
23235
- body: request,
23519
+ body: IngestPaperRequestFromFrontToApi(request),
23236
23520
  secure: true,
23237
23521
  type: "application/json" /* Json */,
23238
23522
  format: "json"
23239
23523
  });
23240
- return response.data;
23524
+ return IngestPaperResponseFromApiToFront(response.data);
23241
23525
  }
23242
23526
  /**
23243
23527
  * Verify a specific claim against evidence in the knowledge base.
@@ -23270,12 +23554,12 @@ var ResearchClient = class {
23270
23554
  const response = await this.http.request({
23271
23555
  path: "/api/v1/research/claims/verify",
23272
23556
  method: "POST",
23273
- body: request,
23557
+ body: VerifyClaimRequestFromFrontToApi(request),
23274
23558
  secure: true,
23275
23559
  type: "application/json" /* Json */,
23276
23560
  format: "json"
23277
23561
  });
23278
- return response.data;
23562
+ return VerifyClaimResponseFromApiToFront(response.data);
23279
23563
  }
23280
23564
  };
23281
23565