@kortexya/reasoninglayer 1.8.1 → 1.10.1
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 +261 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +261 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/config.ts
|
|
10
|
-
var SDK_VERSION = "1.
|
|
10
|
+
var SDK_VERSION = "1.10.1";
|
|
11
11
|
function resolveConfig(config) {
|
|
12
12
|
if (!config.baseUrl) {
|
|
13
13
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -18589,11 +18589,13 @@ var DocumentsClient = class {
|
|
|
18589
18589
|
* Analyse documents against the knowledge base's compliance rules.
|
|
18590
18590
|
*
|
|
18591
18591
|
* @param request - Documents (name + content) plus optional rule-sort focus.
|
|
18592
|
+
* @param options - Per-call options (e.g. an {@link AbortSignal} to cancel).
|
|
18592
18593
|
* @returns Per-document rule results, scores, entities and proof traces.
|
|
18593
18594
|
*/
|
|
18594
|
-
async analyze(request) {
|
|
18595
|
+
async analyze(request, options) {
|
|
18595
18596
|
const response = await this.api.analyzeDocuments(
|
|
18596
|
-
AnalyzeDocumentsRequestFromFrontToApi(request)
|
|
18597
|
+
AnalyzeDocumentsRequestFromFrontToApi(request),
|
|
18598
|
+
{ signal: options?.signal }
|
|
18597
18599
|
);
|
|
18598
18600
|
return DocumentAnalysisResponseFromApiToFront(response.data);
|
|
18599
18601
|
}
|
|
@@ -22873,6 +22875,246 @@ var VerificationClient = class {
|
|
|
22873
22875
|
}
|
|
22874
22876
|
};
|
|
22875
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 ResearchCycleResponseFromApiToFront(raw) {
|
|
22946
|
+
const dto = raw;
|
|
22947
|
+
return {
|
|
22948
|
+
sessionId: dto.session_id,
|
|
22949
|
+
status: dto.status,
|
|
22950
|
+
cycle: ResearchCycleResultFromApiToFront(dto.cycle),
|
|
22951
|
+
converged: dto.converged
|
|
22952
|
+
};
|
|
22953
|
+
}
|
|
22954
|
+
function EvidenceItemSummaryFromApiToFront(dto) {
|
|
22955
|
+
return {
|
|
22956
|
+
termId: dto.term_id,
|
|
22957
|
+
description: dto.description,
|
|
22958
|
+
qualityWeight: dto.quality_weight,
|
|
22959
|
+
supports: dto.supports,
|
|
22960
|
+
contribution: dto.contribution,
|
|
22961
|
+
paperDoi: dto.paper_doi ?? null
|
|
22962
|
+
};
|
|
22963
|
+
}
|
|
22964
|
+
function ProvenanceStepFromApiToFront(dto) {
|
|
22965
|
+
return {
|
|
22966
|
+
stepType: dto.step_type,
|
|
22967
|
+
description: dto.description,
|
|
22968
|
+
entityId: dto.entity_id ?? null,
|
|
22969
|
+
timestamp: dto.timestamp ?? null
|
|
22970
|
+
};
|
|
22971
|
+
}
|
|
22972
|
+
function ResearchFindingFromApiToFront(dto) {
|
|
22973
|
+
return {
|
|
22974
|
+
claimId: dto.claim_id,
|
|
22975
|
+
statement: dto.statement,
|
|
22976
|
+
truthfulness: dto.truthfulness,
|
|
22977
|
+
label: dto.label,
|
|
22978
|
+
supportingEvidence: (dto.supporting_evidence ?? []).map(EvidenceItemSummaryFromApiToFront),
|
|
22979
|
+
contradictingEvidence: (dto.contradicting_evidence ?? []).map(EvidenceItemSummaryFromApiToFront),
|
|
22980
|
+
provenanceChain: (dto.provenance_chain ?? []).map(ProvenanceStepFromApiToFront),
|
|
22981
|
+
residuated: dto.residuated,
|
|
22982
|
+
residuationReason: dto.residuation_reason ?? null
|
|
22983
|
+
};
|
|
22984
|
+
}
|
|
22985
|
+
function ResearchFindingsResponseFromApiToFront(raw) {
|
|
22986
|
+
const dto = raw;
|
|
22987
|
+
return {
|
|
22988
|
+
sessionId: dto.session_id,
|
|
22989
|
+
findings: (dto.findings ?? []).map(ResearchFindingFromApiToFront),
|
|
22990
|
+
total: dto.total
|
|
22991
|
+
};
|
|
22992
|
+
}
|
|
22993
|
+
function KnowledgeGapFromApiToFront(dto) {
|
|
22994
|
+
return {
|
|
22995
|
+
sortName: dto.sort_name,
|
|
22996
|
+
infoGain: dto.info_gain,
|
|
22997
|
+
neededBy: dto.needed_by ?? [],
|
|
22998
|
+
wakeTrigger: dto.wake_trigger,
|
|
22999
|
+
suggestedSearchQuery: dto.suggested_search_query ?? null
|
|
23000
|
+
};
|
|
23001
|
+
}
|
|
23002
|
+
function ResearchGapsResponseFromApiToFront(raw) {
|
|
23003
|
+
const dto = raw;
|
|
23004
|
+
return {
|
|
23005
|
+
sessionId: dto.session_id,
|
|
23006
|
+
gaps: (dto.gaps ?? []).map(KnowledgeGapFromApiToFront),
|
|
23007
|
+
total: dto.total
|
|
23008
|
+
};
|
|
23009
|
+
}
|
|
23010
|
+
function ContradictionFromApiToFront(dto) {
|
|
23011
|
+
return {
|
|
23012
|
+
claimAId: dto.claim_a_id,
|
|
23013
|
+
claimBId: dto.claim_b_id,
|
|
23014
|
+
statementA: dto.statement_a,
|
|
23015
|
+
statementB: dto.statement_b,
|
|
23016
|
+
confidence: dto.confidence,
|
|
23017
|
+
explanation: dto.explanation
|
|
23018
|
+
};
|
|
23019
|
+
}
|
|
23020
|
+
function ResearchContradictionsResponseFromApiToFront(raw) {
|
|
23021
|
+
const dto = raw;
|
|
23022
|
+
return {
|
|
23023
|
+
sessionId: dto.session_id,
|
|
23024
|
+
contradictions: (dto.contradictions ?? []).map(ContradictionFromApiToFront),
|
|
23025
|
+
total: dto.total
|
|
23026
|
+
};
|
|
23027
|
+
}
|
|
23028
|
+
function ResearchStatisticsFromApiToFront(dto) {
|
|
23029
|
+
return {
|
|
23030
|
+
totalCycles: dto.total_cycles,
|
|
23031
|
+
totalPapersRetrieved: dto.total_papers_retrieved,
|
|
23032
|
+
totalPapersIngested: dto.total_papers_ingested,
|
|
23033
|
+
totalClaimsExtracted: dto.total_claims_extracted,
|
|
23034
|
+
totalClaimsVerified: dto.total_claims_verified,
|
|
23035
|
+
totalContradictions: dto.total_contradictions,
|
|
23036
|
+
totalProcessingTimeMs: dto.total_processing_time_ms,
|
|
23037
|
+
gapsResolved: dto.gaps_resolved,
|
|
23038
|
+
gapsRemaining: dto.gaps_remaining
|
|
23039
|
+
};
|
|
23040
|
+
}
|
|
23041
|
+
function ReportVerificationFromApiToFront(dto) {
|
|
23042
|
+
return {
|
|
23043
|
+
verdict: dto.verdict,
|
|
23044
|
+
score: dto.score,
|
|
23045
|
+
computationTimeMs: dto.computation_time_ms
|
|
23046
|
+
};
|
|
23047
|
+
}
|
|
23048
|
+
function ResearchReportResponseFromApiToFront(raw) {
|
|
23049
|
+
const dto = raw;
|
|
23050
|
+
return {
|
|
23051
|
+
sessionId: dto.session_id,
|
|
23052
|
+
question: dto.question,
|
|
23053
|
+
summary: dto.summary,
|
|
23054
|
+
findings: (dto.findings ?? []).map(ResearchFindingFromApiToFront),
|
|
23055
|
+
knowledgeGaps: (dto.knowledge_gaps ?? []).map(KnowledgeGapFromApiToFront),
|
|
23056
|
+
contradictions: (dto.contradictions ?? []).map(ContradictionFromApiToFront),
|
|
23057
|
+
statistics: ResearchStatisticsFromApiToFront(dto.statistics),
|
|
23058
|
+
generatedContent: dto.generated_content ?? null,
|
|
23059
|
+
verification: dto.verification ? ReportVerificationFromApiToFront(dto.verification) : null
|
|
23060
|
+
};
|
|
23061
|
+
}
|
|
23062
|
+
function IngestPaperResponseFromApiToFront(raw) {
|
|
23063
|
+
const dto = raw;
|
|
23064
|
+
return {
|
|
23065
|
+
success: dto.success,
|
|
23066
|
+
metadata: dto.metadata ? PaperMetadataFromApiToFront(dto.metadata) : null,
|
|
23067
|
+
entitiesExtracted: dto.entities_extracted,
|
|
23068
|
+
claimsExtracted: dto.claims_extracted,
|
|
23069
|
+
error: dto.error ?? null
|
|
23070
|
+
};
|
|
23071
|
+
}
|
|
23072
|
+
function VerifyClaimResponseFromApiToFront(raw) {
|
|
23073
|
+
const dto = raw;
|
|
23074
|
+
return {
|
|
23075
|
+
truthfulness: dto.truthfulness,
|
|
23076
|
+
label: dto.label,
|
|
23077
|
+
supportingCount: dto.supporting_count,
|
|
23078
|
+
contradictingCount: dto.contradicting_count,
|
|
23079
|
+
residuated: dto.residuated,
|
|
23080
|
+
residuationReason: dto.residuation_reason ?? null
|
|
23081
|
+
};
|
|
23082
|
+
}
|
|
23083
|
+
function CreateResearchSessionRequestFromFrontToApi(model) {
|
|
23084
|
+
return {
|
|
23085
|
+
question: model.question,
|
|
23086
|
+
max_cycles: model.maxCycles,
|
|
23087
|
+
max_papers: model.maxPapers,
|
|
23088
|
+
paper_sources: model.paperSources
|
|
23089
|
+
};
|
|
23090
|
+
}
|
|
23091
|
+
function RunResearchCycleRequestFromFrontToApi(model) {
|
|
23092
|
+
return {
|
|
23093
|
+
additional_queries: model.additionalQueries,
|
|
23094
|
+
max_papers_this_cycle: model.maxPapersThisCycle
|
|
23095
|
+
};
|
|
23096
|
+
}
|
|
23097
|
+
function SearchPapersRequestFromFrontToApi(model) {
|
|
23098
|
+
return {
|
|
23099
|
+
query: model.query,
|
|
23100
|
+
max_results: model.maxResults,
|
|
23101
|
+
sources: model.sources
|
|
23102
|
+
};
|
|
23103
|
+
}
|
|
23104
|
+
function IngestPaperRequestFromFrontToApi(model) {
|
|
23105
|
+
return {
|
|
23106
|
+
identifier: model.identifier,
|
|
23107
|
+
identifier_type: model.identifierType,
|
|
23108
|
+
session_id: model.sessionId
|
|
23109
|
+
};
|
|
23110
|
+
}
|
|
23111
|
+
function VerifyClaimRequestFromFrontToApi(model) {
|
|
23112
|
+
return {
|
|
23113
|
+
claim_term_id: model.claimTermId,
|
|
23114
|
+
evidence_sort_id: model.evidenceSortId
|
|
23115
|
+
};
|
|
23116
|
+
}
|
|
23117
|
+
|
|
22876
23118
|
// src/resources/research.ts
|
|
22877
23119
|
var ResearchClient = class {
|
|
22878
23120
|
/** @internal */
|
|
@@ -22909,12 +23151,12 @@ var ResearchClient = class {
|
|
|
22909
23151
|
const response = await this.http.request({
|
|
22910
23152
|
path: "/api/v1/research/sessions",
|
|
22911
23153
|
method: "POST",
|
|
22912
|
-
body: request,
|
|
23154
|
+
body: CreateResearchSessionRequestFromFrontToApi(request),
|
|
22913
23155
|
secure: true,
|
|
22914
23156
|
type: "application/json" /* Json */,
|
|
22915
23157
|
format: "json"
|
|
22916
23158
|
});
|
|
22917
|
-
return response.data;
|
|
23159
|
+
return CreateResearchSessionResponseFromApiToFront(response.data);
|
|
22918
23160
|
}
|
|
22919
23161
|
/**
|
|
22920
23162
|
* Get the current state of a research session.
|
|
@@ -22944,7 +23186,7 @@ var ResearchClient = class {
|
|
|
22944
23186
|
secure: true,
|
|
22945
23187
|
format: "json"
|
|
22946
23188
|
});
|
|
22947
|
-
return response.data;
|
|
23189
|
+
return ResearchSessionResponseFromApiToFront(response.data);
|
|
22948
23190
|
}
|
|
22949
23191
|
/**
|
|
22950
23192
|
* Run a single research cycle within a session.
|
|
@@ -22975,12 +23217,12 @@ var ResearchClient = class {
|
|
|
22975
23217
|
const response = await this.http.request({
|
|
22976
23218
|
path: `/api/v1/research/sessions/${encodeURIComponent(sessionId)}/run`,
|
|
22977
23219
|
method: "POST",
|
|
22978
|
-
body: request,
|
|
23220
|
+
body: request ? RunResearchCycleRequestFromFrontToApi(request) : void 0,
|
|
22979
23221
|
secure: true,
|
|
22980
23222
|
type: "application/json" /* Json */,
|
|
22981
23223
|
format: "json"
|
|
22982
23224
|
});
|
|
22983
|
-
return response.data;
|
|
23225
|
+
return ResearchCycleResponseFromApiToFront(response.data);
|
|
22984
23226
|
}
|
|
22985
23227
|
/**
|
|
22986
23228
|
* Run the research session to completion (all remaining cycles).
|
|
@@ -23009,7 +23251,7 @@ var ResearchClient = class {
|
|
|
23009
23251
|
secure: true,
|
|
23010
23252
|
format: "json"
|
|
23011
23253
|
});
|
|
23012
|
-
return response.data;
|
|
23254
|
+
return ResearchSessionResponseFromApiToFront(response.data);
|
|
23013
23255
|
}
|
|
23014
23256
|
/**
|
|
23015
23257
|
* Delete a research session and all associated data.
|
|
@@ -23062,7 +23304,7 @@ var ResearchClient = class {
|
|
|
23062
23304
|
secure: true,
|
|
23063
23305
|
format: "json"
|
|
23064
23306
|
});
|
|
23065
|
-
return response.data;
|
|
23307
|
+
return ResearchFindingsResponseFromApiToFront(response.data);
|
|
23066
23308
|
}
|
|
23067
23309
|
/**
|
|
23068
23310
|
* Get knowledge gaps for a research session.
|
|
@@ -23095,7 +23337,7 @@ var ResearchClient = class {
|
|
|
23095
23337
|
secure: true,
|
|
23096
23338
|
format: "json"
|
|
23097
23339
|
});
|
|
23098
|
-
return response.data;
|
|
23340
|
+
return ResearchGapsResponseFromApiToFront(response.data);
|
|
23099
23341
|
}
|
|
23100
23342
|
/**
|
|
23101
23343
|
* Get detected contradictions for a research session.
|
|
@@ -23127,7 +23369,7 @@ var ResearchClient = class {
|
|
|
23127
23369
|
secure: true,
|
|
23128
23370
|
format: "json"
|
|
23129
23371
|
});
|
|
23130
|
-
return response.data;
|
|
23372
|
+
return ResearchContradictionsResponseFromApiToFront(response.data);
|
|
23131
23373
|
}
|
|
23132
23374
|
/**
|
|
23133
23375
|
* Get the full research report for a session.
|
|
@@ -23161,7 +23403,7 @@ var ResearchClient = class {
|
|
|
23161
23403
|
secure: true,
|
|
23162
23404
|
format: "json"
|
|
23163
23405
|
});
|
|
23164
|
-
return response.data;
|
|
23406
|
+
return ResearchReportResponseFromApiToFront(response.data);
|
|
23165
23407
|
}
|
|
23166
23408
|
/**
|
|
23167
23409
|
* Search for papers across external scientific databases.
|
|
@@ -23193,12 +23435,12 @@ var ResearchClient = class {
|
|
|
23193
23435
|
const response = await this.http.request({
|
|
23194
23436
|
path: "/api/v1/research/papers/search",
|
|
23195
23437
|
method: "POST",
|
|
23196
|
-
body: request,
|
|
23438
|
+
body: SearchPapersRequestFromFrontToApi(request),
|
|
23197
23439
|
secure: true,
|
|
23198
23440
|
type: "application/json" /* Json */,
|
|
23199
23441
|
format: "json"
|
|
23200
23442
|
});
|
|
23201
|
-
return response.data;
|
|
23443
|
+
return SearchPapersResponseFromApiToFront(response.data);
|
|
23202
23444
|
}
|
|
23203
23445
|
/**
|
|
23204
23446
|
* Ingest a specific paper into the knowledge base.
|
|
@@ -23230,12 +23472,12 @@ var ResearchClient = class {
|
|
|
23230
23472
|
const response = await this.http.request({
|
|
23231
23473
|
path: "/api/v1/research/papers/ingest",
|
|
23232
23474
|
method: "POST",
|
|
23233
|
-
body: request,
|
|
23475
|
+
body: IngestPaperRequestFromFrontToApi(request),
|
|
23234
23476
|
secure: true,
|
|
23235
23477
|
type: "application/json" /* Json */,
|
|
23236
23478
|
format: "json"
|
|
23237
23479
|
});
|
|
23238
|
-
return response.data;
|
|
23480
|
+
return IngestPaperResponseFromApiToFront(response.data);
|
|
23239
23481
|
}
|
|
23240
23482
|
/**
|
|
23241
23483
|
* Verify a specific claim against evidence in the knowledge base.
|
|
@@ -23268,12 +23510,12 @@ var ResearchClient = class {
|
|
|
23268
23510
|
const response = await this.http.request({
|
|
23269
23511
|
path: "/api/v1/research/claims/verify",
|
|
23270
23512
|
method: "POST",
|
|
23271
|
-
body: request,
|
|
23513
|
+
body: VerifyClaimRequestFromFrontToApi(request),
|
|
23272
23514
|
secure: true,
|
|
23273
23515
|
type: "application/json" /* Json */,
|
|
23274
23516
|
format: "json"
|
|
23275
23517
|
});
|
|
23276
|
-
return response.data;
|
|
23518
|
+
return VerifyClaimResponseFromApiToFront(response.data);
|
|
23277
23519
|
}
|
|
23278
23520
|
};
|
|
23279
23521
|
|