@kortexya/reasoninglayer 1.7.1 → 1.9.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.7.1";
10
+ var SDK_VERSION = "1.9.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -4356,9 +4356,10 @@ var Reviews = class {
4356
4356
  * @request GET:/api/v1/reviews/pending
4357
4357
  * @secure
4358
4358
  */
4359
- listPendingReviews = (params = {}) => this.http.request({
4359
+ listPendingReviews = (query, params = {}) => this.http.request({
4360
4360
  path: `/api/v1/reviews/pending`,
4361
4361
  method: "GET",
4362
+ query,
4362
4363
  secure: true,
4363
4364
  format: "json",
4364
4365
  ...params
@@ -5022,6 +5023,31 @@ var Extraction = class {
5022
5023
  });
5023
5024
  };
5024
5025
 
5026
+ // src/api-spec/generated/DocumentAnalysis.ts
5027
+ var DocumentAnalysis = class {
5028
+ http;
5029
+ constructor(http) {
5030
+ this.http = http;
5031
+ }
5032
+ /**
5033
+ * No description
5034
+ *
5035
+ * @tags document-analysis
5036
+ * @name AnalyzeDocuments
5037
+ * @request POST:/api/v1/documents/analyze
5038
+ * @secure
5039
+ */
5040
+ analyzeDocuments = (data, params = {}) => this.http.request({
5041
+ path: `/api/v1/documents/analyze`,
5042
+ method: "POST",
5043
+ body: data,
5044
+ secure: true,
5045
+ type: "application/json" /* Json */,
5046
+ format: "json",
5047
+ ...params
5048
+ });
5049
+ };
5050
+
5025
5051
  // src/api-spec/generated/Oversight.ts
5026
5052
  var Oversight = class {
5027
5053
  http;
@@ -11784,6 +11810,30 @@ function MarkMessagesReadResponseFromApiToFront(dto) {
11784
11810
  message: dto.message
11785
11811
  };
11786
11812
  }
11813
+ function GetInboxRequestFromFrontToApi(model) {
11814
+ return {
11815
+ agent_id: model.agentId,
11816
+ tenant_id: model.tenantId,
11817
+ include_read: model.includeRead
11818
+ };
11819
+ }
11820
+ function InboxMessageDtoFromApiToFront(dto) {
11821
+ return {
11822
+ messageId: dto.message_id,
11823
+ fromAgentId: dto.from_agent_id,
11824
+ content: dto.content,
11825
+ priority: dto.priority,
11826
+ timestamp: dto.timestamp,
11827
+ read: dto.read
11828
+ };
11829
+ }
11830
+ function GetInboxResponseFromApiToFront(dto) {
11831
+ return {
11832
+ messages: dto.messages.map(InboxMessageDtoFromApiToFront),
11833
+ unreadCount: dto.unread_count,
11834
+ totalCount: dto.total_count
11835
+ };
11836
+ }
11787
11837
  function ProvideFeedbackRequestFromFrontToApi(model) {
11788
11838
  return {
11789
11839
  agent_id: model.agentId,
@@ -11946,6 +11996,25 @@ var CognitiveClient = class {
11946
11996
  this.ws = ws ?? null;
11947
11997
  }
11948
11998
  // --- Agent CRUD ---
11999
+ /**
12000
+ * List all of the tenant's cognitive agents.
12001
+ *
12002
+ * @returns Every agent's basic BDI state (beliefs, goals, pending status).
12003
+ *
12004
+ * @remarks
12005
+ * Uses GET `/api/v1/cognitive/agents`. Lazy-hydrates from the database on the
12006
+ * backend, so agents created by another client/process are included — not just
12007
+ * those created in the current session. Tenant is identified by the
12008
+ * `X-Tenant-Id` header (set automatically).
12009
+ */
12010
+ async listAgents() {
12011
+ const response = await this.api.http.request({
12012
+ path: `/api/v1/cognitive/agents`,
12013
+ method: "GET",
12014
+ format: "json"
12015
+ });
12016
+ return response.data.agents.map(AgentStateDtoFromApiToFront);
12017
+ }
11949
12018
  /**
11950
12019
  * Create a new cognitive agent.
11951
12020
  *
@@ -12173,6 +12242,20 @@ var CognitiveClient = class {
12173
12242
  const response = await this.messaging.markMessagesRead(MarkMessagesReadRequestFromFrontToApi({ ...request, tenantId: this.tenantId }));
12174
12243
  return MarkMessagesReadResponseFromApiToFront(response.data);
12175
12244
  }
12245
+ /**
12246
+ * Get an agent's inbox (messages addressed to it from other agents).
12247
+ *
12248
+ * @param request - Recipient agent ID and whether to include read messages.
12249
+ * @returns The agent's messages with unread/total counts.
12250
+ *
12251
+ * @remarks
12252
+ * Uses POST `/api/v1/cognitive/agents/messages/inbox`. The inbox is per-agent;
12253
+ * aggregate across a roster by calling this for each agent.
12254
+ */
12255
+ async getInbox(request) {
12256
+ const response = await this.messaging.getInbox(GetInboxRequestFromFrontToApi({ ...request, tenantId: this.tenantId }));
12257
+ return GetInboxResponseFromApiToFront(response.data);
12258
+ }
12176
12259
  // --- Feedback ---
12177
12260
  /**
12178
12261
  * Provide feedback on an agent result.
@@ -15342,9 +15425,14 @@ function RejectEntityRequestFromFrontToApi(model) {
15342
15425
  var ReviewsClient = class {
15343
15426
  /** @internal */
15344
15427
  api;
15428
+ /** @internal — tenant scope; forwarded as the `tenant_id` query the
15429
+ * pending-reviews / summary endpoints require (the `X-Tenant-Id` header
15430
+ * alone is not sufficient for these GET routes). */
15431
+ tenantId;
15345
15432
  /** @internal */
15346
- constructor(api) {
15433
+ constructor(api, tenantId) {
15347
15434
  this.api = api;
15435
+ this.tenantId = tenantId;
15348
15436
  }
15349
15437
  /**
15350
15438
  * Add an entity to the pending review queue.
@@ -15417,12 +15505,16 @@ var ReviewsClient = class {
15417
15505
  return response.data;
15418
15506
  }
15419
15507
  /**
15420
- * List all pending reviews.
15508
+ * List all pending reviews for the configured tenant.
15509
+ *
15510
+ * `GET /api/v1/reviews/pending` requires `tenant_id` as a query parameter
15511
+ * (the `X-Tenant-Id` header is not honoured for this route), so we forward
15512
+ * the client's tenant scope explicitly — omitting it yields a 400.
15421
15513
  *
15422
15514
  * @returns List of pending review entries.
15423
15515
  */
15424
15516
  async listPending() {
15425
- const response = await this.api.listPendingReviews();
15517
+ const response = await this.api.listPendingReviews({ tenant_id: this.tenantId });
15426
15518
  return response.data;
15427
15519
  }
15428
15520
  /**
@@ -18421,6 +18513,94 @@ var ExtractClient = class {
18421
18513
  }
18422
18514
  };
18423
18515
 
18516
+ // src/normalizers/documents.ts
18517
+ function AnalyzeDocumentsRequestFromFrontToApi(model) {
18518
+ return {
18519
+ documents: model.documents.map((d) => ({
18520
+ name: d.name,
18521
+ content: d.content,
18522
+ type_hint: d.typeHint ?? null
18523
+ })),
18524
+ rule_sort_filter: model.ruleSortFilter ?? [],
18525
+ include_proof_traces: model.includeProofTraces ?? true,
18526
+ include_fix_suggestions: model.includeFixSuggestions ?? true,
18527
+ max_rules: model.maxRules ?? 0
18528
+ };
18529
+ }
18530
+ function mapProofStep(s) {
18531
+ return {
18532
+ stepType: s.step_type ?? "",
18533
+ description: s.description ?? "",
18534
+ confidence: s.confidence ?? 0,
18535
+ ruleUsed: s.rule_used ?? null
18536
+ };
18537
+ }
18538
+ function mapEntity(e) {
18539
+ return {
18540
+ sortName: e.sort_name ?? "",
18541
+ features: e.features ?? {},
18542
+ confidence: e.confidence ?? 0,
18543
+ sourceText: e.source_text ?? null
18544
+ };
18545
+ }
18546
+ function mapRuleResult(r) {
18547
+ return {
18548
+ ruleId: r.rule_id ?? "",
18549
+ ruleDescription: r.rule_description ?? "",
18550
+ ruleSort: r.rule_sort ?? "",
18551
+ severity: r.severity ?? "informational",
18552
+ status: r.status ?? "inconclusive",
18553
+ confidence: r.confidence ?? 0,
18554
+ evidence: r.evidence ?? [],
18555
+ proofTrace: r.proof_trace ? r.proof_trace.map(mapProofStep) : null,
18556
+ fixSuggestion: r.fix_suggestion ?? null,
18557
+ relevantExcerpt: r.relevant_excerpt ?? null
18558
+ };
18559
+ }
18560
+ function mapDocument(d) {
18561
+ return {
18562
+ documentName: d.document_name ?? "",
18563
+ detectedType: d.detected_type ?? null,
18564
+ complianceScore: d.compliance_score ?? 0,
18565
+ ruleResults: (d.rule_results ?? []).map(mapRuleResult),
18566
+ extractedEntities: (d.extracted_entities ?? []).map(mapEntity),
18567
+ summary: d.summary ?? ""
18568
+ };
18569
+ }
18570
+ function DocumentAnalysisResponseFromApiToFront(dto) {
18571
+ return {
18572
+ documents: dto.documents.map(mapDocument),
18573
+ overallCompliance: dto.overall_compliance,
18574
+ totalRulesEvaluated: dto.total_rules_evaluated,
18575
+ totalRulesPassed: dto.total_rules_passed,
18576
+ totalRulesFailed: dto.total_rules_failed
18577
+ };
18578
+ }
18579
+
18580
+ // src/resources/documents.ts
18581
+ var DocumentsClient = class {
18582
+ /** @internal */
18583
+ api;
18584
+ /** @internal */
18585
+ constructor(api) {
18586
+ this.api = api;
18587
+ }
18588
+ /**
18589
+ * Analyse documents against the knowledge base's compliance rules.
18590
+ *
18591
+ * @param request - Documents (name + content) plus optional rule-sort focus.
18592
+ * @param options - Per-call options (e.g. an {@link AbortSignal} to cancel).
18593
+ * @returns Per-document rule results, scores, entities and proof traces.
18594
+ */
18595
+ async analyze(request, options) {
18596
+ const response = await this.api.analyzeDocuments(
18597
+ AnalyzeDocumentsRequestFromFrontToApi(request),
18598
+ { signal: options?.signal }
18599
+ );
18600
+ return DocumentAnalysisResponseFromApiToFront(response.data);
18601
+ }
18602
+ };
18603
+
18424
18604
  // src/normalizers/oversight.ts
18425
18605
  function TrajectoryStepDtoFromFrontToApi(model) {
18426
18606
  return {
@@ -22370,6 +22550,42 @@ function UICustomizationDtoFromApiToFront(dto) {
22370
22550
  params: dto.params
22371
22551
  };
22372
22552
  }
22553
+ function CognitiveStrategyDtoFromApiToFront(dto) {
22554
+ return {
22555
+ mode: dto.mode,
22556
+ strategy: dto.strategy,
22557
+ rlActive: dto.rl_active
22558
+ };
22559
+ }
22560
+ function MatchedEntityDtoFromApiToFront2(dto) {
22561
+ return {
22562
+ name: dto.name,
22563
+ sortName: dto.sort_name,
22564
+ termId: dto.term_id ?? void 0,
22565
+ confidence: dto.confidence,
22566
+ matchReason: dto.match_reason
22567
+ };
22568
+ }
22569
+ function ReasoningStageDtoFromApiToFront(dto) {
22570
+ return {
22571
+ name: dto.name,
22572
+ order: dto.order,
22573
+ kind: dto.kind,
22574
+ sensorPoint: dto.sensor_point ?? void 0,
22575
+ llmUsed: dto.llm_used,
22576
+ confidence: dto.confidence ?? void 0,
22577
+ matchedEntities: dto.matched_entities?.map(MatchedEntityDtoFromApiToFront2) ?? [],
22578
+ osfql: dto.osfql ?? void 0,
22579
+ strategy: dto.strategy ?? void 0,
22580
+ detail: dto.detail ?? void 0
22581
+ };
22582
+ }
22583
+ function ReasoningTraceDtoFromApiToFront(dto) {
22584
+ return {
22585
+ stages: dto.stages.map(ReasoningStageDtoFromApiToFront),
22586
+ llmCalls: dto.llm_calls
22587
+ };
22588
+ }
22373
22589
  function ConversationMessageResponseFromApiToFront(dto) {
22374
22590
  return {
22375
22591
  assistantMessage: dto.assistant_message,
@@ -22385,6 +22601,8 @@ function ConversationMessageResponseFromApiToFront(dto) {
22385
22601
  claimAnnotations: dto.claim_annotations?.map(ClaimAnnotationDtoFromApiToFront) ?? void 0,
22386
22602
  proofTrace: dto.proof_trace ? ProofTraceNodeDtoFromApiToFront(dto.proof_trace) : void 0,
22387
22603
  uiCustomizations: dto.ui_customizations?.map(UICustomizationDtoFromApiToFront) ?? void 0,
22604
+ cognitiveStrategy: dto.cognitive_strategy ? CognitiveStrategyDtoFromApiToFront(dto.cognitive_strategy) : void 0,
22605
+ reasoningTrace: dto.reasoning_trace ? ReasoningTraceDtoFromApiToFront(dto.reasoning_trace) : void 0,
22388
22606
  validityCertificateHash: dto.validity_certificate_hash ?? void 0,
22389
22607
  validityCertificateId: dto.validity_certificate_id ?? void 0
22390
22608
  };
@@ -22599,6 +22817,64 @@ var ConversationClient = class {
22599
22817
  }
22600
22818
  };
22601
22819
 
22820
+ // src/normalizers/verification.ts
22821
+ function CertificateDetailFromApiToFront(dto) {
22822
+ const wire = dto;
22823
+ const verdict = wire.verdict ?? {};
22824
+ const verdictTag = Object.keys(verdict)[0] ?? "Unknown";
22825
+ const residuated = verdict["Residuated"];
22826
+ return {
22827
+ certificateId: wire.certificate_id,
22828
+ propertyLabel: wire.property_label,
22829
+ method: wire.method ?? void 0,
22830
+ contentSha256Hex: wire.content_sha256_hex,
22831
+ verdict: verdictTag,
22832
+ verdictPartial: typeof residuated?.partial === "number" ? residuated.partial : void 0,
22833
+ ruleProgramHash: wire.rule_program_hash ?? void 0,
22834
+ ruleRevision: wire.rule_revision ?? void 0
22835
+ };
22836
+ }
22837
+
22838
+ // src/resources/verification.ts
22839
+ var VerificationClient = class {
22840
+ /** @internal */
22841
+ http;
22842
+ /** @internal */
22843
+ constructor(http) {
22844
+ this.http = http;
22845
+ }
22846
+ /**
22847
+ * Fetch a validity certificate by id.
22848
+ *
22849
+ * @param certificateId - The certificate id (an answer's `validityCertificateId`).
22850
+ * @returns The certificate's verdict, content hash, proof method and rule-program pin.
22851
+ * @throws {ApiError} If the certificate is unknown (`404`) or the request fails.
22852
+ *
22853
+ * @remarks
22854
+ * A `404` is expected when the id is a prose-provenance fallback certificate
22855
+ * (not persisted in the verification store) rather than an OSFQL-soundness one —
22856
+ * treat it as "no per-answer certificate available".
22857
+ *
22858
+ * @example
22859
+ * ```typescript
22860
+ * const answer = await client.conversation.sendMessage({ message, generateCertificate: true });
22861
+ * if (answer.validityCertificateId) {
22862
+ * const cert = await client.verification.getCertificate(answer.validityCertificateId);
22863
+ * console.log(cert.verdict, cert.contentSha256Hex);
22864
+ * }
22865
+ * ```
22866
+ */
22867
+ async getCertificate(certificateId) {
22868
+ const response = await this.http.request({
22869
+ path: `/api/v1/verification/certificates/${encodeURIComponent(certificateId)}`,
22870
+ method: "GET",
22871
+ secure: true,
22872
+ format: "json"
22873
+ });
22874
+ return CertificateDetailFromApiToFront(response.data);
22875
+ }
22876
+ };
22877
+
22602
22878
  // src/resources/research.ts
22603
22879
  var ResearchClient = class {
22604
22880
  /** @internal */
@@ -24954,6 +25230,8 @@ var ReasoningLayerClient = class {
24954
25230
  discovery;
24955
25231
  /** Entity extraction operations. */
24956
25232
  extract;
25233
+ /** Document compliance analysis (check document content against KB rules). */
25234
+ documents;
24957
25235
  /** FormalJudge oversight operations (safety verification, refinement). */
24958
25236
  oversight;
24959
25237
  /** Categorical Deep Learning operations (differentiable FC, soft unification, safety). */
@@ -24994,6 +25272,8 @@ var ReasoningLayerClient = class {
24994
25272
  osfql;
24995
25273
  /** Conversational AI operations (NL → OSFQL with self-correction). */
24996
25274
  conversation;
25275
+ /** Validity-certificate lookup (per-answer soundness seals). */
25276
+ verification;
24997
25277
  /** Verified scientific research pipeline operations. */
24998
25278
  research;
24999
25279
  /** Knowledge graph context assembly operations (LLM prompt building). */
@@ -25175,6 +25455,7 @@ var ReasoningLayerClient = class {
25175
25455
  const generatedActionReviews = new ActionReviews(generatedHttp);
25176
25456
  const generatedDiscovery = new Discovery(generatedHttp);
25177
25457
  const generatedExtraction = new Extraction(generatedHttp);
25458
+ const generatedDocumentAnalysis = new DocumentAnalysis(generatedHttp);
25178
25459
  const generatedOversight = new Oversight(generatedHttp);
25179
25460
  const generatedCdl = new Cdl(generatedHttp);
25180
25461
  const generatedPreferences = new Preferences(generatedHttp);
@@ -25212,7 +25493,7 @@ var ReasoningLayerClient = class {
25212
25493
  this.execution = new ExecutionClient(generatedExecution);
25213
25494
  this.causal = new CausalClient(generatedCausal);
25214
25495
  this.ingestion = new IngestionClient(generatedIngestion);
25215
- this.reviews = new ReviewsClient(generatedReviews);
25496
+ this.reviews = new ReviewsClient(generatedReviews, resolved.tenantId);
25216
25497
  this.visualization = new VisualizationClient(generatedVisualization);
25217
25498
  this.ilp = new IlpClient(generatedIlp);
25218
25499
  this.reasoning = new ReasoningClient(generatedReasoning);
@@ -25227,6 +25508,7 @@ var ReasoningLayerClient = class {
25227
25508
  this.actionReviews = new ActionReviewsClient(generatedActionReviews, resolved.tenantId);
25228
25509
  this.discovery = new DiscoveryClient(generatedDiscovery);
25229
25510
  this.extract = new ExtractClient(generatedExtraction);
25511
+ this.documents = new DocumentsClient(generatedDocumentAnalysis);
25230
25512
  this.oversight = new OversightClient(generatedOversight);
25231
25513
  this.cdl = new CdlClient(generatedCdl);
25232
25514
  this.neuroSymbolic = new NeuroSymbolicClient(generatedNeuroSymbolic);
@@ -25247,6 +25529,7 @@ var ReasoningLayerClient = class {
25247
25529
  this.flowNetworks = new FlowNetworksClient(new FlowNetworks(generatedHttp));
25248
25530
  this.osfql = new OsfqlClient(generatedOsfql);
25249
25531
  this.conversation = new ConversationClient(generatedHttp);
25532
+ this.verification = new VerificationClient(generatedHttp);
25250
25533
  this.research = new ResearchClient(generatedHttp);
25251
25534
  const generatedContext = new Context(generatedHttp);
25252
25535
  const generatedRlTraining = new RlTraining(generatedHttp);
@@ -25350,6 +25633,9 @@ var discovery_exports = {};
25350
25633
  // src/types/extract.ts
25351
25634
  var extract_exports = {};
25352
25635
 
25636
+ // src/types/documents.ts
25637
+ var documents_exports = {};
25638
+
25353
25639
  // src/types/oversight.ts
25354
25640
  var oversight_exports = {};
25355
25641
 
@@ -25420,6 +25706,9 @@ var osfql_exports = {};
25420
25706
  // src/types/conversation.ts
25421
25707
  var conversation_exports = {};
25422
25708
 
25709
+ // src/types/verification.ts
25710
+ var verification_exports = {};
25711
+
25423
25712
  // src/types/compliance.ts
25424
25713
  var compliance_exports = {};
25425
25714
 
@@ -26502,6 +26791,7 @@ exports.Constraints = constraints_exports;
26502
26791
  exports.Control = control_exports;
26503
26792
  exports.Conversation = conversation_exports;
26504
26793
  exports.Discovery = discovery_exports;
26794
+ exports.Documents = documents_exports;
26505
26795
  exports.Execution = execution_exports;
26506
26796
  exports.Extract = extract_exports;
26507
26797
  exports.Feasibility = feasibility_exports;
@@ -26562,6 +26852,7 @@ exports.Utilities = utilities_exports;
26562
26852
  exports.ValidationError = ValidationError;
26563
26853
  exports.Value = Value;
26564
26854
  exports.Values = values_exports;
26855
+ exports.Verification = verification_exports;
26565
26856
  exports.Visualization = visualization_exports;
26566
26857
  exports.WebSocketClient = WebSocketClient;
26567
26858
  exports.WebSocketConnection = WebSocketConnection;