@kortexya/reasoninglayer 1.7.0 → 1.8.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 CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/config.ts
10
- var SDK_VERSION = "1.7.0";
10
+ var SDK_VERSION = "1.8.1";
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;
@@ -10247,6 +10273,8 @@ function ProofDtoFromApiToFront(dto) {
10247
10273
  return {
10248
10274
  goalTermId: dto.goal_term_id,
10249
10275
  ruleTermId: dto.rule_term_id,
10276
+ goalDisplay: dto.goal_display,
10277
+ ruleLabel: dto.rule_label,
10250
10278
  substitution: HomoiconicSubstitutionDtoFromApiToFront(dto.substitution),
10251
10279
  subproofs: dto.subproofs?.map(ProofDtoFromApiToFront),
10252
10280
  certainty: dto.certainty
@@ -11782,6 +11810,30 @@ function MarkMessagesReadResponseFromApiToFront(dto) {
11782
11810
  message: dto.message
11783
11811
  };
11784
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
+ }
11785
11837
  function ProvideFeedbackRequestFromFrontToApi(model) {
11786
11838
  return {
11787
11839
  agent_id: model.agentId,
@@ -11944,6 +11996,25 @@ var CognitiveClient = class {
11944
11996
  this.ws = ws ?? null;
11945
11997
  }
11946
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
+ }
11947
12018
  /**
11948
12019
  * Create a new cognitive agent.
11949
12020
  *
@@ -12171,6 +12242,20 @@ var CognitiveClient = class {
12171
12242
  const response = await this.messaging.markMessagesRead(MarkMessagesReadRequestFromFrontToApi({ ...request, tenantId: this.tenantId }));
12172
12243
  return MarkMessagesReadResponseFromApiToFront(response.data);
12173
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
+ }
12174
12259
  // --- Feedback ---
12175
12260
  /**
12176
12261
  * Provide feedback on an agent result.
@@ -15340,9 +15425,14 @@ function RejectEntityRequestFromFrontToApi(model) {
15340
15425
  var ReviewsClient = class {
15341
15426
  /** @internal */
15342
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;
15343
15432
  /** @internal */
15344
- constructor(api) {
15433
+ constructor(api, tenantId) {
15345
15434
  this.api = api;
15435
+ this.tenantId = tenantId;
15346
15436
  }
15347
15437
  /**
15348
15438
  * Add an entity to the pending review queue.
@@ -15415,12 +15505,16 @@ var ReviewsClient = class {
15415
15505
  return response.data;
15416
15506
  }
15417
15507
  /**
15418
- * 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.
15419
15513
  *
15420
15514
  * @returns List of pending review entries.
15421
15515
  */
15422
15516
  async listPending() {
15423
- const response = await this.api.listPendingReviews();
15517
+ const response = await this.api.listPendingReviews({ tenant_id: this.tenantId });
15424
15518
  return response.data;
15425
15519
  }
15426
15520
  /**
@@ -18419,6 +18513,92 @@ var ExtractClient = class {
18419
18513
  }
18420
18514
  };
18421
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
+ * @returns Per-document rule results, scores, entities and proof traces.
18593
+ */
18594
+ async analyze(request) {
18595
+ const response = await this.api.analyzeDocuments(
18596
+ AnalyzeDocumentsRequestFromFrontToApi(request)
18597
+ );
18598
+ return DocumentAnalysisResponseFromApiToFront(response.data);
18599
+ }
18600
+ };
18601
+
18422
18602
  // src/normalizers/oversight.ts
18423
18603
  function TrajectoryStepDtoFromFrontToApi(model) {
18424
18604
  return {
@@ -22368,6 +22548,42 @@ function UICustomizationDtoFromApiToFront(dto) {
22368
22548
  params: dto.params
22369
22549
  };
22370
22550
  }
22551
+ function CognitiveStrategyDtoFromApiToFront(dto) {
22552
+ return {
22553
+ mode: dto.mode,
22554
+ strategy: dto.strategy,
22555
+ rlActive: dto.rl_active
22556
+ };
22557
+ }
22558
+ function MatchedEntityDtoFromApiToFront2(dto) {
22559
+ return {
22560
+ name: dto.name,
22561
+ sortName: dto.sort_name,
22562
+ termId: dto.term_id ?? void 0,
22563
+ confidence: dto.confidence,
22564
+ matchReason: dto.match_reason
22565
+ };
22566
+ }
22567
+ function ReasoningStageDtoFromApiToFront(dto) {
22568
+ return {
22569
+ name: dto.name,
22570
+ order: dto.order,
22571
+ kind: dto.kind,
22572
+ sensorPoint: dto.sensor_point ?? void 0,
22573
+ llmUsed: dto.llm_used,
22574
+ confidence: dto.confidence ?? void 0,
22575
+ matchedEntities: dto.matched_entities?.map(MatchedEntityDtoFromApiToFront2) ?? [],
22576
+ osfql: dto.osfql ?? void 0,
22577
+ strategy: dto.strategy ?? void 0,
22578
+ detail: dto.detail ?? void 0
22579
+ };
22580
+ }
22581
+ function ReasoningTraceDtoFromApiToFront(dto) {
22582
+ return {
22583
+ stages: dto.stages.map(ReasoningStageDtoFromApiToFront),
22584
+ llmCalls: dto.llm_calls
22585
+ };
22586
+ }
22371
22587
  function ConversationMessageResponseFromApiToFront(dto) {
22372
22588
  return {
22373
22589
  assistantMessage: dto.assistant_message,
@@ -22383,6 +22599,8 @@ function ConversationMessageResponseFromApiToFront(dto) {
22383
22599
  claimAnnotations: dto.claim_annotations?.map(ClaimAnnotationDtoFromApiToFront) ?? void 0,
22384
22600
  proofTrace: dto.proof_trace ? ProofTraceNodeDtoFromApiToFront(dto.proof_trace) : void 0,
22385
22601
  uiCustomizations: dto.ui_customizations?.map(UICustomizationDtoFromApiToFront) ?? void 0,
22602
+ cognitiveStrategy: dto.cognitive_strategy ? CognitiveStrategyDtoFromApiToFront(dto.cognitive_strategy) : void 0,
22603
+ reasoningTrace: dto.reasoning_trace ? ReasoningTraceDtoFromApiToFront(dto.reasoning_trace) : void 0,
22386
22604
  validityCertificateHash: dto.validity_certificate_hash ?? void 0,
22387
22605
  validityCertificateId: dto.validity_certificate_id ?? void 0
22388
22606
  };
@@ -22597,6 +22815,64 @@ var ConversationClient = class {
22597
22815
  }
22598
22816
  };
22599
22817
 
22818
+ // src/normalizers/verification.ts
22819
+ function CertificateDetailFromApiToFront(dto) {
22820
+ const wire = dto;
22821
+ const verdict = wire.verdict ?? {};
22822
+ const verdictTag = Object.keys(verdict)[0] ?? "Unknown";
22823
+ const residuated = verdict["Residuated"];
22824
+ return {
22825
+ certificateId: wire.certificate_id,
22826
+ propertyLabel: wire.property_label,
22827
+ method: wire.method ?? void 0,
22828
+ contentSha256Hex: wire.content_sha256_hex,
22829
+ verdict: verdictTag,
22830
+ verdictPartial: typeof residuated?.partial === "number" ? residuated.partial : void 0,
22831
+ ruleProgramHash: wire.rule_program_hash ?? void 0,
22832
+ ruleRevision: wire.rule_revision ?? void 0
22833
+ };
22834
+ }
22835
+
22836
+ // src/resources/verification.ts
22837
+ var VerificationClient = class {
22838
+ /** @internal */
22839
+ http;
22840
+ /** @internal */
22841
+ constructor(http) {
22842
+ this.http = http;
22843
+ }
22844
+ /**
22845
+ * Fetch a validity certificate by id.
22846
+ *
22847
+ * @param certificateId - The certificate id (an answer's `validityCertificateId`).
22848
+ * @returns The certificate's verdict, content hash, proof method and rule-program pin.
22849
+ * @throws {ApiError} If the certificate is unknown (`404`) or the request fails.
22850
+ *
22851
+ * @remarks
22852
+ * A `404` is expected when the id is a prose-provenance fallback certificate
22853
+ * (not persisted in the verification store) rather than an OSFQL-soundness one —
22854
+ * treat it as "no per-answer certificate available".
22855
+ *
22856
+ * @example
22857
+ * ```typescript
22858
+ * const answer = await client.conversation.sendMessage({ message, generateCertificate: true });
22859
+ * if (answer.validityCertificateId) {
22860
+ * const cert = await client.verification.getCertificate(answer.validityCertificateId);
22861
+ * console.log(cert.verdict, cert.contentSha256Hex);
22862
+ * }
22863
+ * ```
22864
+ */
22865
+ async getCertificate(certificateId) {
22866
+ const response = await this.http.request({
22867
+ path: `/api/v1/verification/certificates/${encodeURIComponent(certificateId)}`,
22868
+ method: "GET",
22869
+ secure: true,
22870
+ format: "json"
22871
+ });
22872
+ return CertificateDetailFromApiToFront(response.data);
22873
+ }
22874
+ };
22875
+
22600
22876
  // src/resources/research.ts
22601
22877
  var ResearchClient = class {
22602
22878
  /** @internal */
@@ -24952,6 +25228,8 @@ var ReasoningLayerClient = class {
24952
25228
  discovery;
24953
25229
  /** Entity extraction operations. */
24954
25230
  extract;
25231
+ /** Document compliance analysis (check document content against KB rules). */
25232
+ documents;
24955
25233
  /** FormalJudge oversight operations (safety verification, refinement). */
24956
25234
  oversight;
24957
25235
  /** Categorical Deep Learning operations (differentiable FC, soft unification, safety). */
@@ -24992,6 +25270,8 @@ var ReasoningLayerClient = class {
24992
25270
  osfql;
24993
25271
  /** Conversational AI operations (NL → OSFQL with self-correction). */
24994
25272
  conversation;
25273
+ /** Validity-certificate lookup (per-answer soundness seals). */
25274
+ verification;
24995
25275
  /** Verified scientific research pipeline operations. */
24996
25276
  research;
24997
25277
  /** Knowledge graph context assembly operations (LLM prompt building). */
@@ -25173,6 +25453,7 @@ var ReasoningLayerClient = class {
25173
25453
  const generatedActionReviews = new ActionReviews(generatedHttp);
25174
25454
  const generatedDiscovery = new Discovery(generatedHttp);
25175
25455
  const generatedExtraction = new Extraction(generatedHttp);
25456
+ const generatedDocumentAnalysis = new DocumentAnalysis(generatedHttp);
25176
25457
  const generatedOversight = new Oversight(generatedHttp);
25177
25458
  const generatedCdl = new Cdl(generatedHttp);
25178
25459
  const generatedPreferences = new Preferences(generatedHttp);
@@ -25210,7 +25491,7 @@ var ReasoningLayerClient = class {
25210
25491
  this.execution = new ExecutionClient(generatedExecution);
25211
25492
  this.causal = new CausalClient(generatedCausal);
25212
25493
  this.ingestion = new IngestionClient(generatedIngestion);
25213
- this.reviews = new ReviewsClient(generatedReviews);
25494
+ this.reviews = new ReviewsClient(generatedReviews, resolved.tenantId);
25214
25495
  this.visualization = new VisualizationClient(generatedVisualization);
25215
25496
  this.ilp = new IlpClient(generatedIlp);
25216
25497
  this.reasoning = new ReasoningClient(generatedReasoning);
@@ -25225,6 +25506,7 @@ var ReasoningLayerClient = class {
25225
25506
  this.actionReviews = new ActionReviewsClient(generatedActionReviews, resolved.tenantId);
25226
25507
  this.discovery = new DiscoveryClient(generatedDiscovery);
25227
25508
  this.extract = new ExtractClient(generatedExtraction);
25509
+ this.documents = new DocumentsClient(generatedDocumentAnalysis);
25228
25510
  this.oversight = new OversightClient(generatedOversight);
25229
25511
  this.cdl = new CdlClient(generatedCdl);
25230
25512
  this.neuroSymbolic = new NeuroSymbolicClient(generatedNeuroSymbolic);
@@ -25245,6 +25527,7 @@ var ReasoningLayerClient = class {
25245
25527
  this.flowNetworks = new FlowNetworksClient(new FlowNetworks(generatedHttp));
25246
25528
  this.osfql = new OsfqlClient(generatedOsfql);
25247
25529
  this.conversation = new ConversationClient(generatedHttp);
25530
+ this.verification = new VerificationClient(generatedHttp);
25248
25531
  this.research = new ResearchClient(generatedHttp);
25249
25532
  const generatedContext = new Context(generatedHttp);
25250
25533
  const generatedRlTraining = new RlTraining(generatedHttp);
@@ -25348,6 +25631,9 @@ var discovery_exports = {};
25348
25631
  // src/types/extract.ts
25349
25632
  var extract_exports = {};
25350
25633
 
25634
+ // src/types/documents.ts
25635
+ var documents_exports = {};
25636
+
25351
25637
  // src/types/oversight.ts
25352
25638
  var oversight_exports = {};
25353
25639
 
@@ -25418,6 +25704,9 @@ var osfql_exports = {};
25418
25704
  // src/types/conversation.ts
25419
25705
  var conversation_exports = {};
25420
25706
 
25707
+ // src/types/verification.ts
25708
+ var verification_exports = {};
25709
+
25421
25710
  // src/types/compliance.ts
25422
25711
  var compliance_exports = {};
25423
25712
 
@@ -26500,6 +26789,7 @@ exports.Constraints = constraints_exports;
26500
26789
  exports.Control = control_exports;
26501
26790
  exports.Conversation = conversation_exports;
26502
26791
  exports.Discovery = discovery_exports;
26792
+ exports.Documents = documents_exports;
26503
26793
  exports.Execution = execution_exports;
26504
26794
  exports.Extract = extract_exports;
26505
26795
  exports.Feasibility = feasibility_exports;
@@ -26560,6 +26850,7 @@ exports.Utilities = utilities_exports;
26560
26850
  exports.ValidationError = ValidationError;
26561
26851
  exports.Value = Value;
26562
26852
  exports.Values = values_exports;
26853
+ exports.Verification = verification_exports;
26563
26854
  exports.Visualization = visualization_exports;
26564
26855
  exports.WebSocketClient = WebSocketClient;
26565
26856
  exports.WebSocketConnection = WebSocketConnection;