@kortexya/reasoninglayer 0.4.2 → 0.6.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 +203 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +418 -14
- package/dist/index.d.ts +418 -14
- package/dist/index.js +202 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/config.ts
|
|
4
|
-
var SDK_VERSION = "0.
|
|
4
|
+
var SDK_VERSION = "0.6.0";
|
|
5
5
|
function resolveConfig(config) {
|
|
6
6
|
if (!config.baseUrl) {
|
|
7
7
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -7391,6 +7391,32 @@ var Rag = class {
|
|
|
7391
7391
|
});
|
|
7392
7392
|
};
|
|
7393
7393
|
|
|
7394
|
+
// src/api-spec/generated/Osfql.ts
|
|
7395
|
+
var Osfql = class {
|
|
7396
|
+
http;
|
|
7397
|
+
constructor(http) {
|
|
7398
|
+
this.http = http;
|
|
7399
|
+
}
|
|
7400
|
+
/**
|
|
7401
|
+
* @description Parses, compiles, and executes an OSFQL program against the caller's tenant-isolated knowledge base. Supports all OSFQL statement types: MATCH, INSERT, RETRACT, DERIVE, UNIFY, AWAIT, COUNTERFACTUAL, CAUSES. # Examples ```json { "query": "INSERT person(name: \"Alice\", age: 30);" } ``` ```json { "query": "MATCH person(name: ?N, age: ?A) WHERE ?A > 18;" } ```
|
|
7402
|
+
*
|
|
7403
|
+
* @tags osfql
|
|
7404
|
+
* @name ExecuteOsfql
|
|
7405
|
+
* @summary Execute an OSFQL program.
|
|
7406
|
+
* @request POST:/api/v1/osfql
|
|
7407
|
+
* @secure
|
|
7408
|
+
*/
|
|
7409
|
+
executeOsfql = (data, params = {}) => this.http.request({
|
|
7410
|
+
path: `/api/v1/osfql`,
|
|
7411
|
+
method: "POST",
|
|
7412
|
+
body: data,
|
|
7413
|
+
secure: true,
|
|
7414
|
+
type: "application/json" /* Json */,
|
|
7415
|
+
format: "json",
|
|
7416
|
+
...params
|
|
7417
|
+
});
|
|
7418
|
+
};
|
|
7419
|
+
|
|
7394
7420
|
// src/resources/sorts.ts
|
|
7395
7421
|
var SortsClient = class {
|
|
7396
7422
|
/** @internal */
|
|
@@ -13562,6 +13588,165 @@ function extractNumericValue(features, featureName) {
|
|
|
13562
13588
|
return null;
|
|
13563
13589
|
}
|
|
13564
13590
|
|
|
13591
|
+
// src/resources/osfql.ts
|
|
13592
|
+
var OsfqlClient = class {
|
|
13593
|
+
/** @internal */
|
|
13594
|
+
api;
|
|
13595
|
+
/** @internal */
|
|
13596
|
+
constructor(api) {
|
|
13597
|
+
this.api = api;
|
|
13598
|
+
}
|
|
13599
|
+
/**
|
|
13600
|
+
* Execute an OSFQL program.
|
|
13601
|
+
*
|
|
13602
|
+
* @param query - The OSFQL program text (one or more statements separated by `;`).
|
|
13603
|
+
* @returns The execution result including variable bindings, produced term IDs,
|
|
13604
|
+
* defined sort IDs, diagnostics, and statement count.
|
|
13605
|
+
* @throws {ApiError} If the request fails.
|
|
13606
|
+
*
|
|
13607
|
+
* @remarks
|
|
13608
|
+
* The query is parsed, compiled, and executed against the caller's tenant-isolated
|
|
13609
|
+
* knowledge base. Results include variable bindings from MATCH queries and IDs of
|
|
13610
|
+
* any terms or sorts created by INSERT, DERIVE, or DEFINE statements.
|
|
13611
|
+
*
|
|
13612
|
+
* @example
|
|
13613
|
+
* ```typescript
|
|
13614
|
+
* // Insert a record and query it back
|
|
13615
|
+
* const result = await client.osfql.execute(
|
|
13616
|
+
* 'INSERT person(name: "Alice", age: 30); MATCH person(name: ?N);'
|
|
13617
|
+
* );
|
|
13618
|
+
* console.log(result.success); // true
|
|
13619
|
+
* console.log(result.bindings); // [{ N: { type: "string", value: "Alice" } }]
|
|
13620
|
+
* console.log(result.producedTermIds); // ["<uuid>"]
|
|
13621
|
+
* console.log(result.statementCount); // 2
|
|
13622
|
+
* ```
|
|
13623
|
+
*/
|
|
13624
|
+
async execute(query) {
|
|
13625
|
+
const response = await this.api.executeOsfql({ query });
|
|
13626
|
+
return response.data;
|
|
13627
|
+
}
|
|
13628
|
+
};
|
|
13629
|
+
|
|
13630
|
+
// src/resources/conversation.ts
|
|
13631
|
+
var ConversationClient = class {
|
|
13632
|
+
/** @internal */
|
|
13633
|
+
http;
|
|
13634
|
+
/** @internal */
|
|
13635
|
+
constructor(http) {
|
|
13636
|
+
this.http = http;
|
|
13637
|
+
}
|
|
13638
|
+
/**
|
|
13639
|
+
* Send a natural language message and receive OSFQL-powered results.
|
|
13640
|
+
*
|
|
13641
|
+
* @param request - The conversation message request.
|
|
13642
|
+
* @returns The assistant's response including generated OSFQL, query results, and suggestions.
|
|
13643
|
+
* @throws {ApiError} If the request fails.
|
|
13644
|
+
*
|
|
13645
|
+
* @remarks
|
|
13646
|
+
* The conversation service:
|
|
13647
|
+
* 1. Classifies the intent (query, insert, define, etc.)
|
|
13648
|
+
* 2. Generates OSFQL from the natural language
|
|
13649
|
+
* 3. Executes the OSFQL against the knowledge base
|
|
13650
|
+
* 4. Self-corrects up to 3 times if execution fails
|
|
13651
|
+
* 5. Returns results + the generated OSFQL + suggestions
|
|
13652
|
+
*
|
|
13653
|
+
* Reuse `conversationId` from a previous response for multi-turn context.
|
|
13654
|
+
*
|
|
13655
|
+
* @example
|
|
13656
|
+
* ```typescript
|
|
13657
|
+
* // First message — starts a new conversation
|
|
13658
|
+
* const first = await client.conversation.sendMessage({
|
|
13659
|
+
* message: 'Who are the prime suspects?',
|
|
13660
|
+
* });
|
|
13661
|
+
* console.log(first.osfqlExecuted); // "PROVE prime_suspect(name: ?N, motive: ?M);"
|
|
13662
|
+
* console.log(first.queryResults); // [{ N: ..., M: ... }, ...]
|
|
13663
|
+
*
|
|
13664
|
+
* // Follow-up — reuses conversation context
|
|
13665
|
+
* const followUp = await client.conversation.sendMessage({
|
|
13666
|
+
* message: 'Which of them had a key?',
|
|
13667
|
+
* conversationId: first.conversationId,
|
|
13668
|
+
* });
|
|
13669
|
+
* ```
|
|
13670
|
+
*/
|
|
13671
|
+
async sendMessage(request) {
|
|
13672
|
+
const response = await this.http.request({
|
|
13673
|
+
path: "/api/v1/conversation/message",
|
|
13674
|
+
method: "POST",
|
|
13675
|
+
body: request,
|
|
13676
|
+
secure: true,
|
|
13677
|
+
type: "application/json" /* Json */,
|
|
13678
|
+
format: "json"
|
|
13679
|
+
});
|
|
13680
|
+
return response.data;
|
|
13681
|
+
}
|
|
13682
|
+
/**
|
|
13683
|
+
* List recent conversations for the authenticated user.
|
|
13684
|
+
*
|
|
13685
|
+
* @returns List of conversation summaries.
|
|
13686
|
+
* @throws {ApiError} If the request fails.
|
|
13687
|
+
*
|
|
13688
|
+
* @example
|
|
13689
|
+
* ```typescript
|
|
13690
|
+
* const { conversations } = await client.conversation.listConversations();
|
|
13691
|
+
* for (const c of conversations) {
|
|
13692
|
+
* console.log(`${c.id}: ${c.turnCount} turns (${c.createdAt})`);
|
|
13693
|
+
* }
|
|
13694
|
+
* ```
|
|
13695
|
+
*/
|
|
13696
|
+
async listConversations() {
|
|
13697
|
+
const response = await this.http.request({
|
|
13698
|
+
path: "/api/v1/conversation/history",
|
|
13699
|
+
method: "GET",
|
|
13700
|
+
secure: true,
|
|
13701
|
+
format: "json"
|
|
13702
|
+
});
|
|
13703
|
+
return response.data;
|
|
13704
|
+
}
|
|
13705
|
+
/**
|
|
13706
|
+
* Get all turns for a conversation.
|
|
13707
|
+
*
|
|
13708
|
+
* @param conversationId - The conversation ID.
|
|
13709
|
+
* @returns All turns in the conversation.
|
|
13710
|
+
* @throws {ApiError} If the request fails.
|
|
13711
|
+
*
|
|
13712
|
+
* @example
|
|
13713
|
+
* ```typescript
|
|
13714
|
+
* const { turns } = await client.conversation.getTurns('conv-uuid');
|
|
13715
|
+
* for (const turn of turns) {
|
|
13716
|
+
* console.log(`[${turn.role}] ${turn.content}`);
|
|
13717
|
+
* if (turn.osfql) console.log(` OSFQL: ${turn.osfql}`);
|
|
13718
|
+
* }
|
|
13719
|
+
* ```
|
|
13720
|
+
*/
|
|
13721
|
+
async getTurns(conversationId) {
|
|
13722
|
+
const response = await this.http.request({
|
|
13723
|
+
path: `/api/v1/conversation/${encodeURIComponent(conversationId)}/turns`,
|
|
13724
|
+
method: "GET",
|
|
13725
|
+
secure: true,
|
|
13726
|
+
format: "json"
|
|
13727
|
+
});
|
|
13728
|
+
return response.data;
|
|
13729
|
+
}
|
|
13730
|
+
/**
|
|
13731
|
+
* Delete a conversation and all its turns.
|
|
13732
|
+
*
|
|
13733
|
+
* @param conversationId - The conversation ID to delete.
|
|
13734
|
+
* @throws {ApiError} If the request fails.
|
|
13735
|
+
*
|
|
13736
|
+
* @example
|
|
13737
|
+
* ```typescript
|
|
13738
|
+
* await client.conversation.deleteConversation('conv-uuid');
|
|
13739
|
+
* ```
|
|
13740
|
+
*/
|
|
13741
|
+
async deleteConversation(conversationId) {
|
|
13742
|
+
await this.http.request({
|
|
13743
|
+
path: `/api/v1/conversation/${encodeURIComponent(conversationId)}`,
|
|
13744
|
+
method: "DELETE",
|
|
13745
|
+
secure: true
|
|
13746
|
+
});
|
|
13747
|
+
}
|
|
13748
|
+
};
|
|
13749
|
+
|
|
13565
13750
|
// src/client.ts
|
|
13566
13751
|
var ReasoningLayerClient = class {
|
|
13567
13752
|
/** Sort (type hierarchy) operations. */
|
|
@@ -13650,6 +13835,10 @@ var ReasoningLayerClient = class {
|
|
|
13650
13835
|
rag;
|
|
13651
13836
|
/** Linear program optimization (CLP(Q) simplex solver via backward chaining). */
|
|
13652
13837
|
optimize;
|
|
13838
|
+
/** OSFQL (OSF Query Language) execution operations. */
|
|
13839
|
+
osfql;
|
|
13840
|
+
/** Conversational AI operations (NL → OSFQL with self-correction). */
|
|
13841
|
+
conversation;
|
|
13653
13842
|
// ─── Group Caches ─────────────────────────────────────────────────
|
|
13654
13843
|
_core;
|
|
13655
13844
|
_ai;
|
|
@@ -13825,6 +14014,7 @@ var ReasoningLayerClient = class {
|
|
|
13825
14014
|
const generatedOntology = new Ontology(generatedHttp);
|
|
13826
14015
|
const generatedGeneration = new Generation(generatedHttp);
|
|
13827
14016
|
const generatedRag = new Rag(generatedHttp);
|
|
14017
|
+
const generatedOsfql = new Osfql(generatedHttp);
|
|
13828
14018
|
this.sorts = new SortsClient(generatedSorts, generatedTypes, resolved.tenantId);
|
|
13829
14019
|
this.terms = new TermsClient(generatedTerms);
|
|
13830
14020
|
this.inference = new InferenceClient(generatedInference, resolved.tenantId);
|
|
@@ -13868,6 +14058,8 @@ var ReasoningLayerClient = class {
|
|
|
13868
14058
|
this.generation = new GenerationClient(generatedGeneration);
|
|
13869
14059
|
this.rag = new RagClient(generatedRag);
|
|
13870
14060
|
this.optimize = new OptimizeClient(generatedInference, generatedSorts, generatedQuery, generatedTerms, resolved.tenantId);
|
|
14061
|
+
this.osfql = new OsfqlClient(generatedOsfql);
|
|
14062
|
+
this.conversation = new ConversationClient(generatedHttp);
|
|
13871
14063
|
}
|
|
13872
14064
|
};
|
|
13873
14065
|
|
|
@@ -14009,6 +14201,12 @@ var ilp_exports = {};
|
|
|
14009
14201
|
// src/types/plain-values.ts
|
|
14010
14202
|
var plain_values_exports = {};
|
|
14011
14203
|
|
|
14204
|
+
// src/types/osfql.ts
|
|
14205
|
+
var osfql_exports = {};
|
|
14206
|
+
|
|
14207
|
+
// src/types/conversation.ts
|
|
14208
|
+
var conversation_exports = {};
|
|
14209
|
+
|
|
14012
14210
|
// src/builders/value.ts
|
|
14013
14211
|
var Value = {
|
|
14014
14212
|
/**
|
|
@@ -14288,9 +14486,9 @@ var SortBuilder = class _SortBuilder {
|
|
|
14288
14486
|
* @example
|
|
14289
14487
|
* ```typescript
|
|
14290
14488
|
* builder.boundConstraint({
|
|
14291
|
-
*
|
|
14489
|
+
* constraintType: "upper",
|
|
14292
14490
|
* target: "end_date",
|
|
14293
|
-
*
|
|
14491
|
+
* sourcePath: "company.dissolutionDate",
|
|
14294
14492
|
* })
|
|
14295
14493
|
* ```
|
|
14296
14494
|
*/
|
|
@@ -14416,6 +14614,7 @@ exports.Communities = communities_exports;
|
|
|
14416
14614
|
exports.ConstraintViolationError = ConstraintViolationError;
|
|
14417
14615
|
exports.Constraints = constraints_exports;
|
|
14418
14616
|
exports.Control = control_exports;
|
|
14617
|
+
exports.Conversation = conversation_exports;
|
|
14419
14618
|
exports.Discovery = discovery_exports;
|
|
14420
14619
|
exports.Execution = execution_exports;
|
|
14421
14620
|
exports.Extract = extract_exports;
|
|
@@ -14438,6 +14637,7 @@ exports.NeuroSymbolic = neuro_symbolic_exports;
|
|
|
14438
14637
|
exports.NotFoundError = NotFoundError;
|
|
14439
14638
|
exports.Ontology = ontology_exports;
|
|
14440
14639
|
exports.Optimize = optimize_exports;
|
|
14640
|
+
exports.Osfql = osfql_exports;
|
|
14441
14641
|
exports.Oversight = oversight_exports;
|
|
14442
14642
|
exports.PlainValues = plain_values_exports;
|
|
14443
14643
|
exports.Preferences = preferences_exports;
|